@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
@@ -147,7 +147,7 @@ const Clipboard = class {
147
147
  }
148
148
  };
149
149
 
150
- 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}`;
150
+ 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}`;
151
151
 
152
152
  const RevoEdit = class {
153
153
  constructor(hostRef) {
@@ -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
 
@@ -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 {
@@ -147,7 +147,7 @@ const Clipboard = class {
147
147
  }
148
148
  };
149
149
 
150
- 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}`;
150
+ 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}`;
151
151
 
152
152
  const RevoEdit = class {
153
153
  constructor(hostRef) {
@@ -268,7 +268,7 @@ export declare class OverlaySelection {
268
268
  /**
269
269
  * Sets the focus on a cell and optionally edits a range.
270
270
  */
271
- focus(cell?: Cell, isRangeEdit?: boolean): boolean;
271
+ focus(cell?: Cell, isRangeEdit?: boolean, originalEvent?: MouseEvent | TouchEvent | KeyboardEvent): boolean;
272
272
  get types(): AllDimensionType;
273
273
  /**
274
274
  * Collect data
@@ -18,7 +18,7 @@ import type { GridPlugin } from '../../plugins/base.plugin';
18
18
  import { ColumnCollection } from '../../utils/column.utils';
19
19
  import { ColumnFilterConfig, FilterCollectionItem } from '../../plugins/filter/filter.types';
20
20
  import { PluginService } from './plugin.service';
21
- import { SortingConfig, SortingOrder } from '../../plugins';
21
+ import { AfterSortingApplyEvent, SortingConfig, SortingOrder } from '../../plugins';
22
22
  /**
23
23
  * Revogrid - High-performance, customizable grid library for managing large datasets.
24
24
  * ### Events guide
@@ -298,6 +298,12 @@ export declare class RevoGridComponent {
298
298
  order: 'desc' | 'asc';
299
299
  additive: boolean;
300
300
  }>;
301
+ /**
302
+ * By `SortingPlugin`
303
+ * <br>Triggered after sorting has been applied and completed.
304
+ * <br>Provides final sorting state and sorting column metadata when available.
305
+ */
306
+ aftersortingapply: EventEmitter<AfterSortingApplyEvent>;
301
307
  /**
302
308
  * This event is triggered when the row order change is started.
303
309
  * To prevent the default behavior of changing the row order, you can call `e.preventDefault()`.
@@ -9,7 +9,7 @@ import { AdditionalData, AfterEditEvent, AllDimensionType, ApplyFocusEvent, Befo
9
9
  import { GridPlugin } from "./plugins/base.plugin";
10
10
  import { AutoSizeColumnConfig } from "./plugins/column.auto-size.plugin";
11
11
  import { ColumnFilterConfig, FilterCaptions, FilterCollectionItem, LogicFunction, MultiFilterItem, ShowData } from "./plugins/filter/filter.types";
12
- import { SortingConfig, SortingOrder } from "./plugins";
12
+ import { AfterSortingApplyEvent, SortingConfig, SortingOrder } from "./plugins";
13
13
  import { GroupingOptions } from "./plugins/groupingRow/grouping.row.types";
14
14
  import { VNode } from "./stencil-public-runtime";
15
15
  import { FocusedData } from "./components/revoGrid/viewport.service";
@@ -25,7 +25,7 @@ export { AdditionalData, AfterEditEvent, AllDimensionType, ApplyFocusEvent, Befo
25
25
  export { GridPlugin } from "./plugins/base.plugin";
26
26
  export { AutoSizeColumnConfig } from "./plugins/column.auto-size.plugin";
27
27
  export { ColumnFilterConfig, FilterCaptions, FilterCollectionItem, LogicFunction, MultiFilterItem, ShowData } from "./plugins/filter/filter.types";
28
- export { SortingConfig, SortingOrder } from "./plugins";
28
+ export { AfterSortingApplyEvent, SortingConfig, SortingOrder } from "./plugins";
29
29
  export { GroupingOptions } from "./plugins/groupingRow/grouping.row.types";
30
30
  export { VNode } from "./stencil-public-runtime";
31
31
  export { FocusedData } from "./components/revoGrid/viewport.service";
@@ -889,6 +889,7 @@ declare global {
889
889
  order: 'desc' | 'asc';
890
890
  additive: boolean;
891
891
  };
892
+ "aftersortingapply": AfterSortingApplyEvent;
892
893
  "rowdragstart": RowDragStartDetails;
893
894
  "headerclick": ColumnRegular;
894
895
  "beforecellfocus": BeforeSaveDataDetails;
@@ -1510,6 +1511,10 @@ declare namespace LocalJSX {
1510
1511
  * Emmited after the grid is rendered.
1511
1512
  */
1512
1513
  "onAftergridrender"?: (event: RevoGridCustomEvent<any>) => void;
1514
+ /**
1515
+ * By `SortingPlugin` <br>Triggered after sorting has been applied and completed. <br>Provides final sorting state and sorting column metadata when available.
1516
+ */
1517
+ "onAftersortingapply"?: (event: RevoGridCustomEvent<AfterSortingApplyEvent>) => void;
1513
1518
  /**
1514
1519
  * After main source/rows updated
1515
1520
  */
@@ -9,7 +9,7 @@ export * from './sorting.sign';
9
9
  * 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.
10
10
  * 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.
11
11
  * 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.
12
- * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
12
+ * 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.
13
13
  *
14
14
  * Note: If you prevent an event, it will not proceed to the subsequent steps.
15
15
  */
@@ -72,6 +72,8 @@ export declare class SortingPlugin extends BasePlugin {
72
72
  * comparator, and column metadata maps.
73
73
  */
74
74
  private applySortingConfig;
75
+ private resetSortingForStore;
76
+ private applySortingForStore;
75
77
  /**
76
78
  * Schedules sorting before the next render.
77
79
  *
@@ -1,4 +1,4 @@
1
- import type { CellCompareFunc, ColumnProp, ColumnRegular, Order } from "../../types/index";
1
+ import type { CellCompareFunc, ColumnProp, ColumnRegular, DimensionRows, Order } from "../../types/index";
2
2
  /**
3
3
  * Current sorting order per column property.
4
4
  */
@@ -33,6 +33,27 @@ export type SortingColumnRender = {
33
33
  */
34
34
  sortIndex?: number;
35
35
  };
36
+ /**
37
+ * Sorting information emitted after sorting is applied.
38
+ */
39
+ export type AfterSortingApplyEvent = {
40
+ /**
41
+ * Final active sorting order per column property.
42
+ */
43
+ sorting?: SortingOrder;
44
+ /**
45
+ * Column metadata indexed by sorted column property.
46
+ */
47
+ sortingColumns?: SortingColumnMap;
48
+ /**
49
+ * Active sorting priority in click/config insertion order.
50
+ */
51
+ sortingOrder?: SortingColumnOrder;
52
+ /**
53
+ * Row stores affected by the sorting run.
54
+ */
55
+ types: DimensionRows[];
56
+ };
36
57
  /**
37
58
  * Sorting information emitted after columns are set.
38
59
  */
@@ -1,2 +1,2 @@
1
- export type RevogridEvents = 'contentsizechanged' | 'beforeedit' | 'beforerangeedit' | 'afteredit' | 'beforeautofill' | 'beforerange' | 'afterfocus' | 'roworderchanged' | 'beforesorting' | 'beforesourcesortingapply' | 'beforesortingapply' | 'rowdragstart' | 'headerclick' | 'beforecellfocus' | 'beforefocuslost' | 'beforesourceset' | 'beforeanysource' | 'aftersourceset' | 'afteranysource' | 'beforecolumnsgather' | 'beforecolumnsset' | 'beforecolumnapplied' | 'aftercolumnsset' | 'beforefilterapply' | 'beforefiltertrimmed' | 'beforetrimmed' | 'aftertrimmed' | 'viewportscroll' | 'beforeexport' | 'beforeeditstart' | 'aftercolumnresize' | 'beforerowdefinition' | 'filterconfigchanged' | 'sortingconfigchanged' | 'rowheaderschanged' | 'beforegridrender' | 'aftergridrender' | 'aftergridinit' | 'additionaldatachanged' | 'afterthemechanged' | 'created' | 'beforepaste' | 'beforepasteapply' | 'pasteregion' | 'afterpasteapply' | 'beforecut' | 'clearregion' | 'beforecopy' | 'beforecopyapply' | 'copyregion' | 'beforerowrender' | 'afterrender' | 'beforecellrender' | 'beforedatarender' | 'dragstartcell' | 'celleditinit' | 'closeedit' | 'filterChange' | 'resetChange' | 'beforefocusrender' | 'beforescrollintoview' | 'afterfocus' | 'beforeheaderclick' | 'headerresize' | 'beforeheaderresize' | 'headerdblclick' | 'beforeheaderrender' | 'beforegroupheaderrender' | 'afterheaderrender' | 'columndragstart' | 'columndragmousemove' | 'beforecolumndragend' | 'columndragend' | 'rowdragstartinit' | 'rowdragendinit' | 'rowdragmoveinit' | 'rowdragmousemove' | 'rowdropinit' | 'roworderchange' | 'beforecopyregion' | 'beforepasteregion' | 'celleditapply' | 'beforecellfocusinit' | 'beforenextvpfocus' | 'setedit' | 'beforeapplyrange' | 'beforesetrange' | 'setrange' | 'beforeeditrender' | 'selectall' | 'canceledit' | 'settemprange' | 'beforesettemprange' | 'applyfocus' | 'focuscell' | 'beforerangedataapply' | 'selectionchangeinit' | 'beforerangecopyapply' | 'rangeeditapply' | 'clipboardrangecopy' | 'clipboardrangepaste' | 'beforekeydown' | 'beforekeyup' | 'beforecellsave' | 'celledit' | 'scrollview' | 'ref' | 'scrollvirtual' | 'scrollviewport' | 'resizeviewport' | 'scrollchange' | 'scrollviewportsilent' | 'html';
1
+ export type RevogridEvents = 'contentsizechanged' | 'beforeedit' | 'beforerangeedit' | 'afteredit' | 'beforeautofill' | 'beforerange' | 'afterfocus' | 'roworderchanged' | 'beforesorting' | 'beforesourcesortingapply' | 'beforesortingapply' | 'aftersortingapply' | 'rowdragstart' | 'headerclick' | 'beforecellfocus' | 'beforefocuslost' | 'beforesourceset' | 'beforeanysource' | 'aftersourceset' | 'afteranysource' | 'beforecolumnsgather' | 'beforecolumnsset' | 'beforecolumnapplied' | 'aftercolumnsset' | 'beforefilterapply' | 'beforefiltertrimmed' | 'beforetrimmed' | 'aftertrimmed' | 'viewportscroll' | 'beforeexport' | 'beforeeditstart' | 'aftercolumnresize' | 'beforerowdefinition' | 'filterconfigchanged' | 'sortingconfigchanged' | 'rowheaderschanged' | 'beforegridrender' | 'aftergridrender' | 'aftergridinit' | 'additionaldatachanged' | 'afterthemechanged' | 'created' | 'beforepaste' | 'beforepasteapply' | 'pasteregion' | 'afterpasteapply' | 'beforecut' | 'clearregion' | 'beforecopy' | 'beforecopyapply' | 'copyregion' | 'beforerowrender' | 'afterrender' | 'beforecellrender' | 'beforedatarender' | 'dragstartcell' | 'celleditinit' | 'closeedit' | 'filterChange' | 'resetChange' | 'beforefocusrender' | 'beforescrollintoview' | 'afterfocus' | 'beforeheaderclick' | 'headerresize' | 'beforeheaderresize' | 'headerdblclick' | 'beforeheaderrender' | 'beforegroupheaderrender' | 'afterheaderrender' | 'columndragstart' | 'columndragmousemove' | 'beforecolumndragend' | 'columndragend' | 'rowdragstartinit' | 'rowdragendinit' | 'rowdragmoveinit' | 'rowdragmousemove' | 'rowdropinit' | 'roworderchange' | 'beforecopyregion' | 'beforepasteregion' | 'celleditapply' | 'beforecellfocusinit' | 'beforenextvpfocus' | 'setedit' | 'beforeapplyrange' | 'beforesetrange' | 'setrange' | 'beforeeditrender' | 'selectall' | 'canceledit' | 'settemprange' | 'beforesettemprange' | 'applyfocus' | 'focuscell' | 'beforerangedataapply' | 'selectionchangeinit' | 'beforerangecopyapply' | 'rangeeditapply' | 'clipboardrangecopy' | 'clipboardrangepaste' | 'beforekeydown' | 'beforekeyup' | 'beforecellsave' | 'celledit' | 'scrollview' | 'ref' | 'scrollvirtual' | 'scrollviewport' | 'resizeviewport' | 'scrollchange' | 'scrollviewportsilent' | 'html';
2
2
  export declare const REVOGRID_EVENTS: Map<RevogridEvents, RevogridEvents>;
@@ -742,6 +742,10 @@ export interface FocusRenderEvent extends AllDimensionType {
742
742
  * Changes for the next cell to focus. @example { y: -1 }
743
743
  */
744
744
  next?: Partial<Cell>;
745
+ /**
746
+ * Original user input event that initiated the focus/range change, when available.
747
+ */
748
+ originalEvent?: MouseEvent | TouchEvent | KeyboardEvent;
745
749
  }
746
750
  export interface FocusAfterRenderEvent<TModel extends DataType = DataType> extends AllDimensionType {
747
751
  model?: TModel;
@@ -117,6 +117,10 @@ export interface BeforeSaveDataDetails<TModel extends DataType = DataType, TColu
117
117
  * Value from editor to save, not part of the model value yet
118
118
  */
119
119
  val?: any;
120
+ /**
121
+ * Original user input event that initiated the save/focus flow, when available.
122
+ */
123
+ originalEvent?: MouseEvent | TouchEvent | KeyboardEvent;
120
124
  }
121
125
  export type BeforeRangeSaveDataDetails<TModel extends DataType = DataType> = {
122
126
  data: {
package/hydrate/index.js CHANGED
@@ -14270,13 +14270,13 @@ class OverlaySelection {
14270
14270
  /**
14271
14271
  * Executes the focus operation on the specified range of cells.
14272
14272
  */
14273
- doFocus(focus, end, changes) {
14273
+ doFocus(focus, end, changes, originalEvent) {
14274
14274
  // 1. Trigger beforeFocus event
14275
- const { defaultPrevented } = this.beforeFocusCell.emit(this.columnService.getSaveData(focus.y, focus.x));
14275
+ const { defaultPrevented } = this.beforeFocusCell.emit(Object.assign(Object.assign({}, this.columnService.getSaveData(focus.y, focus.x)), { originalEvent }));
14276
14276
  if (defaultPrevented) {
14277
14277
  return false;
14278
14278
  }
14279
- 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) });
14279
+ 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 });
14280
14280
  // 2. Trigger apply focus event
14281
14281
  const applyEvent = this.applyFocus.emit(evData);
14282
14282
  if (applyEvent.defaultPrevented) {
@@ -14292,10 +14292,10 @@ class OverlaySelection {
14292
14292
  y: range.y1,
14293
14293
  } }, applyEvent.detail)).defaultPrevented;
14294
14294
  }
14295
- triggerRangeEvent(range) {
14295
+ triggerRangeEvent(range, originalEvent) {
14296
14296
  const type = this.types.rowType;
14297
14297
  // 1. Apply range
14298
- 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) }));
14298
+ 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 }));
14299
14299
  if (applyEvent.defaultPrevented) {
14300
14300
  return false;
14301
14301
  }
@@ -14346,7 +14346,7 @@ class OverlaySelection {
14346
14346
  return;
14347
14347
  }
14348
14348
  // Set focus on the current cell
14349
- this.focus(focusCell, this.range && e.shiftKey);
14349
+ this.focus(focusCell, this.range && e.shiftKey, e);
14350
14350
  // Initiate autofill selection
14351
14351
  if (this.range) {
14352
14352
  targetElement &&
@@ -14500,7 +14500,7 @@ class OverlaySelection {
14500
14500
  /**
14501
14501
  * Sets the focus on a cell and optionally edits a range.
14502
14502
  */
14503
- focus(cell, isRangeEdit = false) {
14503
+ focus(cell, isRangeEdit = false, originalEvent) {
14504
14504
  if (!cell)
14505
14505
  return false;
14506
14506
  const end = cell;
@@ -14508,10 +14508,10 @@ class OverlaySelection {
14508
14508
  if (isRangeEdit && start) {
14509
14509
  const range = getRange(start, end);
14510
14510
  if (range) {
14511
- return this.triggerRangeEvent(range);
14511
+ return this.triggerRangeEvent(range, originalEvent);
14512
14512
  }
14513
14513
  }
14514
- return this.doFocus(cell, end);
14514
+ return this.doFocus(cell, end, undefined, originalEvent);
14515
14515
  }
14516
14516
  get types() {
14517
14517
  return {
@@ -14646,7 +14646,7 @@ class TextEditor {
14646
14646
  }
14647
14647
  }
14648
14648
 
14649
- 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}`;
14649
+ 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}`;
14650
14650
 
14651
14651
  /**
14652
14652
  * Represents a cell editor in a grid.
@@ -16469,7 +16469,7 @@ function mergeSortedRowsWithGroups(indexes, source, sortedRows) {
16469
16469
  * 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.
16470
16470
  * 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.
16471
16471
  * 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.
16472
- * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
16472
+ * 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.
16473
16473
  *
16474
16474
  * Note: If you prevent an event, it will not proceed to the subsequent steps.
16475
16475
  */
@@ -16611,6 +16611,38 @@ class SortingPlugin extends BasePlugin {
16611
16611
  });
16612
16612
  this.setSortingState(state);
16613
16613
  }
16614
+ resetSortingForStore(type) {
16615
+ const storeService = this.providers.data.stores[type];
16616
+ // row data
16617
+ const source = storeService.store.get('source');
16618
+ // row indexes
16619
+ const proxyItems = storeService.store.get('proxyItems');
16620
+ // row indexes
16621
+ const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)
16622
+ this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);
16623
+ storeService.setData({ proxyItems: newItemsOrder });
16624
+ }
16625
+ applySortingForStore(type, sorting, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
16626
+ const storeService = this.providers.data.stores[type];
16627
+ // row data
16628
+ const source = storeService.store.get('source');
16629
+ // row indexes
16630
+ const proxyItems = storeService.store.get('proxyItems');
16631
+ const sortItems = getSortableRowIndexes(proxyItems, source);
16632
+ const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, sortingColumns, sortingOrder);
16633
+ const newItemsOrder = mergeSortedRowsWithGroups(proxyItems, source, sortedItems);
16634
+ // take row indexes before trim applied and proxy items
16635
+ const prevItems = storeService.store.get('items');
16636
+ storeService.setData({
16637
+ proxyItems: newItemsOrder,
16638
+ });
16639
+ // take currently visible row indexes
16640
+ const newItems = storeService.store.get('items');
16641
+ if (!ignoreViewportUpdate) {
16642
+ this.providers.dimension
16643
+ .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);
16644
+ }
16645
+ }
16614
16646
  startSorting(order, sortingFunc, sortingColumns, sortingOrder, ignoreViewportUpdate) {
16615
16647
  if (!this.sortingPromise) {
16616
16648
  // add job before render
@@ -16702,45 +16734,25 @@ class SortingPlugin extends BasePlugin {
16702
16734
  // if no sorting - reset
16703
16735
  if (!Object.keys(sorting || {}).length) {
16704
16736
  for (let type of activeTypes) {
16705
- const storeService = this.providers.data.stores[type];
16706
- // row data
16707
- const source = storeService.store.get('source');
16708
- // row indexes
16709
- const proxyItems = storeService.store.get('proxyItems');
16710
- // row indexes
16711
- const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)
16712
- this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);
16713
- storeService.setData({ proxyItems: newItemsOrder });
16737
+ this.resetSortingForStore(type);
16714
16738
  }
16715
16739
  }
16716
16740
  else {
16717
16741
  for (let type of activeTypes) {
16718
- const storeService = this.providers.data.stores[type];
16719
- // row data
16720
- const source = storeService.store.get('source');
16721
- // row indexes
16722
- const proxyItems = storeService.store.get('proxyItems');
16723
- const sortItems = getSortableRowIndexes(proxyItems, source);
16724
- const sortedItems = sortIndexByItems([...sortItems], source, sortingFunc, sorting, activeSortingColumns, activeSortingOrder);
16725
- const newItemsOrder = mergeSortedRowsWithGroups(proxyItems, source, sortedItems);
16726
- // take row indexes before trim applied and proxy items
16727
- const prevItems = storeService.store.get('items');
16728
- storeService.setData({
16729
- proxyItems: newItemsOrder,
16730
- });
16731
- // take currently visible row indexes
16732
- const newItems = storeService.store.get('items');
16733
- if (!activeIgnoreViewportUpdate) {
16734
- this.providers.dimension
16735
- .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);
16736
- }
16742
+ this.applySortingForStore(type, sorting, sortingFunc, activeSortingColumns, activeSortingOrder, activeIgnoreViewportUpdate);
16737
16743
  }
16738
16744
  }
16739
16745
  // refresh columns to redraw column headers and show correct icon
16740
16746
  columnTypes.forEach((type) => {
16741
16747
  this.providers.column.dataSources[type].refresh();
16742
16748
  });
16743
- this.emit('aftersortingapply');
16749
+ const afterSortingDetail = {
16750
+ sorting: hasActiveSorting(sorting) ? sorting : undefined,
16751
+ sortingColumns: activeSortingColumns,
16752
+ sortingOrder: activeSortingOrder,
16753
+ types: activeTypes,
16754
+ };
16755
+ this.emit('aftersortingapply', afterSortingDetail);
16744
16756
  }
16745
16757
  }
16746
16758
 
@@ -19265,6 +19277,7 @@ class RevoGridComponent {
19265
19277
  this.beforesorting = createEvent(this, "beforesorting", 7);
19266
19278
  this.beforesourcesortingapply = createEvent(this, "beforesourcesortingapply", 7);
19267
19279
  this.beforesortingapply = createEvent(this, "beforesortingapply", 7);
19280
+ this.aftersortingapply = createEvent(this, "aftersortingapply", 7);
19268
19281
  this.rowdragstart = createEvent(this, "rowdragstart", 7);
19269
19282
  this.headerclick = createEvent(this, "headerclick", 7);
19270
19283
  this.beforecellfocus = createEvent(this, "beforecellfocus", 7);