@progress/kendo-angular-dropdowns 7.0.2 → 7.0.4-dev.202208041601

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.
@@ -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: 1654848651,
12
+ publishDate: 1659628812,
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
  };