import { Component, EmitType, isUndefined, Browser, compile, isNullOrUndefined, SanitizeHtmlHelper, animationMode } from '@syncfusion/ej2-base';import { Property, INotifyPropertyChanged, NotifyPropertyChanges, ChildProperty, Complex } from '@syncfusion/ej2-base';import { Event, EventHandler, KeyboardEvents, KeyboardEventArgs } from '@syncfusion/ej2-base';import { rippleEffect, Effect, Animation, AnimationOptions, RippleOptions, remove } from '@syncfusion/ej2-base';import { Draggable, DragEventArgs, Droppable, DropEventArgs } from '@syncfusion/ej2-base';import { getElement } from '@syncfusion/ej2-base';import { addClass, removeClass, closest, matches, detach, select, selectAll, isVisible, append } from '@syncfusion/ej2-base';import { DataManager, Query } from '@syncfusion/ej2-data';import { isNullOrUndefined as isNOU, Touch, TapEventArgs, getValue, setValue, extend, merge, attributes } from '@syncfusion/ej2-base';import { ListBase, ListBaseOptions, AriaAttributesMapping, FieldsMapping } from '@syncfusion/ej2-lists';import { createCheckBox, rippleMouseHandler } from '@syncfusion/ej2-buttons';import { Input, InputObject } from '@syncfusion/ej2-inputs';import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups'; import {ExpandOnSettings,SortOrder,FailureEventArgs,DataBoundEventArgs,DataSourceChangedEventArgs,DrawNodeEventArgs,NodeKeyPressEventArgs,NodeCheckEventArgs,NodeClickEventArgs,NodeExpandEventArgs,DragAndDropEventArgs,NodeEditEventArgs,NodeSelectEventArgs} from "./treeview"; import {ComponentModel} from '@syncfusion/ej2-base'; /** * Interface for a class FieldsSettings */ export interface FieldsSettingsModel { /** * Binds the field settings for child nodes or mapping field for nested nodes objects that contain array of JSON objects. */ child?: string | FieldsSettingsModel; /** * Specifies the array of JavaScript objects or instance of DataManager to populate the nodes. * * @default [] * @aspDatasourceNullIgnore * @isGenericType true */ dataSource?: DataManager | { [key: string]: Object }[]; /** * Specifies the mapping field for expand state of the TreeView node. */ expanded?: string; /** * Specifies the mapping field for hasChildren to check whether a node has child nodes or not. */ hasChildren?: string; /** * Specifies the mapping field for htmlAttributes to be added to the TreeView node. */ htmlAttributes?: string; /** * Specifies the mapping field for icon class of each TreeView node that will be added before the text. */ iconCss?: string; /** * Specifies the ID field mapped in dataSource. */ id?: string; /** * Specifies the mapping field for image URL of each TreeView node where image will be added before the text. */ imageUrl?: string; /** * Specifies the field for checked state of the TreeView node. */ isChecked?: string; /** * Specifies the parent ID field mapped in dataSource. */ parentID?: string; /** * Defines the external [`Query`](https://ej2.syncfusion.com/documentation/api/data/query/) * that will execute along with data processing. * * @default null */ query?: Query; /** * Specifies whether the node can be selected by users or not * When set to false, the user interaction is prevented for the corresponding node. */ selectable?: string; /** * Specifies the mapping field for selected state of the TreeView node. */ selected?: string; /** * Specifies the table name used to fetch data from a specific table in the server. */ tableName?: string; /** * Specifies the mapping field for text displayed as TreeView node's display text. */ text?: string; /** * Specifies the mapping field for tooltip that will be displayed as hovering text of the TreeView node. */ tooltip?: string; /** * Specifies the mapping field for navigateUrl to be added as hyper-link of the TreeView node. */ navigateUrl?: string; } /** * Interface for a class ActionSettings */ export interface ActionSettingsModel { /** * Specifies the type of animation. * * @default 'SlideDown' */ effect?: Effect; /** * Specifies the duration to animate. * * @default 400 */ duration?: number; /** * Specifies the animation timing function. * * @default 'linear' */ easing?: string; } /** * Interface for a class NodeAnimationSettings */ export interface NodeAnimationSettingsModel { /** * Specifies the animation that applies on collapsing the nodes. * * @default { effect: 'SlideUp', duration: 400, easing: 'linear' } */ collapse?: ActionSettingsModel; /** * Specifies the animation that applies on expanding the nodes. * * @default { effect: 'SlideDown', duration: 400, easing: 'linear' } */ expand?: ActionSettingsModel; } /** * Interface for a class TreeView */ export interface TreeViewModel extends ComponentModel{ /** * Indicates whether the TreeView allows drag and drop of nodes. To drag and drop a node in * desktop, hold the mouse on the node, drag it to the target node and drop the node by releasing * the mouse. For touch devices, drag and drop operation is performed by touch, touch move * and touch end. For more information on drag and drop nodes concept, refer to * [Drag and Drop](../../treeview/drag-and-drop/). * * @default false */ allowDragAndDrop?: boolean; /** * Enables or disables editing of the text in the TreeView node. When `allowEditing` property is set * to true, the TreeView allows you to edit the node by double clicking the node or by navigating to * the node and pressing **F2** key. For more information on node editing, refer * to [Node Editing](../../treeview/node-editing/). * * @default false */ allowEditing?: boolean; /** * Enables or disables multi-selection of nodes. To select multiple nodes: * * Select the nodes by holding down the **Ctrl** key while clicking on the nodes. * * Select consecutive nodes by clicking the first node to select and hold down the **Shift** key * and click the last node to select. * * For more information on multi-selection, refer to * [Multi-Selection](../../treeview/multiple-selection/). * * @default false */ allowMultiSelection?: boolean; /** * Enables or disables text wrapping when text exceeds the bounds in the TreeView node. * When the allowTextWrap property is set to true, the TreeView node text content will wrap to the next line * when it exceeds the width of the TreeView node. * The TreeView node height will be adjusted automatically based on the TreeView node content. * * @default false */ allowTextWrap?: boolean; /** * Specifies the type of animation applied on expanding and collapsing the nodes along with duration. * * @default {expand: { effect: 'SlideDown', duration: 400, easing: 'linear' }, * collapse: { effect: 'SlideUp', duration: 400, easing: 'linear' }} */ animation?: NodeAnimationSettingsModel; /** * The `checkedNodes` property is used to set the nodes that need to be checked. * This property returns the checked nodes ID in the TreeView component. * The `checkedNodes` property depends upon the value of `showCheckBox` property. * For more information on checkedNodes, refer to * [checkedNodes](../../treeview/check-box#checked-nodes). * ```html *
* ``` * ```typescript * let treeObj: TreeView = new TreeView({ * fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' }, * showCheckBox: true, * checkedNodes: ['01-01','02'] * }); * treeObj.appendTo('#tree'); * ``` * * @default [] */ checkedNodes?: string[]; /** * Determines whether the disabled children will be checked or not if their parent is checked. * * @default true */ checkDisabledChildren?: boolean; /** * Specifies one or more than one CSS classes to be added with root element of the TreeView to help customize the appearance of the component. * ```html * * ``` * ```typescript * let treeObj: TreeView = new TreeView({ * fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' }, * cssClass: 'e-custom e-tree' * }); * treeObj.appendTo('#tree'); * ``` * ```css * .e-custom .e-tree { * max-width: 600px; * } * .e-custom .e-list-item { * padding: 10px 0; * } * ``` * * @default '' */ cssClass?: string; /** * Specifies a value that indicates whether the TreeView component is disabled or not. * When set to true, user interaction will not be occurred in TreeView. * * @default false */ disabled?: boolean; /** * Specifies the target in which the draggable element can be moved and dropped. * By default, the draggable element movement occurs in the page. * ```html * * ``` * ```typescript * let treeObj: TreeView = new TreeView({ * fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' }, * dragArea: '.control_wrapper' * }); * treeObj.appendTo('#tree'); * ``` * ```css * .control_wrapper { * width: 500px; * margin-left: 100px; * } * ``` * * @default null */ dragArea?: HTMLElement | string; /** * Specifies whether to display or remove the untrusted HTML values in the TreeView component. * If 'enableHtmlSanitizer' set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them. * ```html * * ``` * ```typescript * let treeObj: TreeView = new TreeView({ * fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' }, * enableHtmlSanitizer: true * }); * treeObj.appendTo('#tree'); * ``` * **Note:** To correctly remove untrusted HTML values, `disableHtmlEncode` must also be set to true. When `enableHtmlSanitizer` is set to false, `disableHtmlEncode` must also be set to false. * * @default true */ enableHtmlSanitizer?: boolean; /** * Enables rendering of raw text content in the Treeview component without HTML encoding. * When set to true, the text will be displayed exactly as provided (including HTML tags or special characters), * instead of being encoded or truncated (e.g., `hiiih