handsontable 0.0.0-next-6812ce6-20221122 → 0.0.0-next-1b1acbd-20221123

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.

package/base.js CHANGED
@@ -41,8 +41,8 @@ Handsontable.Core = function (rootElement) {
41
41
  Handsontable.DefaultSettings = (0, _dataMap.metaSchemaFactory)();
42
42
  Handsontable.hooks = _pluginHooks.default.getSingleton();
43
43
  Handsontable.packageName = 'handsontable';
44
- Handsontable.buildDate = "22/11/2022 14:31:41";
45
- Handsontable.version = "0.0.0-next-6812ce6-20221122";
44
+ Handsontable.buildDate = "23/11/2022 12:56:09";
45
+ Handsontable.version = "0.0.0-next-1b1acbd-20221123";
46
46
  Handsontable.languages = {
47
47
  dictionaryKeys: _registry.dictionaryKeys,
48
48
  getLanguageDictionary: _registry.getLanguageDictionary,
package/base.mjs CHANGED
@@ -32,8 +32,8 @@ Handsontable.Core = function (rootElement) {
32
32
  Handsontable.DefaultSettings = metaSchemaFactory();
33
33
  Handsontable.hooks = Hooks.getSingleton();
34
34
  Handsontable.packageName = 'handsontable';
35
- Handsontable.buildDate = "22/11/2022 14:31:54";
36
- Handsontable.version = "0.0.0-next-6812ce6-20221122";
35
+ Handsontable.buildDate = "23/11/2022 12:56:22";
36
+ Handsontable.version = "0.0.0-next-1b1acbd-20221123";
37
37
  Handsontable.languages = {
38
38
  dictionaryKeys: dictionaryKeys,
39
39
  getLanguageDictionary: getLanguageDictionary,
package/core.js CHANGED
@@ -1028,8 +1028,8 @@ function Core(rootElement, userSettings) {
1028
1028
  var orgValueSchema = (0, _object.duckSchema)(Array.isArray(orgValue) ? orgValue : orgValue[0] || orgValue);
1029
1029
  var valueSchema = (0, _object.duckSchema)(Array.isArray(value) ? value : value[0] || value);
1030
1030
 
1031
- /* eslint-disable max-depth */
1032
- if ((0, _object.isObjectEqual)(orgValueSchema, valueSchema)) {
1031
+ // Allow overwriting values with the same object-based schema or any array-based schema.
1032
+ if ((0, _object.isObjectEqual)(orgValueSchema, valueSchema) || Array.isArray(orgValueSchema) && Array.isArray(valueSchema)) {
1033
1033
  value = (0, _object.deepClone)(value);
1034
1034
  } else {
1035
1035
  pushData = false;
package/core.mjs CHANGED
@@ -1023,8 +1023,8 @@ export default function Core(rootElement, userSettings) {
1023
1023
  var orgValueSchema = duckSchema(Array.isArray(orgValue) ? orgValue : orgValue[0] || orgValue);
1024
1024
  var valueSchema = duckSchema(Array.isArray(value) ? value : value[0] || value);
1025
1025
 
1026
- /* eslint-disable max-depth */
1027
- if (isObjectEqual(orgValueSchema, valueSchema)) {
1026
+ // Allow overwriting values with the same object-based schema or any array-based schema.
1027
+ if (isObjectEqual(orgValueSchema, valueSchema) || Array.isArray(orgValueSchema) && Array.isArray(valueSchema)) {
1028
1028
  value = deepClone(value);
1029
1029
  } else {
1030
1030
  pushData = false;
@@ -104,7 +104,7 @@ var DataMap = /*#__PURE__*/function () {
104
104
  *
105
105
  * @type {object}
106
106
  */
107
- this.duckSchema = this.dataSource && this.dataSource[0] ? (0, _object.duckSchema)(this.dataSource[0]) : {};
107
+ this.duckSchema = this.createDuckSchema();
108
108
  /**
109
109
  * Cached array of properties to columns.
110
110
  *
@@ -275,6 +275,26 @@ var DataMap = /*#__PURE__*/function () {
275
275
  return this.duckSchema;
276
276
  }
277
277
 
278
+ /**
279
+ * Creates the duck schema based on the current dataset.
280
+ *
281
+ * @returns {Array|object}
282
+ */
283
+ }, {
284
+ key: "createDuckSchema",
285
+ value: function createDuckSchema() {
286
+ return this.dataSource && this.dataSource[0] ? (0, _object.duckSchema)(this.dataSource[0]) : {};
287
+ }
288
+
289
+ /**
290
+ * Refresh the data schema.
291
+ */
292
+ }, {
293
+ key: "refreshDuckSchema",
294
+ value: function refreshDuckSchema() {
295
+ this.duckSchema = this.createDuckSchema();
296
+ }
297
+
278
298
  /**
279
299
  * Creates row at the bottom of the data array.
280
300
  *
@@ -310,7 +330,7 @@ var DataMap = /*#__PURE__*/function () {
310
330
  return 0;
311
331
  }
312
332
  var maxRows = this.tableMeta.maxRows;
313
- var columnCount = this.instance.countCols();
333
+ var columnCount = this.getSchema().length;
314
334
  var rowsToAdd = [];
315
335
  var _loop = function _loop() {
316
336
  var row = null;
@@ -343,6 +363,12 @@ var DataMap = /*#__PURE__*/function () {
343
363
  }
344
364
  this.spliceData(physicalRowIndex, 0, rowsToAdd);
345
365
  var newVisualRowIndex = this.instance.toVisualRow(physicalRowIndex);
366
+
367
+ // In case the created rows are the only ones in the table, the column index mappers need to be rebuilt based on
368
+ // the number of columns created in the row or the schema.
369
+ if (this.instance.countSourceRows() === rowsToAdd.length) {
370
+ this.instance.columnIndexMapper.initToLength(this.instance.getInitialColumnCount());
371
+ }
346
372
  this.instance.runHooks('afterCreateRow', newVisualRowIndex, numberOfCreatedRows, source);
347
373
  this.instance.forceFullRender = true; // used when data was changed
348
374
 
@@ -424,6 +450,7 @@ var DataMap = /*#__PURE__*/function () {
424
450
  this.instance.runHooks('afterCreateCol', newVisualColumnIndex, numberOfCreatedCols, source);
425
451
  this.instance.forceFullRender = true; // used when data was changed
426
452
 
453
+ this.refreshDuckSchema();
427
454
  return {
428
455
  delta: numberOfCreatedCols,
429
456
  startPhysicalIndex: startPhysicalIndex
@@ -536,6 +563,7 @@ var DataMap = /*#__PURE__*/function () {
536
563
  this.instance.runHooks('afterRemoveCol', columnIndex, amount, logicColumns, source);
537
564
  this.instance.forceFullRender = true; // used when data was changed
538
565
 
566
+ this.refreshDuckSchema();
539
567
  return true;
540
568
  }
541
569
 
@@ -100,7 +100,7 @@ var DataMap = /*#__PURE__*/function () {
100
100
  *
101
101
  * @type {object}
102
102
  */
103
- this.duckSchema = this.dataSource && this.dataSource[0] ? duckSchema(this.dataSource[0]) : {};
103
+ this.duckSchema = this.createDuckSchema();
104
104
  /**
105
105
  * Cached array of properties to columns.
106
106
  *
@@ -271,6 +271,26 @@ var DataMap = /*#__PURE__*/function () {
271
271
  return this.duckSchema;
272
272
  }
273
273
 
274
+ /**
275
+ * Creates the duck schema based on the current dataset.
276
+ *
277
+ * @returns {Array|object}
278
+ */
279
+ }, {
280
+ key: "createDuckSchema",
281
+ value: function createDuckSchema() {
282
+ return this.dataSource && this.dataSource[0] ? duckSchema(this.dataSource[0]) : {};
283
+ }
284
+
285
+ /**
286
+ * Refresh the data schema.
287
+ */
288
+ }, {
289
+ key: "refreshDuckSchema",
290
+ value: function refreshDuckSchema() {
291
+ this.duckSchema = this.createDuckSchema();
292
+ }
293
+
274
294
  /**
275
295
  * Creates row at the bottom of the data array.
276
296
  *
@@ -306,7 +326,7 @@ var DataMap = /*#__PURE__*/function () {
306
326
  return 0;
307
327
  }
308
328
  var maxRows = this.tableMeta.maxRows;
309
- var columnCount = this.instance.countCols();
329
+ var columnCount = this.getSchema().length;
310
330
  var rowsToAdd = [];
311
331
  var _loop = function _loop() {
312
332
  var row = null;
@@ -339,6 +359,12 @@ var DataMap = /*#__PURE__*/function () {
339
359
  }
340
360
  this.spliceData(physicalRowIndex, 0, rowsToAdd);
341
361
  var newVisualRowIndex = this.instance.toVisualRow(physicalRowIndex);
362
+
363
+ // In case the created rows are the only ones in the table, the column index mappers need to be rebuilt based on
364
+ // the number of columns created in the row or the schema.
365
+ if (this.instance.countSourceRows() === rowsToAdd.length) {
366
+ this.instance.columnIndexMapper.initToLength(this.instance.getInitialColumnCount());
367
+ }
342
368
  this.instance.runHooks('afterCreateRow', newVisualRowIndex, numberOfCreatedRows, source);
343
369
  this.instance.forceFullRender = true; // used when data was changed
344
370
 
@@ -420,6 +446,7 @@ var DataMap = /*#__PURE__*/function () {
420
446
  this.instance.runHooks('afterCreateCol', newVisualColumnIndex, numberOfCreatedCols, source);
421
447
  this.instance.forceFullRender = true; // used when data was changed
422
448
 
449
+ this.refreshDuckSchema();
423
450
  return {
424
451
  delta: numberOfCreatedCols,
425
452
  startPhysicalIndex: startPhysicalIndex
@@ -532,6 +559,7 @@ var DataMap = /*#__PURE__*/function () {
532
559
  this.instance.runHooks('afterRemoveCol', columnIndex, amount, logicColumns, source);
533
560
  this.instance.forceFullRender = true; // used when data was changed
534
561
 
562
+ this.refreshDuckSchema();
535
563
  return true;
536
564
  }
537
565
 
@@ -25,8 +25,8 @@
25
25
  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM
26
26
  * USE OR INABILITY TO USE THIS SOFTWARE.
27
27
  *
28
- * Version: 0.0.0-next-6812ce6-20221122
29
- * Release date: 25/10/2022 (built at 22/11/2022 14:32:06)
28
+ * Version: 0.0.0-next-1b1acbd-20221123
29
+ * Release date: 25/10/2022 (built at 23/11/2022 12:56:32)
30
30
  */
31
31
  /**
32
32
  * Fix for bootstrap styles
@@ -25,8 +25,8 @@
25
25
  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM
26
26
  * USE OR INABILITY TO USE THIS SOFTWARE.
27
27
  *
28
- * Version: 0.0.0-next-6812ce6-20221122
29
- * Release date: 25/10/2022 (built at 22/11/2022 14:32:06)
28
+ * Version: 0.0.0-next-1b1acbd-20221123
29
+ * Release date: 25/10/2022 (built at 23/11/2022 12:56:32)
30
30
  */
31
31
  /**
32
32
  * Fix for bootstrap styles