@revolist/revogrid 4.22.0 → 4.23.0

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 (130) hide show
  1. package/dist/cjs/{cell-renderer-uZmDBXz7.js → cell-renderer-DWJ9Px9f.js} +9 -3
  2. package/dist/cjs/{column.drag.plugin-CM_5mKV3.js → column.drag.plugin-CaEBDG-Q.js} +409 -267
  3. package/dist/cjs/{column.service-DvQDqxxx.js → column.service-f612L4ql.js} +1 -1
  4. package/dist/cjs/{dimension.helpers-CaIsYC99.js → dimension.helpers-B9HgANnM.js} +14 -146
  5. package/dist/cjs/{edit.utils-CwMzSIVF.js → edit.utils-pKeiYFLJ.js} +22 -1
  6. package/dist/cjs/{header-cell-renderer-B1dJwgTO.js → header-cell-renderer-4yq9_WbM.js} +1 -1
  7. package/dist/cjs/index-DxaSE5uZ.js +136 -0
  8. package/dist/cjs/index.cjs.js +45 -31
  9. package/dist/cjs/revo-grid.cjs.entry.js +35 -15
  10. package/dist/cjs/revogr-attribution_7.cjs.entry.js +44 -26
  11. package/dist/cjs/revogr-clipboard_3.cjs.entry.js +11 -9
  12. package/dist/cjs/revogr-data_4.cjs.entry.js +132 -178
  13. package/dist/cjs/revogr-filter-panel.cjs.entry.js +2 -1
  14. package/dist/cjs/{text-editor-BTnGaIl3.js → text-editor-B4W-m-r-.js} +3 -3
  15. package/dist/cjs/{throttle-CI4MsAqs.js → throttle-BCwEuJJq.js} +59 -24
  16. package/dist/cjs/viewport.helpers-BND76K2j.js +140 -0
  17. package/dist/cjs/{viewport.store-Dcjud-a-.js → viewport.store-BlKQ4x9H.js} +16 -16
  18. package/dist/collection/components/clipboard/revogr-clipboard.js +1 -1
  19. package/dist/collection/components/data/revogr-data.js +5 -3
  20. package/dist/collection/components/header/header-group-renderer.js +2 -1
  21. package/dist/collection/components/header/header-renderer.js +6 -5
  22. package/dist/collection/components/header/revogr-header-style.css +13 -3
  23. package/dist/collection/components/header/revogr-header.js +105 -42
  24. package/dist/collection/components/order/order-row.service.js +6 -5
  25. package/dist/collection/components/overlay/keyboard.service.js +25 -3
  26. package/dist/collection/components/overlay/selection.utils.js +8 -6
  27. package/dist/collection/components/revoGrid/revo-grid.js +6 -5
  28. package/dist/collection/components/revoGrid/viewport.service.js +2 -1
  29. package/dist/collection/components/scroll/revogr-viewport-scroll.js +10 -6
  30. package/dist/collection/components/scrollable/revogr-scroll-virtual.js +4 -10
  31. package/dist/collection/plugins/filter/filter.panel.js +2 -1
  32. package/dist/collection/plugins/filter/filter.plugin.js +11 -4
  33. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +25 -1
  34. package/dist/collection/plugins/moveColumn/column.drag.plugin.js +18 -15
  35. package/dist/collection/plugins/sorting/sorting.func.js +173 -15
  36. package/dist/collection/plugins/sorting/sorting.plugin.js +167 -84
  37. package/dist/collection/plugins/sorting/sorting.sign.js +7 -1
  38. package/dist/collection/serve/controller.js +98 -37
  39. package/dist/collection/serve/data.js +273 -144
  40. package/dist/collection/services/dimension.provider.js +16 -1
  41. package/dist/collection/services/local.scroll.service.js +59 -24
  42. package/dist/collection/services/scroll.dimension.helpers.js +83 -0
  43. package/dist/collection/services/selection.store.connector.js +4 -1
  44. package/dist/collection/store/dimension/dimension.recalculate.plugin.js +22 -9
  45. package/dist/collection/store/dimension/dimension.store.js +4 -2
  46. package/dist/collection/store/vp/viewport.helpers.js +9 -0
  47. package/dist/collection/store/vp/viewport.store.js +5 -16
  48. package/dist/collection/types/events.js +4 -0
  49. package/dist/collection/utils/key.utils.js +20 -0
  50. package/dist/collection/utils/store.utils.js +3 -3
  51. package/dist/{revo-grid/cell-renderer-K_BKH7Kx.js → esm/cell-renderer-8UiGd-s7.js} +9 -3
  52. package/dist/esm/{column.drag.plugin-DEqZ2qXJ.js → column.drag.plugin-BsfhsfmB.js} +402 -266
  53. package/dist/esm/{column.service-Cdz3dYqZ.js → column.service-DbpulTog.js} +1 -1
  54. package/dist/{revo-grid/debounce-BfO9dz9v.js → esm/debounce-PCRWZliA.js} +1 -1
  55. package/dist/{revo-grid/dimension.helpers-DzxqJQqN.js → esm/dimension.helpers-CGKwSvw6.js} +7 -128
  56. package/dist/esm/{edit.utils-CzfeG98N.js → edit.utils-Dnnbd0xG.js} +22 -2
  57. package/dist/{revo-grid/header-cell-renderer-DXhxZMly.js → esm/header-cell-renderer-DGI2FAD8.js} +1 -1
  58. package/dist/esm/index-Db3qZoW5.js +127 -0
  59. package/dist/esm/index.js +15 -10
  60. package/dist/esm/revo-grid.entry.js +34 -14
  61. package/dist/esm/revogr-attribution_7.entry.js +43 -25
  62. package/dist/esm/revogr-clipboard_3.entry.js +12 -10
  63. package/dist/esm/revogr-data_4.entry.js +133 -179
  64. package/dist/esm/revogr-filter-panel.entry.js +3 -2
  65. package/dist/esm/{text-editor-C1ks5eQ4.js → text-editor-C3RUSwH5.js} +2 -2
  66. package/dist/esm/{throttle-BEjFQa2l.js → throttle-CaUDyxyU.js} +60 -25
  67. package/dist/esm/viewport.helpers-CoCAvmZs.js +133 -0
  68. package/dist/{revo-grid/viewport.store-saAZJHRo.js → esm/viewport.store-COAfzAyu.js} +15 -17
  69. package/dist/{esm/cell-renderer-K_BKH7Kx.js → revo-grid/cell-renderer-8UiGd-s7.js} +9 -3
  70. package/dist/revo-grid/{column.drag.plugin-DEqZ2qXJ.js → column.drag.plugin-BsfhsfmB.js} +402 -266
  71. package/dist/revo-grid/{column.service-Cdz3dYqZ.js → column.service-DbpulTog.js} +1 -1
  72. package/dist/{esm/debounce-BfO9dz9v.js → revo-grid/debounce-PCRWZliA.js} +1 -1
  73. package/dist/{esm/dimension.helpers-DzxqJQqN.js → revo-grid/dimension.helpers-CGKwSvw6.js} +7 -128
  74. package/dist/revo-grid/{edit.utils-CzfeG98N.js → edit.utils-Dnnbd0xG.js} +22 -2
  75. package/dist/{esm/header-cell-renderer-DXhxZMly.js → revo-grid/header-cell-renderer-DGI2FAD8.js} +1 -1
  76. package/dist/revo-grid/index-Db3qZoW5.js +127 -0
  77. package/dist/revo-grid/index.esm.js +15 -10
  78. package/dist/revo-grid/revo-grid.entry.js +34 -14
  79. package/dist/revo-grid/revogr-attribution_7.entry.js +43 -25
  80. package/dist/revo-grid/revogr-clipboard_3.entry.js +12 -10
  81. package/dist/revo-grid/revogr-data_4.entry.js +133 -179
  82. package/dist/revo-grid/revogr-filter-panel.entry.js +3 -2
  83. package/dist/revo-grid/{text-editor-C1ks5eQ4.js → text-editor-C3RUSwH5.js} +2 -2
  84. package/dist/revo-grid/{throttle-BEjFQa2l.js → throttle-CaUDyxyU.js} +60 -25
  85. package/dist/revo-grid/viewport.helpers-CoCAvmZs.js +133 -0
  86. package/dist/{esm/viewport.store-saAZJHRo.js → revo-grid/viewport.store-COAfzAyu.js} +15 -17
  87. package/dist/types/components/header/header-group-renderer.d.ts +1 -0
  88. package/dist/types/components/header/header-renderer.d.ts +1 -0
  89. package/dist/types/components/header/revogr-header.d.ts +6 -0
  90. package/dist/types/components/overlay/keyboard.service.d.ts +5 -0
  91. package/dist/types/plugins/groupingRow/grouping.row.plugin.d.ts +8 -0
  92. package/dist/types/plugins/moveColumn/column.drag.plugin.d.ts +29 -3
  93. package/dist/types/plugins/sorting/sorting.func.d.ts +25 -2
  94. package/dist/types/plugins/sorting/sorting.plugin.d.ts +84 -9
  95. package/dist/types/plugins/sorting/sorting.sign.d.ts +5 -1
  96. package/dist/types/plugins/sorting/sorting.types.d.ts +46 -1
  97. package/dist/types/services/local.scroll.service.d.ts +10 -2
  98. package/dist/types/services/scroll.dimension.helpers.d.ts +20 -0
  99. package/dist/types/store/vp/viewport.helpers.d.ts +2 -0
  100. package/dist/types/types/events.d.ts +1 -1
  101. package/dist/types/types/interfaces.d.ts +11 -0
  102. package/dist/types/utils/key.utils.d.ts +8 -0
  103. package/hydrate/index.js +791 -539
  104. package/hydrate/index.mjs +791 -539
  105. package/package.json +1 -1
  106. package/standalone/column.service.js +1 -1
  107. package/standalone/data.store.js +1 -1
  108. package/standalone/debounce.js +1 -1
  109. package/standalone/dimension.helpers.js +1 -1
  110. package/standalone/index.js +1 -1
  111. package/standalone/local.scroll.timer.js +1 -1
  112. package/standalone/revo-grid.js +1 -1
  113. package/standalone/revogr-clipboard2.js +1 -1
  114. package/standalone/revogr-data2.js +1 -1
  115. package/standalone/revogr-edit.js +1 -1
  116. package/standalone/revogr-edit2.js +1 -1
  117. package/standalone/revogr-filter-panel.js +1 -1
  118. package/standalone/revogr-header2.js +1 -1
  119. package/standalone/revogr-order-editor2.js +1 -1
  120. package/standalone/revogr-overlay-selection2.js +1 -1
  121. package/standalone/revogr-row-headers.js +1 -1
  122. package/standalone/revogr-row-headers2.js +1 -1
  123. package/standalone/revogr-scroll-virtual2.js +1 -1
  124. package/standalone/revogr-viewport-scroll2.js +1 -1
  125. package/standalone/selection.utils.js +1 -1
  126. package/standalone/throttle.js +1 -1
  127. package/standalone/toNumber.js +1 -1
  128. package/dist/cjs/viewport.helpers-BAovztDd.js +0 -58
  129. package/dist/esm/viewport.helpers-VXhsJZtn.js +0 -52
  130. package/dist/revo-grid/viewport.helpers-VXhsJZtn.js +0 -52
@@ -49,8 +49,8 @@ export function getCurrentCell({ x, y }, { el, rows, cols }) {
49
49
  cellX = width - 1;
50
50
  }
51
51
  // Get the row and column items based on the cell position
52
- const rgRow = getItemByPosition(rows, cellY);
53
- const rgCol = getItemByPosition(cols, cellX);
52
+ const rgRow = getItemByPosition(rows, cellY + (rows.renderOffset || 0));
53
+ const rgCol = getItemByPosition(cols, cellX + (cols.renderOffset || 0));
54
54
  // Set the row and column index to 0 if they are before the first item
55
55
  if (rgCol.itemIndex < 0) {
56
56
  rgCol.itemIndex = 0;
@@ -120,10 +120,12 @@ export function styleByCellProps(styles) {
120
120
  };
121
121
  }
122
122
  export function getCell({ x, y, x1, y1 }, dimensionRow, dimensionCol) {
123
- const top = getItemByIndex(dimensionRow, y).start;
124
- const left = getItemByIndex(dimensionCol, x).start;
125
- const bottom = getItemByIndex(dimensionRow, y1).end;
126
- const right = getItemByIndex(dimensionCol, x1).end;
123
+ const rowOffset = dimensionRow.renderOffset || 0;
124
+ const colOffset = dimensionCol.renderOffset || 0;
125
+ const top = getItemByIndex(dimensionRow, y).start - rowOffset;
126
+ const left = getItemByIndex(dimensionCol, x).start - colOffset;
127
+ const bottom = getItemByIndex(dimensionRow, y1).end - rowOffset;
128
+ const right = getItemByIndex(dimensionCol, x1).end - colOffset;
127
129
  return {
128
130
  left,
129
131
  right,
@@ -626,12 +626,13 @@ export class RevoGridComponent {
626
626
  return;
627
627
  }
628
628
  const columns = this.columnProvider.setColumns(beforeApplyEvent.detail);
629
+ const order = {};
630
+ for (const prop of Object.keys(beforeApplyEvent.detail.sort)) {
631
+ order[prop] = beforeApplyEvent.detail.sort[prop].order;
632
+ }
629
633
  this.aftercolumnsset.emit({
630
634
  columns,
631
- order: Object.entries(beforeApplyEvent.detail.sort).reduce((acc, [prop, column]) => {
632
- acc[prop] = column.order;
633
- return acc;
634
- }, {}),
635
+ order,
635
636
  });
636
637
  }
637
638
  disableVirtualXChanged(newVal = false, prevVal = false) {
@@ -920,7 +921,7 @@ export class RevoGridComponent {
920
921
  if (Object.keys((_a = this.trimmedRows) !== null && _a !== void 0 ? _a : {}).length > 0) {
921
922
  this.trimmedRowsChanged(this.trimmedRows);
922
923
  }
923
- this.rowDefChanged(this.rowDefinitions);
924
+ this.rowDefChanged(this.rowDefinitions, undefined, undefined, false);
924
925
  // init grouping
925
926
  if (this.grouping && Object.keys(this.grouping).length > 0) {
926
927
  this.groupingChanged(this.grouping);
@@ -108,7 +108,8 @@ export default class ViewportService {
108
108
  (_a = this.config.dimensionProvider) === null || _a === void 0 ? void 0 : _a.setCustomSizes(type, detail, true);
109
109
  // set resize event
110
110
  const changedItems = {};
111
- for (const [i, size] of Object.entries(detail || {})) {
111
+ for (const i of Object.keys(detail || {})) {
112
+ const size = detail[i];
112
113
  const virtualIndex = parseInt(i, 10);
113
114
  const item = getSourceItem(store, virtualIndex);
114
115
  if (item) {
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { h, Host, } from "@stencil/core";
5
5
  import GridResizeService from "../revoGrid/viewport.resize.service";
6
- import LocalScrollService from "../../services/local.scroll.service";
6
+ import LocalScrollService, { getContentSize } from "../../services/local.scroll.service";
7
7
  import { LocalScrollTimer } from "../../services/local.scroll.timer";
8
8
  import { CONTENT_SLOT, FOOTER_SLOT, HEADER_SLOT, } from "../revoGrid/viewport.helpers";
9
9
  /**
@@ -34,7 +34,7 @@ export class RevogrViewportScroll {
34
34
  * @param e
35
35
  */
36
36
  async changeScroll(e, silent = false) {
37
- var _a, _b;
37
+ var _a, _b, _c, _d;
38
38
  if (silent) {
39
39
  if (e.coordinate && this.verticalScroll) {
40
40
  switch (e.dimension) {
@@ -47,15 +47,16 @@ export class RevogrViewportScroll {
47
47
  return;
48
48
  }
49
49
  if (e.delta) {
50
+ let currentPhysicalCoordinate = 0;
50
51
  switch (e.dimension) {
51
52
  case 'rgCol':
52
- e.coordinate = this.horizontalScroll.scrollLeft + e.delta;
53
+ currentPhysicalCoordinate = this.horizontalScroll.scrollLeft;
53
54
  break;
54
55
  case 'rgRow':
55
- e.coordinate = ((_b = (_a = this.verticalScroll) === null || _a === void 0 ? void 0 : _a.scrollTop) !== null && _b !== void 0 ? _b : 0) + e.delta;
56
+ currentPhysicalCoordinate = (_b = (_a = this.verticalScroll) === null || _a === void 0 ? void 0 : _a.scrollTop) !== null && _b !== void 0 ? _b : 0;
56
57
  break;
57
58
  }
58
- this.setScroll(e);
59
+ return (_d = (_c = this.localScrollService) === null || _c === void 0 ? void 0 : _c.setScrollByDelta(e, currentPhysicalCoordinate)) !== null && _d !== void 0 ? _d : e;
59
60
  }
60
61
  return e;
61
62
  }
@@ -207,7 +208,10 @@ export class RevogrViewportScroll {
207
208
  this.setScrollVisibility('rgCol', this.horizontalScroll.clientWidth, this.contentWidth);
208
209
  }
209
210
  render() {
210
- return (h(Host, { key: 'adc7378dba1794ca2ec263d52b09abefe50bcbfd', onWheel: this.horizontalMouseWheel, onScroll: (e) => this.applyScroll('rgCol', e) }, h("div", { key: '7b57a8a0ea44629fefcfe4d2cd77bf0f048d8e06', class: "inner-content-table", style: { width: `${this.contentWidth}px` } }, h("div", { key: 'cca3de158bc2a7f0651f578a281819be5698b257', class: "header-wrapper", ref: e => (this.header = e) }, h("slot", { key: '1d170147dabe034f2c35481a8e2fedd6de2b6aed', name: HEADER_SLOT })), h("div", { key: 'b6dd29a91bb1f380a83a035dfdb749ca669936f2', class: "vertical-inner", ref: el => (this.verticalScroll = el), onWheel: this.verticalMouseWheel, onScroll: (e) => this.applyScroll('rgRow', e) }, h("div", { key: '9bce27bf8ec4d3b679aa9a34eb6379a8c2d46cac', class: "content-wrapper", style: { height: `${this.contentHeight}px` } }, h("slot", { key: 'b44a082c9fbb948fd87bd235b4cd4356fd4a3536', name: CONTENT_SLOT }))), h("div", { key: '28c305ff6bc664f1d1bbb117e8b8565c8d4bb6b2', class: "footer-wrapper", ref: e => (this.footer = e) }, h("slot", { key: '96312fb7f18198fd1feb9dcc00c79cde74ba9c9f', name: FOOTER_SLOT })))));
211
+ var _a, _b, _c, _d;
212
+ const physicalContentHeight = getContentSize(this.contentHeight, (_b = (_a = this.verticalScroll) === null || _a === void 0 ? void 0 : _a.clientHeight) !== null && _b !== void 0 ? _b : 0);
213
+ const physicalContentWidth = getContentSize(this.contentWidth, (_d = (_c = this.horizontalScroll) === null || _c === void 0 ? void 0 : _c.clientWidth) !== null && _d !== void 0 ? _d : 0);
214
+ return (h(Host, { key: 'a0c47dede9d131dea8c8ca449e8a323f24d9b113', onWheel: this.horizontalMouseWheel, onScroll: (e) => this.applyScroll('rgCol', e) }, h("div", { key: '6c960e753ffe522ba4afb1c379264873b6c617f3', class: "inner-content-table", style: { width: `${physicalContentWidth}px` } }, h("div", { key: '1a6cbcbd3634e84756b54c8150aebd25c824e14a', class: "header-wrapper", ref: e => (this.header = e) }, h("slot", { key: 'e4202c687bc39b4f78f3ed9840e979b032f06af8', name: HEADER_SLOT })), h("div", { key: '651415b5b32e72735065b183317386a34042bb85', class: "vertical-inner", ref: el => (this.verticalScroll = el), onWheel: this.verticalMouseWheel, onScroll: (e) => this.applyScroll('rgRow', e) }, h("div", { key: 'e65623b78d80957d8676adb019618953ef267ec3', class: "content-wrapper", style: { height: `${physicalContentHeight}px` } }, h("slot", { key: '5af47b12ef1226587cf774233447b5252d65e836', name: CONTENT_SLOT }))), h("div", { key: 'cbc0fd64fbfb53d3b18e547bbe34e32b7bb9c043', class: "footer-wrapper", ref: e => (this.footer = e) }, h("slot", { key: 'a8e4bfaef400973121090bac3069eb85469a95f3', name: FOOTER_SLOT })))));
211
215
  }
212
216
  /**
213
217
  * Extra layer for scroll event monitoring, where MouseWheel event is not passing
@@ -37,15 +37,9 @@ export class RevogrScrollVirtual {
37
37
  */
38
38
  async changeScroll(e) {
39
39
  if (e.delta) {
40
- switch (e.dimension) {
41
- case 'rgCol':
42
- e.coordinate = this.element.scrollLeft + e.delta;
43
- break;
44
- case 'rgRow':
45
- e.coordinate = this.element.scrollTop + e.delta;
46
- break;
47
- }
48
- this.setScroll(e);
40
+ const scrollProperty = e.dimension === 'rgRow' ? 'scrollTop' : 'scrollLeft';
41
+ const currentPhysicalCoordinate = this.element[scrollProperty];
42
+ return this.localScrollService.setScrollByDelta(e, currentPhysicalCoordinate);
49
43
  }
50
44
  return e;
51
45
  }
@@ -108,7 +102,7 @@ export class RevogrScrollVirtual {
108
102
  }
109
103
  render() {
110
104
  const size = getContentSize(this.realSize, this.dimension === 'rgRow' ? this.element.clientHeight : this.element.clientWidth, this.clientSize);
111
- return (h(Host, { key: '57f81ec9deb2395e96b283338c03b9ad44f1e929', onScroll: (e) => this.onScroll(e) }, h("div", { key: '1a8c869adab53b362c351dae8d53664f33c4212c', style: {
105
+ return (h(Host, { key: '7213817ef941eee4050b714266598ec0c2961ee9', onScroll: (e) => this.onScroll(e) }, h("div", { key: '501da49c63253ab943172494b9dbf5399be56cee', style: {
112
106
  [this.dimension === 'rgRow' ? 'height' : 'width']: `${size}px`,
113
107
  } })));
114
108
  }
@@ -250,7 +250,8 @@ export class FilterPanel {
250
250
  const options = [];
251
251
  const prop = this.changes.prop;
252
252
  const hidden = new Set();
253
- Object.entries(this.filterItems).forEach(([_, values]) => {
253
+ Object.keys(this.filterItems).forEach((prop) => {
254
+ const values = this.filterItems[prop];
254
255
  values.forEach((filter) => {
255
256
  if (filter.hidden) {
256
257
  hidden.add(filter.type);
@@ -152,17 +152,24 @@ export class FilterPlugin extends BasePlugin {
152
152
  }
153
153
  }
154
154
  if (config.collection) {
155
- const filtersWithFilterFunctionPresent = Object.entries(config.collection).filter(([, item]) => this.filterFunctionsIndexedByType[item.type]);
156
- this.filterCollection = Object.fromEntries(filtersWithFilterFunctionPresent);
155
+ const filterCollection = {};
156
+ for (const prop of Object.keys(config.collection)) {
157
+ const item = config.collection[prop];
158
+ if (this.filterFunctionsIndexedByType[item.type]) {
159
+ filterCollection[prop] = item;
160
+ }
161
+ }
162
+ this.filterCollection = filterCollection;
157
163
  }
158
164
  else {
159
165
  this.filterCollection = {};
160
166
  }
161
167
  if (config.localization) {
162
168
  if (config.localization.filterNames) {
163
- Object.entries(config.localization.filterNames).forEach(([k, v]) => {
169
+ const filterNames = config.localization.filterNames;
170
+ Object.keys(filterNames).forEach((k) => {
164
171
  if (this.filterNameIndexByType[k] != void 0) {
165
- this.filterNameIndexByType[k] = v;
172
+ this.filterNameIndexByType[k] = filterNames[k];
166
173
  }
167
174
  });
168
175
  }
@@ -1,6 +1,18 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
+ var __rest = (this && this.__rest) || function (s, e) {
5
+ var t = {};
6
+ for (var p in s)
7
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
8
+ t[p] = s[p];
9
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
10
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
11
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
12
+ t[p[i]] = s[p[i]];
13
+ }
14
+ return t;
15
+ };
4
16
  import { getPhysical, setItems, columnTypes, } from "../../store/index";
5
17
  import { BasePlugin } from "../base.plugin";
6
18
  import { FILTER_TRIMMED_TYPE } from "../filter/filter.plugin";
@@ -97,6 +109,18 @@ export class GroupingRowPlugin extends BasePlugin {
97
109
  const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
98
110
  return !!(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sortingPromise);
99
111
  }
112
+ /**
113
+ * Returns grouping options for regrouping that must preserve current UI state.
114
+ *
115
+ * `expandedAll` and config `prevExpanded` are initial/config instructions.
116
+ * Reusing them after sorting would reopen groups the user collapsed before
117
+ * sorting instead of using the current grouped source state.
118
+ */
119
+ getCurrentExpandedOptions() {
120
+ var _a;
121
+ const _b = (_a = this.options) !== null && _a !== void 0 ? _a : {}, { expandedAll: _expandedAll, prevExpanded: _prevExpanded } = _b, options = __rest(_b, ["expandedAll", "prevExpanded"]);
122
+ return options;
123
+ }
100
124
  /**
101
125
  * Starts global source update with group clearing and applying new one
102
126
  * Initiated when need to reapply grouping
@@ -199,7 +223,7 @@ export class GroupingRowPlugin extends BasePlugin {
199
223
  if (!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length)) {
200
224
  return;
201
225
  }
202
- this.doSourceUpdate(Object.assign({}, this.options));
226
+ this.doSourceUpdate(this.getCurrentExpandedOptions());
203
227
  });
204
228
  /**
205
229
  * Apply logic for focus inside of grouping
@@ -13,11 +13,11 @@ import { dispatch } from "../dispatcher";
13
13
  import { ON_COLUMN_CLICK } from "../../components/header/header-cell-renderer";
14
14
  import { isColGrouping } from "../../utils/column.utils";
15
15
  const COLUMN_CLICK = ON_COLUMN_CLICK;
16
- const MOVE = 'columndragmousemove';
17
- const DRAG_END = 'columndragend';
18
- const BEFORE_DRAG_END = 'beforecolumndragend';
16
+ export const COLUMN_DRAG_MOVE_EVENT = 'columndragmousemove';
17
+ export const COLUMN_DRAG_END_EVENT = 'columndragend';
18
+ export const BEFORE_COLUMN_DRAG_END_EVENT = 'beforecolumndragend';
19
19
  // use this event subscription to drop D&D for particular columns
20
- const DRAG_START = 'columndragstart';
20
+ export const COLUMN_DRAG_START_EVENT = 'columndragstart';
21
21
  export class ColumnMovePlugin extends BasePlugin {
22
22
  constructor(revogrid, providers) {
23
23
  super(revogrid, providers);
@@ -47,7 +47,7 @@ export class ColumnMovePlugin extends BasePlugin {
47
47
  if (event.defaultPrevented) {
48
48
  return;
49
49
  }
50
- const { defaultPrevented } = dispatch(this.revogrid, DRAG_START, data);
50
+ const { defaultPrevented } = dispatch(this.revogrid, COLUMN_DRAG_START_EVENT, data);
51
51
  // check if allowed to drag particulat column
52
52
  if (defaultPrevented) {
53
53
  return;
@@ -68,7 +68,7 @@ export class ColumnMovePlugin extends BasePlugin {
68
68
  const cols = this.getDimension(data.pin || 'rgCol');
69
69
  const gridRect = this.revogrid.getBoundingClientRect();
70
70
  const elRect = dataEl.getBoundingClientRect();
71
- const startItem = getItemByPosition(cols, getLeftRelative(event.x, gridRect.left, elRect.left - gridRect.left));
71
+ const startItem = getItemByPosition(cols, getLeftRelative(event.x, gridRect.left, elRect.left - gridRect.left) + (cols.renderOffset || 0));
72
72
  this.staticDragData = {
73
73
  startPos: event.x,
74
74
  startItem,
@@ -78,7 +78,7 @@ export class ColumnMovePlugin extends BasePlugin {
78
78
  gridEl: this.revogrid,
79
79
  cols,
80
80
  };
81
- this.dragData = this.getData(this.staticDragData);
81
+ this.dragData = this.getData(this.staticDragData, []);
82
82
  mousemove.target.addEventListener('mousemove', mousemove.callback);
83
83
  this.orderUi.start(event, Object.assign(Object.assign({}, this.dragData), this.staticDragData));
84
84
  }
@@ -86,24 +86,24 @@ export class ColumnMovePlugin extends BasePlugin {
86
86
  if (!this.staticDragData) {
87
87
  return;
88
88
  }
89
- const dragData = (this.dragData = this.getData(this.staticDragData));
89
+ const dragData = (this.dragData = this.getData(this.staticDragData, []));
90
90
  if (!dragData) {
91
91
  return;
92
92
  }
93
93
  const start = this.staticDragData.startPos;
94
94
  if (Math.abs(start - e.x) > 10) {
95
95
  const x = getLeftRelative(e.x, this.dragData.gridRect.left, this.dragData.scrollOffset);
96
- const rgCol = getItemByPosition(this.staticDragData.cols, x);
96
+ const rgCol = getItemByPosition(this.staticDragData.cols, x + (this.staticDragData.cols.renderOffset || 0));
97
97
  this.orderUi.autoscroll(x, dragData.elRect.width);
98
98
  // prevent position change if out of bounds
99
99
  if (rgCol.itemIndex >= this.staticDragData.cols.count) {
100
100
  return;
101
101
  }
102
- this.orderUi.showHandler(rgCol.end + dragData.scrollOffset, dragData.gridRect.width);
102
+ this.orderUi.showHandler(rgCol.end - (this.staticDragData.cols.renderOffset || 0) + dragData.scrollOffset, dragData.gridRect.width);
103
103
  }
104
104
  }
105
105
  move(e) {
106
- dispatch(this.revogrid, MOVE, e);
106
+ dispatch(this.revogrid, COLUMN_DRAG_MOVE_EVENT, e);
107
107
  // then do move
108
108
  this.moveFunc(e);
109
109
  }
@@ -117,11 +117,12 @@ export class ColumnMovePlugin extends BasePlugin {
117
117
  if (relativePos < 0) {
118
118
  relativePos = 0;
119
119
  }
120
- const newPosition = getItemByPosition(this.staticDragData.cols, relativePos);
120
+ const newPosition = getItemByPosition(this.staticDragData.cols, relativePos + (this.staticDragData.cols.renderOffset || 0));
121
121
  const store = this.providers.column.stores[this.dragData.type].store;
122
+ const source = store.get('source');
122
123
  const newItems = [...store.get('items')];
123
124
  // prevent position change if needed
124
- const { defaultPrevented: stopDrag } = dispatch(this.revogrid, BEFORE_DRAG_END, Object.assign(Object.assign({}, this.staticDragData), { startPosition: this.staticDragData.startItem, newPosition, newItem: store.get('source')[newItems[this.staticDragData.startItem.itemIndex]] }));
125
+ const { defaultPrevented: stopDrag } = dispatch(this.revogrid, BEFORE_COLUMN_DRAG_END_EVENT, Object.assign(Object.assign({}, this.staticDragData), { startPosition: this.staticDragData.startItem, newPosition, newItem: source[newItems[this.staticDragData.startItem.itemIndex]] }));
125
126
  if (!stopDrag) {
126
127
  const prevItems = [...newItems];
127
128
  // todo: if move item out of group remove item from group
@@ -130,7 +131,7 @@ export class ColumnMovePlugin extends BasePlugin {
130
131
  store.set('items', newItems);
131
132
  this.providers.dimension.updateSizesPositionByNewDataIndexes(this.dragData.type, newItems, prevItems);
132
133
  }
133
- dispatch(this.revogrid, DRAG_END, this.dragData);
134
+ dispatch(this.revogrid, COLUMN_DRAG_END_EVENT, this.getData(this.staticDragData, newItems, source));
134
135
  }
135
136
  this.clearOrder();
136
137
  }
@@ -150,13 +151,15 @@ export class ColumnMovePlugin extends BasePlugin {
150
151
  super.clearSubscriptions();
151
152
  this.clearLocalSubscriptions();
152
153
  }
153
- getData({ gridEl, dataEl, pin, }) {
154
+ getData({ gridEl, dataEl, pin }, order, source = []) {
154
155
  const gridRect = gridEl.getBoundingClientRect();
155
156
  const elRect = dataEl.getBoundingClientRect();
156
157
  const scrollOffset = elRect.left - gridRect.left;
157
158
  return {
159
+ columns: order.map(index => source[index]).filter(Boolean),
158
160
  elRect,
159
161
  gridRect,
162
+ order,
160
163
  type: pin || 'rgCol',
161
164
  scrollOffset,
162
165
  };
@@ -1,13 +1,177 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
+ import { GROUP_COLUMN_PROP } from "../groupingRow/grouping.const";
4
5
  import { isGrouping } from "../groupingRow/grouping.service";
5
6
  import { getCellRaw } from "../../utils/column.utils";
6
- export function sortIndexByItems(indexes, source, sortingFunc = {}) {
7
+ /**
8
+ * Checks whether a sorting map contains at least one active order.
9
+ *
10
+ * Empty maps and properties with `undefined` order are treated as inactive.
11
+ */
12
+ export function hasActiveSorting(sorting) {
13
+ for (const prop of Object.keys(sorting || {})) {
14
+ if (sorting === null || sorting === void 0 ? void 0 : sorting[prop]) {
15
+ return true;
16
+ }
17
+ }
18
+ return false;
19
+ }
20
+ /**
21
+ * Compares column properties after object-key coercion.
22
+ */
23
+ function isSameColumnProp(a, b) {
24
+ return String(a) === String(b);
25
+ }
26
+ /**
27
+ * Returns active sorting properties in explicit priority order.
28
+ */
29
+ function getActiveSortingProps(sorting, sortingOrder) {
30
+ const activeProps = [];
31
+ const add = (prop) => {
32
+ if ((sorting === null || sorting === void 0 ? void 0 : sorting[prop]) && !activeProps.some(active => isSameColumnProp(active, prop))) {
33
+ activeProps.push(prop);
34
+ }
35
+ };
36
+ sortingOrder === null || sortingOrder === void 0 ? void 0 : sortingOrder.forEach(add);
37
+ Object.keys(sorting || {}).forEach(add);
38
+ return activeProps;
39
+ }
40
+ /**
41
+ * Returns one-based additive sorting rank for a column.
42
+ *
43
+ * A single active sort does not need a visible rank, so it returns undefined.
44
+ */
45
+ export function getSortingIndex(sorting, prop, sortingOrder) {
46
+ const activeProps = getActiveSortingProps(sorting, sortingOrder);
47
+ if (activeProps.length <= 1) {
48
+ return undefined;
49
+ }
50
+ const index = activeProps.findIndex(active => isSameColumnProp(active, prop));
51
+ return index >= 0 ? index + 1 : undefined;
52
+ }
53
+ /**
54
+ * Collects only active comparator functions from a sorting function map.
55
+ *
56
+ * This keeps undefined comparator entries from triggering sorting work.
57
+ */
58
+ function activeSortingEntries(sortingFunc = {}, sortingOrder) {
59
+ const entries = [];
60
+ const add = (prop) => {
61
+ const cmp = sortingFunc[prop];
62
+ if (typeof cmp === 'function' && !entries.some(([active]) => isSameColumnProp(active, prop))) {
63
+ entries.push([prop, cmp]);
64
+ }
65
+ };
66
+ sortingOrder === null || sortingOrder === void 0 ? void 0 : sortingOrder.forEach(add);
67
+ Object.keys(sortingFunc).forEach(add);
68
+ return entries;
69
+ }
70
+ /**
71
+ * Reads and normalizes a value for the built-in default comparer.
72
+ */
73
+ function getDefaultCompareValue(item, prop, column) {
74
+ const aRaw = column ? getCellRaw(item, column) : item === null || item === void 0 ? void 0 : item[prop];
75
+ return typeof aRaw === 'number' ? aRaw : aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
76
+ }
77
+ function isEmptyCompareValue(value) {
78
+ return value === '' || value === null || value === undefined;
79
+ }
80
+ /**
81
+ * Compares two already-normalized default comparer values.
82
+ */
83
+ function compareValues(av, bv) {
84
+ if (av === bv) {
85
+ return 0;
86
+ }
87
+ const aEmpty = isEmptyCompareValue(av);
88
+ const bEmpty = isEmptyCompareValue(bv);
89
+ if (aEmpty || bEmpty) {
90
+ if (aEmpty && bEmpty) {
91
+ return 0;
92
+ }
93
+ return aEmpty ? -1 : 1;
94
+ }
95
+ if (av > bv) {
96
+ return 1;
97
+ }
98
+ return -1;
99
+ }
100
+ /**
101
+ * Sorts indexes by precomputed values for default column comparers.
102
+ *
103
+ * This avoids repeatedly parsing the same cell value during large default
104
+ * sorts while preserving normal multi-column ordering.
105
+ */
106
+ function sortIndexByDefaultComparers(indexes, source, entries, sorting, sortingColumns) {
107
+ const prepared = entries.map(([prop]) => {
108
+ const values = [];
109
+ const column = sortingColumns[prop];
110
+ for (const index of indexes) {
111
+ values[index] = getDefaultCompareValue(source[index], prop, column);
112
+ }
113
+ return {
114
+ order: sorting[prop],
115
+ values,
116
+ };
117
+ });
118
+ return indexes.sort((a, b) => {
119
+ for (const { order, values } of prepared) {
120
+ const sorted = compareValues(values[a], values[b]);
121
+ if (sorted) {
122
+ return order === 'desc' ? -sorted : sorted;
123
+ }
124
+ }
125
+ return 0;
126
+ });
127
+ }
128
+ /**
129
+ * Detects whether the optimized default-comparer path can be used.
130
+ *
131
+ * Grouped rows and custom `cellCompare` functions stay on the legacy
132
+ * comparator path to preserve their exact behavior.
133
+ */
134
+ function canUseDefaultCompareFastPath(entries, indexes, source, sorting, sortingColumns) {
135
+ return !indexes.some(index => isGrouping(source[index])) && !!sorting && !!sortingColumns && entries.every(([prop]) => {
136
+ const order = sorting[prop];
137
+ const column = sortingColumns[prop];
138
+ return !!order && !(column === null || column === void 0 ? void 0 : column.cellCompare);
139
+ });
140
+ }
141
+ /**
142
+ * Group placeholder rows are generated for their grouping column. If sorting is
143
+ * requested for another column, the grouped source must be unwrapped first.
144
+ */
145
+ function hasGroupingRowsForOtherSorting(entries, indexes, source) {
146
+ return indexes.some(index => {
147
+ const item = source[index];
148
+ return isGrouping(item) && !entries.some(([prop]) => isSameColumnProp(item[GROUP_COLUMN_PROP], prop));
149
+ });
150
+ }
151
+ /**
152
+ * Sorts row indexes against a source collection.
153
+ *
154
+ * @param indexes - Current proxy row indexes to sort.
155
+ * @param source - Full source collection addressed by the indexes.
156
+ * @param sortingFunc - Comparator functions by column property.
157
+ * @param sorting - Active sorting order by column property.
158
+ * @param sortingColumns - Column metadata by property for default-comparer optimization.
159
+ * @param sortingOrder - Active sorting priority in click/config insertion order.
160
+ * @returns Sorted proxy indexes. With no sorting function keys, returns source-order indexes.
161
+ */
162
+ export function sortIndexByItems(indexes, source, sortingFunc = {}, sorting, sortingColumns, sortingOrder) {
163
+ const hasSortingKeys = Object.keys(sortingFunc).length > 0;
164
+ const sortingEntries = activeSortingEntries(sortingFunc, sortingOrder);
7
165
  // if no sorting - return unsorted indexes
8
- if (Object.entries(sortingFunc).length === 0) {
166
+ if (sortingEntries.length === 0) {
9
167
  // Unsorted indexes
10
- return [...Array(indexes.length).keys()];
168
+ return hasSortingKeys ? indexes : [...new Array(indexes.length).keys()];
169
+ }
170
+ if (hasGroupingRowsForOtherSorting(sortingEntries, indexes, source)) {
171
+ return indexes;
172
+ }
173
+ if (canUseDefaultCompareFastPath(sortingEntries, indexes, source, sorting, sortingColumns)) {
174
+ return sortIndexByDefaultComparers(indexes, source, sortingEntries, sorting, sortingColumns);
11
175
  }
12
176
  //
13
177
  /**
@@ -17,15 +181,15 @@ export function sortIndexByItems(indexes, source, sortingFunc = {}) {
17
181
  return indexes.sort((a, b) => {
18
182
  const itemA = source[a];
19
183
  const itemB = source[b];
20
- for (const [prop, cmp] of Object.entries(sortingFunc)) {
184
+ for (const [prop, cmp] of sortingEntries) {
21
185
  if (isGrouping(itemA)) {
22
- if (itemA['__rvgr-prop'] !== prop) {
23
- return 0;
186
+ if (!isSameColumnProp(itemA[GROUP_COLUMN_PROP], prop)) {
187
+ return a - b;
24
188
  }
25
189
  }
26
190
  if (isGrouping(itemB)) {
27
- if (itemB['__rvgr-prop'] !== prop) {
28
- return 0;
191
+ if (!isSameColumnProp(itemB[GROUP_COLUMN_PROP], prop)) {
192
+ return a - b;
29
193
  }
30
194
  }
31
195
  /**
@@ -45,13 +209,7 @@ export function defaultCellCompare(prop, a, b) {
45
209
  const bRaw = this.column ? getCellRaw(b, this.column) : b === null || b === void 0 ? void 0 : b[prop];
46
210
  const av = typeof aRaw === 'number' ? aRaw : aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
47
211
  const bv = typeof bRaw === 'number' ? bRaw : bRaw === null || bRaw === void 0 ? void 0 : bRaw.toString().toLowerCase();
48
- if (av === bv) {
49
- return 0;
50
- }
51
- if (av > bv) {
52
- return 1;
53
- }
54
- return -1;
212
+ return compareValues(av, bv);
55
213
  }
56
214
  export function descCellCompare(cmp) {
57
215
  return (prop, a, b) => {