handsontable 0.0.0-next-3d099da-20231208 → 0.0.0-next-51d3397-20231211

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 (129) hide show
  1. package/3rdparty/walkontable/src/calculator/index.js +11 -6
  2. package/3rdparty/walkontable/src/calculator/index.mjs +5 -3
  3. package/3rdparty/walkontable/src/calculator/renderAllColumns.js +50 -0
  4. package/3rdparty/walkontable/src/calculator/renderAllColumns.mjs +46 -0
  5. package/3rdparty/walkontable/src/calculator/renderAllRows.js +50 -0
  6. package/3rdparty/walkontable/src/calculator/renderAllRows.mjs +46 -0
  7. package/3rdparty/walkontable/src/calculator/viewportColumns.js +1 -122
  8. package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +2 -124
  9. package/3rdparty/walkontable/src/calculator/viewportRows.js +1 -1
  10. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +2 -3
  11. package/3rdparty/walkontable/src/core/_base.js +0 -12
  12. package/3rdparty/walkontable/src/core/_base.mjs +0 -12
  13. package/3rdparty/walkontable/src/core/core.js +0 -2
  14. package/3rdparty/walkontable/src/core/core.mjs +0 -2
  15. package/3rdparty/walkontable/src/facade/core.js +0 -9
  16. package/3rdparty/walkontable/src/facade/core.mjs +0 -9
  17. package/3rdparty/walkontable/src/index.js +3 -4
  18. package/3rdparty/walkontable/src/index.mjs +1 -2
  19. package/3rdparty/walkontable/src/overlays.js +0 -3
  20. package/3rdparty/walkontable/src/overlays.mjs +0 -4
  21. package/3rdparty/walkontable/src/renderer/colGroup.js +10 -0
  22. package/3rdparty/walkontable/src/renderer/colGroup.mjs +10 -0
  23. package/3rdparty/walkontable/src/renderer/rows.js +4 -3
  24. package/3rdparty/walkontable/src/renderer/rows.mjs +4 -3
  25. package/3rdparty/walkontable/src/selection/manager.js +0 -1
  26. package/3rdparty/walkontable/src/selection/manager.mjs +0 -1
  27. package/3rdparty/walkontable/src/settings.js +3 -0
  28. package/3rdparty/walkontable/src/settings.mjs +2 -0
  29. package/3rdparty/walkontable/src/table.js +0 -1
  30. package/3rdparty/walkontable/src/table.mjs +0 -1
  31. package/3rdparty/walkontable/src/utils/column.js +27 -12
  32. package/3rdparty/walkontable/src/utils/column.mjs +27 -12
  33. package/3rdparty/walkontable/src/utils/columnStretching.js +219 -0
  34. package/3rdparty/walkontable/src/utils/columnStretching.mjs +215 -0
  35. package/3rdparty/walkontable/src/viewport.js +22 -17
  36. package/3rdparty/walkontable/src/viewport.mjs +23 -18
  37. package/base.js +4 -2
  38. package/base.mjs +2 -2
  39. package/core/focusCatcher/index.js +44 -6
  40. package/core/focusCatcher/index.mjs +44 -6
  41. package/core.js +0 -11
  42. package/core.mjs +0 -11
  43. package/dataMap/dataMap.js +1 -0
  44. package/dataMap/metaManager/metaSchema.js +28 -2
  45. package/dataMap/metaManager/metaSchema.mjs +28 -2
  46. package/dataMap/metaManager/mods/extendMetaProperties.js +12 -0
  47. package/dataMap/metaManager/mods/extendMetaProperties.mjs +12 -0
  48. package/dist/handsontable.css +2 -2
  49. package/dist/handsontable.full.css +3 -3
  50. package/dist/handsontable.full.js +3979 -5577
  51. package/dist/handsontable.full.min.css +3 -3
  52. package/dist/handsontable.full.min.js +66 -71
  53. package/dist/handsontable.js +3058 -4305
  54. package/dist/handsontable.min.css +2 -2
  55. package/dist/handsontable.min.js +35 -39
  56. package/editorManager.js +3 -4
  57. package/editorManager.mjs +3 -4
  58. package/editors/autocompleteEditor/autocompleteEditor.js +0 -2
  59. package/editors/autocompleteEditor/autocompleteEditor.mjs +0 -2
  60. package/editors/dateEditor/dateEditor.d.ts +1 -1
  61. package/editors/dateEditor/dateEditor.js +4 -1
  62. package/editors/dateEditor/dateEditor.mjs +4 -1
  63. package/editors/handsontableEditor/handsontableEditor.js +0 -1
  64. package/editors/handsontableEditor/handsontableEditor.mjs +0 -1
  65. package/editors/textEditor/textEditor.js +0 -4
  66. package/editors/textEditor/textEditor.mjs +0 -4
  67. package/helpers/browser.js +5 -2
  68. package/helpers/browser.mjs +5 -2
  69. package/helpers/feature.js +10 -0
  70. package/helpers/feature.mjs +9 -0
  71. package/helpers/mixed.js +1 -1
  72. package/helpers/mixed.mjs +1 -1
  73. package/package.json +3 -4
  74. package/pluginHooks.d.ts +6 -29
  75. package/pluginHooks.js +65 -123
  76. package/pluginHooks.mjs +62 -122
  77. package/plugins/copyPaste/clipboardData.js +18 -0
  78. package/plugins/copyPaste/clipboardData.mjs +14 -0
  79. package/plugins/copyPaste/copyPaste.js +129 -51
  80. package/plugins/copyPaste/copyPaste.mjs +132 -54
  81. package/plugins/copyPaste/copyableRanges.js +43 -7
  82. package/plugins/copyPaste/copyableRanges.mjs +42 -7
  83. package/plugins/copyPaste/pasteEvent.mjs +1 -1
  84. package/plugins/customBorders/customBorders.js +0 -5
  85. package/plugins/customBorders/customBorders.mjs +0 -5
  86. package/plugins/customBorders/utils.js +0 -1
  87. package/plugins/customBorders/utils.mjs +0 -1
  88. package/plugins/filters/ui/radioInput.js +1 -1
  89. package/plugins/filters/ui/radioInput.mjs +1 -1
  90. package/plugins/formulas/formulas.js +0 -2
  91. package/plugins/formulas/formulas.mjs +0 -2
  92. package/plugins/formulas/indexSyncer/axisSyncer.js +0 -1
  93. package/plugins/formulas/indexSyncer/axisSyncer.mjs +0 -1
  94. package/plugins/manualColumnResize/manualColumnResize.js +0 -1
  95. package/plugins/manualColumnResize/manualColumnResize.mjs +0 -1
  96. package/plugins/mergeCells/mergeCells.js +1 -127
  97. package/plugins/mergeCells/mergeCells.mjs +1 -127
  98. package/plugins/nestedHeaders/nestedHeaders.js +41 -87
  99. package/plugins/nestedHeaders/nestedHeaders.mjs +42 -88
  100. package/plugins/nestedHeaders/stateManager/headersTree.js +0 -1
  101. package/plugins/nestedHeaders/stateManager/headersTree.mjs +0 -1
  102. package/plugins/undoRedo/undoRedo.js +0 -2
  103. package/plugins/undoRedo/undoRedo.mjs +0 -2
  104. package/renderers/autocompleteRenderer/autocompleteRenderer.js +0 -1
  105. package/renderers/autocompleteRenderer/autocompleteRenderer.mjs +0 -1
  106. package/renderers/checkboxRenderer/checkboxRenderer.js +0 -2
  107. package/renderers/checkboxRenderer/checkboxRenderer.mjs +0 -2
  108. package/selection/highlight/highlight.js +0 -1
  109. package/selection/highlight/highlight.mjs +0 -1
  110. package/selection/index.js +1 -3
  111. package/selection/index.mjs +2 -2
  112. package/selection/utils.js +0 -34
  113. package/selection/utils.mjs +0 -33
  114. package/settings.d.ts +2 -1
  115. package/tableView.js +1 -2
  116. package/tableView.mjs +1 -2
  117. package/translations/indexMapper.js +2 -1
  118. package/utils/parseTable.js +84 -538
  119. package/utils/parseTable.mjs +83 -534
  120. package/validators/timeValidator/timeValidator.js +0 -1
  121. package/validators/timeValidator/timeValidator.mjs +0 -1
  122. package/plugins/copyPaste/clipboardData/clipboardData.js +0 -588
  123. package/plugins/copyPaste/clipboardData/clipboardData.mjs +0 -584
  124. package/plugins/copyPaste/clipboardData/copyClipboardData.js +0 -69
  125. package/plugins/copyPaste/clipboardData/copyClipboardData.mjs +0 -65
  126. package/plugins/copyPaste/clipboardData/index.js +0 -9
  127. package/plugins/copyPaste/clipboardData/index.mjs +0 -4
  128. package/plugins/copyPaste/clipboardData/pasteClipboardData.js +0 -81
  129. package/plugins/copyPaste/clipboardData/pasteClipboardData.mjs +0 -77
@@ -1,584 +0,0 @@
1
- import "core-js/modules/es.error.cause.js";
2
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
3
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
4
- 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); }
5
- import { isDefined } from "../../../helpers/mixed.mjs";
6
- import { deepClone, isObject } from "../../../helpers/object.mjs";
7
- import { toSingleLine } from "../../../helpers/templateLiteralTag.mjs";
8
- import { warn } from "../../../helpers/console.mjs";
9
- import { getDataWithHeadersByConfig, getHTMLFromConfig, htmlToGridSettings } from "../../../utils/parseTable.mjs";
10
- import { arrayEach } from "../../../helpers/array.mjs";
11
- export const META_HEAD = ['<meta name="generator" content="Handsontable"/>', '<style type="text/css">td{white-space:normal}br{mso-data-placement:same-cell}</style>'].join('');
12
-
13
- /**
14
- * Creates an object containing information about performed action: copy, cut (performing also copying) or paste.
15
- *
16
- * @private
17
- */
18
- export class ClipboardData {
19
- constructor() {
20
- /**
21
- * Sanitized data of "text/html" type inside the clipboard.
22
- *
23
- * @private
24
- * @type {string}
25
- */
26
- _defineProperty(this, "html", void 0);
27
- /**
28
- * Copied data stored as array of arrays.
29
- *
30
- * @private
31
- * @type {string[][]}
32
- */
33
- _defineProperty(this, "data", void 0);
34
- if (this.constructor === ClipboardData) {
35
- throw new Error('The `ClipboardData` is an abstract class and it can\'t be instantiated. Please use ' + '`CopyClipboardData` or `PasteClipboardData` classes instead.');
36
- }
37
- }
38
-
39
- /**
40
- * Gets copied data stored as array of arrays.
41
- *
42
- * @returns {string[][]}
43
- */
44
- getData() {
45
- return deepClone(this.data);
46
- }
47
-
48
- /**
49
- * Gets meta information about copied data.
50
- *
51
- * @returns {object} Object containing `data`, `colHeaders`, `rowHeaders`, `nestedHeaders`, `mergeCells` keys and
52
- * the corresponding values.
53
- */
54
- getMetaInfo() {
55
- return htmlToGridSettings(this.html);
56
- }
57
-
58
- /**
59
- * Sets meta information for certain property.
60
- *
61
- * @private
62
- * @param {string} property Property for which the meta information will be changed.
63
- * @param {*} value New meta information value.
64
- */
65
- setMetaInfo(property, value) {
66
- const metaInfo = this.getMetaInfo();
67
- if (value === null) {
68
- delete metaInfo[property];
69
- } else {
70
- metaInfo[property] = value;
71
- }
72
- this.overwriteInfo(metaInfo);
73
- }
74
-
75
- /**
76
- * Overwrite stored data basing on handled configuration.
77
- *
78
- * @private
79
- * @param {object} config Configuration.
80
- */
81
- overwriteInfo(config) {
82
- this.html = [this.isSerializedHandsontable() ? META_HEAD : '', getHTMLFromConfig(config)].join('');
83
- this.data = getDataWithHeadersByConfig(config);
84
- }
85
-
86
- /**
87
- * Adjust information about merged cells after removing some columns.
88
- *
89
- * Note: Used indexes refers to processed data, not to the instance of Handsontable.
90
- *
91
- * @private
92
- * @param {object} metaInfo Object containing `data`, `colHeaders`, `rowHeaders`, `nestedHeaders`, `mergeCells`
93
- * keys and the corresponding values, which will be changed by the reference.
94
- * @param {number[]} removedColumns List of column indexes which should be excluded when creating copy/cut/paste data.
95
- */
96
- adjustAfterColumnsRemoval(metaInfo, removedColumns) {
97
- const mergedCells = metaInfo.mergeCells;
98
- if (isDefined(mergedCells) === false) {
99
- return;
100
- }
101
- metaInfo.mergeCells = mergedCells.reduce((filteredNestedCells, mergeArea) => {
102
- const {
103
- col: mergeStartColumn,
104
- colspan
105
- } = mergeArea;
106
- const removedMergedColumns = removedColumns.filter(column => column >= mergeStartColumn && column < mergeStartColumn + colspan);
107
- const removedMergedColumnsLength = removedMergedColumns.length;
108
- if (removedMergedColumnsLength === colspan) {
109
- return filteredNestedCells;
110
- } else if (colspan - removedMergedColumnsLength === 1) {
111
- delete mergeArea.colspan;
112
- } else if (removedMergedColumnsLength > 0) {
113
- mergeArea.colspan = colspan - removedMergedColumnsLength;
114
- }
115
- if (Number.isInteger(mergeArea.rowspan) || Number.isInteger(mergeArea.colspan)) {
116
- return filteredNestedCells.concat(mergeArea);
117
- }
118
- return filteredNestedCells;
119
- }, []);
120
- metaInfo.mergeCells.forEach(mergeArea => {
121
- const shiftedColumns = removedColumns.filter(column => column < mergeArea.col);
122
- const shifterColumnsLength = shiftedColumns.length;
123
- mergeArea.col = mergeArea.col - shifterColumnsLength;
124
- });
125
- if (metaInfo.mergeCells.length === 0) {
126
- delete metaInfo.mergeCells;
127
- }
128
- }
129
-
130
- /**
131
- * Adjust information about merged cells after removing some rows.
132
- *
133
- * Note: Used indexes refers to processed data, not to the instance of Handsontable.
134
- *
135
- * @private
136
- * @param {object} metaInfo Object containing `data`, `colHeaders`, `rowHeaders`, `nestedHeaders`, `mergeCells`
137
- * keys and the corresponding values, which will be changed by the reference.
138
- * @param {number[]} removedRows List of row indexes which should be excluded when creating copy/cut/paste data.
139
- */
140
- adjustAfterRowRemoval(metaInfo, removedRows) {
141
- const mergedCells = metaInfo.mergeCells;
142
- if (isDefined(mergedCells) === false) {
143
- return;
144
- }
145
- metaInfo.mergeCells = mergedCells.reduce((filteredNestedCells, mergeArea) => {
146
- const {
147
- row: mergeStartRow,
148
- rowspan
149
- } = mergeArea;
150
- const removedMergedRows = removedRows.filter(row => row >= mergeStartRow && row < mergeStartRow + rowspan);
151
- const removedMergedRowsLength = removedMergedRows.length;
152
- if (removedMergedRowsLength === rowspan) {
153
- return filteredNestedCells;
154
- } else if (rowspan - removedMergedRowsLength === 1) {
155
- delete mergeArea.rowspan;
156
- } else if (removedMergedRowsLength > 0) {
157
- mergeArea.rowspan = rowspan - removedMergedRowsLength;
158
- }
159
- if (Number.isInteger(mergeArea.rowspan) || Number.isInteger(mergeArea.colspan)) {
160
- return filteredNestedCells.concat(mergeArea);
161
- }
162
- return filteredNestedCells;
163
- }, []);
164
- metaInfo.mergeCells.forEach(mergeArea => {
165
- const shiftedRows = removedRows.filter(row => row < mergeArea.row);
166
- const shifterRowsLength = shiftedRows.length;
167
- mergeArea.row = mergeArea.row - shifterRowsLength;
168
- });
169
- if (metaInfo.mergeCells.length === 0) {
170
- delete metaInfo.mergeCells;
171
- }
172
- }
173
-
174
- /**
175
- * Remove rows from the serialized dataset.
176
- *
177
- * Note: Used indexes refers to processed data, not to the instance of Handsontable. Please keep in mind that headers
178
- * are handled separately from cells and they are recognised using negative indexes.
179
- *
180
- * @param {number[]} rows List of row indexes which should be excluded when creating copy/cut/paste data.
181
- */
182
- removeRows(rows) {
183
- if (this.isSerializedTable() === false) {
184
- return;
185
- }
186
- const metaInfo = this.getMetaInfo();
187
- this.adjustAfterRowRemoval(metaInfo, rows);
188
- const config = {
189
- ...metaInfo,
190
- excludedRows: rows
191
- };
192
- this.overwriteInfo(config);
193
- }
194
-
195
- /**
196
- * Remove columns from the serialized dataset.
197
- *
198
- * Note: Used indexes refers to processed data, not to the instance of Handsontable. Please keep in mind that headers
199
- * are handled separately from cells and they are recognised using negative indexes.
200
- *
201
- * @param {number[]} columns List of column indexes which should be excluded when creating copy/cut/paste data.
202
- */
203
- removeColumns(columns) {
204
- if (this.isSerializedTable() === false) {
205
- return;
206
- }
207
- const metaInfo = this.getMetaInfo();
208
- const {
209
- nestedHeaders,
210
- colHeaders
211
- } = metaInfo;
212
- if (Array.isArray(nestedHeaders) && columns.length > 0) {
213
- warn('It\'s not possible to modify copied dataset containing nested headers.');
214
- return;
215
- }
216
- if (Array.isArray(colHeaders) && columns.length > 0) {
217
- metaInfo.colHeaders = colHeaders.filter(columnIndex => columns.includes(columnIndex) === false);
218
- }
219
- this.adjustAfterColumnsRemoval(metaInfo, columns);
220
- const config = {
221
- ...metaInfo,
222
- excludedColumns: columns
223
- };
224
- this.overwriteInfo(config);
225
- }
226
-
227
- /**
228
- * Get warning message when there is some problem with row insertion or undefined otherwise.
229
- *
230
- * @private
231
- * @param {number} rowIndex An index of the row at which the new values will be inserted.
232
- * @param {string[]} values List of values.
233
- * @returns {undefined|string}
234
- */
235
- getRowInsertionWarn(rowIndex, values) {
236
- const metaInfo = this.getMetaInfo();
237
- const data = metaInfo.data;
238
- const insertedElementsCount = values.length;
239
- if (Array.isArray(data) === false) {
240
- const {
241
- nestedHeaders,
242
- colHeaders
243
- } = metaInfo;
244
- if (rowIndex > 0) {
245
- return toSingleLine`Invalid row insertion done inside some \`CopyPaste\` hook. There is no possibility to\x20
246
- expand an empty dataset at position higher than zero.`;
247
- }
248
- if (Array.isArray(nestedHeaders) && nestedHeaders[0].length !== insertedElementsCount || Array.isArray(colHeaders) && colHeaders.length !== insertedElementsCount) {
249
- return toSingleLine`Invalid row insertion done inside some \`CopyPaste\` hook. Please provide proper number\x20
250
- of elements (corresponding to size of the dataset in other rows) for inserted rows.`;
251
- }
252
- return;
253
- }
254
- const numberOfRows = data.length;
255
- const numberOfColumns = data[0].length;
256
- if (rowIndex > numberOfRows) {
257
- return toSingleLine`Invalid row insertion done inside some \`CopyPaste\` hook. Please provide an valid row\x20
258
- index (not too high) for row data insertion.`;
259
- }
260
- if (numberOfColumns !== insertedElementsCount) {
261
- return toSingleLine`Invalid row insertion done inside some \`CopyPaste\` hook. Please provide proper number of\x20
262
- elements (corresponding to size of the dataset in other rows) for inserted rows.`;
263
- }
264
- }
265
-
266
- /**
267
- * Adjust information about merged cells after row insertion.
268
- *
269
- * Note: Used index refers to processed data, not to the instance of Handsontable.
270
- *
271
- * @private
272
- * @param {object} metaInfo Object containing `data`, `colHeaders`, `rowHeaders`, `nestedHeaders`, `mergeCells`
273
- * keys and the corresponding values, which will be changed by the reference.
274
- * @param {number} rowIndex An index of the row at which the new values have been inserted.
275
- */
276
- adjustAfterRowInsertion(metaInfo, rowIndex) {
277
- const {
278
- mergeCells: mergedCells,
279
- data
280
- } = metaInfo;
281
- mergedCells === null || mergedCells === void 0 || mergedCells.forEach(mergeArea => {
282
- const {
283
- row: mergeStartRow,
284
- col: mergeStartColumn,
285
- rowspan,
286
- colspan
287
- } = mergeArea;
288
- if (rowIndex > mergeStartRow && rowIndex < mergeStartRow + rowspan) {
289
- mergeArea.rowspan += 1;
290
- for (let i = 0; i < colspan; i += 1) {
291
- data[rowIndex][mergeStartColumn + i] = '';
292
- }
293
- }
294
- });
295
- mergedCells === null || mergedCells === void 0 || mergedCells.forEach(mergeArea => {
296
- if (rowIndex <= mergeArea.row) {
297
- mergeArea.row += 1;
298
- }
299
- });
300
- }
301
-
302
- /**
303
- * Insert values at row index.
304
- *
305
- * Note: Used index refers to processed data, not to the instance of Handsontable.
306
- *
307
- * @param {number} rowIndex An index of the row at which the new values will be inserted.
308
- * @param {string[]} values List of values.
309
- */
310
- insertAtRow(rowIndex, values) {
311
- if (this.isSerializedTable() === false) {
312
- return;
313
- }
314
- const metaInfo = this.getMetaInfo();
315
- const data = metaInfo.data || [];
316
- const rowInsertionWarn = this.getRowInsertionWarn(rowIndex, values);
317
- if (isDefined(rowInsertionWarn)) {
318
- warn(rowInsertionWarn);
319
- return;
320
- }
321
- metaInfo.data = [...data.slice(0, rowIndex), values, ...data.slice(rowIndex)];
322
- this.adjustAfterRowInsertion(metaInfo, rowIndex);
323
- this.overwriteInfo(metaInfo);
324
- }
325
-
326
- /**
327
- * Get warning message when there is some problem with row insertion or undefined otherwise.
328
- *
329
- * @private
330
- * @param {number} columnIndex An index of the column at which the new values will be inserted or removed.
331
- * @param {string[]} values List of values.
332
- * @returns {undefined|string}
333
- */
334
- getColumnInsertionWarn(columnIndex, values) {
335
- const {
336
- nestedHeaders,
337
- data,
338
- colHeaders
339
- } = this.getMetaInfo();
340
- const headerLevels = isDefined(colHeaders) ? 1 : 0;
341
- if (Array.isArray(nestedHeaders)) {
342
- return toSingleLine`Invalid column insertion done inside some \`CopyPaste\` hook. It's not possible to modify\x20
343
- copied dataset containing nested headers`;
344
- }
345
- if (Array.isArray(data) === false) {
346
- return;
347
- }
348
- const numberOfRows = data.length + headerLevels;
349
- const numberOfColumns = data[0].length;
350
- if (columnIndex > numberOfColumns) {
351
- return toSingleLine`Invalid column insertion done inside some \`CopyPaste\` hook. Please provide an valid\x20
352
- column index (not too high) for column data insertion.`;
353
- }
354
- if (values.length !== numberOfRows) {
355
- return toSingleLine`Invalid column insertion done inside some \`CopyPaste\` hook. Please provide proper number\x20
356
- of elements (corresponding to size of the dataset in other columns, including headers) for inserted columns.`;
357
- }
358
- }
359
-
360
- /**
361
- * Adjust information about merged cells after column insertion.
362
- *
363
- * Note: Used index refers to processed data, not to the instance of Handsontable.
364
- *
365
- * @private
366
- * @param {object} metaInfo Object containing `data`, `colHeaders`, `rowHeaders`, `nestedHeaders`, `mergeCells`
367
- * keys and the corresponding values, which will be changed by the reference.
368
- * @param {number} columnIndex An index of the column at which the new values have been inserted.
369
- */
370
- adjustAfterColumnInsertion(metaInfo, columnIndex) {
371
- const {
372
- mergeCells: mergedCells,
373
- data
374
- } = metaInfo;
375
- mergedCells === null || mergedCells === void 0 || mergedCells.forEach(mergeArea => {
376
- const {
377
- row: mergeStartRow,
378
- col: mergeStartColumn,
379
- colspan,
380
- rowspan
381
- } = mergeArea;
382
- if (columnIndex > mergeStartColumn && columnIndex < mergeStartColumn + colspan) {
383
- mergeArea.colspan += 1;
384
- for (let i = 0; i < rowspan; i += 1) {
385
- data[mergeStartRow + i][columnIndex] = '';
386
- }
387
- }
388
- });
389
- mergedCells === null || mergedCells === void 0 || mergedCells.forEach(mergeArea => {
390
- if (columnIndex <= mergeArea.col) {
391
- mergeArea.col += 1;
392
- }
393
- });
394
- }
395
-
396
- /**
397
- * Insert values at column index.
398
- *
399
- * Note: Used index refers to processed data, not to the instance of Handsontable.
400
- *
401
- * @param {number} columnIndex An index of the column at which the new values will be inserted or removed.
402
- * @param {string[]} values List of values.
403
- */
404
- insertAtColumn(columnIndex, values) {
405
- if (this.isSerializedTable() === false) {
406
- return;
407
- }
408
- const metaInfo = this.getMetaInfo();
409
- const {
410
- data,
411
- colHeaders
412
- } = metaInfo;
413
- const headerLevels = isDefined(colHeaders) ? 1 : 0;
414
- const columnInsertionWarn = this.getColumnInsertionWarn(columnIndex, values);
415
- if (isDefined(columnInsertionWarn)) {
416
- warn(columnInsertionWarn);
417
- return;
418
- }
419
- if (headerLevels > 0) {
420
- colHeaders.splice(columnIndex, 0, values[0]);
421
- }
422
- data === null || data === void 0 || data.forEach((rowData, rowIndex) => {
423
- rowData.splice(columnIndex, 0, values[rowIndex + headerLevels]);
424
- });
425
- this.adjustAfterColumnInsertion(metaInfo, columnIndex);
426
- this.overwriteInfo(metaInfo);
427
- }
428
-
429
- /**
430
- * Get internal column index for nested header with certain row and column indexes.
431
- *
432
- * @private
433
- * @param {number} row Row index related to level of the nested headers.
434
- * @param {number} column Column index for certain row.
435
- * @returns {*}
436
- */
437
- getNestedHeaderColumn(row, column) {
438
- const {
439
- nestedHeaders
440
- } = this.getMetaInfo();
441
- const rowRelative = row + nestedHeaders.length;
442
- const nestedHeadersForLevel = nestedHeaders[rowRelative];
443
- let indexInHeadersArray;
444
- let currentColumnIndex = 0;
445
- if (Array.isArray(nestedHeadersForLevel) === false) {
446
- return;
447
- }
448
- arrayEach(nestedHeadersForLevel, (nestedHeaderInfo, index) => {
449
- const isSimpleHeader = typeof nestedHeaderInfo === 'string';
450
- if (isSimpleHeader === true) {
451
- if (currentColumnIndex === column) {
452
- indexInHeadersArray = index;
453
- return false;
454
- }
455
- currentColumnIndex += 1;
456
- } else {
457
- const {
458
- colspan
459
- } = nestedHeaderInfo;
460
- if (column < currentColumnIndex + colspan) {
461
- indexInHeadersArray = index;
462
- return false;
463
- }
464
- currentColumnIndex += colspan;
465
- }
466
- });
467
- return indexInHeadersArray;
468
- }
469
-
470
- /**
471
- * Change headers or cells in the serialized dataset.
472
- *
473
- * Note: Used indexes refers to processed data, not to the instance of Handsontable. Please keep in mind that headers
474
- * are handled separately from cells and they are recognised using negative indexes.
475
- *
476
- * @param {number} row Row index of cell which should be changed.
477
- * @param {number} column Column index of cell which should be changed.
478
- * @param {string} value Value for particular index.
479
- */
480
- setCellAt(row, column, value) {
481
- if (this.isSerializedTable() === false) {
482
- return;
483
- }
484
- const config = this.getMetaInfo();
485
- const {
486
- data,
487
- nestedHeaders,
488
- colHeaders
489
- } = config;
490
- if (row < 0) {
491
- if (Array.isArray(nestedHeaders)) {
492
- const rowRelative = row + nestedHeaders.length;
493
- const nestedHeaderColumn = this.getNestedHeaderColumn(row, column);
494
- if (isDefined(nestedHeaderColumn) === false) {
495
- return;
496
- }
497
- const header = nestedHeaders[rowRelative][nestedHeaderColumn];
498
- if (isObject(header)) {
499
- header.label = value;
500
- } else {
501
- nestedHeaders[rowRelative][nestedHeaderColumn] = value;
502
- }
503
- } else if (Array.isArray(colHeaders)) {
504
- if (isDefined(colHeaders[column])) {
505
- colHeaders[column] = value;
506
- }
507
- }
508
- } else if (row >= 0 && Array.isArray(data) && Array.isArray(data[row]) && isDefined(data[row][column])) {
509
- data[row][column] = value;
510
- }
511
- this.overwriteInfo(config);
512
- }
513
-
514
- /**
515
- * Gets header or cell values from the serialized dataset.
516
- *
517
- * Note: Used indexes refers to processed data, not to the instance of Handsontable. Please keep in mind that headers
518
- * are handled separately from cells and they are recognised using negative indexes.
519
- *
520
- * @param {number} row Row index of cell which should be get.
521
- * @param {number} column Column index of cell which should be get.
522
- * @returns {undefined|string}
523
- */
524
- getCellAt(row, column) {
525
- if (this.isSerializedTable() === false) {
526
- return;
527
- }
528
- const config = this.getMetaInfo();
529
- const {
530
- data,
531
- nestedHeaders,
532
- colHeaders
533
- } = config;
534
- if (row < 0) {
535
- if (Array.isArray(nestedHeaders)) {
536
- const rowRelative = row + nestedHeaders.length;
537
- const nestedHeaderColumn = this.getNestedHeaderColumn(row, column);
538
- if (isDefined(nestedHeaderColumn) === false) {
539
- return;
540
- }
541
- const header = nestedHeaders[rowRelative][nestedHeaderColumn];
542
- if (isObject(header)) {
543
- return header.label;
544
- }
545
- return header;
546
- } else if (Array.isArray(colHeaders)) {
547
- if (isDefined(colHeaders[column])) {
548
- return colHeaders[column];
549
- }
550
- }
551
- } else if (row >= 0 && Array.isArray(data) && Array.isArray(data[row]) && isDefined(data[row][column])) {
552
- return data[row][column];
553
- }
554
- }
555
-
556
- /**
557
- * Checks whether serialized data is an array.
558
- *
559
- * @private
560
- * @returns {boolean}
561
- */
562
- isSerializedTable() {
563
- return true;
564
- }
565
-
566
- /**
567
- * Checks whether serialized data is a Handsontable.
568
- *
569
- * @private
570
- * @returns {boolean}
571
- */
572
- isSerializedHandsontable() {
573
- return true;
574
- }
575
-
576
- /**
577
- * Gets source of the copied data.
578
- *
579
- * @returns {string}
580
- */
581
- getType() {
582
- return 'handsontable';
583
- }
584
- }
@@ -1,69 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- require("core-js/modules/es.error.cause.js");
5
- var _clipboardData = require("./clipboardData");
6
- var _selection = require("../../../selection");
7
- var _parseTable = require("../../../utils/parseTable");
8
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
10
- 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); }
11
- /**
12
- * Creates an object containing information about copy/cut action.
13
- *
14
- * @private
15
- */
16
- class CopyClipboardData extends _clipboardData.ClipboardData {
17
- /**
18
- * @param {Core} instance Handsontable instance (used only while copying data).
19
- * @param {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>} copyableRanges Cell
20
- * ranges related to instance of Handsontable (used only while copying data).
21
- */
22
- constructor(instance, copyableRanges) {
23
- super();
24
- /**
25
- * Sanitized data of "text/html" type inside the clipboard.
26
- *
27
- * @private
28
- * @type {string}
29
- */
30
- _defineProperty(this, "html", void 0);
31
- /**
32
- * Copied data stored as array of arrays.
33
- *
34
- * @private
35
- * @type {string[][]}
36
- */
37
- _defineProperty(this, "data", void 0);
38
- /**
39
- * Copied cell ranges related to instance of Handsontable.
40
- *
41
- * @private
42
- * @type {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>}
43
- */
44
- _defineProperty(this, "copyableRanges", void 0);
45
- const {
46
- rows,
47
- columns
48
- } = (0, _selection.transformRangeLikeToIndexes)(copyableRanges);
49
- this.html = [_clipboardData.META_HEAD, (0, _parseTable.getHTMLByCoords)(instance, {
50
- rows,
51
- columns
52
- })].join('');
53
- this.data = (0, _parseTable.getDataByCoords)(instance, {
54
- rows,
55
- columns
56
- });
57
- this.copyableRanges = copyableRanges;
58
- }
59
-
60
- /**
61
- * Gets ranges related to copied part of Handsontable.
62
- *
63
- * @returns {Array<{startRow: number, startCol: number, endRow: number, endCol: number}>}
64
- */
65
- getRanges() {
66
- return this.copyableRanges;
67
- }
68
- }
69
- exports.CopyClipboardData = CopyClipboardData;