@handsontable/vue3 18.1.2 → 19.0.0-rc2

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.
@@ -112,6 +112,29 @@ function _unsupportedIterableToArray(r, a) {
112
112
 
113
113
  var unassignedPropSymbol = Symbol('unassigned');
114
114
 
115
+ /**
116
+ * The shape `defineComponent()` reads the prop types from, with one entry per option of `Settings`. `type`
117
+ * exists only for the type checker: the runtime schema built by `propFactory()` carries none, so Vue
118
+ * neither validates nor casts a prop.
119
+ *
120
+ * `RemoveIndexSignature` drops the index signature of `Settings`. Left in, it becomes an index signature of
121
+ * the props, and Vue types every prop as `any` again. The mapping also drops `afterChangesObserved`: the
122
+ * settings types list that hook, but core neither registers nor fires it, so a prop for it could never work.
123
+ * `SettingsProp` is what the `settings` prop takes.
124
+ */
125
+
126
+ /**
127
+ * `HotColumn` takes column settings, not grid settings: its `data` is a property name or a getter, where the
128
+ * grid's `data` is an array of rows. Hooks run from the grid-level settings only, and core reads `getValue`
129
+ * from the table meta only, so neither is a prop of a column. The `settings` prop also takes a grid settings
130
+ * object, as it did when every prop was `any`: such an object has no `data` that would clash.
131
+ */
132
+
133
+ /**
134
+ * `HotTable` takes the settings `updateSettings()` takes: a hook prop may be `null`, which removes the
135
+ * callback the earlier props passed for it.
136
+ */
137
+
115
138
  /**
116
139
  * Message for the warning thrown if the Handsontable instance has been destroyed.
117
140
  */
@@ -134,6 +157,13 @@ function hasOwnProperty(object, key) {
134
157
  * @param {string} source Source for the factory (either 'HotTable' or 'HotColumn').
135
158
  * @returns {object}
136
159
  */
160
+
161
+ /**
162
+ * Implementation of the overloads above.
163
+ *
164
+ * @param {string} source Source for the factory (either 'HotTable' or 'HotColumn').
165
+ * @returns {object}
166
+ */
137
167
  function propFactory(source) {
138
168
  var registeredHooks = Handsontable__default["default"].hooks.getRegistered();
139
169
  var propSchema = {};
@@ -150,18 +180,43 @@ function propFactory(source) {
150
180
  "default": unassignedPropSymbol
151
181
  };
152
182
  }
183
+
184
+ // Documented options that have no entry in `DefaultSettings`, so the loops above never reach them.
185
+ propSchema.handsontable = {
186
+ "default": unassignedPropSymbol
187
+ };
153
188
  propSchema.settings = {
154
189
  "default": unassignedPropSymbol
155
190
  };
156
191
  if (source === 'HotTable') {
192
+ // Core reads `getValue` from the table meta only, so a column has no use for it.
193
+ propSchema.getValue = {
194
+ "default": unassignedPropSymbol
195
+ };
157
196
  propSchema.id = {
158
- type: String,
159
- "default": "hot-".concat(Math.random().toString(36).substring(5))
197
+ type: String
160
198
  };
161
199
  }
200
+
201
+ // The schema is filled at runtime from `DefaultSettings`, the registered hooks, and the options named
202
+ // above, which is why it is built loosely and typed here, from `SettingsUpdate` and `ColumnSettings`, for the template type checker.
162
203
  return propSchema;
163
204
  }
164
205
 
206
+ /**
207
+ * Generate a random id for the `HotTable` container. It has to be created on the client only: an id
208
+ * generated on the server never matches the one the browser generates while hydrating.
209
+ *
210
+ * @returns {string} The container id.
211
+ */
212
+ function generateContainerId() {
213
+ var buffer = new Uint16Array(3);
214
+ globalThis.crypto.getRandomValues(buffer);
215
+ return "hot-".concat(Array.from(buffer, function (value) {
216
+ return value.toString(16).padStart(4, '0');
217
+ }).join(''));
218
+ }
219
+
165
220
  /**
166
221
  * Filter out all of the unassigned props, and return only the one passed to the component.
167
222
  *
@@ -189,36 +244,329 @@ function filterPassedProps(props) {
189
244
  return filteredProps;
190
245
  }
191
246
 
247
+ /**
248
+ * List the hooks the props pass a callback for, directly or through the `settings` prop. A key counts as
249
+ * a hook by the rule core's `updateSettings()` uses in `core.ts`: a registered or a deprecated hook name.
250
+ * Only a function or an array of them counts as a callback: core ignores any other value, so a hook prop
251
+ * that holds `false` (`:afterChange="on && logChange"`) is treated as removed.
252
+ *
253
+ * @param {HotTableProps} props The props passed to the component.
254
+ * @returns {string[]} The hook names.
255
+ */
256
+ function getPassedHookKeys(props) {
257
+ var passedProps = filterPassedProps(props);
258
+ return Object.keys(passedProps).filter(function (key) {
259
+ return (typeof passedProps[key] === 'function' || Array.isArray(passedProps[key])) && (Handsontable__default["default"].hooks.isRegistered(key) || Handsontable__default["default"].hooks.isDeprecated(key));
260
+ });
261
+ }
262
+
263
+ /**
264
+ * What the wrapper last knew about a setting: the prop value it synced, a copy of its content, and the value the
265
+ * grid held right after. The copy is needed because core edits an array it was given in place (`alter()` splices
266
+ * `colHeaders`), so the prop itself no longer shows what was synced.
267
+ */
268
+
269
+ /**
270
+ * Check if a value is a plain object, one made by an object literal or with no prototype. A class instance is not.
271
+ *
272
+ * @param {unknown} value The value to check.
273
+ * @returns {boolean}
274
+ */
275
+ function isLiteralObject(value) {
276
+ if (Object.prototype.toString.call(value) !== '[object Object]') {
277
+ return false;
278
+ }
279
+ var prototype = Object.getPrototypeOf(value);
280
+ return prototype === Object.prototype || prototype === null;
281
+ }
282
+
283
+ /**
284
+ * Copy the plain objects and arrays of a settings value, and keep every other value (functions, class instances)
285
+ * by reference. The copy is what the next change is compared with, so a value the app edits in place reads as
286
+ * changed. Reactive proxies are unwrapped, and a value with a cycle is copied with the same cycle.
287
+ *
288
+ * @param {unknown} value The value to copy.
289
+ * @param {WeakMap<object, unknown>} [copies] The copies made so far, by original.
290
+ * @returns {unknown} The copy.
291
+ */
292
+ function copySettingsValue(value) {
293
+ var copies = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
294
+ var raw = vue.toRaw(value);
295
+ if (!Array.isArray(raw) && !isLiteralObject(raw)) {
296
+ return raw;
297
+ }
298
+ if (copies.has(raw)) {
299
+ return copies.get(raw);
300
+ }
301
+ if (Array.isArray(raw)) {
302
+ var arrayCopy = [];
303
+ copies.set(raw, arrayCopy);
304
+ raw.forEach(function (item) {
305
+ arrayCopy.push(copySettingsValue(item, copies));
306
+ });
307
+ return arrayCopy;
308
+ }
309
+ var objectCopy = {};
310
+ copies.set(raw, objectCopy);
311
+ Object.keys(raw).forEach(function (key) {
312
+ objectCopy[key] = copySettingsValue(raw[key], copies);
313
+ });
314
+ return objectCopy;
315
+ }
316
+
317
+ /**
318
+ * Compare a copy made by `copySettingsValue()` with a value: plain objects and arrays by content, a `RegExp` by
319
+ * its source and flags, anything else by reference. A pair already being compared higher up reads as equal,
320
+ * so a value with a cycle ends.
321
+ *
322
+ * @param {unknown} copied The copy.
323
+ * @param {unknown} value The value to compare it with.
324
+ * @param {WeakMap<object, WeakSet<object>>} [visited] The object pairs on the current comparison path.
325
+ * @returns {boolean} `true` if they hold the same content.
326
+ */
327
+ function isSameAsCopy(copied, value) {
328
+ var visited = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new WeakMap();
329
+ var raw = vue.toRaw(value);
330
+ if (copied === raw) {
331
+ return true;
332
+ }
333
+ if (copied instanceof RegExp || raw instanceof RegExp) {
334
+ return copied instanceof RegExp && raw instanceof RegExp && copied.source === raw.source && copied.flags === raw.flags;
335
+ }
336
+ var bothArrays = Array.isArray(copied) && Array.isArray(raw);
337
+ if (!bothArrays && !(isLiteralObject(copied) && isLiteralObject(raw))) {
338
+ return false;
339
+ }
340
+ var copiedObject = copied;
341
+ var rawObject = raw;
342
+ var comparedWith = visited.get(copiedObject);
343
+ if (comparedWith !== null && comparedWith !== void 0 && comparedWith.has(rawObject)) {
344
+ return true;
345
+ }
346
+ if (comparedWith) {
347
+ comparedWith.add(rawObject);
348
+ } else {
349
+ visited.set(copiedObject, new WeakSet([rawObject]));
350
+ }
351
+ var keys = Object.keys(copiedObject);
352
+ return keys.length === Object.keys(rawObject).length && keys.every(function (key) {
353
+ return hasOwnProperty(rawObject, key) && isSameAsCopy(copiedObject[key], rawObject[key], visited);
354
+ });
355
+ }
356
+
357
+ /**
358
+ * The settings by name, as `SettingBaseline`s. `HotTable` keeps one per instance.
359
+ */
360
+
361
+ /**
362
+ * Settings the baseline rule leaves alone. The sizes are re-sent whenever they differ from the grid's value,
363
+ * because the user can change them by dragging and the prop re-declares them (the React wrapper does the
364
+ * same). `data` has its own path in `HotTable`, and a baseline would keep the previous array alive.
365
+ */
366
+ var BASELINE_EXEMPT_KEYS = ['data', 'colWidths', 'rowHeights', 'minRowHeights', 'themeName'];
367
+
368
+ /**
369
+ * Settings whose baseline holds the reference only, with no copy of the content. `sheetsBar` carries every sheet's
370
+ * `data`, which a copy on each reactive change would walk again (`isEqualSetting()` avoids the same walk).
371
+ */
372
+ var REFERENCE_ONLY_KEYS = ['sheetsBar'];
373
+
374
+ /**
375
+ * Check if the app replaced the value of a setting through the instance (`hot.updateSettings()`) since the
376
+ * wrapper last synced the prop, while the prop itself stayed the same. Such a prop is not sent again: it did
377
+ * not change, and sending it would take back what the app set.
378
+ *
379
+ * @param {string} key The setting name.
380
+ * @param {unknown} propValue The value passed through the props.
381
+ * @param {Handsontable.GridSettings} currentSettings The grid's current settings.
382
+ * @param {SettingBaselines} [baselines] What the wrapper last synced.
383
+ * @returns {boolean} `true` if the app overrode the setting.
384
+ */
385
+ function isOverriddenByApp(key, propValue, currentSettings, baselines) {
386
+ var baseline = baselines === null || baselines === void 0 ? void 0 : baselines[key];
387
+
388
+ // The cheap check goes first: the content compare runs only for a setting the app replaced.
389
+ return !!currentSettings && !!baseline && !BASELINE_EXEMPT_KEYS.includes(key) && !Object.is(currentSettings[key], baseline.live) && (isSameReference(baseline.prop, propValue) || !REFERENCE_ONLY_KEYS.includes(key) && isSameAsCopy(baseline.copy, propValue));
390
+ }
391
+
392
+ /**
393
+ * Record the props the wrapper has just synced with the grid, for the next change to compare with. A setting the
394
+ * app overrode (`overriddenKeys`) keeps its previous baseline, so the override outlives the next changes and
395
+ * is given up only when the prop itself changes.
396
+ *
397
+ * @param {SettingBaselines} baselines What the wrapper last synced. It is updated in place.
398
+ * @param {HotTableProps} props The props passed to the component.
399
+ * @param {Handsontable.GridSettings} currentSettings The grid's current settings.
400
+ * @param {string[]} [overriddenKeys] The settings `prepareSettings()` left out because the app overrode them.
401
+ */
402
+ function recordSettingBaselines(baselines, props, currentSettings) {
403
+ var overriddenKeys = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
404
+ var passedProps = filterPassedProps(props);
405
+ Object.keys(baselines).forEach(function (key) {
406
+ if (!hasOwnProperty(passedProps, key)) {
407
+ delete baselines[key];
408
+ }
409
+ });
410
+ Object.keys(passedProps).forEach(function (key) {
411
+ if (!overriddenKeys.includes(key) && !BASELINE_EXEMPT_KEYS.includes(key)) {
412
+ baselines[key] = {
413
+ prop: vue.toRaw(passedProps[key]),
414
+ copy: REFERENCE_ONLY_KEYS.includes(key) ? undefined : copySettingsValue(passedProps[key]),
415
+ live: currentSettings[key]
416
+ };
417
+ }
418
+ });
419
+ }
420
+
192
421
  /**
193
422
  * Prepare the settings object to be used as the settings for Handsontable, based on the props provided to the component.
194
423
  *
424
+ * A hook listed in `previousHookKeys` that the props no longer pass a callback for (the prop is removed or
425
+ * `undefined`) is sent as `null`, which removes the callback the props registered.
426
+ *
427
+ * A prop that is the same value the wrapper last synced (`baselines`) is left out when the grid's value for it
428
+ * was replaced since, through `hot.updateSettings()`: the app's value stays until the prop changes.
429
+ *
195
430
  * @param {HotTableProps} props The props passed to the component.
196
431
  * @param {Handsontable.GridSettings} currentSettings The current Handsontable settings.
432
+ * @param {string[]} previousHookKeys The hooks the previous props passed a callback for.
433
+ * @param {SettingBaselines} [baselines] What the wrapper last synced.
434
+ * @param {string[]} [overriddenKeys] Receives the names of the props left out because the app overrode them.
197
435
  * @returns {Handsontable.GridSettings} An object containing the properties, ready to be used within Handsontable.
198
436
  */
199
437
  function prepareSettings(props, currentSettings) {
438
+ var previousHookKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
439
+ var baselines = arguments.length > 3 ? arguments[3] : undefined;
440
+ var overriddenKeys = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
200
441
  var assignedProps = filterPassedProps(props);
201
442
  var hotSettingsInProps = props.settings ? props.settings : assignedProps;
202
443
  var additionalHotSettingsInProps = props.settings ? assignedProps : null;
203
444
  var initOnlySettingKeys = (currentSettings === null || currentSettings === void 0 ? void 0 : currentSettings._initOnlySettings) || [];
204
445
  var newSettings = {};
446
+ var isOverridden = function isOverridden(key, value) {
447
+ // A direct prop wins over the same key in the `settings` prop, and the baseline holds the winner.
448
+ var effectiveValue = hasOwnProperty(assignedProps, key) ? assignedProps[key] : value;
449
+ var overridden = isOverriddenByApp(key, effectiveValue, currentSettings, baselines);
450
+ if (overridden && !overriddenKeys.includes(key)) {
451
+ overriddenKeys.push(key);
452
+ }
453
+ return overridden;
454
+ };
205
455
 
206
456
  // eslint-disable-next-line no-restricted-syntax
207
457
  for (var key in hotSettingsInProps) {
208
- if (hasOwnProperty(hotSettingsInProps, key) && hotSettingsInProps[key] !== void 0 && !initOnlySettingKeys.includes(key) && (currentSettings && key !== 'data' ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)) {
458
+ if (hasOwnProperty(hotSettingsInProps, key) && hotSettingsInProps[key] !== undefined && !initOnlySettingKeys.includes(key) && !isOverridden(key, hotSettingsInProps[key]) && (currentSettings && key !== 'data' ? !isEqualSetting(key, currentSettings[key], hotSettingsInProps[key], currentSettings) : true)) {
209
459
  newSettings[key] = hotSettingsInProps[key];
210
460
  }
211
461
  }
212
462
 
213
463
  // eslint-disable-next-line no-restricted-syntax
214
464
  for (var _key in additionalHotSettingsInProps) {
215
- if (hasOwnProperty(additionalHotSettingsInProps, _key) && _key !== 'id' && _key !== 'settings' && additionalHotSettingsInProps[_key] !== void 0 && !initOnlySettingKeys.includes(_key) && (currentSettings && _key !== 'data' ? !simpleEqual(currentSettings[_key], additionalHotSettingsInProps[_key]) : true)) {
465
+ if (hasOwnProperty(additionalHotSettingsInProps, _key) && _key !== 'id' && _key !== 'settings' && additionalHotSettingsInProps[_key] !== undefined && !initOnlySettingKeys.includes(_key) && !isOverridden(_key, additionalHotSettingsInProps[_key]) && (currentSettings && _key !== 'data' ? !isEqualSetting(_key, currentSettings[_key], additionalHotSettingsInProps[_key], currentSettings) : true)) {
216
466
  newSettings[_key] = additionalHotSettingsInProps[_key];
217
467
  }
218
468
  }
469
+ if (previousHookKeys.length > 0) {
470
+ var passedHookKeys = getPassedHookKeys(props);
471
+ previousHookKeys.forEach(function (key) {
472
+ if (!passedHookKeys.includes(key)) {
473
+ newSettings[key] = null;
474
+ }
475
+ });
476
+ }
219
477
  return newSettings;
220
478
  }
221
479
 
480
+ /**
481
+ * Compare the grid's current value of a setting with the value passed through the props.
482
+ *
483
+ * `sheetsBar` is compared key by key: a template writes it as an object literal
484
+ * (`:sheetsBar="{ sheets }"`), which is a new object on every render, while the sheets it holds keep
485
+ * every sheet's data, which must not be serialized on each change. The `sheets` array is compared by
486
+ * reference, and an option given as an object literal (`animation: { switch: false }`) by the
487
+ * references of its own keys. A new `sheets` array or a changed option in a new `sheetsBar` object is
488
+ * therefore sent, even when it differs only by a function. A change made inside the same `sheetsBar`
489
+ * object or the same `sheets` array is not sent, and neither are the plugin's own writes into that
490
+ * array. `themeName` is compared with the grid's `theme`, because core moves the name there and
491
+ * `getSettings().themeName` stays `undefined`. Every other setting is compared with `simpleEqual()`.
492
+ *
493
+ * @param {string} key The setting name.
494
+ * @param {unknown} currentValue The grid's current value.
495
+ * @param {unknown} newValue The value passed through the props.
496
+ * @param {Handsontable.GridSettings} currentSettings The grid's current settings.
497
+ * @returns {boolean} `true` if the value does not need to be sent.
498
+ */
499
+ function isEqualSetting(key, currentValue, newValue, currentSettings) {
500
+ if (key === 'sheetsBar') {
501
+ return haveEqualOwnKeys(currentValue, newValue, function (propName, valueA, valueB) {
502
+ return propName === 'sheets' ? isSameReference(valueA, valueB) : isShallowEqualByReference(valueA, valueB);
503
+ });
504
+ }
505
+ if (key === 'themeName' && currentValue === undefined) {
506
+ return typeof newValue === 'string' && currentSettings.theme === newValue;
507
+ }
508
+ return simpleEqual(currentValue, newValue);
509
+ }
510
+
511
+ /**
512
+ * Compare two values by reference, and two plain objects by the references of their own keys.
513
+ *
514
+ * @param {unknown} valueA First value to compare.
515
+ * @param {unknown} valueB Second value to compare.
516
+ * @returns {boolean} `true` if they're the same, `false` otherwise.
517
+ */
518
+ function isShallowEqualByReference(valueA, valueB) {
519
+ return haveEqualOwnKeys(valueA, valueB, function (propName, keyValueA, keyValueB) {
520
+ return isSameReference(keyValueA, keyValueB);
521
+ });
522
+ }
523
+
524
+ /**
525
+ * Compare two values by reference, or, when both are plain objects, compare their own keys with the
526
+ * given function. Reactive proxies are compared by their raw objects.
527
+ *
528
+ * @param {unknown} valueA First value to compare.
529
+ * @param {unknown} valueB Second value to compare.
530
+ * @param {Function} isEqualValue Compares the values both objects hold under one key.
531
+ * @returns {boolean} `true` if they're the same, `false` otherwise.
532
+ */
533
+ function haveEqualOwnKeys(valueA, valueB, isEqualValue) {
534
+ var rawA = vue.toRaw(valueA);
535
+ var rawB = vue.toRaw(valueB);
536
+ if (rawA === rawB) {
537
+ return true;
538
+ }
539
+ if (!isPlainObject(rawA) || !isPlainObject(rawB)) {
540
+ return false;
541
+ }
542
+ var keysA = Object.keys(rawA);
543
+ var keysB = Object.keys(rawB);
544
+ return keysA.length === keysB.length && keysA.every(function (propName) {
545
+ return hasOwnProperty(rawB, propName) && isEqualValue(propName, rawA[propName], rawB[propName]);
546
+ });
547
+ }
548
+
549
+ /**
550
+ * Compare two values by reference, with reactive proxies compared by their raw objects.
551
+ *
552
+ * @param {unknown} valueA First value to compare.
553
+ * @param {unknown} valueB Second value to compare.
554
+ * @returns {boolean} `true` if they're the same, `false` otherwise.
555
+ */
556
+ function isSameReference(valueA, valueB) {
557
+ return vue.toRaw(valueA) === vue.toRaw(valueB);
558
+ }
559
+
560
+ /**
561
+ * Check if a value is a plain object.
562
+ *
563
+ * @param {unknown} value The value to check.
564
+ * @returns {boolean}
565
+ */
566
+ function isPlainObject(value) {
567
+ return Object.prototype.toString.call(value) === '[object Object]';
568
+ }
569
+
222
570
  /**
223
571
  * Compare two objects using `JSON.stringify`.
224
572
  * *Note: * As it's using the stringify function to compare objects, the property order in both objects is
@@ -275,7 +623,7 @@ function simpleEqual(objectA, objectB) {
275
623
  }
276
624
  }
277
625
 
278
- var version="18.1.2";
626
+ var version="19.0.0-rc2";
279
627
 
280
628
  var HotTable = vue.defineComponent({
281
629
  name: 'HotTable',
@@ -287,13 +635,33 @@ var HotTable = vue.defineComponent({
287
635
  };
288
636
  },
289
637
  watch: {
638
+ // Vue removes the attribute when `id` is cleared, so put the generated one back after the patch.
639
+ id: {
640
+ handler: function handler(id) {
641
+ if (!id) {
642
+ this.$el.id = this.getGeneratedId();
643
+ }
644
+ },
645
+ flush: 'post'
646
+ },
290
647
  $props: {
291
648
  handler: function handler(props) {
292
- var settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);
293
- if (!this.hotInstance || settings === void 0) {
649
+ var overriddenKeys = [];
650
+ var settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : undefined, this.miscCache.hookKeys, this.miscCache.baselines, overriddenKeys);
651
+ if (!this.hotInstance || settings === undefined) {
294
652
  return;
295
653
  }
296
- if (settings.data) {
654
+ this.miscCache.hookKeys = getPassedHookKeys(props);
655
+ var hasData = settings.data !== undefined;
656
+ var incomingData = hasData ? vue.toRaw(settings.data) : undefined;
657
+ var isNewData = hasData && incomingData !== this.miscCache.lastData.value;
658
+
659
+ // A new array replaces the grid's data: `updateSettings()` runs core's `updateData()`, which fits the
660
+ // index mappers to the new length and keeps their state, unless the same payload changes the column layout.
661
+ if (hasData && !isNewData && incomingData === null) {
662
+ // The prop was already cleared: sending `null` again would reset the grid on every later change.
663
+ delete settings.data;
664
+ } else if (settings.data && !isNewData) {
297
665
  if (this.hotInstance.isColumnModificationAllowed() || !this.hotInstance.isColumnModificationAllowed() && this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns) {
298
666
  // If the dataset dimensions change, update the index mappers.
299
667
  this.matchHotMappersSize();
@@ -303,6 +671,12 @@ var HotTable = vue.defineComponent({
303
671
  }
304
672
  }
305
673
 
674
+ // Recorded before the update: core holds the array as soon as `updateSettings()` starts, so a hook that
675
+ // throws must not leave the old one here, or every later in-place edit would reload the data.
676
+ if (hasData) {
677
+ this.miscCache.lastData.value = incomingData;
678
+ }
679
+
306
680
  // If there are another options changed, update the HOT settings, render the table otherwise.
307
681
  if (Object.keys(settings).length) {
308
682
  this.hotInstance.updateSettings(settings);
@@ -310,6 +684,7 @@ var HotTable = vue.defineComponent({
310
684
  this.hotInstance.render();
311
685
  }
312
686
  this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();
687
+ recordSettingBaselines(this.miscCache.baselines, props, this.hotInstance.getSettings(), overriddenKeys);
313
688
  },
314
689
  deep: true,
315
690
  immediate: true
@@ -321,7 +696,16 @@ var HotTable = vue.defineComponent({
321
696
  __hotInstance: null,
322
697
  /* eslint-enable vue/no-reserved-keys */
323
698
  miscCache: {
324
- currentSourceColumns: null
699
+ currentSourceColumns: null,
700
+ generatedId: '',
701
+ hookKeys: [],
702
+ // Holds the grid's own values, so it must not be wrapped in a proxy: the compare is by identity.
703
+ baselines: vue.markRaw({}),
704
+ // The `data` array the grid was last given by the props, compared by identity to tell a new array
705
+ // from an in-place edit. Wrapped in a raw holder so Vue does not proxy the app's array.
706
+ lastData: vue.markRaw({
707
+ value: undefined
708
+ })
325
709
  },
326
710
  columnSettings: null,
327
711
  columnsCache: new Map(),
@@ -342,6 +726,17 @@ var HotTable = vue.defineComponent({
342
726
  };
343
727
  },
344
728
  methods: {
729
+ /**
730
+ * Get the id used when the `id` prop is not passed. It is created once per instance.
731
+ *
732
+ * @returns {string} The generated container id.
733
+ */
734
+ getGeneratedId: function getGeneratedId() {
735
+ if (!this.miscCache.generatedId) {
736
+ this.miscCache.generatedId = generateContainerId();
737
+ }
738
+ return this.miscCache.generatedId;
739
+ },
345
740
  /**
346
741
  * Initialize Handsontable.
347
742
  */
@@ -349,8 +744,13 @@ var HotTable = vue.defineComponent({
349
744
  var newSettings = prepareSettings(this.$props);
350
745
  newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;
351
746
  this.hotInstance = vue.markRaw(new Handsontable__default["default"].Core(this.$el, newSettings));
747
+
748
+ // Recorded before `init()`, so a value the app sets in `afterInit` counts as an override of the prop.
749
+ recordSettingBaselines(this.miscCache.baselines, this.$props, this.hotInstance.getSettings());
352
750
  this.hotInstance.init();
353
751
  this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();
752
+ this.miscCache.hookKeys = getPassedHookKeys(this.$props);
753
+ this.miscCache.lastData.value = vue.toRaw(newSettings.data);
354
754
  },
355
755
  matchHotMappersSize: function matchHotMappersSize() {
356
756
  var _this = this;
@@ -434,7 +834,7 @@ var HotTable = vue.defineComponent({
434
834
  columnSettings = _ref6[1];
435
835
  return columnSettings;
436
836
  });
437
- return orderedColumns.length ? orderedColumns : void 0;
837
+ return orderedColumns.length ? orderedColumns : undefined;
438
838
  },
439
839
  /**
440
840
  * Re-read the column settings declared by `hot-column` children and push them
@@ -468,12 +868,18 @@ var HotTable = vue.defineComponent({
468
868
  }
469
869
  _this2.columnSettings = newColumnSettings || null;
470
870
  _this2.hotInstance.updateSettings({
471
- columns: newColumnSettings || void 0
871
+ columns: newColumnSettings || undefined
472
872
  });
473
873
  });
474
874
  }
475
875
  },
476
876
  mounted: function mounted() {
877
+ // The auto-generated id is set here, on the client only, and not through a prop default or reactive
878
+ // data: an id created on the server never matches the browser's, which breaks hydration, and a
879
+ // reactive id would re-render every `HotTable` right after mounting.
880
+ if (!this.id) {
881
+ this.$el.id = this.getGeneratedId();
882
+ }
477
883
  this.columnSettings = this.getColumnSettings();
478
884
  this.hotInit();
479
885
  },