@revolist/revogrid 4.14.1 → 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 (37) 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 +1 -1
  4. package/dist/cjs/revo-grid.cjs.entry.js +20 -50
  5. package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
  6. package/dist/collection/components/revoGrid/revo-grid.js +42 -42
  7. package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
  8. package/dist/collection/plugins/sorting/sorting.plugin.js +52 -27
  9. package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
  10. package/dist/collection/plugins/sorting/sorting.types.js.map +1 -1
  11. package/dist/collection/serve/controller.js +12 -0
  12. package/dist/collection/services/column.data.provider.js +0 -38
  13. package/dist/collection/services/column.data.provider.js.map +1 -1
  14. package/dist/esm/{column.drag.plugin-eb8f7e38.js → column.drag.plugin-a111b876.js} +53 -28
  15. package/dist/esm/column.drag.plugin-a111b876.js.map +1 -0
  16. package/dist/esm/index.js +2 -2
  17. package/dist/esm/revo-grid.entry.js +20 -50
  18. package/dist/esm/revo-grid.entry.js.map +1 -1
  19. package/dist/revo-grid/{column.drag.plugin-eb8f7e38.js → column.drag.plugin-a111b876.js} +53 -28
  20. package/dist/revo-grid/column.drag.plugin-a111b876.js.map +1 -0
  21. package/dist/revo-grid/index.esm.js +2 -2
  22. package/dist/revo-grid/revo-grid.entry.js +20 -50
  23. package/dist/revo-grid/revo-grid.entry.js.map +1 -1
  24. package/dist/types/components/revoGrid/revo-grid.d.ts +10 -7
  25. package/dist/types/components.d.ts +11 -12
  26. package/dist/types/plugins/sorting/sorting.plugin.d.ts +12 -4
  27. package/dist/types/plugins/sorting/sorting.types.d.ts +1 -0
  28. package/dist/types/services/column.data.provider.d.ts +0 -7
  29. package/hydrate/index.js +137 -142
  30. package/hydrate/index.mjs +137 -142
  31. package/package.json +1 -1
  32. package/readme.md +6 -0
  33. package/standalone/revo-grid.js +70 -75
  34. package/standalone/revo-grid.js.map +1 -1
  35. package/dist/cjs/column.drag.plugin-c61efe93.js.map +0 -1
  36. package/dist/esm/column.drag.plugin-eb8f7e38.js.map +0 -1
  37. package/dist/revo-grid/column.drag.plugin-eb8f7e38.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sorting.plugin.js","sourceRoot":"","sources":["../../../src/plugins/sorting/sorting.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQ5C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE7E,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B;;;;;;;;;GASG;AAEH,MAAM,OAAO,aAAc,SAAQ,UAAU;IAa3C,UAAU,CACR,KAAoB,EACpB,UAAiC,EACjC,oBAA8B;;QAE9B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAC9D,MAAA,IAAI,CAAC,cAAc,oDAAI,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,YACS,QAA6B,EACpC,SAA0B,EAC1B,MAAsB;QAEtB,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAJpB,aAAQ,GAAR,QAAQ,CAAqB;QAlBtC,mBAAc,GAAwB,IA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ACvB,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACtD,WAAW;gBACX,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAChD,cAAc;gBACd,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gBAExD,MAAM,aAAa,GAAG,gBAAgB,CACpC,CAAC,GAAG,UAAU,CAAC,EACf,MAAM,EACN,WAAW,CACZ,CAAC;gBAEF,uDAAuD;gBACvD,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAClD,YAAY,CAAC,OAAO,CAAC;oBACnB,UAAU,EAAE,aAAa;oBACzB,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC;iBACpB,CAAC,CAAC;gBACH,qCAAqC;gBACrC,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACjD,IAAI,CAAC,oBAAoB,EAAE,CAAC;oBAC1B,IAAI,CAAC,SAAS,CAAC,SAAS;yBACrB,mCAAmC,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;gBACpE,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACjC,CAAC;CACF","sourcesContent":["import size from 'lodash/size';\nimport debounce from 'lodash/debounce';\n\nimport { BasePlugin } from '../base.plugin';\nimport type {\n Order,\n ColumnRegular,\n DimensionRows,\n PluginProviders,\n} from '@type';\nimport type { SortingConfig, SortingOrder, SortingOrderFunction } from './sorting.types';\nimport { getColumnByProp } from '../../utils/column.utils';\nimport { rowTypes } from '@store';\nimport { getComparer, getNextOrder, sortIndexByItems } from './sorting.func';\n\nexport * from './sorting.types';\nexport * from './sorting.func';\nexport * from './sorting.sign';\n\n/**\n * Lifecycle\n * 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.\n * 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.\n * 2. Method `updateColumnSorting` - Updates the column sorting icon on the grid and the column itself, but the data remains untouched.\n * 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.\n * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.\n *\n * Note: If you prevent an event, it will not proceed to the subsequent steps.\n */\n\nexport class SortingPlugin extends BasePlugin {\n // sorting order per column\n sorting?: SortingOrder;\n\n // sorting function per column, multiple columns sorting supported\n sortingFunc?: SortingOrderFunction;\n sortingPromise: (() => void) | null = null;\n postponeSort = debounce(\n (order?: SortingOrder, comparison?: SortingOrderFunction, ignoreViewportUpdate?: boolean) =>\n this.runSorting(order, comparison, ignoreViewportUpdate),\n 50,\n );\n\n runSorting(\n order?: SortingOrder,\n comparison?: SortingOrderFunction,\n ignoreViewportUpdate?: boolean\n ) {\n this.sort(order, comparison, undefined, ignoreViewportUpdate);\n this.sortingPromise?.();\n this.sortingPromise = null;\n }\n\n constructor(\n public revogrid: HTMLRevoGridElement,\n providers: PluginProviders,\n config?: SortingConfig,\n ) {\n super(revogrid, providers);\n\n const setConfig = (cfg?: SortingConfig) => {\n if (cfg) {\n const sortingFunc: SortingOrderFunction = {};\n const order: SortingOrder = {};\n cfg.columns?.forEach(col => {\n sortingFunc[col.prop] = getComparer(col, col.order);\n order[col.prop] = col.order;\n });\n\n // // set sorting\n this.sorting = order;\n this.sortingFunc = sortingFunc;\n }\n }\n\n setConfig(config);\n\n this.addEventListener('sortingconfigchanged', ({ detail }) => {\n config = detail;\n setConfig(detail);\n this.startSorting(this.sorting, this.sortingFunc);\n });\n\n this.addEventListener('beforeanysource', ({\n detail: { type },\n }) => {\n // if sorting was provided - sort data\n if (!!this.sorting && this.sortingFunc) {\n const event = this.emit('beforesourcesortingapply', { type, sorting: this.sorting });\n if (event.defaultPrevented) {\n return;\n }\n this.startSorting(this.sorting, this.sortingFunc);\n }\n });\n this.addEventListener('aftercolumnsset', ({\n detail: { order },\n }) => {\n // if config provided - do nothing, read from config\n if (config) {\n return;\n }\n\n const columns = this.providers.column.getColumns();\n const sortingFunc: SortingOrderFunction = {};\n\n for (let prop in order) {\n const cmp = getComparer(\n getColumnByProp(columns, prop),\n order[prop],\n );\n sortingFunc[prop] = cmp;\n }\n\n // set sorting\n this.sorting = order;\n this.sortingFunc = order && sortingFunc;\n });\n this.addEventListener('beforeheaderclick', (e) => {\n if (e.defaultPrevented) {\n return;\n }\n\n if (!e.detail?.column?.sortable) {\n return;\n }\n\n this.headerclick(\n e.detail.column,\n e.detail.index,\n e.detail?.originalEvent?.shiftKey,\n );\n });\n }\n\n startSorting(order?: SortingOrder, sortingFunc?: SortingOrderFunction, ignoreViewportUpdate?: boolean) {\n if (!this.sortingPromise) {\n // add job before render\n this.revogrid.jobsBeforeRender.push(\n new Promise<void>(resolve => {\n this.sortingPromise = resolve;\n }),\n );\n }\n this.postponeSort(order, sortingFunc, ignoreViewportUpdate);\n }\n\n\n /**\n * Apply sorting to data on header click\n * If additive - add to existing sorting, multiple columns can be sorted\n */\n headerclick(column: ColumnRegular, index: number, additive: boolean) {\n let order: Order = getNextOrder(column.order);\n const beforeEvent = this.emit('beforesorting', { column, order, additive });\n if (beforeEvent.defaultPrevented) {\n return;\n }\n order = beforeEvent.detail.order;\n const newCol = this.providers.column.updateColumnSorting(\n beforeEvent.detail.column,\n index,\n order,\n additive,\n );\n\n // apply sort data\n const beforeApplyEvent = this.emit('beforesortingapply', {\n column: newCol,\n order,\n additive,\n });\n if (beforeApplyEvent.defaultPrevented) {\n return;\n }\n const cmp = getComparer(beforeApplyEvent.detail.column, beforeApplyEvent.detail.order);\n\n if (beforeApplyEvent.detail.additive && this.sorting) {\n const sorting: SortingOrder = {};\n const sortingFunc: SortingOrderFunction = {};\n\n this.sorting = {\n ...this.sorting,\n ...sorting,\n };\n // extend sorting function with new sorting for multiple columns sorting\n this.sortingFunc = {\n ...this.sortingFunc,\n ...sortingFunc,\n };\n\n if (column.prop in sorting && size(sorting) > 1 && order === undefined) {\n delete sorting[column.prop];\n delete sortingFunc[column.prop];\n } else {\n sorting[column.prop] = order;\n sortingFunc[column.prop] = cmp;\n }\n } else {\n if (order) {\n // reset sorting\n this.sorting = { [column.prop]: order };\n this.sortingFunc = { [column.prop]: cmp };\n } else {\n delete this.sorting?.[column.prop];\n delete this.sortingFunc?.[column.prop];\n }\n }\n\n this.startSorting(this.sorting, this.sortingFunc);\n }\n\n /**\n * Sort items by sorting function\n * @requires proxyItems applied to row store\n * @requires source applied to row store\n *\n * @param sorting - per column sorting\n * @param data - this.stores['rgRow'].store.get('source')\n */\n sort(\n sorting?: SortingOrder,\n sortingFunc?: SortingOrderFunction,\n types: DimensionRows[] = rowTypes,\n ignoreViewportUpdate = false\n ) {\n // if no sorting - reset\n if (!Object.keys(sorting || {}).length) {\n for (let type of types) {\n const storeService = this.providers.data.stores[type];\n // row data\n const source = storeService.store.get('source');\n // row indexes\n const proxyItems = storeService.store.get('proxyItems');\n // row indexes\n const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)\n this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);\n storeService.setData({ proxyItems: newItemsOrder, source: [...source], });\n }\n } else {\n for (let type of types) {\n const storeService = this.providers.data.stores[type];\n // row data\n const source = storeService.store.get('source');\n // row indexes\n const proxyItems = storeService.store.get('proxyItems');\n\n const newItemsOrder = sortIndexByItems(\n [...proxyItems],\n source,\n sortingFunc,\n );\n \n // take row indexes before trim applied and proxy items\n const prevItems = storeService.store.get('items');\n storeService.setData({\n proxyItems: newItemsOrder,\n source: [...source],\n });\n // take currently visible row indexes\n const newItems = storeService.store.get('items');\n if (!ignoreViewportUpdate) {\n this.providers.dimension\n .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);\n }\n }\n }\n this.emit('aftersortingapply');\n }\n}\n\n\n"]}
1
+ {"version":3,"file":"sorting.plugin.js","sourceRoot":"","sources":["../../../src/plugins/sorting/sorting.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAQ5C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAE7E,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAE/B;;;;;;;;GAQG;AAEH,MAAM,OAAO,aAAc,SAAQ,UAAU;IAoB3C,YACS,QAA6B,EACpC,SAA0B,EAC1B,MAAsB;QAEtB,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAJpB,aAAQ,GAAR,QAAQ,CAAqB;QAftC;;WAEG;QACH,mBAAc,GAAwB,IAAI,CAAC;QAE3C;;WAEG;QACH,iBAAY,GAAG,QAAQ,CACrB,CAAC,KAAoB,EAAE,UAAiC,EAAE,oBAA8B,EAAE,EAAE,CAC1F,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,oBAAoB,CAAC,EAC1D,EAAE,CACH,CAAC;QASA,MAAM,SAAS,GAAG,CAAC,GAAmB,EAAE,EAAE;;YACxC,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,WAAW,GAAyB,EAAE,CAAC;gBAC7C,MAAM,KAAK,GAAiB,EAAE,CAAC;gBAC/B,MAAA,GAAG,CAAC,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CAAC,OAAO,EAAE,CAAC;QACpD,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACjC,CAAC;CACF","sourcesContent":["import size from 'lodash/size';\nimport debounce from 'lodash/debounce';\n\nimport { BasePlugin } from '../base.plugin';\nimport type {\n Order,\n ColumnRegular,\n DimensionRows,\n PluginProviders,\n} from '@type';\nimport type { SortingConfig, SortingOrder, SortingOrderFunction } from './sorting.types';\nimport { getColumnByProp } from '../../utils/column.utils';\nimport { columnTypes, rowTypes } from '@store';\nimport { getComparer, getNextOrder, sortIndexByItems } from './sorting.func';\n\nexport * from './sorting.types';\nexport * from './sorting.func';\nexport * from './sorting.sign';\n\n/**\n * Lifecycle\n * 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.\n * 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.\n * 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.\n * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.\n *\n * Note: If you prevent an event, it will not proceed to the subsequent steps.\n */\n\nexport class SortingPlugin extends BasePlugin {\n // Current sorting order per column prop\n sorting?: SortingOrder;\n\n // Each column sorting function, multiple columns sorting supported\n sortingFunc?: SortingOrderFunction;\n /**\n * Delayed sorting promise\n */\n sortingPromise: (() => void) | null = null;\n\n /**\n * We need to sort only so often\n */\n postponeSort = debounce(\n (order?: SortingOrder, comparison?: SortingOrderFunction, ignoreViewportUpdate?: boolean) =>\n this.runSorting(order, comparison, ignoreViewportUpdate),\n 50,\n );\n\n constructor(\n public revogrid: HTMLRevoGridElement,\n providers: PluginProviders,\n config?: SortingConfig,\n ) {\n super(revogrid, providers);\n\n const setConfig = (cfg?: SortingConfig) => {\n if (cfg) {\n const sortingFunc: SortingOrderFunction = {};\n const order: SortingOrder = {};\n cfg.columns?.forEach(col => {\n sortingFunc[col.prop] = getComparer(col, col.order);\n order[col.prop] = col.order;\n });\n\n if (cfg.additive) {\n this.sorting = {\n ...this.sorting,\n ...order,\n };\n this.sortingFunc = {\n ...this.sortingFunc,\n ...sortingFunc,\n };\n } else {\n // // set sorting\n this.sorting = order;\n this.sortingFunc = sortingFunc;\n }\n }\n }\n\n setConfig(config);\n\n this.addEventListener('sortingconfigchanged', ({ detail }) => {\n config = detail;\n setConfig(detail);\n this.startSorting(this.sorting, this.sortingFunc);\n });\n\n this.addEventListener('beforeheaderrender', ({\n detail,\n }) => {\n const { data: column } = detail;\n if (column.sortable) {\n detail.data = {\n ...column,\n order: this.sorting?.[column.prop],\n };\n }\n });\n\n this.addEventListener('beforeanysource', ({\n detail: { type },\n }) => {\n // if sorting was provided - sort data\n if (!!this.sorting && this.sortingFunc) {\n const event = this.emit('beforesourcesortingapply', { type, sorting: this.sorting });\n if (event.defaultPrevented) {\n return;\n }\n this.startSorting(this.sorting, this.sortingFunc);\n }\n });\n this.addEventListener('aftercolumnsset', ({\n detail: { order },\n }) => {\n // if config provided - do nothing, read from config\n if (config) {\n return;\n }\n\n const columns = this.providers.column.getColumns();\n const sortingFunc: SortingOrderFunction = {};\n\n for (let prop in order) {\n const cmp = getComparer(\n getColumnByProp(columns, prop),\n order[prop],\n );\n sortingFunc[prop] = cmp;\n }\n\n // set sorting\n this.sorting = order;\n this.sortingFunc = order && sortingFunc;\n });\n this.addEventListener('beforeheaderclick', (e) => {\n if (e.defaultPrevented) {\n return;\n }\n\n if (!e.detail?.column?.sortable) {\n return;\n }\n\n this.headerclick(\n e.detail.column,\n e.detail?.originalEvent?.shiftKey,\n );\n });\n }\n\n /**\n * Entry point for sorting, waits for all delayes, registers jobs\n */\n startSorting(order?: SortingOrder, sortingFunc?: SortingOrderFunction, ignoreViewportUpdate?: boolean) {\n if (!this.sortingPromise) {\n // add job before render\n this.revogrid.jobsBeforeRender.push(\n new Promise<void>(resolve => {\n this.sortingPromise = resolve;\n }),\n );\n }\n this.postponeSort(order, sortingFunc, ignoreViewportUpdate);\n }\n\n\n /**\n * Apply sorting to data on header click\n * If additive - add to existing sorting, multiple columns can be sorted\n */\n headerclick(column: ColumnRegular, additive: boolean) {\n const columnProp = column.prop;\n let order: Order = getNextOrder(this.sorting?.[columnProp]);\n const beforeEvent = this.emit('beforesorting', { column, order, additive });\n if (beforeEvent.defaultPrevented) {\n return;\n }\n order = beforeEvent.detail.order;\n\n // apply sort data\n const beforeApplyEvent = this.emit('beforesortingapply', {\n column: beforeEvent.detail.column,\n order,\n additive,\n });\n if (beforeApplyEvent.defaultPrevented) {\n return;\n }\n const cmp = getComparer(beforeApplyEvent.detail.column, beforeApplyEvent.detail.order);\n\n if (beforeApplyEvent.detail.additive && this.sorting) {\n const sorting: SortingOrder = {};\n const sortingFunc: SortingOrderFunction = {};\n\n this.sorting = {\n ...this.sorting,\n ...sorting,\n };\n // extend sorting function with new sorting for multiple columns sorting\n this.sortingFunc = {\n ...this.sortingFunc,\n ...sortingFunc,\n };\n\n if (columnProp in sorting && size(sorting) > 1 && order === undefined) {\n delete sorting[columnProp];\n delete sortingFunc[columnProp];\n } else {\n sorting[columnProp] = order;\n sortingFunc[columnProp] = cmp;\n }\n } else {\n if (order) {\n // reset sorting\n this.sorting = { [columnProp]: order };\n this.sortingFunc = { [columnProp]: cmp };\n } else {\n delete this.sorting?.[columnProp];\n delete this.sortingFunc?.[columnProp];\n }\n }\n\n this.startSorting(this.sorting, this.sortingFunc);\n }\n\n runSorting(\n order?: SortingOrder,\n comparison?: SortingOrderFunction,\n ignoreViewportUpdate?: boolean\n ) {\n this.sort(order, comparison, undefined, ignoreViewportUpdate);\n this.sortingPromise?.();\n this.sortingPromise = null;\n }\n\n /**\n * Sort items by sorting function\n * @requires proxyItems applied to row store\n * @requires source applied to row store\n *\n * @param sorting - per column sorting\n * @param data - this.stores['rgRow'].store.get('source')\n */\n sort(\n sorting?: SortingOrder,\n sortingFunc?: SortingOrderFunction,\n types: DimensionRows[] = rowTypes,\n ignoreViewportUpdate = false\n ) {\n // if no sorting - reset\n if (!Object.keys(sorting || {}).length) {\n for (let type of types) {\n const storeService = this.providers.data.stores[type];\n // row data\n const source = storeService.store.get('source');\n // row indexes\n const proxyItems = storeService.store.get('proxyItems');\n // row indexes\n const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)\n this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);\n storeService.setData({ proxyItems: newItemsOrder, source: [...source], });\n }\n } else {\n for (let type of types) {\n const storeService = this.providers.data.stores[type];\n // row data\n const source = storeService.store.get('source');\n // row indexes\n const proxyItems = storeService.store.get('proxyItems');\n\n const newItemsOrder = sortIndexByItems(\n [...proxyItems],\n source,\n sortingFunc,\n );\n \n // take row indexes before trim applied and proxy items\n const prevItems = storeService.store.get('items');\n storeService.setData({\n proxyItems: newItemsOrder,\n source: [...source],\n });\n // take currently visible row indexes\n const newItems = storeService.store.get('items');\n if (!ignoreViewportUpdate) {\n this.providers.dimension\n .updateSizesPositionByNewDataIndexes(type, newItems, prevItems);\n }\n }\n }\n // refresh columns to redraw column headers and show correct icon\n columnTypes.forEach((type) => {\n this.providers.column.dataSources[type].refresh();\n });\n this.emit('aftersortingapply');\n }\n}\n\n\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sorting.types.js","sourceRoot":"","sources":["../../../src/plugins/sorting/sorting.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CellCompareFunc, ColumnProp, Order } from '@type';\n\nexport type SortingOrder = Record<ColumnProp, Order>;\nexport type SortingOrderFunction = Record<\n ColumnProp,\n CellCompareFunc | undefined\n>;\nexport type ColumnSetEvent = {\n order: SortingOrder;\n};\n\nexport type SortingConfig = {\n columns?: { prop: ColumnProp; order: Order; cellCompare?: CellCompareFunc }[];\n};\n"]}
1
+ {"version":3,"file":"sorting.types.js","sourceRoot":"","sources":["../../../src/plugins/sorting/sorting.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CellCompareFunc, ColumnProp, Order } from '@type';\n\nexport type SortingOrder = Record<ColumnProp, Order>;\nexport type SortingOrderFunction = Record<\n ColumnProp,\n CellCompareFunc | undefined\n>;\nexport type ColumnSetEvent = {\n order: SortingOrder;\n};\n\nexport type SortingConfig = {\n columns?: { prop: ColumnProp; order: Order; cellCompare?: CellCompareFunc }[];\n additive?: boolean;\n};\n"]}
@@ -243,6 +243,18 @@ window.clearFilter = () => {
243
243
  grid.filter = {};
244
244
  };
245
245
 
246
+ window.sortColumn = (columnProp= 0, additive = false) => {
247
+ const grid = document.querySelector('revo-grid');
248
+ grid.updateColumnSorting({
249
+ prop: columnProp,
250
+ }, 'asc', additive);
251
+ };
252
+
253
+ window.clearSorting = () => {
254
+ const grid = document.querySelector('revo-grid');
255
+ grid.clearSorting();
256
+ };
257
+
246
258
  window.setFilter = () => {
247
259
  const grid = document.querySelector('revo-grid');
248
260
  const filterFunc = (cellValue, extraValue) => {
@@ -2,25 +2,13 @@
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
4
  import reduce from "lodash/reduce";
5
- import each from "lodash/each";
6
5
  import { columnTypes, DataStore, getSourceItem, getSourceItemVirtualIndexByProp, setSourceByPhysicalIndex, setSourceByVirtualIndex, } from "../store/index";
7
6
  import { getColumnType } from "../utils/column.utils";
8
7
  export default class ColumnDataProvider {
9
- get order() {
10
- const order = {};
11
- const sorting = this.sorting;
12
- if (sorting) {
13
- Object.keys(sorting).forEach(prop => {
14
- order[prop] = sorting[prop].order;
15
- });
16
- }
17
- return order;
18
- }
19
8
  get stores() {
20
9
  return this.dataSources;
21
10
  }
22
11
  constructor() {
23
- this.sorting = null;
24
12
  this.collection = null;
25
13
  this.dataSources = columnTypes.reduce((sources, k) => {
26
14
  sources[k] = new DataStore(k);
@@ -79,7 +67,6 @@ export default class ColumnDataProvider {
79
67
  }, {}),
80
68
  });
81
69
  });
82
- this.sorting = data.sort;
83
70
  this.collection = data;
84
71
  return data;
85
72
  }
@@ -128,30 +115,5 @@ export default class ColumnDataProvider {
128
115
  const type = getColumnType(column);
129
116
  setSourceByVirtualIndex(this.dataSources[type].store, { [index]: column });
130
117
  }
131
- updateColumnSorting(column, index, sorting, additive) {
132
- if (!additive) {
133
- this.clearSorting();
134
- }
135
- column.order = sorting;
136
- if (!this.sorting) {
137
- this.sorting = {};
138
- }
139
- this.sorting[column.prop] = column;
140
- this.updateColumn(column, index);
141
- return column;
142
- }
143
- clearSorting() {
144
- const types = reduce(this.sorting, (r, c) => {
145
- const k = getColumnType(c);
146
- r[k] = true;
147
- return r;
148
- }, {});
149
- each(types, (_, type) => {
150
- const cols = this.dataSources[type].store.get('source');
151
- each(cols, (c) => (c.order = undefined));
152
- this.dataSources[type].setData({ source: [...cols] });
153
- });
154
- this.sorting = {};
155
- }
156
118
  }
157
119
  //# sourceMappingURL=column.data.provider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"column.data.provider.js","sourceRoot":"","sources":["../../src/services/column.data.provider.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,IAAI,MAAM,aAAa,CAAC;AAE/B,OAAO,EACL,WAAW,EACX,SAAS,EACT,aAAa,EACb,+BAA+B,EAE/B,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,QAAQ,CAAC;AAMhB,OAAO,EAAoB,aAAa,EAAE,MAAM,uBAAuB,CAAC;AASxE,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAKrC,IAAI,KAAK;QACP,MAAM,KAAK,GAAiB,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAClC,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;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K,GAAG,MAAM,CAClB,IAAI,CAAC,OAAO,EACZ,CAAC,CAA+C,EAAE,CAAgB,EAAE,EAAE;YACpE,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;YACZ,OAAO,CAAC,CAAC;QACX,CAAC,EACD,EAAkD,CACnD,CAAC;QACF,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,IAAmB,EAAE,EAAE;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxD,IAAI,CAAC,IAAI,EAAE,CAAC,CAAgB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC;YACxD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;CACF","sourcesContent":["import reduce from 'lodash/reduce';\nimport each from 'lodash/each';\n\nimport {\n columnTypes,\n DataStore,\n getSourceItem,\n getSourceItemVirtualIndexByProp,\n Groups,\n setSourceByPhysicalIndex,\n setSourceByVirtualIndex,\n} from '@store';\nimport type {\n ColumnProp,\n ColumnRegular,\n DimensionCols,\n} from '@type';\nimport { ColumnCollection, getColumnType } from '../utils/column.utils';\n\nexport type ColumnDataSources = Record<\n DimensionCols,\n DataStore<ColumnRegular, DimensionCols>\n>;\ntype Sorting = Record<ColumnProp, ColumnRegular>;\ntype SortingOrder = Record<ColumnProp, 'asc' | 'desc' | undefined>;\n\nexport default class ColumnDataProvider {\n readonly dataSources: ColumnDataSources;\n sorting: Sorting | null = null;\n collection: ColumnCollection | null = null;\n\n get order() {\n const order: SortingOrder = {};\n const sorting = this.sorting;\n if (sorting) {\n Object.keys(sorting).forEach(prop => {\n order[prop] = sorting[prop].order;\n });\n }\n return order;\n }\n\n get stores() {\n return this.dataSources;\n }\n constructor() {\n this.dataSources = columnTypes.reduce(\n (sources: ColumnDataSources, k: DimensionCols) => {\n sources[k] = new DataStore(k);\n return sources;\n },\n {} as ColumnDataSources,\n );\n }\n\n column(c: number, type: DimensionCols = 'rgCol'): ColumnRegular | undefined {\n return this.getColumn(c, type);\n }\n\n getColumn(\n virtualIndex: number,\n type: DimensionCols,\n ): ColumnRegular | undefined {\n return getSourceItem(this.dataSources[type].store, virtualIndex);\n }\n\n getRawColumns(): Record<DimensionCols, ColumnRegular[]> {\n return reduce(\n this.dataSources,\n (\n result: Record<DimensionCols, ColumnRegular[]>,\n item,\n type: DimensionCols,\n ) => {\n result[type] = item.store.get('source');\n return result;\n },\n {\n rgCol: [],\n colPinStart: [],\n colPinEnd: [],\n },\n );\n }\n\n getColumns(type: DimensionCols | 'all' = 'all'): ColumnRegular[] {\n const columnsByType = this.getRawColumns();\n if (type !== 'all') {\n return columnsByType[type];\n }\n return columnTypes.reduce((r: ColumnRegular[], t) => [...r, ...columnsByType[t]], []);\n }\n\n getColumnIndexByProp(prop: ColumnProp, type: DimensionCols): number {\n return getSourceItemVirtualIndexByProp(this.dataSources[type].store, prop);\n }\n\n getColumnByProp(prop: ColumnProp) {\n return this.collection?.columnByProp[prop];\n }\n\n refreshByType(type: DimensionCols) {\n this.dataSources[type].refresh();\n }\n\n /**\n * Main method to set columns\n */\n setColumns(data: ColumnCollection): ColumnCollection {\n columnTypes.forEach(k => {\n // set columns data\n this.dataSources[k].updateData(data.columns[k], {\n // max depth level\n depth: data.maxLevel,\n\n // groups\n groups: data.columnGrouping[k].reduce((res: Groups, g) => {\n if (!res[g.level]) {\n res[g.level] = [];\n }\n res[g.level].push(g);\n return res;\n }, {}),\n });\n });\n this.sorting = data.sort;\n this.collection = data;\n return data;\n }\n\n /**\n * Used in plugins\n * Modify columns in store\n */\n updateColumns(updatedColumns: ColumnRegular[]) {\n // collect column by type and propert\n const columnByKey = updatedColumns.reduce(\n (\n res: Partial<Record<DimensionCols, Record<ColumnProp, ColumnRegular>>>,\n c,\n ) => {\n const type = getColumnType(c);\n if (!res[type]) {\n res[type] = {};\n }\n res[type][c.prop] = c;\n return res;\n },\n {},\n );\n\n // find indexes in source\n const colByIndex: Partial<\n Record<DimensionCols, Record<number, ColumnRegular>>\n > = {};\n for (const t in columnByKey) {\n if (!columnByKey.hasOwnProperty(t)) {\n continue;\n }\n const type = t as DimensionCols;\n const colsToUpdate = columnByKey[type];\n const sourceItems = this.dataSources[type].store.get('source');\n colByIndex[type] = {};\n for (let i = 0; i < sourceItems.length; i++) {\n const column = sourceItems[i];\n const colToUpdateIfExists = colsToUpdate?.[column.prop];\n\n // update column if exists in source\n if (colToUpdateIfExists) {\n colByIndex[type][i] = colToUpdateIfExists;\n }\n }\n }\n for (const t in colByIndex) {\n if (!colByIndex.hasOwnProperty(t)) {\n continue;\n }\n const type = t as DimensionCols;\n setSourceByPhysicalIndex(\n this.dataSources[type].store,\n colByIndex[type] || {},\n );\n }\n }\n\n updateColumn(column: ColumnRegular, index: number) {\n const type = getColumnType(column);\n setSourceByVirtualIndex(this.dataSources[type].store, { [index]: column });\n }\n\n updateColumnSorting(\n column: ColumnRegular,\n index: number,\n sorting: 'asc' | 'desc' | undefined,\n additive: boolean,\n ): ColumnRegular {\n if (!additive) {\n this.clearSorting();\n }\n column.order = sorting;\n if (!this.sorting) {\n this.sorting = {};\n }\n this.sorting[column.prop] = column;\n this.updateColumn(column, index);\n return column;\n }\n\n clearSorting() {\n const types = reduce(\n this.sorting,\n (r: { [key in Partial<DimensionCols>]: boolean }, c: ColumnRegular) => {\n const k = getColumnType(c);\n r[k] = true;\n return r;\n },\n {} as { [key in Partial<DimensionCols>]: boolean },\n );\n each(types, (_, type: DimensionCols) => {\n const cols = this.dataSources[type].store.get('source');\n each(cols, (c: ColumnRegular) => (c.order = undefined));\n this.dataSources[type].setData({ source: [...cols] });\n });\n\n this.sorting = {};\n }\n}\n"]}
1
+ {"version":3,"file":"column.data.provider.js","sourceRoot":"","sources":["../../src/services/column.data.provider.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,EACL,WAAW,EACX,SAAS,EACT,aAAa,EACb,+BAA+B,EAE/B,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,QAAQ,CAAC;AAMhB,OAAO,EAAoB,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAOxE,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAIrC,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IACD;QALA,eAAU,GAA4B,IAAI,CAAC;QAMzC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,MAAM,CACnC,CAAC,OAA0B,EAAE,CAAgB,EAAE,EAAE;YAC/C,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,OAAO,OAAO,CAAC;QACjB,CAAC,EACD,EAAuB,CACxB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,CAAS,EAAE,OAAsB,OAAO;QAC7C,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,SAAS,CACP,YAAoB,EACpB,IAAmB;QAEnB,OAAO,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACnE,CAAC;IAED,aAAa;QACX,OAAO,MAAM,CACX,IAAI,CAAC,WAAW,EAChB,CACE,MAA8C,EAC9C,IAAI,EACJ,IAAmB,EACnB,EAAE;YACF,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxC,OAAO,MAAM,CAAC;QAChB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,GAAG,EAAE,CAAC;YACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC5C,MAAM,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;gBAC9B,MAAM,mBAAmB,GAAG,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAG,MAAM,CAAC,IAAI,CAAC,CAAC;gBAExD,oCAAoC;gBACpC,IAAI,mBAAmB,EAAE,CAAC;oBACxB,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC;gBAC5C,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;YAC3B,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClC,SAAS;YACX,CAAC;YACD,MAAM,IAAI,GAAG,CAAkB,CAAC;YAChC,wBAAwB,CACtB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAC5B,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CACvB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,YAAY,CAAC,MAAqB,EAAE,KAAa;QAC/C,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACnC,uBAAuB,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7E,CAAC;CACF","sourcesContent":["import reduce from 'lodash/reduce';\nimport {\n columnTypes,\n DataStore,\n getSourceItem,\n getSourceItemVirtualIndexByProp,\n Groups,\n setSourceByPhysicalIndex,\n setSourceByVirtualIndex,\n} from '@store';\nimport type {\n ColumnProp,\n ColumnRegular,\n DimensionCols,\n} from '@type';\nimport { ColumnCollection, getColumnType } from '../utils/column.utils';\n\nexport type ColumnDataSources = Record<\n DimensionCols,\n DataStore<ColumnRegular, DimensionCols>\n>;\n\nexport default class ColumnDataProvider {\n readonly dataSources: ColumnDataSources;\n collection: ColumnCollection | null = null;\n\n get stores() {\n return this.dataSources;\n }\n constructor() {\n this.dataSources = columnTypes.reduce(\n (sources: ColumnDataSources, k: DimensionCols) => {\n sources[k] = new DataStore(k);\n return sources;\n },\n {} as ColumnDataSources,\n );\n }\n\n column(c: number, type: DimensionCols = 'rgCol'): ColumnRegular | undefined {\n return this.getColumn(c, type);\n }\n\n getColumn(\n virtualIndex: number,\n type: DimensionCols,\n ): ColumnRegular | undefined {\n return getSourceItem(this.dataSources[type].store, virtualIndex);\n }\n\n getRawColumns(): Record<DimensionCols, ColumnRegular[]> {\n return reduce(\n this.dataSources,\n (\n result: Record<DimensionCols, ColumnRegular[]>,\n item,\n type: DimensionCols,\n ) => {\n result[type] = item.store.get('source');\n return result;\n },\n {\n rgCol: [],\n colPinStart: [],\n colPinEnd: [],\n },\n );\n }\n\n getColumns(type: DimensionCols | 'all' = 'all'): ColumnRegular[] {\n const columnsByType = this.getRawColumns();\n if (type !== 'all') {\n return columnsByType[type];\n }\n return columnTypes.reduce((r: ColumnRegular[], t) => [...r, ...columnsByType[t]], []);\n }\n\n getColumnIndexByProp(prop: ColumnProp, type: DimensionCols): number {\n return getSourceItemVirtualIndexByProp(this.dataSources[type].store, prop);\n }\n\n getColumnByProp(prop: ColumnProp) {\n return this.collection?.columnByProp[prop];\n }\n\n refreshByType(type: DimensionCols) {\n this.dataSources[type].refresh();\n }\n\n /**\n * Main method to set columns\n */\n setColumns(data: ColumnCollection): ColumnCollection {\n columnTypes.forEach(k => {\n // set columns data\n this.dataSources[k].updateData(data.columns[k], {\n // max depth level\n depth: data.maxLevel,\n\n // groups\n groups: data.columnGrouping[k].reduce((res: Groups, g) => {\n if (!res[g.level]) {\n res[g.level] = [];\n }\n res[g.level].push(g);\n return res;\n }, {}),\n });\n });\n this.collection = data;\n return data;\n }\n\n /**\n * Used in plugins\n * Modify columns in store\n */\n updateColumns(updatedColumns: ColumnRegular[]) {\n // collect column by type and propert\n const columnByKey = updatedColumns.reduce(\n (\n res: Partial<Record<DimensionCols, Record<ColumnProp, ColumnRegular>>>,\n c,\n ) => {\n const type = getColumnType(c);\n if (!res[type]) {\n res[type] = {};\n }\n res[type][c.prop] = c;\n return res;\n },\n {},\n );\n\n // find indexes in source\n const colByIndex: Partial<\n Record<DimensionCols, Record<number, ColumnRegular>>\n > = {};\n for (const t in columnByKey) {\n if (!columnByKey.hasOwnProperty(t)) {\n continue;\n }\n const type = t as DimensionCols;\n const colsToUpdate = columnByKey[type];\n const sourceItems = this.dataSources[type].store.get('source');\n colByIndex[type] = {};\n for (let i = 0; i < sourceItems.length; i++) {\n const column = sourceItems[i];\n const colToUpdateIfExists = colsToUpdate?.[column.prop];\n\n // update column if exists in source\n if (colToUpdateIfExists) {\n colByIndex[type][i] = colToUpdateIfExists;\n }\n }\n }\n for (const t in colByIndex) {\n if (!colByIndex.hasOwnProperty(t)) {\n continue;\n }\n const type = t as DimensionCols;\n setSourceByPhysicalIndex(\n this.dataSources[type].store,\n colByIndex[type] || {},\n );\n }\n }\n\n updateColumn(column: ColumnRegular, index: number) {\n const type = getColumnType(column);\n setSourceByVirtualIndex(this.dataSources[type].store, { [index]: column });\n }\n}\n"]}
@@ -1739,24 +1739,23 @@ function getComparer(column, order) {
1739
1739
  /**
1740
1740
  * Lifecycle
1741
1741
  * 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.
1742
- * 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.
1743
- * 2. Method `updateColumnSorting` - Updates the column sorting icon on the grid and the column itself, but the data remains untouched.
1742
+ * 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.
1744
1743
  * 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.
1745
1744
  * 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
1746
1745
  *
1747
1746
  * Note: If you prevent an event, it will not proceed to the subsequent steps.
1748
1747
  */
1749
1748
  class SortingPlugin extends BasePlugin {
1750
- runSorting(order, comparison, ignoreViewportUpdate) {
1751
- var _a;
1752
- this.sort(order, comparison, undefined, ignoreViewportUpdate);
1753
- (_a = this.sortingPromise) === null || _a === void 0 ? void 0 : _a.call(this);
1754
- this.sortingPromise = null;
1755
- }
1756
1749
  constructor(revogrid, providers, config) {
1757
1750
  super(revogrid, providers);
1758
1751
  this.revogrid = revogrid;
1752
+ /**
1753
+ * Delayed sorting promise
1754
+ */
1759
1755
  this.sortingPromise = null;
1756
+ /**
1757
+ * We need to sort only so often
1758
+ */
1760
1759
  this.postponeSort = debounce((order, comparison, ignoreViewportUpdate) => this.runSorting(order, comparison, ignoreViewportUpdate), 50);
1761
1760
  const setConfig = (cfg) => {
1762
1761
  var _a;
@@ -1767,9 +1766,15 @@ class SortingPlugin extends BasePlugin {
1767
1766
  sortingFunc[col.prop] = getComparer(col, col.order);
1768
1767
  order[col.prop] = col.order;
1769
1768
  });
1770
- // // set sorting
1771
- this.sorting = order;
1772
- this.sortingFunc = sortingFunc;
1769
+ if (cfg.additive) {
1770
+ this.sorting = Object.assign(Object.assign({}, this.sorting), order);
1771
+ this.sortingFunc = Object.assign(Object.assign({}, this.sortingFunc), sortingFunc);
1772
+ }
1773
+ else {
1774
+ // // set sorting
1775
+ this.sorting = order;
1776
+ this.sortingFunc = sortingFunc;
1777
+ }
1773
1778
  }
1774
1779
  };
1775
1780
  setConfig(config);
@@ -1778,6 +1783,13 @@ class SortingPlugin extends BasePlugin {
1778
1783
  setConfig(detail);
1779
1784
  this.startSorting(this.sorting, this.sortingFunc);
1780
1785
  });
1786
+ this.addEventListener('beforeheaderrender', ({ detail, }) => {
1787
+ var _a;
1788
+ const { data: column } = detail;
1789
+ if (column.sortable) {
1790
+ detail.data = Object.assign(Object.assign({}, column), { order: (_a = this.sorting) === null || _a === void 0 ? void 0 : _a[column.prop] });
1791
+ }
1792
+ });
1781
1793
  this.addEventListener('beforeanysource', ({ detail: { type }, }) => {
1782
1794
  // if sorting was provided - sort data
1783
1795
  if (!!this.sorting && this.sortingFunc) {
@@ -1811,9 +1823,12 @@ class SortingPlugin extends BasePlugin {
1811
1823
  if (!((_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.sortable)) {
1812
1824
  return;
1813
1825
  }
1814
- 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);
1826
+ 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);
1815
1827
  });
1816
1828
  }
1829
+ /**
1830
+ * Entry point for sorting, waits for all delayes, registers jobs
1831
+ */
1817
1832
  startSorting(order, sortingFunc, ignoreViewportUpdate) {
1818
1833
  if (!this.sortingPromise) {
1819
1834
  // add job before render
@@ -1827,18 +1842,18 @@ class SortingPlugin extends BasePlugin {
1827
1842
  * Apply sorting to data on header click
1828
1843
  * If additive - add to existing sorting, multiple columns can be sorted
1829
1844
  */
1830
- headerclick(column, index, additive) {
1831
- var _a, _b;
1832
- let order = getNextOrder(column.order);
1845
+ headerclick(column, additive) {
1846
+ var _a, _b, _c;
1847
+ const columnProp = column.prop;
1848
+ let order = getNextOrder((_a = this.sorting) === null || _a === void 0 ? void 0 : _a[columnProp]);
1833
1849
  const beforeEvent = this.emit('beforesorting', { column, order, additive });
1834
1850
  if (beforeEvent.defaultPrevented) {
1835
1851
  return;
1836
1852
  }
1837
1853
  order = beforeEvent.detail.order;
1838
- const newCol = this.providers.column.updateColumnSorting(beforeEvent.detail.column, index, order, additive);
1839
1854
  // apply sort data
1840
1855
  const beforeApplyEvent = this.emit('beforesortingapply', {
1841
- column: newCol,
1856
+ column: beforeEvent.detail.column,
1842
1857
  order,
1843
1858
  additive,
1844
1859
  });
@@ -1852,28 +1867,34 @@ class SortingPlugin extends BasePlugin {
1852
1867
  this.sorting = Object.assign(Object.assign({}, this.sorting), sorting);
1853
1868
  // extend sorting function with new sorting for multiple columns sorting
1854
1869
  this.sortingFunc = Object.assign(Object.assign({}, this.sortingFunc), sortingFunc);
1855
- if (column.prop in sorting && size(sorting) > 1 && order === undefined) {
1856
- delete sorting[column.prop];
1857
- delete sortingFunc[column.prop];
1870
+ if (columnProp in sorting && size(sorting) > 1 && order === undefined) {
1871
+ delete sorting[columnProp];
1872
+ delete sortingFunc[columnProp];
1858
1873
  }
1859
1874
  else {
1860
- sorting[column.prop] = order;
1861
- sortingFunc[column.prop] = cmp;
1875
+ sorting[columnProp] = order;
1876
+ sortingFunc[columnProp] = cmp;
1862
1877
  }
1863
1878
  }
1864
1879
  else {
1865
1880
  if (order) {
1866
1881
  // reset sorting
1867
- this.sorting = { [column.prop]: order };
1868
- this.sortingFunc = { [column.prop]: cmp };
1882
+ this.sorting = { [columnProp]: order };
1883
+ this.sortingFunc = { [columnProp]: cmp };
1869
1884
  }
1870
1885
  else {
1871
- (_a = this.sorting) === null || _a === void 0 ? true : delete _a[column.prop];
1872
- (_b = this.sortingFunc) === null || _b === void 0 ? true : delete _b[column.prop];
1886
+ (_b = this.sorting) === null || _b === void 0 ? true : delete _b[columnProp];
1887
+ (_c = this.sortingFunc) === null || _c === void 0 ? true : delete _c[columnProp];
1873
1888
  }
1874
1889
  }
1875
1890
  this.startSorting(this.sorting, this.sortingFunc);
1876
1891
  }
1892
+ runSorting(order, comparison, ignoreViewportUpdate) {
1893
+ var _a;
1894
+ this.sort(order, comparison, undefined, ignoreViewportUpdate);
1895
+ (_a = this.sortingPromise) === null || _a === void 0 ? void 0 : _a.call(this);
1896
+ this.sortingPromise = null;
1897
+ }
1877
1898
  /**
1878
1899
  * Sort items by sorting function
1879
1900
  * @requires proxyItems applied to row store
@@ -1919,6 +1940,10 @@ class SortingPlugin extends BasePlugin {
1919
1940
  }
1920
1941
  }
1921
1942
  }
1943
+ // refresh columns to redraw column headers and show correct icon
1944
+ columnTypes.forEach((type) => {
1945
+ this.providers.column.dataSources[type].refresh();
1946
+ });
1922
1947
  this.emit('aftersortingapply');
1923
1948
  }
1924
1949
  }
@@ -2499,6 +2524,6 @@ function getLeftRelative(absoluteX, gridPos, offset) {
2499
2524
  return absoluteX - gridPos - offset;
2500
2525
  }
2501
2526
 
2502
- export { AutoSizeColumnPlugin as A, BasePlugin as B, ColumnMovePlugin as C, DimensionStore as D, ExportFilePlugin as E, FILTER_TRIMMED_TYPE as F, GroupingRowPlugin as G, StretchColumn as S, ExportCsv as a, FILTER_CONFIG_CHANGED_EVENT as b, FILTE_PANEL as c, FilterPlugin as d, filterTypes as e, filterCoreFunctionsIndexedByType as f, filterNames as g, doCollapse as h, isStretchPlugin as i, doExpand as j, getLeftRelative as k, SortingPlugin as l, defaultCellCompare as m, descCellCompare as n, getNextOrder as o, getComparer as p, forEach as q, sortIndexByItems as s };
2527
+ export { AutoSizeColumnPlugin as A, BasePlugin as B, ColumnMovePlugin as C, DimensionStore as D, ExportFilePlugin as E, FILTER_TRIMMED_TYPE as F, GroupingRowPlugin as G, StretchColumn as S, ExportCsv as a, FILTER_CONFIG_CHANGED_EVENT as b, FILTE_PANEL as c, FilterPlugin as d, filterTypes as e, filterCoreFunctionsIndexedByType as f, filterNames as g, doCollapse as h, isStretchPlugin as i, doExpand as j, getLeftRelative as k, SortingPlugin as l, defaultCellCompare as m, descCellCompare as n, getNextOrder as o, getComparer as p, sortIndexByItems as s };
2503
2528
 
2504
- //# sourceMappingURL=column.drag.plugin-eb8f7e38.js.map
2529
+ //# sourceMappingURL=column.drag.plugin-a111b876.js.map