handsontable 0.0.0-next-9ec04ce-20221121
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.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/SheetClip/SheetClip.js +128 -0
- package/3rdparty/SheetClip/SheetClip.mjs +123 -0
- package/3rdparty/SheetClip/index.js +7 -0
- package/3rdparty/SheetClip/index.mjs +1 -0
- package/3rdparty/autoResize/autoResize.js +164 -0
- package/3rdparty/autoResize/autoResize.mjs +160 -0
- package/3rdparty/autoResize/index.js +6 -0
- package/3rdparty/autoResize/index.mjs +1 -0
- package/3rdparty/walkontable/src/border.js +746 -0
- package/3rdparty/walkontable/src/border.mjs +741 -0
- package/3rdparty/walkontable/src/calculator/constants.js +30 -0
- package/3rdparty/walkontable/src/calculator/constants.mjs +23 -0
- package/3rdparty/walkontable/src/calculator/index.js +22 -0
- package/3rdparty/walkontable/src/calculator/index.mjs +4 -0
- package/3rdparty/walkontable/src/calculator/viewportColumns.d.ts +18 -0
- package/3rdparty/walkontable/src/calculator/viewportColumns.js +297 -0
- package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +292 -0
- package/3rdparty/walkontable/src/calculator/viewportRows.js +175 -0
- package/3rdparty/walkontable/src/calculator/viewportRows.mjs +170 -0
- package/3rdparty/walkontable/src/cell/coords.d.ts +16 -0
- package/3rdparty/walkontable/src/cell/coords.js +185 -0
- package/3rdparty/walkontable/src/cell/coords.mjs +180 -0
- package/3rdparty/walkontable/src/cell/range.d.ts +59 -0
- package/3rdparty/walkontable/src/cell/range.js +888 -0
- package/3rdparty/walkontable/src/cell/range.mjs +882 -0
- package/3rdparty/walkontable/src/core/_base.js +395 -0
- package/3rdparty/walkontable/src/core/_base.mjs +390 -0
- package/3rdparty/walkontable/src/core/clone.js +59 -0
- package/3rdparty/walkontable/src/core/clone.mjs +54 -0
- package/3rdparty/walkontable/src/core/core.js +130 -0
- package/3rdparty/walkontable/src/core/core.mjs +125 -0
- package/3rdparty/walkontable/src/event.js +401 -0
- package/3rdparty/walkontable/src/event.mjs +396 -0
- package/3rdparty/walkontable/src/facade/core.js +236 -0
- package/3rdparty/walkontable/src/facade/core.mjs +231 -0
- package/3rdparty/walkontable/src/filter/column.js +107 -0
- package/3rdparty/walkontable/src/filter/column.mjs +102 -0
- package/3rdparty/walkontable/src/filter/row.js +107 -0
- package/3rdparty/walkontable/src/filter/row.mjs +102 -0
- package/3rdparty/walkontable/src/index.d.ts +1 -0
- package/3rdparty/walkontable/src/index.js +37 -0
- package/3rdparty/walkontable/src/index.mjs +10 -0
- package/3rdparty/walkontable/src/overlay/_base.js +363 -0
- package/3rdparty/walkontable/src/overlay/_base.mjs +357 -0
- package/3rdparty/walkontable/src/overlay/bottom.js +397 -0
- package/3rdparty/walkontable/src/overlay/bottom.mjs +391 -0
- package/3rdparty/walkontable/src/overlay/bottomInlineStartCorner.js +140 -0
- package/3rdparty/walkontable/src/overlay/bottomInlineStartCorner.mjs +134 -0
- package/3rdparty/walkontable/src/overlay/constants.js +26 -0
- package/3rdparty/walkontable/src/overlay/constants.mjs +15 -0
- package/3rdparty/walkontable/src/overlay/index.js +34 -0
- package/3rdparty/walkontable/src/overlay/index.mjs +7 -0
- package/3rdparty/walkontable/src/overlay/inlineStart.js +385 -0
- package/3rdparty/walkontable/src/overlay/inlineStart.mjs +379 -0
- package/3rdparty/walkontable/src/overlay/top.js +415 -0
- package/3rdparty/walkontable/src/overlay/top.mjs +409 -0
- package/3rdparty/walkontable/src/overlay/topInlineStartCorner.js +130 -0
- package/3rdparty/walkontable/src/overlay/topInlineStartCorner.mjs +124 -0
- package/3rdparty/walkontable/src/overlays.js +675 -0
- package/3rdparty/walkontable/src/overlays.mjs +670 -0
- package/3rdparty/walkontable/src/renderer/_base.js +83 -0
- package/3rdparty/walkontable/src/renderer/_base.mjs +78 -0
- package/3rdparty/walkontable/src/renderer/cells.js +127 -0
- package/3rdparty/walkontable/src/renderer/cells.mjs +122 -0
- package/3rdparty/walkontable/src/renderer/colGroup.js +101 -0
- package/3rdparty/walkontable/src/renderer/colGroup.mjs +96 -0
- package/3rdparty/walkontable/src/renderer/columnHeaders.js +115 -0
- package/3rdparty/walkontable/src/renderer/columnHeaders.mjs +110 -0
- package/3rdparty/walkontable/src/renderer/index.js +118 -0
- package/3rdparty/walkontable/src/renderer/index.mjs +107 -0
- package/3rdparty/walkontable/src/renderer/rowHeaders.js +119 -0
- package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +114 -0
- package/3rdparty/walkontable/src/renderer/rows.js +99 -0
- package/3rdparty/walkontable/src/renderer/rows.mjs +94 -0
- package/3rdparty/walkontable/src/renderer/table.js +317 -0
- package/3rdparty/walkontable/src/renderer/table.mjs +313 -0
- package/3rdparty/walkontable/src/scroll.js +316 -0
- package/3rdparty/walkontable/src/scroll.mjs +311 -0
- package/3rdparty/walkontable/src/selection.js +349 -0
- package/3rdparty/walkontable/src/selection.mjs +343 -0
- package/3rdparty/walkontable/src/settings.js +306 -0
- package/3rdparty/walkontable/src/settings.mjs +302 -0
- package/3rdparty/walkontable/src/table/bottom.js +56 -0
- package/3rdparty/walkontable/src/table/bottom.mjs +50 -0
- package/3rdparty/walkontable/src/table/bottomInlineStartCorner.js +57 -0
- package/3rdparty/walkontable/src/table/bottomInlineStartCorner.mjs +51 -0
- package/3rdparty/walkontable/src/table/inlineStart.js +53 -0
- package/3rdparty/walkontable/src/table/inlineStart.mjs +47 -0
- package/3rdparty/walkontable/src/table/master.js +132 -0
- package/3rdparty/walkontable/src/table/master.mjs +126 -0
- package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +93 -0
- package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +88 -0
- package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +93 -0
- package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +88 -0
- package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +85 -0
- package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +80 -0
- package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +90 -0
- package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +85 -0
- package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +85 -0
- package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +80 -0
- package/3rdparty/walkontable/src/table/top.js +56 -0
- package/3rdparty/walkontable/src/table/top.mjs +50 -0
- package/3rdparty/walkontable/src/table/topInlineStartCorner.js +57 -0
- package/3rdparty/walkontable/src/table/topInlineStartCorner.mjs +51 -0
- package/3rdparty/walkontable/src/table.js +1171 -0
- package/3rdparty/walkontable/src/table.mjs +1165 -0
- package/3rdparty/walkontable/src/types.js +98 -0
- package/3rdparty/walkontable/src/types.mjs +97 -0
- package/3rdparty/walkontable/src/utils/column.js +121 -0
- package/3rdparty/walkontable/src/utils/column.mjs +117 -0
- package/3rdparty/walkontable/src/utils/nodesPool.js +48 -0
- package/3rdparty/walkontable/src/utils/nodesPool.mjs +44 -0
- package/3rdparty/walkontable/src/utils/orderView/constants.js +30 -0
- package/3rdparty/walkontable/src/utils/orderView/constants.mjs +23 -0
- package/3rdparty/walkontable/src/utils/orderView/index.js +8 -0
- package/3rdparty/walkontable/src/utils/orderView/index.mjs +3 -0
- package/3rdparty/walkontable/src/utils/orderView/sharedView.js +81 -0
- package/3rdparty/walkontable/src/utils/orderView/sharedView.mjs +76 -0
- package/3rdparty/walkontable/src/utils/orderView/view.js +216 -0
- package/3rdparty/walkontable/src/utils/orderView/view.mjs +211 -0
- package/3rdparty/walkontable/src/utils/orderView/viewSize.js +68 -0
- package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +64 -0
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.js +137 -0
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.mjs +132 -0
- package/3rdparty/walkontable/src/utils/row.js +43 -0
- package/3rdparty/walkontable/src/utils/row.mjs +39 -0
- package/3rdparty/walkontable/src/viewport.js +491 -0
- package/3rdparty/walkontable/src/viewport.mjs +486 -0
- package/CHANGELOG.md +716 -0
- package/LICENSE.txt +25 -0
- package/README.md +140 -0
- package/base.d.ts +3 -0
- package/base.js +54 -0
- package/base.mjs +44 -0
- package/cellTypes/autocompleteType/autocompleteType.d.ts +17 -0
- package/cellTypes/autocompleteType/autocompleteType.js +16 -0
- package/cellTypes/autocompleteType/autocompleteType.mjs +10 -0
- package/cellTypes/autocompleteType/index.d.ts +1 -0
- package/cellTypes/autocompleteType/index.js +7 -0
- package/cellTypes/autocompleteType/index.mjs +1 -0
- package/cellTypes/base.d.ts +14 -0
- package/cellTypes/checkboxType/checkboxType.d.ts +14 -0
- package/cellTypes/checkboxType/checkboxType.js +14 -0
- package/cellTypes/checkboxType/checkboxType.mjs +8 -0
- package/cellTypes/checkboxType/index.d.ts +1 -0
- package/cellTypes/checkboxType/index.js +7 -0
- package/cellTypes/checkboxType/index.mjs +1 -0
- package/cellTypes/dateType/dateType.d.ts +17 -0
- package/cellTypes/dateType/dateType.js +17 -0
- package/cellTypes/dateType/dateType.mjs +11 -0
- package/cellTypes/dateType/index.d.ts +1 -0
- package/cellTypes/dateType/index.js +7 -0
- package/cellTypes/dateType/index.mjs +1 -0
- package/cellTypes/dropdownType/dropdownType.d.ts +17 -0
- package/cellTypes/dropdownType/dropdownType.js +17 -0
- package/cellTypes/dropdownType/dropdownType.mjs +11 -0
- package/cellTypes/dropdownType/index.d.ts +1 -0
- package/cellTypes/dropdownType/index.js +7 -0
- package/cellTypes/dropdownType/index.mjs +1 -0
- package/cellTypes/handsontableType/handsontableType.d.ts +14 -0
- package/cellTypes/handsontableType/handsontableType.js +15 -0
- package/cellTypes/handsontableType/handsontableType.mjs +9 -0
- package/cellTypes/handsontableType/index.d.ts +1 -0
- package/cellTypes/handsontableType/index.js +7 -0
- package/cellTypes/handsontableType/index.mjs +1 -0
- package/cellTypes/index.d.ts +47 -0
- package/cellTypes/index.js +52 -0
- package/cellTypes/index.mjs +26 -0
- package/cellTypes/numericType/index.d.ts +1 -0
- package/cellTypes/numericType/index.js +7 -0
- package/cellTypes/numericType/index.mjs +1 -0
- package/cellTypes/numericType/numericType.d.ts +17 -0
- package/cellTypes/numericType/numericType.js +17 -0
- package/cellTypes/numericType/numericType.mjs +11 -0
- package/cellTypes/passwordType/index.d.ts +1 -0
- package/cellTypes/passwordType/index.js +7 -0
- package/cellTypes/passwordType/index.mjs +1 -0
- package/cellTypes/passwordType/passwordType.d.ts +14 -0
- package/cellTypes/passwordType/passwordType.js +15 -0
- package/cellTypes/passwordType/passwordType.mjs +9 -0
- package/cellTypes/registry.d.ts +18 -0
- package/cellTypes/registry.js +60 -0
- package/cellTypes/registry.mjs +51 -0
- package/cellTypes/textType/index.d.ts +1 -0
- package/cellTypes/textType/index.js +7 -0
- package/cellTypes/textType/index.mjs +1 -0
- package/cellTypes/textType/textType.d.ts +14 -0
- package/cellTypes/textType/textType.js +14 -0
- package/cellTypes/textType/textType.mjs +8 -0
- package/cellTypes/timeType/index.d.ts +1 -0
- package/cellTypes/timeType/index.js +7 -0
- package/cellTypes/timeType/index.mjs +1 -0
- package/cellTypes/timeType/timeType.d.ts +17 -0
- package/cellTypes/timeType/timeType.js +16 -0
- package/cellTypes/timeType/timeType.mjs +10 -0
- package/common.d.ts +74 -0
- package/core.d.ts +167 -0
- package/core.js +4684 -0
- package/core.mjs +4679 -0
- package/dataMap/dataMap.js +975 -0
- package/dataMap/dataMap.mjs +970 -0
- package/dataMap/dataSource.js +325 -0
- package/dataMap/dataSource.mjs +320 -0
- package/dataMap/index.js +16 -0
- package/dataMap/index.mjs +7 -0
- package/dataMap/metaManager/index.js +339 -0
- package/dataMap/metaManager/index.mjs +334 -0
- package/dataMap/metaManager/lazyFactoryMap.js +370 -0
- package/dataMap/metaManager/lazyFactoryMap.mjs +366 -0
- package/dataMap/metaManager/metaLayers/cellMeta.js +275 -0
- package/dataMap/metaManager/metaLayers/cellMeta.mjs +270 -0
- package/dataMap/metaManager/metaLayers/columnMeta.js +153 -0
- package/dataMap/metaManager/metaLayers/columnMeta.mjs +148 -0
- package/dataMap/metaManager/metaLayers/globalMeta.js +103 -0
- package/dataMap/metaManager/metaLayers/globalMeta.mjs +98 -0
- package/dataMap/metaManager/metaLayers/tableMeta.js +73 -0
- package/dataMap/metaManager/metaLayers/tableMeta.mjs +69 -0
- package/dataMap/metaManager/metaSchema.js +4610 -0
- package/dataMap/metaManager/metaSchema.mjs +4605 -0
- package/dataMap/metaManager/mods/dynamicCellMeta.js +107 -0
- package/dataMap/metaManager/mods/dynamicCellMeta.mjs +101 -0
- package/dataMap/metaManager/mods/extendMetaProperties.js +104 -0
- package/dataMap/metaManager/mods/extendMetaProperties.mjs +99 -0
- package/dataMap/metaManager/utils.js +99 -0
- package/dataMap/metaManager/utils.mjs +91 -0
- package/dataMap/replaceData.js +119 -0
- package/dataMap/replaceData.mjs +115 -0
- package/dist/README.md +54 -0
- package/dist/handsontable.css +1941 -0
- package/dist/handsontable.full.css +2172 -0
- package/dist/handsontable.full.js +150392 -0
- package/dist/handsontable.full.min.css +47 -0
- package/dist/handsontable.full.min.js +869 -0
- package/dist/handsontable.js +94075 -0
- package/dist/handsontable.min.css +43 -0
- package/dist/handsontable.min.js +31 -0
- package/dist/languages/all.js +583 -0
- package/dist/languages/all.min.js +1 -0
- package/dist/languages/ar-AR.js +157 -0
- package/dist/languages/ar-AR.min.js +1 -0
- package/dist/languages/cs-CZ.js +157 -0
- package/dist/languages/cs-CZ.min.js +1 -0
- package/dist/languages/de-CH.js +158 -0
- package/dist/languages/de-CH.min.js +1 -0
- package/dist/languages/de-DE.js +159 -0
- package/dist/languages/de-DE.min.js +1 -0
- package/dist/languages/en-US.js +160 -0
- package/dist/languages/en-US.min.js +1 -0
- package/dist/languages/es-MX.js +161 -0
- package/dist/languages/es-MX.min.js +1 -0
- package/dist/languages/fr-FR.js +162 -0
- package/dist/languages/fr-FR.min.js +1 -0
- package/dist/languages/it-IT.js +164 -0
- package/dist/languages/it-IT.min.js +1 -0
- package/dist/languages/ja-JP.js +161 -0
- package/dist/languages/ja-JP.min.js +1 -0
- package/dist/languages/ko-KR.js +161 -0
- package/dist/languages/ko-KR.min.js +1 -0
- package/dist/languages/lv-LV.js +161 -0
- package/dist/languages/lv-LV.min.js +1 -0
- package/dist/languages/nb-NO.js +161 -0
- package/dist/languages/nb-NO.min.js +1 -0
- package/dist/languages/nl-NL.js +161 -0
- package/dist/languages/nl-NL.min.js +1 -0
- package/dist/languages/pl-PL.js +161 -0
- package/dist/languages/pl-PL.min.js +1 -0
- package/dist/languages/pt-BR.js +161 -0
- package/dist/languages/pt-BR.min.js +1 -0
- package/dist/languages/ru-RU.js +161 -0
- package/dist/languages/ru-RU.min.js +1 -0
- package/dist/languages/sr-SP.js +161 -0
- package/dist/languages/sr-SP.min.js +1 -0
- package/dist/languages/zh-CN.js +161 -0
- package/dist/languages/zh-CN.min.js +1 -0
- package/dist/languages/zh-TW.js +161 -0
- package/dist/languages/zh-TW.min.js +1 -0
- package/editorManager.js +522 -0
- package/editorManager.mjs +514 -0
- package/editors/autocompleteEditor/autocompleteEditor.d.ts +29 -0
- package/editors/autocompleteEditor/autocompleteEditor.js +584 -0
- package/editors/autocompleteEditor/autocompleteEditor.mjs +578 -0
- package/editors/autocompleteEditor/index.d.ts +1 -0
- package/editors/autocompleteEditor/index.js +7 -0
- package/editors/autocompleteEditor/index.mjs +1 -0
- package/editors/baseEditor/baseEditor.d.ts +45 -0
- package/editors/baseEditor/baseEditor.js +688 -0
- package/editors/baseEditor/baseEditor.mjs +679 -0
- package/editors/baseEditor/index.d.ts +1 -0
- package/editors/baseEditor/index.js +8 -0
- package/editors/baseEditor/index.mjs +1 -0
- package/editors/checkboxEditor/checkboxEditor.d.ts +12 -0
- package/editors/checkboxEditor/checkboxEditor.js +85 -0
- package/editors/checkboxEditor/checkboxEditor.mjs +79 -0
- package/editors/checkboxEditor/index.d.ts +1 -0
- package/editors/checkboxEditor/index.js +7 -0
- package/editors/checkboxEditor/index.mjs +1 -0
- package/editors/dateEditor/dateEditor.d.ts +18 -0
- package/editors/dateEditor/dateEditor.js +325 -0
- package/editors/dateEditor/dateEditor.mjs +318 -0
- package/editors/dateEditor/index.d.ts +1 -0
- package/editors/dateEditor/index.js +7 -0
- package/editors/dateEditor/index.mjs +1 -0
- package/editors/dropdownEditor/dropdownEditor.d.ts +7 -0
- package/editors/dropdownEditor/dropdownEditor.js +81 -0
- package/editors/dropdownEditor/dropdownEditor.mjs +74 -0
- package/editors/dropdownEditor/index.d.ts +1 -0
- package/editors/dropdownEditor/index.js +7 -0
- package/editors/dropdownEditor/index.mjs +1 -0
- package/editors/handsontableEditor/handsontableEditor.d.ts +10 -0
- package/editors/handsontableEditor/handsontableEditor.js +306 -0
- package/editors/handsontableEditor/handsontableEditor.mjs +300 -0
- package/editors/handsontableEditor/index.d.ts +1 -0
- package/editors/handsontableEditor/index.js +7 -0
- package/editors/handsontableEditor/index.mjs +1 -0
- package/editors/index.d.ts +56 -0
- package/editors/index.js +63 -0
- package/editors/index.mjs +30 -0
- package/editors/numericEditor/index.d.ts +1 -0
- package/editors/numericEditor/index.js +7 -0
- package/editors/numericEditor/index.mjs +1 -0
- package/editors/numericEditor/numericEditor.d.ts +7 -0
- package/editors/numericEditor/numericEditor.js +49 -0
- package/editors/numericEditor/numericEditor.mjs +43 -0
- package/editors/passwordEditor/index.d.ts +1 -0
- package/editors/passwordEditor/index.js +7 -0
- package/editors/passwordEditor/index.mjs +1 -0
- package/editors/passwordEditor/passwordEditor.d.ts +7 -0
- package/editors/passwordEditor/passwordEditor.js +68 -0
- package/editors/passwordEditor/passwordEditor.mjs +62 -0
- package/editors/registry.d.ts +29 -0
- package/editors/registry.js +106 -0
- package/editors/registry.mjs +94 -0
- package/editors/selectEditor/index.d.ts +1 -0
- package/editors/selectEditor/index.js +7 -0
- package/editors/selectEditor/index.mjs +1 -0
- package/editors/selectEditor/selectEditor.d.ts +16 -0
- package/editors/selectEditor/selectEditor.js +302 -0
- package/editors/selectEditor/selectEditor.mjs +296 -0
- package/editors/textEditor/caretPositioner.js +37 -0
- package/editors/textEditor/caretPositioner.mjs +33 -0
- package/editors/textEditor/index.d.ts +1 -0
- package/editors/textEditor/index.js +7 -0
- package/editors/textEditor/index.mjs +1 -0
- package/editors/textEditor/textEditor.d.ts +24 -0
- package/editors/textEditor/textEditor.js +612 -0
- package/editors/textEditor/textEditor.mjs +605 -0
- package/editors/timeEditor/index.d.ts +1 -0
- package/editors/timeEditor/index.js +7 -0
- package/editors/timeEditor/index.mjs +1 -0
- package/editors/timeEditor/timeEditor.d.ts +7 -0
- package/editors/timeEditor/timeEditor.js +70 -0
- package/editors/timeEditor/timeEditor.mjs +64 -0
- package/eventManager.d.ts +13 -0
- package/eventManager.js +236 -0
- package/eventManager.mjs +231 -0
- package/handsontable-non-commercial-license.pdf +0 -0
- package/helpers/array.d.ts +18 -0
- package/helpers/array.js +353 -0
- package/helpers/array.mjs +333 -0
- package/helpers/browser.d.ts +25 -0
- package/helpers/browser.js +231 -0
- package/helpers/browser.mjs +210 -0
- package/helpers/console.d.ts +4 -0
- package/helpers/console.js +65 -0
- package/helpers/console.mjs +56 -0
- package/helpers/data.d.ts +12 -0
- package/helpers/data.js +247 -0
- package/helpers/data.mjs +234 -0
- package/helpers/date.d.ts +1 -0
- package/helpers/date.js +22 -0
- package/helpers/date.mjs +18 -0
- package/helpers/dom/element.d.ts +49 -0
- package/helpers/dom/element.js +1117 -0
- package/helpers/dom/element.mjs +1064 -0
- package/helpers/dom/event.d.ts +4 -0
- package/helpers/dom/event.js +46 -0
- package/helpers/dom/event.mjs +39 -0
- package/helpers/dom/index.d.ts +2 -0
- package/helpers/feature.d.ts +11 -0
- package/helpers/feature.js +184 -0
- package/helpers/feature.mjs +172 -0
- package/helpers/function.d.ts +10 -0
- package/helpers/function.js +319 -0
- package/helpers/function.mjs +307 -0
- package/helpers/index.d.ts +14 -0
- package/helpers/mixed.d.ts +5 -0
- package/helpers/mixed.js +230 -0
- package/helpers/mixed.mjs +220 -0
- package/helpers/number.d.ts +5 -0
- package/helpers/number.js +142 -0
- package/helpers/number.mjs +134 -0
- package/helpers/object.d.ts +16 -0
- package/helpers/object.js +371 -0
- package/helpers/object.mjs +352 -0
- package/helpers/string.d.ts +7 -0
- package/helpers/string.js +115 -0
- package/helpers/string.mjs +104 -0
- package/helpers/templateLiteralTag.d.ts +1 -0
- package/helpers/templateLiteralTag.js +26 -0
- package/helpers/templateLiteralTag.mjs +22 -0
- package/helpers/unicode.d.ts +73 -0
- package/helpers/unicode.js +158 -0
- package/helpers/unicode.mjs +148 -0
- package/helpers/wrappers/jquery.js +50 -0
- package/helpers/wrappers/jquery.mjs +46 -0
- package/i18n/constants.js +162 -0
- package/i18n/constants.mjs +82 -0
- package/i18n/index.d.ts +2 -0
- package/i18n/index.js +18 -0
- package/i18n/index.mjs +2 -0
- package/i18n/languages/ar-AR.js +25 -0
- package/i18n/languages/ar-AR.mjs +15 -0
- package/i18n/languages/cs-CZ.js +24 -0
- package/i18n/languages/cs-CZ.mjs +14 -0
- package/i18n/languages/de-CH.d.ts +5 -0
- package/i18n/languages/de-CH.js +24 -0
- package/i18n/languages/de-CH.mjs +14 -0
- package/i18n/languages/de-DE.d.ts +5 -0
- package/i18n/languages/de-DE.js +24 -0
- package/i18n/languages/de-DE.mjs +14 -0
- package/i18n/languages/en-US.d.ts +5 -0
- package/i18n/languages/en-US.js +24 -0
- package/i18n/languages/en-US.mjs +14 -0
- package/i18n/languages/es-MX.d.ts +5 -0
- package/i18n/languages/es-MX.js +24 -0
- package/i18n/languages/es-MX.mjs +13 -0
- package/i18n/languages/fr-FR.d.ts +5 -0
- package/i18n/languages/fr-FR.js +24 -0
- package/i18n/languages/fr-FR.mjs +14 -0
- package/i18n/languages/index.d.ts +35 -0
- package/i18n/languages/index.js +42 -0
- package/i18n/languages/index.mjs +20 -0
- package/i18n/languages/it-IT.d.ts +5 -0
- package/i18n/languages/it-IT.js +24 -0
- package/i18n/languages/it-IT.mjs +14 -0
- package/i18n/languages/ja-JP.d.ts +5 -0
- package/i18n/languages/ja-JP.js +24 -0
- package/i18n/languages/ja-JP.mjs +14 -0
- package/i18n/languages/ko-KR.d.ts +5 -0
- package/i18n/languages/ko-KR.js +24 -0
- package/i18n/languages/ko-KR.mjs +14 -0
- package/i18n/languages/lv-LV.d.ts +5 -0
- package/i18n/languages/lv-LV.js +24 -0
- package/i18n/languages/lv-LV.mjs +14 -0
- package/i18n/languages/nb-NO.d.ts +5 -0
- package/i18n/languages/nb-NO.js +24 -0
- package/i18n/languages/nb-NO.mjs +14 -0
- package/i18n/languages/nl-NL.d.ts +5 -0
- package/i18n/languages/nl-NL.js +24 -0
- package/i18n/languages/nl-NL.mjs +14 -0
- package/i18n/languages/pl-PL.d.ts +5 -0
- package/i18n/languages/pl-PL.js +24 -0
- package/i18n/languages/pl-PL.mjs +14 -0
- package/i18n/languages/pt-BR.d.ts +5 -0
- package/i18n/languages/pt-BR.js +24 -0
- package/i18n/languages/pt-BR.mjs +14 -0
- package/i18n/languages/ru-RU.d.ts +5 -0
- package/i18n/languages/ru-RU.js +24 -0
- package/i18n/languages/ru-RU.mjs +14 -0
- package/i18n/languages/sr-SP.js +24 -0
- package/i18n/languages/sr-SP.mjs +14 -0
- package/i18n/languages/zh-CN.d.ts +5 -0
- package/i18n/languages/zh-CN.js +24 -0
- package/i18n/languages/zh-CN.mjs +14 -0
- package/i18n/languages/zh-TW.d.ts +5 -0
- package/i18n/languages/zh-TW.js +24 -0
- package/i18n/languages/zh-TW.mjs +14 -0
- package/i18n/phraseFormatters/index.js +31 -0
- package/i18n/phraseFormatters/index.mjs +26 -0
- package/i18n/phraseFormatters/pluralize.js +21 -0
- package/i18n/phraseFormatters/pluralize.mjs +17 -0
- package/i18n/phraseFormatters/substituteVariables.js +22 -0
- package/i18n/phraseFormatters/substituteVariables.mjs +18 -0
- package/i18n/registry.d.ts +13 -0
- package/i18n/registry.js +180 -0
- package/i18n/registry.mjs +155 -0
- package/i18n/utils.js +90 -0
- package/i18n/utils.mjs +83 -0
- package/index.d.ts +520 -0
- package/index.js +130 -0
- package/index.mjs +112 -0
- package/languages/all.js +583 -0
- package/languages/ar-AR.js +157 -0
- package/languages/ar-AR.mjs +17 -0
- package/languages/cs-CZ.js +157 -0
- package/languages/cs-CZ.mjs +16 -0
- package/languages/de-CH.js +158 -0
- package/languages/de-CH.mjs +16 -0
- package/languages/de-DE.js +159 -0
- package/languages/de-DE.mjs +16 -0
- package/languages/en-US.js +160 -0
- package/languages/en-US.mjs +16 -0
- package/languages/es-MX.js +161 -0
- package/languages/es-MX.mjs +15 -0
- package/languages/fr-FR.js +162 -0
- package/languages/fr-FR.mjs +16 -0
- package/languages/index.js +583 -0
- package/languages/index.mjs +20 -0
- package/languages/it-IT.js +164 -0
- package/languages/it-IT.mjs +16 -0
- package/languages/ja-JP.js +161 -0
- package/languages/ja-JP.mjs +16 -0
- package/languages/ko-KR.js +161 -0
- package/languages/ko-KR.mjs +16 -0
- package/languages/lv-LV.js +161 -0
- package/languages/lv-LV.mjs +16 -0
- package/languages/nb-NO.js +161 -0
- package/languages/nb-NO.mjs +16 -0
- package/languages/nl-NL.js +161 -0
- package/languages/nl-NL.mjs +16 -0
- package/languages/pl-PL.js +161 -0
- package/languages/pl-PL.mjs +16 -0
- package/languages/pt-BR.js +161 -0
- package/languages/pt-BR.mjs +16 -0
- package/languages/ru-RU.js +161 -0
- package/languages/ru-RU.mjs +16 -0
- package/languages/sr-SP.js +161 -0
- package/languages/sr-SP.mjs +16 -0
- package/languages/zh-CN.js +161 -0
- package/languages/zh-CN.mjs +16 -0
- package/languages/zh-TW.js +161 -0
- package/languages/zh-TW.mjs +16 -0
- package/mixins/hooksRefRegisterer.js +61 -0
- package/mixins/hooksRefRegisterer.mjs +56 -0
- package/mixins/localHooks.js +71 -0
- package/mixins/localHooks.mjs +66 -0
- package/package.json +751 -0
- package/pluginHooks.d.ts +256 -0
- package/pluginHooks.js +2750 -0
- package/pluginHooks.mjs +2744 -0
- package/plugins/autoColumnSize/autoColumnSize.d.ts +27 -0
- package/plugins/autoColumnSize/autoColumnSize.js +796 -0
- package/plugins/autoColumnSize/autoColumnSize.mjs +788 -0
- package/plugins/autoColumnSize/index.d.ts +1 -0
- package/plugins/autoColumnSize/index.js +8 -0
- package/plugins/autoColumnSize/index.mjs +1 -0
- package/plugins/autoRowSize/autoRowSize.d.ts +27 -0
- package/plugins/autoRowSize/autoRowSize.js +735 -0
- package/plugins/autoRowSize/autoRowSize.mjs +727 -0
- package/plugins/autoRowSize/index.d.ts +1 -0
- package/plugins/autoRowSize/index.js +8 -0
- package/plugins/autoRowSize/index.mjs +1 -0
- package/plugins/autofill/autofill.d.ts +18 -0
- package/plugins/autofill/autofill.js +694 -0
- package/plugins/autofill/autofill.mjs +687 -0
- package/plugins/autofill/index.d.ts +1 -0
- package/plugins/autofill/index.js +8 -0
- package/plugins/autofill/index.mjs +1 -0
- package/plugins/autofill/utils.js +134 -0
- package/plugins/autofill/utils.mjs +126 -0
- package/plugins/base/base.d.ts +27 -0
- package/plugins/base/base.js +345 -0
- package/plugins/base/base.mjs +339 -0
- package/plugins/base/index.d.ts +1 -0
- package/plugins/base/index.js +7 -0
- package/plugins/base/index.mjs +1 -0
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.d.ts +9 -0
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +169 -0
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +161 -0
- package/plugins/bindRowsWithHeaders/index.d.ts +1 -0
- package/plugins/bindRowsWithHeaders/index.js +8 -0
- package/plugins/bindRowsWithHeaders/index.mjs +1 -0
- package/plugins/bindRowsWithHeaders/maps/looseBindsMap.js +80 -0
- package/plugins/bindRowsWithHeaders/maps/looseBindsMap.mjs +75 -0
- package/plugins/bindRowsWithHeaders/maps/strictBindsMap.js +103 -0
- package/plugins/bindRowsWithHeaders/maps/strictBindsMap.mjs +98 -0
- package/plugins/collapsibleColumns/collapsibleColumns.d.ts +22 -0
- package/plugins/collapsibleColumns/collapsibleColumns.js +592 -0
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +584 -0
- package/plugins/collapsibleColumns/index.d.ts +1 -0
- package/plugins/collapsibleColumns/index.js +8 -0
- package/plugins/collapsibleColumns/index.mjs +1 -0
- package/plugins/columnSorting/columnSorting.d.ts +30 -0
- package/plugins/columnSorting/columnSorting.js +865 -0
- package/plugins/columnSorting/columnSorting.mjs +857 -0
- package/plugins/columnSorting/columnStatesManager.js +273 -0
- package/plugins/columnSorting/columnStatesManager.mjs +268 -0
- package/plugins/columnSorting/domHelpers.js +54 -0
- package/plugins/columnSorting/domHelpers.mjs +49 -0
- package/plugins/columnSorting/index.d.ts +1 -0
- package/plugins/columnSorting/index.js +8 -0
- package/plugins/columnSorting/index.mjs +1 -0
- package/plugins/columnSorting/rootComparator.js +52 -0
- package/plugins/columnSorting/rootComparator.mjs +48 -0
- package/plugins/columnSorting/sortFunction/checkbox.js +64 -0
- package/plugins/columnSorting/sortFunction/checkbox.mjs +58 -0
- package/plugins/columnSorting/sortFunction/date.js +61 -0
- package/plugins/columnSorting/sortFunction/date.mjs +54 -0
- package/plugins/columnSorting/sortFunction/default.js +65 -0
- package/plugins/columnSorting/sortFunction/default.mjs +59 -0
- package/plugins/columnSorting/sortFunction/numeric.js +49 -0
- package/plugins/columnSorting/sortFunction/numeric.mjs +43 -0
- package/plugins/columnSorting/sortService/engine.js +26 -0
- package/plugins/columnSorting/sortService/engine.mjs +18 -0
- package/plugins/columnSorting/sortService/index.js +13 -0
- package/plugins/columnSorting/sortService/index.mjs +3 -0
- package/plugins/columnSorting/sortService/registry.js +37 -0
- package/plugins/columnSorting/sortService/registry.mjs +30 -0
- package/plugins/columnSorting/utils.js +122 -0
- package/plugins/columnSorting/utils.mjs +110 -0
- package/plugins/columnSummary/columnSummary.d.ts +72 -0
- package/plugins/columnSummary/columnSummary.js +544 -0
- package/plugins/columnSummary/columnSummary.mjs +536 -0
- package/plugins/columnSummary/endpoints.js +557 -0
- package/plugins/columnSummary/endpoints.mjs +552 -0
- package/plugins/columnSummary/index.d.ts +1 -0
- package/plugins/columnSummary/index.js +8 -0
- package/plugins/columnSummary/index.mjs +1 -0
- package/plugins/columnSummary/utils.js +13 -0
- package/plugins/columnSummary/utils.mjs +9 -0
- package/plugins/comments/commentEditor.js +241 -0
- package/plugins/comments/commentEditor.mjs +236 -0
- package/plugins/comments/comments.d.ts +50 -0
- package/plugins/comments/comments.js +942 -0
- package/plugins/comments/comments.mjs +932 -0
- package/plugins/comments/displaySwitch.js +115 -0
- package/plugins/comments/displaySwitch.mjs +109 -0
- package/plugins/comments/index.d.ts +1 -0
- package/plugins/comments/index.js +8 -0
- package/plugins/comments/index.mjs +1 -0
- package/plugins/contextMenu/commandExecutor.js +113 -0
- package/plugins/contextMenu/commandExecutor.mjs +108 -0
- package/plugins/contextMenu/contextMenu.d.ts +65 -0
- package/plugins/contextMenu/contextMenu.js +445 -0
- package/plugins/contextMenu/contextMenu.mjs +437 -0
- package/plugins/contextMenu/cursor.js +126 -0
- package/plugins/contextMenu/cursor.mjs +121 -0
- package/plugins/contextMenu/index.d.ts +1 -0
- package/plugins/contextMenu/index.js +8 -0
- package/plugins/contextMenu/index.mjs +1 -0
- package/plugins/contextMenu/itemsFactory.js +136 -0
- package/plugins/contextMenu/itemsFactory.mjs +131 -0
- package/plugins/contextMenu/menu.js +1003 -0
- package/plugins/contextMenu/menu.mjs +997 -0
- package/plugins/contextMenu/predefinedItems/alignment.js +277 -0
- package/plugins/contextMenu/predefinedItems/alignment.mjs +259 -0
- package/plugins/contextMenu/predefinedItems/clearColumn.js +47 -0
- package/plugins/contextMenu/predefinedItems/clearColumn.mjs +29 -0
- package/plugins/contextMenu/predefinedItems/columnLeft.js +57 -0
- package/plugins/contextMenu/predefinedItems/columnLeft.mjs +39 -0
- package/plugins/contextMenu/predefinedItems/columnRight.js +55 -0
- package/plugins/contextMenu/predefinedItems/columnRight.mjs +37 -0
- package/plugins/contextMenu/predefinedItems/noItems.js +22 -0
- package/plugins/contextMenu/predefinedItems/noItems.mjs +16 -0
- package/plugins/contextMenu/predefinedItems/readOnly.js +69 -0
- package/plugins/contextMenu/predefinedItems/readOnly.mjs +51 -0
- package/plugins/contextMenu/predefinedItems/redo.js +42 -0
- package/plugins/contextMenu/predefinedItems/redo.mjs +24 -0
- package/plugins/contextMenu/predefinedItems/removeColumn.js +79 -0
- package/plugins/contextMenu/predefinedItems/removeColumn.mjs +68 -0
- package/plugins/contextMenu/predefinedItems/removeRow.js +78 -0
- package/plugins/contextMenu/predefinedItems/removeRow.mjs +67 -0
- package/plugins/contextMenu/predefinedItems/rowAbove.js +53 -0
- package/plugins/contextMenu/predefinedItems/rowAbove.mjs +35 -0
- package/plugins/contextMenu/predefinedItems/rowBelow.js +51 -0
- package/plugins/contextMenu/predefinedItems/rowBelow.mjs +33 -0
- package/plugins/contextMenu/predefinedItems/separator.js +16 -0
- package/plugins/contextMenu/predefinedItems/separator.mjs +10 -0
- package/plugins/contextMenu/predefinedItems/undo.js +42 -0
- package/plugins/contextMenu/predefinedItems/undo.mjs +24 -0
- package/plugins/contextMenu/predefinedItems.js +76 -0
- package/plugins/contextMenu/predefinedItems.mjs +57 -0
- package/plugins/contextMenu/utils.js +278 -0
- package/plugins/contextMenu/utils.mjs +261 -0
- package/plugins/copyPaste/clipboardData.js +29 -0
- package/plugins/copyPaste/clipboardData.mjs +25 -0
- package/plugins/copyPaste/contextMenuItem/copy.js +45 -0
- package/plugins/copyPaste/contextMenuItem/copy.mjs +29 -0
- package/plugins/copyPaste/contextMenuItem/cut.js +45 -0
- package/plugins/copyPaste/contextMenuItem/cut.mjs +29 -0
- package/plugins/copyPaste/copyPaste.d.ts +35 -0
- package/plugins/copyPaste/copyPaste.js +721 -0
- package/plugins/copyPaste/copyPaste.mjs +713 -0
- package/plugins/copyPaste/focusableElement.js +210 -0
- package/plugins/copyPaste/focusableElement.mjs +204 -0
- package/plugins/copyPaste/index.d.ts +1 -0
- package/plugins/copyPaste/index.js +8 -0
- package/plugins/copyPaste/index.mjs +1 -0
- package/plugins/copyPaste/pasteEvent.js +17 -0
- package/plugins/copyPaste/pasteEvent.mjs +12 -0
- package/plugins/customBorders/contextMenuItem/bottom.js +39 -0
- package/plugins/customBorders/contextMenuItem/bottom.mjs +23 -0
- package/plugins/customBorders/contextMenuItem/index.js +14 -0
- package/plugins/customBorders/contextMenuItem/index.mjs +6 -0
- package/plugins/customBorders/contextMenuItem/left.js +40 -0
- package/plugins/customBorders/contextMenuItem/left.mjs +24 -0
- package/plugins/customBorders/contextMenuItem/noBorders.js +36 -0
- package/plugins/customBorders/contextMenuItem/noBorders.mjs +20 -0
- package/plugins/customBorders/contextMenuItem/right.js +40 -0
- package/plugins/customBorders/contextMenuItem/right.mjs +24 -0
- package/plugins/customBorders/contextMenuItem/top.js +39 -0
- package/plugins/customBorders/contextMenuItem/top.mjs +23 -0
- package/plugins/customBorders/customBorders.d.ts +38 -0
- package/plugins/customBorders/customBorders.js +887 -0
- package/plugins/customBorders/customBorders.mjs +877 -0
- package/plugins/customBorders/index.d.ts +1 -0
- package/plugins/customBorders/index.js +8 -0
- package/plugins/customBorders/index.mjs +1 -0
- package/plugins/customBorders/utils.js +265 -0
- package/plugins/customBorders/utils.mjs +249 -0
- package/plugins/dragToScroll/dragToScroll.d.ts +15 -0
- package/plugins/dragToScroll/dragToScroll.js +335 -0
- package/plugins/dragToScroll/dragToScroll.mjs +327 -0
- package/plugins/dragToScroll/index.d.ts +1 -0
- package/plugins/dragToScroll/index.js +8 -0
- package/plugins/dragToScroll/index.mjs +1 -0
- package/plugins/dropdownMenu/dropdownMenu.d.ts +24 -0
- package/plugins/dropdownMenu/dropdownMenu.js +511 -0
- package/plugins/dropdownMenu/dropdownMenu.mjs +504 -0
- package/plugins/dropdownMenu/index.d.ts +1 -0
- package/plugins/dropdownMenu/index.js +8 -0
- package/plugins/dropdownMenu/index.mjs +1 -0
- package/plugins/exportFile/dataProvider.js +200 -0
- package/plugins/exportFile/dataProvider.mjs +195 -0
- package/plugins/exportFile/exportFile.d.ts +12 -0
- package/plugins/exportFile/exportFile.js +262 -0
- package/plugins/exportFile/exportFile.mjs +250 -0
- package/plugins/exportFile/index.d.ts +1 -0
- package/plugins/exportFile/index.js +8 -0
- package/plugins/exportFile/index.mjs +1 -0
- package/plugins/exportFile/typeFactory.js +30 -0
- package/plugins/exportFile/typeFactory.mjs +21 -0
- package/plugins/exportFile/types/_base.js +78 -0
- package/plugins/exportFile/types/_base.mjs +73 -0
- package/plugins/exportFile/types/csv.js +131 -0
- package/plugins/exportFile/types/csv.mjs +125 -0
- package/plugins/filters/component/_base.js +169 -0
- package/plugins/filters/component/_base.mjs +163 -0
- package/plugins/filters/component/actionBar.js +161 -0
- package/plugins/filters/component/actionBar.mjs +151 -0
- package/plugins/filters/component/condition.js +325 -0
- package/plugins/filters/component/condition.mjs +316 -0
- package/plugins/filters/component/operators.js +222 -0
- package/plugins/filters/component/operators.mjs +216 -0
- package/plugins/filters/component/value.js +278 -0
- package/plugins/filters/component/value.mjs +269 -0
- package/plugins/filters/condition/beginsWith.js +50 -0
- package/plugins/filters/condition/beginsWith.mjs +39 -0
- package/plugins/filters/condition/between.js +64 -0
- package/plugins/filters/condition/between.mjs +53 -0
- package/plugins/filters/condition/byValue.js +48 -0
- package/plugins/filters/condition/byValue.mjs +42 -0
- package/plugins/filters/condition/contains.js +50 -0
- package/plugins/filters/condition/contains.mjs +39 -0
- package/plugins/filters/condition/date/after.js +55 -0
- package/plugins/filters/condition/date/after.mjs +43 -0
- package/plugins/filters/condition/date/before.js +55 -0
- package/plugins/filters/condition/date/before.mjs +43 -0
- package/plugins/filters/condition/date/today.js +39 -0
- package/plugins/filters/condition/date/today.mjs +20 -0
- package/plugins/filters/condition/date/tomorrow.js +39 -0
- package/plugins/filters/condition/date/tomorrow.mjs +20 -0
- package/plugins/filters/condition/date/yesterday.js +39 -0
- package/plugins/filters/condition/date/yesterday.mjs +20 -0
- package/plugins/filters/condition/empty.js +35 -0
- package/plugins/filters/condition/empty.mjs +17 -0
- package/plugins/filters/condition/endsWith.js +50 -0
- package/plugins/filters/condition/endsWith.mjs +39 -0
- package/plugins/filters/condition/equal.js +49 -0
- package/plugins/filters/condition/equal.mjs +38 -0
- package/plugins/filters/condition/false.js +18 -0
- package/plugins/filters/condition/false.mjs +12 -0
- package/plugins/filters/condition/greaterThan.js +52 -0
- package/plugins/filters/condition/greaterThan.mjs +41 -0
- package/plugins/filters/condition/greaterThanOrEqual.js +52 -0
- package/plugins/filters/condition/greaterThanOrEqual.mjs +41 -0
- package/plugins/filters/condition/lessThan.js +52 -0
- package/plugins/filters/condition/lessThan.mjs +41 -0
- package/plugins/filters/condition/lessThanOrEqual.js +52 -0
- package/plugins/filters/condition/lessThanOrEqual.mjs +41 -0
- package/plugins/filters/condition/none.js +33 -0
- package/plugins/filters/condition/none.mjs +15 -0
- package/plugins/filters/condition/notBetween.js +36 -0
- package/plugins/filters/condition/notBetween.mjs +18 -0
- package/plugins/filters/condition/notContains.js +36 -0
- package/plugins/filters/condition/notContains.mjs +18 -0
- package/plugins/filters/condition/notEmpty.js +36 -0
- package/plugins/filters/condition/notEmpty.mjs +18 -0
- package/plugins/filters/condition/notEqual.js +36 -0
- package/plugins/filters/condition/notEqual.mjs +18 -0
- package/plugins/filters/condition/true.js +18 -0
- package/plugins/filters/condition/true.mjs +12 -0
- package/plugins/filters/conditionCollection.d.ts +32 -0
- package/plugins/filters/conditionCollection.js +343 -0
- package/plugins/filters/conditionCollection.mjs +337 -0
- package/plugins/filters/conditionRegisterer.js +61 -0
- package/plugins/filters/conditionRegisterer.mjs +53 -0
- package/plugins/filters/conditionUpdateObserver.d.ts +10 -0
- package/plugins/filters/conditionUpdateObserver.js +248 -0
- package/plugins/filters/conditionUpdateObserver.mjs +242 -0
- package/plugins/filters/constants.js +103 -0
- package/plugins/filters/constants.mjs +69 -0
- package/plugins/filters/dataFilter.js +98 -0
- package/plugins/filters/dataFilter.mjs +93 -0
- package/plugins/filters/filters.d.ts +56 -0
- package/plugins/filters/filters.js +1037 -0
- package/plugins/filters/filters.mjs +1026 -0
- package/plugins/filters/index.d.ts +1 -0
- package/plugins/filters/index.js +8 -0
- package/plugins/filters/index.mjs +1 -0
- package/plugins/filters/logicalOperationRegisterer.js +50 -0
- package/plugins/filters/logicalOperationRegisterer.mjs +42 -0
- package/plugins/filters/logicalOperations/conjunction.js +36 -0
- package/plugins/filters/logicalOperations/conjunction.mjs +18 -0
- package/plugins/filters/logicalOperations/disjunction.js +36 -0
- package/plugins/filters/logicalOperations/disjunction.mjs +18 -0
- package/plugins/filters/logicalOperations/disjunctionWithExtraCondition.js +40 -0
- package/plugins/filters/logicalOperations/disjunctionWithExtraCondition.mjs +22 -0
- package/plugins/filters/ui/_base.js +249 -0
- package/plugins/filters/ui/_base.mjs +231 -0
- package/plugins/filters/ui/input.js +140 -0
- package/plugins/filters/ui/input.mjs +134 -0
- package/plugins/filters/ui/link.js +86 -0
- package/plugins/filters/ui/link.mjs +80 -0
- package/plugins/filters/ui/multipleSelect.js +441 -0
- package/plugins/filters/ui/multipleSelect.mjs +434 -0
- package/plugins/filters/ui/radioInput.js +130 -0
- package/plugins/filters/ui/radioInput.mjs +124 -0
- package/plugins/filters/ui/select.js +269 -0
- package/plugins/filters/ui/select.mjs +261 -0
- package/plugins/filters/utils.js +143 -0
- package/plugins/filters/utils.mjs +134 -0
- package/plugins/formulas/engine/register.js +259 -0
- package/plugins/formulas/engine/register.mjs +247 -0
- package/plugins/formulas/engine/settings.js +115 -0
- package/plugins/formulas/engine/settings.mjs +107 -0
- package/plugins/formulas/formulas.d.ts +31 -0
- package/plugins/formulas/formulas.js +1229 -0
- package/plugins/formulas/formulas.mjs +1221 -0
- package/plugins/formulas/index.d.ts +1 -0
- package/plugins/formulas/index.js +8 -0
- package/plugins/formulas/index.mjs +1 -0
- package/plugins/formulas/utils.js +24 -0
- package/plugins/formulas/utils.mjs +19 -0
- package/plugins/hiddenColumns/contextMenuItem/hideColumn.js +76 -0
- package/plugins/hiddenColumns/contextMenuItem/hideColumn.mjs +67 -0
- package/plugins/hiddenColumns/contextMenuItem/showColumn.js +124 -0
- package/plugins/hiddenColumns/contextMenuItem/showColumn.mjs +115 -0
- package/plugins/hiddenColumns/hiddenColumns.d.ts +21 -0
- package/plugins/hiddenColumns/hiddenColumns.js +620 -0
- package/plugins/hiddenColumns/hiddenColumns.mjs +612 -0
- package/plugins/hiddenColumns/index.d.ts +1 -0
- package/plugins/hiddenColumns/index.js +8 -0
- package/plugins/hiddenColumns/index.mjs +1 -0
- package/plugins/hiddenRows/contextMenuItem/hideRow.js +76 -0
- package/plugins/hiddenRows/contextMenuItem/hideRow.mjs +67 -0
- package/plugins/hiddenRows/contextMenuItem/showRow.js +124 -0
- package/plugins/hiddenRows/contextMenuItem/showRow.mjs +115 -0
- package/plugins/hiddenRows/hiddenRows.d.ts +21 -0
- package/plugins/hiddenRows/hiddenRows.js +612 -0
- package/plugins/hiddenRows/hiddenRows.mjs +604 -0
- package/plugins/hiddenRows/index.d.ts +1 -0
- package/plugins/hiddenRows/index.js +8 -0
- package/plugins/hiddenRows/index.mjs +1 -0
- package/plugins/index.d.ts +111 -0
- package/plugins/index.js +115 -0
- package/plugins/index.mjs +75 -0
- package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.js +58 -0
- package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.mjs +49 -0
- package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.js +58 -0
- package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.mjs +49 -0
- package/plugins/manualColumnFreeze/index.d.ts +1 -0
- package/plugins/manualColumnFreeze/index.js +8 -0
- package/plugins/manualColumnFreeze/index.mjs +1 -0
- package/plugins/manualColumnFreeze/manualColumnFreeze.d.ts +11 -0
- package/plugins/manualColumnFreeze/manualColumnFreeze.js +250 -0
- package/plugins/manualColumnFreeze/manualColumnFreeze.mjs +242 -0
- package/plugins/manualColumnMove/index.d.ts +1 -0
- package/plugins/manualColumnMove/index.js +8 -0
- package/plugins/manualColumnMove/index.mjs +1 -0
- package/plugins/manualColumnMove/manualColumnMove.d.ts +14 -0
- package/plugins/manualColumnMove/manualColumnMove.js +775 -0
- package/plugins/manualColumnMove/manualColumnMove.mjs +767 -0
- package/plugins/manualColumnMove/ui/_base.js +209 -0
- package/plugins/manualColumnMove/ui/_base.mjs +204 -0
- package/plugins/manualColumnMove/ui/backlight.js +60 -0
- package/plugins/manualColumnMove/ui/backlight.mjs +54 -0
- package/plugins/manualColumnMove/ui/guideline.js +60 -0
- package/plugins/manualColumnMove/ui/guideline.mjs +54 -0
- package/plugins/manualColumnResize/index.d.ts +1 -0
- package/plugins/manualColumnResize/index.js +8 -0
- package/plugins/manualColumnResize/index.mjs +1 -0
- package/plugins/manualColumnResize/manualColumnResize.d.ts +30 -0
- package/plugins/manualColumnResize/manualColumnResize.js +690 -0
- package/plugins/manualColumnResize/manualColumnResize.mjs +680 -0
- package/plugins/manualRowMove/index.d.ts +1 -0
- package/plugins/manualRowMove/index.js +8 -0
- package/plugins/manualRowMove/index.mjs +1 -0
- package/plugins/manualRowMove/manualRowMove.d.ts +14 -0
- package/plugins/manualRowMove/manualRowMove.js +757 -0
- package/plugins/manualRowMove/manualRowMove.mjs +749 -0
- package/plugins/manualRowMove/ui/_base.js +196 -0
- package/plugins/manualRowMove/ui/_base.mjs +191 -0
- package/plugins/manualRowMove/ui/backlight.js +60 -0
- package/plugins/manualRowMove/ui/backlight.mjs +54 -0
- package/plugins/manualRowMove/ui/guideline.js +60 -0
- package/plugins/manualRowMove/ui/guideline.mjs +54 -0
- package/plugins/manualRowResize/index.d.ts +1 -0
- package/plugins/manualRowResize/index.js +8 -0
- package/plugins/manualRowResize/index.mjs +1 -0
- package/plugins/manualRowResize/manualRowResize.d.ts +29 -0
- package/plugins/manualRowResize/manualRowResize.js +652 -0
- package/plugins/manualRowResize/manualRowResize.mjs +642 -0
- package/plugins/mergeCells/calculations/autofill.js +464 -0
- package/plugins/mergeCells/calculations/autofill.mjs +459 -0
- package/plugins/mergeCells/calculations/selection.js +204 -0
- package/plugins/mergeCells/calculations/selection.mjs +199 -0
- package/plugins/mergeCells/cellCoords.js +347 -0
- package/plugins/mergeCells/cellCoords.mjs +342 -0
- package/plugins/mergeCells/cellsCollection.js +344 -0
- package/plugins/mergeCells/cellsCollection.mjs +338 -0
- package/plugins/mergeCells/contextMenuItem/toggleMerge.js +55 -0
- package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +38 -0
- package/plugins/mergeCells/index.d.ts +1 -0
- package/plugins/mergeCells/index.js +8 -0
- package/plugins/mergeCells/index.mjs +1 -0
- package/plugins/mergeCells/mergeCells.d.ts +22 -0
- package/plugins/mergeCells/mergeCells.js +1290 -0
- package/plugins/mergeCells/mergeCells.mjs +1282 -0
- package/plugins/mergeCells/utils.js +30 -0
- package/plugins/mergeCells/utils.mjs +26 -0
- package/plugins/multiColumnSorting/domHelpers.js +44 -0
- package/plugins/multiColumnSorting/domHelpers.mjs +39 -0
- package/plugins/multiColumnSorting/index.d.ts +1 -0
- package/plugins/multiColumnSorting/index.js +8 -0
- package/plugins/multiColumnSorting/index.mjs +1 -0
- package/plugins/multiColumnSorting/multiColumnSorting.d.ts +8 -0
- package/plugins/multiColumnSorting/multiColumnSorting.js +336 -0
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +329 -0
- package/plugins/multiColumnSorting/rootComparator.js +55 -0
- package/plugins/multiColumnSorting/rootComparator.mjs +51 -0
- package/plugins/multiColumnSorting/utils.js +16 -0
- package/plugins/multiColumnSorting/utils.mjs +12 -0
- package/plugins/multipleSelectionHandles/index.d.ts +1 -0
- package/plugins/multipleSelectionHandles/index.js +8 -0
- package/plugins/multipleSelectionHandles/index.mjs +1 -0
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.d.ts +21 -0
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.js +394 -0
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.mjs +386 -0
- package/plugins/nestedHeaders/index.d.ts +1 -0
- package/plugins/nestedHeaders/index.js +8 -0
- package/plugins/nestedHeaders/index.mjs +1 -0
- package/plugins/nestedHeaders/nestedHeaders.d.ts +17 -0
- package/plugins/nestedHeaders/nestedHeaders.js +666 -0
- package/plugins/nestedHeaders/nestedHeaders.mjs +658 -0
- package/plugins/nestedHeaders/stateManager/headersTree.js +288 -0
- package/plugins/nestedHeaders/stateManager/headersTree.mjs +283 -0
- package/plugins/nestedHeaders/stateManager/index.js +417 -0
- package/plugins/nestedHeaders/stateManager/index.mjs +412 -0
- package/plugins/nestedHeaders/stateManager/matrixGenerator.js +102 -0
- package/plugins/nestedHeaders/stateManager/matrixGenerator.mjs +99 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/collapse.js +98 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/collapse.mjs +94 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/expand.js +95 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/expand.mjs +91 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/hideColumn.js +54 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/hideColumn.mjs +50 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/index.js +40 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/index.mjs +35 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/showColumn.js +55 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/showColumn.mjs +51 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/utils/tree.js +61 -0
- package/plugins/nestedHeaders/stateManager/nodeModifiers/utils/tree.mjs +55 -0
- package/plugins/nestedHeaders/stateManager/settingsNormalizer.js +122 -0
- package/plugins/nestedHeaders/stateManager/settingsNormalizer.mjs +119 -0
- package/plugins/nestedHeaders/stateManager/sourceSettings.js +250 -0
- package/plugins/nestedHeaders/stateManager/sourceSettings.mjs +245 -0
- package/plugins/nestedHeaders/stateManager/utils.js +75 -0
- package/plugins/nestedHeaders/stateManager/utils.mjs +70 -0
- package/plugins/nestedHeaders/utils/ghostTable.js +167 -0
- package/plugins/nestedHeaders/utils/ghostTable.mjs +162 -0
- package/plugins/nestedRows/data/dataManager.js +809 -0
- package/plugins/nestedRows/data/dataManager.mjs +804 -0
- package/plugins/nestedRows/index.d.ts +1 -0
- package/plugins/nestedRows/index.js +8 -0
- package/plugins/nestedRows/index.mjs +1 -0
- package/plugins/nestedRows/nestedRows.d.ts +12 -0
- package/plugins/nestedRows/nestedRows.js +592 -0
- package/plugins/nestedRows/nestedRows.mjs +584 -0
- package/plugins/nestedRows/ui/_base.js +28 -0
- package/plugins/nestedRows/ui/_base.mjs +23 -0
- package/plugins/nestedRows/ui/collapsing.js +562 -0
- package/plugins/nestedRows/ui/collapsing.mjs +556 -0
- package/plugins/nestedRows/ui/contextMenu.js +147 -0
- package/plugins/nestedRows/ui/contextMenu.mjs +138 -0
- package/plugins/nestedRows/ui/headers.js +157 -0
- package/plugins/nestedRows/ui/headers.mjs +151 -0
- package/plugins/nestedRows/utils/rowMoveController.js +331 -0
- package/plugins/nestedRows/utils/rowMoveController.mjs +327 -0
- package/plugins/persistentState/index.d.ts +1 -0
- package/plugins/persistentState/index.js +8 -0
- package/plugins/persistentState/index.mjs +1 -0
- package/plugins/persistentState/persistentState.d.ts +13 -0
- package/plugins/persistentState/persistentState.js +207 -0
- package/plugins/persistentState/persistentState.mjs +199 -0
- package/plugins/persistentState/storage.js +138 -0
- package/plugins/persistentState/storage.mjs +133 -0
- package/plugins/registry.d.ts +9 -0
- package/plugins/registry.js +150 -0
- package/plugins/registry.mjs +146 -0
- package/plugins/search/index.d.ts +1 -0
- package/plugins/search/index.js +8 -0
- package/plugins/search/index.mjs +1 -0
- package/plugins/search/search.d.ts +28 -0
- package/plugins/search/search.js +377 -0
- package/plugins/search/search.mjs +370 -0
- package/plugins/touchScroll/index.d.ts +1 -0
- package/plugins/touchScroll/index.js +8 -0
- package/plugins/touchScroll/index.mjs +1 -0
- package/plugins/touchScroll/touchScroll.d.ts +13 -0
- package/plugins/touchScroll/touchScroll.js +250 -0
- package/plugins/touchScroll/touchScroll.mjs +243 -0
- package/plugins/trimRows/index.d.ts +1 -0
- package/plugins/trimRows/index.js +8 -0
- package/plugins/trimRows/index.mjs +1 -0
- package/plugins/trimRows/trimRows.d.ts +17 -0
- package/plugins/trimRows/trimRows.js +393 -0
- package/plugins/trimRows/trimRows.mjs +386 -0
- package/plugins/undoRedo/index.d.ts +1 -0
- package/plugins/undoRedo/index.js +18 -0
- package/plugins/undoRedo/index.mjs +2 -0
- package/plugins/undoRedo/undoRedo.d.ts +49 -0
- package/plugins/undoRedo/undoRedo.js +935 -0
- package/plugins/undoRedo/undoRedo.mjs +928 -0
- package/registry.d.ts +6 -0
- package/registry.js +35 -0
- package/registry.mjs +26 -0
- package/renderers/autocompleteRenderer/autocompleteRenderer.d.ts +5 -0
- package/renderers/autocompleteRenderer/autocompleteRenderer.js +59 -0
- package/renderers/autocompleteRenderer/autocompleteRenderer.mjs +52 -0
- package/renderers/autocompleteRenderer/index.d.ts +1 -0
- package/renderers/autocompleteRenderer/index.js +7 -0
- package/renderers/autocompleteRenderer/index.mjs +1 -0
- package/renderers/base.d.ts +3 -0
- package/renderers/baseRenderer/baseRenderer.d.ts +5 -0
- package/renderers/baseRenderer/baseRenderer.js +46 -0
- package/renderers/baseRenderer/baseRenderer.mjs +39 -0
- package/renderers/baseRenderer/index.d.ts +1 -0
- package/renderers/baseRenderer/index.js +7 -0
- package/renderers/baseRenderer/index.mjs +1 -0
- package/renderers/checkboxRenderer/checkboxRenderer.d.ts +5 -0
- package/renderers/checkboxRenderer/checkboxRenderer.js +398 -0
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +391 -0
- package/renderers/checkboxRenderer/index.d.ts +1 -0
- package/renderers/checkboxRenderer/index.js +7 -0
- package/renderers/checkboxRenderer/index.mjs +1 -0
- package/renderers/htmlRenderer/htmlRenderer.d.ts +5 -0
- package/renderers/htmlRenderer/htmlRenderer.js +25 -0
- package/renderers/htmlRenderer/htmlRenderer.mjs +19 -0
- package/renderers/htmlRenderer/index.d.ts +1 -0
- package/renderers/htmlRenderer/index.js +7 -0
- package/renderers/htmlRenderer/index.mjs +1 -0
- package/renderers/index.d.ts +45 -0
- package/renderers/index.js +48 -0
- package/renderers/index.mjs +24 -0
- package/renderers/numericRenderer/index.d.ts +1 -0
- package/renderers/numericRenderer/index.js +7 -0
- package/renderers/numericRenderer/index.mjs +1 -0
- package/renderers/numericRenderer/numericRenderer.d.ts +5 -0
- package/renderers/numericRenderer/numericRenderer.js +57 -0
- package/renderers/numericRenderer/numericRenderer.mjs +50 -0
- package/renderers/passwordRenderer/index.d.ts +1 -0
- package/renderers/passwordRenderer/index.js +7 -0
- package/renderers/passwordRenderer/index.mjs +1 -0
- package/renderers/passwordRenderer/passwordRenderer.d.ts +5 -0
- package/renderers/passwordRenderer/passwordRenderer.js +32 -0
- package/renderers/passwordRenderer/passwordRenderer.mjs +26 -0
- package/renderers/registry.d.ts +18 -0
- package/renderers/registry.js +48 -0
- package/renderers/registry.mjs +38 -0
- package/renderers/textRenderer/index.d.ts +1 -0
- package/renderers/textRenderer/index.js +7 -0
- package/renderers/textRenderer/index.mjs +1 -0
- package/renderers/textRenderer/textRenderer.d.ts +5 -0
- package/renderers/textRenderer/textRenderer.js +48 -0
- package/renderers/textRenderer/textRenderer.mjs +42 -0
- package/renderers/timeRenderer/index.d.ts +1 -0
- package/renderers/timeRenderer/index.js +7 -0
- package/renderers/timeRenderer/index.mjs +1 -0
- package/renderers/timeRenderer/timeRenderer.d.ts +5 -0
- package/renderers/timeRenderer/timeRenderer.js +26 -0
- package/renderers/timeRenderer/timeRenderer.mjs +20 -0
- package/selection/highlight/constants.js +16 -0
- package/selection/highlight/constants.mjs +6 -0
- package/selection/highlight/highlight.js +330 -0
- package/selection/highlight/highlight.mjs +325 -0
- package/selection/highlight/types/activeHeader.js +38 -0
- package/selection/highlight/types/activeHeader.mjs +32 -0
- package/selection/highlight/types/area.js +49 -0
- package/selection/highlight/types/area.mjs +43 -0
- package/selection/highlight/types/cell.js +46 -0
- package/selection/highlight/types/cell.mjs +40 -0
- package/selection/highlight/types/customSelection.js +41 -0
- package/selection/highlight/types/customSelection.mjs +35 -0
- package/selection/highlight/types/fill.js +41 -0
- package/selection/highlight/types/fill.mjs +35 -0
- package/selection/highlight/types/header.js +49 -0
- package/selection/highlight/types/header.mjs +43 -0
- package/selection/highlight/types/index.js +43 -0
- package/selection/highlight/types/index.mjs +39 -0
- package/selection/highlight/visualSelection.js +277 -0
- package/selection/highlight/visualSelection.mjs +272 -0
- package/selection/index.d.ts +5 -0
- package/selection/index.js +30 -0
- package/selection/index.mjs +6 -0
- package/selection/mouseEventHandler.js +135 -0
- package/selection/mouseEventHandler.mjs +129 -0
- package/selection/range.js +173 -0
- package/selection/range.mjs +168 -0
- package/selection/selection.js +802 -0
- package/selection/selection.mjs +796 -0
- package/selection/transformation.js +169 -0
- package/selection/transformation.mjs +163 -0
- package/selection/utils.js +256 -0
- package/selection/utils.mjs +242 -0
- package/settings.d.ts +210 -0
- package/shortcuts/context.d.ts +20 -0
- package/shortcuts/context.js +241 -0
- package/shortcuts/context.mjs +236 -0
- package/shortcuts/index.d.ts +1 -0
- package/shortcuts/index.js +6 -0
- package/shortcuts/index.mjs +1 -0
- package/shortcuts/keyObserver.js +58 -0
- package/shortcuts/keyObserver.mjs +54 -0
- package/shortcuts/manager.d.ts +10 -0
- package/shortcuts/manager.js +165 -0
- package/shortcuts/manager.mjs +159 -0
- package/shortcuts/recorder.js +165 -0
- package/shortcuts/recorder.mjs +161 -0
- package/shortcuts/utils.js +58 -0
- package/shortcuts/utils.mjs +51 -0
- package/tableView.js +1313 -0
- package/tableView.mjs +1307 -0
- package/translations/changesObservable/observable.js +175 -0
- package/translations/changesObservable/observable.mjs +170 -0
- package/translations/changesObservable/observer.js +100 -0
- package/translations/changesObservable/observer.mjs +94 -0
- package/translations/changesObservable/utils.js +50 -0
- package/translations/changesObservable/utils.mjs +46 -0
- package/translations/index.d.ts +1 -0
- package/translations/index.js +29 -0
- package/translations/index.mjs +4 -0
- package/translations/indexMapper.d.ts +48 -0
- package/translations/indexMapper.js +865 -0
- package/translations/indexMapper.mjs +859 -0
- package/translations/mapCollections/aggregatedCollection.js +139 -0
- package/translations/mapCollections/aggregatedCollection.mjs +134 -0
- package/translations/mapCollections/index.js +18 -0
- package/translations/mapCollections/index.mjs +2 -0
- package/translations/mapCollections/mapCollection.js +164 -0
- package/translations/mapCollections/mapCollection.mjs +156 -0
- package/translations/maps/hidingMap.js +63 -0
- package/translations/maps/hidingMap.mjs +58 -0
- package/translations/maps/index.js +59 -0
- package/translations/maps/index.mjs +29 -0
- package/translations/maps/indexMap.d.ts +10 -0
- package/translations/maps/indexMap.js +203 -0
- package/translations/maps/indexMap.mjs +197 -0
- package/translations/maps/indexesSequence.js +82 -0
- package/translations/maps/indexesSequence.mjs +77 -0
- package/translations/maps/linkedPhysicalIndexToValueMap.js +216 -0
- package/translations/maps/linkedPhysicalIndexToValueMap.mjs +211 -0
- package/translations/maps/physicalIndexToValueMap.js +76 -0
- package/translations/maps/physicalIndexToValueMap.mjs +71 -0
- package/translations/maps/trimmingMap.js +63 -0
- package/translations/maps/trimmingMap.mjs +58 -0
- package/translations/maps/utils/actionsOnIndexes.js +42 -0
- package/translations/maps/utils/actionsOnIndexes.mjs +37 -0
- package/translations/maps/utils/index.js +28 -0
- package/translations/maps/utils/index.mjs +22 -0
- package/translations/maps/utils/indexesSequence.js +52 -0
- package/translations/maps/utils/indexesSequence.mjs +47 -0
- package/translations/maps/utils/physicallyIndexed.js +61 -0
- package/translations/maps/utils/physicallyIndexed.mjs +56 -0
- package/utils/dataStructures/linkedList.js +263 -0
- package/utils/dataStructures/linkedList.mjs +258 -0
- package/utils/dataStructures/priorityMap.js +106 -0
- package/utils/dataStructures/priorityMap.mjs +99 -0
- package/utils/dataStructures/queue.js +83 -0
- package/utils/dataStructures/queue.mjs +78 -0
- package/utils/dataStructures/stack.js +83 -0
- package/utils/dataStructures/stack.mjs +78 -0
- package/utils/dataStructures/tree.js +254 -0
- package/utils/dataStructures/tree.mjs +246 -0
- package/utils/dataStructures/uniqueMap.js +144 -0
- package/utils/dataStructures/uniqueMap.mjs +140 -0
- package/utils/dataStructures/uniqueSet.js +78 -0
- package/utils/dataStructures/uniqueSet.mjs +74 -0
- package/utils/ghostTable.js +536 -0
- package/utils/ghostTable.mjs +531 -0
- package/utils/interval.js +134 -0
- package/utils/interval.mjs +129 -0
- package/utils/parseTable.d.ts +5 -0
- package/utils/parseTable.js +305 -0
- package/utils/parseTable.mjs +299 -0
- package/utils/rootInstance.js +48 -0
- package/utils/rootInstance.mjs +38 -0
- package/utils/samplesGenerator.js +210 -0
- package/utils/samplesGenerator.mjs +205 -0
- package/utils/staticRegister.js +92 -0
- package/utils/staticRegister.mjs +86 -0
- package/validators/autocompleteValidator/autocompleteValidator.d.ts +5 -0
- package/validators/autocompleteValidator/autocompleteValidator.js +56 -0
- package/validators/autocompleteValidator/autocompleteValidator.mjs +50 -0
- package/validators/autocompleteValidator/index.d.ts +1 -0
- package/validators/autocompleteValidator/index.js +7 -0
- package/validators/autocompleteValidator/index.mjs +1 -0
- package/validators/base.d.ts +6 -0
- package/validators/dateValidator/dateValidator.d.ts +5 -0
- package/validators/dateValidator/dateValidator.js +77 -0
- package/validators/dateValidator/dateValidator.mjs +69 -0
- package/validators/dateValidator/index.d.ts +1 -0
- package/validators/dateValidator/index.js +8 -0
- package/validators/dateValidator/index.mjs +1 -0
- package/validators/index.d.ts +33 -0
- package/validators/index.js +32 -0
- package/validators/index.mjs +16 -0
- package/validators/numericValidator/index.d.ts +1 -0
- package/validators/numericValidator/index.js +7 -0
- package/validators/numericValidator/index.mjs +1 -0
- package/validators/numericValidator/numericValidator.d.ts +5 -0
- package/validators/numericValidator/numericValidator.js +30 -0
- package/validators/numericValidator/numericValidator.mjs +24 -0
- package/validators/registry.d.ts +18 -0
- package/validators/registry.js +48 -0
- package/validators/registry.mjs +38 -0
- package/validators/timeValidator/index.d.ts +1 -0
- package/validators/timeValidator/index.js +7 -0
- package/validators/timeValidator/index.mjs +1 -0
- package/validators/timeValidator/timeValidator.d.ts +5 -0
- package/validators/timeValidator/timeValidator.js +66 -0
- package/validators/timeValidator/timeValidator.mjs +60 -0
package/core.js
ADDED
@@ -0,0 +1,4684 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
require("core-js/modules/es.symbol.js");
|
4
|
+
require("core-js/modules/es.symbol.description.js");
|
5
|
+
require("core-js/modules/es.symbol.iterator.js");
|
6
|
+
require("core-js/modules/es.function.name.js");
|
7
|
+
require("core-js/modules/es.object.freeze.js");
|
8
|
+
exports.__esModule = true;
|
9
|
+
exports.default = Core;
|
10
|
+
require("core-js/modules/es.array.iterator.js");
|
11
|
+
require("core-js/modules/es.object.to-string.js");
|
12
|
+
require("core-js/modules/es.set.js");
|
13
|
+
require("core-js/modules/es.string.iterator.js");
|
14
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
15
|
+
require("core-js/modules/es.array.includes.js");
|
16
|
+
require("core-js/modules/es.array.sort.js");
|
17
|
+
require("core-js/modules/es.array.splice.js");
|
18
|
+
require("core-js/modules/es.number.is-integer.js");
|
19
|
+
require("core-js/modules/es.number.constructor.js");
|
20
|
+
require("core-js/modules/es.array.slice.js");
|
21
|
+
require("core-js/modules/es.array.concat.js");
|
22
|
+
require("core-js/modules/es.array.fill.js");
|
23
|
+
require("core-js/modules/es.array.map.js");
|
24
|
+
require("core-js/modules/es.regexp.exec.js");
|
25
|
+
require("core-js/modules/es.string.replace.js");
|
26
|
+
require("core-js/modules/es.array.from.js");
|
27
|
+
require("core-js/modules/es.array.index-of.js");
|
28
|
+
require("core-js/modules/es.array.reverse.js");
|
29
|
+
require("core-js/modules/web.dom-collections.for-each.js");
|
30
|
+
require("core-js/modules/web.timers.js");
|
31
|
+
require("core-js/modules/web.immediate.js");
|
32
|
+
require("core-js/modules/es.map.js");
|
33
|
+
var _element = require("./helpers/dom/element");
|
34
|
+
var _function = require("./helpers/function");
|
35
|
+
var _mixed = require("./helpers/mixed");
|
36
|
+
var _browser = require("./helpers/browser");
|
37
|
+
var _console = require("./helpers/console");
|
38
|
+
var _templateLiteralTag = require("./helpers/templateLiteralTag");
|
39
|
+
var _editorManager = _interopRequireDefault(require("./editorManager"));
|
40
|
+
var _eventManager = _interopRequireDefault(require("./eventManager"));
|
41
|
+
var _object = require("./helpers/object");
|
42
|
+
var _array = require("./helpers/array");
|
43
|
+
var _parseTable = require("./utils/parseTable");
|
44
|
+
var _registry = require("./plugins/registry");
|
45
|
+
var _registry2 = require("./renderers/registry");
|
46
|
+
var _registry3 = require("./validators/registry");
|
47
|
+
var _string = require("./helpers/string");
|
48
|
+
var _number = require("./helpers/number");
|
49
|
+
var _tableView = _interopRequireDefault(require("./tableView"));
|
50
|
+
var _dataSource = _interopRequireDefault(require("./dataMap/dataSource"));
|
51
|
+
var _data = require("./helpers/data");
|
52
|
+
var _translations = require("./translations");
|
53
|
+
var _rootInstance = require("./utils/rootInstance");
|
54
|
+
var _src = require("./3rdparty/walkontable/src");
|
55
|
+
var _pluginHooks = _interopRequireDefault(require("./pluginHooks"));
|
56
|
+
var _registry4 = require("./i18n/registry");
|
57
|
+
var _utils = require("./i18n/utils");
|
58
|
+
var _selection = require("./selection");
|
59
|
+
var _dataMap = require("./dataMap");
|
60
|
+
var _uniqueMap = require("./utils/dataStructures/uniqueMap");
|
61
|
+
var _shortcuts = require("./shortcuts");
|
62
|
+
var _templateObject, _templateObject2;
|
63
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
64
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
65
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
66
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
67
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
68
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
69
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
70
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
71
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
72
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
73
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
74
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
75
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
76
|
+
var SHORTCUTS_GROUP = 'gridDefault';
|
77
|
+
var activeGuid = null;
|
78
|
+
var deprecationWarns = new Set();
|
79
|
+
|
80
|
+
/* eslint-disable jsdoc/require-description-complete-sentence */
|
81
|
+
/**
|
82
|
+
* Handsontable constructor.
|
83
|
+
*
|
84
|
+
* @core
|
85
|
+
* @class Core
|
86
|
+
* @description
|
87
|
+
*
|
88
|
+
* The `Handsontable` class (known as the `Core`) lets you modify the grid's behavior by using Handsontable's public API methods.
|
89
|
+
*
|
90
|
+
* ::: only-for react
|
91
|
+
* To use these methods, associate a Handsontable instance with your instance
|
92
|
+
* of the [`HotTable` component](@/guides/getting-started/installation.md#hottable-component),
|
93
|
+
* by using React's `ref` feature (read more on the [Instance methods](@/guides/getting-started/react-methods.md) page).
|
94
|
+
* :::
|
95
|
+
*
|
96
|
+
* ## How to call a method
|
97
|
+
*
|
98
|
+
* ::: only-for javascript
|
99
|
+
* ```js
|
100
|
+
* // create a Handsontable instance
|
101
|
+
* const hot = new Handsontable(document.getElementById('example'), options);
|
102
|
+
*
|
103
|
+
* // call a method
|
104
|
+
* hot.setDataAtCell(0, 0, 'new value');
|
105
|
+
* ```
|
106
|
+
* :::
|
107
|
+
*
|
108
|
+
* ::: only-for react
|
109
|
+
* ```jsx{3,7,13}
|
110
|
+
* import { useRef } from 'react';
|
111
|
+
*
|
112
|
+
* const hotTableComponent = useRef(null);
|
113
|
+
*
|
114
|
+
* <HotTable
|
115
|
+
* // associate your `HotTable` component with a Handsontable instance
|
116
|
+
* ref={hotTableComponent}
|
117
|
+
* settings={options}
|
118
|
+
* />
|
119
|
+
*
|
120
|
+
* // access the Handsontable instance, under the `.current.hotInstance` property
|
121
|
+
* // call a method
|
122
|
+
* hotTableComponent.current.hotInstance.setDataAtCell(0, 0, 'new value');
|
123
|
+
* ```
|
124
|
+
* :::
|
125
|
+
*
|
126
|
+
* @param {HTMLElement} rootElement The element to which the Handsontable instance is injected.
|
127
|
+
* @param {object} userSettings The user defined options.
|
128
|
+
* @param {boolean} [rootInstanceSymbol=false] Indicates if the instance is root of all later instances created.
|
129
|
+
*/
|
130
|
+
function Core(rootElement, userSettings) {
|
131
|
+
var _userSettings$layoutD,
|
132
|
+
_this = this;
|
133
|
+
var rootInstanceSymbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
134
|
+
var preventScrollingToCell = false;
|
135
|
+
var instance = this;
|
136
|
+
var eventManager = new _eventManager.default(instance);
|
137
|
+
var datamap;
|
138
|
+
var dataSource;
|
139
|
+
var grid;
|
140
|
+
var editorManager;
|
141
|
+
var firstRun = true;
|
142
|
+
if ((0, _rootInstance.hasValidParameter)(rootInstanceSymbol)) {
|
143
|
+
(0, _rootInstance.registerAsRootInstance)(this);
|
144
|
+
}
|
145
|
+
|
146
|
+
// TODO: check if references to DOM elements should be move to UI layer (Walkontable)
|
147
|
+
/**
|
148
|
+
* Reference to the container element.
|
149
|
+
*
|
150
|
+
* @private
|
151
|
+
* @type {HTMLElement}
|
152
|
+
*/
|
153
|
+
this.rootElement = rootElement;
|
154
|
+
/**
|
155
|
+
* The nearest document over container.
|
156
|
+
*
|
157
|
+
* @private
|
158
|
+
* @type {Document}
|
159
|
+
*/
|
160
|
+
this.rootDocument = rootElement.ownerDocument;
|
161
|
+
/**
|
162
|
+
* Window object over container's document.
|
163
|
+
*
|
164
|
+
* @private
|
165
|
+
* @type {Window}
|
166
|
+
*/
|
167
|
+
this.rootWindow = this.rootDocument.defaultView;
|
168
|
+
/**
|
169
|
+
* A boolean to tell if the Handsontable has been fully destroyed. This is set to `true`
|
170
|
+
* after `afterDestroy` hook is called.
|
171
|
+
*
|
172
|
+
* @memberof Core#
|
173
|
+
* @member isDestroyed
|
174
|
+
* @type {boolean}
|
175
|
+
*/
|
176
|
+
this.isDestroyed = false;
|
177
|
+
/**
|
178
|
+
* The counter determines how many times the render suspending was called. It allows
|
179
|
+
* tracking the nested suspending calls. For each render suspend resuming call the
|
180
|
+
* counter is decremented. The value equal to 0 means the render suspending feature
|
181
|
+
* is disabled.
|
182
|
+
*
|
183
|
+
* @private
|
184
|
+
* @type {number}
|
185
|
+
*/
|
186
|
+
this.renderSuspendedCounter = 0;
|
187
|
+
/**
|
188
|
+
* The counter determines how many times the execution suspending was called. It allows
|
189
|
+
* tracking the nested suspending calls. For each execution suspend resuming call the
|
190
|
+
* counter is decremented. The value equal to 0 means the execution suspending feature
|
191
|
+
* is disabled.
|
192
|
+
*
|
193
|
+
* @private
|
194
|
+
* @type {number}
|
195
|
+
*/
|
196
|
+
this.executionSuspendedCounter = 0;
|
197
|
+
var layoutDirection = (_userSettings$layoutD = userSettings === null || userSettings === void 0 ? void 0 : userSettings.layoutDirection) !== null && _userSettings$layoutD !== void 0 ? _userSettings$layoutD : 'inherit';
|
198
|
+
var rootElementDirection = ['rtl', 'ltr'].includes(layoutDirection) ? layoutDirection : this.rootWindow.getComputedStyle(this.rootElement).direction;
|
199
|
+
this.rootElement.setAttribute('dir', rootElementDirection);
|
200
|
+
|
201
|
+
/**
|
202
|
+
* Checks if the grid is rendered using the right-to-left layout direction.
|
203
|
+
*
|
204
|
+
* @since 12.0.0
|
205
|
+
* @memberof Core#
|
206
|
+
* @function isRtl
|
207
|
+
* @returns {boolean} True if RTL.
|
208
|
+
*/
|
209
|
+
this.isRtl = function () {
|
210
|
+
return rootElementDirection === 'rtl';
|
211
|
+
};
|
212
|
+
|
213
|
+
/**
|
214
|
+
* Checks if the grid is rendered using the left-to-right layout direction.
|
215
|
+
*
|
216
|
+
* @since 12.0.0
|
217
|
+
* @memberof Core#
|
218
|
+
* @function isLtr
|
219
|
+
* @returns {boolean} True if LTR.
|
220
|
+
*/
|
221
|
+
this.isLtr = function () {
|
222
|
+
return !instance.isRtl();
|
223
|
+
};
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Returns 1 for LTR; -1 for RTL. Useful for calculations.
|
227
|
+
*
|
228
|
+
* @since 12.0.0
|
229
|
+
* @memberof Core#
|
230
|
+
* @function getDirectionFactor
|
231
|
+
* @returns {number} Returns 1 for LTR; -1 for RTL.
|
232
|
+
*/
|
233
|
+
this.getDirectionFactor = function () {
|
234
|
+
return instance.isLtr() ? 1 : -1;
|
235
|
+
};
|
236
|
+
userSettings.language = (0, _registry4.getValidLanguageCode)(userSettings.language);
|
237
|
+
var metaManager = new _dataMap.MetaManager(instance, userSettings, [_dataMap.DynamicCellMetaMod, _dataMap.ExtendMetaPropertiesMod]);
|
238
|
+
var tableMeta = metaManager.getTableMeta();
|
239
|
+
var globalMeta = metaManager.getGlobalMeta();
|
240
|
+
var pluginsRegistry = (0, _uniqueMap.createUniqueMap)();
|
241
|
+
this.container = this.rootDocument.createElement('div');
|
242
|
+
this.renderCall = false;
|
243
|
+
rootElement.insertBefore(this.container, rootElement.firstChild);
|
244
|
+
if ((0, _rootInstance.isRootInstance)(this)) {
|
245
|
+
(0, _mixed._injectProductInfo)(userSettings.licenseKey, rootElement);
|
246
|
+
}
|
247
|
+
this.guid = "ht_".concat((0, _string.randomString)()); // this is the namespace for global events
|
248
|
+
|
249
|
+
/**
|
250
|
+
* Instance of index mapper which is responsible for managing the column indexes.
|
251
|
+
*
|
252
|
+
* @memberof Core#
|
253
|
+
* @member columnIndexMapper
|
254
|
+
* @type {IndexMapper}
|
255
|
+
*/
|
256
|
+
this.columnIndexMapper = new _translations.IndexMapper();
|
257
|
+
/**
|
258
|
+
* Instance of index mapper which is responsible for managing the row indexes.
|
259
|
+
*
|
260
|
+
* @memberof Core#
|
261
|
+
* @member rowIndexMapper
|
262
|
+
* @type {IndexMapper}
|
263
|
+
*/
|
264
|
+
this.rowIndexMapper = new _translations.IndexMapper();
|
265
|
+
dataSource = new _dataSource.default(instance);
|
266
|
+
if (!this.rootElement.id || this.rootElement.id.substring(0, 3) === 'ht_') {
|
267
|
+
this.rootElement.id = this.guid; // if root element does not have an id, assign a random id
|
268
|
+
}
|
269
|
+
|
270
|
+
var visualToRenderableCoords = function visualToRenderableCoords(coords) {
|
271
|
+
var visualRow = coords.row,
|
272
|
+
visualColumn = coords.col;
|
273
|
+
return instance._createCellCoords(
|
274
|
+
// We just store indexes for rows and columns without headers.
|
275
|
+
visualRow >= 0 ? instance.rowIndexMapper.getRenderableFromVisualIndex(visualRow) : visualRow, visualColumn >= 0 ? instance.columnIndexMapper.getRenderableFromVisualIndex(visualColumn) : visualColumn);
|
276
|
+
};
|
277
|
+
var renderableToVisualCoords = function renderableToVisualCoords(coords) {
|
278
|
+
var renderableRow = coords.row,
|
279
|
+
renderableColumn = coords.col;
|
280
|
+
return instance._createCellCoords(
|
281
|
+
// We just store indexes for rows and columns without headers.
|
282
|
+
renderableRow >= 0 ? instance.rowIndexMapper.getVisualFromRenderableIndex(renderableRow) : renderableRow, renderableColumn >= 0 ? instance.columnIndexMapper.getVisualFromRenderableIndex(renderableColumn) : renderableColumn // eslint-disable-line max-len
|
283
|
+
);
|
284
|
+
};
|
285
|
+
|
286
|
+
var selection = new _selection.Selection(tableMeta, {
|
287
|
+
rowIndexMapper: function rowIndexMapper() {
|
288
|
+
return instance.rowIndexMapper;
|
289
|
+
},
|
290
|
+
columnIndexMapper: function columnIndexMapper() {
|
291
|
+
return instance.columnIndexMapper;
|
292
|
+
},
|
293
|
+
countCols: function countCols() {
|
294
|
+
return instance.countCols();
|
295
|
+
},
|
296
|
+
countRows: function countRows() {
|
297
|
+
return instance.countRows();
|
298
|
+
},
|
299
|
+
propToCol: function propToCol(prop) {
|
300
|
+
return datamap.propToCol(prop);
|
301
|
+
},
|
302
|
+
isEditorOpened: function isEditorOpened() {
|
303
|
+
return instance.getActiveEditor() ? instance.getActiveEditor().isOpened() : false;
|
304
|
+
},
|
305
|
+
countColsTranslated: function countColsTranslated() {
|
306
|
+
return _this.view.countRenderableColumns();
|
307
|
+
},
|
308
|
+
countRowsTranslated: function countRowsTranslated() {
|
309
|
+
return _this.view.countRenderableRows();
|
310
|
+
},
|
311
|
+
getShortcutManager: function getShortcutManager() {
|
312
|
+
return instance.getShortcutManager();
|
313
|
+
},
|
314
|
+
createCellCoords: function createCellCoords(row, column) {
|
315
|
+
return instance._createCellCoords(row, column);
|
316
|
+
},
|
317
|
+
createCellRange: function createCellRange(highlight, from, to) {
|
318
|
+
return instance._createCellRange(highlight, from, to);
|
319
|
+
},
|
320
|
+
visualToRenderableCoords: visualToRenderableCoords,
|
321
|
+
renderableToVisualCoords: renderableToVisualCoords,
|
322
|
+
isDisabledCellSelection: function isDisabledCellSelection(visualRow, visualColumn) {
|
323
|
+
return instance.getCellMeta(visualRow, visualColumn).disableVisualSelection;
|
324
|
+
}
|
325
|
+
});
|
326
|
+
this.selection = selection;
|
327
|
+
var onIndexMapperCacheUpdate = function onIndexMapperCacheUpdate(_ref) {
|
328
|
+
var hiddenIndexesChanged = _ref.hiddenIndexesChanged;
|
329
|
+
if (hiddenIndexesChanged) {
|
330
|
+
_this.selection.refresh();
|
331
|
+
}
|
332
|
+
};
|
333
|
+
this.columnIndexMapper.addLocalHook('cacheUpdated', onIndexMapperCacheUpdate);
|
334
|
+
this.rowIndexMapper.addLocalHook('cacheUpdated', onIndexMapperCacheUpdate);
|
335
|
+
this.selection.addLocalHook('beforeSetRangeStart', function (cellCoords) {
|
336
|
+
_this.runHooks('beforeSetRangeStart', cellCoords);
|
337
|
+
});
|
338
|
+
this.selection.addLocalHook('beforeSetRangeStartOnly', function (cellCoords) {
|
339
|
+
_this.runHooks('beforeSetRangeStartOnly', cellCoords);
|
340
|
+
});
|
341
|
+
this.selection.addLocalHook('beforeSetRangeEnd', function (cellCoords) {
|
342
|
+
_this.runHooks('beforeSetRangeEnd', cellCoords);
|
343
|
+
if (cellCoords.row < 0) {
|
344
|
+
cellCoords.row = _this.view._wt.wtTable.getFirstVisibleRow();
|
345
|
+
}
|
346
|
+
if (cellCoords.col < 0) {
|
347
|
+
cellCoords.col = _this.view._wt.wtTable.getFirstVisibleColumn();
|
348
|
+
}
|
349
|
+
});
|
350
|
+
this.selection.addLocalHook('afterSetRangeEnd', function (cellCoords) {
|
351
|
+
var preventScrolling = (0, _object.createObjectPropListener)(false);
|
352
|
+
var selectionRange = _this.selection.getSelectedRange();
|
353
|
+
var _selectionRange$curre = selectionRange.current(),
|
354
|
+
from = _selectionRange$curre.from,
|
355
|
+
to = _selectionRange$curre.to;
|
356
|
+
var selectionLayerLevel = selectionRange.size() - 1;
|
357
|
+
_this.runHooks('afterSelection', from.row, from.col, to.row, to.col, preventScrolling, selectionLayerLevel);
|
358
|
+
_this.runHooks('afterSelectionByProp', from.row, instance.colToProp(from.col), to.row, instance.colToProp(to.col), preventScrolling, selectionLayerLevel); // eslint-disable-line max-len
|
359
|
+
|
360
|
+
var isSelectedByAnyHeader = _this.selection.isSelectedByAnyHeader();
|
361
|
+
var currentSelectedRange = _this.selection.selectedRange.current();
|
362
|
+
var scrollToCell = true;
|
363
|
+
if (preventScrollingToCell) {
|
364
|
+
scrollToCell = false;
|
365
|
+
}
|
366
|
+
if (preventScrolling.isTouched()) {
|
367
|
+
scrollToCell = !preventScrolling.value;
|
368
|
+
}
|
369
|
+
var isSelectedByRowHeader = _this.selection.isSelectedByRowHeader();
|
370
|
+
var isSelectedByColumnHeader = _this.selection.isSelectedByColumnHeader();
|
371
|
+
if (scrollToCell !== false) {
|
372
|
+
if (!isSelectedByAnyHeader) {
|
373
|
+
if (currentSelectedRange && !_this.selection.isMultiple()) {
|
374
|
+
_this.view.scrollViewport(visualToRenderableCoords(currentSelectedRange.from));
|
375
|
+
} else {
|
376
|
+
_this.view.scrollViewport(visualToRenderableCoords(cellCoords));
|
377
|
+
}
|
378
|
+
} else if (isSelectedByRowHeader) {
|
379
|
+
_this.view.scrollViewportVertically(instance.rowIndexMapper.getRenderableFromVisualIndex(cellCoords.row));
|
380
|
+
} else if (isSelectedByColumnHeader) {
|
381
|
+
_this.view.scrollViewportHorizontally(instance.columnIndexMapper.getRenderableFromVisualIndex(cellCoords.col));
|
382
|
+
}
|
383
|
+
}
|
384
|
+
|
385
|
+
// @TODO: These CSS classes are no longer needed anymore. They are used only as a indicator of the selected
|
386
|
+
// rows/columns in the MergedCells plugin (via border.js#L520 in the walkontable module). After fixing
|
387
|
+
// the Border class this should be removed.
|
388
|
+
if (isSelectedByRowHeader && isSelectedByColumnHeader) {
|
389
|
+
(0, _element.addClass)(_this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
|
390
|
+
} else if (isSelectedByRowHeader) {
|
391
|
+
(0, _element.removeClass)(_this.rootElement, 'ht__selection--columns');
|
392
|
+
(0, _element.addClass)(_this.rootElement, 'ht__selection--rows');
|
393
|
+
} else if (isSelectedByColumnHeader) {
|
394
|
+
(0, _element.removeClass)(_this.rootElement, 'ht__selection--rows');
|
395
|
+
(0, _element.addClass)(_this.rootElement, 'ht__selection--columns');
|
396
|
+
} else {
|
397
|
+
(0, _element.removeClass)(_this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
|
398
|
+
}
|
399
|
+
_this._refreshBorders(null);
|
400
|
+
});
|
401
|
+
this.selection.addLocalHook('afterSelectionFinished', function (cellRanges) {
|
402
|
+
var selectionLayerLevel = cellRanges.length - 1;
|
403
|
+
var _cellRanges$selection = cellRanges[selectionLayerLevel],
|
404
|
+
from = _cellRanges$selection.from,
|
405
|
+
to = _cellRanges$selection.to;
|
406
|
+
_this.runHooks('afterSelectionEnd', from.row, from.col, to.row, to.col, selectionLayerLevel);
|
407
|
+
_this.runHooks('afterSelectionEndByProp', from.row, instance.colToProp(from.col), to.row, instance.colToProp(to.col), selectionLayerLevel);
|
408
|
+
});
|
409
|
+
this.selection.addLocalHook('afterIsMultipleSelection', function (isMultiple) {
|
410
|
+
var changedIsMultiple = _this.runHooks('afterIsMultipleSelection', isMultiple.value);
|
411
|
+
if (isMultiple.value) {
|
412
|
+
isMultiple.value = changedIsMultiple;
|
413
|
+
}
|
414
|
+
});
|
415
|
+
this.selection.addLocalHook('beforeModifyTransformStart', function (cellCoordsDelta) {
|
416
|
+
_this.runHooks('modifyTransformStart', cellCoordsDelta);
|
417
|
+
});
|
418
|
+
this.selection.addLocalHook('afterModifyTransformStart', function (coords, rowTransformDir, colTransformDir) {
|
419
|
+
_this.runHooks('afterModifyTransformStart', coords, rowTransformDir, colTransformDir);
|
420
|
+
});
|
421
|
+
this.selection.addLocalHook('beforeModifyTransformEnd', function (cellCoordsDelta) {
|
422
|
+
_this.runHooks('modifyTransformEnd', cellCoordsDelta);
|
423
|
+
});
|
424
|
+
this.selection.addLocalHook('afterModifyTransformEnd', function (coords, rowTransformDir, colTransformDir) {
|
425
|
+
_this.runHooks('afterModifyTransformEnd', coords, rowTransformDir, colTransformDir);
|
426
|
+
});
|
427
|
+
this.selection.addLocalHook('afterDeselect', function () {
|
428
|
+
editorManager.destroyEditor();
|
429
|
+
_this._refreshBorders();
|
430
|
+
(0, _element.removeClass)(_this.rootElement, ['ht__selection--rows', 'ht__selection--columns']);
|
431
|
+
_this.runHooks('afterDeselect');
|
432
|
+
});
|
433
|
+
this.selection.addLocalHook('insertRowRequire', function (totalRows) {
|
434
|
+
_this.alter('insert_row_above', totalRows, 1, 'auto');
|
435
|
+
});
|
436
|
+
this.selection.addLocalHook('insertColRequire', function (totalCols) {
|
437
|
+
_this.alter('insert_col_start', totalCols, 1, 'auto');
|
438
|
+
});
|
439
|
+
grid = {
|
440
|
+
/**
|
441
|
+
* Inserts or removes rows and columns.
|
442
|
+
*
|
443
|
+
* @private
|
444
|
+
* @param {string} action Possible values: "insert_row_above", "insert_row_below", "insert_col_start", "insert_col_end",
|
445
|
+
* "remove_row", "remove_col".
|
446
|
+
* @param {number|Array} index Row or column visual index which from the alter action will be triggered.
|
447
|
+
* Alter actions such as "remove_row" and "remove_col" support array indexes in the
|
448
|
+
* format `[[index, amount], [index, amount]...]` this can be used to remove
|
449
|
+
* non-consecutive columns or rows in one call.
|
450
|
+
* @param {number} [amount=1] Amount of rows or columns to remove.
|
451
|
+
* @param {string} [source] Optional. Source of hook runner.
|
452
|
+
* @param {boolean} [keepEmptyRows] Optional. Flag for preventing deletion of empty rows.
|
453
|
+
*/
|
454
|
+
alter: function alter(action, index) {
|
455
|
+
var _index, _index2;
|
456
|
+
var amount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
457
|
+
var source = arguments.length > 3 ? arguments[3] : undefined;
|
458
|
+
var keepEmptyRows = arguments.length > 4 ? arguments[4] : undefined;
|
459
|
+
var normalizeIndexesGroup = function normalizeIndexesGroup(indexes) {
|
460
|
+
if (indexes.length === 0) {
|
461
|
+
return [];
|
462
|
+
}
|
463
|
+
var sortedIndexes = _toConsumableArray(indexes);
|
464
|
+
|
465
|
+
// Sort the indexes in ascending order.
|
466
|
+
sortedIndexes.sort(function (_ref2, _ref3) {
|
467
|
+
var _ref4 = _slicedToArray(_ref2, 1),
|
468
|
+
indexA = _ref4[0];
|
469
|
+
var _ref5 = _slicedToArray(_ref3, 1),
|
470
|
+
indexB = _ref5[0];
|
471
|
+
if (indexA === indexB) {
|
472
|
+
return 0;
|
473
|
+
}
|
474
|
+
return indexA > indexB ? 1 : -1;
|
475
|
+
});
|
476
|
+
|
477
|
+
// Normalize the {index, amount} groups into bigger groups.
|
478
|
+
var normalizedIndexes = (0, _array.arrayReduce)(sortedIndexes, function (acc, _ref6) {
|
479
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
480
|
+
groupIndex = _ref7[0],
|
481
|
+
groupAmount = _ref7[1];
|
482
|
+
var previousItem = acc[acc.length - 1];
|
483
|
+
var _previousItem = _slicedToArray(previousItem, 2),
|
484
|
+
prevIndex = _previousItem[0],
|
485
|
+
prevAmount = _previousItem[1];
|
486
|
+
var prevLastIndex = prevIndex + prevAmount;
|
487
|
+
if (groupIndex <= prevLastIndex) {
|
488
|
+
var amountToAdd = Math.max(groupAmount - (prevLastIndex - groupIndex), 0);
|
489
|
+
previousItem[1] += amountToAdd;
|
490
|
+
} else {
|
491
|
+
acc.push([groupIndex, groupAmount]);
|
492
|
+
}
|
493
|
+
return acc;
|
494
|
+
}, [sortedIndexes[0]]);
|
495
|
+
return normalizedIndexes;
|
496
|
+
};
|
497
|
+
|
498
|
+
/* eslint-disable no-case-declarations */
|
499
|
+
switch (action) {
|
500
|
+
case 'insert_row':
|
501
|
+
// backward compatibility
|
502
|
+
if (!deprecationWarns.has(action)) {
|
503
|
+
deprecationWarns.add(action);
|
504
|
+
(0, _console.warn)((0, _templateLiteralTag.toSingleLine)(_templateObject || (_templateObject = _taggedTemplateLiteral(["The `", "` action of the `alter()` method is deprecated and will be removed \n in the next major release of Handsontable. Use the `insert_row_above` action instead."], ["The \\`", "\\` action of the \\`alter()\\` method is deprecated and will be removed\\x20\n in the next major release of Handsontable. Use the \\`insert_row_above\\` action instead."])), action));
|
505
|
+
}
|
506
|
+
// falls through
|
507
|
+
case 'insert_row_below':
|
508
|
+
case 'insert_row_above':
|
509
|
+
var numberOfSourceRows = instance.countSourceRows();
|
510
|
+
if (tableMeta.maxRows === numberOfSourceRows) {
|
511
|
+
return;
|
512
|
+
}
|
513
|
+
|
514
|
+
// `above` is the default behavior for creating new rows
|
515
|
+
var insertRowMode = action === 'insert_row_below' ? 'below' : 'above';
|
516
|
+
|
517
|
+
// The line below ensures backward compatibility of the `alter()` method's `insert_row` action.
|
518
|
+
// Calling the `insert_row` action with no arguments adds a new row at the end of the data set.
|
519
|
+
// Calling the `insert_row_above` action adds a new row at the beginning of the data set.
|
520
|
+
// eslint-disable-next-line no-param-reassign
|
521
|
+
index = (_index = index) !== null && _index !== void 0 ? _index : action === 'insert_row' || insertRowMode === 'below' ? numberOfSourceRows : 0;
|
522
|
+
var _datamap$createRow = datamap.createRow(index, amount, {
|
523
|
+
source: source,
|
524
|
+
mode: insertRowMode
|
525
|
+
}),
|
526
|
+
rowDelta = _datamap$createRow.delta,
|
527
|
+
startRowPhysicalIndex = _datamap$createRow.startPhysicalIndex;
|
528
|
+
if (rowDelta) {
|
529
|
+
metaManager.createRow(startRowPhysicalIndex, amount);
|
530
|
+
var currentSelectedRange = selection.selectedRange.current();
|
531
|
+
var currentFromRange = currentSelectedRange === null || currentSelectedRange === void 0 ? void 0 : currentSelectedRange.from;
|
532
|
+
var currentFromRow = currentFromRange === null || currentFromRange === void 0 ? void 0 : currentFromRange.row;
|
533
|
+
var startVisualRowIndex = instance.toVisualRow(startRowPhysicalIndex);
|
534
|
+
if (selection.isSelectedByCorner()) {
|
535
|
+
instance.selectAll();
|
536
|
+
} else if ((0, _mixed.isDefined)(currentFromRow) && currentFromRow >= startVisualRowIndex) {
|
537
|
+
// Moving the selection (if it exists) downward – it should be applied to the "old" row.
|
538
|
+
// TODO: The logic here should be handled by selection module.
|
539
|
+
var _currentSelectedRange = currentSelectedRange.to,
|
540
|
+
currentToRow = _currentSelectedRange.row,
|
541
|
+
currentToColumn = _currentSelectedRange.col;
|
542
|
+
var currentFromColumn = currentFromRange.col;
|
543
|
+
|
544
|
+
// Workaround: headers are not stored inside selection.
|
545
|
+
if (selection.isSelectedByRowHeader()) {
|
546
|
+
currentFromColumn = -1;
|
547
|
+
}
|
548
|
+
|
549
|
+
// Remove from the stack the last added selection as that selection below will be
|
550
|
+
// replaced by new transformed selection.
|
551
|
+
selection.getSelectedRange().pop();
|
552
|
+
// I can't use transforms as they don't work in negative indexes.
|
553
|
+
selection.setRangeStartOnly(instance._createCellCoords(currentFromRow + rowDelta, currentFromColumn), true);
|
554
|
+
selection.setRangeEnd(instance._createCellCoords(currentToRow + rowDelta, currentToColumn)); // will call render() internally
|
555
|
+
} else {
|
556
|
+
instance._refreshBorders(); // it will call render and prepare methods
|
557
|
+
}
|
558
|
+
}
|
559
|
+
|
560
|
+
break;
|
561
|
+
case 'insert_col':
|
562
|
+
// backward compatibility
|
563
|
+
if (!deprecationWarns.has(action)) {
|
564
|
+
deprecationWarns.add(action);
|
565
|
+
(0, _console.warn)((0, _templateLiteralTag.toSingleLine)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["The `", "` action of the `alter()` method is deprecated and will be removed \n in the next major release of Handsontable. Use the `insert_col_start` action instead."], ["The \\`", "\\` action of the \\`alter()\\` method is deprecated and will be removed\\x20\n in the next major release of Handsontable. Use the \\`insert_col_start\\` action instead."])), action));
|
566
|
+
}
|
567
|
+
// falls through
|
568
|
+
case 'insert_col_start':
|
569
|
+
case 'insert_col_end':
|
570
|
+
// "start" is a default behavior for creating new columns
|
571
|
+
var insertColumnMode = action === 'insert_col_end' ? 'end' : 'start';
|
572
|
+
|
573
|
+
// The line below ensures backward compatibility of the `alter()` method's `insert_col` action.
|
574
|
+
// Calling the `insert_col` action with no arguments adds a new column to the right of the data set.
|
575
|
+
// Calling the `insert_col_start` action adds a new column to the left of the data set.
|
576
|
+
// eslint-disable-next-line no-param-reassign
|
577
|
+
index = (_index2 = index) !== null && _index2 !== void 0 ? _index2 : action === 'insert_col' || insertColumnMode === 'end' ? instance.countSourceCols() : 0;
|
578
|
+
var _datamap$createCol = datamap.createCol(index, amount, {
|
579
|
+
source: source,
|
580
|
+
mode: insertColumnMode
|
581
|
+
}),
|
582
|
+
colDelta = _datamap$createCol.delta,
|
583
|
+
startColumnPhysicalIndex = _datamap$createCol.startPhysicalIndex;
|
584
|
+
if (colDelta) {
|
585
|
+
metaManager.createColumn(startColumnPhysicalIndex, amount);
|
586
|
+
if (Array.isArray(tableMeta.colHeaders)) {
|
587
|
+
var spliceArray = [instance.toVisualColumn(startColumnPhysicalIndex), 0];
|
588
|
+
spliceArray.length += colDelta; // inserts empty (undefined) elements at the end of an array
|
589
|
+
Array.prototype.splice.apply(tableMeta.colHeaders, spliceArray); // inserts empty (undefined) elements into the colHeader array
|
590
|
+
}
|
591
|
+
|
592
|
+
var _currentSelectedRange2 = selection.selectedRange.current();
|
593
|
+
var _currentFromRange = _currentSelectedRange2 === null || _currentSelectedRange2 === void 0 ? void 0 : _currentSelectedRange2.from;
|
594
|
+
var _currentFromColumn = _currentFromRange === null || _currentFromRange === void 0 ? void 0 : _currentFromRange.col;
|
595
|
+
var startVisualColumnIndex = instance.toVisualColumn(startColumnPhysicalIndex);
|
596
|
+
if (selection.isSelectedByCorner()) {
|
597
|
+
instance.selectAll();
|
598
|
+
} else if ((0, _mixed.isDefined)(_currentFromColumn) && _currentFromColumn >= startVisualColumnIndex) {
|
599
|
+
// Moving the selection (if it exists) rightward – it should be applied to the "old" column.
|
600
|
+
// TODO: The logic here should be handled by selection module.
|
601
|
+
var _currentSelectedRange3 = _currentSelectedRange2.to,
|
602
|
+
_currentToRow = _currentSelectedRange3.row,
|
603
|
+
_currentToColumn = _currentSelectedRange3.col;
|
604
|
+
var _currentFromRow = _currentFromRange.row;
|
605
|
+
|
606
|
+
// Workaround: headers are not stored inside selection.
|
607
|
+
if (selection.isSelectedByColumnHeader()) {
|
608
|
+
_currentFromRow = -1;
|
609
|
+
}
|
610
|
+
|
611
|
+
// Remove from the stack the last added selection as that selection below will be
|
612
|
+
// replaced by new transformed selection.
|
613
|
+
selection.getSelectedRange().pop();
|
614
|
+
|
615
|
+
// I can't use transforms as they don't work in negative indexes.
|
616
|
+
selection.setRangeStartOnly(instance._createCellCoords(_currentFromRow, _currentFromColumn + colDelta), true);
|
617
|
+
selection.setRangeEnd(instance._createCellCoords(_currentToRow, _currentToColumn + colDelta)); // will call render() internally
|
618
|
+
} else {
|
619
|
+
instance._refreshBorders(); // it will call render and prepare methods
|
620
|
+
}
|
621
|
+
}
|
622
|
+
|
623
|
+
break;
|
624
|
+
case 'remove_row':
|
625
|
+
var removeRow = function removeRow(indexes) {
|
626
|
+
var offset = 0;
|
627
|
+
|
628
|
+
// Normalize the {index, amount} groups into bigger groups.
|
629
|
+
(0, _array.arrayEach)(indexes, function (_ref8) {
|
630
|
+
var _ref9 = _slicedToArray(_ref8, 2),
|
631
|
+
groupIndex = _ref9[0],
|
632
|
+
groupAmount = _ref9[1];
|
633
|
+
var calcIndex = (0, _mixed.isEmpty)(groupIndex) ? instance.countRows() - 1 : Math.max(groupIndex - offset, 0);
|
634
|
+
|
635
|
+
// If the 'index' is an integer decrease it by 'offset' otherwise pass it through to make the value
|
636
|
+
// compatible with datamap.removeCol method.
|
637
|
+
if (Number.isInteger(groupIndex)) {
|
638
|
+
// eslint-disable-next-line no-param-reassign
|
639
|
+
groupIndex = Math.max(groupIndex - offset, 0);
|
640
|
+
}
|
641
|
+
|
642
|
+
// TODO: for datamap.removeRow index should be passed as it is (with undefined and null values). If not, the logic
|
643
|
+
// inside the datamap.removeRow breaks the removing functionality.
|
644
|
+
var wasRemoved = datamap.removeRow(groupIndex, groupAmount, source);
|
645
|
+
if (!wasRemoved) {
|
646
|
+
return;
|
647
|
+
}
|
648
|
+
metaManager.removeRow(instance.toPhysicalRow(calcIndex), groupAmount);
|
649
|
+
var totalRows = instance.countRows();
|
650
|
+
var fixedRowsTop = tableMeta.fixedRowsTop;
|
651
|
+
if (fixedRowsTop >= calcIndex + 1) {
|
652
|
+
tableMeta.fixedRowsTop -= Math.min(groupAmount, fixedRowsTop - calcIndex);
|
653
|
+
}
|
654
|
+
var fixedRowsBottom = tableMeta.fixedRowsBottom;
|
655
|
+
if (fixedRowsBottom && calcIndex >= totalRows - fixedRowsBottom) {
|
656
|
+
tableMeta.fixedRowsBottom -= Math.min(groupAmount, fixedRowsBottom);
|
657
|
+
}
|
658
|
+
offset += groupAmount;
|
659
|
+
});
|
660
|
+
};
|
661
|
+
if (Array.isArray(index)) {
|
662
|
+
removeRow(normalizeIndexesGroup(index));
|
663
|
+
} else {
|
664
|
+
removeRow([[index, amount]]);
|
665
|
+
}
|
666
|
+
grid.adjustRowsAndCols();
|
667
|
+
instance._refreshBorders(); // it will call render and prepare methods
|
668
|
+
break;
|
669
|
+
case 'remove_col':
|
670
|
+
var removeCol = function removeCol(indexes) {
|
671
|
+
var offset = 0;
|
672
|
+
|
673
|
+
// Normalize the {index, amount} groups into bigger groups.
|
674
|
+
(0, _array.arrayEach)(indexes, function (_ref10) {
|
675
|
+
var _ref11 = _slicedToArray(_ref10, 2),
|
676
|
+
groupIndex = _ref11[0],
|
677
|
+
groupAmount = _ref11[1];
|
678
|
+
var calcIndex = (0, _mixed.isEmpty)(groupIndex) ? instance.countCols() - 1 : Math.max(groupIndex - offset, 0);
|
679
|
+
var physicalColumnIndex = instance.toPhysicalColumn(calcIndex);
|
680
|
+
|
681
|
+
// If the 'index' is an integer decrease it by 'offset' otherwise pass it through to make the value
|
682
|
+
// compatible with datamap.removeCol method.
|
683
|
+
if (Number.isInteger(groupIndex)) {
|
684
|
+
// eslint-disable-next-line no-param-reassign
|
685
|
+
groupIndex = Math.max(groupIndex - offset, 0);
|
686
|
+
}
|
687
|
+
|
688
|
+
// TODO: for datamap.removeCol index should be passed as it is (with undefined and null values). If not, the logic
|
689
|
+
// inside the datamap.removeCol breaks the removing functionality.
|
690
|
+
var wasRemoved = datamap.removeCol(groupIndex, groupAmount, source);
|
691
|
+
if (!wasRemoved) {
|
692
|
+
return;
|
693
|
+
}
|
694
|
+
metaManager.removeColumn(physicalColumnIndex, groupAmount);
|
695
|
+
var fixedColumnsStart = tableMeta.fixedColumnsStart;
|
696
|
+
if (fixedColumnsStart >= calcIndex + 1) {
|
697
|
+
tableMeta.fixedColumnsStart -= Math.min(groupAmount, fixedColumnsStart - calcIndex);
|
698
|
+
}
|
699
|
+
if (Array.isArray(tableMeta.colHeaders)) {
|
700
|
+
if (typeof physicalColumnIndex === 'undefined') {
|
701
|
+
physicalColumnIndex = -1;
|
702
|
+
}
|
703
|
+
tableMeta.colHeaders.splice(physicalColumnIndex, groupAmount);
|
704
|
+
}
|
705
|
+
offset += groupAmount;
|
706
|
+
});
|
707
|
+
};
|
708
|
+
if (Array.isArray(index)) {
|
709
|
+
removeCol(normalizeIndexesGroup(index));
|
710
|
+
} else {
|
711
|
+
removeCol([[index, amount]]);
|
712
|
+
}
|
713
|
+
grid.adjustRowsAndCols();
|
714
|
+
instance._refreshBorders(); // it will call render and prepare methods
|
715
|
+
|
716
|
+
break;
|
717
|
+
default:
|
718
|
+
throw new Error("There is no such action \"".concat(action, "\""));
|
719
|
+
}
|
720
|
+
if (!keepEmptyRows) {
|
721
|
+
grid.adjustRowsAndCols(); // makes sure that we did not add rows that will be removed in next refresh
|
722
|
+
}
|
723
|
+
},
|
724
|
+
/**
|
725
|
+
* Makes sure there are empty rows at the bottom of the table.
|
726
|
+
*
|
727
|
+
* @private
|
728
|
+
*/
|
729
|
+
adjustRowsAndCols: function adjustRowsAndCols() {
|
730
|
+
var minRows = tableMeta.minRows;
|
731
|
+
var minSpareRows = tableMeta.minSpareRows;
|
732
|
+
var minCols = tableMeta.minCols;
|
733
|
+
var minSpareCols = tableMeta.minSpareCols;
|
734
|
+
if (instance.countRows() === 0 && instance.countCols() === 0) {
|
735
|
+
selection.deselect();
|
736
|
+
}
|
737
|
+
if (minRows) {
|
738
|
+
// should I add empty rows to data source to meet minRows?
|
739
|
+
var nrOfRows = instance.countRows();
|
740
|
+
if (nrOfRows < minRows) {
|
741
|
+
// The synchronization with cell meta is not desired here. For `minRows` option,
|
742
|
+
// we don't want to touch/shift cell meta objects.
|
743
|
+
datamap.createRow(nrOfRows, minRows - nrOfRows, {
|
744
|
+
source: 'auto'
|
745
|
+
});
|
746
|
+
}
|
747
|
+
}
|
748
|
+
if (minSpareRows) {
|
749
|
+
var emptyRows = instance.countEmptyRows(true);
|
750
|
+
|
751
|
+
// should I add empty rows to meet minSpareRows?
|
752
|
+
if (emptyRows < minSpareRows) {
|
753
|
+
var emptyRowsMissing = minSpareRows - emptyRows;
|
754
|
+
var rowsToCreate = Math.min(emptyRowsMissing, tableMeta.maxRows - instance.countSourceRows());
|
755
|
+
|
756
|
+
// The synchronization with cell meta is not desired here. For `minSpareRows` option,
|
757
|
+
// we don't want to touch/shift cell meta objects.
|
758
|
+
datamap.createRow(instance.countRows(), rowsToCreate, {
|
759
|
+
source: 'auto'
|
760
|
+
});
|
761
|
+
}
|
762
|
+
}
|
763
|
+
{
|
764
|
+
var emptyCols;
|
765
|
+
|
766
|
+
// count currently empty cols
|
767
|
+
if (minCols || minSpareCols) {
|
768
|
+
emptyCols = instance.countEmptyCols(true);
|
769
|
+
}
|
770
|
+
var nrOfColumns = instance.countCols();
|
771
|
+
|
772
|
+
// should I add empty cols to meet minCols?
|
773
|
+
if (minCols && !tableMeta.columns && nrOfColumns < minCols) {
|
774
|
+
// The synchronization with cell meta is not desired here. For `minSpareRows` option,
|
775
|
+
// we don't want to touch/shift cell meta objects.
|
776
|
+
var colsToCreate = minCols - nrOfColumns;
|
777
|
+
emptyCols += colsToCreate;
|
778
|
+
datamap.createCol(nrOfColumns, colsToCreate, {
|
779
|
+
source: 'auto'
|
780
|
+
});
|
781
|
+
}
|
782
|
+
// should I add empty cols to meet minSpareCols?
|
783
|
+
if (minSpareCols && !tableMeta.columns && instance.dataType === 'array' && emptyCols < minSpareCols) {
|
784
|
+
nrOfColumns = instance.countCols();
|
785
|
+
var emptyColsMissing = minSpareCols - emptyCols;
|
786
|
+
var _colsToCreate = Math.min(emptyColsMissing, tableMeta.maxCols - nrOfColumns);
|
787
|
+
|
788
|
+
// The synchronization with cell meta is not desired here. For `minSpareRows` option,
|
789
|
+
// we don't want to touch/shift cell meta objects.
|
790
|
+
datamap.createCol(nrOfColumns, _colsToCreate, {
|
791
|
+
source: 'auto'
|
792
|
+
});
|
793
|
+
}
|
794
|
+
}
|
795
|
+
if (selection.isSelected()) {
|
796
|
+
var rowCount = instance.countRows();
|
797
|
+
var colCount = instance.countCols();
|
798
|
+
(0, _array.arrayEach)(selection.selectedRange, function (range) {
|
799
|
+
var selectionChanged = false;
|
800
|
+
var fromRow = range.from.row;
|
801
|
+
var fromCol = range.from.col;
|
802
|
+
var toRow = range.to.row;
|
803
|
+
var toCol = range.to.col;
|
804
|
+
|
805
|
+
// if selection is outside, move selection to last row
|
806
|
+
if (fromRow > rowCount - 1) {
|
807
|
+
fromRow = rowCount - 1;
|
808
|
+
selectionChanged = true;
|
809
|
+
if (toRow > fromRow) {
|
810
|
+
toRow = fromRow;
|
811
|
+
}
|
812
|
+
} else if (toRow > rowCount - 1) {
|
813
|
+
toRow = rowCount - 1;
|
814
|
+
selectionChanged = true;
|
815
|
+
if (fromRow > toRow) {
|
816
|
+
fromRow = toRow;
|
817
|
+
}
|
818
|
+
}
|
819
|
+
// if selection is outside, move selection to last row
|
820
|
+
if (fromCol > colCount - 1) {
|
821
|
+
fromCol = colCount - 1;
|
822
|
+
selectionChanged = true;
|
823
|
+
if (toCol > fromCol) {
|
824
|
+
toCol = fromCol;
|
825
|
+
}
|
826
|
+
} else if (toCol > colCount - 1) {
|
827
|
+
toCol = colCount - 1;
|
828
|
+
selectionChanged = true;
|
829
|
+
if (fromCol > toCol) {
|
830
|
+
fromCol = toCol;
|
831
|
+
}
|
832
|
+
}
|
833
|
+
if (selectionChanged) {
|
834
|
+
instance.selectCell(fromRow, fromCol, toRow, toCol);
|
835
|
+
}
|
836
|
+
});
|
837
|
+
}
|
838
|
+
if (instance.view) {
|
839
|
+
instance.view.adjustElementsSize();
|
840
|
+
}
|
841
|
+
},
|
842
|
+
/**
|
843
|
+
* Populate the data from the provided 2d array from the given cell coordinates.
|
844
|
+
*
|
845
|
+
* @private
|
846
|
+
* @param {object} start Start selection position. Visual indexes.
|
847
|
+
* @param {Array} input 2d data array.
|
848
|
+
* @param {object} [end] End selection position (only for drag-down mode). Visual indexes.
|
849
|
+
* @param {string} [source="populateFromArray"] Source information string.
|
850
|
+
* @param {string} [method="overwrite"] Populate method. Possible options: `shift_down`, `shift_right`, `overwrite`.
|
851
|
+
* @param {string} direction (left|right|up|down) String specifying the direction.
|
852
|
+
* @param {Array} deltas The deltas array. A difference between values of adjacent cells.
|
853
|
+
* Useful **only** when the type of handled cells is `numeric`.
|
854
|
+
* @returns {object|undefined} Ending td in pasted area (only if any cell was changed).
|
855
|
+
*/
|
856
|
+
populateFromArray: function populateFromArray(start, input, end, source, method, direction, deltas) {
|
857
|
+
// TODO: either remove or implement the `direction` argument. Currently it's not working at all.
|
858
|
+
var r;
|
859
|
+
var rlen;
|
860
|
+
var c;
|
861
|
+
var clen;
|
862
|
+
var setData = [];
|
863
|
+
var current = {};
|
864
|
+
var newDataByColumns = [];
|
865
|
+
var startRow = start.row;
|
866
|
+
var startColumn = start.col;
|
867
|
+
rlen = input.length;
|
868
|
+
if (rlen === 0) {
|
869
|
+
return false;
|
870
|
+
}
|
871
|
+
var columnsPopulationEnd = 0;
|
872
|
+
var rowsPopulationEnd = 0;
|
873
|
+
if ((0, _object.isObject)(end)) {
|
874
|
+
columnsPopulationEnd = end.col - startColumn + 1;
|
875
|
+
rowsPopulationEnd = end.row - startRow + 1;
|
876
|
+
}
|
877
|
+
|
878
|
+
// insert data with specified pasteMode method
|
879
|
+
switch (method) {
|
880
|
+
case 'shift_down':
|
881
|
+
// translate data from a list of rows to a list of columns
|
882
|
+
var populatedDataByColumns = (0, _array.pivot)(input);
|
883
|
+
var numberOfDataColumns = populatedDataByColumns.length;
|
884
|
+
// method's argument can extend the range of data population (data would be repeated)
|
885
|
+
var numberOfColumnsToPopulate = Math.max(numberOfDataColumns, columnsPopulationEnd);
|
886
|
+
var pushedDownDataByRows = instance.getData().slice(startRow);
|
887
|
+
|
888
|
+
// translate data from a list of rows to a list of columns
|
889
|
+
var pushedDownDataByColumns = (0, _array.pivot)(pushedDownDataByRows).slice(startColumn, startColumn + numberOfColumnsToPopulate);
|
890
|
+
for (c = 0; c < numberOfColumnsToPopulate; c += 1) {
|
891
|
+
if (c < numberOfDataColumns) {
|
892
|
+
for (r = 0, rlen = populatedDataByColumns[c].length; r < rowsPopulationEnd - rlen; r += 1) {
|
893
|
+
// repeating data for rows
|
894
|
+
populatedDataByColumns[c].push(populatedDataByColumns[c][r % rlen]);
|
895
|
+
}
|
896
|
+
if (c < pushedDownDataByColumns.length) {
|
897
|
+
newDataByColumns.push(populatedDataByColumns[c].concat(pushedDownDataByColumns[c]));
|
898
|
+
} else {
|
899
|
+
// if before data population, there was no data in the column
|
900
|
+
// we fill the required rows' newly-created cells with `null` values
|
901
|
+
newDataByColumns.push(populatedDataByColumns[c].concat(new Array(pushedDownDataByRows.length).fill(null)));
|
902
|
+
}
|
903
|
+
} else {
|
904
|
+
// Repeating data for columns.
|
905
|
+
newDataByColumns.push(populatedDataByColumns[c % numberOfDataColumns].concat(pushedDownDataByColumns[c]));
|
906
|
+
}
|
907
|
+
}
|
908
|
+
instance.populateFromArray(startRow, startColumn, (0, _array.pivot)(newDataByColumns));
|
909
|
+
break;
|
910
|
+
case 'shift_right':
|
911
|
+
var numberOfDataRows = input.length;
|
912
|
+
// method's argument can extend the range of data population (data would be repeated)
|
913
|
+
var numberOfRowsToPopulate = Math.max(numberOfDataRows, rowsPopulationEnd);
|
914
|
+
var pushedRightDataByRows = instance.getData().slice(startRow).map(function (rowData) {
|
915
|
+
return rowData.slice(startColumn);
|
916
|
+
});
|
917
|
+
for (r = 0; r < numberOfRowsToPopulate; r += 1) {
|
918
|
+
if (r < numberOfDataRows) {
|
919
|
+
for (c = 0, clen = input[r].length; c < columnsPopulationEnd - clen; c += 1) {
|
920
|
+
// repeating data for rows
|
921
|
+
input[r].push(input[r][c % clen]);
|
922
|
+
}
|
923
|
+
if (r < pushedRightDataByRows.length) {
|
924
|
+
for (var i = 0; i < pushedRightDataByRows[r].length; i += 1) {
|
925
|
+
input[r].push(pushedRightDataByRows[r][i]);
|
926
|
+
}
|
927
|
+
} else {
|
928
|
+
var _input$r;
|
929
|
+
// if before data population, there was no data in the row
|
930
|
+
// we fill the required columns' newly-created cells with `null` values
|
931
|
+
(_input$r = input[r]).push.apply(_input$r, _toConsumableArray(new Array(pushedRightDataByRows[0].length).fill(null)));
|
932
|
+
}
|
933
|
+
} else {
|
934
|
+
// Repeating data for columns.
|
935
|
+
input.push(input[r % rlen].slice(0, numberOfRowsToPopulate).concat(pushedRightDataByRows[r]));
|
936
|
+
}
|
937
|
+
}
|
938
|
+
instance.populateFromArray(startRow, startColumn, input);
|
939
|
+
break;
|
940
|
+
case 'overwrite':
|
941
|
+
default:
|
942
|
+
// overwrite and other not specified options
|
943
|
+
current.row = start.row;
|
944
|
+
current.col = start.col;
|
945
|
+
var selected = {
|
946
|
+
// selected range
|
947
|
+
row: end && start ? end.row - start.row + 1 : 1,
|
948
|
+
col: end && start ? end.col - start.col + 1 : 1
|
949
|
+
};
|
950
|
+
var skippedRow = 0;
|
951
|
+
var skippedColumn = 0;
|
952
|
+
var pushData = true;
|
953
|
+
var cellMeta;
|
954
|
+
var getInputValue = function getInputValue(row) {
|
955
|
+
var col = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
956
|
+
var rowValue = input[row % input.length];
|
957
|
+
if (col !== null) {
|
958
|
+
return rowValue[col % rowValue.length];
|
959
|
+
}
|
960
|
+
return rowValue;
|
961
|
+
};
|
962
|
+
var rowInputLength = input.length;
|
963
|
+
var rowSelectionLength = end ? end.row - start.row + 1 : 0;
|
964
|
+
if (end) {
|
965
|
+
rlen = rowSelectionLength;
|
966
|
+
} else {
|
967
|
+
rlen = Math.max(rowInputLength, rowSelectionLength);
|
968
|
+
}
|
969
|
+
for (r = 0; r < rlen; r++) {
|
970
|
+
if (end && current.row > end.row && rowSelectionLength > rowInputLength || !tableMeta.allowInsertRow && current.row > instance.countRows() - 1 || current.row >= tableMeta.maxRows) {
|
971
|
+
break;
|
972
|
+
}
|
973
|
+
var visualRow = r - skippedRow;
|
974
|
+
var colInputLength = getInputValue(visualRow).length;
|
975
|
+
var colSelectionLength = end ? end.col - start.col + 1 : 0;
|
976
|
+
if (end) {
|
977
|
+
clen = colSelectionLength;
|
978
|
+
} else {
|
979
|
+
clen = Math.max(colInputLength, colSelectionLength);
|
980
|
+
}
|
981
|
+
current.col = start.col;
|
982
|
+
cellMeta = instance.getCellMeta(current.row, current.col);
|
983
|
+
if ((source === 'CopyPaste.paste' || source === 'Autofill.fill') && cellMeta.skipRowOnPaste) {
|
984
|
+
skippedRow += 1;
|
985
|
+
current.row += 1;
|
986
|
+
rlen += 1;
|
987
|
+
/* eslint-disable no-continue */
|
988
|
+
continue;
|
989
|
+
}
|
990
|
+
skippedColumn = 0;
|
991
|
+
for (c = 0; c < clen; c++) {
|
992
|
+
if (end && current.col > end.col && colSelectionLength > colInputLength || !tableMeta.allowInsertColumn && current.col > instance.countCols() - 1 || current.col >= tableMeta.maxCols) {
|
993
|
+
break;
|
994
|
+
}
|
995
|
+
cellMeta = instance.getCellMeta(current.row, current.col);
|
996
|
+
if ((source === 'CopyPaste.paste' || source === 'Autofill.fill') && cellMeta.skipColumnOnPaste) {
|
997
|
+
skippedColumn += 1;
|
998
|
+
current.col += 1;
|
999
|
+
clen += 1;
|
1000
|
+
continue;
|
1001
|
+
}
|
1002
|
+
if (cellMeta.readOnly && source !== 'UndoRedo.undo') {
|
1003
|
+
current.col += 1;
|
1004
|
+
/* eslint-disable no-continue */
|
1005
|
+
continue;
|
1006
|
+
}
|
1007
|
+
var visualColumn = c - skippedColumn;
|
1008
|
+
var value = getInputValue(visualRow, visualColumn);
|
1009
|
+
var orgValue = instance.getDataAtCell(current.row, current.col);
|
1010
|
+
var index = {
|
1011
|
+
row: visualRow,
|
1012
|
+
col: visualColumn
|
1013
|
+
};
|
1014
|
+
if (source === 'Autofill.fill') {
|
1015
|
+
var result = instance.runHooks('beforeAutofillInsidePopulate', index, direction, input, deltas, {}, selected);
|
1016
|
+
if (result) {
|
1017
|
+
value = (0, _mixed.isUndefined)(result.value) ? value : result.value;
|
1018
|
+
}
|
1019
|
+
}
|
1020
|
+
if (value !== null && _typeof(value) === 'object') {
|
1021
|
+
// when 'value' is array and 'orgValue' is null, set 'orgValue' to
|
1022
|
+
// an empty array so that the null value can be compared to 'value'
|
1023
|
+
// as an empty value for the array context
|
1024
|
+
if (Array.isArray(value) && orgValue === null) orgValue = [];
|
1025
|
+
if (orgValue === null || _typeof(orgValue) !== 'object') {
|
1026
|
+
pushData = false;
|
1027
|
+
} else {
|
1028
|
+
var orgValueSchema = (0, _object.duckSchema)(Array.isArray(orgValue) ? orgValue : orgValue[0] || orgValue);
|
1029
|
+
var valueSchema = (0, _object.duckSchema)(Array.isArray(value) ? value : value[0] || value);
|
1030
|
+
|
1031
|
+
/* eslint-disable max-depth */
|
1032
|
+
if ((0, _object.isObjectEqual)(orgValueSchema, valueSchema)) {
|
1033
|
+
value = (0, _object.deepClone)(value);
|
1034
|
+
} else {
|
1035
|
+
pushData = false;
|
1036
|
+
}
|
1037
|
+
}
|
1038
|
+
} else if (orgValue !== null && _typeof(orgValue) === 'object') {
|
1039
|
+
pushData = false;
|
1040
|
+
}
|
1041
|
+
if (pushData) {
|
1042
|
+
setData.push([current.row, current.col, value]);
|
1043
|
+
}
|
1044
|
+
pushData = true;
|
1045
|
+
current.col += 1;
|
1046
|
+
}
|
1047
|
+
current.row += 1;
|
1048
|
+
}
|
1049
|
+
instance.setDataAtCell(setData, null, null, source || 'populateFromArray');
|
1050
|
+
break;
|
1051
|
+
}
|
1052
|
+
}
|
1053
|
+
};
|
1054
|
+
|
1055
|
+
/**
|
1056
|
+
* Internal function to set `language` key of settings.
|
1057
|
+
*
|
1058
|
+
* @private
|
1059
|
+
* @param {string} languageCode Language code for specific language i.e. 'en-US', 'pt-BR', 'de-DE'.
|
1060
|
+
* @fires Hooks#afterLanguageChange
|
1061
|
+
*/
|
1062
|
+
function setLanguage(languageCode) {
|
1063
|
+
var normalizedLanguageCode = (0, _utils.normalizeLanguageCode)(languageCode);
|
1064
|
+
if ((0, _registry4.hasLanguageDictionary)(normalizedLanguageCode)) {
|
1065
|
+
instance.runHooks('beforeLanguageChange', normalizedLanguageCode);
|
1066
|
+
globalMeta.language = normalizedLanguageCode;
|
1067
|
+
instance.runHooks('afterLanguageChange', normalizedLanguageCode);
|
1068
|
+
} else {
|
1069
|
+
(0, _utils.warnUserAboutLanguageRegistration)(languageCode);
|
1070
|
+
}
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
/**
|
1074
|
+
* Internal function to set `className` or `tableClassName`, depending on the key from the settings object.
|
1075
|
+
*
|
1076
|
+
* @private
|
1077
|
+
* @param {string} className `className` or `tableClassName` from the key in the settings object.
|
1078
|
+
* @param {string|string[]} classSettings String or array of strings. Contains class name(s) from settings object.
|
1079
|
+
*/
|
1080
|
+
function setClassName(className, classSettings) {
|
1081
|
+
var element = className === 'className' ? instance.rootElement : instance.table;
|
1082
|
+
if (firstRun) {
|
1083
|
+
(0, _element.addClass)(element, classSettings);
|
1084
|
+
} else {
|
1085
|
+
var globalMetaSettingsArray = [];
|
1086
|
+
var settingsArray = [];
|
1087
|
+
if (globalMeta[className]) {
|
1088
|
+
globalMetaSettingsArray = Array.isArray(globalMeta[className]) ? globalMeta[className] : (0, _array.stringToArray)(globalMeta[className]);
|
1089
|
+
}
|
1090
|
+
if (classSettings) {
|
1091
|
+
settingsArray = Array.isArray(classSettings) ? classSettings : (0, _array.stringToArray)(classSettings);
|
1092
|
+
}
|
1093
|
+
var classNameToRemove = (0, _array.getDifferenceOfArrays)(globalMetaSettingsArray, settingsArray);
|
1094
|
+
var classNameToAdd = (0, _array.getDifferenceOfArrays)(settingsArray, globalMetaSettingsArray);
|
1095
|
+
if (classNameToRemove.length) {
|
1096
|
+
(0, _element.removeClass)(element, classNameToRemove);
|
1097
|
+
}
|
1098
|
+
if (classNameToAdd.length) {
|
1099
|
+
(0, _element.addClass)(element, classNameToAdd);
|
1100
|
+
}
|
1101
|
+
}
|
1102
|
+
globalMeta[className] = classSettings;
|
1103
|
+
}
|
1104
|
+
this.init = function () {
|
1105
|
+
dataSource.setData(tableMeta.data);
|
1106
|
+
instance.runHooks('beforeInit');
|
1107
|
+
if ((0, _browser.isMobileBrowser)() || (0, _browser.isIpadOS)()) {
|
1108
|
+
(0, _element.addClass)(instance.rootElement, 'mobile');
|
1109
|
+
}
|
1110
|
+
this.updateSettings(tableMeta, true);
|
1111
|
+
this.view = new _tableView.default(this);
|
1112
|
+
editorManager = _editorManager.default.getInstance(instance, tableMeta, selection);
|
1113
|
+
instance.runHooks('init');
|
1114
|
+
this.forceFullRender = true; // used when data was changed
|
1115
|
+
this.view.render();
|
1116
|
+
if (_typeof(firstRun) === 'object') {
|
1117
|
+
instance.runHooks('afterChange', firstRun[0], firstRun[1]);
|
1118
|
+
firstRun = false;
|
1119
|
+
}
|
1120
|
+
instance.runHooks('afterInit');
|
1121
|
+
};
|
1122
|
+
|
1123
|
+
/**
|
1124
|
+
* @ignore
|
1125
|
+
* @returns {object}
|
1126
|
+
*/
|
1127
|
+
function ValidatorsQueue() {
|
1128
|
+
// moved this one level up so it can be used in any function here. Probably this should be moved to a separate file
|
1129
|
+
var resolved = false;
|
1130
|
+
return {
|
1131
|
+
validatorsInQueue: 0,
|
1132
|
+
valid: true,
|
1133
|
+
addValidatorToQueue: function addValidatorToQueue() {
|
1134
|
+
this.validatorsInQueue += 1;
|
1135
|
+
resolved = false;
|
1136
|
+
},
|
1137
|
+
removeValidatorFormQueue: function removeValidatorFormQueue() {
|
1138
|
+
this.validatorsInQueue = this.validatorsInQueue - 1 < 0 ? 0 : this.validatorsInQueue - 1;
|
1139
|
+
this.checkIfQueueIsEmpty();
|
1140
|
+
},
|
1141
|
+
onQueueEmpty: function onQueueEmpty() {},
|
1142
|
+
checkIfQueueIsEmpty: function checkIfQueueIsEmpty() {
|
1143
|
+
if (this.validatorsInQueue === 0 && resolved === false) {
|
1144
|
+
resolved = true;
|
1145
|
+
this.onQueueEmpty(this.valid);
|
1146
|
+
}
|
1147
|
+
}
|
1148
|
+
};
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
/**
|
1152
|
+
* Get parsed number from numeric string.
|
1153
|
+
*
|
1154
|
+
* @private
|
1155
|
+
* @param {string} numericData Float (separated by a dot or a comma) or integer.
|
1156
|
+
* @returns {number} Number if we get data in parsable format, not changed value otherwise.
|
1157
|
+
*/
|
1158
|
+
function getParsedNumber(numericData) {
|
1159
|
+
// Unifying "float like" string. Change from value with comma determiner to value with dot determiner,
|
1160
|
+
// for example from `450,65` to `450.65`.
|
1161
|
+
var unifiedNumericData = numericData.replace(',', '.');
|
1162
|
+
if (isNaN(parseFloat(unifiedNumericData)) === false) {
|
1163
|
+
return parseFloat(unifiedNumericData);
|
1164
|
+
}
|
1165
|
+
return numericData;
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
/**
|
1169
|
+
* @ignore
|
1170
|
+
* @param {Array} changes The 2D array containing information about each of the edited cells.
|
1171
|
+
* @param {string} source The string that identifies source of validation.
|
1172
|
+
* @param {Function} callback The callback function fot async validation.
|
1173
|
+
*/
|
1174
|
+
function validateChanges(changes, source, callback) {
|
1175
|
+
if (!changes.length) {
|
1176
|
+
return;
|
1177
|
+
}
|
1178
|
+
var activeEditor = instance.getActiveEditor();
|
1179
|
+
var beforeChangeResult = instance.runHooks('beforeChange', changes, source || 'edit');
|
1180
|
+
var shouldBeCanceled = true;
|
1181
|
+
if (beforeChangeResult === false) {
|
1182
|
+
if (activeEditor) {
|
1183
|
+
activeEditor.cancelChanges();
|
1184
|
+
}
|
1185
|
+
return;
|
1186
|
+
}
|
1187
|
+
var waitingForValidator = new ValidatorsQueue();
|
1188
|
+
waitingForValidator.onQueueEmpty = function (isValid) {
|
1189
|
+
if (activeEditor && shouldBeCanceled) {
|
1190
|
+
activeEditor.cancelChanges();
|
1191
|
+
}
|
1192
|
+
callback(isValid); // called when async validators are resolved and beforeChange was not async
|
1193
|
+
};
|
1194
|
+
|
1195
|
+
for (var i = changes.length - 1; i >= 0; i--) {
|
1196
|
+
if (changes[i] === null) {
|
1197
|
+
changes.splice(i, 1);
|
1198
|
+
} else {
|
1199
|
+
var _changes$i = _slicedToArray(changes[i], 4),
|
1200
|
+
row = _changes$i[0],
|
1201
|
+
prop = _changes$i[1],
|
1202
|
+
newValue = _changes$i[3];
|
1203
|
+
var col = datamap.propToCol(prop);
|
1204
|
+
var cellProperties = instance.getCellMeta(row, col);
|
1205
|
+
if (cellProperties.type === 'numeric' && typeof newValue === 'string' && (0, _number.isNumericLike)(newValue)) {
|
1206
|
+
changes[i][3] = getParsedNumber(newValue);
|
1207
|
+
}
|
1208
|
+
|
1209
|
+
/* eslint-disable no-loop-func */
|
1210
|
+
if (instance.getCellValidator(cellProperties)) {
|
1211
|
+
waitingForValidator.addValidatorToQueue();
|
1212
|
+
instance.validateCell(changes[i][3], cellProperties, function (index, cellPropertiesReference) {
|
1213
|
+
return function (result) {
|
1214
|
+
if (typeof result !== 'boolean') {
|
1215
|
+
throw new Error('Validation error: result is not boolean');
|
1216
|
+
}
|
1217
|
+
if (result === false && cellPropertiesReference.allowInvalid === false) {
|
1218
|
+
shouldBeCanceled = false;
|
1219
|
+
changes.splice(index, 1); // cancel the change
|
1220
|
+
cellPropertiesReference.valid = true; // we cancelled the change, so cell value is still valid
|
1221
|
+
|
1222
|
+
var cell = instance.getCell(cellPropertiesReference.visualRow, cellPropertiesReference.visualCol);
|
1223
|
+
if (cell !== null) {
|
1224
|
+
(0, _element.removeClass)(cell, tableMeta.invalidCellClassName);
|
1225
|
+
}
|
1226
|
+
// index -= 1;
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
waitingForValidator.removeValidatorFormQueue();
|
1230
|
+
};
|
1231
|
+
}(i, cellProperties), source);
|
1232
|
+
}
|
1233
|
+
}
|
1234
|
+
}
|
1235
|
+
waitingForValidator.checkIfQueueIsEmpty();
|
1236
|
+
}
|
1237
|
+
|
1238
|
+
/**
|
1239
|
+
* Internal function to apply changes. Called after validateChanges.
|
1240
|
+
*
|
1241
|
+
* @private
|
1242
|
+
* @param {Array} changes Array in form of [row, prop, oldValue, newValue].
|
1243
|
+
* @param {string} source String that identifies how this change will be described in changes array (useful in onChange callback).
|
1244
|
+
* @fires Hooks#beforeChangeRender
|
1245
|
+
* @fires Hooks#afterChange
|
1246
|
+
*/
|
1247
|
+
function applyChanges(changes, source) {
|
1248
|
+
var i = changes.length - 1;
|
1249
|
+
if (i < 0) {
|
1250
|
+
return;
|
1251
|
+
}
|
1252
|
+
for (; i >= 0; i--) {
|
1253
|
+
var skipThisChange = false;
|
1254
|
+
if (changes[i] === null) {
|
1255
|
+
changes.splice(i, 1);
|
1256
|
+
/* eslint-disable no-continue */
|
1257
|
+
continue;
|
1258
|
+
}
|
1259
|
+
if ((changes[i][2] === null || changes[i][2] === void 0) && (changes[i][3] === null || changes[i][3] === void 0)) {
|
1260
|
+
/* eslint-disable no-continue */
|
1261
|
+
continue;
|
1262
|
+
}
|
1263
|
+
if (tableMeta.allowInsertRow) {
|
1264
|
+
while (changes[i][0] > instance.countRows() - 1) {
|
1265
|
+
var _datamap$createRow2 = datamap.createRow(void 0, void 0, {
|
1266
|
+
source: source
|
1267
|
+
}),
|
1268
|
+
numberOfCreatedRows = _datamap$createRow2.delta;
|
1269
|
+
if (numberOfCreatedRows >= 1) {
|
1270
|
+
metaManager.createRow(null, numberOfCreatedRows);
|
1271
|
+
} else {
|
1272
|
+
skipThisChange = true;
|
1273
|
+
break;
|
1274
|
+
}
|
1275
|
+
}
|
1276
|
+
}
|
1277
|
+
if (instance.dataType === 'array' && (!tableMeta.columns || tableMeta.columns.length === 0) && tableMeta.allowInsertColumn) {
|
1278
|
+
while (datamap.propToCol(changes[i][1]) > instance.countCols() - 1) {
|
1279
|
+
var _datamap$createCol2 = datamap.createCol(void 0, void 0, {
|
1280
|
+
source: source
|
1281
|
+
}),
|
1282
|
+
numberOfCreatedColumns = _datamap$createCol2.delta;
|
1283
|
+
if (numberOfCreatedColumns >= 1) {
|
1284
|
+
metaManager.createColumn(null, numberOfCreatedColumns);
|
1285
|
+
} else {
|
1286
|
+
skipThisChange = true;
|
1287
|
+
break;
|
1288
|
+
}
|
1289
|
+
}
|
1290
|
+
}
|
1291
|
+
if (skipThisChange) {
|
1292
|
+
/* eslint-disable no-continue */
|
1293
|
+
continue;
|
1294
|
+
}
|
1295
|
+
datamap.set(changes[i][0], changes[i][1], changes[i][3]);
|
1296
|
+
}
|
1297
|
+
instance.forceFullRender = true; // used when data was changed
|
1298
|
+
grid.adjustRowsAndCols();
|
1299
|
+
instance.runHooks('beforeChangeRender', changes, source);
|
1300
|
+
editorManager.lockEditor();
|
1301
|
+
instance._refreshBorders(null);
|
1302
|
+
editorManager.unlockEditor();
|
1303
|
+
instance.view.adjustElementsSize();
|
1304
|
+
instance.runHooks('afterChange', changes, source || 'edit');
|
1305
|
+
var activeEditor = instance.getActiveEditor();
|
1306
|
+
if (activeEditor && (0, _mixed.isDefined)(activeEditor.refreshValue)) {
|
1307
|
+
activeEditor.refreshValue();
|
1308
|
+
}
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
/**
|
1312
|
+
* Creates and returns the CellCoords object.
|
1313
|
+
*
|
1314
|
+
* @private
|
1315
|
+
* @memberof Core#
|
1316
|
+
* @function _createCellCoords
|
1317
|
+
* @param {number} row The row index.
|
1318
|
+
* @param {number} column The column index.
|
1319
|
+
* @returns {CellCoords}
|
1320
|
+
*/
|
1321
|
+
this._createCellCoords = function (row, column) {
|
1322
|
+
return instance.view._wt.createCellCoords(row, column);
|
1323
|
+
};
|
1324
|
+
|
1325
|
+
/**
|
1326
|
+
* Creates and returns the CellRange object.
|
1327
|
+
*
|
1328
|
+
* @private
|
1329
|
+
* @memberof Core#
|
1330
|
+
* @function _createCellRange
|
1331
|
+
* @param {CellCoords} highlight Defines the border around a cell where selection was started and to edit the cell
|
1332
|
+
* when you press Enter. The highlight cannot point to headers (negative values).
|
1333
|
+
* @param {CellCoords} from Initial coordinates.
|
1334
|
+
* @param {CellCoords} to Final coordinates.
|
1335
|
+
* @returns {CellRange}
|
1336
|
+
*/
|
1337
|
+
this._createCellRange = function (highlight, from, to) {
|
1338
|
+
return instance.view._wt.createCellRange(highlight, from, to);
|
1339
|
+
};
|
1340
|
+
|
1341
|
+
/**
|
1342
|
+
* Validate a single cell.
|
1343
|
+
*
|
1344
|
+
* @memberof Core#
|
1345
|
+
* @function validateCell
|
1346
|
+
* @param {string|number} value The value to validate.
|
1347
|
+
* @param {object} cellProperties The cell meta which corresponds with the value.
|
1348
|
+
* @param {Function} callback The callback function.
|
1349
|
+
* @param {string} source The string that identifies source of the validation.
|
1350
|
+
*/
|
1351
|
+
this.validateCell = function (value, cellProperties, callback, source) {
|
1352
|
+
var validator = instance.getCellValidator(cellProperties);
|
1353
|
+
|
1354
|
+
// the `canBeValidated = false` argument suggests, that the cell passes validation by default.
|
1355
|
+
/**
|
1356
|
+
* @private
|
1357
|
+
* @function done
|
1358
|
+
* @param {boolean} valid Indicates if the validation was successful.
|
1359
|
+
* @param {boolean} [canBeValidated=true] Flag which controls the validation process.
|
1360
|
+
*/
|
1361
|
+
function done(valid) {
|
1362
|
+
var canBeValidated = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
1363
|
+
// Fixes GH#3903
|
1364
|
+
if (!canBeValidated || cellProperties.hidden === true) {
|
1365
|
+
callback(valid);
|
1366
|
+
return;
|
1367
|
+
}
|
1368
|
+
var col = cellProperties.visualCol;
|
1369
|
+
var row = cellProperties.visualRow;
|
1370
|
+
var td = instance.getCell(row, col, true);
|
1371
|
+
if (td && td.nodeName !== 'TH') {
|
1372
|
+
var renderableRow = instance.rowIndexMapper.getRenderableFromVisualIndex(row);
|
1373
|
+
var renderableColumn = instance.columnIndexMapper.getRenderableFromVisualIndex(col);
|
1374
|
+
instance.view._wt.getSetting('cellRenderer', renderableRow, renderableColumn, td);
|
1375
|
+
}
|
1376
|
+
callback(valid);
|
1377
|
+
}
|
1378
|
+
if ((0, _mixed.isRegExp)(validator)) {
|
1379
|
+
validator = function (expression) {
|
1380
|
+
return function (cellValue, validatorCallback) {
|
1381
|
+
validatorCallback(expression.test(cellValue));
|
1382
|
+
};
|
1383
|
+
}(validator);
|
1384
|
+
}
|
1385
|
+
if ((0, _function.isFunction)(validator)) {
|
1386
|
+
// eslint-disable-next-line no-param-reassign
|
1387
|
+
value = instance.runHooks('beforeValidate', value, cellProperties.visualRow, cellProperties.prop, source);
|
1388
|
+
|
1389
|
+
// To provide consistent behaviour, validation should be always asynchronous
|
1390
|
+
instance._registerImmediate(function () {
|
1391
|
+
validator.call(cellProperties, value, function (valid) {
|
1392
|
+
if (!instance) {
|
1393
|
+
return;
|
1394
|
+
}
|
1395
|
+
// eslint-disable-next-line no-param-reassign
|
1396
|
+
valid = instance.runHooks('afterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
|
1397
|
+
cellProperties.valid = valid;
|
1398
|
+
done(valid);
|
1399
|
+
instance.runHooks('postAfterValidate', valid, value, cellProperties.visualRow, cellProperties.prop, source);
|
1400
|
+
});
|
1401
|
+
});
|
1402
|
+
} else {
|
1403
|
+
// resolve callback even if validator function was not found
|
1404
|
+
instance._registerImmediate(function () {
|
1405
|
+
cellProperties.valid = true;
|
1406
|
+
done(cellProperties.valid, false);
|
1407
|
+
});
|
1408
|
+
}
|
1409
|
+
};
|
1410
|
+
|
1411
|
+
/**
|
1412
|
+
* @ignore
|
1413
|
+
* @param {number} row The visual row index.
|
1414
|
+
* @param {string|number} propOrCol The visual prop or column index.
|
1415
|
+
* @param {*} value The cell value.
|
1416
|
+
* @returns {Array}
|
1417
|
+
*/
|
1418
|
+
function setDataInputToArray(row, propOrCol, value) {
|
1419
|
+
if (Array.isArray(row)) {
|
1420
|
+
// it's an array of changes
|
1421
|
+
return row;
|
1422
|
+
}
|
1423
|
+
return [[row, propOrCol, value]];
|
1424
|
+
}
|
1425
|
+
|
1426
|
+
/**
|
1427
|
+
* @description
|
1428
|
+
* Set new value to a cell. To change many cells at once (recommended way), pass an array of `changes` in format
|
1429
|
+
* `[[row, col, value],...]` as the first argument.
|
1430
|
+
*
|
1431
|
+
* @memberof Core#
|
1432
|
+
* @function setDataAtCell
|
1433
|
+
* @param {number|Array} row Visual row index or array of changes in format `[[row, col, value],...]`.
|
1434
|
+
* @param {number} [column] Visual column index.
|
1435
|
+
* @param {string} [value] New value.
|
1436
|
+
* @param {string} [source] String that identifies how this change will be described in the changes array (useful in afterChange or beforeChange callback). Set to 'edit' if left empty.
|
1437
|
+
*/
|
1438
|
+
this.setDataAtCell = function (row, column, value, source) {
|
1439
|
+
var input = setDataInputToArray(row, column, value);
|
1440
|
+
var changes = [];
|
1441
|
+
var changeSource = source;
|
1442
|
+
var i;
|
1443
|
+
var ilen;
|
1444
|
+
var prop;
|
1445
|
+
for (i = 0, ilen = input.length; i < ilen; i++) {
|
1446
|
+
if (_typeof(input[i]) !== 'object') {
|
1447
|
+
throw new Error('Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter');
|
1448
|
+
}
|
1449
|
+
if (typeof input[i][1] !== 'number') {
|
1450
|
+
throw new Error('Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`'); // eslint-disable-line max-len
|
1451
|
+
}
|
1452
|
+
|
1453
|
+
if (input[i][1] >= this.countCols()) {
|
1454
|
+
prop = input[i][1];
|
1455
|
+
} else {
|
1456
|
+
prop = datamap.colToProp(input[i][1]);
|
1457
|
+
}
|
1458
|
+
changes.push([input[i][0], prop, dataSource.getAtCell(this.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
|
1459
|
+
}
|
1460
|
+
if (!changeSource && _typeof(row) === 'object') {
|
1461
|
+
changeSource = column;
|
1462
|
+
}
|
1463
|
+
instance.runHooks('afterSetDataAtCell', changes, changeSource);
|
1464
|
+
validateChanges(changes, changeSource, function () {
|
1465
|
+
applyChanges(changes, changeSource);
|
1466
|
+
});
|
1467
|
+
};
|
1468
|
+
|
1469
|
+
/**
|
1470
|
+
* @description
|
1471
|
+
* Set new value to a cell. To change many cells at once (recommended way), pass an array of `changes` in format
|
1472
|
+
* `[[row, prop, value],...]` as the first argument.
|
1473
|
+
*
|
1474
|
+
* @memberof Core#
|
1475
|
+
* @function setDataAtRowProp
|
1476
|
+
* @param {number|Array} row Visual row index or array of changes in format `[[row, prop, value], ...]`.
|
1477
|
+
* @param {string} prop Property name or the source string (e.g. `'first.name'` or `'0'`).
|
1478
|
+
* @param {string} value Value to be set.
|
1479
|
+
* @param {string} [source] String that identifies how this change will be described in changes array (useful in onChange callback).
|
1480
|
+
*/
|
1481
|
+
this.setDataAtRowProp = function (row, prop, value, source) {
|
1482
|
+
var input = setDataInputToArray(row, prop, value);
|
1483
|
+
var changes = [];
|
1484
|
+
var changeSource = source;
|
1485
|
+
var i;
|
1486
|
+
var ilen;
|
1487
|
+
for (i = 0, ilen = input.length; i < ilen; i++) {
|
1488
|
+
changes.push([input[i][0], input[i][1], dataSource.getAtCell(this.toPhysicalRow(input[i][0]), input[i][1]), input[i][2]]);
|
1489
|
+
}
|
1490
|
+
if (!changeSource && _typeof(row) === 'object') {
|
1491
|
+
changeSource = prop;
|
1492
|
+
}
|
1493
|
+
instance.runHooks('afterSetDataAtRowProp', changes, changeSource);
|
1494
|
+
validateChanges(changes, changeSource, function () {
|
1495
|
+
applyChanges(changes, changeSource);
|
1496
|
+
});
|
1497
|
+
};
|
1498
|
+
|
1499
|
+
/**
|
1500
|
+
* Listen to the keyboard input on document body. This allows Handsontable to capture keyboard events and respond
|
1501
|
+
* in the right way.
|
1502
|
+
*
|
1503
|
+
* @memberof Core#
|
1504
|
+
* @function listen
|
1505
|
+
* @fires Hooks#afterListen
|
1506
|
+
*/
|
1507
|
+
this.listen = function () {
|
1508
|
+
if (instance && !instance.isListening()) {
|
1509
|
+
activeGuid = instance.guid;
|
1510
|
+
instance.runHooks('afterListen');
|
1511
|
+
}
|
1512
|
+
};
|
1513
|
+
|
1514
|
+
/**
|
1515
|
+
* Stop listening to keyboard input on the document body. Calling this method makes the Handsontable inactive for
|
1516
|
+
* any keyboard events.
|
1517
|
+
*
|
1518
|
+
* @memberof Core#
|
1519
|
+
* @function unlisten
|
1520
|
+
*/
|
1521
|
+
this.unlisten = function () {
|
1522
|
+
if (this.isListening()) {
|
1523
|
+
activeGuid = null;
|
1524
|
+
instance.runHooks('afterUnlisten');
|
1525
|
+
}
|
1526
|
+
};
|
1527
|
+
|
1528
|
+
/**
|
1529
|
+
* Returns `true` if the current Handsontable instance is listening to keyboard input on document body.
|
1530
|
+
*
|
1531
|
+
* @memberof Core#
|
1532
|
+
* @function isListening
|
1533
|
+
* @returns {boolean} `true` if the instance is listening, `false` otherwise.
|
1534
|
+
*/
|
1535
|
+
this.isListening = function () {
|
1536
|
+
return activeGuid === instance.guid;
|
1537
|
+
};
|
1538
|
+
|
1539
|
+
/**
|
1540
|
+
* Destroys the current editor, render the table and prepares the editor of the newly selected cell.
|
1541
|
+
*
|
1542
|
+
* @memberof Core#
|
1543
|
+
* @function destroyEditor
|
1544
|
+
* @param {boolean} [revertOriginal=false] If `true`, the previous value will be restored. Otherwise, the edited value will be saved.
|
1545
|
+
* @param {boolean} [prepareEditorIfNeeded=true] If `true` the editor under the selected cell will be prepared to open.
|
1546
|
+
*/
|
1547
|
+
this.destroyEditor = function () {
|
1548
|
+
var revertOriginal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1549
|
+
var prepareEditorIfNeeded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
1550
|
+
instance._refreshBorders(revertOriginal, prepareEditorIfNeeded);
|
1551
|
+
};
|
1552
|
+
|
1553
|
+
/**
|
1554
|
+
* Populates cells at position with 2D input array (e.g. `[[1, 2], [3, 4]]`). Use `endRow`, `endCol` when you
|
1555
|
+
* want to cut input when a certain row is reached.
|
1556
|
+
*
|
1557
|
+
* The `populateFromArray()` method can't change [`readOnly`](@/api/options.md#readonly) cells.
|
1558
|
+
*
|
1559
|
+
* Optional `method` argument has the same effect as pasteMode option (see {@link Options#pasteMode}).
|
1560
|
+
*
|
1561
|
+
* @memberof Core#
|
1562
|
+
* @function populateFromArray
|
1563
|
+
* @param {number} row Start visual row index.
|
1564
|
+
* @param {number} column Start visual column index.
|
1565
|
+
* @param {Array} input 2d array.
|
1566
|
+
* @param {number} [endRow] End visual row index (use when you want to cut input when certain row is reached).
|
1567
|
+
* @param {number} [endCol] End visual column index (use when you want to cut input when certain column is reached).
|
1568
|
+
* @param {string} [source=populateFromArray] Used to identify this call in the resulting events (beforeChange, afterChange).
|
1569
|
+
* @param {string} [method=overwrite] Populate method, possible values: `'shift_down'`, `'shift_right'`, `'overwrite'`.
|
1570
|
+
* @param {string} direction Populate direction, possible values: `'left'`, `'right'`, `'up'`, `'down'`.
|
1571
|
+
* @param {Array} deltas The deltas array. A difference between values of adjacent cells.
|
1572
|
+
* Useful **only** when the type of handled cells is `numeric`.
|
1573
|
+
* @returns {object|undefined} Ending td in pasted area (only if any cell was changed).
|
1574
|
+
*/
|
1575
|
+
this.populateFromArray = function (row, column, input, endRow, endCol, source, method, direction, deltas) {
|
1576
|
+
if (!(_typeof(input) === 'object' && _typeof(input[0]) === 'object')) {
|
1577
|
+
throw new Error('populateFromArray parameter `input` must be an array of arrays'); // API changed in 0.9-beta2, let's check if you use it correctly
|
1578
|
+
}
|
1579
|
+
|
1580
|
+
var c = typeof endRow === 'number' ? instance._createCellCoords(endRow, endCol) : null;
|
1581
|
+
return grid.populateFromArray(instance._createCellCoords(row, column), input, c, source, method, direction, deltas);
|
1582
|
+
};
|
1583
|
+
|
1584
|
+
/**
|
1585
|
+
* Adds/removes data from the column. This method works the same as Array.splice for arrays.
|
1586
|
+
*
|
1587
|
+
* @memberof Core#
|
1588
|
+
* @function spliceCol
|
1589
|
+
* @param {number} column Index of the column in which do you want to do splice.
|
1590
|
+
* @param {number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
|
1591
|
+
* @param {number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
|
1592
|
+
* @param {...number} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
|
1593
|
+
* @returns {Array} Returns removed portion of columns.
|
1594
|
+
*/
|
1595
|
+
this.spliceCol = function (column, index, amount) {
|
1596
|
+
var _datamap;
|
1597
|
+
for (var _len = arguments.length, elements = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
1598
|
+
elements[_key - 3] = arguments[_key];
|
1599
|
+
}
|
1600
|
+
return (_datamap = datamap).spliceCol.apply(_datamap, [column, index, amount].concat(elements));
|
1601
|
+
};
|
1602
|
+
|
1603
|
+
/**
|
1604
|
+
* Adds/removes data from the row. This method works the same as Array.splice for arrays.
|
1605
|
+
*
|
1606
|
+
* @memberof Core#
|
1607
|
+
* @function spliceRow
|
1608
|
+
* @param {number} row Index of column in which do you want to do splice.
|
1609
|
+
* @param {number} index Index at which to start changing the array. If negative, will begin that many elements from the end.
|
1610
|
+
* @param {number} amount An integer indicating the number of old array elements to remove. If amount is 0, no elements are removed.
|
1611
|
+
* @param {...number} [elements] The elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
|
1612
|
+
* @returns {Array} Returns removed portion of rows.
|
1613
|
+
*/
|
1614
|
+
this.spliceRow = function (row, index, amount) {
|
1615
|
+
var _datamap2;
|
1616
|
+
for (var _len2 = arguments.length, elements = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
|
1617
|
+
elements[_key2 - 3] = arguments[_key2];
|
1618
|
+
}
|
1619
|
+
return (_datamap2 = datamap).spliceRow.apply(_datamap2, [row, index, amount].concat(elements));
|
1620
|
+
};
|
1621
|
+
|
1622
|
+
/**
|
1623
|
+
* Returns indexes of the currently selected cells as an array of arrays `[[startRow, startCol, endRow, endCol],...]`.
|
1624
|
+
*
|
1625
|
+
* Start row and start column are the coordinates of the active cell (where the selection was started).
|
1626
|
+
*
|
1627
|
+
* The version 0.36.0 adds a non-consecutive selection feature. Since this version, the method returns an array of arrays.
|
1628
|
+
* Additionally to collect the coordinates of the currently selected area (as it was previously done by the method)
|
1629
|
+
* you need to use `getSelectedLast` method.
|
1630
|
+
*
|
1631
|
+
* @memberof Core#
|
1632
|
+
* @function getSelected
|
1633
|
+
* @returns {Array[]|undefined} An array of arrays of the selection's coordinates.
|
1634
|
+
*/
|
1635
|
+
this.getSelected = function () {
|
1636
|
+
// https://github.com/handsontable/handsontable/issues/44 //cjl
|
1637
|
+
if (selection.isSelected()) {
|
1638
|
+
return (0, _array.arrayMap)(selection.getSelectedRange(), function (_ref12) {
|
1639
|
+
var from = _ref12.from,
|
1640
|
+
to = _ref12.to;
|
1641
|
+
return [from.row, from.col, to.row, to.col];
|
1642
|
+
});
|
1643
|
+
}
|
1644
|
+
};
|
1645
|
+
|
1646
|
+
/**
|
1647
|
+
* Returns the last coordinates applied to the table as a an array `[startRow, startCol, endRow, endCol]`.
|
1648
|
+
*
|
1649
|
+
* @since 0.36.0
|
1650
|
+
* @memberof Core#
|
1651
|
+
* @function getSelectedLast
|
1652
|
+
* @returns {Array|undefined} An array of the selection's coordinates.
|
1653
|
+
*/
|
1654
|
+
this.getSelectedLast = function () {
|
1655
|
+
var selected = this.getSelected();
|
1656
|
+
var result;
|
1657
|
+
if (selected && selected.length > 0) {
|
1658
|
+
result = selected[selected.length - 1];
|
1659
|
+
}
|
1660
|
+
return result;
|
1661
|
+
};
|
1662
|
+
|
1663
|
+
/**
|
1664
|
+
* Returns the current selection as an array of CellRange objects.
|
1665
|
+
*
|
1666
|
+
* The version 0.36.0 adds a non-consecutive selection feature. Since this version, the method returns an array of arrays.
|
1667
|
+
* Additionally to collect the coordinates of the currently selected area (as it was previously done by the method)
|
1668
|
+
* you need to use `getSelectedRangeLast` method.
|
1669
|
+
*
|
1670
|
+
* @memberof Core#
|
1671
|
+
* @function getSelectedRange
|
1672
|
+
* @returns {CellRange[]|undefined} Selected range object or undefined if there is no selection.
|
1673
|
+
*/
|
1674
|
+
this.getSelectedRange = function () {
|
1675
|
+
// https://github.com/handsontable/handsontable/issues/44 //cjl
|
1676
|
+
if (selection.isSelected()) {
|
1677
|
+
return Array.from(selection.getSelectedRange());
|
1678
|
+
}
|
1679
|
+
};
|
1680
|
+
|
1681
|
+
/**
|
1682
|
+
* Returns the last coordinates applied to the table as a CellRange object.
|
1683
|
+
*
|
1684
|
+
* @memberof Core#
|
1685
|
+
* @function getSelectedRangeLast
|
1686
|
+
* @since 0.36.0
|
1687
|
+
* @returns {CellRange|undefined} Selected range object or undefined` if there is no selection.
|
1688
|
+
*/
|
1689
|
+
this.getSelectedRangeLast = function () {
|
1690
|
+
var selectedRange = this.getSelectedRange();
|
1691
|
+
var result;
|
1692
|
+
if (selectedRange && selectedRange.length > 0) {
|
1693
|
+
result = selectedRange[selectedRange.length - 1];
|
1694
|
+
}
|
1695
|
+
return result;
|
1696
|
+
};
|
1697
|
+
|
1698
|
+
/**
|
1699
|
+
* Erases content from cells that have been selected in the table.
|
1700
|
+
*
|
1701
|
+
* @memberof Core#
|
1702
|
+
* @function emptySelectedCells
|
1703
|
+
* @param {string} [source] String that identifies how this change will be described in the changes array (useful in afterChange or beforeChange callback). Set to 'edit' if left empty.
|
1704
|
+
* @since 0.36.0
|
1705
|
+
*/
|
1706
|
+
this.emptySelectedCells = function (source) {
|
1707
|
+
var _this2 = this;
|
1708
|
+
if (!selection.isSelected() || this.countRows() === 0 || this.countCols() === 0) {
|
1709
|
+
return;
|
1710
|
+
}
|
1711
|
+
var changes = [];
|
1712
|
+
(0, _array.arrayEach)(selection.getSelectedRange(), function (cellRange) {
|
1713
|
+
var topStart = cellRange.getTopStartCorner();
|
1714
|
+
var bottomEnd = cellRange.getBottomEndCorner();
|
1715
|
+
(0, _number.rangeEach)(topStart.row, bottomEnd.row, function (row) {
|
1716
|
+
(0, _number.rangeEach)(topStart.col, bottomEnd.col, function (column) {
|
1717
|
+
if (!_this2.getCellMeta(row, column).readOnly) {
|
1718
|
+
changes.push([row, column, null]);
|
1719
|
+
}
|
1720
|
+
});
|
1721
|
+
});
|
1722
|
+
});
|
1723
|
+
if (changes.length > 0) {
|
1724
|
+
this.setDataAtCell(changes, source);
|
1725
|
+
}
|
1726
|
+
};
|
1727
|
+
|
1728
|
+
/**
|
1729
|
+
* Checks if the table rendering process was suspended. See explanation in {@link Core#suspendRender}.
|
1730
|
+
*
|
1731
|
+
* @memberof Core#
|
1732
|
+
* @function isRenderSuspended
|
1733
|
+
* @since 8.3.0
|
1734
|
+
* @returns {boolean}
|
1735
|
+
*/
|
1736
|
+
this.isRenderSuspended = function () {
|
1737
|
+
return this.renderSuspendedCounter > 0;
|
1738
|
+
};
|
1739
|
+
|
1740
|
+
/**
|
1741
|
+
* Suspends the rendering process. It's helpful to wrap the table render
|
1742
|
+
* cycles triggered by API calls or UI actions (or both) and call the "render"
|
1743
|
+
* once in the end. As a result, it improves the performance of wrapped operations.
|
1744
|
+
* When the table is in the suspend state, most operations will have no visual
|
1745
|
+
* effect until the rendering state is resumed. Resuming the state automatically
|
1746
|
+
* invokes the table rendering. To make sure that after executing all operations,
|
1747
|
+
* the table will be rendered, it's highly recommended to use the {@link Core#batchRender}
|
1748
|
+
* method or {@link Core#batch}, which additionally aggregates the logic execution
|
1749
|
+
* that happens behind the table.
|
1750
|
+
*
|
1751
|
+
* The method is intended to be used by advanced users. Suspending the rendering
|
1752
|
+
* process could cause visual glitches when wrongly implemented.
|
1753
|
+
*
|
1754
|
+
* Every [`suspendRender()`](@/api/core.md#suspendrender) call needs to correspond with one [`resumeRender()`](@/api/core.md#resumerender) call.
|
1755
|
+
* For example, if you call [`suspendRender()`](@/api/core.md#suspendrender) 5 times, you need to call [`resumeRender()`](@/api/core.md#resumerender) 5 times as well.
|
1756
|
+
*
|
1757
|
+
* @memberof Core#
|
1758
|
+
* @function suspendRender
|
1759
|
+
* @since 8.3.0
|
1760
|
+
* @example
|
1761
|
+
* ```js
|
1762
|
+
* hot.suspendRender();
|
1763
|
+
* hot.alter('insert_row_above', 5, 45);
|
1764
|
+
* hot.alter('insert_col_start', 10, 40);
|
1765
|
+
* hot.setDataAtCell(1, 1, 'John');
|
1766
|
+
* hot.setDataAtCell(2, 2, 'Mark');
|
1767
|
+
* hot.setDataAtCell(3, 3, 'Ann');
|
1768
|
+
* hot.setDataAtCell(4, 4, 'Sophia');
|
1769
|
+
* hot.setDataAtCell(5, 5, 'Mia');
|
1770
|
+
* hot.selectCell(0, 0);
|
1771
|
+
* hot.resumeRender(); // It re-renders the table internally
|
1772
|
+
* ```
|
1773
|
+
*/
|
1774
|
+
this.suspendRender = function () {
|
1775
|
+
this.renderSuspendedCounter += 1;
|
1776
|
+
};
|
1777
|
+
|
1778
|
+
/**
|
1779
|
+
* Resumes the rendering process. In combination with the {@link Core#suspendRender}
|
1780
|
+
* method it allows aggregating the table render cycles triggered by API calls or UI
|
1781
|
+
* actions (or both) and calls the "render" once in the end. When the table is in
|
1782
|
+
* the suspend state, most operations will have no visual effect until the rendering
|
1783
|
+
* state is resumed. Resuming the state automatically invokes the table rendering.
|
1784
|
+
*
|
1785
|
+
* The method is intended to be used by advanced users. Suspending the rendering
|
1786
|
+
* process could cause visual glitches when wrongly implemented.
|
1787
|
+
*
|
1788
|
+
* Every [`suspendRender()`](@/api/core.md#suspendrender) call needs to correspond with one [`resumeRender()`](@/api/core.md#resumerender) call.
|
1789
|
+
* For example, if you call [`suspendRender()`](@/api/core.md#suspendrender) 5 times, you need to call [`resumeRender()`](@/api/core.md#resumerender) 5 times as well.
|
1790
|
+
*
|
1791
|
+
* @memberof Core#
|
1792
|
+
* @function resumeRender
|
1793
|
+
* @since 8.3.0
|
1794
|
+
* @example
|
1795
|
+
* ```js
|
1796
|
+
* hot.suspendRender();
|
1797
|
+
* hot.alter('insert_row_above', 5, 45);
|
1798
|
+
* hot.alter('insert_col_start', 10, 40);
|
1799
|
+
* hot.setDataAtCell(1, 1, 'John');
|
1800
|
+
* hot.setDataAtCell(2, 2, 'Mark');
|
1801
|
+
* hot.setDataAtCell(3, 3, 'Ann');
|
1802
|
+
* hot.setDataAtCell(4, 4, 'Sophia');
|
1803
|
+
* hot.setDataAtCell(5, 5, 'Mia');
|
1804
|
+
* hot.selectCell(0, 0);
|
1805
|
+
* hot.resumeRender(); // It re-renders the table internally
|
1806
|
+
* ```
|
1807
|
+
*/
|
1808
|
+
this.resumeRender = function () {
|
1809
|
+
var nextValue = this.renderSuspendedCounter - 1;
|
1810
|
+
this.renderSuspendedCounter = Math.max(nextValue, 0);
|
1811
|
+
if (!this.isRenderSuspended() && nextValue === this.renderSuspendedCounter) {
|
1812
|
+
if (this.renderCall) {
|
1813
|
+
this.render();
|
1814
|
+
} else {
|
1815
|
+
this._refreshBorders(null);
|
1816
|
+
}
|
1817
|
+
}
|
1818
|
+
};
|
1819
|
+
|
1820
|
+
/**
|
1821
|
+
* Rerender the table. Calling this method starts the process of recalculating, redrawing and applying the changes
|
1822
|
+
* to the DOM. While rendering the table all cell renderers are recalled.
|
1823
|
+
*
|
1824
|
+
* Calling this method manually is not recommended. Handsontable tries to render itself by choosing the most
|
1825
|
+
* optimal moments in its lifecycle.
|
1826
|
+
*
|
1827
|
+
* @memberof Core#
|
1828
|
+
* @function render
|
1829
|
+
*/
|
1830
|
+
this.render = function () {
|
1831
|
+
if (this.view) {
|
1832
|
+
this.renderCall = true;
|
1833
|
+
this.forceFullRender = true; // used when data was changed
|
1834
|
+
|
1835
|
+
if (!this.isRenderSuspended()) {
|
1836
|
+
editorManager.lockEditor();
|
1837
|
+
this._refreshBorders(null);
|
1838
|
+
editorManager.unlockEditor();
|
1839
|
+
}
|
1840
|
+
}
|
1841
|
+
};
|
1842
|
+
|
1843
|
+
/**
|
1844
|
+
* The method aggregates multi-line API calls into a callback and postpones the
|
1845
|
+
* table rendering process. After the execution of the operations, the table is
|
1846
|
+
* rendered once. As a result, it improves the performance of wrapped operations.
|
1847
|
+
* Without batching, a similar case could trigger multiple table render calls.
|
1848
|
+
*
|
1849
|
+
* @memberof Core#
|
1850
|
+
* @function batchRender
|
1851
|
+
* @param {Function} wrappedOperations Batched operations wrapped in a function.
|
1852
|
+
* @returns {*} Returns result from the wrappedOperations callback.
|
1853
|
+
* @since 8.3.0
|
1854
|
+
* @example
|
1855
|
+
* ```js
|
1856
|
+
* hot.batchRender(() => {
|
1857
|
+
* hot.alter('insert_row_above', 5, 45);
|
1858
|
+
* hot.alter('insert_col_start', 10, 40);
|
1859
|
+
* hot.setDataAtCell(1, 1, 'John');
|
1860
|
+
* hot.setDataAtCell(2, 2, 'Mark');
|
1861
|
+
* hot.setDataAtCell(3, 3, 'Ann');
|
1862
|
+
* hot.setDataAtCell(4, 4, 'Sophia');
|
1863
|
+
* hot.setDataAtCell(5, 5, 'Mia');
|
1864
|
+
* hot.selectCell(0, 0);
|
1865
|
+
* // The table will be rendered once after executing the callback
|
1866
|
+
* });
|
1867
|
+
* ```
|
1868
|
+
*/
|
1869
|
+
this.batchRender = function (wrappedOperations) {
|
1870
|
+
this.suspendRender();
|
1871
|
+
var result = wrappedOperations();
|
1872
|
+
this.resumeRender();
|
1873
|
+
return result;
|
1874
|
+
};
|
1875
|
+
|
1876
|
+
/**
|
1877
|
+
* Checks if the table indexes recalculation process was suspended. See explanation
|
1878
|
+
* in {@link Core#suspendExecution}.
|
1879
|
+
*
|
1880
|
+
* @memberof Core#
|
1881
|
+
* @function isExecutionSuspended
|
1882
|
+
* @since 8.3.0
|
1883
|
+
* @returns {boolean}
|
1884
|
+
*/
|
1885
|
+
this.isExecutionSuspended = function () {
|
1886
|
+
return this.executionSuspendedCounter > 0;
|
1887
|
+
};
|
1888
|
+
|
1889
|
+
/**
|
1890
|
+
* Suspends the execution process. It's helpful to wrap the table logic changes
|
1891
|
+
* such as index changes into one call after which the cache is updated. As a result,
|
1892
|
+
* it improves the performance of wrapped operations.
|
1893
|
+
*
|
1894
|
+
* The method is intended to be used by advanced users. Suspending the execution
|
1895
|
+
* process could cause visual glitches caused by not updated the internal table cache.
|
1896
|
+
*
|
1897
|
+
* @memberof Core#
|
1898
|
+
* @function suspendExecution
|
1899
|
+
* @since 8.3.0
|
1900
|
+
* @example
|
1901
|
+
* ```js
|
1902
|
+
* hot.suspendExecution();
|
1903
|
+
* const filters = hot.getPlugin('filters');
|
1904
|
+
*
|
1905
|
+
* filters.addCondition(2, 'contains', ['3']);
|
1906
|
+
* filters.filter();
|
1907
|
+
* hot.getPlugin('columnSorting').sort({ column: 1, sortOrder: 'desc' });
|
1908
|
+
* hot.resumeExecution(); // It updates the cache internally
|
1909
|
+
* ```
|
1910
|
+
*/
|
1911
|
+
this.suspendExecution = function () {
|
1912
|
+
this.executionSuspendedCounter += 1;
|
1913
|
+
this.columnIndexMapper.suspendOperations();
|
1914
|
+
this.rowIndexMapper.suspendOperations();
|
1915
|
+
};
|
1916
|
+
|
1917
|
+
/**
|
1918
|
+
* Resumes the execution process. In combination with the {@link Core#suspendExecution}
|
1919
|
+
* method it allows aggregating the table logic changes after which the cache is
|
1920
|
+
* updated. Resuming the state automatically invokes the table cache updating process.
|
1921
|
+
*
|
1922
|
+
* The method is intended to be used by advanced users. Suspending the execution
|
1923
|
+
* process could cause visual glitches caused by not updated the internal table cache.
|
1924
|
+
*
|
1925
|
+
* @memberof Core#
|
1926
|
+
* @function resumeExecution
|
1927
|
+
* @param {boolean} [forceFlushChanges=false] If `true`, the table internal data cache
|
1928
|
+
* is recalculated after the execution of the batched operations. For nested
|
1929
|
+
* {@link Core#batchExecution} calls, it can be desire to recalculate the table
|
1930
|
+
* after each batch.
|
1931
|
+
* @since 8.3.0
|
1932
|
+
* @example
|
1933
|
+
* ```js
|
1934
|
+
* hot.suspendExecution();
|
1935
|
+
* const filters = hot.getPlugin('filters');
|
1936
|
+
*
|
1937
|
+
* filters.addCondition(2, 'contains', ['3']);
|
1938
|
+
* filters.filter();
|
1939
|
+
* hot.getPlugin('columnSorting').sort({ column: 1, sortOrder: 'desc' });
|
1940
|
+
* hot.resumeExecution(); // It updates the cache internally
|
1941
|
+
* ```
|
1942
|
+
*/
|
1943
|
+
this.resumeExecution = function () {
|
1944
|
+
var forceFlushChanges = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
1945
|
+
var nextValue = this.executionSuspendedCounter - 1;
|
1946
|
+
this.executionSuspendedCounter = Math.max(nextValue, 0);
|
1947
|
+
if (!this.isExecutionSuspended() && nextValue === this.executionSuspendedCounter || forceFlushChanges) {
|
1948
|
+
this.columnIndexMapper.resumeOperations();
|
1949
|
+
this.rowIndexMapper.resumeOperations();
|
1950
|
+
}
|
1951
|
+
};
|
1952
|
+
|
1953
|
+
/**
|
1954
|
+
* The method aggregates multi-line API calls into a callback and postpones the
|
1955
|
+
* table execution process. After the execution of the operations, the internal table
|
1956
|
+
* cache is recalculated once. As a result, it improves the performance of wrapped
|
1957
|
+
* operations. Without batching, a similar case could trigger multiple table cache rebuilds.
|
1958
|
+
*
|
1959
|
+
* @memberof Core#
|
1960
|
+
* @function batchExecution
|
1961
|
+
* @param {Function} wrappedOperations Batched operations wrapped in a function.
|
1962
|
+
* @param {boolean} [forceFlushChanges=false] If `true`, the table internal data cache
|
1963
|
+
* is recalculated after the execution of the batched operations. For nested calls,
|
1964
|
+
* it can be a desire to recalculate the table after each batch.
|
1965
|
+
* @returns {*} Returns result from the wrappedOperations callback.
|
1966
|
+
* @since 8.3.0
|
1967
|
+
* @example
|
1968
|
+
* ```js
|
1969
|
+
* hot.batchExecution(() => {
|
1970
|
+
* const filters = hot.getPlugin('filters');
|
1971
|
+
*
|
1972
|
+
* filters.addCondition(2, 'contains', ['3']);
|
1973
|
+
* filters.filter();
|
1974
|
+
* hot.getPlugin('columnSorting').sort({ column: 1, sortOrder: 'desc' });
|
1975
|
+
* // The table cache will be recalculated once after executing the callback
|
1976
|
+
* });
|
1977
|
+
* ```
|
1978
|
+
*/
|
1979
|
+
this.batchExecution = function (wrappedOperations) {
|
1980
|
+
var forceFlushChanges = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
1981
|
+
this.suspendExecution();
|
1982
|
+
var result = wrappedOperations();
|
1983
|
+
this.resumeExecution(forceFlushChanges);
|
1984
|
+
return result;
|
1985
|
+
};
|
1986
|
+
|
1987
|
+
/**
|
1988
|
+
* It batches the rendering process and index recalculations. The method aggregates
|
1989
|
+
* multi-line API calls into a callback and postpones the table rendering process
|
1990
|
+
* as well aggregates the table logic changes such as index changes into one call
|
1991
|
+
* after which the cache is updated. After the execution of the operations, the
|
1992
|
+
* table is rendered, and the cache is updated once. As a result, it improves the
|
1993
|
+
* performance of wrapped operations.
|
1994
|
+
*
|
1995
|
+
* @memberof Core#
|
1996
|
+
* @function batch
|
1997
|
+
* @param {Function} wrappedOperations Batched operations wrapped in a function.
|
1998
|
+
* @returns {*} Returns result from the wrappedOperations callback.
|
1999
|
+
* @since 8.3.0
|
2000
|
+
* @example
|
2001
|
+
* ```js
|
2002
|
+
* hot.batch(() => {
|
2003
|
+
* hot.alter('insert_row_above', 5, 45);
|
2004
|
+
* hot.alter('insert_col_start', 10, 40);
|
2005
|
+
* hot.setDataAtCell(1, 1, 'x');
|
2006
|
+
* hot.setDataAtCell(2, 2, 'c');
|
2007
|
+
* hot.setDataAtCell(3, 3, 'v');
|
2008
|
+
* hot.setDataAtCell(4, 4, 'b');
|
2009
|
+
* hot.setDataAtCell(5, 5, 'n');
|
2010
|
+
* hot.selectCell(0, 0);
|
2011
|
+
*
|
2012
|
+
* const filters = hot.getPlugin('filters');
|
2013
|
+
*
|
2014
|
+
* filters.addCondition(2, 'contains', ['3']);
|
2015
|
+
* filters.filter();
|
2016
|
+
* hot.getPlugin('columnSorting').sort({ column: 1, sortOrder: 'desc' });
|
2017
|
+
* // The table will be re-rendered and cache will be recalculated once after executing the callback
|
2018
|
+
* });
|
2019
|
+
* ```
|
2020
|
+
*/
|
2021
|
+
this.batch = function (wrappedOperations) {
|
2022
|
+
this.suspendRender();
|
2023
|
+
this.suspendExecution();
|
2024
|
+
var result = wrappedOperations();
|
2025
|
+
this.resumeExecution();
|
2026
|
+
this.resumeRender();
|
2027
|
+
return result;
|
2028
|
+
};
|
2029
|
+
|
2030
|
+
/**
|
2031
|
+
* Updates dimensions of the table. The method compares previous dimensions with the current ones and updates accordingly.
|
2032
|
+
*
|
2033
|
+
* @memberof Core#
|
2034
|
+
* @function refreshDimensions
|
2035
|
+
* @fires Hooks#beforeRefreshDimensions
|
2036
|
+
* @fires Hooks#afterRefreshDimensions
|
2037
|
+
*/
|
2038
|
+
this.refreshDimensions = function () {
|
2039
|
+
if (!instance.view) {
|
2040
|
+
return;
|
2041
|
+
}
|
2042
|
+
var _instance$view$getLas = instance.view.getLastSize(),
|
2043
|
+
lastWidth = _instance$view$getLas.width,
|
2044
|
+
lastHeight = _instance$view$getLas.height;
|
2045
|
+
var _instance$rootElement = instance.rootElement.getBoundingClientRect(),
|
2046
|
+
width = _instance$rootElement.width,
|
2047
|
+
height = _instance$rootElement.height;
|
2048
|
+
var isSizeChanged = width !== lastWidth || height !== lastHeight;
|
2049
|
+
var isResizeBlocked = instance.runHooks('beforeRefreshDimensions', {
|
2050
|
+
width: lastWidth,
|
2051
|
+
height: lastHeight
|
2052
|
+
}, {
|
2053
|
+
width: width,
|
2054
|
+
height: height
|
2055
|
+
}, isSizeChanged) === false;
|
2056
|
+
if (isResizeBlocked) {
|
2057
|
+
return;
|
2058
|
+
}
|
2059
|
+
if (isSizeChanged || instance.view._wt.wtOverlays.scrollableElement === instance.rootWindow) {
|
2060
|
+
instance.view.setLastSize(width, height);
|
2061
|
+
instance.render();
|
2062
|
+
}
|
2063
|
+
instance.runHooks('afterRefreshDimensions', {
|
2064
|
+
width: lastWidth,
|
2065
|
+
height: lastHeight
|
2066
|
+
}, {
|
2067
|
+
width: width,
|
2068
|
+
height: height
|
2069
|
+
}, isSizeChanged);
|
2070
|
+
};
|
2071
|
+
|
2072
|
+
/**
|
2073
|
+
* The `updateData()` method replaces Handsontable's [`data`](@/api/options.md#data) with a new dataset.
|
2074
|
+
*
|
2075
|
+
* The `updateData()` method:
|
2076
|
+
* - Keeps cells' states (e.g. cells' [formatting](@/guides/cell-features/formatting-cells.md) and cells' [`readOnly`](@/api/options.md#readonly) states)
|
2077
|
+
* - Keeps rows' states (e.g. row order)
|
2078
|
+
* - Keeps columns' states (e.g. column order)
|
2079
|
+
*
|
2080
|
+
* To replace Handsontable's [`data`](@/api/options.md#data) and reset states, use the [`loadData()`](#loaddata) method.
|
2081
|
+
*
|
2082
|
+
* Read more:
|
2083
|
+
* - [Binding to data](@/guides/getting-started/binding-to-data.md)
|
2084
|
+
* - [Saving data](@/guides/getting-started/saving-data.md)
|
2085
|
+
*
|
2086
|
+
* @memberof Core#
|
2087
|
+
* @function updateData
|
2088
|
+
* @since 11.1.0
|
2089
|
+
* @param {Array} data An [array of arrays](@/guides/getting-started/binding-to-data.md#array-of-arrays), or an [array of objects](@/guides/getting-started/binding-to-data.md#array-of-objects), that contains Handsontable's data
|
2090
|
+
* @param {string} [source] The source of the `updateData()` call
|
2091
|
+
* @fires Hooks#beforeUpdateData
|
2092
|
+
* @fires Hooks#afterUpdateData
|
2093
|
+
* @fires Hooks#afterChange
|
2094
|
+
*/
|
2095
|
+
this.updateData = function (data, source) {
|
2096
|
+
var _this3 = this;
|
2097
|
+
(0, _dataMap.replaceData)(data, function (newDataMap) {
|
2098
|
+
datamap = newDataMap;
|
2099
|
+
}, function (newDataMap) {
|
2100
|
+
datamap = newDataMap;
|
2101
|
+
instance.columnIndexMapper.fitToLength(_this3.getInitialColumnCount());
|
2102
|
+
instance.rowIndexMapper.fitToLength(_this3.countSourceRows());
|
2103
|
+
grid.adjustRowsAndCols();
|
2104
|
+
}, {
|
2105
|
+
hotInstance: instance,
|
2106
|
+
dataMap: datamap,
|
2107
|
+
dataSource: dataSource,
|
2108
|
+
internalSource: 'updateData',
|
2109
|
+
source: source,
|
2110
|
+
firstRun: firstRun
|
2111
|
+
});
|
2112
|
+
};
|
2113
|
+
|
2114
|
+
/**
|
2115
|
+
* The `loadData()` method replaces Handsontable's [`data`](@/api/options.md#data) with a new dataset.
|
2116
|
+
*
|
2117
|
+
* Additionally, the `loadData()` method:
|
2118
|
+
* - Resets cells' states (e.g. cells' [formatting](@/guides/cell-features/formatting-cells.md) and cells' [`readOnly`](@/api/options.md#readonly) states)
|
2119
|
+
* - Resets rows' states (e.g. row order)
|
2120
|
+
* - Resets columns' states (e.g. column order)
|
2121
|
+
*
|
2122
|
+
* To replace Handsontable's [`data`](@/api/options.md#data) without resetting states, use the [`updateData()`](#updatedata) method.
|
2123
|
+
*
|
2124
|
+
* Read more:
|
2125
|
+
* - [Binding to data](@/guides/getting-started/binding-to-data.md)
|
2126
|
+
* - [Saving data](@/guides/getting-started/saving-data.md)
|
2127
|
+
*
|
2128
|
+
* @memberof Core#
|
2129
|
+
* @function loadData
|
2130
|
+
* @param {Array} data An [array of arrays](@/guides/getting-started/binding-to-data.md#array-of-arrays), or an [array of objects](@/guides/getting-started/binding-to-data.md#array-of-objects), that contains Handsontable's data
|
2131
|
+
* @param {string} [source] The source of the `loadData()` call
|
2132
|
+
* @fires Hooks#beforeLoadData
|
2133
|
+
* @fires Hooks#afterLoadData
|
2134
|
+
* @fires Hooks#afterChange
|
2135
|
+
*/
|
2136
|
+
this.loadData = function (data, source) {
|
2137
|
+
(0, _dataMap.replaceData)(data, function (newDataMap) {
|
2138
|
+
datamap = newDataMap;
|
2139
|
+
}, function () {
|
2140
|
+
metaManager.clearCellsCache();
|
2141
|
+
instance.initIndexMappers();
|
2142
|
+
grid.adjustRowsAndCols();
|
2143
|
+
if (firstRun) {
|
2144
|
+
firstRun = [null, 'loadData'];
|
2145
|
+
}
|
2146
|
+
}, {
|
2147
|
+
hotInstance: instance,
|
2148
|
+
dataMap: datamap,
|
2149
|
+
dataSource: dataSource,
|
2150
|
+
internalSource: 'loadData',
|
2151
|
+
source: source,
|
2152
|
+
firstRun: firstRun
|
2153
|
+
});
|
2154
|
+
};
|
2155
|
+
|
2156
|
+
/**
|
2157
|
+
* Gets the initial column count, calculated based on the `columns` setting.
|
2158
|
+
*
|
2159
|
+
* @private
|
2160
|
+
* @returns {number} The calculated number of columns.
|
2161
|
+
*/
|
2162
|
+
this.getInitialColumnCount = function () {
|
2163
|
+
var columnsSettings = tableMeta.columns;
|
2164
|
+
var finalNrOfColumns = 0;
|
2165
|
+
|
2166
|
+
// We will check number of columns when the `columns` property was defined as an array. Columns option may
|
2167
|
+
// narrow down or expand displayed dataset in that case.
|
2168
|
+
if (Array.isArray(columnsSettings)) {
|
2169
|
+
finalNrOfColumns = columnsSettings.length;
|
2170
|
+
} else if ((0, _function.isFunction)(columnsSettings)) {
|
2171
|
+
if (instance.dataType === 'array') {
|
2172
|
+
var nrOfSourceColumns = this.countSourceCols();
|
2173
|
+
for (var columnIndex = 0; columnIndex < nrOfSourceColumns; columnIndex += 1) {
|
2174
|
+
if (columnsSettings(columnIndex)) {
|
2175
|
+
finalNrOfColumns += 1;
|
2176
|
+
}
|
2177
|
+
}
|
2178
|
+
|
2179
|
+
// Extended dataset by the `columns` property? Moved code right from the refactored `countCols` method.
|
2180
|
+
} else if (instance.dataType === 'object' || instance.dataType === 'function') {
|
2181
|
+
finalNrOfColumns = datamap.colToPropCache.length;
|
2182
|
+
}
|
2183
|
+
|
2184
|
+
// In some cases we need to check columns length from the schema, i.e. `data` may be empty.
|
2185
|
+
} else if ((0, _mixed.isDefined)(tableMeta.dataSchema)) {
|
2186
|
+
var schema = datamap.getSchema();
|
2187
|
+
|
2188
|
+
// Schema may be defined as an array of objects. Each object will define column.
|
2189
|
+
finalNrOfColumns = Array.isArray(schema) ? schema.length : (0, _object.deepObjectSize)(schema);
|
2190
|
+
} else {
|
2191
|
+
// We init index mappers by length of source data to provide indexes also for skipped indexes.
|
2192
|
+
finalNrOfColumns = this.countSourceCols();
|
2193
|
+
}
|
2194
|
+
return finalNrOfColumns;
|
2195
|
+
};
|
2196
|
+
|
2197
|
+
/**
|
2198
|
+
* Init index mapper which manage indexes assigned to the data.
|
2199
|
+
*
|
2200
|
+
* @private
|
2201
|
+
*/
|
2202
|
+
this.initIndexMappers = function () {
|
2203
|
+
this.columnIndexMapper.initToLength(this.getInitialColumnCount());
|
2204
|
+
this.rowIndexMapper.initToLength(this.countSourceRows());
|
2205
|
+
};
|
2206
|
+
|
2207
|
+
/**
|
2208
|
+
* Returns the current data object (the same one that was passed by `data` configuration option or `loadData` method,
|
2209
|
+
* unless some modifications have been applied (i.e. Sequence of rows/columns was changed, some row/column was skipped).
|
2210
|
+
* If that's the case - use the {@link Core#getSourceData} method.).
|
2211
|
+
*
|
2212
|
+
* Optionally you can provide cell range by defining `row`, `column`, `row2`, `column2` to get only a fragment of table data.
|
2213
|
+
*
|
2214
|
+
* @memberof Core#
|
2215
|
+
* @function getData
|
2216
|
+
* @param {number} [row] From visual row index.
|
2217
|
+
* @param {number} [column] From visual column index.
|
2218
|
+
* @param {number} [row2] To visual row index.
|
2219
|
+
* @param {number} [column2] To visual column index.
|
2220
|
+
* @returns {Array[]} Array with the data.
|
2221
|
+
* @example
|
2222
|
+
* ```js
|
2223
|
+
* // Get all data (in order how it is rendered in the table).
|
2224
|
+
* hot.getData();
|
2225
|
+
* // Get data fragment (from top-left 0, 0 to bottom-right 3, 3).
|
2226
|
+
* hot.getData(3, 3);
|
2227
|
+
* // Get data fragment (from top-left 2, 1 to bottom-right 3, 3).
|
2228
|
+
* hot.getData(2, 1, 3, 3);
|
2229
|
+
* ```
|
2230
|
+
*/
|
2231
|
+
this.getData = function (row, column, row2, column2) {
|
2232
|
+
if ((0, _mixed.isUndefined)(row)) {
|
2233
|
+
return datamap.getAll();
|
2234
|
+
}
|
2235
|
+
return datamap.getRange(instance._createCellCoords(row, column), instance._createCellCoords(row2, column2), datamap.DESTINATION_RENDERER);
|
2236
|
+
};
|
2237
|
+
|
2238
|
+
/**
|
2239
|
+
* Returns a string value of the selected range. Each column is separated by tab, each row is separated by a new
|
2240
|
+
* line character.
|
2241
|
+
*
|
2242
|
+
* @memberof Core#
|
2243
|
+
* @function getCopyableText
|
2244
|
+
* @param {number} startRow From visual row index.
|
2245
|
+
* @param {number} startCol From visual column index.
|
2246
|
+
* @param {number} endRow To visual row index.
|
2247
|
+
* @param {number} endCol To visual column index.
|
2248
|
+
* @returns {string}
|
2249
|
+
*/
|
2250
|
+
this.getCopyableText = function (startRow, startCol, endRow, endCol) {
|
2251
|
+
return datamap.getCopyableText(instance._createCellCoords(startRow, startCol), instance._createCellCoords(endRow, endCol));
|
2252
|
+
};
|
2253
|
+
|
2254
|
+
/**
|
2255
|
+
* Returns the data's copyable value at specified `row` and `column` index.
|
2256
|
+
*
|
2257
|
+
* @memberof Core#
|
2258
|
+
* @function getCopyableData
|
2259
|
+
* @param {number} row Visual row index.
|
2260
|
+
* @param {number} column Visual column index.
|
2261
|
+
* @returns {string}
|
2262
|
+
*/
|
2263
|
+
this.getCopyableData = function (row, column) {
|
2264
|
+
return datamap.getCopyable(row, datamap.colToProp(column));
|
2265
|
+
};
|
2266
|
+
|
2267
|
+
/**
|
2268
|
+
* Returns schema provided by constructor settings. If it doesn't exist then it returns the schema based on the data
|
2269
|
+
* structure in the first row.
|
2270
|
+
*
|
2271
|
+
* @memberof Core#
|
2272
|
+
* @function getSchema
|
2273
|
+
* @returns {object} Schema object.
|
2274
|
+
*/
|
2275
|
+
this.getSchema = function () {
|
2276
|
+
return datamap.getSchema();
|
2277
|
+
};
|
2278
|
+
|
2279
|
+
/**
|
2280
|
+
* Use it if you need to change configuration after initialization. The `settings` argument is an object containing the changed
|
2281
|
+
* settings, declared the same way as in the initial settings object.
|
2282
|
+
*
|
2283
|
+
* __Note__, that although the `updateSettings` method doesn't overwrite the previously declared settings, it might reset
|
2284
|
+
* the settings made post-initialization. (for example - ignore changes made using the columnResize feature).
|
2285
|
+
*
|
2286
|
+
* Since 8.0.0 passing `columns` or `data` inside `settings` objects will result in resetting states corresponding to rows and columns
|
2287
|
+
* (for example, row/column sequence, column width, row height, frozen columns etc.).
|
2288
|
+
*
|
2289
|
+
* Since 12.0.0 passing `data` inside `settings` objects no longer results in resetting states corresponding to rows and columns
|
2290
|
+
* (for example, row/column sequence, column width, row height, frozen columns etc.).
|
2291
|
+
*
|
2292
|
+
* @memberof Core#
|
2293
|
+
* @function updateSettings
|
2294
|
+
* @param {object} settings A settings object (see {@link Options}). Only provide the settings that are changed, not the whole settings object that was used for initialization.
|
2295
|
+
* @param {boolean} [init=false] Internally used for in initialization mode.
|
2296
|
+
* @example
|
2297
|
+
* ```js
|
2298
|
+
* hot.updateSettings({
|
2299
|
+
* contextMenu: true,
|
2300
|
+
* colHeaders: true,
|
2301
|
+
* fixedRowsTop: 2
|
2302
|
+
* });
|
2303
|
+
* ```
|
2304
|
+
* @fires Hooks#afterCellMetaReset
|
2305
|
+
* @fires Hooks#afterUpdateSettings
|
2306
|
+
*/
|
2307
|
+
this.updateSettings = function (settings) {
|
2308
|
+
var init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2309
|
+
var dataUpdateFunction = (firstRun ? instance.loadData : instance.updateData).bind(this);
|
2310
|
+
var columnsAsFunc = false;
|
2311
|
+
var i;
|
2312
|
+
var j;
|
2313
|
+
if ((0, _mixed.isDefined)(settings.rows)) {
|
2314
|
+
throw new Error('The "rows" setting is no longer supported. Do you mean startRows, minRows or maxRows?');
|
2315
|
+
}
|
2316
|
+
if ((0, _mixed.isDefined)(settings.cols)) {
|
2317
|
+
throw new Error('The "cols" setting is no longer supported. Do you mean startCols, minCols or maxCols?');
|
2318
|
+
}
|
2319
|
+
if ((0, _mixed.isDefined)(settings.ganttChart)) {
|
2320
|
+
throw new Error('Since 8.0.0 the "ganttChart" setting is no longer supported.');
|
2321
|
+
}
|
2322
|
+
|
2323
|
+
// eslint-disable-next-line no-restricted-syntax
|
2324
|
+
for (i in settings) {
|
2325
|
+
if (i === 'data') {
|
2326
|
+
// Do nothing. loadData will be triggered later
|
2327
|
+
} else if (i === 'language') {
|
2328
|
+
setLanguage(settings.language);
|
2329
|
+
} else if (i === 'className') {
|
2330
|
+
setClassName('className', settings.className);
|
2331
|
+
} else if (i === 'tableClassName' && instance.table) {
|
2332
|
+
setClassName('tableClassName', settings.tableClassName);
|
2333
|
+
instance.view._wt.wtOverlays.syncOverlayTableClassNames();
|
2334
|
+
} else if (_pluginHooks.default.getSingleton().isRegistered(i) || _pluginHooks.default.getSingleton().isDeprecated(i)) {
|
2335
|
+
if ((0, _function.isFunction)(settings[i]) || Array.isArray(settings[i])) {
|
2336
|
+
settings[i].initialHook = true;
|
2337
|
+
instance.addHook(i, settings[i]);
|
2338
|
+
}
|
2339
|
+
} else if (!init && (0, _object.hasOwnProperty)(settings, i)) {
|
2340
|
+
// Update settings
|
2341
|
+
globalMeta[i] = settings[i];
|
2342
|
+
}
|
2343
|
+
}
|
2344
|
+
|
2345
|
+
// Load data or create data map
|
2346
|
+
if (settings.data === void 0 && tableMeta.data === void 0) {
|
2347
|
+
dataUpdateFunction(null, 'updateSettings'); // data source created just now
|
2348
|
+
} else if (settings.data !== void 0) {
|
2349
|
+
dataUpdateFunction(settings.data, 'updateSettings'); // data source given as option
|
2350
|
+
} else if (settings.columns !== void 0) {
|
2351
|
+
datamap.createMap();
|
2352
|
+
|
2353
|
+
// The `column` property has changed - dataset may be expanded or narrowed down. The `loadData` do the same.
|
2354
|
+
instance.initIndexMappers();
|
2355
|
+
}
|
2356
|
+
var clen = instance.countCols();
|
2357
|
+
var columnSetting = tableMeta.columns;
|
2358
|
+
|
2359
|
+
// Init columns constructors configuration
|
2360
|
+
if (columnSetting && (0, _function.isFunction)(columnSetting)) {
|
2361
|
+
columnsAsFunc = true;
|
2362
|
+
}
|
2363
|
+
|
2364
|
+
// Clear cell meta cache
|
2365
|
+
if (settings.cell !== void 0 || settings.cells !== void 0 || settings.columns !== void 0) {
|
2366
|
+
metaManager.clearCache();
|
2367
|
+
}
|
2368
|
+
if (clen > 0) {
|
2369
|
+
for (i = 0, j = 0; i < clen; i++) {
|
2370
|
+
// Use settings provided by user
|
2371
|
+
if (columnSetting) {
|
2372
|
+
var column = columnsAsFunc ? columnSetting(i) : columnSetting[j];
|
2373
|
+
if (column) {
|
2374
|
+
metaManager.updateColumnMeta(j, column);
|
2375
|
+
}
|
2376
|
+
}
|
2377
|
+
j += 1;
|
2378
|
+
}
|
2379
|
+
}
|
2380
|
+
if ((0, _mixed.isDefined)(settings.cell)) {
|
2381
|
+
(0, _object.objectEach)(settings.cell, function (cell) {
|
2382
|
+
instance.setCellMetaObject(cell.row, cell.col, cell);
|
2383
|
+
});
|
2384
|
+
}
|
2385
|
+
instance.runHooks('afterCellMetaReset');
|
2386
|
+
var currentHeight = instance.rootElement.style.height;
|
2387
|
+
if (currentHeight !== '') {
|
2388
|
+
currentHeight = parseInt(instance.rootElement.style.height, 10);
|
2389
|
+
}
|
2390
|
+
var height = settings.height;
|
2391
|
+
if ((0, _function.isFunction)(height)) {
|
2392
|
+
height = height();
|
2393
|
+
}
|
2394
|
+
if (init) {
|
2395
|
+
var initialStyle = instance.rootElement.getAttribute('style');
|
2396
|
+
if (initialStyle) {
|
2397
|
+
instance.rootElement.setAttribute('data-initialstyle', instance.rootElement.getAttribute('style'));
|
2398
|
+
}
|
2399
|
+
}
|
2400
|
+
if (height === null) {
|
2401
|
+
var _initialStyle = instance.rootElement.getAttribute('data-initialstyle');
|
2402
|
+
if (_initialStyle && (_initialStyle.indexOf('height') > -1 || _initialStyle.indexOf('overflow') > -1)) {
|
2403
|
+
instance.rootElement.setAttribute('style', _initialStyle);
|
2404
|
+
} else {
|
2405
|
+
instance.rootElement.style.height = '';
|
2406
|
+
instance.rootElement.style.overflow = '';
|
2407
|
+
}
|
2408
|
+
} else if (height !== void 0) {
|
2409
|
+
instance.rootElement.style.height = isNaN(height) ? "".concat(height) : "".concat(height, "px");
|
2410
|
+
instance.rootElement.style.overflow = 'hidden';
|
2411
|
+
}
|
2412
|
+
if (typeof settings.width !== 'undefined') {
|
2413
|
+
var width = settings.width;
|
2414
|
+
if ((0, _function.isFunction)(width)) {
|
2415
|
+
width = width();
|
2416
|
+
}
|
2417
|
+
instance.rootElement.style.width = isNaN(width) ? "".concat(width) : "".concat(width, "px");
|
2418
|
+
}
|
2419
|
+
if (!init) {
|
2420
|
+
if (instance.view) {
|
2421
|
+
instance.view._wt.wtViewport.resetHasOversizedColumnHeadersMarked();
|
2422
|
+
instance.view._wt.exportSettingsAsClassNames();
|
2423
|
+
}
|
2424
|
+
instance.runHooks('afterUpdateSettings', settings);
|
2425
|
+
}
|
2426
|
+
grid.adjustRowsAndCols();
|
2427
|
+
if (instance.view && !firstRun) {
|
2428
|
+
instance.forceFullRender = true; // used when data was changed
|
2429
|
+
editorManager.lockEditor();
|
2430
|
+
instance._refreshBorders(null);
|
2431
|
+
instance.view._wt.wtOverlays.adjustElementsSize();
|
2432
|
+
editorManager.unlockEditor();
|
2433
|
+
}
|
2434
|
+
if (!init && instance.view && (currentHeight === '' || height === '' || height === void 0) && currentHeight !== height) {
|
2435
|
+
instance.view._wt.wtOverlays.updateMainScrollableElements();
|
2436
|
+
}
|
2437
|
+
};
|
2438
|
+
|
2439
|
+
/**
|
2440
|
+
* Get value from the selected cell.
|
2441
|
+
*
|
2442
|
+
* @memberof Core#
|
2443
|
+
* @function getValue
|
2444
|
+
* @returns {*} Value of selected cell.
|
2445
|
+
*/
|
2446
|
+
this.getValue = function () {
|
2447
|
+
var sel = instance.getSelectedLast();
|
2448
|
+
if (tableMeta.getValue) {
|
2449
|
+
if ((0, _function.isFunction)(tableMeta.getValue)) {
|
2450
|
+
return tableMeta.getValue.call(instance);
|
2451
|
+
} else if (sel) {
|
2452
|
+
return instance.getData()[sel[0][0]][tableMeta.getValue];
|
2453
|
+
}
|
2454
|
+
} else if (sel) {
|
2455
|
+
return instance.getDataAtCell(sel[0], sel[1]);
|
2456
|
+
}
|
2457
|
+
};
|
2458
|
+
|
2459
|
+
/**
|
2460
|
+
* Returns the object settings.
|
2461
|
+
*
|
2462
|
+
* @memberof Core#
|
2463
|
+
* @function getSettings
|
2464
|
+
* @returns {TableMeta} Object containing the current table settings.
|
2465
|
+
*/
|
2466
|
+
this.getSettings = function () {
|
2467
|
+
return tableMeta;
|
2468
|
+
};
|
2469
|
+
|
2470
|
+
/**
|
2471
|
+
* Clears the data from the table (the table settings remain intact).
|
2472
|
+
*
|
2473
|
+
* @memberof Core#
|
2474
|
+
* @function clear
|
2475
|
+
*/
|
2476
|
+
this.clear = function () {
|
2477
|
+
this.selectAll();
|
2478
|
+
this.emptySelectedCells();
|
2479
|
+
};
|
2480
|
+
|
2481
|
+
/**
|
2482
|
+
* The `alter()` method lets you alter the grid's structure
|
2483
|
+
* by adding or removing rows and columns at specified positions.
|
2484
|
+
*
|
2485
|
+
* ::: tip
|
2486
|
+
* The `alter()` method works only when your [`data`](@/api/options.md#data)
|
2487
|
+
* is an [array of arrays](@/guides/getting-started/binding-to-data.md#array-of-arrays).
|
2488
|
+
* :::
|
2489
|
+
*
|
2490
|
+
* ```js
|
2491
|
+
* // above row 10 (by visual index), insert 1 new row
|
2492
|
+
* hot.alter('insert_row_above', 10);
|
2493
|
+
* ```
|
2494
|
+
*
|
2495
|
+
* | Action | With `index` | Without `index` |
|
2496
|
+
* | -------------------- | ------------ | --------------- |
|
2497
|
+
* | `'insert_row_above'` | Inserts rows above the `index` row. | Inserts rows above the first row. |
|
2498
|
+
* | `'insert_row_below'` | Inserts rows below the `index` row. | Inserts rows below the last row. |
|
2499
|
+
* | `'remove_row'` | Removes rows, starting from the `index` row. | Removes rows, starting from the last row. |
|
2500
|
+
* | `'insert_col_start'` | Inserts columns before the `index` column. | Inserts columns before the first column. |
|
2501
|
+
* | `'insert_col_end'` | Inserts columns after the `index` column. | Inserts columns after the last column. |
|
2502
|
+
* | `'remove_col'` | Removes columns, starting from the `index` column. | Removes columns, starting from the last column. |
|
2503
|
+
* | `'insert_row'` (<b>Deprecated</b>) | Inserts rows above the `index` row. | Inserts rows below the last row. |
|
2504
|
+
* | `'insert_col'` (<b>Deprecated</b>) | Inserts columns before the `index` column. | Inserts columns after the last column. |
|
2505
|
+
*
|
2506
|
+
* The behavior of `'insert_col_start'`, `'insert_col_end'`, and `'insert_col'` depends on your [`layoutDirection`](@/api/options.md#layoutdirection).
|
2507
|
+
*
|
2508
|
+
* @memberof Core#
|
2509
|
+
* @function alter
|
2510
|
+
* @param {string} action Available operations:
|
2511
|
+
* <ul>
|
2512
|
+
* <li> `'insert_row_above'` </li>
|
2513
|
+
* <li> `'insert_row_below'` </li>
|
2514
|
+
* <li> `'remove_row'` </li> </li>
|
2515
|
+
* <li> `'insert_col_start'` </li>
|
2516
|
+
* <li> `'insert_col_end'` </li>
|
2517
|
+
* <li> `'remove_col'` </li>
|
2518
|
+
* <li> `'insert_row'` (<b>Deprecated</b>) </li>
|
2519
|
+
* <li> `'insert_col'` (<b>Deprecated</b>) </li>
|
2520
|
+
* </ul>
|
2521
|
+
* @param {number|number[]} [index] A visual index of the row/column before or after which the new row/column will be
|
2522
|
+
* inserted or removed. Can also be an array of arrays, in format `[[index, amount],...]`.
|
2523
|
+
* @param {number} [amount] The amount of rows or columns to be inserted or removed (default: `1`).
|
2524
|
+
* @param {string} [source] Source indicator.
|
2525
|
+
* @param {boolean} [keepEmptyRows] If set to `true`: prevents removing empty rows.
|
2526
|
+
* @example
|
2527
|
+
* ```js
|
2528
|
+
* // above row 10 (by visual index), insert 1 new row
|
2529
|
+
* hot.alter('insert_row_above', 10);
|
2530
|
+
*
|
2531
|
+
* // below row 10 (by visual index), insert 3 new rows
|
2532
|
+
* hot.alter('insert_row_below', 10, 3);
|
2533
|
+
*
|
2534
|
+
* // in the LTR layout direction: to the left of column 10 (by visual index), insert 3 new columns
|
2535
|
+
* // in the RTL layout direction: to the right of column 10 (by visual index), insert 3 new columns
|
2536
|
+
* hot.alter('insert_col_start', 10, 3);
|
2537
|
+
*
|
2538
|
+
* // in the LTR layout direction: to the right of column 10 (by visual index), insert 1 new column
|
2539
|
+
* // in the RTL layout direction: to the left of column 10 (by visual index), insert 1 new column
|
2540
|
+
* hot.alter('insert_col_end', 10);
|
2541
|
+
*
|
2542
|
+
* // remove 2 rows, starting from row 10 (by visual index)
|
2543
|
+
* hot.alter('remove_row', 10, 2);
|
2544
|
+
*
|
2545
|
+
* // remove 3 rows, starting from row 1 (by visual index)
|
2546
|
+
* // remove 2 rows, starting from row 5 (by visual index)
|
2547
|
+
* hot.alter('remove_row', [[1, 3], [5, 2]]);
|
2548
|
+
* ```
|
2549
|
+
*/
|
2550
|
+
this.alter = function (action, index, amount, source, keepEmptyRows) {
|
2551
|
+
grid.alter(action, index, amount, source, keepEmptyRows);
|
2552
|
+
};
|
2553
|
+
|
2554
|
+
/**
|
2555
|
+
* Returns a TD element for the given `row` and `column` arguments, if it is rendered on screen.
|
2556
|
+
* Returns `null` if the TD is not rendered on screen (probably because that part of the table is not visible).
|
2557
|
+
*
|
2558
|
+
* @memberof Core#
|
2559
|
+
* @function getCell
|
2560
|
+
* @param {number} row Visual row index.
|
2561
|
+
* @param {number} column Visual column index.
|
2562
|
+
* @param {boolean} [topmost=false] If set to `true`, it returns the TD element from the topmost overlay. For example,
|
2563
|
+
* if the wanted cell is in the range of fixed rows, it will return a TD element from the `top` overlay.
|
2564
|
+
* @returns {HTMLTableCellElement|null} The cell's TD element.
|
2565
|
+
*/
|
2566
|
+
this.getCell = function (row, column) {
|
2567
|
+
var topmost = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
2568
|
+
var renderableColumnIndex = column; // Handling also column headers.
|
2569
|
+
var renderableRowIndex = row; // Handling also row headers.
|
2570
|
+
|
2571
|
+
if (column >= 0) {
|
2572
|
+
if (this.columnIndexMapper.isHidden(this.toPhysicalColumn(column))) {
|
2573
|
+
return null;
|
2574
|
+
}
|
2575
|
+
renderableColumnIndex = this.columnIndexMapper.getRenderableFromVisualIndex(column);
|
2576
|
+
}
|
2577
|
+
if (row >= 0) {
|
2578
|
+
if (this.rowIndexMapper.isHidden(this.toPhysicalRow(row))) {
|
2579
|
+
return null;
|
2580
|
+
}
|
2581
|
+
renderableRowIndex = this.rowIndexMapper.getRenderableFromVisualIndex(row);
|
2582
|
+
}
|
2583
|
+
if (renderableRowIndex === null || renderableColumnIndex === null) {
|
2584
|
+
return null;
|
2585
|
+
}
|
2586
|
+
return instance.view.getCellAtCoords(instance._createCellCoords(renderableRowIndex, renderableColumnIndex), topmost);
|
2587
|
+
};
|
2588
|
+
|
2589
|
+
/**
|
2590
|
+
* Returns the coordinates of the cell, provided as a HTML table cell element.
|
2591
|
+
*
|
2592
|
+
* @memberof Core#
|
2593
|
+
* @function getCoords
|
2594
|
+
* @param {HTMLTableCellElement} element The HTML Element representing the cell.
|
2595
|
+
* @returns {CellCoords|null} Visual coordinates object.
|
2596
|
+
* @example
|
2597
|
+
* ```js
|
2598
|
+
* hot.getCoords(hot.getCell(1, 1));
|
2599
|
+
* // it returns CellCoords object instance with props row: 1 and col: 1.
|
2600
|
+
* ```
|
2601
|
+
*/
|
2602
|
+
this.getCoords = function (element) {
|
2603
|
+
var renderableCoords = this.view._wt.wtTable.getCoords(element);
|
2604
|
+
if (renderableCoords === null) {
|
2605
|
+
return null;
|
2606
|
+
}
|
2607
|
+
var renderableRow = renderableCoords.row,
|
2608
|
+
renderableColumn = renderableCoords.col;
|
2609
|
+
var visualRow = renderableRow;
|
2610
|
+
var visualColumn = renderableColumn;
|
2611
|
+
if (renderableRow >= 0) {
|
2612
|
+
visualRow = this.rowIndexMapper.getVisualFromRenderableIndex(renderableRow);
|
2613
|
+
}
|
2614
|
+
if (renderableColumn >= 0) {
|
2615
|
+
visualColumn = this.columnIndexMapper.getVisualFromRenderableIndex(renderableColumn);
|
2616
|
+
}
|
2617
|
+
return instance._createCellCoords(visualRow, visualColumn);
|
2618
|
+
};
|
2619
|
+
|
2620
|
+
/**
|
2621
|
+
* Returns the property name that corresponds with the given column index.
|
2622
|
+
* If the data source is an array of arrays, it returns the columns index.
|
2623
|
+
*
|
2624
|
+
* @memberof Core#
|
2625
|
+
* @function colToProp
|
2626
|
+
* @param {number} column Visual column index.
|
2627
|
+
* @returns {string|number} Column property or physical column index.
|
2628
|
+
*/
|
2629
|
+
this.colToProp = function (column) {
|
2630
|
+
return datamap.colToProp(column);
|
2631
|
+
};
|
2632
|
+
|
2633
|
+
/**
|
2634
|
+
* Returns column index that corresponds with the given property.
|
2635
|
+
*
|
2636
|
+
* @memberof Core#
|
2637
|
+
* @function propToCol
|
2638
|
+
* @param {string|number} prop Property name or physical column index.
|
2639
|
+
* @returns {number} Visual column index.
|
2640
|
+
*/
|
2641
|
+
this.propToCol = function (prop) {
|
2642
|
+
return datamap.propToCol(prop);
|
2643
|
+
};
|
2644
|
+
|
2645
|
+
/**
|
2646
|
+
* Translate physical row index into visual.
|
2647
|
+
*
|
2648
|
+
* This method is useful when you want to retrieve visual row index which can be reordered, moved or trimmed
|
2649
|
+
* based on a physical index.
|
2650
|
+
*
|
2651
|
+
* @memberof Core#
|
2652
|
+
* @function toVisualRow
|
2653
|
+
* @param {number} row Physical row index.
|
2654
|
+
* @returns {number} Returns visual row index.
|
2655
|
+
*/
|
2656
|
+
this.toVisualRow = function (row) {
|
2657
|
+
return _this.rowIndexMapper.getVisualFromPhysicalIndex(row);
|
2658
|
+
};
|
2659
|
+
|
2660
|
+
/**
|
2661
|
+
* Translate physical column index into visual.
|
2662
|
+
*
|
2663
|
+
* This method is useful when you want to retrieve visual column index which can be reordered, moved or trimmed
|
2664
|
+
* based on a physical index.
|
2665
|
+
*
|
2666
|
+
* @memberof Core#
|
2667
|
+
* @function toVisualColumn
|
2668
|
+
* @param {number} column Physical column index.
|
2669
|
+
* @returns {number} Returns visual column index.
|
2670
|
+
*/
|
2671
|
+
this.toVisualColumn = function (column) {
|
2672
|
+
return _this.columnIndexMapper.getVisualFromPhysicalIndex(column);
|
2673
|
+
};
|
2674
|
+
|
2675
|
+
/**
|
2676
|
+
* Translate visual row index into physical.
|
2677
|
+
*
|
2678
|
+
* This method is useful when you want to retrieve physical row index based on a visual index which can be
|
2679
|
+
* reordered, moved or trimmed.
|
2680
|
+
*
|
2681
|
+
* @memberof Core#
|
2682
|
+
* @function toPhysicalRow
|
2683
|
+
* @param {number} row Visual row index.
|
2684
|
+
* @returns {number} Returns physical row index.
|
2685
|
+
*/
|
2686
|
+
this.toPhysicalRow = function (row) {
|
2687
|
+
return _this.rowIndexMapper.getPhysicalFromVisualIndex(row);
|
2688
|
+
};
|
2689
|
+
|
2690
|
+
/**
|
2691
|
+
* Translate visual column index into physical.
|
2692
|
+
*
|
2693
|
+
* This method is useful when you want to retrieve physical column index based on a visual index which can be
|
2694
|
+
* reordered, moved or trimmed.
|
2695
|
+
*
|
2696
|
+
* @memberof Core#
|
2697
|
+
* @function toPhysicalColumn
|
2698
|
+
* @param {number} column Visual column index.
|
2699
|
+
* @returns {number} Returns physical column index.
|
2700
|
+
*/
|
2701
|
+
this.toPhysicalColumn = function (column) {
|
2702
|
+
return _this.columnIndexMapper.getPhysicalFromVisualIndex(column);
|
2703
|
+
};
|
2704
|
+
|
2705
|
+
/**
|
2706
|
+
* @description
|
2707
|
+
* Returns the cell value at `row`, `column`.
|
2708
|
+
*
|
2709
|
+
* __Note__: If data is reordered, sorted or trimmed, the currently visible order will be used.
|
2710
|
+
*
|
2711
|
+
* @memberof Core#
|
2712
|
+
* @function getDataAtCell
|
2713
|
+
* @param {number} row Visual row index.
|
2714
|
+
* @param {number} column Visual column index.
|
2715
|
+
* @returns {*} Data at cell.
|
2716
|
+
*/
|
2717
|
+
this.getDataAtCell = function (row, column) {
|
2718
|
+
return datamap.get(row, datamap.colToProp(column));
|
2719
|
+
};
|
2720
|
+
|
2721
|
+
/**
|
2722
|
+
* Returns value at visual `row` and `prop` indexes.
|
2723
|
+
*
|
2724
|
+
* __Note__: If data is reordered, sorted or trimmed, the currently visible order will be used.
|
2725
|
+
*
|
2726
|
+
* @memberof Core#
|
2727
|
+
* @function getDataAtRowProp
|
2728
|
+
* @param {number} row Visual row index.
|
2729
|
+
* @param {string} prop Property name.
|
2730
|
+
* @returns {*} Cell value.
|
2731
|
+
*/
|
2732
|
+
this.getDataAtRowProp = function (row, prop) {
|
2733
|
+
return datamap.get(row, prop);
|
2734
|
+
};
|
2735
|
+
|
2736
|
+
/**
|
2737
|
+
* @description
|
2738
|
+
* Returns array of column values from the data source.
|
2739
|
+
*
|
2740
|
+
* __Note__: If columns were reordered or sorted, the currently visible order will be used.
|
2741
|
+
*
|
2742
|
+
* @memberof Core#
|
2743
|
+
* @function getDataAtCol
|
2744
|
+
* @param {number} column Visual column index.
|
2745
|
+
* @returns {Array} Array of cell values.
|
2746
|
+
*/
|
2747
|
+
this.getDataAtCol = function (column) {
|
2748
|
+
var _ref13;
|
2749
|
+
return (_ref13 = []).concat.apply(_ref13, _toConsumableArray(datamap.getRange(instance._createCellCoords(0, column), instance._createCellCoords(tableMeta.data.length - 1, column), datamap.DESTINATION_RENDERER)));
|
2750
|
+
};
|
2751
|
+
|
2752
|
+
/**
|
2753
|
+
* Given the object property name (e.g. `'first.name'` or `'0'`), returns an array of column's values from the table data.
|
2754
|
+
* You can also provide a column index as the first argument.
|
2755
|
+
*
|
2756
|
+
* @memberof Core#
|
2757
|
+
* @function getDataAtProp
|
2758
|
+
* @param {string|number} prop Property name or physical column index.
|
2759
|
+
* @returns {Array} Array of cell values.
|
2760
|
+
*/
|
2761
|
+
// TODO: Getting data from `datamap` should work on visual indexes.
|
2762
|
+
this.getDataAtProp = function (prop) {
|
2763
|
+
var _ref14;
|
2764
|
+
var range = datamap.getRange(instance._createCellCoords(0, datamap.propToCol(prop)), instance._createCellCoords(tableMeta.data.length - 1, datamap.propToCol(prop)), datamap.DESTINATION_RENDERER);
|
2765
|
+
return (_ref14 = []).concat.apply(_ref14, _toConsumableArray(range));
|
2766
|
+
};
|
2767
|
+
|
2768
|
+
/**
|
2769
|
+
* Returns a clone of the source data object.
|
2770
|
+
* Optionally you can provide a cell range by using the `row`, `column`, `row2`, `column2` arguments, to get only a
|
2771
|
+
* fragment of the table data.
|
2772
|
+
*
|
2773
|
+
* __Note__: This method does not participate in data transformation. If the visual data of the table is reordered,
|
2774
|
+
* sorted or trimmed only physical indexes are correct.
|
2775
|
+
*
|
2776
|
+
* @memberof Core#
|
2777
|
+
* @function getSourceData
|
2778
|
+
* @param {number} [row] From physical row index.
|
2779
|
+
* @param {number} [column] From physical column index (or visual index, if data type is an array of objects).
|
2780
|
+
* @param {number} [row2] To physical row index.
|
2781
|
+
* @param {number} [column2] To physical column index (or visual index, if data type is an array of objects).
|
2782
|
+
* @returns {Array[]|object[]} The table data.
|
2783
|
+
*/
|
2784
|
+
this.getSourceData = function (row, column, row2, column2) {
|
2785
|
+
var data;
|
2786
|
+
if (row === void 0) {
|
2787
|
+
data = dataSource.getData();
|
2788
|
+
} else {
|
2789
|
+
data = dataSource.getByRange(instance._createCellCoords(row, column), instance._createCellCoords(row2, column2));
|
2790
|
+
}
|
2791
|
+
return data;
|
2792
|
+
};
|
2793
|
+
|
2794
|
+
/**
|
2795
|
+
* Returns the source data object as an arrays of arrays format even when source data was provided in another format.
|
2796
|
+
* Optionally you can provide a cell range by using the `row`, `column`, `row2`, `column2` arguments, to get only a
|
2797
|
+
* fragment of the table data.
|
2798
|
+
*
|
2799
|
+
* __Note__: This method does not participate in data transformation. If the visual data of the table is reordered,
|
2800
|
+
* sorted or trimmed only physical indexes are correct.
|
2801
|
+
*
|
2802
|
+
* @memberof Core#
|
2803
|
+
* @function getSourceDataArray
|
2804
|
+
* @param {number} [row] From physical row index.
|
2805
|
+
* @param {number} [column] From physical column index (or visual index, if data type is an array of objects).
|
2806
|
+
* @param {number} [row2] To physical row index.
|
2807
|
+
* @param {number} [column2] To physical column index (or visual index, if data type is an array of objects).
|
2808
|
+
* @returns {Array} An array of arrays.
|
2809
|
+
*/
|
2810
|
+
this.getSourceDataArray = function (row, column, row2, column2) {
|
2811
|
+
var data;
|
2812
|
+
if (row === void 0) {
|
2813
|
+
data = dataSource.getData(true);
|
2814
|
+
} else {
|
2815
|
+
data = dataSource.getByRange(instance._createCellCoords(row, column), instance._createCellCoords(row2, column2), true);
|
2816
|
+
}
|
2817
|
+
return data;
|
2818
|
+
};
|
2819
|
+
|
2820
|
+
/**
|
2821
|
+
* Returns an array of column values from the data source.
|
2822
|
+
*
|
2823
|
+
* @memberof Core#
|
2824
|
+
* @function getSourceDataAtCol
|
2825
|
+
* @param {number} column Visual column index.
|
2826
|
+
* @returns {Array} Array of the column's cell values.
|
2827
|
+
*/
|
2828
|
+
// TODO: Getting data from `sourceData` should work always on physical indexes.
|
2829
|
+
this.getSourceDataAtCol = function (column) {
|
2830
|
+
return dataSource.getAtColumn(column);
|
2831
|
+
};
|
2832
|
+
|
2833
|
+
/* eslint-disable jsdoc/require-param */
|
2834
|
+
/**
|
2835
|
+
* Set the provided value in the source data set at the provided coordinates.
|
2836
|
+
*
|
2837
|
+
* @memberof Core#
|
2838
|
+
* @function setSourceDataAtCell
|
2839
|
+
* @param {number|Array} row Physical row index or array of changes in format `[[row, prop, value], ...]`.
|
2840
|
+
* @param {number|string} column Physical column index / prop name.
|
2841
|
+
* @param {*} value The value to be set at the provided coordinates.
|
2842
|
+
* @param {string} [source] Source of the change as a string.
|
2843
|
+
*/
|
2844
|
+
/* eslint-enable jsdoc/require-param */
|
2845
|
+
this.setSourceDataAtCell = function (row, column, value, source) {
|
2846
|
+
var input = setDataInputToArray(row, column, value);
|
2847
|
+
var isThereAnySetSourceListener = this.hasHook('afterSetSourceDataAtCell');
|
2848
|
+
var changesForHook = [];
|
2849
|
+
if (isThereAnySetSourceListener) {
|
2850
|
+
(0, _array.arrayEach)(input, function (_ref15) {
|
2851
|
+
var _ref16 = _slicedToArray(_ref15, 3),
|
2852
|
+
changeRow = _ref16[0],
|
2853
|
+
changeProp = _ref16[1],
|
2854
|
+
changeValue = _ref16[2];
|
2855
|
+
changesForHook.push([changeRow, changeProp, dataSource.getAtCell(changeRow, changeProp),
|
2856
|
+
// The previous value.
|
2857
|
+
changeValue]);
|
2858
|
+
});
|
2859
|
+
}
|
2860
|
+
(0, _array.arrayEach)(input, function (_ref17) {
|
2861
|
+
var _ref18 = _slicedToArray(_ref17, 3),
|
2862
|
+
changeRow = _ref18[0],
|
2863
|
+
changeProp = _ref18[1],
|
2864
|
+
changeValue = _ref18[2];
|
2865
|
+
dataSource.setAtCell(changeRow, changeProp, changeValue);
|
2866
|
+
});
|
2867
|
+
if (isThereAnySetSourceListener) {
|
2868
|
+
this.runHooks('afterSetSourceDataAtCell', changesForHook, source);
|
2869
|
+
}
|
2870
|
+
this.render();
|
2871
|
+
var activeEditor = instance.getActiveEditor();
|
2872
|
+
if (activeEditor && (0, _mixed.isDefined)(activeEditor.refreshValue)) {
|
2873
|
+
activeEditor.refreshValue();
|
2874
|
+
}
|
2875
|
+
};
|
2876
|
+
|
2877
|
+
/**
|
2878
|
+
* Returns a single row of the data (array or object, depending on what data format you use).
|
2879
|
+
*
|
2880
|
+
* __Note__: This method does not participate in data transformation. If the visual data of the table is reordered,
|
2881
|
+
* sorted or trimmed only physical indexes are correct.
|
2882
|
+
*
|
2883
|
+
* @memberof Core#
|
2884
|
+
* @function getSourceDataAtRow
|
2885
|
+
* @param {number} row Physical row index.
|
2886
|
+
* @returns {Array|object} Single row of data.
|
2887
|
+
*/
|
2888
|
+
this.getSourceDataAtRow = function (row) {
|
2889
|
+
return dataSource.getAtRow(row);
|
2890
|
+
};
|
2891
|
+
|
2892
|
+
/**
|
2893
|
+
* Returns a single value from the data source.
|
2894
|
+
*
|
2895
|
+
* @memberof Core#
|
2896
|
+
* @function getSourceDataAtCell
|
2897
|
+
* @param {number} row Physical row index.
|
2898
|
+
* @param {number} column Visual column index.
|
2899
|
+
* @returns {*} Cell data.
|
2900
|
+
*/
|
2901
|
+
// TODO: Getting data from `sourceData` should work always on physical indexes.
|
2902
|
+
this.getSourceDataAtCell = function (row, column) {
|
2903
|
+
return dataSource.getAtCell(row, column);
|
2904
|
+
};
|
2905
|
+
|
2906
|
+
/**
|
2907
|
+
* @description
|
2908
|
+
* Returns a single row of the data.
|
2909
|
+
*
|
2910
|
+
* __Note__: If rows were reordered, sorted or trimmed, the currently visible order will be used.
|
2911
|
+
*
|
2912
|
+
* @memberof Core#
|
2913
|
+
* @function getDataAtRow
|
2914
|
+
* @param {number} row Visual row index.
|
2915
|
+
* @returns {Array} Array of row's cell data.
|
2916
|
+
*/
|
2917
|
+
this.getDataAtRow = function (row) {
|
2918
|
+
var data = datamap.getRange(instance._createCellCoords(row, 0), instance._createCellCoords(row, this.countCols() - 1), datamap.DESTINATION_RENDERER);
|
2919
|
+
return data[0] || [];
|
2920
|
+
};
|
2921
|
+
|
2922
|
+
/**
|
2923
|
+
* @description
|
2924
|
+
* Returns a data type defined in the Handsontable settings under the `type` key ({@link Options#type}).
|
2925
|
+
* If there are cells with different types in the selected range, it returns `'mixed'`.
|
2926
|
+
*
|
2927
|
+
* __Note__: If data is reordered, sorted or trimmed, the currently visible order will be used.
|
2928
|
+
*
|
2929
|
+
* @memberof Core#
|
2930
|
+
* @function getDataType
|
2931
|
+
* @param {number} rowFrom From visual row index.
|
2932
|
+
* @param {number} columnFrom From visual column index.
|
2933
|
+
* @param {number} rowTo To visual row index.
|
2934
|
+
* @param {number} columnTo To visual column index.
|
2935
|
+
* @returns {string} Cell type (e.q: `'mixed'`, `'text'`, `'numeric'`, `'autocomplete'`).
|
2936
|
+
*/
|
2937
|
+
this.getDataType = function (rowFrom, columnFrom, rowTo, columnTo) {
|
2938
|
+
var _this4 = this;
|
2939
|
+
var coords = rowFrom === void 0 ? [0, 0, this.countRows(), this.countCols()] : [rowFrom, columnFrom, rowTo, columnTo];
|
2940
|
+
var rowStart = coords[0],
|
2941
|
+
columnStart = coords[1];
|
2942
|
+
var rowEnd = coords[2],
|
2943
|
+
columnEnd = coords[3];
|
2944
|
+
var previousType = null;
|
2945
|
+
var currentType = null;
|
2946
|
+
if (rowEnd === void 0) {
|
2947
|
+
rowEnd = rowStart;
|
2948
|
+
}
|
2949
|
+
if (columnEnd === void 0) {
|
2950
|
+
columnEnd = columnStart;
|
2951
|
+
}
|
2952
|
+
var type = 'mixed';
|
2953
|
+
(0, _number.rangeEach)(Math.max(Math.min(rowStart, rowEnd), 0), Math.max(rowStart, rowEnd), function (row) {
|
2954
|
+
var isTypeEqual = true;
|
2955
|
+
(0, _number.rangeEach)(Math.max(Math.min(columnStart, columnEnd), 0), Math.max(columnStart, columnEnd), function (column) {
|
2956
|
+
var cellType = _this4.getCellMeta(row, column);
|
2957
|
+
currentType = cellType.type;
|
2958
|
+
if (previousType) {
|
2959
|
+
isTypeEqual = previousType === currentType;
|
2960
|
+
} else {
|
2961
|
+
previousType = currentType;
|
2962
|
+
}
|
2963
|
+
return isTypeEqual;
|
2964
|
+
});
|
2965
|
+
type = isTypeEqual ? currentType : 'mixed';
|
2966
|
+
return isTypeEqual;
|
2967
|
+
});
|
2968
|
+
return type;
|
2969
|
+
};
|
2970
|
+
|
2971
|
+
/**
|
2972
|
+
* Remove a property defined by the `key` argument from the cell meta object for the provided `row` and `column` coordinates.
|
2973
|
+
*
|
2974
|
+
* @memberof Core#
|
2975
|
+
* @function removeCellMeta
|
2976
|
+
* @param {number} row Visual row index.
|
2977
|
+
* @param {number} column Visual column index.
|
2978
|
+
* @param {string} key Property name.
|
2979
|
+
* @fires Hooks#beforeRemoveCellMeta
|
2980
|
+
* @fires Hooks#afterRemoveCellMeta
|
2981
|
+
*/
|
2982
|
+
this.removeCellMeta = function (row, column, key) {
|
2983
|
+
var _ref19 = [this.toPhysicalRow(row), this.toPhysicalColumn(column)],
|
2984
|
+
physicalRow = _ref19[0],
|
2985
|
+
physicalColumn = _ref19[1];
|
2986
|
+
var cachedValue = metaManager.getCellMetaKeyValue(physicalRow, physicalColumn, key);
|
2987
|
+
var hookResult = instance.runHooks('beforeRemoveCellMeta', row, column, key, cachedValue);
|
2988
|
+
if (hookResult !== false) {
|
2989
|
+
metaManager.removeCellMeta(physicalRow, physicalColumn, key);
|
2990
|
+
instance.runHooks('afterRemoveCellMeta', row, column, key, cachedValue);
|
2991
|
+
}
|
2992
|
+
cachedValue = null;
|
2993
|
+
};
|
2994
|
+
|
2995
|
+
/**
|
2996
|
+
* Removes or adds one or more rows of the cell meta objects to the cell meta collections.
|
2997
|
+
*
|
2998
|
+
* @since 0.30.0
|
2999
|
+
* @memberof Core#
|
3000
|
+
* @function spliceCellsMeta
|
3001
|
+
* @param {number} visualIndex A visual index that specifies at what position to add/remove items.
|
3002
|
+
* @param {number} [deleteAmount=0] The number of items to be removed. If set to 0, no cell meta objects will be removed.
|
3003
|
+
* @param {...object} [cellMetaRows] The new cell meta row objects to be added to the cell meta collection.
|
3004
|
+
*/
|
3005
|
+
this.spliceCellsMeta = function (visualIndex) {
|
3006
|
+
var _this5 = this;
|
3007
|
+
var deleteAmount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
3008
|
+
for (var _len3 = arguments.length, cellMetaRows = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
3009
|
+
cellMetaRows[_key3 - 2] = arguments[_key3];
|
3010
|
+
}
|
3011
|
+
if (cellMetaRows.length > 0 && !Array.isArray(cellMetaRows[0])) {
|
3012
|
+
throw new Error('The 3rd argument (cellMetaRows) has to be passed as an array of cell meta objects array.');
|
3013
|
+
}
|
3014
|
+
if (deleteAmount > 0) {
|
3015
|
+
metaManager.removeRow(this.toPhysicalRow(visualIndex), deleteAmount);
|
3016
|
+
}
|
3017
|
+
if (cellMetaRows.length > 0) {
|
3018
|
+
(0, _array.arrayEach)(cellMetaRows.reverse(), function (cellMetaRow) {
|
3019
|
+
metaManager.createRow(_this5.toPhysicalRow(visualIndex));
|
3020
|
+
(0, _array.arrayEach)(cellMetaRow, function (cellMeta, columnIndex) {
|
3021
|
+
return _this5.setCellMetaObject(visualIndex, columnIndex, cellMeta);
|
3022
|
+
});
|
3023
|
+
});
|
3024
|
+
}
|
3025
|
+
instance.render();
|
3026
|
+
};
|
3027
|
+
|
3028
|
+
/**
|
3029
|
+
* Set cell meta data object defined by `prop` to the corresponding params `row` and `column`.
|
3030
|
+
*
|
3031
|
+
* @memberof Core#
|
3032
|
+
* @function setCellMetaObject
|
3033
|
+
* @param {number} row Visual row index.
|
3034
|
+
* @param {number} column Visual column index.
|
3035
|
+
* @param {object} prop Meta object.
|
3036
|
+
*/
|
3037
|
+
this.setCellMetaObject = function (row, column, prop) {
|
3038
|
+
var _this6 = this;
|
3039
|
+
if (_typeof(prop) === 'object') {
|
3040
|
+
(0, _object.objectEach)(prop, function (value, key) {
|
3041
|
+
_this6.setCellMeta(row, column, key, value);
|
3042
|
+
});
|
3043
|
+
}
|
3044
|
+
};
|
3045
|
+
|
3046
|
+
/**
|
3047
|
+
* Sets a property defined by the `key` property to the meta object of a cell corresponding to params `row` and `column`.
|
3048
|
+
*
|
3049
|
+
* @memberof Core#
|
3050
|
+
* @function setCellMeta
|
3051
|
+
* @param {number} row Visual row index.
|
3052
|
+
* @param {number} column Visual column index.
|
3053
|
+
* @param {string} key Property name.
|
3054
|
+
* @param {string} value Property value.
|
3055
|
+
* @fires Hooks#beforeSetCellMeta
|
3056
|
+
* @fires Hooks#afterSetCellMeta
|
3057
|
+
*/
|
3058
|
+
this.setCellMeta = function (row, column, key, value) {
|
3059
|
+
var allowSetCellMeta = instance.runHooks('beforeSetCellMeta', row, column, key, value);
|
3060
|
+
if (allowSetCellMeta === false) {
|
3061
|
+
return;
|
3062
|
+
}
|
3063
|
+
var physicalRow = row;
|
3064
|
+
var physicalColumn = column;
|
3065
|
+
if (row < this.countRows()) {
|
3066
|
+
physicalRow = this.toPhysicalRow(row);
|
3067
|
+
}
|
3068
|
+
if (column < this.countCols()) {
|
3069
|
+
physicalColumn = this.toPhysicalColumn(column);
|
3070
|
+
}
|
3071
|
+
metaManager.setCellMeta(physicalRow, physicalColumn, key, value);
|
3072
|
+
instance.runHooks('afterSetCellMeta', row, column, key, value);
|
3073
|
+
};
|
3074
|
+
|
3075
|
+
/**
|
3076
|
+
* Get all the cells meta settings at least once generated in the table (in order of cell initialization).
|
3077
|
+
*
|
3078
|
+
* @memberof Core#
|
3079
|
+
* @function getCellsMeta
|
3080
|
+
* @returns {Array} Returns an array of ColumnSettings object instances.
|
3081
|
+
*/
|
3082
|
+
this.getCellsMeta = function () {
|
3083
|
+
return metaManager.getCellsMeta();
|
3084
|
+
};
|
3085
|
+
|
3086
|
+
/**
|
3087
|
+
* Returns the cell properties object for the given `row` and `column` coordinates.
|
3088
|
+
*
|
3089
|
+
* @memberof Core#
|
3090
|
+
* @function getCellMeta
|
3091
|
+
* @param {number} row Visual row index.
|
3092
|
+
* @param {number} column Visual column index.
|
3093
|
+
* @returns {object} The cell properties object.
|
3094
|
+
* @fires Hooks#beforeGetCellMeta
|
3095
|
+
* @fires Hooks#afterGetCellMeta
|
3096
|
+
*/
|
3097
|
+
this.getCellMeta = function (row, column) {
|
3098
|
+
var physicalRow = this.toPhysicalRow(row);
|
3099
|
+
var physicalColumn = this.toPhysicalColumn(column);
|
3100
|
+
if (physicalRow === null) {
|
3101
|
+
physicalRow = row;
|
3102
|
+
}
|
3103
|
+
if (physicalColumn === null) {
|
3104
|
+
physicalColumn = column;
|
3105
|
+
}
|
3106
|
+
return metaManager.getCellMeta(physicalRow, physicalColumn, {
|
3107
|
+
visualRow: row,
|
3108
|
+
visualColumn: column
|
3109
|
+
});
|
3110
|
+
};
|
3111
|
+
|
3112
|
+
/**
|
3113
|
+
* Returns an array of cell meta objects for specified physical row index.
|
3114
|
+
*
|
3115
|
+
* @memberof Core#
|
3116
|
+
* @function getCellMetaAtRow
|
3117
|
+
* @param {number} row Physical row index.
|
3118
|
+
* @returns {Array}
|
3119
|
+
*/
|
3120
|
+
this.getCellMetaAtRow = function (row) {
|
3121
|
+
return metaManager.getCellsMetaAtRow(row);
|
3122
|
+
};
|
3123
|
+
|
3124
|
+
/**
|
3125
|
+
* Checks if the data format and config allows user to modify the column structure.
|
3126
|
+
*
|
3127
|
+
* @memberof Core#
|
3128
|
+
* @function isColumnModificationAllowed
|
3129
|
+
* @returns {boolean}
|
3130
|
+
*/
|
3131
|
+
this.isColumnModificationAllowed = function () {
|
3132
|
+
return !(instance.dataType === 'object' || tableMeta.columns);
|
3133
|
+
};
|
3134
|
+
var rendererLookup = (0, _data.cellMethodLookupFactory)('renderer');
|
3135
|
+
|
3136
|
+
/**
|
3137
|
+
* Returns the cell renderer function by given `row` and `column` arguments.
|
3138
|
+
*
|
3139
|
+
* @memberof Core#
|
3140
|
+
* @function getCellRenderer
|
3141
|
+
* @param {number|object} row Visual row index or cell meta object (see {@link Core#getCellMeta}).
|
3142
|
+
* @param {number} column Visual column index.
|
3143
|
+
* @returns {Function} The renderer function.
|
3144
|
+
* @example
|
3145
|
+
* ```js
|
3146
|
+
* // Get cell renderer using `row` and `column` coordinates.
|
3147
|
+
* hot.getCellRenderer(1, 1);
|
3148
|
+
* // Get cell renderer using cell meta object.
|
3149
|
+
* hot.getCellRenderer(hot.getCellMeta(1, 1));
|
3150
|
+
* ```
|
3151
|
+
*/
|
3152
|
+
this.getCellRenderer = function (row, column) {
|
3153
|
+
return (0, _registry2.getRenderer)(rendererLookup.call(this, row, column));
|
3154
|
+
};
|
3155
|
+
|
3156
|
+
/**
|
3157
|
+
* Returns the cell editor class by the provided `row` and `column` arguments.
|
3158
|
+
*
|
3159
|
+
* @memberof Core#
|
3160
|
+
* @function getCellEditor
|
3161
|
+
* @param {number} row Visual row index or cell meta object (see {@link Core#getCellMeta}).
|
3162
|
+
* @param {number} column Visual column index.
|
3163
|
+
* @returns {Function} The editor class.
|
3164
|
+
* @example
|
3165
|
+
* ```js
|
3166
|
+
* // Get cell editor class using `row` and `column` coordinates.
|
3167
|
+
* hot.getCellEditor(1, 1);
|
3168
|
+
* // Get cell editor class using cell meta object.
|
3169
|
+
* hot.getCellEditor(hot.getCellMeta(1, 1));
|
3170
|
+
* ```
|
3171
|
+
*/
|
3172
|
+
this.getCellEditor = (0, _data.cellMethodLookupFactory)('editor');
|
3173
|
+
var validatorLookup = (0, _data.cellMethodLookupFactory)('validator');
|
3174
|
+
|
3175
|
+
/**
|
3176
|
+
* Returns the cell validator by `row` and `column`.
|
3177
|
+
*
|
3178
|
+
* @memberof Core#
|
3179
|
+
* @function getCellValidator
|
3180
|
+
* @param {number|object} row Visual row index or cell meta object (see {@link Core#getCellMeta}).
|
3181
|
+
* @param {number} column Visual column index.
|
3182
|
+
* @returns {Function|RegExp|undefined} The validator function.
|
3183
|
+
* @example
|
3184
|
+
* ```js
|
3185
|
+
* // Get cell valiator using `row` and `column` coordinates.
|
3186
|
+
* hot.getCellValidator(1, 1);
|
3187
|
+
* // Get cell valiator using cell meta object.
|
3188
|
+
* hot.getCellValidator(hot.getCellMeta(1, 1));
|
3189
|
+
* ```
|
3190
|
+
*/
|
3191
|
+
this.getCellValidator = function (row, column) {
|
3192
|
+
var validator = validatorLookup.call(this, row, column);
|
3193
|
+
if (typeof validator === 'string') {
|
3194
|
+
validator = (0, _registry3.getValidator)(validator);
|
3195
|
+
}
|
3196
|
+
return validator;
|
3197
|
+
};
|
3198
|
+
|
3199
|
+
/**
|
3200
|
+
* Validates all cells using their validator functions and calls callback when finished.
|
3201
|
+
*
|
3202
|
+
* If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it
|
3203
|
+
* would equal `true`.
|
3204
|
+
*
|
3205
|
+
* @memberof Core#
|
3206
|
+
* @function validateCells
|
3207
|
+
* @param {Function} [callback] The callback function.
|
3208
|
+
* @example
|
3209
|
+
* ```js
|
3210
|
+
* hot.validateCells((valid) => {
|
3211
|
+
* if (valid) {
|
3212
|
+
* // ... code for validated cells
|
3213
|
+
* }
|
3214
|
+
* })
|
3215
|
+
* ```
|
3216
|
+
*/
|
3217
|
+
this.validateCells = function (callback) {
|
3218
|
+
this._validateCells(callback);
|
3219
|
+
};
|
3220
|
+
|
3221
|
+
/**
|
3222
|
+
* Validates rows using their validator functions and calls callback when finished.
|
3223
|
+
*
|
3224
|
+
* If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it
|
3225
|
+
* would equal `true`.
|
3226
|
+
*
|
3227
|
+
* @memberof Core#
|
3228
|
+
* @function validateRows
|
3229
|
+
* @param {Array} [rows] Array of validation target visual row indexes.
|
3230
|
+
* @param {Function} [callback] The callback function.
|
3231
|
+
* @example
|
3232
|
+
* ```js
|
3233
|
+
* hot.validateRows([3, 4, 5], (valid) => {
|
3234
|
+
* if (valid) {
|
3235
|
+
* // ... code for validated rows
|
3236
|
+
* }
|
3237
|
+
* })
|
3238
|
+
* ```
|
3239
|
+
*/
|
3240
|
+
this.validateRows = function (rows, callback) {
|
3241
|
+
if (!Array.isArray(rows)) {
|
3242
|
+
throw new Error('validateRows parameter `rows` must be an array');
|
3243
|
+
}
|
3244
|
+
this._validateCells(callback, rows);
|
3245
|
+
};
|
3246
|
+
|
3247
|
+
/**
|
3248
|
+
* Validates columns using their validator functions and calls callback when finished.
|
3249
|
+
*
|
3250
|
+
* If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it
|
3251
|
+
* would equal `true`.
|
3252
|
+
*
|
3253
|
+
* @memberof Core#
|
3254
|
+
* @function validateColumns
|
3255
|
+
* @param {Array} [columns] Array of validation target visual columns indexes.
|
3256
|
+
* @param {Function} [callback] The callback function.
|
3257
|
+
* @example
|
3258
|
+
* ```js
|
3259
|
+
* hot.validateColumns([3, 4, 5], (valid) => {
|
3260
|
+
* if (valid) {
|
3261
|
+
* // ... code for validated columns
|
3262
|
+
* }
|
3263
|
+
* })
|
3264
|
+
* ```
|
3265
|
+
*/
|
3266
|
+
this.validateColumns = function (columns, callback) {
|
3267
|
+
if (!Array.isArray(columns)) {
|
3268
|
+
throw new Error('validateColumns parameter `columns` must be an array');
|
3269
|
+
}
|
3270
|
+
this._validateCells(callback, undefined, columns);
|
3271
|
+
};
|
3272
|
+
|
3273
|
+
/**
|
3274
|
+
* Validates all cells using their validator functions and calls callback when finished.
|
3275
|
+
*
|
3276
|
+
* If one of the cells is invalid, the callback will be fired with `'valid'` arguments as `false` - otherwise it would equal `true`.
|
3277
|
+
*
|
3278
|
+
* Private use intended.
|
3279
|
+
*
|
3280
|
+
* @private
|
3281
|
+
* @memberof Core#
|
3282
|
+
* @function _validateCells
|
3283
|
+
* @param {Function} [callback] The callback function.
|
3284
|
+
* @param {Array} [rows] An array of validation target visual row indexes.
|
3285
|
+
* @param {Array} [columns] An array of validation target visual column indexes.
|
3286
|
+
*/
|
3287
|
+
this._validateCells = function (callback, rows, columns) {
|
3288
|
+
var waitingForValidator = new ValidatorsQueue();
|
3289
|
+
if (callback) {
|
3290
|
+
waitingForValidator.onQueueEmpty = callback;
|
3291
|
+
}
|
3292
|
+
var i = instance.countRows() - 1;
|
3293
|
+
while (i >= 0) {
|
3294
|
+
if (rows !== undefined && rows.indexOf(i) === -1) {
|
3295
|
+
i -= 1;
|
3296
|
+
continue;
|
3297
|
+
}
|
3298
|
+
var j = instance.countCols() - 1;
|
3299
|
+
while (j >= 0) {
|
3300
|
+
if (columns !== undefined && columns.indexOf(j) === -1) {
|
3301
|
+
j -= 1;
|
3302
|
+
continue;
|
3303
|
+
}
|
3304
|
+
waitingForValidator.addValidatorToQueue();
|
3305
|
+
instance.validateCell(instance.getDataAtCell(i, j), instance.getCellMeta(i, j), function (result) {
|
3306
|
+
if (typeof result !== 'boolean') {
|
3307
|
+
throw new Error('Validation error: result is not boolean');
|
3308
|
+
}
|
3309
|
+
if (result === false) {
|
3310
|
+
waitingForValidator.valid = false;
|
3311
|
+
}
|
3312
|
+
waitingForValidator.removeValidatorFormQueue();
|
3313
|
+
}, 'validateCells');
|
3314
|
+
j -= 1;
|
3315
|
+
}
|
3316
|
+
i -= 1;
|
3317
|
+
}
|
3318
|
+
waitingForValidator.checkIfQueueIsEmpty();
|
3319
|
+
};
|
3320
|
+
|
3321
|
+
/**
|
3322
|
+
* Returns an array of row headers' values (if they are enabled). If param `row` was given, it returns the header of the given row as a string.
|
3323
|
+
*
|
3324
|
+
* @memberof Core#
|
3325
|
+
* @function getRowHeader
|
3326
|
+
* @param {number} [row] Visual row index.
|
3327
|
+
* @fires Hooks#modifyRowHeader
|
3328
|
+
* @returns {Array|string|number} Array of header values / single header value.
|
3329
|
+
*/
|
3330
|
+
this.getRowHeader = function (row) {
|
3331
|
+
var rowHeader = tableMeta.rowHeaders;
|
3332
|
+
var physicalRow = row;
|
3333
|
+
if (physicalRow !== void 0) {
|
3334
|
+
physicalRow = instance.runHooks('modifyRowHeader', physicalRow);
|
3335
|
+
}
|
3336
|
+
if (physicalRow === void 0) {
|
3337
|
+
rowHeader = [];
|
3338
|
+
(0, _number.rangeEach)(instance.countRows() - 1, function (i) {
|
3339
|
+
rowHeader.push(instance.getRowHeader(i));
|
3340
|
+
});
|
3341
|
+
} else if (Array.isArray(rowHeader) && rowHeader[physicalRow] !== void 0) {
|
3342
|
+
rowHeader = rowHeader[physicalRow];
|
3343
|
+
} else if ((0, _function.isFunction)(rowHeader)) {
|
3344
|
+
rowHeader = rowHeader(physicalRow);
|
3345
|
+
} else if (rowHeader && typeof rowHeader !== 'string' && typeof rowHeader !== 'number') {
|
3346
|
+
rowHeader = physicalRow + 1;
|
3347
|
+
}
|
3348
|
+
return rowHeader;
|
3349
|
+
};
|
3350
|
+
|
3351
|
+
/**
|
3352
|
+
* Returns information about if this table is configured to display row headers.
|
3353
|
+
*
|
3354
|
+
* @memberof Core#
|
3355
|
+
* @function hasRowHeaders
|
3356
|
+
* @returns {boolean} `true` if the instance has the row headers enabled, `false` otherwise.
|
3357
|
+
*/
|
3358
|
+
this.hasRowHeaders = function () {
|
3359
|
+
return !!tableMeta.rowHeaders;
|
3360
|
+
};
|
3361
|
+
|
3362
|
+
/**
|
3363
|
+
* Returns information about if this table is configured to display column headers.
|
3364
|
+
*
|
3365
|
+
* @memberof Core#
|
3366
|
+
* @function hasColHeaders
|
3367
|
+
* @returns {boolean} `true` if the instance has the column headers enabled, `false` otherwise.
|
3368
|
+
*/
|
3369
|
+
this.hasColHeaders = function () {
|
3370
|
+
if (tableMeta.colHeaders !== void 0 && tableMeta.colHeaders !== null) {
|
3371
|
+
// Polymer has empty value = null
|
3372
|
+
return !!tableMeta.colHeaders;
|
3373
|
+
}
|
3374
|
+
for (var i = 0, ilen = instance.countCols(); i < ilen; i++) {
|
3375
|
+
if (instance.getColHeader(i)) {
|
3376
|
+
return true;
|
3377
|
+
}
|
3378
|
+
}
|
3379
|
+
return false;
|
3380
|
+
};
|
3381
|
+
|
3382
|
+
/**
|
3383
|
+
* Returns an array of column headers (in string format, if they are enabled). If param `column` is given, it
|
3384
|
+
* returns the header at the given column.
|
3385
|
+
*
|
3386
|
+
* @memberof Core#
|
3387
|
+
* @function getColHeader
|
3388
|
+
* @param {number} [column] Visual column index.
|
3389
|
+
* @fires Hooks#modifyColHeader
|
3390
|
+
* @returns {Array|string|number} The column header(s).
|
3391
|
+
*/
|
3392
|
+
this.getColHeader = function (column) {
|
3393
|
+
var columnIndex = instance.runHooks('modifyColHeader', column);
|
3394
|
+
var result = tableMeta.colHeaders;
|
3395
|
+
if (columnIndex === void 0) {
|
3396
|
+
var out = [];
|
3397
|
+
var ilen = instance.countCols();
|
3398
|
+
for (var i = 0; i < ilen; i++) {
|
3399
|
+
out.push(instance.getColHeader(i));
|
3400
|
+
}
|
3401
|
+
result = out;
|
3402
|
+
} else {
|
3403
|
+
var translateVisualIndexToColumns = function translateVisualIndexToColumns(visualColumnIndex) {
|
3404
|
+
var arr = [];
|
3405
|
+
var columnsLen = instance.countCols();
|
3406
|
+
var index = 0;
|
3407
|
+
for (; index < columnsLen; index++) {
|
3408
|
+
if ((0, _function.isFunction)(tableMeta.columns) && tableMeta.columns(index)) {
|
3409
|
+
arr.push(index);
|
3410
|
+
}
|
3411
|
+
}
|
3412
|
+
return arr[visualColumnIndex];
|
3413
|
+
};
|
3414
|
+
var physicalColumn = instance.toPhysicalColumn(columnIndex);
|
3415
|
+
var prop = translateVisualIndexToColumns(physicalColumn);
|
3416
|
+
if (tableMeta.colHeaders === false) {
|
3417
|
+
result = null;
|
3418
|
+
} else if (tableMeta.columns && (0, _function.isFunction)(tableMeta.columns) && tableMeta.columns(prop) && tableMeta.columns(prop).title) {
|
3419
|
+
result = tableMeta.columns(prop).title;
|
3420
|
+
} else if (tableMeta.columns && tableMeta.columns[physicalColumn] && tableMeta.columns[physicalColumn].title) {
|
3421
|
+
result = tableMeta.columns[physicalColumn].title;
|
3422
|
+
} else if (Array.isArray(tableMeta.colHeaders) && tableMeta.colHeaders[physicalColumn] !== void 0) {
|
3423
|
+
result = tableMeta.colHeaders[physicalColumn];
|
3424
|
+
} else if ((0, _function.isFunction)(tableMeta.colHeaders)) {
|
3425
|
+
result = tableMeta.colHeaders(physicalColumn);
|
3426
|
+
} else if (tableMeta.colHeaders && typeof tableMeta.colHeaders !== 'string' && typeof tableMeta.colHeaders !== 'number') {
|
3427
|
+
result = (0, _data.spreadsheetColumnLabel)(columnIndex); // see #1458
|
3428
|
+
}
|
3429
|
+
}
|
3430
|
+
|
3431
|
+
return result;
|
3432
|
+
};
|
3433
|
+
|
3434
|
+
/**
|
3435
|
+
* Return column width from settings (no guessing). Private use intended.
|
3436
|
+
*
|
3437
|
+
* @private
|
3438
|
+
* @memberof Core#
|
3439
|
+
* @function _getColWidthFromSettings
|
3440
|
+
* @param {number} col Visual col index.
|
3441
|
+
* @returns {number}
|
3442
|
+
*/
|
3443
|
+
this._getColWidthFromSettings = function (col) {
|
3444
|
+
var width;
|
3445
|
+
|
3446
|
+
// We currently don't support cell meta objects for headers (negative values)
|
3447
|
+
if (col >= 0) {
|
3448
|
+
var cellProperties = instance.getCellMeta(0, col);
|
3449
|
+
width = cellProperties.width;
|
3450
|
+
}
|
3451
|
+
if (width === void 0 || width === tableMeta.width) {
|
3452
|
+
width = tableMeta.colWidths;
|
3453
|
+
}
|
3454
|
+
if (width !== void 0 && width !== null) {
|
3455
|
+
switch (_typeof(width)) {
|
3456
|
+
case 'object':
|
3457
|
+
// array
|
3458
|
+
width = width[col];
|
3459
|
+
break;
|
3460
|
+
case 'function':
|
3461
|
+
width = width(col);
|
3462
|
+
break;
|
3463
|
+
default:
|
3464
|
+
break;
|
3465
|
+
}
|
3466
|
+
if (typeof width === 'string') {
|
3467
|
+
width = parseInt(width, 10);
|
3468
|
+
}
|
3469
|
+
}
|
3470
|
+
return width;
|
3471
|
+
};
|
3472
|
+
|
3473
|
+
/**
|
3474
|
+
* Returns the width of the requested column.
|
3475
|
+
*
|
3476
|
+
* @memberof Core#
|
3477
|
+
* @function getColWidth
|
3478
|
+
* @param {number} column Visual column index.
|
3479
|
+
* @returns {number} Column width.
|
3480
|
+
* @fires Hooks#modifyColWidth
|
3481
|
+
*/
|
3482
|
+
this.getColWidth = function (column) {
|
3483
|
+
var width = instance._getColWidthFromSettings(column);
|
3484
|
+
width = instance.runHooks('modifyColWidth', width, column);
|
3485
|
+
if (width === void 0) {
|
3486
|
+
width = _src.ViewportColumnsCalculator.DEFAULT_WIDTH;
|
3487
|
+
}
|
3488
|
+
return width;
|
3489
|
+
};
|
3490
|
+
|
3491
|
+
/**
|
3492
|
+
* Return row height from settings (no guessing). Private use intended.
|
3493
|
+
*
|
3494
|
+
* @private
|
3495
|
+
* @memberof Core#
|
3496
|
+
* @function _getRowHeightFromSettings
|
3497
|
+
* @param {number} row Visual row index.
|
3498
|
+
* @returns {number}
|
3499
|
+
*/
|
3500
|
+
this._getRowHeightFromSettings = function (row) {
|
3501
|
+
// let cellProperties = instance.getCellMeta(row, 0);
|
3502
|
+
// let height = cellProperties.height;
|
3503
|
+
//
|
3504
|
+
// if (height === void 0 || height === tableMeta.height) {
|
3505
|
+
// height = cellProperties.rowHeights;
|
3506
|
+
// }
|
3507
|
+
var height = tableMeta.rowHeights;
|
3508
|
+
if (height !== void 0 && height !== null) {
|
3509
|
+
switch (_typeof(height)) {
|
3510
|
+
case 'object':
|
3511
|
+
// array
|
3512
|
+
height = height[row];
|
3513
|
+
break;
|
3514
|
+
case 'function':
|
3515
|
+
height = height(row);
|
3516
|
+
break;
|
3517
|
+
default:
|
3518
|
+
break;
|
3519
|
+
}
|
3520
|
+
if (typeof height === 'string') {
|
3521
|
+
height = parseInt(height, 10);
|
3522
|
+
}
|
3523
|
+
}
|
3524
|
+
return height;
|
3525
|
+
};
|
3526
|
+
|
3527
|
+
/**
|
3528
|
+
* Returns a row's height, as recognized by Handsontable.
|
3529
|
+
*
|
3530
|
+
* Depending on your configuration, the method returns (in order of priority):
|
3531
|
+
* 1. The row height set by the [`ManualRowResize`](@/api/manualRowResize.md) plugin
|
3532
|
+
* (if the plugin is enabled).
|
3533
|
+
* 2. The row height set by the [`rowHeights`](@/api/options.md#rowheights) configuration option
|
3534
|
+
* (if the option is set).
|
3535
|
+
* 3. The row height as measured in the DOM by the [`AutoRowSize`](@/api/autoRowSize.md) plugin
|
3536
|
+
* (if the plugin is enabled).
|
3537
|
+
* 4. `undefined`, if neither [`ManualRowResize`](@/api/manualRowResize.md),
|
3538
|
+
* nor [`rowHeights`](@/api/options.md#rowheights),
|
3539
|
+
* nor [`AutoRowSize`](@/api/autoRowSize.md) is used.
|
3540
|
+
*
|
3541
|
+
* The height returned includes 1 px of the row's bottom border.
|
3542
|
+
*
|
3543
|
+
* Mind that this method is different from the
|
3544
|
+
* [`getRowHeight()`](@/api/autoRowSize.md#getrowheight) method
|
3545
|
+
* of the [`AutoRowSize`](@/api/autoRowSize.md) plugin.
|
3546
|
+
*
|
3547
|
+
* @memberof Core#
|
3548
|
+
* @function getRowHeight
|
3549
|
+
* @param {number} row A visual row index.
|
3550
|
+
* @returns {number|undefined} The height of the specified row, in pixels.
|
3551
|
+
* @fires Hooks#modifyRowHeight
|
3552
|
+
*/
|
3553
|
+
this.getRowHeight = function (row) {
|
3554
|
+
var height = instance._getRowHeightFromSettings(row);
|
3555
|
+
height = instance.runHooks('modifyRowHeight', height, row);
|
3556
|
+
return height;
|
3557
|
+
};
|
3558
|
+
|
3559
|
+
/**
|
3560
|
+
* Returns the total number of rows in the data source.
|
3561
|
+
*
|
3562
|
+
* @memberof Core#
|
3563
|
+
* @function countSourceRows
|
3564
|
+
* @returns {number} Total number of rows.
|
3565
|
+
*/
|
3566
|
+
this.countSourceRows = function () {
|
3567
|
+
return dataSource.countRows();
|
3568
|
+
};
|
3569
|
+
|
3570
|
+
/**
|
3571
|
+
* Returns the total number of columns in the data source.
|
3572
|
+
*
|
3573
|
+
* @memberof Core#
|
3574
|
+
* @function countSourceCols
|
3575
|
+
* @returns {number} Total number of columns.
|
3576
|
+
*/
|
3577
|
+
this.countSourceCols = function () {
|
3578
|
+
return dataSource.countFirstRowKeys();
|
3579
|
+
};
|
3580
|
+
|
3581
|
+
/**
|
3582
|
+
* Returns the total number of visual rows in the table.
|
3583
|
+
*
|
3584
|
+
* @memberof Core#
|
3585
|
+
* @function countRows
|
3586
|
+
* @returns {number} Total number of rows.
|
3587
|
+
*/
|
3588
|
+
this.countRows = function () {
|
3589
|
+
return datamap.getLength();
|
3590
|
+
};
|
3591
|
+
|
3592
|
+
/**
|
3593
|
+
* Returns the total number of visible columns in the table.
|
3594
|
+
*
|
3595
|
+
* @memberof Core#
|
3596
|
+
* @function countCols
|
3597
|
+
* @returns {number} Total number of columns.
|
3598
|
+
*/
|
3599
|
+
this.countCols = function () {
|
3600
|
+
var maxCols = tableMeta.maxCols;
|
3601
|
+
var dataLen = this.columnIndexMapper.getNotTrimmedIndexesLength();
|
3602
|
+
return Math.min(maxCols, dataLen);
|
3603
|
+
};
|
3604
|
+
|
3605
|
+
/**
|
3606
|
+
* Returns the number of rendered rows including rows that are partially or fully rendered
|
3607
|
+
* outside the table viewport.
|
3608
|
+
*
|
3609
|
+
* @memberof Core#
|
3610
|
+
* @function countRenderedRows
|
3611
|
+
* @returns {number} Returns -1 if table is not visible.
|
3612
|
+
*/
|
3613
|
+
this.countRenderedRows = function () {
|
3614
|
+
return instance.view._wt.drawn ? instance.view._wt.wtTable.getRenderedRowsCount() : -1;
|
3615
|
+
};
|
3616
|
+
|
3617
|
+
/**
|
3618
|
+
* Returns the number of rendered rows that are only visible in the table viewport.
|
3619
|
+
* The rows that are partially visible are not counted.
|
3620
|
+
*
|
3621
|
+
* @memberof Core#
|
3622
|
+
* @function countVisibleRows
|
3623
|
+
* @returns {number} Number of visible rows or -1.
|
3624
|
+
*/
|
3625
|
+
this.countVisibleRows = function () {
|
3626
|
+
return instance.view._wt.drawn ? instance.view._wt.wtTable.getVisibleRowsCount() : -1;
|
3627
|
+
};
|
3628
|
+
|
3629
|
+
/**
|
3630
|
+
* Returns the number of rendered rows including columns that are partially or fully rendered
|
3631
|
+
* outside the table viewport.
|
3632
|
+
*
|
3633
|
+
* @memberof Core#
|
3634
|
+
* @function countRenderedCols
|
3635
|
+
* @returns {number} Returns -1 if table is not visible.
|
3636
|
+
*/
|
3637
|
+
this.countRenderedCols = function () {
|
3638
|
+
return instance.view._wt.drawn ? instance.view._wt.wtTable.getRenderedColumnsCount() : -1;
|
3639
|
+
};
|
3640
|
+
|
3641
|
+
/**
|
3642
|
+
* Returns the number of rendered columns that are only visible in the table viewport.
|
3643
|
+
* The columns that are partially visible are not counted.
|
3644
|
+
*
|
3645
|
+
* @memberof Core#
|
3646
|
+
* @function countVisibleCols
|
3647
|
+
* @returns {number} Number of visible columns or -1.
|
3648
|
+
*/
|
3649
|
+
this.countVisibleCols = function () {
|
3650
|
+
return instance.view._wt.drawn ? instance.view._wt.wtTable.getVisibleColumnsCount() : -1;
|
3651
|
+
};
|
3652
|
+
|
3653
|
+
/**
|
3654
|
+
* Returns the number of empty rows. If the optional ending parameter is `true`, returns the
|
3655
|
+
* number of empty rows at the bottom of the table.
|
3656
|
+
*
|
3657
|
+
* @memberof Core#
|
3658
|
+
* @function countEmptyRows
|
3659
|
+
* @param {boolean} [ending=false] If `true`, will only count empty rows at the end of the data source.
|
3660
|
+
* @returns {number} Count empty rows.
|
3661
|
+
*/
|
3662
|
+
this.countEmptyRows = function () {
|
3663
|
+
var ending = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
3664
|
+
var emptyRows = 0;
|
3665
|
+
(0, _number.rangeEachReverse)(instance.countRows() - 1, function (visualIndex) {
|
3666
|
+
if (instance.isEmptyRow(visualIndex)) {
|
3667
|
+
emptyRows += 1;
|
3668
|
+
} else if (ending === true) {
|
3669
|
+
return false;
|
3670
|
+
}
|
3671
|
+
});
|
3672
|
+
return emptyRows;
|
3673
|
+
};
|
3674
|
+
|
3675
|
+
/**
|
3676
|
+
* Returns the number of empty columns. If the optional ending parameter is `true`, returns the number of empty
|
3677
|
+
* columns at right hand edge of the table.
|
3678
|
+
*
|
3679
|
+
* @memberof Core#
|
3680
|
+
* @function countEmptyCols
|
3681
|
+
* @param {boolean} [ending=false] If `true`, will only count empty columns at the end of the data source row.
|
3682
|
+
* @returns {number} Count empty cols.
|
3683
|
+
*/
|
3684
|
+
this.countEmptyCols = function () {
|
3685
|
+
var ending = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
3686
|
+
var emptyColumns = 0;
|
3687
|
+
(0, _number.rangeEachReverse)(instance.countCols() - 1, function (visualIndex) {
|
3688
|
+
if (instance.isEmptyCol(visualIndex)) {
|
3689
|
+
emptyColumns += 1;
|
3690
|
+
} else if (ending === true) {
|
3691
|
+
return false;
|
3692
|
+
}
|
3693
|
+
});
|
3694
|
+
return emptyColumns;
|
3695
|
+
};
|
3696
|
+
|
3697
|
+
/**
|
3698
|
+
* Check if all cells in the row declared by the `row` argument are empty.
|
3699
|
+
*
|
3700
|
+
* @memberof Core#
|
3701
|
+
* @function isEmptyRow
|
3702
|
+
* @param {number} row Visual row index.
|
3703
|
+
* @returns {boolean} `true` if the row at the given `row` is empty, `false` otherwise.
|
3704
|
+
*/
|
3705
|
+
this.isEmptyRow = function (row) {
|
3706
|
+
return tableMeta.isEmptyRow.call(instance, row);
|
3707
|
+
};
|
3708
|
+
|
3709
|
+
/**
|
3710
|
+
* Check if all cells in the the column declared by the `column` argument are empty.
|
3711
|
+
*
|
3712
|
+
* @memberof Core#
|
3713
|
+
* @function isEmptyCol
|
3714
|
+
* @param {number} column Column index.
|
3715
|
+
* @returns {boolean} `true` if the column at the given `col` is empty, `false` otherwise.
|
3716
|
+
*/
|
3717
|
+
this.isEmptyCol = function (column) {
|
3718
|
+
return tableMeta.isEmptyCol.call(instance, column);
|
3719
|
+
};
|
3720
|
+
|
3721
|
+
/**
|
3722
|
+
* Select a single cell, or a single range of adjacent cells.
|
3723
|
+
*
|
3724
|
+
* To select a cell, pass its visual row and column indexes, for example: `selectCell(2, 4)`.
|
3725
|
+
*
|
3726
|
+
* To select a range, pass the visual indexes of the first and last cell in the range, for example: `selectCell(2, 4, 3, 5)`.
|
3727
|
+
*
|
3728
|
+
* If your columns have properties, you can pass those properties' values instead of column indexes, for example: `selectCell(2, 'first_name')`.
|
3729
|
+
*
|
3730
|
+
* By default, `selectCell()` also:
|
3731
|
+
* - Scrolls the viewport to the newly-selected cells.
|
3732
|
+
* - Switches the keyboard focus to Handsontable (by calling Handsontable's [`listen()`](#listen) method).
|
3733
|
+
*
|
3734
|
+
* @example
|
3735
|
+
* ```js
|
3736
|
+
* // select a single cell
|
3737
|
+
* hot.selectCell(2, 4);
|
3738
|
+
*
|
3739
|
+
* // select a range of cells
|
3740
|
+
* hot.selectCell(2, 4, 3, 5);
|
3741
|
+
*
|
3742
|
+
* // select a single cell, using a column property
|
3743
|
+
* hot.selectCell(2, 'first_name');
|
3744
|
+
*
|
3745
|
+
* // select a range of cells, using column properties
|
3746
|
+
* hot.selectCell(2, 'first_name', 3, 'last_name');
|
3747
|
+
*
|
3748
|
+
* // select a range of cells, without scrolling to them
|
3749
|
+
* hot.selectCell(2, 4, 3, 5, false);
|
3750
|
+
*
|
3751
|
+
* // select a range of cells, without switching the keyboard focus to Handsontable
|
3752
|
+
* hot.selectCell(2, 4, 3, 5, null, false);
|
3753
|
+
* ```
|
3754
|
+
*
|
3755
|
+
* @memberof Core#
|
3756
|
+
* @function selectCell
|
3757
|
+
* @param {number} row A visual row index.
|
3758
|
+
* @param {number|string} column A visual column index (`number`), or a column property's value (`string`).
|
3759
|
+
* @param {number} [endRow] If selecting a range: the visual row index of the last cell in the range.
|
3760
|
+
* @param {number|string} [endColumn] If selecting a range: the visual column index (or a column property's value) of the last cell in the range.
|
3761
|
+
* @param {boolean} [scrollToCell=true] `true`: scroll the viewport to the newly-selected cells. `false`: keep the previous viewport.
|
3762
|
+
* @param {boolean} [changeListener=true] `true`: switch the keyboard focus to Handsontable. `false`: keep the previous keyboard focus.
|
3763
|
+
* @returns {boolean} `true`: the selection was successful, `false`: the selection failed.
|
3764
|
+
*/
|
3765
|
+
this.selectCell = function (row, column, endRow, endColumn) {
|
3766
|
+
var scrollToCell = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
3767
|
+
var changeListener = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
|
3768
|
+
if ((0, _mixed.isUndefined)(row) || (0, _mixed.isUndefined)(column)) {
|
3769
|
+
return false;
|
3770
|
+
}
|
3771
|
+
return this.selectCells([[row, column, endRow, endColumn]], scrollToCell, changeListener);
|
3772
|
+
};
|
3773
|
+
|
3774
|
+
/**
|
3775
|
+
* Select multiple cells or ranges of cells, adjacent or non-adjacent.
|
3776
|
+
*
|
3777
|
+
* You can pass one of the below:
|
3778
|
+
* - An array of arrays (which matches the output of Handsontable's [`getSelected()`](#getselected) method).
|
3779
|
+
* - An array of [`CellRange`](@/api/cellRange.md) objects (which matches the output of Handsontable's [`getSelectedRange()`](#getselectedrange) method).
|
3780
|
+
*
|
3781
|
+
* To select multiple cells, pass the visual row and column indexes of each cell, for example: `hot.selectCells([[1, 1], [5, 5]])`.
|
3782
|
+
*
|
3783
|
+
* To select multiple ranges, pass the visual indexes of the first and last cell in each range, for example: `hot.selectCells([[1, 1, 2, 2], [6, 2, 0, 2]])`.
|
3784
|
+
*
|
3785
|
+
* If your columns have properties, you can pass those properties' values instead of column indexes, for example: `hot.selectCells([[1, 'first_name'], [5, 'last_name']])`.
|
3786
|
+
*
|
3787
|
+
* By default, `selectCell()` also:
|
3788
|
+
* - Scrolls the viewport to the newly-selected cells.
|
3789
|
+
* - Switches the keyboard focus to Handsontable (by calling Handsontable's [`listen()`](#listen) method).
|
3790
|
+
*
|
3791
|
+
* @example
|
3792
|
+
* ```js
|
3793
|
+
* // select non-adjacent cells
|
3794
|
+
* hot.selectCells([[1, 1], [5, 5], [10, 10]]);
|
3795
|
+
*
|
3796
|
+
* // select non-adjacent ranges of cells
|
3797
|
+
* hot.selectCells([[1, 1, 2, 2], [10, 10, 20, 20]]);
|
3798
|
+
*
|
3799
|
+
* // select cells and ranges of cells
|
3800
|
+
* hot.selectCells([[1, 1, 2, 2], [3, 3], [6, 2, 0, 2]]);
|
3801
|
+
*
|
3802
|
+
* // select cells, using column properties
|
3803
|
+
* hot.selectCells([[1, 'id', 2, 'first_name'], [3, 'full_name'], [6, 'last_name', 0, 'first_name']]);
|
3804
|
+
*
|
3805
|
+
* // select multiple ranges, using an array of `CellRange` objects
|
3806
|
+
* const selected = hot.getSelectedRange();
|
3807
|
+
*
|
3808
|
+
* selected[0].from.row = 0;
|
3809
|
+
* selected[0].from.col = 0;
|
3810
|
+
* selected[0].to.row = 5;
|
3811
|
+
* selected[0].to.col = 5;
|
3812
|
+
*
|
3813
|
+
* selected[1].from.row = 10;
|
3814
|
+
* selected[1].from.col = 10;
|
3815
|
+
* selected[1].to.row = 20;
|
3816
|
+
* selected[1].to.col = 20;
|
3817
|
+
*
|
3818
|
+
* hot.selectCells(selected);
|
3819
|
+
* ```
|
3820
|
+
*
|
3821
|
+
* @memberof Core#
|
3822
|
+
* @since 0.38.0
|
3823
|
+
* @function selectCells
|
3824
|
+
* @param {Array[]|CellRange[]} coords Visual coordinates,
|
3825
|
+
* passed either as an array of arrays (`[[rowStart, columnStart, rowEnd, columnEnd], ...]`)
|
3826
|
+
* or as an array of [`CellRange`](@/api/cellRange.md) objects.
|
3827
|
+
* @param {boolean} [scrollToCell=true] `true`: scroll the viewport to the newly-selected cells. `false`: keep the previous viewport.
|
3828
|
+
* @param {boolean} [changeListener=true] `true`: switch the keyboard focus to Handsontable. `false`: keep the previous keyboard focus.
|
3829
|
+
* @returns {boolean} `true`: the selection was successful, `false`: the selection failed.
|
3830
|
+
*/
|
3831
|
+
this.selectCells = function () {
|
3832
|
+
var coords = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [[]];
|
3833
|
+
var scrollToCell = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
3834
|
+
var changeListener = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
3835
|
+
if (scrollToCell === false) {
|
3836
|
+
preventScrollingToCell = true;
|
3837
|
+
}
|
3838
|
+
var wasSelected = selection.selectCells(coords);
|
3839
|
+
if (wasSelected && changeListener) {
|
3840
|
+
instance.listen();
|
3841
|
+
}
|
3842
|
+
preventScrollingToCell = false;
|
3843
|
+
return wasSelected;
|
3844
|
+
};
|
3845
|
+
|
3846
|
+
/**
|
3847
|
+
* Select column specified by `startColumn` visual index, column property or a range of columns finishing at `endColumn`.
|
3848
|
+
*
|
3849
|
+
* @example
|
3850
|
+
* ```js
|
3851
|
+
* // Select column using visual index.
|
3852
|
+
* hot.selectColumns(1);
|
3853
|
+
* // Select column using column property.
|
3854
|
+
* hot.selectColumns('id');
|
3855
|
+
* // Select range of columns using visual indexes.
|
3856
|
+
* hot.selectColumns(1, 4);
|
3857
|
+
* // Select range of columns using column properties.
|
3858
|
+
* hot.selectColumns('id', 'last_name');
|
3859
|
+
* ```
|
3860
|
+
*
|
3861
|
+
* @memberof Core#
|
3862
|
+
* @since 0.38.0
|
3863
|
+
* @function selectColumns
|
3864
|
+
* @param {number} startColumn The visual column index from which the selection starts.
|
3865
|
+
* @param {number} [endColumn=startColumn] The visual column index to which the selection finishes. If `endColumn`
|
3866
|
+
* is not defined the column defined by `startColumn` will be selected.
|
3867
|
+
* @returns {boolean} `true` if selection was successful, `false` otherwise.
|
3868
|
+
*/
|
3869
|
+
this.selectColumns = function (startColumn) {
|
3870
|
+
var endColumn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startColumn;
|
3871
|
+
return selection.selectColumns(startColumn, endColumn);
|
3872
|
+
};
|
3873
|
+
|
3874
|
+
/**
|
3875
|
+
* Select row specified by `startRow` visual index or a range of rows finishing at `endRow`.
|
3876
|
+
*
|
3877
|
+
* @example
|
3878
|
+
* ```js
|
3879
|
+
* // Select row using visual index.
|
3880
|
+
* hot.selectRows(1);
|
3881
|
+
* // Select range of rows using visual indexes.
|
3882
|
+
* hot.selectRows(1, 4);
|
3883
|
+
* ```
|
3884
|
+
*
|
3885
|
+
* @memberof Core#
|
3886
|
+
* @since 0.38.0
|
3887
|
+
* @function selectRows
|
3888
|
+
* @param {number} startRow The visual row index from which the selection starts.
|
3889
|
+
* @param {number} [endRow=startRow] The visual row index to which the selection finishes. If `endRow`
|
3890
|
+
* is not defined the row defined by `startRow` will be selected.
|
3891
|
+
* @returns {boolean} `true` if selection was successful, `false` otherwise.
|
3892
|
+
*/
|
3893
|
+
this.selectRows = function (startRow) {
|
3894
|
+
var endRow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : startRow;
|
3895
|
+
return selection.selectRows(startRow, endRow);
|
3896
|
+
};
|
3897
|
+
|
3898
|
+
/**
|
3899
|
+
* Deselects the current cell selection on the table.
|
3900
|
+
*
|
3901
|
+
* @memberof Core#
|
3902
|
+
* @function deselectCell
|
3903
|
+
*/
|
3904
|
+
this.deselectCell = function () {
|
3905
|
+
selection.deselect();
|
3906
|
+
};
|
3907
|
+
|
3908
|
+
/**
|
3909
|
+
* Select the whole table.
|
3910
|
+
*
|
3911
|
+
* The previous selection is overwritten.
|
3912
|
+
*
|
3913
|
+
* ```js
|
3914
|
+
* // select all cells in the table, including all headers
|
3915
|
+
* hot.selectAll();
|
3916
|
+
*
|
3917
|
+
* // select all cells in the table, without headers
|
3918
|
+
* hot.selectAll(false);
|
3919
|
+
* ```
|
3920
|
+
*
|
3921
|
+
* @since 0.38.2
|
3922
|
+
* @memberof Core#
|
3923
|
+
* @function selectAll
|
3924
|
+
* @param {boolean} [includeHeaders=true] `true`: include all row, column and corner headers.
|
3925
|
+
* `false`: don't include any headers.
|
3926
|
+
*/
|
3927
|
+
this.selectAll = function () {
|
3928
|
+
var includeHeaders = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
3929
|
+
var includeRowHeaders = includeHeaders && this.hasRowHeaders();
|
3930
|
+
var includeColumnHeaders = includeHeaders && this.hasColHeaders();
|
3931
|
+
preventScrollingToCell = true;
|
3932
|
+
selection.selectAll(includeRowHeaders, includeColumnHeaders);
|
3933
|
+
preventScrollingToCell = false;
|
3934
|
+
};
|
3935
|
+
var getIndexToScroll = function getIndexToScroll(indexMapper, visualIndex) {
|
3936
|
+
// Looking for a visual index on the right and then (when not found) on the left.
|
3937
|
+
return indexMapper.getNearestNotHiddenIndex(visualIndex, 1, true);
|
3938
|
+
};
|
3939
|
+
|
3940
|
+
/**
|
3941
|
+
* Scroll viewport to coordinates specified by the `row` and `column` arguments.
|
3942
|
+
*
|
3943
|
+
* @memberof Core#
|
3944
|
+
* @function scrollViewportTo
|
3945
|
+
* @param {number} [row] Row index. If the last argument isn't defined we treat the index as a visual row index. Otherwise,
|
3946
|
+
* we are using the index for numbering only this rows which may be rendered (we don't consider hidden rows).
|
3947
|
+
* @param {number} [column] Column index. If the last argument isn't defined we treat the index as a visual column index.
|
3948
|
+
* Otherwise, we are using the index for numbering only this columns which may be rendered (we don't consider hidden columns).
|
3949
|
+
* @param {boolean} [snapToBottom=false] If `true`, the viewport is scrolled to show the cell at the bottom of the table.
|
3950
|
+
* However, if the cell's height is greater than the table's viewport height, the cell is snapped to the top edge.
|
3951
|
+
* @param {boolean} [snapToRight=false] If `true`, the viewport is scrolled to show the cell at the right side of the table.
|
3952
|
+
* However, if the cell is wider than the table's viewport width, the cell is snapped to the left edge (or to the right edge, if the layout direction is set to `rtl`).
|
3953
|
+
* @param {boolean} [considerHiddenIndexes=true] If `true`, we handle visual indexes, otherwise we handle only indexes which
|
3954
|
+
* may be rendered when they are in the viewport (we don't consider hidden indexes as they aren't rendered).
|
3955
|
+
* @returns {boolean} `true` if scroll was successful, `false` otherwise.
|
3956
|
+
*/
|
3957
|
+
this.scrollViewportTo = function (row, column) {
|
3958
|
+
var snapToBottom = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
3959
|
+
var snapToRight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
3960
|
+
var considerHiddenIndexes = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
3961
|
+
var snapToTop = !snapToBottom;
|
3962
|
+
var snapToLeft = !snapToRight;
|
3963
|
+
var renderableRow = row;
|
3964
|
+
var renderableColumn = column;
|
3965
|
+
if (considerHiddenIndexes) {
|
3966
|
+
var _isRowInteger = Number.isInteger(row);
|
3967
|
+
var _isColumnInteger = Number.isInteger(column);
|
3968
|
+
var visualRowToScroll = _isRowInteger ? getIndexToScroll(this.rowIndexMapper, row) : void 0;
|
3969
|
+
var visualColumnToScroll = _isColumnInteger ? getIndexToScroll(this.columnIndexMapper, column) : void 0;
|
3970
|
+
if (visualRowToScroll === null || visualColumnToScroll === null) {
|
3971
|
+
return false;
|
3972
|
+
}
|
3973
|
+
renderableRow = _isRowInteger ? instance.rowIndexMapper.getRenderableFromVisualIndex(visualRowToScroll) : void 0;
|
3974
|
+
renderableColumn = _isColumnInteger ? instance.columnIndexMapper.getRenderableFromVisualIndex(visualColumnToScroll) : void 0;
|
3975
|
+
}
|
3976
|
+
var isRowInteger = Number.isInteger(renderableRow);
|
3977
|
+
var isColumnInteger = Number.isInteger(renderableColumn);
|
3978
|
+
if (isRowInteger && isColumnInteger) {
|
3979
|
+
return instance.view.scrollViewport(instance._createCellCoords(renderableRow, renderableColumn), snapToTop, snapToRight, snapToBottom, snapToLeft);
|
3980
|
+
}
|
3981
|
+
if (isRowInteger && isColumnInteger === false) {
|
3982
|
+
return instance.view.scrollViewportVertically(renderableRow, snapToTop, snapToBottom);
|
3983
|
+
}
|
3984
|
+
if (isColumnInteger && isRowInteger === false) {
|
3985
|
+
return instance.view.scrollViewportHorizontally(renderableColumn, snapToRight, snapToLeft);
|
3986
|
+
}
|
3987
|
+
return false;
|
3988
|
+
};
|
3989
|
+
|
3990
|
+
/**
|
3991
|
+
* Removes the table from the DOM and destroys the instance of the Handsontable.
|
3992
|
+
*
|
3993
|
+
* @memberof Core#
|
3994
|
+
* @function destroy
|
3995
|
+
* @fires Hooks#afterDestroy
|
3996
|
+
*/
|
3997
|
+
this.destroy = function () {
|
3998
|
+
instance._clearTimeouts();
|
3999
|
+
instance._clearImmediates();
|
4000
|
+
if (instance.view) {
|
4001
|
+
// in case HT is destroyed before initialization has finished
|
4002
|
+
instance.view.destroy();
|
4003
|
+
}
|
4004
|
+
if (dataSource) {
|
4005
|
+
dataSource.destroy();
|
4006
|
+
}
|
4007
|
+
dataSource = null;
|
4008
|
+
this.getShortcutManager().destroy();
|
4009
|
+
metaManager.clearCache();
|
4010
|
+
if ((0, _rootInstance.isRootInstance)(instance)) {
|
4011
|
+
var licenseInfo = this.rootDocument.querySelector('#hot-display-license-info');
|
4012
|
+
if (licenseInfo) {
|
4013
|
+
licenseInfo.parentNode.removeChild(licenseInfo);
|
4014
|
+
}
|
4015
|
+
}
|
4016
|
+
(0, _element.empty)(instance.rootElement);
|
4017
|
+
eventManager.destroy();
|
4018
|
+
if (editorManager) {
|
4019
|
+
editorManager.destroy();
|
4020
|
+
}
|
4021
|
+
|
4022
|
+
// The plugin's `destroy` method is called as a consequence and it should handle
|
4023
|
+
// unregistration of plugin's maps. Some unregistered maps reset the cache.
|
4024
|
+
instance.batchExecution(function () {
|
4025
|
+
instance.rowIndexMapper.unregisterAll();
|
4026
|
+
instance.columnIndexMapper.unregisterAll();
|
4027
|
+
pluginsRegistry.getItems().forEach(function (_ref20) {
|
4028
|
+
var _ref21 = _slicedToArray(_ref20, 2),
|
4029
|
+
plugin = _ref21[1];
|
4030
|
+
plugin.destroy();
|
4031
|
+
});
|
4032
|
+
pluginsRegistry.clear();
|
4033
|
+
instance.runHooks('afterDestroy');
|
4034
|
+
}, true);
|
4035
|
+
_pluginHooks.default.getSingleton().destroy(instance);
|
4036
|
+
(0, _object.objectEach)(instance, function (property, key, obj) {
|
4037
|
+
// replace instance methods with post mortem
|
4038
|
+
if ((0, _function.isFunction)(property)) {
|
4039
|
+
obj[key] = postMortem(key);
|
4040
|
+
} else if (key !== 'guid') {
|
4041
|
+
// replace instance properties with null (restores memory)
|
4042
|
+
// it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
|
4043
|
+
obj[key] = null;
|
4044
|
+
}
|
4045
|
+
});
|
4046
|
+
instance.isDestroyed = true;
|
4047
|
+
|
4048
|
+
// replace private properties with null (restores memory)
|
4049
|
+
// it should not be necessary but this prevents a memory leak side effects that show itself in Jasmine tests
|
4050
|
+
if (datamap) {
|
4051
|
+
datamap.destroy();
|
4052
|
+
}
|
4053
|
+
instance.rowIndexMapper = null;
|
4054
|
+
instance.columnIndexMapper = null;
|
4055
|
+
datamap = null;
|
4056
|
+
grid = null;
|
4057
|
+
selection = null;
|
4058
|
+
editorManager = null;
|
4059
|
+
instance = null;
|
4060
|
+
};
|
4061
|
+
|
4062
|
+
/**
|
4063
|
+
* Replacement for all methods after the Handsontable was destroyed.
|
4064
|
+
*
|
4065
|
+
* @private
|
4066
|
+
* @param {string} method The method name.
|
4067
|
+
* @returns {Function}
|
4068
|
+
*/
|
4069
|
+
function postMortem(method) {
|
4070
|
+
return function () {
|
4071
|
+
throw new Error("The \"".concat(method, "\" method cannot be called because this Handsontable instance has been destroyed"));
|
4072
|
+
};
|
4073
|
+
}
|
4074
|
+
|
4075
|
+
/**
|
4076
|
+
* Returns the active editor class instance.
|
4077
|
+
*
|
4078
|
+
* @memberof Core#
|
4079
|
+
* @function getActiveEditor
|
4080
|
+
* @returns {BaseEditor} The active editor instance.
|
4081
|
+
*/
|
4082
|
+
this.getActiveEditor = function () {
|
4083
|
+
return editorManager.getActiveEditor();
|
4084
|
+
};
|
4085
|
+
|
4086
|
+
/**
|
4087
|
+
* Returns plugin instance by provided its name.
|
4088
|
+
*
|
4089
|
+
* @memberof Core#
|
4090
|
+
* @function getPlugin
|
4091
|
+
* @param {string} pluginName The plugin name.
|
4092
|
+
* @returns {BasePlugin|undefined} The plugin instance or undefined if there is no plugin.
|
4093
|
+
*/
|
4094
|
+
this.getPlugin = function (pluginName) {
|
4095
|
+
var unifiedPluginName = (0, _string.toUpperCaseFirst)(pluginName);
|
4096
|
+
|
4097
|
+
// Workaround for the UndoRedo plugin which, currently doesn't follow the plugin architecture.
|
4098
|
+
if (unifiedPluginName === 'UndoRedo') {
|
4099
|
+
return this.undoRedo;
|
4100
|
+
}
|
4101
|
+
return pluginsRegistry.getItem(unifiedPluginName);
|
4102
|
+
};
|
4103
|
+
|
4104
|
+
/**
|
4105
|
+
* Returns name of the passed plugin.
|
4106
|
+
*
|
4107
|
+
* @private
|
4108
|
+
* @memberof Core#
|
4109
|
+
* @param {BasePlugin} plugin The plugin instance.
|
4110
|
+
* @returns {string}
|
4111
|
+
*/
|
4112
|
+
this.getPluginName = function (plugin) {
|
4113
|
+
// Workaround for the UndoRedo plugin which, currently doesn't follow the plugin architecture.
|
4114
|
+
if (plugin === this.undoRedo) {
|
4115
|
+
return this.undoRedo.constructor.PLUGIN_KEY;
|
4116
|
+
}
|
4117
|
+
return pluginsRegistry.getId(plugin);
|
4118
|
+
};
|
4119
|
+
|
4120
|
+
/**
|
4121
|
+
* Returns the Handsontable instance.
|
4122
|
+
*
|
4123
|
+
* @memberof Core#
|
4124
|
+
* @function getInstance
|
4125
|
+
* @returns {Handsontable} The Handsontable instance.
|
4126
|
+
*/
|
4127
|
+
this.getInstance = function () {
|
4128
|
+
return instance;
|
4129
|
+
};
|
4130
|
+
|
4131
|
+
/**
|
4132
|
+
* Adds listener to the specified hook name (only for this Handsontable instance).
|
4133
|
+
*
|
4134
|
+
* @memberof Core#
|
4135
|
+
* @function addHook
|
4136
|
+
* @see Hooks#add
|
4137
|
+
* @param {string} key Hook name (see {@link Hooks}).
|
4138
|
+
* @param {Function|Array} callback Function or array of functions.
|
4139
|
+
* @example
|
4140
|
+
* ```js
|
4141
|
+
* hot.addHook('beforeInit', myCallback);
|
4142
|
+
* ```
|
4143
|
+
*/
|
4144
|
+
this.addHook = function (key, callback) {
|
4145
|
+
_pluginHooks.default.getSingleton().add(key, callback, instance);
|
4146
|
+
};
|
4147
|
+
|
4148
|
+
/**
|
4149
|
+
* Check if for a specified hook name there are added listeners (only for this Handsontable instance). All available
|
4150
|
+
* hooks you will find {@link Hooks}.
|
4151
|
+
*
|
4152
|
+
* @memberof Core#
|
4153
|
+
* @function hasHook
|
4154
|
+
* @see Hooks#has
|
4155
|
+
* @param {string} key Hook name.
|
4156
|
+
* @returns {boolean}
|
4157
|
+
*
|
4158
|
+
* @example
|
4159
|
+
* ```js
|
4160
|
+
* const hasBeforeInitListeners = hot.hasHook('beforeInit');
|
4161
|
+
* ```
|
4162
|
+
*/
|
4163
|
+
this.hasHook = function (key) {
|
4164
|
+
return _pluginHooks.default.getSingleton().has(key, instance) || _pluginHooks.default.getSingleton().has(key);
|
4165
|
+
};
|
4166
|
+
|
4167
|
+
/**
|
4168
|
+
* Adds listener to specified hook name (only for this Handsontable instance). After the listener is triggered,
|
4169
|
+
* it will be automatically removed.
|
4170
|
+
*
|
4171
|
+
* @memberof Core#
|
4172
|
+
* @function addHookOnce
|
4173
|
+
* @see Hooks#once
|
4174
|
+
* @param {string} key Hook name (see {@link Hooks}).
|
4175
|
+
* @param {Function|Array} callback Function or array of functions.
|
4176
|
+
* @example
|
4177
|
+
* ```js
|
4178
|
+
* hot.addHookOnce('beforeInit', myCallback);
|
4179
|
+
* ```
|
4180
|
+
*/
|
4181
|
+
this.addHookOnce = function (key, callback) {
|
4182
|
+
_pluginHooks.default.getSingleton().once(key, callback, instance);
|
4183
|
+
};
|
4184
|
+
|
4185
|
+
/**
|
4186
|
+
* Removes the hook listener previously registered with {@link Core#addHook}.
|
4187
|
+
*
|
4188
|
+
* @memberof Core#
|
4189
|
+
* @function removeHook
|
4190
|
+
* @see Hooks#remove
|
4191
|
+
* @param {string} key Hook name.
|
4192
|
+
* @param {Function} callback Reference to the function which has been registered using {@link Core#addHook}.
|
4193
|
+
*
|
4194
|
+
* @example
|
4195
|
+
* ```js
|
4196
|
+
* hot.removeHook('beforeInit', myCallback);
|
4197
|
+
* ```
|
4198
|
+
*/
|
4199
|
+
this.removeHook = function (key, callback) {
|
4200
|
+
_pluginHooks.default.getSingleton().remove(key, callback, instance);
|
4201
|
+
};
|
4202
|
+
|
4203
|
+
/**
|
4204
|
+
* Run the callbacks for the hook provided in the `key` argument using the parameters given in the other arguments.
|
4205
|
+
*
|
4206
|
+
* @memberof Core#
|
4207
|
+
* @function runHooks
|
4208
|
+
* @see Hooks#run
|
4209
|
+
* @param {string} key Hook name.
|
4210
|
+
* @param {*} [p1] Argument passed to the callback.
|
4211
|
+
* @param {*} [p2] Argument passed to the callback.
|
4212
|
+
* @param {*} [p3] Argument passed to the callback.
|
4213
|
+
* @param {*} [p4] Argument passed to the callback.
|
4214
|
+
* @param {*} [p5] Argument passed to the callback.
|
4215
|
+
* @param {*} [p6] Argument passed to the callback.
|
4216
|
+
* @returns {*}
|
4217
|
+
*
|
4218
|
+
* @example
|
4219
|
+
* ```js
|
4220
|
+
* // Run built-in hook
|
4221
|
+
* hot.runHooks('beforeInit');
|
4222
|
+
* // Run custom hook
|
4223
|
+
* hot.runHooks('customAction', 10, 'foo');
|
4224
|
+
* ```
|
4225
|
+
*/
|
4226
|
+
this.runHooks = function (key, p1, p2, p3, p4, p5, p6) {
|
4227
|
+
return _pluginHooks.default.getSingleton().run(instance, key, p1, p2, p3, p4, p5, p6);
|
4228
|
+
};
|
4229
|
+
|
4230
|
+
/**
|
4231
|
+
* Get language phrase for specified dictionary key.
|
4232
|
+
*
|
4233
|
+
* @memberof Core#
|
4234
|
+
* @function getTranslatedPhrase
|
4235
|
+
* @since 0.35.0
|
4236
|
+
* @param {string} dictionaryKey Constant which is dictionary key.
|
4237
|
+
* @param {*} extraArguments Arguments which will be handled by formatters.
|
4238
|
+
* @returns {string}
|
4239
|
+
*/
|
4240
|
+
this.getTranslatedPhrase = function (dictionaryKey, extraArguments) {
|
4241
|
+
return (0, _registry4.getTranslatedPhrase)(tableMeta.language, dictionaryKey, extraArguments);
|
4242
|
+
};
|
4243
|
+
|
4244
|
+
/**
|
4245
|
+
* Converts instance into outerHTML of HTMLTableElement.
|
4246
|
+
*
|
4247
|
+
* @memberof Core#
|
4248
|
+
* @function toHTML
|
4249
|
+
* @since 7.1.0
|
4250
|
+
* @returns {string}
|
4251
|
+
*/
|
4252
|
+
this.toHTML = function () {
|
4253
|
+
return (0, _parseTable.instanceToHTML)(_this);
|
4254
|
+
};
|
4255
|
+
|
4256
|
+
/**
|
4257
|
+
* Converts instance into HTMLTableElement.
|
4258
|
+
*
|
4259
|
+
* @memberof Core#
|
4260
|
+
* @function toTableElement
|
4261
|
+
* @since 7.1.0
|
4262
|
+
* @returns {HTMLTableElement}
|
4263
|
+
*/
|
4264
|
+
this.toTableElement = function () {
|
4265
|
+
var tempElement = _this.rootDocument.createElement('div');
|
4266
|
+
tempElement.insertAdjacentHTML('afterbegin', (0, _parseTable.instanceToHTML)(_this));
|
4267
|
+
return tempElement.firstElementChild;
|
4268
|
+
};
|
4269
|
+
this.timeouts = [];
|
4270
|
+
|
4271
|
+
/**
|
4272
|
+
* Sets timeout. Purpose of this method is to clear all known timeouts when `destroy` method is called.
|
4273
|
+
*
|
4274
|
+
* @param {number|Function} handle Handler returned from setTimeout or function to execute (it will be automatically wraped
|
4275
|
+
* by setTimeout function).
|
4276
|
+
* @param {number} [delay=0] If first argument is passed as a function this argument set delay of the execution of that function.
|
4277
|
+
* @private
|
4278
|
+
*/
|
4279
|
+
this._registerTimeout = function (handle) {
|
4280
|
+
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
4281
|
+
var handleFunc = handle;
|
4282
|
+
if (typeof handleFunc === 'function') {
|
4283
|
+
handleFunc = setTimeout(handleFunc, delay);
|
4284
|
+
}
|
4285
|
+
this.timeouts.push(handleFunc);
|
4286
|
+
};
|
4287
|
+
|
4288
|
+
/**
|
4289
|
+
* Clears all known timeouts.
|
4290
|
+
*
|
4291
|
+
* @private
|
4292
|
+
*/
|
4293
|
+
this._clearTimeouts = function () {
|
4294
|
+
(0, _array.arrayEach)(this.timeouts, function (handler) {
|
4295
|
+
clearTimeout(handler);
|
4296
|
+
});
|
4297
|
+
};
|
4298
|
+
this.immediates = [];
|
4299
|
+
|
4300
|
+
/**
|
4301
|
+
* Execute function execution to the next event loop cycle. Purpose of this method is to clear all known timeouts when `destroy` method is called.
|
4302
|
+
*
|
4303
|
+
* @param {Function} callback Function to be delayed in execution.
|
4304
|
+
* @private
|
4305
|
+
*/
|
4306
|
+
this._registerImmediate = function (callback) {
|
4307
|
+
this.immediates.push(setImmediate(callback));
|
4308
|
+
};
|
4309
|
+
|
4310
|
+
/**
|
4311
|
+
* Clears all known timeouts.
|
4312
|
+
*
|
4313
|
+
* @private
|
4314
|
+
*/
|
4315
|
+
this._clearImmediates = function () {
|
4316
|
+
(0, _array.arrayEach)(this.immediates, function (handler) {
|
4317
|
+
clearImmediate(handler);
|
4318
|
+
});
|
4319
|
+
};
|
4320
|
+
|
4321
|
+
/**
|
4322
|
+
* Refresh selection borders. This is temporary method relic after selection rewrite.
|
4323
|
+
*
|
4324
|
+
* @private
|
4325
|
+
* @param {boolean} [revertOriginal=false] If `true`, the previous value will be restored. Otherwise, the edited value will be saved.
|
4326
|
+
* @param {boolean} [prepareEditorIfNeeded=true] If `true` the editor under the selected cell will be prepared to open.
|
4327
|
+
*/
|
4328
|
+
this._refreshBorders = function () {
|
4329
|
+
var revertOriginal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
4330
|
+
var prepareEditorIfNeeded = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
4331
|
+
editorManager.destroyEditor(revertOriginal);
|
4332
|
+
instance.view.render();
|
4333
|
+
if (prepareEditorIfNeeded && selection.isSelected()) {
|
4334
|
+
editorManager.prepareEditor();
|
4335
|
+
}
|
4336
|
+
};
|
4337
|
+
|
4338
|
+
/**
|
4339
|
+
* Check if currently it is RTL direction.
|
4340
|
+
*
|
4341
|
+
* @private
|
4342
|
+
* @memberof Core#
|
4343
|
+
* @function isRtl
|
4344
|
+
* @returns {boolean} True if RTL.
|
4345
|
+
*/
|
4346
|
+
this.isRtl = function () {
|
4347
|
+
return instance.rootWindow.getComputedStyle(instance.rootElement).direction === 'rtl';
|
4348
|
+
};
|
4349
|
+
|
4350
|
+
/**
|
4351
|
+
* Check if currently it is LTR direction.
|
4352
|
+
*
|
4353
|
+
* @private
|
4354
|
+
* @memberof Core#
|
4355
|
+
* @function isLtr
|
4356
|
+
* @returns {boolean} True if LTR.
|
4357
|
+
*/
|
4358
|
+
this.isLtr = function () {
|
4359
|
+
return !instance.isRtl();
|
4360
|
+
};
|
4361
|
+
|
4362
|
+
/**
|
4363
|
+
* Returns 1 for LTR; -1 for RTL. Useful for calculations.
|
4364
|
+
*
|
4365
|
+
* @private
|
4366
|
+
* @memberof Core#
|
4367
|
+
* @function getDirectionFactor
|
4368
|
+
* @returns {number} Returns 1 for LTR; -1 for RTL.
|
4369
|
+
*/
|
4370
|
+
this.getDirectionFactor = function () {
|
4371
|
+
return instance.isLtr() ? 1 : -1;
|
4372
|
+
};
|
4373
|
+
var shortcutManager = (0, _shortcuts.createShortcutManager)({
|
4374
|
+
handleEvent: function handleEvent(event) {
|
4375
|
+
var isListening = instance.isListening();
|
4376
|
+
var isKeyboardEventWithKey = (event === null || event === void 0 ? void 0 : event.key) !== void 0;
|
4377
|
+
return isListening && isKeyboardEventWithKey;
|
4378
|
+
},
|
4379
|
+
beforeKeyDown: function beforeKeyDown(event) {
|
4380
|
+
return _this.runHooks('beforeKeyDown', event);
|
4381
|
+
},
|
4382
|
+
afterKeyDown: function afterKeyDown(event) {
|
4383
|
+
if (_this.isDestroyed) {
|
4384
|
+
// Handsontable could be destroyed after performing action (executing a callback).
|
4385
|
+
return;
|
4386
|
+
}
|
4387
|
+
instance.runHooks('afterDocumentKeyDown', event);
|
4388
|
+
},
|
4389
|
+
ownerWindow: this.rootWindow
|
4390
|
+
});
|
4391
|
+
|
4392
|
+
/**
|
4393
|
+
* Returns instance of a manager responsible for handling shortcuts stored in some contexts. It run actions after
|
4394
|
+
* pressing key combination in active Handsontable instance.
|
4395
|
+
*
|
4396
|
+
* @memberof Core#
|
4397
|
+
* @since 12.0.0
|
4398
|
+
* @function getShortcutManager
|
4399
|
+
* @returns {ShortcutManager} Instance of {@link ShortcutManager}
|
4400
|
+
*/
|
4401
|
+
this.getShortcutManager = function () {
|
4402
|
+
return shortcutManager;
|
4403
|
+
};
|
4404
|
+
var gridContext = shortcutManager.addContext('grid');
|
4405
|
+
var gridConfig = {
|
4406
|
+
runOnlyIf: function runOnlyIf() {
|
4407
|
+
return (0, _mixed.isDefined)(instance.getSelected()) && instance.countRenderedRows() > 0 && instance.countRenderedCols() > 0;
|
4408
|
+
},
|
4409
|
+
group: SHORTCUTS_GROUP
|
4410
|
+
};
|
4411
|
+
shortcutManager.setActiveContextName('grid');
|
4412
|
+
gridContext.addShortcuts([{
|
4413
|
+
keys: [['Control/Meta', 'A']],
|
4414
|
+
callback: function callback() {
|
4415
|
+
instance.selectAll();
|
4416
|
+
}
|
4417
|
+
}, {
|
4418
|
+
keys: [['Control/Meta', 'Enter']],
|
4419
|
+
callback: function callback() {
|
4420
|
+
var selectedRange = instance.getSelectedRange();
|
4421
|
+
var _selectedRange$highli = selectedRange[selectedRange.length - 1].highlight,
|
4422
|
+
highlightRow = _selectedRange$highli.row,
|
4423
|
+
highlightColumn = _selectedRange$highli.col;
|
4424
|
+
var valueToPopulate = instance.getDataAtCell(highlightRow, highlightColumn);
|
4425
|
+
var cellValues = new Map();
|
4426
|
+
for (var i = 0; i < selectedRange.length; i++) {
|
4427
|
+
selectedRange[i].forAll(function (row, column) {
|
4428
|
+
if (row >= 0 && column >= 0 && (row !== highlightRow || column !== highlightColumn)) {
|
4429
|
+
var _instance$getCellMeta = instance.getCellMeta(row, column),
|
4430
|
+
readOnly = _instance$getCellMeta.readOnly;
|
4431
|
+
if (!readOnly) {
|
4432
|
+
cellValues.set("".concat(row, "x").concat(column), [row, column, valueToPopulate]);
|
4433
|
+
}
|
4434
|
+
}
|
4435
|
+
});
|
4436
|
+
}
|
4437
|
+
instance.setDataAtCell(Array.from(cellValues.values()));
|
4438
|
+
},
|
4439
|
+
runOnlyIf: function runOnlyIf() {
|
4440
|
+
return instance.getSelectedRangeLast().getCellsCount() > 1;
|
4441
|
+
}
|
4442
|
+
}, {
|
4443
|
+
keys: [['ArrowUp']],
|
4444
|
+
callback: function callback() {
|
4445
|
+
selection.transformStart(-1, 0);
|
4446
|
+
}
|
4447
|
+
}, {
|
4448
|
+
keys: [['ArrowUp', 'Control/Meta']],
|
4449
|
+
captureCtrl: true,
|
4450
|
+
callback: function callback() {
|
4451
|
+
selection.setRangeStart(instance._createCellCoords(instance.rowIndexMapper.getNearestNotHiddenIndex(0, 1), instance.getSelectedRangeLast().highlight.col));
|
4452
|
+
}
|
4453
|
+
}, {
|
4454
|
+
keys: [['ArrowUp', 'Shift']],
|
4455
|
+
callback: function callback() {
|
4456
|
+
selection.transformEnd(-1, 0);
|
4457
|
+
}
|
4458
|
+
}, {
|
4459
|
+
keys: [['ArrowUp', 'Shift', 'Control/Meta']],
|
4460
|
+
captureCtrl: true,
|
4461
|
+
callback: function callback() {
|
4462
|
+
var _instance$getSelected = instance.getSelectedRangeLast(),
|
4463
|
+
from = _instance$getSelected.from,
|
4464
|
+
to = _instance$getSelected.to;
|
4465
|
+
var row = instance.rowIndexMapper.getNearestNotHiddenIndex(0, 1);
|
4466
|
+
selection.setRangeStart(from.clone());
|
4467
|
+
selection.setRangeEnd(instance._createCellCoords(row, to.col));
|
4468
|
+
},
|
4469
|
+
runOnlyIf: function runOnlyIf() {
|
4470
|
+
return !(instance.selection.isSelectedByCorner() || instance.selection.isSelectedByColumnHeader());
|
4471
|
+
}
|
4472
|
+
}, {
|
4473
|
+
keys: [['ArrowDown']],
|
4474
|
+
callback: function callback() {
|
4475
|
+
selection.transformStart(1, 0);
|
4476
|
+
}
|
4477
|
+
}, {
|
4478
|
+
keys: [['ArrowDown', 'Control/Meta']],
|
4479
|
+
captureCtrl: true,
|
4480
|
+
callback: function callback() {
|
4481
|
+
selection.setRangeStart(instance._createCellCoords(instance.rowIndexMapper.getNearestNotHiddenIndex(instance.countRows() - 1, -1), instance.getSelectedRangeLast().highlight.col));
|
4482
|
+
}
|
4483
|
+
}, {
|
4484
|
+
keys: [['ArrowDown', 'Shift']],
|
4485
|
+
callback: function callback() {
|
4486
|
+
selection.transformEnd(1, 0);
|
4487
|
+
}
|
4488
|
+
}, {
|
4489
|
+
keys: [['ArrowDown', 'Shift', 'Control/Meta']],
|
4490
|
+
captureCtrl: true,
|
4491
|
+
callback: function callback() {
|
4492
|
+
var _instance$getSelected2 = instance.getSelectedRangeLast(),
|
4493
|
+
from = _instance$getSelected2.from,
|
4494
|
+
to = _instance$getSelected2.to;
|
4495
|
+
var row = instance.rowIndexMapper.getNearestNotHiddenIndex(instance.countRows() - 1, -1);
|
4496
|
+
selection.setRangeStart(from.clone());
|
4497
|
+
selection.setRangeEnd(instance._createCellCoords(row, to.col));
|
4498
|
+
},
|
4499
|
+
runOnlyIf: function runOnlyIf() {
|
4500
|
+
return !(instance.selection.isSelectedByCorner() || instance.selection.isSelectedByColumnHeader());
|
4501
|
+
}
|
4502
|
+
}, {
|
4503
|
+
keys: [['ArrowLeft']],
|
4504
|
+
callback: function callback() {
|
4505
|
+
selection.transformStart(0, -1 * instance.getDirectionFactor());
|
4506
|
+
}
|
4507
|
+
}, {
|
4508
|
+
keys: [['ArrowLeft', 'Control/Meta']],
|
4509
|
+
captureCtrl: true,
|
4510
|
+
callback: function callback() {
|
4511
|
+
var _instance$columnIndex;
|
4512
|
+
var row = instance.getSelectedRangeLast().highlight.row;
|
4513
|
+
var column = (_instance$columnIndex = instance.columnIndexMapper).getNearestNotHiddenIndex.apply(_instance$columnIndex, _toConsumableArray(instance.isRtl() ? [instance.countCols() - 1, -1] : [0, 1]));
|
4514
|
+
selection.setRangeStart(instance._createCellCoords(row, column));
|
4515
|
+
}
|
4516
|
+
}, {
|
4517
|
+
keys: [['ArrowLeft', 'Shift']],
|
4518
|
+
callback: function callback() {
|
4519
|
+
selection.transformEnd(0, -1 * instance.getDirectionFactor());
|
4520
|
+
}
|
4521
|
+
}, {
|
4522
|
+
keys: [['ArrowLeft', 'Shift', 'Control/Meta']],
|
4523
|
+
captureCtrl: true,
|
4524
|
+
callback: function callback() {
|
4525
|
+
var _instance$columnIndex2;
|
4526
|
+
var _instance$getSelected3 = instance.getSelectedRangeLast(),
|
4527
|
+
from = _instance$getSelected3.from,
|
4528
|
+
to = _instance$getSelected3.to;
|
4529
|
+
var column = (_instance$columnIndex2 = instance.columnIndexMapper).getNearestNotHiddenIndex.apply(_instance$columnIndex2, _toConsumableArray(instance.isRtl() ? [instance.countCols() - 1, -1] : [0, 1]));
|
4530
|
+
selection.setRangeStart(from.clone());
|
4531
|
+
selection.setRangeEnd(instance._createCellCoords(to.row, column));
|
4532
|
+
},
|
4533
|
+
runOnlyIf: function runOnlyIf() {
|
4534
|
+
return !(instance.selection.isSelectedByCorner() || instance.selection.isSelectedByRowHeader());
|
4535
|
+
}
|
4536
|
+
}, {
|
4537
|
+
keys: [['ArrowRight']],
|
4538
|
+
callback: function callback() {
|
4539
|
+
selection.transformStart(0, instance.getDirectionFactor());
|
4540
|
+
}
|
4541
|
+
}, {
|
4542
|
+
keys: [['ArrowRight', 'Control/Meta']],
|
4543
|
+
captureCtrl: true,
|
4544
|
+
callback: function callback() {
|
4545
|
+
var _instance$columnIndex3;
|
4546
|
+
var row = instance.getSelectedRangeLast().highlight.row;
|
4547
|
+
var column = (_instance$columnIndex3 = instance.columnIndexMapper).getNearestNotHiddenIndex.apply(_instance$columnIndex3, _toConsumableArray(instance.isRtl() ? [0, 1] : [instance.countCols() - 1, -1]));
|
4548
|
+
selection.setRangeStart(instance._createCellCoords(row, column));
|
4549
|
+
}
|
4550
|
+
}, {
|
4551
|
+
keys: [['ArrowRight', 'Shift']],
|
4552
|
+
callback: function callback() {
|
4553
|
+
selection.transformEnd(0, instance.getDirectionFactor());
|
4554
|
+
}
|
4555
|
+
}, {
|
4556
|
+
keys: [['ArrowRight', 'Shift', 'Control/Meta']],
|
4557
|
+
captureCtrl: true,
|
4558
|
+
callback: function callback() {
|
4559
|
+
var _instance$columnIndex4;
|
4560
|
+
var _instance$getSelected4 = instance.getSelectedRangeLast(),
|
4561
|
+
from = _instance$getSelected4.from,
|
4562
|
+
to = _instance$getSelected4.to;
|
4563
|
+
var column = (_instance$columnIndex4 = instance.columnIndexMapper).getNearestNotHiddenIndex.apply(_instance$columnIndex4, _toConsumableArray(instance.isRtl() ? [0, 1] : [instance.countCols() - 1, -1]));
|
4564
|
+
selection.setRangeStart(from.clone());
|
4565
|
+
selection.setRangeEnd(instance._createCellCoords(to.row, column));
|
4566
|
+
},
|
4567
|
+
runOnlyIf: function runOnlyIf() {
|
4568
|
+
return !(instance.selection.isSelectedByCorner() || instance.selection.isSelectedByRowHeader());
|
4569
|
+
}
|
4570
|
+
}, {
|
4571
|
+
keys: [['Home']],
|
4572
|
+
captureCtrl: true,
|
4573
|
+
callback: function callback() {
|
4574
|
+
var fixedColumns = parseInt(instance.getSettings().fixedColumnsStart, 10);
|
4575
|
+
var row = instance.getSelectedRangeLast().highlight.row;
|
4576
|
+
var column = instance.columnIndexMapper.getNearestNotHiddenIndex(fixedColumns, 1);
|
4577
|
+
selection.setRangeStart(instance._createCellCoords(row, column));
|
4578
|
+
},
|
4579
|
+
runOnlyIf: function runOnlyIf() {
|
4580
|
+
return instance.view.isMainTableNotFullyCoveredByOverlays();
|
4581
|
+
}
|
4582
|
+
}, {
|
4583
|
+
keys: [['Home', 'Shift']],
|
4584
|
+
callback: function callback() {
|
4585
|
+
selection.setRangeEnd(instance._createCellCoords(selection.selectedRange.current().from.row, instance.columnIndexMapper.getNearestNotHiddenIndex(0, 1)));
|
4586
|
+
}
|
4587
|
+
}, {
|
4588
|
+
keys: [['Home', 'Control/Meta']],
|
4589
|
+
captureCtrl: true,
|
4590
|
+
callback: function callback() {
|
4591
|
+
var fixedRows = parseInt(instance.getSettings().fixedRowsTop, 10);
|
4592
|
+
var fixedColumns = parseInt(instance.getSettings().fixedColumnsStart, 10);
|
4593
|
+
var row = instance.rowIndexMapper.getNearestNotHiddenIndex(fixedRows, 1);
|
4594
|
+
var column = instance.columnIndexMapper.getNearestNotHiddenIndex(fixedColumns, 1);
|
4595
|
+
selection.setRangeStart(instance._createCellCoords(row, column));
|
4596
|
+
},
|
4597
|
+
runOnlyIf: function runOnlyIf() {
|
4598
|
+
return instance.view.isMainTableNotFullyCoveredByOverlays();
|
4599
|
+
}
|
4600
|
+
}, {
|
4601
|
+
keys: [['End']],
|
4602
|
+
captureCtrl: true,
|
4603
|
+
callback: function callback() {
|
4604
|
+
selection.setRangeStart(instance._createCellCoords(instance.getSelectedRangeLast().highlight.row, instance.columnIndexMapper.getNearestNotHiddenIndex(instance.countCols() - 1, -1)));
|
4605
|
+
},
|
4606
|
+
runOnlyIf: function runOnlyIf() {
|
4607
|
+
return instance.view.isMainTableNotFullyCoveredByOverlays();
|
4608
|
+
}
|
4609
|
+
}, {
|
4610
|
+
keys: [['End', 'Shift']],
|
4611
|
+
callback: function callback() {
|
4612
|
+
selection.setRangeEnd(instance._createCellCoords(selection.selectedRange.current().from.row, instance.columnIndexMapper.getNearestNotHiddenIndex(instance.countCols() - 1, -1)));
|
4613
|
+
}
|
4614
|
+
}, {
|
4615
|
+
keys: [['End', 'Control/Meta']],
|
4616
|
+
captureCtrl: true,
|
4617
|
+
callback: function callback() {
|
4618
|
+
var fixedRows = parseInt(instance.getSettings().fixedRowsBottom, 10);
|
4619
|
+
var row = instance.rowIndexMapper.getNearestNotHiddenIndex(instance.countRows() - fixedRows - 1, -1);
|
4620
|
+
var column = instance.columnIndexMapper.getNearestNotHiddenIndex(instance.countCols() - 1, -1);
|
4621
|
+
selection.setRangeStart(instance._createCellCoords(row, column));
|
4622
|
+
},
|
4623
|
+
runOnlyIf: function runOnlyIf() {
|
4624
|
+
return instance.view.isMainTableNotFullyCoveredByOverlays();
|
4625
|
+
}
|
4626
|
+
}, {
|
4627
|
+
keys: [['PageUp']],
|
4628
|
+
callback: function callback() {
|
4629
|
+
selection.transformStart(-instance.countVisibleRows(), 0);
|
4630
|
+
}
|
4631
|
+
}, {
|
4632
|
+
keys: [['PageUp', 'Shift']],
|
4633
|
+
callback: function callback() {
|
4634
|
+
var _instance$getSelected5 = instance.getSelectedRangeLast(),
|
4635
|
+
to = _instance$getSelected5.to;
|
4636
|
+
var nextRowIndexToSelect = Math.max(to.row - instance.countVisibleRows(), 0);
|
4637
|
+
var row = instance.rowIndexMapper.getNearestNotHiddenIndex(nextRowIndexToSelect, 1);
|
4638
|
+
if (row !== null) {
|
4639
|
+
var coords = instance._createCellCoords(row, to.col);
|
4640
|
+
var scrollPadding = to.row - instance.view.getFirstFullyVisibleRow();
|
4641
|
+
var nextVerticalScroll = Math.max(coords.row - scrollPadding, 0);
|
4642
|
+
selection.setRangeEnd(coords);
|
4643
|
+
instance.scrollViewportTo(nextVerticalScroll);
|
4644
|
+
}
|
4645
|
+
}
|
4646
|
+
}, {
|
4647
|
+
keys: [['PageDown']],
|
4648
|
+
callback: function callback() {
|
4649
|
+
selection.transformStart(instance.countVisibleRows(), 0);
|
4650
|
+
}
|
4651
|
+
}, {
|
4652
|
+
keys: [['PageDown', 'Shift']],
|
4653
|
+
callback: function callback() {
|
4654
|
+
var _instance$getSelected6 = instance.getSelectedRangeLast(),
|
4655
|
+
to = _instance$getSelected6.to;
|
4656
|
+
var nextRowIndexToSelect = Math.min(to.row + instance.countVisibleRows(), instance.countRows() - 1);
|
4657
|
+
var row = instance.rowIndexMapper.getNearestNotHiddenIndex(nextRowIndexToSelect, -1);
|
4658
|
+
if (row !== null) {
|
4659
|
+
var coords = instance._createCellCoords(row, to.col);
|
4660
|
+
var scrollPadding = to.row - instance.view.getFirstFullyVisibleRow();
|
4661
|
+
var nextVerticalScroll = Math.min(coords.row - scrollPadding, instance.countRows() - 1);
|
4662
|
+
selection.setRangeEnd(coords);
|
4663
|
+
instance.scrollViewportTo(nextVerticalScroll);
|
4664
|
+
}
|
4665
|
+
}
|
4666
|
+
}, {
|
4667
|
+
keys: [['Tab']],
|
4668
|
+
callback: function callback(event) {
|
4669
|
+
var tabMoves = typeof tableMeta.tabMoves === 'function' ? tableMeta.tabMoves(event) : tableMeta.tabMoves;
|
4670
|
+
selection.transformStart(tabMoves.row, tabMoves.col, true);
|
4671
|
+
}
|
4672
|
+
}, {
|
4673
|
+
keys: [['Shift', 'Tab']],
|
4674
|
+
callback: function callback(event) {
|
4675
|
+
var tabMoves = typeof tableMeta.tabMoves === 'function' ? tableMeta.tabMoves(event) : tableMeta.tabMoves;
|
4676
|
+
selection.transformStart(-tabMoves.row, -tabMoves.col);
|
4677
|
+
}
|
4678
|
+
}], gridConfig);
|
4679
|
+
(0, _registry.getPluginsNames)().forEach(function (pluginName) {
|
4680
|
+
var PluginClass = (0, _registry.getPlugin)(pluginName);
|
4681
|
+
pluginsRegistry.addItem(pluginName, new PluginClass(_this));
|
4682
|
+
});
|
4683
|
+
_pluginHooks.default.getSingleton().run(instance, 'construct');
|
4684
|
+
}
|