handsontable 16.0.1-next-eee5f08-20250710 → 16.1.0-next-abd8f2e-20250904
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/3rdparty/walkontable/src/overlays.js +12 -2
- package/3rdparty/walkontable/src/overlays.mjs +12 -2
- package/3rdparty/walkontable/src/viewport.js +2 -6
- package/3rdparty/walkontable/src/viewport.mjs +2 -6
- package/CHANGELOG.md +32 -0
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/cellTypes/autocompleteType/accessors/index.js +7 -0
- package/cellTypes/autocompleteType/accessors/index.mjs +2 -0
- package/cellTypes/autocompleteType/accessors/valueGetter.js +14 -0
- package/cellTypes/autocompleteType/accessors/valueGetter.mjs +10 -0
- package/cellTypes/autocompleteType/accessors/valueSetter.js +25 -0
- package/cellTypes/autocompleteType/accessors/valueSetter.mjs +21 -0
- package/cellTypes/autocompleteType/autocompleteType.js +4 -1
- package/cellTypes/autocompleteType/autocompleteType.mjs +4 -1
- package/cellTypes/checkboxType/accessors/index.js +5 -0
- package/cellTypes/checkboxType/accessors/index.mjs +1 -0
- package/cellTypes/checkboxType/accessors/valueSetter.js +26 -0
- package/cellTypes/checkboxType/accessors/valueSetter.mjs +22 -0
- package/cellTypes/checkboxType/checkboxType.js +3 -1
- package/cellTypes/checkboxType/checkboxType.mjs +3 -1
- package/cellTypes/dropdownType/accessors/index.js +7 -0
- package/cellTypes/dropdownType/accessors/index.mjs +2 -0
- package/cellTypes/dropdownType/accessors/valueGetter.js +14 -0
- package/cellTypes/dropdownType/accessors/valueGetter.mjs +10 -0
- package/cellTypes/dropdownType/accessors/valueSetter.js +17 -0
- package/cellTypes/dropdownType/accessors/valueSetter.mjs +13 -0
- package/cellTypes/dropdownType/dropdownType.js +4 -1
- package/cellTypes/dropdownType/dropdownType.mjs +4 -1
- package/cellTypes/numericType/accessors/index.js +5 -0
- package/cellTypes/numericType/accessors/index.mjs +1 -0
- package/cellTypes/numericType/accessors/valueSetter.js +19 -0
- package/cellTypes/numericType/accessors/valueSetter.mjs +15 -0
- package/cellTypes/numericType/numericType.js +3 -1
- package/cellTypes/numericType/numericType.mjs +3 -1
- package/core/focusCatcher/index.js +37 -112
- package/core/focusCatcher/index.mjs +35 -110
- package/core/focusCatcher/utils.js +31 -0
- package/core/focusCatcher/utils.mjs +27 -0
- package/core/hooks/constants.js +242 -0
- package/core/hooks/constants.mjs +242 -0
- package/core/hooks/index.d.ts +22 -0
- package/core/viewportScroll/scrollStrategies/focusScroll.js +5 -1
- package/core/viewportScroll/scrollStrategies/focusScroll.mjs +5 -1
- package/core/viewportScroll/utils.js +1 -1
- package/core/viewportScroll/utils.mjs +1 -1
- package/core.d.ts +4 -0
- package/core.js +237 -139
- package/core.mjs +240 -142
- package/dataMap/dataMap.js +13 -3
- package/dataMap/dataMap.mjs +14 -4
- package/dataMap/dataSource.js +16 -0
- package/dataMap/dataSource.mjs +16 -0
- package/dataMap/metaManager/lazyFactoryMap.js +4 -3
- package/dataMap/metaManager/lazyFactoryMap.mjs +2 -1
- package/dataMap/metaManager/metaLayers/cellMeta.js +3 -2
- package/dataMap/metaManager/metaLayers/cellMeta.mjs +3 -2
- package/dataMap/metaManager/metaSchema.js +289 -4
- package/dataMap/metaManager/metaSchema.mjs +289 -4
- package/dataMap/metaManager/utils.js +0 -11
- package/dataMap/metaManager/utils.mjs +0 -10
- package/dataMap/replaceData.js +1 -0
- package/dataMap/replaceData.mjs +1 -0
- package/dist/handsontable.css +281 -4
- package/dist/handsontable.full.css +281 -4
- package/dist/handsontable.full.js +7844 -2990
- package/dist/handsontable.full.min.css +4 -5
- package/dist/handsontable.full.min.js +167 -165
- package/dist/handsontable.js +9639 -4806
- package/dist/handsontable.min.css +4 -4
- package/dist/handsontable.min.js +52 -50
- package/dist/languages/all.js +231 -21
- package/dist/languages/all.min.js +1 -1
- package/dist/languages/ar-AR.js +11 -1
- package/dist/languages/ar-AR.min.js +1 -1
- package/dist/languages/cs-CZ.js +11 -1
- package/dist/languages/cs-CZ.min.js +1 -1
- package/dist/languages/de-CH.js +11 -1
- package/dist/languages/de-CH.min.js +1 -1
- package/dist/languages/de-DE.js +11 -1
- package/dist/languages/de-DE.min.js +1 -1
- package/dist/languages/en-US.js +11 -1
- package/dist/languages/en-US.min.js +1 -1
- package/dist/languages/es-MX.js +11 -1
- package/dist/languages/es-MX.min.js +1 -1
- package/dist/languages/fa-IR.js +11 -1
- package/dist/languages/fa-IR.min.js +1 -1
- package/dist/languages/fr-FR.js +11 -1
- package/dist/languages/fr-FR.min.js +1 -1
- package/dist/languages/hr-HR.js +11 -1
- package/dist/languages/hr-HR.min.js +1 -1
- package/dist/languages/it-IT.js +11 -1
- package/dist/languages/it-IT.min.js +1 -1
- package/dist/languages/ja-JP.js +11 -1
- package/dist/languages/ja-JP.min.js +1 -1
- package/dist/languages/ko-KR.js +11 -1
- package/dist/languages/ko-KR.min.js +1 -1
- package/dist/languages/lv-LV.js +11 -1
- package/dist/languages/lv-LV.min.js +1 -1
- package/dist/languages/nb-NO.js +11 -1
- package/dist/languages/nb-NO.min.js +1 -1
- package/dist/languages/nl-NL.js +11 -1
- package/dist/languages/nl-NL.min.js +1 -1
- package/dist/languages/pl-PL.js +11 -1
- package/dist/languages/pl-PL.min.js +1 -1
- package/dist/languages/pt-BR.js +11 -1
- package/dist/languages/pt-BR.min.js +1 -1
- package/dist/languages/ru-RU.js +11 -1
- package/dist/languages/ru-RU.min.js +1 -1
- package/dist/languages/sr-SP.js +11 -1
- package/dist/languages/sr-SP.min.js +1 -1
- package/dist/languages/zh-CN.js +11 -1
- package/dist/languages/zh-CN.min.js +1 -1
- package/dist/languages/zh-TW.js +11 -1
- package/dist/languages/zh-TW.min.js +1 -1
- package/editorManager.js +4 -4
- package/editorManager.mjs +4 -4
- package/editors/autocompleteEditor/autocompleteEditor.js +50 -112
- package/editors/autocompleteEditor/autocompleteEditor.mjs +51 -113
- package/editors/baseEditor/baseEditor.js +10 -6
- package/editors/baseEditor/baseEditor.mjs +10 -6
- package/editors/handsontableEditor/handsontableEditor.js +9 -9
- package/editors/handsontableEditor/handsontableEditor.mjs +9 -9
- package/editors/textEditor/textEditor.js +0 -7
- package/editors/textEditor/textEditor.mjs +0 -7
- package/focusManager.js +2 -2
- package/focusManager.mjs +2 -2
- package/helpers/a11y.js +15 -2
- package/helpers/a11y.mjs +10 -2
- package/helpers/console.js +12 -0
- package/helpers/console.mjs +11 -0
- package/helpers/dom/element.js +4 -4
- package/helpers/dom/element.mjs +4 -4
- package/helpers/mixed.js +65 -2
- package/helpers/mixed.mjs +63 -2
- package/helpers/number.js +28 -0
- package/helpers/number.mjs +26 -0
- package/helpers/object.js +35 -0
- package/helpers/object.mjs +34 -0
- package/helpers/string.js +19 -0
- package/helpers/string.mjs +18 -0
- package/helpers/templateLiteralTag.js +57 -1
- package/helpers/templateLiteralTag.mjs +56 -1
- package/i18n/constants.js +13 -1
- package/i18n/constants.mjs +13 -1
- package/i18n/languages/ar-AR.js +11 -1
- package/i18n/languages/ar-AR.mjs +11 -1
- package/i18n/languages/cs-CZ.js +11 -1
- package/i18n/languages/cs-CZ.mjs +11 -1
- package/i18n/languages/de-CH.js +11 -1
- package/i18n/languages/de-CH.mjs +11 -1
- package/i18n/languages/de-DE.js +11 -1
- package/i18n/languages/de-DE.mjs +11 -1
- package/i18n/languages/en-US.js +11 -1
- package/i18n/languages/en-US.mjs +11 -1
- package/i18n/languages/es-MX.js +11 -1
- package/i18n/languages/es-MX.mjs +11 -1
- package/i18n/languages/fa-IR.js +11 -1
- package/i18n/languages/fa-IR.mjs +11 -1
- package/i18n/languages/fr-FR.js +11 -1
- package/i18n/languages/fr-FR.mjs +11 -1
- package/i18n/languages/hr-HR.js +11 -1
- package/i18n/languages/hr-HR.mjs +11 -1
- package/i18n/languages/it-IT.js +11 -1
- package/i18n/languages/it-IT.mjs +11 -1
- package/i18n/languages/ja-JP.js +11 -1
- package/i18n/languages/ja-JP.mjs +11 -1
- package/i18n/languages/ko-KR.js +11 -1
- package/i18n/languages/ko-KR.mjs +11 -1
- package/i18n/languages/lv-LV.js +11 -1
- package/i18n/languages/lv-LV.mjs +11 -1
- package/i18n/languages/nb-NO.js +11 -1
- package/i18n/languages/nb-NO.mjs +11 -1
- package/i18n/languages/nl-NL.js +11 -1
- package/i18n/languages/nl-NL.mjs +11 -1
- package/i18n/languages/pl-PL.js +11 -1
- package/i18n/languages/pl-PL.mjs +11 -1
- package/i18n/languages/pt-BR.js +11 -1
- package/i18n/languages/pt-BR.mjs +11 -1
- package/i18n/languages/ru-RU.js +11 -1
- package/i18n/languages/ru-RU.mjs +11 -1
- package/i18n/languages/sr-SP.js +11 -1
- package/i18n/languages/sr-SP.mjs +11 -1
- package/i18n/languages/zh-CN.js +11 -1
- package/i18n/languages/zh-CN.mjs +11 -1
- package/i18n/languages/zh-TW.js +11 -1
- package/i18n/languages/zh-TW.mjs +11 -1
- package/i18n/phraseFormatters/index.js +3 -1
- package/i18n/phraseFormatters/index.mjs +3 -1
- package/i18n/registry.js +5 -6
- package/i18n/registry.mjs +5 -6
- package/index.d.ts +27 -0
- package/languages/all.js +231 -21
- package/languages/ar-AR.js +11 -1
- package/languages/ar-AR.mjs +11 -1
- package/languages/cs-CZ.js +11 -1
- package/languages/cs-CZ.mjs +11 -1
- package/languages/de-CH.js +11 -1
- package/languages/de-CH.mjs +11 -1
- package/languages/de-DE.js +11 -1
- package/languages/de-DE.mjs +11 -1
- package/languages/en-US.js +11 -1
- package/languages/en-US.mjs +11 -1
- package/languages/es-MX.js +11 -1
- package/languages/es-MX.mjs +11 -1
- package/languages/fa-IR.js +11 -1
- package/languages/fa-IR.mjs +11 -1
- package/languages/fr-FR.js +11 -1
- package/languages/fr-FR.mjs +11 -1
- package/languages/hr-HR.js +11 -1
- package/languages/hr-HR.mjs +11 -1
- package/languages/index.js +231 -21
- package/languages/it-IT.js +11 -1
- package/languages/it-IT.mjs +11 -1
- package/languages/ja-JP.js +11 -1
- package/languages/ja-JP.mjs +11 -1
- package/languages/ko-KR.js +11 -1
- package/languages/ko-KR.mjs +11 -1
- package/languages/lv-LV.js +11 -1
- package/languages/lv-LV.mjs +11 -1
- package/languages/nb-NO.js +11 -1
- package/languages/nb-NO.mjs +11 -1
- package/languages/nl-NL.js +11 -1
- package/languages/nl-NL.mjs +11 -1
- package/languages/pl-PL.js +11 -1
- package/languages/pl-PL.mjs +11 -1
- package/languages/pt-BR.js +11 -1
- package/languages/pt-BR.mjs +11 -1
- package/languages/ru-RU.js +11 -1
- package/languages/ru-RU.mjs +11 -1
- package/languages/sr-SP.js +11 -1
- package/languages/sr-SP.mjs +11 -1
- package/languages/zh-CN.js +11 -1
- package/languages/zh-CN.mjs +11 -1
- package/languages/zh-TW.js +11 -1
- package/languages/zh-TW.mjs +11 -1
- package/mixins/localHooks.js +16 -0
- package/mixins/localHooks.mjs +16 -0
- package/package.json +19 -1
- package/plugins/autoRowSize/autoRowSize.js +43 -6
- package/plugins/autoRowSize/autoRowSize.mjs +43 -6
- package/plugins/autofill/autofill.js +50 -3
- package/plugins/autofill/autofill.mjs +50 -3
- package/plugins/base/base.js +86 -15
- package/plugins/base/base.mjs +87 -16
- package/plugins/collapsibleColumns/collapsibleColumns.js +4 -4
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +4 -4
- package/plugins/columnSorting/columnSorting.js +3 -3
- package/plugins/columnSorting/columnSorting.mjs +3 -3
- package/plugins/comments/comments.js +52 -22
- package/plugins/comments/comments.mjs +52 -22
- package/plugins/comments/contextMenuItem/addEditComment.js +3 -3
- package/plugins/comments/contextMenuItem/addEditComment.mjs +3 -3
- package/plugins/comments/contextMenuItem/readOnlyComment.js +2 -2
- package/plugins/comments/contextMenuItem/readOnlyComment.mjs +2 -2
- package/plugins/comments/contextMenuItem/removeComment.js +2 -2
- package/plugins/comments/contextMenuItem/removeComment.mjs +2 -2
- package/plugins/contextMenu/contextMenu.js +4 -5
- package/plugins/contextMenu/contextMenu.mjs +4 -5
- package/plugins/contextMenu/menu/cursor.js +1 -1
- package/plugins/contextMenu/menu/cursor.mjs +1 -1
- package/plugins/contextMenu/menu/defaultShortcutsList.js +5 -5
- package/plugins/contextMenu/menu/defaultShortcutsList.mjs +5 -5
- package/plugins/contextMenu/menu/menu.js +3 -3
- package/plugins/contextMenu/menu/menu.mjs +3 -3
- package/plugins/contextMenu/menu/positioner.js +1 -1
- package/plugins/contextMenu/menu/positioner.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/alignment.js +1 -1
- package/plugins/contextMenu/predefinedItems/alignment.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/clearColumn.js +1 -1
- package/plugins/contextMenu/predefinedItems/clearColumn.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/columnLeft.js +3 -3
- package/plugins/contextMenu/predefinedItems/columnLeft.mjs +3 -3
- package/plugins/contextMenu/predefinedItems/columnRight.js +3 -3
- package/plugins/contextMenu/predefinedItems/columnRight.mjs +3 -3
- package/plugins/contextMenu/predefinedItems/readOnly.js +1 -1
- package/plugins/contextMenu/predefinedItems/readOnly.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/removeColumn.js +1 -1
- package/plugins/contextMenu/predefinedItems/removeColumn.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/removeRow.js +1 -1
- package/plugins/contextMenu/predefinedItems/removeRow.mjs +1 -1
- package/plugins/contextMenu/predefinedItems/rowAbove.js +3 -3
- package/plugins/contextMenu/predefinedItems/rowAbove.mjs +3 -3
- package/plugins/contextMenu/predefinedItems/rowBelow.js +3 -3
- package/plugins/contextMenu/predefinedItems/rowBelow.mjs +3 -3
- package/plugins/copyPaste/contextMenuItem/copy.js +1 -1
- package/plugins/copyPaste/contextMenuItem/copy.mjs +1 -1
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.js +3 -3
- package/plugins/copyPaste/contextMenuItem/copyColumnHeadersOnly.mjs +3 -3
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.js +3 -3
- package/plugins/copyPaste/contextMenuItem/copyWithColumnGroupHeaders.mjs +3 -3
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.js +3 -3
- package/plugins/copyPaste/contextMenuItem/copyWithColumnHeaders.mjs +3 -3
- package/plugins/copyPaste/contextMenuItem/cut.js +1 -1
- package/plugins/copyPaste/contextMenuItem/cut.mjs +1 -1
- package/plugins/copyPaste/copyPaste.js +75 -40
- package/plugins/copyPaste/copyPaste.mjs +76 -41
- package/plugins/customBorders/customBorders.js +1 -1
- package/plugins/customBorders/customBorders.mjs +1 -1
- package/plugins/dialog/dialog.d.ts +23 -0
- package/plugins/dialog/dialog.js +489 -0
- package/plugins/dialog/dialog.mjs +485 -0
- package/plugins/dialog/index.d.ts +1 -0
- package/plugins/dialog/index.js +7 -0
- package/plugins/dialog/index.mjs +1 -0
- package/plugins/dialog/ui.js +264 -0
- package/plugins/dialog/ui.mjs +259 -0
- package/plugins/dropdownMenu/dropdownMenu.js +5 -4
- package/plugins/dropdownMenu/dropdownMenu.mjs +5 -4
- package/plugins/filters/filters.js +2 -2
- package/plugins/filters/filters.mjs +2 -2
- package/plugins/hiddenColumns/contextMenuItem/hideColumn.js +3 -3
- package/plugins/hiddenColumns/contextMenuItem/hideColumn.mjs +3 -3
- package/plugins/hiddenColumns/contextMenuItem/showColumn.js +4 -4
- package/plugins/hiddenColumns/contextMenuItem/showColumn.mjs +4 -4
- package/plugins/hiddenRows/contextMenuItem/hideRow.js +3 -3
- package/plugins/hiddenRows/contextMenuItem/hideRow.mjs +3 -3
- package/plugins/hiddenRows/contextMenuItem/showRow.js +4 -4
- package/plugins/hiddenRows/contextMenuItem/showRow.mjs +4 -4
- package/plugins/index.d.ts +9 -0
- package/plugins/index.js +9 -0
- package/plugins/index.mjs +7 -1
- package/plugins/loading/content.js +36 -0
- package/plugins/loading/content.mjs +31 -0
- package/plugins/loading/index.d.ts +1 -0
- package/plugins/loading/index.js +7 -0
- package/plugins/loading/index.mjs +1 -0
- package/plugins/loading/loading.d.ts +19 -0
- package/plugins/loading/loading.js +292 -0
- package/plugins/loading/loading.mjs +287 -0
- package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.js +1 -1
- package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.mjs +1 -1
- package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.js +1 -1
- package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.mjs +1 -1
- package/plugins/manualColumnMove/manualColumnMove.js +3 -3
- package/plugins/manualColumnMove/manualColumnMove.mjs +3 -3
- package/plugins/manualColumnResize/manualColumnResize.js +3 -3
- package/plugins/manualColumnResize/manualColumnResize.mjs +3 -3
- package/plugins/manualRowMove/manualRowMove.js +4 -4
- package/plugins/manualRowMove/manualRowMove.mjs +4 -4
- package/plugins/manualRowResize/manualRowResize.js +5 -2
- package/plugins/manualRowResize/manualRowResize.mjs +5 -2
- package/plugins/mergeCells/contextMenuItem/toggleMerge.js +15 -15
- package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +15 -15
- package/plugins/mergeCells/focusOrder.js +75 -39
- package/plugins/mergeCells/focusOrder.mjs +75 -39
- package/plugins/mergeCells/mergeCells.js +26 -19
- package/plugins/mergeCells/mergeCells.mjs +26 -19
- package/plugins/mergeCells/renderer.js +14 -8
- package/plugins/mergeCells/renderer.mjs +14 -8
- package/plugins/multiColumnSorting/multiColumnSorting.js +3 -3
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +3 -3
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.js +3 -3
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.mjs +3 -3
- package/plugins/nestedHeaders/nestedHeaders.js +47 -41
- package/plugins/nestedHeaders/nestedHeaders.mjs +47 -41
- package/plugins/nestedRows/nestedRows.js +3 -3
- package/plugins/nestedRows/nestedRows.mjs +3 -3
- package/plugins/nestedRows/ui/collapsing.js +1 -2
- package/plugins/nestedRows/ui/collapsing.mjs +1 -2
- package/plugins/nestedRows/ui/contextMenu.js +4 -4
- package/plugins/nestedRows/ui/contextMenu.mjs +4 -4
- package/plugins/nestedRows/ui/headers.js +4 -1
- package/plugins/nestedRows/ui/headers.mjs +4 -1
- package/plugins/pagination/focusController.js +27 -0
- package/plugins/pagination/focusController.mjs +23 -0
- package/plugins/pagination/index.d.ts +1 -0
- package/plugins/pagination/index.js +7 -0
- package/plugins/pagination/index.mjs +1 -0
- package/plugins/pagination/pagination.d.ts +52 -0
- package/plugins/pagination/pagination.js +1034 -0
- package/plugins/pagination/pagination.mjs +1030 -0
- package/plugins/pagination/strategies/autoPageSize.js +96 -0
- package/plugins/pagination/strategies/autoPageSize.mjs +92 -0
- package/plugins/pagination/strategies/fixedPageSize.js +88 -0
- package/plugins/pagination/strategies/fixedPageSize.mjs +84 -0
- package/plugins/pagination/strategies/index.js +22 -0
- package/plugins/pagination/strategies/index.mjs +18 -0
- package/plugins/pagination/ui.js +449 -0
- package/plugins/pagination/ui.mjs +443 -0
- package/plugins/pagination/utils.js +28 -0
- package/plugins/pagination/utils.mjs +24 -0
- package/plugins/stretchColumns/calculator.js +4 -0
- package/plugins/stretchColumns/calculator.mjs +4 -0
- package/plugins/stretchColumns/stretchColumns.js +1 -1
- package/plugins/stretchColumns/stretchColumns.mjs +1 -1
- package/plugins/undoRedo/actions/dataChange.js +17 -15
- package/plugins/undoRedo/actions/dataChange.mjs +17 -15
- package/renderers/checkboxRenderer/checkboxRenderer.js +3 -3
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +3 -3
- package/selection/range.js +11 -0
- package/selection/range.mjs +11 -0
- package/selection/selection.js +163 -124
- package/selection/selection.mjs +163 -124
- package/selection/transformation/_base.js +448 -0
- package/selection/transformation/_base.mjs +443 -0
- package/selection/transformation/extender.js +55 -0
- package/selection/transformation/extender.mjs +51 -0
- package/selection/transformation/focus.js +77 -0
- package/selection/transformation/focus.mjs +73 -0
- package/selection/transformation/index.js +7 -0
- package/selection/transformation/index.mjs +2 -0
- package/selection/utils.js +2 -1
- package/selection/utils.mjs +2 -1
- package/settings.d.ts +10 -1
- package/shortcutContexts/commands/editor/fastOpen.js +1 -1
- package/shortcutContexts/commands/editor/fastOpen.mjs +1 -1
- package/shortcutContexts/commands/editor/open.js +10 -4
- package/shortcutContexts/commands/editor/open.mjs +10 -4
- package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +2 -2
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +2 -2
- package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +2 -2
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +2 -2
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.js +2 -2
- package/shortcutContexts/commands/moveCellSelection/downByViewportHeight.mjs +2 -2
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +5 -2
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +5 -2
- package/shortcutContexts/commands/moveCellSelection/inlineStart.js +5 -2
- package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +5 -2
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostBottom.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostInlineEnd.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostInlineStart.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostLeft.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostRight.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostRight.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostTop.js +1 -1
- package/shortcutContexts/commands/moveCellSelection/toMostTop.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.js +2 -2
- package/shortcutContexts/commands/moveCellSelection/upByViewportHeight.mjs +2 -2
- package/shortcutContexts/commands/scrollToFocusedCell.js +1 -1
- package/shortcutContexts/commands/scrollToFocusedCell.mjs +1 -1
- package/shortcutContexts/grid.js +3 -3
- package/shortcutContexts/grid.mjs +3 -3
- package/shortcuts/context.js +4 -1
- package/shortcuts/context.mjs +4 -1
- package/shortcuts/manager.js +17 -3
- package/shortcuts/manager.mjs +17 -3
- package/styles/handsontable.css +288 -22
- package/styles/handsontable.min.css +3 -3
- package/styles/ht-theme-classic.css +828 -0
- package/styles/ht-theme-classic.min.css +30 -0
- package/styles/ht-theme-horizon.css +122 -26
- package/styles/ht-theme-horizon.min.css +3 -3
- package/styles/ht-theme-main.css +124 -28
- package/styles/ht-theme-main.min.css +3 -3
- package/tableView.js +61 -25
- package/tableView.mjs +61 -25
- package/utils/a11yAnnouncer.js +70 -0
- package/utils/a11yAnnouncer.mjs +64 -0
- package/{core/focusCatcher → utils}/focusDetector.js +30 -12
- package/{core/focusCatcher → utils}/focusDetector.mjs +30 -12
- package/utils/samplesGenerator.js +17 -1
- package/utils/samplesGenerator.mjs +17 -1
- package/utils/stylesHandler.js +23 -8
- package/utils/stylesHandler.mjs +23 -8
- package/utils/valueAccessors.js +45 -0
- package/utils/valueAccessors.mjs +40 -0
- package/validators/autocompleteValidator/autocompleteValidator.js +2 -1
- package/validators/autocompleteValidator/autocompleteValidator.mjs +2 -1
- package/selection/transformation.js +0 -335
- package/selection/transformation.mjs +0 -331
@@ -0,0 +1,1030 @@
|
|
1
|
+
import "core-js/modules/es.error.cause.js";
|
2
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
3
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
4
|
+
import "core-js/modules/esnext.iterator.map.js";
|
5
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
6
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
7
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
8
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
9
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
10
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
11
|
+
import { BasePlugin } from "../base/index.mjs";
|
12
|
+
import { clamp } from "../../helpers/number.mjs";
|
13
|
+
import { getScrollbarWidth } from "../../helpers/dom/element.mjs";
|
14
|
+
import { PaginationUI } from "./ui.mjs";
|
15
|
+
import { checkPluginSettingsConflict } from "./utils.mjs";
|
16
|
+
import { announce } from "../../utils/a11yAnnouncer.mjs";
|
17
|
+
import { createPaginatorStrategy } from "./strategies/index.mjs";
|
18
|
+
import { toSingleLine } from "../../helpers/templateLiteralTag.mjs";
|
19
|
+
import { warn } from "../../helpers/console.mjs";
|
20
|
+
import { createPaginationFocusController } from "./focusController.mjs";
|
21
|
+
import { installFocusDetector } from "../../utils/focusDetector.mjs";
|
22
|
+
export const PLUGIN_KEY = 'pagination';
|
23
|
+
export const PLUGIN_PRIORITY = 900;
|
24
|
+
const SHORTCUTS_GROUP = PLUGIN_KEY;
|
25
|
+
const SHORTCUTS_CONTEXT_NAME = `plugin:${PLUGIN_KEY}`;
|
26
|
+
const AUTO_PAGE_SIZE_WARNING = toSingleLine`The \`auto\` page size setting requires the \`autoRowSize\`\x20
|
27
|
+
plugin to be enabled. Set the \`autoRowSize: true\` in the configuration to ensure correct behavior.`;
|
28
|
+
|
29
|
+
/* eslint-disable jsdoc/require-description-complete-sentence */
|
30
|
+
/**
|
31
|
+
* @plugin Pagination
|
32
|
+
* @class Pagination
|
33
|
+
*
|
34
|
+
* @description
|
35
|
+
* The plugin adds full-featured pagination capabilities to a table component.
|
36
|
+
* It manages splitting rows into pages, rendering navigation controls, and exposing
|
37
|
+
* methods and configuration for initializing and updating pagination state.
|
38
|
+
*
|
39
|
+
* Core responsibilities:
|
40
|
+
* - Calculate which rows should be visible based on current `page` and `pageSize`.
|
41
|
+
* - Render a toolbar area containing:
|
42
|
+
* - a page size dropdown section (if `showPageSize` = `true`)
|
43
|
+
* - a row counter section ("1 - 10 of 50", if `showCounter` = `true`)
|
44
|
+
* - page navigation section (if `showNavigation` = `true`)
|
45
|
+
* - Emit hooks when:
|
46
|
+
* - the user navigates to a different page
|
47
|
+
* - the user changes the number of rows per page
|
48
|
+
* - the user changes the visibility of any sections
|
49
|
+
* - Allow external code to programmatically:
|
50
|
+
* - jump to a specific page
|
51
|
+
* - change the page size
|
52
|
+
* - change the visibility of UI sections
|
53
|
+
*
|
54
|
+
* @example
|
55
|
+
*
|
56
|
+
* ::: only-for javascript
|
57
|
+
* ```js
|
58
|
+
* const hot = new Handsontable(document.getElementById('example'), {
|
59
|
+
* data: getData(),
|
60
|
+
* pagination: {
|
61
|
+
* pageSize: 10,
|
62
|
+
* pageSizeList: ['auto', 5, 10, 20, 50, 100],
|
63
|
+
* initialPage: 1,
|
64
|
+
* showPageSize: true,
|
65
|
+
* showCounter: true,
|
66
|
+
* showNavigation: true,
|
67
|
+
* },
|
68
|
+
* });
|
69
|
+
* ```
|
70
|
+
* :::
|
71
|
+
*
|
72
|
+
* ::: only-for react
|
73
|
+
* ```jsx
|
74
|
+
* <HotTable
|
75
|
+
* data={getData()}
|
76
|
+
* pagination={{
|
77
|
+
* pageSize: 10,
|
78
|
+
* pageSizeList: ['auto', 5, 10, 20, 50, 100],
|
79
|
+
* initialPage: 1,
|
80
|
+
* showPageSize: true,
|
81
|
+
* showCounter: true,
|
82
|
+
* showNavigation: true,
|
83
|
+
* }}
|
84
|
+
* />
|
85
|
+
* ```
|
86
|
+
* :::
|
87
|
+
*
|
88
|
+
* ::: only-for angular
|
89
|
+
* ```ts
|
90
|
+
* settings = {
|
91
|
+
* pagination: {
|
92
|
+
* pageSize: 10,
|
93
|
+
* pageSizeList: ['auto', 5, 10, 20, 50, 100],
|
94
|
+
* initialPage: 1,
|
95
|
+
* showPageSize: true,
|
96
|
+
* showCounter: true,
|
97
|
+
* showNavigation: true,
|
98
|
+
* },
|
99
|
+
* };
|
100
|
+
* ```
|
101
|
+
* :::
|
102
|
+
*/
|
103
|
+
var _pagedRowsMap = /*#__PURE__*/new WeakMap();
|
104
|
+
var _currentPage = /*#__PURE__*/new WeakMap();
|
105
|
+
var _pageSize = /*#__PURE__*/new WeakMap();
|
106
|
+
var _ui = /*#__PURE__*/new WeakMap();
|
107
|
+
var _calcStrategy = /*#__PURE__*/new WeakMap();
|
108
|
+
var _internalExecutionCall = /*#__PURE__*/new WeakMap();
|
109
|
+
var _internalRenderCall = /*#__PURE__*/new WeakMap();
|
110
|
+
var _focusController = /*#__PURE__*/new WeakMap();
|
111
|
+
var _focusDetector = /*#__PURE__*/new WeakMap();
|
112
|
+
var _Pagination_brand = /*#__PURE__*/new WeakSet();
|
113
|
+
var _onIndexCacheUpdate = /*#__PURE__*/new WeakMap();
|
114
|
+
export class Pagination extends BasePlugin {
|
115
|
+
constructor() {
|
116
|
+
super(...arguments);
|
117
|
+
/**
|
118
|
+
* Bind the events used by the plugin.
|
119
|
+
*/
|
120
|
+
_classPrivateMethodInitSpec(this, _Pagination_brand);
|
121
|
+
/**
|
122
|
+
* Map of hidden rows controlled by the pagination plugin.
|
123
|
+
*
|
124
|
+
* @type {HiddenMap | null}
|
125
|
+
*/
|
126
|
+
_classPrivateFieldInitSpec(this, _pagedRowsMap, null);
|
127
|
+
/**
|
128
|
+
* Current page number.
|
129
|
+
*
|
130
|
+
* @type {number}
|
131
|
+
*/
|
132
|
+
_classPrivateFieldInitSpec(this, _currentPage, 1);
|
133
|
+
/**
|
134
|
+
* Page size setup by the user. It can be a number or 'auto' (in which case the plugin will
|
135
|
+
* calculate the page size based on the viewport size and row heights).
|
136
|
+
*
|
137
|
+
* @type {number | 'auto'}
|
138
|
+
*/
|
139
|
+
_classPrivateFieldInitSpec(this, _pageSize, 10);
|
140
|
+
/**
|
141
|
+
* UI instance of the pagination plugin.
|
142
|
+
*
|
143
|
+
* @type {PaginationUI}
|
144
|
+
*/
|
145
|
+
_classPrivateFieldInitSpec(this, _ui, null);
|
146
|
+
/**
|
147
|
+
* Pagination calculation strategy instance. It is used to calculate the pagination state
|
148
|
+
* based on the user-defined settings. The result of the state is used to update the
|
149
|
+
* pagination index mapper.
|
150
|
+
*
|
151
|
+
* @type {AutoPageSizeStrategy | FixedPageSizeStrategy | null}
|
152
|
+
*/
|
153
|
+
_classPrivateFieldInitSpec(this, _calcStrategy, null);
|
154
|
+
/**
|
155
|
+
* Flag indicating if the plugin is in the process of updating the index cache (execution operation).
|
156
|
+
* Prevents circular calls when the index cache is updated.
|
157
|
+
*
|
158
|
+
* @type {boolean}
|
159
|
+
*/
|
160
|
+
_classPrivateFieldInitSpec(this, _internalExecutionCall, false);
|
161
|
+
/**
|
162
|
+
* Flag indicating if the plugin is in the process of updating the internal state (render operation).
|
163
|
+
* Prevents circular calls when the render call is triggered by the pagination plugin itself.
|
164
|
+
*
|
165
|
+
* @type {boolean}
|
166
|
+
*/
|
167
|
+
_classPrivateFieldInitSpec(this, _internalRenderCall, false);
|
168
|
+
/**
|
169
|
+
* Pagination focus controller instance.
|
170
|
+
*
|
171
|
+
* @type {PaginationController}
|
172
|
+
*/
|
173
|
+
_classPrivateFieldInitSpec(this, _focusController, null);
|
174
|
+
/**
|
175
|
+
* Pagination focus detector instance.
|
176
|
+
*
|
177
|
+
* @type {object}
|
178
|
+
*/
|
179
|
+
_classPrivateFieldInitSpec(this, _focusDetector, null);
|
180
|
+
/**
|
181
|
+
* IndexMapper cache update listener. Once the cache is updated, we need to recompute
|
182
|
+
* the pagination state.
|
183
|
+
*
|
184
|
+
* The method uses arrow function to keep the reference to the class method. Necessary for
|
185
|
+
* the `removeLocalHook` method of the row index mapper.
|
186
|
+
*/
|
187
|
+
_classPrivateFieldInitSpec(this, _onIndexCacheUpdate, () => {
|
188
|
+
var _this$hot;
|
189
|
+
if (!_classPrivateFieldGet(_internalExecutionCall, this) && (_this$hot = this.hot) !== null && _this$hot !== void 0 && _this$hot.view) {
|
190
|
+
_assertClassBrand(_Pagination_brand, this, _computeAndApplyState).call(this);
|
191
|
+
}
|
192
|
+
});
|
193
|
+
}
|
194
|
+
static get PLUGIN_KEY() {
|
195
|
+
return PLUGIN_KEY;
|
196
|
+
}
|
197
|
+
static get PLUGIN_PRIORITY() {
|
198
|
+
return PLUGIN_PRIORITY;
|
199
|
+
}
|
200
|
+
static get DEFAULT_SETTINGS() {
|
201
|
+
return {
|
202
|
+
pageSize: 10,
|
203
|
+
pageSizeList: ['auto', 5, 10, 20, 50, 100],
|
204
|
+
initialPage: 1,
|
205
|
+
showPageSize: true,
|
206
|
+
showCounter: true,
|
207
|
+
showNavigation: true,
|
208
|
+
uiContainer: null
|
209
|
+
};
|
210
|
+
}
|
211
|
+
/**
|
212
|
+
* Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
|
213
|
+
* hook and if it returns `true` than the {@link Pagination#enablePlugin} method is called.
|
214
|
+
*
|
215
|
+
* @returns {boolean}
|
216
|
+
*/
|
217
|
+
isEnabled() {
|
218
|
+
return !!this.hot.getSettings()[PLUGIN_KEY];
|
219
|
+
}
|
220
|
+
|
221
|
+
/**
|
222
|
+
* Enables the plugin functionality for this Handsontable instance.
|
223
|
+
*/
|
224
|
+
enablePlugin() {
|
225
|
+
var _this$hot$getPlugin,
|
226
|
+
_this = this;
|
227
|
+
if (checkPluginSettingsConflict(this.hot.getSettings())) {
|
228
|
+
this.hot.getSettings()[PLUGIN_KEY] = false;
|
229
|
+
return;
|
230
|
+
}
|
231
|
+
if (this.enabled) {
|
232
|
+
return;
|
233
|
+
}
|
234
|
+
const settings = this.hot.getSettings()[PLUGIN_KEY];
|
235
|
+
if ((settings === null || settings === void 0 ? void 0 : settings.initialPage) !== undefined) {
|
236
|
+
_classPrivateFieldSet(_currentPage, this, this.getSetting('initialPage'));
|
237
|
+
}
|
238
|
+
if ((settings === null || settings === void 0 ? void 0 : settings.pageSize) !== undefined) {
|
239
|
+
_classPrivateFieldSet(_pageSize, this, this.getSetting('pageSize'));
|
240
|
+
}
|
241
|
+
_classPrivateFieldSet(_pagedRowsMap, this, this.hot.rowIndexMapper.createAndRegisterIndexMap(this.pluginName, 'hiding', false));
|
242
|
+
if (_classPrivateFieldGet(_pageSize, this) === 'auto' && !((_this$hot$getPlugin = this.hot.getPlugin('autoRowSize')) !== null && _this$hot$getPlugin !== void 0 && _this$hot$getPlugin.enabled)) {
|
243
|
+
warn(AUTO_PAGE_SIZE_WARNING);
|
244
|
+
}
|
245
|
+
_classPrivateFieldSet(_calcStrategy, this, createPaginatorStrategy(_classPrivateFieldGet(_pageSize, this) === 'auto' ? 'auto' : 'fixed'));
|
246
|
+
if (!_classPrivateFieldGet(_ui, this)) {
|
247
|
+
_classPrivateFieldSet(_ui, this, new PaginationUI({
|
248
|
+
rootElement: this.hot.rootGridElement,
|
249
|
+
uiContainer: this.getSetting('uiContainer'),
|
250
|
+
isRtl: this.hot.isRtl(),
|
251
|
+
themeName: this.hot.getSettings().themeName,
|
252
|
+
phraseTranslator: function () {
|
253
|
+
return _this.hot.getTranslatedPhrase(...arguments);
|
254
|
+
},
|
255
|
+
shouldHaveBorder: () => _assertClassBrand(_Pagination_brand, this, _computeNeedsBorder).call(this),
|
256
|
+
a11yAnnouncer: message => announce(message)
|
257
|
+
}));
|
258
|
+
_assertClassBrand(_Pagination_brand, this, _updateSectionsVisibilityState).call(this);
|
259
|
+
_classPrivateFieldGet(_ui, this).addLocalHook('firstPageClick', () => this.firstPage()).addLocalHook('prevPageClick', () => this.prevPage()).addLocalHook('nextPageClick', () => this.nextPage()).addLocalHook('lastPageClick', () => this.lastPage()).addLocalHook('pageSizeChange', pageSize => this.setPageSize(pageSize)).addLocalHook('focus', element => {
|
260
|
+
_classPrivateFieldGet(_focusController, this).setCurrentPage(_classPrivateFieldGet(_ui, this).getFocusableElements().indexOf(element));
|
261
|
+
this.hot.unlisten();
|
262
|
+
this.hot.getShortcutManager().setActiveContextName(SHORTCUTS_CONTEXT_NAME);
|
263
|
+
this.hot.listen();
|
264
|
+
_classPrivateFieldGet(_focusDetector, this).deactivate();
|
265
|
+
});
|
266
|
+
}
|
267
|
+
if (!_classPrivateFieldGet(_focusController, this)) {
|
268
|
+
_classPrivateFieldSet(_focusController, this, createPaginationFocusController({
|
269
|
+
focusableElements: () => _classPrivateFieldGet(_ui, this).getFocusableElements()
|
270
|
+
}));
|
271
|
+
}
|
272
|
+
if (!_classPrivateFieldGet(_focusDetector, this)) {
|
273
|
+
_classPrivateFieldSet(_focusDetector, this, installFocusDetector(this.hot, _classPrivateFieldGet(_ui, this).getContainer(), {
|
274
|
+
onFocus: from => {
|
275
|
+
this.hot.getShortcutManager().setActiveContextName(SHORTCUTS_CONTEXT_NAME);
|
276
|
+
this.hot.listen();
|
277
|
+
if (from === 'from_above') {
|
278
|
+
_classPrivateFieldGet(_focusController, this).toFirstItem();
|
279
|
+
} else {
|
280
|
+
_classPrivateFieldGet(_focusController, this).toLastItem();
|
281
|
+
}
|
282
|
+
_classPrivateFieldGet(_focusDetector, this).deactivate();
|
283
|
+
}
|
284
|
+
}));
|
285
|
+
}
|
286
|
+
_assertClassBrand(_Pagination_brand, this, _registerEvents).call(this);
|
287
|
+
_assertClassBrand(_Pagination_brand, this, _registerShortcuts).call(this);
|
288
|
+
|
289
|
+
// Place the onInit hook before others to make sure that the pagination state is computed
|
290
|
+
// and applied to the index mapper before AutoColumnSize plugin begins calculate the column sizes.
|
291
|
+
this.addHook('init', function () {
|
292
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
293
|
+
args[_key] = arguments[_key];
|
294
|
+
}
|
295
|
+
return _assertClassBrand(_Pagination_brand, _this, _onInit).call(_this, ...args);
|
296
|
+
}, -1);
|
297
|
+
this.addHook('beforeSelectAll', function () {
|
298
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
299
|
+
args[_key2] = arguments[_key2];
|
300
|
+
}
|
301
|
+
return _assertClassBrand(_Pagination_brand, _this, _onBeforeSelectAllRows).call(_this, ...args);
|
302
|
+
});
|
303
|
+
this.addHook('beforeSelectColumns', function () {
|
304
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
305
|
+
args[_key3] = arguments[_key3];
|
306
|
+
}
|
307
|
+
return _assertClassBrand(_Pagination_brand, _this, _onBeforeSelectAllRows).call(_this, ...args);
|
308
|
+
});
|
309
|
+
this.addHook('beforeSetRangeEnd', function () {
|
310
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
311
|
+
args[_key4] = arguments[_key4];
|
312
|
+
}
|
313
|
+
return _assertClassBrand(_Pagination_brand, _this, _onBeforeSetRangeEnd).call(_this, ...args);
|
314
|
+
});
|
315
|
+
this.addHook('beforeSelectionHighlightSet', function () {
|
316
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
317
|
+
args[_key5] = arguments[_key5];
|
318
|
+
}
|
319
|
+
return _assertClassBrand(_Pagination_brand, _this, _onBeforeSelectionHighlightSet).call(_this, ...args);
|
320
|
+
});
|
321
|
+
this.addHook('beforePaste', function () {
|
322
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
323
|
+
args[_key6] = arguments[_key6];
|
324
|
+
}
|
325
|
+
return _assertClassBrand(_Pagination_brand, _this, _onBeforePaste).call(_this, ...args);
|
326
|
+
});
|
327
|
+
this.addHook('afterViewRender', function () {
|
328
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
329
|
+
args[_key7] = arguments[_key7];
|
330
|
+
}
|
331
|
+
return _assertClassBrand(_Pagination_brand, _this, _onAfterViewRender).call(_this, ...args);
|
332
|
+
});
|
333
|
+
this.addHook('afterRender', function () {
|
334
|
+
for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
335
|
+
args[_key8] = arguments[_key8];
|
336
|
+
}
|
337
|
+
return _assertClassBrand(_Pagination_brand, _this, _onAfterRender).call(_this, ...args);
|
338
|
+
});
|
339
|
+
this.addHook('afterScrollVertically', function () {
|
340
|
+
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
341
|
+
args[_key9] = arguments[_key9];
|
342
|
+
}
|
343
|
+
return _assertClassBrand(_Pagination_brand, _this, _onAfterScrollVertically).call(_this, ...args);
|
344
|
+
});
|
345
|
+
this.addHook('afterLanguageChange', function () {
|
346
|
+
for (var _len0 = arguments.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
|
347
|
+
args[_key0] = arguments[_key0];
|
348
|
+
}
|
349
|
+
return _assertClassBrand(_Pagination_brand, _this, _onAfterLanguageChange).call(_this, ...args);
|
350
|
+
});
|
351
|
+
this.addHook('modifyRowHeight', function () {
|
352
|
+
for (var _len1 = arguments.length, args = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++) {
|
353
|
+
args[_key1] = arguments[_key1];
|
354
|
+
}
|
355
|
+
return _assertClassBrand(_Pagination_brand, _this, _onModifyRowHeight).call(_this, ...args);
|
356
|
+
});
|
357
|
+
this.addHook('beforeHeightChange', function () {
|
358
|
+
for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
|
359
|
+
args[_key10] = arguments[_key10];
|
360
|
+
}
|
361
|
+
return _assertClassBrand(_Pagination_brand, _this, _onBeforeHeightChange).call(_this, ...args);
|
362
|
+
});
|
363
|
+
this.addHook('afterSetTheme', function () {
|
364
|
+
for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
|
365
|
+
args[_key11] = arguments[_key11];
|
366
|
+
}
|
367
|
+
return _assertClassBrand(_Pagination_brand, _this, _onAfterSetTheme).call(_this, ...args);
|
368
|
+
});
|
369
|
+
this.addHook('afterDialogShow', function () {
|
370
|
+
for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
|
371
|
+
args[_key12] = arguments[_key12];
|
372
|
+
}
|
373
|
+
return _assertClassBrand(_Pagination_brand, _this, _onAfterDialogShow).call(_this, ...args);
|
374
|
+
});
|
375
|
+
this.addHook('beforeDialogHide', function () {
|
376
|
+
for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
|
377
|
+
args[_key13] = arguments[_key13];
|
378
|
+
}
|
379
|
+
return _assertClassBrand(_Pagination_brand, _this, _onAfterDialogHide).call(_this, ...args);
|
380
|
+
});
|
381
|
+
this.hot.rowIndexMapper.addLocalHook('cacheUpdated', _classPrivateFieldGet(_onIndexCacheUpdate, this));
|
382
|
+
super.enablePlugin();
|
383
|
+
}
|
384
|
+
|
385
|
+
/**
|
386
|
+
* Updates the plugin state. This method is executed when {@link Core#updateSettings} is invoked.
|
387
|
+
*/
|
388
|
+
updatePlugin() {
|
389
|
+
this.disablePlugin();
|
390
|
+
this.enablePlugin();
|
391
|
+
_assertClassBrand(_Pagination_brand, this, _computeAndApplyState).call(this);
|
392
|
+
super.updatePlugin();
|
393
|
+
}
|
394
|
+
|
395
|
+
/**
|
396
|
+
* Disables the plugin functionality for this Handsontable instance.
|
397
|
+
*/
|
398
|
+
disablePlugin() {
|
399
|
+
this.hot.rowIndexMapper.removeLocalHook('cacheUpdated', _classPrivateFieldGet(_onIndexCacheUpdate, this)).unregisterMap(this.pluginName);
|
400
|
+
_classPrivateFieldGet(_ui, this).destroy();
|
401
|
+
_classPrivateFieldSet(_ui, this, null);
|
402
|
+
_assertClassBrand(_Pagination_brand, this, _unregisterShortcuts).call(this);
|
403
|
+
super.disablePlugin();
|
404
|
+
}
|
405
|
+
/**
|
406
|
+
* Gets the pagination current state. Returns an object with the following properties:
|
407
|
+
* - `currentPage`: The current page number.
|
408
|
+
* - `totalPages`: The total number of pages.
|
409
|
+
* - `pageSize`: The page size.
|
410
|
+
* - `pageSizeList`: The list of page sizes.
|
411
|
+
* - `autoPageSize`: Whether the page size is calculated automatically.
|
412
|
+
* - `numberOfRenderedRows`: The number of rendered rows.
|
413
|
+
* - `firstVisibleRowIndex`: The index of the first visible row.
|
414
|
+
* - `lastVisibleRowIndex`: The index of the last visible row.
|
415
|
+
*
|
416
|
+
* @returns {{
|
417
|
+
* currentPage: number,
|
418
|
+
* totalPages: number,
|
419
|
+
* pageSize: number,
|
420
|
+
* pageSizeList: Array<number | 'auto'>,
|
421
|
+
* autoPageSize: boolean,
|
422
|
+
* numberOfRenderedRows: number,
|
423
|
+
* firstVisibleRowIndex: number,
|
424
|
+
* lastVisibleRowIndex: number
|
425
|
+
* }}
|
426
|
+
*/
|
427
|
+
getPaginationData() {
|
428
|
+
const totalPages = _classPrivateFieldGet(_calcStrategy, this).getTotalPages();
|
429
|
+
let firstVisibleRowIndex = -1;
|
430
|
+
let lastVisibleRowIndex = -1;
|
431
|
+
const {
|
432
|
+
pageSize,
|
433
|
+
startIndex
|
434
|
+
} = _classPrivateFieldGet(_calcStrategy, this).getState(_classPrivateFieldGet(_currentPage, this));
|
435
|
+
const countRows = this.hot.countRows();
|
436
|
+
let visibleCount = 0;
|
437
|
+
for (let rowIndex = startIndex; visibleCount < pageSize; rowIndex++) {
|
438
|
+
if (rowIndex >= countRows) {
|
439
|
+
break;
|
440
|
+
}
|
441
|
+
if (this.hot.rowIndexMapper.isHidden(this.hot.toPhysicalRow(rowIndex))) {
|
442
|
+
// eslint-disable-next-line no-continue
|
443
|
+
continue;
|
444
|
+
}
|
445
|
+
if (firstVisibleRowIndex === -1) {
|
446
|
+
firstVisibleRowIndex = rowIndex;
|
447
|
+
}
|
448
|
+
lastVisibleRowIndex = rowIndex;
|
449
|
+
visibleCount += 1;
|
450
|
+
}
|
451
|
+
return {
|
452
|
+
currentPage: _classPrivateFieldGet(_currentPage, this),
|
453
|
+
totalPages,
|
454
|
+
pageSize,
|
455
|
+
pageSizeList: [...this.getSetting('pageSizeList')],
|
456
|
+
autoPageSize: _classPrivateFieldGet(_pageSize, this) === 'auto',
|
457
|
+
numberOfRenderedRows: this.hot.rowIndexMapper.getRenderableIndexesLength(),
|
458
|
+
firstVisibleRowIndex,
|
459
|
+
lastVisibleRowIndex
|
460
|
+
};
|
461
|
+
}
|
462
|
+
|
463
|
+
/**
|
464
|
+
* Allows changing the page for specified page number.
|
465
|
+
*
|
466
|
+
* @param {number} pageNumber The page number to set (from 1 to N). If `0` is passed, it
|
467
|
+
* will be transformed to `1`.
|
468
|
+
* @fires Hooks#beforePageChange
|
469
|
+
* @fires Hooks#afterPageChange
|
470
|
+
*/
|
471
|
+
setPage(pageNumber) {
|
472
|
+
const oldPage = _classPrivateFieldGet(_currentPage, this);
|
473
|
+
const shouldProceed = this.hot.runHooks('beforePageChange', oldPage, pageNumber);
|
474
|
+
if (shouldProceed === false) {
|
475
|
+
return;
|
476
|
+
}
|
477
|
+
_classPrivateFieldSet(_currentPage, this, pageNumber);
|
478
|
+
_assertClassBrand(_Pagination_brand, this, _computeAndApplyState).call(this);
|
479
|
+
this.hot.scrollViewportTo({
|
480
|
+
row: 0
|
481
|
+
});
|
482
|
+
this.hot.runHooks('afterPageChange', oldPage, _classPrivateFieldGet(_currentPage, this));
|
483
|
+
this.hot.view.adjustElementsSize();
|
484
|
+
this.hot.render();
|
485
|
+
}
|
486
|
+
|
487
|
+
/**
|
488
|
+
* Resets the current page to the initial page (`initialValue`) defined in the settings.
|
489
|
+
*/
|
490
|
+
resetPage() {
|
491
|
+
this.setPage(this.getSetting('initialPage'));
|
492
|
+
}
|
493
|
+
|
494
|
+
/**
|
495
|
+
* Changes the page size for the pagination. The method recalculates the state based
|
496
|
+
* on the new page size and re-renders the table. If `'auto'` is passed, the plugin will
|
497
|
+
* calculate the page size based on the viewport size and row heights to make sure
|
498
|
+
* that there will be no vertical scrollbar in the table.
|
499
|
+
*
|
500
|
+
* @param {number | 'auto'} pageSize The page size to set.
|
501
|
+
* @fires Hooks#beforePageSizeChange
|
502
|
+
* @fires Hooks#afterPageSizeChange
|
503
|
+
*/
|
504
|
+
setPageSize(pageSize) {
|
505
|
+
var _this$hot$getPlugin2;
|
506
|
+
const oldPageSize = _classPrivateFieldGet(_pageSize, this);
|
507
|
+
const shouldProceed = this.hot.runHooks('beforePageSizeChange', oldPageSize, pageSize);
|
508
|
+
if (shouldProceed === false) {
|
509
|
+
return;
|
510
|
+
}
|
511
|
+
if (pageSize === 'auto' && !((_this$hot$getPlugin2 = this.hot.getPlugin('autoRowSize')) !== null && _this$hot$getPlugin2 !== void 0 && _this$hot$getPlugin2.enabled)) {
|
512
|
+
warn(AUTO_PAGE_SIZE_WARNING);
|
513
|
+
}
|
514
|
+
_classPrivateFieldSet(_calcStrategy, this, createPaginatorStrategy(pageSize === 'auto' ? 'auto' : 'fixed'));
|
515
|
+
_classPrivateFieldSet(_pageSize, this, pageSize);
|
516
|
+
_assertClassBrand(_Pagination_brand, this, _computeAndApplyState).call(this);
|
517
|
+
this.hot.runHooks('afterPageSizeChange', oldPageSize, _classPrivateFieldGet(_pageSize, this));
|
518
|
+
this.hot.view.adjustElementsSize();
|
519
|
+
this.hot.render();
|
520
|
+
}
|
521
|
+
|
522
|
+
/**
|
523
|
+
* Resets the page size to the initial value (`pageSize`) defined in the settings.
|
524
|
+
*/
|
525
|
+
resetPageSize() {
|
526
|
+
this.setPageSize(this.getSetting('pageSize'));
|
527
|
+
}
|
528
|
+
|
529
|
+
/**
|
530
|
+
* Resets the pagination state to the initial values defined in the settings.
|
531
|
+
*/
|
532
|
+
resetPagination() {
|
533
|
+
this.resetPage();
|
534
|
+
this.resetPageSize();
|
535
|
+
_assertClassBrand(_Pagination_brand, this, _updateSectionsVisibilityState).call(this);
|
536
|
+
}
|
537
|
+
|
538
|
+
/**
|
539
|
+
* Switches the page to the next one.
|
540
|
+
*/
|
541
|
+
nextPage() {
|
542
|
+
this.setPage(_classPrivateFieldGet(_currentPage, this) + 1);
|
543
|
+
}
|
544
|
+
|
545
|
+
/**
|
546
|
+
* Switches the page to the previous one.
|
547
|
+
*/
|
548
|
+
prevPage() {
|
549
|
+
this.setPage(_classPrivateFieldGet(_currentPage, this) - 1);
|
550
|
+
}
|
551
|
+
|
552
|
+
/**
|
553
|
+
* Switches the page to the first one.
|
554
|
+
*/
|
555
|
+
firstPage() {
|
556
|
+
this.setPage(1);
|
557
|
+
}
|
558
|
+
|
559
|
+
/**
|
560
|
+
* Switches the page to the last one.
|
561
|
+
*/
|
562
|
+
lastPage() {
|
563
|
+
this.setPage(_classPrivateFieldGet(_calcStrategy, this).getTotalPages());
|
564
|
+
}
|
565
|
+
|
566
|
+
/**
|
567
|
+
* Checks, based on the current internal state, if there is a previous page.
|
568
|
+
*
|
569
|
+
* @returns {boolean}
|
570
|
+
*/
|
571
|
+
hasPreviousPage() {
|
572
|
+
return _classPrivateFieldGet(_currentPage, this) > 1;
|
573
|
+
}
|
574
|
+
|
575
|
+
/**
|
576
|
+
* Checks, based on the current internal state, if there is a next page.
|
577
|
+
*
|
578
|
+
* @returns {boolean}
|
579
|
+
*/
|
580
|
+
hasNextPage() {
|
581
|
+
return _classPrivateFieldGet(_currentPage, this) < _classPrivateFieldGet(_calcStrategy, this).getTotalPages();
|
582
|
+
}
|
583
|
+
|
584
|
+
/**
|
585
|
+
* Gets the visual data for the current page. The returned data may be longer than the defined
|
586
|
+
* page size as the data may contain hidden rows (rows that are not rendered in the table).
|
587
|
+
*
|
588
|
+
* @returns {Array<Array>} Returns the data for the current page.
|
589
|
+
*/
|
590
|
+
getCurrentPageData() {
|
591
|
+
const {
|
592
|
+
firstVisibleRowIndex,
|
593
|
+
lastVisibleRowIndex
|
594
|
+
} = this.getPaginationData();
|
595
|
+
if (firstVisibleRowIndex === -1 || lastVisibleRowIndex === -1) {
|
596
|
+
return [];
|
597
|
+
}
|
598
|
+
return this.hot.getData(firstVisibleRowIndex, 0, lastVisibleRowIndex, this.hot.countCols() - 1);
|
599
|
+
}
|
600
|
+
|
601
|
+
/**
|
602
|
+
* Shows the page size section in the pagination UI.
|
603
|
+
*
|
604
|
+
* @fires Hooks#afterPageSizeVisibilityChange
|
605
|
+
*/
|
606
|
+
showPageSizeSection() {
|
607
|
+
_classPrivateFieldGet(_ui, this).setPageSizeSectionVisibility(true);
|
608
|
+
this.hot.runHooks('afterPageSizeVisibilityChange', true);
|
609
|
+
}
|
610
|
+
|
611
|
+
/**
|
612
|
+
* Hides the page size section in the pagination UI.
|
613
|
+
*
|
614
|
+
* @fires Hooks#afterPageSizeVisibilityChange
|
615
|
+
*/
|
616
|
+
hidePageSizeSection() {
|
617
|
+
_classPrivateFieldGet(_ui, this).setPageSizeSectionVisibility(false);
|
618
|
+
this.hot.runHooks('afterPageSizeVisibilityChange', false);
|
619
|
+
}
|
620
|
+
|
621
|
+
/**
|
622
|
+
* Shows the page counter section in the pagination UI.
|
623
|
+
*
|
624
|
+
* @fires Hooks#afterPageCounterVisibilityChange
|
625
|
+
*/
|
626
|
+
showPageCounterSection() {
|
627
|
+
_classPrivateFieldGet(_ui, this).setCounterSectionVisibility(true);
|
628
|
+
this.hot.runHooks('afterPageCounterVisibilityChange', true);
|
629
|
+
}
|
630
|
+
|
631
|
+
/**
|
632
|
+
* Hides the page counter section in the pagination UI.
|
633
|
+
*
|
634
|
+
* @fires Hooks#afterPageCounterVisibilityChange
|
635
|
+
*/
|
636
|
+
hidePageCounterSection() {
|
637
|
+
_classPrivateFieldGet(_ui, this).setCounterSectionVisibility(false);
|
638
|
+
this.hot.runHooks('afterPageCounterVisibilityChange', false);
|
639
|
+
}
|
640
|
+
|
641
|
+
/**
|
642
|
+
* Shows the page navigation section in the pagination UI.
|
643
|
+
*
|
644
|
+
* @fires Hooks#afterPageNavigationVisibilityChange
|
645
|
+
*/
|
646
|
+
showPageNavigationSection() {
|
647
|
+
_classPrivateFieldGet(_ui, this).setNavigationSectionVisibility(true);
|
648
|
+
this.hot.runHooks('afterPageNavigationVisibilityChange', true);
|
649
|
+
}
|
650
|
+
|
651
|
+
/**
|
652
|
+
* Hides the page navigation section in the pagination UI.
|
653
|
+
*
|
654
|
+
* @fires Hooks#afterPageNavigationVisibilityChange
|
655
|
+
*/
|
656
|
+
hidePageNavigationSection() {
|
657
|
+
_classPrivateFieldGet(_ui, this).setNavigationSectionVisibility(false);
|
658
|
+
this.hot.runHooks('afterPageNavigationVisibilityChange', false);
|
659
|
+
}
|
660
|
+
|
661
|
+
/**
|
662
|
+
* Updates the visibility state of the pagination sections based on the current settings.
|
663
|
+
*/
|
664
|
+
|
665
|
+
/**
|
666
|
+
* Destroys the plugin instance.
|
667
|
+
*/
|
668
|
+
destroy() {
|
669
|
+
var _classPrivateFieldGet2;
|
670
|
+
_classPrivateFieldSet(_pagedRowsMap, this, null);
|
671
|
+
_classPrivateFieldSet(_calcStrategy, this, null);
|
672
|
+
(_classPrivateFieldGet2 = _classPrivateFieldGet(_ui, this)) === null || _classPrivateFieldGet2 === void 0 || _classPrivateFieldGet2.destroy();
|
673
|
+
_classPrivateFieldSet(_ui, this, null);
|
674
|
+
super.destroy();
|
675
|
+
}
|
676
|
+
}
|
677
|
+
function _registerEvents() {
|
678
|
+
// TODO: move to general focus manager module
|
679
|
+
this.eventManager.addEventListener(this.hot.rootDocument, 'mouseup', event => {
|
680
|
+
const container = _classPrivateFieldGet(_ui, this).getContainer();
|
681
|
+
if (!container.contains(event.target) && this.hot.getShortcutManager().getActiveContextName() === SHORTCUTS_CONTEXT_NAME) {
|
682
|
+
_classPrivateFieldGet(_focusDetector, this).activate();
|
683
|
+
_classPrivateFieldGet(_focusController, this).clear();
|
684
|
+
this.hot.getShortcutManager().setActiveContextName('grid');
|
685
|
+
}
|
686
|
+
});
|
687
|
+
}
|
688
|
+
/**
|
689
|
+
* Register shortcuts responsible for navigating through the pagination.
|
690
|
+
*/
|
691
|
+
function _registerShortcuts() {
|
692
|
+
var _manager$getContext;
|
693
|
+
const manager = this.hot.getShortcutManager();
|
694
|
+
const pluginContext = (_manager$getContext = manager.getContext(SHORTCUTS_CONTEXT_NAME)) !== null && _manager$getContext !== void 0 ? _manager$getContext : manager.addContext(SHORTCUTS_CONTEXT_NAME, 'global');
|
695
|
+
pluginContext.addShortcut({
|
696
|
+
keys: [['Shift', 'Tab'], ['Tab']],
|
697
|
+
preventDefault: false,
|
698
|
+
callback: event => {
|
699
|
+
let previousIndex = _classPrivateFieldGet(_focusController, this).getCurrentPage();
|
700
|
+
if (event.shiftKey) {
|
701
|
+
_classPrivateFieldGet(_focusController, this).toPreviousItem();
|
702
|
+
const currentPage = _classPrivateFieldGet(_focusController, this).getCurrentPage();
|
703
|
+
if (currentPage >= previousIndex) {
|
704
|
+
_assertClassBrand(_Pagination_brand, this, _unFocusPagination).call(this);
|
705
|
+
return;
|
706
|
+
}
|
707
|
+
previousIndex = currentPage;
|
708
|
+
} else {
|
709
|
+
_classPrivateFieldGet(_focusController, this).toNextItem();
|
710
|
+
const currentPage = _classPrivateFieldGet(_focusController, this).getCurrentPage();
|
711
|
+
if (currentPage <= previousIndex) {
|
712
|
+
_assertClassBrand(_Pagination_brand, this, _unFocusPagination).call(this);
|
713
|
+
return;
|
714
|
+
}
|
715
|
+
previousIndex = currentPage;
|
716
|
+
}
|
717
|
+
event.preventDefault();
|
718
|
+
},
|
719
|
+
group: SHORTCUTS_GROUP
|
720
|
+
});
|
721
|
+
}
|
722
|
+
/**
|
723
|
+
* Unregister shortcuts responsible for navigating through the pagination.
|
724
|
+
*/
|
725
|
+
function _unregisterShortcuts() {
|
726
|
+
const shortcutManager = this.hot.getShortcutManager();
|
727
|
+
const pluginContext = shortcutManager.getContext(SHORTCUTS_CONTEXT_NAME);
|
728
|
+
pluginContext.removeShortcutsByGroup(SHORTCUTS_GROUP);
|
729
|
+
}
|
730
|
+
function _updateSectionsVisibilityState() {
|
731
|
+
if (this.getSetting('showPageSize')) {
|
732
|
+
this.showPageSizeSection();
|
733
|
+
} else {
|
734
|
+
this.hidePageSizeSection();
|
735
|
+
}
|
736
|
+
if (this.getSetting('showCounter')) {
|
737
|
+
this.showPageCounterSection();
|
738
|
+
} else {
|
739
|
+
this.hidePageCounterSection();
|
740
|
+
}
|
741
|
+
if (this.getSetting('showNavigation')) {
|
742
|
+
this.showPageNavigationSection();
|
743
|
+
} else {
|
744
|
+
this.hidePageNavigationSection();
|
745
|
+
}
|
746
|
+
}
|
747
|
+
/**
|
748
|
+
* Applies the current pagination state to the internal index mapper and updates the UI.
|
749
|
+
*/
|
750
|
+
function _computeAndApplyState() {
|
751
|
+
_classPrivateFieldSet(_internalExecutionCall, this, true);
|
752
|
+
_classPrivateFieldGet(_pagedRowsMap, this).clear();
|
753
|
+
const renderableIndexes = this.hot.rowIndexMapper.getRenderableIndexes();
|
754
|
+
const renderableRowsLength = renderableIndexes.length;
|
755
|
+
const {
|
756
|
+
stylesHandler
|
757
|
+
} = this.hot;
|
758
|
+
_classPrivateFieldGet(_calcStrategy, this).calculate({
|
759
|
+
pageSize: _classPrivateFieldGet(_pageSize, this),
|
760
|
+
totalItems: renderableRowsLength,
|
761
|
+
viewportSizeProvider: () => {
|
762
|
+
const {
|
763
|
+
view
|
764
|
+
} = this.hot;
|
765
|
+
if (view.isVerticallyScrollableByWindow()) {
|
766
|
+
const bodyStyle = getComputedStyle(this.hot.rootDocument.body);
|
767
|
+
const margin = Number.parseInt(bodyStyle.marginTop, 10) + Number.parseInt(bodyStyle.marginBottom, 10);
|
768
|
+
const columnHeaderHeight = this.hot.hasColHeaders() ? view._wt.wtTable.getColumnHeaderHeight() : 0;
|
769
|
+
const paginationContainerHeight = _classPrivateFieldGet(_ui, this).getHeight();
|
770
|
+
const workspaceHeight = view.getWorkspaceHeight();
|
771
|
+
return workspaceHeight - paginationContainerHeight - columnHeaderHeight - margin;
|
772
|
+
}
|
773
|
+
const scrollbarWidth = view.hasHorizontalScroll() ? getScrollbarWidth() : 0;
|
774
|
+
return view.getViewportHeight() - scrollbarWidth;
|
775
|
+
},
|
776
|
+
itemsSizeProvider: () => {
|
777
|
+
const defaultRowHeight = stylesHandler.getDefaultRowHeight();
|
778
|
+
const rowHeights = this.hot.rowIndexMapper.getRenderableIndexes().map(physicalIndex => {
|
779
|
+
var _this$hot$getRowHeigh;
|
780
|
+
return (_this$hot$getRowHeigh = this.hot.getRowHeight(this.hot.toVisualRow(physicalIndex))) !== null && _this$hot$getRowHeigh !== void 0 ? _this$hot$getRowHeigh : defaultRowHeight;
|
781
|
+
});
|
782
|
+
return rowHeights;
|
783
|
+
}
|
784
|
+
});
|
785
|
+
const totalPages = _classPrivateFieldGet(_calcStrategy, this).getTotalPages();
|
786
|
+
_classPrivateFieldSet(_currentPage, this, clamp(_classPrivateFieldGet(_currentPage, this), 1, totalPages));
|
787
|
+
if (renderableIndexes.length > 0) {
|
788
|
+
const {
|
789
|
+
startIndex,
|
790
|
+
pageSize
|
791
|
+
} = _classPrivateFieldGet(_calcStrategy, this).getState(_classPrivateFieldGet(_currentPage, this));
|
792
|
+
renderableIndexes.splice(startIndex, pageSize);
|
793
|
+
}
|
794
|
+
if (renderableIndexes.length > 0) {
|
795
|
+
this.hot.batchExecution(() => {
|
796
|
+
renderableIndexes.forEach(index => _classPrivateFieldGet(_pagedRowsMap, this).setValueAtIndex(index, true));
|
797
|
+
}, true);
|
798
|
+
} else {
|
799
|
+
this.hot.rowIndexMapper.updateCache(true);
|
800
|
+
}
|
801
|
+
_classPrivateFieldSet(_internalExecutionCall, this, false);
|
802
|
+
const paginationData = this.getPaginationData();
|
803
|
+
_classPrivateFieldGet(_ui, this).updateState({
|
804
|
+
...paginationData,
|
805
|
+
totalRenderedRows: renderableRowsLength
|
806
|
+
});
|
807
|
+
if ((this.getSetting('showPageSize') || this.getSetting('showNavigation')) && paginationData.totalPages > 1) {
|
808
|
+
_classPrivateFieldGet(_focusDetector, this).activate();
|
809
|
+
} else {
|
810
|
+
_classPrivateFieldGet(_focusDetector, this).deactivate();
|
811
|
+
}
|
812
|
+
}
|
813
|
+
/**
|
814
|
+
* Based on the external factors (like the scroll position of the table, size etc.) it computes
|
815
|
+
* the need for the top border of the pagination UI container.
|
816
|
+
*
|
817
|
+
* @returns {boolean} Returns `true` if the pagination UI should have a top border, `false` otherwise.
|
818
|
+
*/
|
819
|
+
function _computeNeedsBorder() {
|
820
|
+
if (!this.hot.view) {
|
821
|
+
return true;
|
822
|
+
}
|
823
|
+
const {
|
824
|
+
view
|
825
|
+
} = this.hot;
|
826
|
+
if (view.isVerticallyScrollableByWindow()) {
|
827
|
+
return false;
|
828
|
+
}
|
829
|
+
if (view.hasHorizontalScroll() || view.getTableHeight() < view.getWorkspaceHeight()) {
|
830
|
+
return true;
|
831
|
+
}
|
832
|
+
const {
|
833
|
+
lastVisibleRowIndex
|
834
|
+
} = this.getPaginationData();
|
835
|
+
return view.getLastFullyVisibleRow() !== lastVisibleRowIndex;
|
836
|
+
}
|
837
|
+
/**
|
838
|
+
* Called before the selection of columns or all table is made. It modifies the selection rows range
|
839
|
+
* to the range of the current page.
|
840
|
+
*
|
841
|
+
* @param {CellCoords} from Starting cell coordinates.
|
842
|
+
* @param {CellCoords} to Ending cell coordinates.
|
843
|
+
*/
|
844
|
+
function _onBeforeSelectAllRows(from, to) {
|
845
|
+
const {
|
846
|
+
firstVisibleRowIndex,
|
847
|
+
lastVisibleRowIndex
|
848
|
+
} = this.getPaginationData();
|
849
|
+
if (_classPrivateFieldGet(_currentPage, this) > 1 || from.row >= 0) {
|
850
|
+
from.row = firstVisibleRowIndex;
|
851
|
+
}
|
852
|
+
to.row = lastVisibleRowIndex;
|
853
|
+
}
|
854
|
+
/**
|
855
|
+
* Called before the selection end is fired. It modifies the selection to the range of
|
856
|
+
* the current page.
|
857
|
+
*
|
858
|
+
* @param {CellCoords} coords Ending cell coordinates.
|
859
|
+
*/
|
860
|
+
function _onBeforeSetRangeEnd(coords) {
|
861
|
+
if (this.hot.selection.isSelectedByColumnHeader()) {
|
862
|
+
const {
|
863
|
+
lastVisibleRowIndex
|
864
|
+
} = this.getPaginationData();
|
865
|
+
coords.row = lastVisibleRowIndex;
|
866
|
+
}
|
867
|
+
}
|
868
|
+
/**
|
869
|
+
* The hook corrects the focus position (before drawing it) after the selection was made
|
870
|
+
* (the visual coordinates was collected).
|
871
|
+
*/
|
872
|
+
function _onBeforeSelectionHighlightSet() {
|
873
|
+
if (!this.hot.getSettings().navigableHeaders) {
|
874
|
+
return;
|
875
|
+
}
|
876
|
+
const selectedRange = this.hot.getSelectedRangeLast();
|
877
|
+
if (!selectedRange.isSingle()) {
|
878
|
+
const {
|
879
|
+
highlight
|
880
|
+
} = selectedRange;
|
881
|
+
highlight.row = clamp(highlight.row, selectedRange.getTopStartCorner().row, selectedRange.getBottomEndCorner().row);
|
882
|
+
}
|
883
|
+
}
|
884
|
+
/**
|
885
|
+
* Called before the paste operation is performed. It removes the rows that are not visible
|
886
|
+
* from the pasted data.
|
887
|
+
*
|
888
|
+
* @param {Array} pastedData The data that was pasted.
|
889
|
+
* @param {Array<{startRow: number, endRow: number}>} ranges The ranges of the pasted data.
|
890
|
+
* @returns {boolean} Returns `false` to prevent the paste operation.
|
891
|
+
*/
|
892
|
+
function _onBeforePaste(pastedData, ranges) {
|
893
|
+
const {
|
894
|
+
firstVisibleRowIndex,
|
895
|
+
lastVisibleRowIndex
|
896
|
+
} = this.getPaginationData();
|
897
|
+
if (firstVisibleRowIndex === -1 || lastVisibleRowIndex === -1) {
|
898
|
+
return false;
|
899
|
+
}
|
900
|
+
ranges.forEach(_ref => {
|
901
|
+
let {
|
902
|
+
startRow
|
903
|
+
} = _ref;
|
904
|
+
if (pastedData.length === 0) {
|
905
|
+
return;
|
906
|
+
}
|
907
|
+
const rowsToRemove = Math.min(pastedData.length - (lastVisibleRowIndex - startRow + 1), pastedData.length);
|
908
|
+
pastedData.splice(0, rowsToRemove);
|
909
|
+
});
|
910
|
+
}
|
911
|
+
/**
|
912
|
+
* Called when the row height is modified. It adds 1px border top compensation for
|
913
|
+
* the first row of the each page to make sure that the table's hider element
|
914
|
+
* height is correctly calculated.
|
915
|
+
*
|
916
|
+
* @param {number | undefined} height Row height.
|
917
|
+
* @param {number} row Visual row index.
|
918
|
+
* @returns {number}
|
919
|
+
*/
|
920
|
+
function _onModifyRowHeight(height, row) {
|
921
|
+
if (height === undefined || !_classPrivateFieldGet(_calcStrategy, this).getState(_classPrivateFieldGet(_currentPage, this))) {
|
922
|
+
return;
|
923
|
+
}
|
924
|
+
const {
|
925
|
+
firstVisibleRowIndex
|
926
|
+
} = this.getPaginationData();
|
927
|
+
if (row !== 0 && row === firstVisibleRowIndex) {
|
928
|
+
height += 1; // 1px border top compensation for the first row of the page.
|
929
|
+
}
|
930
|
+
return height;
|
931
|
+
}
|
932
|
+
/**
|
933
|
+
* Called after the view is rendered. It recalculates the pagination state only when
|
934
|
+
* the `pageSize` is set to `'auto'`. In this case, the plugin will compute the
|
935
|
+
* page size based on the viewport size and row heights for each render cycle to make sure
|
936
|
+
* that each row resize, multiline cell value, or other factors that may affect the
|
937
|
+
* rows height will be taken into account.
|
938
|
+
*/
|
939
|
+
function _onAfterViewRender() {
|
940
|
+
if (_classPrivateFieldGet(_pageSize, this) !== 'auto' || _classPrivateFieldGet(_internalRenderCall, this)) {
|
941
|
+
_classPrivateFieldSet(_internalRenderCall, this, false);
|
942
|
+
return;
|
943
|
+
}
|
944
|
+
_assertClassBrand(_Pagination_brand, this, _computeAndApplyState).call(this);
|
945
|
+
_classPrivateFieldSet(_internalRenderCall, this, true);
|
946
|
+
// there is need to re-render the table as on the initial the engine returns incorrect
|
947
|
+
// values about table and column header sizes.
|
948
|
+
this.hot.view.adjustElementsSize();
|
949
|
+
this.hot.render();
|
950
|
+
}
|
951
|
+
/**
|
952
|
+
* Called after the rendering of the table is completed. It updates the width of
|
953
|
+
* the pagination container to the same size as the table.
|
954
|
+
*/
|
955
|
+
function _onAfterRender() {
|
956
|
+
const {
|
957
|
+
view
|
958
|
+
} = this.hot;
|
959
|
+
const width = view.isHorizontallyScrollableByWindow() ? view.getTotalTableWidth() : view.getWorkspaceWidth();
|
960
|
+
_classPrivateFieldGet(_ui, this).updateWidth(width).refreshBorderState();
|
961
|
+
}
|
962
|
+
/**
|
963
|
+
* Called before the height of the table is changed. It adjusts the table height to fit the pagination container
|
964
|
+
* in declared height.
|
965
|
+
*
|
966
|
+
* @param {number|string} height Table height.
|
967
|
+
* @returns {string} Returns the new table height.
|
968
|
+
*/
|
969
|
+
function _onBeforeHeightChange(height) {
|
970
|
+
if (this.getSetting('uiContainer')) {
|
971
|
+
return height;
|
972
|
+
}
|
973
|
+
const isPixelValue = typeof height === 'number' || typeof height === 'string' && /^\d+$/.test(height) || typeof height === 'string' && height.endsWith('px');
|
974
|
+
if (!isPixelValue) {
|
975
|
+
return height;
|
976
|
+
}
|
977
|
+
const heightValue = typeof height === 'string' && height.endsWith('px') ? height : `${height}px`;
|
978
|
+
return `calc(${heightValue} - ${_classPrivateFieldGet(_ui, this).getHeight()}px)`;
|
979
|
+
}
|
980
|
+
/**
|
981
|
+
* Called after the initialization of the plugin. It computes the initial state of the pagination.
|
982
|
+
*/
|
983
|
+
function _onInit() {
|
984
|
+
if (_classPrivateFieldGet(_pageSize, this) === 'auto') {
|
985
|
+
return;
|
986
|
+
}
|
987
|
+
_assertClassBrand(_Pagination_brand, this, _computeAndApplyState).call(this);
|
988
|
+
}
|
989
|
+
/**
|
990
|
+
* Called after the vertical scrolling of the table is completed. It refreshes
|
991
|
+
* the border state of the pagination UI.
|
992
|
+
*/
|
993
|
+
function _onAfterScrollVertically() {
|
994
|
+
_classPrivateFieldGet(_ui, this).refreshBorderState();
|
995
|
+
}
|
996
|
+
/**
|
997
|
+
* Called after the language change. It recomputes the pagination state which updates the UI.
|
998
|
+
*/
|
999
|
+
function _onAfterLanguageChange() {
|
1000
|
+
_assertClassBrand(_Pagination_brand, this, _computeAndApplyState).call(this);
|
1001
|
+
}
|
1002
|
+
/**
|
1003
|
+
* Called after the theme is set. It updates the theme of the pagination container.
|
1004
|
+
*
|
1005
|
+
* @param {string | undefined} themeName The name of the theme to use.
|
1006
|
+
*/
|
1007
|
+
function _onAfterSetTheme(themeName) {
|
1008
|
+
_classPrivateFieldGet(_ui, this).updateTheme(themeName);
|
1009
|
+
}
|
1010
|
+
/**
|
1011
|
+
* Unfocuses the pagination and sets the active context for the shortcuts.
|
1012
|
+
*/
|
1013
|
+
function _unFocusPagination() {
|
1014
|
+
_classPrivateFieldGet(_focusDetector, this).activate();
|
1015
|
+
_classPrivateFieldGet(_focusController, this).clear();
|
1016
|
+
this.hot.unlisten();
|
1017
|
+
this.hot.getShortcutManager().setActiveContextName('grid');
|
1018
|
+
}
|
1019
|
+
/**
|
1020
|
+
* Called after the dialog is shown. It sets the active context for the shortcuts.
|
1021
|
+
*/
|
1022
|
+
function _onAfterDialogShow() {
|
1023
|
+
_classPrivateFieldGet(_focusDetector, this).deactivate();
|
1024
|
+
}
|
1025
|
+
/**
|
1026
|
+
* Called after the dialog is hidden. It sets the active context for the shortcuts.
|
1027
|
+
*/
|
1028
|
+
function _onAfterDialogHide() {
|
1029
|
+
_classPrivateFieldGet(_focusDetector, this).activate();
|
1030
|
+
}
|