@revolist/revogrid 4.9.37 → 4.9.40
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.
- package/dist/cjs/{column.drag.plugin-ffe1918f.js → column.drag.plugin-fcd892ec.js} +18 -18
- package/dist/cjs/column.drag.plugin-fcd892ec.js.map +1 -0
- package/dist/cjs/{index-947f3534.js → column.service-26c61ed6.js} +1256 -469
- package/dist/cjs/column.service-26c61ed6.js.map +1 -0
- package/dist/cjs/{edit.utils-68a4f1c4.js → edit.utils-179c0800.js} +2 -2
- package/dist/cjs/{edit.utils-68a4f1c4.js.map → edit.utils-179c0800.js.map} +1 -1
- package/dist/cjs/{header-cell-renderer-57fb8f18.js → header-cell-renderer-d879d95e.js} +2 -2
- package/dist/cjs/{header-cell-renderer-57fb8f18.js.map → header-cell-renderer-d879d95e.js.map} +1 -1
- package/dist/cjs/index-3ab26ab9.js +513 -0
- package/dist/cjs/index-3ab26ab9.js.map +1 -0
- package/dist/cjs/index.cjs.js +21 -20
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/{key.utils-da2ead49.js → key.utils-f49d7bee.js} +2 -2
- package/dist/cjs/{key.utils-da2ead49.js.map → key.utils-f49d7bee.js.map} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/revo-grid.cjs.entry.js +87 -55
- package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/revo-grid.cjs.js +1 -1
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +13 -13
- package/dist/cjs/revogr-attribution_7.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js +21 -18
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-data_4.cjs.entry.js +9 -9
- package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -1
- package/dist/cjs/{row-header-utils-fe2264e7.js → row-header-utils-c37f76e4.js} +6 -5
- package/dist/cjs/row-header-utils-c37f76e4.js.map +1 -0
- package/dist/cjs/{text-editor-55511a6a.js → text-editor-b756d6b3.js} +3 -3
- package/dist/cjs/{text-editor-55511a6a.js.map → text-editor-b756d6b3.js.map} +1 -1
- package/dist/cjs/{throttle-2ae258fb.js → throttle-a57f51f9.js} +2 -2
- package/dist/cjs/{throttle-2ae258fb.js.map → throttle-a57f51f9.js.map} +1 -1
- package/dist/collection/components/order/revogr-order-editor.js +99 -27
- package/dist/collection/components/order/revogr-order-editor.js.map +1 -1
- package/dist/collection/components/overlay/revogr-overlay-selection.js +2 -2
- package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
- package/dist/collection/components/revoGrid/revo-grid.js +10 -0
- package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
- package/dist/collection/plugins/sorting/sorting.plugin.js +25 -27
- package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
- package/dist/collection/services/data.provider.js +12 -5
- package/dist/collection/services/data.provider.js.map +1 -1
- package/dist/collection/services/dimension.provider.js +22 -0
- package/dist/collection/services/dimension.provider.js.map +1 -1
- package/dist/collection/store/dataSource/data.proxy.js +19 -6
- package/dist/collection/store/dataSource/data.proxy.js.map +1 -1
- package/dist/collection/store/dataSource/data.store.js +3 -0
- package/dist/collection/store/dataSource/data.store.js.map +1 -1
- package/dist/collection/types/events.js +1 -0
- package/dist/collection/types/events.js.map +1 -1
- package/dist/esm/{column.drag.plugin-bbd79520.js → column.drag.plugin-3cc77986.js} +6 -6
- package/dist/esm/{column.drag.plugin-bbd79520.js.map → column.drag.plugin-3cc77986.js.map} +1 -1
- package/dist/esm/{index-8eeaa30d.js → column.service-751345b2.js} +1216 -427
- package/dist/esm/column.service-751345b2.js.map +1 -0
- package/dist/esm/{debounce-7b511afc.js → debounce-72878ced.js} +2 -2
- package/dist/esm/{debounce-7b511afc.js.map → debounce-72878ced.js.map} +1 -1
- package/dist/esm/{edit.utils-aeb2dc7c.js → edit.utils-6fc686b9.js} +2 -2
- package/dist/esm/{edit.utils-aeb2dc7c.js.map → edit.utils-6fc686b9.js.map} +1 -1
- package/dist/esm/{header-cell-renderer-1aec2328.js → header-cell-renderer-32d2ed96.js} +2 -2
- package/dist/esm/{header-cell-renderer-1aec2328.js.map → header-cell-renderer-32d2ed96.js.map} +1 -1
- package/dist/esm/index-1dcad6ef.js +476 -0
- package/dist/esm/index-1dcad6ef.js.map +1 -0
- package/dist/esm/index.js +9 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{key.utils-9ee5fa40.js → key.utils-17273f42.js} +2 -2
- package/dist/esm/{key.utils-9ee5fa40.js.map → key.utils-17273f42.js.map} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/revo-grid.entry.js +67 -35
- package/dist/esm/revo-grid.entry.js.map +1 -1
- package/dist/esm/revo-grid.js +1 -1
- package/dist/esm/revogr-attribution_7.entry.js +9 -9
- package/dist/esm/revogr-attribution_7.entry.js.map +1 -1
- package/dist/esm/revogr-clipboard_3.entry.js +22 -19
- package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/esm/revogr-data_4.entry.js +5 -5
- package/dist/esm/revogr-filter-panel.entry.js +1 -1
- package/dist/esm/{row-header-utils-3220f80d.js → row-header-utils-3dfbb81f.js} +3 -2
- package/dist/esm/row-header-utils-3dfbb81f.js.map +1 -0
- package/dist/esm/{text-editor-d9dcf56d.js → text-editor-901c3eb8.js} +3 -3
- package/dist/esm/{text-editor-d9dcf56d.js.map → text-editor-901c3eb8.js.map} +1 -1
- package/dist/esm/{throttle-ce8e57c9.js → throttle-138d69c3.js} +3 -3
- package/dist/esm/{throttle-ce8e57c9.js.map → throttle-138d69c3.js.map} +1 -1
- package/dist/revo-grid/column.drag.plugin-3cc77986.js +5 -0
- package/dist/revo-grid/{column.drag.plugin-bbd79520.js.map → column.drag.plugin-3cc77986.js.map} +1 -1
- package/dist/revo-grid/column.service-751345b2.js +5 -0
- package/dist/revo-grid/column.service-751345b2.js.map +1 -0
- package/dist/revo-grid/{debounce-7b511afc.js → debounce-72878ced.js} +2 -2
- package/dist/revo-grid/{edit.utils-aeb2dc7c.js → edit.utils-6fc686b9.js} +2 -2
- package/dist/revo-grid/{header-cell-renderer-1aec2328.js → header-cell-renderer-32d2ed96.js} +2 -2
- package/dist/revo-grid/index-1dcad6ef.js +5 -0
- package/dist/revo-grid/index-1dcad6ef.js.map +1 -0
- package/dist/revo-grid/index.esm.js +1 -1
- package/dist/revo-grid/index.esm.js.map +1 -1
- package/dist/revo-grid/key.utils-17273f42.js +5 -0
- package/dist/revo-grid/{key.utils-9ee5fa40.js.map → key.utils-17273f42.js.map} +1 -1
- package/dist/revo-grid/revo-grid.entry.js +1 -1
- package/dist/revo-grid/revo-grid.entry.js.map +1 -1
- package/dist/revo-grid/revo-grid.esm.js +1 -1
- package/dist/revo-grid/revo-grid.esm.js.map +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js.map +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js.map +1 -1
- package/dist/revo-grid/revogr-filter-panel.entry.js +1 -1
- package/dist/revo-grid/row-header-utils-3dfbb81f.js +5 -0
- package/dist/revo-grid/{row-header-utils-3220f80d.js.map → row-header-utils-3dfbb81f.js.map} +1 -1
- package/dist/revo-grid/text-editor-901c3eb8.js +5 -0
- package/dist/revo-grid/{throttle-ce8e57c9.js → throttle-138d69c3.js} +2 -2
- package/dist/types/components/order/revogr-order-editor.d.ts +18 -4
- package/dist/types/components/overlay/revogr-overlay-selection.d.ts +2 -4
- package/dist/types/components/revoGrid/revo-grid.d.ts +1 -0
- package/dist/types/components.d.ts +25 -6
- package/dist/types/plugins/sorting/sorting.plugin.d.ts +4 -4
- package/dist/types/services/data.provider.d.ts +5 -0
- package/dist/types/services/dimension.provider.d.ts +1 -0
- package/dist/types/store/dataSource/data.proxy.d.ts +9 -3
- package/dist/types/store/dataSource/data.store.d.ts +1 -0
- package/dist/types/types/events.d.ts +1 -1
- package/hydrate/index.js +127 -75
- package/hydrate/index.mjs +127 -75
- package/package.json +1 -1
- package/standalone/column.service.js +1 -1
- package/standalone/data.store.js +28 -31
- package/standalone/data.store.js.map +1 -1
- package/standalone/dimension.helpers.js +1 -1
- package/standalone/identity.js +26 -0
- package/standalone/identity.js.map +1 -0
- package/standalone/index.js +2 -1
- package/standalone/index.js.map +1 -1
- package/standalone/revo-grid.js +64 -31
- package/standalone/revo-grid.js.map +1 -1
- package/standalone/revogr-header2.js +1 -1
- package/standalone/revogr-order-editor2.js +18 -15
- package/standalone/revogr-order-editor2.js.map +1 -1
- package/standalone/revogr-overlay-selection2.js +2 -2
- package/standalone/revogr-overlay-selection2.js.map +1 -1
- package/dist/cjs/column.drag.plugin-ffe1918f.js.map +0 -1
- package/dist/cjs/column.service-e9ab1aa3.js +0 -1286
- package/dist/cjs/column.service-e9ab1aa3.js.map +0 -1
- package/dist/cjs/index-947f3534.js.map +0 -1
- package/dist/cjs/row-header-utils-fe2264e7.js.map +0 -1
- package/dist/esm/column.service-397b7249.js +0 -1249
- package/dist/esm/column.service-397b7249.js.map +0 -1
- package/dist/esm/index-8eeaa30d.js.map +0 -1
- package/dist/esm/row-header-utils-3220f80d.js.map +0 -1
- package/dist/revo-grid/column.drag.plugin-bbd79520.js +0 -5
- package/dist/revo-grid/column.service-397b7249.js +0 -5
- package/dist/revo-grid/column.service-397b7249.js.map +0 -1
- package/dist/revo-grid/index-8eeaa30d.js +0 -5
- package/dist/revo-grid/index-8eeaa30d.js.map +0 -1
- package/dist/revo-grid/key.utils-9ee5fa40.js +0 -5
- package/dist/revo-grid/row-header-utils-3220f80d.js +0 -5
- package/dist/revo-grid/text-editor-d9dcf56d.js +0 -5
- /package/dist/revo-grid/{debounce-7b511afc.js.map → debounce-72878ced.js.map} +0 -0
- /package/dist/revo-grid/{edit.utils-aeb2dc7c.js.map → edit.utils-6fc686b9.js.map} +0 -0
- /package/dist/revo-grid/{header-cell-renderer-1aec2328.js.map → header-cell-renderer-32d2ed96.js.map} +0 -0
- /package/dist/revo-grid/{text-editor-d9dcf56d.js.map → text-editor-901c3eb8.js.map} +0 -0
- /package/dist/revo-grid/{throttle-ce8e57c9.js.map → throttle-138d69c3.js.map} +0 -0
|
@@ -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;AACvC,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAW5C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAQ3D;;;;;;;;GAQG;AAEH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IAanD,KAAK,CAAC,UAAU,CACd,KAAoB,EACpB,UAAiC;;QAEjC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QACnC,MAAA,IAAI,CAAC,cAAc,oDAAI,CAAC;QACxB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,YACS,QAA6B,EACpC,SAA0B;QAE1B,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAHpB,aAAQ,GAAR,QAAQ,CAAqB;QAjBtC,mBAAc,GAAwB,IAAI,CAAC;QAC3C,iBAAY,GAAG,QAAQ,CACrB,KAAK,EAAE,KAAoB,EAAE,UAAiC,EAAE,EAAE,CAChE,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,E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YAAmB;QAC9B,QAAQ,YAAY,EAAE,CAAC;YACrB,KAAK,SAAS;gBACZ,OAAO,KAAK,CAAC;YACf,KAAK,KAAK;gBACR,OAAO,MAAM,CAAC;YAChB,KAAK,MAAM;gBACT,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;CACF","sourcesContent":["import size from 'lodash/size';\nimport debounce from 'lodash/debounce';\nimport range from 'lodash/range';\n\nimport { setStore } from '../../utils/store.utils';\nimport { BasePlugin } from '../base.plugin';\nimport {\n ColumnProp,\n Order,\n CellCompareFunc,\n ColumnRegular,\n InitialHeaderClick,\n DataType,\n DimensionRows,\n PluginProviders,\n} from '@type';\nimport { getColumnByProp } from '../../utils/column.utils';\n\nexport type SortingOrder = Record<ColumnProp, Order>;\ntype SortingOrderFunction = Record<ColumnProp, CellCompareFunc | undefined>;\ntype ColumnSetEvent = {\n order: SortingOrder;\n};\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. @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 default 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 async (order?: SortingOrder, comparison?: SortingOrderFunction) =>\n this.runSorting(order, comparison),\n 50,\n );\n\n async runSorting(\n order?: SortingOrder,\n comparison?: SortingOrderFunction,\n ) {\n await this.sort(order, comparison);\n this.sortingPromise?.();\n this.sortingPromise = null;\n }\n\n constructor(\n public revogrid: HTMLRevoGridElement,\n providers: PluginProviders,\n ) {\n super(revogrid, providers);\n\n const beforeanysource = async ({\n detail: { type },\n }: CustomEvent<{\n type: DimensionRows;\n source: any[];\n }>) => {\n // if sorting was provided - sort data\n if (!!this.sorting && this.sortingFunc) {\n const beforeEvent = this.emit('beforesorting', { type });\n if (beforeEvent.defaultPrevented) {\n return;\n }\n this.startSorting(this.sorting, this.sortingFunc);\n }\n };\n const aftercolumnsset = async ({\n detail: { order },\n }: CustomEvent<ColumnSetEvent>) => {\n const columns = (await this.revogrid.getColumns());\n const sortingFunc: SortingOrderFunction = {};\n\n for (let prop in order) {\n const cmp = this.getComparer(\n getColumnByProp(columns, prop),\n order[prop],\n );\n sortingFunc[prop] = cmp;\n }\n this.runSorting(order, sortingFunc);\n };\n const headerclick = async (e: CustomEvent<InitialHeaderClick>) => {\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 this.addEventListener('beforeanysource', beforeanysource);\n this.addEventListener('aftercolumnsset', aftercolumnsset);\n this.addEventListener('beforeheaderclick', headerclick);\n }\n\n startSorting(order?: SortingOrder, sortingFunc?: SortingOrderFunction) {\n if (!this.sortingPromise) {\n this.revogrid.jobsBeforeRender.push(\n new Promise<void>(resolve => {\n this.sortingPromise = resolve;\n }),\n );\n }\n this.postponeSort(order, sortingFunc);\n }\n\n getComparer(column: ColumnRegular | undefined, order: Order): CellCompareFunc | undefined {\n const cellCmp: CellCompareFunc =\n column?.cellCompare?.bind({ order }) || this.defaultCellCompare;\n if (order == 'asc') {\n return cellCmp;\n }\n if (order == 'desc') {\n return this.descCellCompare(cellCmp);\n }\n return undefined;\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 async headerclick(column: ColumnRegular, index: number, additive: boolean) {\n let order: Order = this.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 = await this.revogrid.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 order = beforeApplyEvent.detail.order;\n const cmp = this.getComparer(column, order);\n\n if (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 async sort(\n sorting?: SortingOrder,\n sortingFunc?: SortingOrderFunction,\n types: DimensionRows[] = ['rgRow', 'rowPinStart', 'rowPinEnd'],\n ) {\n // if no sorting - reset\n if (!size(sorting)) {\n this.sorting = undefined;\n this.sortingFunc = undefined;\n\n for (let type of types) {\n const store = await this.revogrid.getSourceStore(type);\n // row data\n const source = store.get('source');\n // row indexes\n const proxyItems = range(0, source.length);\n setStore(store, {\n proxyItems,\n source: [...source],\n });\n }\n } else {\n // set sorting\n this.sorting = sorting;\n this.sortingFunc = sortingFunc;\n\n // by default it'll sort by rgRow store\n // todo: support multiple stores\n for (let type of types) {\n const store = await this.revogrid.getSourceStore(type);\n // row data\n const source = store.get('source');\n // row indexes\n const proxyItems = store.get('proxyItems');\n const data = this.sortIndexByItems(\n [...proxyItems],\n source,\n sortingFunc,\n );\n setStore(store, {\n proxyItems: data,\n source: [...source],\n });\n }\n }\n this.emit('aftersortingapply');\n }\n\n defaultCellCompare(prop: ColumnProp, a: DataType, b: DataType) {\n const av = a[prop]?.toString().toLowerCase();\n const bv = b[prop]?.toString().toLowerCase();\n\n return av == bv ? 0 : av > bv ? 1 : -1;\n }\n\n descCellCompare(cmp: CellCompareFunc) {\n return (prop: ColumnProp, a: DataType, b: DataType): number => {\n return -1 * cmp(prop, a, b);\n };\n }\n\n sortIndexByItems(\n indexes: number[],\n source: DataType[],\n sortingFunc: SortingOrderFunction = {},\n ): number[] {\n // if no sorting - return unsorted indexes\n if (Object.entries(sortingFunc).length === 0) {\n // Unsorted indexes\n return [...Array(indexes.length).keys()];\n }\n //\n /**\n * go through all indexes and align in new order\n * performs a multi-level sorting by applying multiple comparison functions to determine the order of the items based on different properties.\n */\n return indexes.sort((a, b) => {\n for (const [prop, cmp] of Object.entries(sortingFunc)) {\n const itemA = source[a];\n const itemB = source[b];\n\n /**\n * If the comparison function returns a non-zero value (sorted), it means that the items should be sorted based on the given property. In such a case, the function immediately returns the sorted value, indicating the order in which the items should be arranged.\n * If none of the comparison functions result in a non-zero value, indicating that the items are equal or should remain in the same order, the function eventually returns 0.\n */\n const sorted = cmp?.(prop, itemA, itemB);\n if (sorted) {\n return sorted;\n }\n }\n return 0;\n });\n }\n\n getNextOrder(currentOrder: Order): Order {\n switch (currentOrder) {\n case undefined:\n return 'asc';\n case 'asc':\n return 'desc';\n case 'desc':\n return undefined;\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,QA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ePlugin } from '../base.plugin';\nimport {\n ColumnProp,\n Order,\n CellCompareFunc,\n ColumnRegular,\n InitialHeaderClick,\n DataType,\n DimensionRows,\n PluginProviders,\n} from '@type';\nimport { getColumnByProp } from '../../utils/column.utils';\nimport { rowTypes } from '@store';\n\nexport type SortingOrder = Record<ColumnProp, Order>;\ntype SortingOrderFunction = Record<ColumnProp, CellCompareFunc | undefined>;\ntype ColumnSetEvent = {\n order: SortingOrder;\n};\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. @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 default 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) =>\n this.runSorting(order, comparison),\n 50,\n );\n\n runSorting(\n order?: SortingOrder,\n comparison?: SortingOrderFunction,\n ) {\n this.sort(order, comparison);\n this.sortingPromise?.();\n this.sortingPromise = null;\n }\n\n constructor(\n public revogrid: HTMLRevoGridElement,\n providers: PluginProviders,\n ) {\n super(revogrid, providers);\n\n const beforeanysource = ({\n detail: { type },\n }: CustomEvent<{\n type: DimensionRows;\n source: any[];\n }>) => {\n // if sorting was provided - sort data\n if (!!this.sorting && this.sortingFunc) {\n const beforeEvent = this.emit('beforesorting', { type });\n if (beforeEvent.defaultPrevented) {\n return;\n }\n this.startSorting(this.sorting, this.sortingFunc);\n }\n };\n const aftercolumnsset = ({\n detail: { order },\n }: CustomEvent<ColumnSetEvent>) => {\n const columns = this.providers.column.getColumns();\n const sortingFunc: SortingOrderFunction = {};\n\n for (let prop in order) {\n const cmp = this.getComparer(\n getColumnByProp(columns, prop),\n order[prop],\n );\n sortingFunc[prop] = cmp;\n }\n this.runSorting(order, sortingFunc);\n };\n const headerclick = (e: CustomEvent<InitialHeaderClick>) => {\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 this.addEventListener('beforeanysource', beforeanysource);\n this.addEventListener('aftercolumnsset', aftercolumnsset);\n this.addEventListener('beforeheaderclick', headerclick);\n }\n\n startSorting(order?: SortingOrder, sortingFunc?: SortingOrderFunction) {\n if (!this.sortingPromise) {\n this.revogrid.jobsBeforeRender.push(\n new Promise<void>(resolve => {\n this.sortingPromise = resolve;\n }),\n );\n }\n this.postponeSort(order, sortingFunc);\n }\n\n getComparer(column: ColumnRegular | undefined, order: Order): CellCompareFunc | undefined {\n const cellCmp: CellCompareFunc =\n column?.cellCompare?.bind({ order }) || this.defaultCellCompare;\n if (order == 'asc') {\n return cellCmp;\n }\n if (order == 'desc') {\n return this.descCellCompare(cellCmp);\n }\n return undefined;\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 = this.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 order = beforeApplyEvent.detail.order;\n const cmp = this.getComparer(column, order);\n\n if (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 ) {\n // if no sorting - reset\n if (!size(sorting)) {\n this.sorting = undefined;\n this.sortingFunc = undefined;\n\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 = storeService.store.get('items'); // 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 // set sorting\n this.sorting = sorting;\n this.sortingFunc = sortingFunc;\n\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 = this.sortIndexByItems(\n [...proxyItems],\n source,\n sortingFunc,\n );\n\n this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);\n \n storeService.setData({\n proxyItems: newItemsOrder,\n source: [...source],\n });\n }\n }\n this.emit('aftersortingapply');\n }\n\n defaultCellCompare(prop: ColumnProp, a: DataType, b: DataType) {\n const av = a[prop]?.toString().toLowerCase();\n const bv = b[prop]?.toString().toLowerCase();\n\n return av == bv ? 0 : av > bv ? 1 : -1;\n }\n\n descCellCompare(cmp: CellCompareFunc) {\n return (prop: ColumnProp, a: DataType, b: DataType): number => {\n return -1 * cmp(prop, a, b);\n };\n }\n\n sortIndexByItems(\n indexes: number[],\n source: DataType[],\n sortingFunc: SortingOrderFunction = {},\n ): number[] {\n // if no sorting - return unsorted indexes\n if (Object.entries(sortingFunc).length === 0) {\n // Unsorted indexes\n return [...Array(indexes.length).keys()];\n }\n //\n /**\n * go through all indexes and align in new order\n * performs a multi-level sorting by applying multiple comparison functions to determine the order of the items based on different properties.\n */\n return indexes.sort((a, b) => {\n for (const [prop, cmp] of Object.entries(sortingFunc)) {\n const itemA = source[a];\n const itemB = source[b];\n\n /**\n * If the comparison function returns a non-zero value (sorted), it means that the items should be sorted based on the given property. In such a case, the function immediately returns the sorted value, indicating the order in which the items should be arranged.\n * If none of the comparison functions result in a non-zero value, indicating that the items are equal or should remain in the same order, the function eventually returns 0.\n */\n const sorted = cmp?.(prop, itemA, itemB);\n if (sorted) {\n return sorted;\n }\n }\n return 0;\n });\n }\n\n getNextOrder(currentOrder: Order): Order {\n switch (currentOrder) {\n case undefined:\n return 'asc';\n case 'asc':\n return 'desc';\n case 'desc':\n return undefined;\n }\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
4
|
import reduce from "lodash/reduce";
|
|
5
|
-
import { isRowType, rowTypes, DataStore, getSourceItem, getVisibleSourceItem,
|
|
5
|
+
import { isRowType, rowTypes, DataStore, getSourceItem, getVisibleSourceItem, } from "../store/index";
|
|
6
6
|
/**
|
|
7
7
|
* Data source provider
|
|
8
8
|
*/
|
|
@@ -26,11 +26,19 @@ export class DataProvider {
|
|
|
26
26
|
const store = this.stores[type].store;
|
|
27
27
|
return getSourceItem(store, virtualIndex);
|
|
28
28
|
}
|
|
29
|
+
changeOrder({ rowType = 'rgRow', from, to }) {
|
|
30
|
+
const service = this.stores[rowType];
|
|
31
|
+
const items = [...service.store.get('items')];
|
|
32
|
+
const prevItems = [...items];
|
|
33
|
+
const toMove = items.splice(from, 1);
|
|
34
|
+
items.splice(to, 0, ...toMove);
|
|
35
|
+
this.dimensionProvider.updateSizesPositionByNewDataIndexes(rowType, items, prevItems);
|
|
36
|
+
service.setData({ items });
|
|
37
|
+
}
|
|
29
38
|
setCellData({ type, rowIndex, prop, val }, mutate = true) {
|
|
30
39
|
const model = this.getModel(rowIndex, type);
|
|
31
40
|
model[prop] = val;
|
|
32
|
-
|
|
33
|
-
setSourceByVirtualIndex(this.stores[type].store, { [rowIndex]: model }, mutate);
|
|
41
|
+
this.stores[type].setSourceData({ [rowIndex]: model }, mutate);
|
|
34
42
|
}
|
|
35
43
|
setRangeData(data, type) {
|
|
36
44
|
const items = {};
|
|
@@ -43,8 +51,7 @@ export class DataProvider {
|
|
|
43
51
|
oldModel[prop] = data[rowIndex][prop];
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
|
-
|
|
47
|
-
setSourceByVirtualIndex(this.stores[type].store, items);
|
|
54
|
+
this.stores[type].setSourceData(items);
|
|
48
55
|
}
|
|
49
56
|
refresh(type = 'all') {
|
|
50
57
|
if (isRowType(type)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.provider.js","sourceRoot":"","sources":["../../src/services/data.provider.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,eAAe,CAAC;AAEnC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,aAAa,EACb,oBAAoB,
|
|
1
|
+
{"version":3,"file":"data.provider.js","sourceRoot":"","sources":["../../src/services/data.provider.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MA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I,CAAC,iBAAiB,CAAC,OAAO,CAC5B,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,EACxC,IAAI,CACL,CAAC;QACJ,CAAC;IACH,CAAC;CACF","sourcesContent":["import reduce from 'lodash/reduce';\n\nimport {\n isRowType,\n rowTypes,\n DataStore,\n getSourceItem,\n getVisibleSourceItem,\n Groups,\n Trimmed,\n} from '@store';\nimport DimensionProvider from './dimension.provider';\nimport type { GroupLabelTemplateFunc } from '../plugins/groupingRow/grouping.row.types';\nimport type {\n DataLookup,\n DimensionRows,\n DataType,\n BeforeSaveDataDetails,\n} from '@type';\n\nexport type RowDataSources = {\n [T in DimensionRows]: DataStore<DataType, DimensionRows>;\n};\n\n/**\n * Data source provider\n */\n\nexport class DataProvider {\n public readonly stores: RowDataSources;\n constructor(private dimensionProvider: DimensionProvider) {\n this.stores = reduce(\n rowTypes,\n (sources: Partial<RowDataSources>, k: DimensionRows) => {\n sources[k] = new DataStore(k);\n return sources;\n },\n {},\n ) as RowDataSources;\n }\n\n setData(\n data: DataType[],\n type: DimensionRows = 'rgRow',\n disableVirtualRows = false,\n grouping?: {\n depth: number;\n groups?: Groups;\n customRenderer?: GroupLabelTemplateFunc;\n },\n silent = false,\n ): DataType[] {\n // set rgRow data\n this.stores[type].updateData([...data], grouping, silent);\n\n // for pinned row no need virtual data\n const noVirtual = type !== 'rgRow' || disableVirtualRows;\n this.dimensionProvider.setData(data.length, type, noVirtual);\n return data;\n }\n\n getModel(virtualIndex: number, type: DimensionRows = 'rgRow') {\n const store = this.stores[type].store;\n return getSourceItem(store, virtualIndex);\n }\n\n changeOrder({ rowType = 'rgRow', from, to }: { rowType: DimensionRows, from: number; to: number }) {\n const service = this.stores[rowType];\n const items = [...service.store.get('items')];\n const prevItems = [...items];\n\n const toMove = items.splice(from, 1);\n items.splice(to, 0, ...toMove);\n this.dimensionProvider.updateSizesPositionByNewDataIndexes(rowType, items, prevItems);\n service.setData({ items });\n }\n\n setCellData(\n { type, rowIndex, prop, val }: BeforeSaveDataDetails,\n mutate = true,\n ) {\n const model = this.getModel(rowIndex, type);\n model[prop] = val;\n this.stores[type].setSourceData({ [rowIndex]: model }, mutate);\n }\n\n setRangeData(data: DataLookup, type: DimensionRows) {\n const items: Record<number, DataType> = {};\n for (let rowIndex in data) {\n const oldModel = (items[rowIndex] = getSourceItem(\n this.stores[type].store,\n parseInt(rowIndex, 10),\n ));\n if (!oldModel) {\n continue;\n }\n for (let prop in data[rowIndex]) {\n oldModel[prop] = data[rowIndex][prop];\n }\n }\n this.stores[type].setSourceData(items);\n }\n\n refresh(type: DimensionRows | 'all' = 'all') {\n if (isRowType(type)) {\n this.refreshItems(type);\n }\n rowTypes.forEach((t: DimensionRows) => this.refreshItems(t));\n }\n\n refreshItems(type: DimensionRows = 'rgRow') {\n const items = this.stores[type].store.get('items');\n this.stores[type].setData({ items: [...items] });\n }\n\n setGrouping({ depth }: { depth: number }, type: DimensionRows = 'rgRow') {\n this.stores[type].setData({ groupingDepth: depth });\n }\n\n setTrimmed(trimmed: Trimmed, type: DimensionRows = 'rgRow') {\n const store = this.stores[type];\n store.addTrimmed(trimmed);\n this.dimensionProvider.setTrimmed(trimmed, type);\n if (type === 'rgRow') {\n this.dimensionProvider.setData(\n getVisibleSourceItem(store.store).length,\n type,\n );\n }\n }\n}\n"]}
|
|
@@ -156,5 +156,27 @@ export default class DimensionProvider {
|
|
|
156
156
|
this.stores[s].setStore(data);
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
+
updateSizesPositionByNewDataIndexes(type, newItemsOrder, prevItemsOrder = []) {
|
|
160
|
+
// Move custom sizes to new order
|
|
161
|
+
const dimService = this.stores[type];
|
|
162
|
+
const customSizes = Object.assign({}, dimService.store.get('sizes'));
|
|
163
|
+
if (Object.keys(customSizes).length) {
|
|
164
|
+
const originalIndices = new Map();
|
|
165
|
+
prevItemsOrder.forEach((value, index) => {
|
|
166
|
+
originalIndices.set(value, index);
|
|
167
|
+
});
|
|
168
|
+
const newSizes = {};
|
|
169
|
+
newItemsOrder.forEach((value, newIndex) => {
|
|
170
|
+
const originalIndex = originalIndices.get(value);
|
|
171
|
+
if (originalIndex !== newIndex && customSizes[originalIndex]) {
|
|
172
|
+
newSizes[newIndex] = customSizes[originalIndex];
|
|
173
|
+
delete customSizes[originalIndex];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
if (Object.keys(newSizes).length) {
|
|
177
|
+
this.setCustomSizes(type, Object.assign(Object.assign({}, customSizes), newSizes));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
159
181
|
}
|
|
160
182
|
//# sourceMappingURL=dimension.provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dimension.provider.js","sourceRoot":"","sources":["../../src/services/dimension.provider.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,cAAc,EACd,cAAc,EAEd,kBAAkB,GAEnB,MAAM,QAAQ,CAAC;AAWhB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAEpC,YACU,SAA2B,EACnC,MAAuB;QADf,cAAS,GAAT,SAAS,CAAkB;QAGnC,MAAM,WAAW,GAAG,QAAQ,CAC1B,CAAC,CAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,EACpD,eAAe,CAChB,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAClB,CAAC,GAAG,QAAQ,EAAE,GAAG,WAAW,CAAC,EAC7B,CAAC,OAA0C,EAAE,CAAqB,EAAE,EAAE;YACpE,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,cAAc,CAAC,C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":["import reduce from 'lodash/reduce';\nimport debounce from 'lodash/debounce';\nimport ViewportProvider from './viewport.provider';\nimport { RESIZE_INTERVAL } from '../utils/consts';\n\nimport {\n columnTypes,\n rowTypes,\n getItemByIndex,\n DimensionStore,\n DimensionStoreCollection,\n gatherTrimmedItems,\n Trimmed,\n} from '@store';\nimport {\n DimensionCols,\n DimensionType,\n MultiDimensionType,\n ColumnRegular,\n DimensionSettingsState,\n ViewPortScrollEvent,\n ViewSettingSizeProp,\n ViewportState,\n} from '@type';\nimport { getColumnSizes } from '../utils/column.utils';\n\nexport type DimensionConfig = {\n realSizeChanged(k: MultiDimensionType): void;\n};\n/**\n * Dimension provider\n * Stores dimension information and custom sizes\n */\nexport default class DimensionProvider {\n readonly stores: DimensionStoreCollection;\n constructor(\n private viewports: ViewportProvider,\n config: DimensionConfig,\n ) {\n const sizeChanged = debounce(\n (k: MultiDimensionType) => config.realSizeChanged(k),\n RESIZE_INTERVAL,\n );\n this.stores = reduce(\n [...rowTypes, ...columnTypes],\n (sources: Partial<DimensionStoreCollection>, t: MultiDimensionType) => {\n sources[t] = new DimensionStore(t);\n sources[t].store.onChange('realSize', () => sizeChanged(t));\n return sources;\n },\n {},\n ) as DimensionStoreCollection;\n }\n\n /**\n * Clear old sizes from dimension and viewports\n * @param type - dimension type\n * @param count - count of items\n */\n clearSize(t: MultiDimensionType, count: number) {\n this.stores[t].drop();\n // after we done with drop trigger viewport recalculaction\n this.viewports.stores[t].setOriginalSizes(\n this.stores[t].store.get('originItemSize'),\n );\n this.setItemCount(count, t);\n }\n\n /**\n * Apply new custom sizes to dimension and view port\n * @param type - dimension type\n * @param sizes - new custom sizes\n * @param keepOld - keep old sizes merge new with old\n */\n setCustomSizes(\n type: MultiDimensionType,\n sizes: ViewSettingSizeProp,\n keepOld = false,\n ) {\n let newSizes = sizes;\n if (keepOld) {\n const oldSizes = this.stores[type].store.get('sizes');\n newSizes = {\n ...oldSizes,\n ...sizes,\n };\n }\n this.stores[type].setDimensionSize(newSizes);\n this.updateViewport(type, true);\n }\n\n setItemCount(realCount: number, type: MultiDimensionType) {\n this.viewports.stores[type].setViewport({ realCount });\n this.stores[type].setStore({ count: realCount });\n }\n\n /**\n * Apply trimmed items\n * @param trimmed - trimmed items\n * @param type\n */\n setTrimmed(trimmed: Trimmed, type: MultiDimensionType) {\n const allTrimmed = gatherTrimmedItems(trimmed);\n const dimStoreType = this.stores[type];\n dimStoreType.setStore({ trimmed: allTrimmed });\n this.updateViewport(type, true);\n }\n\n /**\n * Sets dimension data and view port coordinate\n * @param itemCount\n * @param type - dimension type\n * @param noVirtual - disable virtual data\n */\n setData(itemCount: number, type: MultiDimensionType, noVirtual = false) {\n this.setItemCount(itemCount, type);\n\n // Virtualization will get disabled\n if (noVirtual) {\n const dimension = this.stores[type].getCurrentState();\n this.viewports.stores[type].setViewport({\n virtualSize: dimension.realSize,\n });\n }\n this.updateViewport(type);\n }\n\n /**\n * Applies new columns to the dimension provider\n * @param columns - new columns data\n * @param disableVirtualX - disable virtual data for X axis\n */\n applyNewColumns(\n columns: Record<DimensionCols, ColumnRegular[]>,\n disableVirtualX: boolean,\n ) {\n // Apply new columns to dimension provider\n for (let type of columnTypes) {\n // Clear existing data in the dimension provider\n this.stores[type].drop();\n\n // Get the new columns for the current type\n const items = columns[type];\n\n // Determine if virtual data should be disabled for the current type\n const noVirtual = type !== 'rgCol' || disableVirtualX;\n\n // Set the items count in the dimension provider\n this.stores[type].setStore({ count: items.length });\n\n // Set the custom sizes for the columns\n const newSizes = getColumnSizes(items);\n this.stores[type].setDimensionSize(newSizes);\n\n // Update the viewport with new data\n const vpUpdate: Partial<ViewportState> = {\n // This triggers drop on realCount change\n realCount: items.length,\n };\n\n // If virtual data is disabled, set the virtual size to the real size\n if (noVirtual) {\n vpUpdate.virtualSize = this.stores[type].getCurrentState().realSize;\n }\n\n // Update the viewport\n this.viewports.stores[type].setViewport(vpUpdate);\n this.setViewPortCoordinate({\n coordinate: this.viewports.stores[type].lastCoordinate,\n type,\n });\n }\n }\n\n getFullSize(): { x: number; y: number } {\n let x = 0;\n let y = 0;\n for (let type of columnTypes) {\n x += this.stores[type]?.store.get('realSize') || 0;\n }\n for (let type of rowTypes) {\n y += this.stores[type]?.store.get('realSize') || 0;\n }\n return { y, x };\n }\n\n updateViewport(type: MultiDimensionType, force = false) {\n this.setViewPortCoordinate({\n coordinate: this.viewports.stores[type].lastCoordinate,\n type,\n force,\n });\n }\n\n setViewPortCoordinate({\n coordinate,\n type,\n force = false,\n }: {\n coordinate: number;\n type: MultiDimensionType;\n force?: boolean;\n }) {\n const dimension = this.stores[type].getCurrentState();\n this.viewports.stores[type].setViewPortCoordinate(coordinate, dimension, force);\n }\n\n getViewPortPos(e: ViewPortScrollEvent): number {\n const dimension = this.stores[e.dimension].getCurrentState();\n const item = getItemByIndex(dimension, e.coordinate);\n\n return item.start;\n }\n\n setSettings(\n data: Partial<DimensionSettingsState>,\n dimensionType: DimensionType,\n ) {\n let stores: MultiDimensionType[] = [];\n switch (dimensionType) {\n case 'rgCol':\n stores = columnTypes;\n break;\n case 'rgRow':\n stores = rowTypes;\n break;\n }\n for (let s of stores) {\n this.stores[s].setStore(data);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dimension.provider.js","sourceRoot":"","sources":["../../src/services/dimension.provider.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EACL,WAAW,EACX,QAAQ,EACR,cAAc,EACd,cAAc,EAEd,kBAAkB,GAEnB,MAAM,QAAQ,CAAC;AAWhB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAKvD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAEpC,YACU,SAA2B,EACnC,MAAuB;QADf,cAAS,GAAT,SAAS,CAAkB;QAGnC,MAAM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AAC,CAAC,MAAM,EAAE,CAAC;gBACjC,IAAI,CAAC,cAAc,CAAC,IAAI,kCACnB,WAAW,GACX,QAAQ,EACX,CAAC;YACL,CAAC;QACH,CAAC;IACJ,CAAC;CACD","sourcesContent":["import reduce from 'lodash/reduce';\nimport debounce from 'lodash/debounce';\nimport ViewportProvider from './viewport.provider';\nimport { RESIZE_INTERVAL } from '../utils/consts';\n\nimport {\n columnTypes,\n rowTypes,\n getItemByIndex,\n DimensionStore,\n DimensionStoreCollection,\n gatherTrimmedItems,\n Trimmed,\n} from '@store';\nimport {\n DimensionCols,\n DimensionType,\n MultiDimensionType,\n ColumnRegular,\n DimensionSettingsState,\n ViewPortScrollEvent,\n ViewSettingSizeProp,\n ViewportState,\n} from '@type';\nimport { getColumnSizes } from '../utils/column.utils';\n\nexport type DimensionConfig = {\n realSizeChanged(k: MultiDimensionType): void;\n};\n/**\n * Dimension provider\n * Stores dimension information and custom sizes\n */\nexport default class DimensionProvider {\n readonly stores: DimensionStoreCollection;\n constructor(\n private viewports: ViewportProvider,\n config: DimensionConfig,\n ) {\n const sizeChanged = debounce(\n (k: MultiDimensionType) => config.realSizeChanged(k),\n RESIZE_INTERVAL,\n );\n this.stores = reduce(\n [...rowTypes, ...columnTypes],\n (sources: Partial<DimensionStoreCollection>, t: MultiDimensionType) => {\n sources[t] = new DimensionStore(t);\n sources[t].store.onChange('realSize', () => sizeChanged(t));\n return sources;\n },\n {},\n ) as DimensionStoreCollection;\n }\n\n /**\n * Clear old sizes from dimension and viewports\n * @param type - dimension type\n * @param count - count of items\n */\n clearSize(t: MultiDimensionType, count: number) {\n this.stores[t].drop();\n // after we done with drop trigger viewport recalculaction\n this.viewports.stores[t].setOriginalSizes(\n this.stores[t].store.get('originItemSize'),\n );\n this.setItemCount(count, t);\n }\n\n /**\n * Apply new custom sizes to dimension and view port\n * @param type - dimension type\n * @param sizes - new custom sizes\n * @param keepOld - keep old sizes merge new with old\n */\n setCustomSizes(\n type: MultiDimensionType,\n sizes: ViewSettingSizeProp,\n keepOld = false,\n ) {\n let newSizes = sizes;\n if (keepOld) {\n const oldSizes = this.stores[type].store.get('sizes');\n newSizes = {\n ...oldSizes,\n ...sizes,\n };\n }\n this.stores[type].setDimensionSize(newSizes);\n this.updateViewport(type, true);\n }\n\n setItemCount(realCount: number, type: MultiDimensionType) {\n this.viewports.stores[type].setViewport({ realCount });\n this.stores[type].setStore({ count: realCount });\n }\n\n /**\n * Apply trimmed items\n * @param trimmed - trimmed items\n * @param type\n */\n setTrimmed(trimmed: Trimmed, type: MultiDimensionType) {\n const allTrimmed = gatherTrimmedItems(trimmed);\n const dimStoreType = this.stores[type];\n dimStoreType.setStore({ trimmed: allTrimmed });\n this.updateViewport(type, true);\n }\n\n /**\n * Sets dimension data and view port coordinate\n * @param itemCount\n * @param type - dimension type\n * @param noVirtual - disable virtual data\n */\n setData(itemCount: number, type: MultiDimensionType, noVirtual = false) {\n this.setItemCount(itemCount, type);\n\n // Virtualization will get disabled\n if (noVirtual) {\n const dimension = this.stores[type].getCurrentState();\n this.viewports.stores[type].setViewport({\n virtualSize: dimension.realSize,\n });\n }\n this.updateViewport(type);\n }\n\n /**\n * Applies new columns to the dimension provider\n * @param columns - new columns data\n * @param disableVirtualX - disable virtual data for X axis\n */\n applyNewColumns(\n columns: Record<DimensionCols, ColumnRegular[]>,\n disableVirtualX: boolean,\n ) {\n // Apply new columns to dimension provider\n for (let type of columnTypes) {\n // Clear existing data in the dimension provider\n this.stores[type].drop();\n\n // Get the new columns for the current type\n const items = columns[type];\n\n // Determine if virtual data should be disabled for the current type\n const noVirtual = type !== 'rgCol' || disableVirtualX;\n\n // Set the items count in the dimension provider\n this.stores[type].setStore({ count: items.length });\n\n // Set the custom sizes for the columns\n const newSizes = getColumnSizes(items);\n this.stores[type].setDimensionSize(newSizes);\n\n // Update the viewport with new data\n const vpUpdate: Partial<ViewportState> = {\n // This triggers drop on realCount change\n realCount: items.length,\n };\n\n // If virtual data is disabled, set the virtual size to the real size\n if (noVirtual) {\n vpUpdate.virtualSize = this.stores[type].getCurrentState().realSize;\n }\n\n // Update the viewport\n this.viewports.stores[type].setViewport(vpUpdate);\n this.setViewPortCoordinate({\n coordinate: this.viewports.stores[type].lastCoordinate,\n type,\n });\n }\n }\n\n getFullSize(): { x: number; y: number } {\n let x = 0;\n let y = 0;\n for (let type of columnTypes) {\n x += this.stores[type]?.store.get('realSize') || 0;\n }\n for (let type of rowTypes) {\n y += this.stores[type]?.store.get('realSize') || 0;\n }\n return { y, x };\n }\n\n updateViewport(type: MultiDimensionType, force = false) {\n this.setViewPortCoordinate({\n coordinate: this.viewports.stores[type].lastCoordinate,\n type,\n force,\n });\n }\n\n setViewPortCoordinate({\n coordinate,\n type,\n force = false,\n }: {\n coordinate: number;\n type: MultiDimensionType;\n force?: boolean;\n }) {\n const dimension = this.stores[type].getCurrentState();\n this.viewports.stores[type].setViewPortCoordinate(coordinate, dimension, force);\n }\n\n getViewPortPos(e: ViewPortScrollEvent): number {\n const dimension = this.stores[e.dimension].getCurrentState();\n const item = getItemByIndex(dimension, e.coordinate);\n\n return item.start;\n }\n\n setSettings(\n data: Partial<DimensionSettingsState>,\n dimensionType: DimensionType,\n ) {\n let stores: MultiDimensionType[] = [];\n switch (dimensionType) {\n case 'rgCol':\n stores = columnTypes;\n break;\n case 'rgRow':\n stores = rowTypes;\n break;\n }\n for (let s of stores) {\n this.stores[s].setStore(data);\n }\n }\n\n updateSizesPositionByNewDataIndexes(type: MultiDimensionType, newItemsOrder: number[], prevItemsOrder: number[] = []) {\n // Move custom sizes to new order\n const dimService = this.stores[type];\n const customSizes = {...dimService.store.get('sizes')};\n if (Object.keys(customSizes).length) {\n const originalIndices = new Map();\n prevItemsOrder.forEach((value, index) => {\n originalIndices.set(value, index);\n });\n const newSizes: Record<number, number> = {};\n newItemsOrder.forEach((value, newIndex) => {\n const originalIndex = originalIndices.get(value);\n if (originalIndex !== newIndex && customSizes[originalIndex]) {\n newSizes[newIndex] = customSizes[originalIndex];\n delete customSizes[originalIndex];\n }\n });\n if (Object.keys(newSizes).length) {\n this.setCustomSizes(type, {\n ...customSizes,\n ...newSizes,\n });\n }\n }\n }\n}\n"]}
|
|
@@ -2,11 +2,24 @@
|
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Proxy plugin for data source.
|
|
6
|
+
* This plugin is used to sort the data source.
|
|
7
|
+
* It keeps the order of the items but does not modify the final source.
|
|
8
|
+
* It is also used to filter the items in the data source.
|
|
9
|
+
* The `set` method takes a key and a new value as arguments.
|
|
10
|
+
* If the key is 'proxyItems' it will filter the items in the data source according to the new value.
|
|
11
|
+
* The new value should be an array of numbers representing the indexes of the items that should be visible.
|
|
12
|
+
* The method will return a new array of numbers with the indexes of the items that should be visible.
|
|
13
|
+
* The method will also update the 'items' property of the store with the new array.
|
|
8
14
|
*/
|
|
9
15
|
export const proxyPlugin = (store) => ({
|
|
16
|
+
/**
|
|
17
|
+
* Set the value of a property in the store.
|
|
18
|
+
* If the key is 'proxyItems' it will filter the items in the data source according to the new value.
|
|
19
|
+
* The new value should be an array of numbers representing the indexes of the items that should be visible.
|
|
20
|
+
* The method will return a new array of numbers with the indexes of the items that should be visible.
|
|
21
|
+
* The method will also update the 'items' property of the store with the new array.
|
|
22
|
+
*/
|
|
10
23
|
set(k, newVal) {
|
|
11
24
|
if (!isProxy(k)) {
|
|
12
25
|
return;
|
|
@@ -16,15 +29,15 @@ export const proxyPlugin = (store) => ({
|
|
|
16
29
|
* Mark indexes as visible
|
|
17
30
|
*/
|
|
18
31
|
const oldItems = store.get('items').reduce((r, v) => {
|
|
19
|
-
r
|
|
32
|
+
r.add(v);
|
|
20
33
|
return r;
|
|
21
|
-
},
|
|
34
|
+
}, new Set());
|
|
22
35
|
/**
|
|
23
36
|
* Check if new values where present in items
|
|
24
37
|
* Filter item collection according presense
|
|
25
38
|
*/
|
|
26
39
|
const newItems = newVal.reduce((r, i) => {
|
|
27
|
-
if (oldItems
|
|
40
|
+
if (oldItems.has(i)) {
|
|
28
41
|
r.push(i);
|
|
29
42
|
}
|
|
30
43
|
return r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.proxy.js","sourceRoot":"","sources":["../../../src/store/dataSource/data.proxy.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"data.proxy.js","sourceRoot":"","sources":["../../../src/store/dataSource/data.proxy.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAwB,EAA0B,EAAE,CAAC,CAAC;IAChF;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,MAAM;QACX,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD;;;WAGG;QACH,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE;YAC1D,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACT,OAAO,CAAC,CAAC;QACX,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;QACtB;;;WAGG;QACH,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAW,EAAE,CAAS,EAAE,EAAE;YACxD,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,OAAO,CAAC,CAAc;IAC7B,OAAO,CAAC,KAAK,YAAY,CAAC;AAC5B,CAAC","sourcesContent":["import { DSourceState } from '@store';\nimport { Observable, PluginSubscribe } from '../../utils/store.utils';\n\ntype State = DSourceState<any, any>;\n\n/**\n * Proxy plugin for data source.\n * This plugin is used to sort the data source.\n * It keeps the order of the items but does not modify the final source.\n * It is also used to filter the items in the data source.\n * The `set` method takes a key and a new value as arguments.\n * If the key is 'proxyItems' it will filter the items in the data source according to the new value.\n * The new value should be an array of numbers representing the indexes of the items that should be visible.\n * The method will return a new array of numbers with the indexes of the items that should be visible.\n * The method will also update the 'items' property of the store with the new array.\n */\nexport const proxyPlugin = (store: Observable<State>): PluginSubscribe<State> => ({\n /**\n * Set the value of a property in the store.\n * If the key is 'proxyItems' it will filter the items in the data source according to the new value.\n * The new value should be an array of numbers representing the indexes of the items that should be visible.\n * The method will return a new array of numbers with the indexes of the items that should be visible.\n * The method will also update the 'items' property of the store with the new array.\n */\n set(k, newVal) {\n if (!isProxy(k)) {\n return;\n }\n /**\n * Getting existing collection of items\n * Mark indexes as visible\n */\n const oldItems = store.get('items').reduce((r, v: number) => {\n r.add(v);\n return r;\n }, new Set<number>());\n /**\n * Check if new values where present in items\n * Filter item collection according presense\n */\n const newItems = newVal.reduce((r: number[], i: number) => {\n if (oldItems.has(i)) {\n r.push(i);\n }\n return r;\n }, []);\n store.set('items', newItems);\n },\n});\n\nfunction isProxy(k: keyof State): k is 'proxyItems' {\n return k === 'proxyItems';\n}\n"]}
|
|
@@ -54,6 +54,9 @@ export class DataStore {
|
|
|
54
54
|
trimmed = Object.assign(Object.assign({}, trimmed), some);
|
|
55
55
|
setStore(this.store, { trimmed });
|
|
56
56
|
}
|
|
57
|
+
setSourceData(items, mutate = true) {
|
|
58
|
+
setSourceByVirtualIndex(this.store, items, mutate);
|
|
59
|
+
}
|
|
57
60
|
// local data update
|
|
58
61
|
setData(input) {
|
|
59
62
|
const data = Object.assign({}, input);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.store.js","source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IACD,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAuC,EACvC,YAA+B,EAC/B,MAAM,GAAG,IAAI;IAEb,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,KAAK,IAAI,KAAK,IAAI,YAAY,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,KAAuC,EACvC,KAAe;IAEf,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,KAAyC,EACzC,IAAgB;IAEhB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import findIndex from 'lodash/findIndex';\nimport range from 'lodash/range';\nimport { createStore } from '@stencil/store';\n\nimport { Trimmed, trimmedPlugin } from './trimmed.plugin';\nimport { setStore, Observable } from '../../utils/store.utils';\nimport { proxyPlugin } from './data.proxy';\nimport { GroupLabelTemplateFunc } from '../../plugins/groupingRow/grouping.row.types';\nimport { DimensionRows, DimensionCols } from '@type';\nimport type {\n ColumnProperties,\n ColumnGrouping,\n ColumnRegular,\n DataType,\n DataSourceState,\n ColumnProp,\n} from '@type';\n\nexport interface Group extends ColumnProperties {\n name: string;\n children: (ColumnGrouping | ColumnRegular)[];\n // props/ids\n ids: (string | number)[];\n}\nexport type Groups = Record<any, any>;\nexport type GDataType = DataType | ColumnRegular;\nexport type GDimension = DimensionRows | DimensionCols;\nexport type DSourceState<\n T1 extends GDataType,\n T2 extends GDimension,\n> = DataSourceState<T1, T2> & {\n groupingCustomRenderer?: GroupLabelTemplateFunc | null;\n};\n\n/**\n * Data store\n * Manage the state of a data source and provide methods for updating, adding, and refreshing the data.\n */\nexport class DataStore<T extends GDataType, ST extends GDimension> {\n private readonly dataStore: Observable<DSourceState<T, ST>>;\n get store(): Observable<DSourceState<T, ST>> {\n return this.dataStore;\n }\n constructor(type: ST, storeData?: DSourceState<T, ST>) {\n const store = (this.dataStore = createStore<DSourceState<T, ST>>({\n items: [],\n proxyItems: [],\n source: [],\n groupingDepth: 0,\n groups: {},\n type,\n trimmed: {},\n groupingCustomRenderer: undefined,\n ...storeData,\n }));\n store.use(proxyPlugin(store));\n store.use(trimmedPlugin(store));\n }\n\n /**\n * full data source update\n * @param source - data column/rgRow source\n * @param grouping - grouping information if present\n */\n updateData(\n source: T[],\n grouping?: {\n depth: number;\n groups?: Groups;\n customRenderer?: GroupLabelTemplateFunc;\n },\n silent = false,\n ) {\n // during full update we do drop trim\n if (!silent) {\n this.store.set('trimmed', {});\n }\n // clear items\n this.store.set('items', []);\n const items = range(0, source?.length || 0);\n\n // set proxy first\n setStore(this.store, {\n source,\n proxyItems: [...items],\n });\n // update data items\n this.store.set('items', items);\n // apply grouping if present\n if (grouping) {\n setStore(this.store, {\n groupingDepth: grouping.depth,\n groups: grouping.groups,\n groupingCustomRenderer: grouping.customRenderer,\n });\n }\n }\n\n addTrimmed(some: Partial<Trimmed>) {\n let trimmed = this.store.get('trimmed');\n trimmed = { ...trimmed, ...some };\n setStore(this.store, { trimmed });\n }\n\n // local data update\n setData(input: Partial<DSourceState<T, ST>>) {\n const data: Partial<DSourceState<T, ST>> = {\n ...input,\n };\n setStore(this.store, data);\n }\n\n refresh() {\n const source = this.store.get('source');\n this.store.set('source', [...source]);\n }\n}\n/**\n * get physical index by virtual\n * @param store - store to process\n */\nexport function getPhysical(\n store: Observable<DSourceState<any, any>>,\n virtualIndex: number,\n) {\n const items = store.get('items');\n return items[virtualIndex];\n}\n\n/**\n * get all visible items\n * @param store - store to process\n */\nexport function getVisibleSourceItem(\n store: Observable<DSourceState<any, any>>,\n) {\n const source = store.get('source');\n return store.get('items').map(v => source[v]);\n}\n\n/**\n * get mapped item from source\n * @param store - store to process\n * @param virtualIndex - virtual index to process\n */\nexport const getSourceItem = <T1 extends GDataType, T2 extends GDimension>(\n store: Observable<DSourceState<T1, T2>>,\n virtualIndex: number,\n) => {\n const source = store.get('source');\n return source[getSourcePhysicalIndex(store, virtualIndex)];\n};\n/**\n * Get physical index from virtual index\n */\nexport const getSourcePhysicalIndex = <T1 extends GDataType, T2 extends GDimension>(\n store: Observable<DSourceState<T1, T2>>,\n virtualIndex: number,\n) => {\n const items = store.get('items');\n return items[virtualIndex];\n};\n\n/**\n * Apply silently item/model/row value to data source\n * @param store - data source with changes\n * @param modelByIndex - collection of rows/values with virtual indexes to setup/replace in store/data source\n * @param mutate - if true, store will be mutated and whole viewport will be re-rendered\n */\nexport function setSourceByVirtualIndex<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n modelByIndex: Record<number, T | undefined>,\n mutate = true,\n) {\n const items = store.get('items');\n const source = store.get('source');\n\n for (let virtualIndex in modelByIndex) {\n const realIndex = items[virtualIndex];\n const item = modelByIndex[virtualIndex];\n source[realIndex] = item as T;\n }\n if (mutate) {\n store.set('source', [...source]);\n }\n}\n\n/**\n * set item to source\n * @param store - store to process\n * @param modelByIndex - collection of rows with physical indexes to setup\n * @param mutate - if true, store will be mutated and whole viewport will be re-rendered\n */\nexport function setSourceByPhysicalIndex<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n modelByIndex: Record<number, T>,\n mutate = true,\n) {\n const source = store.get('source');\n for (let index in modelByIndex) {\n source[index] = modelByIndex[index];\n }\n if (mutate) {\n store.set('source', [...source]);\n }\n}\n\nexport function setItems<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n items: number[],\n) {\n store.set('items', items);\n}\n\nexport function getSourceItemVirtualIndexByProp(\n store: Observable<DSourceState<any, any>>,\n prop: ColumnProp,\n) {\n const items = store.get('items');\n const source = store.get('source');\n const physicalIndex = findIndex(source, { prop });\n return items.indexOf(physicalIndex);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"data.store.js","sourceRoot":"","sources":["../../../src/store/dataSource/data.store.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAW,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA4B3C;;;GAGG;AACH,MAAM,OAAO,SAAS;IAEpB,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IACD,YAAY,IAAQ,EAAE,SAA+B;QACnD,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,SAAS,GAAG,WAAW,iBACzC,KAAK,EAAE,EAAE,EACT,UAAU,EAAE,EAAE,EACd,MAAM,EAAE,EAAE,EACV,aAAa,EAAE,CAAC,EAChB,MAAM,EAAE,EAAE,EACV,IAAI,EACJ,OAAO,EAAE,EAAE,EACX,sBAAsB,EAAE,SAAS,IAC9B,SAAS,EACZ,CAAC,CAAC;QACJ,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC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AC;AAC5B,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,KAAyC,EACzC,IAAgB;IAEhB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import findIndex from 'lodash/findIndex';\nimport range from 'lodash/range';\nimport { createStore } from '@stencil/store';\n\nimport { Trimmed, trimmedPlugin } from './trimmed.plugin';\nimport { setStore, Observable } from '../../utils/store.utils';\nimport { proxyPlugin } from './data.proxy';\nimport { GroupLabelTemplateFunc } from '../../plugins/groupingRow/grouping.row.types';\nimport { DimensionRows, DimensionCols } from '@type';\nimport type {\n ColumnProperties,\n ColumnGrouping,\n ColumnRegular,\n DataType,\n DataSourceState,\n ColumnProp,\n} from '@type';\n\nexport interface Group extends ColumnProperties {\n name: string;\n children: (ColumnGrouping | ColumnRegular)[];\n // props/ids\n ids: (string | number)[];\n}\nexport type Groups = Record<any, any>;\nexport type GDataType = DataType | ColumnRegular;\nexport type GDimension = DimensionRows | DimensionCols;\nexport type DSourceState<\n T1 extends GDataType,\n T2 extends GDimension,\n> = DataSourceState<T1, T2> & {\n groupingCustomRenderer?: GroupLabelTemplateFunc | null;\n};\n\n/**\n * Data store\n * Manage the state of a data source and provide methods for updating, adding, and refreshing the data.\n */\nexport class DataStore<T extends GDataType, ST extends GDimension> {\n private readonly dataStore: Observable<DSourceState<T, ST>>;\n get store(): Observable<DSourceState<T, ST>> {\n return this.dataStore;\n }\n constructor(type: ST, storeData?: DSourceState<T, ST>) {\n const store = (this.dataStore = createStore<DSourceState<T, ST>>({\n items: [],\n proxyItems: [],\n source: [],\n groupingDepth: 0,\n groups: {},\n type,\n trimmed: {},\n groupingCustomRenderer: undefined,\n ...storeData,\n }));\n store.use(proxyPlugin(store));\n store.use(trimmedPlugin(store));\n }\n\n /**\n * full data source update\n * @param source - data column/rgRow source\n * @param grouping - grouping information if present\n */\n updateData(\n source: T[],\n grouping?: {\n depth: number;\n groups?: Groups;\n customRenderer?: GroupLabelTemplateFunc;\n },\n silent = false,\n ) {\n // during full update we do drop trim\n if (!silent) {\n this.store.set('trimmed', {});\n }\n // clear items\n this.store.set('items', []);\n const items = range(0, source?.length || 0);\n\n // set proxy first\n setStore(this.store, {\n source,\n proxyItems: [...items],\n });\n // update data items\n this.store.set('items', items);\n // apply grouping if present\n if (grouping) {\n setStore(this.store, {\n groupingDepth: grouping.depth,\n groups: grouping.groups,\n groupingCustomRenderer: grouping.customRenderer,\n });\n }\n }\n\n addTrimmed(some: Partial<Trimmed>) {\n let trimmed = this.store.get('trimmed');\n trimmed = { ...trimmed, ...some };\n setStore(this.store, { trimmed });\n }\n\n setSourceData(items: Record<number, any>, mutate = true) {\n setSourceByVirtualIndex(this.store, items, mutate);\n }\n\n // local data update\n setData(input: Partial<DSourceState<T, ST>>) {\n const data: Partial<DSourceState<T, ST>> = {\n ...input,\n };\n setStore(this.store, data);\n }\n\n refresh() {\n const source = this.store.get('source');\n this.store.set('source', [...source]);\n }\n}\n/**\n * get physical index by virtual\n * @param store - store to process\n */\nexport function getPhysical(\n store: Observable<DSourceState<any, any>>,\n virtualIndex: number,\n) {\n const items = store.get('items');\n return items[virtualIndex];\n}\n\n/**\n * get all visible items\n * @param store - store to process\n */\nexport function getVisibleSourceItem(\n store: Observable<DSourceState<any, any>>,\n) {\n const source = store.get('source');\n return store.get('items').map(v => source[v]);\n}\n\n/**\n * get mapped item from source\n * @param store - store to process\n * @param virtualIndex - virtual index to process\n */\nexport const getSourceItem = <T1 extends GDataType, T2 extends GDimension>(\n store: Observable<DSourceState<T1, T2>>,\n virtualIndex: number,\n) => {\n const source = store.get('source');\n return source[getSourcePhysicalIndex(store, virtualIndex)];\n};\n/**\n * Get physical index from virtual index\n */\nexport const getSourcePhysicalIndex = <T1 extends GDataType, T2 extends GDimension>(\n store: Observable<DSourceState<T1, T2>>,\n virtualIndex: number,\n) => {\n const items = store.get('items');\n return items[virtualIndex];\n};\n\n/**\n * Apply silently item/model/row value to data source\n * @param store - data source with changes\n * @param modelByIndex - collection of rows/values with virtual indexes to setup/replace in store/data source\n * @param mutate - if true, store will be mutated and whole viewport will be re-rendered\n */\nexport function setSourceByVirtualIndex<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n modelByIndex: Record<number, T | undefined>,\n mutate = true,\n) {\n const items = store.get('items');\n const source = store.get('source');\n\n for (let virtualIndex in modelByIndex) {\n const realIndex = items[virtualIndex];\n const item = modelByIndex[virtualIndex];\n source[realIndex] = item as T;\n }\n if (mutate) {\n store.set('source', [...source]);\n }\n}\n\n/**\n * set item to source\n * @param store - store to process\n * @param modelByIndex - collection of rows with physical indexes to setup\n * @param mutate - if true, store will be mutated and whole viewport will be re-rendered\n */\nexport function setSourceByPhysicalIndex<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n modelByIndex: Record<number, T>,\n mutate = true,\n) {\n const source = store.get('source');\n for (let index in modelByIndex) {\n source[index] = modelByIndex[index];\n }\n if (mutate) {\n store.set('source', [...source]);\n }\n}\n\nexport function setItems<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n items: number[],\n) {\n store.set('items', items);\n}\n\nexport function getSourceItemVirtualIndexByProp(\n store: Observable<DSourceState<any, any>>,\n prop: ColumnProp,\n) {\n const items = store.get('items');\n const source = store.get('source');\n const physicalIndex = findIndex(source, { prop });\n return items.indexOf(physicalIndex);\n}\n"]}
|
|
@@ -70,6 +70,7 @@ export const REVOGRID_EVENTS = new Map([
|
|
|
70
70
|
['rowdragmoveinit', 'rowdragmoveinit'],
|
|
71
71
|
['rowdragmousemove', 'rowdragmousemove'],
|
|
72
72
|
['rowdropinit', 'rowdropinit'],
|
|
73
|
+
['roworderchange', 'roworderchange'],
|
|
73
74
|
['beforecopyregion', 'beforecopyregion'],
|
|
74
75
|
['beforepasteregion', 'beforepasteregion'],
|
|
75
76
|
['celleditapply', 'celleditapply'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAsGA,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAiC;IACrE,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAC5C,CAAC,YAAY,EAAE,YAAY,CAAC;IAC5B,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IACtC,CAAC,WAAW,EAAE,WAAW,CAAC;IAC1B,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,aAAa,EAAE,aAAa,CAAC;IAC9B,CAAC,YAAY,EAAE,YAAY,CAAC;IAC5B,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IACtC,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAC5C,CAAC,eAAe,EAAE,eAAe,CAAC;IAClC,CAAC,cAAc,EAAE,cAAc,CAAC;IAChC,CAAC,aAAa,EAAE,aAAa,CAAC;IAC9B,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IACtC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IACtC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IACtC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IACtC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;IACxC,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAC9C,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;IACtC,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IAC1C,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAC9C,CAAC,eAAe,EAAE,eAAe,CAA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AAsB,EAAE,sBAAsB,CAAC;IAChD,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAC5C,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAC9C,CAAC,eAAe,EAAE,eAAe,CAAC;IAClC,CAAC,aAAa,EAAE,aAAa,CAAC;IAC9B,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,YAAY,EAAE,YAAY,CAAC;IAC5B,CAAC,KAAK,EAAE,KAAK,CAAC;IACd,CAAC,eAAe,EAAE,eAAe,CAAC;IAClC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,cAAc,EAAE,cAAc,CAAC;IAChC,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAChD,CAAC,MAAM,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC","sourcesContent":["\nexport type RevogridEvents = 'contentsizechanged'|\n 'beforeedit'|\n 'beforerangeedit'|\n 'afteredit'|\n 'beforeautofill'|\n 'beforerange'|\n 'afterfocus'|\n 'roworderchanged'|\n 'beforesortingapply'|\n 'beforesorting'|\n 'rowdragstart'|\n 'headerclick'|\n 'beforecellfocus'|\n 'beforefocuslost'|\n 'beforesourceset'|\n 'beforeanysource'|\n 'aftersourceset'|\n 'afteranysource'|\n 'beforecolumnsset'|\n 'beforecolumnapplied'|\n 'aftercolumnsset'|\n 'beforefilterapply'|\n 'beforefiltertrimmed'|\n 'beforetrimmed'|\n 'aftertrimmed'|\n 'viewportscroll'|\n 'beforeexport'|\n 'beforeeditstart'|\n 'aftercolumnresize'|\n 'beforerowdefinition'|\n 'filterconfigchanged'|\n 'rowheaderschanged'|\n 'beforegridrender'|\n 'aftergridrender'|\n 'aftergridinit'|\n 'additionaldatachanged'|\n 'afterthemechanged'|\n 'beforepaste'|\n 'beforepasteapply'|\n 'pasteregion'|\n 'afterpasteapply'|\n 'beforecut'|\n 'clearregion'|\n 'beforecopy'|\n 'beforecopyapply'|\n 'copyregion'|\n 'beforerowrender'|\n 'afterrender'|\n 'beforecellrender'|\n 'dragstartcell'|\n 'celledit'|\n 'closeedit'|\n 'filterChange'|\n 'resetChange'|\n 'beforefocusrender'|\n 'beforescrollintoview'|\n 'afterfocus'|\n 'beforeheaderclick'|\n 'headerresize'|\n 'beforeheaderresize'|\n 'headerdblclick'|\n 'beforeheaderrender'|\n 'afterheaderrender'|\n 'rowdragstartinit'|\n 'rowdragendinit'|\n 'rowdragmoveinit'|\n 'rowdragmousemove'|\n 'rowdropinit'|\n 'beforecopyregion'|\n 'beforepasteregion'|\n 'celleditapply'|\n 'beforecellfocusinit'|\n 'beforenextvpfocus'|\n 'setedit'|\n 'beforeapplyrange'|\n 'beforesetrange'|\n 'beforeeditrender'|\n 'setrange'|\n 'selectall'|\n 'canceledit'|\n 'settemprange'|\n 'beforesettemprange'|\n 'applyfocus'|\n 'focuscell'|\n 'beforerangedataapply'|\n 'selectionchangeinit'|\n 'beforerangecopyapply'|\n 'rangeeditapply'|\n 'clipboardrangecopy'|\n 'clipboardrangepaste'|\n 'beforekeydown'|\n 'beforekeyup'|\n 'beforecellsave'|\n 'scrollview'|\n 'ref'|\n 'scrollvirtual'|\n 'scrollviewport'|\n 'resizeviewport'|\n 'scrollchange'|\n 'scrollviewportsilent'|\n 'html'\nexport const REVOGRID_EVENTS = new Map<RevogridEvents, RevogridEvents>([\n ['contentsizechanged', 'contentsizechanged'],\n ['beforeedit', 'beforeedit'],\n ['beforerangeedit', 'beforerangeedit'],\n ['afteredit', 'afteredit'],\n ['beforeautofill', 'beforeautofill'],\n ['beforerange', 'beforerange'],\n ['afterfocus', 'afterfocus'],\n ['roworderchanged', 'roworderchanged'],\n ['beforesortingapply', 'beforesortingapply'],\n ['beforesorting', 'beforesorting'],\n ['rowdragstart', 'rowdragstart'],\n ['headerclick', 'headerclick'],\n ['beforecellfocus', 'beforecellfocus'],\n ['beforefocuslost', 'beforefocuslost'],\n ['beforesourceset', 'beforesourceset'],\n ['beforeanysource', 'beforeanysource'],\n ['aftersourceset', 'aftersourceset'],\n ['afteranysource', 'afteranysource'],\n ['beforecolumnsset', 'beforecolumnsset'],\n ['beforecolumnapplied', 'beforecolumnapplied'],\n ['aftercolumnsset', 'aftercolumnsset'],\n ['beforefilterapply', 'beforefilterapply'],\n ['beforefiltertrimmed', 'beforefiltertrimmed'],\n ['beforetrimmed', 'beforetrimmed'],\n ['aftertrimmed', 'aftertrimmed'],\n ['viewportscroll', 'viewportscroll'],\n ['beforeexport', 'beforeexport'],\n ['beforeeditstart', 'beforeeditstart'],\n ['aftercolumnresize', 'aftercolumnresize'],\n ['beforerowdefinition', 'beforerowdefinition'],\n ['filterconfigchanged', 'filterconfigchanged'],\n ['rowheaderschanged', 'rowheaderschanged'],\n ['beforegridrender', 'beforegridrender'],\n ['aftergridrender', 'aftergridrender'],\n ['aftergridinit', 'aftergridinit'],\n ['additionaldatachanged', 'additionaldatachanged'],\n ['afterthemechanged', 'afterthemechanged'],\n ['beforepaste', 'beforepaste'],\n ['beforepasteapply', 'beforepasteapply'],\n ['pasteregion', 'pasteregion'],\n ['afterpasteapply', 'afterpasteapply'],\n ['beforecut', 'beforecut'],\n ['clearregion', 'clearregion'],\n ['beforecopy', 'beforecopy'],\n ['beforecopyapply', 'beforecopyapply'],\n ['copyregion', 'copyregion'],\n ['beforerowrender', 'beforerowrender'],\n ['afterrender', 'afterrender'],\n ['beforecellrender', 'beforecellrender'],\n ['dragstartcell', 'dragstartcell'],\n ['celledit', 'celledit'],\n ['closeedit', 'closeedit'],\n ['filterChange', 'filterChange'],\n ['resetChange', 'resetChange'],\n ['beforefocusrender', 'beforefocusrender'],\n ['beforescrollintoview', 'beforescrollintoview'],\n ['afterfocus', 'afterfocus'],\n ['beforeheaderclick', 'beforeheaderclick'],\n ['headerresize', 'headerresize'],\n ['beforeheaderresize', 'beforeheaderresize'],\n ['headerdblclick', 'headerdblclick'],\n ['beforeheaderrender', 'beforeheaderrender'],\n ['afterheaderrender', 'afterheaderrender'],\n ['rowdragstartinit', 'rowdragstartinit'],\n ['rowdragendinit', 'rowdragendinit'],\n ['rowdragmoveinit', 'rowdragmoveinit'],\n ['rowdragmousemove', 'rowdragmousemove'],\n ['rowdropinit', 'rowdropinit'],\n ['beforecopyregion', 'beforecopyregion'],\n ['beforepasteregion', 'beforepasteregion'],\n ['celleditapply', 'celleditapply'],\n ['beforecellfocusinit', 'beforecellfocusinit'],\n ['beforenextvpfocus', 'beforenextvpfocus'],\n ['setedit', 'setedit'],\n ['beforeapplyrange', 'beforeapplyrange'],\n ['beforesetrange', 'beforesetrange'],\n ['beforeeditrender', 'beforeeditrender'],\n ['setrange', 'setrange'],\n ['selectall', 'selectall'],\n ['canceledit', 'canceledit'],\n ['settemprange', 'settemprange'],\n ['beforesettemprange', 'beforesettemprange'],\n ['applyfocus', 'applyfocus'],\n ['focuscell', 'focuscell'],\n ['beforerangedataapply', 'beforerangedataapply'],\n ['selectionchangeinit', 'selectionchangeinit'],\n ['beforerangecopyapply', 'beforerangecopyapply'],\n ['rangeeditapply', 'rangeeditapply'],\n ['clipboardrangecopy', 'clipboardrangecopy'],\n ['clipboardrangepaste', 'clipboardrangepaste'],\n ['beforekeydown', 'beforekeydown'],\n ['beforekeyup', 'beforekeyup'],\n ['beforecellsave', 'beforecellsave'],\n ['scrollview', 'scrollview'],\n ['ref', 'ref'],\n ['scrollvirtual', 'scrollvirtual'],\n ['scrollviewport', 'scrollviewport'],\n ['resizeviewport', 'resizeviewport'],\n ['scrollchange', 'scrollchange'],\n ['scrollviewportsilent', 'scrollviewportsilent'],\n ['html', 'html']\n]);"]}
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAuGA,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAiC;IACrE,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAC5C,CAAC,YA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,CAAC;IAC5B,CAAC,KAAK,EAAE,KAAK,CAAC;IACd,CAAC,eAAe,EAAE,eAAe,CAAC;IAClC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IACpC,CAAC,cAAc,EAAE,cAAc,CAAC;IAChC,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IAChD,CAAC,MAAM,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC","sourcesContent":["\nexport type RevogridEvents = 'contentsizechanged'|\n 'beforeedit'|\n 'beforerangeedit'|\n 'afteredit'|\n 'beforeautofill'|\n 'beforerange'|\n 'afterfocus'|\n 'roworderchanged'|\n 'beforesortingapply'|\n 'beforesorting'|\n 'rowdragstart'|\n 'headerclick'|\n 'beforecellfocus'|\n 'beforefocuslost'|\n 'beforesourceset'|\n 'beforeanysource'|\n 'aftersourceset'|\n 'afteranysource'|\n 'beforecolumnsset'|\n 'beforecolumnapplied'|\n 'aftercolumnsset'|\n 'beforefilterapply'|\n 'beforefiltertrimmed'|\n 'beforetrimmed'|\n 'aftertrimmed'|\n 'viewportscroll'|\n 'beforeexport'|\n 'beforeeditstart'|\n 'aftercolumnresize'|\n 'beforerowdefinition'|\n 'filterconfigchanged'|\n 'rowheaderschanged'|\n 'beforegridrender'|\n 'aftergridrender'|\n 'aftergridinit'|\n 'additionaldatachanged'|\n 'afterthemechanged'|\n 'beforepaste'|\n 'beforepasteapply'|\n 'pasteregion'|\n 'afterpasteapply'|\n 'beforecut'|\n 'clearregion'|\n 'beforecopy'|\n 'beforecopyapply'|\n 'copyregion'|\n 'beforerowrender'|\n 'afterrender'|\n 'beforecellrender'|\n 'dragstartcell'|\n 'celledit'|\n 'closeedit'|\n 'filterChange'|\n 'resetChange'|\n 'beforefocusrender'|\n 'beforescrollintoview'|\n 'afterfocus'|\n 'beforeheaderclick'|\n 'headerresize'|\n 'beforeheaderresize'|\n 'headerdblclick'|\n 'beforeheaderrender'|\n 'afterheaderrender'|\n 'rowdragstartinit'|\n 'rowdragendinit'|\n 'rowdragmoveinit'|\n 'rowdragmousemove'|\n 'rowdropinit'|\n 'roworderchange'|\n 'beforecopyregion'|\n 'beforepasteregion'|\n 'celleditapply'|\n 'beforecellfocusinit'|\n 'beforenextvpfocus'|\n 'setedit'|\n 'beforeapplyrange'|\n 'beforesetrange'|\n 'beforeeditrender'|\n 'setrange'|\n 'selectall'|\n 'canceledit'|\n 'settemprange'|\n 'beforesettemprange'|\n 'applyfocus'|\n 'focuscell'|\n 'beforerangedataapply'|\n 'selectionchangeinit'|\n 'beforerangecopyapply'|\n 'rangeeditapply'|\n 'clipboardrangecopy'|\n 'clipboardrangepaste'|\n 'beforekeydown'|\n 'beforekeyup'|\n 'beforecellsave'|\n 'scrollview'|\n 'ref'|\n 'scrollvirtual'|\n 'scrollviewport'|\n 'resizeviewport'|\n 'scrollchange'|\n 'scrollviewportsilent'|\n 'html'\nexport const REVOGRID_EVENTS = new Map<RevogridEvents, RevogridEvents>([\n ['contentsizechanged', 'contentsizechanged'],\n ['beforeedit', 'beforeedit'],\n ['beforerangeedit', 'beforerangeedit'],\n ['afteredit', 'afteredit'],\n ['beforeautofill', 'beforeautofill'],\n ['beforerange', 'beforerange'],\n ['afterfocus', 'afterfocus'],\n ['roworderchanged', 'roworderchanged'],\n ['beforesortingapply', 'beforesortingapply'],\n ['beforesorting', 'beforesorting'],\n ['rowdragstart', 'rowdragstart'],\n ['headerclick', 'headerclick'],\n ['beforecellfocus', 'beforecellfocus'],\n ['beforefocuslost', 'beforefocuslost'],\n ['beforesourceset', 'beforesourceset'],\n ['beforeanysource', 'beforeanysource'],\n ['aftersourceset', 'aftersourceset'],\n ['afteranysource', 'afteranysource'],\n ['beforecolumnsset', 'beforecolumnsset'],\n ['beforecolumnapplied', 'beforecolumnapplied'],\n ['aftercolumnsset', 'aftercolumnsset'],\n ['beforefilterapply', 'beforefilterapply'],\n ['beforefiltertrimmed', 'beforefiltertrimmed'],\n ['beforetrimmed', 'beforetrimmed'],\n ['aftertrimmed', 'aftertrimmed'],\n ['viewportscroll', 'viewportscroll'],\n ['beforeexport', 'beforeexport'],\n ['beforeeditstart', 'beforeeditstart'],\n ['aftercolumnresize', 'aftercolumnresize'],\n ['beforerowdefinition', 'beforerowdefinition'],\n ['filterconfigchanged', 'filterconfigchanged'],\n ['rowheaderschanged', 'rowheaderschanged'],\n ['beforegridrender', 'beforegridrender'],\n ['aftergridrender', 'aftergridrender'],\n ['aftergridinit', 'aftergridinit'],\n ['additionaldatachanged', 'additionaldatachanged'],\n ['afterthemechanged', 'afterthemechanged'],\n ['beforepaste', 'beforepaste'],\n ['beforepasteapply', 'beforepasteapply'],\n ['pasteregion', 'pasteregion'],\n ['afterpasteapply', 'afterpasteapply'],\n ['beforecut', 'beforecut'],\n ['clearregion', 'clearregion'],\n ['beforecopy', 'beforecopy'],\n ['beforecopyapply', 'beforecopyapply'],\n ['copyregion', 'copyregion'],\n ['beforerowrender', 'beforerowrender'],\n ['afterrender', 'afterrender'],\n ['beforecellrender', 'beforecellrender'],\n ['dragstartcell', 'dragstartcell'],\n ['celledit', 'celledit'],\n ['closeedit', 'closeedit'],\n ['filterChange', 'filterChange'],\n ['resetChange', 'resetChange'],\n ['beforefocusrender', 'beforefocusrender'],\n ['beforescrollintoview', 'beforescrollintoview'],\n ['afterfocus', 'afterfocus'],\n ['beforeheaderclick', 'beforeheaderclick'],\n ['headerresize', 'headerresize'],\n ['beforeheaderresize', 'beforeheaderresize'],\n ['headerdblclick', 'headerdblclick'],\n ['beforeheaderrender', 'beforeheaderrender'],\n ['afterheaderrender', 'afterheaderrender'],\n ['rowdragstartinit', 'rowdragstartinit'],\n ['rowdragendinit', 'rowdragendinit'],\n ['rowdragmoveinit', 'rowdragmoveinit'],\n ['rowdragmousemove', 'rowdragmousemove'],\n ['rowdropinit', 'rowdropinit'],\n ['roworderchange', 'roworderchange'],\n ['beforecopyregion', 'beforecopyregion'],\n ['beforepasteregion', 'beforepasteregion'],\n ['celleditapply', 'celleditapply'],\n ['beforecellfocusinit', 'beforecellfocusinit'],\n ['beforenextvpfocus', 'beforenextvpfocus'],\n ['setedit', 'setedit'],\n ['beforeapplyrange', 'beforeapplyrange'],\n ['beforesetrange', 'beforesetrange'],\n ['beforeeditrender', 'beforeeditrender'],\n ['setrange', 'setrange'],\n ['selectall', 'selectall'],\n ['canceledit', 'canceledit'],\n ['settemprange', 'settemprange'],\n ['beforesettemprange', 'beforesettemprange'],\n ['applyfocus', 'applyfocus'],\n ['focuscell', 'focuscell'],\n ['beforerangedataapply', 'beforerangedataapply'],\n ['selectionchangeinit', 'selectionchangeinit'],\n ['beforerangecopyapply', 'beforerangecopyapply'],\n ['rangeeditapply', 'rangeeditapply'],\n ['clipboardrangecopy', 'clipboardrangecopy'],\n ['clipboardrangepaste', 'clipboardrangepaste'],\n ['beforekeydown', 'beforekeydown'],\n ['beforekeyup', 'beforekeyup'],\n ['beforecellsave', 'beforecellsave'],\n ['scrollview', 'scrollview'],\n ['ref', 'ref'],\n ['scrollvirtual', 'scrollvirtual'],\n ['scrollviewport', 'scrollviewport'],\n ['resizeviewport', 'resizeviewport'],\n ['scrollchange', 'scrollchange'],\n ['scrollviewportsilent', 'scrollviewportsilent'],\n ['html', 'html']\n]);"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { f as calculateRowHeaderSize } from './row-header-utils-
|
|
4
|
+
import { z as createStore, A as reduce, m as setStore, B as isArray, C as baseEach, b as getSourceItem, r as getColumnType, E as toInteger, F as isIterateeCall, G as isGrouping, H as getGroupingName, q as getCellDataParsed, v as isColGrouping } from './column.service-751345b2.js';
|
|
5
|
+
import { c as calculateDimensionData, z as identity, b as getScrollbarSize, t as timeout, g as getItemByPosition } from './index-1dcad6ef.js';
|
|
6
|
+
import { f as calculateRowHeaderSize } from './row-header-utils-3dfbb81f.js';
|
|
7
7
|
import { h } from './index-a61f225b.js';
|
|
8
8
|
import { b as FILTER_PROP, i as isFilterBtn } from './filter.button-d40ab17b.js';
|
|
9
|
-
import { d as debounce } from './debounce-
|
|
10
|
-
import { d as dispatch, O as ON_COLUMN_CLICK } from './header-cell-renderer-
|
|
9
|
+
import { d as debounce } from './debounce-72878ced.js';
|
|
10
|
+
import { d as dispatch, O as ON_COLUMN_CLICK } from './header-cell-renderer-32d2ed96.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Storing pre-calculated
|
|
@@ -1656,4 +1656,4 @@ function getLeftRelative(absoluteX, gridPos, offset) {
|
|
|
1656
1656
|
|
|
1657
1657
|
export { AutoSizeColumnPlugin as A, BasePlugin as B, ColumnPlugin as C, DimensionStore as D, ExportFilePlugin as E, FILTER_TRIMMED_TYPE as F, StretchColumn as S, isStretchPlugin as a, FILTER_CONFIG_CHANGED_EVENT as b, columnTypes as c, FILTE_PANEL as d, FilterPlugin as e, filterCoreFunctionsIndexedByType as f, filterTypes as g, filterNames as h, isRowType as i, getLeftRelative as j, forEach as k, rowTypes as r };
|
|
1658
1658
|
|
|
1659
|
-
//# sourceMappingURL=column.drag.plugin-
|
|
1659
|
+
//# sourceMappingURL=column.drag.plugin-3cc77986.js.map
|