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