@progress/kendo-angular-dropdowns 7.0.2-dev.202205271051 → 7.0.3-dev.202207081325

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common/util.d.ts CHANGED
@@ -134,7 +134,7 @@ export declare const getHierarchicalItemLevel: (index: string) => number;
134
134
  *
135
135
  * Retrieves all descendant nodes' lookups which are currently registered in the provided lookup item as a flat array.
136
136
  */
137
- export declare const fetchDescendentNodes: (lookup: TreeItemLookup, filterExpression?: (lookup: TreeItem) => boolean) => TreeItemLookup[];
137
+ export declare const fetchDescendentNodes: (lookup: any, filterExpression?: (lookup: TreeItem) => boolean) => TreeItemLookup[];
138
138
  /**
139
139
  * @hidden
140
140
  *
@@ -19,6 +19,13 @@ export declare abstract class BaseCheckDirective {
19
19
  * Defines the collection that will store the full checked items.
20
20
  */
21
21
  abstract checkedItems: CheckedItem[];
22
+ /**
23
+ * @hidden
24
+ * The flag is needed in order to determine how to construct the items map keys.
25
+ * If `true`, then the key consists of the item's value and 0 (no leveling required),
26
+ * else the key consists of the item's value and level (depth)
27
+ */
28
+ isHeterogeneous: boolean;
22
29
  /**
23
30
  * Holds a Set with just the checked item keys.
24
31
  *
@@ -34,9 +41,9 @@ export declare abstract class BaseCheckDirective {
34
41
  * Adds the item's depth to the item's value to allow duplicate values on different levels.
35
42
  *
36
43
  * @param item - The checked key.
37
- * @returns { string } - A string key consisting of the item's `valueField` value and its depth.
44
+ * @returns { string } - A string key consisting of the item's `valueField` value and its depth (depth is 0 if data is homogeneous).
38
45
  */
39
46
  private getKey;
40
47
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseCheckDirective, never>;
41
- static ɵdir: i0.ɵɵDirectiveDeclaration<BaseCheckDirective, never, never, { "valueField": "valueField"; "checkedItems": "checkedItems"; }, {}, never>;
48
+ static ɵdir: i0.ɵɵDirectiveDeclaration<BaseCheckDirective, never, never, { "valueField": "valueField"; "checkedItems": "checkedItems"; "isHeterogeneous": "isHeterogeneous"; }, {}, never>;
42
49
  }
@@ -21,4 +21,8 @@ export interface CheckedItem {
21
21
  * Used to retrieve the correct valueField, when using heterogenous data.
22
22
  */
23
23
  level?: number;
24
+ /**
25
+ * Represents a unique key identifier constructed from the item's value and level (if heterogeneous data)
26
+ */
27
+ key?: string;
24
28
  }
@@ -0,0 +1,51 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * @hidden
7
+ */
8
+ export interface NormalizedTreeItem {
9
+ /**
10
+ * The original dataItem
11
+ */
12
+ dataItem?: any;
13
+ /**
14
+ * The unique item's key identifier.
15
+ */
16
+ key?: string;
17
+ }
18
+ /**
19
+ * @hidden
20
+ */
21
+ export interface NormalizedItemLookup {
22
+ /**
23
+ * The current TreeItem instance
24
+ */
25
+ item: NormalizedTreeItem;
26
+ /**
27
+ * The children of the current node
28
+ */
29
+ children?: NormalizedTreeItem[];
30
+ /**
31
+ * The parent of the current node
32
+ */
33
+ parent?: NormalizedItemLookup;
34
+ }
35
+ /**
36
+ * @hidden
37
+ */
38
+ export interface NormalizedTreeItemLookup {
39
+ /**
40
+ * The current TreeItem instance.
41
+ */
42
+ item: NormalizedTreeItem;
43
+ /**
44
+ * The lookup details for the parent of the current TreeView node.
45
+ */
46
+ parent?: NormalizedItemLookup;
47
+ /**
48
+ * The lookup details for the children of the current TreeView node.
49
+ */
50
+ children?: NormalizedTreeItemLookup[];
51
+ }
@@ -0,0 +1,32 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { NormalizedItemLookup, NormalizedTreeItem, NormalizedTreeItemLookup } from './lookup';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * @hidden
9
+ */
10
+ export declare const nodeIndex: (item: NormalizedTreeItem) => string;
11
+ /**
12
+ * @hidden
13
+ */
14
+ export declare const buildTreeIndex: (parentIndex: string, itemIndex: string | number) => string;
15
+ /**
16
+ * @hidden
17
+ */
18
+ export declare const buildTreeItem: (dataItem: any, valueField: any, currentLevelIndex: number) => NormalizedTreeItem;
19
+ /**
20
+ * @hidden
21
+ */
22
+ export declare class MultiSelectTreeLookupService {
23
+ private map;
24
+ reset(): void;
25
+ registerChildren(index: string, children: NormalizedTreeItem[]): void;
26
+ item(index: string): NormalizedItemLookup;
27
+ registerItem(item: any, parent?: NormalizedTreeItem): void;
28
+ itemLookup(index: string): NormalizedTreeItemLookup;
29
+ private mapChildren;
30
+ static ɵfac: i0.ɵɵFactoryDeclaration<MultiSelectTreeLookupService, never>;
31
+ static ɵprov: i0.ɵɵInjectableDeclaration<MultiSelectTreeLookupService>;
32
+ }
@@ -24,6 +24,7 @@ import { Observable } from 'rxjs';
24
24
  import { DropDownSize } from '../common/models/size';
25
25
  import { DropDownRounded } from '../common/models/rounded';
26
26
  import { DropDownFillMode } from '../common/models/fillmode';
27
+ import { MultiSelectTreeLookupService } from './lookup/lookup.service';
27
28
  import * as i0 from "@angular/core";
28
29
  /**
29
30
  * Represents the [Kendo UI MultiSelectTree component for Angular]({% slug overview_multiselecttree %}).
@@ -36,6 +37,7 @@ export declare class MultiSelectTreeComponent implements OnInit, OnDestroy, OnCh
36
37
  private _zone;
37
38
  private localization;
38
39
  private cdr;
40
+ private lookup;
39
41
  touchEnabled: boolean;
40
42
  hostClasses: boolean;
41
43
  get isDisabled(): boolean;
@@ -395,8 +397,11 @@ export declare class MultiSelectTreeComponent implements OnInit, OnDestroy, OnCh
395
397
  checkedItems: CheckedItem[];
396
398
  /**
397
399
  * @hidden
400
+ * The flag is needed in order to determine how to construct the items map keys.
401
+ * If `true`, then the key consists of the item's value and 0 (no leveling required),
402
+ * else the key consists of the item's value and level (depth)
398
403
  */
399
- checkBy: (item: any) => any;
404
+ isHeterogeneous: boolean;
400
405
  /**
401
406
  * @hidden
402
407
  */
@@ -424,7 +429,7 @@ export declare class MultiSelectTreeComponent implements OnInit, OnDestroy, OnCh
424
429
  private _fillMode;
425
430
  private subscriptions;
426
431
  private lastNodeOnFocus;
427
- constructor(wrapper: ElementRef, popupService: PopupService, renderer: Renderer2, navigationService: NavigationService, _zone: NgZone, localization: LocalizationService, cdr: ChangeDetectorRef, touchEnabled: boolean);
432
+ constructor(wrapper: ElementRef, popupService: PopupService, renderer: Renderer2, navigationService: NavigationService, _zone: NgZone, localization: LocalizationService, cdr: ChangeDetectorRef, lookup: MultiSelectTreeLookupService, touchEnabled: boolean);
428
433
  ngOnInit(): void;
429
434
  /**
430
435
  * @hidden
@@ -438,6 +443,7 @@ export declare class MultiSelectTreeComponent implements OnInit, OnDestroy, OnCh
438
443
  * @hidden
439
444
  */
440
445
  ngAfterContentChecked(): void;
446
+ ngAfterContentInit(): void;
441
447
  /**
442
448
  * @hidden
443
449
  *
@@ -581,6 +587,13 @@ export declare class MultiSelectTreeComponent implements OnInit, OnDestroy, OnCh
581
587
  */
582
588
  private disabledItemsMapper;
583
589
  private setComponentClasses;
584
- static ɵfac: i0.ɵɵFactoryDeclaration<MultiSelectTreeComponent, [null, null, null, null, null, null, null, { optional: true; }]>;
590
+ private removeParents;
591
+ /**
592
+ * Creates an internal map of the available tree items to be used as a reference
593
+ * to retrieve the item's children/parent and determine the checked sate
594
+ */
595
+ private registerLookupItems;
596
+ private registerChildLookupItems;
597
+ static ɵfac: i0.ɵɵFactoryDeclaration<MultiSelectTreeComponent, [null, null, null, null, null, null, null, null, { optional: true; }]>;
585
598
  static ɵcmp: i0.ɵɵComponentDeclaration<MultiSelectTreeComponent, "kendo-multiselecttree", ["kendoMultiSelectTree"], { "tabindex": "tabindex"; "size": "size"; "rounded": "rounded"; "fillMode": "fillMode"; "popupSettings": "popupSettings"; "checkableSettings": "checkableSettings"; "data": "data"; "value": "value"; "dataItems": "dataItems"; "textField": "textField"; "valueField": "valueField"; "valueDepth": "valueDepth"; "loading": "loading"; "placeholder": "placeholder"; "listHeight": "listHeight"; "disabled": "disabled"; "readonly": "readonly"; "valuePrimitive": "valuePrimitive"; "loadOnDemand": "loadOnDemand"; "focusableId": "focusableId"; "clearButton": "clearButton"; "filterable": "filterable"; "checkAll": "checkAll"; "hasChildren": "hasChildren"; "fetchChildren": "fetchChildren"; "isNodeExpanded": "isNodeExpanded"; "isNodeVisible": "isNodeVisible"; "itemDisabled": "itemDisabled"; "tagMapper": "tagMapper"; }, { "onFocus": "focus"; "onBlur": "blur"; "open": "open"; "opened": "opened"; "close": "close"; "closed": "closed"; "nodeExpand": "nodeExpand"; "nodeCollapse": "nodeCollapse"; "valueChange": "valueChange"; "removeTag": "removeTag"; "filterChange": "filterChange"; }, ["headerTemplate", "footerTemplate", "nodeTemplate", "noDataTemplate", "tagTemplate", "groupTagTemplate"], never>;
586
599
  }
@@ -3,7 +3,7 @@
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { Directive, Input } from '@angular/core';
6
- import { getHierarchicalItemLevel, isArray, valueFrom } from '../../common/util';
6
+ import { getHierarchicalItemLevel, valueFrom } from '../../common/util';
7
7
  import * as i0 from "@angular/core";
8
8
  /**
9
9
  * @hidden
@@ -16,48 +16,50 @@ export class BaseCheckDirective {
16
16
  return;
17
17
  }
18
18
  const level = getHierarchicalItemLevel(item.index);
19
- const candidate = Object.assign(Object.assign({}, item), { level });
19
+ const key = this.getKey(item, level);
20
+ const candidate = Object.assign(Object.assign({}, item), { level, key });
20
21
  this.checkedItems.push(candidate);
21
- this.checkedKeys.add(this.getKey(candidate));
22
+ this.checkedKeys.add(key);
22
23
  }
23
24
  removeItem(item) {
24
25
  if (!this.isItemChecked(item)) {
25
26
  return;
26
27
  }
27
28
  const level = getHierarchicalItemLevel(item.index);
28
- const candidate = Object.assign(Object.assign({}, item), { level });
29
+ const key = this.getKey(item, level);
30
+ const candidate = Object.assign(Object.assign({}, item), { level, key });
29
31
  this.checkedItems = this.checkedItems
30
32
  .filter(item => valueFrom(item, this.valueField) !== valueFrom(candidate, this.valueField));
31
- this.checkedKeys.delete(this.getKey(candidate));
33
+ this.checkedKeys.delete(key);
32
34
  }
33
35
  isItemChecked(item) {
34
36
  const level = item.index.split('_').length - 1;
35
37
  item.level = level;
36
- return this.checkedKeys.has(this.getKey(item));
38
+ const key = this.getKey(item, level);
39
+ return this.checkedKeys.has(key);
37
40
  }
38
41
  updateItems() {
39
42
  this.checkedItems = this.checkedItems || [];
40
- this.checkedKeys = new Set(this.checkedItems.map(item => this.getKey(item)));
43
+ this.checkedKeys = new Set(this.checkedItems.map(item => item.key));
41
44
  }
42
45
  /**
43
46
  * Adds the item's depth to the item's value to allow duplicate values on different levels.
44
47
  *
45
48
  * @param item - The checked key.
46
- * @returns { string } - A string key consisting of the item's `valueField` value and its depth.
49
+ * @returns { string } - A string key consisting of the item's `valueField` value and its depth (depth is 0 if data is homogeneous).
47
50
  */
48
- getKey(item) {
49
- if (isArray(this.valueField)) {
50
- return valueFrom(item, this.valueField) + '_' + item.level;
51
- }
52
- return valueFrom(item, this.valueField);
51
+ getKey(item, level) {
52
+ return valueFrom(item, this.valueField) + '_' + (this.isHeterogeneous ? level : 0);
53
53
  }
54
54
  }
55
55
  BaseCheckDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BaseCheckDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
56
- BaseCheckDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: BaseCheckDirective, inputs: { valueField: "valueField", checkedItems: "checkedItems" }, ngImport: i0 });
56
+ BaseCheckDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: BaseCheckDirective, inputs: { valueField: "valueField", checkedItems: "checkedItems", isHeterogeneous: "isHeterogeneous" }, ngImport: i0 });
57
57
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: BaseCheckDirective, decorators: [{
58
58
  type: Directive
59
59
  }], propDecorators: { valueField: [{
60
60
  type: Input
61
61
  }], checkedItems: [{
62
62
  type: Input
63
+ }], isHeterogeneous: [{
64
+ type: Input
63
65
  }] } });
@@ -1129,7 +1129,7 @@ DropDownTreeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0",
1129
1129
  </div>
1130
1130
  </ng-template>
1131
1131
  <ng-container #container></ng-container>
1132
- `, isInline: true, components: [{ type: i4.TreeViewComponent, selector: "kendo-treeview", inputs: ["filterInputPlaceholder", "animate", "nodeTemplate", "loadMoreButtonTemplate", "trackBy", "nodes", "textField", "hasChildren", "isChecked", "isDisabled", "isExpanded", "isSelected", "isVisible", "navigable", "children", "loadOnDemand", "filterable", "filter", "size"], outputs: ["childrenLoaded", "blur", "focus", "expand", "collapse", "nodeDragStart", "nodeDrag", "filterStateChange", "nodeDrop", "nodeDragEnd", "addItem", "removeItem", "checkedChange", "selectionChange", "filterChange", "nodeClick", "nodeDblClick"], exportAs: ["kendoTreeView"] }], directives: [{ type: i5.LocalizedMessagesDirective, selector: "\n [kendoDropDownListLocalizedMessages],\n [kendoDropDownTreeLocalizedMessages],\n [kendoComboBoxLocalizedMessages],\n [kendoMultiColumnComboBoxLocalizedMessages],\n [kendoAutoCompleteLocalizedMessages],\n [kendoMultiSelectLocalizedMessages],\n [kendoMultiSelectTreeLocalizedMessages]\n " }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.TemplateContextDirective, selector: "[templateContext]", inputs: ["templateContext"] }, { type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i8.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i9.FilterInputDirective, selector: "[filterInput]", inputs: ["filterInput"] }, { type: i8.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i8.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i10.EventsOutsideAngularDirective, selector: "[kendoEventsOutsideAngular]", inputs: ["kendoEventsOutsideAngular", "scope"] }, { type: i4.SelectDirective, selector: "[kendoTreeViewSelectable]", inputs: ["isSelected", "selectBy", "kendoTreeViewSelectable", "selectedKeys"], outputs: ["selectedKeysChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1132
+ `, isInline: true, components: [{ type: i4.TreeViewComponent, selector: "kendo-treeview", inputs: ["filterInputPlaceholder", "expandDisabledNodes", "animate", "nodeTemplate", "loadMoreButtonTemplate", "trackBy", "nodes", "textField", "hasChildren", "isChecked", "isDisabled", "isExpanded", "isSelected", "isVisible", "navigable", "children", "loadOnDemand", "filterable", "filter", "size", "disableParentNodesOnly"], outputs: ["childrenLoaded", "blur", "focus", "expand", "collapse", "nodeDragStart", "nodeDrag", "filterStateChange", "nodeDrop", "nodeDragEnd", "addItem", "removeItem", "checkedChange", "selectionChange", "filterChange", "nodeClick", "nodeDblClick"], exportAs: ["kendoTreeView"] }], directives: [{ type: i5.LocalizedMessagesDirective, selector: "\n [kendoDropDownListLocalizedMessages],\n [kendoDropDownTreeLocalizedMessages],\n [kendoComboBoxLocalizedMessages],\n [kendoMultiColumnComboBoxLocalizedMessages],\n [kendoAutoCompleteLocalizedMessages],\n [kendoMultiSelectLocalizedMessages],\n [kendoMultiSelectTreeLocalizedMessages]\n " }, { type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.TemplateContextDirective, selector: "[templateContext]", inputs: ["templateContext"] }, { type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i8.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i9.FilterInputDirective, selector: "[filterInput]", inputs: ["filterInput"] }, { type: i8.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i8.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i10.EventsOutsideAngularDirective, selector: "[kendoEventsOutsideAngular]", inputs: ["kendoEventsOutsideAngular", "scope"] }, { type: i4.SelectDirective, selector: "[kendoTreeViewSelectable]", inputs: ["isSelected", "selectBy", "kendoTreeViewSelectable", "selectedKeys"], outputs: ["selectedKeysChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1133
1133
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: DropDownTreeComponent, decorators: [{
1134
1134
  type: Component,
1135
1135
  args: [{
@@ -0,0 +1,6 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ ;
6
+ export {};
@@ -0,0 +1,84 @@
1
+ /**-----------------------------------------------------------------------------------------
2
+ * Copyright © 2021 Progress Software Corporation. All rights reserved.
3
+ * Licensed under commercial license. See LICENSE.md in the project root for more information
4
+ *-------------------------------------------------------------------------------------------*/
5
+ import { Injectable } from '@angular/core';
6
+ import { isPresent, valueFrom } from '../../common/util';
7
+ import * as i0 from "@angular/core";
8
+ /**
9
+ * @hidden
10
+ */
11
+ export const nodeIndex = (item) => (item || {}).key;
12
+ /**
13
+ * @hidden
14
+ */
15
+ export const buildTreeIndex = (parentIndex, itemIndex) => {
16
+ return [parentIndex, itemIndex].filter(part => isPresent(part)).join('_');
17
+ };
18
+ /**
19
+ * @hidden
20
+ */
21
+ export const buildTreeItem = (dataItem, valueField, currentLevelIndex) => {
22
+ if (!isPresent(dataItem)) {
23
+ return null;
24
+ }
25
+ return {
26
+ dataItem,
27
+ key: valueFrom({ dataItem, level: currentLevelIndex }, valueField) + '_' + currentLevelIndex
28
+ };
29
+ };
30
+ /**
31
+ * @hidden
32
+ */
33
+ export class MultiSelectTreeLookupService {
34
+ constructor() {
35
+ this.map = new Map();
36
+ }
37
+ reset() {
38
+ this.map.clear();
39
+ }
40
+ registerChildren(index, children) {
41
+ const item = this.item(index);
42
+ if (!item) {
43
+ return;
44
+ }
45
+ item.children = children;
46
+ }
47
+ item(index) {
48
+ return this.map.get(index) || null;
49
+ }
50
+ registerItem(item, parent) {
51
+ const currentLookup = {
52
+ children: [],
53
+ item,
54
+ parent: this.item(nodeIndex(parent))
55
+ };
56
+ this.map.set(item.key, currentLookup);
57
+ }
58
+ itemLookup(index) {
59
+ const item = this.item(index);
60
+ if (!item) {
61
+ return null;
62
+ }
63
+ return {
64
+ children: this.mapChildren(item.children),
65
+ item: item.item,
66
+ parent: item.parent
67
+ };
68
+ }
69
+ mapChildren(children = []) {
70
+ return children.map(c => {
71
+ const { item, parent, children } = this.item(c.key);
72
+ return {
73
+ children: this.mapChildren(children),
74
+ item,
75
+ parent
76
+ };
77
+ });
78
+ }
79
+ }
80
+ MultiSelectTreeLookupService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MultiSelectTreeLookupService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
81
+ MultiSelectTreeLookupService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MultiSelectTreeLookupService });
82
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MultiSelectTreeLookupService, decorators: [{
83
+ type: Injectable
84
+ }] });
@@ -13,9 +13,9 @@ import { DisabledItemsService } from '../common/disabled-items/disabled-items.se
13
13
  import { SelectionService } from '../common/selection/selection.service';
14
14
  import { PreventableEvent } from '../common/models/preventable-event';
15
15
  import { NavigationAction } from '../common/navigation/navigation-action';
16
- import { getFillModeClass, getRoundedClass, getSizeClass, hasProps, isArray, isObject, isObjectArray, isPresent, isUntouched, noop, parseNumber, valueFrom } from '../common/util';
17
16
  import { RemoveTagEvent } from '../common/models/remove-tag-event';
18
17
  import { MultiSelectTreeMessages } from '../common/constants/error-messages';
18
+ import { fetchDescendentNodes, getFillModeClass, getRoundedClass, getSizeClass, hasProps, isArray, isObject, isObjectArray, isPresent, isUntouched, noop, parseNumber, valueFrom } from '../common/util';
19
19
  import { HeaderTemplateDirective } from '../common/templates/header-template.directive';
20
20
  import { FooterTemplateDirective } from '../common/templates/footer-template.directive';
21
21
  import { NodeTemplateDirective } from './templates/node-template.directive';
@@ -25,20 +25,22 @@ import { GroupTagTemplateDirective } from '../common/templates/group-tag-templat
25
25
  import { TOUCH_ENABLED } from '../common/constants/touch-enabled';
26
26
  import { merge, of } from 'rxjs';
27
27
  import { filter, tap } from 'rxjs/operators';
28
+ import { buildTreeItem, MultiSelectTreeLookupService, nodeIndex } from './lookup/lookup.service';
28
29
  import * as i0 from "@angular/core";
29
30
  import * as i1 from "@progress/kendo-angular-popup";
30
31
  import * as i2 from "../common/navigation/navigation.service";
31
32
  import * as i3 from "@progress/kendo-angular-l10n";
32
- import * as i4 from "../common/taglist.component";
33
- import * as i5 from "@progress/kendo-angular-treeview";
34
- import * as i6 from "../common/localization/localized-messages.directive";
35
- import * as i7 from "@angular/common";
36
- import * as i8 from "@angular/forms";
37
- import * as i9 from "../common/filter-input.directive";
38
- import * as i10 from "@progress/kendo-angular-common";
39
- import * as i11 from "../common/templates/template-context.directive";
40
- import * as i12 from "./checked-state/check-all.directive";
41
- import * as i13 from "./checked-state/check.directive";
33
+ import * as i4 from "./lookup/lookup.service";
34
+ import * as i5 from "../common/taglist.component";
35
+ import * as i6 from "@progress/kendo-angular-treeview";
36
+ import * as i7 from "../common/localization/localized-messages.directive";
37
+ import * as i8 from "@angular/common";
38
+ import * as i9 from "@angular/forms";
39
+ import * as i10 from "../common/filter-input.directive";
40
+ import * as i11 from "@progress/kendo-angular-common";
41
+ import * as i12 from "../common/templates/template-context.directive";
42
+ import * as i13 from "./checked-state/check-all.directive";
43
+ import * as i14 from "./checked-state/check.directive";
42
44
  const DEFAULT_POPUP_SETTINGS = { animate: true };
43
45
  const DEFAULT_CHECKABLE_SETTINGS = { checkChildren: true, checkOnClick: true };
44
46
  const hasChildren = () => false;
@@ -52,7 +54,7 @@ const DEFAULT_FILL_MODE = 'solid';
52
54
  * Represents the [Kendo UI MultiSelectTree component for Angular]({% slug overview_multiselecttree %}).
53
55
  */
54
56
  export class MultiSelectTreeComponent {
55
- constructor(wrapper, popupService, renderer, navigationService, _zone, localization, cdr, touchEnabled) {
57
+ constructor(wrapper, popupService, renderer, navigationService, _zone, localization, cdr, lookup, touchEnabled) {
56
58
  this.wrapper = wrapper;
57
59
  this.popupService = popupService;
58
60
  this.renderer = renderer;
@@ -60,6 +62,7 @@ export class MultiSelectTreeComponent {
60
62
  this._zone = _zone;
61
63
  this.localization = localization;
62
64
  this.cdr = cdr;
65
+ this.lookup = lookup;
63
66
  this.touchEnabled = touchEnabled;
64
67
  this.hostClasses = true;
65
68
  this.role = 'combobox';
@@ -206,10 +209,6 @@ export class MultiSelectTreeComponent {
206
209
  * @hidden
207
210
  */
208
211
  this.checkedItems = [];
209
- /**
210
- * @hidden
211
- */
212
- this.checkBy = (item) => item;
213
212
  /**
214
213
  * @hidden
215
214
  */
@@ -448,7 +447,8 @@ export class MultiSelectTreeComponent {
448
447
  return {
449
448
  dataItem: item,
450
449
  index: null,
451
- level: this.valueDepth[index] || 0
450
+ level: this.valueDepth[index] || 0,
451
+ key: valueFrom({ dataItem: item }, this.valueField) + '_' + (this.isHeterogeneous ? this.valueDepth[index] : 0)
452
452
  };
453
453
  });
454
454
  this.setState();
@@ -457,7 +457,8 @@ export class MultiSelectTreeComponent {
457
457
  return this._dataItems || this.value.map((value, index) => ({
458
458
  dataItem: value,
459
459
  index: null,
460
- level: this.valueDepth[index] || 0
460
+ level: this.valueDepth[index] || 0,
461
+ key: valueFrom({ dataItem: value }, this.valueField) + '_' + (this.isHeterogeneous ? this.valueDepth[index] : 0)
461
462
  }));
462
463
  }
463
464
  /**
@@ -614,6 +615,7 @@ export class MultiSelectTreeComponent {
614
615
  */
615
616
  ngOnChanges(changes) {
616
617
  if (anyChanged(['textField', 'valueField', 'valuePrimitive'], changes, false)) {
618
+ this.isHeterogeneous = this.valueField && isArray(this.valueField);
617
619
  this.setState();
618
620
  }
619
621
  if (anyChanged(['valueDepth', 'value', 'dataItems'], changes, false)) {
@@ -627,6 +629,10 @@ export class MultiSelectTreeComponent {
627
629
  this.dataItems = this.dataItems.map((item, index) => (Object.assign(Object.assign({}, item), { level: this.valueDepth[index] || 0 })));
628
630
  }
629
631
  }
632
+ if (anyChanged(['data', 'children', 'hasChildren', 'loadOnDemand', 'valueField'], changes, true) && !this.loadOnDemand) {
633
+ this.lookup.reset();
634
+ this.registerLookupItems(this.data);
635
+ }
630
636
  }
631
637
  /**
632
638
  * @hidden
@@ -634,6 +640,9 @@ export class MultiSelectTreeComponent {
634
640
  ngAfterContentChecked() {
635
641
  this.verifySettings();
636
642
  }
643
+ ngAfterContentInit() {
644
+ this.registerLookupItems(this.data);
645
+ }
637
646
  /**
638
647
  * @hidden
639
648
  *
@@ -816,11 +825,26 @@ export class MultiSelectTreeComponent {
816
825
  }
817
826
  else {
818
827
  // Remove single tag
819
- this.dataItems = this.dataItems.filter((_item, i) => i !== index || this.disabledIndices.has(i));
820
- this.valueDepth = this.valueDepth.filter((_item, i) => i !== index || this.disabledIndices.has(i));
828
+ const dataItem = this.dataItems[index];
829
+ const itemKey = dataItem.key;
830
+ const lookup = this.lookup.itemLookup(itemKey);
831
+ const pendingCheck = [lookup.item];
832
+ if (this.checkableSettings.checkChildren) {
833
+ fetchDescendentNodes(lookup)
834
+ .forEach(lookup => pendingCheck.push(lookup.item));
835
+ pendingCheck.push(...this.removeParents(lookup.parent));
836
+ }
837
+ const keysToRemove = pendingCheck.map(item => item.key);
838
+ const valueDepthIndices = [];
839
+ this.dataItems = this.dataItems.filter((_item, i) => {
840
+ // We need to know the index position of the data item to be able to update the valueDepth array accordignly
841
+ // as each data item's position is corresponding to the same position in valueDepth
842
+ valueDepthIndices.push(i);
843
+ return !keysToRemove.includes(_item.key) || this.disabledIndices.has(i);
844
+ });
845
+ this.valueDepth = this.valueDepth.filter((_item, i) => valueDepthIndices.includes(i) || this.disabledIndices.has(i));
821
846
  }
822
847
  this.updateValue(this.dataItems);
823
- // focus the wrapper if the component is not focused - the floating label reacts to focus/blur
824
848
  if (!this.isFocused) {
825
849
  this.focus();
826
850
  }
@@ -1196,14 +1220,53 @@ export class MultiSelectTreeComponent {
1196
1220
  this.renderer.addClass(this.wrapper.nativeElement, getFillModeClass('input', this.fillMode));
1197
1221
  }
1198
1222
  }
1223
+ removeParents(parent) {
1224
+ let currentParent = parent;
1225
+ const nodes = [];
1226
+ while (currentParent) {
1227
+ nodes.push(currentParent.item);
1228
+ currentParent = currentParent.parent;
1229
+ }
1230
+ return nodes;
1231
+ }
1232
+ /**
1233
+ * Creates an internal map of the available tree items to be used as a reference
1234
+ * to retrieve the item's children/parent and determine the checked sate
1235
+ */
1236
+ registerLookupItems(data, parentItem = null, levelIndex = 0) {
1237
+ if (!isPresent(data) || data.length === 0) {
1238
+ return;
1239
+ }
1240
+ const parentIndex = nodeIndex(parentItem);
1241
+ const treeItems = data.map((node) => buildTreeItem(node, this.valueField, levelIndex));
1242
+ if (isPresent(parentItem)) {
1243
+ this.lookup.registerChildren(parentIndex, treeItems);
1244
+ }
1245
+ treeItems.forEach(item => {
1246
+ this.lookup.registerItem(item, parentItem);
1247
+ if (!this.loadOnDemand) {
1248
+ this.registerChildLookupItems(item, levelIndex);
1249
+ }
1250
+ });
1251
+ }
1252
+ registerChildLookupItems(item, levelIndex) {
1253
+ if (this.hasChildren(item.dataItem)) {
1254
+ this.children(item.dataItem)
1255
+ .subscribe(children => {
1256
+ const index = this.isHeterogeneous ? levelIndex + 1 : 0;
1257
+ this.registerLookupItems(children, item, index);
1258
+ });
1259
+ }
1260
+ }
1199
1261
  }
1200
- MultiSelectTreeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MultiSelectTreeComponent, deps: [{ token: i0.ElementRef }, { token: i1.PopupService }, { token: i0.Renderer2 }, { token: i2.NavigationService }, { token: i0.NgZone }, { token: i3.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: TOUCH_ENABLED, optional: true }], target: i0.ɵɵFactoryTarget.Component });
1262
+ MultiSelectTreeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MultiSelectTreeComponent, deps: [{ token: i0.ElementRef }, { token: i1.PopupService }, { token: i0.Renderer2 }, { token: i2.NavigationService }, { token: i0.NgZone }, { token: i3.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i4.MultiSelectTreeLookupService }, { token: TOUCH_ENABLED, optional: true }], target: i0.ɵɵFactoryTarget.Component });
1201
1263
  MultiSelectTreeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.16", type: MultiSelectTreeComponent, selector: "kendo-multiselecttree", inputs: { tabindex: "tabindex", size: "size", rounded: "rounded", fillMode: "fillMode", popupSettings: "popupSettings", checkableSettings: "checkableSettings", data: "data", value: "value", dataItems: "dataItems", textField: "textField", valueField: "valueField", valueDepth: "valueDepth", loading: "loading", placeholder: "placeholder", listHeight: "listHeight", disabled: "disabled", readonly: "readonly", valuePrimitive: "valuePrimitive", loadOnDemand: "loadOnDemand", focusableId: "focusableId", clearButton: "clearButton", filterable: "filterable", checkAll: "checkAll", hasChildren: "hasChildren", fetchChildren: "fetchChildren", isNodeExpanded: "isNodeExpanded", isNodeVisible: "isNodeVisible", itemDisabled: "itemDisabled", tagMapper: "tagMapper" }, outputs: { onFocus: "focus", onBlur: "blur", open: "open", opened: "opened", close: "close", closed: "closed", nodeExpand: "nodeExpand", nodeCollapse: "nodeCollapse", valueChange: "valueChange", removeTag: "removeTag", filterChange: "filterChange" }, host: { listeners: { "click": "handleClick()", "keydown": "handleKeydown($event)" }, properties: { "class.k-dropdowntree": "this.hostClasses", "class.k-input": "this.hostClasses", "class.k-disabled": "this.isDisabled", "attr.aria-disabled": "this.isDisabled", "class.k-loading": "this.isLoading", "attr.id": "this.id", "attr.dir": "this.direction", "attr.tabindex": "this.hostTabIndex", "attr.role": "this.role", "attr.aria-expanded": "this.isAriaExpanded", "attr.aria-haspopup": "this.ariaHasPopup", "attr.readonly": "this.isReadonly", "attr.aria-readonly": "this.isReadonly", "attr.aria-describedby": "this.ariaDescribedBy", "attr.aria-activedescendant": "this.ariaActiveDescendant" } }, providers: [
1202
1264
  LocalizationService,
1203
1265
  NavigationService,
1204
1266
  DataService,
1205
1267
  DisabledItemsService,
1206
1268
  SelectionService,
1269
+ MultiSelectTreeLookupService,
1207
1270
  {
1208
1271
  provide: L10N_PREFIX,
1209
1272
  useValue: 'kendo.multiselecttree'
@@ -1394,7 +1457,7 @@ MultiSelectTreeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0
1394
1457
  </div>
1395
1458
  </ng-template>
1396
1459
  <ng-container #container></ng-container>
1397
- `, isInline: true, components: [{ type: i4.TagListComponent, selector: "kendo-taglist", inputs: ["tags", "textField", "valueField", "valueDepth", "focused", "template", "groupTemplate", "disabled", "tagPrefix", "id", "size", "rounded", "fillMode", "disabledIndices"], outputs: ["removeTag"] }, { type: i5.TreeViewComponent, selector: "kendo-treeview", inputs: ["filterInputPlaceholder", "animate", "nodeTemplate", "loadMoreButtonTemplate", "trackBy", "nodes", "textField", "hasChildren", "isChecked", "isDisabled", "isExpanded", "isSelected", "isVisible", "navigable", "children", "loadOnDemand", "filterable", "filter", "size"], outputs: ["childrenLoaded", "blur", "focus", "expand", "collapse", "nodeDragStart", "nodeDrag", "filterStateChange", "nodeDrop", "nodeDragEnd", "addItem", "removeItem", "checkedChange", "selectionChange", "filterChange", "nodeClick", "nodeDblClick"], exportAs: ["kendoTreeView"] }], directives: [{ type: i6.LocalizedMessagesDirective, selector: "\n [kendoDropDownListLocalizedMessages],\n [kendoDropDownTreeLocalizedMessages],\n [kendoComboBoxLocalizedMessages],\n [kendoMultiColumnComboBoxLocalizedMessages],\n [kendoAutoCompleteLocalizedMessages],\n [kendoMultiSelectLocalizedMessages],\n [kendoMultiSelectTreeLocalizedMessages]\n " }, { type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i8.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i9.FilterInputDirective, selector: "[filterInput]", inputs: ["filterInput"] }, { type: i8.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i8.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i10.EventsOutsideAngularDirective, selector: "[kendoEventsOutsideAngular]", inputs: ["kendoEventsOutsideAngular", "scope"] }, { type: i11.TemplateContextDirective, selector: "[templateContext]", inputs: ["templateContext"] }, { type: i12.CheckAllDirective, selector: "[checkAll]", inputs: ["lastAction", "treeview", "checkedItems", "valueField", "checkAll"], outputs: ["checkedItemsChange"] }, { type: i13.CheckDirective, selector: "[kendoMultiSelectTreeCheckable]", inputs: ["checkable", "valueField", "checkedItems"], outputs: ["checkedItemsChange"] }] });
1460
+ `, isInline: true, components: [{ type: i5.TagListComponent, selector: "kendo-taglist", inputs: ["tags", "textField", "valueField", "valueDepth", "focused", "template", "groupTemplate", "disabled", "tagPrefix", "id", "size", "rounded", "fillMode", "disabledIndices"], outputs: ["removeTag"] }, { type: i6.TreeViewComponent, selector: "kendo-treeview", inputs: ["filterInputPlaceholder", "expandDisabledNodes", "animate", "nodeTemplate", "loadMoreButtonTemplate", "trackBy", "nodes", "textField", "hasChildren", "isChecked", "isDisabled", "isExpanded", "isSelected", "isVisible", "navigable", "children", "loadOnDemand", "filterable", "filter", "size", "disableParentNodesOnly"], outputs: ["childrenLoaded", "blur", "focus", "expand", "collapse", "nodeDragStart", "nodeDrag", "filterStateChange", "nodeDrop", "nodeDragEnd", "addItem", "removeItem", "checkedChange", "selectionChange", "filterChange", "nodeClick", "nodeDblClick"], exportAs: ["kendoTreeView"] }], directives: [{ type: i7.LocalizedMessagesDirective, selector: "\n [kendoDropDownListLocalizedMessages],\n [kendoDropDownTreeLocalizedMessages],\n [kendoComboBoxLocalizedMessages],\n [kendoMultiColumnComboBoxLocalizedMessages],\n [kendoAutoCompleteLocalizedMessages],\n [kendoMultiSelectLocalizedMessages],\n [kendoMultiSelectTreeLocalizedMessages]\n " }, { type: i8.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i9.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i10.FilterInputDirective, selector: "[filterInput]", inputs: ["filterInput"] }, { type: i9.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i9.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i11.EventsOutsideAngularDirective, selector: "[kendoEventsOutsideAngular]", inputs: ["kendoEventsOutsideAngular", "scope"] }, { type: i12.TemplateContextDirective, selector: "[templateContext]", inputs: ["templateContext"] }, { type: i13.CheckAllDirective, selector: "[checkAll]", inputs: ["lastAction", "treeview", "checkedItems", "valueField", "checkAll"], outputs: ["checkedItemsChange"] }, { type: i14.CheckDirective, selector: "[kendoMultiSelectTreeCheckable]", inputs: ["checkable", "valueField", "checkedItems"], outputs: ["checkedItemsChange"] }] });
1398
1461
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: MultiSelectTreeComponent, decorators: [{
1399
1462
  type: Component,
1400
1463
  args: [{
@@ -1405,6 +1468,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
1405
1468
  DataService,
1406
1469
  DisabledItemsService,
1407
1470
  SelectionService,
1471
+ MultiSelectTreeLookupService,
1408
1472
  {
1409
1473
  provide: L10N_PREFIX,
1410
1474
  useValue: 'kendo.multiselecttree'
@@ -1599,7 +1663,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImpo
1599
1663
  <ng-container #container></ng-container>
1600
1664
  `
1601
1665
  }]
1602
- }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.PopupService }, { type: i0.Renderer2 }, { type: i2.NavigationService }, { type: i0.NgZone }, { type: i3.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
1666
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.PopupService }, { type: i0.Renderer2 }, { type: i2.NavigationService }, { type: i0.NgZone }, { type: i3.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i4.MultiSelectTreeLookupService }, { type: undefined, decorators: [{
1603
1667
  type: Optional
1604
1668
  }, {
1605
1669
  type: Inject,
@@ -9,7 +9,7 @@ export const packageMetadata = {
9
9
  name: '@progress/kendo-angular-dropdowns',
10
10
  productName: 'Kendo UI for Angular',
11
11
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
12
- publishDate: 1653648605,
12
+ publishDate: 1657286636,
13
13
  version: '',
14
14
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
15
15
  };