@revolist/revogrid 4.27.0 → 4.27.1

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.
Files changed (55) hide show
  1. package/dist/cjs/{cell-renderer-C7rdgaov.js → cell-renderer-BDIx0xys.js} +1 -1
  2. package/dist/cjs/{column.service-Bbml5C2j.js → column.service-D-ENzqyb.js} +2 -0
  3. package/dist/cjs/{header-cell-renderer-BljFI6wj.js → header-cell-renderer-B5Y4fdZC.js} +1 -1
  4. package/dist/cjs/index.cjs.js +5 -4
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/revo-grid.cjs.entry.js +61 -41
  7. package/dist/cjs/revo-grid.cjs.js +1 -1
  8. package/dist/cjs/revogr-attribution_7.cjs.entry.js +1 -1
  9. package/dist/cjs/revogr-data_4.cjs.entry.js +3 -3
  10. package/dist/cjs/{row-resize.plugin-BRQy_qNn.js → row-resize.plugin-sK9_rcUN.js} +299 -180
  11. package/dist/collection/components/revoGrid/revo-grid.js +37 -21
  12. package/dist/collection/plugins/groupingRow/grouping.const.js +1 -0
  13. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +84 -54
  14. package/dist/collection/plugins/groupingRow/grouping.sorting.service.js +58 -0
  15. package/dist/collection/plugins/groupingRow/grouping.trimmed.service.js +5 -3
  16. package/dist/collection/plugins/row-resize/row-resize.plugin.js +144 -113
  17. package/dist/collection/plugins/sorting/sorting.plugin.js +16 -13
  18. package/dist/collection/plugins/wcag/index.js +5 -4
  19. package/dist/collection/services/dimension.provider.js +17 -1
  20. package/dist/esm/{cell-renderer-BFpmdV8H.js → cell-renderer-D9ze8OJw.js} +1 -1
  21. package/dist/esm/{column.service-CM-wgGs8.js → column.service-pu_fdQ0S.js} +2 -1
  22. package/dist/{revo-grid/header-cell-renderer-Bqh1PrgH.js → esm/header-cell-renderer-YCiVIQ2E.js} +1 -1
  23. package/dist/esm/index.js +5 -5
  24. package/dist/esm/loader.js +1 -1
  25. package/dist/esm/revo-grid.entry.js +61 -41
  26. package/dist/esm/revo-grid.js +1 -1
  27. package/dist/esm/revogr-attribution_7.entry.js +1 -1
  28. package/dist/esm/revogr-data_4.entry.js +3 -3
  29. package/dist/esm/{row-resize.plugin-BRiaHlHA.js → row-resize.plugin-DBOgjLdE.js} +300 -181
  30. package/dist/revo-grid/{cell-renderer-BFpmdV8H.js → cell-renderer-D9ze8OJw.js} +1 -1
  31. package/dist/revo-grid/{column.service-CM-wgGs8.js → column.service-pu_fdQ0S.js} +2 -1
  32. package/dist/{esm/header-cell-renderer-Bqh1PrgH.js → revo-grid/header-cell-renderer-YCiVIQ2E.js} +1 -1
  33. package/dist/revo-grid/index.esm.js +5 -5
  34. package/dist/revo-grid/revo-grid.entry.js +61 -41
  35. package/dist/revo-grid/revo-grid.esm.js +1 -1
  36. package/dist/revo-grid/revogr-attribution_7.entry.js +1 -1
  37. package/dist/revo-grid/revogr-data_4.entry.js +3 -3
  38. package/dist/revo-grid/{row-resize.plugin-BRiaHlHA.js → row-resize.plugin-DBOgjLdE.js} +300 -181
  39. package/dist/types/components/revoGrid/revo-grid.d.ts +2 -0
  40. package/dist/types/plugins/groupingRow/grouping.const.d.ts +1 -0
  41. package/dist/types/plugins/groupingRow/grouping.row.plugin.d.ts +5 -7
  42. package/dist/types/plugins/groupingRow/grouping.sorting.service.d.ts +7 -0
  43. package/dist/types/plugins/groupingRow/grouping.trimmed.service.d.ts +9 -0
  44. package/dist/types/plugins/row-resize/row-resize.plugin.d.ts +14 -12
  45. package/dist/types/plugins/sorting/sorting.plugin.d.ts +5 -0
  46. package/dist/types/services/dimension.provider.d.ts +7 -1
  47. package/hydrate/index.js +358 -218
  48. package/hydrate/index.mjs +358 -218
  49. package/package.json +1 -1
  50. package/standalone/column.service.js +1 -1
  51. package/standalone/index.js +1 -1
  52. package/standalone/revo-grid.js +1 -1
  53. package/standalone/revogr-data2.js +1 -1
  54. package/standalone/revogr-header2.js +1 -1
  55. package/standalone/revogr-overlay-selection2.js +1 -1
package/hydrate/index.mjs CHANGED
@@ -13077,6 +13077,7 @@ const GROUP_COLUMN_PROP = `${GRID_INTERNALS}-prop`;
13077
13077
  const GROUP_ORIGINAL_INDEX = `${GRID_INTERNALS}-original-index`;
13078
13078
  const GROUP_EXPAND_BTN = `group-expand`;
13079
13079
  const GROUP_EXPAND_EVENT = `groupexpandclick`;
13080
+ const BEFORE_GROUPING_APPLY_EVENT = `beforegroupingapply`;
13080
13081
  const GROUPING_ROW_TYPE = 'rgRow';
13081
13082
 
13082
13083
  function getGroupValueDefault(item, prop, emptyGroupValue) {
@@ -15373,7 +15374,9 @@ function isVirtualXDimension(type, disableVirtualX = false, virtualX = DEFAULT_V
15373
15374
  class DimensionProvider {
15374
15375
  constructor(viewports, config) {
15375
15376
  this.viewports = viewports;
15376
- const sizeChanged = debounce$1((k) => config.realSizeChanged(k), RESIZE_INTERVAL);
15377
+ this.config = config;
15378
+ this.rowDefinitions = [];
15379
+ const sizeChanged = debounce$1((k) => this.config.realSizeChanged(k), RESIZE_INTERVAL);
15377
15380
  this.stores = [...rowTypes, ...columnTypes].reduce((sources, t) => {
15378
15381
  sources[t] = new DimensionStore(t);
15379
15382
  sources[t].store.onChange('realSize', () => sizeChanged(t));
@@ -15391,6 +15394,20 @@ class DimensionProvider {
15391
15394
  this.viewports.stores[t].setOriginalSizes(this.stores[t].store.get('originItemSize'));
15392
15395
  this.setItemCount(count, t);
15393
15396
  }
15397
+ getRowDefinitions() {
15398
+ return this.rowDefinitions;
15399
+ }
15400
+ syncRowDefinitions(definitions) {
15401
+ this.rowDefinitions = definitions;
15402
+ }
15403
+ setRowDefinitions(definitions) {
15404
+ var _a, _b;
15405
+ if (definitions === this.rowDefinitions) {
15406
+ return;
15407
+ }
15408
+ this.syncRowDefinitions(definitions);
15409
+ (_b = (_a = this.config).rowDefinitionsChanged) === null || _b === void 0 ? void 0 : _b.call(_a, definitions);
15410
+ }
15394
15411
  /**
15395
15412
  * Apply new custom sizes to dimension and view port
15396
15413
  * @param type - dimension type
@@ -16921,6 +16938,60 @@ function allAndConditionsSatisfied(pendingResults) {
16921
16938
  return !pendingResults.includes(true);
16922
16939
  }
16923
16940
 
16941
+ /**
16942
+ * Restores group headers around already-sorted data indexes without rebuilding
16943
+ * the physical source. Group insertion order follows the first sorted member,
16944
+ * matching the order produced by regrouping a sorted source.
16945
+ */
16946
+ function gatherGroupedRowIndexes(source, sortedDataIndexes) {
16947
+ const groupPathByDataIndex = new Map();
16948
+ const currentGroupPath = [];
16949
+ source.forEach((model, physicalIndex) => {
16950
+ if (isGrouping(model)) {
16951
+ const depth = model[GROUP_DEPTH];
16952
+ if (typeof depth !== 'number') {
16953
+ return;
16954
+ }
16955
+ currentGroupPath.length = depth;
16956
+ currentGroupPath[depth] = physicalIndex;
16957
+ return;
16958
+ }
16959
+ if (model != null) {
16960
+ groupPathByDataIndex.set(physicalIndex, [...currentGroupPath]);
16961
+ }
16962
+ });
16963
+ const root = {
16964
+ children: new Map(),
16965
+ items: [],
16966
+ };
16967
+ for (const physicalIndex of sortedDataIndexes) {
16968
+ const groupPath = groupPathByDataIndex.get(physicalIndex);
16969
+ if (!(groupPath === null || groupPath === void 0 ? void 0 : groupPath.length)) {
16970
+ return undefined;
16971
+ }
16972
+ let node = root;
16973
+ for (const groupIndex of groupPath) {
16974
+ let child = node.children.get(groupIndex);
16975
+ if (!child) {
16976
+ child = { children: new Map(), items: [] };
16977
+ node.children.set(groupIndex, child);
16978
+ }
16979
+ node = child;
16980
+ }
16981
+ node.items.push(physicalIndex);
16982
+ }
16983
+ const groupedIndexes = [];
16984
+ const appendNode = (node) => {
16985
+ node.children.forEach((child, groupIndex) => {
16986
+ groupedIndexes.push(groupIndex);
16987
+ appendNode(child);
16988
+ });
16989
+ groupedIndexes.push(...node.items);
16990
+ };
16991
+ appendNode(root);
16992
+ return groupedIndexes;
16993
+ }
16994
+
16924
16995
  /**
16925
16996
  * Checks whether a sorting map contains at least one active order.
16926
16997
  *
@@ -17169,18 +17240,6 @@ const SortingSign = ({ column }) => {
17169
17240
  function getSortableRowIndexes(indexes, source) {
17170
17241
  return indexes.filter(index => !isGrouping(source[index]));
17171
17242
  }
17172
- function mergeSortedRowsWithGroups(indexes, source, sortedRows) {
17173
- if (sortedRows.length === indexes.length) {
17174
- return sortedRows;
17175
- }
17176
- let rowIndex = 0;
17177
- return indexes.map(index => {
17178
- if (isGrouping(source[index])) {
17179
- return index;
17180
- }
17181
- return sortedRows[rowIndex++];
17182
- });
17183
- }
17184
17243
  /**
17185
17244
  * Lifecycle
17186
17245
  * 1. @event `beforesorting` - Triggered when sorting just starts. Nothing has happened yet. This can be triggered from a column or from the source. If the type is from rows, the column will be undefined.
@@ -17340,6 +17399,7 @@ class SortingPlugin extends BasePlugin {
17340
17399
  storeService.setData({ proxyItems: newItemsOrder });
17341
17400
  }
17342
17401
  applySortingForStore(type, sorting, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
17402
+ var _a;
17343
17403
  const storeService = this.providers.data.stores[type];
17344
17404
  // row data
17345
17405
  const source = storeService.store.get('source');
@@ -17347,7 +17407,10 @@ class SortingPlugin extends BasePlugin {
17347
17407
  const proxyItems = storeService.store.get('proxyItems');
17348
17408
  const sortItems = getSortableRowIndexes(proxyItems, source);
17349
17409
  const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, sortingColumns, sortingOrder);
17350
- const newItemsOrder = mergeSortedRowsWithGroups(proxyItems, source, sortedItems);
17410
+ const hasGroupingRows = sortedItems.length !== proxyItems.length;
17411
+ const newItemsOrder = hasGroupingRows
17412
+ ? (_a = gatherGroupedRowIndexes(source, sortedItems)) !== null && _a !== void 0 ? _a : proxyItems
17413
+ : sortedItems;
17351
17414
  // take row indexes before trim applied and proxy items
17352
17415
  const prevItems = storeService.store.get('items');
17353
17416
  storeService.setData({
@@ -17373,6 +17436,16 @@ class SortingPlugin extends BasePlugin {
17373
17436
  }
17374
17437
  this.postponeSort(order, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate);
17375
17438
  }
17439
+ /**
17440
+ * Schedules the current active sort again after another plugin rebuilds row
17441
+ * proxy indexes while keeping the physical source unchanged.
17442
+ */
17443
+ reapplySorting() {
17444
+ if (!hasActiveSorting(this.sorting) || !this.sortingFunc) {
17445
+ return;
17446
+ }
17447
+ this.startSorting(this.sorting, this.sortingFunc, this.sortingColumns, this.sortingOrder);
17448
+ }
17376
17449
  /**
17377
17450
  * Applies sorting requested by a sortable header click.
17378
17451
  *
@@ -17891,8 +17964,10 @@ const TRIMMED_GROUPING = 'grouping';
17891
17964
  * against the grouped physical source can still be remapped. If neither path
17892
17965
  * resolves to a number, the caller drops the stale trim entry.
17893
17966
  */
17894
- function convertTrimmedIndex(initialIndex, firstLevelMap, secondLevelMap) {
17895
- const sourceIndex = Number.parseInt(initialIndex, 10);
17967
+ function convertGroupingIndex(initialIndex, firstLevelMap, secondLevelMap) {
17968
+ const sourceIndex = typeof initialIndex === 'number'
17969
+ ? initialIndex
17970
+ : Number.parseInt(initialIndex, 10);
17896
17971
  const firstConversionIndex = firstLevelMap[sourceIndex];
17897
17972
  if (!secondLevelMap) {
17898
17973
  return firstConversionIndex;
@@ -17925,7 +18000,7 @@ function processDoubleConversionTrimmed(initiallyTrimed, firstLevelMap, secondLe
17925
18000
  * if item exists we find it in collection
17926
18001
  * we support 2 level of conversions
17927
18002
  */
17928
- const newConversionIndex = convertTrimmedIndex(initialIndex, firstLevelMap, secondLevelMap);
18003
+ const newConversionIndex = convertGroupingIndex(initialIndex, firstLevelMap, secondLevelMap);
17929
18004
  // Group rows do not exist in the ungrouped index map and must not leak into new trims.
17930
18005
  if (typeof newConversionIndex !== 'number') {
17931
18006
  continue;
@@ -17986,7 +18061,7 @@ function filterOutEmptyGroupRows(source, filterTrimmed) {
17986
18061
  return trimmed;
17987
18062
  }
17988
18063
 
17989
- var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
18064
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
17990
18065
  var t = {};
17991
18066
  for (var p in s)
17992
18067
  if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -18000,7 +18075,7 @@ var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
18000
18075
  };
18001
18076
  const PADDING_DEPTH = 10;
18002
18077
  const RowRenderer = (_a, cells) => {
18003
- var { rowClass, index, size, start, depth, groupingLevel } = _a, attrs = __rest$1(_a, ["rowClass", "index", "size", "start", "depth", "groupingLevel"]);
18078
+ var { rowClass, index, size, start, depth, groupingLevel } = _a, attrs = __rest(_a, ["rowClass", "index", "size", "start", "depth", "groupingLevel"]);
18004
18079
  const props = Object.assign(Object.assign(Object.assign({}, attrs), { [DATA_ROW]: index }), (typeof groupingLevel === 'number'
18005
18080
  ? { 'data-level': groupingLevel }
18006
18081
  : {}));
@@ -18100,18 +18175,6 @@ const expandSvgIconVNode = (expanded = false) => {
18100
18175
  return (hAsync("svg", { "aria-hidden": "true", style: { transform: `rotate(${!expanded ? -90 : 0}deg)` }, focusable: "false", viewBox: "0 0 448 512" }, hAsync("path", { fill: "currentColor", d: "M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z" })));
18101
18176
  };
18102
18177
 
18103
- var __rest = (undefined && undefined.__rest) || function (s, e) {
18104
- var t = {};
18105
- for (var p in s)
18106
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
18107
- t[p] = s[p];
18108
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18109
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18110
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18111
- t[p[i]] = s[p[i]];
18112
- }
18113
- return t;
18114
- };
18115
18178
  class GroupingRowPlugin extends BasePlugin {
18116
18179
  getStore(type = GROUPING_ROW_TYPE) {
18117
18180
  return this.providers.data.stores[type].store;
@@ -18127,15 +18190,16 @@ class GroupingRowPlugin extends BasePlugin {
18127
18190
  }
18128
18191
  // expand event triggered
18129
18192
  onExpand({ virtualIndex }) {
18130
- const { source } = getSource(this.getStore().get('source'), this.getStore().get('proxyItems'));
18131
- let newTrimmed = this.getStore().get('trimmed')[TRIMMED_GROUPING];
18132
- let i = getPhysical(this.getStore(), virtualIndex);
18193
+ const store = this.getStore();
18194
+ const source = store.get('source');
18195
+ let newTrimmed = store.get('trimmed')[TRIMMED_GROUPING];
18196
+ const i = getPhysical(store, virtualIndex);
18133
18197
  const isExpanded = getExpanded(source[i]);
18134
18198
  if (!isExpanded) {
18135
- const { trimmed, items } = doExpand(virtualIndex, source, this.getStore().get('items'));
18199
+ const { trimmed, items: expandedItems } = doExpand(virtualIndex, source, store.get('items'));
18136
18200
  newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
18137
- if (items) {
18138
- setItems(this.getStore(), items);
18201
+ if (expandedItems) {
18202
+ setItems(store, expandedItems);
18139
18203
  }
18140
18204
  }
18141
18205
  else {
@@ -18143,7 +18207,7 @@ class GroupingRowPlugin extends BasePlugin {
18143
18207
  newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
18144
18208
  this.revogrid.clearFocus();
18145
18209
  }
18146
- this.getStore().set('source', source);
18210
+ store.set('source', source);
18147
18211
  this.revogrid.addTrimmed(newTrimmed, TRIMMED_GROUPING);
18148
18212
  }
18149
18213
  setColumnGrouping(cols) {
@@ -18165,7 +18229,7 @@ class GroupingRowPlugin extends BasePlugin {
18165
18229
  onDrag(e) {
18166
18230
  const { from, to } = e.detail;
18167
18231
  const isDown = to - from >= 0;
18168
- const { source } = getSource(this.getStore().get('source'), this.getStore().get('proxyItems'));
18232
+ const source = this.getStore().get('source');
18169
18233
  const items = this.getStore().get('items');
18170
18234
  let i = isDown ? from : to;
18171
18235
  const end = isDown ? to : from;
@@ -18191,21 +18255,13 @@ class GroupingRowPlugin extends BasePlugin {
18191
18255
  const source = this.getStore().get('source');
18192
18256
  return filterOutEmptyGroupRows(source, trimmed);
18193
18257
  }
18194
- isSortingRunning() {
18195
- const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
18196
- return !!(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sortingPromise);
18197
- }
18198
18258
  /**
18199
- * Returns grouping options for regrouping that must preserve current UI state.
18200
- *
18201
- * `expandedAll` and config `prevExpanded` are initial/config instructions.
18202
- * Reusing them after sorting would reopen groups the user collapsed before
18203
- * sorting instead of using the current grouped source state.
18259
+ * Sorting changes proxy order without changing the physical source baseline.
18260
+ * Other proxy changes, such as row dragging, are user-authored source order
18261
+ * and must be retained when grouping is rebuilt.
18204
18262
  */
18205
- getCurrentExpandedOptions() {
18206
- var _a;
18207
- const _b = (_a = this.options) !== null && _a !== void 0 ? _a : {}, options = __rest(_b, ["expandedAll", "prevExpanded"]);
18208
- return options;
18263
+ isSortingActiveOrPending(sortingPlugin) {
18264
+ return !!(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sortingPromise) || hasActiveSorting(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sorting);
18209
18265
  }
18210
18266
  /**
18211
18267
  * Starts global source update with group clearing and applying new one
@@ -18218,7 +18274,12 @@ class GroupingRowPlugin extends BasePlugin {
18218
18274
  * @param newOldIndexMap - provides us mapping with new indexes vs old indexes, we would use it for trimmed mapping
18219
18275
  */
18220
18276
  const store = this.getStore();
18221
- const { source, prevExpanded, oldNewIndexes } = getSource(store.get('source'), store.get('proxyItems'), true);
18277
+ const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
18278
+ const currentSource = store.get('source');
18279
+ const sourceItems = this.isSortingActiveOrPending(sortingPlugin)
18280
+ ? currentSource.map((_, index) => index)
18281
+ : store.get('proxyItems');
18282
+ const { source, prevExpanded, oldNewIndexes } = getSource(currentSource, sourceItems, true);
18222
18283
  const expanded = Object.assign({ prevExpanded }, options);
18223
18284
  /**
18224
18285
  * Group again
@@ -18228,8 +18289,13 @@ class GroupingRowPlugin extends BasePlugin {
18228
18289
  const customRenderer = options === null || options === void 0 ? void 0 : options.groupLabelTemplate;
18229
18290
  const cellRenderer = options === null || options === void 0 ? void 0 : options.groupCellTemplate;
18230
18291
  // setup source
18292
+ this.revogrid.dispatchEvent(new CustomEvent(BEFORE_GROUPING_APPLY_EVENT));
18231
18293
  this.providers.data.setData(sourceWithGroups, GROUPING_ROW_TYPE, this.revogrid.disableVirtualY, { depth, customRenderer, cellRenderer }, true);
18294
+ this.remapRowDefinitions(oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap, currentSource, sourceWithGroups);
18232
18295
  this.updateTrimmed(trimmed, oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap, sourceWithGroups);
18296
+ if (hasActiveSorting(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sorting)) {
18297
+ sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.reapplySorting();
18298
+ }
18233
18299
  }
18234
18300
  /**
18235
18301
  * Apply grouping on data set
@@ -18238,9 +18304,14 @@ class GroupingRowPlugin extends BasePlugin {
18238
18304
  */
18239
18305
  onDataSet(data) {
18240
18306
  var _a, _b, _c;
18307
+ const currentSource = this.getStore().get('source');
18308
+ const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
18309
+ const currentItems = this.isSortingActiveOrPending(sortingPlugin)
18310
+ ? currentSource.map((_, index) => index)
18311
+ : this.getStore().get('proxyItems');
18312
+ const { prevExpanded, oldNewIndexes } = getSource(currentSource, currentItems, true);
18241
18313
  let preservedExpanded = {};
18242
18314
  if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.preserveGroupingOnUpdate) !== false) {
18243
- let { prevExpanded } = getSource(this.getStore().get('source'), this.getStore().get('proxyItems'), true);
18244
18315
  preservedExpanded = prevExpanded;
18245
18316
  }
18246
18317
  const source = data.source.filter(s => !isGrouping(s));
@@ -18252,6 +18323,7 @@ class GroupingRowPlugin extends BasePlugin {
18252
18323
  customRenderer: options.groupLabelTemplate,
18253
18324
  cellRenderer: options.groupCellTemplate,
18254
18325
  });
18326
+ queueMicrotask(() => this.remapRowDefinitions(oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap, currentSource, sourceWithGroups));
18255
18327
  this.updateTrimmed(trimmed, oldNewIndexMap, undefined, sourceWithGroups, { filterTrimmedMode: 'recompute-after-source-set' });
18256
18328
  }
18257
18329
  /**
@@ -18287,10 +18359,6 @@ class GroupingRowPlugin extends BasePlugin {
18287
18359
  if (!(((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length) && ((_c = detail === null || detail === void 0 ? void 0 : detail.source) === null || _c === void 0 ? void 0 : _c.length))) {
18288
18360
  return;
18289
18361
  }
18290
- // if sorting is running don't apply grouping, wait for sorting, then it'll apply in @aftersortingapply
18291
- if (this.isSortingRunning()) {
18292
- return;
18293
- }
18294
18362
  this.onDataSet(detail);
18295
18363
  });
18296
18364
  this.addEventListener('beforecolumnsset', ({ detail }) => {
@@ -18305,17 +18373,6 @@ class GroupingRowPlugin extends BasePlugin {
18305
18373
  this.addEventListener('beforefiltertrimmed', ({ detail }) => {
18306
18374
  detail.itemsToFilter = this.beforeFilterTrimmed(detail.itemsToFilter);
18307
18375
  });
18308
- /**
18309
- * sorting applied need to clear grouping and apply again
18310
- * based on new results whole grouping order will changed
18311
- */
18312
- this.addEventListener('aftersortingapply', () => {
18313
- var _a, _b;
18314
- if (!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length)) {
18315
- return;
18316
- }
18317
- this.doSourceUpdate(this.getCurrentExpandedOptions());
18318
- });
18319
18376
  /**
18320
18377
  * Apply logic for focus inside of grouping
18321
18378
  * We can't focus on grouping rows, navigation only inside of groups for now
@@ -18348,9 +18405,57 @@ class GroupingRowPlugin extends BasePlugin {
18348
18405
  }
18349
18406
  });
18350
18407
  // clear rows
18351
- const { source, oldNewIndexes } = getSource(this.getStore().get('source'), this.getStore().get('proxyItems'), true);
18408
+ const store = this.getStore();
18409
+ const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
18410
+ const currentSource = store.get('source');
18411
+ const sourceItems = this.isSortingActiveOrPending(sortingPlugin)
18412
+ ? currentSource.map((_, index) => index)
18413
+ : store.get('proxyItems');
18414
+ const { source, oldNewIndexes } = getSource(currentSource, sourceItems, true);
18415
+ this.revogrid.dispatchEvent(new CustomEvent(BEFORE_GROUPING_APPLY_EVENT));
18352
18416
  this.providers.data.setData(source, GROUPING_ROW_TYPE, this.revogrid.disableVirtualY, undefined, true);
18417
+ this.remapRowDefinitions(oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, undefined, currentSource, source);
18353
18418
  this.updateTrimmed(undefined, undefined, oldNewIndexes, source);
18419
+ if (hasActiveSorting(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sorting)) {
18420
+ sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.reapplySorting();
18421
+ }
18422
+ }
18423
+ remapRowDefinitions(firstLevelMap, secondLevelMap, previousSource, nextSource) {
18424
+ const definitions = this.providers.dimension.getRowDefinitions();
18425
+ const nextGroupIndexes = new Map();
18426
+ nextSource === null || nextSource === void 0 ? void 0 : nextSource.forEach((row, index) => {
18427
+ const groupId = row[PSEUDO_GROUP_ITEM_ID];
18428
+ if (groupId && !nextGroupIndexes.has(groupId)) {
18429
+ nextGroupIndexes.set(groupId, index);
18430
+ }
18431
+ });
18432
+ let changed = false;
18433
+ const remapped = definitions.flatMap(definition => {
18434
+ if (definition.type !== GROUPING_ROW_TYPE) {
18435
+ return [definition];
18436
+ }
18437
+ const previousRow = previousSource === null || previousSource === void 0 ? void 0 : previousSource[definition.index];
18438
+ const groupId = previousRow === null || previousRow === void 0 ? void 0 : previousRow[PSEUDO_GROUP_ITEM_ID];
18439
+ const index = groupId
18440
+ ? nextGroupIndexes.get(groupId)
18441
+ : convertGroupingIndex(definition.index, firstLevelMap, secondLevelMap);
18442
+ if (typeof index !== 'number') {
18443
+ changed = true;
18444
+ return [];
18445
+ }
18446
+ if (index < 0) {
18447
+ changed = true;
18448
+ return [];
18449
+ }
18450
+ if (index === definition.index) {
18451
+ return [definition];
18452
+ }
18453
+ changed = true;
18454
+ return [Object.assign(Object.assign({}, definition), { index })];
18455
+ });
18456
+ if (changed) {
18457
+ this.providers.dimension.setRowDefinitions(remapped);
18458
+ }
18354
18459
  }
18355
18460
  updateTrimmed(trimmedGroup = {}, firstLevelMap = {}, secondLevelMap, source = this.getStore().get('source'), { filterTrimmedMode = 'remap', } = {}) {
18356
18461
  // map previously trimmed data
@@ -19202,19 +19307,6 @@ const rowDefinitionByType = (newVal = []) => {
19202
19307
  }
19203
19308
  return result;
19204
19309
  };
19205
- const rowDefinitionRemoveByType = (oldVal = []) => {
19206
- const result = {};
19207
- for (const v of oldVal) {
19208
- let rowDefs = result[v.type];
19209
- if (!rowDefs) {
19210
- rowDefs = result[v.type] = [];
19211
- }
19212
- if (typeof v.size === 'number') {
19213
- rowDefs.push(v.index);
19214
- }
19215
- }
19216
- return result;
19217
- };
19218
19310
 
19219
19311
  const COLUMN_DRAG_CLASS = 'column-drag-start';
19220
19312
  class ColumnOrderHandler {
@@ -19774,6 +19866,7 @@ function isMobileDevice() {
19774
19866
  return /Mobi/i.test(navigator.userAgent) || /Android/i.test(navigator.userAgent) || navigator.maxTouchPoints > 0;
19775
19867
  }
19776
19868
 
19869
+ const toAriaIndex = (index) => `${index + 1}`;
19777
19870
  /**
19778
19871
  * WCAG Plugin is responsible for enhancing the accessibility features of the RevoGrid component.
19779
19872
  * It ensures that the grid is fully compliant with Web Content Accessibility Guidelines (WCAG) 2.1.
@@ -19817,14 +19910,14 @@ class WCAGPlugin extends BasePlugin {
19817
19910
  column.columnProperties = (...args) => {
19818
19911
  const result = (columnProperties === null || columnProperties === void 0 ? void 0 : columnProperties(...args)) || {};
19819
19912
  result.role = 'columnheader';
19820
- result['aria-colindex'] = `${index}`;
19913
+ result['aria-colindex'] = toAriaIndex(index);
19821
19914
  return result;
19822
19915
  };
19823
19916
  column.cellProperties = (...args) => {
19824
19917
  const wcagProps = {
19825
19918
  ['role']: 'gridcell',
19826
- ['aria-colindex']: `${index}`,
19827
- ['aria-rowindex']: `${args[0].rowIndex}`,
19919
+ ['aria-colindex']: toAriaIndex(index),
19920
+ ['aria-rowindex']: toAriaIndex(args[0].rowIndex),
19828
19921
  ['tabindex']: -1,
19829
19922
  };
19830
19923
  const columnProps = (cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties(...args)) || {};
@@ -19839,7 +19932,7 @@ class WCAGPlugin extends BasePlugin {
19839
19932
  revogrid.setAttribute('aria-rowcount', `${detail.source.length}`);
19840
19933
  });
19841
19934
  this.addEventListener('beforerowrender', ({ detail, }) => {
19842
- detail.node.$attrs$ = Object.assign(Object.assign({}, detail.node.$attrs$), { role: 'row', ['aria-rowindex']: detail.item.itemIndex });
19935
+ detail.node.$attrs$ = Object.assign(Object.assign({}, detail.node.$attrs$), { role: 'row', ['aria-rowindex']: toAriaIndex(detail.item.itemIndex) });
19843
19936
  });
19844
19937
  // focuscell
19845
19938
  this.addEventListener('afterfocus', async (e) => {
@@ -20097,18 +20190,14 @@ const ROW_RESIZE_EVENT = 'rowresize';
20097
20190
  const AFTER_ROW_RESIZE_EVENT = 'afterrowresize';
20098
20191
  const ROW_RESIZE_CANCEL_EVENT = 'rowresizecancel';
20099
20192
  class RowResizePlugin extends BasePlugin {
20100
- static fromGridProperty(revogrid, providers) {
20101
- const plugin = new RowResizePlugin(revogrid, providers);
20102
- plugin.controlFromGridProperty();
20103
- return plugin;
20104
- }
20105
20193
  constructor(revogrid, providers, config = {}) {
20106
20194
  super(revogrid, providers);
20107
20195
  this.enabled = false;
20108
- this.gridResizeRow = false;
20109
- this.gridPlugins = [];
20110
- this.committedSizes = new Map();
20111
- this.appliedIndexes = new Map();
20196
+ this.appliedDefinitionIndexes = new Map();
20197
+ this.pendingBottomAnchor = false;
20198
+ this.keepBottomAnchor = false;
20199
+ this.rowDefinitionRemapQueued = false;
20200
+ this.pendingSourceCounts = new Map();
20112
20201
  this.previousBodyCursor = '';
20113
20202
  this.decorateRow = ({ detail, }) => {
20114
20203
  if (!this.enabled ||
@@ -20172,22 +20261,72 @@ class RowResizePlugin extends BasePlugin {
20172
20261
  }
20173
20262
  };
20174
20263
  this.onWindowBlur = () => this.cancel('blur');
20175
- this.reapplyCommittedSizes = () => this.applyCommittedSizes(false);
20176
- this.rebuildCommittedSizes = () => this.applyCommittedSizes(true);
20177
- this.syncAppliedIndexes = () => {
20178
- for (const [rowType, committed] of this.committedSizes) {
20264
+ this.updateBottomAnchorState = ({ detail, }) => {
20265
+ if (detail.dimension !== 'rgRow') {
20266
+ return;
20267
+ }
20268
+ this.keepBottomAnchor = this.isMainViewportAtBottom(detail.coordinate);
20269
+ };
20270
+ this.applyPendingBottomAnchor = () => {
20271
+ if (!this.pendingBottomAnchor) {
20272
+ return;
20273
+ }
20274
+ this.pendingBottomAnchor = false;
20275
+ const dimension = this.providers.dimension.stores.rgRow.store;
20276
+ // Scroll surfaces have slightly different client sizes. Give the shared
20277
+ // scrolling service the content end and let each surface clamp to its own
20278
+ // exact bottom coordinate.
20279
+ void this.revogrid.scrollToCoordinate({ y: dimension.get('realSize') });
20280
+ };
20281
+ this.scheduleRowDefinitionRemap = () => {
20282
+ if (this.rowDefinitionRemapQueued) {
20283
+ return;
20284
+ }
20285
+ this.rowDefinitionRemapQueued = true;
20286
+ queueMicrotask(() => {
20287
+ if (!this.rowDefinitionRemapQueued) {
20288
+ return;
20289
+ }
20290
+ this.pruneRowDefinitions();
20291
+ this.reapplyRowDefinitionSizes();
20292
+ this.rowDefinitionRemapQueued = false;
20293
+ });
20294
+ };
20295
+ /** Map source-indexed row definitions back onto the current virtual order. */
20296
+ this.reapplyRowDefinitionSizes = () => {
20297
+ const rowDefinitions = this.providers.dimension.getRowDefinitions();
20298
+ for (const rowType of rowTypes) {
20179
20299
  const items = this.providers.data.stores[rowType].store.get('items');
20300
+ const definitions = new Map(rowDefinitions
20301
+ .filter(definition => definition.type === rowType)
20302
+ .map(definition => [definition.index, definition.size]));
20303
+ const appliedIndexes = this.appliedDefinitionIndexes.get(rowType);
20304
+ if (!definitions.size && !(appliedIndexes === null || appliedIndexes === void 0 ? void 0 : appliedIndexes.size)) {
20305
+ continue;
20306
+ }
20307
+ const dimension = this.providers.dimension.stores[rowType];
20308
+ const currentSizes = dimension.store.get('sizes');
20309
+ const sizes = Object.assign({}, currentSizes);
20310
+ for (const index of appliedIndexes || []) {
20311
+ delete sizes[index];
20312
+ }
20180
20313
  const indexes = new Set();
20181
20314
  items.forEach((physicalIndex, virtualIndex) => {
20182
- if (committed.has(physicalIndex)) {
20315
+ const size = definitions.get(physicalIndex);
20316
+ if (size !== undefined) {
20317
+ sizes[virtualIndex] = size;
20183
20318
  indexes.add(virtualIndex);
20184
20319
  }
20185
20320
  });
20186
- this.appliedIndexes.set(rowType, indexes);
20321
+ this.appliedDefinitionIndexes.set(rowType, indexes);
20322
+ const sizeKeys = Object.keys(sizes);
20323
+ if (sizeKeys.length !== Object.keys(currentSizes).length ||
20324
+ sizeKeys.some(index => sizes[index] !== currentSizes[index])) {
20325
+ this.providers.dimension.setCustomSizes(rowType, sizes);
20326
+ }
20187
20327
  }
20188
20328
  };
20189
20329
  this.config = resolveRowResizeConfig(config);
20190
- this.rowDefinitionsRef = revogrid.rowDefinitions;
20191
20330
  if (new.target !== RowResizePlugin) {
20192
20331
  this.enabled = true;
20193
20332
  this.registerEventListeners();
@@ -20195,77 +20334,53 @@ class RowResizePlugin extends BasePlugin {
20195
20334
  }
20196
20335
  registerEventListeners() {
20197
20336
  this.addEventListener('beforerowrender', this.decorateRow);
20198
- this.addEventListener('beforeanysource', ({ detail }) => {
20337
+ this.addEventListener('beforeanysource', () => {
20199
20338
  this.cancel('data-change');
20200
- const committed = this.committedSizes.get(detail.type);
20201
- if (!committed) {
20202
- return;
20203
- }
20204
- const removedIndexes = new Set();
20205
- for (const index of committed.keys()) {
20206
- if (index >= detail.source.length) {
20207
- committed.delete(index);
20208
- removedIndexes.add(index);
20209
- }
20210
- }
20211
- if (removedIndexes.size) {
20212
- const rowDefinitions = this.revogrid.rowDefinitions.filter(definition => definition.type !== detail.type ||
20213
- !removedIndexes.has(definition.index));
20214
- this.rowDefinitionsRef = rowDefinitions;
20215
- this.revogrid.rowDefinitions = rowDefinitions;
20216
- }
20339
+ this.keepBottomAnchor = false;
20340
+ });
20341
+ this.addEventListener('afteranysource', ({ detail }) => {
20342
+ this.pendingSourceCounts.set(detail.type, detail.source.length);
20343
+ this.scheduleRowDefinitionRemap();
20217
20344
  });
20218
- this.addEventListener('afteranysource', this.rebuildCommittedSizes);
20219
20345
  this.addEventListener('beforesourcesortingapply', this.cancelForDataChange);
20220
- this.addEventListener('aftersortingapply', this.reapplyCommittedSizes);
20346
+ this.addEventListener('beforesortingapply', this.cancelForDataChange);
20347
+ this.addEventListener('sortingconfigchanged', this.cancelForDataChange);
20348
+ this.addEventListener(BEFORE_GROUPING_APPLY_EVENT, this.cancelForDataChange);
20349
+ this.addEventListener('aftersortingapply', this.scheduleRowDefinitionRemap);
20221
20350
  this.addEventListener('beforefilterapply', this.cancelForDataChange);
20222
- this.addEventListener('beforerowdefinition', ({ detail }) => {
20351
+ this.addEventListener('afterfilterapply', this.scheduleRowDefinitionRemap);
20352
+ this.addEventListener('beforerowdefinition', () => {
20223
20353
  this.cancel('data-change');
20224
- if (detail.vals !== this.rowDefinitionsRef) {
20225
- this.committedSizes.clear();
20226
- this.appliedIndexes.clear();
20227
- this.rowDefinitionsRef = detail.vals;
20228
- }
20229
- });
20230
- this.addEventListener('afterthemechanged', this.reapplyCommittedSizes);
20231
- this.addEventListener('aftertrimmed', this.syncAppliedIndexes);
20232
- this.addEventListener('roworderchange', () => {
20233
- queueMicrotask(this.reapplyCommittedSizes);
20354
+ this.scheduleRowDefinitionRemap();
20234
20355
  });
20356
+ this.addEventListener('afterthemechanged', this.scheduleRowDefinitionRemap);
20357
+ this.addEventListener('aftertrimmed', this.scheduleRowDefinitionRemap);
20358
+ this.addEventListener('roworderchange', this.scheduleRowDefinitionRemap);
20235
20359
  this.addEventListener(GROUP_EXPAND_EVENT, () => {
20236
- queueMicrotask(this.reapplyCommittedSizes);
20360
+ if (this.keepBottomAnchor) {
20361
+ this.pendingBottomAnchor = true;
20362
+ }
20363
+ this.scheduleRowDefinitionRemap();
20237
20364
  });
20365
+ this.addEventListener('aftergridrender', this.applyPendingBottomAnchor);
20366
+ this.addEventListener('viewportscroll', this.updateBottomAnchorState);
20238
20367
  this.addEventListener('rowheaderschanged', ({ detail }) => {
20239
20368
  if (!detail && !this.config.fullRow) {
20240
20369
  this.cancel('row-headers-hidden');
20241
20370
  }
20242
20371
  });
20243
20372
  }
20244
- controlFromGridProperty() {
20245
- this.gridResizeRow = this.revogrid.resizeRow;
20246
- this.gridPlugins = this.revogrid.plugins;
20247
- this.syncGridProperty(false);
20248
- this.watch('resizeRow', value => {
20249
- this.gridResizeRow = value;
20250
- this.syncGridProperty();
20251
- });
20252
- this.watch('plugins', value => {
20253
- this.gridPlugins = value || [];
20254
- this.syncGridProperty();
20255
- });
20256
- }
20257
- syncGridProperty(refresh = true) {
20258
- const hasConfiguredPlugin = this.gridPlugins.some(plugin => plugin !== RowResizePlugin &&
20373
+ syncGridConfig(refresh = true) {
20374
+ const { plugins = [], resizeRow } = this.revogrid;
20375
+ const isCorePlugin = this.constructor === RowResizePlugin;
20376
+ const hasConfiguredPlugin = plugins.some(plugin => plugin !== RowResizePlugin &&
20259
20377
  plugin.prototype instanceof RowResizePlugin);
20260
- const explicitlyEnabled = this.gridPlugins.includes(RowResizePlugin);
20261
- const enabled = hasConfiguredPlugin
20262
- ? false
20263
- : explicitlyEnabled || !!this.gridResizeRow;
20264
- const config = resolveRowResizeConfig(!hasConfiguredPlugin &&
20265
- !explicitlyEnabled &&
20266
- typeof this.gridResizeRow === 'object'
20267
- ? this.gridResizeRow
20268
- : undefined);
20378
+ const enabled = !isCorePlugin ||
20379
+ (!hasConfiguredPlugin && !!resizeRow);
20380
+ const resizeConfig = typeof resizeRow === 'object' ? resizeRow : undefined;
20381
+ const config = isCorePlugin
20382
+ ? resolveRowResizeConfig(resizeConfig)
20383
+ : this.config;
20269
20384
  const configChanged = config.minHeight !== this.config.minHeight ||
20270
20385
  config.maxHeight !== this.config.maxHeight ||
20271
20386
  config.fullRow !== this.config.fullRow;
@@ -20277,10 +20392,13 @@ class RowResizePlugin extends BasePlugin {
20277
20392
  if (enabled !== this.enabled) {
20278
20393
  this.enabled = enabled;
20279
20394
  if (enabled) {
20280
- this.rowDefinitionsRef = this.revogrid.rowDefinitions;
20281
20395
  this.registerEventListeners();
20282
20396
  }
20283
20397
  else {
20398
+ this.pendingBottomAnchor = false;
20399
+ this.keepBottomAnchor = false;
20400
+ this.rowDefinitionRemapQueued = false;
20401
+ this.pendingSourceCounts.clear();
20284
20402
  this.clearSubscriptions();
20285
20403
  }
20286
20404
  }
@@ -20299,6 +20417,7 @@ class RowResizePlugin extends BasePlugin {
20299
20417
  }
20300
20418
  const dimension = this.providers.dimension.stores[rowType];
20301
20419
  const dimensionState = dimension.getCurrentState();
20420
+ const viewport = this.providers.viewport.stores[rowType];
20302
20421
  const item = getItemByIndex(dimensionState, index);
20303
20422
  const focusedStore = this.providers.selection.focusedStore;
20304
20423
  const selectedRowType = focusedStore
@@ -20330,16 +20449,23 @@ class RowResizePlugin extends BasePlugin {
20330
20449
  currentHeight: startHeight,
20331
20450
  previousSizes,
20332
20451
  originalCustomSizes: Object.assign({}, dimensionState.sizes),
20333
- startEvent: event,
20452
+ bottomAnchored: rowType === 'rgRow' &&
20453
+ this.isMainViewportAtBottom(viewport.lastCoordinate),
20334
20454
  lastEvent: event,
20335
20455
  };
20456
+ this.active = active;
20336
20457
  const beforeEvent = this.emit(BEFORE_ROW_RESIZE_EVENT, this.eventDetail(active, event, startHeight));
20337
20458
  if (beforeEvent.defaultPrevented) {
20459
+ if (this.active === active) {
20460
+ this.active = undefined;
20461
+ }
20462
+ return;
20463
+ }
20464
+ if (!this.enabled || this.active !== active) {
20338
20465
  return;
20339
20466
  }
20340
20467
  event.preventDefault();
20341
20468
  event.stopPropagation();
20342
- this.active = active;
20343
20469
  const doc = this.revogrid.ownerDocument;
20344
20470
  this.previousBodyCursor = ((_a = doc.body) === null || _a === void 0 ? void 0 : _a.style.cursor) || '';
20345
20471
  if (doc.body) {
@@ -20362,6 +20488,7 @@ class RowResizePlugin extends BasePlugin {
20362
20488
  return;
20363
20489
  }
20364
20490
  this.providers.dimension.setCustomSizes(active.rowType, createRowResizePatch(active.indexes, size), true);
20491
+ this.requestBottomAnchor(active);
20365
20492
  active.currentHeight = size;
20366
20493
  this.emit(ROW_RESIZE_EVENT, this.eventDetail(active, active.lastEvent, size));
20367
20494
  }
@@ -20380,7 +20507,8 @@ class RowResizePlugin extends BasePlugin {
20380
20507
  }
20381
20508
  }
20382
20509
  this.providers.dimension.setCustomSizes(active.rowType, currentSizes);
20383
- const detail = Object.assign(Object.assign({}, this.eventDetail(active, active.lastEvent || active.startEvent, active.startHeight)), { reason });
20510
+ this.requestBottomAnchor(active);
20511
+ const detail = Object.assign(Object.assign({}, this.eventDetail(active, active.lastEvent, active.startHeight)), { reason });
20384
20512
  this.finishGesture();
20385
20513
  this.emit(ROW_RESIZE_CANCEL_EVENT, detail);
20386
20514
  }
@@ -20399,51 +20527,44 @@ class RowResizePlugin extends BasePlugin {
20399
20527
  return;
20400
20528
  }
20401
20529
  const items = this.providers.data.stores[active.rowType].store.get('items');
20402
- let committed = this.committedSizes.get(active.rowType);
20403
- if (!committed) {
20404
- committed = new Map();
20405
- this.committedSizes.set(active.rowType, committed);
20406
- }
20407
- let applied = this.appliedIndexes.get(active.rowType);
20408
- if (!applied) {
20409
- applied = new Set();
20410
- this.appliedIndexes.set(active.rowType, applied);
20411
- }
20412
20530
  const physicalIndexes = active.indexes.reduce((result, index) => {
20413
20531
  const physicalIndex = items[index];
20414
20532
  if (physicalIndex !== undefined) {
20415
- committed.set(physicalIndex, active.currentHeight);
20416
- applied.add(index);
20417
20533
  result.push(physicalIndex);
20418
20534
  }
20419
20535
  return result;
20420
20536
  }, []);
20421
20537
  if (physicalIndexes.length) {
20422
- const rowDefinitions = mergeRowResizeDefinitions(this.revogrid.rowDefinitions, active.rowType, physicalIndexes, active.currentHeight);
20423
- this.rowDefinitionsRef = rowDefinitions;
20424
- this.revogrid.rowDefinitions = rowDefinitions;
20538
+ const rowDefinitions = mergeRowResizeDefinitions(this.providers.dimension.getRowDefinitions(), active.rowType, physicalIndexes, active.currentHeight);
20539
+ this.providers.dimension.setRowDefinitions(rowDefinitions);
20540
+ this.scheduleRowDefinitionRemap();
20541
+ this.keepBottomAnchor = active.bottomAnchored;
20542
+ this.requestBottomAnchor(active);
20425
20543
  }
20426
20544
  }
20427
- applyCommittedSizes(clearAppliedIndexes) {
20428
- for (const [rowType, committed] of this.committedSizes) {
20429
- const dimension = this.providers.dimension.stores[rowType];
20430
- const sizes = Object.assign({}, dimension.store.get('sizes'));
20431
- if (clearAppliedIndexes) {
20432
- for (const index of this.appliedIndexes.get(rowType) || []) {
20433
- delete sizes[index];
20434
- }
20435
- }
20436
- const items = this.providers.data.stores[rowType].store.get('items');
20437
- const indexes = new Set();
20438
- items.forEach((physicalIndex, virtualIndex) => {
20439
- const size = committed.get(physicalIndex);
20440
- if (size !== undefined) {
20441
- sizes[virtualIndex] = size;
20442
- indexes.add(virtualIndex);
20443
- }
20444
- });
20445
- this.appliedIndexes.set(rowType, indexes);
20446
- this.providers.dimension.setCustomSizes(rowType, sizes);
20545
+ requestBottomAnchor(active) {
20546
+ if (active.bottomAnchored) {
20547
+ this.pendingBottomAnchor = true;
20548
+ }
20549
+ }
20550
+ isMainViewportAtBottom(coordinate) {
20551
+ const dimension = this.providers.dimension.stores.rgRow.getCurrentState();
20552
+ const viewport = this.providers.viewport.stores.rgRow.store.state;
20553
+ return (dimension.realSize > viewport.clientSize &&
20554
+ coordinate >= getViewportMaxCoordinate(dimension, viewport.virtualSize));
20555
+ }
20556
+ pruneRowDefinitions() {
20557
+ if (!this.pendingSourceCounts.size) {
20558
+ return;
20559
+ }
20560
+ const definitions = this.providers.dimension.getRowDefinitions();
20561
+ const rowDefinitions = definitions.filter(definition => {
20562
+ const count = this.pendingSourceCounts.get(definition.type);
20563
+ return count === undefined || definition.index < count;
20564
+ });
20565
+ this.pendingSourceCounts.clear();
20566
+ if (rowDefinitions.length !== definitions.length) {
20567
+ this.providers.dimension.setRowDefinitions(rowDefinitions);
20447
20568
  }
20448
20569
  }
20449
20570
  finishGesture() {
@@ -20466,6 +20587,9 @@ class RowResizePlugin extends BasePlugin {
20466
20587
  }
20467
20588
  destroy() {
20468
20589
  this.cancel('destroy');
20590
+ this.keepBottomAnchor = false;
20591
+ this.rowDefinitionRemapQueued = false;
20592
+ this.pendingSourceCounts.clear();
20469
20593
  super.destroy();
20470
20594
  }
20471
20595
  }
@@ -21342,29 +21466,31 @@ class RevoGridComponent {
21342
21466
  vals: after,
21343
21467
  oldVals: before,
21344
21468
  });
21345
- // apply new values
21469
+ this.dimensionProvider.syncRowDefinitions(newVal);
21346
21470
  const newRows = rowDefinitionByType(newVal);
21347
- // clear current defs
21348
- if (oldVal) {
21349
- const remove = rowDefinitionRemoveByType(oldVal);
21350
- // clear all old data and drop sizes
21351
- for (const t in remove) {
21352
- if (remove.hasOwnProperty(t)) {
21353
- const type = t;
21354
- const store = this.dataProvider.stores[type];
21355
- const sourceLength = store.store.get('source').length;
21356
- this.dimensionProvider.clearSize(type, sourceLength);
21357
- }
21358
- }
21359
- }
21360
- // set new sizes
21471
+ const oldRows = rowDefinitionByType(oldVal);
21472
+ const dataProvider = this.dataProvider;
21473
+ const dimensionProvider = this.dimensionProvider;
21361
21474
  rowTypes.forEach((t) => {
21362
- var _a;
21363
21475
  const newSizes = newRows[t];
21364
- // apply new sizes or force update
21365
- if (newSizes || forceUpdate) {
21366
- (_a = this.dimensionProvider) === null || _a === void 0 ? void 0 : _a.setCustomSizes(t, (newSizes === null || newSizes === void 0 ? void 0 : newSizes.sizes) || {});
21476
+ const oldSizes = oldRows[t];
21477
+ if (!newSizes && !oldSizes && !forceUpdate) {
21478
+ return;
21367
21479
  }
21480
+ const sizes = Object.assign({}, dimensionProvider.stores[t].store.get('sizes'));
21481
+ const definitionSizes = (newSizes === null || newSizes === void 0 ? void 0 : newSizes.sizes) || {};
21482
+ const previousDefinitionSizes = (oldSizes === null || oldSizes === void 0 ? void 0 : oldSizes.sizes) || {};
21483
+ const items = dataProvider.stores[t].store.get('items');
21484
+ items.forEach((physicalIndex, virtualIndex) => {
21485
+ if (Object.hasOwn(previousDefinitionSizes, physicalIndex) &&
21486
+ sizes[virtualIndex] === previousDefinitionSizes[physicalIndex]) {
21487
+ delete sizes[virtualIndex];
21488
+ }
21489
+ if (Object.hasOwn(definitionSizes, physicalIndex)) {
21490
+ sizes[virtualIndex] = definitionSizes[physicalIndex];
21491
+ }
21492
+ });
21493
+ dimensionProvider.setCustomSizes(t, sizes);
21368
21494
  });
21369
21495
  }
21370
21496
  trimmedRowsChanged(newVal = {}) {
@@ -21413,6 +21539,9 @@ class RevoGridComponent {
21413
21539
  rowHeadersChange(rowHeaders) {
21414
21540
  this.rowheaderschanged.emit(rowHeaders);
21415
21541
  }
21542
+ resizeRowChanged() {
21543
+ this.syncRowResizeConfig();
21544
+ }
21416
21545
  /**
21417
21546
  * Register external VNodes
21418
21547
  */
@@ -21435,6 +21564,7 @@ class RevoGridComponent {
21435
21564
  */
21436
21565
  pluginsChanged(plugins = [], prevPlugins) {
21437
21566
  this.pluginService.addUserPluginsAndCreate(this.element, plugins, prevPlugins, this.getPluginData());
21567
+ this.syncRowResizeConfig();
21438
21568
  }
21439
21569
  // #endregion
21440
21570
  // #region Plugins
@@ -21475,11 +21605,15 @@ class RevoGridComponent {
21475
21605
  this.pluginService.add(new SortingPlugin(this.element, pluginData));
21476
21606
  // register grouping plugin
21477
21607
  this.pluginService.add(new GroupingRowPlugin(this.element, pluginData));
21478
- this.pluginService.add(RowResizePlugin.fromGridProperty(this.element, pluginData));
21608
+ this.pluginService.add(new RowResizePlugin(this.element, pluginData));
21479
21609
  if (this.canMoveColumns) {
21480
21610
  this.pluginService.add(new ColumnMovePlugin(this.element, pluginData));
21481
21611
  }
21482
21612
  }
21613
+ syncRowResizeConfig() {
21614
+ const plugin = this.pluginService.getByClass(RowResizePlugin);
21615
+ plugin === null || plugin === void 0 ? void 0 : plugin.syncGridConfig();
21616
+ }
21483
21617
  getPluginData() {
21484
21618
  if (!this.dimensionProvider || !this.dataProvider || !this.columnProvider || !this.viewportProvider || !this.selectionStoreConnector) {
21485
21619
  return;
@@ -21522,6 +21656,9 @@ class RevoGridComponent {
21522
21656
  this.themeService.setDefinitions(this.themeDefinitions);
21523
21657
  this.dimensionProvider = new DimensionProvider(this.viewportProvider, {
21524
21658
  realSizeChanged: (k) => this.contentsizechanged.emit(k),
21659
+ rowDefinitionsChanged: definitions => {
21660
+ this.rowDefinitions = definitions;
21661
+ },
21525
21662
  });
21526
21663
  this.dimensionProvider.setSettings({ originItemSize: getColumnSize(this.colSize) }, 'rgCol');
21527
21664
  this.columnProvider = new ColumnDataProvider();
@@ -21712,6 +21849,9 @@ class RevoGridComponent {
21712
21849
  "rowHeaders": [{
21713
21850
  "rowHeadersChange": 0
21714
21851
  }],
21852
+ "resizeRow": [{
21853
+ "resizeRowChanged": 0
21854
+ }],
21715
21855
  "registerVNode": [{
21716
21856
  "registerOutsideVNodes": 0
21717
21857
  }],