/*! * devextreme-angular-test * Version: 17.2.8 * Build date: Mon Feb 05 2018 * * Copyright (c) 2012 - 2018 Developer Express Inc. ALL RIGHTS RESERVED * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file in the root of the project for details. * * https://github.com/DevExpress/devextreme-angular */ import { Component, NgModule, ElementRef, NgZone, Input, Output, OnDestroy, Injector, EventEmitter, OnChanges, DoCheck, SimpleChanges, ContentChildren, QueryList } from '@angular/core'; import DevExpress from 'devextreme/bundles/dx.all'; import DxTreeView from 'devextreme/ui/tree_view'; import { DxComponent } from '../core/component'; import { DxTemplateHost } from '../core/template-host'; import { DxTemplateModule } from '../core/template'; import { EventsRegistrator } from '../core/events-strategy'; import { NestedOptionHost } from '../core/nested-option'; import { WatcherHelper } from '../core/watcher-helper'; import { IterableDifferHelper } from '../core/iterable-differ-helper'; import { DxiItemModule } from './nested/item-dxi'; import { DxoSearchEditorOptionsModule } from './nested/search-editor-options'; import { DxiItemComponent } from './nested/item-dxi'; /** * The TreeView widget is a tree-like representation of textual data. */ @Component({ selector: 'dx-tree-view', template: '', providers: [ DxTemplateHost, WatcherHelper, NestedOptionHost, IterableDifferHelper ] }) export class DxTreeViewComponent extends DxComponent implements OnDestroy, OnChanges, DoCheck { instance: DxTreeView; /** * Specifies the shortcut key that sets focus on the widget. */ @Input() get accessKey(): string { return this._getOption('accessKey'); } set accessKey(value: string) { this._setOption('accessKey', value); } /** * Specifies whether or not the widget changes its state when interacting with a user. */ @Input() get activeStateEnabled(): boolean { return this._getOption('activeStateEnabled'); } set activeStateEnabled(value: boolean) { this._setOption('activeStateEnabled', value); } /** * Specifies whether or not to animate item collapsing and expanding. */ @Input() get animationEnabled(): boolean { return this._getOption('animationEnabled'); } set animationEnabled(value: boolean) { this._setOption('animationEnabled', value); } /** * Allows you to load nodes manually. */ @Input() get createChildren(): Function { return this._getOption('createChildren'); } set createChildren(value: Function) { this._setOption('createChildren', value); } /** * A data source used to fetch data to be displayed by the widget. */ @Input() get dataSource(): DevExpress.data.DataSource| DevExpress.data.DataSourceOptions| string| Array { return this._getOption('dataSource'); } set dataSource(value: DevExpress.data.DataSource| DevExpress.data.DataSourceOptions| string| Array) { this._setOption('dataSource', value); } /** * Specifies whether a nested or plain array is used as a data source. */ @Input() get dataStructure(): string { return this._getOption('dataStructure'); } set dataStructure(value: string) { this._setOption('dataStructure', value); } /** * Specifies whether the widget responds to user interaction. */ @Input() get disabled(): boolean { return this._getOption('disabled'); } set disabled(value: boolean) { this._setOption('disabled', value); } /** * Specifies the name of the data source item field whose value defines whether or not the corresponding widget item is disabled. */ @Input() get disabledExpr(): Function| string { return this._getOption('disabledExpr'); } set disabledExpr(value: Function| string) { this._setOption('disabledExpr', value); } /** * Specifies the name of the data source item field whose value is displayed by the widget. */ @Input() get displayExpr(): Function| string { return this._getOption('displayExpr'); } set displayExpr(value: Function| string) { this._setOption('displayExpr', value); } /** * Specifies the attributes to be attached to the widget's root element. */ @Input() get elementAttr(): any { return this._getOption('elementAttr'); } set elementAttr(value: any) { this._setOption('elementAttr', value); } /** * Specifies whether or not a user can expand all tree view items by the "*" hot key. */ @Input() get expandAllEnabled(): boolean { return this._getOption('expandAllEnabled'); } set expandAllEnabled(value: boolean) { this._setOption('expandAllEnabled', value); } /** * Specifies the name of the data source item field whose value defines whether or not the corresponding widget item is displayed expanded. */ @Input() get expandedExpr(): Function| string { return this._getOption('expandedExpr'); } set expandedExpr(value: Function| string) { this._setOption('expandedExpr', value); } /** * Specifies whether or not all parent nodes of an initially expanded node are displayed expanded. */ @Input() get expandNodesRecursive(): boolean { return this._getOption('expandNodesRecursive'); } set expandNodesRecursive(value: boolean) { this._setOption('expandNodesRecursive', value); } /** * Specifies whether the widget can be focused using keyboard navigation. */ @Input() get focusStateEnabled(): boolean { return this._getOption('focusStateEnabled'); } set focusStateEnabled(value: boolean) { this._setOption('focusStateEnabled', value); } /** * Specifies the name of the data source item field whose value defines whether or not the corresponding node includes child nodes. */ @Input() get hasItemsExpr(): Function| string { return this._getOption('hasItemsExpr'); } set hasItemsExpr(value: Function| string) { this._setOption('hasItemsExpr', value); } /** * Specifies the widget's height. */ @Input() get height(): number| Function| string { return this._getOption('height'); } set height(value: number| Function| string) { this._setOption('height', value); } /** * Specifies text for a hint that appears when a user pauses on the widget. */ @Input() get hint(): string { return this._getOption('hint'); } set hint(value: string) { this._setOption('hint', value); } /** * Specifies whether the widget changes its state when a user pauses on it. */ @Input() get hoverStateEnabled(): boolean { return this._getOption('hoverStateEnabled'); } set hoverStateEnabled(value: boolean) { this._setOption('hoverStateEnabled', value); } /** * The time period in milliseconds before the onItemHold event is raised. */ @Input() get itemHoldTimeout(): number { return this._getOption('itemHoldTimeout'); } set itemHoldTimeout(value: number) { this._setOption('itemHoldTimeout', value); } @Input() get items(): any| Array { return this._getOption('items'); } set items(value: any| Array) { this._setOption('items', value); } /** * Specifies which data field contains nested items. */ @Input() get itemsExpr(): Function| string { return this._getOption('itemsExpr'); } set itemsExpr(value: Function| string) { this._setOption('itemsExpr', value); } /** * Specifies a custom template for an item. */ @Input() get itemTemplate(): any { return this._getOption('itemTemplate'); } set itemTemplate(value: any) { this._setOption('itemTemplate', value); } /** * Specifies which data field provides keys for TreeView items. */ @Input() get keyExpr(): Function| string { return this._getOption('keyExpr'); } set keyExpr(value: Function| string) { this._setOption('keyExpr', value); } /** * The text or HTML markup displayed by the widget if the item collection is empty. */ @Input() get noDataText(): string { return this._getOption('noDataText'); } set noDataText(value: string) { this._setOption('noDataText', value); } /** * Specifies the name of the data source item field for holding the parent key of the corresponding node. */ @Input() get parentIdExpr(): Function| string { return this._getOption('parentIdExpr'); } set parentIdExpr(value: Function| string) { this._setOption('parentIdExpr', value); } /** * Specifies the parent ID value of the root item. */ @Input() get rootValue(): any { return this._getOption('rootValue'); } set rootValue(value: any) { this._setOption('rootValue', value); } /** * Switches the widget to a right-to-left representation. */ @Input() get rtlEnabled(): boolean { return this._getOption('rtlEnabled'); } set rtlEnabled(value: boolean) { this._setOption('rtlEnabled', value); } /** * A string value specifying available scrolling directions. */ @Input() get scrollDirection(): string { return this._getOption('scrollDirection'); } set scrollDirection(value: string) { this._setOption('scrollDirection', value); } /** * Configures the search panel. */ @Input() get searchEditorOptions(): DevExpress.ui.dxTextBoxOptions { return this._getOption('searchEditorOptions'); } set searchEditorOptions(value: DevExpress.ui.dxTextBoxOptions) { this._setOption('searchEditorOptions', value); } /** * Specifies whether the search panel is visible. */ @Input() get searchEnabled(): boolean { return this._getOption('searchEnabled'); } set searchEnabled(value: boolean) { this._setOption('searchEnabled', value); } /** * Specifies a data object's field name or an expression whose value is compared to the search string. */ @Input() get searchExpr(): Function| Array { return this._getOption('searchExpr'); } set searchExpr(value: Function| Array) { this._setOption('searchExpr', value); } /** * Specifies whether the widget finds entries that contain your search string or entries that only start with it. */ @Input() get searchMode(): string { return this._getOption('searchMode'); } set searchMode(value: string) { this._setOption('searchMode', value); } /** * Specifies the current search string. */ @Input() get searchValue(): string { return this._getOption('searchValue'); } set searchValue(value: string) { this._setOption('searchValue', value); } /** * Use the showCheckBoxesMode options instead. */ @Input() get selectAllEnabled(): boolean { return this._getOption('selectAllEnabled'); } set selectAllEnabled(value: boolean) { this._setOption('selectAllEnabled', value); } /** * Specifies the text displayed at the "Select All" check box. */ @Input() get selectAllText(): string { return this._getOption('selectAllText'); } set selectAllText(value: string) { this._setOption('selectAllText', value); } /** * Specifies whether or not an item becomes selected if a user clicks it. */ @Input() get selectByClick(): boolean { return this._getOption('selectByClick'); } set selectByClick(value: boolean) { this._setOption('selectByClick', value); } /** * Specifies the name of the data source item field whose value defines whether or not the corresponding widget items is selected. */ @Input() get selectedExpr(): Function| string { return this._getOption('selectedExpr'); } set selectedExpr(value: Function| string) { this._setOption('selectedExpr', value); } /** * Specifies item selection mode. */ @Input() get selectionMode(): string { return this._getOption('selectionMode'); } set selectionMode(value: string) { this._setOption('selectionMode', value); } /** * Specifies whether or not to select nodes recursively. */ @Input() get selectNodesRecursive(): boolean { return this._getOption('selectNodesRecursive'); } set selectNodesRecursive(value: boolean) { this._setOption('selectNodesRecursive', value); } /** * Use the showCheckBoxesMode options instead. */ @Input() get showCheckBoxes(): boolean { return this._getOption('showCheckBoxes'); } set showCheckBoxes(value: boolean) { this._setOption('showCheckBoxes', value); } /** * Specifies the current check boxes display mode. */ @Input() get showCheckBoxesMode(): string { return this._getOption('showCheckBoxesMode'); } set showCheckBoxesMode(value: string) { this._setOption('showCheckBoxesMode', value); } /** * Specifies the number of the element when the Tab key is used for navigating. */ @Input() get tabIndex(): number { return this._getOption('tabIndex'); } set tabIndex(value: number) { this._setOption('tabIndex', value); } /** * Specifies if the virtual mode is enabled. */ @Input() get virtualModeEnabled(): boolean { return this._getOption('virtualModeEnabled'); } set virtualModeEnabled(value: boolean) { this._setOption('virtualModeEnabled', value); } /** * Specifies whether the widget is visible. */ @Input() get visible(): boolean { return this._getOption('visible'); } set visible(value: boolean) { this._setOption('visible', value); } /** * Specifies the widget's width. */ @Input() get width(): number| Function| string { return this._getOption('width'); } set width(value: number| Function| string) { this._setOption('width', value); } /** * A handler for the contentReady event. Executed when the widget's content is ready. This handler may be executed multiple times during the widget's lifetime depending on the number of times its content changes. */ @Output() onContentReady: EventEmitter; /** * A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only. */ @Output() onDisposing: EventEmitter; /** * A handler for the initialized event. Executed only once, after the widget is initialized. */ @Output() onInitialized: EventEmitter; /** * A handler for the itemClick event. */ @Output() onItemClick: EventEmitter; /** * A handler for the itemCollapsed event. */ @Output() onItemCollapsed: EventEmitter; /** * A handler for the itemContextMenu event. */ @Output() onItemContextMenu: EventEmitter; /** * A handler for the itemExpanded event. */ @Output() onItemExpanded: EventEmitter; /** * A handler for the itemHold event. */ @Output() onItemHold: EventEmitter; /** * A handler for the itemRendered event. */ @Output() onItemRendered: EventEmitter; /** * Use the itemSelectionChanged event instead. */ @Output() onItemSelected: EventEmitter; /** * A handler for the itemSelectionChanged event. */ @Output() onItemSelectionChanged: EventEmitter; /** * A handler for the optionChanged event. Executed after an option of the widget is changed. */ @Output() onOptionChanged: EventEmitter; /** * A handler for the selectionChanged event. Raised after an item is selected or unselected. */ @Output() onSelectionChanged: EventEmitter; /** * A handler for the accessKeyChange event. */ @Output() accessKeyChange: EventEmitter; /** * A handler for the activeStateEnabledChange event. */ @Output() activeStateEnabledChange: EventEmitter; /** * A handler for the animationEnabledChange event. */ @Output() animationEnabledChange: EventEmitter; /** * A handler for the createChildrenChange event. */ @Output() createChildrenChange: EventEmitter; /** * A handler for the dataSourceChange event. */ @Output() dataSourceChange: EventEmitter>; /** * A handler for the dataStructureChange event. */ @Output() dataStructureChange: EventEmitter; /** * A handler for the disabledChange event. */ @Output() disabledChange: EventEmitter; /** * A handler for the disabledExprChange event. */ @Output() disabledExprChange: EventEmitter; /** * A handler for the displayExprChange event. */ @Output() displayExprChange: EventEmitter; /** * A handler for the elementAttrChange event. */ @Output() elementAttrChange: EventEmitter; /** * A handler for the expandAllEnabledChange event. */ @Output() expandAllEnabledChange: EventEmitter; /** * A handler for the expandedExprChange event. */ @Output() expandedExprChange: EventEmitter; /** * A handler for the expandNodesRecursiveChange event. */ @Output() expandNodesRecursiveChange: EventEmitter; /** * A handler for the focusStateEnabledChange event. */ @Output() focusStateEnabledChange: EventEmitter; /** * A handler for the hasItemsExprChange event. */ @Output() hasItemsExprChange: EventEmitter; /** * A handler for the heightChange event. */ @Output() heightChange: EventEmitter; /** * A handler for the hintChange event. */ @Output() hintChange: EventEmitter; /** * A handler for the hoverStateEnabledChange event. */ @Output() hoverStateEnabledChange: EventEmitter; /** * A handler for the itemHoldTimeoutChange event. */ @Output() itemHoldTimeoutChange: EventEmitter; /** * A handler for the itemsChange event. */ @Output() itemsChange: EventEmitter>; /** * A handler for the itemsExprChange event. */ @Output() itemsExprChange: EventEmitter; /** * A handler for the itemTemplateChange event. */ @Output() itemTemplateChange: EventEmitter; /** * A handler for the keyExprChange event. */ @Output() keyExprChange: EventEmitter; /** * A handler for the noDataTextChange event. */ @Output() noDataTextChange: EventEmitter; /** * A handler for the parentIdExprChange event. */ @Output() parentIdExprChange: EventEmitter; /** * A handler for the rootValueChange event. */ @Output() rootValueChange: EventEmitter; /** * A handler for the rtlEnabledChange event. */ @Output() rtlEnabledChange: EventEmitter; /** * A handler for the scrollDirectionChange event. */ @Output() scrollDirectionChange: EventEmitter; /** * A handler for the searchEditorOptionsChange event. */ @Output() searchEditorOptionsChange: EventEmitter; /** * A handler for the searchEnabledChange event. */ @Output() searchEnabledChange: EventEmitter; /** * A handler for the searchExprChange event. */ @Output() searchExprChange: EventEmitter>; /** * A handler for the searchModeChange event. */ @Output() searchModeChange: EventEmitter; /** * A handler for the searchValueChange event. */ @Output() searchValueChange: EventEmitter; /** * A handler for the selectAllEnabledChange event. */ @Output() selectAllEnabledChange: EventEmitter; /** * A handler for the selectAllTextChange event. */ @Output() selectAllTextChange: EventEmitter; /** * A handler for the selectByClickChange event. */ @Output() selectByClickChange: EventEmitter; /** * A handler for the selectedExprChange event. */ @Output() selectedExprChange: EventEmitter; /** * A handler for the selectionModeChange event. */ @Output() selectionModeChange: EventEmitter; /** * A handler for the selectNodesRecursiveChange event. */ @Output() selectNodesRecursiveChange: EventEmitter; /** * A handler for the showCheckBoxesChange event. */ @Output() showCheckBoxesChange: EventEmitter; /** * A handler for the showCheckBoxesModeChange event. */ @Output() showCheckBoxesModeChange: EventEmitter; /** * A handler for the tabIndexChange event. */ @Output() tabIndexChange: EventEmitter; /** * A handler for the virtualModeEnabledChange event. */ @Output() virtualModeEnabledChange: EventEmitter; /** * A handler for the visibleChange event. */ @Output() visibleChange: EventEmitter; /** * A handler for the widthChange event. */ @Output() widthChange: EventEmitter; @ContentChildren(DxiItemComponent) get itemsChildren(): QueryList { return this._getOption('items'); } set itemsChildren(value) { this.setChildren('items', value); } constructor(elementRef: ElementRef, ngZone: NgZone, templateHost: DxTemplateHost, injector: Injector, private _watcherHelper: WatcherHelper, private _idh: IterableDifferHelper, optionHost: NestedOptionHost) { super(elementRef, ngZone, templateHost, _watcherHelper); injector.get(EventsRegistrator); this._createEventEmitters([ { subscribe: 'contentReady', emit: 'onContentReady' }, { subscribe: 'disposing', emit: 'onDisposing' }, { subscribe: 'initialized', emit: 'onInitialized' }, { subscribe: 'itemClick', emit: 'onItemClick' }, { subscribe: 'itemCollapsed', emit: 'onItemCollapsed' }, { subscribe: 'itemContextMenu', emit: 'onItemContextMenu' }, { subscribe: 'itemExpanded', emit: 'onItemExpanded' }, { subscribe: 'itemHold', emit: 'onItemHold' }, { subscribe: 'itemRendered', emit: 'onItemRendered' }, { subscribe: 'itemSelected', emit: 'onItemSelected' }, { subscribe: 'itemSelectionChanged', emit: 'onItemSelectionChanged' }, { subscribe: 'optionChanged', emit: 'onOptionChanged' }, { subscribe: 'selectionChanged', emit: 'onSelectionChanged' }, { emit: 'accessKeyChange' }, { emit: 'activeStateEnabledChange' }, { emit: 'animationEnabledChange' }, { emit: 'createChildrenChange' }, { emit: 'dataSourceChange' }, { emit: 'dataStructureChange' }, { emit: 'disabledChange' }, { emit: 'disabledExprChange' }, { emit: 'displayExprChange' }, { emit: 'elementAttrChange' }, { emit: 'expandAllEnabledChange' }, { emit: 'expandedExprChange' }, { emit: 'expandNodesRecursiveChange' }, { emit: 'focusStateEnabledChange' }, { emit: 'hasItemsExprChange' }, { emit: 'heightChange' }, { emit: 'hintChange' }, { emit: 'hoverStateEnabledChange' }, { emit: 'itemHoldTimeoutChange' }, { emit: 'itemsChange' }, { emit: 'itemsExprChange' }, { emit: 'itemTemplateChange' }, { emit: 'keyExprChange' }, { emit: 'noDataTextChange' }, { emit: 'parentIdExprChange' }, { emit: 'rootValueChange' }, { emit: 'rtlEnabledChange' }, { emit: 'scrollDirectionChange' }, { emit: 'searchEditorOptionsChange' }, { emit: 'searchEnabledChange' }, { emit: 'searchExprChange' }, { emit: 'searchModeChange' }, { emit: 'searchValueChange' }, { emit: 'selectAllEnabledChange' }, { emit: 'selectAllTextChange' }, { emit: 'selectByClickChange' }, { emit: 'selectedExprChange' }, { emit: 'selectionModeChange' }, { emit: 'selectNodesRecursiveChange' }, { emit: 'showCheckBoxesChange' }, { emit: 'showCheckBoxesModeChange' }, { emit: 'tabIndexChange' }, { emit: 'virtualModeEnabledChange' }, { emit: 'visibleChange' }, { emit: 'widthChange' } ]); this._idh.setHost(this); optionHost.setHost(this); } protected _createInstance(element, options) { return new DxTreeView(element, options); } ngOnDestroy() { this._destroyWidget(); } ngOnChanges(changes: SimpleChanges) { super.ngOnChanges(changes); this.setupChanges('dataSource', changes); this.setupChanges('items', changes); this.setupChanges('searchExpr', changes); } setupChanges(prop: string, changes: SimpleChanges) { if (!(prop in this._optionsToUpdate)) { this._idh.setup(prop, changes); } } ngDoCheck() { this._idh.doCheck('dataSource'); this._idh.doCheck('items'); this._idh.doCheck('searchExpr'); this._watcherHelper.checkWatchers(); super.ngDoCheck(); } _setOption(name: string, value: any) { let isSetup = this._idh.setupSingle(name, value); let isChanged = this._idh.getChanges(name, value) !== null; if (isSetup || isChanged) { super._setOption(name, value); } } } @NgModule({ imports: [ DxiItemModule, DxoSearchEditorOptionsModule, DxTemplateModule ], declarations: [ DxTreeViewComponent ], exports: [ DxTreeViewComponent, DxiItemModule, DxoSearchEditorOptionsModule, DxTemplateModule ], providers: [EventsRegistrator] }) export class DxTreeViewModule { }