handsontable 0.0.0-next-5e7f0fe-20230504 → 0.0.0-next-48677e7-20230509

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (227) hide show
  1. package/3rdparty/walkontable/src/cell/coords.js +40 -13
  2. package/3rdparty/walkontable/src/cell/coords.mjs +40 -13
  3. package/3rdparty/walkontable/src/cell/range.js +29 -25
  4. package/3rdparty/walkontable/src/cell/range.mjs +28 -24
  5. package/3rdparty/walkontable/src/core/_base.js +9 -3
  6. package/3rdparty/walkontable/src/core/_base.mjs +9 -3
  7. package/3rdparty/walkontable/src/core/clone.js +2 -2
  8. package/3rdparty/walkontable/src/core/clone.mjs +2 -2
  9. package/3rdparty/walkontable/src/core/core.js +3 -2
  10. package/3rdparty/walkontable/src/core/core.mjs +3 -2
  11. package/3rdparty/walkontable/src/event.js +12 -10
  12. package/3rdparty/walkontable/src/event.mjs +12 -10
  13. package/3rdparty/walkontable/src/facade/core.js +2 -2
  14. package/3rdparty/walkontable/src/facade/core.mjs +2 -2
  15. package/3rdparty/walkontable/src/index.js +10 -2
  16. package/3rdparty/walkontable/src/index.mjs +2 -2
  17. package/3rdparty/walkontable/src/overlay/_base.js +8 -7
  18. package/3rdparty/walkontable/src/overlay/_base.mjs +8 -7
  19. package/3rdparty/walkontable/src/overlay/bottom.js +7 -6
  20. package/3rdparty/walkontable/src/overlay/bottom.mjs +7 -6
  21. package/3rdparty/walkontable/src/overlay/inlineStart.js +2 -4
  22. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +2 -4
  23. package/3rdparty/walkontable/src/overlay/top.js +9 -10
  24. package/3rdparty/walkontable/src/overlay/top.mjs +9 -10
  25. package/3rdparty/walkontable/src/overlay/topInlineStartCorner.js +12 -10
  26. package/3rdparty/walkontable/src/overlay/topInlineStartCorner.mjs +12 -10
  27. package/3rdparty/walkontable/src/overlays.js +64 -55
  28. package/3rdparty/walkontable/src/overlays.mjs +64 -55
  29. package/3rdparty/walkontable/src/renderer/table.js +2 -0
  30. package/3rdparty/walkontable/src/renderer/table.mjs +2 -0
  31. package/3rdparty/walkontable/src/scroll.js +23 -20
  32. package/3rdparty/walkontable/src/scroll.mjs +23 -20
  33. package/3rdparty/walkontable/src/{border.js → selection/border/border.js} +7 -12
  34. package/3rdparty/walkontable/src/{border.mjs → selection/border/border.mjs} +7 -12
  35. package/3rdparty/walkontable/src/selection/border/constants.js +18 -0
  36. package/3rdparty/walkontable/src/selection/border/constants.mjs +13 -0
  37. package/3rdparty/walkontable/src/selection/constants.js +63 -0
  38. package/3rdparty/walkontable/src/selection/constants.mjs +51 -0
  39. package/3rdparty/walkontable/src/selection/index.js +30 -0
  40. package/3rdparty/walkontable/src/selection/index.mjs +5 -0
  41. package/3rdparty/walkontable/src/selection/manager.js +334 -0
  42. package/3rdparty/walkontable/src/selection/manager.mjs +328 -0
  43. package/3rdparty/walkontable/src/selection/scanner.js +363 -0
  44. package/3rdparty/walkontable/src/selection/scanner.mjs +359 -0
  45. package/3rdparty/walkontable/src/selection/selection.js +133 -0
  46. package/3rdparty/walkontable/src/selection/selection.mjs +127 -0
  47. package/3rdparty/walkontable/src/settings.js +15 -13
  48. package/3rdparty/walkontable/src/settings.mjs +15 -13
  49. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.js +9 -0
  50. package/3rdparty/walkontable/src/table/mixin/calculatedColumns.mjs +9 -0
  51. package/3rdparty/walkontable/src/table/mixin/calculatedRows.js +9 -0
  52. package/3rdparty/walkontable/src/table/mixin/calculatedRows.mjs +9 -0
  53. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.js +9 -0
  54. package/3rdparty/walkontable/src/table/mixin/stickyColumnsStart.mjs +9 -0
  55. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.js +9 -0
  56. package/3rdparty/walkontable/src/table/mixin/stickyRowsBottom.mjs +9 -0
  57. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.js +9 -0
  58. package/3rdparty/walkontable/src/table/mixin/stickyRowsTop.mjs +9 -0
  59. package/3rdparty/walkontable/src/table.js +33 -101
  60. package/3rdparty/walkontable/src/table.mjs +34 -102
  61. package/base.js +4 -2
  62. package/base.mjs +2 -2
  63. package/core.d.ts +4 -0
  64. package/core.js +49 -8
  65. package/core.mjs +49 -8
  66. package/dataMap/dataSource.js +5 -5
  67. package/dataMap/dataSource.mjs +5 -5
  68. package/dataMap/metaManager/metaSchema.js +7 -0
  69. package/dataMap/metaManager/metaSchema.mjs +7 -0
  70. package/dist/handsontable.css +7 -2
  71. package/dist/handsontable.full.css +7 -2
  72. package/dist/handsontable.full.js +9409 -9084
  73. package/dist/handsontable.full.min.css +3 -3
  74. package/dist/handsontable.full.min.js +115 -123
  75. package/dist/handsontable.js +9497 -9171
  76. package/dist/handsontable.min.css +3 -3
  77. package/dist/handsontable.min.js +3 -11
  78. package/dist/languages/all.js +0 -133
  79. package/dist/languages/ar-AR.js +0 -7
  80. package/dist/languages/cs-CZ.js +0 -7
  81. package/dist/languages/de-CH.js +0 -7
  82. package/dist/languages/de-DE.js +0 -7
  83. package/dist/languages/en-US.js +0 -7
  84. package/dist/languages/es-MX.js +0 -7
  85. package/dist/languages/fr-FR.js +0 -7
  86. package/dist/languages/it-IT.js +0 -7
  87. package/dist/languages/ja-JP.js +0 -7
  88. package/dist/languages/ko-KR.js +0 -7
  89. package/dist/languages/lv-LV.js +0 -7
  90. package/dist/languages/nb-NO.js +0 -7
  91. package/dist/languages/nl-NL.js +0 -7
  92. package/dist/languages/pl-PL.js +0 -7
  93. package/dist/languages/pt-BR.js +0 -7
  94. package/dist/languages/ru-RU.js +0 -7
  95. package/dist/languages/sr-SP.js +0 -7
  96. package/dist/languages/zh-CN.js +0 -7
  97. package/dist/languages/zh-TW.js +0 -7
  98. package/editorManager.js +7 -3
  99. package/editorManager.mjs +7 -3
  100. package/editors/textEditor/textEditor.js +3 -16
  101. package/editors/textEditor/textEditor.mjs +4 -17
  102. package/focusManager.d.ts +12 -0
  103. package/focusManager.js +249 -0
  104. package/focusManager.mjs +245 -0
  105. package/helpers/dom/element.js +11 -0
  106. package/helpers/dom/element.mjs +10 -0
  107. package/helpers/mixed.js +1 -1
  108. package/helpers/mixed.mjs +1 -1
  109. package/i18n/languages/ar-AR.js +1 -7
  110. package/i18n/languages/cs-CZ.js +1 -7
  111. package/i18n/languages/de-CH.js +1 -7
  112. package/i18n/languages/de-DE.js +1 -7
  113. package/i18n/languages/en-US.js +1 -7
  114. package/i18n/languages/es-MX.js +1 -7
  115. package/i18n/languages/fr-FR.js +1 -7
  116. package/i18n/languages/it-IT.js +1 -7
  117. package/i18n/languages/ja-JP.js +1 -7
  118. package/i18n/languages/ko-KR.js +1 -7
  119. package/i18n/languages/lv-LV.js +1 -7
  120. package/i18n/languages/nb-NO.js +1 -7
  121. package/i18n/languages/nl-NL.js +1 -7
  122. package/i18n/languages/pl-PL.js +1 -7
  123. package/i18n/languages/pt-BR.js +1 -7
  124. package/i18n/languages/ru-RU.js +1 -7
  125. package/i18n/languages/sr-SP.js +1 -7
  126. package/i18n/languages/zh-CN.js +1 -7
  127. package/i18n/languages/zh-TW.js +1 -7
  128. package/languages/all.js +0 -133
  129. package/languages/ar-AR.js +0 -7
  130. package/languages/cs-CZ.js +0 -7
  131. package/languages/de-CH.js +0 -7
  132. package/languages/de-DE.js +0 -7
  133. package/languages/en-US.js +0 -7
  134. package/languages/es-MX.js +0 -7
  135. package/languages/fr-FR.js +0 -7
  136. package/languages/index.js +0 -133
  137. package/languages/it-IT.js +0 -7
  138. package/languages/ja-JP.js +0 -7
  139. package/languages/ko-KR.js +0 -7
  140. package/languages/lv-LV.js +0 -7
  141. package/languages/nb-NO.js +0 -7
  142. package/languages/nl-NL.js +0 -7
  143. package/languages/pl-PL.js +0 -7
  144. package/languages/pt-BR.js +0 -7
  145. package/languages/ru-RU.js +0 -7
  146. package/languages/sr-SP.js +0 -7
  147. package/languages/zh-CN.js +0 -7
  148. package/languages/zh-TW.js +0 -7
  149. package/package.json +2 -3
  150. package/pluginHooks.js +7 -17
  151. package/pluginHooks.mjs +4 -16
  152. package/plugins/autoRowSize/autoRowSize.js +2 -2
  153. package/plugins/autoRowSize/autoRowSize.mjs +2 -2
  154. package/plugins/copyPaste/copyPaste.js +12 -93
  155. package/plugins/copyPaste/copyPaste.mjs +12 -93
  156. package/plugins/copyPaste/copyableRanges.js +31 -25
  157. package/plugins/copyPaste/copyableRanges.mjs +24 -18
  158. package/plugins/customBorders/customBorders.js +6 -2
  159. package/plugins/customBorders/customBorders.mjs +7 -3
  160. package/plugins/filters/filters.js +0 -5
  161. package/plugins/filters/filters.mjs +0 -5
  162. package/plugins/formulas/formulas.js +168 -190
  163. package/plugins/formulas/formulas.mjs +168 -190
  164. package/plugins/mergeCells/mergeCells.js +0 -16
  165. package/plugins/mergeCells/mergeCells.mjs +0 -16
  166. package/plugins/nestedHeaders/nestedHeaders.js +3 -4
  167. package/plugins/nestedHeaders/nestedHeaders.mjs +3 -4
  168. package/plugins/nestedHeaders/stateManager/headersTree.js +26 -23
  169. package/plugins/nestedHeaders/stateManager/headersTree.mjs +23 -20
  170. package/plugins/nestedHeaders/stateManager/index.js +3 -3
  171. package/plugins/nestedHeaders/stateManager/matrixGenerator.js +0 -1
  172. package/plugins/nestedHeaders/stateManager/settingsNormalizer.js +1 -1
  173. package/plugins/nestedHeaders/utils/ghostTable.js +35 -30
  174. package/plugins/nestedHeaders/utils/ghostTable.mjs +35 -30
  175. package/plugins/registry.js +1 -3
  176. package/plugins/undoRedo/undoRedo.js +1 -0
  177. package/plugins/undoRedo/undoRedo.mjs +1 -0
  178. package/renderers/baseRenderer/baseRenderer.js +3 -0
  179. package/renderers/baseRenderer/baseRenderer.mjs +3 -0
  180. package/selection/highlight/highlight.js +335 -133
  181. package/selection/highlight/highlight.mjs +325 -129
  182. package/selection/highlight/types/activeHeader.js +10 -9
  183. package/selection/highlight/types/activeHeader.mjs +10 -8
  184. package/selection/highlight/types/area.js +12 -27
  185. package/selection/highlight/types/area.mjs +16 -30
  186. package/selection/highlight/types/areaLayered.js +54 -0
  187. package/selection/highlight/types/areaLayered.mjs +49 -0
  188. package/selection/highlight/types/column.js +50 -0
  189. package/selection/highlight/types/column.mjs +45 -0
  190. package/selection/highlight/types/customSelection.js +7 -10
  191. package/selection/highlight/types/customSelection.mjs +7 -9
  192. package/selection/highlight/types/fill.js +5 -8
  193. package/selection/highlight/types/fill.mjs +5 -7
  194. package/selection/highlight/types/{cell.js → focus.js} +5 -8
  195. package/selection/highlight/types/{cell.mjs → focus.mjs} +5 -7
  196. package/selection/highlight/types/header.js +10 -20
  197. package/selection/highlight/types/header.mjs +10 -19
  198. package/selection/highlight/types/{index.js → row.js} +27 -31
  199. package/selection/highlight/types/{index.mjs → row.mjs} +24 -29
  200. package/selection/highlight/visualSelection.js +12 -21
  201. package/selection/highlight/visualSelection.mjs +12 -21
  202. package/selection/index.js +4 -7
  203. package/selection/index.mjs +2 -3
  204. package/selection/selection.js +88 -46
  205. package/selection/selection.mjs +82 -44
  206. package/settings.d.ts +1 -0
  207. package/tableView.js +94 -66
  208. package/tableView.mjs +94 -66
  209. package/translations/changesObservable/observable.js +46 -41
  210. package/translations/changesObservable/observable.mjs +41 -36
  211. package/translations/changesObservable/observer.js +1 -1
  212. package/translations/indexMapper.js +0 -21
  213. package/translations/indexMapper.mjs +0 -21
  214. package/utils/dataStructures/tree.js +18 -15
  215. package/utils/dataStructures/tree.mjs +18 -15
  216. package/utils/parseTable.js +1 -5
  217. package/utils/parseTable.mjs +1 -5
  218. package/3rdparty/walkontable/src/selection.js +0 -354
  219. package/3rdparty/walkontable/src/selection.mjs +0 -348
  220. package/plugins/copyPaste/focusableElement.js +0 -219
  221. package/plugins/copyPaste/focusableElement.mjs +0 -213
  222. package/plugins/formulas/indexSyncer/axisSyncer.js +0 -379
  223. package/plugins/formulas/indexSyncer/axisSyncer.mjs +0 -374
  224. package/plugins/formulas/indexSyncer/index.js +0 -225
  225. package/plugins/formulas/indexSyncer/index.mjs +0 -219
  226. package/selection/highlight/constants.js +0 -16
  227. package/selection/highlight/constants.mjs +0 -6
@@ -21,7 +21,6 @@ require("core-js/modules/es.string.replace.js");
21
21
  require("core-js/modules/es.object.to-string.js");
22
22
  require("core-js/modules/es.array.concat.js");
23
23
  require("core-js/modules/es.array.splice.js");
24
- require("core-js/modules/es.string.repeat.js");
25
24
  require("core-js/modules/es.string.match.js");
26
25
  require("core-js/modules/es.array.last-index-of.js");
27
26
  require("core-js/modules/es.array.reduce.js");
@@ -140,10 +139,7 @@ function _dataToHTML(input) {
140
139
  }
141
140
  for (var column = 0; column < columnsLen; column += 1) {
142
141
  var cellData = rowData[column];
143
- var parsedCellData = (0, _mixed.isEmpty)(cellData) ? '' : cellData.toString().replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, '<br>\r\n').replace(/\x20{2,}/gi, function (substring) {
144
- // The way how Excel serializes data with at least two spaces.
145
- return "<span style=\"mso-spacerun: yes\">".concat('&nbsp;'.repeat(substring.length - 1), " </span>");
146
- }).replace(/\t/gi, '&#9;');
142
+ var parsedCellData = (0, _mixed.isEmpty)(cellData) ? '' : cellData.toString().replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, '<br>\r\n').replace(/\x20/gi, '&nbsp;').replace(/\t/gi, '&#9;');
147
143
  columnsResult.push("<td>".concat(parsedCellData, "</td>"));
148
144
  }
149
145
  result.push.apply(result, ['<tr>'].concat(columnsResult, ['</tr>']));
@@ -14,7 +14,6 @@ import "core-js/modules/es.string.replace.js";
14
14
  import "core-js/modules/es.object.to-string.js";
15
15
  import "core-js/modules/es.array.concat.js";
16
16
  import "core-js/modules/es.array.splice.js";
17
- import "core-js/modules/es.string.repeat.js";
18
17
  import "core-js/modules/es.string.match.js";
19
18
  import "core-js/modules/es.array.last-index-of.js";
20
19
  import "core-js/modules/es.array.reduce.js";
@@ -134,10 +133,7 @@ export function _dataToHTML(input) {
134
133
  }
135
134
  for (var column = 0; column < columnsLen; column += 1) {
136
135
  var cellData = rowData[column];
137
- var parsedCellData = isEmpty(cellData) ? '' : cellData.toString().replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, '<br>\r\n').replace(/\x20{2,}/gi, function (substring) {
138
- // The way how Excel serializes data with at least two spaces.
139
- return "<span style=\"mso-spacerun: yes\">".concat('&nbsp;'.repeat(substring.length - 1), " </span>");
140
- }).replace(/\t/gi, '&#9;');
136
+ var parsedCellData = isEmpty(cellData) ? '' : cellData.toString().replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/(<br(\s*|\/)>(\r\n|\n)?|\r\n|\n)/g, '<br>\r\n').replace(/\x20/gi, '&nbsp;').replace(/\t/gi, '&#9;');
141
137
  columnsResult.push("<td>".concat(parsedCellData, "</td>"));
142
138
  }
143
139
  result.push.apply(result, ['<tr>'].concat(columnsResult, ['</tr>']));
@@ -1,354 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.symbol.iterator.js");
4
- require("core-js/modules/es.array.iterator.js");
5
- require("core-js/modules/es.string.iterator.js");
6
- require("core-js/modules/web.dom-collections.iterator.js");
7
- require("core-js/modules/es.array.slice.js");
8
- require("core-js/modules/es.function.name.js");
9
- require("core-js/modules/es.array.from.js");
10
- require("core-js/modules/es.regexp.exec.js");
11
- exports.__esModule = true;
12
- exports.default = void 0;
13
- require("core-js/modules/es.array.includes.js");
14
- require("core-js/modules/es.string.includes.js");
15
- require("core-js/modules/es.array.concat.js");
16
- require("core-js/modules/es.object.to-string.js");
17
- require("core-js/modules/web.dom-collections.for-each.js");
18
- require("core-js/modules/es.object.values.js");
19
- require("core-js/modules/es.symbol.to-primitive.js");
20
- require("core-js/modules/es.date.to-primitive.js");
21
- require("core-js/modules/es.symbol.js");
22
- require("core-js/modules/es.symbol.description.js");
23
- require("core-js/modules/es.number.constructor.js");
24
- var _element = require("./../../../helpers/dom/element");
25
- var _border = _interopRequireDefault(require("./border"));
26
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
28
- 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."); }
29
- 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); }
30
- 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; }
31
- 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; } }
32
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
33
- 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); }
34
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
35
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
36
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
38
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
39
- /**
40
- * @class Selection
41
- */
42
- var Selection = /*#__PURE__*/function () {
43
- /**
44
- * @param {object} settings The selection settings object. @todo type.
45
- * @param {CellRange} cellRange The cell range instance.
46
- */
47
- function Selection(settings, cellRange) {
48
- _classCallCheck(this, Selection);
49
- this.settings = settings;
50
- this.cellRange = cellRange || null;
51
- this.instanceBorders = {};
52
- this.classNames = [this.settings.className];
53
- this.classNameGenerator = this.linearClassNameGenerator(this.settings.className, this.settings.layerLevel);
54
- }
55
-
56
- /**
57
- * Each Walkontable clone requires it's own border for every selection. This method creates and returns selection
58
- * borders per instance.
59
- *
60
- * @param {WalkontableFacade} wotInstance The Walkontable instance.
61
- * @returns {Border}
62
- */
63
- _createClass(Selection, [{
64
- key: "getBorder",
65
- value: function getBorder(wotInstance) {
66
- if (!this.instanceBorders[wotInstance.guid]) {
67
- this.instanceBorders[wotInstance.guid] = new _border.default(wotInstance, this.settings);
68
- }
69
- return this.instanceBorders[wotInstance.guid];
70
- }
71
-
72
- /**
73
- * Checks if selection is empty.
74
- *
75
- * @returns {boolean}
76
- */
77
- }, {
78
- key: "isEmpty",
79
- value: function isEmpty() {
80
- return this.cellRange === null;
81
- }
82
-
83
- /**
84
- * Adds a cell coords to the selection.
85
- *
86
- * @param {CellCoords} coords The cell coordinates to add.
87
- * @returns {Selection}
88
- */
89
- }, {
90
- key: "add",
91
- value: function add(coords) {
92
- if (this.isEmpty()) {
93
- this.cellRange = this.settings.createCellRange(coords);
94
- } else {
95
- this.cellRange.expand(coords);
96
- }
97
- return this;
98
- }
99
-
100
- /**
101
- * If selection range from or to property equals oldCoords, replace it with newCoords. Return boolean
102
- * information about success.
103
- *
104
- * @param {CellCoords} oldCoords An old cell coordinates to replace.
105
- * @param {CellCoords} newCoords The new cell coordinates.
106
- * @returns {boolean}
107
- */
108
- }, {
109
- key: "replace",
110
- value: function replace(oldCoords, newCoords) {
111
- if (!this.isEmpty()) {
112
- if (this.cellRange.from.isEqual(oldCoords)) {
113
- this.cellRange.from = newCoords;
114
- return true;
115
- }
116
- if (this.cellRange.to.isEqual(oldCoords)) {
117
- this.cellRange.to = newCoords;
118
- return true;
119
- }
120
- }
121
- return false;
122
- }
123
-
124
- /**
125
- * Clears selection.
126
- *
127
- * @returns {Selection}
128
- */
129
- }, {
130
- key: "clear",
131
- value: function clear() {
132
- this.cellRange = null;
133
- return this;
134
- }
135
-
136
- /**
137
- * Returns the top left (or top right in RTL) and bottom right (or bottom left in RTL) selection coordinates.
138
- *
139
- * @returns {Array} Returns array of coordinates for example `[1, 1, 5, 5]`.
140
- */
141
- }, {
142
- key: "getCorners",
143
- value: function getCorners() {
144
- var topStart = this.cellRange.getOuterTopStartCorner();
145
- var bottomEnd = this.cellRange.getOuterBottomEndCorner();
146
- return [topStart.row, topStart.col, bottomEnd.row, bottomEnd.col];
147
- }
148
-
149
- /**
150
- * Adds class name to cell element at given coords.
151
- *
152
- * @param {WalkontableFacade} wotInstance Walkontable instance.
153
- * @param {number} sourceRow Cell row coord.
154
- * @param {number} sourceColumn Cell column coord.
155
- * @param {string} className Class name.
156
- * @param {boolean} [markIntersections=false] If `true`, linear className generator will be used to add CSS classes
157
- * in a continuous way.
158
- * @returns {Selection}
159
- */
160
- }, {
161
- key: "addClassAtCoords",
162
- value: function addClassAtCoords(wotInstance, sourceRow, sourceColumn, className) {
163
- var markIntersections = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
164
- var TD = wotInstance.wtTable.getCell(this.settings.createCellCoords(sourceRow, sourceColumn));
165
- if (_typeof(TD) === 'object') {
166
- var cellClassName = className;
167
- if (markIntersections) {
168
- cellClassName = this.classNameGenerator(TD);
169
- if (!this.classNames.includes(cellClassName)) {
170
- this.classNames.push(cellClassName);
171
- }
172
- }
173
- (0, _element.addClass)(TD, cellClassName);
174
- }
175
- return this;
176
- }
177
-
178
- /**
179
- * Generate helper for calculating classNames based on previously added base className.
180
- * The generated className is always generated as a continuation of the previous className. For example, when
181
- * the currently checked element has 'area-2' className the generated new className will be 'area-3'. When
182
- * the element doesn't have any classNames than the base className will be returned ('area');.
183
- *
184
- * @param {string} baseClassName Base className to be used.
185
- * @param {number} layerLevelOwner Layer level which the instance of the Selection belongs to.
186
- * @returns {Function}
187
- */
188
- }, {
189
- key: "linearClassNameGenerator",
190
- value: function linearClassNameGenerator(baseClassName, layerLevelOwner) {
191
- // TODO: Make this recursive function Proper Tail Calls (TCO/PTC) friendly.
192
- return function calcClassName(element) {
193
- var previousIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;
194
- if (layerLevelOwner === 0 || previousIndex === 0) {
195
- return baseClassName;
196
- }
197
- var index = previousIndex >= 0 ? previousIndex : layerLevelOwner;
198
- var className = baseClassName;
199
- index -= 1;
200
- var previousClassName = index === 0 ? baseClassName : "".concat(baseClassName, "-").concat(index);
201
- if ((0, _element.hasClass)(element, previousClassName)) {
202
- var currentLayer = index + 1;
203
- className = "".concat(baseClassName, "-").concat(currentLayer);
204
- } else {
205
- className = calcClassName(element, index);
206
- }
207
- return className;
208
- };
209
- }
210
-
211
- /**
212
- * @param {WalkontableFacade} wotInstance The Walkontable instance.
213
- */
214
- }, {
215
- key: "draw",
216
- value: function draw(wotInstance) {
217
- if (this.isEmpty()) {
218
- if (this.settings.border) {
219
- this.getBorder(wotInstance).disappear();
220
- }
221
- return;
222
- }
223
- var renderedRows = wotInstance.wtTable.getRenderedRowsCount();
224
- var renderedColumns = wotInstance.wtTable.getRenderedColumnsCount();
225
- var corners = this.getCorners();
226
- var _corners = _slicedToArray(corners, 4),
227
- topRow = _corners[0],
228
- topColumn = _corners[1],
229
- bottomRow = _corners[2],
230
- bottomColumn = _corners[3];
231
- var _this$settings = this.settings,
232
- highlightHeaderClassName = _this$settings.highlightHeaderClassName,
233
- highlightColumnClassName = _this$settings.highlightColumnClassName,
234
- highlightRowClassName = _this$settings.highlightRowClassName,
235
- highlightOnlyClosestHeader = _this$settings.highlightOnlyClosestHeader,
236
- selectionType = _this$settings.selectionType;
237
- var isHeaderSelectionType = selectionType === void 0 || ['active-header', 'header'].includes(selectionType);
238
- if (isHeaderSelectionType && topColumn !== null && bottomColumn !== null) {
239
- var selectionColumnCursor = 0;
240
- for (var column = 0; column < renderedColumns; column += 1) {
241
- var sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(column);
242
- if (sourceCol >= topColumn && sourceCol <= bottomColumn) {
243
- var THs = wotInstance.wtTable.getColumnHeaders(sourceCol);
244
- var closestHeaderLevel = THs.length - 1;
245
- if (highlightOnlyClosestHeader && THs.length > 1) {
246
- THs = [THs[closestHeaderLevel]];
247
- }
248
- for (var headerLevel = 0; headerLevel < THs.length; headerLevel += 1) {
249
- var newClasses = [];
250
- var TH = THs[headerLevel];
251
- if (highlightHeaderClassName) {
252
- newClasses.push(highlightHeaderClassName);
253
- }
254
- if (highlightColumnClassName) {
255
- newClasses.push(highlightColumnClassName);
256
- }
257
- headerLevel = highlightOnlyClosestHeader ? closestHeaderLevel : headerLevel;
258
- var newSourceCol = wotInstance.getSetting('onBeforeHighlightingColumnHeader', sourceCol, headerLevel, {
259
- selectionType: selectionType,
260
- columnCursor: selectionColumnCursor,
261
- selectionWidth: bottomColumn - topColumn + 1,
262
- classNames: newClasses
263
- });
264
- if (newSourceCol !== sourceCol) {
265
- TH = wotInstance.wtTable.getColumnHeader(newSourceCol, headerLevel);
266
- }
267
- (0, _element.addClass)(TH, newClasses);
268
- }
269
- selectionColumnCursor += 1;
270
- }
271
- }
272
- }
273
- if (topRow !== null && bottomRow !== null) {
274
- var selectionRowCursor = 0;
275
- for (var row = 0; row < renderedRows; row += 1) {
276
- var sourceRow = wotInstance.wtTable.rowFilter.renderedToSource(row);
277
- if (isHeaderSelectionType && sourceRow >= topRow && sourceRow <= bottomRow) {
278
- var _THs = wotInstance.wtTable.getRowHeaders(sourceRow);
279
- var _closestHeaderLevel = _THs.length - 1;
280
- if (highlightOnlyClosestHeader && _THs.length > 1) {
281
- _THs = [_THs[_closestHeaderLevel]];
282
- }
283
- for (var _headerLevel = 0; _headerLevel < _THs.length; _headerLevel += 1) {
284
- var _newClasses = [];
285
- var _TH = _THs[_headerLevel];
286
- if (highlightHeaderClassName) {
287
- _newClasses.push(highlightHeaderClassName);
288
- }
289
- if (highlightRowClassName) {
290
- _newClasses.push(highlightRowClassName);
291
- }
292
- _headerLevel = highlightOnlyClosestHeader ? _closestHeaderLevel : _headerLevel;
293
- var newSourceRow = wotInstance.getSetting('onBeforeHighlightingRowHeader', sourceRow, _headerLevel, {
294
- selectionType: selectionType,
295
- rowCursor: selectionRowCursor,
296
- selectionHeight: bottomRow - topRow + 1,
297
- classNames: _newClasses
298
- });
299
- if (newSourceRow !== sourceRow) {
300
- _TH = wotInstance.wtTable.getRowHeader(newSourceRow, _headerLevel);
301
- }
302
- (0, _element.addClass)(_TH, _newClasses);
303
- }
304
- selectionRowCursor += 1;
305
- }
306
- if (topColumn !== null && bottomColumn !== null) {
307
- for (var _column = 0; _column < renderedColumns; _column += 1) {
308
- var _sourceCol = wotInstance.wtTable.columnFilter.renderedToSource(_column);
309
- if (sourceRow >= topRow && sourceRow <= bottomRow && _sourceCol >= topColumn && _sourceCol <= bottomColumn) {
310
- // selected cell
311
- if (this.settings.className) {
312
- this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, this.settings.className, this.settings.markIntersections);
313
- }
314
- } else if (sourceRow >= topRow && sourceRow <= bottomRow) {
315
- // selection is in this row
316
- if (highlightRowClassName) {
317
- this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, highlightRowClassName);
318
- }
319
- } else if (_sourceCol >= topColumn && _sourceCol <= bottomColumn) {
320
- // selection is in this column
321
- if (highlightColumnClassName) {
322
- this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, highlightColumnClassName);
323
- }
324
- }
325
- var additionalSelectionClass = wotInstance.getSetting('onAfterDrawSelection', sourceRow, _sourceCol, this.settings.layerLevel);
326
- if (typeof additionalSelectionClass === 'string') {
327
- this.addClassAtCoords(wotInstance, sourceRow, _sourceCol, additionalSelectionClass);
328
- }
329
- }
330
- }
331
- }
332
- }
333
- wotInstance.getSetting('onBeforeDrawBorders', corners, this.settings.className);
334
- if (this.settings.border) {
335
- // warning! border.appear modifies corners!
336
- this.getBorder(wotInstance).appear(corners);
337
- }
338
- }
339
-
340
- /**
341
- * Cleans up all the DOM state related to a Selection instance. Call this prior to deleting a Selection instance.
342
- */
343
- }, {
344
- key: "destroy",
345
- value: function destroy() {
346
- Object.values(this.instanceBorders).forEach(function (border) {
347
- return border.destroy();
348
- });
349
- }
350
- }]);
351
- return Selection;
352
- }();
353
- var _default = Selection;
354
- exports.default = _default;