@progress/kendo-angular-grid 19.2.0-develop.10 → 19.2.0-develop.12

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.
@@ -21214,8 +21214,8 @@ const packageMetadata = {
21214
21214
  productName: 'Kendo UI for Angular',
21215
21215
  productCode: 'KENDOUIANGULAR',
21216
21216
  productCodes: ['KENDOUIANGULAR'],
21217
- publishDate: 1751281289,
21218
- version: '19.2.0-develop.10',
21217
+ publishDate: 1751375460,
21218
+ version: '19.2.0-develop.12',
21219
21219
  licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
21220
21220
  };
21221
21221
 
@@ -27645,538 +27645,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
27645
27645
  args: [GroupToolbarToolComponent]
27646
27646
  }] } });
27647
27647
 
27648
- /**
27649
- * A directive that handles in-memory data operations like [paging]({% slug paging_grid %}),
27650
- * [sorting]({% slug sorting_grid %}), and [grouping]({% slug grouping_grid %}).
27651
- *
27652
- * Use this directive with local data and enable the Grid data operations with minimal configuration.
27653
- * ([More information and examples]({% slug local_data_grid %}#toc-using-the-data-binding-directive)).
27654
- *
27655
- * @example
27656
- * ```html
27657
- * <kendo-grid [kendoGridBinding]="gridData"></kendo-grid>
27658
- * ```
27659
- * @remarks
27660
- * Applied to: {@link GridComponent}.
27661
- */
27662
- class DataBindingDirective {
27663
- grid;
27664
- changeDetector;
27665
- localDataChangesService;
27666
- rowReorderService;
27667
- /**
27668
- * Sets the number of records to skip in the Grid.
27669
- *
27670
- * @default 0
27671
- */
27672
- set skip(value) {
27673
- if (!isPresent(value)) {
27674
- value = 0;
27675
- }
27676
- this.grid.skip = this.state.skip = value;
27677
- if (this.rowReorderService) {
27678
- this.rowReorderService.skip = value;
27679
- }
27680
- }
27681
- /**
27682
- * Sets the sort descriptors for the Grid data.
27683
- *
27684
- */
27685
- set sort(value) {
27686
- this.grid.sort = this.state.sort = value;
27687
- }
27688
- /**
27689
- * Sets the filter descriptor for the Grid data.
27690
- *
27691
- */
27692
- set filter(value) {
27693
- this.grid.filter = this.state.filter = value;
27694
- }
27695
- /**
27696
- * Sets the page size for the Grid pager.
27697
- *
27698
- */
27699
- set pageSize(value) {
27700
- this.grid.pageSize = this.state.take = value;
27701
- }
27702
- /**
27703
- * Sets the group descriptors for the Grid data.
27704
- *
27705
- */
27706
- set group(value) {
27707
- this.grid.group = this.state.group = value;
27708
- }
27709
- /**
27710
- * Sets the data array for the Grid.
27711
- *
27712
- */
27713
- set data(value) {
27714
- this.originalData = value || [];
27715
- if (this.localDataChangesService) {
27716
- this.localDataChangesService.data = value;
27717
- }
27718
- this.dataChanged = true;
27719
- }
27720
- state = {
27721
- skip: 0
27722
- };
27723
- originalData = [];
27724
- dataChanged;
27725
- stateChangeSubscription;
27726
- dataChangedSubscription;
27727
- rowReorderSubscription;
27728
- constructor(grid, changeDetector, localDataChangesService, rowReorderService, ctx) {
27729
- this.grid = grid;
27730
- this.changeDetector = changeDetector;
27731
- this.localDataChangesService = localDataChangesService;
27732
- this.rowReorderService = rowReorderService;
27733
- if (localDataChangesService) {
27734
- this.dataChangedSubscription = this.localDataChangesService.changes.subscribe(this.rebind.bind(this));
27735
- }
27736
- ctx && (ctx.dataBindingDirective = this);
27737
- }
27738
- /**
27739
- * @hidden
27740
- */
27741
- ngOnInit() {
27742
- this.applyState(this.state);
27743
- this.stateChangeSubscription = this.grid
27744
- .dataStateChange
27745
- .subscribe(this.onStateChange.bind(this));
27746
- if (this.rowReorderService) {
27747
- this.rowReorderSubscription = this.grid
27748
- .rowReorder
27749
- .subscribe(this.onRowReorder.bind(this));
27750
- }
27751
- }
27752
- /**
27753
- * @hidden
27754
- */
27755
- ngOnDestroy() {
27756
- if (this.stateChangeSubscription) {
27757
- this.stateChangeSubscription.unsubscribe();
27758
- }
27759
- if (this.dataChangedSubscription) {
27760
- this.dataChangedSubscription.unsubscribe();
27761
- }
27762
- if (this.rowReorderSubscription) {
27763
- this.rowReorderSubscription.unsubscribe();
27764
- }
27765
- }
27766
- /**
27767
- * @hidden
27768
- */
27769
- ngOnChanges(changes) {
27770
- if (anyChanged(["pageSize", "skip", "sort", "group", "filter"], changes)) {
27771
- this.rebind();
27772
- }
27773
- }
27774
- ngDoCheck() {
27775
- if (this.dataChanged) {
27776
- this.updateGridData();
27777
- }
27778
- }
27779
- /**
27780
- * @hidden
27781
- */
27782
- onStateChange(state) {
27783
- this.applyState(state);
27784
- this.rebind();
27785
- }
27786
- /**
27787
- * @hidden
27788
- */
27789
- onRowReorder(ev) {
27790
- this.rowReorderService.reorderRows(ev, this.originalData);
27791
- this.rebind();
27792
- }
27793
- /**
27794
- * @hidden
27795
- */
27796
- rebind() {
27797
- this.data = this.originalData;
27798
- this.updateGridData();
27799
- this.notifyDataChange();
27800
- }
27801
- /**
27802
- * Notifies the Grid that its data has changed.
27803
- */
27804
- notifyDataChange() {
27805
- this.grid.onDataChange();
27806
- if (this.changeDetector) {
27807
- this.changeDetector.markForCheck();
27808
- }
27809
- }
27810
- process(state) {
27811
- if (this.grid.isVirtual && (!isPresent(state.take) || state.take === 0)) {
27812
- return {
27813
- data: [],
27814
- total: this.originalData?.length || 0
27815
- };
27816
- }
27817
- return process(this.originalData, state);
27818
- }
27819
- applyState({ skip, take, sort, group, filter }) {
27820
- this.skip = skip;
27821
- this.pageSize = take;
27822
- this.sort = sort;
27823
- this.group = group;
27824
- this.filter = filter;
27825
- }
27826
- updateGridData() {
27827
- this.grid.data = this.process(this.state);
27828
- this.grid.updateNavigationMetadata();
27829
- this.dataChanged = false;
27830
- }
27831
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataBindingDirective, deps: [{ token: GridComponent }, { token: i0.ChangeDetectorRef }, { token: LocalDataChangesService }, { token: RowReorderService }, { token: ContextService }], target: i0.ɵɵFactoryTarget.Directive });
27832
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: DataBindingDirective, isStandalone: true, selector: "[kendoGridBinding]", inputs: { skip: "skip", sort: "sort", filter: "filter", pageSize: "pageSize", group: "group", data: ["kendoGridBinding", "data"] }, exportAs: ["kendoGridBinding"], usesOnChanges: true, ngImport: i0 });
27833
- }
27834
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataBindingDirective, decorators: [{
27835
- type: Directive,
27836
- args: [{
27837
- selector: '[kendoGridBinding]',
27838
- exportAs: 'kendoGridBinding',
27839
- standalone: true
27840
- }]
27841
- }], ctorParameters: function () { return [{ type: GridComponent }, { type: i0.ChangeDetectorRef }, { type: LocalDataChangesService }, { type: RowReorderService }, { type: ContextService }]; }, propDecorators: { skip: [{
27842
- type: Input
27843
- }], sort: [{
27844
- type: Input
27845
- }], filter: [{
27846
- type: Input
27847
- }], pageSize: [{
27848
- type: Input
27849
- }], group: [{
27850
- type: Input
27851
- }], data: [{
27852
- type: Input,
27853
- args: ["kendoGridBinding"]
27854
- }] } });
27855
-
27856
- const hasGroups = (items) => items && items.length && items[0].field && items[0].items;
27857
- const groupDescriptorsPresent = (descriptors) => isPresent(descriptors) && descriptors.length > 0;
27858
- const processGroups = (data, state) => process(data, state).data;
27859
- const removeParentDescriptors = (parents, owner) => g => g.field !== owner.field && !parents.some(y => y.field === g.field);
27860
- const findGroup = (groupIndex, groups) => {
27861
- const parents = [];
27862
- return {
27863
- group: groupIndex.split("_").reduce((acc, x) => {
27864
- const idx = parseInt(x, 10);
27865
- if (acc.items) {
27866
- parents.push(acc);
27867
- return acc.items[idx];
27868
- }
27869
- return isArray(acc) ? acc[idx] : acc;
27870
- }, groups),
27871
- parents
27872
- };
27873
- };
27874
- const findChildren = (data, parents) => {
27875
- const filters = parents.map(p => ({ field: p.field, operator: "eq", value: p.value }));
27876
- return filterBy(data, {
27877
- filters: filters,
27878
- logic: "and"
27879
- });
27880
- };
27881
- /**
27882
- * @hidden
27883
- */
27884
- const count = (groups, includeFooters = false) => (groups.reduce((acc, group) => {
27885
- if (!group.skipHeader) {
27886
- acc++;
27887
- }
27888
- if (group.items) {
27889
- const children = count(group.items, includeFooters);
27890
- if (includeFooters && children && !group.hideFooter) {
27891
- acc++;
27892
- }
27893
- acc += children;
27894
- }
27895
- return acc;
27896
- }, 0));
27897
- /**
27898
- * @hidden
27899
- */
27900
- const noDescriptors = (descriptors) => !isPresent(descriptors) || !descriptors.length;
27901
- /**
27902
- * @hidden
27903
- */
27904
- const slice = (groups, skip, take, includeFooters = false) => {
27905
- if (!isPresent(take)) {
27906
- return groups;
27907
- }
27908
- const result = [];
27909
- for (let idx = 0, length = groups.length; idx < length; idx++) {
27910
- if (take <= 0) {
27911
- break;
27912
- }
27913
- const group = groups[idx];
27914
- const groupItems = group.items;
27915
- let itemCount = count(groupItems, includeFooters);
27916
- if (includeFooters && groupItems.length) {
27917
- itemCount++;
27918
- }
27919
- const skipHeader = skip > 0;
27920
- if (skip) {
27921
- skip--;
27922
- if (itemCount && skip >= itemCount) {
27923
- skip -= itemCount;
27924
- continue;
27925
- }
27926
- }
27927
- if (!skipHeader || itemCount) {
27928
- const items = [];
27929
- let hideFooter = true;
27930
- if (!skipHeader) {
27931
- take--;
27932
- }
27933
- if (take) {
27934
- if (hasGroups(groupItems)) {
27935
- const children = slice(groupItems, skip, take, includeFooters);
27936
- items.push(...children);
27937
- take -= count(children, includeFooters);
27938
- }
27939
- else {
27940
- items.push(...groupItems.slice(skip, Math.min(skip + take, groupItems.length)));
27941
- take -= items.length;
27942
- }
27943
- if (take && includeFooters) {
27944
- hideFooter = false;
27945
- take--;
27946
- }
27947
- skip = 0;
27948
- }
27949
- result.push({
27950
- aggregates: group.aggregates,
27951
- field: group.field,
27952
- hideFooter,
27953
- items,
27954
- offset: idx,
27955
- skipHeader,
27956
- value: group.value
27957
- });
27958
- }
27959
- }
27960
- return result;
27961
- };
27962
- const skippedHeaders = (groupItem) => {
27963
- let total = 0;
27964
- while (groupItem) {
27965
- if (groupItem.skipHeader) {
27966
- total++;
27967
- }
27968
- groupItem = groupItem.items && groupItem.items[0] || null;
27969
- }
27970
- return total;
27971
- };
27972
- /**
27973
- * A directive which encapsulates the in-memory handling of grouping with virtual scrolling.
27974
- * @remarks
27975
- * Applied to: {@link GridComponent}.
27976
- */
27977
- class GroupBindingDirective extends DataBindingDirective {
27978
- groupsService;
27979
- /**
27980
- * The array of data which will be used to populate the Grid.
27981
- */
27982
- set kendoGridGroupBinding(value) {
27983
- this.groups = null;
27984
- this.grid.resetGroupsState();
27985
- this.data = value;
27986
- }
27987
- /**
27988
- * @hidden
27989
- */
27990
- set data(value) {
27991
- this.originalData = value || [];
27992
- this.dataChanged = true;
27993
- }
27994
- /**
27995
- * Defines the descriptors by which the data will be sorted.
27996
- */
27997
- set sort(value) {
27998
- const noCurrentDescriptors = noDescriptors(this.state.sort);
27999
- const noIncomingDescriptors = noDescriptors(value);
28000
- const clear = this.state.sort !== value && !(noCurrentDescriptors && noIncomingDescriptors);
28001
- this.grid.sort = this.state.sort = value;
28002
- if (clear) {
28003
- this.groups = null;
28004
- this.grid.resetGroupsState();
28005
- }
28006
- }
28007
- /**
28008
- * Defines the descriptor by which the data will be filtered.
28009
- */
28010
- set filter(value) {
28011
- const clear = diffFilters(this.state.filter, value);
28012
- if (clear) {
28013
- this.state.filter = value;
28014
- this.grid.filter = cloneFilters(value);
28015
- this.groups = null;
28016
- this.grid.resetGroupsState();
28017
- }
28018
- }
28019
- /**
28020
- * Defines the descriptors by which the data will be grouped.
28021
- */
28022
- set group(value) {
28023
- // don't clear if no groups are present in previous and current value
28024
- const groupsPresent = groupDescriptorsPresent(this.state.group) || groupDescriptorsPresent(value);
28025
- const clear = this.state.group !== value && groupsPresent;
28026
- this.grid.group = this.state.group = value;
28027
- if (clear) {
28028
- this.groups = null;
28029
- this.grid.resetGroupsState();
28030
- this.skip = 0;
28031
- }
28032
- }
28033
- groups;
28034
- gridSubs = new Subscription();
28035
- constructor(changeDetector, localDataChangesService, ctxService, groupsService) {
28036
- super(ctxService.grid, changeDetector, localDataChangesService, null, ctxService);
28037
- this.groupsService = groupsService;
28038
- ctxService.dataBindingDirective = this;
28039
- }
28040
- ngOnInit() {
28041
- super.ngOnInit();
28042
- this.gridSubs.add(this.grid.groupExpand.subscribe(this.groupExpand.bind(this)));
28043
- this.gridSubs.add(this.grid.groupCollapse.subscribe(this.groupCollapse.bind(this)));
28044
- }
28045
- ngAfterContentInit() {
28046
- if (isDevMode() && this.grid.isGroupExpanded) {
28047
- throw new Error(GridConfigurationErrorMessages.groupBindingDirectives);
28048
- }
28049
- }
28050
- ngOnDestroy() {
28051
- this.gridSubs.unsubscribe();
28052
- }
28053
- /**
28054
- * @hidden
28055
- */
28056
- toggleAll(expand) {
28057
- this.skip = 0;
28058
- this.grid.scrollTo({ row: 0, column: 0 });
28059
- this.groups.forEach((gr, idx) => {
28060
- const expanded = this.groupsService.isExpanded({
28061
- group: gr,
28062
- groupIndex: idx.toString(),
28063
- parentGroup: undefined
28064
- });
28065
- const performToggle = (expand && !expanded) || (!expand && expanded);
28066
- if (performToggle) {
28067
- this.grid.groupsService.toggleRow({
28068
- type: 'group',
28069
- data: gr,
28070
- index: idx.toString(),
28071
- level: 0,
28072
- parentGroup: undefined
28073
- });
28074
- this[expand ? 'groupExpand' : 'groupCollapse']({ groupIndex: idx.toString() });
28075
- }
28076
- });
28077
- }
28078
- /**
28079
- * Collapses all expanded root level groups.
28080
- */
28081
- collapseAll() {
28082
- this.toggleAll(false);
28083
- }
28084
- /**
28085
- * Expands all expanded root level groups.
28086
- */
28087
- expandAll() {
28088
- this.toggleAll(true);
28089
- }
28090
- /**
28091
- * @hidden
28092
- */
28093
- groupExpand({ groupIndex }) {
28094
- const { group, parents } = findGroup(groupIndex, this.groups);
28095
- if (!group) {
28096
- return;
28097
- }
28098
- this.groupsService.expandChildren(groupIndex);
28099
- if (!group.items.length) {
28100
- const descriptors = this.state.group.filter(removeParentDescriptors(parents, group));
28101
- const children = findChildren(this.originalData, parents.concat(group));
28102
- group.items = processGroups(children, {
28103
- filter: this.state.filter,
28104
- group: descriptors,
28105
- sort: this.state.sort
28106
- });
28107
- }
28108
- this.grid.data = this.dataResult(this.state.skip, this.state.take);
28109
- }
28110
- /**
28111
- * @hidden
28112
- */
28113
- groupCollapse({ groupIndex }) {
28114
- const { group } = findGroup(groupIndex, this.groups);
28115
- if (group) {
28116
- group.items = [];
28117
- }
28118
- else {
28119
- return;
28120
- }
28121
- this.grid.data = this.dataResult(this.state.skip, this.state.take);
28122
- }
28123
- process(state) {
28124
- if (state.group && state.group.length) {
28125
- const groups = this.processGroups(state);
28126
- this.grid.skip -= skippedHeaders(groups.data[0]);
28127
- return groups;
28128
- }
28129
- else {
28130
- this.groups = null;
28131
- }
28132
- return super.process(state);
28133
- }
28134
- processGroups(state) {
28135
- if (!this.groups || !this.groups.length) {
28136
- this.groups = processGroups(this.originalData, {
28137
- filter: state.filter,
28138
- group: state.group,
28139
- sort: state.sort
28140
- });
28141
- }
28142
- return this.dataResult(state.skip, state.take);
28143
- }
28144
- dataResult(skip, take) {
28145
- const includeFooters = this.grid.showGroupFooters;
28146
- return {
28147
- data: slice(this.groups, skip, take, includeFooters),
28148
- total: count(this.groups, includeFooters)
28149
- };
28150
- }
28151
- applyState({ skip, take, sort, group, filter }) {
28152
- this.skip = skip;
28153
- this.state.take = take;
28154
- // this.pageSize = take; // do need to update take as the process with slice correctly
28155
- this.sort = sort;
28156
- this.group = group;
28157
- this.filter = filter;
28158
- }
28159
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GroupBindingDirective, deps: [{ token: i0.ChangeDetectorRef }, { token: LocalDataChangesService }, { token: ContextService }, { token: GroupsService }], target: i0.ɵɵFactoryTarget.Directive });
28160
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: GroupBindingDirective, isStandalone: true, selector: "[kendoGridGroupBinding]", inputs: { kendoGridGroupBinding: "kendoGridGroupBinding", sort: "sort", filter: "filter", group: "group" }, exportAs: ["kendoGridGroupBinding"], usesInheritance: true, ngImport: i0 });
28161
- }
28162
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GroupBindingDirective, decorators: [{
28163
- type: Directive,
28164
- args: [{
28165
- selector: '[kendoGridGroupBinding]',
28166
- exportAs: 'kendoGridGroupBinding',
28167
- standalone: true
28168
- }]
28169
- }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: LocalDataChangesService }, { type: ContextService }, { type: GroupsService }]; }, propDecorators: { kendoGridGroupBinding: [{
28170
- type: Input,
28171
- args: ["kendoGridGroupBinding"]
28172
- }], sort: [{
28173
- type: Input
28174
- }], filter: [{
28175
- type: Input
28176
- }], group: [{
28177
- type: Input
28178
- }] } });
28179
-
28180
27648
  const createControl = (source) => (acc, key) => {
28181
27649
  acc[key] = new FormControl(source[key]);
28182
27650
  return acc;
@@ -30353,7 +29821,7 @@ class GridComponent {
30353
29821
  }
30354
29822
  if (this.groupsService.isExpanded({ groupIndex: index }) !== expand) {
30355
29823
  this.groupsService.toggleRow({ index }, false);
30356
- if (this.ctx.dataBindingDirective && this.ctx.dataBindingDirective instanceof GroupBindingDirective) {
29824
+ if (this.ctx.dataBindingDirective && isPresent(this.ctx.dataBindingDirective.groupExpand)) {
30357
29825
  this.ctx.dataBindingDirective[`group${expand ? 'Expand' : 'Collapse'}`]({ groupIndex: index });
30358
29826
  }
30359
29827
  }
@@ -32293,7 +31761,215 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
32293
31761
  template: ``,
32294
31762
  standalone: true
32295
31763
  }]
32296
- }], ctorParameters: function () { return [{ type: i1$2.LocalizationService }]; } });
31764
+ }], ctorParameters: function () { return [{ type: i1$2.LocalizationService }]; } });
31765
+
31766
+ /**
31767
+ * A directive that handles in-memory data operations like [paging]({% slug paging_grid %}),
31768
+ * [sorting]({% slug sorting_grid %}), and [grouping]({% slug grouping_grid %}).
31769
+ *
31770
+ * Use this directive with local data and enable the Grid data operations with minimal configuration.
31771
+ * ([More information and examples]({% slug local_data_grid %}#toc-using-the-data-binding-directive)).
31772
+ *
31773
+ * @example
31774
+ * ```html
31775
+ * <kendo-grid [kendoGridBinding]="gridData"></kendo-grid>
31776
+ * ```
31777
+ * @remarks
31778
+ * Applied to: {@link GridComponent}.
31779
+ */
31780
+ class DataBindingDirective {
31781
+ grid;
31782
+ changeDetector;
31783
+ localDataChangesService;
31784
+ rowReorderService;
31785
+ /**
31786
+ * Sets the number of records to skip in the Grid.
31787
+ *
31788
+ * @default 0
31789
+ */
31790
+ set skip(value) {
31791
+ if (!isPresent(value)) {
31792
+ value = 0;
31793
+ }
31794
+ this.grid.skip = this.state.skip = value;
31795
+ if (this.rowReorderService) {
31796
+ this.rowReorderService.skip = value;
31797
+ }
31798
+ }
31799
+ /**
31800
+ * Sets the sort descriptors for the Grid data.
31801
+ *
31802
+ */
31803
+ set sort(value) {
31804
+ this.grid.sort = this.state.sort = value;
31805
+ }
31806
+ /**
31807
+ * Sets the filter descriptor for the Grid data.
31808
+ *
31809
+ */
31810
+ set filter(value) {
31811
+ this.grid.filter = this.state.filter = value;
31812
+ }
31813
+ /**
31814
+ * Sets the page size for the Grid pager.
31815
+ *
31816
+ */
31817
+ set pageSize(value) {
31818
+ this.grid.pageSize = this.state.take = value;
31819
+ }
31820
+ /**
31821
+ * Sets the group descriptors for the Grid data.
31822
+ *
31823
+ */
31824
+ set group(value) {
31825
+ this.grid.group = this.state.group = value;
31826
+ }
31827
+ /**
31828
+ * Sets the data array for the Grid.
31829
+ *
31830
+ */
31831
+ set data(value) {
31832
+ this.originalData = value || [];
31833
+ if (this.localDataChangesService) {
31834
+ this.localDataChangesService.data = value;
31835
+ }
31836
+ this.dataChanged = true;
31837
+ }
31838
+ state = {
31839
+ skip: 0
31840
+ };
31841
+ originalData = [];
31842
+ dataChanged;
31843
+ stateChangeSubscription;
31844
+ dataChangedSubscription;
31845
+ rowReorderSubscription;
31846
+ constructor(grid, changeDetector, localDataChangesService, rowReorderService, ctx) {
31847
+ this.grid = grid;
31848
+ this.changeDetector = changeDetector;
31849
+ this.localDataChangesService = localDataChangesService;
31850
+ this.rowReorderService = rowReorderService;
31851
+ if (localDataChangesService) {
31852
+ this.dataChangedSubscription = this.localDataChangesService.changes.subscribe(this.rebind.bind(this));
31853
+ }
31854
+ ctx && (ctx.dataBindingDirective = this);
31855
+ }
31856
+ /**
31857
+ * @hidden
31858
+ */
31859
+ ngOnInit() {
31860
+ this.applyState(this.state);
31861
+ this.stateChangeSubscription = this.grid
31862
+ .dataStateChange
31863
+ .subscribe(this.onStateChange.bind(this));
31864
+ if (this.rowReorderService) {
31865
+ this.rowReorderSubscription = this.grid
31866
+ .rowReorder
31867
+ .subscribe(this.onRowReorder.bind(this));
31868
+ }
31869
+ }
31870
+ /**
31871
+ * @hidden
31872
+ */
31873
+ ngOnDestroy() {
31874
+ if (this.stateChangeSubscription) {
31875
+ this.stateChangeSubscription.unsubscribe();
31876
+ }
31877
+ if (this.dataChangedSubscription) {
31878
+ this.dataChangedSubscription.unsubscribe();
31879
+ }
31880
+ if (this.rowReorderSubscription) {
31881
+ this.rowReorderSubscription.unsubscribe();
31882
+ }
31883
+ }
31884
+ /**
31885
+ * @hidden
31886
+ */
31887
+ ngOnChanges(changes) {
31888
+ if (anyChanged(["pageSize", "skip", "sort", "group", "filter"], changes)) {
31889
+ this.rebind();
31890
+ }
31891
+ }
31892
+ ngDoCheck() {
31893
+ if (this.dataChanged) {
31894
+ this.updateGridData();
31895
+ }
31896
+ }
31897
+ /**
31898
+ * @hidden
31899
+ */
31900
+ onStateChange(state) {
31901
+ this.applyState(state);
31902
+ this.rebind();
31903
+ }
31904
+ /**
31905
+ * @hidden
31906
+ */
31907
+ onRowReorder(ev) {
31908
+ this.rowReorderService.reorderRows(ev, this.originalData);
31909
+ this.rebind();
31910
+ }
31911
+ /**
31912
+ * @hidden
31913
+ */
31914
+ rebind() {
31915
+ this.data = this.originalData;
31916
+ this.updateGridData();
31917
+ this.notifyDataChange();
31918
+ }
31919
+ /**
31920
+ * Notifies the Grid that its data has changed.
31921
+ */
31922
+ notifyDataChange() {
31923
+ this.grid.onDataChange();
31924
+ if (this.changeDetector) {
31925
+ this.changeDetector.markForCheck();
31926
+ }
31927
+ }
31928
+ process(state) {
31929
+ if (this.grid.isVirtual && (!isPresent(state.take) || state.take === 0)) {
31930
+ return {
31931
+ data: [],
31932
+ total: this.originalData?.length || 0
31933
+ };
31934
+ }
31935
+ return process(this.originalData, state);
31936
+ }
31937
+ applyState({ skip, take, sort, group, filter }) {
31938
+ this.skip = skip;
31939
+ this.pageSize = take;
31940
+ this.sort = sort;
31941
+ this.group = group;
31942
+ this.filter = filter;
31943
+ }
31944
+ updateGridData() {
31945
+ this.grid.data = this.process(this.state);
31946
+ this.grid.updateNavigationMetadata();
31947
+ this.dataChanged = false;
31948
+ }
31949
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataBindingDirective, deps: [{ token: GridComponent }, { token: i0.ChangeDetectorRef }, { token: LocalDataChangesService }, { token: RowReorderService }, { token: ContextService }], target: i0.ɵɵFactoryTarget.Directive });
31950
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: DataBindingDirective, isStandalone: true, selector: "[kendoGridBinding]", inputs: { skip: "skip", sort: "sort", filter: "filter", pageSize: "pageSize", group: "group", data: ["kendoGridBinding", "data"] }, exportAs: ["kendoGridBinding"], usesOnChanges: true, ngImport: i0 });
31951
+ }
31952
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DataBindingDirective, decorators: [{
31953
+ type: Directive,
31954
+ args: [{
31955
+ selector: '[kendoGridBinding]',
31956
+ exportAs: 'kendoGridBinding',
31957
+ standalone: true
31958
+ }]
31959
+ }], ctorParameters: function () { return [{ type: GridComponent }, { type: i0.ChangeDetectorRef }, { type: LocalDataChangesService }, { type: RowReorderService }, { type: ContextService }]; }, propDecorators: { skip: [{
31960
+ type: Input
31961
+ }], sort: [{
31962
+ type: Input
31963
+ }], filter: [{
31964
+ type: Input
31965
+ }], pageSize: [{
31966
+ type: Input
31967
+ }], group: [{
31968
+ type: Input
31969
+ }], data: [{
31970
+ type: Input,
31971
+ args: ["kendoGridBinding"]
31972
+ }] } });
32297
31973
 
32298
31974
  /**
32299
31975
  * Stores the row selection state of the Grid in memory
@@ -33086,114 +32762,438 @@ const DEFAULT_KEY_GETTER = (groupRowArgs) => ({
33086
32762
  class ExpandGroupDirective {
33087
32763
  grid;
33088
32764
  /**
33089
- * Fires when the `expandedGroupKeys` collection changes.
32765
+ * Fires when the `expandedGroupKeys` collection changes.
32766
+ */
32767
+ expandedGroupKeysChange = new EventEmitter();
32768
+ /**
32769
+ * Sets the item format stored in the `expandedGroupKeys` collection.
32770
+ * Accepts a property name or a function that returns a unique key for each group
32771
+ * ([see example]({% slug groups_expanded_state_grid %}#toc-custom-group-key-format)).
32772
+ */
32773
+ get expandGroupBy() {
32774
+ return this._expandGroupBy;
32775
+ }
32776
+ set expandGroupBy(key) {
32777
+ if (typeof key === 'function') {
32778
+ this._expandGroupBy = key;
32779
+ }
32780
+ }
32781
+ /**
32782
+ * Holds the collection of expanded group keys.
32783
+ * Set this property to control which group rows are expanded.
32784
+ */
32785
+ get expandedGroupKeys() {
32786
+ return this._expandedGroupKeys;
32787
+ }
32788
+ set expandedGroupKeys(expandedGroups) {
32789
+ this._expandedGroupKeys = (expandedGroups || []).slice();
32790
+ }
32791
+ /**
32792
+ * Specifies if group items are expanded by default.
32793
+ * @default false
32794
+ */
32795
+ groupsInitiallyExpanded = false;
32796
+ _expandGroupBy;
32797
+ _expandedGroupKeys;
32798
+ subscriptions = new Subscription();
32799
+ constructor(grid) {
32800
+ this.grid = grid;
32801
+ this.grid.isGroupExpanded = this.isExpanded.bind(this);
32802
+ this.subscriptions.add(merge(this.grid.groupExpand.pipe(map(e => ({ expand: true, ...e }))), this.grid.groupCollapse.pipe(map(e => ({ expand: false, ...e })))).subscribe(this.toggleState.bind(this)));
32803
+ }
32804
+ ngOnDestroy() {
32805
+ this.subscriptions.unsubscribe();
32806
+ }
32807
+ get keyGetter() {
32808
+ return this.expandGroupBy || DEFAULT_KEY_GETTER;
32809
+ }
32810
+ /**
32811
+ * @hidden
32812
+ */
32813
+ isExpanded(groupArgs) {
32814
+ const itemIndex = this.getItemIndex(groupArgs);
32815
+ return itemIndex > -1 ? !this.groupsInitiallyExpanded : this.groupsInitiallyExpanded;
32816
+ }
32817
+ getItemIndex(groupArgs) {
32818
+ if (this.expandGroupBy) {
32819
+ return this.expandedGroupKeys.indexOf(this.keyGetter(groupArgs));
32820
+ }
32821
+ return this.expandedGroupKeys.findIndex(item => {
32822
+ let index = 0;
32823
+ let parentGroup = groupArgs.parentGroup;
32824
+ while (isPresent(parentGroup)) {
32825
+ if (!isPresent(item.parentGroupKeys) || !isPresent(item.parentGroupKeys[index]) ||
32826
+ parentGroup.group.value !== item.parentGroupKeys[index].value ||
32827
+ parentGroup.group.field !== item.parentGroupKeys[index].field) {
32828
+ return false;
32829
+ }
32830
+ parentGroup = parentGroup.parentGroup;
32831
+ index++;
32832
+ }
32833
+ return item.value === groupArgs.group.value && item.field === groupArgs.group.field;
32834
+ });
32835
+ }
32836
+ toggleState(groupArgs) {
32837
+ const key = this.keyGetter(groupArgs);
32838
+ if (Boolean(this.groupsInitiallyExpanded) !== groupArgs.expand) {
32839
+ this.expandedGroupKeys.push(key);
32840
+ }
32841
+ else {
32842
+ const index = this.expandedGroupKeys.findIndex(group => {
32843
+ if (this.expandGroupBy) {
32844
+ return group === key;
32845
+ }
32846
+ else if (key.parentGroupKeys?.length === 0) {
32847
+ return group.value === key.value;
32848
+ }
32849
+ return JSON.stringify(group) === JSON.stringify(key);
32850
+ });
32851
+ this.expandedGroupKeys.splice(index, 1);
32852
+ }
32853
+ this.expandedGroupKeysChange.emit(this.expandedGroupKeys.slice());
32854
+ }
32855
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExpandGroupDirective, deps: [{ token: GridComponent }], target: i0.ɵɵFactoryTarget.Directive });
32856
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: ExpandGroupDirective, isStandalone: true, selector: "[kendoGridExpandGroupBy]", inputs: { expandGroupBy: ["kendoGridExpandGroupBy", "expandGroupBy"], expandedGroupKeys: "expandedGroupKeys", groupsInitiallyExpanded: "groupsInitiallyExpanded" }, outputs: { expandedGroupKeysChange: "expandedGroupKeysChange" }, exportAs: ["kendoGridExpandGroupBy"], ngImport: i0 });
32857
+ }
32858
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExpandGroupDirective, decorators: [{
32859
+ type: Directive,
32860
+ args: [{
32861
+ selector: '[kendoGridExpandGroupBy]',
32862
+ exportAs: 'kendoGridExpandGroupBy',
32863
+ standalone: true
32864
+ }]
32865
+ }], ctorParameters: function () { return [{ type: GridComponent }]; }, propDecorators: { expandedGroupKeysChange: [{
32866
+ type: Output
32867
+ }], expandGroupBy: [{
32868
+ type: Input,
32869
+ args: ['kendoGridExpandGroupBy']
32870
+ }], expandedGroupKeys: [{
32871
+ type: Input
32872
+ }], groupsInitiallyExpanded: [{
32873
+ type: Input
32874
+ }] } });
32875
+
32876
+ const hasGroups = (items) => items && items.length && items[0].field && items[0].items;
32877
+ const groupDescriptorsPresent = (descriptors) => isPresent(descriptors) && descriptors.length > 0;
32878
+ const processGroups = (data, state) => process(data, state).data;
32879
+ const removeParentDescriptors = (parents, owner) => g => g.field !== owner.field && !parents.some(y => y.field === g.field);
32880
+ const findGroup = (groupIndex, groups) => {
32881
+ const parents = [];
32882
+ return {
32883
+ group: groupIndex.split("_").reduce((acc, x) => {
32884
+ const idx = parseInt(x, 10);
32885
+ if (acc.items) {
32886
+ parents.push(acc);
32887
+ return acc.items[idx];
32888
+ }
32889
+ return isArray(acc) ? acc[idx] : acc;
32890
+ }, groups),
32891
+ parents
32892
+ };
32893
+ };
32894
+ const findChildren = (data, parents) => {
32895
+ const filters = parents.map(p => ({ field: p.field, operator: "eq", value: p.value }));
32896
+ return filterBy(data, {
32897
+ filters: filters,
32898
+ logic: "and"
32899
+ });
32900
+ };
32901
+ /**
32902
+ * @hidden
32903
+ */
32904
+ const count = (groups, includeFooters = false) => (groups.reduce((acc, group) => {
32905
+ if (!group.skipHeader) {
32906
+ acc++;
32907
+ }
32908
+ if (group.items) {
32909
+ const children = count(group.items, includeFooters);
32910
+ if (includeFooters && children && !group.hideFooter) {
32911
+ acc++;
32912
+ }
32913
+ acc += children;
32914
+ }
32915
+ return acc;
32916
+ }, 0));
32917
+ /**
32918
+ * @hidden
32919
+ */
32920
+ const noDescriptors = (descriptors) => !isPresent(descriptors) || !descriptors.length;
32921
+ /**
32922
+ * @hidden
32923
+ */
32924
+ const slice = (groups, skip, take, includeFooters = false) => {
32925
+ if (!isPresent(take)) {
32926
+ return groups;
32927
+ }
32928
+ const result = [];
32929
+ for (let idx = 0, length = groups.length; idx < length; idx++) {
32930
+ if (take <= 0) {
32931
+ break;
32932
+ }
32933
+ const group = groups[idx];
32934
+ const groupItems = group.items;
32935
+ let itemCount = count(groupItems, includeFooters);
32936
+ if (includeFooters && groupItems.length) {
32937
+ itemCount++;
32938
+ }
32939
+ const skipHeader = skip > 0;
32940
+ if (skip) {
32941
+ skip--;
32942
+ if (itemCount && skip >= itemCount) {
32943
+ skip -= itemCount;
32944
+ continue;
32945
+ }
32946
+ }
32947
+ if (!skipHeader || itemCount) {
32948
+ const items = [];
32949
+ let hideFooter = true;
32950
+ if (!skipHeader) {
32951
+ take--;
32952
+ }
32953
+ if (take) {
32954
+ if (hasGroups(groupItems)) {
32955
+ const children = slice(groupItems, skip, take, includeFooters);
32956
+ items.push(...children);
32957
+ take -= count(children, includeFooters);
32958
+ }
32959
+ else {
32960
+ items.push(...groupItems.slice(skip, Math.min(skip + take, groupItems.length)));
32961
+ take -= items.length;
32962
+ }
32963
+ if (take && includeFooters) {
32964
+ hideFooter = false;
32965
+ take--;
32966
+ }
32967
+ skip = 0;
32968
+ }
32969
+ result.push({
32970
+ aggregates: group.aggregates,
32971
+ field: group.field,
32972
+ hideFooter,
32973
+ items,
32974
+ offset: idx,
32975
+ skipHeader,
32976
+ value: group.value
32977
+ });
32978
+ }
32979
+ }
32980
+ return result;
32981
+ };
32982
+ const skippedHeaders = (groupItem) => {
32983
+ let total = 0;
32984
+ while (groupItem) {
32985
+ if (groupItem.skipHeader) {
32986
+ total++;
32987
+ }
32988
+ groupItem = groupItem.items && groupItem.items[0] || null;
32989
+ }
32990
+ return total;
32991
+ };
32992
+ /**
32993
+ * A directive which encapsulates the in-memory handling of grouping with virtual scrolling.
32994
+ * @remarks
32995
+ * Applied to: {@link GridComponent}.
32996
+ */
32997
+ class GroupBindingDirective extends DataBindingDirective {
32998
+ groupsService;
32999
+ /**
33000
+ * The array of data which will be used to populate the Grid.
33001
+ */
33002
+ set kendoGridGroupBinding(value) {
33003
+ this.groups = null;
33004
+ this.grid.resetGroupsState();
33005
+ this.data = value;
33006
+ }
33007
+ /**
33008
+ * @hidden
33090
33009
  */
33091
- expandedGroupKeysChange = new EventEmitter();
33010
+ set data(value) {
33011
+ this.originalData = value || [];
33012
+ this.dataChanged = true;
33013
+ }
33092
33014
  /**
33093
- * Sets the item format stored in the `expandedGroupKeys` collection.
33094
- * Accepts a property name or a function that returns a unique key for each group
33095
- * ([see example]({% slug groups_expanded_state_grid %}#toc-custom-group-key-format)).
33015
+ * Defines the descriptors by which the data will be sorted.
33096
33016
  */
33097
- get expandGroupBy() {
33098
- return this._expandGroupBy;
33017
+ set sort(value) {
33018
+ const noCurrentDescriptors = noDescriptors(this.state.sort);
33019
+ const noIncomingDescriptors = noDescriptors(value);
33020
+ const clear = this.state.sort !== value && !(noCurrentDescriptors && noIncomingDescriptors);
33021
+ this.grid.sort = this.state.sort = value;
33022
+ if (clear) {
33023
+ this.groups = null;
33024
+ this.grid.resetGroupsState();
33025
+ }
33099
33026
  }
33100
- set expandGroupBy(key) {
33101
- if (typeof key === 'function') {
33102
- this._expandGroupBy = key;
33027
+ /**
33028
+ * Defines the descriptor by which the data will be filtered.
33029
+ */
33030
+ set filter(value) {
33031
+ const clear = diffFilters(this.state.filter, value);
33032
+ if (clear) {
33033
+ this.state.filter = value;
33034
+ this.grid.filter = cloneFilters(value);
33035
+ this.groups = null;
33036
+ this.grid.resetGroupsState();
33103
33037
  }
33104
33038
  }
33105
33039
  /**
33106
- * Holds the collection of expanded group keys.
33107
- * Set this property to control which group rows are expanded.
33040
+ * Defines the descriptors by which the data will be grouped.
33108
33041
  */
33109
- get expandedGroupKeys() {
33110
- return this._expandedGroupKeys;
33042
+ set group(value) {
33043
+ // don't clear if no groups are present in previous and current value
33044
+ const groupsPresent = groupDescriptorsPresent(this.state.group) || groupDescriptorsPresent(value);
33045
+ const clear = this.state.group !== value && groupsPresent;
33046
+ this.grid.group = this.state.group = value;
33047
+ if (clear) {
33048
+ this.groups = null;
33049
+ this.grid.resetGroupsState();
33050
+ this.skip = 0;
33051
+ }
33111
33052
  }
33112
- set expandedGroupKeys(expandedGroups) {
33113
- this._expandedGroupKeys = (expandedGroups || []).slice();
33053
+ groups;
33054
+ gridSubs = new Subscription();
33055
+ constructor(changeDetector, localDataChangesService, ctxService, groupsService) {
33056
+ super(ctxService.grid, changeDetector, localDataChangesService, null, ctxService);
33057
+ this.groupsService = groupsService;
33058
+ ctxService.dataBindingDirective = this;
33059
+ }
33060
+ ngOnInit() {
33061
+ super.ngOnInit();
33062
+ this.gridSubs.add(this.grid.groupExpand.subscribe(this.groupExpand.bind(this)));
33063
+ this.gridSubs.add(this.grid.groupCollapse.subscribe(this.groupCollapse.bind(this)));
33064
+ }
33065
+ ngAfterContentInit() {
33066
+ if (isDevMode() && this.grid.isGroupExpanded) {
33067
+ throw new Error(GridConfigurationErrorMessages.groupBindingDirectives);
33068
+ }
33069
+ }
33070
+ ngOnDestroy() {
33071
+ this.gridSubs.unsubscribe();
33114
33072
  }
33115
33073
  /**
33116
- * Specifies if group items are expanded by default.
33117
- * @default false
33074
+ * @hidden
33118
33075
  */
33119
- groupsInitiallyExpanded = false;
33120
- _expandGroupBy;
33121
- _expandedGroupKeys;
33122
- subscriptions = new Subscription();
33123
- constructor(grid) {
33124
- this.grid = grid;
33125
- this.grid.isGroupExpanded = this.isExpanded.bind(this);
33126
- this.subscriptions.add(merge(this.grid.groupExpand.pipe(map(e => ({ expand: true, ...e }))), this.grid.groupCollapse.pipe(map(e => ({ expand: false, ...e })))).subscribe(this.toggleState.bind(this)));
33076
+ toggleAll(expand) {
33077
+ this.skip = 0;
33078
+ this.grid.scrollTo({ row: 0, column: 0 });
33079
+ this.groups.forEach((gr, idx) => {
33080
+ const expanded = this.groupsService.isExpanded({
33081
+ group: gr,
33082
+ groupIndex: idx.toString(),
33083
+ parentGroup: undefined
33084
+ });
33085
+ const performToggle = (expand && !expanded) || (!expand && expanded);
33086
+ if (performToggle) {
33087
+ this.grid.groupsService.toggleRow({
33088
+ type: 'group',
33089
+ data: gr,
33090
+ index: idx.toString(),
33091
+ level: 0,
33092
+ parentGroup: undefined
33093
+ });
33094
+ this[expand ? 'groupExpand' : 'groupCollapse']({ groupIndex: idx.toString() });
33095
+ }
33096
+ });
33127
33097
  }
33128
- ngOnDestroy() {
33129
- this.subscriptions.unsubscribe();
33098
+ /**
33099
+ * Collapses all expanded root level groups.
33100
+ */
33101
+ collapseAll() {
33102
+ this.toggleAll(false);
33130
33103
  }
33131
- get keyGetter() {
33132
- return this.expandGroupBy || DEFAULT_KEY_GETTER;
33104
+ /**
33105
+ * Expands all expanded root level groups.
33106
+ */
33107
+ expandAll() {
33108
+ this.toggleAll(true);
33133
33109
  }
33134
33110
  /**
33135
33111
  * @hidden
33136
33112
  */
33137
- isExpanded(groupArgs) {
33138
- const itemIndex = this.getItemIndex(groupArgs);
33139
- return itemIndex > -1 ? !this.groupsInitiallyExpanded : this.groupsInitiallyExpanded;
33113
+ groupExpand({ groupIndex }) {
33114
+ const { group, parents } = findGroup(groupIndex, this.groups);
33115
+ if (!group) {
33116
+ return;
33117
+ }
33118
+ this.groupsService.expandChildren(groupIndex);
33119
+ if (!group.items.length) {
33120
+ const descriptors = this.state.group.filter(removeParentDescriptors(parents, group));
33121
+ const children = findChildren(this.originalData, parents.concat(group));
33122
+ group.items = processGroups(children, {
33123
+ filter: this.state.filter,
33124
+ group: descriptors,
33125
+ sort: this.state.sort
33126
+ });
33127
+ }
33128
+ this.grid.data = this.dataResult(this.state.skip, this.state.take);
33140
33129
  }
33141
- getItemIndex(groupArgs) {
33142
- if (this.expandGroupBy) {
33143
- return this.expandedGroupKeys.indexOf(this.keyGetter(groupArgs));
33130
+ /**
33131
+ * @hidden
33132
+ */
33133
+ groupCollapse({ groupIndex }) {
33134
+ const { group } = findGroup(groupIndex, this.groups);
33135
+ if (group) {
33136
+ group.items = [];
33144
33137
  }
33145
- return this.expandedGroupKeys.findIndex(item => {
33146
- let index = 0;
33147
- let parentGroup = groupArgs.parentGroup;
33148
- while (isPresent(parentGroup)) {
33149
- if (!isPresent(item.parentGroupKeys) || !isPresent(item.parentGroupKeys[index]) ||
33150
- parentGroup.group.value !== item.parentGroupKeys[index].value ||
33151
- parentGroup.group.field !== item.parentGroupKeys[index].field) {
33152
- return false;
33153
- }
33154
- parentGroup = parentGroup.parentGroup;
33155
- index++;
33156
- }
33157
- return item.value === groupArgs.group.value && item.field === groupArgs.group.field;
33158
- });
33138
+ else {
33139
+ return;
33140
+ }
33141
+ this.grid.data = this.dataResult(this.state.skip, this.state.take);
33159
33142
  }
33160
- toggleState(groupArgs) {
33161
- const key = this.keyGetter(groupArgs);
33162
- if (Boolean(this.groupsInitiallyExpanded) !== groupArgs.expand) {
33163
- this.expandedGroupKeys.push(key);
33143
+ process(state) {
33144
+ if (state.group && state.group.length) {
33145
+ const groups = this.processGroups(state);
33146
+ this.grid.skip -= skippedHeaders(groups.data[0]);
33147
+ return groups;
33164
33148
  }
33165
33149
  else {
33166
- const index = this.expandedGroupKeys.findIndex(group => {
33167
- if (this.expandGroupBy) {
33168
- return group === key;
33169
- }
33170
- else if (key.parentGroupKeys?.length === 0) {
33171
- return group.value === key.value;
33172
- }
33173
- return JSON.stringify(group) === JSON.stringify(key);
33150
+ this.groups = null;
33151
+ }
33152
+ return super.process(state);
33153
+ }
33154
+ processGroups(state) {
33155
+ if (!this.groups || !this.groups.length) {
33156
+ this.groups = processGroups(this.originalData, {
33157
+ filter: state.filter,
33158
+ group: state.group,
33159
+ sort: state.sort
33174
33160
  });
33175
- this.expandedGroupKeys.splice(index, 1);
33176
33161
  }
33177
- this.expandedGroupKeysChange.emit(this.expandedGroupKeys.slice());
33162
+ return this.dataResult(state.skip, state.take);
33178
33163
  }
33179
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExpandGroupDirective, deps: [{ token: GridComponent }], target: i0.ɵɵFactoryTarget.Directive });
33180
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: ExpandGroupDirective, isStandalone: true, selector: "[kendoGridExpandGroupBy]", inputs: { expandGroupBy: ["kendoGridExpandGroupBy", "expandGroupBy"], expandedGroupKeys: "expandedGroupKeys", groupsInitiallyExpanded: "groupsInitiallyExpanded" }, outputs: { expandedGroupKeysChange: "expandedGroupKeysChange" }, exportAs: ["kendoGridExpandGroupBy"], ngImport: i0 });
33164
+ dataResult(skip, take) {
33165
+ const includeFooters = this.grid.showGroupFooters;
33166
+ return {
33167
+ data: slice(this.groups, skip, take, includeFooters),
33168
+ total: count(this.groups, includeFooters)
33169
+ };
33170
+ }
33171
+ applyState({ skip, take, sort, group, filter }) {
33172
+ this.skip = skip;
33173
+ this.state.take = take;
33174
+ // this.pageSize = take; // do need to update take as the process with slice correctly
33175
+ this.sort = sort;
33176
+ this.group = group;
33177
+ this.filter = filter;
33178
+ }
33179
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GroupBindingDirective, deps: [{ token: i0.ChangeDetectorRef }, { token: LocalDataChangesService }, { token: ContextService }, { token: GroupsService }], target: i0.ɵɵFactoryTarget.Directive });
33180
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: GroupBindingDirective, isStandalone: true, selector: "[kendoGridGroupBinding]", inputs: { kendoGridGroupBinding: "kendoGridGroupBinding", sort: "sort", filter: "filter", group: "group" }, exportAs: ["kendoGridGroupBinding"], usesInheritance: true, ngImport: i0 });
33181
33181
  }
33182
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExpandGroupDirective, decorators: [{
33182
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: GroupBindingDirective, decorators: [{
33183
33183
  type: Directive,
33184
33184
  args: [{
33185
- selector: '[kendoGridExpandGroupBy]',
33186
- exportAs: 'kendoGridExpandGroupBy',
33185
+ selector: '[kendoGridGroupBinding]',
33186
+ exportAs: 'kendoGridGroupBinding',
33187
33187
  standalone: true
33188
33188
  }]
33189
- }], ctorParameters: function () { return [{ type: GridComponent }]; }, propDecorators: { expandedGroupKeysChange: [{
33190
- type: Output
33191
- }], expandGroupBy: [{
33189
+ }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: LocalDataChangesService }, { type: ContextService }, { type: GroupsService }]; }, propDecorators: { kendoGridGroupBinding: [{
33192
33190
  type: Input,
33193
- args: ['kendoGridExpandGroupBy']
33194
- }], expandedGroupKeys: [{
33191
+ args: ["kendoGridGroupBinding"]
33192
+ }], sort: [{
33195
33193
  type: Input
33196
- }], groupsInitiallyExpanded: [{
33194
+ }], filter: [{
33195
+ type: Input
33196
+ }], group: [{
33197
33197
  type: Input
33198
33198
  }] } });
33199
33199
 
@@ -34039,15 +34039,6 @@ class UndoRedoDirective {
34039
34039
  }
34040
34040
  ngOnInit() {
34041
34041
  this.stack = new UndoRedoStack(this.maxStoredStates);
34042
- this.stack.add({
34043
- originalEvent: {
34044
- skip: this.host.skip,
34045
- take: this.host.pageSize,
34046
- sort: this.host.sort,
34047
- filter: this.host.filter,
34048
- group: this.host.group
34049
- }, gridState: this.host.currentState
34050
- });
34051
34042
  this.subs = this.host.gridStateChange.subscribe((state) => {
34052
34043
  if (this.addToState) {
34053
34044
  this.stack.add({
@@ -34118,7 +34109,7 @@ class UndoRedoDirective {
34118
34109
  if (isSaveOrRemove) {
34119
34110
  if (originalAction === 'save') {
34120
34111
  const stateItem = this.getGridDataItems(this.stack.current.gridState.currentData).find(item => item[this.itemIdKey] === event.originalEvent.dataItem[this.itemIdKey]);
34121
- Object.assign(event.originalEvent.originalDataItem, stateItem);
34112
+ this.localDataChangesService?.data.splice(event.originalEvent.rowIndex, 1, stateItem);
34122
34113
  }
34123
34114
  else if (action === 'Undo') {
34124
34115
  this.localDataChangesService?.data.splice(event.originalEvent.rowIndex, 0, event.originalEvent.dataItem);
@@ -34131,13 +34122,24 @@ class UndoRedoDirective {
34131
34122
  else {
34132
34123
  this.host.loadState({ ...this.stack.current.gridState, currentData: null });
34133
34124
  if (this.isDataStateChangeEvent(event.originalEvent)) {
34134
- const { skip, take, sort, filter, group } = this.stack.current.gridState;
34125
+ const { skip, take, sort, filter, group } = event.gridState;
34135
34126
  this.host.dataStateChange.emit({ skip, take, sort, filter, group });
34136
34127
  }
34137
34128
  }
34138
34129
  }));
34139
34130
  });
34140
34131
  }
34132
+ ngAfterViewInit() {
34133
+ this.stack.add({
34134
+ originalEvent: {
34135
+ skip: this.host.skip,
34136
+ take: this.host.pageSize,
34137
+ sort: this.host.sort,
34138
+ filter: this.host.filter,
34139
+ group: this.host.group
34140
+ }, gridState: this.host.currentState
34141
+ });
34142
+ }
34141
34143
  ngOnDestroy() {
34142
34144
  this.stack.clear();
34143
34145
  this.stack = null;