@revolist/revogrid 4.23.19 → 4.23.21

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 (35) hide show
  1. package/dist/cjs/{column.drag.plugin-ByDJ7Rk3.js → column.drag.plugin-Bjnv6C0x.js} +42 -30
  2. package/dist/cjs/index.cjs.js +2 -1
  3. package/dist/cjs/revo-grid.cjs.entry.js +2 -1
  4. package/dist/cjs/revogr-attribution_7.cjs.entry.js +9 -9
  5. package/dist/cjs/revogr-clipboard_3.cjs.entry.js +1 -1
  6. package/dist/collection/components/editors/revogr-edit-style.css +2 -1
  7. package/dist/collection/components/overlay/revogr-overlay-selection.js +9 -9
  8. package/dist/collection/components/revoGrid/revo-grid.js +22 -0
  9. package/dist/collection/plugins/sorting/sorting.plugin.js +42 -30
  10. package/dist/collection/types/events.js +1 -0
  11. package/dist/esm/{column.drag.plugin-BZacA8n_.js → column.drag.plugin-Bzb8TAwZ.js} +42 -30
  12. package/dist/esm/index.js +3 -2
  13. package/dist/esm/revo-grid.entry.js +2 -1
  14. package/dist/esm/revogr-attribution_7.entry.js +9 -9
  15. package/dist/esm/revogr-clipboard_3.entry.js +1 -1
  16. package/dist/revo-grid/{column.drag.plugin-BZacA8n_.js → column.drag.plugin-Bzb8TAwZ.js} +42 -30
  17. package/dist/revo-grid/index.esm.js +3 -2
  18. package/dist/revo-grid/revo-grid.entry.js +2 -1
  19. package/dist/revo-grid/revogr-attribution_7.entry.js +9 -9
  20. package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
  21. package/dist/types/components/overlay/revogr-overlay-selection.d.ts +1 -1
  22. package/dist/types/components/revoGrid/revo-grid.d.ts +7 -1
  23. package/dist/types/components.d.ts +7 -2
  24. package/dist/types/plugins/sorting/sorting.plugin.d.ts +3 -1
  25. package/dist/types/plugins/sorting/sorting.types.d.ts +22 -1
  26. package/dist/types/types/events.d.ts +1 -1
  27. package/dist/types/types/interfaces.d.ts +4 -0
  28. package/dist/types/types/selection.d.ts +4 -0
  29. package/hydrate/index.js +53 -40
  30. package/hydrate/index.mjs +53 -40
  31. package/package.json +1 -1
  32. package/standalone/index.js +1 -1
  33. package/standalone/revo-grid.js +1 -1
  34. package/standalone/revogr-edit2.js +1 -1
  35. package/standalone/revogr-overlay-selection2.js +1 -1
@@ -1877,7 +1877,7 @@ function mergeSortedRowsWithGroups(indexes, source, sortedRows) {
1877
1877
  * 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.
1878
1878
  * 2. @event `beforesourcesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted.
1879
1879
  * 3. @event `beforesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted. This event is only called from a column sorting click.
1880
- * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
1880
+ * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. The event detail includes the final sorting state and sorting column metadata when available.
1881
1881
  *
1882
1882
  * Note: If you prevent an event, it will not proceed to the subsequent steps.
1883
1883
  */
@@ -2019,6 +2019,38 @@ class SortingPlugin extends BasePlugin {
2019
2019
  });
2020
2020
  this.setSortingState(state);
2021
2021
  }
2022
+ resetSortingForStore(type) {
2023
+ const storeService = this.providers.data.stores[type];
2024
+ // row data
2025
+ const source = storeService.store.get('source');
2026
+ // row indexes
2027
+ const proxyItems = storeService.store.get('proxyItems');
2028
+ // row indexes
2029
+ const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)
2030
+ this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);
2031
+ storeService.setData({ proxyItems: newItemsOrder });
2032
+ }
2033
+ applySortingForStore(type, sorting, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
2034
+ const storeService = this.providers.data.stores[type];
2035
+ // row data
2036
+ const source = storeService.store.get('source');
2037
+ // row indexes
2038
+ const proxyItems = storeService.store.get('proxyItems');
2039
+ const sortItems = getSortableRowIndexes(proxyItems, source);
2040
+ const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, sortingColumns, sortingOrder);
2041
+ const newItemsOrder = mergeSortedRowsWithGroups(proxyItems, source, sortedItems);
2042
+ // take row indexes before trim applied and proxy items
2043
+ const prevItems = storeService.store.get('items');
2044
+ storeService.setData({
2045
+ proxyItems: newItemsOrder,
2046
+ });
2047
+ // take currently visible row indexes
2048
+ const newItems = storeService.store.get('items');
2049
+ if (!ignoreViewportUpdate) {
2050
+ this.providers.dimension
2051
+ .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);
2052
+ }
2053
+ }
2022
2054
  startSorting(order, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
2023
2055
  if (!this.sortingPromise) {
2024
2056
  // add job before render
@@ -2110,45 +2142,25 @@ class SortingPlugin extends BasePlugin {
2110
2142
  // if no sorting - reset
2111
2143
  if (!Object.keys(sorting || {}).length) {
2112
2144
  for (let type of activeTypes) {
2113
- const storeService = this.providers.data.stores[type];
2114
- // row data
2115
- const source = storeService.store.get('source');
2116
- // row indexes
2117
- const proxyItems = storeService.store.get('proxyItems');
2118
- // row indexes
2119
- const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)
2120
- this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);
2121
- storeService.setData({ proxyItems: newItemsOrder });
2145
+ this.resetSortingForStore(type);
2122
2146
  }
2123
2147
  }
2124
2148
  else {
2125
2149
  for (let type of activeTypes) {
2126
- const storeService = this.providers.data.stores[type];
2127
- // row data
2128
- const source = storeService.store.get('source');
2129
- // row indexes
2130
- const proxyItems = storeService.store.get('proxyItems');
2131
- const sortItems = getSortableRowIndexes(proxyItems, source);
2132
- const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, activeSortingColumns, activeSortingOrder);
2133
- const newItemsOrder = mergeSortedRowsWithGroups(proxyItems, source, sortedItems);
2134
- // take row indexes before trim applied and proxy items
2135
- const prevItems = storeService.store.get('items');
2136
- storeService.setData({
2137
- proxyItems: newItemsOrder,
2138
- });
2139
- // take currently visible row indexes
2140
- const newItems = storeService.store.get('items');
2141
- if (!activeIgnoreViewportUpdate) {
2142
- this.providers.dimension
2143
- .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);
2144
- }
2150
+ this.applySortingForStore(type, sorting, sortingFunc, activeSortingColumns, activeSortingOrder, activeIgnoreViewportUpdate);
2145
2151
  }
2146
2152
  }
2147
2153
  // refresh columns to redraw column headers and show correct icon
2148
2154
  column_service.columnTypes.forEach((type) => {
2149
2155
  this.providers.column.dataSources[type].refresh();
2150
2156
  });
2151
- this.emit('aftersortingapply');
2157
+ const afterSortingDetail = {
2158
+ sorting: hasActiveSorting(sorting) ? sorting : undefined,
2159
+ sortingColumns: activeSortingColumns,
2160
+ sortingOrder: activeSortingOrder,
2161
+ types: activeTypes,
2162
+ };
2163
+ this.emit('aftersortingapply', afterSortingDetail);
2152
2164
  }
2153
2165
  }
2154
2166
 
@@ -4,7 +4,7 @@
4
4
  'use strict';
5
5
 
6
6
  var column_service = require('./column.service-BNWNiJW3.js');
7
- var column_drag_plugin = require('./column.drag.plugin-ByDJ7Rk3.js');
7
+ var column_drag_plugin = require('./column.drag.plugin-Bjnv6C0x.js');
8
8
  var headerCellRenderer = require('./header-cell-renderer-DyjOxArm.js');
9
9
  var cellRenderer = require('./cell-renderer-DfUCisis.js');
10
10
  var index$1 = require('./index-DxaSE5uZ.js');
@@ -28,6 +28,7 @@ const REVOGRID_EVENTS = new Map([
28
28
  ['beforesorting', 'beforesorting'],
29
29
  ['beforesourcesortingapply', 'beforesourcesortingapply'],
30
30
  ['beforesortingapply', 'beforesortingapply'],
31
+ ['aftersortingapply', 'aftersortingapply'],
31
32
  ['rowdragstart', 'rowdragstart'],
32
33
  ['headerclick', 'headerclick'],
33
34
  ['beforecellfocus', 'beforecellfocus'],
@@ -8,7 +8,7 @@ var column_service = require('./column.service-BNWNiJW3.js');
8
8
  var dimension_helpers = require('./dimension.helpers-B9HgANnM.js');
9
9
  var debounce = require('./debounce-CcpHiH2p.js');
10
10
  var viewport_helpers = require('./viewport.helpers-BND76K2j.js');
11
- var column_drag_plugin = require('./column.drag.plugin-ByDJ7Rk3.js');
11
+ var column_drag_plugin = require('./column.drag.plugin-Bjnv6C0x.js');
12
12
  var viewport_store = require('./viewport.store-BscUCiUk.js');
13
13
  var theme_service = require('./theme.service-BgnxGIjK.js');
14
14
  var index$1 = require('./index-DxaSE5uZ.js');
@@ -1407,6 +1407,7 @@ const RevoGridComponent = class {
1407
1407
  this.beforesorting = index.createEvent(this, "beforesorting", 7);
1408
1408
  this.beforesourcesortingapply = index.createEvent(this, "beforesourcesortingapply", 7);
1409
1409
  this.beforesortingapply = index.createEvent(this, "beforesortingapply", 7);
1410
+ this.aftersortingapply = index.createEvent(this, "aftersortingapply", 7);
1410
1411
  this.rowdragstart = index.createEvent(this, "rowdragstart", 7);
1411
1412
  this.headerclick = index.createEvent(this, "headerclick", 7);
1412
1413
  this.beforecellfocus = index.createEvent(this, "beforecellfocus", 7);
@@ -929,13 +929,13 @@ const OverlaySelection = class {
929
929
  /**
930
930
  * Executes the focus operation on the specified range of cells.
931
931
  */
932
- doFocus(focus, end, changes) {
932
+ doFocus(focus, end, changes, originalEvent) {
933
933
  // 1. Trigger beforeFocus event
934
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
934
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
935
935
  if (defaultPrevented) {
936
936
  return false;
937
937
  }
938
- const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
938
+ const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
939
939
  // 2. Trigger apply focus event
940
940
  const applyEvent = this.applyFocus.emit(evData);
941
941
  if (applyEvent.defaultPrevented) {
@@ -951,10 +951,10 @@ const OverlaySelection = class {
951
951
  y: range.y1,
952
952
  } }, applyEvent.detail)).defaultPrevented;
953
953
  }
954
- triggerRangeEvent(range) {
954
+ triggerRangeEvent(range, originalEvent) {
955
955
  const type = this.types.rowType;
956
956
  // 1. Apply range
957
- const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
957
+ const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
958
958
  if (applyEvent.defaultPrevented) {
959
959
  return false;
960
960
  }
@@ -1005,7 +1005,7 @@ const OverlaySelection = class {
1005
1005
  return;
1006
1006
  }
1007
1007
  // Set focus on the current cell
1008
- this.focus(focusCell, this.range && e.shiftKey);
1008
+ this.focus(focusCell, this.range && e.shiftKey, e);
1009
1009
  // Initiate autofill selection
1010
1010
  if (this.range) {
1011
1011
  targetElement &&
@@ -1159,7 +1159,7 @@ const OverlaySelection = class {
1159
1159
  /**
1160
1160
  * Sets the focus on a cell and optionally edits a range.
1161
1161
  */
1162
- focus(cell, isRangeEdit = false) {
1162
+ focus(cell, isRangeEdit = false, originalEvent) {
1163
1163
  if (!cell)
1164
1164
  return false;
1165
1165
  const end = cell;
@@ -1167,10 +1167,10 @@ const OverlaySelection = class {
1167
1167
  if (isRangeEdit && start) {
1168
1168
  const range = column_service.getRange(start, end);
1169
1169
  if (range) {
1170
- return this.triggerRangeEvent(range);
1170
+ return this.triggerRangeEvent(range, originalEvent);
1171
1171
  }
1172
1172
  }
1173
- return this.doFocus(cell, end);
1173
+ return this.doFocus(cell, end, undefined, originalEvent);
1174
1174
  }
1175
1175
  get types() {
1176
1176
  return {
@@ -149,7 +149,7 @@ const Clipboard = class {
149
149
  }
150
150
  };
151
151
 
152
- const revogrEditStyleCss = () => `revogr-edit{display:block;position:absolute;background-color:#fff}revogr-edit input{height:100%;width:100%;box-sizing:border-box}revogr-edit revo-dropdown{height:100%}revogr-edit revo-dropdown.shrink fieldset legend>span{display:none}`;
152
+ const revogrEditStyleCss = () => `revogr-edit{display:block;position:absolute;background-color:var(--revo-grid-background, #fff)}revogr-edit input{height:100%;width:100%;box-sizing:border-box;background-color:var(--revo-grid-background, transparent)}revogr-edit revo-dropdown{height:100%}revogr-edit revo-dropdown.shrink fieldset legend>span{display:none}`;
153
153
 
154
154
  const RevoEdit = class {
155
155
  constructor(hostRef) {
@@ -1,12 +1,13 @@
1
1
  revogr-edit {
2
2
  display: block;
3
3
  position: absolute;
4
- background-color: #fff;
4
+ background-color: var(--revo-grid-background, #fff);
5
5
  }
6
6
  revogr-edit input {
7
7
  height: 100%;
8
8
  width: 100%;
9
9
  box-sizing: border-box;
10
+ background-color: var(--revo-grid-background, transparent);
10
11
  }
11
12
  revogr-edit revo-dropdown {
12
13
  height: 100%;
@@ -241,13 +241,13 @@ export class OverlaySelection {
241
241
  /**
242
242
  * Executes the focus operation on the specified range of cells.
243
243
  */
244
- doFocus(focus, end, changes) {
244
+ doFocus(focus, end, changes, originalEvent) {
245
245
  // 1. Trigger beforeFocus event
246
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
246
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
247
247
  if (defaultPrevented) {
248
248
  return false;
249
249
  }
250
- const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
250
+ const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
251
251
  // 2. Trigger apply focus event
252
252
  const applyEvent = this.applyFocus.emit(evData);
253
253
  if (applyEvent.defaultPrevented) {
@@ -263,10 +263,10 @@ export class OverlaySelection {
263
263
  y: range.y1,
264
264
  } }, applyEvent.detail)).defaultPrevented;
265
265
  }
266
- triggerRangeEvent(range) {
266
+ triggerRangeEvent(range, originalEvent) {
267
267
  const type = this.types.rowType;
268
268
  // 1. Apply range
269
- const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
269
+ const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
270
270
  if (applyEvent.defaultPrevented) {
271
271
  return false;
272
272
  }
@@ -317,7 +317,7 @@ export class OverlaySelection {
317
317
  return;
318
318
  }
319
319
  // Set focus on the current cell
320
- this.focus(focusCell, this.range && e.shiftKey);
320
+ this.focus(focusCell, this.range && e.shiftKey, e);
321
321
  // Initiate autofill selection
322
322
  if (this.range) {
323
323
  targetElement &&
@@ -471,7 +471,7 @@ export class OverlaySelection {
471
471
  /**
472
472
  * Sets the focus on a cell and optionally edits a range.
473
473
  */
474
- focus(cell, isRangeEdit = false) {
474
+ focus(cell, isRangeEdit = false, originalEvent) {
475
475
  if (!cell)
476
476
  return false;
477
477
  const end = cell;
@@ -479,10 +479,10 @@ export class OverlaySelection {
479
479
  if (isRangeEdit && start) {
480
480
  const range = getRange(start, end);
481
481
  if (range) {
482
- return this.triggerRangeEvent(range);
482
+ return this.triggerRangeEvent(range, originalEvent);
483
483
  }
484
484
  }
485
- return this.doFocus(cell, end);
485
+ return this.doFocus(cell, end, undefined, originalEvent);
486
486
  }
487
487
  get types() {
488
488
  return {
@@ -2248,6 +2248,28 @@ export class RevoGridComponent {
2248
2248
  }
2249
2249
  }
2250
2250
  }
2251
+ }, {
2252
+ "method": "aftersortingapply",
2253
+ "name": "aftersortingapply",
2254
+ "bubbles": true,
2255
+ "cancelable": true,
2256
+ "composed": true,
2257
+ "docs": {
2258
+ "tags": [],
2259
+ "text": "By `SortingPlugin`\n<br>Triggered after sorting has been applied and completed.\n<br>Provides final sorting state and sorting column metadata when available."
2260
+ },
2261
+ "complexType": {
2262
+ "original": "AfterSortingApplyEvent",
2263
+ "resolved": "{ sorting?: SortingOrder | undefined; sortingColumns?: SortingColumnMap | undefined; sortingOrder?: SortingColumnOrder | undefined; types: DimensionRows[]; }",
2264
+ "references": {
2265
+ "AfterSortingApplyEvent": {
2266
+ "location": "import",
2267
+ "path": "../../plugins",
2268
+ "id": "src/plugins/index.ts::AfterSortingApplyEvent",
2269
+ "referenceLocation": "AfterSortingApplyEvent"
2270
+ }
2271
+ }
2272
+ }
2251
2273
  }, {
2252
2274
  "method": "rowdragstart",
2253
2275
  "name": "rowdragstart",
@@ -30,7 +30,7 @@ function mergeSortedRowsWithGroups(indexes, source, sortedRows) {
30
30
  * 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.
31
31
  * 2. @event `beforesourcesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted.
32
32
  * 3. @event `beforesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted. This event is only called from a column sorting click.
33
- * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
33
+ * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. The event detail includes the final sorting state and sorting column metadata when available.
34
34
  *
35
35
  * Note: If you prevent an event, it will not proceed to the subsequent steps.
36
36
  */
@@ -172,6 +172,38 @@ export class SortingPlugin extends BasePlugin {
172
172
  });
173
173
  this.setSortingState(state);
174
174
  }
175
+ resetSortingForStore(type) {
176
+ const storeService = this.providers.data.stores[type];
177
+ // row data
178
+ const source = storeService.store.get('source');
179
+ // row indexes
180
+ const proxyItems = storeService.store.get('proxyItems');
181
+ // row indexes
182
+ const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)
183
+ this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);
184
+ storeService.setData({ proxyItems: newItemsOrder });
185
+ }
186
+ applySortingForStore(type, sorting, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
187
+ const storeService = this.providers.data.stores[type];
188
+ // row data
189
+ const source = storeService.store.get('source');
190
+ // row indexes
191
+ const proxyItems = storeService.store.get('proxyItems');
192
+ const sortItems = getSortableRowIndexes(proxyItems, source);
193
+ const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, sortingColumns, sortingOrder);
194
+ const newItemsOrder = mergeSortedRowsWithGroups(proxyItems, source, sortedItems);
195
+ // take row indexes before trim applied and proxy items
196
+ const prevItems = storeService.store.get('items');
197
+ storeService.setData({
198
+ proxyItems: newItemsOrder,
199
+ });
200
+ // take currently visible row indexes
201
+ const newItems = storeService.store.get('items');
202
+ if (!ignoreViewportUpdate) {
203
+ this.providers.dimension
204
+ .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);
205
+ }
206
+ }
175
207
  startSorting(order, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
176
208
  if (!this.sortingPromise) {
177
209
  // add job before render
@@ -263,44 +295,24 @@ export class SortingPlugin extends BasePlugin {
263
295
  // if no sorting - reset
264
296
  if (!Object.keys(sorting || {}).length) {
265
297
  for (let type of activeTypes) {
266
- const storeService = this.providers.data.stores[type];
267
- // row data
268
- const source = storeService.store.get('source');
269
- // row indexes
270
- const proxyItems = storeService.store.get('proxyItems');
271
- // row indexes
272
- const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)
273
- this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);
274
- storeService.setData({ proxyItems: newItemsOrder });
298
+ this.resetSortingForStore(type);
275
299
  }
276
300
  }
277
301
  else {
278
302
  for (let type of activeTypes) {
279
- const storeService = this.providers.data.stores[type];
280
- // row data
281
- const source = storeService.store.get('source');
282
- // row indexes
283
- const proxyItems = storeService.store.get('proxyItems');
284
- const sortItems = getSortableRowIndexes(proxyItems, source);
285
- const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, activeSortingColumns, activeSortingOrder);
286
- const newItemsOrder = mergeSortedRowsWithGroups(proxyItems, source, sortedItems);
287
- // take row indexes before trim applied and proxy items
288
- const prevItems = storeService.store.get('items');
289
- storeService.setData({
290
- proxyItems: newItemsOrder,
291
- });
292
- // take currently visible row indexes
293
- const newItems = storeService.store.get('items');
294
- if (!activeIgnoreViewportUpdate) {
295
- this.providers.dimension
296
- .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);
297
- }
303
+ this.applySortingForStore(type, sorting, sortingFunc, activeSortingColumns, activeSortingOrder, activeIgnoreViewportUpdate);
298
304
  }
299
305
  }
300
306
  // refresh columns to redraw column headers and show correct icon
301
307
  columnTypes.forEach((type) => {
302
308
  this.providers.column.dataSources[type].refresh();
303
309
  });
304
- this.emit('aftersortingapply');
310
+ const afterSortingDetail = {
311
+ sorting: hasActiveSorting(sorting) ? sorting : undefined,
312
+ sortingColumns: activeSortingColumns,
313
+ sortingOrder: activeSortingOrder,
314
+ types: activeTypes,
315
+ };
316
+ this.emit('aftersortingapply', afterSortingDetail);
305
317
  }
306
318
  }
@@ -13,6 +13,7 @@ export const REVOGRID_EVENTS = new Map([
13
13
  ['beforesorting', 'beforesorting'],
14
14
  ['beforesourcesortingapply', 'beforesourcesortingapply'],
15
15
  ['beforesortingapply', 'beforesortingapply'],
16
+ ['aftersortingapply', 'aftersortingapply'],
16
17
  ['rowdragstart', 'rowdragstart'],
17
18
  ['headerclick', 'headerclick'],
18
19
  ['beforecellfocus', 'beforecellfocus'],
@@ -1875,7 +1875,7 @@ function mergeSortedRowsWithGroups(indexes, source, sortedRows) {
1875
1875
  * 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.
1876
1876
  * 2. @event `beforesourcesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted.
1877
1877
  * 3. @event `beforesortingapply` - Triggered before the sorting data is applied to the data source. You can prevent this event, and the data will not be sorted. This event is only called from a column sorting click.
1878
- * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
1878
+ * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. The event detail includes the final sorting state and sorting column metadata when available.
1879
1879
  *
1880
1880
  * Note: If you prevent an event, it will not proceed to the subsequent steps.
1881
1881
  */
@@ -2017,6 +2017,38 @@ class SortingPlugin extends BasePlugin {
2017
2017
  });
2018
2018
  this.setSortingState(state);
2019
2019
  }
2020
+ resetSortingForStore(type) {
2021
+ const storeService = this.providers.data.stores[type];
2022
+ // row data
2023
+ const source = storeService.store.get('source');
2024
+ // row indexes
2025
+ const proxyItems = storeService.store.get('proxyItems');
2026
+ // row indexes
2027
+ const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)
2028
+ this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);
2029
+ storeService.setData({ proxyItems: newItemsOrder });
2030
+ }
2031
+ applySortingForStore(type, sorting, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
2032
+ const storeService = this.providers.data.stores[type];
2033
+ // row data
2034
+ const source = storeService.store.get('source');
2035
+ // row indexes
2036
+ const proxyItems = storeService.store.get('proxyItems');
2037
+ const sortItems = getSortableRowIndexes(proxyItems, source);
2038
+ const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, sortingColumns, sortingOrder);
2039
+ const newItemsOrder = mergeSortedRowsWithGroups(proxyItems, source, sortedItems);
2040
+ // take row indexes before trim applied and proxy items
2041
+ const prevItems = storeService.store.get('items');
2042
+ storeService.setData({
2043
+ proxyItems: newItemsOrder,
2044
+ });
2045
+ // take currently visible row indexes
2046
+ const newItems = storeService.store.get('items');
2047
+ if (!ignoreViewportUpdate) {
2048
+ this.providers.dimension
2049
+ .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);
2050
+ }
2051
+ }
2020
2052
  startSorting(order, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
2021
2053
  if (!this.sortingPromise) {
2022
2054
  // add job before render
@@ -2108,45 +2140,25 @@ class SortingPlugin extends BasePlugin {
2108
2140
  // if no sorting - reset
2109
2141
  if (!Object.keys(sorting || {}).length) {
2110
2142
  for (let type of activeTypes) {
2111
- const storeService = this.providers.data.stores[type];
2112
- // row data
2113
- const source = storeService.store.get('source');
2114
- // row indexes
2115
- const proxyItems = storeService.store.get('proxyItems');
2116
- // row indexes
2117
- const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)
2118
- this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);
2119
- storeService.setData({ proxyItems: newItemsOrder });
2143
+ this.resetSortingForStore(type);
2120
2144
  }
2121
2145
  }
2122
2146
  else {
2123
2147
  for (let type of activeTypes) {
2124
- const storeService = this.providers.data.stores[type];
2125
- // row data
2126
- const source = storeService.store.get('source');
2127
- // row indexes
2128
- const proxyItems = storeService.store.get('proxyItems');
2129
- const sortItems = getSortableRowIndexes(proxyItems, source);
2130
- const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, activeSortingColumns, activeSortingOrder);
2131
- const newItemsOrder = mergeSortedRowsWithGroups(proxyItems, source, sortedItems);
2132
- // take row indexes before trim applied and proxy items
2133
- const prevItems = storeService.store.get('items');
2134
- storeService.setData({
2135
- proxyItems: newItemsOrder,
2136
- });
2137
- // take currently visible row indexes
2138
- const newItems = storeService.store.get('items');
2139
- if (!activeIgnoreViewportUpdate) {
2140
- this.providers.dimension
2141
- .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);
2142
- }
2148
+ this.applySortingForStore(type, sorting, sortingFunc, activeSortingColumns, activeSortingOrder, activeIgnoreViewportUpdate);
2143
2149
  }
2144
2150
  }
2145
2151
  // refresh columns to redraw column headers and show correct icon
2146
2152
  columnTypes.forEach((type) => {
2147
2153
  this.providers.column.dataSources[type].refresh();
2148
2154
  });
2149
- this.emit('aftersortingapply');
2155
+ const afterSortingDetail = {
2156
+ sorting: hasActiveSorting(sorting) ? sorting : undefined,
2157
+ sortingColumns: activeSortingColumns,
2158
+ sortingOrder: activeSortingOrder,
2159
+ types: activeTypes,
2160
+ };
2161
+ this.emit('aftersortingapply', afterSortingDetail);
2150
2162
  }
2151
2163
  }
2152
2164
 
package/dist/esm/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
4
  export { o as GROUPING_ROW_TYPE, j as GROUP_COLUMN_PROP, G as GROUP_DEPTH, h as GROUP_EXPANDED, l as GROUP_EXPAND_BTN, m as GROUP_EXPAND_EVENT, k as GROUP_ORIGINAL_INDEX, f as PSEUDO_GROUP_COLUMN, P as PSEUDO_GROUP_ITEM, d as PSEUDO_GROUP_ITEM_ID, e as PSEUDO_GROUP_ITEM_VALUE, c as columnTypes, a as cropCellToMax, H as gatherGroup, s as gatherGrouping, z as getCellData, B as getCellDataParsed, A as getCellRaw, I as getColumnByProp, D as getColumnSizes, C as getColumnType, F as getColumns, q as getExpanded, t as getGroupingName, x as getParsedGroup, g as getRange, p as getSource, E as isColGrouping, u as isGrouping, v as isGroupingColumn, b as isRangeSingleCell, i as isRowType, y as isSameGroup, w as measureEqualDepth, n as nextCell, r as rowTypes } from './column.service-C6hByxPy.js';
5
- import { B as BasePlugin } from './column.drag.plugin-BZacA8n_.js';
6
- export { A as AutoSizeColumnPlugin, n as BEFORE_COLUMN_DRAG_END_EVENT, m as COLUMN_DRAG_END_EVENT, l as COLUMN_DRAG_MOVE_EVENT, o as COLUMN_DRAG_START_EVENT, C as ColumnAutoSizeMode, p as ColumnMovePlugin, D as DimensionStore, b as ExportCsv, E as ExportFilePlugin, c as FILTER_CONFIG_CHANGED_EVENT, F as FILTER_TRIMMED_TYPE, d as FILTE_PANEL, e as FilterPlugin, G as GroupingRowPlugin, S as SelectionStore, s as SortingPlugin, a as StretchColumn, w as defaultCellCompare, x as descCellCompare, j as doCollapse, k as doExpand, f as filterCoreFunctionsIndexedByType, h as filterNames, g as filterTypes, r as getColumnDragPosition, z as getComparer, q as getLeftRelative, y as getNextOrder, u as getSortingIndex, t as hasActiveSorting, i as isStretchPlugin, v as sortIndexByItems } from './column.drag.plugin-BZacA8n_.js';
5
+ import { B as BasePlugin } from './column.drag.plugin-Bzb8TAwZ.js';
6
+ export { A as AutoSizeColumnPlugin, n as BEFORE_COLUMN_DRAG_END_EVENT, m as COLUMN_DRAG_END_EVENT, l as COLUMN_DRAG_MOVE_EVENT, o as COLUMN_DRAG_START_EVENT, C as ColumnAutoSizeMode, p as ColumnMovePlugin, D as DimensionStore, b as ExportCsv, E as ExportFilePlugin, c as FILTER_CONFIG_CHANGED_EVENT, F as FILTER_TRIMMED_TYPE, d as FILTE_PANEL, e as FilterPlugin, G as GroupingRowPlugin, S as SelectionStore, s as SortingPlugin, a as StretchColumn, w as defaultCellCompare, x as descCellCompare, j as doCollapse, k as doExpand, f as filterCoreFunctionsIndexedByType, h as filterNames, g as filterTypes, r as getColumnDragPosition, z as getComparer, q as getLeftRelative, y as getNextOrder, u as getSortingIndex, t as hasActiveSorting, i as isStretchPlugin, v as sortIndexByItems } from './column.drag.plugin-Bzb8TAwZ.js';
7
7
  export { d as dispatch, a as dispatchByEvent } from './header-cell-renderer-BMmXRsd_.js';
8
8
  export { C as CellRenderer, G as GroupingRowRenderer, S as SortingSign, e as expandEvent, a as expandSvgIconVNode } from './cell-renderer-CLTRlCa5.js';
9
9
  export { a as applyMixins, f as findPositionInArray, g as getScrollbarSize, m as mergeSortedArray, p as pushSorted, r as range, s as scaleValue, t as timeout } from './index-Db3qZoW5.js';
@@ -27,6 +27,7 @@ const REVOGRID_EVENTS = new Map([
27
27
  ['beforesorting', 'beforesorting'],
28
28
  ['beforesourcesortingapply', 'beforesourcesortingapply'],
29
29
  ['beforesortingapply', 'beforesortingapply'],
30
+ ['aftersortingapply', 'aftersortingapply'],
30
31
  ['rowdragstart', 'rowdragstart'],
31
32
  ['headerclick', 'headerclick'],
32
33
  ['beforecellfocus', 'beforecellfocus'],
@@ -6,7 +6,7 @@ import { c as columnTypes, J as reduce, C as getColumnType, r as rowTypes, i as
6
6
  import { D as DataStore, b as getSourceItem, f as getSourceItemVirtualIndexByProp, d as setSourceByPhysicalIndex, s as setSourceByVirtualIndex, a as getVisibleSourceItem, h as gatherTrimmedItems, k as getItemByIndex, R as RESIZE_INTERVAL } from './dimension.helpers-CGKwSvw6.js';
7
7
  import { d as debounce } from './debounce-PCRWZliA.js';
8
8
  import { g as getScrollDimension, v as viewportDataPartition, F as FOOTER_SLOT, C as CONTENT_SLOT, H as HEADER_SLOT, D as DATA_SLOT } from './viewport.helpers-CoCAvmZs.js';
9
- import { D as DimensionStore, S as SelectionStore, B as BasePlugin, G as GroupingRowPlugin, a as StretchColumn, i as isStretchPlugin, A as AutoSizeColumnPlugin, e as FilterPlugin, E as ExportFilePlugin, s as SortingPlugin, p as ColumnMovePlugin } from './column.drag.plugin-BZacA8n_.js';
9
+ import { D as DimensionStore, S as SelectionStore, B as BasePlugin, G as GroupingRowPlugin, a as StretchColumn, i as isStretchPlugin, A as AutoSizeColumnPlugin, e as FilterPlugin, E as ExportFilePlugin, s as SortingPlugin, p as ColumnMovePlugin } from './column.drag.plugin-Bzb8TAwZ.js';
10
10
  import { V as ViewportStore } from './viewport.store-_c579YyM.js';
11
11
  import { T as ThemeService } from './theme.service-BmnDvr6P.js';
12
12
  import { t as timeout } from './index-Db3qZoW5.js';
@@ -1405,6 +1405,7 @@ const RevoGridComponent = class {
1405
1405
  this.beforesorting = createEvent(this, "beforesorting", 7);
1406
1406
  this.beforesourcesortingapply = createEvent(this, "beforesourcesortingapply", 7);
1407
1407
  this.beforesortingapply = createEvent(this, "beforesortingapply", 7);
1408
+ this.aftersortingapply = createEvent(this, "aftersortingapply", 7);
1408
1409
  this.rowdragstart = createEvent(this, "rowdragstart", 7);
1409
1410
  this.headerclick = createEvent(this, "headerclick", 7);
1410
1411
  this.beforecellfocus = createEvent(this, "beforecellfocus", 7);
@@ -927,13 +927,13 @@ const OverlaySelection = class {
927
927
  /**
928
928
  * Executes the focus operation on the specified range of cells.
929
929
  */
930
- doFocus(focus, end, changes) {
930
+ doFocus(focus, end, changes, originalEvent) {
931
931
  // 1. Trigger beforeFocus event
932
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
932
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
933
933
  if (defaultPrevented) {
934
934
  return false;
935
935
  }
936
- const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) });
936
+ const evData = Object.assign(Object.assign({ range: Object.assign(Object.assign({}, focus), { x1: end.x, y1: end.y }), next: changes }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent });
937
937
  // 2. Trigger apply focus event
938
938
  const applyEvent = this.applyFocus.emit(evData);
939
939
  if (applyEvent.defaultPrevented) {
@@ -949,10 +949,10 @@ const OverlaySelection = class {
949
949
  y: range.y1,
950
950
  } }, applyEvent.detail)).defaultPrevented;
951
951
  }
952
- triggerRangeEvent(range) {
952
+ triggerRangeEvent(range, originalEvent) {
953
953
  const type = this.types.rowType;
954
954
  // 1. Apply range
955
- const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state) }));
955
+ const applyEvent = this.beforeApplyRange.emit(Object.assign(Object.assign({ range: Object.assign({}, range) }, this.types), { rowDimension: Object.assign({}, this.dimensionRow.state), colDimension: Object.assign({}, this.dimensionCol.state), originalEvent }));
956
956
  if (applyEvent.defaultPrevented) {
957
957
  return false;
958
958
  }
@@ -1003,7 +1003,7 @@ const OverlaySelection = class {
1003
1003
  return;
1004
1004
  }
1005
1005
  // Set focus on the current cell
1006
- this.focus(focusCell, this.range && e.shiftKey);
1006
+ this.focus(focusCell, this.range && e.shiftKey, e);
1007
1007
  // Initiate autofill selection
1008
1008
  if (this.range) {
1009
1009
  targetElement &&
@@ -1157,7 +1157,7 @@ const OverlaySelection = class {
1157
1157
  /**
1158
1158
  * Sets the focus on a cell and optionally edits a range.
1159
1159
  */
1160
- focus(cell, isRangeEdit = false) {
1160
+ focus(cell, isRangeEdit = false, originalEvent) {
1161
1161
  if (!cell)
1162
1162
  return false;
1163
1163
  const end = cell;
@@ -1165,10 +1165,10 @@ const OverlaySelection = class {
1165
1165
  if (isRangeEdit && start) {
1166
1166
  const range = getRange(start, end);
1167
1167
  if (range) {
1168
- return this.triggerRangeEvent(range);
1168
+ return this.triggerRangeEvent(range, originalEvent);
1169
1169
  }
1170
1170
  }
1171
- return this.doFocus(cell, end);
1171
+ return this.doFocus(cell, end, undefined, originalEvent);
1172
1172
  }
1173
1173
  get types() {
1174
1174
  return {