lsp-grid 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/cjs/app-globals-Bfsg1bDt.js +16 -0
- package/dist/cjs/app-globals-Bfsg1bDt.js.map +1 -0
- package/dist/cjs/cell-renderer-DtuYp7tj.js +106 -0
- package/dist/cjs/cell-renderer-DtuYp7tj.js.map +1 -0
- package/dist/cjs/column.drag.plugin-BIptTmfz.js +2554 -0
- package/dist/cjs/column.drag.plugin-BIptTmfz.js.map +1 -0
- package/dist/cjs/column.service-BnVSAfcu.js +1391 -0
- package/dist/cjs/column.service-BnVSAfcu.js.map +1 -0
- package/dist/cjs/data.store-CrF4Nf9q.js +3615 -0
- package/dist/cjs/data.store-CrF4Nf9q.js.map +1 -0
- package/dist/cjs/debounce-DgeyTQM0.js +498 -0
- package/dist/cjs/debounce-DgeyTQM0.js.map +1 -0
- package/dist/cjs/edit.utils-Bw-E3Fj6.js +118 -0
- package/dist/cjs/edit.utils-Bw-E3Fj6.js.map +1 -0
- package/dist/cjs/events-D0Syn6ut.js +46 -0
- package/dist/cjs/events-D0Syn6ut.js.map +1 -0
- package/dist/cjs/filter.button-CaAAXq-6.js +49 -0
- package/dist/cjs/filter.button-CaAAXq-6.js.map +1 -0
- package/dist/cjs/header-cell-renderer-DhRJqZ-w.js +356 -0
- package/dist/cjs/header-cell-renderer-DhRJqZ-w.js.map +1 -0
- package/dist/cjs/index-VM40U6Gh.js +2549 -0
- package/dist/cjs/index-VM40U6Gh.js.map +1 -0
- package/dist/cjs/index.cjs.js +346 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +19 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/revo-grid.cjs.entry.js +2187 -0
- package/dist/cjs/revo-grid.cjs.entry.js.map +1 -0
- package/dist/cjs/revo-grid.cjs.js +31 -0
- package/dist/cjs/revo-grid.cjs.js.map +1 -0
- package/dist/cjs/revo-grid.entry.cjs.js.map +1 -0
- package/dist/cjs/revogr-attribution.revogr-extra.revogr-focus.revogr-overlay-selection.revogr-row-headers.revogr-scroll-virtual.revogr-temp-range.entry.cjs.js.map +1 -0
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +1463 -0
- package/dist/cjs/revogr-attribution_7.cjs.entry.js.map +1 -0
- package/dist/cjs/revogr-clipboard.revogr-edit.revogr-order-editor.entry.cjs.js.map +1 -0
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js +456 -0
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -0
- package/dist/cjs/revogr-data.revogr-header.revogr-viewport-scroll.vnode-html.entry.cjs.js.map +1 -0
- package/dist/cjs/revogr-data_4.cjs.entry.js +948 -0
- package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -0
- package/dist/cjs/revogr-filter-panel.cjs.entry.js +382 -0
- package/dist/cjs/revogr-filter-panel.cjs.entry.js.map +1 -0
- package/dist/cjs/revogr-filter-panel.entry.cjs.js.map +1 -0
- package/dist/cjs/row-header-utils-DL640c7x.js +420 -0
- package/dist/cjs/row-header-utils-DL640c7x.js.map +1 -0
- package/dist/cjs/text-editor-DWChyeVV.js +81 -0
- package/dist/cjs/text-editor-DWChyeVV.js.map +1 -0
- package/dist/cjs/throttle-Bb1Bbfd1.js +278 -0
- package/dist/cjs/throttle-Bb1Bbfd1.js.map +1 -0
- package/dist/cjs/viewport.helpers-CI6uB8tu.js +59 -0
- package/dist/cjs/viewport.helpers-CI6uB8tu.js.map +1 -0
- package/dist/collection/collection-manifest.json +28 -0
- package/dist/collection/components/attribution/revogr-attribution.js +20 -0
- package/dist/collection/components/attribution/revogr-attribution.js.map +1 -0
- package/dist/collection/components/clipboard/revogr-clipboard.js +396 -0
- package/dist/collection/components/clipboard/revogr-clipboard.js.map +1 -0
- package/dist/collection/components/data/cell-renderer.js +44 -0
- package/dist/collection/components/data/cell-renderer.js.map +1 -0
- package/dist/collection/components/data/column.service.js +293 -0
- package/dist/collection/components/data/column.service.js.map +1 -0
- package/dist/collection/components/data/revogr-data-style.css +75 -0
- package/dist/collection/components/data/revogr-data.js +697 -0
- package/dist/collection/components/data/revogr-data.js.map +1 -0
- package/dist/collection/components/data/row-highlight.plugin.js +51 -0
- package/dist/collection/components/data/row-highlight.plugin.js.map +1 -0
- package/dist/collection/components/data/row-renderer.js +16 -0
- package/dist/collection/components/data/row-renderer.js.map +1 -0
- package/dist/collection/components/editors/edit.utils.js +13 -0
- package/dist/collection/components/editors/edit.utils.js.map +1 -0
- package/dist/collection/components/editors/revogr-edit-style.css +16 -0
- package/dist/collection/components/editors/revogr-edit.js +346 -0
- package/dist/collection/components/editors/revogr-edit.js.map +1 -0
- package/dist/collection/components/editors/text-editor.js +74 -0
- package/dist/collection/components/editors/text-editor.js.map +1 -0
- package/dist/collection/components/extra/revogr-extra.js +125 -0
- package/dist/collection/components/extra/revogr-extra.js.map +1 -0
- package/dist/collection/components/header/header-cell-renderer.js +34 -0
- package/dist/collection/components/header/header-cell-renderer.js.map +1 -0
- package/dist/collection/components/header/header-group-renderer.js +25 -0
- package/dist/collection/components/header/header-group-renderer.js.map +1 -0
- package/dist/collection/components/header/header-renderer.js +61 -0
- package/dist/collection/components/header/header-renderer.js.map +1 -0
- package/dist/collection/components/header/resizable.directive.js +237 -0
- package/dist/collection/components/header/resizable.directive.js.map +1 -0
- package/dist/collection/components/header/resizable.element.js +38 -0
- package/dist/collection/components/header/resizable.element.js.map +1 -0
- package/dist/collection/components/header/revogr-header-style.css +144 -0
- package/dist/collection/components/header/revogr-header.js +573 -0
- package/dist/collection/components/header/revogr-header.js.map +1 -0
- package/dist/collection/components/order/order-renderer.js +50 -0
- package/dist/collection/components/order/order-renderer.js.map +1 -0
- package/dist/collection/components/order/order-row.service.js +72 -0
- package/dist/collection/components/order/order-row.service.js.map +1 -0
- package/dist/collection/components/order/revogr-order-editor.js +461 -0
- package/dist/collection/components/order/revogr-order-editor.js.map +1 -0
- package/dist/collection/components/overlay/autofill.service.js +224 -0
- package/dist/collection/components/overlay/autofill.service.js.map +1 -0
- package/dist/collection/components/overlay/keyboard.service.js +158 -0
- package/dist/collection/components/overlay/keyboard.service.js.map +1 -0
- package/dist/collection/components/overlay/revogr-overlay-selection.js +1515 -0
- package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -0
- package/dist/collection/components/overlay/revogr-overlay-style.css +95 -0
- package/dist/collection/components/overlay/selection.utils.js +136 -0
- package/dist/collection/components/overlay/selection.utils.js.map +1 -0
- package/dist/collection/components/revoGrid/grid.helpers.js +33 -0
- package/dist/collection/components/revoGrid/grid.helpers.js.map +1 -0
- package/dist/collection/components/revoGrid/plugin.service.js +81 -0
- package/dist/collection/components/revoGrid/plugin.service.js.map +1 -0
- package/dist/collection/components/revoGrid/revo-grid-style.css +567 -0
- package/dist/collection/components/revoGrid/revo-grid.js +3671 -0
- package/dist/collection/components/revoGrid/revo-grid.js.map +1 -0
- package/dist/collection/components/revoGrid/viewport.helpers.js +49 -0
- package/dist/collection/components/revoGrid/viewport.helpers.js.map +1 -0
- package/dist/collection/components/revoGrid/viewport.resize.service.js +55 -0
- package/dist/collection/components/revoGrid/viewport.resize.service.js.map +1 -0
- package/dist/collection/components/revoGrid/viewport.scrolling.service.js +90 -0
- package/dist/collection/components/revoGrid/viewport.scrolling.service.js.map +1 -0
- package/dist/collection/components/revoGrid/viewport.service.js +237 -0
- package/dist/collection/components/revoGrid/viewport.service.js.map +1 -0
- package/dist/collection/components/rowHeaders/revogr-row-headers.js +291 -0
- package/dist/collection/components/rowHeaders/revogr-row-headers.js.map +1 -0
- package/dist/collection/components/rowHeaders/row-header-render.js +5 -0
- package/dist/collection/components/rowHeaders/row-header-render.js.map +1 -0
- package/dist/collection/components/scroll/revogr-viewport-scroll-style.css +69 -0
- package/dist/collection/components/scroll/revogr-viewport-scroll.js +601 -0
- package/dist/collection/components/scroll/revogr-viewport-scroll.js.map +1 -0
- package/dist/collection/components/scrollable/autohide-scroll.plugin.js +44 -0
- package/dist/collection/components/scrollable/autohide-scroll.plugin.js.map +1 -0
- package/dist/collection/components/scrollable/revogr-scroll-style.css +34 -0
- package/dist/collection/components/scrollable/revogr-scroll-virtual.js +295 -0
- package/dist/collection/components/scrollable/revogr-scroll-virtual.js.map +1 -0
- package/dist/collection/components/selectionFocus/revogr-focus-style.css +7 -0
- package/dist/collection/components/selectionFocus/revogr-focus.js +400 -0
- package/dist/collection/components/selectionFocus/revogr-focus.js.map +1 -0
- package/dist/collection/components/selectionTempRange/revogr-temp-range-style.css +28 -0
- package/dist/collection/components/selectionTempRange/revogr-temp-range.js +171 -0
- package/dist/collection/components/selectionTempRange/revogr-temp-range.js.map +1 -0
- package/dist/collection/components/vnode/vnode-converter.js +84 -0
- package/dist/collection/components/vnode/vnode-converter.js.map +1 -0
- package/dist/collection/components/vnode/vnode.utils.js +18 -0
- package/dist/collection/components/vnode/vnode.utils.js.map +1 -0
- package/dist/collection/global/global.js +19 -0
- package/dist/collection/global/global.js.map +1 -0
- package/dist/collection/index.js +13 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/plugins/add-rows-on-paste.plugin.js +40 -0
- package/dist/collection/plugins/add-rows-on-paste.plugin.js.map +1 -0
- package/dist/collection/plugins/base.plugin.js +90 -0
- package/dist/collection/plugins/base.plugin.js.map +1 -0
- package/dist/collection/plugins/column.auto-size.plugin.js +225 -0
- package/dist/collection/plugins/column.auto-size.plugin.js.map +1 -0
- package/dist/collection/plugins/column.stretch.plugin.js +96 -0
- package/dist/collection/plugins/column.stretch.plugin.js.map +1 -0
- package/dist/collection/plugins/dispatcher.js +40 -0
- package/dist/collection/plugins/dispatcher.js.map +1 -0
- package/dist/collection/plugins/export/csv.js +72 -0
- package/dist/collection/plugins/export/csv.js.map +1 -0
- package/dist/collection/plugins/export/export.plugin.js +157 -0
- package/dist/collection/plugins/export/export.plugin.js.map +1 -0
- package/dist/collection/plugins/export/types.js +2 -0
- package/dist/collection/plugins/export/types.js.map +1 -0
- package/dist/collection/plugins/filter/conditions/equal.js +21 -0
- package/dist/collection/plugins/filter/conditions/equal.js.map +1 -0
- package/dist/collection/plugins/filter/conditions/number/greaterThan.js +14 -0
- package/dist/collection/plugins/filter/conditions/number/greaterThan.js.map +1 -0
- package/dist/collection/plugins/filter/conditions/number/greaterThanOrEqual.js +11 -0
- package/dist/collection/plugins/filter/conditions/number/greaterThanOrEqual.js.map +1 -0
- package/dist/collection/plugins/filter/conditions/number/lessThan.js +16 -0
- package/dist/collection/plugins/filter/conditions/number/lessThan.js.map +1 -0
- package/dist/collection/plugins/filter/conditions/number/lessThanOrEqual.js +11 -0
- package/dist/collection/plugins/filter/conditions/number/lessThanOrEqual.js.map +1 -0
- package/dist/collection/plugins/filter/conditions/set.js +7 -0
- package/dist/collection/plugins/filter/conditions/set.js.map +1 -0
- package/dist/collection/plugins/filter/conditions/string/beginswith.js +21 -0
- package/dist/collection/plugins/filter/conditions/string/beginswith.js.map +1 -0
- package/dist/collection/plugins/filter/conditions/string/contains.js +25 -0
- package/dist/collection/plugins/filter/conditions/string/contains.js.map +1 -0
- package/dist/collection/plugins/filter/filter.button.js +28 -0
- package/dist/collection/plugins/filter/filter.button.js.map +1 -0
- package/dist/collection/plugins/filter/filter.indexed.js +49 -0
- package/dist/collection/plugins/filter/filter.indexed.js.map +1 -0
- package/dist/collection/plugins/filter/filter.panel.js +610 -0
- package/dist/collection/plugins/filter/filter.panel.js.map +1 -0
- package/dist/collection/plugins/filter/filter.plugin.js +388 -0
- package/dist/collection/plugins/filter/filter.plugin.js.map +1 -0
- package/dist/collection/plugins/filter/filter.style.css +165 -0
- package/dist/collection/plugins/filter/filter.types.js +9 -0
- package/dist/collection/plugins/filter/filter.types.js.map +1 -0
- package/dist/collection/plugins/groupingRow/grouping.const.js +16 -0
- package/dist/collection/plugins/groupingRow/grouping.const.js.map +1 -0
- package/dist/collection/plugins/groupingRow/grouping.row.expand.service.js +79 -0
- package/dist/collection/plugins/groupingRow/grouping.row.expand.service.js.map +1 -0
- package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +245 -0
- package/dist/collection/plugins/groupingRow/grouping.row.plugin.js.map +1 -0
- package/dist/collection/plugins/groupingRow/grouping.row.renderer.js +38 -0
- package/dist/collection/plugins/groupingRow/grouping.row.renderer.js.map +1 -0
- package/dist/collection/plugins/groupingRow/grouping.row.types.js +2 -0
- package/dist/collection/plugins/groupingRow/grouping.row.types.js.map +1 -0
- package/dist/collection/plugins/groupingRow/grouping.service.js +178 -0
- package/dist/collection/plugins/groupingRow/grouping.service.js.map +1 -0
- package/dist/collection/plugins/groupingRow/grouping.trimmed.service.js +61 -0
- package/dist/collection/plugins/groupingRow/grouping.trimmed.service.js.map +1 -0
- package/dist/collection/plugins/index.js +15 -0
- package/dist/collection/plugins/index.js.map +1 -0
- package/dist/collection/plugins/moveColumn/column.drag.plugin.js +175 -0
- package/dist/collection/plugins/moveColumn/column.drag.plugin.js.map +1 -0
- package/dist/collection/plugins/moveColumn/order-column.handler.js +71 -0
- package/dist/collection/plugins/moveColumn/order-column.handler.js.map +1 -0
- package/dist/collection/plugins/rtl/rtl.plugin.js +110 -0
- package/dist/collection/plugins/rtl/rtl.plugin.js.map +1 -0
- package/dist/collection/plugins/sorting/sorting.func.js +82 -0
- package/dist/collection/plugins/sorting/sorting.func.js.map +1 -0
- package/dist/collection/plugins/sorting/sorting.plugin.js +224 -0
- package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -0
- package/dist/collection/plugins/sorting/sorting.sign.js +9 -0
- package/dist/collection/plugins/sorting/sorting.sign.js.map +1 -0
- package/dist/collection/plugins/sorting/sorting.types.js +2 -0
- package/dist/collection/plugins/sorting/sorting.types.js.map +1 -0
- package/dist/collection/plugins/wcag/index.js +84 -0
- package/dist/collection/plugins/wcag/index.js.map +1 -0
- package/dist/collection/serve/controller.js +344 -0
- package/dist/collection/serve/data.js +201 -0
- package/dist/collection/services/cell.helpers.js +12 -0
- package/dist/collection/services/cell.helpers.js.map +1 -0
- package/dist/collection/services/column.data.provider.js +119 -0
- package/dist/collection/services/column.data.provider.js.map +1 -0
- package/dist/collection/services/data.provider.js +89 -0
- package/dist/collection/services/data.provider.js.map +1 -0
- package/dist/collection/services/dimension.provider.js +176 -0
- package/dist/collection/services/dimension.provider.js.map +1 -0
- package/dist/collection/services/local.scroll.service.js +124 -0
- package/dist/collection/services/local.scroll.service.js.map +1 -0
- package/dist/collection/services/local.scroll.timer.js +81 -0
- package/dist/collection/services/local.scroll.timer.js.map +1 -0
- package/dist/collection/services/selection.store.connector.js +307 -0
- package/dist/collection/services/selection.store.connector.js.map +1 -0
- package/dist/collection/services/viewport.provider.js +17 -0
- package/dist/collection/services/viewport.provider.js.map +1 -0
- package/dist/collection/store/dataSource/data.proxy.js +45 -0
- package/dist/collection/store/dataSource/data.proxy.js.map +1 -0
- package/dist/collection/store/dataSource/data.store.js +144 -0
- package/dist/collection/store/dataSource/data.store.js.map +1 -0
- package/dist/collection/store/dataSource/index.js +7 -0
- package/dist/collection/store/dataSource/index.js.map +1 -0
- package/dist/collection/store/dataSource/trimmed.plugin.js +34 -0
- package/dist/collection/store/dataSource/trimmed.plugin.js.map +1 -0
- package/dist/collection/store/dimension/dimension.helpers.js +101 -0
- package/dist/collection/store/dimension/dimension.helpers.js.map +1 -0
- package/dist/collection/store/dimension/dimension.recalculate.plugin.js +35 -0
- package/dist/collection/store/dimension/dimension.recalculate.plugin.js.map +1 -0
- package/dist/collection/store/dimension/dimension.store.js +109 -0
- package/dist/collection/store/dimension/dimension.store.js.map +1 -0
- package/dist/collection/store/dimension/dimension.trim.plugin.js +61 -0
- package/dist/collection/store/dimension/dimension.trim.plugin.js.map +1 -0
- package/dist/collection/store/dimension/index.js +6 -0
- package/dist/collection/store/dimension/index.js.map +1 -0
- package/dist/collection/store/index.js +17 -0
- package/dist/collection/store/index.js.map +1 -0
- package/dist/collection/store/selection/index.js +6 -0
- package/dist/collection/store/selection/index.js.map +1 -0
- package/dist/collection/store/selection/selection.helpers.js +53 -0
- package/dist/collection/store/selection/selection.helpers.js.map +1 -0
- package/dist/collection/store/selection/selection.store.js +85 -0
- package/dist/collection/store/selection/selection.store.js.map +1 -0
- package/dist/collection/store/vp/index.js +6 -0
- package/dist/collection/store/vp/index.js.map +1 -0
- package/dist/collection/store/vp/viewport.helpers.js +251 -0
- package/dist/collection/store/vp/viewport.helpers.js.map +1 -0
- package/dist/collection/store/vp/viewport.store.js +151 -0
- package/dist/collection/store/vp/viewport.store.js.map +1 -0
- package/dist/collection/themeManager/theme.compact.js +9 -0
- package/dist/collection/themeManager/theme.compact.js.map +1 -0
- package/dist/collection/themeManager/theme.default.js +9 -0
- package/dist/collection/themeManager/theme.default.js.map +1 -0
- package/dist/collection/themeManager/theme.material.js +9 -0
- package/dist/collection/themeManager/theme.material.js.map +1 -0
- package/dist/collection/themeManager/theme.service.js +53 -0
- package/dist/collection/themeManager/theme.service.js.map +1 -0
- package/dist/collection/types/dimension.js +2 -0
- package/dist/collection/types/dimension.js.map +1 -0
- package/dist/collection/types/events.js +118 -0
- package/dist/collection/types/events.js.map +1 -0
- package/dist/collection/types/index.js +12 -0
- package/dist/collection/types/index.js.map +1 -0
- package/dist/collection/types/interfaces.js +2 -0
- package/dist/collection/types/interfaces.js.map +1 -0
- package/dist/collection/types/plugin.js +2 -0
- package/dist/collection/types/plugin.js.map +1 -0
- package/dist/collection/types/plugin.types.js +2 -0
- package/dist/collection/types/plugin.types.js.map +1 -0
- package/dist/collection/types/selection.js +2 -0
- package/dist/collection/types/selection.js.map +1 -0
- package/dist/collection/types/theme.js +2 -0
- package/dist/collection/types/theme.js.map +1 -0
- package/dist/collection/types/viewport.interfaces.js +2 -0
- package/dist/collection/types/viewport.interfaces.js.map +1 -0
- package/dist/collection/utils/browser.js +7 -0
- package/dist/collection/utils/browser.js.map +1 -0
- package/dist/collection/utils/closest.polifill.js +22 -0
- package/dist/collection/utils/closest.polifill.js.map +1 -0
- package/dist/collection/utils/column.utils.js +153 -0
- package/dist/collection/utils/column.utils.js.map +1 -0
- package/dist/collection/utils/consts.js +26 -0
- package/dist/collection/utils/consts.js.map +1 -0
- package/dist/collection/utils/events.js +39 -0
- package/dist/collection/utils/events.js.map +1 -0
- package/dist/collection/utils/header.utils.js +24 -0
- package/dist/collection/utils/header.utils.js.map +1 -0
- package/dist/collection/utils/index.js +140 -0
- package/dist/collection/utils/index.js.map +1 -0
- package/dist/collection/utils/key.codes.js +80 -0
- package/dist/collection/utils/key.codes.js.map +1 -0
- package/dist/collection/utils/key.utils.js +90 -0
- package/dist/collection/utils/key.utils.js.map +1 -0
- package/dist/collection/utils/mobile.js +7 -0
- package/dist/collection/utils/mobile.js.map +1 -0
- package/dist/collection/utils/platform.js +9 -0
- package/dist/collection/utils/platform.js.map +1 -0
- package/dist/collection/utils/row-header-utils.js +9 -0
- package/dist/collection/utils/row-header-utils.js.map +1 -0
- package/dist/collection/utils/store.types.js +2 -0
- package/dist/collection/utils/store.types.js.map +1 -0
- package/dist/collection/utils/store.utils.js +15 -0
- package/dist/collection/utils/store.utils.js.map +1 -0
- package/dist/esm/app-globals-FBz64o-g.js +14 -0
- package/dist/esm/app-globals-FBz64o-g.js.map +1 -0
- package/dist/esm/cell-renderer-Ca_PCGjJ.js +98 -0
- package/dist/esm/cell-renderer-Ca_PCGjJ.js.map +1 -0
- package/dist/esm/column.drag.plugin-BtuUyB-2.js +2528 -0
- package/dist/esm/column.drag.plugin-BtuUyB-2.js.map +1 -0
- package/dist/esm/column.service-CTqFIQUy.js +1343 -0
- package/dist/esm/column.service-CTqFIQUy.js.map +1 -0
- package/dist/esm/data.store-B-lvmoFH.js +3553 -0
- package/dist/esm/data.store-B-lvmoFH.js.map +1 -0
- package/dist/esm/debounce-DTUQ1fY7.js +488 -0
- package/dist/esm/debounce-DTUQ1fY7.js.map +1 -0
- package/dist/esm/edit.utils-CyCANCLB.js +103 -0
- package/dist/esm/edit.utils-CyCANCLB.js.map +1 -0
- package/dist/esm/events-CKtYJJSv.js +43 -0
- package/dist/esm/events-CKtYJJSv.js.map +1 -0
- package/dist/esm/filter.button-CjABZQgg.js +39 -0
- package/dist/esm/filter.button-CjABZQgg.js.map +1 -0
- package/dist/esm/header-cell-renderer-DnjpJuXq.js +351 -0
- package/dist/esm/header-cell-renderer-DnjpJuXq.js.map +1 -0
- package/dist/esm/index-BAoInZ4V.js +2519 -0
- package/dist/esm/index-BAoInZ4V.js.map +1 -0
- package/dist/esm/index.js +181 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/revo-grid.entry.js +2185 -0
- package/dist/esm/revo-grid.entry.js.map +1 -0
- package/dist/esm/revo-grid.js +27 -0
- package/dist/esm/revo-grid.js.map +1 -0
- package/dist/esm/revogr-attribution.revogr-extra.revogr-focus.revogr-overlay-selection.revogr-row-headers.revogr-scroll-virtual.revogr-temp-range.entry.js.map +1 -0
- package/dist/esm/revogr-attribution_7.entry.js +1455 -0
- package/dist/esm/revogr-attribution_7.entry.js.map +1 -0
- package/dist/esm/revogr-clipboard.revogr-edit.revogr-order-editor.entry.js.map +1 -0
- package/dist/esm/revogr-clipboard_3.entry.js +452 -0
- package/dist/esm/revogr-clipboard_3.entry.js.map +1 -0
- package/dist/esm/revogr-data.revogr-header.revogr-viewport-scroll.vnode-html.entry.js.map +1 -0
- package/dist/esm/revogr-data_4.entry.js +943 -0
- package/dist/esm/revogr-data_4.entry.js.map +1 -0
- package/dist/esm/revogr-filter-panel.entry.js +380 -0
- package/dist/esm/revogr-filter-panel.entry.js.map +1 -0
- package/dist/esm/row-header-utils-vnoLGj5A.js +407 -0
- package/dist/esm/row-header-utils-vnoLGj5A.js.map +1 -0
- package/dist/esm/text-editor-Cp7lwBZi.js +79 -0
- package/dist/esm/text-editor-Cp7lwBZi.js.map +1 -0
- package/dist/esm/throttle-DiUrHjcY.js +273 -0
- package/dist/esm/throttle-DiUrHjcY.js.map +1 -0
- package/dist/esm/viewport.helpers-Ch4AQMMg.js +53 -0
- package/dist/esm/viewport.helpers-Ch4AQMMg.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/revo-grid/app-globals-FBz64o-g.js +14 -0
- package/dist/revo-grid/app-globals-FBz64o-g.js.map +1 -0
- package/dist/revo-grid/cell-renderer-Ca_PCGjJ.js +98 -0
- package/dist/revo-grid/cell-renderer-Ca_PCGjJ.js.map +1 -0
- package/dist/revo-grid/column.drag.plugin-BtuUyB-2.js +2528 -0
- package/dist/revo-grid/column.drag.plugin-BtuUyB-2.js.map +1 -0
- package/dist/revo-grid/column.service-CTqFIQUy.js +1343 -0
- package/dist/revo-grid/column.service-CTqFIQUy.js.map +1 -0
- package/dist/revo-grid/data.store-B-lvmoFH.js +3553 -0
- package/dist/revo-grid/data.store-B-lvmoFH.js.map +1 -0
- package/dist/revo-grid/debounce-DTUQ1fY7.js +488 -0
- package/dist/revo-grid/debounce-DTUQ1fY7.js.map +1 -0
- package/dist/revo-grid/edit.utils-CyCANCLB.js +103 -0
- package/dist/revo-grid/edit.utils-CyCANCLB.js.map +1 -0
- package/dist/revo-grid/events-CKtYJJSv.js +43 -0
- package/dist/revo-grid/events-CKtYJJSv.js.map +1 -0
- package/dist/revo-grid/filter.button-CjABZQgg.js +39 -0
- package/dist/revo-grid/filter.button-CjABZQgg.js.map +1 -0
- package/dist/revo-grid/header-cell-renderer-DnjpJuXq.js +351 -0
- package/dist/revo-grid/header-cell-renderer-DnjpJuXq.js.map +1 -0
- package/dist/revo-grid/index-BAoInZ4V.js +2490 -0
- package/dist/revo-grid/index-BAoInZ4V.js.map +1 -0
- package/dist/revo-grid/index.esm.js +181 -0
- package/dist/revo-grid/index.esm.js.map +1 -0
- package/dist/revo-grid/loader.esm.js.map +1 -0
- package/dist/revo-grid/revo-grid.entry.esm.js.map +1 -0
- package/dist/revo-grid/revo-grid.entry.js +2185 -0
- package/dist/revo-grid/revo-grid.entry.js.map +1 -0
- package/dist/revo-grid/revo-grid.esm.js +27 -0
- package/dist/revo-grid/revo-grid.esm.js.map +1 -0
- package/dist/revo-grid/revogr-attribution.revogr-extra.revogr-focus.revogr-overlay-selection.revogr-row-headers.revogr-scroll-virtual.revogr-temp-range.entry.esm.js.map +1 -0
- package/dist/revo-grid/revogr-attribution_7.entry.js +1455 -0
- package/dist/revo-grid/revogr-attribution_7.entry.js.map +1 -0
- package/dist/revo-grid/revogr-clipboard.revogr-edit.revogr-order-editor.entry.esm.js.map +1 -0
- package/dist/revo-grid/revogr-clipboard_3.entry.js +452 -0
- package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -0
- package/dist/revo-grid/revogr-data.revogr-header.revogr-viewport-scroll.vnode-html.entry.esm.js.map +1 -0
- package/dist/revo-grid/revogr-data_4.entry.js +943 -0
- package/dist/revo-grid/revogr-data_4.entry.js.map +1 -0
- package/dist/revo-grid/revogr-filter-panel.entry.esm.js.map +1 -0
- package/dist/revo-grid/revogr-filter-panel.entry.js +380 -0
- package/dist/revo-grid/revogr-filter-panel.entry.js.map +1 -0
- package/dist/revo-grid/row-header-utils-vnoLGj5A.js +407 -0
- package/dist/revo-grid/row-header-utils-vnoLGj5A.js.map +1 -0
- package/dist/revo-grid/text-editor-Cp7lwBZi.js +79 -0
- package/dist/revo-grid/text-editor-Cp7lwBZi.js.map +1 -0
- package/dist/revo-grid/throttle-DiUrHjcY.js +273 -0
- package/dist/revo-grid/throttle-DiUrHjcY.js.map +1 -0
- package/dist/revo-grid/viewport.helpers-Ch4AQMMg.js +53 -0
- package/dist/revo-grid/viewport.helpers-Ch4AQMMg.js.map +1 -0
- package/dist/types/components/attribution/revogr-attribution.d.ts +12 -0
- package/dist/types/components/clipboard/revogr-clipboard.d.ts +89 -0
- package/dist/types/components/data/cell-renderer.d.ts +12 -0
- package/dist/types/components/data/column.service.d.ts +61 -0
- package/dist/types/components/data/revogr-data.d.ts +107 -0
- package/dist/types/components/data/row-highlight.plugin.d.ts +10 -0
- package/dist/types/components/data/row-renderer.d.ts +12 -0
- package/dist/types/components/editors/edit.utils.d.ts +3 -0
- package/dist/types/components/editors/revogr-edit.d.ts +63 -0
- package/dist/types/components/editors/text-editor.d.ts +43 -0
- package/dist/types/components/extra/revogr-extra.d.ts +38 -0
- package/dist/types/components/header/header-cell-renderer.d.ts +9 -0
- package/dist/types/components/header/header-group-renderer.d.ts +15 -0
- package/dist/types/components/header/header-renderer.d.ts +16 -0
- package/dist/types/components/header/resizable.directive.d.ts +55 -0
- package/dist/types/components/header/resizable.element.d.ts +5 -0
- package/dist/types/components/header/revogr-header.d.ts +90 -0
- package/dist/types/components/order/order-renderer.d.ts +29 -0
- package/dist/types/components/order/order-row.service.d.ts +27 -0
- package/dist/types/components/order/revogr-order-editor.d.ts +56 -0
- package/dist/types/components/overlay/autofill.service.d.ts +80 -0
- package/dist/types/components/overlay/keyboard.service.d.ts +28 -0
- package/dist/types/components/overlay/revogr-overlay-selection.d.ts +278 -0
- package/dist/types/components/overlay/selection.utils.d.ts +47 -0
- package/dist/types/components/revoGrid/grid.helpers.d.ts +17 -0
- package/dist/types/components/revoGrid/plugin.service.d.ts +37 -0
- package/dist/types/components/revoGrid/revo-grid.d.ts +686 -0
- package/dist/types/components/revoGrid/viewport.helpers.d.ts +39 -0
- package/dist/types/components/revoGrid/viewport.resize.service.d.ts +17 -0
- package/dist/types/components/revoGrid/viewport.scrolling.service.d.ts +20 -0
- package/dist/types/components/revoGrid/viewport.service.d.ts +59 -0
- package/dist/types/components/rowHeaders/revogr-row-headers.d.ts +51 -0
- package/dist/types/components/rowHeaders/row-header-render.d.ts +9 -0
- package/dist/types/components/scroll/revogr-viewport-scroll.d.ts +117 -0
- package/dist/types/components/scrollable/autohide-scroll.plugin.d.ts +22 -0
- package/dist/types/components/scrollable/revogr-scroll-virtual.d.ts +43 -0
- package/dist/types/components/selectionFocus/revogr-focus.d.ts +58 -0
- package/dist/types/components/selectionTempRange/revogr-temp-range.d.ts +28 -0
- package/dist/types/components/vnode/vnode-converter.d.ts +19 -0
- package/dist/types/components/vnode/vnode.utils.d.ts +9 -0
- package/dist/types/components.d.ts +2583 -0
- package/dist/types/global/global.d.ts +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/plugins/add-rows-on-paste.plugin.d.ts +14 -0
- package/dist/types/plugins/base.plugin.d.ts +51 -0
- package/dist/types/plugins/column.auto-size.plugin.d.ts +55 -0
- package/dist/types/plugins/column.stretch.plugin.d.ts +20 -0
- package/dist/types/plugins/dispatcher.d.ts +20 -0
- package/dist/types/plugins/export/csv.d.ts +9 -0
- package/dist/types/plugins/export/export.plugin.d.ts +24 -0
- package/dist/types/plugins/export/types.d.ts +23 -0
- package/dist/types/plugins/filter/conditions/equal.d.ts +4 -0
- package/dist/types/plugins/filter/conditions/number/greaterThan.d.ts +3 -0
- package/dist/types/plugins/filter/conditions/number/greaterThanOrEqual.d.ts +3 -0
- package/dist/types/plugins/filter/conditions/number/lessThan.d.ts +3 -0
- package/dist/types/plugins/filter/conditions/number/lessThanOrEqual.d.ts +3 -0
- package/dist/types/plugins/filter/conditions/set.d.ts +4 -0
- package/dist/types/plugins/filter/conditions/string/beginswith.d.ts +3 -0
- package/dist/types/plugins/filter/conditions/string/contains.d.ts +4 -0
- package/dist/types/plugins/filter/filter.button.d.ts +14 -0
- package/dist/types/plugins/filter/filter.indexed.d.ts +20 -0
- package/dist/types/plugins/filter/filter.panel.d.ts +53 -0
- package/dist/types/plugins/filter/filter.plugin.d.ts +73 -0
- package/dist/types/plugins/filter/filter.types.d.ts +129 -0
- package/dist/types/plugins/groupingRow/grouping.const.d.ts +12 -0
- package/dist/types/plugins/groupingRow/grouping.row.expand.service.d.ts +15 -0
- package/dist/types/plugins/groupingRow/grouping.row.plugin.d.ts +39 -0
- package/dist/types/plugins/groupingRow/grouping.row.renderer.d.ts +6 -0
- package/dist/types/plugins/groupingRow/grouping.row.types.d.ts +103 -0
- package/dist/types/plugins/groupingRow/grouping.service.d.ts +36 -0
- package/dist/types/plugins/groupingRow/grouping.trimmed.service.d.ts +10 -0
- package/dist/types/plugins/index.d.ts +11 -0
- package/dist/types/plugins/moveColumn/column.drag.plugin.d.ts +42 -0
- package/dist/types/plugins/moveColumn/order-column.handler.d.ts +16 -0
- package/dist/types/plugins/rtl/rtl.plugin.d.ts +37 -0
- package/dist/types/plugins/sorting/sorting.func.d.ts +9 -0
- package/dist/types/plugins/sorting/sorting.plugin.d.ts +48 -0
- package/dist/types/plugins/sorting/sorting.sign.d.ts +6 -0
- package/dist/types/plugins/sorting/sorting.types.d.ts +14 -0
- package/dist/types/plugins/wcag/index.d.ts +26 -0
- package/dist/types/services/cell.helpers.d.ts +2 -0
- package/dist/types/services/column.data.provider.d.ts +27 -0
- package/dist/types/services/data.provider.d.ts +36 -0
- package/dist/types/services/dimension.provider.d.ts +66 -0
- package/dist/types/services/local.scroll.service.d.ts +36 -0
- package/dist/types/services/local.scroll.timer.d.ts +32 -0
- package/dist/types/services/selection.store.connector.d.ts +79 -0
- package/dist/types/services/viewport.provider.d.ts +7 -0
- package/dist/types/stencil-public-runtime.d.ts +1709 -0
- package/dist/types/store/dataSource/data.proxy.d.ts +14 -0
- package/dist/types/store/dataSource/data.store.d.ts +74 -0
- package/dist/types/store/dataSource/index.d.ts +3 -0
- package/dist/types/store/dataSource/trimmed.plugin.d.ts +12 -0
- package/dist/types/store/dimension/dimension.helpers.d.ts +24 -0
- package/dist/types/store/dimension/dimension.recalculate.plugin.d.ts +9 -0
- package/dist/types/store/dimension/dimension.store.d.ts +21 -0
- package/dist/types/store/dimension/dimension.trim.plugin.d.ts +13 -0
- package/dist/types/store/dimension/index.d.ts +2 -0
- package/dist/types/store/index.d.ts +8 -0
- package/dist/types/store/selection/index.d.ts +2 -0
- package/dist/types/store/selection/selection.helpers.d.ts +6 -0
- package/dist/types/store/selection/selection.store.d.ts +22 -0
- package/dist/types/store/vp/index.d.ts +7 -0
- package/dist/types/store/vp/viewport.helpers.d.ts +54 -0
- package/dist/types/store/vp/viewport.store.d.ts +26 -0
- package/dist/types/themeManager/theme.compact.d.ts +4 -0
- package/dist/types/themeManager/theme.default.d.ts +4 -0
- package/dist/types/themeManager/theme.material.d.ts +4 -0
- package/dist/types/themeManager/theme.service.d.ts +13 -0
- package/dist/types/types/dimension.d.ts +8 -0
- package/dist/types/types/events.d.ts +2 -0
- package/dist/types/types/index.d.ts +8 -0
- package/dist/types/types/interfaces.d.ts +768 -0
- package/dist/types/types/plugin.d.ts +9 -0
- package/dist/types/types/plugin.types.d.ts +48 -0
- package/dist/types/types/selection.d.ts +178 -0
- package/dist/types/types/theme.d.ts +7 -0
- package/dist/types/types/viewport.interfaces.d.ts +45 -0
- package/dist/types/utils/browser.d.ts +1 -0
- package/dist/types/utils/closest.polifill.d.ts +0 -0
- package/dist/types/utils/column.utils.d.ts +52 -0
- package/dist/types/utils/consts.d.ts +22 -0
- package/dist/types/utils/events.d.ts +5 -0
- package/dist/types/utils/header.utils.d.ts +2 -0
- package/dist/types/utils/index.d.ts +32 -0
- package/dist/types/utils/key.codes.d.ts +73 -0
- package/dist/types/utils/key.utils.d.ts +13 -0
- package/dist/types/utils/mobile.d.ts +1 -0
- package/dist/types/utils/platform.d.ts +4 -0
- package/dist/types/utils/row-header-utils.d.ts +2 -0
- package/dist/types/utils/store.types.d.ts +97 -0
- package/dist/types/utils/store.utils.d.ts +10 -0
- package/hydrate/index.d.ts +273 -0
- package/hydrate/index.js +33890 -0
- package/hydrate/index.mjs +33882 -0
- package/hydrate/package.json +12 -0
- package/loader/cdn.js +4 -0
- package/loader/index.cjs.js +4 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +4 -0
- package/loader/index.js +5 -0
- package/package.json +101 -0
- package/react/dist/index.d.ts +6191 -0
- package/react/dist/react-datagrid.js +260 -0
- package/react/dist/react-datagrid.umd.cjs +272 -0
- package/standalone/column.service.js +1345 -0
- package/standalone/column.service.js.map +1 -0
- package/standalone/consts.js +30 -0
- package/standalone/consts.js.map +1 -0
- package/standalone/data.store.js +3099 -0
- package/standalone/data.store.js.map +1 -0
- package/standalone/debounce.js +215 -0
- package/standalone/debounce.js.map +1 -0
- package/standalone/dimension.helpers.js +229 -0
- package/standalone/dimension.helpers.js.map +1 -0
- package/standalone/filter.button.js +39 -0
- package/standalone/filter.button.js.map +1 -0
- package/standalone/index.d.ts +68 -0
- package/standalone/index.js +217 -0
- package/standalone/index.js.map +1 -0
- package/standalone/index2.js +140 -0
- package/standalone/index2.js.map +1 -0
- package/standalone/local.scroll.timer.js +207 -0
- package/standalone/local.scroll.timer.js.map +1 -0
- package/standalone/platform.js +90 -0
- package/standalone/platform.js.map +1 -0
- package/standalone/revo-grid.d.ts +11 -0
- package/standalone/revo-grid.js +4884 -0
- package/standalone/revo-grid.js.map +1 -0
- package/standalone/revogr-attribution.d.ts +11 -0
- package/standalone/revogr-attribution.js +12 -0
- package/standalone/revogr-attribution.js.map +1 -0
- package/standalone/revogr-attribution2.js +32 -0
- package/standalone/revogr-attribution2.js.map +1 -0
- package/standalone/revogr-clipboard.d.ts +11 -0
- package/standalone/revogr-clipboard.js +12 -0
- package/standalone/revogr-clipboard.js.map +1 -0
- package/standalone/revogr-clipboard2.js +164 -0
- package/standalone/revogr-clipboard2.js.map +1 -0
- package/standalone/revogr-data.d.ts +11 -0
- package/standalone/revogr-data.js +12 -0
- package/standalone/revogr-data.js.map +1 -0
- package/standalone/revogr-data2.js +378 -0
- package/standalone/revogr-data2.js.map +1 -0
- package/standalone/revogr-edit.d.ts +11 -0
- package/standalone/revogr-edit.js +12 -0
- package/standalone/revogr-edit.js.map +1 -0
- package/standalone/revogr-edit2.js +334 -0
- package/standalone/revogr-edit2.js.map +1 -0
- package/standalone/revogr-extra.d.ts +11 -0
- package/standalone/revogr-extra.js +12 -0
- package/standalone/revogr-extra.js.map +1 -0
- package/standalone/revogr-extra2.js +73 -0
- package/standalone/revogr-extra2.js.map +1 -0
- package/standalone/revogr-filter-panel.d.ts +11 -0
- package/standalone/revogr-filter-panel.js +411 -0
- package/standalone/revogr-filter-panel.js.map +1 -0
- package/standalone/revogr-focus.d.ts +11 -0
- package/standalone/revogr-focus.js +12 -0
- package/standalone/revogr-focus.js.map +1 -0
- package/standalone/revogr-focus2.js +112 -0
- package/standalone/revogr-focus2.js.map +1 -0
- package/standalone/revogr-header.d.ts +11 -0
- package/standalone/revogr-header.js +12 -0
- package/standalone/revogr-header.js.map +1 -0
- package/standalone/revogr-header2.js +707 -0
- package/standalone/revogr-header2.js.map +1 -0
- package/standalone/revogr-order-editor.d.ts +11 -0
- package/standalone/revogr-order-editor.js +12 -0
- package/standalone/revogr-order-editor.js.map +1 -0
- package/standalone/revogr-order-editor2.js +201 -0
- package/standalone/revogr-order-editor2.js.map +1 -0
- package/standalone/revogr-overlay-selection.d.ts +11 -0
- package/standalone/revogr-overlay-selection.js +12 -0
- package/standalone/revogr-overlay-selection.js.map +1 -0
- package/standalone/revogr-overlay-selection2.js +972 -0
- package/standalone/revogr-overlay-selection2.js.map +1 -0
- package/standalone/revogr-row-headers.d.ts +11 -0
- package/standalone/revogr-row-headers.js +12 -0
- package/standalone/revogr-row-headers.js.map +1 -0
- package/standalone/revogr-row-headers2.js +520 -0
- package/standalone/revogr-row-headers2.js.map +1 -0
- package/standalone/revogr-scroll-virtual.d.ts +11 -0
- package/standalone/revogr-scroll-virtual.js +12 -0
- package/standalone/revogr-scroll-virtual.js.map +1 -0
- package/standalone/revogr-scroll-virtual2.js +184 -0
- package/standalone/revogr-scroll-virtual2.js.map +1 -0
- package/standalone/revogr-temp-range.d.ts +11 -0
- package/standalone/revogr-temp-range.js +12 -0
- package/standalone/revogr-temp-range.js.map +1 -0
- package/standalone/revogr-temp-range2.js +93 -0
- package/standalone/revogr-temp-range2.js.map +1 -0
- package/standalone/revogr-viewport-scroll.d.ts +11 -0
- package/standalone/revogr-viewport-scroll.js +12 -0
- package/standalone/revogr-viewport-scroll.js.map +1 -0
- package/standalone/revogr-viewport-scroll2.js +421 -0
- package/standalone/revogr-viewport-scroll2.js.map +1 -0
- package/standalone/selection.utils.js +179 -0
- package/standalone/selection.utils.js.map +1 -0
- package/standalone/throttle.js +75 -0
- package/standalone/throttle.js.map +1 -0
- package/standalone/toNumber.js +282 -0
- package/standalone/toNumber.js.map +1 -0
- package/standalone/vnode-converter.js +46 -0
- package/standalone/vnode-converter.js.map +1 -0
- package/standalone/vnode-html.d.ts +11 -0
- package/standalone/vnode-html.js +12 -0
- package/standalone/vnode-html.js.map +1 -0
|
@@ -0,0 +1,4884 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Built by LevelSkill.Pro
|
|
3
|
+
*/
|
|
4
|
+
import { h, proxyCustomElement, HTMLElement as HTMLElement$1, createEvent, Host } from '@stencil/core/internal/client';
|
|
5
|
+
import { H as reduce, I as baseEach, A as getColumnType, J as columnTypes, K as toInteger, s as isGrouping, r as getGroupingName, L as rowTypes, z as getCellDataParsed, y as getCellRaw, F as getColumnByProp, f as GROUP_EXPANDED, v as getParsedGroup, w as isSameGroup, G as GROUP_DEPTH, d as PSEUDO_GROUP_ITEM_VALUE, b as PSEUDO_GROUP_ITEM_ID, m as GROUPING_ROW_TYPE, o as getSource, e as PSEUDO_GROUP_COLUMN, q as gatherGrouping, l as GROUP_EXPAND_EVENT, t as isGroupingColumn, p as getExpanded, C as isColGrouping, M as isRowType, B as getColumnSizes, N as EMPTY_INDEX, D as getColumns, O as SelectionStoreConnector } from './column.service.js';
|
|
6
|
+
import { j as createStore, i as setStore, k as identity, l as isArray, b as getSourceItem, m as baseProperty, n as isArrayLike, o as getTag, q as baseKeys, g as getPhysical, e as setItems, D as DataStore, f as getSourceItemVirtualIndexByProp, d as setSourceByPhysicalIndex, s as setSourceByVirtualIndex, a as getVisibleSourceItem, h as gatherTrimmedItems } from './data.store.js';
|
|
7
|
+
import { d as debounce } from './debounce.js';
|
|
8
|
+
import { R as RESIZE_INTERVAL } from './consts.js';
|
|
9
|
+
import { c as calculateDimensionData, g as getItemByPosition, a as getItemByIndex } from './dimension.helpers.js';
|
|
10
|
+
import './platform.js';
|
|
11
|
+
import { f as calculateRowHeaderSize, V as ViewportStore, h as defineCustomElement$6 } from './revogr-row-headers2.js';
|
|
12
|
+
import { g as getScrollbarSize, t as timeout, c as checkIsRightClick } from './index2.js';
|
|
13
|
+
import { b as FILTER_PROP, i as isFilterBtn } from './filter.button.js';
|
|
14
|
+
import { i as isObjectLike, b as baseGetTag } from './toNumber.js';
|
|
15
|
+
import { v as viewportDataPartition, F as FOOTER_SLOT, C as CONTENT_SLOT, H as HEADER_SLOT, D as DATA_SLOT, d as defineCustomElement$3 } from './revogr-viewport-scroll2.js';
|
|
16
|
+
import { O as ON_COLUMN_CLICK, d as dispatch, b as defineCustomElement$9 } from './revogr-header2.js';
|
|
17
|
+
import { g as getPropertyFromEvent } from './selection.utils.js';
|
|
18
|
+
import { d as defineCustomElement$f } from './revogr-attribution2.js';
|
|
19
|
+
import { d as defineCustomElement$e } from './revogr-clipboard2.js';
|
|
20
|
+
import { d as defineCustomElement$d } from './revogr-data2.js';
|
|
21
|
+
import { o as defineCustomElement$c } from './revogr-edit2.js';
|
|
22
|
+
import { d as defineCustomElement$b } from './revogr-extra2.js';
|
|
23
|
+
import { d as defineCustomElement$a } from './revogr-focus2.js';
|
|
24
|
+
import { d as defineCustomElement$8 } from './revogr-order-editor2.js';
|
|
25
|
+
import { d as defineCustomElement$7 } from './revogr-overlay-selection2.js';
|
|
26
|
+
import { d as defineCustomElement$5 } from './revogr-scroll-virtual2.js';
|
|
27
|
+
import { d as defineCustomElement$4 } from './revogr-temp-range2.js';
|
|
28
|
+
import { d as defineCustomElement$2 } from './vnode-converter.js';
|
|
29
|
+
|
|
30
|
+
class ThemeCompact {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.defaultRowSize = 32;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class ThemeDefault {
|
|
37
|
+
constructor() {
|
|
38
|
+
this.defaultRowSize = 27;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
class ThemeMaterial {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.defaultRowSize = 42;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const DEFAULT_THEME = 'default';
|
|
49
|
+
const allowedThemes = [
|
|
50
|
+
DEFAULT_THEME,
|
|
51
|
+
'material',
|
|
52
|
+
'compact',
|
|
53
|
+
'darkMaterial',
|
|
54
|
+
'darkCompact',
|
|
55
|
+
];
|
|
56
|
+
class ThemeService {
|
|
57
|
+
get theme() {
|
|
58
|
+
return this.currentTheme;
|
|
59
|
+
}
|
|
60
|
+
get rowSize() {
|
|
61
|
+
return this.customRowSize || this.currentTheme.defaultRowSize;
|
|
62
|
+
}
|
|
63
|
+
set rowSize(size) {
|
|
64
|
+
this.customRowSize = size;
|
|
65
|
+
}
|
|
66
|
+
constructor(cfg) {
|
|
67
|
+
this.customRowSize = 0;
|
|
68
|
+
this.customRowSize = cfg.rowSize;
|
|
69
|
+
this.register('default');
|
|
70
|
+
}
|
|
71
|
+
register(theme) {
|
|
72
|
+
const parsedTheme = getTheme(theme);
|
|
73
|
+
switch (parsedTheme) {
|
|
74
|
+
case 'material':
|
|
75
|
+
case 'darkMaterial':
|
|
76
|
+
this.currentTheme = new ThemeMaterial();
|
|
77
|
+
break;
|
|
78
|
+
case 'compact':
|
|
79
|
+
case 'darkCompact':
|
|
80
|
+
this.currentTheme = new ThemeCompact();
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
this.currentTheme = new ThemeDefault();
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function getTheme(theme) {
|
|
89
|
+
if (theme && allowedThemes.indexOf(theme) > -1) {
|
|
90
|
+
return theme;
|
|
91
|
+
}
|
|
92
|
+
return DEFAULT_THEME;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Plugin which recalculates realSize on changes of sizes, originItemSize and count
|
|
97
|
+
*/
|
|
98
|
+
const recalculateRealSizePlugin = (storeService) => {
|
|
99
|
+
/**
|
|
100
|
+
* Recalculates realSize if size, origin size or count changes
|
|
101
|
+
*/
|
|
102
|
+
return {
|
|
103
|
+
/**
|
|
104
|
+
* Reacts on changes of count, sizes and originItemSize
|
|
105
|
+
*/
|
|
106
|
+
set(k) {
|
|
107
|
+
switch (k) {
|
|
108
|
+
case 'count':
|
|
109
|
+
case 'sizes':
|
|
110
|
+
case 'originItemSize': {
|
|
111
|
+
// recalculate realSize
|
|
112
|
+
let realSize = 0;
|
|
113
|
+
const count = storeService.store.get('count');
|
|
114
|
+
for (let i = 0; i < count; i++) {
|
|
115
|
+
realSize +=
|
|
116
|
+
storeService.store.get('sizes')[i] ||
|
|
117
|
+
storeService.store.get('originItemSize');
|
|
118
|
+
}
|
|
119
|
+
storeService.setStore({ realSize });
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Plugin for trimming
|
|
129
|
+
*
|
|
130
|
+
* 1.a. Retrieves the previous sizes value. Saves the resulting trimmed data as a new sizes value.
|
|
131
|
+
* 1.b. Stores a reference to the trimmed data to prevent further changes.
|
|
132
|
+
* 2. Removes multiple and shifts the data based on the trimmed value.
|
|
133
|
+
*/
|
|
134
|
+
const trimmedPlugin = (storeService) => {
|
|
135
|
+
let trimmingObject = null;
|
|
136
|
+
let trimmedPreviousSizes = null;
|
|
137
|
+
return {
|
|
138
|
+
set(key, val) {
|
|
139
|
+
switch (key) {
|
|
140
|
+
case 'sizes': {
|
|
141
|
+
// prevent changes after trimming
|
|
142
|
+
if (trimmingObject && trimmingObject === val) {
|
|
143
|
+
trimmingObject = null;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
trimmedPreviousSizes = null;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case 'trimmed': {
|
|
150
|
+
const trim = val;
|
|
151
|
+
if (!trimmedPreviousSizes) {
|
|
152
|
+
trimmedPreviousSizes = storeService.store.get('sizes');
|
|
153
|
+
}
|
|
154
|
+
trimmingObject = removeMultipleAndShift(trimmedPreviousSizes, trim || {});
|
|
155
|
+
// save a reference to the trimmed object to prevent changes after trimming
|
|
156
|
+
storeService.setSizes(trimmingObject);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
function removeMultipleAndShift(items, toRemove) {
|
|
164
|
+
const newItems = {};
|
|
165
|
+
const sortedIndexes = Object.keys(items || {})
|
|
166
|
+
.map(Number)
|
|
167
|
+
.sort((a, b) => a - b);
|
|
168
|
+
const lastIndex = sortedIndexes[sortedIndexes.length - 1];
|
|
169
|
+
let shift = 0;
|
|
170
|
+
for (let i = 0; i <= lastIndex; i++) {
|
|
171
|
+
if (toRemove[i] !== undefined) {
|
|
172
|
+
shift++;
|
|
173
|
+
// skip already removed
|
|
174
|
+
if (items[i] !== undefined) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (items[i] !== undefined) {
|
|
179
|
+
newItems[i - shift] = items[i];
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return newItems;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Storing pre-calculated
|
|
187
|
+
* Dimension information and sizes
|
|
188
|
+
*/
|
|
189
|
+
function initialBase() {
|
|
190
|
+
return {
|
|
191
|
+
indexes: [],
|
|
192
|
+
count: 0,
|
|
193
|
+
// hidden items
|
|
194
|
+
trimmed: null,
|
|
195
|
+
// virtual item index to size
|
|
196
|
+
sizes: {},
|
|
197
|
+
// order in indexes[] to coordinate
|
|
198
|
+
positionIndexToItem: {},
|
|
199
|
+
// initial element to coordinate ^
|
|
200
|
+
indexToItem: {},
|
|
201
|
+
positionIndexes: [],
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function initialState() {
|
|
205
|
+
return Object.assign(Object.assign({}, initialBase()), {
|
|
206
|
+
// size which all items can take
|
|
207
|
+
realSize: 0,
|
|
208
|
+
// initial item size if it wasn't changed
|
|
209
|
+
originItemSize: 0 });
|
|
210
|
+
}
|
|
211
|
+
class DimensionStore {
|
|
212
|
+
constructor(type) {
|
|
213
|
+
this.type = type;
|
|
214
|
+
this.store = createStore(initialState());
|
|
215
|
+
this.store.use(trimmedPlugin({
|
|
216
|
+
store: this.store,
|
|
217
|
+
setSizes: this.setDimensionSize.bind(this),
|
|
218
|
+
}));
|
|
219
|
+
this.store.use(recalculateRealSizePlugin({
|
|
220
|
+
store: this.store,
|
|
221
|
+
setStore: this.setStore.bind(this),
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
getCurrentState() {
|
|
225
|
+
const state = initialState();
|
|
226
|
+
const keys = Object.keys(state);
|
|
227
|
+
return reduce(keys, (r, k) => {
|
|
228
|
+
const data = this.store.get(k);
|
|
229
|
+
r[k] = data;
|
|
230
|
+
return r;
|
|
231
|
+
}, state);
|
|
232
|
+
}
|
|
233
|
+
dispose() {
|
|
234
|
+
setStore(this.store, initialState());
|
|
235
|
+
}
|
|
236
|
+
setStore(data) {
|
|
237
|
+
setStore(this.store, data);
|
|
238
|
+
}
|
|
239
|
+
drop() {
|
|
240
|
+
setStore(this.store, initialBase());
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Set custom dimension sizes and overwrite old
|
|
244
|
+
* Generates new indexes based on sizes
|
|
245
|
+
* @param sizes - sizes to set
|
|
246
|
+
*/
|
|
247
|
+
setDimensionSize(sizes = {}) {
|
|
248
|
+
const dimensionData = calculateDimensionData(this.store.get('originItemSize'), sizes);
|
|
249
|
+
setStore(this.store, Object.assign(Object.assign({}, dimensionData), { sizes }));
|
|
250
|
+
}
|
|
251
|
+
updateSizesPositionByIndexes(newItemsOrder, prevItemsOrder = []) {
|
|
252
|
+
// Move custom sizes to new order
|
|
253
|
+
const customSizes = Object.assign({}, this.store.get('sizes'));
|
|
254
|
+
if (!Object.keys(customSizes).length) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
// Step 1: Create a map of original indices, but allow duplicates by storing arrays of indices
|
|
258
|
+
const originalIndices = {};
|
|
259
|
+
prevItemsOrder.forEach((physIndex, virtIndex) => {
|
|
260
|
+
if (!originalIndices[physIndex]) {
|
|
261
|
+
originalIndices[physIndex] = [];
|
|
262
|
+
}
|
|
263
|
+
originalIndices[physIndex].push(virtIndex); // Store all indices for each value
|
|
264
|
+
});
|
|
265
|
+
// Step 2: Create new sizes based on new item order
|
|
266
|
+
const newSizes = {};
|
|
267
|
+
newItemsOrder.forEach((physIndex, virtIndex) => {
|
|
268
|
+
const indices = originalIndices[physIndex]; // Get all original indices for this value
|
|
269
|
+
if (indices && indices.length > 0) {
|
|
270
|
+
const originalIndex = indices.shift(); // Get the first available original index
|
|
271
|
+
if (originalIndex !== undefined && originalIndex !== virtIndex && customSizes[originalIndex]) {
|
|
272
|
+
newSizes[virtIndex] = customSizes[originalIndex];
|
|
273
|
+
delete customSizes[originalIndex];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
// Step 3: Set new sizes if there are changes
|
|
278
|
+
if (Object.keys(newSizes).length) {
|
|
279
|
+
this.setDimensionSize(Object.assign(Object.assign({}, customSizes), newSizes));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Base layer for plugins
|
|
286
|
+
* Provide minimal starting core for plugins to work
|
|
287
|
+
* Extend this class to create plugin
|
|
288
|
+
*/
|
|
289
|
+
class BasePlugin {
|
|
290
|
+
constructor(revogrid, providers) {
|
|
291
|
+
this.revogrid = revogrid;
|
|
292
|
+
this.providers = providers;
|
|
293
|
+
this.h = h;
|
|
294
|
+
this.subscriptions = {};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
*
|
|
298
|
+
* @param eventName - event name to subscribe to in revo-grid component (e.g. 'beforeheaderclick')
|
|
299
|
+
* @param callback - callback function for event
|
|
300
|
+
*/
|
|
301
|
+
addEventListener(eventName, callback) {
|
|
302
|
+
this.revogrid.addEventListener(eventName, callback);
|
|
303
|
+
this.subscriptions[eventName] = callback;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Subscribe to property change in revo-grid component
|
|
307
|
+
* You can return false in callback to prevent default value set
|
|
308
|
+
*
|
|
309
|
+
* @param prop - property name
|
|
310
|
+
* @param callback - callback function
|
|
311
|
+
* @param immediate - trigger callback immediately with current value
|
|
312
|
+
*/
|
|
313
|
+
watch(prop, callback, { immediate } = { immediate: false }) {
|
|
314
|
+
const nativeValueDesc = Object.getOwnPropertyDescriptor(this.revogrid, prop) ||
|
|
315
|
+
Object.getOwnPropertyDescriptor(this.revogrid.constructor.prototype, prop);
|
|
316
|
+
// Overwrite property descriptor for this instance
|
|
317
|
+
Object.defineProperty(this.revogrid, prop, {
|
|
318
|
+
set(val) {
|
|
319
|
+
var _a;
|
|
320
|
+
const keepDefault = callback(val);
|
|
321
|
+
if (keepDefault === false) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
// Continue with native behavior
|
|
325
|
+
return (_a = nativeValueDesc === null || nativeValueDesc === void 0 ? void 0 : nativeValueDesc.set) === null || _a === void 0 ? void 0 : _a.call(this, val);
|
|
326
|
+
},
|
|
327
|
+
get() {
|
|
328
|
+
var _a;
|
|
329
|
+
// Continue with native behavior
|
|
330
|
+
return (_a = nativeValueDesc === null || nativeValueDesc === void 0 ? void 0 : nativeValueDesc.get) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
if (immediate) {
|
|
334
|
+
callback(nativeValueDesc === null || nativeValueDesc === void 0 ? void 0 : nativeValueDesc.value);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Remove event listener
|
|
339
|
+
* @param eventName
|
|
340
|
+
*/
|
|
341
|
+
removeEventListener(eventName) {
|
|
342
|
+
this.revogrid.removeEventListener(eventName, this.subscriptions[eventName]);
|
|
343
|
+
delete this.subscriptions[eventName];
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Emit event from revo-grid component
|
|
347
|
+
* Event can be cancelled by calling event.preventDefault() in callback
|
|
348
|
+
*/
|
|
349
|
+
emit(eventName, detail) {
|
|
350
|
+
const event = new CustomEvent(eventName, { detail, cancelable: true });
|
|
351
|
+
this.revogrid.dispatchEvent(event);
|
|
352
|
+
return event;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Clear all subscriptions
|
|
356
|
+
*/
|
|
357
|
+
clearSubscriptions() {
|
|
358
|
+
for (let type in this.subscriptions) {
|
|
359
|
+
this.removeEventListener(type);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Destroy plugin and clear all subscriptions
|
|
364
|
+
*/
|
|
365
|
+
destroy() {
|
|
366
|
+
this.clearSubscriptions();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* A specialized version of `_.forEach` for arrays without support for
|
|
372
|
+
* iteratee shorthands.
|
|
373
|
+
*
|
|
374
|
+
* @private
|
|
375
|
+
* @param {Array} [array] The array to iterate over.
|
|
376
|
+
* @param {Function} iteratee The function invoked per iteration.
|
|
377
|
+
* @returns {Array} Returns `array`.
|
|
378
|
+
*/
|
|
379
|
+
function arrayEach(array, iteratee) {
|
|
380
|
+
var index = -1,
|
|
381
|
+
length = array == null ? 0 : array.length;
|
|
382
|
+
|
|
383
|
+
while (++index < length) {
|
|
384
|
+
if (iteratee(array[index], index, array) === false) {
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return array;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Casts `value` to `identity` if it's not a function.
|
|
393
|
+
*
|
|
394
|
+
* @private
|
|
395
|
+
* @param {*} value The value to inspect.
|
|
396
|
+
* @returns {Function} Returns cast function.
|
|
397
|
+
*/
|
|
398
|
+
function castFunction(value) {
|
|
399
|
+
return typeof value == 'function' ? value : identity;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Iterates over elements of `collection` and invokes `iteratee` for each element.
|
|
404
|
+
* The iteratee is invoked with three arguments: (value, index|key, collection).
|
|
405
|
+
* Iteratee functions may exit iteration early by explicitly returning `false`.
|
|
406
|
+
*
|
|
407
|
+
* **Note:** As with other "Collections" methods, objects with a "length"
|
|
408
|
+
* property are iterated like arrays. To avoid this behavior use `_.forIn`
|
|
409
|
+
* or `_.forOwn` for object iteration.
|
|
410
|
+
*
|
|
411
|
+
* @static
|
|
412
|
+
* @memberOf _
|
|
413
|
+
* @since 0.1.0
|
|
414
|
+
* @alias each
|
|
415
|
+
* @category Collection
|
|
416
|
+
* @param {Array|Object} collection The collection to iterate over.
|
|
417
|
+
* @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
|
418
|
+
* @returns {Array|Object} Returns `collection`.
|
|
419
|
+
* @see _.forEachRight
|
|
420
|
+
* @example
|
|
421
|
+
*
|
|
422
|
+
* _.forEach([1, 2], function(value) {
|
|
423
|
+
* console.log(value);
|
|
424
|
+
* });
|
|
425
|
+
* // => Logs `1` then `2`.
|
|
426
|
+
*
|
|
427
|
+
* _.forEach({ 'a': 1, 'b': 2 }, function(value, key) {
|
|
428
|
+
* console.log(key);
|
|
429
|
+
* });
|
|
430
|
+
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
|
431
|
+
*/
|
|
432
|
+
function forEach(collection, iteratee) {
|
|
433
|
+
var func = isArray(collection) ? arrayEach : baseEach;
|
|
434
|
+
return func(collection, castFunction(iteratee));
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Plugin module for revo-grid grid system
|
|
439
|
+
* Add support for automatic column resize
|
|
440
|
+
*/
|
|
441
|
+
const LETTER_BLOCK_SIZE = 7;
|
|
442
|
+
class AutoSizeColumnPlugin extends BasePlugin {
|
|
443
|
+
constructor(revogrid, providers, config) {
|
|
444
|
+
super(revogrid, providers);
|
|
445
|
+
this.providers = providers;
|
|
446
|
+
this.config = config;
|
|
447
|
+
this.autoSizeColumns = null;
|
|
448
|
+
/** for edge case when no columns defined before data */
|
|
449
|
+
this.dataResolve = null;
|
|
450
|
+
this.dataReject = null;
|
|
451
|
+
this.letterBlockSize = (config === null || config === void 0 ? void 0 : config.letterBlockSize) || LETTER_BLOCK_SIZE;
|
|
452
|
+
// create test container to check text width
|
|
453
|
+
if (config === null || config === void 0 ? void 0 : config.preciseSize) {
|
|
454
|
+
this.precsizeCalculationArea = this.initiatePresizeElement();
|
|
455
|
+
revogrid.appendChild(this.precsizeCalculationArea);
|
|
456
|
+
}
|
|
457
|
+
const aftersourceset = ({ detail: { source }, }) => {
|
|
458
|
+
this.setSource(source);
|
|
459
|
+
};
|
|
460
|
+
const beforecolumnsset = ({ detail: { columns }, }) => {
|
|
461
|
+
this.columnSet(columns);
|
|
462
|
+
};
|
|
463
|
+
this.addEventListener('beforecolumnsset', beforecolumnsset);
|
|
464
|
+
switch (config === null || config === void 0 ? void 0 : config.mode) {
|
|
465
|
+
case "autoSizeOnTextOverlap" /* ColumnAutoSizeMode.autoSizeOnTextOverlap */:
|
|
466
|
+
this.addEventListener('aftersourceset', aftersourceset);
|
|
467
|
+
this.addEventListener('afteredit', ({ detail }) => {
|
|
468
|
+
this.afteredit(detail);
|
|
469
|
+
});
|
|
470
|
+
break;
|
|
471
|
+
case "autoSizeAll" /* ColumnAutoSizeMode.autoSizeAll */:
|
|
472
|
+
this.addEventListener('aftersourceset', aftersourceset);
|
|
473
|
+
this.addEventListener('afteredit', ({ detail }) => {
|
|
474
|
+
this.afterEditAll(detail);
|
|
475
|
+
});
|
|
476
|
+
break;
|
|
477
|
+
default:
|
|
478
|
+
this.addEventListener('headerdblclick', ({ detail }) => {
|
|
479
|
+
const type = getColumnType(detail.column);
|
|
480
|
+
const size = this.getColumnSize(detail.index, type);
|
|
481
|
+
if (size) {
|
|
482
|
+
this.providers.dimension.setCustomSizes(type, {
|
|
483
|
+
[detail.index]: size,
|
|
484
|
+
}, true);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
async setSource(source) {
|
|
491
|
+
let autoSize = this.autoSizeColumns;
|
|
492
|
+
if (this.dataReject) {
|
|
493
|
+
this.dataReject();
|
|
494
|
+
this.clearPromise();
|
|
495
|
+
}
|
|
496
|
+
/** If data set first and no column provided await until get one */
|
|
497
|
+
if (!autoSize) {
|
|
498
|
+
const request = new Promise((resolve, reject) => {
|
|
499
|
+
this.dataResolve = resolve;
|
|
500
|
+
this.dataReject = reject;
|
|
501
|
+
});
|
|
502
|
+
try {
|
|
503
|
+
autoSize = await request;
|
|
504
|
+
}
|
|
505
|
+
catch (e) {
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
// calculate sizes
|
|
510
|
+
forEach(autoSize, (_v, type) => {
|
|
511
|
+
const sizes = {};
|
|
512
|
+
forEach(autoSize[type], rgCol => {
|
|
513
|
+
// calculate size
|
|
514
|
+
rgCol.size = sizes[rgCol.index] = source.reduce((prev, rgRow) => Math.max(prev, this.getLength(rgRow[rgCol.prop])), this.getLength(rgCol.name || ''));
|
|
515
|
+
});
|
|
516
|
+
this.providers.dimension.setCustomSizes(type, sizes, true);
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
getLength(len) {
|
|
520
|
+
var _a;
|
|
521
|
+
const padding = 15;
|
|
522
|
+
if (!len) {
|
|
523
|
+
return 0;
|
|
524
|
+
}
|
|
525
|
+
try {
|
|
526
|
+
const str = len.toString();
|
|
527
|
+
/**if exact calculation required proxy with html element, slow operation */
|
|
528
|
+
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.preciseSize) {
|
|
529
|
+
this.precsizeCalculationArea.innerText = str;
|
|
530
|
+
return this.precsizeCalculationArea.scrollWidth + padding * 2;
|
|
531
|
+
}
|
|
532
|
+
return str.length * this.letterBlockSize + padding * 2;
|
|
533
|
+
}
|
|
534
|
+
catch (e) {
|
|
535
|
+
return 0;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
afteredit(e) {
|
|
539
|
+
let data;
|
|
540
|
+
if (this.isRangeEdit(e)) {
|
|
541
|
+
data = e.data;
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
data = { 0: { [e.prop]: e.val } };
|
|
545
|
+
}
|
|
546
|
+
forEach(this.autoSizeColumns, (columns, type) => {
|
|
547
|
+
const sizes = {};
|
|
548
|
+
forEach(columns, rgCol => {
|
|
549
|
+
var _a;
|
|
550
|
+
// calculate size
|
|
551
|
+
const size = reduce(data, (prev, rgRow) => {
|
|
552
|
+
if (typeof rgRow[rgCol.prop] === 'undefined') {
|
|
553
|
+
return prev;
|
|
554
|
+
}
|
|
555
|
+
return Math.max(prev || 0, this.getLength(rgRow[rgCol.prop]));
|
|
556
|
+
}, undefined);
|
|
557
|
+
if (size && ((_a = rgCol.size) !== null && _a !== void 0 ? _a : 0) < size) {
|
|
558
|
+
rgCol.size = sizes[rgCol.index] = size;
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
this.providers.dimension.setCustomSizes(type, sizes, true);
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
afterEditAll(e) {
|
|
565
|
+
const props = {};
|
|
566
|
+
if (this.isRangeEdit(e)) {
|
|
567
|
+
forEach(e.data, r => forEach(r, (_v, p) => (props[p] = true)));
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
props[e.prop] = true;
|
|
571
|
+
}
|
|
572
|
+
forEach(this.autoSizeColumns, (columns, type) => {
|
|
573
|
+
const sizes = {};
|
|
574
|
+
forEach(columns, rgCol => {
|
|
575
|
+
if (props[rgCol.prop]) {
|
|
576
|
+
const size = this.getColumnSize(rgCol.index, type);
|
|
577
|
+
if (size) {
|
|
578
|
+
sizes[rgCol.index] = size;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
this.providers.dimension.setCustomSizes(type, sizes, true);
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
getColumnSize(index, type) {
|
|
586
|
+
var _a, _b;
|
|
587
|
+
const rgCol = (_b = (_a = this.autoSizeColumns) === null || _a === void 0 ? void 0 : _a[type]) === null || _b === void 0 ? void 0 : _b[index];
|
|
588
|
+
if (!rgCol) {
|
|
589
|
+
return 0;
|
|
590
|
+
}
|
|
591
|
+
return reduce(this.providers.data.stores, (r, s) => {
|
|
592
|
+
const perStore = reduce(s.store.get('items'), (prev, _row, i) => {
|
|
593
|
+
const item = getSourceItem(s.store, i);
|
|
594
|
+
return Math.max(prev || 0, this.getLength(item === null || item === void 0 ? void 0 : item[rgCol.prop]));
|
|
595
|
+
}, 0);
|
|
596
|
+
return Math.max(r, perStore);
|
|
597
|
+
}, rgCol.size || 0);
|
|
598
|
+
}
|
|
599
|
+
columnSet(columns) {
|
|
600
|
+
var _a;
|
|
601
|
+
for (let t of columnTypes) {
|
|
602
|
+
const type = t;
|
|
603
|
+
const cols = columns[type];
|
|
604
|
+
for (let i in cols) {
|
|
605
|
+
if (cols[i].autoSize || ((_a = this.config) === null || _a === void 0 ? void 0 : _a.allColumns)) {
|
|
606
|
+
if (!this.autoSizeColumns) {
|
|
607
|
+
this.autoSizeColumns = {};
|
|
608
|
+
}
|
|
609
|
+
if (!this.autoSizeColumns[type]) {
|
|
610
|
+
this.autoSizeColumns[type] = {};
|
|
611
|
+
}
|
|
612
|
+
this.autoSizeColumns[type][i] = Object.assign(Object.assign({}, cols[i]), { index: parseInt(i, 10) });
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (this.dataResolve) {
|
|
617
|
+
this.dataResolve(this.autoSizeColumns || {});
|
|
618
|
+
this.clearPromise();
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
clearPromise() {
|
|
622
|
+
this.dataResolve = null;
|
|
623
|
+
this.dataReject = null;
|
|
624
|
+
}
|
|
625
|
+
isRangeEdit(e) {
|
|
626
|
+
return !!e.data;
|
|
627
|
+
}
|
|
628
|
+
initiatePresizeElement() {
|
|
629
|
+
var _a;
|
|
630
|
+
const styleForFontTest = {
|
|
631
|
+
position: 'absolute',
|
|
632
|
+
fontSize: '14px',
|
|
633
|
+
height: '0',
|
|
634
|
+
width: '0',
|
|
635
|
+
whiteSpace: 'nowrap',
|
|
636
|
+
top: '0',
|
|
637
|
+
overflowX: 'scroll',
|
|
638
|
+
display: 'block',
|
|
639
|
+
};
|
|
640
|
+
const el = document.createElement('div');
|
|
641
|
+
for (let s in styleForFontTest) {
|
|
642
|
+
el.style[s] = (_a = styleForFontTest[s]) !== null && _a !== void 0 ? _a : '';
|
|
643
|
+
}
|
|
644
|
+
el.classList.add('revo-test-container');
|
|
645
|
+
return el;
|
|
646
|
+
}
|
|
647
|
+
destroy() {
|
|
648
|
+
var _a;
|
|
649
|
+
super.destroy();
|
|
650
|
+
(_a = this.precsizeCalculationArea) === null || _a === void 0 ? void 0 : _a.remove();
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
class StretchColumn extends BasePlugin {
|
|
655
|
+
constructor(revogrid, providers) {
|
|
656
|
+
super(revogrid, providers);
|
|
657
|
+
this.providers = providers;
|
|
658
|
+
this.stretchedColumn = null;
|
|
659
|
+
// calculate scroll bar size for current user session
|
|
660
|
+
this.scrollSize = getScrollbarSize(document);
|
|
661
|
+
// subscribe to column changes
|
|
662
|
+
const beforecolumnapplied = ({ detail: { columns }, }) => this.applyStretch(columns);
|
|
663
|
+
this.addEventListener('beforecolumnapplied', beforecolumnapplied);
|
|
664
|
+
}
|
|
665
|
+
setScroll({ type, hasScroll }) {
|
|
666
|
+
var _a;
|
|
667
|
+
if (type === 'rgRow' &&
|
|
668
|
+
this.stretchedColumn &&
|
|
669
|
+
((_a = this.stretchedColumn) === null || _a === void 0 ? void 0 : _a.initialSize) === this.stretchedColumn.size) {
|
|
670
|
+
if (hasScroll) {
|
|
671
|
+
this.stretchedColumn.size -= this.scrollSize;
|
|
672
|
+
this.apply();
|
|
673
|
+
this.dropChanges();
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
activateChanges() {
|
|
678
|
+
const setScroll = ({ detail }) => this.setScroll(detail);
|
|
679
|
+
this.addEventListener('scrollchange', setScroll);
|
|
680
|
+
}
|
|
681
|
+
dropChanges() {
|
|
682
|
+
this.stretchedColumn = null;
|
|
683
|
+
this.removeEventListener('scrollchange');
|
|
684
|
+
}
|
|
685
|
+
apply() {
|
|
686
|
+
if (!this.stretchedColumn) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
const type = 'rgCol';
|
|
690
|
+
const sizes = this.providers.dimension.stores[type].store.get('sizes');
|
|
691
|
+
this.providers.dimension.setCustomSizes(type, Object.assign(Object.assign({}, sizes), { [this.stretchedColumn.index]: this.stretchedColumn.size }), true);
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Apply stretch changes
|
|
695
|
+
*/
|
|
696
|
+
applyStretch(columns) {
|
|
697
|
+
// unsubscribe from all events
|
|
698
|
+
this.dropChanges();
|
|
699
|
+
// calculate grid size
|
|
700
|
+
let sizeDifference = this.revogrid.clientWidth - 1;
|
|
701
|
+
forEach(columns, (_, type) => {
|
|
702
|
+
const realSize = this.providers.dimension.stores[type].store.get('realSize');
|
|
703
|
+
sizeDifference -= realSize;
|
|
704
|
+
});
|
|
705
|
+
if (this.revogrid.rowHeaders) {
|
|
706
|
+
const itemsLength = this.providers.data.stores.rgRow.store.get('source').length;
|
|
707
|
+
const header = this.revogrid.rowHeaders;
|
|
708
|
+
const rowHeaderSize = calculateRowHeaderSize(itemsLength, typeof header === 'object' ? header : undefined);
|
|
709
|
+
if (rowHeaderSize) {
|
|
710
|
+
sizeDifference -= rowHeaderSize;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
if (sizeDifference > 0) {
|
|
714
|
+
// currently plugin accepts last column only
|
|
715
|
+
const index = columns.rgCol.length - 1;
|
|
716
|
+
const last = columns.rgCol[index];
|
|
717
|
+
/**
|
|
718
|
+
* has column
|
|
719
|
+
* no auto size applied
|
|
720
|
+
* size for column shouldn't be defined
|
|
721
|
+
*/
|
|
722
|
+
const colSize = (last === null || last === void 0 ? void 0 : last.size) || this.revogrid.colSize || 0;
|
|
723
|
+
const size = sizeDifference + colSize - 1;
|
|
724
|
+
if (last && !last.autoSize && colSize < size) {
|
|
725
|
+
this.stretchedColumn = {
|
|
726
|
+
initialSize: size,
|
|
727
|
+
index,
|
|
728
|
+
size,
|
|
729
|
+
};
|
|
730
|
+
this.apply();
|
|
731
|
+
this.activateChanges();
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Check plugin type is Stretch
|
|
738
|
+
*/
|
|
739
|
+
function isStretchPlugin(plugin) {
|
|
740
|
+
return !!plugin.applyStretch;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* The base implementation of `_.clamp` which doesn't coerce arguments.
|
|
745
|
+
*
|
|
746
|
+
* @private
|
|
747
|
+
* @param {number} number The number to clamp.
|
|
748
|
+
* @param {number} [lower] The lower bound.
|
|
749
|
+
* @param {number} upper The upper bound.
|
|
750
|
+
* @returns {number} Returns the clamped number.
|
|
751
|
+
*/
|
|
752
|
+
function baseClamp(number, lower, upper) {
|
|
753
|
+
if (number === number) {
|
|
754
|
+
{
|
|
755
|
+
number = number <= upper ? number : upper;
|
|
756
|
+
}
|
|
757
|
+
{
|
|
758
|
+
number = number >= lower ? number : lower;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
return number;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/** Used as references for the maximum length and index of an array. */
|
|
765
|
+
var MAX_ARRAY_LENGTH = 4294967295;
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Converts `value` to an integer suitable for use as the length of an
|
|
769
|
+
* array-like object.
|
|
770
|
+
*
|
|
771
|
+
* **Note:** This method is based on
|
|
772
|
+
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
|
|
773
|
+
*
|
|
774
|
+
* @static
|
|
775
|
+
* @memberOf _
|
|
776
|
+
* @since 4.0.0
|
|
777
|
+
* @category Lang
|
|
778
|
+
* @param {*} value The value to convert.
|
|
779
|
+
* @returns {number} Returns the converted integer.
|
|
780
|
+
* @example
|
|
781
|
+
*
|
|
782
|
+
* _.toLength(3.2);
|
|
783
|
+
* // => 3
|
|
784
|
+
*
|
|
785
|
+
* _.toLength(Number.MIN_VALUE);
|
|
786
|
+
* // => 0
|
|
787
|
+
*
|
|
788
|
+
* _.toLength(Infinity);
|
|
789
|
+
* // => 4294967295
|
|
790
|
+
*
|
|
791
|
+
* _.toLength('3.2');
|
|
792
|
+
* // => 3
|
|
793
|
+
*/
|
|
794
|
+
function toLength(value) {
|
|
795
|
+
return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* The base implementation of `_.fill` without an iteratee call guard.
|
|
800
|
+
*
|
|
801
|
+
* @private
|
|
802
|
+
* @param {Array} array The array to fill.
|
|
803
|
+
* @param {*} value The value to fill `array` with.
|
|
804
|
+
* @param {number} [start=0] The start position.
|
|
805
|
+
* @param {number} [end=array.length] The end position.
|
|
806
|
+
* @returns {Array} Returns `array`.
|
|
807
|
+
*/
|
|
808
|
+
function baseFill(array, value, start, end) {
|
|
809
|
+
var length = array.length;
|
|
810
|
+
|
|
811
|
+
start = toInteger(start);
|
|
812
|
+
if (start < 0) {
|
|
813
|
+
start = -start > length ? 0 : (length + start);
|
|
814
|
+
}
|
|
815
|
+
end = (end === undefined || end > length) ? length : toInteger(end);
|
|
816
|
+
if (end < 0) {
|
|
817
|
+
end += length;
|
|
818
|
+
}
|
|
819
|
+
end = start > end ? 0 : toLength(end);
|
|
820
|
+
while (start < end) {
|
|
821
|
+
array[start++] = value;
|
|
822
|
+
}
|
|
823
|
+
return array;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Fills elements of `array` with `value` from `start` up to, but not
|
|
828
|
+
* including, `end`.
|
|
829
|
+
*
|
|
830
|
+
* **Note:** This method mutates `array`.
|
|
831
|
+
*
|
|
832
|
+
* @static
|
|
833
|
+
* @memberOf _
|
|
834
|
+
* @since 3.2.0
|
|
835
|
+
* @category Array
|
|
836
|
+
* @param {Array} array The array to fill.
|
|
837
|
+
* @param {*} value The value to fill `array` with.
|
|
838
|
+
* @param {number} [start=0] The start position.
|
|
839
|
+
* @param {number} [end=array.length] The end position.
|
|
840
|
+
* @returns {Array} Returns `array`.
|
|
841
|
+
* @example
|
|
842
|
+
*
|
|
843
|
+
* var array = [1, 2, 3];
|
|
844
|
+
*
|
|
845
|
+
* _.fill(array, 'a');
|
|
846
|
+
* console.log(array);
|
|
847
|
+
* // => ['a', 'a', 'a']
|
|
848
|
+
*
|
|
849
|
+
* _.fill(Array(3), 2);
|
|
850
|
+
* // => [2, 2, 2]
|
|
851
|
+
*
|
|
852
|
+
* _.fill([4, 6, 8, 10], '*', 1, 3);
|
|
853
|
+
* // => [4, '*', '*', 10]
|
|
854
|
+
*/
|
|
855
|
+
function fill(array, value, start, end) {
|
|
856
|
+
var length = array == null ? 0 : array.length;
|
|
857
|
+
if (!length) {
|
|
858
|
+
return [];
|
|
859
|
+
}
|
|
860
|
+
return baseFill(array, value, start, end);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
const INITIAL = {
|
|
864
|
+
mime: 'text/csv',
|
|
865
|
+
fileKind: 'csv',
|
|
866
|
+
// BOM signature
|
|
867
|
+
bom: true,
|
|
868
|
+
columnDelimiter: ',',
|
|
869
|
+
rowDelimiter: '\r\n',
|
|
870
|
+
encoding: '',
|
|
871
|
+
};
|
|
872
|
+
// The ASCII character code 13 is called a Carriage Return or CR.
|
|
873
|
+
const CARRIAGE_RETURN = String.fromCharCode(13);
|
|
874
|
+
// Chr(13) followed by a Chr(10) that compose a proper CRLF.
|
|
875
|
+
const LINE_FEED = String.fromCharCode(10);
|
|
876
|
+
const DOUBLE_QT = String.fromCharCode(34);
|
|
877
|
+
const NO_BREAK_SPACE = String.fromCharCode(0xfeff);
|
|
878
|
+
const escapeRegex = new RegExp('"', 'g');
|
|
879
|
+
class ExportCsv {
|
|
880
|
+
constructor(options = {}) {
|
|
881
|
+
this.options = Object.assign(Object.assign({}, INITIAL), options);
|
|
882
|
+
}
|
|
883
|
+
doExport({ data, headers, props }) {
|
|
884
|
+
let result = this.options.bom ? NO_BREAK_SPACE : '';
|
|
885
|
+
// any header
|
|
886
|
+
if ((headers === null || headers === void 0 ? void 0 : headers.length) > 0) {
|
|
887
|
+
headers.forEach(header => {
|
|
888
|
+
// ignore empty
|
|
889
|
+
if (!header.length) {
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
result += this.prepareHeader(header, this.options.columnDelimiter);
|
|
893
|
+
result += this.options.rowDelimiter;
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
data.forEach((rgRow, index) => {
|
|
897
|
+
if (index > 0) {
|
|
898
|
+
result += this.options.rowDelimiter;
|
|
899
|
+
}
|
|
900
|
+
// support grouping
|
|
901
|
+
if (isGrouping(rgRow)) {
|
|
902
|
+
result += this.parseCell(getGroupingName(rgRow), this.options.columnDelimiter);
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
result += props.map(p => this.parseCell(rgRow[p], this.options.columnDelimiter)).join(this.options.columnDelimiter);
|
|
906
|
+
});
|
|
907
|
+
return result;
|
|
908
|
+
}
|
|
909
|
+
prepareHeader(columnHeaders, columnDelimiter) {
|
|
910
|
+
let result = '';
|
|
911
|
+
const newColumnHeaders = columnHeaders.map(v => this.parseCell(v, columnDelimiter, true));
|
|
912
|
+
result += newColumnHeaders.join(columnDelimiter);
|
|
913
|
+
return result;
|
|
914
|
+
}
|
|
915
|
+
parseCell(value, columnDelimiter, force = false) {
|
|
916
|
+
let escape = value;
|
|
917
|
+
if (typeof value !== 'string') {
|
|
918
|
+
escape = JSON.stringify(value);
|
|
919
|
+
}
|
|
920
|
+
const toEscape = [CARRIAGE_RETURN, DOUBLE_QT, LINE_FEED, columnDelimiter];
|
|
921
|
+
if (typeof escape === 'undefined') {
|
|
922
|
+
return '';
|
|
923
|
+
}
|
|
924
|
+
if (escape !== '' && (force || toEscape.some(i => escape.indexOf(i) >= 0))) {
|
|
925
|
+
return `"${escape.replace(escapeRegex, '""')}"`;
|
|
926
|
+
}
|
|
927
|
+
return escape;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
var ExportTypes;
|
|
932
|
+
(function (ExportTypes) {
|
|
933
|
+
ExportTypes["csv"] = "csv";
|
|
934
|
+
})(ExportTypes || (ExportTypes = {}));
|
|
935
|
+
class ExportFilePlugin extends BasePlugin {
|
|
936
|
+
/** Exports string */
|
|
937
|
+
async exportString(options = {}, t = ExportTypes.csv) {
|
|
938
|
+
const data = await this.beforeexport();
|
|
939
|
+
if (!data) {
|
|
940
|
+
return null;
|
|
941
|
+
}
|
|
942
|
+
return this.formatter(t, options).doExport(data);
|
|
943
|
+
}
|
|
944
|
+
/** Exports Blob */
|
|
945
|
+
async exportBlob(options = {}, t = ExportTypes.csv) {
|
|
946
|
+
return await this.getBlob(this.formatter(t, options));
|
|
947
|
+
}
|
|
948
|
+
/** Export file */
|
|
949
|
+
async exportFile(options = {}, t = ExportTypes.csv) {
|
|
950
|
+
const formatter = this.formatter(t, options);
|
|
951
|
+
// url
|
|
952
|
+
const URL = window.URL || window.webkitURL;
|
|
953
|
+
const a = document.createElement('a');
|
|
954
|
+
const { filename, fileKind } = formatter.options;
|
|
955
|
+
const name = `${filename}.${fileKind}`;
|
|
956
|
+
const blob = await this.getBlob(formatter);
|
|
957
|
+
const url = blob ? URL.createObjectURL(blob) : '';
|
|
958
|
+
a.style.display = 'none';
|
|
959
|
+
a.setAttribute('href', url);
|
|
960
|
+
a.setAttribute('download', name);
|
|
961
|
+
this.revogrid.appendChild(a);
|
|
962
|
+
a.dispatchEvent(new MouseEvent('click'));
|
|
963
|
+
this.revogrid.removeChild(a);
|
|
964
|
+
// delay for revoke, correct for some browsers
|
|
965
|
+
await timeout(120);
|
|
966
|
+
URL.revokeObjectURL(url);
|
|
967
|
+
}
|
|
968
|
+
/** Blob object */
|
|
969
|
+
async getBlob(formatter) {
|
|
970
|
+
const type = `${formatter.options.mime};charset=${formatter.options.encoding}`;
|
|
971
|
+
if (typeof Blob !== 'undefined') {
|
|
972
|
+
const data = await this.beforeexport();
|
|
973
|
+
if (!data) {
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
976
|
+
return new Blob([formatter.doExport(data)], { type });
|
|
977
|
+
}
|
|
978
|
+
return null;
|
|
979
|
+
}
|
|
980
|
+
// before event
|
|
981
|
+
async beforeexport() {
|
|
982
|
+
let data = await this.getData();
|
|
983
|
+
const event = this.emit('beforeexport', { data });
|
|
984
|
+
if (event.defaultPrevented) {
|
|
985
|
+
return null;
|
|
986
|
+
}
|
|
987
|
+
return event.detail.data;
|
|
988
|
+
}
|
|
989
|
+
async getData() {
|
|
990
|
+
const data = await this.getSource();
|
|
991
|
+
const colSource = [];
|
|
992
|
+
const colPromises = [];
|
|
993
|
+
columnTypes.forEach((t, i) => {
|
|
994
|
+
colPromises.push(this.getColPerSource(t).then(s => (colSource[i] = s)));
|
|
995
|
+
});
|
|
996
|
+
await Promise.all(colPromises);
|
|
997
|
+
const columns = {
|
|
998
|
+
headers: [],
|
|
999
|
+
props: [],
|
|
1000
|
+
};
|
|
1001
|
+
for (let source of colSource) {
|
|
1002
|
+
source.headers.forEach((h, i) => {
|
|
1003
|
+
if (!columns.headers[i]) {
|
|
1004
|
+
columns.headers[i] = [];
|
|
1005
|
+
}
|
|
1006
|
+
columns.headers[i].push(...h);
|
|
1007
|
+
});
|
|
1008
|
+
columns.props.push(...source.props);
|
|
1009
|
+
}
|
|
1010
|
+
return Object.assign({ data }, columns);
|
|
1011
|
+
}
|
|
1012
|
+
async getColPerSource(t) {
|
|
1013
|
+
const store = await this.revogrid.getColumnStore(t);
|
|
1014
|
+
const source = store.get('source');
|
|
1015
|
+
const virtualIndexes = store.get('items');
|
|
1016
|
+
const depth = store.get('groupingDepth');
|
|
1017
|
+
const groups = store.get('groups');
|
|
1018
|
+
const colNames = [];
|
|
1019
|
+
const colProps = [];
|
|
1020
|
+
virtualIndexes.forEach((v) => {
|
|
1021
|
+
const prop = source[v].prop;
|
|
1022
|
+
colNames.push(source[v].name || '');
|
|
1023
|
+
colProps.push(prop);
|
|
1024
|
+
});
|
|
1025
|
+
const rows = this.getGroupHeaders(depth, groups, virtualIndexes);
|
|
1026
|
+
rows.push(colNames);
|
|
1027
|
+
return {
|
|
1028
|
+
headers: rows,
|
|
1029
|
+
props: colProps,
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
getGroupHeaders(depth, groups, items) {
|
|
1033
|
+
const rows = [];
|
|
1034
|
+
const template = fill(new Array(items.length), '');
|
|
1035
|
+
for (let d = 0; d < depth; d++) {
|
|
1036
|
+
const rgRow = [...template];
|
|
1037
|
+
rows.push(rgRow);
|
|
1038
|
+
if (!groups[d]) {
|
|
1039
|
+
continue;
|
|
1040
|
+
}
|
|
1041
|
+
const levelGroups = groups[d];
|
|
1042
|
+
// add names of groups
|
|
1043
|
+
levelGroups.forEach((group) => {
|
|
1044
|
+
const minIndex = group.indexes[0];
|
|
1045
|
+
if (typeof minIndex === 'number') {
|
|
1046
|
+
rgRow[minIndex] = group.name;
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
return rows;
|
|
1051
|
+
}
|
|
1052
|
+
async getSource() {
|
|
1053
|
+
const data = [];
|
|
1054
|
+
const promisesData = [];
|
|
1055
|
+
rowTypes.forEach(t => {
|
|
1056
|
+
const dataPart = [];
|
|
1057
|
+
data.push(dataPart);
|
|
1058
|
+
const promise = this.revogrid.getVisibleSource(t).then((d) => dataPart.push(...d));
|
|
1059
|
+
promisesData.push(promise);
|
|
1060
|
+
});
|
|
1061
|
+
await Promise.all(promisesData);
|
|
1062
|
+
return data.reduce((r, v) => {
|
|
1063
|
+
r.push(...v);
|
|
1064
|
+
return r;
|
|
1065
|
+
}, []);
|
|
1066
|
+
}
|
|
1067
|
+
// get correct class for future multiple types support
|
|
1068
|
+
formatter(type, options = {}) {
|
|
1069
|
+
switch (type) {
|
|
1070
|
+
case ExportTypes.csv:
|
|
1071
|
+
return new ExportCsv(options);
|
|
1072
|
+
default:
|
|
1073
|
+
throw new Error('Unknown format');
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
const eq = (value, extra) => {
|
|
1079
|
+
if (typeof value === 'undefined' || (value === null && !extra)) {
|
|
1080
|
+
return true;
|
|
1081
|
+
}
|
|
1082
|
+
if (typeof value !== 'string') {
|
|
1083
|
+
value = JSON.stringify(value);
|
|
1084
|
+
}
|
|
1085
|
+
const filterVal = extra === null || extra === void 0 ? void 0 : extra.toString().toLocaleLowerCase();
|
|
1086
|
+
if ((filterVal === null || filterVal === void 0 ? void 0 : filterVal.length) === 0) {
|
|
1087
|
+
return true;
|
|
1088
|
+
}
|
|
1089
|
+
return value.toLocaleLowerCase() === filterVal;
|
|
1090
|
+
};
|
|
1091
|
+
const notEq = (value, extra) => !eq(value, extra);
|
|
1092
|
+
notEq.extra = 'input';
|
|
1093
|
+
eq.extra = 'input';
|
|
1094
|
+
|
|
1095
|
+
const gtThan = function (value, extra) {
|
|
1096
|
+
let conditionValue;
|
|
1097
|
+
if (typeof value === 'number' && typeof extra !== 'undefined' && extra !== null) {
|
|
1098
|
+
conditionValue = parseFloat(extra === null || extra === void 0 ? void 0 : extra.toString());
|
|
1099
|
+
return value > conditionValue;
|
|
1100
|
+
}
|
|
1101
|
+
return false;
|
|
1102
|
+
};
|
|
1103
|
+
gtThan.extra = 'input';
|
|
1104
|
+
|
|
1105
|
+
const gtThanEq = function (value, extra) {
|
|
1106
|
+
return eq(value, extra) || gtThan(value, extra);
|
|
1107
|
+
};
|
|
1108
|
+
gtThanEq.extra = 'input';
|
|
1109
|
+
|
|
1110
|
+
const lt = function (value, extra) {
|
|
1111
|
+
let conditionValue;
|
|
1112
|
+
if (typeof value === 'number' && typeof extra !== 'undefined' && extra !== null) {
|
|
1113
|
+
conditionValue = parseFloat(extra.toString());
|
|
1114
|
+
return value < conditionValue;
|
|
1115
|
+
}
|
|
1116
|
+
else {
|
|
1117
|
+
return false;
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
lt.extra = 'input';
|
|
1121
|
+
|
|
1122
|
+
const lsEq = function (value, extra) {
|
|
1123
|
+
return eq(value, extra) || lt(value, extra);
|
|
1124
|
+
};
|
|
1125
|
+
lsEq.extra = 'input';
|
|
1126
|
+
|
|
1127
|
+
const set = (value) => !(value === '' || value === null || value === void 0);
|
|
1128
|
+
const notSet = (value) => !set(value);
|
|
1129
|
+
|
|
1130
|
+
const beginsWith = (value, extra) => {
|
|
1131
|
+
if (!value) {
|
|
1132
|
+
return false;
|
|
1133
|
+
}
|
|
1134
|
+
if (!extra) {
|
|
1135
|
+
return true;
|
|
1136
|
+
}
|
|
1137
|
+
if (typeof value !== 'string') {
|
|
1138
|
+
value = JSON.stringify(value);
|
|
1139
|
+
}
|
|
1140
|
+
if (typeof extra !== 'string') {
|
|
1141
|
+
extra = JSON.stringify(extra);
|
|
1142
|
+
}
|
|
1143
|
+
return value.toLocaleLowerCase().indexOf(extra.toLocaleLowerCase()) === 0;
|
|
1144
|
+
};
|
|
1145
|
+
beginsWith.extra = 'input';
|
|
1146
|
+
|
|
1147
|
+
const contains = (value, extra) => {
|
|
1148
|
+
if (!extra) {
|
|
1149
|
+
return true;
|
|
1150
|
+
}
|
|
1151
|
+
if (!value) {
|
|
1152
|
+
return false;
|
|
1153
|
+
}
|
|
1154
|
+
if (extra) {
|
|
1155
|
+
if (typeof value !== 'string') {
|
|
1156
|
+
value = JSON.stringify(value);
|
|
1157
|
+
}
|
|
1158
|
+
return value.toLocaleLowerCase().indexOf(extra.toString().toLowerCase()) > -1;
|
|
1159
|
+
}
|
|
1160
|
+
return true;
|
|
1161
|
+
};
|
|
1162
|
+
const notContains = (value, extra) => {
|
|
1163
|
+
return !contains(value, extra);
|
|
1164
|
+
};
|
|
1165
|
+
notContains.extra = 'input';
|
|
1166
|
+
contains.extra = 'input';
|
|
1167
|
+
|
|
1168
|
+
// filter.indexed.ts
|
|
1169
|
+
const filterCoreFunctionsIndexedByType = {
|
|
1170
|
+
none: () => true,
|
|
1171
|
+
empty: notSet,
|
|
1172
|
+
notEmpty: set,
|
|
1173
|
+
eq: eq,
|
|
1174
|
+
notEq: notEq,
|
|
1175
|
+
begins: beginsWith,
|
|
1176
|
+
contains: contains,
|
|
1177
|
+
notContains: notContains,
|
|
1178
|
+
eqN: eq,
|
|
1179
|
+
neqN: notEq,
|
|
1180
|
+
gt: gtThan,
|
|
1181
|
+
gte: gtThanEq,
|
|
1182
|
+
lt: lt,
|
|
1183
|
+
lte: lsEq,
|
|
1184
|
+
};
|
|
1185
|
+
const filterTypes = {
|
|
1186
|
+
string: ['notEmpty', 'empty', 'eq', 'notEq', 'begins', 'contains', 'notContains'],
|
|
1187
|
+
number: ['notEmpty', 'empty', 'eqN', 'neqN', 'gt', 'gte', 'lt', 'lte'],
|
|
1188
|
+
};
|
|
1189
|
+
const filterNames = {
|
|
1190
|
+
none: 'None',
|
|
1191
|
+
empty: 'Not set',
|
|
1192
|
+
notEmpty: 'Set',
|
|
1193
|
+
eq: 'Equal',
|
|
1194
|
+
notEq: 'Not equal',
|
|
1195
|
+
begins: 'Begins with',
|
|
1196
|
+
contains: 'Contains',
|
|
1197
|
+
notContains: 'Does not contain',
|
|
1198
|
+
eqN: '=',
|
|
1199
|
+
neqN: '!=',
|
|
1200
|
+
gt: '>',
|
|
1201
|
+
gte: '>=',
|
|
1202
|
+
lt: '<',
|
|
1203
|
+
lte: '<=',
|
|
1204
|
+
};
|
|
1205
|
+
|
|
1206
|
+
// filter.plugin.tsx
|
|
1207
|
+
const FILTER_TRIMMED_TYPE = 'filter';
|
|
1208
|
+
const FILTER_CONFIG_CHANGED_EVENT = 'filterconfigchanged';
|
|
1209
|
+
const FILTE_PANEL = 'revogr-filter-panel';
|
|
1210
|
+
/**
|
|
1211
|
+
* @typedef ColumnFilterConfig
|
|
1212
|
+
* @type {object}
|
|
1213
|
+
*
|
|
1214
|
+
* @property {MultiFilterItem|undefined} multiFilterItems - data for multi filtering with relation
|
|
1215
|
+
*
|
|
1216
|
+
* @property {Record<ColumnProp, FilterCollectionItem>|undefined} collection - preserved filter data, relation for filters will be applied as 'and'
|
|
1217
|
+
*
|
|
1218
|
+
* @property {string[]|undefined} include - filters to be included, if defined everything else out of scope will be ignored
|
|
1219
|
+
*
|
|
1220
|
+
* @property {Record<string, CustomFilter>|undefined} customFilters - hash map of {FilterType:CustomFilter}.
|
|
1221
|
+
*
|
|
1222
|
+
* @property {FilterLocalization|undefined} localization - translation for filter popup captions.
|
|
1223
|
+
*
|
|
1224
|
+
* @property {boolean|undefined} disableDynamicFiltering - disables dynamic filtering. A way to apply filters on Save only.
|
|
1225
|
+
*/
|
|
1226
|
+
/**
|
|
1227
|
+
* @internal
|
|
1228
|
+
*/
|
|
1229
|
+
class FilterPlugin extends BasePlugin {
|
|
1230
|
+
constructor(revogrid, providers, config) {
|
|
1231
|
+
var _a;
|
|
1232
|
+
super(revogrid, providers);
|
|
1233
|
+
this.revogrid = revogrid;
|
|
1234
|
+
this.config = config;
|
|
1235
|
+
this.filterCollection = {};
|
|
1236
|
+
this.multiFilterItems = {};
|
|
1237
|
+
/**
|
|
1238
|
+
* Filter types
|
|
1239
|
+
* @example
|
|
1240
|
+
* {
|
|
1241
|
+
* string: ['contains', 'beginswith'],
|
|
1242
|
+
* number: ['eqN', 'neqN', 'gt']
|
|
1243
|
+
* }
|
|
1244
|
+
*/
|
|
1245
|
+
this.filterByType = Object.assign({}, filterTypes);
|
|
1246
|
+
this.filterNameIndexByType = Object.assign({}, filterNames);
|
|
1247
|
+
this.filterFunctionsIndexedByType = Object.assign({}, filterCoreFunctionsIndexedByType);
|
|
1248
|
+
this.filterProp = FILTER_PROP;
|
|
1249
|
+
if (config) {
|
|
1250
|
+
this.initConfig(config);
|
|
1251
|
+
}
|
|
1252
|
+
const existingNodes = this.revogrid.registerVNode.filter(n => typeof n === 'object' && n.$tag$ !== FILTE_PANEL);
|
|
1253
|
+
this.revogrid.registerVNode = [
|
|
1254
|
+
...existingNodes,
|
|
1255
|
+
h("revogr-filter-panel", { filterNames: this.filterNameIndexByType, filterEntities: this.filterFunctionsIndexedByType, filterCaptions: (_a = config === null || config === void 0 ? void 0 : config.localization) === null || _a === void 0 ? void 0 : _a.captions, onFilterChange: e => this.onFilterChange(e.detail), onResetChange: e => this.onFilterReset(e.detail), disableDynamicFiltering: config === null || config === void 0 ? void 0 : config.disableDynamicFiltering, closeOnOutsideClick: config === null || config === void 0 ? void 0 : config.closeFilterPanelOnOutsideClick, ref: e => (this.pop = e) },
|
|
1256
|
+
' ',
|
|
1257
|
+
this.extraContent()),
|
|
1258
|
+
];
|
|
1259
|
+
const aftersourceset = async () => {
|
|
1260
|
+
const filterCollectionProps = Object.keys(this.filterCollection);
|
|
1261
|
+
if (filterCollectionProps.length > 0) {
|
|
1262
|
+
// handle old way of filtering by reworking FilterCollection to new MultiFilterItem
|
|
1263
|
+
filterCollectionProps.forEach((prop, index) => {
|
|
1264
|
+
if (!this.multiFilterItems[prop]) {
|
|
1265
|
+
this.multiFilterItems[prop] = [
|
|
1266
|
+
{
|
|
1267
|
+
id: index,
|
|
1268
|
+
type: this.filterCollection[prop].type,
|
|
1269
|
+
value: this.filterCollection[prop].value,
|
|
1270
|
+
relation: 'and',
|
|
1271
|
+
},
|
|
1272
|
+
];
|
|
1273
|
+
}
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
if (Object.keys(this.multiFilterItems).length === 0) {
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
await this.runFiltering(this.multiFilterItems);
|
|
1280
|
+
};
|
|
1281
|
+
this.addEventListener('headerclick', e => this.headerclick(e));
|
|
1282
|
+
this.addEventListener(FILTER_CONFIG_CHANGED_EVENT, ({ detail }) => {
|
|
1283
|
+
if (!detail ||
|
|
1284
|
+
(typeof detail === 'object' &&
|
|
1285
|
+
(!detail.multiFilterItems ||
|
|
1286
|
+
!Object.keys(detail.multiFilterItems).length))) {
|
|
1287
|
+
this.clearFiltering();
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
if (typeof detail === 'object') {
|
|
1291
|
+
this.initConfig(detail);
|
|
1292
|
+
}
|
|
1293
|
+
aftersourceset();
|
|
1294
|
+
});
|
|
1295
|
+
this.addEventListener('aftersourceset', aftersourceset);
|
|
1296
|
+
this.addEventListener('filter', ({ detail }) => this.onFilterChange(detail));
|
|
1297
|
+
}
|
|
1298
|
+
beforeshow(_) {
|
|
1299
|
+
// used as hook for filter panel
|
|
1300
|
+
}
|
|
1301
|
+
extraContent() {
|
|
1302
|
+
return null;
|
|
1303
|
+
}
|
|
1304
|
+
initConfig(config) {
|
|
1305
|
+
if (config.multiFilterItems) {
|
|
1306
|
+
this.multiFilterItems = Object.assign({}, config.multiFilterItems);
|
|
1307
|
+
}
|
|
1308
|
+
else {
|
|
1309
|
+
this.multiFilterItems = {};
|
|
1310
|
+
}
|
|
1311
|
+
// Add custom filters
|
|
1312
|
+
if (config.customFilters) {
|
|
1313
|
+
for (let customFilterType in config.customFilters) {
|
|
1314
|
+
const cFilter = config.customFilters[customFilterType];
|
|
1315
|
+
if (!this.filterByType[cFilter.columnFilterType]) {
|
|
1316
|
+
this.filterByType[cFilter.columnFilterType] = [];
|
|
1317
|
+
}
|
|
1318
|
+
// add custom filter type
|
|
1319
|
+
this.filterByType[cFilter.columnFilterType].push(customFilterType);
|
|
1320
|
+
// add custom filter function
|
|
1321
|
+
this.filterFunctionsIndexedByType[customFilterType] = cFilter.func;
|
|
1322
|
+
// add custom filter name
|
|
1323
|
+
this.filterNameIndexByType[customFilterType] = cFilter.name;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
// Add filterProp if provided in config
|
|
1327
|
+
if (config.filterProp) {
|
|
1328
|
+
this.filterProp = config.filterProp;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* which filters has to be included/excluded
|
|
1332
|
+
* convenient way to exclude system filters
|
|
1333
|
+
*/
|
|
1334
|
+
const cfgInlcude = config.include;
|
|
1335
|
+
if (cfgInlcude) {
|
|
1336
|
+
const filters = {};
|
|
1337
|
+
for (let t in this.filterByType) {
|
|
1338
|
+
// validate filters, if appropriate function present
|
|
1339
|
+
const newTypes = this.filterByType[t].filter(f => cfgInlcude.indexOf(f) > -1);
|
|
1340
|
+
if (newTypes.length) {
|
|
1341
|
+
filters[t] = newTypes;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
// if any valid filters provided show them
|
|
1345
|
+
if (Object.keys(filters).length > 0) {
|
|
1346
|
+
this.filterByType = filters;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
if (config.collection) {
|
|
1350
|
+
const filtersWithFilterFunctionPresent = Object.entries(config.collection).filter(([, item]) => this.filterFunctionsIndexedByType[item.type]);
|
|
1351
|
+
this.filterCollection = Object.fromEntries(filtersWithFilterFunctionPresent);
|
|
1352
|
+
}
|
|
1353
|
+
else {
|
|
1354
|
+
this.filterCollection = {};
|
|
1355
|
+
}
|
|
1356
|
+
if (config.localization) {
|
|
1357
|
+
if (config.localization.filterNames) {
|
|
1358
|
+
Object.entries(config.localization.filterNames).forEach(([k, v]) => {
|
|
1359
|
+
if (this.filterNameIndexByType[k] != void 0) {
|
|
1360
|
+
this.filterNameIndexByType[k] = v;
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
async headerclick(e) {
|
|
1367
|
+
var _a, _b;
|
|
1368
|
+
const el = (_a = e.detail.originalEvent) === null || _a === void 0 ? void 0 : _a.target;
|
|
1369
|
+
if (!isFilterBtn(el)) {
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
e.preventDefault();
|
|
1373
|
+
if (!this.pop) {
|
|
1374
|
+
return;
|
|
1375
|
+
}
|
|
1376
|
+
// filter button clicked, open filter dialog
|
|
1377
|
+
const gridPos = this.revogrid.getBoundingClientRect();
|
|
1378
|
+
const buttonPos = el.getBoundingClientRect();
|
|
1379
|
+
const prop = e.detail.prop;
|
|
1380
|
+
const data = Object.assign(Object.assign(Object.assign({}, e.detail), this.filterCollection[prop]), { x: buttonPos.x - gridPos.x, y: buttonPos.y - gridPos.y + buttonPos.height, autoCorrect: true, filterTypes: this.getColumnFilter(e.detail.filter), filterItems: this.multiFilterItems, extraContent: this.extraHyperContent });
|
|
1381
|
+
(_b = this.beforeshow) === null || _b === void 0 ? void 0 : _b.call(this, data);
|
|
1382
|
+
this.pop.show(data);
|
|
1383
|
+
}
|
|
1384
|
+
getColumnFilter(type) {
|
|
1385
|
+
let filterType = 'string';
|
|
1386
|
+
if (!type) {
|
|
1387
|
+
return { [filterType]: this.filterByType[filterType] };
|
|
1388
|
+
}
|
|
1389
|
+
// if custom column filter
|
|
1390
|
+
if (this.isValidType(type)) {
|
|
1391
|
+
filterType = type;
|
|
1392
|
+
// if multiple filters applied
|
|
1393
|
+
}
|
|
1394
|
+
else if (typeof type === 'object' && type.length) {
|
|
1395
|
+
return type.reduce((r, multiType) => {
|
|
1396
|
+
if (this.isValidType(multiType)) {
|
|
1397
|
+
r[multiType] = this.filterByType[multiType];
|
|
1398
|
+
}
|
|
1399
|
+
return r;
|
|
1400
|
+
}, {});
|
|
1401
|
+
}
|
|
1402
|
+
return { [filterType]: this.filterByType[filterType] };
|
|
1403
|
+
}
|
|
1404
|
+
isValidType(type) {
|
|
1405
|
+
return !!(typeof type === 'string' && this.filterByType[type]);
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Called on internal component change
|
|
1409
|
+
*/
|
|
1410
|
+
async onFilterChange(filterItems) {
|
|
1411
|
+
// store the filter items
|
|
1412
|
+
this.multiFilterItems = filterItems;
|
|
1413
|
+
// run the filtering when the items change
|
|
1414
|
+
this.runFiltering(this.multiFilterItems);
|
|
1415
|
+
}
|
|
1416
|
+
onFilterReset(prop) {
|
|
1417
|
+
delete this.multiFilterItems[prop !== null && prop !== void 0 ? prop : ''];
|
|
1418
|
+
this.onFilterChange(this.multiFilterItems);
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Triggers grid filtering
|
|
1422
|
+
*/
|
|
1423
|
+
async doFiltering(collection, source, columns, filterItems) {
|
|
1424
|
+
const columnsToUpdate = [];
|
|
1425
|
+
/**
|
|
1426
|
+
* Loop through the columns and update the columns that need to be updated with the `hasFilter` property.
|
|
1427
|
+
*/
|
|
1428
|
+
const columnByProp = {};
|
|
1429
|
+
columns.forEach(rgCol => {
|
|
1430
|
+
const column = Object.assign({}, rgCol);
|
|
1431
|
+
const hasFilter = filterItems[column.prop];
|
|
1432
|
+
columnByProp[column.prop] = column;
|
|
1433
|
+
/**
|
|
1434
|
+
* If the column has a filter and it's not already marked as filtered, update the column.
|
|
1435
|
+
*/
|
|
1436
|
+
if (column[this.filterProp] && !hasFilter) {
|
|
1437
|
+
delete column[this.filterProp];
|
|
1438
|
+
columnsToUpdate.push(column);
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* If the column does not have a filter and it's marked as filtered, update the column.
|
|
1442
|
+
*/
|
|
1443
|
+
if (!column[this.filterProp] && hasFilter) {
|
|
1444
|
+
columnsToUpdate.push(column);
|
|
1445
|
+
column[this.filterProp] = true;
|
|
1446
|
+
}
|
|
1447
|
+
});
|
|
1448
|
+
const itemsToTrim = this.getRowFilter(source, filterItems, columnByProp);
|
|
1449
|
+
// check is filter event prevented
|
|
1450
|
+
const { defaultPrevented, detail } = this.emit('beforefiltertrimmed', {
|
|
1451
|
+
collection,
|
|
1452
|
+
itemsToFilter: itemsToTrim,
|
|
1453
|
+
source,
|
|
1454
|
+
filterItems,
|
|
1455
|
+
});
|
|
1456
|
+
if (defaultPrevented) {
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
this.providers.data.setTrimmed({ [FILTER_TRIMMED_TYPE]: detail.itemsToFilter });
|
|
1460
|
+
// applies the hasFilter to the columns to show filter icon
|
|
1461
|
+
this.providers.column.updateColumns(columnsToUpdate);
|
|
1462
|
+
this.emit('afterfilterapply', {
|
|
1463
|
+
multiFilterItems: filterItems,
|
|
1464
|
+
source,
|
|
1465
|
+
collection,
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
async clearFiltering() {
|
|
1469
|
+
this.multiFilterItems = {};
|
|
1470
|
+
await this.runFiltering(this.multiFilterItems);
|
|
1471
|
+
}
|
|
1472
|
+
async runFiltering(multiFilterItems) {
|
|
1473
|
+
const collection = {};
|
|
1474
|
+
// handle old filterCollection to return the first filter only (if any) from multiFilterItems
|
|
1475
|
+
const filterProps = Object.keys(multiFilterItems);
|
|
1476
|
+
for (const prop of filterProps) {
|
|
1477
|
+
// check if we have any filter for a column
|
|
1478
|
+
if (multiFilterItems[prop].length > 0) {
|
|
1479
|
+
const firstFilterItem = multiFilterItems[prop][0];
|
|
1480
|
+
collection[prop] = {
|
|
1481
|
+
type: firstFilterItem.type,
|
|
1482
|
+
value: firstFilterItem.value,
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
this.filterCollection = collection;
|
|
1487
|
+
const columns = this.providers.column.getColumns();
|
|
1488
|
+
// run the filtering on the main source only
|
|
1489
|
+
const source = this.providers.data.stores['rgRow'].store.get('source');
|
|
1490
|
+
const { defaultPrevented, detail } = this.emit('beforefilterapply', {
|
|
1491
|
+
collection: this.filterCollection,
|
|
1492
|
+
source,
|
|
1493
|
+
columns,
|
|
1494
|
+
filterItems: this.multiFilterItems,
|
|
1495
|
+
});
|
|
1496
|
+
if (defaultPrevented) {
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
this.doFiltering(detail.collection, detail.source, detail.columns, detail.filterItems);
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1502
|
+
* Get trimmed rows based on filter
|
|
1503
|
+
*/
|
|
1504
|
+
getRowFilter(rows, filterItems, columnByProp) {
|
|
1505
|
+
const propKeys = Object.keys(filterItems);
|
|
1506
|
+
const trimmed = {};
|
|
1507
|
+
// each rows
|
|
1508
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
1509
|
+
// check filter by column properties
|
|
1510
|
+
for (const prop of propKeys) {
|
|
1511
|
+
// add to the list of removed/trimmed rows of filter condition is satisfied
|
|
1512
|
+
if (this.shouldTrimRow(filterItems[prop], prop, columnByProp[prop], rows[rowIndex])) {
|
|
1513
|
+
trimmed[rowIndex] = true;
|
|
1514
|
+
}
|
|
1515
|
+
} // end of for-of propKeys
|
|
1516
|
+
}
|
|
1517
|
+
return trimmed;
|
|
1518
|
+
}
|
|
1519
|
+
shouldTrimRow(propFilters, prop, column, model = {}) {
|
|
1520
|
+
// reset the count of satisfied filters
|
|
1521
|
+
let propFilterSatisfiedCount = 0;
|
|
1522
|
+
// reset the array of last filter results
|
|
1523
|
+
let lastFilterResults = [];
|
|
1524
|
+
// testing each filter for a prop
|
|
1525
|
+
for (const [filterIndex, filterData] of propFilters.entries()) {
|
|
1526
|
+
// the filter LogicFunction based on the type
|
|
1527
|
+
const filterFunc = this.filterFunctionsIndexedByType[filterData.type];
|
|
1528
|
+
// THE MAGIC OF FILTERING IS HERE
|
|
1529
|
+
// If there is no column but user wants to filter by a property
|
|
1530
|
+
const value = column ? getCellDataParsed(model, column) : model[prop];
|
|
1531
|
+
// OR relation
|
|
1532
|
+
if (filterData.relation === 'or') {
|
|
1533
|
+
// reset the array of last filter results
|
|
1534
|
+
lastFilterResults = [];
|
|
1535
|
+
// if the filter is satisfied, continue to the next filter
|
|
1536
|
+
if (filterFunc(value, filterData.value)) {
|
|
1537
|
+
continue;
|
|
1538
|
+
}
|
|
1539
|
+
// if the filter is not satisfied, count it
|
|
1540
|
+
propFilterSatisfiedCount++;
|
|
1541
|
+
// AND relation
|
|
1542
|
+
}
|
|
1543
|
+
else {
|
|
1544
|
+
// 'and' relation will need to know the next filter
|
|
1545
|
+
// so we save this current filter to include it in the next filter
|
|
1546
|
+
lastFilterResults.push(!filterFunc(value, filterData.value));
|
|
1547
|
+
if (isFinalAndFilter(filterIndex, propFilters)) {
|
|
1548
|
+
// let's just continue since for sure propFilterSatisfiedCount cannot be satisfied
|
|
1549
|
+
if (allAndConditionsSatisfied(lastFilterResults)) {
|
|
1550
|
+
// reset the array of last filter results
|
|
1551
|
+
lastFilterResults = [];
|
|
1552
|
+
continue;
|
|
1553
|
+
}
|
|
1554
|
+
// we need to add all of the lastFilterResults since we need to satisfy all
|
|
1555
|
+
propFilterSatisfiedCount += lastFilterResults.length;
|
|
1556
|
+
// reset the array of last filter results
|
|
1557
|
+
lastFilterResults = [];
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
} // end of propFilters forEach
|
|
1561
|
+
return propFilterSatisfiedCount === propFilters.length;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Checks if the current filter is the final one in an AND sequence.
|
|
1566
|
+
* @param index - Current filter index in the list.
|
|
1567
|
+
* @param filters - Array of filters for the property.
|
|
1568
|
+
* @returns True if this is the last AND condition; false otherwise.
|
|
1569
|
+
*/
|
|
1570
|
+
function isFinalAndFilter(index, filters) {
|
|
1571
|
+
const nextFilter = filters[index + 1]; // Get the next filter in the list.
|
|
1572
|
+
// Return true if there's no next filter or if the next filter defined and is not part of the AND sequence.
|
|
1573
|
+
return !nextFilter || (!!nextFilter.relation && nextFilter.relation !== 'and');
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* Determines if all conditions in an AND sequence are satisfied.
|
|
1577
|
+
* @param pendingResults - An array of results from the AND conditions.
|
|
1578
|
+
* @returns True if all conditions are satisfied; false otherwise.
|
|
1579
|
+
*/
|
|
1580
|
+
function allAndConditionsSatisfied(pendingResults) {
|
|
1581
|
+
// Check if there are any failed conditions in the pending results.
|
|
1582
|
+
return !pendingResults.includes(true);
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
/** `Object#toString` result references. */
|
|
1586
|
+
var stringTag = '[object String]';
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* Checks if `value` is classified as a `String` primitive or object.
|
|
1590
|
+
*
|
|
1591
|
+
* @static
|
|
1592
|
+
* @since 0.1.0
|
|
1593
|
+
* @memberOf _
|
|
1594
|
+
* @category Lang
|
|
1595
|
+
* @param {*} value The value to check.
|
|
1596
|
+
* @returns {boolean} Returns `true` if `value` is a string, else `false`.
|
|
1597
|
+
* @example
|
|
1598
|
+
*
|
|
1599
|
+
* _.isString('abc');
|
|
1600
|
+
* // => true
|
|
1601
|
+
*
|
|
1602
|
+
* _.isString(1);
|
|
1603
|
+
* // => false
|
|
1604
|
+
*/
|
|
1605
|
+
function isString(value) {
|
|
1606
|
+
return typeof value == 'string' ||
|
|
1607
|
+
(!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* Gets the size of an ASCII `string`.
|
|
1612
|
+
*
|
|
1613
|
+
* @private
|
|
1614
|
+
* @param {string} string The string inspect.
|
|
1615
|
+
* @returns {number} Returns the string size.
|
|
1616
|
+
*/
|
|
1617
|
+
var asciiSize = baseProperty('length');
|
|
1618
|
+
|
|
1619
|
+
/** Used to compose unicode character classes. */
|
|
1620
|
+
var rsAstralRange$1 = '\\ud800-\\udfff',
|
|
1621
|
+
rsComboMarksRange$1 = '\\u0300-\\u036f',
|
|
1622
|
+
reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f',
|
|
1623
|
+
rsComboSymbolsRange$1 = '\\u20d0-\\u20ff',
|
|
1624
|
+
rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1,
|
|
1625
|
+
rsVarRange$1 = '\\ufe0e\\ufe0f';
|
|
1626
|
+
|
|
1627
|
+
/** Used to compose unicode capture groups. */
|
|
1628
|
+
var rsZWJ$1 = '\\u200d';
|
|
1629
|
+
|
|
1630
|
+
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
|
|
1631
|
+
var reHasUnicode = RegExp('[' + rsZWJ$1 + rsAstralRange$1 + rsComboRange$1 + rsVarRange$1 + ']');
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* Checks if `string` contains Unicode symbols.
|
|
1635
|
+
*
|
|
1636
|
+
* @private
|
|
1637
|
+
* @param {string} string The string to inspect.
|
|
1638
|
+
* @returns {boolean} Returns `true` if a symbol is found, else `false`.
|
|
1639
|
+
*/
|
|
1640
|
+
function hasUnicode(string) {
|
|
1641
|
+
return reHasUnicode.test(string);
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
/** Used to compose unicode character classes. */
|
|
1645
|
+
var rsAstralRange = '\\ud800-\\udfff',
|
|
1646
|
+
rsComboMarksRange = '\\u0300-\\u036f',
|
|
1647
|
+
reComboHalfMarksRange = '\\ufe20-\\ufe2f',
|
|
1648
|
+
rsComboSymbolsRange = '\\u20d0-\\u20ff',
|
|
1649
|
+
rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
|
|
1650
|
+
rsVarRange = '\\ufe0e\\ufe0f';
|
|
1651
|
+
|
|
1652
|
+
/** Used to compose unicode capture groups. */
|
|
1653
|
+
var rsAstral = '[' + rsAstralRange + ']',
|
|
1654
|
+
rsCombo = '[' + rsComboRange + ']',
|
|
1655
|
+
rsFitz = '\\ud83c[\\udffb-\\udfff]',
|
|
1656
|
+
rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')',
|
|
1657
|
+
rsNonAstral = '[^' + rsAstralRange + ']',
|
|
1658
|
+
rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
|
|
1659
|
+
rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
|
|
1660
|
+
rsZWJ = '\\u200d';
|
|
1661
|
+
|
|
1662
|
+
/** Used to compose unicode regexes. */
|
|
1663
|
+
var reOptMod = rsModifier + '?',
|
|
1664
|
+
rsOptVar = '[' + rsVarRange + ']?',
|
|
1665
|
+
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
|
|
1666
|
+
rsSeq = rsOptVar + reOptMod + rsOptJoin,
|
|
1667
|
+
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
|
|
1668
|
+
|
|
1669
|
+
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
|
|
1670
|
+
var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
|
|
1671
|
+
|
|
1672
|
+
/**
|
|
1673
|
+
* Gets the size of a Unicode `string`.
|
|
1674
|
+
*
|
|
1675
|
+
* @private
|
|
1676
|
+
* @param {string} string The string inspect.
|
|
1677
|
+
* @returns {number} Returns the string size.
|
|
1678
|
+
*/
|
|
1679
|
+
function unicodeSize(string) {
|
|
1680
|
+
var result = reUnicode.lastIndex = 0;
|
|
1681
|
+
while (reUnicode.test(string)) {
|
|
1682
|
+
++result;
|
|
1683
|
+
}
|
|
1684
|
+
return result;
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
/**
|
|
1688
|
+
* Gets the number of symbols in `string`.
|
|
1689
|
+
*
|
|
1690
|
+
* @private
|
|
1691
|
+
* @param {string} string The string to inspect.
|
|
1692
|
+
* @returns {number} Returns the string size.
|
|
1693
|
+
*/
|
|
1694
|
+
function stringSize(string) {
|
|
1695
|
+
return hasUnicode(string)
|
|
1696
|
+
? unicodeSize(string)
|
|
1697
|
+
: asciiSize(string);
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
/** `Object#toString` result references. */
|
|
1701
|
+
var mapTag = '[object Map]',
|
|
1702
|
+
setTag = '[object Set]';
|
|
1703
|
+
|
|
1704
|
+
/**
|
|
1705
|
+
* Gets the size of `collection` by returning its length for array-like
|
|
1706
|
+
* values or the number of own enumerable string keyed properties for objects.
|
|
1707
|
+
*
|
|
1708
|
+
* @static
|
|
1709
|
+
* @memberOf _
|
|
1710
|
+
* @since 0.1.0
|
|
1711
|
+
* @category Collection
|
|
1712
|
+
* @param {Array|Object|string} collection The collection to inspect.
|
|
1713
|
+
* @returns {number} Returns the collection size.
|
|
1714
|
+
* @example
|
|
1715
|
+
*
|
|
1716
|
+
* _.size([1, 2, 3]);
|
|
1717
|
+
* // => 3
|
|
1718
|
+
*
|
|
1719
|
+
* _.size({ 'a': 1, 'b': 2 });
|
|
1720
|
+
* // => 2
|
|
1721
|
+
*
|
|
1722
|
+
* _.size('pebbles');
|
|
1723
|
+
* // => 7
|
|
1724
|
+
*/
|
|
1725
|
+
function size(collection) {
|
|
1726
|
+
if (collection == null) {
|
|
1727
|
+
return 0;
|
|
1728
|
+
}
|
|
1729
|
+
if (isArrayLike(collection)) {
|
|
1730
|
+
return isString(collection) ? stringSize(collection) : collection.length;
|
|
1731
|
+
}
|
|
1732
|
+
var tag = getTag(collection);
|
|
1733
|
+
if (tag == mapTag || tag == setTag) {
|
|
1734
|
+
return collection.size;
|
|
1735
|
+
}
|
|
1736
|
+
return baseKeys(collection).length;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
function sortIndexByItems(indexes, source, sortingFunc = {}) {
|
|
1740
|
+
// if no sorting - return unsorted indexes
|
|
1741
|
+
if (Object.entries(sortingFunc).length === 0) {
|
|
1742
|
+
// Unsorted indexes
|
|
1743
|
+
return [...Array(indexes.length).keys()];
|
|
1744
|
+
}
|
|
1745
|
+
//
|
|
1746
|
+
/**
|
|
1747
|
+
* go through all indexes and align in new order
|
|
1748
|
+
* performs a multi-level sorting by applying multiple comparison functions to determine the order of the items based on different properties.
|
|
1749
|
+
*/
|
|
1750
|
+
return indexes.sort((a, b) => {
|
|
1751
|
+
const itemA = source[a];
|
|
1752
|
+
const itemB = source[b];
|
|
1753
|
+
for (const [prop, cmp] of Object.entries(sortingFunc)) {
|
|
1754
|
+
if (isGrouping(itemA)) {
|
|
1755
|
+
if (itemA['__rvgr-prop'] !== prop) {
|
|
1756
|
+
return 0;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
if (isGrouping(itemB)) {
|
|
1760
|
+
if (itemB['__rvgr-prop'] !== prop) {
|
|
1761
|
+
return 0;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* 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.
|
|
1766
|
+
* 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.
|
|
1767
|
+
*/
|
|
1768
|
+
const sorted = cmp === null || cmp === void 0 ? void 0 : cmp(prop, itemA, itemB);
|
|
1769
|
+
if (sorted) {
|
|
1770
|
+
return sorted;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
return 0;
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
function defaultCellCompare(prop, a, b) {
|
|
1777
|
+
const aRaw = this.column ? getCellRaw(a, this.column) : a === null || a === void 0 ? void 0 : a[prop];
|
|
1778
|
+
const bRaw = this.column ? getCellRaw(b, this.column) : b === null || b === void 0 ? void 0 : b[prop];
|
|
1779
|
+
const av = typeof aRaw === 'number' ? aRaw : aRaw === null || aRaw === void 0 ? void 0 : aRaw.toString().toLowerCase();
|
|
1780
|
+
const bv = typeof bRaw === 'number' ? bRaw : bRaw === null || bRaw === void 0 ? void 0 : bRaw.toString().toLowerCase();
|
|
1781
|
+
if (av === bv) {
|
|
1782
|
+
return 0;
|
|
1783
|
+
}
|
|
1784
|
+
if (av > bv) {
|
|
1785
|
+
return 1;
|
|
1786
|
+
}
|
|
1787
|
+
return -1;
|
|
1788
|
+
}
|
|
1789
|
+
function descCellCompare(cmp) {
|
|
1790
|
+
return (prop, a, b) => {
|
|
1791
|
+
return -1 * cmp(prop, a, b);
|
|
1792
|
+
};
|
|
1793
|
+
}
|
|
1794
|
+
function getNextOrder(currentOrder) {
|
|
1795
|
+
switch (currentOrder) {
|
|
1796
|
+
case undefined:
|
|
1797
|
+
return 'asc';
|
|
1798
|
+
case 'asc':
|
|
1799
|
+
return 'desc';
|
|
1800
|
+
case 'desc':
|
|
1801
|
+
return undefined;
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
function getComparer(column, order) {
|
|
1805
|
+
var _a;
|
|
1806
|
+
const cellCmp = ((_a = column === null || column === void 0 ? void 0 : column.cellCompare) === null || _a === void 0 ? void 0 : _a.bind({ order })) || (defaultCellCompare === null || defaultCellCompare === void 0 ? void 0 : defaultCellCompare.bind({ column, order }));
|
|
1807
|
+
if (order == 'asc') {
|
|
1808
|
+
return cellCmp;
|
|
1809
|
+
}
|
|
1810
|
+
if (order == 'desc') {
|
|
1811
|
+
return descCellCompare(cellCmp);
|
|
1812
|
+
}
|
|
1813
|
+
return undefined;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/**
|
|
1817
|
+
* Lifecycle
|
|
1818
|
+
* 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.
|
|
1819
|
+
* 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.
|
|
1820
|
+
* 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.
|
|
1821
|
+
* 4. @event `aftersortingapply` - Triggered after sorting has been applied and completed. This event occurs for both row and column sorting.
|
|
1822
|
+
*
|
|
1823
|
+
* Note: If you prevent an event, it will not proceed to the subsequent steps.
|
|
1824
|
+
*/
|
|
1825
|
+
class SortingPlugin extends BasePlugin {
|
|
1826
|
+
constructor(revogrid, providers, config) {
|
|
1827
|
+
super(revogrid, providers);
|
|
1828
|
+
this.revogrid = revogrid;
|
|
1829
|
+
/**
|
|
1830
|
+
* Delayed sorting promise
|
|
1831
|
+
*/
|
|
1832
|
+
this.sortingPromise = null;
|
|
1833
|
+
/**
|
|
1834
|
+
* We need to sort only so often
|
|
1835
|
+
*/
|
|
1836
|
+
this.postponeSort = debounce((order, comparison, ignoreViewportUpdate) => this.runSorting(order, comparison, ignoreViewportUpdate), 50);
|
|
1837
|
+
const setConfig = (cfg) => {
|
|
1838
|
+
var _a;
|
|
1839
|
+
if (cfg) {
|
|
1840
|
+
const sortingFunc = {};
|
|
1841
|
+
const order = {};
|
|
1842
|
+
(_a = cfg.columns) === null || _a === void 0 ? void 0 : _a.forEach(col => {
|
|
1843
|
+
sortingFunc[col.prop] = getComparer(col, col.order);
|
|
1844
|
+
order[col.prop] = col.order;
|
|
1845
|
+
});
|
|
1846
|
+
if (cfg.additive) {
|
|
1847
|
+
this.sorting = Object.assign(Object.assign({}, this.sorting), order);
|
|
1848
|
+
this.sortingFunc = Object.assign(Object.assign({}, this.sortingFunc), sortingFunc);
|
|
1849
|
+
}
|
|
1850
|
+
else {
|
|
1851
|
+
// // set sorting
|
|
1852
|
+
this.sorting = order;
|
|
1853
|
+
this.sortingFunc = sortingFunc;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
};
|
|
1857
|
+
setConfig(config);
|
|
1858
|
+
this.addEventListener('sortingconfigchanged', ({ detail }) => {
|
|
1859
|
+
config = detail;
|
|
1860
|
+
setConfig(detail);
|
|
1861
|
+
this.startSorting(this.sorting, this.sortingFunc);
|
|
1862
|
+
});
|
|
1863
|
+
this.addEventListener('beforeheaderrender', ({ detail, }) => {
|
|
1864
|
+
var _a;
|
|
1865
|
+
const { data: column } = detail;
|
|
1866
|
+
if (column.sortable) {
|
|
1867
|
+
detail.data = Object.assign(Object.assign({}, column), { order: (_a = this.sorting) === null || _a === void 0 ? void 0 : _a[column.prop] });
|
|
1868
|
+
}
|
|
1869
|
+
});
|
|
1870
|
+
this.addEventListener('beforeanysource', ({ detail: { type }, }) => {
|
|
1871
|
+
// if sorting was provided - sort data
|
|
1872
|
+
if (!!this.sorting && this.sortingFunc) {
|
|
1873
|
+
const event = this.emit('beforesourcesortingapply', { type, sorting: this.sorting });
|
|
1874
|
+
if (event.defaultPrevented) {
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
this.startSorting(this.sorting, this.sortingFunc);
|
|
1878
|
+
}
|
|
1879
|
+
});
|
|
1880
|
+
this.addEventListener('aftercolumnsset', ({ detail: { order }, }) => {
|
|
1881
|
+
// if config provided - do nothing, read from config
|
|
1882
|
+
if (config) {
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
const columns = this.providers.column.getColumns();
|
|
1886
|
+
const sortingFunc = {};
|
|
1887
|
+
for (let prop in order) {
|
|
1888
|
+
const cmp = getComparer(getColumnByProp(columns, prop), order[prop]);
|
|
1889
|
+
sortingFunc[prop] = cmp;
|
|
1890
|
+
}
|
|
1891
|
+
// set sorting
|
|
1892
|
+
this.sorting = order;
|
|
1893
|
+
this.sortingFunc = order && sortingFunc;
|
|
1894
|
+
});
|
|
1895
|
+
this.addEventListener('beforeheaderclick', (e) => {
|
|
1896
|
+
var _a, _b, _c, _d;
|
|
1897
|
+
if (e.defaultPrevented) {
|
|
1898
|
+
return;
|
|
1899
|
+
}
|
|
1900
|
+
if (!((_b = (_a = e.detail) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.sortable)) {
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
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);
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Entry point for sorting, waits for all delayes, registers jobs
|
|
1908
|
+
*/
|
|
1909
|
+
startSorting(order, sortingFunc, ignoreViewportUpdate) {
|
|
1910
|
+
if (!this.sortingPromise) {
|
|
1911
|
+
// add job before render
|
|
1912
|
+
this.revogrid.jobsBeforeRender.push(new Promise(resolve => {
|
|
1913
|
+
this.sortingPromise = resolve;
|
|
1914
|
+
}));
|
|
1915
|
+
}
|
|
1916
|
+
this.postponeSort(order, sortingFunc, ignoreViewportUpdate);
|
|
1917
|
+
}
|
|
1918
|
+
/**
|
|
1919
|
+
* Apply sorting to data on header click
|
|
1920
|
+
* If additive - add to existing sorting, multiple columns can be sorted
|
|
1921
|
+
*/
|
|
1922
|
+
headerclick(column, additive) {
|
|
1923
|
+
var _a, _b, _c;
|
|
1924
|
+
const columnProp = column.prop;
|
|
1925
|
+
let order = getNextOrder((_a = this.sorting) === null || _a === void 0 ? void 0 : _a[columnProp]);
|
|
1926
|
+
const beforeEvent = this.emit('beforesorting', { column, order, additive });
|
|
1927
|
+
if (beforeEvent.defaultPrevented) {
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
order = beforeEvent.detail.order;
|
|
1931
|
+
// apply sort data
|
|
1932
|
+
const beforeApplyEvent = this.emit('beforesortingapply', {
|
|
1933
|
+
column: beforeEvent.detail.column,
|
|
1934
|
+
order,
|
|
1935
|
+
additive,
|
|
1936
|
+
});
|
|
1937
|
+
if (beforeApplyEvent.defaultPrevented) {
|
|
1938
|
+
return;
|
|
1939
|
+
}
|
|
1940
|
+
const cmp = getComparer(beforeApplyEvent.detail.column, beforeApplyEvent.detail.order);
|
|
1941
|
+
if (beforeApplyEvent.detail.additive && this.sorting) {
|
|
1942
|
+
const sorting = {};
|
|
1943
|
+
const sortingFunc = {};
|
|
1944
|
+
if (columnProp in sorting && size(sorting) > 1 && order === undefined) {
|
|
1945
|
+
delete sorting[columnProp];
|
|
1946
|
+
delete sortingFunc[columnProp];
|
|
1947
|
+
}
|
|
1948
|
+
else {
|
|
1949
|
+
sorting[columnProp] = order;
|
|
1950
|
+
sortingFunc[columnProp] = cmp;
|
|
1951
|
+
}
|
|
1952
|
+
this.sorting = Object.assign(Object.assign({}, this.sorting), sorting);
|
|
1953
|
+
// extend sorting function with new sorting for multiple columns sorting
|
|
1954
|
+
this.sortingFunc = Object.assign(Object.assign({}, this.sortingFunc), sortingFunc);
|
|
1955
|
+
}
|
|
1956
|
+
else {
|
|
1957
|
+
if (order) {
|
|
1958
|
+
// reset sorting
|
|
1959
|
+
this.sorting = { [columnProp]: order };
|
|
1960
|
+
this.sortingFunc = { [columnProp]: cmp };
|
|
1961
|
+
}
|
|
1962
|
+
else {
|
|
1963
|
+
(_b = this.sorting) === null || _b === void 0 ? true : delete _b[columnProp];
|
|
1964
|
+
(_c = this.sortingFunc) === null || _c === void 0 ? true : delete _c[columnProp];
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
this.startSorting(this.sorting, this.sortingFunc);
|
|
1968
|
+
}
|
|
1969
|
+
runSorting(order, comparison, ignoreViewportUpdate) {
|
|
1970
|
+
var _a;
|
|
1971
|
+
this.sort(order, comparison, undefined, ignoreViewportUpdate);
|
|
1972
|
+
(_a = this.sortingPromise) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
1973
|
+
this.sortingPromise = null;
|
|
1974
|
+
}
|
|
1975
|
+
/**
|
|
1976
|
+
* Sort items by sorting function
|
|
1977
|
+
* @requires proxyItems applied to row store
|
|
1978
|
+
* @requires source applied to row store
|
|
1979
|
+
*
|
|
1980
|
+
* @param sorting - per column sorting
|
|
1981
|
+
* @param data - this.stores['rgRow'].store.get('source')
|
|
1982
|
+
*/
|
|
1983
|
+
sort(sorting, sortingFunc, types = rowTypes, ignoreViewportUpdate = false) {
|
|
1984
|
+
// if no sorting - reset
|
|
1985
|
+
if (!Object.keys(sorting || {}).length) {
|
|
1986
|
+
for (let type of types) {
|
|
1987
|
+
const storeService = this.providers.data.stores[type];
|
|
1988
|
+
// row data
|
|
1989
|
+
const source = storeService.store.get('source');
|
|
1990
|
+
// row indexes
|
|
1991
|
+
const proxyItems = storeService.store.get('proxyItems');
|
|
1992
|
+
// row indexes
|
|
1993
|
+
const newItemsOrder = Array.from({ length: source.length }, (_, i) => i); // recover indexes range(0, source.length)
|
|
1994
|
+
this.providers.dimension.updateSizesPositionByNewDataIndexes(type, newItemsOrder, proxyItems);
|
|
1995
|
+
storeService.setData({ proxyItems: newItemsOrder, source: [...source], });
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
else {
|
|
1999
|
+
for (let type of types) {
|
|
2000
|
+
const storeService = this.providers.data.stores[type];
|
|
2001
|
+
// row data
|
|
2002
|
+
const source = storeService.store.get('source');
|
|
2003
|
+
// row indexes
|
|
2004
|
+
const proxyItems = storeService.store.get('proxyItems');
|
|
2005
|
+
const newItemsOrder = sortIndexByItems([...proxyItems], source, sortingFunc);
|
|
2006
|
+
// take row indexes before trim applied and proxy items
|
|
2007
|
+
const prevItems = storeService.store.get('items');
|
|
2008
|
+
storeService.setData({
|
|
2009
|
+
proxyItems: newItemsOrder,
|
|
2010
|
+
source: [...source],
|
|
2011
|
+
});
|
|
2012
|
+
// take currently visible row indexes
|
|
2013
|
+
const newItems = storeService.store.get('items');
|
|
2014
|
+
if (!ignoreViewportUpdate) {
|
|
2015
|
+
this.providers.dimension
|
|
2016
|
+
.updateSizesPositionByNewDataIndexes(type, newItems, prevItems);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
// refresh columns to redraw column headers and show correct icon
|
|
2021
|
+
columnTypes.forEach((type) => {
|
|
2022
|
+
this.providers.column.dataSources[type].refresh();
|
|
2023
|
+
});
|
|
2024
|
+
this.emit('aftersortingapply');
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
// provide collapse data
|
|
2029
|
+
function doCollapse(pIndex, source) {
|
|
2030
|
+
const model = source[pIndex];
|
|
2031
|
+
const collapseValue = model[PSEUDO_GROUP_ITEM_VALUE];
|
|
2032
|
+
const trimmed = {};
|
|
2033
|
+
let i = pIndex + 1;
|
|
2034
|
+
const total = source.length;
|
|
2035
|
+
while (i < total) {
|
|
2036
|
+
const currentModel = source[i];
|
|
2037
|
+
if (isGrouping(currentModel)) {
|
|
2038
|
+
const currentValue = currentModel[PSEUDO_GROUP_ITEM_VALUE];
|
|
2039
|
+
if (!currentValue.length || !currentValue.startsWith(collapseValue + ',')) {
|
|
2040
|
+
break;
|
|
2041
|
+
}
|
|
2042
|
+
currentModel[GROUP_EXPANDED] = false;
|
|
2043
|
+
}
|
|
2044
|
+
trimmed[i++] = true;
|
|
2045
|
+
}
|
|
2046
|
+
model[GROUP_EXPANDED] = false;
|
|
2047
|
+
return { trimmed };
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
*
|
|
2051
|
+
* @param pIndex - physical index
|
|
2052
|
+
* @param vIndex - virtual index, need to update item collection
|
|
2053
|
+
* @param source - data source
|
|
2054
|
+
* @param rowItemsIndexes - rgRow indexes
|
|
2055
|
+
*/
|
|
2056
|
+
function doExpand(vIndex, source, rowItemsIndexes) {
|
|
2057
|
+
const physicalIndex = rowItemsIndexes[vIndex];
|
|
2058
|
+
const model = source[physicalIndex];
|
|
2059
|
+
const currentGroup = getParsedGroup(model[PSEUDO_GROUP_ITEM_ID]);
|
|
2060
|
+
const trimmed = {};
|
|
2061
|
+
// no group found
|
|
2062
|
+
if (!currentGroup) {
|
|
2063
|
+
return { trimmed };
|
|
2064
|
+
}
|
|
2065
|
+
const groupItems = [];
|
|
2066
|
+
model[GROUP_EXPANDED] = true;
|
|
2067
|
+
let i = physicalIndex + 1;
|
|
2068
|
+
const total = source.length;
|
|
2069
|
+
let groupLevelOnly = 0;
|
|
2070
|
+
// go through all rows
|
|
2071
|
+
while (i < total) {
|
|
2072
|
+
const currentModel = source[i];
|
|
2073
|
+
const isGroup = isGrouping(currentModel);
|
|
2074
|
+
// group found
|
|
2075
|
+
if (isGroup) {
|
|
2076
|
+
if (!isSameGroup(currentGroup, model, currentModel)) {
|
|
2077
|
+
break;
|
|
2078
|
+
}
|
|
2079
|
+
else if (!groupLevelOnly) {
|
|
2080
|
+
// if get group first it's group only level
|
|
2081
|
+
groupLevelOnly = currentModel[GROUP_DEPTH];
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
// level 0 or same depth
|
|
2085
|
+
if (!groupLevelOnly || (isGroup && groupLevelOnly === currentModel[GROUP_DEPTH])) {
|
|
2086
|
+
trimmed[i] = false;
|
|
2087
|
+
groupItems.push(i);
|
|
2088
|
+
}
|
|
2089
|
+
i++;
|
|
2090
|
+
}
|
|
2091
|
+
const result = {
|
|
2092
|
+
trimmed,
|
|
2093
|
+
};
|
|
2094
|
+
if (groupItems.length) {
|
|
2095
|
+
const items = [...rowItemsIndexes];
|
|
2096
|
+
items.splice(vIndex + 1, 0, ...groupItems);
|
|
2097
|
+
result.items = items;
|
|
2098
|
+
}
|
|
2099
|
+
return result;
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
const TRIMMED_GROUPING = 'grouping';
|
|
2103
|
+
/**
|
|
2104
|
+
* Prepare trimming updated indexes for grouping
|
|
2105
|
+
* @param initiallyTrimed
|
|
2106
|
+
* @param firstLevelMap
|
|
2107
|
+
* @param secondLevelMap
|
|
2108
|
+
*/
|
|
2109
|
+
function processDoubleConversionTrimmed(initiallyTrimed, firstLevelMap, secondLevelMap) {
|
|
2110
|
+
const trimemedOptionsToUpgrade = {};
|
|
2111
|
+
/**
|
|
2112
|
+
* go through all groups except grouping
|
|
2113
|
+
*/
|
|
2114
|
+
for (let type in initiallyTrimed) {
|
|
2115
|
+
if (type === TRIMMED_GROUPING) {
|
|
2116
|
+
continue;
|
|
2117
|
+
}
|
|
2118
|
+
const items = initiallyTrimed[type];
|
|
2119
|
+
const newItems = {};
|
|
2120
|
+
for (let initialIndex in items) {
|
|
2121
|
+
/**
|
|
2122
|
+
* if item exists we find it in collection
|
|
2123
|
+
* we support 2 level of conversions
|
|
2124
|
+
*/
|
|
2125
|
+
let newConversionIndex = firstLevelMap[initialIndex];
|
|
2126
|
+
if (secondLevelMap) {
|
|
2127
|
+
newConversionIndex = secondLevelMap[newConversionIndex];
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* if item was trimmed previously
|
|
2131
|
+
* trimming makes sense to apply
|
|
2132
|
+
*/
|
|
2133
|
+
if (items[initialIndex]) {
|
|
2134
|
+
newItems[newConversionIndex] = true;
|
|
2135
|
+
/**
|
|
2136
|
+
* If changes present apply changes to new source
|
|
2137
|
+
*/
|
|
2138
|
+
if (newConversionIndex !== parseInt(initialIndex, 10)) {
|
|
2139
|
+
trimemedOptionsToUpgrade[type] = newItems;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
return trimemedOptionsToUpgrade;
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
class GroupingRowPlugin extends BasePlugin {
|
|
2148
|
+
getStore(type = GROUPING_ROW_TYPE) {
|
|
2149
|
+
return this.providers.data.stores[type].store;
|
|
2150
|
+
}
|
|
2151
|
+
constructor(revogrid, providers) {
|
|
2152
|
+
super(revogrid, providers);
|
|
2153
|
+
}
|
|
2154
|
+
// befoce cell focus
|
|
2155
|
+
onFocus(e) {
|
|
2156
|
+
if (isGrouping(e.detail.model)) {
|
|
2157
|
+
e.preventDefault();
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
// expand event triggered
|
|
2161
|
+
onExpand({ virtualIndex }) {
|
|
2162
|
+
const { source } = getSource(this.getStore().get('source'), this.getStore().get('proxyItems'));
|
|
2163
|
+
let newTrimmed = this.getStore().get('trimmed')[TRIMMED_GROUPING];
|
|
2164
|
+
let i = getPhysical(this.getStore(), virtualIndex);
|
|
2165
|
+
const isExpanded = getExpanded(source[i]);
|
|
2166
|
+
if (!isExpanded) {
|
|
2167
|
+
const { trimmed, items } = doExpand(virtualIndex, source, this.getStore().get('items'));
|
|
2168
|
+
newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
|
|
2169
|
+
if (items) {
|
|
2170
|
+
setItems(this.getStore(), items);
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
else {
|
|
2174
|
+
const { trimmed } = doCollapse(i, source);
|
|
2175
|
+
newTrimmed = Object.assign(Object.assign({}, newTrimmed), trimmed);
|
|
2176
|
+
this.revogrid.clearFocus();
|
|
2177
|
+
}
|
|
2178
|
+
this.getStore().set('source', source);
|
|
2179
|
+
this.revogrid.addTrimmed(newTrimmed, TRIMMED_GROUPING);
|
|
2180
|
+
}
|
|
2181
|
+
setColumnGrouping(cols) {
|
|
2182
|
+
// if 0 column as holder
|
|
2183
|
+
if (cols === null || cols === void 0 ? void 0 : cols.length) {
|
|
2184
|
+
cols[0][PSEUDO_GROUP_COLUMN] = true;
|
|
2185
|
+
return true;
|
|
2186
|
+
}
|
|
2187
|
+
return false;
|
|
2188
|
+
}
|
|
2189
|
+
setColumns({ columns }) {
|
|
2190
|
+
for (let type of columnTypes) {
|
|
2191
|
+
if (this.setColumnGrouping(columns[type])) {
|
|
2192
|
+
break;
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
// evaluate drag between groups
|
|
2197
|
+
onDrag(e) {
|
|
2198
|
+
const { from, to } = e.detail;
|
|
2199
|
+
const isDown = to - from >= 0;
|
|
2200
|
+
const { source } = getSource(this.getStore().get('source'), this.getStore().get('proxyItems'));
|
|
2201
|
+
const items = this.getStore().get('items');
|
|
2202
|
+
let i = isDown ? from : to;
|
|
2203
|
+
const end = isDown ? to : from;
|
|
2204
|
+
for (; i < end; i++) {
|
|
2205
|
+
const model = source[items[i]];
|
|
2206
|
+
const isGroup = isGrouping(model);
|
|
2207
|
+
if (isGroup) {
|
|
2208
|
+
e.preventDefault();
|
|
2209
|
+
return;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
beforeTrimmedApply(trimmed, type) {
|
|
2214
|
+
/** Before filter apply remove grouping filtering */
|
|
2215
|
+
if (type === FILTER_TRIMMED_TYPE) {
|
|
2216
|
+
const source = this.getStore().get('source');
|
|
2217
|
+
for (let index in trimmed) {
|
|
2218
|
+
if (trimmed[index] && isGrouping(source[index])) {
|
|
2219
|
+
trimmed[index] = false;
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
isSortingRunning() {
|
|
2225
|
+
const sortingPlugin = this.providers.plugins.getByClass(SortingPlugin);
|
|
2226
|
+
return !!(sortingPlugin === null || sortingPlugin === void 0 ? void 0 : sortingPlugin.sortingPromise);
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Starts global source update with group clearing and applying new one
|
|
2230
|
+
* Initiated when need to reapply grouping
|
|
2231
|
+
*/
|
|
2232
|
+
doSourceUpdate(options) {
|
|
2233
|
+
var _a;
|
|
2234
|
+
/**
|
|
2235
|
+
* Get source without grouping
|
|
2236
|
+
* @param newOldIndexMap - provides us mapping with new indexes vs old indexes, we would use it for trimmed mapping
|
|
2237
|
+
*/
|
|
2238
|
+
const store = this.getStore();
|
|
2239
|
+
const { source, prevExpanded, oldNewIndexes } = getSource(store.get('source'), store.get('proxyItems'), true);
|
|
2240
|
+
const expanded = Object.assign({ prevExpanded }, options);
|
|
2241
|
+
/**
|
|
2242
|
+
* Group again
|
|
2243
|
+
* @param oldNewIndexMap - provides us mapping with new indexes vs old indexes
|
|
2244
|
+
*/
|
|
2245
|
+
const { sourceWithGroups, depth, trimmed, oldNewIndexMap, } = gatherGrouping(source, ((_a = this.options) === null || _a === void 0 ? void 0 : _a.props) || [], expanded);
|
|
2246
|
+
const customRenderer = options === null || options === void 0 ? void 0 : options.groupLabelTemplate;
|
|
2247
|
+
// setup source
|
|
2248
|
+
this.providers.data.setData(sourceWithGroups, GROUPING_ROW_TYPE, this.revogrid.disableVirtualY, { depth, customRenderer }, true);
|
|
2249
|
+
this.updateTrimmed(trimmed, oldNewIndexes !== null && oldNewIndexes !== void 0 ? oldNewIndexes : {}, oldNewIndexMap);
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* Apply grouping on data set
|
|
2253
|
+
* Clear grouping from source
|
|
2254
|
+
* If source came from other plugin
|
|
2255
|
+
*/
|
|
2256
|
+
onDataSet(data) {
|
|
2257
|
+
var _a, _b;
|
|
2258
|
+
let preservedExpanded = {};
|
|
2259
|
+
if (((_a = this.options) === null || _a === void 0 ? void 0 : _a.preserveGroupingOnUpdate) !== false) {
|
|
2260
|
+
let { prevExpanded } = getSource(this.getStore().get('source'), this.getStore().get('proxyItems'), true);
|
|
2261
|
+
preservedExpanded = prevExpanded;
|
|
2262
|
+
}
|
|
2263
|
+
const source = data.source.filter(s => !isGrouping(s));
|
|
2264
|
+
const options = Object.assign(Object.assign({}, (this.revogrid.grouping || {})), { prevExpanded: preservedExpanded });
|
|
2265
|
+
const { sourceWithGroups, depth, trimmed, oldNewIndexMap, } = gatherGrouping(source, ((_b = this.options) === null || _b === void 0 ? void 0 : _b.props) || [], options);
|
|
2266
|
+
data.source = sourceWithGroups;
|
|
2267
|
+
this.providers.data.setGrouping({ depth });
|
|
2268
|
+
this.updateTrimmed(trimmed, oldNewIndexMap);
|
|
2269
|
+
}
|
|
2270
|
+
/**
|
|
2271
|
+
* External call to apply grouping. Called by revogrid when prop changed.
|
|
2272
|
+
*/
|
|
2273
|
+
setGrouping(options) {
|
|
2274
|
+
var _a, _b;
|
|
2275
|
+
// unsubscribe from all events when group applied
|
|
2276
|
+
this.clearSubscriptions();
|
|
2277
|
+
this.options = options;
|
|
2278
|
+
// clear props, no grouping exists
|
|
2279
|
+
if (!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
2280
|
+
this.clearGrouping();
|
|
2281
|
+
return;
|
|
2282
|
+
}
|
|
2283
|
+
// props exist and source initd
|
|
2284
|
+
const store = this.getStore();
|
|
2285
|
+
const { source } = getSource(store.get('source'), store.get('proxyItems'));
|
|
2286
|
+
if (source.length) {
|
|
2287
|
+
this.doSourceUpdate(Object.assign({}, options));
|
|
2288
|
+
}
|
|
2289
|
+
// props exist and columns initd
|
|
2290
|
+
for (let t of columnTypes) {
|
|
2291
|
+
if (this.setColumnGrouping(this.providers.column.getColumns(t))) {
|
|
2292
|
+
this.providers.column.refreshByType(t);
|
|
2293
|
+
break;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
// if has any grouping subscribe to events again
|
|
2297
|
+
/** if grouping present and new data source arrived */
|
|
2298
|
+
this.addEventListener('beforesourceset', ({ detail }) => {
|
|
2299
|
+
var _a, _b, _c;
|
|
2300
|
+
if (!(((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length) && ((_c = detail === null || detail === void 0 ? void 0 : detail.source) === null || _c === void 0 ? void 0 : _c.length))) {
|
|
2301
|
+
return;
|
|
2302
|
+
}
|
|
2303
|
+
// if sorting is running don't apply grouping, wait for sorting, then it'll apply in @aftersortingapply
|
|
2304
|
+
if (this.isSortingRunning()) {
|
|
2305
|
+
return;
|
|
2306
|
+
}
|
|
2307
|
+
this.onDataSet(detail);
|
|
2308
|
+
});
|
|
2309
|
+
this.addEventListener('beforecolumnsset', ({ detail }) => {
|
|
2310
|
+
this.setColumns(detail);
|
|
2311
|
+
});
|
|
2312
|
+
/**
|
|
2313
|
+
* filter applied need to clear grouping and apply again
|
|
2314
|
+
* based on new results can be new grouping
|
|
2315
|
+
*/
|
|
2316
|
+
this.addEventListener('beforetrimmed', ({ detail: { trimmed, trimmedType } }) => this.beforeTrimmedApply(trimmed, trimmedType));
|
|
2317
|
+
/**
|
|
2318
|
+
* sorting applied need to clear grouping and apply again
|
|
2319
|
+
* based on new results whole grouping order will changed
|
|
2320
|
+
*/
|
|
2321
|
+
this.addEventListener('aftersortingapply', () => {
|
|
2322
|
+
var _a, _b;
|
|
2323
|
+
if (!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
this.doSourceUpdate(Object.assign({}, this.options));
|
|
2327
|
+
});
|
|
2328
|
+
/**
|
|
2329
|
+
* Apply logic for focus inside of grouping
|
|
2330
|
+
* We can't focus on grouping rows, navigation only inside of groups for now
|
|
2331
|
+
*/
|
|
2332
|
+
this.addEventListener('beforecellfocus', e => this.onFocus(e));
|
|
2333
|
+
/**
|
|
2334
|
+
* Prevent rgRow drag outside the group
|
|
2335
|
+
*/
|
|
2336
|
+
this.addEventListener('roworderchanged', e => this.onDrag(e));
|
|
2337
|
+
/**
|
|
2338
|
+
* When grouping expand icon was clicked
|
|
2339
|
+
*/
|
|
2340
|
+
this.addEventListener(GROUP_EXPAND_EVENT, e => this.onExpand(e.detail));
|
|
2341
|
+
}
|
|
2342
|
+
// clear grouping
|
|
2343
|
+
clearGrouping() {
|
|
2344
|
+
// clear columns
|
|
2345
|
+
columnTypes.forEach(t => {
|
|
2346
|
+
const cols = this.providers.column.getColumns(t);
|
|
2347
|
+
let deleted = false;
|
|
2348
|
+
cols.forEach(c => {
|
|
2349
|
+
if (isGroupingColumn(c)) {
|
|
2350
|
+
delete c[PSEUDO_GROUP_COLUMN];
|
|
2351
|
+
deleted = true;
|
|
2352
|
+
}
|
|
2353
|
+
});
|
|
2354
|
+
// if column store had grouping clear and refresh
|
|
2355
|
+
if (deleted) {
|
|
2356
|
+
this.providers.column.refreshByType(t);
|
|
2357
|
+
}
|
|
2358
|
+
});
|
|
2359
|
+
// clear rows
|
|
2360
|
+
const { source, oldNewIndexes } = getSource(this.getStore().get('source'), this.getStore().get('proxyItems'), true);
|
|
2361
|
+
this.providers.data.setData(source, GROUPING_ROW_TYPE, this.revogrid.disableVirtualY, undefined, true);
|
|
2362
|
+
this.updateTrimmed(undefined, undefined, oldNewIndexes);
|
|
2363
|
+
}
|
|
2364
|
+
updateTrimmed(trimmedGroup = {}, firstLevelMap = {}, secondLevelMap) {
|
|
2365
|
+
// map previously trimmed data
|
|
2366
|
+
const trimemedOptionsToUpgrade = processDoubleConversionTrimmed(this.getStore().get('trimmed'), firstLevelMap, secondLevelMap);
|
|
2367
|
+
for (let type in trimemedOptionsToUpgrade) {
|
|
2368
|
+
this.revogrid.addTrimmed(trimemedOptionsToUpgrade[type], type);
|
|
2369
|
+
}
|
|
2370
|
+
// const emptyGroups = this.filterOutEmptyGroups(trimemedOptionsToUpgrade, childrenByGroup);
|
|
2371
|
+
// setup trimmed data for grouping
|
|
2372
|
+
this.revogrid.addTrimmed(Object.assign({}, trimmedGroup), TRIMMED_GROUPING);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
const COLUMN_DRAG_CLASS = 'column-drag-start';
|
|
2377
|
+
class ColumnOrderHandler {
|
|
2378
|
+
constructor() {
|
|
2379
|
+
this.offset = 0;
|
|
2380
|
+
}
|
|
2381
|
+
renderAutoscroll(_, parent) {
|
|
2382
|
+
if (!parent) {
|
|
2383
|
+
return;
|
|
2384
|
+
}
|
|
2385
|
+
this.autoscrollEl = document.createElement('div');
|
|
2386
|
+
this.autoscrollEl.classList.add('drag-auto-scroll-y');
|
|
2387
|
+
parent.appendChild(this.autoscrollEl);
|
|
2388
|
+
}
|
|
2389
|
+
autoscroll(pos, dataContainerSize, direction = 'translateX') {
|
|
2390
|
+
if (!this.autoscrollEl) {
|
|
2391
|
+
return;
|
|
2392
|
+
}
|
|
2393
|
+
const helperOffset = 10;
|
|
2394
|
+
// calculate current y position inside of the grid active holder
|
|
2395
|
+
// 3 - size of element + border
|
|
2396
|
+
const maxScroll = Math.min(pos + helperOffset, dataContainerSize - 3);
|
|
2397
|
+
this.autoscrollEl.style.transform = `${direction}(${maxScroll}px)`;
|
|
2398
|
+
this.autoscrollEl.scrollIntoView({
|
|
2399
|
+
block: 'nearest',
|
|
2400
|
+
inline: 'nearest',
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2403
|
+
start(e, { dataEl, gridRect, scrollEl, gridEl, }, dir = 'left') {
|
|
2404
|
+
gridEl.classList.add(COLUMN_DRAG_CLASS);
|
|
2405
|
+
const scrollContainerRect = scrollEl.getBoundingClientRect();
|
|
2406
|
+
if (scrollContainerRect) {
|
|
2407
|
+
this.offset = scrollContainerRect[dir] - gridRect[dir];
|
|
2408
|
+
}
|
|
2409
|
+
this.renderAutoscroll(e, dataEl);
|
|
2410
|
+
}
|
|
2411
|
+
stop(gridEl) {
|
|
2412
|
+
var _a;
|
|
2413
|
+
gridEl.classList.remove(COLUMN_DRAG_CLASS);
|
|
2414
|
+
if (this.element) {
|
|
2415
|
+
this.element.hidden = true;
|
|
2416
|
+
}
|
|
2417
|
+
this.offset = 0;
|
|
2418
|
+
(_a = this.autoscrollEl) === null || _a === void 0 ? void 0 : _a.remove();
|
|
2419
|
+
this.autoscrollEl = undefined;
|
|
2420
|
+
}
|
|
2421
|
+
showHandler(pos, size, columnWidth, direction = 'translateX') {
|
|
2422
|
+
if (!this.element) {
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2425
|
+
// do not allow overcross top of the scrollable area, header excluded
|
|
2426
|
+
if (this.offset) {
|
|
2427
|
+
pos = Math.max(pos, this.offset);
|
|
2428
|
+
}
|
|
2429
|
+
// can not be bigger then grid end
|
|
2430
|
+
pos = Math.min(pos, size);
|
|
2431
|
+
this.element.style.transform = `${direction}(${pos}px)`;
|
|
2432
|
+
this.element.style.width = `${columnWidth}px`;
|
|
2433
|
+
this.element.style.opacity = `10%`;
|
|
2434
|
+
this.element.hidden = false;
|
|
2435
|
+
}
|
|
2436
|
+
render() {
|
|
2437
|
+
const el = (this.element = document.createElement('div'));
|
|
2438
|
+
el.classList.add('drag-position-y');
|
|
2439
|
+
el.hidden = true;
|
|
2440
|
+
return el;
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
/**
|
|
2445
|
+
* Plugin for column manual move
|
|
2446
|
+
*/
|
|
2447
|
+
const COLUMN_CLICK = ON_COLUMN_CLICK;
|
|
2448
|
+
const MOVE = 'columndragmousemove';
|
|
2449
|
+
const DRAG_END = 'columndragend';
|
|
2450
|
+
const BEFORE_DRAG_END = 'beforecolumndragend';
|
|
2451
|
+
// use this event subscription to drop D&D for particular columns
|
|
2452
|
+
const DRAG_START = 'columndragstart';
|
|
2453
|
+
class ColumnMovePlugin extends BasePlugin {
|
|
2454
|
+
constructor(revogrid, providers) {
|
|
2455
|
+
super(revogrid, providers);
|
|
2456
|
+
this.revogrid = revogrid;
|
|
2457
|
+
this.providers = providers;
|
|
2458
|
+
this.moveFunc = debounce((e) => this.doMove(e), 5);
|
|
2459
|
+
this.staticDragData = null;
|
|
2460
|
+
this.dragData = null;
|
|
2461
|
+
this.localSubscriptions = {};
|
|
2462
|
+
this.orderUi = new ColumnOrderHandler();
|
|
2463
|
+
revogrid.appendChild(this.orderUi.render());
|
|
2464
|
+
revogrid.classList.add('column-draggable');
|
|
2465
|
+
// Register events
|
|
2466
|
+
this.localSubscriptions['mouseleave'] = {
|
|
2467
|
+
target: document,
|
|
2468
|
+
callback: (e) => this.onMouseOut(e),
|
|
2469
|
+
};
|
|
2470
|
+
this.localSubscriptions['mouseup'] = {
|
|
2471
|
+
target: document,
|
|
2472
|
+
callback: (e) => this.onMouseUp(e),
|
|
2473
|
+
};
|
|
2474
|
+
this.localSubscriptions['mousemove'] = {
|
|
2475
|
+
target: document,
|
|
2476
|
+
callback: (e) => this.move(e),
|
|
2477
|
+
};
|
|
2478
|
+
this.addEventListener(COLUMN_CLICK, ({ detail }) => this.dragStart(detail));
|
|
2479
|
+
}
|
|
2480
|
+
dragStart({ event, data }) {
|
|
2481
|
+
if (event.defaultPrevented) {
|
|
2482
|
+
return;
|
|
2483
|
+
}
|
|
2484
|
+
const { defaultPrevented } = dispatch(this.revogrid, DRAG_START, data);
|
|
2485
|
+
// check if allowed to drag particulat column
|
|
2486
|
+
if (defaultPrevented) {
|
|
2487
|
+
return;
|
|
2488
|
+
}
|
|
2489
|
+
this.clearOrder();
|
|
2490
|
+
const { mouseleave, mouseup, mousemove } = this.localSubscriptions;
|
|
2491
|
+
mouseleave.target.addEventListener('mouseleave', mouseleave.callback);
|
|
2492
|
+
mouseup.target.addEventListener('mouseup', mouseup.callback);
|
|
2493
|
+
const dataEl = event.target.closest('revogr-header');
|
|
2494
|
+
const scrollEl = event.target.closest('revogr-viewport-scroll');
|
|
2495
|
+
if (!dataEl || !scrollEl) {
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
// no grouping drag and no row header column drag
|
|
2499
|
+
if (isColGrouping(data) || data.providers.type === 'rowHeaders') {
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
const cols = this.getDimension(data.pin || 'rgCol');
|
|
2503
|
+
const gridRect = this.revogrid.getBoundingClientRect();
|
|
2504
|
+
const elRect = dataEl.getBoundingClientRect();
|
|
2505
|
+
const startItem = getItemByPosition(cols, getLeftRelative(event.x, gridRect.left, elRect.left - gridRect.left));
|
|
2506
|
+
this.staticDragData = {
|
|
2507
|
+
startPos: event.x,
|
|
2508
|
+
startItem,
|
|
2509
|
+
data,
|
|
2510
|
+
dataEl,
|
|
2511
|
+
scrollEl,
|
|
2512
|
+
gridEl: this.revogrid,
|
|
2513
|
+
cols,
|
|
2514
|
+
};
|
|
2515
|
+
this.dragData = this.getData(this.staticDragData);
|
|
2516
|
+
mousemove.target.addEventListener('mousemove', mousemove.callback);
|
|
2517
|
+
this.orderUi.start(event, Object.assign(Object.assign({}, this.dragData), this.staticDragData));
|
|
2518
|
+
}
|
|
2519
|
+
doMove(e) {
|
|
2520
|
+
if (!this.staticDragData) {
|
|
2521
|
+
return;
|
|
2522
|
+
}
|
|
2523
|
+
const dragData = (this.dragData = this.getData(this.staticDragData));
|
|
2524
|
+
if (!dragData) {
|
|
2525
|
+
return;
|
|
2526
|
+
}
|
|
2527
|
+
const start = this.staticDragData.startPos;
|
|
2528
|
+
if (Math.abs(start - e.x) > 10) {
|
|
2529
|
+
const x = getLeftRelative(e.x, this.dragData.gridRect.left, this.dragData.scrollOffset);
|
|
2530
|
+
const rgCol = getItemByPosition(this.staticDragData.cols, x);
|
|
2531
|
+
this.orderUi.autoscroll(x, dragData.elRect.width);
|
|
2532
|
+
// prevent position change if out of bounds
|
|
2533
|
+
if (rgCol.itemIndex >= this.staticDragData.cols.count) {
|
|
2534
|
+
return;
|
|
2535
|
+
}
|
|
2536
|
+
this.orderUi.showHandler(rgCol.start + dragData.scrollOffset, dragData.gridRect.width, Math.abs(rgCol.end - rgCol.start));
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
move(e) {
|
|
2540
|
+
dispatch(this.revogrid, MOVE, e);
|
|
2541
|
+
// then do move
|
|
2542
|
+
this.moveFunc(e);
|
|
2543
|
+
}
|
|
2544
|
+
onMouseOut(_) {
|
|
2545
|
+
this.clearOrder();
|
|
2546
|
+
}
|
|
2547
|
+
onMouseUp(e) {
|
|
2548
|
+
// apply new positions
|
|
2549
|
+
if (this.dragData && this.staticDragData) {
|
|
2550
|
+
let relativePos = getLeftRelative(e.x, this.dragData.gridRect.left, this.dragData.scrollOffset);
|
|
2551
|
+
if (relativePos < 0) {
|
|
2552
|
+
relativePos = 0;
|
|
2553
|
+
}
|
|
2554
|
+
const newPosition = getItemByPosition(this.staticDragData.cols, relativePos);
|
|
2555
|
+
const store = this.providers.column.stores[this.dragData.type].store;
|
|
2556
|
+
const newItems = [...store.get('items')];
|
|
2557
|
+
const allColumns = store.get('source');
|
|
2558
|
+
const onDropColumn = allColumns[newPosition.itemIndex];
|
|
2559
|
+
// prevent position change if needed
|
|
2560
|
+
const { defaultPrevented: stopDrag } = dispatch(this.revogrid, BEFORE_DRAG_END, Object.assign(Object.assign({}, this.staticDragData), { startPosition: this.staticDragData.startItem, newPosition, newItem: store.get('source')[newItems[this.staticDragData.startItem.itemIndex]] }));
|
|
2561
|
+
if (!stopDrag && onDropColumn && onDropColumn.draggable !== false) {
|
|
2562
|
+
const prevItems = [...newItems];
|
|
2563
|
+
// todo: if move item out of group remove item from group
|
|
2564
|
+
const toMove = newItems.splice(this.staticDragData.startItem.itemIndex, 1);
|
|
2565
|
+
newItems.splice(newPosition.itemIndex, 0, ...toMove);
|
|
2566
|
+
store.set('items', newItems);
|
|
2567
|
+
this.providers.dimension.updateSizesPositionByNewDataIndexes(this.dragData.type, newItems, prevItems);
|
|
2568
|
+
}
|
|
2569
|
+
dispatch(this.revogrid, DRAG_END, this.dragData);
|
|
2570
|
+
}
|
|
2571
|
+
this.clearOrder();
|
|
2572
|
+
}
|
|
2573
|
+
clearLocalSubscriptions() {
|
|
2574
|
+
forEach(this.localSubscriptions, ({ target, callback }, key) => target.removeEventListener(key, callback));
|
|
2575
|
+
}
|
|
2576
|
+
clearOrder() {
|
|
2577
|
+
this.staticDragData = null;
|
|
2578
|
+
this.dragData = null;
|
|
2579
|
+
this.clearLocalSubscriptions();
|
|
2580
|
+
this.orderUi.stop(this.revogrid);
|
|
2581
|
+
}
|
|
2582
|
+
/**
|
|
2583
|
+
* Clearing subscription
|
|
2584
|
+
*/
|
|
2585
|
+
clearSubscriptions() {
|
|
2586
|
+
super.clearSubscriptions();
|
|
2587
|
+
this.clearLocalSubscriptions();
|
|
2588
|
+
}
|
|
2589
|
+
getData({ gridEl, dataEl, data }) {
|
|
2590
|
+
const gridRect = gridEl.getBoundingClientRect();
|
|
2591
|
+
const elRect = dataEl.getBoundingClientRect();
|
|
2592
|
+
const scrollOffset = elRect.left - gridRect.left;
|
|
2593
|
+
return {
|
|
2594
|
+
elRect,
|
|
2595
|
+
gridRect,
|
|
2596
|
+
type: data.pin || 'rgCol',
|
|
2597
|
+
scrollOffset,
|
|
2598
|
+
};
|
|
2599
|
+
}
|
|
2600
|
+
getDimension(type) {
|
|
2601
|
+
return this.providers.dimension.stores[type].getCurrentState();
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
function getLeftRelative(absoluteX, gridPos, offset) {
|
|
2605
|
+
return absoluteX - gridPos - offset;
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
class ColumnDataProvider {
|
|
2609
|
+
get stores() {
|
|
2610
|
+
return this.dataSources;
|
|
2611
|
+
}
|
|
2612
|
+
constructor() {
|
|
2613
|
+
this.collection = null;
|
|
2614
|
+
this.dataSources = columnTypes.reduce((sources, k) => {
|
|
2615
|
+
sources[k] = new DataStore(k);
|
|
2616
|
+
return sources;
|
|
2617
|
+
}, {});
|
|
2618
|
+
}
|
|
2619
|
+
column(c, type = 'rgCol') {
|
|
2620
|
+
return this.getColumn(c, type);
|
|
2621
|
+
}
|
|
2622
|
+
getColumn(virtualIndex, type) {
|
|
2623
|
+
return getSourceItem(this.dataSources[type].store, virtualIndex);
|
|
2624
|
+
}
|
|
2625
|
+
getRawColumns() {
|
|
2626
|
+
return reduce(this.dataSources, (result, item, type) => {
|
|
2627
|
+
result[type] = item.store.get('source');
|
|
2628
|
+
return result;
|
|
2629
|
+
}, {
|
|
2630
|
+
rgCol: [],
|
|
2631
|
+
colPinStart: [],
|
|
2632
|
+
colPinEnd: [],
|
|
2633
|
+
});
|
|
2634
|
+
}
|
|
2635
|
+
getColumns(type = 'all') {
|
|
2636
|
+
const columnsByType = this.getRawColumns();
|
|
2637
|
+
if (type !== 'all') {
|
|
2638
|
+
return columnsByType[type];
|
|
2639
|
+
}
|
|
2640
|
+
return columnTypes.reduce((r, t) => [...r, ...columnsByType[t]], []);
|
|
2641
|
+
}
|
|
2642
|
+
getColumnIndexByProp(prop, type) {
|
|
2643
|
+
return getSourceItemVirtualIndexByProp(this.dataSources[type].store, prop);
|
|
2644
|
+
}
|
|
2645
|
+
getColumnByProp(prop) {
|
|
2646
|
+
var _a;
|
|
2647
|
+
return (_a = this.collection) === null || _a === void 0 ? void 0 : _a.columnByProp[prop];
|
|
2648
|
+
}
|
|
2649
|
+
refreshByType(type) {
|
|
2650
|
+
this.dataSources[type].refresh();
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* Main method to set columns
|
|
2654
|
+
*/
|
|
2655
|
+
setColumns(data) {
|
|
2656
|
+
columnTypes.forEach(k => {
|
|
2657
|
+
// set columns data
|
|
2658
|
+
this.dataSources[k].updateData(data.columns[k], {
|
|
2659
|
+
// max depth level
|
|
2660
|
+
depth: data.maxLevel,
|
|
2661
|
+
// groups
|
|
2662
|
+
groups: data.columnGrouping[k].reduce((res, g) => {
|
|
2663
|
+
if (!res[g.level]) {
|
|
2664
|
+
res[g.level] = [];
|
|
2665
|
+
}
|
|
2666
|
+
res[g.level].push(g);
|
|
2667
|
+
return res;
|
|
2668
|
+
}, {}),
|
|
2669
|
+
});
|
|
2670
|
+
});
|
|
2671
|
+
this.collection = data;
|
|
2672
|
+
return data;
|
|
2673
|
+
}
|
|
2674
|
+
/**
|
|
2675
|
+
* Used in plugins
|
|
2676
|
+
* Modify columns in store
|
|
2677
|
+
*/
|
|
2678
|
+
updateColumns(updatedColumns) {
|
|
2679
|
+
// collect column by type and propert
|
|
2680
|
+
const columnByKey = updatedColumns.reduce((res, c) => {
|
|
2681
|
+
const type = getColumnType(c);
|
|
2682
|
+
if (!res[type]) {
|
|
2683
|
+
res[type] = {};
|
|
2684
|
+
}
|
|
2685
|
+
res[type][c.prop] = c;
|
|
2686
|
+
return res;
|
|
2687
|
+
}, {});
|
|
2688
|
+
// find indexes in source
|
|
2689
|
+
const colByIndex = {};
|
|
2690
|
+
for (const t in columnByKey) {
|
|
2691
|
+
if (!columnByKey.hasOwnProperty(t)) {
|
|
2692
|
+
continue;
|
|
2693
|
+
}
|
|
2694
|
+
const type = t;
|
|
2695
|
+
const colsToUpdate = columnByKey[type];
|
|
2696
|
+
const sourceItems = this.dataSources[type].store.get('source');
|
|
2697
|
+
colByIndex[type] = {};
|
|
2698
|
+
for (let i = 0; i < sourceItems.length; i++) {
|
|
2699
|
+
const column = sourceItems[i];
|
|
2700
|
+
const colToUpdateIfExists = colsToUpdate === null || colsToUpdate === void 0 ? void 0 : colsToUpdate[column.prop];
|
|
2701
|
+
// update column if exists in source
|
|
2702
|
+
if (colToUpdateIfExists) {
|
|
2703
|
+
colByIndex[type][i] = colToUpdateIfExists;
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
for (const t in colByIndex) {
|
|
2708
|
+
if (!colByIndex.hasOwnProperty(t)) {
|
|
2709
|
+
continue;
|
|
2710
|
+
}
|
|
2711
|
+
const type = t;
|
|
2712
|
+
setSourceByPhysicalIndex(this.dataSources[type].store, colByIndex[type] || {});
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
updateColumn(column, index) {
|
|
2716
|
+
const type = getColumnType(column);
|
|
2717
|
+
setSourceByVirtualIndex(this.dataSources[type].store, { [index]: column });
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
|
|
2721
|
+
/**
|
|
2722
|
+
* Data source provider
|
|
2723
|
+
*
|
|
2724
|
+
* @dependsOn DimensionProvider
|
|
2725
|
+
*/
|
|
2726
|
+
class DataProvider {
|
|
2727
|
+
constructor(dimensionProvider) {
|
|
2728
|
+
this.dimensionProvider = dimensionProvider;
|
|
2729
|
+
this.stores = reduce(rowTypes, (sources, k) => {
|
|
2730
|
+
sources[k] = new DataStore(k);
|
|
2731
|
+
return sources;
|
|
2732
|
+
}, {});
|
|
2733
|
+
}
|
|
2734
|
+
setData(data, type = 'rgRow', disableVirtualRows = false, grouping, silent = false) {
|
|
2735
|
+
// set rgRow data
|
|
2736
|
+
this.stores[type].updateData([...data], grouping, silent);
|
|
2737
|
+
// for pinned row no need virtual data
|
|
2738
|
+
const noVirtual = type !== 'rgRow' || disableVirtualRows;
|
|
2739
|
+
this.dimensionProvider.setData(data.length, type, noVirtual);
|
|
2740
|
+
return data;
|
|
2741
|
+
}
|
|
2742
|
+
getModel(virtualIndex, type = 'rgRow') {
|
|
2743
|
+
const store = this.stores[type].store;
|
|
2744
|
+
return getSourceItem(store, virtualIndex);
|
|
2745
|
+
}
|
|
2746
|
+
changeOrder({ rowType = 'rgRow', from, to }) {
|
|
2747
|
+
const storeService = this.stores[rowType];
|
|
2748
|
+
// take currently visible row indexes
|
|
2749
|
+
const newItemsOrder = [...storeService.store.get('proxyItems')];
|
|
2750
|
+
const prevItems = storeService.store.get('items');
|
|
2751
|
+
// take out
|
|
2752
|
+
const toMove = newItemsOrder.splice(newItemsOrder.indexOf(prevItems[from]), // get index in proxy
|
|
2753
|
+
1);
|
|
2754
|
+
// insert before
|
|
2755
|
+
newItemsOrder.splice(newItemsOrder.indexOf(prevItems[to]), // get index in proxy
|
|
2756
|
+
0, ...toMove);
|
|
2757
|
+
storeService.setData({
|
|
2758
|
+
proxyItems: newItemsOrder,
|
|
2759
|
+
});
|
|
2760
|
+
// take currently visible row indexes
|
|
2761
|
+
const newItems = storeService.store.get('items');
|
|
2762
|
+
this.dimensionProvider.updateSizesPositionByNewDataIndexes(rowType, newItems, prevItems);
|
|
2763
|
+
}
|
|
2764
|
+
setCellData({ type, rowIndex, prop, val }, mutate = true) {
|
|
2765
|
+
const model = this.getModel(rowIndex, type);
|
|
2766
|
+
model[prop] = val;
|
|
2767
|
+
this.stores[type].setSourceData({ [rowIndex]: model }, mutate);
|
|
2768
|
+
}
|
|
2769
|
+
setRangeData(data, type) {
|
|
2770
|
+
const items = {};
|
|
2771
|
+
for (let rowIndex in data) {
|
|
2772
|
+
const oldModel = (items[rowIndex] = getSourceItem(this.stores[type].store, parseInt(rowIndex, 10)));
|
|
2773
|
+
if (!oldModel) {
|
|
2774
|
+
continue;
|
|
2775
|
+
}
|
|
2776
|
+
for (let prop in data[rowIndex]) {
|
|
2777
|
+
oldModel[prop] = data[rowIndex][prop];
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
this.stores[type].setSourceData(items);
|
|
2781
|
+
}
|
|
2782
|
+
refresh(type = 'all') {
|
|
2783
|
+
if (isRowType(type)) {
|
|
2784
|
+
this.refreshItems(type);
|
|
2785
|
+
}
|
|
2786
|
+
rowTypes.forEach((t) => this.refreshItems(t));
|
|
2787
|
+
}
|
|
2788
|
+
refreshItems(type = 'rgRow') {
|
|
2789
|
+
const items = this.stores[type].store.get('items');
|
|
2790
|
+
this.stores[type].setData({ items: [...items] });
|
|
2791
|
+
}
|
|
2792
|
+
setGrouping({ depth }, type = 'rgRow') {
|
|
2793
|
+
this.stores[type].setData({ groupingDepth: depth });
|
|
2794
|
+
}
|
|
2795
|
+
setTrimmed(trimmed, type = 'rgRow') {
|
|
2796
|
+
const store = this.stores[type];
|
|
2797
|
+
store.addTrimmed(trimmed);
|
|
2798
|
+
this.dimensionProvider.setTrimmed(trimmed, type);
|
|
2799
|
+
if (type === 'rgRow') {
|
|
2800
|
+
this.dimensionProvider.setData(getVisibleSourceItem(store.store).length, type);
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
|
|
2805
|
+
/**
|
|
2806
|
+
* Dimension provider
|
|
2807
|
+
* Stores dimension information and custom sizes
|
|
2808
|
+
*
|
|
2809
|
+
* @dependsOn ViewportProvider
|
|
2810
|
+
*/
|
|
2811
|
+
class DimensionProvider {
|
|
2812
|
+
constructor(viewports, config) {
|
|
2813
|
+
this.viewports = viewports;
|
|
2814
|
+
const sizeChanged = debounce((k) => config.realSizeChanged(k), RESIZE_INTERVAL);
|
|
2815
|
+
this.stores = reduce([...rowTypes, ...columnTypes], (sources, t) => {
|
|
2816
|
+
sources[t] = new DimensionStore(t);
|
|
2817
|
+
sources[t].store.onChange('realSize', () => sizeChanged(t));
|
|
2818
|
+
return sources;
|
|
2819
|
+
}, {});
|
|
2820
|
+
}
|
|
2821
|
+
/**
|
|
2822
|
+
* Clear old sizes from dimension and viewports
|
|
2823
|
+
* @param type - dimension type
|
|
2824
|
+
* @param count - count of items
|
|
2825
|
+
*/
|
|
2826
|
+
clearSize(t, count) {
|
|
2827
|
+
this.stores[t].drop();
|
|
2828
|
+
// after we done with drop trigger viewport recalculaction
|
|
2829
|
+
this.viewports.stores[t].setOriginalSizes(this.stores[t].store.get('originItemSize'));
|
|
2830
|
+
this.setItemCount(count, t);
|
|
2831
|
+
}
|
|
2832
|
+
/**
|
|
2833
|
+
* Apply new custom sizes to dimension and view port
|
|
2834
|
+
* @param type - dimension type
|
|
2835
|
+
* @param sizes - new custom sizes
|
|
2836
|
+
* @param keepOld - keep old sizes merge new with old
|
|
2837
|
+
*/
|
|
2838
|
+
setCustomSizes(type, sizes, keepOld = false) {
|
|
2839
|
+
let newSizes = sizes;
|
|
2840
|
+
if (keepOld) {
|
|
2841
|
+
const oldSizes = this.stores[type].store.get('sizes');
|
|
2842
|
+
newSizes = Object.assign(Object.assign({}, oldSizes), sizes);
|
|
2843
|
+
}
|
|
2844
|
+
this.stores[type].setDimensionSize(newSizes);
|
|
2845
|
+
this.setViewPortCoordinate({
|
|
2846
|
+
type,
|
|
2847
|
+
force: true,
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
setItemCount(realCount, type) {
|
|
2851
|
+
this.viewports.stores[type].setViewport({ realCount });
|
|
2852
|
+
this.stores[type].setStore({ count: realCount });
|
|
2853
|
+
}
|
|
2854
|
+
/**
|
|
2855
|
+
* Apply trimmed items
|
|
2856
|
+
* @param trimmed - trimmed items
|
|
2857
|
+
* @param type
|
|
2858
|
+
*/
|
|
2859
|
+
setTrimmed(trimmed, type) {
|
|
2860
|
+
const allTrimmed = gatherTrimmedItems(trimmed);
|
|
2861
|
+
const dimStoreType = this.stores[type];
|
|
2862
|
+
dimStoreType.setStore({ trimmed: allTrimmed });
|
|
2863
|
+
this.setViewPortCoordinate({
|
|
2864
|
+
type,
|
|
2865
|
+
force: true,
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
/**
|
|
2869
|
+
* Sets dimension data and viewport coordinate
|
|
2870
|
+
* @param itemCount
|
|
2871
|
+
* @param type - dimension type
|
|
2872
|
+
* @param noVirtual - disable virtual data
|
|
2873
|
+
*/
|
|
2874
|
+
setData(itemCount, type, noVirtual = false) {
|
|
2875
|
+
this.setItemCount(itemCount, type);
|
|
2876
|
+
// Virtualization will get disabled
|
|
2877
|
+
if (noVirtual) {
|
|
2878
|
+
const dimension = this.stores[type].getCurrentState();
|
|
2879
|
+
this.viewports.stores[type].setViewport({
|
|
2880
|
+
virtualSize: dimension.realSize,
|
|
2881
|
+
});
|
|
2882
|
+
}
|
|
2883
|
+
this.setViewPortCoordinate({
|
|
2884
|
+
type,
|
|
2885
|
+
});
|
|
2886
|
+
}
|
|
2887
|
+
/**
|
|
2888
|
+
* Applies new columns to the dimension provider
|
|
2889
|
+
* @param columns - new columns data
|
|
2890
|
+
* @param disableVirtualX - disable virtual data for X axis
|
|
2891
|
+
*/
|
|
2892
|
+
applyNewColumns(columns, disableVirtualX, keepOld = false) {
|
|
2893
|
+
// Apply new columns to dimension provider
|
|
2894
|
+
for (let type of columnTypes) {
|
|
2895
|
+
if (!keepOld) {
|
|
2896
|
+
// Clear existing data in the dimension provider
|
|
2897
|
+
this.stores[type].drop();
|
|
2898
|
+
}
|
|
2899
|
+
// Get the new columns for the current type
|
|
2900
|
+
const items = columns[type];
|
|
2901
|
+
// Determine if virtual data should be disabled for the current type
|
|
2902
|
+
const noVirtual = type !== 'rgCol' || disableVirtualX;
|
|
2903
|
+
// Set the items count in the dimension provider
|
|
2904
|
+
this.stores[type].setStore({ count: items.length });
|
|
2905
|
+
// Set the custom sizes for the columns
|
|
2906
|
+
const newSizes = getColumnSizes(items);
|
|
2907
|
+
this.stores[type].setDimensionSize(newSizes);
|
|
2908
|
+
// Update the viewport with new data
|
|
2909
|
+
const vpUpdate = {
|
|
2910
|
+
// This triggers drop on realCount change
|
|
2911
|
+
realCount: items.length,
|
|
2912
|
+
};
|
|
2913
|
+
// If virtual data is disabled, set the virtual size to the real size
|
|
2914
|
+
if (noVirtual) {
|
|
2915
|
+
vpUpdate.virtualSize = this.stores[type].getCurrentState().realSize;
|
|
2916
|
+
}
|
|
2917
|
+
// Update the viewport
|
|
2918
|
+
this.viewports.stores[type].setViewport(vpUpdate);
|
|
2919
|
+
this.setViewPortCoordinate({
|
|
2920
|
+
type,
|
|
2921
|
+
});
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
/**
|
|
2925
|
+
* Gets the full size of the grid by summing up the sizes of all dimensions
|
|
2926
|
+
* Goes through all dimensions columnTypes (x) and rowTypes (y) and sums up their sizes
|
|
2927
|
+
*/
|
|
2928
|
+
getFullSize() {
|
|
2929
|
+
var _a, _b;
|
|
2930
|
+
let x = 0;
|
|
2931
|
+
let y = 0;
|
|
2932
|
+
for (let type of columnTypes) {
|
|
2933
|
+
x += ((_a = this.stores[type]) === null || _a === void 0 ? void 0 : _a.store.get('realSize')) || 0;
|
|
2934
|
+
}
|
|
2935
|
+
for (let type of rowTypes) {
|
|
2936
|
+
y += ((_b = this.stores[type]) === null || _b === void 0 ? void 0 : _b.store.get('realSize')) || 0;
|
|
2937
|
+
}
|
|
2938
|
+
return { y, x };
|
|
2939
|
+
}
|
|
2940
|
+
setViewPortCoordinate({ type, coordinate = this.viewports.stores[type].lastCoordinate, force = false, }) {
|
|
2941
|
+
const dimension = this.stores[type].getCurrentState();
|
|
2942
|
+
this.viewports.stores[type].setViewPortCoordinate(coordinate, dimension, force);
|
|
2943
|
+
}
|
|
2944
|
+
getViewPortPos(e) {
|
|
2945
|
+
const dimension = this.stores[e.dimension].getCurrentState();
|
|
2946
|
+
const item = getItemByIndex(dimension, e.coordinate);
|
|
2947
|
+
return item.start;
|
|
2948
|
+
}
|
|
2949
|
+
setSettings(data, dimensionType) {
|
|
2950
|
+
let stores = [];
|
|
2951
|
+
switch (dimensionType) {
|
|
2952
|
+
case 'rgCol':
|
|
2953
|
+
stores = columnTypes;
|
|
2954
|
+
break;
|
|
2955
|
+
case 'rgRow':
|
|
2956
|
+
stores = rowTypes;
|
|
2957
|
+
break;
|
|
2958
|
+
}
|
|
2959
|
+
for (let s of stores) {
|
|
2960
|
+
this.stores[s].setStore(data);
|
|
2961
|
+
}
|
|
2962
|
+
}
|
|
2963
|
+
updateSizesPositionByNewDataIndexes(type, newItemsOrder, prevItemsOrder = []) {
|
|
2964
|
+
// Move custom sizes to new order
|
|
2965
|
+
this.stores[type].updateSizesPositionByIndexes(newItemsOrder, prevItemsOrder);
|
|
2966
|
+
this.setViewPortCoordinate({
|
|
2967
|
+
type,
|
|
2968
|
+
force: true,
|
|
2969
|
+
});
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
|
|
2973
|
+
class ViewportProvider {
|
|
2974
|
+
constructor() {
|
|
2975
|
+
this.stores = reduce([...rowTypes, ...columnTypes], (sources, k) => {
|
|
2976
|
+
sources[k] = new ViewportStore(k);
|
|
2977
|
+
return sources;
|
|
2978
|
+
}, {});
|
|
2979
|
+
}
|
|
2980
|
+
setViewport(type, data) {
|
|
2981
|
+
this.stores[type].setViewport(data);
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2985
|
+
/** Collect Column data */
|
|
2986
|
+
function gatherColumnData(data) {
|
|
2987
|
+
const colDimension = data.dimensions[data.colType].store;
|
|
2988
|
+
const realWidth = colDimension.get('realSize');
|
|
2989
|
+
const prop = {
|
|
2990
|
+
contentWidth: realWidth,
|
|
2991
|
+
class: data.colType,
|
|
2992
|
+
contentHeight: data.contentHeight,
|
|
2993
|
+
key: data.colType,
|
|
2994
|
+
colType: data.colType,
|
|
2995
|
+
onResizeviewport: data.onResizeviewport,
|
|
2996
|
+
// set viewport size to real size
|
|
2997
|
+
style: data.fixWidth ? { minWidth: `${realWidth}px` } : undefined,
|
|
2998
|
+
};
|
|
2999
|
+
const headerProp = {
|
|
3000
|
+
colData: getVisibleSourceItem(data.colStore),
|
|
3001
|
+
dimensionCol: colDimension,
|
|
3002
|
+
type: data.colType,
|
|
3003
|
+
groups: data.colStore.get('groups'),
|
|
3004
|
+
groupingDepth: data.colStore.get('groupingDepth'),
|
|
3005
|
+
resizeHandler: data.colType === 'colPinEnd' ? ['l'] : undefined,
|
|
3006
|
+
onHeaderresize: data.onHeaderresize,
|
|
3007
|
+
};
|
|
3008
|
+
return {
|
|
3009
|
+
prop,
|
|
3010
|
+
type: data.colType,
|
|
3011
|
+
position: data.position,
|
|
3012
|
+
headerProp,
|
|
3013
|
+
viewportCol: data.viewports[data.colType].store,
|
|
3014
|
+
};
|
|
3015
|
+
}
|
|
3016
|
+
class ViewportService {
|
|
3017
|
+
constructor(config, contentHeight) {
|
|
3018
|
+
var _a, _b;
|
|
3019
|
+
this.config = config;
|
|
3020
|
+
(_a = this.config.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.beforeUpdate();
|
|
3021
|
+
// ----------- Handle columns ----------- //
|
|
3022
|
+
// Transform data from stores and apply it to different components
|
|
3023
|
+
const columns = [];
|
|
3024
|
+
let x = 0; // we increase x only if column present
|
|
3025
|
+
columnTypes.forEach(val => {
|
|
3026
|
+
const colStore = config.columnProvider.stores[val].store;
|
|
3027
|
+
// only columns that have data show
|
|
3028
|
+
if (!colStore.get('items').length) {
|
|
3029
|
+
return;
|
|
3030
|
+
}
|
|
3031
|
+
const column = {
|
|
3032
|
+
colType: val,
|
|
3033
|
+
position: { x, y: 1 },
|
|
3034
|
+
contentHeight,
|
|
3035
|
+
// only central column has dynamic width
|
|
3036
|
+
fixWidth: val !== 'rgCol',
|
|
3037
|
+
viewports: config.viewportProvider.stores,
|
|
3038
|
+
dimensions: config.dimensionProvider.stores,
|
|
3039
|
+
rowStores: config.dataProvider.stores,
|
|
3040
|
+
colStore,
|
|
3041
|
+
onHeaderresize: e => this.onColumnResize(val, e, colStore),
|
|
3042
|
+
};
|
|
3043
|
+
if (val === 'rgCol') {
|
|
3044
|
+
column.onResizeviewport = (e) => {
|
|
3045
|
+
var _a;
|
|
3046
|
+
const vpState = {
|
|
3047
|
+
clientSize: e.detail.size,
|
|
3048
|
+
};
|
|
3049
|
+
// virtual size will be handled by dimension provider if disabled
|
|
3050
|
+
if ((e.detail.dimension === 'rgRow' && !config.disableVirtualY)
|
|
3051
|
+
|| (e.detail.dimension === 'rgCol' && !config.disableVirtualX)) {
|
|
3052
|
+
vpState.virtualSize = e.detail.size;
|
|
3053
|
+
}
|
|
3054
|
+
(_a = config.viewportProvider) === null || _a === void 0 ? void 0 : _a.setViewport(e.detail.dimension, vpState);
|
|
3055
|
+
};
|
|
3056
|
+
}
|
|
3057
|
+
const colData = gatherColumnData(column);
|
|
3058
|
+
const columnSelectionStore = this.registerCol(colData.position.x, val);
|
|
3059
|
+
// render per each column data collections vertically
|
|
3060
|
+
const dataPorts = this.dataViewPort(column).reduce((r, rgRow) => {
|
|
3061
|
+
// register selection store for Segment
|
|
3062
|
+
const segmentSelection = this.registerSegment(rgRow.position);
|
|
3063
|
+
segmentSelection.setLastCell(rgRow.lastCell);
|
|
3064
|
+
// register selection store for Row
|
|
3065
|
+
const rowSelectionStore = this.registerRow(rgRow.position.y, rgRow.type);
|
|
3066
|
+
const rowDef = Object.assign(Object.assign({ colType: val }, rgRow), { rowSelectionStore, selectionStore: segmentSelection.store, ref: (e) => config.selectionStoreConnector.registerSection(e), onSetrange: e => {
|
|
3067
|
+
segmentSelection.setRangeArea(e.detail);
|
|
3068
|
+
}, onSettemprange: e => segmentSelection.setTempArea(e.detail), onFocuscell: e => {
|
|
3069
|
+
// todo: multi focus
|
|
3070
|
+
segmentSelection.clearFocus();
|
|
3071
|
+
config.selectionStoreConnector.focus(segmentSelection, e.detail);
|
|
3072
|
+
} });
|
|
3073
|
+
r.push(rowDef);
|
|
3074
|
+
return r;
|
|
3075
|
+
}, []);
|
|
3076
|
+
columns.push(Object.assign(Object.assign({}, colData), { columnSelectionStore,
|
|
3077
|
+
dataPorts }));
|
|
3078
|
+
x++;
|
|
3079
|
+
});
|
|
3080
|
+
this.columns = columns;
|
|
3081
|
+
// ----------- Handle columns end ----------- //
|
|
3082
|
+
(_b = this.config.scrollingService) === null || _b === void 0 ? void 0 : _b.unregister();
|
|
3083
|
+
}
|
|
3084
|
+
onColumnResize(type, { detail }, store) {
|
|
3085
|
+
var _a;
|
|
3086
|
+
// apply to dimension provider
|
|
3087
|
+
(_a = this.config.dimensionProvider) === null || _a === void 0 ? void 0 : _a.setCustomSizes(type, detail, true);
|
|
3088
|
+
// set resize event
|
|
3089
|
+
const changedItems = {};
|
|
3090
|
+
for (const [i, size] of Object.entries(detail || {})) {
|
|
3091
|
+
const virtualIndex = parseInt(i, 10);
|
|
3092
|
+
const item = getSourceItem(store, virtualIndex);
|
|
3093
|
+
if (item) {
|
|
3094
|
+
changedItems[virtualIndex] = Object.assign(Object.assign({}, item), { size });
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
this.config.resize(changedItems);
|
|
3098
|
+
}
|
|
3099
|
+
/** register selection store for Segment */
|
|
3100
|
+
registerSegment(position) {
|
|
3101
|
+
return this.config.selectionStoreConnector.register(position);
|
|
3102
|
+
}
|
|
3103
|
+
/** register selection store for Row */
|
|
3104
|
+
registerRow(y, type) {
|
|
3105
|
+
return this.config.selectionStoreConnector.registerRow(y, type).store;
|
|
3106
|
+
}
|
|
3107
|
+
/** register selection store for Column */
|
|
3108
|
+
registerCol(x, type) {
|
|
3109
|
+
return this.config.selectionStoreConnector.registerColumn(x, type).store;
|
|
3110
|
+
}
|
|
3111
|
+
/** Collect Row data */
|
|
3112
|
+
dataViewPort(data) {
|
|
3113
|
+
const slots = {
|
|
3114
|
+
rowPinStart: HEADER_SLOT,
|
|
3115
|
+
rgRow: CONTENT_SLOT,
|
|
3116
|
+
rowPinEnd: FOOTER_SLOT,
|
|
3117
|
+
};
|
|
3118
|
+
// y position for selection
|
|
3119
|
+
let y = 0;
|
|
3120
|
+
return rowTypes.reduce((result, type) => {
|
|
3121
|
+
// filter out empty sources, we still need to return source to keep slot working
|
|
3122
|
+
const isPresent = data.viewports[type].store.get('realCount') || type === 'rgRow';
|
|
3123
|
+
const rgCol = Object.assign(Object.assign({}, data), { position: Object.assign(Object.assign({}, data.position), { y: isPresent ? y : EMPTY_INDEX }) });
|
|
3124
|
+
const partition = viewportDataPartition(rgCol, type, slots[type], type !== 'rgRow');
|
|
3125
|
+
result.push(partition);
|
|
3126
|
+
if (isPresent) {
|
|
3127
|
+
y++;
|
|
3128
|
+
}
|
|
3129
|
+
return result;
|
|
3130
|
+
}, []);
|
|
3131
|
+
}
|
|
3132
|
+
scrollToCell(cell) {
|
|
3133
|
+
for (let key in cell) {
|
|
3134
|
+
const coordinate = cell[key];
|
|
3135
|
+
if (typeof coordinate === 'number') {
|
|
3136
|
+
this.config.scrollingService.proxyScroll({
|
|
3137
|
+
dimension: key === 'x' ? 'rgCol' : 'rgRow',
|
|
3138
|
+
coordinate,
|
|
3139
|
+
});
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
/**
|
|
3144
|
+
* Clear current grid focus
|
|
3145
|
+
*/
|
|
3146
|
+
clearFocused() {
|
|
3147
|
+
this.config.selectionStoreConnector.clearAll();
|
|
3148
|
+
}
|
|
3149
|
+
clearEdit() {
|
|
3150
|
+
this.config.selectionStoreConnector.setEdit(false);
|
|
3151
|
+
}
|
|
3152
|
+
/**
|
|
3153
|
+
* Collect focused element data
|
|
3154
|
+
*/
|
|
3155
|
+
getFocused() {
|
|
3156
|
+
const focused = this.config.selectionStoreConnector.focusedStore;
|
|
3157
|
+
if (!focused) {
|
|
3158
|
+
return null;
|
|
3159
|
+
}
|
|
3160
|
+
// get column data
|
|
3161
|
+
const colType = this.config.selectionStoreConnector.storesXToType[focused.position.x];
|
|
3162
|
+
const column = this.config.columnProvider.getColumn(focused.cell.x, colType);
|
|
3163
|
+
// get row data
|
|
3164
|
+
const rowType = this.config.selectionStoreConnector.storesYToType[focused.position.y];
|
|
3165
|
+
const model = this.config.dataProvider.getModel(focused.cell.y, rowType);
|
|
3166
|
+
return {
|
|
3167
|
+
column,
|
|
3168
|
+
model,
|
|
3169
|
+
cell: focused.cell,
|
|
3170
|
+
colType,
|
|
3171
|
+
rowType,
|
|
3172
|
+
};
|
|
3173
|
+
}
|
|
3174
|
+
getStoreCoordinateByType(colType, rowType) {
|
|
3175
|
+
const stores = this.config.selectionStoreConnector.storesByType;
|
|
3176
|
+
if (typeof stores[colType] === 'undefined' || typeof stores[rowType] === 'undefined') {
|
|
3177
|
+
return;
|
|
3178
|
+
}
|
|
3179
|
+
return {
|
|
3180
|
+
x: stores[colType],
|
|
3181
|
+
y: stores[rowType],
|
|
3182
|
+
};
|
|
3183
|
+
}
|
|
3184
|
+
setFocus(colType, rowType, start, end) {
|
|
3185
|
+
var _a;
|
|
3186
|
+
const coordinate = this.getStoreCoordinateByType(colType, rowType);
|
|
3187
|
+
if (coordinate) {
|
|
3188
|
+
(_a = this.config.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.focusByCell(coordinate, start, end);
|
|
3189
|
+
}
|
|
3190
|
+
}
|
|
3191
|
+
getSelectedRange() {
|
|
3192
|
+
const focused = this.config.selectionStoreConnector.focusedStore;
|
|
3193
|
+
if (!focused) {
|
|
3194
|
+
return null;
|
|
3195
|
+
}
|
|
3196
|
+
// get column data
|
|
3197
|
+
const colType = this.config.selectionStoreConnector.storesXToType[focused.position.x];
|
|
3198
|
+
// get row data
|
|
3199
|
+
const rowType = this.config.selectionStoreConnector.storesYToType[focused.position.y];
|
|
3200
|
+
const range = focused.entity.store.get('range');
|
|
3201
|
+
if (!range) {
|
|
3202
|
+
return null;
|
|
3203
|
+
}
|
|
3204
|
+
return Object.assign(Object.assign({}, range), { colType,
|
|
3205
|
+
rowType });
|
|
3206
|
+
}
|
|
3207
|
+
setEdit(rowIndex, colIndex, colType, rowType) {
|
|
3208
|
+
var _a;
|
|
3209
|
+
const coordinate = this.getStoreCoordinateByType(colType, rowType);
|
|
3210
|
+
if (coordinate) {
|
|
3211
|
+
(_a = this.config.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEditByCell(coordinate, { x: colIndex, y: rowIndex });
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
|
|
3216
|
+
class GridScrollingService {
|
|
3217
|
+
constructor(setViewport) {
|
|
3218
|
+
this.setViewport = setViewport;
|
|
3219
|
+
this.elements = {};
|
|
3220
|
+
}
|
|
3221
|
+
async proxyScroll(e, key) {
|
|
3222
|
+
var _a;
|
|
3223
|
+
let newEventPromise;
|
|
3224
|
+
let event = e;
|
|
3225
|
+
for (let elKey in this.elements) {
|
|
3226
|
+
// skip
|
|
3227
|
+
if (e.dimension === 'rgCol' && elKey === 'headerRow') {
|
|
3228
|
+
continue;
|
|
3229
|
+
// pinned column only
|
|
3230
|
+
}
|
|
3231
|
+
else if (this.isPinnedColumn(key) && e.dimension === 'rgCol') {
|
|
3232
|
+
if (elKey === key || !e.delta) {
|
|
3233
|
+
continue;
|
|
3234
|
+
}
|
|
3235
|
+
for (let el of this.elements[elKey]) {
|
|
3236
|
+
if (el.changeScroll) {
|
|
3237
|
+
newEventPromise = el.changeScroll(e);
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
else {
|
|
3242
|
+
for (let el of this.elements[elKey]) {
|
|
3243
|
+
await ((_a = el.setScroll) === null || _a === void 0 ? void 0 : _a.call(el, e));
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
const newEvent = await newEventPromise;
|
|
3248
|
+
if (newEvent) {
|
|
3249
|
+
event = newEvent;
|
|
3250
|
+
}
|
|
3251
|
+
this.setViewport(event);
|
|
3252
|
+
}
|
|
3253
|
+
/**
|
|
3254
|
+
* Silent scroll update for mobile devices when we have negative scroll top
|
|
3255
|
+
*/
|
|
3256
|
+
async scrollSilentService(e, key) {
|
|
3257
|
+
var _a;
|
|
3258
|
+
for (let elKey in this.elements) {
|
|
3259
|
+
// skip same element update
|
|
3260
|
+
if (elKey === key) {
|
|
3261
|
+
continue;
|
|
3262
|
+
}
|
|
3263
|
+
if (columnTypes.includes(key) &&
|
|
3264
|
+
(elKey === 'headerRow' ||
|
|
3265
|
+
columnTypes.includes(elKey))) {
|
|
3266
|
+
for (let el of this.elements[elKey]) {
|
|
3267
|
+
await ((_a = el.changeScroll) === null || _a === void 0 ? void 0 : _a.call(el, e, true));
|
|
3268
|
+
}
|
|
3269
|
+
continue;
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
isPinnedColumn(key) {
|
|
3274
|
+
return !!key && ['colPinStart', 'colPinEnd'].indexOf(key) > -1;
|
|
3275
|
+
}
|
|
3276
|
+
registerElements(els) {
|
|
3277
|
+
this.elements = els;
|
|
3278
|
+
}
|
|
3279
|
+
/**
|
|
3280
|
+
* Register new element for farther scroll support
|
|
3281
|
+
* @param el - can be null if holder removed
|
|
3282
|
+
* @param key - element key
|
|
3283
|
+
*/
|
|
3284
|
+
registerElement(el, key) {
|
|
3285
|
+
if (!this.elements[key]) {
|
|
3286
|
+
this.elements[key] = [];
|
|
3287
|
+
}
|
|
3288
|
+
// new element added
|
|
3289
|
+
if (el) {
|
|
3290
|
+
this.elements[key].push(el);
|
|
3291
|
+
}
|
|
3292
|
+
else if (this.elements[key]) {
|
|
3293
|
+
// element removed
|
|
3294
|
+
delete this.elements[key];
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
unregister() {
|
|
3298
|
+
this.elements = {};
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3302
|
+
/**
|
|
3303
|
+
* Draw drag
|
|
3304
|
+
*/
|
|
3305
|
+
class OrdererService {
|
|
3306
|
+
constructor() {
|
|
3307
|
+
this.parentY = 0;
|
|
3308
|
+
}
|
|
3309
|
+
start(parent, { pos, text, event }) {
|
|
3310
|
+
var _a;
|
|
3311
|
+
const { top } = parent.getBoundingClientRect();
|
|
3312
|
+
this.parentY = top;
|
|
3313
|
+
if (this.text) {
|
|
3314
|
+
this.text.innerText = text;
|
|
3315
|
+
}
|
|
3316
|
+
this.move(pos);
|
|
3317
|
+
this.moveTip({ x: event.x, y: event.y });
|
|
3318
|
+
(_a = this.el) === null || _a === void 0 ? void 0 : _a.classList.remove('hidden');
|
|
3319
|
+
}
|
|
3320
|
+
end() {
|
|
3321
|
+
var _a;
|
|
3322
|
+
(_a = this.el) === null || _a === void 0 ? void 0 : _a.classList.add('hidden');
|
|
3323
|
+
}
|
|
3324
|
+
move(pos) {
|
|
3325
|
+
this.moveElement(pos.end - this.parentY);
|
|
3326
|
+
}
|
|
3327
|
+
moveTip({ x, y }) {
|
|
3328
|
+
if (!this.draggable) {
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
this.draggable.style.left = `${x}px`;
|
|
3332
|
+
this.draggable.style.top = `${y}px`;
|
|
3333
|
+
}
|
|
3334
|
+
moveElement(y) {
|
|
3335
|
+
if (!this.rgRow) {
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3338
|
+
this.rgRow.style.transform = `translateY(${y}px)`;
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
const OrderRenderer = ({ ref }) => {
|
|
3342
|
+
const service = new OrdererService();
|
|
3343
|
+
ref(service);
|
|
3344
|
+
return (h("div", { class: "draggable-wrapper hidden", ref: e => (service.el = e) },
|
|
3345
|
+
h("div", { class: "draggable", ref: el => (service.draggable = el) },
|
|
3346
|
+
h("span", { class: "revo-alt-icon" }),
|
|
3347
|
+
h("span", { ref: e => (service.text = e) })),
|
|
3348
|
+
h("div", { class: "drag-position", ref: e => (service.rgRow = e) })));
|
|
3349
|
+
};
|
|
3350
|
+
|
|
3351
|
+
const rowDefinitionByType = (newVal = []) => {
|
|
3352
|
+
const result = {};
|
|
3353
|
+
for (const v of newVal) {
|
|
3354
|
+
let rowDefs = result[v.type];
|
|
3355
|
+
if (!rowDefs) {
|
|
3356
|
+
rowDefs = result[v.type] = {};
|
|
3357
|
+
}
|
|
3358
|
+
if (v.size) {
|
|
3359
|
+
if (!rowDefs.sizes) {
|
|
3360
|
+
rowDefs.sizes = {};
|
|
3361
|
+
}
|
|
3362
|
+
rowDefs.sizes[v.index] = v.size;
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
return result;
|
|
3366
|
+
};
|
|
3367
|
+
const rowDefinitionRemoveByType = (oldVal = []) => {
|
|
3368
|
+
const result = {};
|
|
3369
|
+
for (const v of oldVal) {
|
|
3370
|
+
let rowDefs = result[v.type];
|
|
3371
|
+
if (!rowDefs) {
|
|
3372
|
+
rowDefs = result[v.type] = [];
|
|
3373
|
+
}
|
|
3374
|
+
if (v.size) {
|
|
3375
|
+
rowDefs.push(v.index);
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
return result;
|
|
3379
|
+
};
|
|
3380
|
+
|
|
3381
|
+
function isMobileDevice() {
|
|
3382
|
+
return /Mobi/i.test(navigator.userAgent) || /Android/i.test(navigator.userAgent) || navigator.maxTouchPoints > 0;
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
/**
|
|
3386
|
+
* WCAG Plugin is responsible for enhancing the accessibility features of the RevoGrid component.
|
|
3387
|
+
* It ensures that the grid is fully compliant with Web Content Accessibility Guidelines (WCAG) 2.1.
|
|
3388
|
+
* This plugin should be the last plugin you add, as it modifies the grid's default behavior.
|
|
3389
|
+
*
|
|
3390
|
+
* The WCAG Plugin performs the following tasks:
|
|
3391
|
+
* - Sets the 'dir' attribute to 'ltr' for left-to-right text direction.
|
|
3392
|
+
* - Sets the 'role' attribute to 'treegrid' for treelike hierarchical structure.
|
|
3393
|
+
* - Sets the 'aria-keyshortcuts' attribute to 'Enter' and 'Esc' for keyboard shortcuts.
|
|
3394
|
+
* - Adds event listeners for keyboard navigation and editing.
|
|
3395
|
+
*
|
|
3396
|
+
* By default, the plugin adds ARIA roles and properties to the grid elements, providing semantic information
|
|
3397
|
+
* for assistive technologies. These roles include 'grid', 'row', and 'gridcell'. The plugin also sets
|
|
3398
|
+
* ARIA attributes such as 'aria-rowindex', 'aria-colindex', and 'aria-selected'.
|
|
3399
|
+
*
|
|
3400
|
+
* The WCAG Plugin ensures that the grid is fully functional and usable for users with various disabilities,
|
|
3401
|
+
* including visual impairments, deaf-blindness, and cognitive disabilities.
|
|
3402
|
+
*
|
|
3403
|
+
* Note: The WCAG Plugin should be added as the last plugin in the list of plugins, as it modifies the grid's
|
|
3404
|
+
* default behavior and may conflict with other plugins if added earlier.
|
|
3405
|
+
*/
|
|
3406
|
+
class WCAGPlugin extends BasePlugin {
|
|
3407
|
+
constructor(revogrid, providers) {
|
|
3408
|
+
super(revogrid, providers);
|
|
3409
|
+
revogrid.setAttribute('role', 'treegrid');
|
|
3410
|
+
revogrid.setAttribute('aria-keyshortcuts', 'Enter');
|
|
3411
|
+
revogrid.setAttribute('aria-multiselectable', 'true');
|
|
3412
|
+
revogrid.setAttribute('tabindex', '0');
|
|
3413
|
+
/**
|
|
3414
|
+
* Before Columns Set Event
|
|
3415
|
+
*/
|
|
3416
|
+
this.addEventListener('beforecolumnsset', ({ detail }) => {
|
|
3417
|
+
const columns = [
|
|
3418
|
+
...detail.columns.colPinStart,
|
|
3419
|
+
...detail.columns.rgCol,
|
|
3420
|
+
...detail.columns.colPinEnd,
|
|
3421
|
+
];
|
|
3422
|
+
revogrid.setAttribute('aria-colcount', `${columns.length}`);
|
|
3423
|
+
columns.forEach((column, index) => {
|
|
3424
|
+
const { columnProperties, cellProperties } = column;
|
|
3425
|
+
column.columnProperties = (...args) => {
|
|
3426
|
+
const result = (columnProperties === null || columnProperties === void 0 ? void 0 : columnProperties(...args)) || {};
|
|
3427
|
+
result.role = 'columnheader';
|
|
3428
|
+
result['aria-colindex'] = `${index}`;
|
|
3429
|
+
return result;
|
|
3430
|
+
};
|
|
3431
|
+
column.cellProperties = (...args) => {
|
|
3432
|
+
const wcagProps = {
|
|
3433
|
+
['role']: 'gridcell',
|
|
3434
|
+
['aria-colindex']: `${index}`,
|
|
3435
|
+
['aria-rowindex']: `${args[0].rowIndex}`,
|
|
3436
|
+
['tabindex']: -1,
|
|
3437
|
+
};
|
|
3438
|
+
const columnProps = (cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties(...args)) || {};
|
|
3439
|
+
return Object.assign(Object.assign({}, wcagProps), columnProps);
|
|
3440
|
+
};
|
|
3441
|
+
});
|
|
3442
|
+
});
|
|
3443
|
+
/**
|
|
3444
|
+
* Before Row Set Event
|
|
3445
|
+
*/
|
|
3446
|
+
this.addEventListener('beforesourceset', ({ detail, }) => {
|
|
3447
|
+
revogrid.setAttribute('aria-rowcount', `${detail.source.length}`);
|
|
3448
|
+
});
|
|
3449
|
+
this.addEventListener('beforerowrender', ({ detail, }) => {
|
|
3450
|
+
detail.node.$attrs$ = Object.assign(Object.assign({}, detail.node.$attrs$), { role: 'row', ['aria-rowindex']: detail.item.itemIndex });
|
|
3451
|
+
});
|
|
3452
|
+
// focuscell
|
|
3453
|
+
this.addEventListener('afterfocus', async (e) => {
|
|
3454
|
+
if (e.defaultPrevented) {
|
|
3455
|
+
return;
|
|
3456
|
+
}
|
|
3457
|
+
const el = this.revogrid.querySelector(`revogr-data[type="${e.detail.rowType}"][col-type="${e.detail.colType}"] [data-rgrow="${e.detail.rowIndex}"][data-rgcol="${e.detail.colIndex}"]`);
|
|
3458
|
+
if (el instanceof HTMLElement) {
|
|
3459
|
+
el.focus();
|
|
3460
|
+
}
|
|
3461
|
+
});
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
|
|
3465
|
+
/**
|
|
3466
|
+
* Plugin service
|
|
3467
|
+
* Manages plugins
|
|
3468
|
+
*/
|
|
3469
|
+
class PluginService {
|
|
3470
|
+
constructor() {
|
|
3471
|
+
/**
|
|
3472
|
+
* Plugins
|
|
3473
|
+
* Define plugins collection
|
|
3474
|
+
*/
|
|
3475
|
+
this.internalPlugins = [];
|
|
3476
|
+
}
|
|
3477
|
+
/**
|
|
3478
|
+
* Get all plugins
|
|
3479
|
+
*/
|
|
3480
|
+
get() {
|
|
3481
|
+
return [...this.internalPlugins];
|
|
3482
|
+
}
|
|
3483
|
+
/**
|
|
3484
|
+
* Add plugin to collection
|
|
3485
|
+
*/
|
|
3486
|
+
add(plugin) {
|
|
3487
|
+
this.internalPlugins.push(plugin);
|
|
3488
|
+
}
|
|
3489
|
+
/**
|
|
3490
|
+
* Add user plugins and create
|
|
3491
|
+
*/
|
|
3492
|
+
addUserPluginsAndCreate(element, plugins = [], prevPlugins, pluginData) {
|
|
3493
|
+
if (!pluginData) {
|
|
3494
|
+
return;
|
|
3495
|
+
}
|
|
3496
|
+
// Step 1: Identify plugins to remove, compare new and old plugins
|
|
3497
|
+
const pluginsToRemove = (prevPlugins === null || prevPlugins === void 0 ? void 0 : prevPlugins.filter(prevPlugin => !plugins.some(userPlugin => userPlugin === prevPlugin))) || [];
|
|
3498
|
+
// Step 2: Remove old plugins
|
|
3499
|
+
pluginsToRemove.forEach(plugin => {
|
|
3500
|
+
var _a, _b;
|
|
3501
|
+
const index = this.internalPlugins.findIndex(createdPlugin => createdPlugin instanceof plugin);
|
|
3502
|
+
if (index !== -1) {
|
|
3503
|
+
(_b = (_a = this.internalPlugins[index]).destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3504
|
+
this.internalPlugins.splice(index, 1); // Remove the plugin
|
|
3505
|
+
}
|
|
3506
|
+
});
|
|
3507
|
+
// Step 3: Register user plugins
|
|
3508
|
+
plugins === null || plugins === void 0 ? void 0 : plugins.forEach(userPlugin => {
|
|
3509
|
+
// check if plugin already exists, if so, skip
|
|
3510
|
+
const existingPlugin = this.internalPlugins.find(createdPlugin => createdPlugin instanceof userPlugin);
|
|
3511
|
+
if (existingPlugin) {
|
|
3512
|
+
return;
|
|
3513
|
+
}
|
|
3514
|
+
this.add(new userPlugin(element, pluginData));
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3517
|
+
/**
|
|
3518
|
+
* Get plugin by class
|
|
3519
|
+
*/
|
|
3520
|
+
getByClass(pluginClass) {
|
|
3521
|
+
return this.internalPlugins.find(p => p instanceof pluginClass);
|
|
3522
|
+
}
|
|
3523
|
+
/**
|
|
3524
|
+
* Remove plugin
|
|
3525
|
+
*/
|
|
3526
|
+
remove(plugin) {
|
|
3527
|
+
var _a, _b;
|
|
3528
|
+
const index = this.internalPlugins.indexOf(plugin);
|
|
3529
|
+
if (index > -1) {
|
|
3530
|
+
(_b = (_a = this.internalPlugins[index]).destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
3531
|
+
this.internalPlugins.splice(index, 1);
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
/**
|
|
3535
|
+
* Remove all plugins
|
|
3536
|
+
*/
|
|
3537
|
+
destroy() {
|
|
3538
|
+
this.internalPlugins.forEach(p => { var _a; return (_a = p.destroy) === null || _a === void 0 ? void 0 : _a.call(p); });
|
|
3539
|
+
this.internalPlugins = [];
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
|
|
3543
|
+
/**
|
|
3544
|
+
* RTL (Right-to-Left) Plugin for RevoGrid
|
|
3545
|
+
*
|
|
3546
|
+
* This plugin handles RTL transformation by subscribing to the beforecolumnsset event
|
|
3547
|
+
* and applying column order reversal when RTL mode is enabled.
|
|
3548
|
+
*/
|
|
3549
|
+
class RTLPlugin extends BasePlugin {
|
|
3550
|
+
constructor(revogrid, providers) {
|
|
3551
|
+
super(revogrid, providers);
|
|
3552
|
+
this.isRTLEnabled = false;
|
|
3553
|
+
this.init();
|
|
3554
|
+
}
|
|
3555
|
+
init() {
|
|
3556
|
+
// Subscribe to beforecolumnsset event to apply RTL transformation
|
|
3557
|
+
this.addEventListener('beforecolumnsset', (event) => {
|
|
3558
|
+
this.handleBeforeColumnsSet(event);
|
|
3559
|
+
});
|
|
3560
|
+
// Listen for RTL property changes
|
|
3561
|
+
this.addEventListener('aftergridinit', () => {
|
|
3562
|
+
this.updateRTLState();
|
|
3563
|
+
});
|
|
3564
|
+
// Watch for RTL property changes
|
|
3565
|
+
this.watch('rtl', (value) => {
|
|
3566
|
+
this.isRTLEnabled = value;
|
|
3567
|
+
this.emit('rtlstatechanged', { rtl: this.isRTLEnabled });
|
|
3568
|
+
}, { immediate: true });
|
|
3569
|
+
}
|
|
3570
|
+
/**
|
|
3571
|
+
* Handle the beforecolumnsset event to apply RTL transformation
|
|
3572
|
+
*/
|
|
3573
|
+
handleBeforeColumnsSet(event) {
|
|
3574
|
+
if (!this.isRTLEnabled) {
|
|
3575
|
+
return; // No transformation needed if RTL is disabled
|
|
3576
|
+
}
|
|
3577
|
+
const columnCollection = event.detail;
|
|
3578
|
+
// Apply RTL transformation to all column types
|
|
3579
|
+
const transformedColumns = this.applyRTLTransformationToCollection(columnCollection);
|
|
3580
|
+
// Update the event detail with transformed columns
|
|
3581
|
+
event.detail.columns = transformedColumns.columns;
|
|
3582
|
+
event.detail.columnByProp = transformedColumns.columnByProp;
|
|
3583
|
+
event.detail.columnGrouping = transformedColumns.columnGrouping;
|
|
3584
|
+
}
|
|
3585
|
+
/**
|
|
3586
|
+
* Apply RTL transformation to the entire column collection
|
|
3587
|
+
*/
|
|
3588
|
+
applyRTLTransformationToCollection(collection) {
|
|
3589
|
+
const transformedCollection = {
|
|
3590
|
+
columns: {
|
|
3591
|
+
rgCol: [],
|
|
3592
|
+
colPinStart: [],
|
|
3593
|
+
colPinEnd: [],
|
|
3594
|
+
},
|
|
3595
|
+
columnByProp: Object.assign({}, collection.columnByProp),
|
|
3596
|
+
columnGrouping: {
|
|
3597
|
+
rgCol: [],
|
|
3598
|
+
colPinStart: [],
|
|
3599
|
+
colPinEnd: [],
|
|
3600
|
+
},
|
|
3601
|
+
maxLevel: collection.maxLevel,
|
|
3602
|
+
sort: Object.assign({}, collection.sort),
|
|
3603
|
+
};
|
|
3604
|
+
// Transform each column type
|
|
3605
|
+
Object.keys(collection.columns).forEach((type) => {
|
|
3606
|
+
const columnType = type;
|
|
3607
|
+
const columns = collection.columns[columnType];
|
|
3608
|
+
// Apply RTL transformation to columns - create new reversed array
|
|
3609
|
+
const reversedColumns = [...columns].reverse();
|
|
3610
|
+
transformedCollection.columns[columnType] = reversedColumns;
|
|
3611
|
+
// Transform column grouping for this type
|
|
3612
|
+
transformedCollection.columnGrouping[columnType] = this.applyRTLTransformationToGroups(collection.columnGrouping[columnType], columns.length);
|
|
3613
|
+
});
|
|
3614
|
+
return transformedCollection;
|
|
3615
|
+
}
|
|
3616
|
+
/**
|
|
3617
|
+
* Apply RTL transformation to column groups
|
|
3618
|
+
*/
|
|
3619
|
+
applyRTLTransformationToGroups(groups, totalColumns) {
|
|
3620
|
+
return groups.map(group => {
|
|
3621
|
+
// Reverse the indexes for RTL
|
|
3622
|
+
const reversedIndexes = group.indexes.map((index) => totalColumns - 1 - index).reverse();
|
|
3623
|
+
return Object.assign(Object.assign({}, group), { indexes: reversedIndexes });
|
|
3624
|
+
}).reverse(); // Reverse the group order
|
|
3625
|
+
}
|
|
3626
|
+
/**
|
|
3627
|
+
* Update RTL state based on the grid's rtl property
|
|
3628
|
+
*/
|
|
3629
|
+
updateRTLState() {
|
|
3630
|
+
const grid = this.revogrid;
|
|
3631
|
+
if (grid && typeof grid.rtl === 'boolean') {
|
|
3632
|
+
this.isRTLEnabled = grid.rtl;
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3635
|
+
/**
|
|
3636
|
+
* Get current RTL state
|
|
3637
|
+
*/
|
|
3638
|
+
getRTLState() {
|
|
3639
|
+
return this.isRTLEnabled;
|
|
3640
|
+
}
|
|
3641
|
+
/**
|
|
3642
|
+
* Clean up the plugin
|
|
3643
|
+
*/
|
|
3644
|
+
destroy() {
|
|
3645
|
+
super.destroy();
|
|
3646
|
+
}
|
|
3647
|
+
}
|
|
3648
|
+
|
|
3649
|
+
const revoGridStyleCss = "revo-grid[theme=default],revo-grid:not([theme]){border:1px solid var(--revo-grid-header-border);font-size:12px}revo-grid[theme=default] .rowHeaders revogr-header,revo-grid:not([theme]) .rowHeaders revogr-header{box-shadow:-1px 0 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] revogr-header,revo-grid:not([theme]) revogr-header{text-align:center;line-height:30px;background-color:var(--revo-grid-header-bg)}revo-grid[theme=default] revogr-header .group-rgRow,revo-grid:not([theme]) revogr-header .group-rgRow{box-shadow:none}revo-grid[theme=default] revogr-header .group-rgRow .rgHeaderCell,revo-grid:not([theme]) revogr-header .group-rgRow .rgHeaderCell{box-shadow:-1px 0 0 0 var(--revo-grid-header-border), -1px 0 0 0 var(--revo-grid-header-border) inset, 0 -1px 0 0 var(--revo-grid-header-border), 0 -1px 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] revogr-header .header-rgRow,revo-grid[theme=default] revogr-header .group-rgRow,revo-grid:not([theme]) revogr-header .header-rgRow,revo-grid:not([theme]) revogr-header .group-rgRow{text-transform:uppercase;font-size:12px;color:var(--revo-grid-header-color)}revo-grid[theme=default] revogr-header .header-rgRow,revo-grid:not([theme]) revogr-header .header-rgRow{height:30px;box-shadow:0 -1px 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] revogr-header .rgHeaderCell,revo-grid:not([theme]) revogr-header .rgHeaderCell{box-shadow:-1px 0 0 0 var(--revo-grid-header-border) inset, 0 -1px 0 0 var(--revo-grid-header-border), 0 -1px 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] .rowHeaders,revo-grid:not([theme]) .rowHeaders{background-color:var(--revo-grid-header-bg)}revo-grid[theme=default] .rowHeaders revogr-data .rgCell,revo-grid:not([theme]) .rowHeaders revogr-data .rgCell{color:var(--revo-grid-header-color)}revo-grid[theme=default] .rowHeaders revogr-data .rgCell:first-child,revo-grid:not([theme]) .rowHeaders revogr-data .rgCell:first-child{box-shadow:0 -1px 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] .rowHeaders revogr-data .rgCell:not(:first-child),revo-grid:not([theme]) .rowHeaders revogr-data .rgCell:not(:first-child){box-shadow:0 -1px 0 0 var(--revo-grid-header-border) inset, 1px 0 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] .rowHeaders revogr-data .rgCell:last-child,revo-grid:not([theme]) .rowHeaders revogr-data .rgCell:last-child{border-right:1px solid var(--revo-grid-header-border)}revo-grid[theme=default] .rowHeaders revogr-data revogr-header,revo-grid:not([theme]) .rowHeaders revogr-data revogr-header{box-shadow:0 -1px 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] revogr-viewport-scroll.colPinStart revogr-data .rgRow .rgCell:last-child,revo-grid:not([theme]) revogr-viewport-scroll.colPinStart revogr-data .rgRow .rgCell:last-child{box-shadow:0 -1px 0 0 var(--revo-grid-cell-border) inset, -1px 0 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] revogr-viewport-scroll.colPinStart .footer-wrapper revogr-data .rgRow:first-child .rgCell,revo-grid:not([theme]) revogr-viewport-scroll.colPinStart .footer-wrapper revogr-data .rgRow:first-child .rgCell{box-shadow:0 1px 0 0 var(--revo-grid-header-border) inset, -1px 0 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] revogr-viewport-scroll.colPinEnd,revo-grid[theme=default] revogr-viewport-scroll.colPinEnd revogr-header,revo-grid:not([theme]) revogr-viewport-scroll.colPinEnd,revo-grid:not([theme]) revogr-viewport-scroll.colPinEnd revogr-header{box-shadow:1px 0 0 var(--revo-grid-header-border) inset}revo-grid[theme=default] .footer-wrapper revogr-data .rgRow:first-child .rgCell,revo-grid:not([theme]) .footer-wrapper revogr-data .rgRow:first-child .rgCell{box-shadow:0 1px 0 0 var(--revo-grid-cell-border) inset, -1px 0 0 0 var(--revo-grid-cell-border) inset, 0 -1px 0 0 var(--revo-grid-cell-border) inset}revo-grid[theme=default] revogr-data,revo-grid:not([theme]) revogr-data{text-align:center}revo-grid[theme=default] revogr-data .revo-draggable,revo-grid:not([theme]) revogr-data .revo-draggable{float:left}revo-grid[theme=default] revogr-data .rgRow,revo-grid:not([theme]) revogr-data .rgRow{line-height:27px}revo-grid[theme=default] revogr-data .rgCell,revo-grid:not([theme]) revogr-data .rgCell{box-shadow:0 -1px 0 0 var(--revo-grid-cell-border) inset, -1px 0 0 0 var(--revo-grid-cell-border) inset}revo-grid[theme=material]{font-family:Nunito, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"}revo-grid[theme=material] revogr-header{line-height:50px;font-weight:600;text-align:left}revo-grid[theme=material] revogr-header .rgHeaderCell{padding:0 15px;text-overflow:ellipsis}revo-grid[theme=material] revogr-header .header-rgRow{height:50px}revo-grid[theme=material] revogr-data{text-align:left}revo-grid[theme=material] revogr-data .rgRow{line-height:42px}revo-grid[theme=material] revogr-data .rgCell{padding:0 15px}revo-grid[theme=darkMaterial]{font-family:Nunito, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"}revo-grid[theme=darkMaterial] revogr-header{line-height:50px;font-weight:600;text-align:left}revo-grid[theme=darkMaterial] revogr-header .rgHeaderCell{padding:0 15px;text-overflow:ellipsis}revo-grid[theme=darkMaterial] revogr-header .header-rgRow{height:50px}revo-grid[theme=darkMaterial] revogr-data{text-align:left}revo-grid[theme=darkMaterial] revogr-data .rgRow{line-height:42px}revo-grid[theme=darkMaterial] revogr-data .rgCell{padding:0 15px}revo-grid[theme=darkCompact]{font-family:Nunito, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"}revo-grid[theme=darkCompact] revogr-header{line-height:45px;font-weight:600;text-align:left}revo-grid[theme=darkCompact] revogr-header .rgHeaderCell{padding:0 15px;text-overflow:ellipsis}revo-grid[theme=darkCompact] revogr-header .header-rgRow{height:45px}revo-grid[theme=darkCompact] revogr-data{text-align:left}revo-grid[theme=darkCompact] revogr-data .rgRow{line-height:32px}revo-grid[theme=darkCompact] revogr-data .rgCell{padding:0 15px}revo-grid[theme=compact]{font-family:Nunito, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"}revo-grid[theme=compact] revogr-header{line-height:45px;font-weight:600;text-align:left}revo-grid[theme=compact] revogr-header .rgHeaderCell{padding:0 15px;text-overflow:ellipsis}revo-grid[theme=compact] revogr-header .header-rgRow{height:45px}revo-grid[theme=compact] revogr-data{text-align:left}revo-grid[theme=compact] revogr-data .rgRow{line-height:32px}revo-grid[theme=compact] revogr-data .rgCell{padding:0 15px}revo-grid[theme=compact] revo-dropdown .rv-dr-root{padding:0px 9px}revo-grid[dir=rtl] .viewports{flex-direction:row-reverse}revo-grid[dir=rtl] revogr-header .rgHeaderCell{text-align:right}revo-grid[dir=rtl] revogr-data .rgCell{text-align:right}revo-grid[dir=rtl] .rowHeaders revogr-data .rgCell{text-align:right}revo-grid[dir=rtl] revogr-filter-panel{direction:rtl}revo-grid[dir=rtl] revo-dropdown .rv-dr-root{text-align:right}revo-grid[dir=rtl] .drag-position{right:0;left:auto}revo-grid[dir=rtl] .drag-auto-scroll-y{right:0;left:auto}revo-grid[dir=rtl] .clipboard{right:0;left:auto}revo-grid[dir=rtl] .draggable{margin-left:-20px;margin-right:0;padding-right:20px;padding-left:5px}revo-grid[dir=rtl] .draggable .revo-alt-icon{right:5px;left:auto}revo-grid[dir=rtl] .focused-cell{border-right:2px solid var(--revo-grid-primary);border-left:none}revo-grid[dir=rtl] .selection-range{border-right:2px solid var(--revo-grid-primary);border-left:none}revo-grid[dir=rtl] .resize-handle{right:0;left:auto}revo-grid[dir=rtl] .sort-indicator{margin-left:0;margin-right:5px}revo-grid[dir=rtl] .filter-button{margin-left:0;margin-right:5px}revo-grid[dir=rtl] .group-expand{margin-right:0;margin-left:2px;padding-right:5px;padding-left:0}revo-grid[dir=rtl] .rgCell,revo-grid[dir=rtl] .rgHeaderCell{padding-left:5px;padding-right:5px}revo-grid[dir=rtl] revogr-edit{direction:rtl}revo-grid[dir=rtl] .rgHeaderCell{direction:rtl}revo-grid[dir=rtl][theme=material] revogr-header,revo-grid[dir=rtl][theme=darkMaterial] revogr-header{text-align:right}revo-grid[dir=rtl][theme=material] revogr-data,revo-grid[dir=rtl][theme=darkMaterial] revogr-data{text-align:right}revo-grid[dir=rtl][theme=default] .rowHeaders,revo-grid[dir=rtl]:not([theme]) .rowHeaders{background-color:var(--revo-grid-header-bg)}revo-grid[dir=rtl][theme=default] .rowHeaders revogr-data .rgCell,revo-grid[dir=rtl]:not([theme]) .rowHeaders revogr-data .rgCell{color:var(--revo-grid-header-color)}revo-grid[dir=rtl][theme=default] .rowHeaders revogr-data .rgCell:first-child,revo-grid[dir=rtl]:not([theme]) .rowHeaders revogr-data .rgCell:first-child{box-shadow:0 -1px 0 0 var(--revo-grid-header-border) inset}revo-grid[dir=rtl][theme=default] .rowHeaders revogr-data .rgCell:not(:first-child),revo-grid[dir=rtl]:not([theme]) .rowHeaders revogr-data .rgCell:not(:first-child){box-shadow:0 -1px 0 0 var(--revo-grid-header-border) inset, 1px 0 0 0 var(--revo-grid-header-border) inset}revo-grid[dir=rtl][theme=default] .rowHeaders revogr-data .rgCell:last-child,revo-grid[dir=rtl]:not([theme]) .rowHeaders revogr-data .rgCell:last-child{border-left:1px solid var(--revo-grid-header-border);border-right:none}revo-grid[dir=rtl][theme=default] .rowHeaders revogr-data revogr-header,revo-grid[dir=rtl]:not([theme]) .rowHeaders revogr-data revogr-header{box-shadow:0 -1px 0 0 var(--revo-grid-header-border) inset}revo-grid[dir=rtl][theme=default] revogr-header,revo-grid[dir=rtl]:not([theme]) revogr-header{text-align:right}revo-grid[dir=rtl][theme=default] revogr-data,revo-grid[dir=rtl]:not([theme]) revogr-data{text-align:right}revo-grid[dir=rtl][theme=compact] revogr-header,revo-grid[dir=rtl][theme=darkCompact] revogr-header{text-align:right}revo-grid[dir=rtl][theme=compact] revogr-data,revo-grid[dir=rtl][theme=darkCompact] revogr-data{text-align:right}revo-grid{--revo-grid-primary:#266ae8;--revo-grid-primary-transparent:rgba(38, 106, 232, 0.9);--revo-grid-background:#fff;--revo-grid-foreground:black;--revo-grid-divider:gray;--revo-grid-shadow:rgba(0, 0, 0, 0.15);--revo-grid-text:black;--revo-grid-border:rgba(0, 0, 0, 0.2);--revo-grid-filter-panel-bg:#fff;--revo-grid-filter-panel-border:#d9d9d9;--revo-grid-filter-panel-shadow:rgba(0, 0, 0, 0.15);--revo-grid-filter-panel-input-bg:#eaeaeb;--revo-grid-filter-panel-divider:#d9d9d9;--revo-grid-filter-panel-select-border:transparent;--revo-grid-filter-panel-select-border-hover:transparent;--revo-grid-header-bg:#f8f9fa;--revo-grid-header-color:#000;--revo-grid-header-border:#cecece;--revo-grid-cell-border:#e2e3e3;--revo-grid-focused-bg:rgba(233, 234, 237, 0.5);--revo-grid-row-hover:#f1f1f1;--revo-grid-row-headers-bg:#f7faff;--revo-grid-row-headers-color:#757a82;--revo-grid-cell-disabled-bg:rgba(0, 0, 0, 0.07);direction:ltr !important;display:flex !important;height:100%;min-height:300px;font-family:Helvetica, Arial, Sans-Serif, serif;font-size:14px;position:relative;color:var(--revo-grid-text);-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:flex;flex-direction:column;width:100%;height:100%}revo-grid[theme*=dark]{--revo-grid-background:#212529;--revo-grid-foreground:#fff;--revo-grid-text:rgba(255, 255, 255, 0.9);--revo-grid-divider:#505050;--revo-grid-border:rgba(255, 255, 255, 0.2);--revo-grid-filter-panel-bg:#212529;--revo-grid-filter-panel-border:#505050;--revo-grid-filter-panel-input-bg:#343a40;--revo-grid-filter-panel-divider:#505050;--revo-grid-header-bg:#343a40;--revo-grid-header-color:#fff;--revo-grid-header-border:#505050;--revo-grid-cell-border:#424242;--revo-grid-focused-bg:rgba(52, 58, 64, 0.5);--revo-grid-row-hover:rgba(80, 80, 80, 0.5);--revo-grid-row-headers-bg:rgba(52, 58, 64, 0.8);--revo-grid-row-headers-color:rgba(255, 255, 255, 0.8);--revo-grid-cell-disabled-bg:rgba(255, 255, 255, 0.07)}revo-grid revogr-header .header-rgRow.group{box-shadow:0 -1px 0 0 var(--revo-grid-header-border) inset}revo-grid revogr-header .header-rgRow:not(.group){box-shadow:0 -1px 0 0 var(--revo-grid-header-border), 0 -1px 0 0 var(--revo-grid-header-border) inset}revo-grid revogr-header .rgHeaderCell.sortable:hover{background-color:var(--revo-grid-row-hover)}revo-grid revogr-header .rgHeaderCell.focused-cell{background:var(--revo-grid-focused-bg)}revo-grid .footer-wrapper revogr-data{box-shadow:0 -1px 0 var(--revo-grid-cell-border)}revo-grid revogr-viewport-scroll.colPinStart{box-shadow:-1px 0 0 var(--revo-grid-cell-border) inset}revo-grid revogr-viewport-scroll.colPinEnd{box-shadow:-1px 0 0 var(--revo-grid-cell-border)}revo-grid revogr-data .rgRow{box-shadow:0 -1px 0 0 var(--revo-grid-cell-border) inset}revo-grid revogr-data .rgRow.focused-rgRow{background-color:var(--revo-grid-focused-bg)}revo-grid revogr-data .rgCell{color:var(--revo-grid-text)}revo-grid revogr-data .rgCell.disabled{background-color:var(--revo-grid-cell-disabled-bg)}revo-grid .attribution{position:absolute;bottom:0;left:0;right:0;z-index:1000;width:0;height:0;border-left:4px solid var(--revo-grid-primary-transparent);border-bottom:4px solid var(--revo-grid-primary-transparent);border-top:4px solid transparent;border-right:4px solid transparent;cursor:pointer}revo-grid .attribution .value{position:absolute;bottom:0;left:0;background-color:var(--revo-grid-background);padding:4px;border-radius:4px;box-shadow:0 1px 10px var(--revo-grid-border);white-space:nowrap;text-decoration:none;color:var(--revo-grid-text);letter-spacing:0.3px;font-size:11px;opacity:0;width:4px;overflow:hidden;transition:opacity 0.5s ease-in-out, width 0.3s ease-in-out}revo-grid .attribution:hover .value{width:63px;opacity:1}revo-grid.column-draggable.column-drag-start:hover,revo-grid.column-draggable.column-drag-start *:hover{cursor:grabbing}revo-grid .footer-wrapper,revo-grid .header-wrapper{width:100%}revo-grid .footer-wrapper revogr-data,revo-grid .header-wrapper revogr-data{z-index:3}revo-grid revo-dropdown{width:100%}revo-grid revo-dropdown .rv-dr-root{max-height:100%}revo-grid revo-dropdown.shrink label{opacity:0}revo-grid .viewports{max-width:100%;display:flex;flex-direction:row;align-items:flex-start;flex-grow:1}revo-grid .main-viewport{flex-grow:1;height:0;display:flex;justify-content:space-between;flex-direction:row}revo-grid .draggable{position:fixed;height:30px;line-height:30px;background:var(--revo-grid-background);border-radius:3px;display:block;z-index:100;margin-top:5px;margin-right:-20px;box-shadow:0 4px 20px 0 var(--revo-grid-shadow);padding-left:20px;padding-right:5px}revo-grid .draggable.hidden{display:none}revo-grid .draggable .revo-alt-icon{background-color:var(--revo-grid-foreground);position:absolute;left:5px;top:10px}revo-grid .draggable-wrapper.hidden{display:none}revo-grid .drag-position{position:absolute;left:0;right:0;height:1px;z-index:2;background:var(--revo-grid-divider);pointer-events:none}revo-grid .drag-position-y{position:absolute;top:0;left:0;bottom:0;width:1px;z-index:2;background:var(--revo-grid-divider);pointer-events:none;transition:all 0.1s ease-out}revo-grid .drag-auto-scroll-y{pointer-events:none;position:absolute;left:0;top:0;height:50px;width:1px}revo-grid .clipboard{position:absolute;left:0;top:0}revo-grid revogr-scroll-virtual{position:relative}revo-grid revogr-scroll-virtual.vertical,revo-grid revogr-scroll-virtual.horizontal{z-index:3}";
|
|
3650
|
+
|
|
3651
|
+
const RevoGridComponent = /*@__PURE__*/ proxyCustomElement(class RevoGridComponent extends HTMLElement$1 {
|
|
3652
|
+
constructor() {
|
|
3653
|
+
super();
|
|
3654
|
+
this.__registerHost();
|
|
3655
|
+
this.contentsizechanged = createEvent(this, "contentsizechanged", 7);
|
|
3656
|
+
this.beforeedit = createEvent(this, "beforeedit", 7);
|
|
3657
|
+
this.beforerangeedit = createEvent(this, "beforerangeedit", 7);
|
|
3658
|
+
this.afteredit = createEvent(this, "afteredit", 7);
|
|
3659
|
+
this.beforeautofill = createEvent(this, "beforeautofill", 7);
|
|
3660
|
+
this.beforerange = createEvent(this, "beforerange", 7);
|
|
3661
|
+
this.afterfocus = createEvent(this, "afterfocus", 7);
|
|
3662
|
+
this.roworderchanged = createEvent(this, "roworderchanged", 7);
|
|
3663
|
+
this.beforesorting = createEvent(this, "beforesorting", 7);
|
|
3664
|
+
this.beforesourcesortingapply = createEvent(this, "beforesourcesortingapply", 7);
|
|
3665
|
+
this.beforesortingapply = createEvent(this, "beforesortingapply", 7);
|
|
3666
|
+
this.rowdragstart = createEvent(this, "rowdragstart", 7);
|
|
3667
|
+
this.headerclick = createEvent(this, "headerclick", 7);
|
|
3668
|
+
this.beforecellfocus = createEvent(this, "beforecellfocus", 7);
|
|
3669
|
+
this.beforefocuslost = createEvent(this, "beforefocuslost", 7);
|
|
3670
|
+
this.beforesourceset = createEvent(this, "beforesourceset", 7);
|
|
3671
|
+
this.beforeanysource = createEvent(this, "beforeanysource", 7);
|
|
3672
|
+
this.aftersourceset = createEvent(this, "aftersourceset", 7);
|
|
3673
|
+
this.afteranysource = createEvent(this, "afteranysource", 7);
|
|
3674
|
+
this.beforecolumnsset = createEvent(this, "beforecolumnsset", 7);
|
|
3675
|
+
this.beforecolumnapplied = createEvent(this, "beforecolumnapplied", 7);
|
|
3676
|
+
this.aftercolumnsset = createEvent(this, "aftercolumnsset", 7);
|
|
3677
|
+
this.beforefilterapply = createEvent(this, "beforefilterapply", 7);
|
|
3678
|
+
this.beforefiltertrimmed = createEvent(this, "beforefiltertrimmed", 7);
|
|
3679
|
+
this.beforetrimmed = createEvent(this, "beforetrimmed", 7);
|
|
3680
|
+
this.aftertrimmed = createEvent(this, "aftertrimmed", 7);
|
|
3681
|
+
this.viewportscroll = createEvent(this, "viewportscroll", 7);
|
|
3682
|
+
this.beforeexport = createEvent(this, "beforeexport", 7);
|
|
3683
|
+
this.beforeeditstart = createEvent(this, "beforeeditstart", 7);
|
|
3684
|
+
this.afterrollback = createEvent(this, "afterrollback", 7);
|
|
3685
|
+
this.aftermouseup = createEvent(this, "aftermouseup", 7);
|
|
3686
|
+
this.aftercolumnresize = createEvent(this, "aftercolumnresize", 7);
|
|
3687
|
+
this.beforerowdefinition = createEvent(this, "beforerowdefinition", 7);
|
|
3688
|
+
this.filterconfigchanged = createEvent(this, "filterconfigchanged", 7);
|
|
3689
|
+
this.sortingconfigchanged = createEvent(this, "sortingconfigchanged", 7);
|
|
3690
|
+
this.rowheaderschanged = createEvent(this, "rowheaderschanged", 7);
|
|
3691
|
+
this.beforegridrender = createEvent(this, "beforegridrender", 7);
|
|
3692
|
+
this.aftergridrender = createEvent(this, "aftergridrender", 7);
|
|
3693
|
+
this.aftergridinit = createEvent(this, "aftergridinit", 7);
|
|
3694
|
+
this.beforecolumndrag = createEvent(this, "beforecolumndrag", 7);
|
|
3695
|
+
this.additionaldatachanged = createEvent(this, "additionaldatachanged", 7);
|
|
3696
|
+
this.afterthemechanged = createEvent(this, "afterthemechanged", 7);
|
|
3697
|
+
this.created = createEvent(this, "created", 7);
|
|
3698
|
+
/**
|
|
3699
|
+
* Defines how many rows/columns should be rendered outside visible area.
|
|
3700
|
+
*/
|
|
3701
|
+
this.frameSize = 1;
|
|
3702
|
+
/**
|
|
3703
|
+
* Indicates default rgRow size.
|
|
3704
|
+
* By default 0, means theme package size will be applied
|
|
3705
|
+
*
|
|
3706
|
+
* Alternatively you can use `rowSize` to reset viewport
|
|
3707
|
+
*/
|
|
3708
|
+
this.rowSize = 0;
|
|
3709
|
+
/** Indicates default column size. */
|
|
3710
|
+
this.colSize = 100;
|
|
3711
|
+
/** When true, user can range selection. */
|
|
3712
|
+
this.range = false;
|
|
3713
|
+
/** When true, grid in read only mode. */
|
|
3714
|
+
this.readonly = false;
|
|
3715
|
+
/** When true, columns are resizable. */
|
|
3716
|
+
this.resize = false;
|
|
3717
|
+
/** When true cell focus appear. */
|
|
3718
|
+
this.canFocus = true;
|
|
3719
|
+
/** When true enable clipboard. */
|
|
3720
|
+
this.useClipboard = true;
|
|
3721
|
+
/**
|
|
3722
|
+
* Columns - defines an array of grid columns.
|
|
3723
|
+
* Can be column or grouped column.
|
|
3724
|
+
*/
|
|
3725
|
+
this.columns = [];
|
|
3726
|
+
/**
|
|
3727
|
+
* Source - defines main data source.
|
|
3728
|
+
* Can be an Object or 2 dimensional array([][]);
|
|
3729
|
+
* Keys/indexes referenced from columns Prop.
|
|
3730
|
+
*/
|
|
3731
|
+
this.source = [];
|
|
3732
|
+
/** Pinned top Source: {[T in ColumnProp]: any} - defines pinned top rows data source. */
|
|
3733
|
+
this.pinnedTopSource = [];
|
|
3734
|
+
/** Pinned bottom Source: {[T in ColumnProp]: any} - defines pinned bottom rows data source. */
|
|
3735
|
+
this.pinnedBottomSource = [];
|
|
3736
|
+
/** Custom row properies to be applied. See `RowDefinition` for more info. */
|
|
3737
|
+
this.rowDefinitions = [];
|
|
3738
|
+
/** Custom editors register. */
|
|
3739
|
+
this.editors = {};
|
|
3740
|
+
/**
|
|
3741
|
+
* Apply changes in editor when closed except 'Escape' cases.
|
|
3742
|
+
* If custom editor in use method getValue required.
|
|
3743
|
+
* Check interfaces.d.ts `EditorBase` for more info.
|
|
3744
|
+
*/
|
|
3745
|
+
this.applyOnClose = false;
|
|
3746
|
+
/**
|
|
3747
|
+
* Custom grid plugins. Can be added or removed at runtime.
|
|
3748
|
+
* Every plugin should be inherited from BasePlugin class.
|
|
3749
|
+
*
|
|
3750
|
+
* For more details check [Plugin guide](https://rv-grid.com/guide/plugin/)
|
|
3751
|
+
*/
|
|
3752
|
+
this.plugins = [];
|
|
3753
|
+
/**
|
|
3754
|
+
* Column Types Format.
|
|
3755
|
+
* Every type represent multiple column properties.
|
|
3756
|
+
* Types will be merged but can be replaced with column properties.
|
|
3757
|
+
* Types were made as separate objects to be reusable per multiple columns.
|
|
3758
|
+
*/
|
|
3759
|
+
this.columnTypes = {};
|
|
3760
|
+
/** Theme name. */
|
|
3761
|
+
this.theme = 'default';
|
|
3762
|
+
/**
|
|
3763
|
+
* Row class property mapping.
|
|
3764
|
+
* Map custom classes to rows from row object data.
|
|
3765
|
+
* Define this property in rgRow object and this will be mapped as rgRow class.
|
|
3766
|
+
*/
|
|
3767
|
+
this.rowClass = '';
|
|
3768
|
+
/**
|
|
3769
|
+
* Autosize config.
|
|
3770
|
+
* Enables columns autoSize.
|
|
3771
|
+
* For more details check `autoSizeColumn` plugin.
|
|
3772
|
+
* By default disabled, hence operation is not performance efficient.
|
|
3773
|
+
* `true` to enable with default params (double header separator click for autosize).
|
|
3774
|
+
* Or define config. See `AutoSizeColumnConfig` for more details.
|
|
3775
|
+
*/
|
|
3776
|
+
this.autoSizeColumn = false;
|
|
3777
|
+
/**
|
|
3778
|
+
* Enables filter plugin.
|
|
3779
|
+
* Can be boolean.
|
|
3780
|
+
* Or can be filter collection See `FilterCollection` for more info.
|
|
3781
|
+
*/
|
|
3782
|
+
this.filter = false;
|
|
3783
|
+
/**
|
|
3784
|
+
* Enable column move plugin.
|
|
3785
|
+
*/
|
|
3786
|
+
this.canMoveColumns = false;
|
|
3787
|
+
/**
|
|
3788
|
+
* Trimmed rows.
|
|
3789
|
+
* Functionality which allows to hide rows from main data set.
|
|
3790
|
+
* `trimmedRows` are physical `rgRow` indexes to hide.
|
|
3791
|
+
*/
|
|
3792
|
+
this.trimmedRows = {};
|
|
3793
|
+
/**
|
|
3794
|
+
* Enable export plugin.
|
|
3795
|
+
*/
|
|
3796
|
+
this.exporting = false;
|
|
3797
|
+
/**
|
|
3798
|
+
* Stretch strategy for columns by `StretchColumn` plugin.
|
|
3799
|
+
* For example if there are more space on the right last column size would be increased.
|
|
3800
|
+
*/
|
|
3801
|
+
this.stretch = false;
|
|
3802
|
+
/**
|
|
3803
|
+
* Additional data to be passed to plugins, renders or editors.
|
|
3804
|
+
* For example if you need to pass Vue component instance.
|
|
3805
|
+
*/
|
|
3806
|
+
this.additionalData = {};
|
|
3807
|
+
/**
|
|
3808
|
+
* Disable lazy rendering mode for the `X axis`.
|
|
3809
|
+
* Use when not many columns present and you don't need rerenader cells during scroll.
|
|
3810
|
+
* Can be used for initial rendering performance improvement.
|
|
3811
|
+
*/
|
|
3812
|
+
this.disableVirtualX = false;
|
|
3813
|
+
/**
|
|
3814
|
+
* Disable lazy rendering mode for the `Y axis`.
|
|
3815
|
+
* Use when not many rows present and you don't need rerenader cells during scroll.
|
|
3816
|
+
* Can be used for initial rendering performance improvement.
|
|
3817
|
+
*/
|
|
3818
|
+
this.disableVirtualY = false;
|
|
3819
|
+
/**
|
|
3820
|
+
* Please only hide the attribution if you are subscribed to Pro version
|
|
3821
|
+
*/
|
|
3822
|
+
this.hideAttribution = false;
|
|
3823
|
+
/**
|
|
3824
|
+
* Prevent rendering until job is done.
|
|
3825
|
+
* Can be used for initial rendering performance improvement.
|
|
3826
|
+
* When several plugins require initial rendering this will prevent double initial rendering.
|
|
3827
|
+
*/
|
|
3828
|
+
this.jobsBeforeRender = [];
|
|
3829
|
+
/**
|
|
3830
|
+
* Register new virtual node inside of grid.
|
|
3831
|
+
* Used for additional items creation such as plugin elements.
|
|
3832
|
+
* Should be set before grid render inside of plugins.
|
|
3833
|
+
* Can return VNode result of h() function or a function that returns VNode.
|
|
3834
|
+
* Function can be used for performance improvement and additional renders.
|
|
3835
|
+
*/
|
|
3836
|
+
this.registerVNode = [];
|
|
3837
|
+
/**
|
|
3838
|
+
* Enable accessibility. If disabled, the grid will not be accessible.
|
|
3839
|
+
* @default true
|
|
3840
|
+
*/
|
|
3841
|
+
this.accessible = true;
|
|
3842
|
+
/**
|
|
3843
|
+
* Enable right-to-left (RTL) mode. When enabled, columns will be displayed from right to left.
|
|
3844
|
+
* @default false
|
|
3845
|
+
*/
|
|
3846
|
+
this.rtl = false;
|
|
3847
|
+
/**
|
|
3848
|
+
* Disable native drag&drop plugin.
|
|
3849
|
+
*/
|
|
3850
|
+
this.canDrag = true;
|
|
3851
|
+
this.extraElements = [];
|
|
3852
|
+
this.pluginService = new PluginService();
|
|
3853
|
+
this.viewport = null;
|
|
3854
|
+
this.isInited = false;
|
|
3855
|
+
}
|
|
3856
|
+
// #endregion
|
|
3857
|
+
// #region Methods
|
|
3858
|
+
/**
|
|
3859
|
+
* Refreshes data viewport.
|
|
3860
|
+
* Can be specific part as rgRow or pinned rgRow or 'all' by default.
|
|
3861
|
+
*/
|
|
3862
|
+
async refresh(type = 'all') {
|
|
3863
|
+
if (!this.dataProvider) {
|
|
3864
|
+
throw new Error('Not connected');
|
|
3865
|
+
}
|
|
3866
|
+
this.dataProvider.refresh(type);
|
|
3867
|
+
}
|
|
3868
|
+
/**
|
|
3869
|
+
* Refreshes data at specified cell.
|
|
3870
|
+
* Useful for performance optimization.
|
|
3871
|
+
* No viewport update will be triggered.
|
|
3872
|
+
*
|
|
3873
|
+
* @example
|
|
3874
|
+
* const grid = document.querySelector('revo-grid');
|
|
3875
|
+
* grid.setDataAt({ row: 0, col: 0, val: 'test' }); // refresh
|
|
3876
|
+
*/
|
|
3877
|
+
async setDataAt({ row, col, colType = 'rgCol', rowType = 'rgRow', val, skipDataUpdate = false, }) {
|
|
3878
|
+
var _a;
|
|
3879
|
+
if (this.dataProvider && this.columnProvider && !skipDataUpdate) {
|
|
3880
|
+
const columnProp = (_a = this.columnProvider.getColumn(col, colType)) === null || _a === void 0 ? void 0 : _a.prop;
|
|
3881
|
+
if (typeof columnProp !== 'undefined') {
|
|
3882
|
+
this.dataProvider.setCellData({
|
|
3883
|
+
type: rowType,
|
|
3884
|
+
rowIndex: row,
|
|
3885
|
+
prop: columnProp,
|
|
3886
|
+
val,
|
|
3887
|
+
}, false);
|
|
3888
|
+
}
|
|
3889
|
+
}
|
|
3890
|
+
const dataElement = this.element.querySelector(`revogr-data[type="${rowType}"][col-type="${colType}"]`);
|
|
3891
|
+
return dataElement === null || dataElement === void 0 ? void 0 : dataElement.updateCell({
|
|
3892
|
+
row,
|
|
3893
|
+
col,
|
|
3894
|
+
});
|
|
3895
|
+
}
|
|
3896
|
+
/**
|
|
3897
|
+
* Scrolls viewport to specified row by index.
|
|
3898
|
+
*/
|
|
3899
|
+
async scrollToRow(coordinate = 0) {
|
|
3900
|
+
if (!this.dimensionProvider) {
|
|
3901
|
+
throw new Error('Not connected');
|
|
3902
|
+
}
|
|
3903
|
+
const y = this.dimensionProvider.getViewPortPos({
|
|
3904
|
+
coordinate,
|
|
3905
|
+
dimension: 'rgRow',
|
|
3906
|
+
});
|
|
3907
|
+
await this.scrollToCoordinate({ y });
|
|
3908
|
+
}
|
|
3909
|
+
/**
|
|
3910
|
+
* Scrolls viewport to specified column by index.
|
|
3911
|
+
*/
|
|
3912
|
+
async scrollToColumnIndex(coordinate = 0) {
|
|
3913
|
+
if (!this.dimensionProvider) {
|
|
3914
|
+
throw new Error('Not connected');
|
|
3915
|
+
}
|
|
3916
|
+
const x = this.dimensionProvider.getViewPortPos({
|
|
3917
|
+
coordinate,
|
|
3918
|
+
dimension: 'rgCol',
|
|
3919
|
+
});
|
|
3920
|
+
await this.scrollToCoordinate({ x });
|
|
3921
|
+
}
|
|
3922
|
+
/**
|
|
3923
|
+
* Scrolls viewport to specified column by prop
|
|
3924
|
+
*/
|
|
3925
|
+
async scrollToColumnProp(prop, dimension = 'rgCol') {
|
|
3926
|
+
if (!this.dimensionProvider || !this.columnProvider) {
|
|
3927
|
+
throw new Error('Not connected');
|
|
3928
|
+
}
|
|
3929
|
+
const coordinate = this.columnProvider.getColumnIndexByProp(prop, dimension);
|
|
3930
|
+
if (coordinate < 0) {
|
|
3931
|
+
// already on the screen
|
|
3932
|
+
return;
|
|
3933
|
+
}
|
|
3934
|
+
const x = this.dimensionProvider.getViewPortPos({
|
|
3935
|
+
coordinate,
|
|
3936
|
+
dimension,
|
|
3937
|
+
});
|
|
3938
|
+
await this.scrollToCoordinate({ x });
|
|
3939
|
+
}
|
|
3940
|
+
/** Update columns */
|
|
3941
|
+
async updateColumns(cols) {
|
|
3942
|
+
var _a;
|
|
3943
|
+
(_a = this.columnProvider) === null || _a === void 0 ? void 0 : _a.updateColumns(cols);
|
|
3944
|
+
}
|
|
3945
|
+
/** Add trimmed by type */
|
|
3946
|
+
async addTrimmed(trimmed, trimmedType = 'external', type = 'rgRow') {
|
|
3947
|
+
if (!this.dataProvider) {
|
|
3948
|
+
throw new Error('Not connected');
|
|
3949
|
+
}
|
|
3950
|
+
const event = this.beforetrimmed.emit({
|
|
3951
|
+
trimmed,
|
|
3952
|
+
trimmedType,
|
|
3953
|
+
type,
|
|
3954
|
+
});
|
|
3955
|
+
if (event.defaultPrevented) {
|
|
3956
|
+
return event;
|
|
3957
|
+
}
|
|
3958
|
+
this.dataProvider.setTrimmed({ [trimmedType]: event.detail.trimmed }, type);
|
|
3959
|
+
this.aftertrimmed.emit();
|
|
3960
|
+
return event;
|
|
3961
|
+
}
|
|
3962
|
+
/** Scrolls view port to coordinate */
|
|
3963
|
+
async scrollToCoordinate(cell) {
|
|
3964
|
+
var _a;
|
|
3965
|
+
(_a = this.viewport) === null || _a === void 0 ? void 0 : _a.scrollToCell(cell);
|
|
3966
|
+
}
|
|
3967
|
+
/** Open editor for cell. */
|
|
3968
|
+
async setCellEdit(rgRow, prop, rowSource = 'rgRow') {
|
|
3969
|
+
var _a;
|
|
3970
|
+
const rgCol = getColumnByProp(this.columns, prop);
|
|
3971
|
+
if (!rgCol) {
|
|
3972
|
+
return;
|
|
3973
|
+
}
|
|
3974
|
+
await timeout();
|
|
3975
|
+
const colGroup = rgCol.pin || 'rgCol';
|
|
3976
|
+
if (!this.columnProvider) {
|
|
3977
|
+
throw new Error('Not connected');
|
|
3978
|
+
}
|
|
3979
|
+
(_a = this.viewport) === null || _a === void 0 ? void 0 : _a.setEdit(rgRow, this.columnProvider.getColumnIndexByProp(prop, colGroup), colGroup, rowSource);
|
|
3980
|
+
}
|
|
3981
|
+
/** Set focus range. */
|
|
3982
|
+
async setCellsFocus(cellStart = { x: 0, y: 0 }, cellEnd = { x: 0, y: 0 }, colType = 'rgCol', rowType = 'rgRow') {
|
|
3983
|
+
var _a;
|
|
3984
|
+
(_a = this.viewport) === null || _a === void 0 ? void 0 : _a.setFocus(colType, rowType, cellStart, cellEnd);
|
|
3985
|
+
}
|
|
3986
|
+
/** Get data from source */
|
|
3987
|
+
async getSource(type = 'rgRow') {
|
|
3988
|
+
if (!this.dataProvider) {
|
|
3989
|
+
throw new Error('Not connected');
|
|
3990
|
+
}
|
|
3991
|
+
return this.dataProvider.stores[type].store.get('source');
|
|
3992
|
+
}
|
|
3993
|
+
/**
|
|
3994
|
+
* Get data from visible part of source
|
|
3995
|
+
* Trimmed/filtered rows will be excluded
|
|
3996
|
+
* @param type - type of source
|
|
3997
|
+
*/
|
|
3998
|
+
async getVisibleSource(type = 'rgRow') {
|
|
3999
|
+
if (!this.dataProvider) {
|
|
4000
|
+
throw new Error('Not connected');
|
|
4001
|
+
}
|
|
4002
|
+
return getVisibleSourceItem(this.dataProvider.stores[type].store);
|
|
4003
|
+
}
|
|
4004
|
+
/**
|
|
4005
|
+
* Provides access to rows internal store observer
|
|
4006
|
+
* Can be used for plugin support
|
|
4007
|
+
* @param type - type of source
|
|
4008
|
+
*/
|
|
4009
|
+
async getSourceStore(type = 'rgRow') {
|
|
4010
|
+
if (!this.dataProvider) {
|
|
4011
|
+
throw new Error('Not connected');
|
|
4012
|
+
}
|
|
4013
|
+
return this.dataProvider.stores[type].store;
|
|
4014
|
+
}
|
|
4015
|
+
/**
|
|
4016
|
+
* Provides access to column internal store observer
|
|
4017
|
+
* Can be used for plugin support
|
|
4018
|
+
* @param type - type of column
|
|
4019
|
+
*/
|
|
4020
|
+
async getColumnStore(type = 'rgCol') {
|
|
4021
|
+
if (!this.columnProvider) {
|
|
4022
|
+
throw new Error('Not connected');
|
|
4023
|
+
}
|
|
4024
|
+
return this.columnProvider.stores[type].store;
|
|
4025
|
+
}
|
|
4026
|
+
/**
|
|
4027
|
+
* Update column sorting
|
|
4028
|
+
* @param column - column prop and cellCompare
|
|
4029
|
+
* @param order - order to apply
|
|
4030
|
+
* @param additive - if false will replace current order
|
|
4031
|
+
*
|
|
4032
|
+
* later passed to SortingPlugin
|
|
4033
|
+
*/
|
|
4034
|
+
async updateColumnSorting(column, order, additive) {
|
|
4035
|
+
this.sortingconfigchanged.emit({
|
|
4036
|
+
columns: [
|
|
4037
|
+
{
|
|
4038
|
+
prop: column.prop,
|
|
4039
|
+
order,
|
|
4040
|
+
cellCompare: column.cellCompare,
|
|
4041
|
+
},
|
|
4042
|
+
],
|
|
4043
|
+
additive,
|
|
4044
|
+
});
|
|
4045
|
+
}
|
|
4046
|
+
/**
|
|
4047
|
+
* Clears column sorting
|
|
4048
|
+
*/
|
|
4049
|
+
async clearSorting() {
|
|
4050
|
+
this.sortingconfigchanged.emit({
|
|
4051
|
+
columns: [],
|
|
4052
|
+
});
|
|
4053
|
+
}
|
|
4054
|
+
/**
|
|
4055
|
+
* Receive all columns in data source
|
|
4056
|
+
*/
|
|
4057
|
+
async getColumns() {
|
|
4058
|
+
if (!this.columnProvider) {
|
|
4059
|
+
throw new Error('Not connected');
|
|
4060
|
+
}
|
|
4061
|
+
return this.columnProvider.getColumns();
|
|
4062
|
+
}
|
|
4063
|
+
/**
|
|
4064
|
+
* Clear current grid focus. Grid has no longer focus on it.
|
|
4065
|
+
*/
|
|
4066
|
+
async clearFocus() {
|
|
4067
|
+
var _a, _b;
|
|
4068
|
+
const focused = (_a = this.viewport) === null || _a === void 0 ? void 0 : _a.getFocused();
|
|
4069
|
+
const event = this.beforefocuslost.emit(focused);
|
|
4070
|
+
if (event.defaultPrevented) {
|
|
4071
|
+
return;
|
|
4072
|
+
}
|
|
4073
|
+
(_b = this.selectionStoreConnector) === null || _b === void 0 ? void 0 : _b.clearAll();
|
|
4074
|
+
}
|
|
4075
|
+
/**
|
|
4076
|
+
* Get all active plugins instances
|
|
4077
|
+
*/
|
|
4078
|
+
async getPlugins() {
|
|
4079
|
+
return this.pluginService.get();
|
|
4080
|
+
}
|
|
4081
|
+
/**
|
|
4082
|
+
* Get the currently focused cell.
|
|
4083
|
+
*/
|
|
4084
|
+
async getFocused() {
|
|
4085
|
+
var _a, _b;
|
|
4086
|
+
return (_b = (_a = this.viewport) === null || _a === void 0 ? void 0 : _a.getFocused()) !== null && _b !== void 0 ? _b : null;
|
|
4087
|
+
}
|
|
4088
|
+
/**
|
|
4089
|
+
* Get size of content
|
|
4090
|
+
* Including all pinned data
|
|
4091
|
+
*/
|
|
4092
|
+
async getContentSize() {
|
|
4093
|
+
var _a;
|
|
4094
|
+
if (!this.dimensionProvider) {
|
|
4095
|
+
throw new Error('Not connected');
|
|
4096
|
+
}
|
|
4097
|
+
return (_a = this.dimensionProvider) === null || _a === void 0 ? void 0 : _a.getFullSize();
|
|
4098
|
+
}
|
|
4099
|
+
/**
|
|
4100
|
+
* Get the currently selected Range.
|
|
4101
|
+
*/
|
|
4102
|
+
async getSelectedRange() {
|
|
4103
|
+
var _a, _b;
|
|
4104
|
+
return (_b = (_a = this.viewport) === null || _a === void 0 ? void 0 : _a.getSelectedRange()) !== null && _b !== void 0 ? _b : null;
|
|
4105
|
+
}
|
|
4106
|
+
/**
|
|
4107
|
+
* Refresh extra elements. Triggers re-rendering of extra elements and functions.
|
|
4108
|
+
* Part of extraElements and registerVNode methods.
|
|
4109
|
+
* Useful for plugins.
|
|
4110
|
+
*/
|
|
4111
|
+
async refreshExtraElements() {
|
|
4112
|
+
var _a;
|
|
4113
|
+
(_a = this.extraService) === null || _a === void 0 ? void 0 : _a.refresh();
|
|
4114
|
+
}
|
|
4115
|
+
/**
|
|
4116
|
+
* Get all providers for grid
|
|
4117
|
+
* Useful for external grid integration
|
|
4118
|
+
*/
|
|
4119
|
+
async getProviders() {
|
|
4120
|
+
return this.getPluginData();
|
|
4121
|
+
}
|
|
4122
|
+
mousedownHandle(event) {
|
|
4123
|
+
const screenX = getPropertyFromEvent(event, 'screenX');
|
|
4124
|
+
const screenY = getPropertyFromEvent(event, 'screenY');
|
|
4125
|
+
if (screenX === null || screenY === null) {
|
|
4126
|
+
return;
|
|
4127
|
+
}
|
|
4128
|
+
this.clickTrackForFocusClear = screenX + screenY;
|
|
4129
|
+
}
|
|
4130
|
+
/**
|
|
4131
|
+
* To keep your elements from losing focus use mouseup/touchend e.preventDefault();
|
|
4132
|
+
*/
|
|
4133
|
+
async mouseupHandle(event) {
|
|
4134
|
+
var _a;
|
|
4135
|
+
const screenX = getPropertyFromEvent(event, 'screenX');
|
|
4136
|
+
const screenY = getPropertyFromEvent(event, 'screenY');
|
|
4137
|
+
if (screenX === null || screenY === null) {
|
|
4138
|
+
return;
|
|
4139
|
+
}
|
|
4140
|
+
if (event.defaultPrevented) {
|
|
4141
|
+
return;
|
|
4142
|
+
}
|
|
4143
|
+
const isRightClick = checkIsRightClick(event);
|
|
4144
|
+
this.aftermouseup.emit({ eventData: event, isRightClick });
|
|
4145
|
+
const pos = screenX + screenY;
|
|
4146
|
+
// detect if mousemove then do nothing
|
|
4147
|
+
if (Math.abs(((_a = this.clickTrackForFocusClear) !== null && _a !== void 0 ? _a : 0) - pos) > 10) {
|
|
4148
|
+
return;
|
|
4149
|
+
}
|
|
4150
|
+
// Check if action finished inside the document
|
|
4151
|
+
// if event prevented, or it is current table don't clear focus
|
|
4152
|
+
const path = event.composedPath();
|
|
4153
|
+
if (!path.includes(this.element) &&
|
|
4154
|
+
!(this.element.shadowRoot && path.includes(this.element.shadowRoot))) {
|
|
4155
|
+
// Perform actions if the click is outside the component
|
|
4156
|
+
await this.clearFocus();
|
|
4157
|
+
}
|
|
4158
|
+
}
|
|
4159
|
+
/**
|
|
4160
|
+
* Cancel drag & drop using e.preventDefault();
|
|
4161
|
+
*/
|
|
4162
|
+
beforeColumnDragEnd(event) {
|
|
4163
|
+
this.beforecolumndrag.emit(event.detail);
|
|
4164
|
+
}
|
|
4165
|
+
// #endregion
|
|
4166
|
+
// #region Listeners
|
|
4167
|
+
/** Drag events */
|
|
4168
|
+
onRowDragStarted(e) {
|
|
4169
|
+
var _a;
|
|
4170
|
+
const dragStart = this.rowdragstart.emit(e.detail);
|
|
4171
|
+
if (dragStart.defaultPrevented) {
|
|
4172
|
+
e.preventDefault();
|
|
4173
|
+
return;
|
|
4174
|
+
}
|
|
4175
|
+
(_a = this.orderService) === null || _a === void 0 ? void 0 : _a.start(this.element, Object.assign(Object.assign({}, e.detail), dragStart.detail));
|
|
4176
|
+
}
|
|
4177
|
+
onRowDragEnd() {
|
|
4178
|
+
var _a;
|
|
4179
|
+
(_a = this.orderService) === null || _a === void 0 ? void 0 : _a.end();
|
|
4180
|
+
}
|
|
4181
|
+
onRowOrderChange(e) {
|
|
4182
|
+
var _a;
|
|
4183
|
+
(_a = this.dataProvider) === null || _a === void 0 ? void 0 : _a.changeOrder(e.detail);
|
|
4184
|
+
}
|
|
4185
|
+
onRowDrag({ detail }) {
|
|
4186
|
+
var _a;
|
|
4187
|
+
(_a = this.orderService) === null || _a === void 0 ? void 0 : _a.move(detail);
|
|
4188
|
+
}
|
|
4189
|
+
onRowMouseMove(e) {
|
|
4190
|
+
var _a;
|
|
4191
|
+
(_a = this.orderService) === null || _a === void 0 ? void 0 : _a.moveTip(e.detail);
|
|
4192
|
+
}
|
|
4193
|
+
async onCellEdit(e) {
|
|
4194
|
+
var _a;
|
|
4195
|
+
const previousModel = JSON.parse(JSON.stringify(e.detail.model));
|
|
4196
|
+
const { defaultPrevented, detail } = this.beforeedit.emit(e.detail);
|
|
4197
|
+
await timeout();
|
|
4198
|
+
// apply data
|
|
4199
|
+
if (!defaultPrevented) {
|
|
4200
|
+
(_a = this.dataProvider) === null || _a === void 0 ? void 0 : _a.setCellData(detail);
|
|
4201
|
+
// @feature: incrimental update for cells
|
|
4202
|
+
// this.dataProvider.setCellData(detail, false);
|
|
4203
|
+
// await this.setDataAt({
|
|
4204
|
+
// row: detail.rowIndex,
|
|
4205
|
+
// col: detail.colIndex,
|
|
4206
|
+
// rowType: detail.type,
|
|
4207
|
+
// colType: detail.colType,
|
|
4208
|
+
// });
|
|
4209
|
+
this.afteredit.emit(Object.assign(Object.assign({}, detail), { previousModel }));
|
|
4210
|
+
}
|
|
4211
|
+
}
|
|
4212
|
+
async onRangeEdit(e) {
|
|
4213
|
+
if (!this.dataProvider) {
|
|
4214
|
+
throw new Error('Not connected');
|
|
4215
|
+
}
|
|
4216
|
+
const previousModels = JSON.parse(JSON.stringify(e.detail.models));
|
|
4217
|
+
const { defaultPrevented, detail } = this.beforerangeedit.emit(e.detail);
|
|
4218
|
+
if (defaultPrevented) {
|
|
4219
|
+
e.preventDefault();
|
|
4220
|
+
return;
|
|
4221
|
+
}
|
|
4222
|
+
this.dataProvider.setRangeData(detail.data, detail.type);
|
|
4223
|
+
this.afteredit.emit(Object.assign(Object.assign({}, detail), { previousModels }));
|
|
4224
|
+
}
|
|
4225
|
+
onRangeChanged(e) {
|
|
4226
|
+
const beforeange = this.beforerange.emit(e.detail);
|
|
4227
|
+
if (beforeange.defaultPrevented) {
|
|
4228
|
+
e.preventDefault();
|
|
4229
|
+
}
|
|
4230
|
+
const beforeFill = this.beforeautofill.emit(beforeange.detail);
|
|
4231
|
+
if (beforeFill.defaultPrevented) {
|
|
4232
|
+
e.preventDefault();
|
|
4233
|
+
}
|
|
4234
|
+
}
|
|
4235
|
+
onRowDropped(e) {
|
|
4236
|
+
// e.cancelBubble = true;
|
|
4237
|
+
const { defaultPrevented } = this.roworderchanged.emit(e.detail);
|
|
4238
|
+
if (defaultPrevented) {
|
|
4239
|
+
e.preventDefault();
|
|
4240
|
+
}
|
|
4241
|
+
}
|
|
4242
|
+
onHeaderClick(e) {
|
|
4243
|
+
const { defaultPrevented } = this.headerclick.emit(Object.assign(Object.assign({}, e.detail.column), { originalEvent: e.detail.originalEvent }));
|
|
4244
|
+
if (defaultPrevented) {
|
|
4245
|
+
e.preventDefault();
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
onCellFocus(e) {
|
|
4249
|
+
const { defaultPrevented } = this.beforecellfocus.emit(e.detail);
|
|
4250
|
+
if (!this.canFocus || defaultPrevented) {
|
|
4251
|
+
e.preventDefault();
|
|
4252
|
+
}
|
|
4253
|
+
}
|
|
4254
|
+
// #endregion
|
|
4255
|
+
// #region Watchers
|
|
4256
|
+
columnTypesChanged() {
|
|
4257
|
+
// Column format change will trigger column structure update
|
|
4258
|
+
this.columnChanged(this.columns);
|
|
4259
|
+
}
|
|
4260
|
+
columnChanged(newVal = [], _prevVal = undefined, __watchName = 'columns', init = false) {
|
|
4261
|
+
if (!this.dimensionProvider || !this.columnProvider) {
|
|
4262
|
+
return;
|
|
4263
|
+
}
|
|
4264
|
+
const columnGather = getColumns(newVal, 0, this.columnTypes);
|
|
4265
|
+
const beforeSetEvent = this.beforecolumnsset.emit(columnGather);
|
|
4266
|
+
if (beforeSetEvent.defaultPrevented) {
|
|
4267
|
+
return;
|
|
4268
|
+
}
|
|
4269
|
+
this.dimensionProvider.applyNewColumns(beforeSetEvent.detail.columns, this.disableVirtualX, init);
|
|
4270
|
+
const beforeApplyEvent = this.beforecolumnapplied.emit(columnGather);
|
|
4271
|
+
if (beforeApplyEvent.defaultPrevented) {
|
|
4272
|
+
return;
|
|
4273
|
+
}
|
|
4274
|
+
const columns = this.columnProvider.setColumns(beforeApplyEvent.detail);
|
|
4275
|
+
this.aftercolumnsset.emit({
|
|
4276
|
+
columns,
|
|
4277
|
+
order: Object.entries(beforeApplyEvent.detail.sort).reduce((acc, [prop, column]) => {
|
|
4278
|
+
acc[prop] = column.order;
|
|
4279
|
+
return acc;
|
|
4280
|
+
}, {}),
|
|
4281
|
+
});
|
|
4282
|
+
}
|
|
4283
|
+
disableVirtualXChanged(newVal = false, prevVal = false) {
|
|
4284
|
+
if (newVal === prevVal) {
|
|
4285
|
+
return;
|
|
4286
|
+
}
|
|
4287
|
+
this.columnChanged(this.columns);
|
|
4288
|
+
}
|
|
4289
|
+
rowSizeChanged(s) {
|
|
4290
|
+
if (!this.dimensionProvider) {
|
|
4291
|
+
return;
|
|
4292
|
+
}
|
|
4293
|
+
// clear existing data
|
|
4294
|
+
this.dimensionProvider.setSettings({ originItemSize: s }, 'rgRow');
|
|
4295
|
+
this.rowDefChanged(this.rowDefinitions, this.rowDefinitions, 'rowSize', true);
|
|
4296
|
+
}
|
|
4297
|
+
themeChanged(t, _, __ = 'theme', init = false) {
|
|
4298
|
+
if (!this.dimensionProvider) {
|
|
4299
|
+
return;
|
|
4300
|
+
}
|
|
4301
|
+
this.themeService.register(t);
|
|
4302
|
+
this.dimensionProvider.setSettings({ originItemSize: this.themeService.rowSize }, 'rgRow');
|
|
4303
|
+
this.dimensionProvider.setSettings({ originItemSize: this.colSize }, 'rgCol');
|
|
4304
|
+
// if theme change we need to reapply row size and reset viewport
|
|
4305
|
+
if (!init) {
|
|
4306
|
+
// clear existing data
|
|
4307
|
+
this.dimensionProvider.setSettings({ originItemSize: this.themeService.rowSize }, 'rgRow');
|
|
4308
|
+
this.rowDefChanged(
|
|
4309
|
+
// for cases when some custom size present and not
|
|
4310
|
+
this.rowDefinitions, this.rowDefinitions, 'theme', true);
|
|
4311
|
+
}
|
|
4312
|
+
this.afterthemechanged.emit(t);
|
|
4313
|
+
}
|
|
4314
|
+
dataSourceChanged(newVal = [], _, watchName) {
|
|
4315
|
+
if (!this.dataProvider) {
|
|
4316
|
+
return;
|
|
4317
|
+
}
|
|
4318
|
+
let type = 'rgRow';
|
|
4319
|
+
switch (watchName) {
|
|
4320
|
+
case 'pinnedBottomSource':
|
|
4321
|
+
type = 'rowPinEnd';
|
|
4322
|
+
break;
|
|
4323
|
+
case 'pinnedTopSource':
|
|
4324
|
+
type = 'rowPinStart';
|
|
4325
|
+
break;
|
|
4326
|
+
case 'source':
|
|
4327
|
+
type = 'rgRow';
|
|
4328
|
+
/**
|
|
4329
|
+
* Applied for source only for cross compatability between plugins
|
|
4330
|
+
*/
|
|
4331
|
+
const beforesourceset = this.beforesourceset.emit({
|
|
4332
|
+
type,
|
|
4333
|
+
source: newVal,
|
|
4334
|
+
});
|
|
4335
|
+
newVal = beforesourceset.detail.source;
|
|
4336
|
+
break;
|
|
4337
|
+
}
|
|
4338
|
+
const beforesourceset = this.beforeanysource.emit({
|
|
4339
|
+
type,
|
|
4340
|
+
source: newVal,
|
|
4341
|
+
});
|
|
4342
|
+
const newSource = [...beforesourceset.detail.source];
|
|
4343
|
+
this.dataProvider.setData(newSource, type, this.disableVirtualY);
|
|
4344
|
+
/**
|
|
4345
|
+
* Applied for source only for cross compatability between plugins
|
|
4346
|
+
*/
|
|
4347
|
+
if (watchName === 'source') {
|
|
4348
|
+
this.aftersourceset.emit({
|
|
4349
|
+
type,
|
|
4350
|
+
source: newVal,
|
|
4351
|
+
});
|
|
4352
|
+
}
|
|
4353
|
+
this.afteranysource.emit({
|
|
4354
|
+
type,
|
|
4355
|
+
source: newVal,
|
|
4356
|
+
});
|
|
4357
|
+
}
|
|
4358
|
+
disableVirtualYChanged(newVal = false, prevVal = false) {
|
|
4359
|
+
if (newVal === prevVal) {
|
|
4360
|
+
return;
|
|
4361
|
+
}
|
|
4362
|
+
this.dataSourceChanged(this.source, this.source, 'source');
|
|
4363
|
+
}
|
|
4364
|
+
rowDefChanged(after, before, _watchName, forceUpdate = true) {
|
|
4365
|
+
// in firefox it's triggered before init
|
|
4366
|
+
if (!this.dimensionProvider || !this.dataProvider) {
|
|
4367
|
+
return;
|
|
4368
|
+
}
|
|
4369
|
+
const { detail: { vals: newVal, oldVals: oldVal }, } = this.beforerowdefinition.emit({
|
|
4370
|
+
vals: after,
|
|
4371
|
+
oldVals: before,
|
|
4372
|
+
});
|
|
4373
|
+
// apply new values
|
|
4374
|
+
const newRows = rowDefinitionByType(newVal);
|
|
4375
|
+
// clear current defs
|
|
4376
|
+
if (oldVal) {
|
|
4377
|
+
const remove = rowDefinitionRemoveByType(oldVal);
|
|
4378
|
+
// clear all old data and drop sizes
|
|
4379
|
+
for (const t in remove) {
|
|
4380
|
+
if (remove.hasOwnProperty(t)) {
|
|
4381
|
+
const type = t;
|
|
4382
|
+
const store = this.dataProvider.stores[type];
|
|
4383
|
+
const sourceLength = store.store.get('source').length;
|
|
4384
|
+
this.dimensionProvider.clearSize(type, sourceLength);
|
|
4385
|
+
}
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
// set new sizes
|
|
4389
|
+
rowTypes.forEach(t => {
|
|
4390
|
+
var _a;
|
|
4391
|
+
const newSizes = newRows[t];
|
|
4392
|
+
// apply new sizes or force update
|
|
4393
|
+
if (newSizes || forceUpdate) {
|
|
4394
|
+
(_a = this.dimensionProvider) === null || _a === void 0 ? void 0 : _a.setCustomSizes(t, (newSizes === null || newSizes === void 0 ? void 0 : newSizes.sizes) || {});
|
|
4395
|
+
}
|
|
4396
|
+
});
|
|
4397
|
+
}
|
|
4398
|
+
trimmedRowsChanged(newVal = {}) {
|
|
4399
|
+
this.addTrimmed(newVal);
|
|
4400
|
+
}
|
|
4401
|
+
/**
|
|
4402
|
+
* Grouping
|
|
4403
|
+
*/
|
|
4404
|
+
groupingChanged(newVal = {}) {
|
|
4405
|
+
var _a;
|
|
4406
|
+
(_a = this.pluginService.getByClass(GroupingRowPlugin)) === null || _a === void 0 ? void 0 : _a.setGrouping(newVal || {});
|
|
4407
|
+
}
|
|
4408
|
+
/**
|
|
4409
|
+
* Stretch Plugin Apply
|
|
4410
|
+
*/
|
|
4411
|
+
applyStretch(isStretch) {
|
|
4412
|
+
if (!this.dimensionProvider ||
|
|
4413
|
+
!this.dataProvider ||
|
|
4414
|
+
!this.columnProvider ||
|
|
4415
|
+
!this.viewportProvider) {
|
|
4416
|
+
return;
|
|
4417
|
+
}
|
|
4418
|
+
if (isStretch === 'false') {
|
|
4419
|
+
isStretch = false;
|
|
4420
|
+
}
|
|
4421
|
+
const pluginData = this.getPluginData();
|
|
4422
|
+
if (!pluginData) {
|
|
4423
|
+
return;
|
|
4424
|
+
}
|
|
4425
|
+
const stretch = this.pluginService.getByClass(StretchColumn);
|
|
4426
|
+
if ((typeof isStretch === 'boolean' && isStretch) || isStretch === 'true') {
|
|
4427
|
+
if (!stretch) {
|
|
4428
|
+
this.pluginService.add(new StretchColumn(this.element, pluginData));
|
|
4429
|
+
}
|
|
4430
|
+
else if (isStretchPlugin(stretch)) {
|
|
4431
|
+
stretch.applyStretch(this.columnProvider.getRawColumns());
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
else if (stretch) {
|
|
4435
|
+
this.pluginService.remove(stretch);
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
applyFilter(cfg) {
|
|
4439
|
+
this.filterconfigchanged.emit(cfg);
|
|
4440
|
+
}
|
|
4441
|
+
applySorting(cfg) {
|
|
4442
|
+
this.sortingconfigchanged.emit(cfg);
|
|
4443
|
+
}
|
|
4444
|
+
rowHeadersChange(rowHeaders) {
|
|
4445
|
+
this.rowheaderschanged.emit(rowHeaders);
|
|
4446
|
+
}
|
|
4447
|
+
/**
|
|
4448
|
+
* Register external VNodes
|
|
4449
|
+
*/
|
|
4450
|
+
registerOutsideVNodes(elements = []) {
|
|
4451
|
+
this.extraElements = elements;
|
|
4452
|
+
}
|
|
4453
|
+
additionalDataChanged(data) {
|
|
4454
|
+
this.additionaldatachanged.emit(data);
|
|
4455
|
+
}
|
|
4456
|
+
/**
|
|
4457
|
+
* Watch for RTL changes and reapply column ordering
|
|
4458
|
+
*/
|
|
4459
|
+
rtlChanged() {
|
|
4460
|
+
// The RTL plugin will handle the transformation automatically
|
|
4461
|
+
// Just trigger a column refresh to ensure the plugin processes the change
|
|
4462
|
+
this.columnChanged(this.columns);
|
|
4463
|
+
}
|
|
4464
|
+
/**
|
|
4465
|
+
* User can add plugins via plugins property
|
|
4466
|
+
*/
|
|
4467
|
+
pluginsChanged(plugins = [], prevPlugins) {
|
|
4468
|
+
this.pluginService.addUserPluginsAndCreate(this.element, plugins, prevPlugins, this.getPluginData());
|
|
4469
|
+
}
|
|
4470
|
+
// #endregion
|
|
4471
|
+
// #region Plugins
|
|
4472
|
+
setPlugins() {
|
|
4473
|
+
// remove old plugins if any
|
|
4474
|
+
this.removePlugins();
|
|
4475
|
+
// pass data provider to plugins
|
|
4476
|
+
const pluginData = this.getPluginData();
|
|
4477
|
+
if (!pluginData) {
|
|
4478
|
+
return;
|
|
4479
|
+
}
|
|
4480
|
+
// register system plugins
|
|
4481
|
+
this.setCorePlugins(pluginData);
|
|
4482
|
+
// register user plugins
|
|
4483
|
+
this.pluginsChanged(this.plugins);
|
|
4484
|
+
}
|
|
4485
|
+
setCorePlugins(pluginData) {
|
|
4486
|
+
if (this.accessible) {
|
|
4487
|
+
this.pluginService.add(new WCAGPlugin(this.element, pluginData));
|
|
4488
|
+
}
|
|
4489
|
+
// register RTL plugin
|
|
4490
|
+
this.pluginService.add(new RTLPlugin(this.element, pluginData));
|
|
4491
|
+
// register auto size plugin
|
|
4492
|
+
if (this.autoSizeColumn) {
|
|
4493
|
+
this.pluginService.add(new AutoSizeColumnPlugin(this.element, pluginData, typeof this.autoSizeColumn === 'object'
|
|
4494
|
+
? this.autoSizeColumn
|
|
4495
|
+
: undefined));
|
|
4496
|
+
}
|
|
4497
|
+
// register filter plugin
|
|
4498
|
+
if (this.filter) {
|
|
4499
|
+
this.pluginService.add(new FilterPlugin(this.element, pluginData, typeof this.filter === 'object' ? this.filter : undefined));
|
|
4500
|
+
}
|
|
4501
|
+
// register export plugin
|
|
4502
|
+
if (this.exporting) {
|
|
4503
|
+
this.pluginService.add(new ExportFilePlugin(this.element, pluginData));
|
|
4504
|
+
}
|
|
4505
|
+
// register sorting plugin
|
|
4506
|
+
this.pluginService.add(new SortingPlugin(this.element, pluginData));
|
|
4507
|
+
// register grouping plugin
|
|
4508
|
+
this.pluginService.add(new GroupingRowPlugin(this.element, pluginData));
|
|
4509
|
+
if (this.canMoveColumns) {
|
|
4510
|
+
this.pluginService.add(new ColumnMovePlugin(this.element, pluginData));
|
|
4511
|
+
}
|
|
4512
|
+
}
|
|
4513
|
+
getPluginData() {
|
|
4514
|
+
if (!this.dimensionProvider ||
|
|
4515
|
+
!this.dataProvider ||
|
|
4516
|
+
!this.columnProvider ||
|
|
4517
|
+
!this.viewportProvider ||
|
|
4518
|
+
!this.selectionStoreConnector) {
|
|
4519
|
+
return;
|
|
4520
|
+
}
|
|
4521
|
+
// pass data provider to plugins
|
|
4522
|
+
const pluginData = {
|
|
4523
|
+
data: this.dataProvider,
|
|
4524
|
+
column: this.columnProvider,
|
|
4525
|
+
dimension: this.dimensionProvider,
|
|
4526
|
+
viewport: this.viewportProvider,
|
|
4527
|
+
selection: this.selectionStoreConnector,
|
|
4528
|
+
plugins: this.pluginService,
|
|
4529
|
+
};
|
|
4530
|
+
return pluginData;
|
|
4531
|
+
}
|
|
4532
|
+
removePlugins() {
|
|
4533
|
+
this.pluginService.destroy();
|
|
4534
|
+
}
|
|
4535
|
+
// #endregion
|
|
4536
|
+
// if reconnect to dom we need to set up plugins
|
|
4537
|
+
connectedCallback() {
|
|
4538
|
+
if (this.isInited) {
|
|
4539
|
+
this.setPlugins();
|
|
4540
|
+
}
|
|
4541
|
+
this.created.emit();
|
|
4542
|
+
}
|
|
4543
|
+
/**
|
|
4544
|
+
* Called once just after the component is first connected to the DOM.
|
|
4545
|
+
* Since this method is only called once, it's a good place to load data asynchronously and to setup the state
|
|
4546
|
+
* without triggering extra re-renders.
|
|
4547
|
+
* A promise can be returned, that can be used to wait for the first render().
|
|
4548
|
+
*/
|
|
4549
|
+
componentWillLoad() {
|
|
4550
|
+
var _a;
|
|
4551
|
+
// #region Setup Providers
|
|
4552
|
+
this.viewportProvider = new ViewportProvider();
|
|
4553
|
+
this.themeService = new ThemeService({
|
|
4554
|
+
rowSize: this.rowSize,
|
|
4555
|
+
});
|
|
4556
|
+
this.dimensionProvider = new DimensionProvider(this.viewportProvider, {
|
|
4557
|
+
realSizeChanged: (k) => this.contentsizechanged.emit(k),
|
|
4558
|
+
});
|
|
4559
|
+
this.columnProvider = new ColumnDataProvider();
|
|
4560
|
+
this.selectionStoreConnector = new SelectionStoreConnector();
|
|
4561
|
+
this.dataProvider = new DataProvider(this.dimensionProvider);
|
|
4562
|
+
// #endregion
|
|
4563
|
+
this.registerOutsideVNodes(this.registerVNode);
|
|
4564
|
+
// init plugins
|
|
4565
|
+
this.setPlugins();
|
|
4566
|
+
// set data
|
|
4567
|
+
this.applyStretch(this.stretch);
|
|
4568
|
+
this.themeChanged(this.theme, undefined, undefined, true);
|
|
4569
|
+
this.columnChanged(this.columns, undefined, undefined, true);
|
|
4570
|
+
this.dataSourceChanged(this.source, undefined, 'source');
|
|
4571
|
+
this.dataSourceChanged(this.pinnedTopSource, undefined, 'pinnedTopSource');
|
|
4572
|
+
this.dataSourceChanged(this.pinnedBottomSource, undefined, 'pinnedBottomSource');
|
|
4573
|
+
if (Object.keys((_a = this.trimmedRows) !== null && _a !== void 0 ? _a : {}).length > 0) {
|
|
4574
|
+
this.trimmedRowsChanged(this.trimmedRows);
|
|
4575
|
+
}
|
|
4576
|
+
this.rowDefChanged(this.rowDefinitions);
|
|
4577
|
+
// init grouping
|
|
4578
|
+
if (this.grouping && Object.keys(this.grouping).length > 0) {
|
|
4579
|
+
this.groupingChanged(this.grouping);
|
|
4580
|
+
}
|
|
4581
|
+
// init scrolling service
|
|
4582
|
+
this.scrollingService = new GridScrollingService((e) => {
|
|
4583
|
+
var _a, _b;
|
|
4584
|
+
(_a = this.dimensionProvider) === null || _a === void 0 ? void 0 : _a.setViewPortCoordinate({
|
|
4585
|
+
coordinate: e.coordinate,
|
|
4586
|
+
type: e.dimension,
|
|
4587
|
+
});
|
|
4588
|
+
const viewportRows = (_b = this.viewportProvider) === null || _b === void 0 ? void 0 : _b.stores.rgRow.store.get('items');
|
|
4589
|
+
this.viewportscroll.emit(Object.assign(Object.assign({}, e), { viewportRows }));
|
|
4590
|
+
});
|
|
4591
|
+
this.aftergridinit.emit();
|
|
4592
|
+
// set inited flag for connectedCallback
|
|
4593
|
+
this.isInited = true;
|
|
4594
|
+
}
|
|
4595
|
+
componentWillRender() {
|
|
4596
|
+
const event = this.beforegridrender.emit();
|
|
4597
|
+
if (event.defaultPrevented) {
|
|
4598
|
+
return false;
|
|
4599
|
+
}
|
|
4600
|
+
return Promise.all(this.jobsBeforeRender);
|
|
4601
|
+
}
|
|
4602
|
+
componentDidRender() {
|
|
4603
|
+
this.aftergridrender.emit();
|
|
4604
|
+
}
|
|
4605
|
+
render() {
|
|
4606
|
+
if (!this.dimensionProvider ||
|
|
4607
|
+
!this.dataProvider ||
|
|
4608
|
+
!this.columnProvider ||
|
|
4609
|
+
!this.viewportProvider ||
|
|
4610
|
+
!this.selectionStoreConnector) {
|
|
4611
|
+
return;
|
|
4612
|
+
}
|
|
4613
|
+
const contentHeight = this.dimensionProvider.stores['rgRow'].store.get('realSize');
|
|
4614
|
+
// init viewport service helpers
|
|
4615
|
+
this.viewport = new ViewportService({
|
|
4616
|
+
columnProvider: this.columnProvider,
|
|
4617
|
+
dataProvider: this.dataProvider,
|
|
4618
|
+
dimensionProvider: this.dimensionProvider,
|
|
4619
|
+
viewportProvider: this.viewportProvider,
|
|
4620
|
+
scrollingService: this.scrollingService,
|
|
4621
|
+
orderService: this.orderService,
|
|
4622
|
+
selectionStoreConnector: this.selectionStoreConnector,
|
|
4623
|
+
disableVirtualX: this.disableVirtualX,
|
|
4624
|
+
disableVirtualY: this.disableVirtualY,
|
|
4625
|
+
resize: c => this.aftercolumnresize.emit(c),
|
|
4626
|
+
}, contentHeight);
|
|
4627
|
+
// #region ViewportSections
|
|
4628
|
+
/**
|
|
4629
|
+
* The code renders a viewport divided into sections.
|
|
4630
|
+
* It starts by rendering the pinned start, data, and pinned end sections.
|
|
4631
|
+
* Within each section, it renders columns along with their headers, pinned top, center data, and pinned bottom.
|
|
4632
|
+
* The code iterates over the columns and their data to generate the view port's HTML structure.
|
|
4633
|
+
*/
|
|
4634
|
+
const viewportSections = [];
|
|
4635
|
+
// Row headers setting
|
|
4636
|
+
if (this.rowHeaders && this.viewport.columns.length) {
|
|
4637
|
+
const anyView = this.viewport.columns[0];
|
|
4638
|
+
viewportSections.push(h("revogr-row-headers", { additionalData: this.additionalData, height: contentHeight, rowClass: this.rowClass, resize: this.resize, dataPorts: anyView.dataPorts, headerProp: anyView.headerProp, jobsBeforeRender: this.jobsBeforeRender, rowHeaderColumn: typeof this.rowHeaders === 'object' ? this.rowHeaders : undefined, onScrollview: ({ detail: e }) => this.scrollingService.proxyScroll(e, 'headerRow'), onRef: ({ detail: e }) => this.scrollingService.registerElement(e, 'headerRow') }));
|
|
4639
|
+
}
|
|
4640
|
+
// Viewport section render
|
|
4641
|
+
const isMobile = isMobileDevice();
|
|
4642
|
+
const viewPortHtml = [];
|
|
4643
|
+
// Render viewports column(horizontal sections)
|
|
4644
|
+
for (let view of this.viewport.columns) {
|
|
4645
|
+
const headerProperties = Object.assign(Object.assign({}, view.headerProp), { type: view.type, additionalData: this.additionalData, viewportCol: view.viewportCol, selectionStore: view.columnSelectionStore, canResize: this.resize, readonly: this.readonly, columnFilter: !!this.filter });
|
|
4646
|
+
// Column headers
|
|
4647
|
+
const dataViews = [
|
|
4648
|
+
h("revogr-header", Object.assign({}, headerProperties, { slot: HEADER_SLOT })),
|
|
4649
|
+
];
|
|
4650
|
+
// Render viewport data (vertical sections)
|
|
4651
|
+
view.dataPorts.forEach(data => {
|
|
4652
|
+
const key = `${data.type}_${view.type}`;
|
|
4653
|
+
const dataView = (h("revogr-overlay-selection", Object.assign({}, data, { canDrag: this.canDrag && data.canDrag, isMobileDevice: isMobile, onSelectall: () => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.selectAll(); }, onRollback: () => this.afterrollback.emit(), editors: this.editors, readonly: this.readonly, range: this.range, useClipboard: this.useClipboard, applyChangesOnClose: this.applyOnClose, additionalData: this.additionalData, slot: data.slot, onBeforenextvpfocus: e => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.beforeNextFocusCell(e.detail); }, onCanceledit: () => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEdit(false); }, onSetedit: ({ detail }) => {
|
|
4654
|
+
var _a;
|
|
4655
|
+
const event = this.beforeeditstart.emit(detail);
|
|
4656
|
+
if (!event.defaultPrevented) {
|
|
4657
|
+
(_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEdit(detail.val);
|
|
4658
|
+
}
|
|
4659
|
+
} }), h("revogr-data", Object.assign({}, data, { colType: view.type, key: key, readonly: this.readonly, range: this.range, rowClass: this.rowClass, rowSelectionStore: data.rowSelectionStore, additionalData: this.additionalData, jobsBeforeRender: this.jobsBeforeRender, slot: DATA_SLOT }), h("slot", { name: `data-${view.type}-${data.type}` })), h("revogr-temp-range", { selectionStore: data.selectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }), h("revogr-focus", { colData: data.colData, dataStore: data.dataStore, focusTemplate: this.focusTemplate, rowType: data.type, colType: view.type, selectionStore: data.selectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }, h("slot", { name: `focus-${view.type}-${data.type}` }))));
|
|
4660
|
+
dataViews.push(dataView);
|
|
4661
|
+
});
|
|
4662
|
+
// Add viewport scroll in the end
|
|
4663
|
+
viewPortHtml.push(h("revogr-viewport-scroll", Object.assign({}, view.prop, { ref: el => this.scrollingService.registerElement(el, `${view.prop.key}`), onScrollviewport: e => this.scrollingService.proxyScroll(e.detail, `${view.prop.key}`), onScrollviewportsilent: e => this.scrollingService.scrollSilentService(e.detail, `${view.prop.key}`) }), dataViews));
|
|
4664
|
+
}
|
|
4665
|
+
viewportSections.push(viewPortHtml);
|
|
4666
|
+
// #endregion
|
|
4667
|
+
const typeRow = 'rgRow';
|
|
4668
|
+
const typeCol = 'rgCol';
|
|
4669
|
+
const viewports = this.viewportProvider.stores;
|
|
4670
|
+
const dimensions = this.dimensionProvider.stores;
|
|
4671
|
+
const verticalScroll = (h("revogr-scroll-virtual", { class: "vertical", dimension: typeRow, clientSize: viewports[typeRow].store.get('clientSize'), virtualSize: viewports[typeRow].store.get('virtualSize'), realSize: dimensions[typeRow].store.get('realSize'), ref: el => this.scrollingService.registerElement(el, 'rowScroll'), onScrollvirtual: e => this.scrollingService.proxyScroll(e.detail) }));
|
|
4672
|
+
const horizontalScroll = (h("revogr-scroll-virtual", { class: "horizontal", dimension: typeCol, clientSize: viewports[typeCol].store.get('clientSize'), virtualSize: viewports[typeCol].store.get('virtualSize'), realSize: dimensions[typeCol].store.get('realSize'), ref: el => this.scrollingService.registerElement(el, 'colScroll'), onScrollvirtual: e => this.scrollingService.proxyScroll(e.detail) }));
|
|
4673
|
+
return (h(Host, { dir: this.rtl ? 'rtl' : 'ltr' }, this.hideAttribution ? null : (h("revogr-attribution", { class: "attribution" })), h("slot", { name: "header" }), h("div", { class: "main-viewport", onClick: (e) => {
|
|
4674
|
+
var _a;
|
|
4675
|
+
if (e.currentTarget === e.target) {
|
|
4676
|
+
(_a = this.viewport) === null || _a === void 0 ? void 0 : _a.clearEdit();
|
|
4677
|
+
}
|
|
4678
|
+
} }, h("div", { class: "viewports" }, h("slot", { name: "viewport" }), viewportSections, verticalScroll, h(OrderRenderer, { ref: e => (this.orderService = e) }))), horizontalScroll, h("revogr-extra", { ref: el => (this.extraService = el), nodes: this.extraElements }), h("slot", { name: "footer" })));
|
|
4679
|
+
}
|
|
4680
|
+
disconnectedCallback() {
|
|
4681
|
+
// Remove all plugins, to avoid memory leaks
|
|
4682
|
+
// and unexpected behaviour when the component is removed
|
|
4683
|
+
this.removePlugins();
|
|
4684
|
+
}
|
|
4685
|
+
get element() { return this; }
|
|
4686
|
+
static get watchers() { return {
|
|
4687
|
+
"columnTypes": ["columnTypesChanged"],
|
|
4688
|
+
"columns": ["columnChanged"],
|
|
4689
|
+
"disableVirtualX": ["disableVirtualXChanged"],
|
|
4690
|
+
"rowSize": ["rowSizeChanged"],
|
|
4691
|
+
"theme": ["themeChanged"],
|
|
4692
|
+
"source": ["dataSourceChanged"],
|
|
4693
|
+
"pinnedBottomSource": ["dataSourceChanged"],
|
|
4694
|
+
"pinnedTopSource": ["dataSourceChanged"],
|
|
4695
|
+
"disableVirtualY": ["disableVirtualYChanged"],
|
|
4696
|
+
"rowDefinitions": ["rowDefChanged"],
|
|
4697
|
+
"trimmedRows": ["trimmedRowsChanged"],
|
|
4698
|
+
"grouping": ["groupingChanged"],
|
|
4699
|
+
"stretch": ["applyStretch"],
|
|
4700
|
+
"filter": ["applyFilter"],
|
|
4701
|
+
"sorting": ["applySorting"],
|
|
4702
|
+
"rowHeaders": ["rowHeadersChange"],
|
|
4703
|
+
"registerVNode": ["registerOutsideVNodes"],
|
|
4704
|
+
"additionalData": ["additionalDataChanged"],
|
|
4705
|
+
"rtl": ["rtlChanged"],
|
|
4706
|
+
"plugins": ["pluginsChanged"]
|
|
4707
|
+
}; }
|
|
4708
|
+
static get style() { return revoGridStyleCss; }
|
|
4709
|
+
}, [260, "revo-grid", {
|
|
4710
|
+
"rowHeaders": [4, "row-headers"],
|
|
4711
|
+
"frameSize": [2, "frame-size"],
|
|
4712
|
+
"rowSize": [2, "row-size"],
|
|
4713
|
+
"colSize": [2, "col-size"],
|
|
4714
|
+
"range": [4],
|
|
4715
|
+
"readonly": [4],
|
|
4716
|
+
"resize": [4],
|
|
4717
|
+
"canFocus": [4, "can-focus"],
|
|
4718
|
+
"useClipboard": [4, "use-clipboard"],
|
|
4719
|
+
"columns": [16],
|
|
4720
|
+
"source": [16],
|
|
4721
|
+
"pinnedTopSource": [16, "pinned-top-source"],
|
|
4722
|
+
"pinnedBottomSource": [16, "pinned-bottom-source"],
|
|
4723
|
+
"rowDefinitions": [16, "row-definitions"],
|
|
4724
|
+
"editors": [16],
|
|
4725
|
+
"applyOnClose": [4, "apply-on-close"],
|
|
4726
|
+
"plugins": [16],
|
|
4727
|
+
"columnTypes": [16, "column-types"],
|
|
4728
|
+
"theme": [1537],
|
|
4729
|
+
"rowClass": [513, "row-class"],
|
|
4730
|
+
"autoSizeColumn": [4, "auto-size-column"],
|
|
4731
|
+
"filter": [4],
|
|
4732
|
+
"sorting": [16],
|
|
4733
|
+
"focusTemplate": [16, "focus-template"],
|
|
4734
|
+
"canMoveColumns": [4, "can-move-columns"],
|
|
4735
|
+
"trimmedRows": [16, "trimmed-rows"],
|
|
4736
|
+
"exporting": [4],
|
|
4737
|
+
"grouping": [16],
|
|
4738
|
+
"stretch": [8],
|
|
4739
|
+
"additionalData": [16, "additional-data"],
|
|
4740
|
+
"disableVirtualX": [4, "disable-virtual-x"],
|
|
4741
|
+
"disableVirtualY": [4, "disable-virtual-y"],
|
|
4742
|
+
"hideAttribution": [4, "hide-attribution"],
|
|
4743
|
+
"jobsBeforeRender": [16, "jobs-before-render"],
|
|
4744
|
+
"registerVNode": [16, "register-v-node"],
|
|
4745
|
+
"accessible": [4],
|
|
4746
|
+
"rtl": [4],
|
|
4747
|
+
"canDrag": [4, "can-drag"],
|
|
4748
|
+
"refresh": [64],
|
|
4749
|
+
"setDataAt": [64],
|
|
4750
|
+
"scrollToRow": [64],
|
|
4751
|
+
"scrollToColumnIndex": [64],
|
|
4752
|
+
"scrollToColumnProp": [64],
|
|
4753
|
+
"updateColumns": [64],
|
|
4754
|
+
"addTrimmed": [64],
|
|
4755
|
+
"scrollToCoordinate": [64],
|
|
4756
|
+
"setCellEdit": [64],
|
|
4757
|
+
"setCellsFocus": [64],
|
|
4758
|
+
"getSource": [64],
|
|
4759
|
+
"getVisibleSource": [64],
|
|
4760
|
+
"getSourceStore": [64],
|
|
4761
|
+
"getColumnStore": [64],
|
|
4762
|
+
"updateColumnSorting": [64],
|
|
4763
|
+
"clearSorting": [64],
|
|
4764
|
+
"getColumns": [64],
|
|
4765
|
+
"clearFocus": [64],
|
|
4766
|
+
"getPlugins": [64],
|
|
4767
|
+
"getFocused": [64],
|
|
4768
|
+
"getContentSize": [64],
|
|
4769
|
+
"getSelectedRange": [64],
|
|
4770
|
+
"refreshExtraElements": [64],
|
|
4771
|
+
"getProviders": [64]
|
|
4772
|
+
}, [[5, "touchstart", "mousedownHandle"], [5, "mousedown", "mousedownHandle"], [5, "touchend", "mouseupHandle"], [5, "mouseup", "mouseupHandle"], [0, "beforecolumndragend", "beforeColumnDragEnd"], [0, "rowdragstartinit", "onRowDragStarted"], [0, "rowdragendinit", "onRowDragEnd"], [0, "roworderchange", "onRowOrderChange"], [0, "rowdragmoveinit", "onRowDrag"], [0, "rowdragmousemove", "onRowMouseMove"], [0, "celleditapply", "onCellEdit"], [0, "rangeeditapply", "onRangeEdit"], [0, "selectionchangeinit", "onRangeChanged"], [0, "rowdropinit", "onRowDropped"], [0, "beforeheaderclick", "onHeaderClick"], [0, "beforecellfocusinit", "onCellFocus"]], {
|
|
4773
|
+
"columnTypes": ["columnTypesChanged"],
|
|
4774
|
+
"columns": ["columnChanged"],
|
|
4775
|
+
"disableVirtualX": ["disableVirtualXChanged"],
|
|
4776
|
+
"rowSize": ["rowSizeChanged"],
|
|
4777
|
+
"theme": ["themeChanged"],
|
|
4778
|
+
"source": ["dataSourceChanged"],
|
|
4779
|
+
"pinnedBottomSource": ["dataSourceChanged"],
|
|
4780
|
+
"pinnedTopSource": ["dataSourceChanged"],
|
|
4781
|
+
"disableVirtualY": ["disableVirtualYChanged"],
|
|
4782
|
+
"rowDefinitions": ["rowDefChanged"],
|
|
4783
|
+
"trimmedRows": ["trimmedRowsChanged"],
|
|
4784
|
+
"grouping": ["groupingChanged"],
|
|
4785
|
+
"stretch": ["applyStretch"],
|
|
4786
|
+
"filter": ["applyFilter"],
|
|
4787
|
+
"sorting": ["applySorting"],
|
|
4788
|
+
"rowHeaders": ["rowHeadersChange"],
|
|
4789
|
+
"registerVNode": ["registerOutsideVNodes"],
|
|
4790
|
+
"additionalData": ["additionalDataChanged"],
|
|
4791
|
+
"rtl": ["rtlChanged"],
|
|
4792
|
+
"plugins": ["pluginsChanged"]
|
|
4793
|
+
}]);
|
|
4794
|
+
function defineCustomElement$1() {
|
|
4795
|
+
if (typeof customElements === "undefined") {
|
|
4796
|
+
return;
|
|
4797
|
+
}
|
|
4798
|
+
const components = ["revo-grid", "revogr-attribution", "revogr-clipboard", "revogr-data", "revogr-edit", "revogr-extra", "revogr-focus", "revogr-header", "revogr-order-editor", "revogr-overlay-selection", "revogr-row-headers", "revogr-scroll-virtual", "revogr-temp-range", "revogr-viewport-scroll", "vnode-html"];
|
|
4799
|
+
components.forEach(tagName => { switch (tagName) {
|
|
4800
|
+
case "revo-grid":
|
|
4801
|
+
if (!customElements.get(tagName)) {
|
|
4802
|
+
customElements.define(tagName, RevoGridComponent);
|
|
4803
|
+
}
|
|
4804
|
+
break;
|
|
4805
|
+
case "revogr-attribution":
|
|
4806
|
+
if (!customElements.get(tagName)) {
|
|
4807
|
+
defineCustomElement$f();
|
|
4808
|
+
}
|
|
4809
|
+
break;
|
|
4810
|
+
case "revogr-clipboard":
|
|
4811
|
+
if (!customElements.get(tagName)) {
|
|
4812
|
+
defineCustomElement$e();
|
|
4813
|
+
}
|
|
4814
|
+
break;
|
|
4815
|
+
case "revogr-data":
|
|
4816
|
+
if (!customElements.get(tagName)) {
|
|
4817
|
+
defineCustomElement$d();
|
|
4818
|
+
}
|
|
4819
|
+
break;
|
|
4820
|
+
case "revogr-edit":
|
|
4821
|
+
if (!customElements.get(tagName)) {
|
|
4822
|
+
defineCustomElement$c();
|
|
4823
|
+
}
|
|
4824
|
+
break;
|
|
4825
|
+
case "revogr-extra":
|
|
4826
|
+
if (!customElements.get(tagName)) {
|
|
4827
|
+
defineCustomElement$b();
|
|
4828
|
+
}
|
|
4829
|
+
break;
|
|
4830
|
+
case "revogr-focus":
|
|
4831
|
+
if (!customElements.get(tagName)) {
|
|
4832
|
+
defineCustomElement$a();
|
|
4833
|
+
}
|
|
4834
|
+
break;
|
|
4835
|
+
case "revogr-header":
|
|
4836
|
+
if (!customElements.get(tagName)) {
|
|
4837
|
+
defineCustomElement$9();
|
|
4838
|
+
}
|
|
4839
|
+
break;
|
|
4840
|
+
case "revogr-order-editor":
|
|
4841
|
+
if (!customElements.get(tagName)) {
|
|
4842
|
+
defineCustomElement$8();
|
|
4843
|
+
}
|
|
4844
|
+
break;
|
|
4845
|
+
case "revogr-overlay-selection":
|
|
4846
|
+
if (!customElements.get(tagName)) {
|
|
4847
|
+
defineCustomElement$7();
|
|
4848
|
+
}
|
|
4849
|
+
break;
|
|
4850
|
+
case "revogr-row-headers":
|
|
4851
|
+
if (!customElements.get(tagName)) {
|
|
4852
|
+
defineCustomElement$6();
|
|
4853
|
+
}
|
|
4854
|
+
break;
|
|
4855
|
+
case "revogr-scroll-virtual":
|
|
4856
|
+
if (!customElements.get(tagName)) {
|
|
4857
|
+
defineCustomElement$5();
|
|
4858
|
+
}
|
|
4859
|
+
break;
|
|
4860
|
+
case "revogr-temp-range":
|
|
4861
|
+
if (!customElements.get(tagName)) {
|
|
4862
|
+
defineCustomElement$4();
|
|
4863
|
+
}
|
|
4864
|
+
break;
|
|
4865
|
+
case "revogr-viewport-scroll":
|
|
4866
|
+
if (!customElements.get(tagName)) {
|
|
4867
|
+
defineCustomElement$3();
|
|
4868
|
+
}
|
|
4869
|
+
break;
|
|
4870
|
+
case "vnode-html":
|
|
4871
|
+
if (!customElements.get(tagName)) {
|
|
4872
|
+
defineCustomElement$2();
|
|
4873
|
+
}
|
|
4874
|
+
break;
|
|
4875
|
+
} });
|
|
4876
|
+
}
|
|
4877
|
+
|
|
4878
|
+
const RevoGrid = RevoGridComponent;
|
|
4879
|
+
const defineCustomElement = defineCustomElement$1;
|
|
4880
|
+
|
|
4881
|
+
export { AutoSizeColumnPlugin as A, BasePlugin as B, ColumnMovePlugin as C, DimensionStore as D, ExportFilePlugin as E, FILTER_TRIMMED_TYPE as F, GroupingRowPlugin as G, RevoGrid, StretchColumn as S, ExportCsv as a, FILTER_CONFIG_CHANGED_EVENT as b, FILTE_PANEL as c, FilterPlugin as d, defineCustomElement, filterTypes as e, filterCoreFunctionsIndexedByType as f, getTheme as g, filterNames as h, isStretchPlugin as i, doCollapse as j, doExpand as k, getLeftRelative as l, SortingPlugin as m, defaultCellCompare as n, descCellCompare as o, getNextOrder as p, getComparer as q, sortIndexByItems as s };
|
|
4882
|
+
//# sourceMappingURL=revo-grid.js.map
|
|
4883
|
+
|
|
4884
|
+
//# sourceMappingURL=revo-grid.js.map
|