@revolist/revogrid 4.14.0 → 4.14.2

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 (67) hide show
  1. package/dist/cjs/{column.drag.plugin-c61efe93.js → column.drag.plugin-911acec7.js} +52 -28
  2. package/dist/cjs/column.drag.plugin-911acec7.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +3 -2
  4. package/dist/cjs/index.cjs.js.map +1 -1
  5. package/dist/cjs/revo-grid.cjs.entry.js +20 -50
  6. package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
  7. package/dist/cjs/revogr-attribution_7.cjs.entry.js +20 -11
  8. package/dist/cjs/revogr-attribution_7.cjs.entry.js.map +1 -1
  9. package/dist/cjs/revogr-clipboard_3.cjs.entry.js +1 -1
  10. package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
  11. package/dist/collection/components/editors/revogr-edit.js +2 -2
  12. package/dist/collection/components/editors/revogr-edit.js.map +1 -1
  13. package/dist/collection/components/overlay/revogr-overlay-selection.js +40 -11
  14. package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
  15. package/dist/collection/components/revoGrid/revo-grid.js +42 -42
  16. package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
  17. package/dist/collection/plugins/sorting/sorting.plugin.js +52 -27
  18. package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
  19. package/dist/collection/plugins/sorting/sorting.types.js.map +1 -1
  20. package/dist/collection/serve/controller.js +12 -0
  21. package/dist/collection/services/column.data.provider.js +0 -38
  22. package/dist/collection/services/column.data.provider.js.map +1 -1
  23. package/dist/collection/types/events.js +2 -1
  24. package/dist/collection/types/events.js.map +1 -1
  25. package/dist/esm/{column.drag.plugin-eb8f7e38.js → column.drag.plugin-a111b876.js} +53 -28
  26. package/dist/esm/column.drag.plugin-a111b876.js.map +1 -0
  27. package/dist/esm/index.js +4 -3
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/revo-grid.entry.js +20 -50
  30. package/dist/esm/revo-grid.entry.js.map +1 -1
  31. package/dist/esm/revogr-attribution_7.entry.js +20 -11
  32. package/dist/esm/revogr-attribution_7.entry.js.map +1 -1
  33. package/dist/esm/revogr-clipboard_3.entry.js +1 -1
  34. package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
  35. package/dist/revo-grid/{column.drag.plugin-eb8f7e38.js → column.drag.plugin-a111b876.js} +53 -28
  36. package/dist/revo-grid/column.drag.plugin-a111b876.js.map +1 -0
  37. package/dist/revo-grid/index.esm.js +4 -3
  38. package/dist/revo-grid/index.esm.js.map +1 -1
  39. package/dist/revo-grid/revo-grid.entry.js +20 -50
  40. package/dist/revo-grid/revo-grid.entry.js.map +1 -1
  41. package/dist/revo-grid/revogr-attribution_7.entry.js +20 -11
  42. package/dist/revo-grid/revogr-attribution_7.entry.js.map +1 -1
  43. package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
  44. package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
  45. package/dist/types/components/editors/revogr-edit.d.ts +1 -1
  46. package/dist/types/components/overlay/revogr-overlay-selection.d.ts +5 -0
  47. package/dist/types/components/revoGrid/revo-grid.d.ts +10 -7
  48. package/dist/types/components.d.ts +19 -15
  49. package/dist/types/plugins/sorting/sorting.plugin.d.ts +12 -4
  50. package/dist/types/plugins/sorting/sorting.types.d.ts +1 -0
  51. package/dist/types/services/column.data.provider.d.ts +0 -7
  52. package/dist/types/types/events.d.ts +1 -1
  53. package/hydrate/index.js +158 -154
  54. package/hydrate/index.mjs +158 -154
  55. package/package.json +1 -1
  56. package/readme.md +6 -0
  57. package/standalone/index.js +2 -1
  58. package/standalone/index.js.map +1 -1
  59. package/standalone/revo-grid.js +70 -75
  60. package/standalone/revo-grid.js.map +1 -1
  61. package/standalone/revogr-edit2.js +1 -1
  62. package/standalone/revogr-edit2.js.map +1 -1
  63. package/standalone/revogr-overlay-selection2.js +20 -11
  64. package/standalone/revogr-overlay-selection2.js.map +1 -1
  65. package/dist/cjs/column.drag.plugin-c61efe93.js.map +0 -1
  66. package/dist/esm/column.drag.plugin-eb8f7e38.js.map +0 -1
  67. package/dist/revo-grid/column.drag.plugin-eb8f7e38.js.map +0 -1
@@ -1822,24 +1822,23 @@ function getComparer(column, order) {
1822
1822
  /**
1823
1823
  * Lifecycle
1824
1824
  * 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.
1825
- * 1.1. @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.
1826
- * 2. Method `updateColumnSorting` - Updates the column sorting icon on the grid and the column itself, but the data remains untouched.
1825
+ * 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.
1827
1826
  * 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.
1828
1827
  * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
1829
1828
  *
1830
1829
  * Note: If you prevent an event, it will not proceed to the subsequent steps.
1831
1830
  */
1832
1831
  class SortingPlugin extends BasePlugin {
1833
- runSorting(order, comparison, ignoreViewportUpdate) {
1834
- var _a;
1835
- this.sort(order, comparison, undefined, ignoreViewportUpdate);
1836
- (_a = this.sortingPromise) === null || _a === void 0 ? void 0 : _a.call(this);
1837
- this.sortingPromise = null;
1838
- }
1839
1832
  constructor(revogrid, providers, config) {
1840
1833
  super(revogrid, providers);
1841
1834
  this.revogrid = revogrid;
1835
+ /**
1836
+ * Delayed sorting promise
1837
+ */
1842
1838
  this.sortingPromise = null;
1839
+ /**
1840
+ * We need to sort only so often
1841
+ */
1843
1842
  this.postponeSort = debounce((order, comparison, ignoreViewportUpdate) => this.runSorting(order, comparison, ignoreViewportUpdate), 50);
1844
1843
  const setConfig = (cfg) => {
1845
1844
  var _a;
@@ -1850,9 +1849,15 @@ class SortingPlugin extends BasePlugin {
1850
1849
  sortingFunc[col.prop] = getComparer(col, col.order);
1851
1850
  order[col.prop] = col.order;
1852
1851
  });
1853
- // // set sorting
1854
- this.sorting = order;
1855
- this.sortingFunc = sortingFunc;
1852
+ if (cfg.additive) {
1853
+ this.sorting = Object.assign(Object.assign({}, this.sorting), order);
1854
+ this.sortingFunc = Object.assign(Object.assign({}, this.sortingFunc), sortingFunc);
1855
+ }
1856
+ else {
1857
+ // // set sorting
1858
+ this.sorting = order;
1859
+ this.sortingFunc = sortingFunc;
1860
+ }
1856
1861
  }
1857
1862
  };
1858
1863
  setConfig(config);
@@ -1861,6 +1866,13 @@ class SortingPlugin extends BasePlugin {
1861
1866
  setConfig(detail);
1862
1867
  this.startSorting(this.sorting, this.sortingFunc);
1863
1868
  });
1869
+ this.addEventListener('beforeheaderrender', ({ detail, }) => {
1870
+ var _a;
1871
+ const { data: column } = detail;
1872
+ if (column.sortable) {
1873
+ detail.data = Object.assign(Object.assign({}, column), { order: (_a = this.sorting) === null || _a === void 0 ? void 0 : _a[column.prop] });
1874
+ }
1875
+ });
1864
1876
  this.addEventListener('beforeanysource', ({ detail: { type }, }) => {
1865
1877
  // if sorting was provided - sort data
1866
1878
  if (!!this.sorting && this.sortingFunc) {
@@ -1894,9 +1906,12 @@ class SortingPlugin extends BasePlugin {
1894
1906
  if (!((_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.sortable)) {
1895
1907
  return;
1896
1908
  }
1897
- this.headerclick(e.detail.column, e.detail.index, (_d = (_c = e.detail) === null || _c === void 0 ? void 0 : _c.originalEvent) === null || _d === void 0 ? void 0 : _d.shiftKey);
1909
+ this.headerclick(e.detail.column, (_d = (_c = e.detail) === null || _c === void 0 ? void 0 : _c.originalEvent) === null || _d === void 0 ? void 0 : _d.shiftKey);
1898
1910
  });
1899
1911
  }
1912
+ /**
1913
+ * Entry point for sorting, waits for all delayes, registers jobs
1914
+ */
1900
1915
  startSorting(order, sortingFunc, ignoreViewportUpdate) {
1901
1916
  if (!this.sortingPromise) {
1902
1917
  // add job before render
@@ -1910,18 +1925,18 @@ class SortingPlugin extends BasePlugin {
1910
1925
  * Apply sorting to data on header click
1911
1926
  * If additive - add to existing sorting, multiple columns can be sorted
1912
1927
  */
1913
- headerclick(column, index, additive) {
1914
- var _a, _b;
1915
- let order = getNextOrder(column.order);
1928
+ headerclick(column, additive) {
1929
+ var _a, _b, _c;
1930
+ const columnProp = column.prop;
1931
+ let order = getNextOrder((_a = this.sorting) === null || _a === void 0 ? void 0 : _a[columnProp]);
1916
1932
  const beforeEvent = this.emit('beforesorting', { column, order, additive });
1917
1933
  if (beforeEvent.defaultPrevented) {
1918
1934
  return;
1919
1935
  }
1920
1936
  order = beforeEvent.detail.order;
1921
- const newCol = this.providers.column.updateColumnSorting(beforeEvent.detail.column, index, order, additive);
1922
1937
  // apply sort data
1923
1938
  const beforeApplyEvent = this.emit('beforesortingapply', {
1924
- column: newCol,
1939
+ column: beforeEvent.detail.column,
1925
1940
  order,
1926
1941
  additive,
1927
1942
  });
@@ -1935,28 +1950,34 @@ class SortingPlugin extends BasePlugin {
1935
1950
  this.sorting = Object.assign(Object.assign({}, this.sorting), sorting);
1936
1951
  // extend sorting function with new sorting for multiple columns sorting
1937
1952
  this.sortingFunc = Object.assign(Object.assign({}, this.sortingFunc), sortingFunc);
1938
- if (column.prop in sorting && size(sorting) > 1 && order === undefined) {
1939
- delete sorting[column.prop];
1940
- delete sortingFunc[column.prop];
1953
+ if (columnProp in sorting && size(sorting) > 1 && order === undefined) {
1954
+ delete sorting[columnProp];
1955
+ delete sortingFunc[columnProp];
1941
1956
  }
1942
1957
  else {
1943
- sorting[column.prop] = order;
1944
- sortingFunc[column.prop] = cmp;
1958
+ sorting[columnProp] = order;
1959
+ sortingFunc[columnProp] = cmp;
1945
1960
  }
1946
1961
  }
1947
1962
  else {
1948
1963
  if (order) {
1949
1964
  // reset sorting
1950
- this.sorting = { [column.prop]: order };
1951
- this.sortingFunc = { [column.prop]: cmp };
1965
+ this.sorting = { [columnProp]: order };
1966
+ this.sortingFunc = { [columnProp]: cmp };
1952
1967
  }
1953
1968
  else {
1954
- (_a = this.sorting) === null || _a === void 0 ? true : delete _a[column.prop];
1955
- (_b = this.sortingFunc) === null || _b === void 0 ? true : delete _b[column.prop];
1969
+ (_b = this.sorting) === null || _b === void 0 ? true : delete _b[columnProp];
1970
+ (_c = this.sortingFunc) === null || _c === void 0 ? true : delete _c[columnProp];
1956
1971
  }
1957
1972
  }
1958
1973
  this.startSorting(this.sorting, this.sortingFunc);
1959
1974
  }
1975
+ runSorting(order, comparison, ignoreViewportUpdate) {
1976
+ var _a;
1977
+ this.sort(order, comparison, undefined, ignoreViewportUpdate);
1978
+ (_a = this.sortingPromise) === null || _a === void 0 ? void 0 : _a.call(this);
1979
+ this.sortingPromise = null;
1980
+ }
1960
1981
  /**
1961
1982
  * Sort items by sorting function
1962
1983
  * @requires proxyItems applied to row store
@@ -2002,6 +2023,10 @@ class SortingPlugin extends BasePlugin {
2002
2023
  }
2003
2024
  }
2004
2025
  }
2026
+ // refresh columns to redraw column headers and show correct icon
2027
+ columnTypes.forEach((type) => {
2028
+ this.providers.column.dataSources[type].refresh();
2029
+ });
2005
2030
  this.emit('aftersortingapply');
2006
2031
  }
2007
2032
  }
@@ -2583,21 +2608,10 @@ function getLeftRelative(absoluteX, gridPos, offset) {
2583
2608
  }
2584
2609
 
2585
2610
  class ColumnDataProvider {
2586
- get order() {
2587
- const order = {};
2588
- const sorting = this.sorting;
2589
- if (sorting) {
2590
- Object.keys(sorting).forEach(prop => {
2591
- order[prop] = sorting[prop].order;
2592
- });
2593
- }
2594
- return order;
2595
- }
2596
2611
  get stores() {
2597
2612
  return this.dataSources;
2598
2613
  }
2599
2614
  constructor() {
2600
- this.sorting = null;
2601
2615
  this.collection = null;
2602
2616
  this.dataSources = columnTypes.reduce((sources, k) => {
2603
2617
  sources[k] = new DataStore(k);
@@ -2656,7 +2670,6 @@ class ColumnDataProvider {
2656
2670
  }, {}),
2657
2671
  });
2658
2672
  });
2659
- this.sorting = data.sort;
2660
2673
  this.collection = data;
2661
2674
  return data;
2662
2675
  }
@@ -2705,31 +2718,6 @@ class ColumnDataProvider {
2705
2718
  const type = getColumnType(column);
2706
2719
  setSourceByVirtualIndex(this.dataSources[type].store, { [index]: column });
2707
2720
  }
2708
- updateColumnSorting(column, index, sorting, additive) {
2709
- if (!additive) {
2710
- this.clearSorting();
2711
- }
2712
- column.order = sorting;
2713
- if (!this.sorting) {
2714
- this.sorting = {};
2715
- }
2716
- this.sorting[column.prop] = column;
2717
- this.updateColumn(column, index);
2718
- return column;
2719
- }
2720
- clearSorting() {
2721
- const types = reduce(this.sorting, (r, c) => {
2722
- const k = getColumnType(c);
2723
- r[k] = true;
2724
- return r;
2725
- }, {});
2726
- forEach(types, (_, type) => {
2727
- const cols = this.dataSources[type].store.get('source');
2728
- forEach(cols, (c) => (c.order = undefined));
2729
- this.dataSources[type].setData({ source: [...cols] });
2730
- });
2731
- this.sorting = {};
2732
- }
2733
2721
  }
2734
2722
 
2735
2723
  /**
@@ -3816,25 +3804,29 @@ const RevoGridComponent = /*@__PURE__*/ proxyCustomElement(class RevoGridCompone
3816
3804
  }
3817
3805
  /**
3818
3806
  * Update column sorting
3819
- * @param column - full column details to update
3820
- * @param index - virtual column index
3807
+ * @param column - column prop and cellCompare
3821
3808
  * @param order - order to apply
3822
3809
  * @param additive - if false will replace current order
3810
+ *
3811
+ * later passed to SortingPlugin
3823
3812
  */
3824
- async updateColumnSorting(column, index, order, additive) {
3825
- if (!this.columnProvider) {
3826
- throw new Error('Not connected');
3827
- }
3828
- return this.columnProvider.updateColumnSorting(column, index, order, additive);
3813
+ async updateColumnSorting(column, order, additive) {
3814
+ this.sortingconfigchanged.emit({
3815
+ columns: [{
3816
+ prop: column.prop,
3817
+ order,
3818
+ cellCompare: column.cellCompare,
3819
+ }],
3820
+ additive,
3821
+ });
3829
3822
  }
3830
3823
  /**
3831
3824
  * Clears column sorting
3832
3825
  */
3833
3826
  async clearSorting() {
3834
- if (!this.columnProvider) {
3835
- throw new Error('Not connected');
3836
- }
3837
- this.columnProvider.clearSorting();
3827
+ this.sortingconfigchanged.emit({
3828
+ columns: [],
3829
+ });
3838
3830
  }
3839
3831
  /**
3840
3832
  * Receive all columns in data source
@@ -4042,7 +4034,10 @@ const RevoGridComponent = /*@__PURE__*/ proxyCustomElement(class RevoGridCompone
4042
4034
  const columns = this.columnProvider.setColumns(beforeApplyEvent.detail);
4043
4035
  this.aftercolumnsset.emit({
4044
4036
  columns,
4045
- order: this.columnProvider.order,
4037
+ order: Object.entries(beforeApplyEvent.detail.sort).reduce((acc, [prop, column]) => {
4038
+ acc[prop] = column.order;
4039
+ return acc;
4040
+ }, {}),
4046
4041
  });
4047
4042
  }
4048
4043
  disableVirtualXChanged(newVal = false, prevVal = false) {