UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

280 lines • 8.05 kB
import { Injector, TemplateRef, Type } from '@angular/core'; import { NavigatorNodeData } from './navigator-node-data'; import { PopoverConfirmComponent } from '../modal/popover-confirm.component'; import { SupportedIconsSuggestions } from '@c8y/ngx-components/icon-selector/icons'; /** * Interface that determines the available click options. * @ignore */ export interface ClickOptions { /** * Indicates that the source of the event is a click on the node icon. */ icon?: boolean; /** * Indicates that the source of the event is a click on the node expander. */ expander?: boolean; /** * Indicates that the navigator node is expanded/collapsed. */ open?: boolean; /** * Creates a new group node which will contain all unassigned devices. */ showUnassignedDevices?: boolean; /** * DOM event. */ $event?: any; } /** * Base navigator node. Represents a single entry in the navigator menu. * Is considered to be the basic building block of the navigator. */ export declare class NavigatorNode { static NAME: string; /** * Navigator node icon. */ icon: SupportedIconsSuggestions; /** * Navigator node icon when expanded. */ iconOpen: string; /** * Custom icon template. */ iconTemplate?: TemplateRef<any>; /** * Custom icon component. */ iconComponent?: Type<any>; /** * Navigator node children (subentries). */ children: NavigatorNode[]; /** * Label to be displayed in the navigator node. */ label: string; /** * Whether to pass `label` through `translate` pipe when being displayed. */ translateLabel: boolean; /** * The path to which the UI will be redirected after clicking the navigator node. */ path: string; /** * Navigator node parent nodes. */ parents: NavigatorNode[]; /** * Loading state indicator. */ loading?: boolean; /** * Used to load the providers for the components. If not provided, default injector us used. */ injector?: Injector; /** * Custom component to use. */ component?: Type<any>; /** * Indicates whether the navigator node should be active based on matching the node path and the URL path. * To match the URL exactly, set this option to true. * * routerLinkExact set to true: * When the URL path is set to /a/b/c and the node path to /a/b then the node will not be set active. * * routerLinkExact set to false: * When the URL path is set to /a/b/c and the node path to /a/b then the node will be set active. */ routerLinkExact: boolean; /** * Indicates that the navigator node is expanded/collapsed. */ open: boolean; /** * Indicates that the navigator node is visible/hidden. */ hidden: boolean; /** * Indicates that the navigator node is draggable. */ draggable: boolean; /** * Indicates that the navigator node is droppable. */ droppable: boolean; /** * Indicates that the navigator node is dragged. */ dragged: boolean; /** * Indicates that currently something is dragged over the node. */ draggedHover: boolean; /** * Confirmation popover displayed at the end of the process of moving the navigator menu item. */ confirm: PopoverConfirmComponent; /** * The breadcrumb of the node, displaying the "path", but supports multiple levels. * e.g. (Groups > Level 1 > Level 2) */ breadcrumb?: string; /** * Id to identify specific feature node. */ featureId?: string; private _priority; private expandDragTimeout; /** * Returns information whether a navigator node has children. * @readonly */ get hasChildren(): boolean; /** * Returns the ID of the navigator node. * @readonly */ get id(): string; /** * Returns the priority value of the navigator node. * @readonly */ get priority(): number; /** * Sets the priority value of the navigator node. * * @param {number} priority Priority value. */ set priority(priority: number); constructor(data?: NavigatorNodeData); /** * Adds a child navigator node to the node. * * @param {NavigatorNode} node Child node. */ add(node: NavigatorNode): void; /** * Removes the child navigator node from the node. * * @param {NavigatorNode} node Child node. */ remove(node: NavigatorNode): void; /** * Updates the navigator node. * * @param {NavigatorNodeData} data Data to be updated. */ update(data?: NavigatorNodeData): void; /** * * Returns a child navigator node based on the predicate. * * ```ts * // The function will compare the labels to the string and return a matching result. * // The capitalization of the characters does not matter (case insensitive). * const predicate = 'group1'; * const childNode = parentNode.find(predicate); * // Check: [lodash matches](https://lodash.com/docs/4.17.15#matches) * const predicate = { label: 'group2' }; * const childNode = parentNode.find(predicate); * ``` * * @param predicate Filter criteria. * @param findBy NavigatorNode field name to compare. * */ find(predicate: any, findBy?: keyof Pick<NavigatorNode, 'label' | 'featureId'>): any; /** * Removes children nodes. */ empty(): void; /** * @ignore */ click(_options?: ClickOptions): void; /** * This event is fired when an element is dropped on a valid drop target. * @param $event DOM event. */ drop($event: any): void; /** * This event is fired when the user starts dragging an element. * @param $event DOM event. */ dragStart($event: any): void; /** * This event is fired when a drag operation has ended. * @param $event DOM event. */ dragEnd($event: any): void; /** * Returns information whether the navigator node is droppable. * @readonly */ get canDrop(): boolean; /** * Returns information whether navigation is possible. * @readonly */ get canNavigate(): boolean; /** * This event is fired when a dragged element enters a valid drop target. * @param $event DOM event. */ dragEnter($event: any): void; /** * This event is fired when a dragged element leaves a valid drop target. * @param $event DOM event. */ dragLeave($event: any): void; /** * Expands the navigator node if it is collapsed. */ expand(): void; /** * Performs a callback function recursively on each of the navigator node's children down the hierarchy. * * ```ts * const expandChild = (childNode) => childNode.expand(); * parentNode.traverse(expandChild); * ``` * * @param callback Function to be called. */ traverse(callback: any): void; /** * @ignore */ destroy(): void; /** * Counts the amount of children nodes. */ protected countChildren(): number; /** * Identifies itself. */ protected toString(): string; protected hasChildDevices(): boolean; /** * Updates the navigator node by sorting its children and also checking their visibility. */ protected updateChildren(): void; /** * Sorts the children of the navigator node, by priority and name (ASC). * The higher the priority, the higher the position in the hierarchy. * For the same priority values, the alphabetical order will take precedence. */ protected sort(): void; /** * Checks if the navigator node should be hidden based on the visibility of its child nodes. */ protected updateHidden(): void; } //# sourceMappingURL=navigator-node.d.ts.map