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