/** Core */ import { CoreComponent } from "cmf.core/src/core"; /** Nested modules */ import { ExplorerViewModel, ExplorerViewNode, ExplorerViewServiceDef } from "./explorerViewStructure"; import { BreadcrumbItem, BreadcrumbItemSelectArgs } from "../breadcrumb/breadcrumb"; import { ElementQuery } from "../../directives/elementQuery/elementQuery"; /** Angular */ import * as ng from "@angular/core"; /** * Defines additional data for an "ExplorerViewNode" to be used internally in the component. */ interface ExplorerViewNodeInternal extends ExplorerViewNode { /** * Indicates if the node is selected. */ selected?: boolean; /** * Indicates if we are in the root level */ rootLevel?: boolean; /** * Indicates if the children have been loaded by the explorer view */ childrenLoaded?: boolean; } /** * Exntended version of the model to be used if preserved selection is turned on in the injected service. */ interface ExplorerViewModelInternal extends ExplorerViewModel { /** * Last selected node */ lastSelectedNode?: ExplorerViewNodeInternal; /** * Last selected main node */ lastSelectedMainNode?: ExplorerViewNodeInternal; /** * Last selected node parent */ lastSelectedMainNodeParent?: ExplorerViewNodeInternal; /** * Last parent navigation stack for the breadcrumb and path state */ lastNavigationParentStack?: ExplorerViewNodeInternal[]; /** * Last mobile show details flag state */ lastMobileShowDetails?: boolean; /** * Last explorer title value */ lastExplorerTitle?: string; } /** * @whatItDoes * * The components allows the user to have a "folder explorer alike" experience on the left side of the screen while being able to display information * about the selected node on the right side behaving similar to a column view both on desktop and mobile sizes. * The explorer nodes displayed and navigable on the left side are populated through an input 'model' * where the right side information is displayed through content projection, by adding 'node-content' attribute to an html element inside the explorer view tag. * In order to change what is displayed on the right side, the user needs to subscribe to an event 'nodeSelect', which fires when a new node is selected, * and manually change the external template that is projected. * * This component also needs a service of type ExplorerViewServiceDef to be provided in a parent component by injecting a token CUSTOM_EXPLORER_VIEW_SERVICE. * This token is available in the ExplorerViewStructure class. * * @howToUse * * This component is used with the inputs and outputs mentioned below. * * ### Inputs * `ExplorerViewModel` : **model** - The model for the explorer view to be rendered in the left side of the component * * ### Outputs * `ExplorerViewNode` : **nodeSelect** - Fires an event with the newly selected node data * * ### Example * To use the component, assume this HTML Template as an example: * * ```HTML * * * ``` * * @description * * ## ExplorerView Component * * ### Dependencies * * #### Components * * Breadcrumb : `cmf.core.controls` * * #### Services * _This component needs a service of type ExplorerViewServiceDef to be provided in a parent component_ * * #### Directives * * ElementQuery : `cmf.core.controls` * */ export declare class ExplorerView extends CoreComponent implements ng.OnChanges, ng.AfterViewInit, ng.OnDestroy { private _viewContainerRef; private _customExplorerViewService; /** * The explorer view container resize subscription from the element query. * Used to store the subscription reference in order to unsubscribe from it when the component is destroyed. */ private _explorerViewContainerResizeSubscription; /** * Indicates whether the user has selected an element. */ private _hasUserSelectedAnElement; /** * Stack of nodes indicating the navigated path (only parent nodes, i.e. nodes with children) */ _navigationParentStack: ExplorerViewNodeInternal[]; /** * Indicates the current selected node, and it can be any 'type' of node - parent, child, root, etc. * This is the only property that contains a reference to the current selected node of any type. */ _currentSelectedNode: ExplorerViewNodeInternal; /** * Indicates the current selected main node, i.e. the node that we are currently seeing in the explorer as the top node. */ _currentSelectedMainNode: ExplorerViewNodeInternal; /** * Indicates the current selected main node parent, i.e. the node that is the parent of the current main node, * which is the last node in the @see _navigationParentStack stack. This node is cached in order to ease its use in the template. */ _currentSelectedMainNodeParent: ExplorerViewNodeInternal; /** * Indicates if it is to display the node content or not while in mobile node. */ _currentSelectedNodeMobileViewDetails: boolean; /** * The current explorer title to be displayed on top of the explorer. * Either is the title of the @see model or the title of a main node. */ _explorerTitle: string; /** * Indicates if we are currently displayed the component for desktop mode. Defaults to true. * This value is changed by the use of the element query. */ _isLargeMode: boolean; /** * The items for the breadcrumb */ _breadcrumbItems: BreadcrumbItem[]; /** * Indicates if the component is being used in single root mode */ _isSingleRoot: boolean; /** * Reference to the element query instance. */ _elementQuery: ElementQuery; /** * The model of the explorer to be rendered. This model is used directly in the dom and is not cloned. */ model: ExplorerViewModelInternal; /** * EventEmmiter that emits the node when it is clicked. * In the event or multi clicking/going back and fourth in mobile view details, the duplicated node select is not emmited! */ nodeSelect: ng.EventEmitter; /** * Constructor * * @param _viewContainerRef the reference to the component view container */ constructor(_viewContainerRef: ng.ViewContainerRef, _customExplorerViewService: ExplorerViewServiceDef); /** * Resets the explorer model by setting the main node as being the root node and setting all the other selected nodes or preserving the selection. * Emits 'nodeSelect' as being the first node - the root - in the model. */ private resetExplorer; /** * Callback used when the element query emits changes. * Changes the value of the @see _isLargeMode depending on the current size of the container. * @param args Element query on size change args */ private onExplorerViewContainerSizeChange; /** * Updates the breadcrumb items by adding the parents and the main node. * Also adds the current selected node if its not the same as the main node. */ private updateBreadcrumb; private updateSelectionsOnClick; /** * Callback used when a node is clicked. * Only used for desktop mode. * Changes the current selected node and updates all the other references to nodes and the navigation stack. * Also updates the explorer title if necessary. * Emits the @see _currentSelectedNode as the node selected. * The event's default behavior and propagation is prevented. * @param event The mouse click event * @param node Node clicked on */ onNodeClick(event: MouseEvent, node: ExplorerViewNodeInternal): Promise; /** * Callback used when the user goes back in the navigation. * Updates all the references to the current selected nodes and the navigation stack. * Emits the @see _currentSelectedNode as the node selected. * The event's default behavior and propagation is prevented. * @param event mouse click event */ onGoBackClick(event: MouseEvent): void; /** * Callback used when the user touches the view action on a node in mobile node. * Changes the view in order to display the node content and not the explorer. * Updates references to the current selected node. * Emits @see _currentSelectedNode as the node selected. * The event's default behavior and propagation is prevented. * @param event The touch event * @param node Node touched on */ onMobileNodeViewClick(event: MouseEvent, node: ExplorerViewNodeInternal): void; /** * Callback used whe the user touches the 'go back' action after selecting the view action on a node. * Changes the view to display the node explorer and not the node content. * Changes the current selected node to be the main node. * Emits @see _currentSelectedNode as the node selected. * The event's default behavior and propagation is prevented. * @param event the touch event */ onMobileGoBackClick(event: MouseEvent): void; /** * Callback used when the user clicks on an item in the breadcrumb. * Resets the main node to be the one clicked on and the parent node to be its parent (or null if has no parent - when the main node is the root) * Updates other references to the current selected nodes. * Emits @see _currentSelectedNode as the node selected. * @param event the arguments sent from the breadcrumb item select event */ onBreadcrumbNodeClick(event: BreadcrumbItemSelectArgs): void; /** * Angular 'AfterViewInit' component lifecycle. * Subscribes to the 'sizeChangeEvent' of the element query. */ ngAfterViewInit(): void; /** * Angular 'OnChanges' component lifecycle. * Resets the explorer if there are changes to the model. * @param changes the changes made to the component properties */ ngOnChanges(changes: ng.SimpleChanges): void; /** * Angular 'OnDestroy' component lifecycle. * Unsubscribes the 'sizeChangeEvent' of the element query. */ ngOnDestroy(): void; } export declare class ExplorerViewModule { } export {};