@progress/kendo-angular-treelist 17.0.2-develop.7 → 17.0.2-develop.9

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.
@@ -9,7 +9,7 @@ export const packageMetadata = {
9
9
  name: '@progress/kendo-angular-treelist',
10
10
  productName: 'Kendo UI for Angular',
11
11
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
12
- publishDate: 1731668811,
13
- version: '17.0.2-develop.7',
12
+ publishDate: 1731923537,
13
+ version: '17.0.2-develop.9',
14
14
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
15
15
  };
@@ -2,31 +2,46 @@
2
2
  * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- import { ChangeDetectorRef, Directive, ElementRef, NgZone, Renderer2 } from '@angular/core';
5
+ import { ChangeDetectorRef, Directive, ElementRef, Renderer2 } from '@angular/core';
6
6
  import { CheckBoxComponent } from '@progress/kendo-angular-inputs';
7
7
  import { SelectionService } from '../../selection/selection.service';
8
8
  import { Subscription } from 'rxjs';
9
- import { SelectableDirective } from '../../selection/selectable.directive';
10
9
  import { isPresent } from '@progress/kendo-angular-common';
10
+ import { ViewCollection } from '../../data/data.collection';
11
11
  import * as i0 from "@angular/core";
12
12
  import * as i1 from "@progress/kendo-angular-inputs";
13
13
  import * as i2 from "../../selection/selection.service";
14
- import * as i3 from "../../selection/selectable.directive";
15
14
  /**
16
15
  * @hidden
17
16
  */
18
17
  export class TreeListSelectAllCheckboxDirective {
19
18
  sub = new Subscription();
20
19
  setState = true;
21
- constructor(host, hostEl, selectionService, selectableDirective, cdr, zone, renderer) {
20
+ constructor(host, hostEl, selectionService, cdr, renderer) {
22
21
  this.sub = selectionService.changes.subscribe(eventData => {
23
22
  // omit setting the state when the selection change comes from clicking the checkbox, and clear the flag
24
23
  if (!this.setState) {
25
24
  this.setState = true;
26
25
  return;
27
26
  }
28
- const allSelected = eventData.sender.view.total === selectableDirective.stateArray.length;
29
- const noneSelected = selectableDirective.stateArray.length === 0;
27
+ const view = eventData.sender.view;
28
+ let total;
29
+ ViewCollection.loadView({
30
+ fields: Object.assign({}, view.fieldAccessor(), {
31
+ hasFooter: false,
32
+ pageable: false,
33
+ isVirtual: false
34
+ }),
35
+ loaded: view.loaded,
36
+ selectionState: view.selectionState
37
+ }).subscribe(view => {
38
+ if (!view) {
39
+ return;
40
+ }
41
+ total = view.data.length;
42
+ });
43
+ const allSelected = total === selectionService.state.length;
44
+ const noneSelected = selectionService.state.length === 0;
30
45
  const someSelected = !noneSelected && !allSelected;
31
46
  if (allSelected && host.checkedState !== true) {
32
47
  host.checkedState = true;
@@ -37,7 +52,7 @@ export class TreeListSelectAllCheckboxDirective {
37
52
  else if (noneSelected && host.checkedState !== false) {
38
53
  host.checkedState = false;
39
54
  }
40
- cdr.markForCheck();
55
+ cdr.detectChanges();
41
56
  });
42
57
  // set flag for conditional checkbox state logic
43
58
  ['pointerdown', 'keydown'].forEach(eventName => this.sub.add(renderer.listen(hostEl.nativeElement, eventName, (e) => {
@@ -49,7 +64,7 @@ export class TreeListSelectAllCheckboxDirective {
49
64
  ngOnDestroy() {
50
65
  this.sub && this.sub.unsubscribe();
51
66
  }
52
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TreeListSelectAllCheckboxDirective, deps: [{ token: i1.CheckBoxComponent }, { token: i0.ElementRef }, { token: i2.SelectionService }, { token: i3.SelectableDirective }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
67
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TreeListSelectAllCheckboxDirective, deps: [{ token: i1.CheckBoxComponent }, { token: i0.ElementRef }, { token: i2.SelectionService }, { token: i0.ChangeDetectorRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
53
68
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: TreeListSelectAllCheckboxDirective, isStandalone: true, selector: "[kendoTreeListSelectAllCheckbox]", ngImport: i0 });
54
69
  }
55
70
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TreeListSelectAllCheckboxDirective, decorators: [{
@@ -58,4 +73,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
58
73
  selector: '[kendoTreeListSelectAllCheckbox]',
59
74
  standalone: true
60
75
  }]
61
- }], ctorParameters: function () { return [{ type: i1.CheckBoxComponent }, { type: i0.ElementRef }, { type: i2.SelectionService }, { type: i3.SelectableDirective }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i0.Renderer2 }]; } });
76
+ }], ctorParameters: function () { return [{ type: i1.CheckBoxComponent }, { type: i0.ElementRef }, { type: i2.SelectionService }, { type: i0.ChangeDetectorRef }, { type: i0.Renderer2 }]; } });
@@ -7,14 +7,17 @@ import { TreeListComponent } from '../treelist.component';
7
7
  import { getter } from '@progress/kendo-common';
8
8
  import { isString } from '../utils';
9
9
  import { createState, RowSelectionState } from './selection-state';
10
+ import { SelectionService } from './selection.service';
10
11
  import * as i0 from "@angular/core";
11
12
  import * as i1 from "../treelist.component";
13
+ import * as i2 from "./selection.service";
12
14
  const defaultColumnKeyGetter = (_column, columnIndex) => columnIndex;
13
15
  /**
14
16
  * A directive which controls the selection state. [See example](slug:selection_treelist).
15
17
  */
16
18
  export class SelectableDirective {
17
19
  treelist;
20
+ selectionService;
18
21
  /**
19
22
  * @hidden
20
23
  */
@@ -78,12 +81,6 @@ export class SelectableDirective {
78
81
  this._columnKeyGetter = value;
79
82
  }
80
83
  }
81
- /**
82
- * @hidden
83
- */
84
- get stateArray() {
85
- return this.state.toArray();
86
- }
87
84
  get keyGetter() {
88
85
  return this._keyGetter || this.treelist.idGetter;
89
86
  }
@@ -97,8 +94,9 @@ export class SelectableDirective {
97
94
  _columnKeyGetter;
98
95
  _keyGetter;
99
96
  _selectedItems = [];
100
- constructor(treelist) {
97
+ constructor(treelist, selectionService) {
101
98
  this.treelist = treelist;
99
+ this.selectionService = selectionService;
102
100
  this.cellSelected = this.cellSelected.bind(this);
103
101
  this.rowSelected = this.rowSelected.bind(this);
104
102
  this.selectionChange = this.selectionChange.bind(this);
@@ -137,7 +135,7 @@ export class SelectableDirective {
137
135
  this.emitSelectedItemsChange();
138
136
  }
139
137
  emitSelectedItemsChange() {
140
- this.lastChange = this.state.toArray();
138
+ this.selectionService.state = this.lastChange = this.state.toArray();
141
139
  this.selectedItemsChange.emit(this.lastChange);
142
140
  }
143
141
  subscribeSelection() {
@@ -176,7 +174,7 @@ export class SelectableDirective {
176
174
  get leafColumns() {
177
175
  return this.treelist.lockedLeafColumns.toArray().concat(this.treelist.nonLockedLeafColumns.toArray());
178
176
  }
179
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SelectableDirective, deps: [{ token: i1.TreeListComponent }], target: i0.ɵɵFactoryTarget.Directive });
177
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SelectableDirective, deps: [{ token: i1.TreeListComponent }, { token: i2.SelectionService }], target: i0.ɵɵFactoryTarget.Directive });
180
178
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SelectableDirective, isStandalone: true, selector: "[kendoTreeListSelectable]", inputs: { selectable: "selectable", selectedItems: "selectedItems", itemKey: "itemKey", columnKey: "columnKey" }, outputs: { selectedItemsChange: "selectedItemsChange" }, exportAs: ["kendoTreeListSelectable"], ngImport: i0 });
181
179
  }
182
180
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SelectableDirective, decorators: [{
@@ -186,7 +184,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
186
184
  selector: '[kendoTreeListSelectable]',
187
185
  standalone: true
188
186
  }]
189
- }], ctorParameters: function () { return [{ type: i1.TreeListComponent }]; }, propDecorators: { selectable: [{
187
+ }], ctorParameters: function () { return [{ type: i1.TreeListComponent }, { type: i2.SelectionService }]; }, propDecorators: { selectable: [{
190
188
  type: Input
191
189
  }], selectedItems: [{
192
190
  type: Input
@@ -18,6 +18,7 @@ const noop = () => false;
18
18
  */
19
19
  export class SelectionService {
20
20
  changes = new Subject();
21
+ state = [];
21
22
  set settings(value) {
22
23
  if (typeof value === 'object') {
23
24
  this._settings = value;
@@ -46,8 +46,8 @@ const packageMetadata = {
46
46
  name: '@progress/kendo-angular-treelist',
47
47
  productName: 'Kendo UI for Angular',
48
48
  productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
49
- publishDate: 1731668811,
50
- version: '17.0.2-develop.7',
49
+ publishDate: 1731923537,
50
+ version: '17.0.2-develop.9',
51
51
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
52
52
  };
53
53
 
@@ -4214,6 +4214,7 @@ const noop = () => false;
4214
4214
  */
4215
4215
  class SelectionService {
4216
4216
  changes = new Subject();
4217
+ state = [];
4217
4218
  set settings(value) {
4218
4219
  if (typeof value === 'object') {
4219
4220
  this._settings = value;
@@ -13309,210 +13310,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
13309
13310
  type: Input
13310
13311
  }] } });
13311
13312
 
13312
- const defaultColumnKeyGetter = (_column, columnIndex) => columnIndex;
13313
- /**
13314
- * A directive which controls the selection state. [See example](slug:selection_treelist).
13315
- */
13316
- class SelectableDirective {
13317
- treelist;
13318
- /**
13319
- * @hidden
13320
- */
13321
- set selectable(value) {
13322
- if (typeof value === 'object') { // add method to normalize this
13323
- this._settings = value;
13324
- }
13325
- else {
13326
- this._settings = {
13327
- enabled: value
13328
- };
13329
- }
13330
- this.state = createState(this._settings);
13331
- this.state.fromArray(this._selectedItems || []);
13332
- if (this._settings.enabled !== false) {
13333
- this.treelist.isSelected = this._settings.mode === 'cell' ? this.cellSelected : this.rowSelected;
13334
- this.subscribeSelection();
13335
- }
13336
- else {
13337
- this.treelist.isSelected = () => false;
13338
- this.unsubscribeSelection();
13339
- }
13340
- this.treelist.updateView();
13341
- }
13342
- /**
13343
- * Specifies the selected items.
13344
- */
13345
- set selectedItems(value) {
13346
- if (!value) {
13347
- this.state.clear();
13348
- }
13349
- else if (value !== this.lastChange) {
13350
- this.state.fromArray(value);
13351
- this.treelist.updateView();
13352
- }
13353
- this._selectedItems = value;
13354
- }
13355
- /**
13356
- * Fires when the selected items are changed.
13357
- */
13358
- selectedItemsChange = new EventEmitter();
13359
- /**
13360
- * The field name or a function that specify the dataItems key.
13361
- */
13362
- set itemKey(value) {
13363
- if (isString(value)) {
13364
- this._keyGetter = getter(String(value));
13365
- }
13366
- else {
13367
- this._keyGetter = value;
13368
- }
13369
- }
13370
- /**
13371
- * The field name or a function that specify the columns key.
13372
- */
13373
- set columnKey(value) {
13374
- if (isString(value)) {
13375
- this._columnKeyGetter = getter(String(value));
13376
- }
13377
- else if (value) {
13378
- this._columnKeyGetter = value;
13379
- }
13380
- }
13381
- /**
13382
- * @hidden
13383
- */
13384
- get stateArray() {
13385
- return this.state.toArray();
13386
- }
13387
- get keyGetter() {
13388
- return this._keyGetter || this.treelist.idGetter;
13389
- }
13390
- get columnKeyGetter() {
13391
- return this._columnKeyGetter || defaultColumnKeyGetter;
13392
- }
13393
- subscriptions;
13394
- state = new RowSelectionState();
13395
- _settings;
13396
- lastChange;
13397
- _columnKeyGetter;
13398
- _keyGetter;
13399
- _selectedItems = [];
13400
- constructor(treelist) {
13401
- this.treelist = treelist;
13402
- this.cellSelected = this.cellSelected.bind(this);
13403
- this.rowSelected = this.rowSelected.bind(this);
13404
- this.selectionChange = this.selectionChange.bind(this);
13405
- this.updateColumnIndices = this.updateColumnIndices.bind(this);
13406
- this.treelist.selectable = this.selectable = true;
13407
- }
13408
- ngOnDestroy() {
13409
- this.unsubscribeSelection();
13410
- }
13411
- /**
13412
- * @hidden
13413
- */
13414
- cellSelected(dataItem, column, columnIndex) {
13415
- return this.state.has(this.keyGetter(dataItem), this.columnKeyGetter(column, columnIndex));
13416
- }
13417
- /**
13418
- * @hidden
13419
- */
13420
- rowSelected(dataItem) {
13421
- return this.state.has(this.keyGetter(dataItem));
13422
- }
13423
- selectionChange({ action, items }) {
13424
- if (action === 'select' || action === 'add') {
13425
- if (action === 'select') {
13426
- this.state.clear();
13427
- }
13428
- items.forEach(item => {
13429
- this.state.add(this.keyGetter(item.dataItem), this.columnKeyGetter(item.column, item.columnIndex));
13430
- });
13431
- }
13432
- else {
13433
- items.forEach(item => {
13434
- this.state.remove(this.keyGetter(item.dataItem), this.columnKeyGetter(item.column, item.columnIndex));
13435
- });
13436
- }
13437
- this.emitSelectedItemsChange();
13438
- }
13439
- emitSelectedItemsChange() {
13440
- this.lastChange = this.state.toArray();
13441
- this.selectedItemsChange.emit(this.lastChange);
13442
- }
13443
- subscribeSelection() {
13444
- this.unsubscribeSelection();
13445
- this.subscriptions = this.treelist.selectionChange.subscribe(this.selectionChange);
13446
- if (this._settings.mode === 'cell') {
13447
- this.subscriptions.add(this.treelist.columnOrderChange.subscribe(this.updateColumnIndices));
13448
- this.subscriptions.add(this.treelist.columnLockedChange.subscribe(this.updateColumnIndices));
13449
- }
13450
- }
13451
- unsubscribeSelection() {
13452
- if (this.subscriptions) {
13453
- this.subscriptions.unsubscribe();
13454
- this.subscriptions = null;
13455
- }
13456
- }
13457
- updateColumnIndices() {
13458
- if (!this._columnKeyGetter) {
13459
- const changes = new Map();
13460
- const currentIndices = [];
13461
- this.leafColumns.forEach((column) => {
13462
- currentIndices.push(column);
13463
- });
13464
- this.treelist.columnsContainer.refresh();
13465
- const leafColumns = this.leafColumns;
13466
- currentIndices.forEach((column, index) => {
13467
- if (column !== leafColumns[index]) {
13468
- changes.set(index, leafColumns.indexOf(column));
13469
- }
13470
- });
13471
- if (changes.size && this.state.updateColumKeys(changes)) {
13472
- this.emitSelectedItemsChange();
13473
- }
13474
- }
13475
- }
13476
- get leafColumns() {
13477
- return this.treelist.lockedLeafColumns.toArray().concat(this.treelist.nonLockedLeafColumns.toArray());
13478
- }
13479
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SelectableDirective, deps: [{ token: TreeListComponent }], target: i0.ɵɵFactoryTarget.Directive });
13480
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SelectableDirective, isStandalone: true, selector: "[kendoTreeListSelectable]", inputs: { selectable: "selectable", selectedItems: "selectedItems", itemKey: "itemKey", columnKey: "columnKey" }, outputs: { selectedItemsChange: "selectedItemsChange" }, exportAs: ["kendoTreeListSelectable"], ngImport: i0 });
13481
- }
13482
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SelectableDirective, decorators: [{
13483
- type: Directive,
13484
- args: [{
13485
- exportAs: 'kendoTreeListSelectable',
13486
- selector: '[kendoTreeListSelectable]',
13487
- standalone: true
13488
- }]
13489
- }], ctorParameters: function () { return [{ type: TreeListComponent }]; }, propDecorators: { selectable: [{
13490
- type: Input
13491
- }], selectedItems: [{
13492
- type: Input
13493
- }], selectedItemsChange: [{
13494
- type: Output
13495
- }], itemKey: [{
13496
- type: Input
13497
- }], columnKey: [{
13498
- type: Input
13499
- }] } });
13500
-
13501
13313
  /**
13502
13314
  * @hidden
13503
13315
  */
13504
13316
  class TreeListSelectAllCheckboxDirective {
13505
13317
  sub = new Subscription();
13506
13318
  setState = true;
13507
- constructor(host, hostEl, selectionService, selectableDirective, cdr, zone, renderer) {
13319
+ constructor(host, hostEl, selectionService, cdr, renderer) {
13508
13320
  this.sub = selectionService.changes.subscribe(eventData => {
13509
13321
  // omit setting the state when the selection change comes from clicking the checkbox, and clear the flag
13510
13322
  if (!this.setState) {
13511
13323
  this.setState = true;
13512
13324
  return;
13513
13325
  }
13514
- const allSelected = eventData.sender.view.total === selectableDirective.stateArray.length;
13515
- const noneSelected = selectableDirective.stateArray.length === 0;
13326
+ const view = eventData.sender.view;
13327
+ let total;
13328
+ ViewCollection.loadView({
13329
+ fields: Object.assign({}, view.fieldAccessor(), {
13330
+ hasFooter: false,
13331
+ pageable: false,
13332
+ isVirtual: false
13333
+ }),
13334
+ loaded: view.loaded,
13335
+ selectionState: view.selectionState
13336
+ }).subscribe(view => {
13337
+ if (!view) {
13338
+ return;
13339
+ }
13340
+ total = view.data.length;
13341
+ });
13342
+ const allSelected = total === selectionService.state.length;
13343
+ const noneSelected = selectionService.state.length === 0;
13516
13344
  const someSelected = !noneSelected && !allSelected;
13517
13345
  if (allSelected && host.checkedState !== true) {
13518
13346
  host.checkedState = true;
@@ -13523,7 +13351,7 @@ class TreeListSelectAllCheckboxDirective {
13523
13351
  else if (noneSelected && host.checkedState !== false) {
13524
13352
  host.checkedState = false;
13525
13353
  }
13526
- cdr.markForCheck();
13354
+ cdr.detectChanges();
13527
13355
  });
13528
13356
  // set flag for conditional checkbox state logic
13529
13357
  ['pointerdown', 'keydown'].forEach(eventName => this.sub.add(renderer.listen(hostEl.nativeElement, eventName, (e) => {
@@ -13535,7 +13363,7 @@ class TreeListSelectAllCheckboxDirective {
13535
13363
  ngOnDestroy() {
13536
13364
  this.sub && this.sub.unsubscribe();
13537
13365
  }
13538
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TreeListSelectAllCheckboxDirective, deps: [{ token: i1$5.CheckBoxComponent }, { token: i0.ElementRef }, { token: SelectionService }, { token: SelectableDirective }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
13366
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TreeListSelectAllCheckboxDirective, deps: [{ token: i1$5.CheckBoxComponent }, { token: i0.ElementRef }, { token: SelectionService }, { token: i0.ChangeDetectorRef }, { token: i0.Renderer2 }], target: i0.ɵɵFactoryTarget.Directive });
13539
13367
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: TreeListSelectAllCheckboxDirective, isStandalone: true, selector: "[kendoTreeListSelectAllCheckbox]", ngImport: i0 });
13540
13368
  }
13541
13369
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TreeListSelectAllCheckboxDirective, decorators: [{
@@ -13544,7 +13372,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
13544
13372
  selector: '[kendoTreeListSelectAllCheckbox]',
13545
13373
  standalone: true
13546
13374
  }]
13547
- }], ctorParameters: function () { return [{ type: i1$5.CheckBoxComponent }, { type: i0.ElementRef }, { type: SelectionService }, { type: SelectableDirective }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: i0.Renderer2 }]; } });
13375
+ }], ctorParameters: function () { return [{ type: i1$5.CheckBoxComponent }, { type: i0.ElementRef }, { type: SelectionService }, { type: i0.ChangeDetectorRef }, { type: i0.Renderer2 }]; } });
13548
13376
 
13549
13377
  /* eslint-disable @typescript-eslint/no-explicit-any */
13550
13378
  const mergeObjects = (...args) => Object.assign.apply(null, [{}].concat(args));
@@ -18750,6 +18578,191 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
18750
18578
  type: Input
18751
18579
  }] } });
18752
18580
 
18581
+ const defaultColumnKeyGetter = (_column, columnIndex) => columnIndex;
18582
+ /**
18583
+ * A directive which controls the selection state. [See example](slug:selection_treelist).
18584
+ */
18585
+ class SelectableDirective {
18586
+ treelist;
18587
+ selectionService;
18588
+ /**
18589
+ * @hidden
18590
+ */
18591
+ set selectable(value) {
18592
+ if (typeof value === 'object') { // add method to normalize this
18593
+ this._settings = value;
18594
+ }
18595
+ else {
18596
+ this._settings = {
18597
+ enabled: value
18598
+ };
18599
+ }
18600
+ this.state = createState(this._settings);
18601
+ this.state.fromArray(this._selectedItems || []);
18602
+ if (this._settings.enabled !== false) {
18603
+ this.treelist.isSelected = this._settings.mode === 'cell' ? this.cellSelected : this.rowSelected;
18604
+ this.subscribeSelection();
18605
+ }
18606
+ else {
18607
+ this.treelist.isSelected = () => false;
18608
+ this.unsubscribeSelection();
18609
+ }
18610
+ this.treelist.updateView();
18611
+ }
18612
+ /**
18613
+ * Specifies the selected items.
18614
+ */
18615
+ set selectedItems(value) {
18616
+ if (!value) {
18617
+ this.state.clear();
18618
+ }
18619
+ else if (value !== this.lastChange) {
18620
+ this.state.fromArray(value);
18621
+ this.treelist.updateView();
18622
+ }
18623
+ this._selectedItems = value;
18624
+ }
18625
+ /**
18626
+ * Fires when the selected items are changed.
18627
+ */
18628
+ selectedItemsChange = new EventEmitter();
18629
+ /**
18630
+ * The field name or a function that specify the dataItems key.
18631
+ */
18632
+ set itemKey(value) {
18633
+ if (isString(value)) {
18634
+ this._keyGetter = getter(String(value));
18635
+ }
18636
+ else {
18637
+ this._keyGetter = value;
18638
+ }
18639
+ }
18640
+ /**
18641
+ * The field name or a function that specify the columns key.
18642
+ */
18643
+ set columnKey(value) {
18644
+ if (isString(value)) {
18645
+ this._columnKeyGetter = getter(String(value));
18646
+ }
18647
+ else if (value) {
18648
+ this._columnKeyGetter = value;
18649
+ }
18650
+ }
18651
+ get keyGetter() {
18652
+ return this._keyGetter || this.treelist.idGetter;
18653
+ }
18654
+ get columnKeyGetter() {
18655
+ return this._columnKeyGetter || defaultColumnKeyGetter;
18656
+ }
18657
+ subscriptions;
18658
+ state = new RowSelectionState();
18659
+ _settings;
18660
+ lastChange;
18661
+ _columnKeyGetter;
18662
+ _keyGetter;
18663
+ _selectedItems = [];
18664
+ constructor(treelist, selectionService) {
18665
+ this.treelist = treelist;
18666
+ this.selectionService = selectionService;
18667
+ this.cellSelected = this.cellSelected.bind(this);
18668
+ this.rowSelected = this.rowSelected.bind(this);
18669
+ this.selectionChange = this.selectionChange.bind(this);
18670
+ this.updateColumnIndices = this.updateColumnIndices.bind(this);
18671
+ this.treelist.selectable = this.selectable = true;
18672
+ }
18673
+ ngOnDestroy() {
18674
+ this.unsubscribeSelection();
18675
+ }
18676
+ /**
18677
+ * @hidden
18678
+ */
18679
+ cellSelected(dataItem, column, columnIndex) {
18680
+ return this.state.has(this.keyGetter(dataItem), this.columnKeyGetter(column, columnIndex));
18681
+ }
18682
+ /**
18683
+ * @hidden
18684
+ */
18685
+ rowSelected(dataItem) {
18686
+ return this.state.has(this.keyGetter(dataItem));
18687
+ }
18688
+ selectionChange({ action, items }) {
18689
+ if (action === 'select' || action === 'add') {
18690
+ if (action === 'select') {
18691
+ this.state.clear();
18692
+ }
18693
+ items.forEach(item => {
18694
+ this.state.add(this.keyGetter(item.dataItem), this.columnKeyGetter(item.column, item.columnIndex));
18695
+ });
18696
+ }
18697
+ else {
18698
+ items.forEach(item => {
18699
+ this.state.remove(this.keyGetter(item.dataItem), this.columnKeyGetter(item.column, item.columnIndex));
18700
+ });
18701
+ }
18702
+ this.emitSelectedItemsChange();
18703
+ }
18704
+ emitSelectedItemsChange() {
18705
+ this.selectionService.state = this.lastChange = this.state.toArray();
18706
+ this.selectedItemsChange.emit(this.lastChange);
18707
+ }
18708
+ subscribeSelection() {
18709
+ this.unsubscribeSelection();
18710
+ this.subscriptions = this.treelist.selectionChange.subscribe(this.selectionChange);
18711
+ if (this._settings.mode === 'cell') {
18712
+ this.subscriptions.add(this.treelist.columnOrderChange.subscribe(this.updateColumnIndices));
18713
+ this.subscriptions.add(this.treelist.columnLockedChange.subscribe(this.updateColumnIndices));
18714
+ }
18715
+ }
18716
+ unsubscribeSelection() {
18717
+ if (this.subscriptions) {
18718
+ this.subscriptions.unsubscribe();
18719
+ this.subscriptions = null;
18720
+ }
18721
+ }
18722
+ updateColumnIndices() {
18723
+ if (!this._columnKeyGetter) {
18724
+ const changes = new Map();
18725
+ const currentIndices = [];
18726
+ this.leafColumns.forEach((column) => {
18727
+ currentIndices.push(column);
18728
+ });
18729
+ this.treelist.columnsContainer.refresh();
18730
+ const leafColumns = this.leafColumns;
18731
+ currentIndices.forEach((column, index) => {
18732
+ if (column !== leafColumns[index]) {
18733
+ changes.set(index, leafColumns.indexOf(column));
18734
+ }
18735
+ });
18736
+ if (changes.size && this.state.updateColumKeys(changes)) {
18737
+ this.emitSelectedItemsChange();
18738
+ }
18739
+ }
18740
+ }
18741
+ get leafColumns() {
18742
+ return this.treelist.lockedLeafColumns.toArray().concat(this.treelist.nonLockedLeafColumns.toArray());
18743
+ }
18744
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SelectableDirective, deps: [{ token: TreeListComponent }, { token: SelectionService }], target: i0.ɵɵFactoryTarget.Directive });
18745
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SelectableDirective, isStandalone: true, selector: "[kendoTreeListSelectable]", inputs: { selectable: "selectable", selectedItems: "selectedItems", itemKey: "itemKey", columnKey: "columnKey" }, outputs: { selectedItemsChange: "selectedItemsChange" }, exportAs: ["kendoTreeListSelectable"], ngImport: i0 });
18746
+ }
18747
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SelectableDirective, decorators: [{
18748
+ type: Directive,
18749
+ args: [{
18750
+ exportAs: 'kendoTreeListSelectable',
18751
+ selector: '[kendoTreeListSelectable]',
18752
+ standalone: true
18753
+ }]
18754
+ }], ctorParameters: function () { return [{ type: TreeListComponent }, { type: SelectionService }]; }, propDecorators: { selectable: [{
18755
+ type: Input
18756
+ }], selectedItems: [{
18757
+ type: Input
18758
+ }], selectedItemsChange: [{
18759
+ type: Output
18760
+ }], itemKey: [{
18761
+ type: Input
18762
+ }], columnKey: [{
18763
+ type: Input
18764
+ }] } });
18765
+
18753
18766
  /**
18754
18767
  * Represents the Kendo UI TreeListSpacer component for Angular.
18755
18768
  * Used to give additional white space between the Pager inner elements,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progress/kendo-angular-treelist",
3
- "version": "17.0.2-develop.7",
3
+ "version": "17.0.2-develop.9",
4
4
  "description": "Kendo UI TreeList for Angular - Display hierarchical data in an Angular tree grid view that supports sorting, filtering, paging, and much more.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "Progress",
@@ -31,26 +31,26 @@
31
31
  "@progress/kendo-data-query": "^1.0.0",
32
32
  "@progress/kendo-drawing": "^1.21.0",
33
33
  "@progress/kendo-licensing": "^1.0.2",
34
- "@progress/kendo-angular-buttons": "17.0.2-develop.7",
35
- "@progress/kendo-angular-common": "17.0.2-develop.7",
36
- "@progress/kendo-angular-dateinputs": "17.0.2-develop.7",
37
- "@progress/kendo-angular-dropdowns": "17.0.2-develop.7",
38
- "@progress/kendo-angular-excel-export": "17.0.2-develop.7",
39
- "@progress/kendo-angular-icons": "17.0.2-develop.7",
40
- "@progress/kendo-angular-inputs": "17.0.2-develop.7",
41
- "@progress/kendo-angular-intl": "17.0.2-develop.7",
42
- "@progress/kendo-angular-l10n": "17.0.2-develop.7",
43
- "@progress/kendo-angular-label": "17.0.2-develop.7",
44
- "@progress/kendo-angular-pager": "17.0.2-develop.7",
45
- "@progress/kendo-angular-pdf-export": "17.0.2-develop.7",
46
- "@progress/kendo-angular-popup": "17.0.2-develop.7",
47
- "@progress/kendo-angular-toolbar": "17.0.2-develop.7",
48
- "@progress/kendo-angular-utils": "17.0.2-develop.7",
34
+ "@progress/kendo-angular-buttons": "17.0.2-develop.9",
35
+ "@progress/kendo-angular-common": "17.0.2-develop.9",
36
+ "@progress/kendo-angular-dateinputs": "17.0.2-develop.9",
37
+ "@progress/kendo-angular-dropdowns": "17.0.2-develop.9",
38
+ "@progress/kendo-angular-excel-export": "17.0.2-develop.9",
39
+ "@progress/kendo-angular-icons": "17.0.2-develop.9",
40
+ "@progress/kendo-angular-inputs": "17.0.2-develop.9",
41
+ "@progress/kendo-angular-intl": "17.0.2-develop.9",
42
+ "@progress/kendo-angular-l10n": "17.0.2-develop.9",
43
+ "@progress/kendo-angular-label": "17.0.2-develop.9",
44
+ "@progress/kendo-angular-pager": "17.0.2-develop.9",
45
+ "@progress/kendo-angular-pdf-export": "17.0.2-develop.9",
46
+ "@progress/kendo-angular-popup": "17.0.2-develop.9",
47
+ "@progress/kendo-angular-toolbar": "17.0.2-develop.9",
48
+ "@progress/kendo-angular-utils": "17.0.2-develop.9",
49
49
  "rxjs": "^6.5.3 || ^7.0.0"
50
50
  },
51
51
  "dependencies": {
52
52
  "tslib": "^2.3.1",
53
- "@progress/kendo-angular-schematics": "17.0.2-develop.7",
53
+ "@progress/kendo-angular-schematics": "17.0.2-develop.9",
54
54
  "@progress/kendo-common": "^1.0.1",
55
55
  "@progress/kendo-file-saver": "^1.0.0"
56
56
  },
@@ -2,10 +2,9 @@
2
2
  * Copyright © 2024 Progress Software Corporation. All rights reserved.
3
3
  * Licensed under commercial license. See LICENSE.md in the project root for more information
4
4
  *-------------------------------------------------------------------------------------------*/
5
- import { ChangeDetectorRef, ElementRef, NgZone, OnDestroy, Renderer2 } from '@angular/core';
5
+ import { ChangeDetectorRef, ElementRef, OnDestroy, Renderer2 } from '@angular/core';
6
6
  import { CheckBoxComponent } from '@progress/kendo-angular-inputs';
7
7
  import { SelectionService } from '../../selection/selection.service';
8
- import { SelectableDirective } from '../../selection/selectable.directive';
9
8
  import * as i0 from "@angular/core";
10
9
  /**
11
10
  * @hidden
@@ -13,7 +12,7 @@ import * as i0 from "@angular/core";
13
12
  export declare class TreeListSelectAllCheckboxDirective implements OnDestroy {
14
13
  private sub;
15
14
  private setState;
16
- constructor(host: CheckBoxComponent, hostEl: ElementRef, selectionService: SelectionService, selectableDirective: SelectableDirective, cdr: ChangeDetectorRef, zone: NgZone, renderer: Renderer2);
15
+ constructor(host: CheckBoxComponent, hostEl: ElementRef, selectionService: SelectionService, cdr: ChangeDetectorRef, renderer: Renderer2);
17
16
  ngOnDestroy(): void;
18
17
  static ɵfac: i0.ɵɵFactoryDeclaration<TreeListSelectAllCheckboxDirective, never>;
19
18
  static ɵdir: i0.ɵɵDirectiveDeclaration<TreeListSelectAllCheckboxDirective, "[kendoTreeListSelectAllCheckbox]", never, {}, {}, never, never, true, never>;
@@ -4,13 +4,13 @@ const schematics_1 = require("@angular-devkit/schematics");
4
4
  function default_1(options) {
5
5
  const finalOptions = Object.assign(Object.assign({}, options), { mainNgModule: 'TreeListModule', package: 'treelist', peerDependencies: {
6
6
  // peer dep of the dropdowns
7
- '@progress/kendo-angular-treeview': '17.0.2-develop.7',
7
+ '@progress/kendo-angular-treeview': '17.0.2-develop.9',
8
8
  // peer dependency of kendo-angular-inputs
9
- '@progress/kendo-angular-dialog': '17.0.2-develop.7',
9
+ '@progress/kendo-angular-dialog': '17.0.2-develop.9',
10
10
  // peer dependency of kendo-angular-icons
11
11
  '@progress/kendo-svg-icons': '^4.0.0',
12
12
  // peer dependency of kendo-angular-dateinputs
13
- '@progress/kendo-angular-navigation': '17.0.2-develop.7',
13
+ '@progress/kendo-angular-navigation': '17.0.2-develop.9',
14
14
  } });
15
15
  return (0, schematics_1.externalSchematic)('@progress/kendo-angular-schematics', 'ng-add', finalOptions);
16
16
  }
@@ -4,6 +4,7 @@
4
4
  *-------------------------------------------------------------------------------------------*/
5
5
  import { OnDestroy, EventEmitter } from '@angular/core';
6
6
  import { TreeListComponent } from '../treelist.component';
7
+ import { SelectionService } from './selection.service';
7
8
  import * as i0 from "@angular/core";
8
9
  /**
9
10
  * The [`kendoTreeListSelectable`](slug:api_treelist_selectabledirective) state items.
@@ -23,6 +24,7 @@ export interface SelectionItem {
23
24
  */
24
25
  export declare class SelectableDirective implements OnDestroy {
25
26
  private treelist;
27
+ private selectionService;
26
28
  /**
27
29
  * @hidden
28
30
  */
@@ -43,10 +45,6 @@ export declare class SelectableDirective implements OnDestroy {
43
45
  * The field name or a function that specify the columns key.
44
46
  */
45
47
  set columnKey(value: string | ((column: any, columnIndex: number) => any));
46
- /**
47
- * @hidden
48
- */
49
- get stateArray(): any[];
50
48
  protected get keyGetter(): any;
51
49
  protected get columnKeyGetter(): any;
52
50
  protected subscriptions: any;
@@ -56,7 +54,7 @@ export declare class SelectableDirective implements OnDestroy {
56
54
  protected _columnKeyGetter: any;
57
55
  protected _keyGetter: any;
58
56
  private _selectedItems;
59
- constructor(treelist: TreeListComponent);
57
+ constructor(treelist: TreeListComponent, selectionService: SelectionService);
60
58
  ngOnDestroy(): void;
61
59
  /**
62
60
  * @hidden
@@ -14,6 +14,7 @@ export declare const defaultSelected: (_item: any) => boolean;
14
14
  */
15
15
  export declare class SelectionService {
16
16
  changes: Subject<SelectionChangeEvent>;
17
+ state: any[];
17
18
  set settings(value: any);
18
19
  get settings(): any;
19
20
  get enableMarquee(): boolean;