handsontable 14.6.1 → 15.0.0-next-fdd4480-20241205
Sign up to get free protection for your applications and to get access to all the features.
- package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.js +23 -0
- package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.mjs +23 -0
- package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.js +23 -0
- package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.mjs +23 -0
- package/3rdparty/walkontable/src/calculator/index.js +1 -2
- package/3rdparty/walkontable/src/calculator/index.mjs +2 -2
- package/3rdparty/walkontable/src/calculator/viewportBase.js +2 -0
- package/3rdparty/walkontable/src/calculator/viewportBase.mjs +2 -0
- package/3rdparty/walkontable/src/calculator/viewportRows.js +3 -3
- package/3rdparty/walkontable/src/calculator/viewportRows.mjs +3 -3
- package/3rdparty/walkontable/src/core/_base.js +29 -23
- package/3rdparty/walkontable/src/core/_base.mjs +29 -23
- package/3rdparty/walkontable/src/core/clone.js +1 -0
- package/3rdparty/walkontable/src/core/clone.mjs +1 -0
- package/3rdparty/walkontable/src/core/core.js +2 -0
- package/3rdparty/walkontable/src/core/core.mjs +2 -0
- package/3rdparty/walkontable/src/facade/core.js +12 -6
- package/3rdparty/walkontable/src/facade/core.mjs +12 -6
- package/3rdparty/walkontable/src/index.js +0 -1
- package/3rdparty/walkontable/src/index.mjs +2 -2
- package/3rdparty/walkontable/src/overlay/_base.js +8 -1
- package/3rdparty/walkontable/src/overlay/_base.mjs +8 -1
- package/3rdparty/walkontable/src/overlay/bottom.js +5 -6
- package/3rdparty/walkontable/src/overlay/bottom.mjs +5 -6
- package/3rdparty/walkontable/src/overlay/index.js +2 -0
- package/3rdparty/walkontable/src/overlay/inlineStart.js +8 -7
- package/3rdparty/walkontable/src/overlay/inlineStart.mjs +9 -8
- package/3rdparty/walkontable/src/overlay/top.js +9 -8
- package/3rdparty/walkontable/src/overlay/top.mjs +10 -9
- package/3rdparty/walkontable/src/overlays.js +10 -26
- package/3rdparty/walkontable/src/overlays.mjs +10 -26
- package/3rdparty/walkontable/src/renderer/colGroup.js +1 -1
- package/3rdparty/walkontable/src/renderer/colGroup.mjs +1 -1
- package/3rdparty/walkontable/src/renderer/index.js +4 -2
- package/3rdparty/walkontable/src/renderer/index.mjs +4 -2
- package/3rdparty/walkontable/src/renderer/table.js +13 -4
- package/3rdparty/walkontable/src/renderer/table.mjs +13 -4
- package/3rdparty/walkontable/src/scroll.js +46 -37
- package/3rdparty/walkontable/src/scroll.mjs +46 -37
- package/3rdparty/walkontable/src/selection/border/border.js +52 -58
- package/3rdparty/walkontable/src/selection/border/border.mjs +53 -59
- package/3rdparty/walkontable/src/selection/border/utils.js +26 -0
- package/3rdparty/walkontable/src/selection/border/utils.mjs +22 -0
- package/3rdparty/walkontable/src/selection/index.js +6 -4
- package/3rdparty/walkontable/src/selection/index.mjs +1 -1
- package/3rdparty/walkontable/src/selection/manager.js +3 -0
- package/3rdparty/walkontable/src/selection/manager.mjs +3 -0
- package/3rdparty/walkontable/src/selection/scanner.js +46 -11
- package/3rdparty/walkontable/src/selection/scanner.mjs +46 -11
- package/3rdparty/walkontable/src/settings.js +8 -9
- package/3rdparty/walkontable/src/settings.mjs +8 -9
- package/3rdparty/walkontable/src/table/master.js +1 -1
- package/3rdparty/walkontable/src/table/master.mjs +2 -2
- package/3rdparty/walkontable/src/table.js +25 -36
- package/3rdparty/walkontable/src/table.mjs +25 -36
- package/3rdparty/walkontable/src/types.js +1 -0
- package/3rdparty/walkontable/src/types.mjs +1 -0
- package/3rdparty/walkontable/src/utils/column.js +1 -43
- package/3rdparty/walkontable/src/utils/column.mjs +1 -43
- package/3rdparty/walkontable/src/utils/stylesHandler.js +295 -0
- package/3rdparty/walkontable/src/utils/stylesHandler.mjs +291 -0
- package/3rdparty/walkontable/src/viewport.js +94 -91
- package/3rdparty/walkontable/src/viewport.mjs +95 -92
- package/CHANGELOG.md +36 -0
- package/README.md +1 -1
- package/base.js +4 -4
- package/base.mjs +3 -3
- package/core/focusCatcher/focusDetector.js +1 -0
- package/core/focusCatcher/focusDetector.mjs +1 -0
- package/core/hooks/bucket.js +184 -0
- package/core/hooks/bucket.mjs +180 -0
- package/{pluginHooks.mjs → core/hooks/constants.js} +38 -486
- package/{pluginHooks.js → core/hooks/constants.mjs} +34 -489
- package/{pluginHooks.d.ts → core/hooks/index.d.ts} +22 -25
- package/core/hooks/index.js +385 -0
- package/core/hooks/index.mjs +381 -0
- package/core/index.js +2 -0
- package/core.d.ts +5 -3
- package/core.js +77 -35
- package/core.mjs +69 -27
- package/dataMap/dataMap.js +3 -0
- package/dataMap/dataMap.mjs +3 -0
- package/dataMap/dataSource.js +2 -0
- package/dataMap/dataSource.mjs +2 -0
- package/dataMap/metaManager/index.js +2 -0
- package/dataMap/metaManager/index.mjs +2 -0
- package/dataMap/metaManager/metaSchema.js +91 -5
- package/dataMap/metaManager/metaSchema.mjs +91 -5
- package/dataMap/metaManager/mods/dynamicCellMeta.js +2 -3
- package/dataMap/metaManager/mods/dynamicCellMeta.mjs +1 -1
- package/dataMap/metaManager/mods/extendMetaProperties.js +2 -0
- package/dataMap/metaManager/mods/extendMetaProperties.mjs +2 -0
- package/dist/handsontable.css +84 -72
- package/dist/handsontable.full.css +317 -304
- package/dist/handsontable.full.js +14826 -7294
- package/dist/handsontable.full.min.css +15 -10
- package/dist/handsontable.full.min.js +262 -69
- package/dist/handsontable.js +7826 -5552
- package/dist/handsontable.min.css +10 -6
- package/dist/handsontable.min.js +33 -33
- package/dist/languages/all.js +1 -1
- package/dist/languages/ar-AR.js +1 -1
- package/dist/languages/cs-CZ.js +1 -1
- package/dist/languages/de-CH.js +1 -1
- package/dist/languages/de-DE.js +1 -1
- package/dist/languages/en-US.js +1 -1
- package/dist/languages/es-MX.js +1 -1
- package/dist/languages/fr-FR.js +1 -1
- package/dist/languages/hr-HR.js +1 -1
- package/dist/languages/it-IT.js +1 -1
- package/dist/languages/ja-JP.js +1 -1
- package/dist/languages/ko-KR.js +1 -1
- package/dist/languages/lv-LV.js +1 -1
- package/dist/languages/nb-NO.js +1 -1
- package/dist/languages/nl-NL.js +1 -1
- package/dist/languages/pl-PL.js +1 -1
- package/dist/languages/pt-BR.js +1 -1
- package/dist/languages/ru-RU.js +1 -1
- package/dist/languages/sr-SP.js +1 -1
- package/dist/languages/zh-CN.js +1 -1
- package/dist/languages/zh-TW.js +1 -1
- package/editorManager.js +2 -2
- package/editorManager.mjs +2 -2
- package/editors/autocompleteEditor/autocompleteEditor.js +34 -16
- package/editors/autocompleteEditor/autocompleteEditor.mjs +34 -16
- package/editors/baseEditor/baseEditor.js +25 -18
- package/editors/baseEditor/baseEditor.mjs +26 -19
- package/editors/dateEditor/dateEditor.js +9 -0
- package/editors/dateEditor/dateEditor.mjs +10 -1
- package/editors/dropdownEditor/dropdownEditor.js +4 -3
- package/editors/dropdownEditor/dropdownEditor.mjs +3 -1
- package/editors/handsontableEditor/handsontableEditor.js +36 -2
- package/editors/handsontableEditor/handsontableEditor.mjs +36 -2
- package/editors/passwordEditor/passwordEditor.js +18 -0
- package/editors/passwordEditor/passwordEditor.mjs +18 -0
- package/editors/registry.js +2 -2
- package/editors/registry.mjs +1 -1
- package/editors/selectEditor/selectEditor.js +20 -9
- package/editors/selectEditor/selectEditor.mjs +20 -9
- package/editors/textEditor/textEditor.js +5 -12
- package/editors/textEditor/textEditor.mjs +6 -13
- package/focusManager.js +5 -7
- package/focusManager.mjs +5 -7
- package/helpers/array.js +2 -0
- package/helpers/array.mjs +2 -0
- package/helpers/data.js +3 -0
- package/helpers/data.mjs +3 -0
- package/helpers/dom/element.js +39 -18
- package/helpers/dom/element.mjs +38 -17
- package/helpers/mixed.js +3 -3
- package/helpers/mixed.mjs +3 -3
- package/helpers/moves.js +3 -0
- package/helpers/moves.mjs +3 -0
- package/helpers/number.js +1 -0
- package/helpers/number.mjs +1 -0
- package/helpers/object.js +2 -0
- package/helpers/object.mjs +2 -0
- package/helpers/themes.js +17 -0
- package/helpers/themes.mjs +13 -0
- package/i18n/index.js +2 -0
- package/i18n/languages/index.d.ts +8 -0
- package/i18n/languages/ja-JP.d.ts +1 -1
- package/i18n/phraseFormatters/substituteVariables.js +1 -0
- package/i18n/phraseFormatters/substituteVariables.mjs +1 -0
- package/index.d.ts +9 -1
- package/languages/all.js +1 -1
- package/languages/ar-AR.js +1 -1
- package/languages/cs-CZ.js +1 -1
- package/languages/de-CH.js +1 -1
- package/languages/de-DE.js +1 -1
- package/languages/en-US.js +1 -1
- package/languages/es-MX.js +1 -1
- package/languages/fr-FR.js +1 -1
- package/languages/hr-HR.js +1 -1
- package/languages/index.js +1 -1
- package/languages/it-IT.js +1 -1
- package/languages/ja-JP.js +1 -1
- package/languages/ko-KR.js +1 -1
- package/languages/lv-LV.js +1 -1
- package/languages/nb-NO.js +1 -1
- package/languages/nl-NL.js +1 -1
- package/languages/pl-PL.js +1 -1
- package/languages/pt-BR.js +1 -1
- package/languages/ru-RU.js +1 -1
- package/languages/sr-SP.js +1 -1
- package/languages/zh-CN.js +1 -1
- package/languages/zh-TW.js +1 -1
- package/package.json +22 -7
- package/plugins/autoColumnSize/autoColumnSize.js +22 -27
- package/plugins/autoColumnSize/autoColumnSize.mjs +22 -27
- package/plugins/autoRowSize/autoRowSize.js +20 -22
- package/plugins/autoRowSize/autoRowSize.mjs +21 -23
- package/plugins/autofill/autofill.js +4 -5
- package/plugins/autofill/autofill.mjs +1 -1
- package/plugins/base/base.d.ts +1 -1
- package/plugins/base/base.js +41 -0
- package/plugins/base/base.mjs +42 -1
- package/plugins/base/index.js +2 -1
- package/plugins/base/index.mjs +1 -1
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +2 -5
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +2 -5
- package/plugins/columnSorting/columnSorting.js +5 -4
- package/plugins/columnSorting/columnSorting.mjs +3 -1
- package/plugins/columnSorting/columnStatesManager.js +1 -0
- package/plugins/columnSorting/columnStatesManager.mjs +1 -0
- package/plugins/columnSorting/utils.js +3 -0
- package/plugins/columnSorting/utils.mjs +3 -0
- package/plugins/columnSummary/endpoints.js +3 -0
- package/plugins/columnSummary/endpoints.mjs +3 -0
- package/plugins/comments/commentEditor.js +9 -0
- package/plugins/comments/commentEditor.mjs +9 -0
- package/plugins/comments/comments.js +24 -18
- package/plugins/comments/comments.mjs +26 -20
- package/plugins/comments/editorResizeObserver.js +2 -0
- package/plugins/comments/editorResizeObserver.mjs +2 -0
- package/plugins/contextMenu/contextMenu.d.ts +2 -1
- package/plugins/contextMenu/contextMenu.js +6 -7
- package/plugins/contextMenu/contextMenu.mjs +1 -1
- package/plugins/contextMenu/menu/index.js +2 -0
- package/plugins/contextMenu/menu/menu.js +10 -5
- package/plugins/contextMenu/menu/menu.mjs +11 -6
- package/plugins/contextMenu/menu/positioner.js +4 -2
- package/plugins/contextMenu/menu/positioner.mjs +4 -2
- package/plugins/contextMenu/menu/shortcuts.js +3 -1
- package/plugins/contextMenu/menu/shortcuts.mjs +3 -1
- package/plugins/contextMenu/predefinedItems/alignment.js +7 -84
- package/plugins/contextMenu/predefinedItems/alignment.mjs +8 -85
- package/plugins/contextMenu/utils.js +0 -10
- package/plugins/contextMenu/utils.mjs +0 -9
- package/plugins/copyPaste/copyPaste.d.ts +1 -0
- package/plugins/copyPaste/copyPaste.js +32 -23
- package/plugins/copyPaste/copyPaste.mjs +24 -15
- package/plugins/customBorders/utils.js +2 -0
- package/plugins/customBorders/utils.mjs +2 -0
- package/plugins/dropdownMenu/dropdownMenu.d.ts +2 -1
- package/plugins/dropdownMenu/dropdownMenu.js +6 -7
- package/plugins/dropdownMenu/dropdownMenu.mjs +1 -1
- package/plugins/exportFile/types/csv.js +1 -0
- package/plugins/exportFile/types/csv.mjs +1 -0
- package/plugins/filters/component/condition.js +2 -0
- package/plugins/filters/component/condition.mjs +2 -0
- package/plugins/filters/component/operators.js +2 -0
- package/plugins/filters/component/operators.mjs +2 -0
- package/plugins/filters/component/value.js +3 -0
- package/plugins/filters/component/value.mjs +3 -0
- package/plugins/filters/conditionCollection.js +3 -0
- package/plugins/filters/conditionCollection.mjs +3 -0
- package/plugins/filters/conditionUpdateObserver.js +2 -0
- package/plugins/filters/conditionUpdateObserver.mjs +2 -0
- package/plugins/filters/filters.js +43 -13
- package/plugins/filters/filters.mjs +43 -13
- package/plugins/filters/logicalOperations/conjunction.js +2 -0
- package/plugins/filters/logicalOperations/conjunction.mjs +2 -0
- package/plugins/filters/logicalOperations/disjunction.js +2 -0
- package/plugins/filters/logicalOperations/disjunction.mjs +2 -0
- package/plugins/filters/logicalOperations/disjunctionWithExtraCondition.js +2 -0
- package/plugins/filters/logicalOperations/disjunctionWithExtraCondition.mjs +2 -0
- package/plugins/filters/menu/focusController.js +38 -14
- package/plugins/filters/menu/focusController.mjs +38 -14
- package/plugins/filters/ui/multipleSelect.js +10 -0
- package/plugins/filters/ui/multipleSelect.mjs +10 -0
- package/plugins/formulas/engine/register.js +3 -0
- package/plugins/formulas/engine/register.mjs +3 -0
- package/plugins/formulas/engine/settings.js +3 -0
- package/plugins/formulas/engine/settings.mjs +3 -0
- package/plugins/formulas/formulas.js +12 -7
- package/plugins/formulas/formulas.mjs +6 -1
- package/plugins/formulas/indexSyncer/axisSyncer.js +3 -0
- package/plugins/formulas/indexSyncer/axisSyncer.mjs +3 -0
- package/plugins/hiddenColumns/contextMenuItem/showColumn.js +2 -0
- package/plugins/hiddenColumns/contextMenuItem/showColumn.mjs +2 -0
- package/plugins/hiddenColumns/hiddenColumns.js +22 -30
- package/plugins/hiddenColumns/hiddenColumns.mjs +18 -26
- package/plugins/hiddenRows/contextMenuItem/showRow.js +2 -0
- package/plugins/hiddenRows/contextMenuItem/showRow.mjs +2 -0
- package/plugins/hiddenRows/hiddenRows.js +21 -29
- package/plugins/hiddenRows/hiddenRows.mjs +17 -25
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +3 -0
- package/plugins/index.mjs +3 -1
- package/plugins/manualColumnFreeze/manualColumnFreeze.js +7 -5
- package/plugins/manualColumnFreeze/manualColumnFreeze.mjs +3 -1
- package/plugins/manualColumnMove/manualColumnMove.js +6 -6
- package/plugins/manualColumnMove/manualColumnMove.mjs +4 -4
- package/plugins/manualColumnResize/manualColumnResize.js +26 -12
- package/plugins/manualColumnResize/manualColumnResize.mjs +26 -12
- package/plugins/manualRowMove/manualRowMove.js +8 -6
- package/plugins/manualRowMove/manualRowMove.mjs +6 -4
- package/plugins/manualRowResize/manualRowResize.js +3 -2
- package/plugins/manualRowResize/manualRowResize.mjs +4 -3
- package/plugins/mergeCells/cellsCollection.js +19 -3
- package/plugins/mergeCells/cellsCollection.mjs +20 -4
- package/plugins/mergeCells/mergeCells.d.ts +6 -2
- package/plugins/mergeCells/mergeCells.js +84 -56
- package/plugins/mergeCells/mergeCells.mjs +82 -54
- package/plugins/mergeCells/renderer.js +13 -3
- package/plugins/mergeCells/renderer.mjs +13 -3
- package/plugins/multiColumnSorting/domHelpers.js +2 -0
- package/plugins/multiColumnSorting/domHelpers.mjs +2 -0
- package/plugins/nestedHeaders/nestedHeaders.js +63 -16
- package/plugins/nestedHeaders/nestedHeaders.mjs +63 -16
- package/plugins/nestedHeaders/stateManager/index.js +1 -0
- package/plugins/nestedHeaders/stateManager/index.mjs +1 -0
- package/plugins/nestedRows/nestedRows.js +3 -0
- package/plugins/nestedRows/nestedRows.mjs +3 -0
- package/plugins/nestedRows/ui/headers.js +7 -1
- package/plugins/nestedRows/ui/headers.mjs +7 -1
- package/plugins/nestedRows/utils/rowMoveController.js +4 -0
- package/plugins/nestedRows/utils/rowMoveController.mjs +4 -0
- package/plugins/persistentState/persistentState.js +4 -4
- package/plugins/persistentState/persistentState.mjs +1 -1
- package/plugins/stretchColumns/calculator.js +162 -0
- package/plugins/stretchColumns/calculator.mjs +158 -0
- package/plugins/stretchColumns/index.d.ts +1 -0
- package/plugins/stretchColumns/index.js +7 -0
- package/plugins/stretchColumns/index.mjs +1 -0
- package/plugins/stretchColumns/strategies/_base.js +85 -0
- package/plugins/stretchColumns/strategies/_base.mjs +81 -0
- package/plugins/stretchColumns/strategies/all.js +71 -0
- package/plugins/stretchColumns/strategies/all.mjs +67 -0
- package/plugins/stretchColumns/strategies/last.js +79 -0
- package/plugins/stretchColumns/strategies/last.mjs +75 -0
- package/plugins/stretchColumns/stretchColumns.d.ts +11 -0
- package/plugins/stretchColumns/stretchColumns.js +222 -0
- package/plugins/stretchColumns/stretchColumns.mjs +218 -0
- package/plugins/trimRows/trimRows.js +2 -0
- package/plugins/trimRows/trimRows.mjs +2 -0
- package/plugins/undoRedo/undoRedo.js +9 -5
- package/plugins/undoRedo/undoRedo.mjs +8 -3
- package/renderers/checkboxRenderer/checkboxRenderer.js +19 -8
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +18 -7
- package/selection/index.js +2 -0
- package/selection/range.js +2 -0
- package/selection/range.mjs +2 -0
- package/selection/selection.js +7 -2
- package/selection/selection.mjs +7 -2
- package/selection/utils.js +2 -0
- package/selection/utils.mjs +2 -0
- package/settings.d.ts +4 -1
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/downByViewportHeight.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/upByViewportHeight.mjs +1 -1
- package/shortcutContexts/commands/index.js +2 -0
- package/shortcutContexts/commands/index.mjs +2 -0
- package/shortcutContexts/commands/scrollToFocusedCell.js +4 -4
- package/shortcutContexts/commands/scrollToFocusedCell.mjs +4 -4
- package/shortcutContexts/index.js +2 -0
- package/shortcutContexts/index.mjs +2 -0
- package/shortcuts/context.js +3 -0
- package/shortcuts/context.mjs +3 -0
- package/shortcuts/recorder.js +3 -3
- package/shortcuts/recorder.mjs +3 -3
- package/shortcuts/utils.js +1 -0
- package/shortcuts/utils.mjs +1 -0
- package/styles/handsontable.css +2307 -0
- package/styles/handsontable.min.css +30 -0
- package/styles/ht-theme-horizon.css +607 -0
- package/styles/ht-theme-horizon.min.css +30 -0
- package/styles/ht-theme-main.css +613 -0
- package/styles/ht-theme-main.min.css +30 -0
- package/tableView.js +205 -33
- package/tableView.mjs +206 -34
- package/translations/changesObservable/observable.js +2 -0
- package/translations/changesObservable/observable.mjs +2 -0
- package/translations/index.js +2 -0
- package/translations/indexMapper.js +4 -0
- package/translations/indexMapper.mjs +4 -0
- package/translations/mapCollections/index.js +2 -0
- package/translations/mapCollections/mapCollection.js +2 -0
- package/translations/mapCollections/mapCollection.mjs +2 -0
- package/translations/maps/index.js +2 -0
- package/translations/maps/linkedPhysicalIndexToValueMap.js +1 -0
- package/translations/maps/linkedPhysicalIndexToValueMap.mjs +1 -0
- package/translations/maps/utils/actionsOnIndexes.js +2 -0
- package/translations/maps/utils/actionsOnIndexes.mjs +2 -0
- package/translations/maps/utils/physicallyIndexed.js +1 -0
- package/translations/maps/utils/physicallyIndexed.mjs +1 -0
- package/utils/autoResize.js +11 -3
- package/utils/autoResize.mjs +11 -3
- package/utils/dataStructures/priorityMap.js +1 -0
- package/utils/dataStructures/priorityMap.mjs +1 -0
- package/utils/dataStructures/uniqueMap.js +2 -0
- package/utils/dataStructures/uniqueMap.mjs +2 -0
- package/utils/ghostTable.js +7 -3
- package/utils/ghostTable.mjs +7 -3
- package/utils/parseTable.js +4 -0
- package/utils/parseTable.mjs +4 -0
- package/3rdparty/walkontable/src/selection/border/constants.js +0 -15
- package/3rdparty/walkontable/src/selection/border/constants.mjs +0 -12
- package/3rdparty/walkontable/src/utils/columnStretching.js +0 -197
- package/3rdparty/walkontable/src/utils/columnStretching.mjs +0 -193
@@ -0,0 +1,381 @@
|
|
1
|
+
import "core-js/modules/es.error.cause.js";
|
2
|
+
import "core-js/modules/es.array.push.js";
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
6
|
+
import { arrayEach } from "../../helpers/array.mjs";
|
7
|
+
import { substitute } from "../../helpers/string.mjs";
|
8
|
+
import { warn } from "../../helpers/console.mjs";
|
9
|
+
import { toSingleLine } from "../../helpers/templateLiteralTag.mjs";
|
10
|
+
import { fastCall } from "../../helpers/function.mjs";
|
11
|
+
import { REGISTERED_HOOKS, REMOVED_HOOKS, DEPRECATED_HOOKS } from "./constants.mjs";
|
12
|
+
import { HooksBucket } from "./bucket.mjs";
|
13
|
+
/**
|
14
|
+
* Template warning message for removed hooks.
|
15
|
+
*
|
16
|
+
* @type {string}
|
17
|
+
*/
|
18
|
+
const REMOVED_MESSAGE = toSingleLine`The plugin hook "[hookName]" was removed in Handsontable [removedInVersion].\x20
|
19
|
+
Please consult release notes https://github.com/handsontable/handsontable/releases/tag/[removedInVersion] to\x20
|
20
|
+
learn about the migration path.`;
|
21
|
+
export class Hooks {
|
22
|
+
constructor() {
|
23
|
+
/**
|
24
|
+
* @type {HooksBucket}
|
25
|
+
*/
|
26
|
+
_defineProperty(this, "globalBucket", new HooksBucket());
|
27
|
+
}
|
28
|
+
static getSingleton() {
|
29
|
+
return getGlobalSingleton();
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Get hook bucket based on the context of the object or if argument is missing, get the global hook bucket.
|
33
|
+
*
|
34
|
+
* @param {object} [context=null] A Handsontable instance.
|
35
|
+
* @returns {HooksBucket} Returns a global or Handsontable instance bucket.
|
36
|
+
*/
|
37
|
+
getBucket() {
|
38
|
+
let context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
39
|
+
if (context) {
|
40
|
+
if (!context.pluginHookBucket) {
|
41
|
+
context.pluginHookBucket = new HooksBucket();
|
42
|
+
}
|
43
|
+
return context.pluginHookBucket;
|
44
|
+
}
|
45
|
+
return this.globalBucket;
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Adds a listener (globally or locally) to a specified hook name.
|
50
|
+
* If the `context` parameter is provided, the hook will be added only to the instance it references.
|
51
|
+
* Otherwise, the callback will be used every time the hook fires on any Handsontable instance.
|
52
|
+
* You can provide an array of callback functions as the `callback` argument, this way they will all be fired
|
53
|
+
* once the hook is triggered.
|
54
|
+
*
|
55
|
+
* @param {string} key Hook name.
|
56
|
+
* @param {Function|Function[]} callback Callback function or an array of functions.
|
57
|
+
* @param {object} [context=null] The context for the hook callback to be added - a Handsontable instance or leave empty.
|
58
|
+
* @param {number} [orderIndex] Order index of the callback.
|
59
|
+
* If > 0, the callback will be added after the others, for example, with an index of 1, the callback will be added before the ones with an index of 2, 3, etc., but after the ones with an index of 0 and lower.
|
60
|
+
* If < 0, the callback will be added before the others, for example, with an index of -1, the callback will be added after the ones with an index of -2, -3, etc., but before the ones with an index of 0 and higher.
|
61
|
+
* If 0 or no order index is provided, the callback will be added between the "negative" and "positive" indexes.
|
62
|
+
* @returns {Hooks} Instance of Hooks.
|
63
|
+
*
|
64
|
+
* @example
|
65
|
+
* ```js
|
66
|
+
* // single callback, added locally
|
67
|
+
* Handsontable.hooks.add('beforeInit', myCallback, hotInstance);
|
68
|
+
*
|
69
|
+
* // single callback, added globally
|
70
|
+
* Handsontable.hooks.add('beforeInit', myCallback);
|
71
|
+
*
|
72
|
+
* // multiple callbacks, added locally
|
73
|
+
* Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback], hotInstance);
|
74
|
+
*
|
75
|
+
* // multiple callbacks, added globally
|
76
|
+
* Handsontable.hooks.add('beforeInit', [myCallback, anotherCallback]);
|
77
|
+
* ```
|
78
|
+
*/
|
79
|
+
add(key, callback) {
|
80
|
+
let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
81
|
+
let orderIndex = arguments.length > 3 ? arguments[3] : undefined;
|
82
|
+
if (Array.isArray(callback)) {
|
83
|
+
arrayEach(callback, c => this.add(key, c, context));
|
84
|
+
} else {
|
85
|
+
if (REMOVED_HOOKS.has(key)) {
|
86
|
+
warn(substitute(REMOVED_MESSAGE, {
|
87
|
+
hookName: key,
|
88
|
+
removedInVersion: REMOVED_HOOKS.get(key)
|
89
|
+
}));
|
90
|
+
}
|
91
|
+
if (DEPRECATED_HOOKS.has(key)) {
|
92
|
+
warn(DEPRECATED_HOOKS.get(key));
|
93
|
+
}
|
94
|
+
this.getBucket(context).add(key, callback, {
|
95
|
+
orderIndex,
|
96
|
+
runOnce: false
|
97
|
+
});
|
98
|
+
}
|
99
|
+
return this;
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Adds a listener to a specified hook. After the hook runs this listener will be automatically removed from the bucket.
|
104
|
+
*
|
105
|
+
* @param {string} key Hook/Event name.
|
106
|
+
* @param {Function|Function[]} callback Callback function.
|
107
|
+
* @param {object} [context=null] A Handsontable instance.
|
108
|
+
* @param {number} [orderIndex] Order index of the callback.
|
109
|
+
* If > 0, the callback will be added after the others, for example, with an index of 1, the callback will be added before the ones with an index of 2, 3, etc., but after the ones with an index of 0 and lower.
|
110
|
+
* If < 0, the callback will be added before the others, for example, with an index of -1, the callback will be added after the ones with an index of -2, -3, etc., but before the ones with an index of 0 and higher.
|
111
|
+
* If 0 or no order index is provided, the callback will be added between the "negative" and "positive" indexes.
|
112
|
+
* @returns {Hooks} Instance of Hooks.
|
113
|
+
*
|
114
|
+
* @example
|
115
|
+
* ```js
|
116
|
+
* Handsontable.hooks.once('beforeInit', myCallback, hotInstance);
|
117
|
+
* ```
|
118
|
+
*/
|
119
|
+
once(key, callback) {
|
120
|
+
let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
121
|
+
let orderIndex = arguments.length > 3 ? arguments[3] : undefined;
|
122
|
+
if (Array.isArray(callback)) {
|
123
|
+
arrayEach(callback, c => this.once(key, c, context));
|
124
|
+
} else {
|
125
|
+
this.getBucket(context).add(key, callback, {
|
126
|
+
orderIndex,
|
127
|
+
runOnce: true
|
128
|
+
});
|
129
|
+
}
|
130
|
+
return this;
|
131
|
+
}
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Adds a listener to a specified hook. The added hook stays in the bucket at specified index position even after
|
135
|
+
* adding another one with the same hook name.
|
136
|
+
*
|
137
|
+
* @param {string} key Hook/Event name.
|
138
|
+
* @param {Function|Function[]} callback Callback function.
|
139
|
+
* @param {object} [context=null] A Handsontable instance.
|
140
|
+
* @returns {Hooks} Instance of Hooks.
|
141
|
+
*
|
142
|
+
* @example
|
143
|
+
* ```js
|
144
|
+
* Handsontable.hooks.addAsFixed('beforeInit', myCallback, hotInstance);
|
145
|
+
* ```
|
146
|
+
*/
|
147
|
+
addAsFixed(key, callback) {
|
148
|
+
let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
149
|
+
if (Array.isArray(callback)) {
|
150
|
+
arrayEach(callback, c => this.addAsFixed(key, c, context));
|
151
|
+
} else {
|
152
|
+
this.getBucket(context).add(key, callback, {
|
153
|
+
initialHook: true
|
154
|
+
});
|
155
|
+
}
|
156
|
+
return this;
|
157
|
+
}
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Removes a listener from a hook with a given name. If the `context` argument is provided, it removes a listener from a local hook assigned to the given Handsontable instance.
|
161
|
+
*
|
162
|
+
* @param {string} key Hook/Event name.
|
163
|
+
* @param {Function} callback Callback function (needs the be the function that was previously added to the hook).
|
164
|
+
* @param {object} [context=null] Handsontable instance.
|
165
|
+
* @returns {boolean} Returns `true` if hook was removed, `false` otherwise.
|
166
|
+
*
|
167
|
+
* @example
|
168
|
+
* ```js
|
169
|
+
* Handsontable.hooks.remove('beforeInit', myCallback);
|
170
|
+
* ```
|
171
|
+
*/
|
172
|
+
remove(key, callback) {
|
173
|
+
let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
174
|
+
return this.getBucket(context).remove(key, callback);
|
175
|
+
}
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Checks whether there are any registered listeners for the provided hook name.
|
179
|
+
* If the `context` parameter is provided, it only checks for listeners assigned to the given Handsontable instance.
|
180
|
+
*
|
181
|
+
* @param {string} key Hook name.
|
182
|
+
* @param {object} [context=null] A Handsontable instance.
|
183
|
+
* @returns {boolean} `true` for success, `false` otherwise.
|
184
|
+
*/
|
185
|
+
has(key) {
|
186
|
+
let context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
187
|
+
return this.getBucket(context).has(key);
|
188
|
+
}
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Runs all local and global callbacks assigned to the hook identified by the `key` parameter.
|
192
|
+
* It returns either a return value from the last called callback or the first parameter (`p1`) passed to the `run` function.
|
193
|
+
*
|
194
|
+
* @param {object} context Handsontable instance.
|
195
|
+
* @param {string} key Hook/Event name.
|
196
|
+
* @param {*} [p1] Parameter to be passed as an argument to the callback function.
|
197
|
+
* @param {*} [p2] Parameter to be passed as an argument to the callback function.
|
198
|
+
* @param {*} [p3] Parameter to be passed as an argument to the callback function.
|
199
|
+
* @param {*} [p4] Parameter to be passed as an argument to the callback function.
|
200
|
+
* @param {*} [p5] Parameter to be passed as an argument to the callback function.
|
201
|
+
* @param {*} [p6] Parameter to be passed as an argument to the callback function.
|
202
|
+
* @returns {*} Either a return value from the last called callback or `p1`.
|
203
|
+
*
|
204
|
+
* @example
|
205
|
+
* ```js
|
206
|
+
* Handsontable.hooks.run(hot, 'beforeInit');
|
207
|
+
* ```
|
208
|
+
*/
|
209
|
+
run(context, key, p1, p2, p3, p4, p5, p6) {
|
210
|
+
{
|
211
|
+
const globalHandlers = this.getBucket().getHooks(key);
|
212
|
+
const length = globalHandlers ? globalHandlers.length : 0;
|
213
|
+
let index = 0;
|
214
|
+
if (length) {
|
215
|
+
// Do not optimize this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
|
216
|
+
while (index < length) {
|
217
|
+
if (!globalHandlers[index] || globalHandlers[index].skip) {
|
218
|
+
index += 1;
|
219
|
+
/* eslint-disable no-continue */
|
220
|
+
continue;
|
221
|
+
}
|
222
|
+
const res = fastCall(globalHandlers[index].callback, context, p1, p2, p3, p4, p5, p6);
|
223
|
+
if (res !== undefined) {
|
224
|
+
// eslint-disable-next-line no-param-reassign
|
225
|
+
p1 = res;
|
226
|
+
}
|
227
|
+
if (globalHandlers[index] && globalHandlers[index].runOnce) {
|
228
|
+
this.remove(key, globalHandlers[index].callback);
|
229
|
+
}
|
230
|
+
index += 1;
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
{
|
235
|
+
const localHandlers = this.getBucket(context).getHooks(key);
|
236
|
+
const length = localHandlers ? localHandlers.length : 0;
|
237
|
+
let index = 0;
|
238
|
+
if (length) {
|
239
|
+
// Do not optimize this loop with arrayEach or arrow function! If you do You'll decrease perf because of GC.
|
240
|
+
while (index < length) {
|
241
|
+
if (!localHandlers[index] || localHandlers[index].skip) {
|
242
|
+
index += 1;
|
243
|
+
/* eslint-disable no-continue */
|
244
|
+
continue;
|
245
|
+
}
|
246
|
+
const res = fastCall(localHandlers[index].callback, context, p1, p2, p3, p4, p5, p6);
|
247
|
+
if (res !== undefined) {
|
248
|
+
// eslint-disable-next-line no-param-reassign
|
249
|
+
p1 = res;
|
250
|
+
}
|
251
|
+
if (localHandlers[index] && localHandlers[index].runOnce) {
|
252
|
+
this.remove(key, localHandlers[index].callback, context);
|
253
|
+
}
|
254
|
+
index += 1;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
}
|
258
|
+
return p1;
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* Destroy all listeners connected to the context. If no context is provided, the global listeners will be destroyed.
|
263
|
+
*
|
264
|
+
* @param {object} [context=null] A Handsontable instance.
|
265
|
+
* @example
|
266
|
+
* ```js
|
267
|
+
* // destroy the global listeners
|
268
|
+
* Handsontable.hooks.destroy();
|
269
|
+
*
|
270
|
+
* // destroy the local listeners
|
271
|
+
* Handsontable.hooks.destroy(hotInstance);
|
272
|
+
* ```
|
273
|
+
*/
|
274
|
+
destroy() {
|
275
|
+
let context = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
276
|
+
this.getBucket(context).destroy();
|
277
|
+
}
|
278
|
+
|
279
|
+
/**
|
280
|
+
* Registers a hook name (adds it to the list of the known hook names). Used by plugins.
|
281
|
+
* It is not necessary to call register, but if you use it, your plugin hook will be used returned by
|
282
|
+
* the `getRegistered` method. (which itself is used in the [demo](@/guides/getting-started/events-and-hooks/events-and-hooks.md)).
|
283
|
+
*
|
284
|
+
* @param {string} key The hook name.
|
285
|
+
*
|
286
|
+
* @example
|
287
|
+
* ```js
|
288
|
+
* Handsontable.hooks.register('myHook');
|
289
|
+
* ```
|
290
|
+
*/
|
291
|
+
register(key) {
|
292
|
+
if (!this.isRegistered(key)) {
|
293
|
+
REGISTERED_HOOKS.push(key);
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
/**
|
298
|
+
* Deregisters a hook name (removes it from the list of known hook names).
|
299
|
+
*
|
300
|
+
* @param {string} key The hook name.
|
301
|
+
*
|
302
|
+
* @example
|
303
|
+
* ```js
|
304
|
+
* Handsontable.hooks.deregister('myHook');
|
305
|
+
* ```
|
306
|
+
*/
|
307
|
+
deregister(key) {
|
308
|
+
if (this.isRegistered(key)) {
|
309
|
+
REGISTERED_HOOKS.splice(REGISTERED_HOOKS.indexOf(key), 1);
|
310
|
+
}
|
311
|
+
}
|
312
|
+
|
313
|
+
/**
|
314
|
+
* Returns a boolean value depending on if a hook by such name has been removed or deprecated.
|
315
|
+
*
|
316
|
+
* @param {string} hookName The hook name to check.
|
317
|
+
* @returns {boolean} Returns `true` if the provided hook name was marked as deprecated or
|
318
|
+
* removed from API, `false` otherwise.
|
319
|
+
* @example
|
320
|
+
* ```js
|
321
|
+
* Handsontable.hooks.isDeprecated('skipLengthCache');
|
322
|
+
*
|
323
|
+
* // Results:
|
324
|
+
* true
|
325
|
+
* ```
|
326
|
+
*/
|
327
|
+
isDeprecated(hookName) {
|
328
|
+
return DEPRECATED_HOOKS.has(hookName) || REMOVED_HOOKS.has(hookName);
|
329
|
+
}
|
330
|
+
|
331
|
+
/**
|
332
|
+
* Returns a boolean depending on if a hook by such name has been registered.
|
333
|
+
*
|
334
|
+
* @param {string} hookName The hook name to check.
|
335
|
+
* @returns {boolean} `true` for success, `false` otherwise.
|
336
|
+
* @example
|
337
|
+
* ```js
|
338
|
+
* Handsontable.hooks.isRegistered('beforeInit');
|
339
|
+
*
|
340
|
+
* // Results:
|
341
|
+
* true
|
342
|
+
* ```
|
343
|
+
*/
|
344
|
+
isRegistered(hookName) {
|
345
|
+
return REGISTERED_HOOKS.indexOf(hookName) >= 0;
|
346
|
+
}
|
347
|
+
|
348
|
+
/**
|
349
|
+
* Returns an array of registered hooks.
|
350
|
+
*
|
351
|
+
* @returns {Array} An array of registered hooks.
|
352
|
+
*
|
353
|
+
* @example
|
354
|
+
* ```js
|
355
|
+
* Handsontable.hooks.getRegistered();
|
356
|
+
*
|
357
|
+
* // Results:
|
358
|
+
* [
|
359
|
+
* ...
|
360
|
+
* 'beforeInit',
|
361
|
+
* 'beforeRender',
|
362
|
+
* 'beforeSetRangeEnd',
|
363
|
+
* 'beforeDrawBorders',
|
364
|
+
* 'beforeChange',
|
365
|
+
* ...
|
366
|
+
* ]
|
367
|
+
* ```
|
368
|
+
*/
|
369
|
+
getRegistered() {
|
370
|
+
return REGISTERED_HOOKS;
|
371
|
+
}
|
372
|
+
}
|
373
|
+
const globalSingleton = new Hooks();
|
374
|
+
|
375
|
+
/**
|
376
|
+
* @returns {Hooks}
|
377
|
+
*/
|
378
|
+
function getGlobalSingleton() {
|
379
|
+
return globalSingleton;
|
380
|
+
}
|
381
|
+
export default Hooks;
|
package/core/index.js
CHANGED
package/core.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { IndexMapper } from './translations';
|
2
|
-
import { Events } from './
|
2
|
+
import { Events } from './core/hooks';
|
3
3
|
import {
|
4
4
|
CellValue,
|
5
5
|
RowObject,
|
@@ -69,10 +69,11 @@ export default class Core {
|
|
69
69
|
getColHeader(): Array<number | string>;
|
70
70
|
getColHeader(column: number, headerLevel?: number): number | string;
|
71
71
|
getColumnMeta(column: number): ColumnSettings;
|
72
|
-
getColWidth(column: number): number;
|
72
|
+
getColWidth(column: number, source?: string): number;
|
73
73
|
getCoords(element: Element | null): CellCoords;
|
74
74
|
getCopyableData(row: number, column: number): string;
|
75
75
|
getCopyableText(startRow: number, startColumn: number, endRow: number, endColumn: number): string;
|
76
|
+
getCurrentThemeName(): string | undefined;
|
76
77
|
getData(row?: number, column?: number, row2?: number, column2?: number): CellValue[];
|
77
78
|
getDataAtCell(row: number, column: number): CellValue;
|
78
79
|
getDataAtCol(column: number): CellValue[];
|
@@ -99,7 +100,7 @@ export default class Core {
|
|
99
100
|
getPlugin(pluginName: string): Plugins['basePlugin'];
|
100
101
|
getRowHeader(): Array<string | number>;
|
101
102
|
getRowHeader(row: number): string | number;
|
102
|
-
getRowHeight(row: number): number;
|
103
|
+
getRowHeight(row: number, source?: string): number;
|
103
104
|
getSchema(): RowObject;
|
104
105
|
getSelected(): Array<[number, number, number, number]> | undefined;
|
105
106
|
getSelectedLast(): number[] | undefined;
|
@@ -179,6 +180,7 @@ export default class Core {
|
|
179
180
|
unlisten(): void;
|
180
181
|
updateData(data: CellValue[][] | RowObject[], source?: string): void;
|
181
182
|
updateSettings(settings: GridSettings, init?: boolean): void;
|
183
|
+
useTheme(themeName: string|boolean|undefined): void;
|
182
184
|
validateCell(value: any, cellProperties: CellProperties, callback: (valid: boolean) => void, source: string): void;
|
183
185
|
validateCells(callback?: (valid: boolean) => void): void;
|
184
186
|
validateColumns(columns: number[], callback?: (valid: boolean) => void): void;
|
package/core.js
CHANGED
@@ -11,6 +11,10 @@ require("core-js/modules/es.set.is-subset-of.v2.js");
|
|
11
11
|
require("core-js/modules/es.set.is-superset-of.v2.js");
|
12
12
|
require("core-js/modules/es.set.symmetric-difference.v2.js");
|
13
13
|
require("core-js/modules/es.set.union.v2.js");
|
14
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
15
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
16
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
17
|
+
require("core-js/modules/esnext.iterator.map.js");
|
14
18
|
require("core-js/modules/web.immediate.js");
|
15
19
|
var _element = require("./helpers/dom/element");
|
16
20
|
var _function = require("./helpers/function");
|
@@ -34,7 +38,7 @@ var _data = require("./helpers/data");
|
|
34
38
|
var _translations = require("./translations");
|
35
39
|
var _rootInstance = require("./utils/rootInstance");
|
36
40
|
var _src = require("./3rdparty/walkontable/src");
|
37
|
-
var
|
41
|
+
var _hooks = require("./core/hooks");
|
38
42
|
var _registry5 = require("./i18n/registry");
|
39
43
|
var _utils = require("./i18n/utils");
|
40
44
|
var _selection = require("./selection");
|
@@ -43,6 +47,7 @@ var _index3 = require("./core/index");
|
|
43
47
|
var _uniqueMap = require("./utils/dataStructures/uniqueMap");
|
44
48
|
var _shortcuts = require("./shortcuts");
|
45
49
|
var _shortcutContexts = require("./shortcutContexts");
|
50
|
+
var _themes = require("./helpers/themes");
|
46
51
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
47
52
|
let activeGuid = null;
|
48
53
|
|
@@ -230,6 +235,7 @@ function Core(rootElement, userSettings) {
|
|
230
235
|
rootElement.insertBefore(this.container, rootElement.firstChild);
|
231
236
|
if ((0, _rootInstance.isRootInstance)(this)) {
|
232
237
|
(0, _mixed._injectProductInfo)(userSettings.licenseKey, rootElement);
|
238
|
+
(0, _element.addClass)(rootElement, 'ht-wrapper');
|
233
239
|
}
|
234
240
|
this.guid = `ht_${(0, _string.randomString)()}`; // this is the namespace for global events
|
235
241
|
|
@@ -942,7 +948,9 @@ function Core(rootElement, userSettings) {
|
|
942
948
|
// when 'value' is array and 'orgValue' is null, set 'orgValue' to
|
943
949
|
// an empty array so that the null value can be compared to 'value'
|
944
950
|
// as an empty value for the array context
|
945
|
-
if (Array.isArray(value) && orgValue === null)
|
951
|
+
if (Array.isArray(value) && orgValue === null) {
|
952
|
+
orgValue = [];
|
953
|
+
}
|
946
954
|
if (orgValue === null || typeof orgValue !== 'object') {
|
947
955
|
pushData = false;
|
948
956
|
} else {
|
@@ -1030,6 +1038,13 @@ function Core(rootElement, userSettings) {
|
|
1030
1038
|
}
|
1031
1039
|
this.updateSettings(tableMeta, true);
|
1032
1040
|
this.view = new _tableView.default(this);
|
1041
|
+
const themeName = tableMeta.themeName || (0, _themes.getThemeClassName)(instance.rootElement);
|
1042
|
+
|
1043
|
+
// Use the theme defined as a root element class or in the settings (in that order).
|
1044
|
+
instance.useTheme(themeName);
|
1045
|
+
|
1046
|
+
// Add the theme class name to the license info element.
|
1047
|
+
instance.view.addClassNameToLicenseElement(instance.getCurrentThemeName());
|
1033
1048
|
editorManager = _editorManager.default.getInstance(instance, tableMeta, selection);
|
1034
1049
|
viewportScroller = (0, _index3.createViewportScroller)(instance);
|
1035
1050
|
focusManager = new _focusManager.FocusManager(instance);
|
@@ -1407,7 +1422,7 @@ function Core(rootElement, userSettings) {
|
|
1407
1422
|
if (!changeSource && typeof row === 'object') {
|
1408
1423
|
changeSource = column;
|
1409
1424
|
}
|
1410
|
-
const processedChanges = processChanges(changes,
|
1425
|
+
const processedChanges = processChanges(changes, changeSource);
|
1411
1426
|
instance.runHooks('afterSetDataAtCell', processedChanges, changeSource);
|
1412
1427
|
validateChanges(processedChanges, changeSource, () => {
|
1413
1428
|
applyChanges(processedChanges, changeSource);
|
@@ -2293,10 +2308,11 @@ function Core(rootElement, userSettings) {
|
|
2293
2308
|
} else if (i === 'tableClassName' && instance.table) {
|
2294
2309
|
setClassName('tableClassName', settings.tableClassName);
|
2295
2310
|
instance.view._wt.wtOverlays.syncOverlayTableClassNames();
|
2296
|
-
} else if (
|
2297
|
-
if ((0, _function.isFunction)(settings[i])
|
2298
|
-
settings[i]
|
2299
|
-
|
2311
|
+
} else if (_hooks.Hooks.getSingleton().isRegistered(i) || _hooks.Hooks.getSingleton().isDeprecated(i)) {
|
2312
|
+
if ((0, _function.isFunction)(settings[i])) {
|
2313
|
+
_hooks.Hooks.getSingleton().addAsFixed(i, settings[i], instance);
|
2314
|
+
} else if (Array.isArray(settings[i])) {
|
2315
|
+
_hooks.Hooks.getSingleton().add(i, settings[i], instance);
|
2300
2316
|
}
|
2301
2317
|
} else if (!init && (0, _object.hasOwnProperty)(settings, i)) {
|
2302
2318
|
// Update settings
|
@@ -2382,6 +2398,19 @@ function Core(rootElement, userSettings) {
|
|
2382
2398
|
if (instance.view) {
|
2383
2399
|
instance.view._wt.wtViewport.resetHasOversizedColumnHeadersMarked();
|
2384
2400
|
instance.view._wt.exportSettingsAsClassNames();
|
2401
|
+
const currentThemeName = instance.getCurrentThemeName();
|
2402
|
+
const themeNameOptionExists = (0, _object.hasOwnProperty)(settings, 'themeName');
|
2403
|
+
if (currentThemeName && themeNameOptionExists) {
|
2404
|
+
instance.view.getStylesHandler().removeClassNames();
|
2405
|
+
instance.view.removeClassNameFromLicenseElement(currentThemeName);
|
2406
|
+
}
|
2407
|
+
const themeName = themeNameOptionExists && settings.themeName || (0, _themes.getThemeClassName)(instance.rootElement);
|
2408
|
+
|
2409
|
+
// Use the theme defined as a root element class or in the settings (in that order).
|
2410
|
+
instance.useTheme(themeName);
|
2411
|
+
|
2412
|
+
// Add the theme class name to the license info element.
|
2413
|
+
instance.view.addClassNameToLicenseElement(instance.getCurrentThemeName());
|
2385
2414
|
}
|
2386
2415
|
instance.runHooks('afterUpdateSettings', settings);
|
2387
2416
|
}
|
@@ -3493,12 +3522,13 @@ function Core(rootElement, userSettings) {
|
|
3493
3522
|
* @memberof Core#
|
3494
3523
|
* @function getColWidth
|
3495
3524
|
* @param {number} column Visual column index.
|
3525
|
+
* @param {string} [source] The source of the call.
|
3496
3526
|
* @returns {number} Column width.
|
3497
3527
|
* @fires Hooks#modifyColWidth
|
3498
3528
|
*/
|
3499
|
-
this.getColWidth = function (column) {
|
3529
|
+
this.getColWidth = function (column, source) {
|
3500
3530
|
let width = instance._getColWidthFromSettings(column);
|
3501
|
-
width = instance.runHooks('modifyColWidth', width, column);
|
3531
|
+
width = instance.runHooks('modifyColWidth', width, column, source);
|
3502
3532
|
if (width === undefined) {
|
3503
3533
|
width = _src.DEFAULT_COLUMN_WIDTH;
|
3504
3534
|
}
|
@@ -3558,12 +3588,13 @@ function Core(rootElement, userSettings) {
|
|
3558
3588
|
* @memberof Core#
|
3559
3589
|
* @function getRowHeight
|
3560
3590
|
* @param {number} row A visual row index.
|
3591
|
+
* @param {string} [source] The source of the call.
|
3561
3592
|
* @returns {number|undefined} The height of the specified row, in pixels.
|
3562
3593
|
* @fires Hooks#modifyRowHeight
|
3563
3594
|
*/
|
3564
|
-
this.getRowHeight = function (row) {
|
3595
|
+
this.getRowHeight = function (row, source) {
|
3565
3596
|
let height = instance._getRowHeightFromSettings(row);
|
3566
|
-
height = instance.runHooks('modifyRowHeight', height, row);
|
3597
|
+
height = instance.runHooks('modifyRowHeight', height, row, source);
|
3567
3598
|
return height;
|
3568
3599
|
};
|
3569
3600
|
|
@@ -4076,22 +4107,8 @@ function Core(rootElement, userSettings) {
|
|
4076
4107
|
const {
|
4077
4108
|
row,
|
4078
4109
|
col,
|
4079
|
-
verticalSnap,
|
4080
|
-
horizontalSnap,
|
4081
4110
|
considerHiddenIndexes
|
4082
4111
|
} = (_options = options) !== null && _options !== void 0 ? _options : {};
|
4083
|
-
let snapToTop;
|
4084
|
-
let snapToBottom;
|
4085
|
-
let snapToInlineStart;
|
4086
|
-
let snapToInlineEnd;
|
4087
|
-
if (verticalSnap !== undefined) {
|
4088
|
-
snapToTop = verticalSnap === 'top';
|
4089
|
-
snapToBottom = !snapToTop;
|
4090
|
-
}
|
4091
|
-
if (horizontalSnap !== undefined) {
|
4092
|
-
snapToInlineStart = horizontalSnap === 'start';
|
4093
|
-
snapToInlineEnd = !snapToInlineStart;
|
4094
|
-
}
|
4095
4112
|
let renderableRow = row;
|
4096
4113
|
let renderableColumn = col;
|
4097
4114
|
if (considerHiddenIndexes === undefined || considerHiddenIndexes) {
|
@@ -4108,13 +4125,13 @@ function Core(rootElement, userSettings) {
|
|
4108
4125
|
const isRowInteger = Number.isInteger(renderableRow);
|
4109
4126
|
const isColumnInteger = Number.isInteger(renderableColumn);
|
4110
4127
|
if (isRowInteger && renderableRow >= 0 && isColumnInteger && renderableColumn >= 0) {
|
4111
|
-
return instance.view.scrollViewport(instance._createCellCoords(renderableRow, renderableColumn),
|
4128
|
+
return instance.view.scrollViewport(instance._createCellCoords(renderableRow, renderableColumn), options.horizontalSnap, options.verticalSnap);
|
4112
4129
|
}
|
4113
4130
|
if (isRowInteger && renderableRow >= 0 && (isColumnInteger && renderableColumn < 0 || !isColumnInteger)) {
|
4114
|
-
return instance.view.scrollViewportVertically(renderableRow,
|
4131
|
+
return instance.view.scrollViewportVertically(renderableRow, options.verticalSnap);
|
4115
4132
|
}
|
4116
4133
|
if (isColumnInteger && renderableColumn >= 0 && (isRowInteger && renderableRow < 0 || !isRowInteger)) {
|
4117
|
-
return instance.view.scrollViewportHorizontally(renderableColumn,
|
4134
|
+
return instance.view.scrollViewportHorizontally(renderableColumn, options.horizontalSnap);
|
4118
4135
|
}
|
4119
4136
|
return false;
|
4120
4137
|
};
|
@@ -4191,7 +4208,7 @@ function Core(rootElement, userSettings) {
|
|
4191
4208
|
pluginsRegistry.clear();
|
4192
4209
|
instance.runHooks('afterDestroy');
|
4193
4210
|
}, true);
|
4194
|
-
|
4211
|
+
_hooks.Hooks.getSingleton().destroy(instance);
|
4195
4212
|
(0, _object.objectEach)(instance, (property, key, obj) => {
|
4196
4213
|
// replace instance methods with post mortem
|
4197
4214
|
if ((0, _function.isFunction)(property)) {
|
@@ -4455,7 +4472,7 @@ function Core(rootElement, userSettings) {
|
|
4455
4472
|
* ```
|
4456
4473
|
*/
|
4457
4474
|
this.addHook = function (key, callback, orderIndex) {
|
4458
|
-
|
4475
|
+
_hooks.Hooks.getSingleton().add(key, callback, instance, orderIndex);
|
4459
4476
|
};
|
4460
4477
|
|
4461
4478
|
/**
|
@@ -4474,7 +4491,7 @@ function Core(rootElement, userSettings) {
|
|
4474
4491
|
* ```
|
4475
4492
|
*/
|
4476
4493
|
this.hasHook = function (key) {
|
4477
|
-
return
|
4494
|
+
return _hooks.Hooks.getSingleton().has(key, instance) || _hooks.Hooks.getSingleton().has(key);
|
4478
4495
|
};
|
4479
4496
|
|
4480
4497
|
/**
|
@@ -4496,7 +4513,7 @@ function Core(rootElement, userSettings) {
|
|
4496
4513
|
* ```
|
4497
4514
|
*/
|
4498
4515
|
this.addHookOnce = function (key, callback, orderIndex) {
|
4499
|
-
|
4516
|
+
_hooks.Hooks.getSingleton().once(key, callback, instance, orderIndex);
|
4500
4517
|
};
|
4501
4518
|
|
4502
4519
|
/**
|
@@ -4514,7 +4531,7 @@ function Core(rootElement, userSettings) {
|
|
4514
4531
|
* ```
|
4515
4532
|
*/
|
4516
4533
|
this.removeHook = function (key, callback) {
|
4517
|
-
|
4534
|
+
_hooks.Hooks.getSingleton().remove(key, callback, instance);
|
4518
4535
|
};
|
4519
4536
|
|
4520
4537
|
/**
|
@@ -4541,7 +4558,7 @@ function Core(rootElement, userSettings) {
|
|
4541
4558
|
* ```
|
4542
4559
|
*/
|
4543
4560
|
this.runHooks = function (key, p1, p2, p3, p4, p5, p6) {
|
4544
|
-
return
|
4561
|
+
return _hooks.Hooks.getSingleton().run(instance, key, p1, p2, p3, p4, p5, p6);
|
4545
4562
|
};
|
4546
4563
|
|
4547
4564
|
/**
|
@@ -4583,6 +4600,31 @@ function Core(rootElement, userSettings) {
|
|
4583
4600
|
};
|
4584
4601
|
this.timeouts = [];
|
4585
4602
|
|
4603
|
+
/**
|
4604
|
+
* Use the theme specified by the provided name.
|
4605
|
+
*
|
4606
|
+
* @memberof Core#
|
4607
|
+
* @function useTheme
|
4608
|
+
* @since 15.0.0
|
4609
|
+
* @param {string|boolean|undefined} themeName The name of the theme to use.
|
4610
|
+
*/
|
4611
|
+
this.useTheme = themeName => {
|
4612
|
+
this.view.getStylesHandler().useTheme(themeName);
|
4613
|
+
this.runHooks('afterSetTheme', themeName, !!firstRun);
|
4614
|
+
};
|
4615
|
+
|
4616
|
+
/**
|
4617
|
+
* Gets the name of the currently used theme.
|
4618
|
+
*
|
4619
|
+
* @memberof Core#
|
4620
|
+
* @function getCurrentThemeName
|
4621
|
+
* @since 15.0.0
|
4622
|
+
* @returns {string|undefined} The name of the currently used theme.
|
4623
|
+
*/
|
4624
|
+
this.getCurrentThemeName = () => {
|
4625
|
+
return this.view.getStylesHandler().getThemeName();
|
4626
|
+
};
|
4627
|
+
|
4586
4628
|
/**
|
4587
4629
|
* Sets timeout. Purpose of this method is to clear all known timeouts when `destroy` method is called.
|
4588
4630
|
*
|
@@ -4731,5 +4773,5 @@ function Core(rootElement, userSettings) {
|
|
4731
4773
|
});
|
4732
4774
|
(0, _shortcutContexts.registerAllShortcutContexts)(instance);
|
4733
4775
|
shortcutManager.setActiveContextName('grid');
|
4734
|
-
|
4776
|
+
_hooks.Hooks.getSingleton().run(instance, 'construct');
|
4735
4777
|
}
|