@handsontable/vue3 18.0.0 → 18.1.0-rc7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +1 -1
- package/README.md +2 -2
- package/commonjs/vue-handsontable.js +147 -9
- package/dist/vue-handsontable.js +149 -11
- package/dist/vue-handsontable.js.map +1 -1
- package/dist/vue-handsontable.min.js +3 -3
- package/dist/vue-handsontable.min.js.map +1 -1
- package/es/vue-handsontable.mjs +148 -10
- package/handsontable-non-commercial-license.pdf +0 -0
- package/package.json +1 -1
package/LICENSE.txt
CHANGED
|
@@ -2,7 +2,7 @@ Copyright (c) HANDSONCODE sp. z o. o.
|
|
|
2
2
|
|
|
3
3
|
HANDSONTABLE is a software distributed by HANDSONCODE sp. z o. o., a Polish corporation based in
|
|
4
4
|
Gdynia, Poland, at Aleja Zwyciestwa 96-98, registered by the District Court in Gdansk under number
|
|
5
|
-
538651, EU tax ID number: PL5862294002, share capital: PLN
|
|
5
|
+
538651, EU tax ID number: PL5862294002, share capital: PLN 67,200.00.
|
|
6
6
|
|
|
7
7
|
This software is protected by applicable copyright laws, including international treaties, and dual-
|
|
8
8
|
licensed - depending on whether your use for commercial purposes, meaning intended for or
|
package/README.md
CHANGED
|
@@ -130,7 +130,7 @@ Use this data grid as you would any other component in your application. [Option
|
|
|
130
130
|
</script>
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
-
[](https://handsontable.com
|
|
133
|
+
[](https://demos.handsontable.com/?example=vue)
|
|
134
134
|
|
|
135
135
|
</div>
|
|
136
136
|
|
|
@@ -231,7 +231,7 @@ If you're using Handsontable in a project that supports commercial activities, y
|
|
|
231
231
|
|
|
232
232
|
## 🙌 Contributing
|
|
233
233
|
|
|
234
|
-
Contributions are welcome, but before you make them, please read the [Contributing Guide](https://github.com/handsontable/handsontable/blob/develop/CONTRIBUTING.md) and accept the [Contributor License Agreement](https://
|
|
234
|
+
Contributions are welcome, but before you make them, please read the [Contributing Guide](https://github.com/handsontable/handsontable/blob/develop/CONTRIBUTING.md) and accept the [Contributor License Agreement](https://cla.handsontable.com/sign).
|
|
235
235
|
|
|
236
236
|
<br>
|
|
237
237
|
<br>
|
|
@@ -9,6 +9,14 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
|
|
10
10
|
var Handsontable__default = /*#__PURE__*/_interopDefaultCompat(Handsontable);
|
|
11
11
|
|
|
12
|
+
function _arrayLikeToArray(r, a) {
|
|
13
|
+
(null == a || a > r.length) && (a = r.length);
|
|
14
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
15
|
+
return n;
|
|
16
|
+
}
|
|
17
|
+
function _arrayWithHoles(r) {
|
|
18
|
+
if (Array.isArray(r)) return r;
|
|
19
|
+
}
|
|
12
20
|
function _defineProperty(e, r, t) {
|
|
13
21
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
14
22
|
value: t,
|
|
@@ -17,6 +25,36 @@ function _defineProperty(e, r, t) {
|
|
|
17
25
|
writable: true
|
|
18
26
|
}) : e[r] = t, e;
|
|
19
27
|
}
|
|
28
|
+
function _iterableToArrayLimit(r, l) {
|
|
29
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
30
|
+
if (null != t) {
|
|
31
|
+
var e,
|
|
32
|
+
n,
|
|
33
|
+
i,
|
|
34
|
+
u,
|
|
35
|
+
a = [],
|
|
36
|
+
f = true,
|
|
37
|
+
o = false;
|
|
38
|
+
try {
|
|
39
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
40
|
+
if (Object(t) !== t) return;
|
|
41
|
+
f = !1;
|
|
42
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
43
|
+
} catch (r) {
|
|
44
|
+
o = true, n = r;
|
|
45
|
+
} finally {
|
|
46
|
+
try {
|
|
47
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
48
|
+
} finally {
|
|
49
|
+
if (o) throw n;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return a;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function _nonIterableRest() {
|
|
56
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
57
|
+
}
|
|
20
58
|
function ownKeys(e, r) {
|
|
21
59
|
var t = Object.keys(e);
|
|
22
60
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -38,6 +76,9 @@ function _objectSpread2(e) {
|
|
|
38
76
|
}
|
|
39
77
|
return e;
|
|
40
78
|
}
|
|
79
|
+
function _slicedToArray(r, e) {
|
|
80
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
81
|
+
}
|
|
41
82
|
function _toPrimitive(t, r) {
|
|
42
83
|
if ("object" != typeof t || !t) return t;
|
|
43
84
|
var e = t[Symbol.toPrimitive];
|
|
@@ -61,6 +102,13 @@ function _typeof(o) {
|
|
|
61
102
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
62
103
|
}, _typeof(o);
|
|
63
104
|
}
|
|
105
|
+
function _unsupportedIterableToArray(r, a) {
|
|
106
|
+
if (r) {
|
|
107
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
108
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
109
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
64
112
|
|
|
65
113
|
var unassignedPropSymbol = Symbol('unassigned');
|
|
66
114
|
|
|
@@ -227,16 +275,15 @@ function simpleEqual(objectA, objectB) {
|
|
|
227
275
|
}
|
|
228
276
|
}
|
|
229
277
|
|
|
230
|
-
var version="18.
|
|
278
|
+
var version="18.1.0-rc7";
|
|
231
279
|
|
|
232
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
233
|
-
// @ts-ignore
|
|
234
280
|
var HotTable = vue.defineComponent({
|
|
235
281
|
name: 'HotTable',
|
|
236
282
|
props: propFactory('HotTable'),
|
|
237
283
|
provide: function provide() {
|
|
238
284
|
return {
|
|
239
|
-
columnsCache: this.columnsCache
|
|
285
|
+
columnsCache: this.columnsCache,
|
|
286
|
+
refreshColumns: this.refreshColumns
|
|
240
287
|
};
|
|
241
288
|
},
|
|
242
289
|
watch: {
|
|
@@ -278,6 +325,7 @@ var HotTable = vue.defineComponent({
|
|
|
278
325
|
},
|
|
279
326
|
columnSettings: null,
|
|
280
327
|
columnsCache: new Map(),
|
|
328
|
+
columnsRefreshScheduled: false,
|
|
281
329
|
get hotInstance() {
|
|
282
330
|
if (!this.__hotInstance || this.__hotInstance && !this.__hotInstance.isDestroyed) {
|
|
283
331
|
// Will return the Handsontable instance or `null` if it's not yet been created.
|
|
@@ -351,17 +399,91 @@ var HotTable = vue.defineComponent({
|
|
|
351
399
|
/**
|
|
352
400
|
* Get settings for the columns provided in the `hot-column` components.
|
|
353
401
|
*
|
|
402
|
+
* The columns are ordered by the document position of each `hot-column`'s
|
|
403
|
+
* anchor node, not by the `columnsCache` insertion order. This keeps the
|
|
404
|
+
* order correct when columns are inserted in the middle, removed, or
|
|
405
|
+
* reordered, and when a `hot-column` is nested inside a wrapper component.
|
|
406
|
+
*
|
|
354
407
|
* @returns {HotTableProps[] | undefined}
|
|
355
408
|
*/
|
|
356
409
|
getColumnSettings: function getColumnSettings() {
|
|
357
|
-
var
|
|
358
|
-
|
|
410
|
+
var orderedColumns = Array.from(this.columnsCache.entries()).sort(function (_ref, _ref2) {
|
|
411
|
+
var _ref3 = _slicedToArray(_ref, 1),
|
|
412
|
+
columnA = _ref3[0];
|
|
413
|
+
var _ref4 = _slicedToArray(_ref2, 1),
|
|
414
|
+
columnB = _ref4[0];
|
|
415
|
+
var anchorA = columnA.$el;
|
|
416
|
+
var anchorB = columnB.$el;
|
|
417
|
+
if (!anchorA || !anchorB) {
|
|
418
|
+
return 0;
|
|
419
|
+
}
|
|
420
|
+
var position = anchorA.compareDocumentPosition(anchorB);
|
|
421
|
+
|
|
422
|
+
// eslint-disable-next-line no-bitwise
|
|
423
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
424
|
+
return -1;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// eslint-disable-next-line no-bitwise
|
|
428
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
429
|
+
return 1;
|
|
430
|
+
}
|
|
431
|
+
return 0;
|
|
432
|
+
}).map(function (_ref5) {
|
|
433
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
434
|
+
columnSettings = _ref6[1];
|
|
435
|
+
return columnSettings;
|
|
436
|
+
});
|
|
437
|
+
return orderedColumns.length ? orderedColumns : void 0;
|
|
438
|
+
},
|
|
439
|
+
/**
|
|
440
|
+
* Re-read the column settings declared by `hot-column` children and push them
|
|
441
|
+
* to the Handsontable instance. Called by children on mount, prop change, and
|
|
442
|
+
* unmount, and by the parent on reorder. Multiple notifications in the same
|
|
443
|
+
* tick are coalesced into a single `updateSettings` call.
|
|
444
|
+
*/
|
|
445
|
+
refreshColumns: function refreshColumns() {
|
|
446
|
+
var _this2 = this;
|
|
447
|
+
if (this.columnsRefreshScheduled) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
this.columnsRefreshScheduled = true;
|
|
451
|
+
this.$nextTick(function () {
|
|
452
|
+
_this2.columnsRefreshScheduled = false;
|
|
453
|
+
if (!_this2.hotInstance) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
var newColumnSettings = _this2.getColumnSettings();
|
|
457
|
+
var previousColumnSettings = _this2.columnSettings;
|
|
458
|
+
|
|
459
|
+
// Each `hot-column` rebuilds its settings object whenever its props change,
|
|
460
|
+
// so an unchanged column keeps the same object reference. Comparing the
|
|
461
|
+
// arrays by reference and order is cheaper than a deep compare and avoids
|
|
462
|
+
// an `updateSettings` call on unrelated re-renders (e.g. data-only updates).
|
|
463
|
+
var isUnchanged = !previousColumnSettings && !newColumnSettings || !!previousColumnSettings && !!newColumnSettings && previousColumnSettings.length === newColumnSettings.length && previousColumnSettings.every(function (settings, index) {
|
|
464
|
+
return settings === newColumnSettings[index];
|
|
465
|
+
});
|
|
466
|
+
if (isUnchanged) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
_this2.columnSettings = newColumnSettings || null;
|
|
470
|
+
_this2.hotInstance.updateSettings({
|
|
471
|
+
columns: newColumnSettings || void 0
|
|
472
|
+
});
|
|
473
|
+
});
|
|
359
474
|
}
|
|
360
475
|
},
|
|
361
476
|
mounted: function mounted() {
|
|
362
477
|
this.columnSettings = this.getColumnSettings();
|
|
363
478
|
this.hotInit();
|
|
364
479
|
},
|
|
480
|
+
updated: function updated() {
|
|
481
|
+
// Reordering keyed `hot-column` children reuses their instances and fires no
|
|
482
|
+
// child lifecycle hook, so the children cannot notify on their own. The slot
|
|
483
|
+
// vnodes do change, which re-renders `HotTable` - refresh from here to cover
|
|
484
|
+
// reorders (coalesced with any child-triggered refresh).
|
|
485
|
+
this.refreshColumns();
|
|
486
|
+
},
|
|
365
487
|
beforeUnmount: function beforeUnmount() {
|
|
366
488
|
if (this.hotInstance) {
|
|
367
489
|
this.hotInstance.destroy();
|
|
@@ -377,7 +499,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
377
499
|
style: {
|
|
378
500
|
"height": "100%"
|
|
379
501
|
}
|
|
380
|
-
}, [vue.renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1);
|
|
502
|
+
}, [vue.createCommentVNode(" `hot-column` children render invisible comment anchors in source order.\n Handsontable appends its own DOM to this container without clearing\n pre-existing nodes, so the anchors survive; the parent reads their\n document position to order the columns. "), vue.renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1);
|
|
381
503
|
}
|
|
382
504
|
|
|
383
505
|
HotTable.render = render;
|
|
@@ -386,7 +508,7 @@ HotTable.__file = "src/HotTable.vue";
|
|
|
386
508
|
var HotColumn = vue.defineComponent({
|
|
387
509
|
name: 'HotColumn',
|
|
388
510
|
props: propFactory('HotColumn'),
|
|
389
|
-
inject: ['columnsCache'],
|
|
511
|
+
inject: ['columnsCache', 'refreshColumns'],
|
|
390
512
|
methods: {
|
|
391
513
|
/**
|
|
392
514
|
* Create the column settings based on the data provided to the `hot-column`
|
|
@@ -404,14 +526,30 @@ var HotColumn = vue.defineComponent({
|
|
|
404
526
|
this.columnsCache.set(this, columnSettings);
|
|
405
527
|
}
|
|
406
528
|
},
|
|
529
|
+
watch: {
|
|
530
|
+
$props: {
|
|
531
|
+
handler: function handler() {
|
|
532
|
+
this.createColumnSettings();
|
|
533
|
+
this.refreshColumns();
|
|
534
|
+
},
|
|
535
|
+
deep: true
|
|
536
|
+
}
|
|
537
|
+
},
|
|
407
538
|
mounted: function mounted() {
|
|
408
539
|
this.createColumnSettings();
|
|
540
|
+
this.refreshColumns();
|
|
409
541
|
},
|
|
410
542
|
unmounted: function unmounted() {
|
|
411
543
|
this.columnsCache["delete"](this);
|
|
544
|
+
this.refreshColumns();
|
|
412
545
|
},
|
|
413
546
|
render: function render() {
|
|
414
|
-
|
|
547
|
+
// Render an (invisible) comment anchor instead of nothing, so the parent
|
|
548
|
+
// `HotTable` can order columns by the anchors' document position. This keeps
|
|
549
|
+
// ordering correct for dynamic inserts, removals, and reorders - and works
|
|
550
|
+
// regardless of how deeply the `hot-column` is nested inside wrapper
|
|
551
|
+
// components - because `provide`/`inject` and the anchor both cross nesting.
|
|
552
|
+
return vue.createCommentVNode('hot-column');
|
|
415
553
|
}
|
|
416
554
|
});
|
|
417
555
|
|
package/dist/vue-handsontable.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* HANDSONTABLE is a software distributed by HANDSONCODE sp. z o. o., a Polish corporation based in
|
|
5
5
|
* Gdynia, Poland, at Aleja Zwyciestwa 96-98, registered by the District Court in Gdansk under number
|
|
6
|
-
* 538651, EU tax ID number: PL5862294002, share capital: PLN
|
|
6
|
+
* 538651, EU tax ID number: PL5862294002, share capital: PLN 67,200.00.
|
|
7
7
|
*
|
|
8
8
|
* This software is protected by applicable copyright laws, including international treaties, and dual-
|
|
9
9
|
* licensed - depending on whether your use for commercial purposes, meaning intended for or
|
|
@@ -25,7 +25,7 @@
|
|
|
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: 18.
|
|
28
|
+
* Version: 18.1.0-rc7 (built at Fri Aug 28 2026 07:03:29 GMT+0000 (Coordinated Universal Time))
|
|
29
29
|
*/
|
|
30
30
|
(function (global, factory) {
|
|
31
31
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('handsontable/base')) :
|
|
@@ -37,6 +37,14 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
37
37
|
|
|
38
38
|
var Handsontable__default = /*#__PURE__*/_interopDefaultCompat(Handsontable);
|
|
39
39
|
|
|
40
|
+
function _arrayLikeToArray(r, a) {
|
|
41
|
+
(null == a || a > r.length) && (a = r.length);
|
|
42
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
43
|
+
return n;
|
|
44
|
+
}
|
|
45
|
+
function _arrayWithHoles(r) {
|
|
46
|
+
if (Array.isArray(r)) return r;
|
|
47
|
+
}
|
|
40
48
|
function _defineProperty(e, r, t) {
|
|
41
49
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
50
|
value: t,
|
|
@@ -45,6 +53,36 @@ function _defineProperty(e, r, t) {
|
|
|
45
53
|
writable: true
|
|
46
54
|
}) : e[r] = t, e;
|
|
47
55
|
}
|
|
56
|
+
function _iterableToArrayLimit(r, l) {
|
|
57
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
58
|
+
if (null != t) {
|
|
59
|
+
var e,
|
|
60
|
+
n,
|
|
61
|
+
i,
|
|
62
|
+
u,
|
|
63
|
+
a = [],
|
|
64
|
+
f = true,
|
|
65
|
+
o = false;
|
|
66
|
+
try {
|
|
67
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
68
|
+
if (Object(t) !== t) return;
|
|
69
|
+
f = !1;
|
|
70
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
71
|
+
} catch (r) {
|
|
72
|
+
o = true, n = r;
|
|
73
|
+
} finally {
|
|
74
|
+
try {
|
|
75
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
76
|
+
} finally {
|
|
77
|
+
if (o) throw n;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return a;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function _nonIterableRest() {
|
|
84
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
85
|
+
}
|
|
48
86
|
function ownKeys(e, r) {
|
|
49
87
|
var t = Object.keys(e);
|
|
50
88
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -66,6 +104,9 @@ function _objectSpread2(e) {
|
|
|
66
104
|
}
|
|
67
105
|
return e;
|
|
68
106
|
}
|
|
107
|
+
function _slicedToArray(r, e) {
|
|
108
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
109
|
+
}
|
|
69
110
|
function _toPrimitive(t, r) {
|
|
70
111
|
if ("object" != typeof t || !t) return t;
|
|
71
112
|
var e = t[Symbol.toPrimitive];
|
|
@@ -89,6 +130,13 @@ function _typeof(o) {
|
|
|
89
130
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
90
131
|
}, _typeof(o);
|
|
91
132
|
}
|
|
133
|
+
function _unsupportedIterableToArray(r, a) {
|
|
134
|
+
if (r) {
|
|
135
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
136
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
137
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
92
140
|
|
|
93
141
|
var unassignedPropSymbol = Symbol('unassigned');
|
|
94
142
|
|
|
@@ -255,16 +303,15 @@ function simpleEqual(objectA, objectB) {
|
|
|
255
303
|
}
|
|
256
304
|
}
|
|
257
305
|
|
|
258
|
-
var version="18.
|
|
306
|
+
var version="18.1.0-rc7";
|
|
259
307
|
|
|
260
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
261
|
-
// @ts-ignore
|
|
262
308
|
var HotTable = vue.defineComponent({
|
|
263
309
|
name: 'HotTable',
|
|
264
310
|
props: propFactory('HotTable'),
|
|
265
311
|
provide: function provide() {
|
|
266
312
|
return {
|
|
267
|
-
columnsCache: this.columnsCache
|
|
313
|
+
columnsCache: this.columnsCache,
|
|
314
|
+
refreshColumns: this.refreshColumns
|
|
268
315
|
};
|
|
269
316
|
},
|
|
270
317
|
watch: {
|
|
@@ -306,6 +353,7 @@ var HotTable = vue.defineComponent({
|
|
|
306
353
|
},
|
|
307
354
|
columnSettings: null,
|
|
308
355
|
columnsCache: new Map(),
|
|
356
|
+
columnsRefreshScheduled: false,
|
|
309
357
|
get hotInstance() {
|
|
310
358
|
if (!this.__hotInstance || this.__hotInstance && !this.__hotInstance.isDestroyed) {
|
|
311
359
|
// Will return the Handsontable instance or `null` if it's not yet been created.
|
|
@@ -379,17 +427,91 @@ var HotTable = vue.defineComponent({
|
|
|
379
427
|
/**
|
|
380
428
|
* Get settings for the columns provided in the `hot-column` components.
|
|
381
429
|
*
|
|
430
|
+
* The columns are ordered by the document position of each `hot-column`'s
|
|
431
|
+
* anchor node, not by the `columnsCache` insertion order. This keeps the
|
|
432
|
+
* order correct when columns are inserted in the middle, removed, or
|
|
433
|
+
* reordered, and when a `hot-column` is nested inside a wrapper component.
|
|
434
|
+
*
|
|
382
435
|
* @returns {HotTableProps[] | undefined}
|
|
383
436
|
*/
|
|
384
437
|
getColumnSettings: function getColumnSettings() {
|
|
385
|
-
var
|
|
386
|
-
|
|
438
|
+
var orderedColumns = Array.from(this.columnsCache.entries()).sort(function (_ref, _ref2) {
|
|
439
|
+
var _ref3 = _slicedToArray(_ref, 1),
|
|
440
|
+
columnA = _ref3[0];
|
|
441
|
+
var _ref4 = _slicedToArray(_ref2, 1),
|
|
442
|
+
columnB = _ref4[0];
|
|
443
|
+
var anchorA = columnA.$el;
|
|
444
|
+
var anchorB = columnB.$el;
|
|
445
|
+
if (!anchorA || !anchorB) {
|
|
446
|
+
return 0;
|
|
447
|
+
}
|
|
448
|
+
var position = anchorA.compareDocumentPosition(anchorB);
|
|
449
|
+
|
|
450
|
+
// eslint-disable-next-line no-bitwise
|
|
451
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
452
|
+
return -1;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// eslint-disable-next-line no-bitwise
|
|
456
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
457
|
+
return 1;
|
|
458
|
+
}
|
|
459
|
+
return 0;
|
|
460
|
+
}).map(function (_ref5) {
|
|
461
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
462
|
+
columnSettings = _ref6[1];
|
|
463
|
+
return columnSettings;
|
|
464
|
+
});
|
|
465
|
+
return orderedColumns.length ? orderedColumns : void 0;
|
|
466
|
+
},
|
|
467
|
+
/**
|
|
468
|
+
* Re-read the column settings declared by `hot-column` children and push them
|
|
469
|
+
* to the Handsontable instance. Called by children on mount, prop change, and
|
|
470
|
+
* unmount, and by the parent on reorder. Multiple notifications in the same
|
|
471
|
+
* tick are coalesced into a single `updateSettings` call.
|
|
472
|
+
*/
|
|
473
|
+
refreshColumns: function refreshColumns() {
|
|
474
|
+
var _this2 = this;
|
|
475
|
+
if (this.columnsRefreshScheduled) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
this.columnsRefreshScheduled = true;
|
|
479
|
+
this.$nextTick(function () {
|
|
480
|
+
_this2.columnsRefreshScheduled = false;
|
|
481
|
+
if (!_this2.hotInstance) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
var newColumnSettings = _this2.getColumnSettings();
|
|
485
|
+
var previousColumnSettings = _this2.columnSettings;
|
|
486
|
+
|
|
487
|
+
// Each `hot-column` rebuilds its settings object whenever its props change,
|
|
488
|
+
// so an unchanged column keeps the same object reference. Comparing the
|
|
489
|
+
// arrays by reference and order is cheaper than a deep compare and avoids
|
|
490
|
+
// an `updateSettings` call on unrelated re-renders (e.g. data-only updates).
|
|
491
|
+
var isUnchanged = !previousColumnSettings && !newColumnSettings || !!previousColumnSettings && !!newColumnSettings && previousColumnSettings.length === newColumnSettings.length && previousColumnSettings.every(function (settings, index) {
|
|
492
|
+
return settings === newColumnSettings[index];
|
|
493
|
+
});
|
|
494
|
+
if (isUnchanged) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
_this2.columnSettings = newColumnSettings || null;
|
|
498
|
+
_this2.hotInstance.updateSettings({
|
|
499
|
+
columns: newColumnSettings || void 0
|
|
500
|
+
});
|
|
501
|
+
});
|
|
387
502
|
}
|
|
388
503
|
},
|
|
389
504
|
mounted: function mounted() {
|
|
390
505
|
this.columnSettings = this.getColumnSettings();
|
|
391
506
|
this.hotInit();
|
|
392
507
|
},
|
|
508
|
+
updated: function updated() {
|
|
509
|
+
// Reordering keyed `hot-column` children reuses their instances and fires no
|
|
510
|
+
// child lifecycle hook, so the children cannot notify on their own. The slot
|
|
511
|
+
// vnodes do change, which re-renders `HotTable` - refresh from here to cover
|
|
512
|
+
// reorders (coalesced with any child-triggered refresh).
|
|
513
|
+
this.refreshColumns();
|
|
514
|
+
},
|
|
393
515
|
beforeUnmount: function beforeUnmount() {
|
|
394
516
|
if (this.hotInstance) {
|
|
395
517
|
this.hotInstance.destroy();
|
|
@@ -405,7 +527,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
405
527
|
style: {
|
|
406
528
|
"height": "100%"
|
|
407
529
|
}
|
|
408
|
-
}, [vue.renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1);
|
|
530
|
+
}, [vue.createCommentVNode(" `hot-column` children render invisible comment anchors in source order.\n Handsontable appends its own DOM to this container without clearing\n pre-existing nodes, so the anchors survive; the parent reads their\n document position to order the columns. "), vue.renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1);
|
|
409
531
|
}
|
|
410
532
|
|
|
411
533
|
HotTable.render = render;
|
|
@@ -414,7 +536,7 @@ HotTable.__file = "src/HotTable.vue";
|
|
|
414
536
|
var HotColumn = vue.defineComponent({
|
|
415
537
|
name: 'HotColumn',
|
|
416
538
|
props: propFactory('HotColumn'),
|
|
417
|
-
inject: ['columnsCache'],
|
|
539
|
+
inject: ['columnsCache', 'refreshColumns'],
|
|
418
540
|
methods: {
|
|
419
541
|
/**
|
|
420
542
|
* Create the column settings based on the data provided to the `hot-column`
|
|
@@ -432,14 +554,30 @@ var HotColumn = vue.defineComponent({
|
|
|
432
554
|
this.columnsCache.set(this, columnSettings);
|
|
433
555
|
}
|
|
434
556
|
},
|
|
557
|
+
watch: {
|
|
558
|
+
$props: {
|
|
559
|
+
handler: function handler() {
|
|
560
|
+
this.createColumnSettings();
|
|
561
|
+
this.refreshColumns();
|
|
562
|
+
},
|
|
563
|
+
deep: true
|
|
564
|
+
}
|
|
565
|
+
},
|
|
435
566
|
mounted: function mounted() {
|
|
436
567
|
this.createColumnSettings();
|
|
568
|
+
this.refreshColumns();
|
|
437
569
|
},
|
|
438
570
|
unmounted: function unmounted() {
|
|
439
571
|
this.columnsCache["delete"](this);
|
|
572
|
+
this.refreshColumns();
|
|
440
573
|
},
|
|
441
574
|
render: function render() {
|
|
442
|
-
|
|
575
|
+
// Render an (invisible) comment anchor instead of nothing, so the parent
|
|
576
|
+
// `HotTable` can order columns by the anchors' document position. This keeps
|
|
577
|
+
// ordering correct for dynamic inserts, removals, and reorders - and works
|
|
578
|
+
// regardless of how deeply the `hot-column` is nested inside wrapper
|
|
579
|
+
// components - because `provide`/`inject` and the anchor both cross nesting.
|
|
580
|
+
return vue.createCommentVNode('hot-column');
|
|
443
581
|
}
|
|
444
582
|
});
|
|
445
583
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue-handsontable.js","sources":["../src/helpers.ts","../src/HotTable.vue","../src/HotTable.vue?vue&type=template&id=54bcc3fa&lang.js","../src/HotColumn.vue"],"sourcesContent":["import Handsontable from 'handsontable/base';\nimport { HotTableProps, VueProps } from './types';\n\nconst unassignedPropSymbol = Symbol('unassigned');\n\n/**\n * Message for the warning thrown if the Handsontable instance has been destroyed.\n */\nexport const HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' +\n ' used properly.';\n\n/**\n * Check if at specified `key` there is any value for `object`.\n *\n * @param {object} object Object to search value at specyfic key.\n * @param {string} key String key to check.\n * @returns {boolean}\n */\nexport function hasOwnProperty(object: unknown, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\n/**\n * Generate an object containing all the available Handsontable properties and plugin hooks.\n *\n * @param {string} source Source for the factory (either 'HotTable' or 'HotColumn').\n * @returns {object}\n */\nexport function propFactory(source: 'HotTable' | 'HotColumn'): VueProps<HotTableProps> {\n const registeredHooks = Handsontable.hooks.getRegistered();\n const propSchema: VueProps<HotTableProps> = {};\n\n Object.assign(propSchema, Handsontable.DefaultSettings);\n\n // eslint-disable-next-line no-restricted-syntax, guard-for-in\n for (const prop in propSchema) {\n propSchema[prop] = {\n default: unassignedPropSymbol\n };\n }\n\n for (let i = 0; i < registeredHooks.length; i++) {\n propSchema[registeredHooks[i]] = {\n default: unassignedPropSymbol\n };\n }\n\n propSchema.settings = {\n default: unassignedPropSymbol\n };\n\n if (source === 'HotTable') {\n propSchema.id = {\n type: String,\n default: `hot-${Math.random().toString(36).substring(5)}`\n };\n }\n\n return propSchema;\n}\n\n/**\n * Filter out all of the unassigned props, and return only the one passed to the component.\n *\n * @param {object} props Object containing all the possible props.\n * @returns {object} Object containing only used props.\n */\nexport function filterPassedProps(props) {\n const filteredProps: VueProps<HotTableProps> = {};\n const columnSettingsProp = props.settings;\n\n if (columnSettingsProp !== unassignedPropSymbol) {\n // eslint-disable-next-line no-restricted-syntax\n for (const propName in columnSettingsProp) {\n if (hasOwnProperty(columnSettingsProp, propName) && columnSettingsProp[propName] !== unassignedPropSymbol) {\n filteredProps[propName] = columnSettingsProp[propName];\n }\n }\n }\n\n // eslint-disable-next-line no-restricted-syntax\n for (const propName in props) {\n if (hasOwnProperty(props, propName) && propName !== 'settings' && props[propName] !== unassignedPropSymbol) {\n filteredProps[propName] = props[propName];\n }\n }\n\n return filteredProps;\n}\n\n/**\n * Prepare the settings object to be used as the settings for Handsontable, based on the props provided to the component.\n *\n * @param {HotTableProps} props The props passed to the component.\n * @param {Handsontable.GridSettings} currentSettings The current Handsontable settings.\n * @returns {Handsontable.GridSettings} An object containing the properties, ready to be used within Handsontable.\n */\nexport function prepareSettings(props: HotTableProps, currentSettings?: Handsontable.GridSettings): HotTableProps {\n const assignedProps: VueProps<HotTableProps> = filterPassedProps(props);\n const hotSettingsInProps: Handsontable.GridSettings = props.settings ? props.settings : assignedProps;\n const additionalHotSettingsInProps: Handsontable.GridSettings = props.settings ? assignedProps : null;\n const initOnlySettingKeys: string[] =\n (currentSettings as any)?._initOnlySettings || [];\n const newSettings: Handsontable.GridSettings = {};\n\n // eslint-disable-next-line no-restricted-syntax\n for (const key in hotSettingsInProps) {\n if (\n hasOwnProperty(hotSettingsInProps, key) &&\n hotSettingsInProps[key] !== void 0 &&\n !initOnlySettingKeys.includes(key) &&\n ((currentSettings && key !== 'data') ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)\n ) {\n newSettings[key] = hotSettingsInProps[key];\n }\n }\n\n // eslint-disable-next-line no-restricted-syntax\n for (const key in additionalHotSettingsInProps) {\n if (\n hasOwnProperty(additionalHotSettingsInProps, key) &&\n key !== 'id' &&\n key !== 'settings' &&\n additionalHotSettingsInProps[key] !== void 0 &&\n !initOnlySettingKeys.includes(key) &&\n ((currentSettings && key !== 'data')\n ? !simpleEqual(currentSettings[key], additionalHotSettingsInProps[key]) : true)\n ) {\n newSettings[key] = additionalHotSettingsInProps[key];\n }\n }\n\n return newSettings;\n}\n\n/**\n * Compare two objects using `JSON.stringify`.\n * *Note: * As it's using the stringify function to compare objects, the property order in both objects is\n * important. It will return `false` for the same objects, if they're defined in a different order.\n *\n * @param {object} objectA First object to compare.\n * @param {object} objectB Second object to compare.\n * @returns {boolean} `true` if they're the same, `false` otherwise.\n */\nfunction simpleEqual(objectA, objectB) {\n // Shared across both stringify calls so the same Node/function instance maps\n // to the same identity token in objectA's string and objectB's string.\n const identityMap = new WeakMap<object, string>();\n let nextIdentityId = 0;\n\n const stringifyToJSON = (val) => {\n const seen = new WeakSet();\n\n return JSON.stringify(val, (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return undefined;\n }\n\n seen.add(value);\n\n // DOM nodes carry framework metadata as enumerable own properties\n // (e.g., Vue 3 attaches `_vnode` to the mount root). Recursing into them\n // can reach getters that throw - see GH #11220 - and produces noise that\n // is irrelevant to settings equality. Replace each Node with an identity\n // token so reference equality is still detected.\n if (typeof Node !== 'undefined' && value instanceof Node) {\n let id = identityMap.get(value);\n\n if (id === undefined) {\n nextIdentityId += 1;\n id = `__hot_node_${nextIdentityId}__`;\n identityMap.set(value, id);\n }\n\n return id;\n }\n }\n\n return value;\n });\n };\n\n if (typeof objectA === 'function' && typeof objectB === 'function') {\n return objectA.toString() === objectB.toString();\n\n } else if (typeof objectA !== typeof objectB) {\n return false;\n\n } else {\n try {\n return stringifyToJSON(objectA) === stringifyToJSON(objectB);\n } catch (e) {\n // If either side cannot be serialized (e.g., contains a throwing getter),\n // assume the values are not equal so the wrapper still updates settings.\n return false;\n }\n }\n}\n","<template>\n <div :id=\"id\" style=\"height: 100%\">\n <slot></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, VNode, markRaw } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport Handsontable from 'handsontable/base';\nimport {\n HOT_DESTROYED_WARNING,\n prepareSettings,\n propFactory,\n} from './helpers';\nimport {\n HotTableProps,\n} from './types';\nimport * as packageJson from '../package.json';\n\nconst HotTable = defineComponent({\n name: 'HotTable',\n props: propFactory('HotTable'),\n provide() {\n return {\n columnsCache: this.columnsCache\n };\n },\n watch: {\n $props: {\n handler(props) {\n const settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);\n\n if (!this.hotInstance || settings === void 0) {\n return;\n }\n\n if (settings.data) {\n if (\n this.hotInstance.isColumnModificationAllowed() ||\n (\n !this.hotInstance.isColumnModificationAllowed() &&\n this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns\n )\n ) {\n // If the dataset dimensions change, update the index mappers.\n this.matchHotMappersSize();\n\n // Data is automatically synchronized by reference.\n delete settings.data;\n }\n }\n\n // If there are another options changed, update the HOT settings, render the table otherwise.\n if (Object.keys(settings).length) {\n this.hotInstance.updateSettings(settings);\n\n } else {\n this.hotInstance.render();\n }\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n deep: true,\n immediate: true,\n },\n },\n data() {\n return {\n /* eslint-disable vue/no-reserved-keys */\n __hotInstance: null as Handsontable,\n /* eslint-enable vue/no-reserved-keys */\n miscCache: {\n currentSourceColumns: null,\n },\n columnSettings: null as HotTableProps[],\n columnsCache: new Map<VNode, HotTableProps>(),\n get hotInstance(): Handsontable | null {\n if (!this.__hotInstance || (this.__hotInstance && !this.__hotInstance.isDestroyed)) {\n\n // Will return the Handsontable instance or `null` if it's not yet been created.\n return this.__hotInstance;\n\n } else {\n /* eslint-disable-next-line no-console */\n console.warn(HOT_DESTROYED_WARNING);\n\n return null;\n }\n },\n set hotInstance(hotInstance: Handsontable) {\n this.__hotInstance = hotInstance;\n },\n };\n },\n methods: {\n /**\n * Initialize Handsontable.\n */\n hotInit() {\n const newSettings = prepareSettings(this.$props);\n\n newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;\n\n this.hotInstance = markRaw<Handsontable>(new Handsontable.Core(this.$el, newSettings));\n this.hotInstance.init();\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n\n matchHotMappersSize(): void {\n if (!this.hotInstance) {\n return;\n }\n\n const data: Handsontable.CellValue[][] = this.hotInstance.getSourceData();\n const rowsToRemove: number[] = [];\n const columnsToRemove: number[] = [];\n const indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes();\n const isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed();\n let indexMapperColumnCount = 0;\n\n if (data && data.length !== indexMapperRowCount) {\n if (data.length < indexMapperRowCount) {\n for (let r = data.length; r < indexMapperRowCount; r++) {\n rowsToRemove.push(r);\n }\n }\n }\n\n if (isColumnModificationAllowed) {\n indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes();\n\n if (data && data[0] && data[0]?.length !== indexMapperColumnCount) {\n if (data[0].length < indexMapperColumnCount) {\n for (let c = data[0].length; c < indexMapperColumnCount; c++) {\n columnsToRemove.push(c);\n }\n }\n }\n }\n\n this.hotInstance.batch(() => {\n if (rowsToRemove.length > 0) {\n this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove);\n\n } else {\n this.hotInstance.rowIndexMapper\n .insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount);\n }\n\n if (isColumnModificationAllowed && data.length !== 0) {\n if (columnsToRemove.length > 0) {\n this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove);\n\n } else {\n this.hotInstance.columnIndexMapper\n .insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount);\n }\n }\n });\n },\n\n /**\n * Get settings for the columns provided in the `hot-column` components.\n *\n * @returns {HotTableProps[] | undefined}\n */\n getColumnSettings(): HotTableProps[] | void {\n const columnSettings: HotTableProps[] = Array.from(this.columnsCache.values());\n\n return columnSettings.length ? columnSettings : void 0;\n },\n },\n mounted() {\n this.columnSettings = this.getColumnSettings();\n this.hotInit();\n },\n beforeUnmount() {\n if (this.hotInstance) {\n this.hotInstance.destroy();\n }\n },\n version: (packageJson as unknown as { version: string }).version,\n});\n\nexport default HotTable;\nexport { HotTable };\n</script>\n","<template>\n <div :id=\"id\" style=\"height: 100%\">\n <slot></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, VNode, markRaw } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport Handsontable from 'handsontable/base';\nimport {\n HOT_DESTROYED_WARNING,\n prepareSettings,\n propFactory,\n} from './helpers';\nimport {\n HotTableProps,\n} from './types';\nimport * as packageJson from '../package.json';\n\nconst HotTable = defineComponent({\n name: 'HotTable',\n props: propFactory('HotTable'),\n provide() {\n return {\n columnsCache: this.columnsCache\n };\n },\n watch: {\n $props: {\n handler(props) {\n const settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);\n\n if (!this.hotInstance || settings === void 0) {\n return;\n }\n\n if (settings.data) {\n if (\n this.hotInstance.isColumnModificationAllowed() ||\n (\n !this.hotInstance.isColumnModificationAllowed() &&\n this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns\n )\n ) {\n // If the dataset dimensions change, update the index mappers.\n this.matchHotMappersSize();\n\n // Data is automatically synchronized by reference.\n delete settings.data;\n }\n }\n\n // If there are another options changed, update the HOT settings, render the table otherwise.\n if (Object.keys(settings).length) {\n this.hotInstance.updateSettings(settings);\n\n } else {\n this.hotInstance.render();\n }\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n deep: true,\n immediate: true,\n },\n },\n data() {\n return {\n /* eslint-disable vue/no-reserved-keys */\n __hotInstance: null as Handsontable,\n /* eslint-enable vue/no-reserved-keys */\n miscCache: {\n currentSourceColumns: null,\n },\n columnSettings: null as HotTableProps[],\n columnsCache: new Map<VNode, HotTableProps>(),\n get hotInstance(): Handsontable | null {\n if (!this.__hotInstance || (this.__hotInstance && !this.__hotInstance.isDestroyed)) {\n\n // Will return the Handsontable instance or `null` if it's not yet been created.\n return this.__hotInstance;\n\n } else {\n /* eslint-disable-next-line no-console */\n console.warn(HOT_DESTROYED_WARNING);\n\n return null;\n }\n },\n set hotInstance(hotInstance: Handsontable) {\n this.__hotInstance = hotInstance;\n },\n };\n },\n methods: {\n /**\n * Initialize Handsontable.\n */\n hotInit() {\n const newSettings = prepareSettings(this.$props);\n\n newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;\n\n this.hotInstance = markRaw<Handsontable>(new Handsontable.Core(this.$el, newSettings));\n this.hotInstance.init();\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n\n matchHotMappersSize(): void {\n if (!this.hotInstance) {\n return;\n }\n\n const data: Handsontable.CellValue[][] = this.hotInstance.getSourceData();\n const rowsToRemove: number[] = [];\n const columnsToRemove: number[] = [];\n const indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes();\n const isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed();\n let indexMapperColumnCount = 0;\n\n if (data && data.length !== indexMapperRowCount) {\n if (data.length < indexMapperRowCount) {\n for (let r = data.length; r < indexMapperRowCount; r++) {\n rowsToRemove.push(r);\n }\n }\n }\n\n if (isColumnModificationAllowed) {\n indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes();\n\n if (data && data[0] && data[0]?.length !== indexMapperColumnCount) {\n if (data[0].length < indexMapperColumnCount) {\n for (let c = data[0].length; c < indexMapperColumnCount; c++) {\n columnsToRemove.push(c);\n }\n }\n }\n }\n\n this.hotInstance.batch(() => {\n if (rowsToRemove.length > 0) {\n this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove);\n\n } else {\n this.hotInstance.rowIndexMapper\n .insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount);\n }\n\n if (isColumnModificationAllowed && data.length !== 0) {\n if (columnsToRemove.length > 0) {\n this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove);\n\n } else {\n this.hotInstance.columnIndexMapper\n .insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount);\n }\n }\n });\n },\n\n /**\n * Get settings for the columns provided in the `hot-column` components.\n *\n * @returns {HotTableProps[] | undefined}\n */\n getColumnSettings(): HotTableProps[] | void {\n const columnSettings: HotTableProps[] = Array.from(this.columnsCache.values());\n\n return columnSettings.length ? columnSettings : void 0;\n },\n },\n mounted() {\n this.columnSettings = this.getColumnSettings();\n this.hotInit();\n },\n beforeUnmount() {\n if (this.hotInstance) {\n this.hotInstance.destroy();\n }\n },\n version: (packageJson as unknown as { version: string }).version,\n});\n\nexport default HotTable;\nexport { HotTable };\n</script>\n","<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport {\n propFactory,\n filterPassedProps\n} from './helpers';\n\nconst HotColumn = defineComponent({\n name: 'HotColumn',\n props: propFactory('HotColumn'),\n inject: ['columnsCache'],\n methods: {\n /**\n * Create the column settings based on the data provided to the `hot-column`\n * component and it's child components.\n */\n createColumnSettings(): void {\n const assignedProps = filterPassedProps(this.$props);\n const columnSettings = { ...assignedProps };\n\n if (assignedProps.renderer) {\n columnSettings.renderer = assignedProps.renderer;\n }\n\n if (assignedProps.editor) {\n columnSettings.editor = assignedProps.editor;\n }\n\n this.columnsCache.set(this, columnSettings);\n }\n },\n mounted() {\n this.createColumnSettings();\n },\n unmounted() {\n this.columnsCache.delete(this);\n },\n render() {\n return null;\n }\n});\n\nexport default HotColumn;\nexport { HotColumn };\n</script>\n"],"names":["unassignedPropSymbol","Symbol","HOT_DESTROYED_WARNING","hasOwnProperty","object","key","Object","prototype","call","propFactory","source","registeredHooks","Handsontable","hooks","getRegistered","propSchema","assign","DefaultSettings","prop","i","length","settings","id","type","String","concat","Math","random","toString","substring","filterPassedProps","props","filteredProps","columnSettingsProp","propName","prepareSettings","currentSettings","assignedProps","hotSettingsInProps","additionalHotSettingsInProps","initOnlySettingKeys","_initOnlySettings","newSettings","includes","simpleEqual","objectA","objectB","identityMap","WeakMap","nextIdentityId","stringifyToJSON","val","seen","WeakSet","JSON","stringify","value","_typeof","has","undefined","add","Node","get","set","e","HotTable","defineComponent","name","provide","columnsCache","watch","$props","handler","hotInstance","getSettings","data","isColumnModificationAllowed","countSourceCols","miscCache","currentSourceColumns","matchHotMappersSize","keys","updateSettings","render","deep","immediate","__hotInstance","columnSettings","Map","isDestroyed","console","warn","methods","hotInit","columns","markRaw","Core","$el","init","_this","getSourceData","rowsToRemove","columnsToRemove","indexMapperRowCount","rowIndexMapper","getNumberOfIndexes","indexMapperColumnCount","r","push","_data$","columnIndexMapper","c","batch","removeIndexes","insertIndexes","getColumnSettings","Array","from","values","mounted","beforeUnmount","destroy","version","packageJson","_createElementBlock","_ctx","style","_renderSlot","$slots","HotColumn","inject","createColumnSettings","_objectSpread","renderer","editor","unmounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAMA,oBAAoB,GAAGC,MAAM,CAAC,YAAY,CAAC;;AAEjD;AACA;AACA;AACO,IAAMC,qBAAqB,GAAG,+EAA+E,GAClH,iBAAiB;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAACC,MAAe,EAAEC,GAAW,EAAW;EACpE,OAAOC,MAAM,CAACC,SAAS,CAACJ,cAAc,CAACK,IAAI,CAACJ,MAAM,EAAEC,GAAG,CAAC;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,WAAWA,CAACC,MAAgC,EAA2B;EACrF,IAAMC,eAAe,GAAGC,gCAAY,CAACC,KAAK,CAACC,aAAa,EAAE;EAC1D,IAAMC,UAAmC,GAAG,EAAE;EAE9CT,MAAM,CAACU,MAAM,CAACD,UAAU,EAAEH,gCAAY,CAACK,eAAe,CAAC;;AAEvD;AACA,EAAA,KAAK,IAAMC,IAAI,IAAIH,UAAU,EAAE;IAC7BA,UAAU,CAACG,IAAI,CAAC,GAAG;MACjB,SAAA,EAASlB;KACV;AACH,EAAA;AAEA,EAAA,KAAK,IAAImB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGR,eAAe,CAACS,MAAM,EAAED,CAAC,EAAE,EAAE;AAC/CJ,IAAAA,UAAU,CAACJ,eAAe,CAACQ,CAAC,CAAC,CAAC,GAAG;MAC/B,SAAA,EAASnB;KACV;AACH,EAAA;EAEAe,UAAU,CAACM,Q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AA,KAAK,EAAEtB,WAAW,CAAC,WAAW,CAAC;EAC/ByH,MAAM,EAAE,CAAC,cAAc,CAAC;AACxBtC,EAAAA,OAAO,EAAE;AACP;AACC;AACA;;IAEDuC,oBAAoB,EAAA,SAApBA,oBAAoBA,GAAS;AAC3B,MAAA,IAAM9F,gBAAgBP,iBAAiB,CAAC,IAAI,CAACyC,MAAM,CAAC;AACpD,MAAA,IAAMgB,cAAa,GAAA6C,cAAA,CAAA,EAAA,EAAS/F,cAAe;MAE3C,IAAIA,aAAa,CAACgG,QAAQ,EAAE;AAC1B9C,QAAAA,cAAc,CAAC8C,QAAO,GAAIhG,aAAa,CAACgG,QAAQ;AAClD,MAAA;MAEA,IAAIhG,aAAa,CAACiG,MAAM,EAAE;AACxB/C,QAAAA,cAAc,CAAC+C,MAAK,GAAIjG,aAAa,CAACiG,MAAM;AAC9C,MAAA;MAEA,IAAI,CAACjE,YAAY,CAACN,GAAG,CAAC,IAAI,EAAEwB,cAAc,CAAC;AAC7C,IAAA;GACD;EACDgC,OAAO,EAAA,SAAPA,OAAOA,GAAG;IACR,IAAI,CAACY,oBAAoB,EAAE;EAC7B,CAAC;EACDI,SAAS,EAAA,SAATA,SAASA,GAAG;AACV,IAAA,IAAI,CAAClE,YAAY,CAAA,QAAA,CAAO,CAAC,IAAI,CAAC;EAChC,CAAC;EACDc,MAAM,EAAA,SAANA,MAAMA,GAAG;AACP,IAAA,OAAO,IAAI;AACb,EAAA;AACF,CAAC;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"vue-handsontable.js","sources":["../src/helpers.ts","../src/HotTable.vue","../src/HotTable.vue?vue&type=template&id=54bcc3fa&lang.js","../src/HotColumn.vue"],"sourcesContent":["import Handsontable from 'handsontable/base';\nimport { HotTableProps, VueProps } from './types';\n\nconst unassignedPropSymbol = Symbol('unassigned');\n\n/**\n * Message for the warning thrown if the Handsontable instance has been destroyed.\n */\nexport const HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' +\n ' used properly.';\n\n/**\n * Check if at specified `key` there is any value for `object`.\n *\n * @param {object} object Object to search value at specyfic key.\n * @param {string} key String key to check.\n * @returns {boolean}\n */\nexport function hasOwnProperty(object: unknown, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\n/**\n * Generate an object containing all the available Handsontable properties and plugin hooks.\n *\n * @param {string} source Source for the factory (either 'HotTable' or 'HotColumn').\n * @returns {object}\n */\nexport function propFactory(source: 'HotTable' | 'HotColumn'): VueProps<HotTableProps> {\n const registeredHooks = Handsontable.hooks.getRegistered();\n const propSchema: VueProps<HotTableProps> = {};\n\n Object.assign(propSchema, Handsontable.DefaultSettings);\n\n // eslint-disable-next-line no-restricted-syntax, guard-for-in\n for (const prop in propSchema) {\n propSchema[prop] = {\n default: unassignedPropSymbol\n };\n }\n\n for (let i = 0; i < registeredHooks.length; i++) {\n propSchema[registeredHooks[i]] = {\n default: unassignedPropSymbol\n };\n }\n\n propSchema.settings = {\n default: unassignedPropSymbol\n };\n\n if (source === 'HotTable') {\n propSchema.id = {\n type: String,\n default: `hot-${Math.random().toString(36).substring(5)}`\n };\n }\n\n return propSchema;\n}\n\n/**\n * Filter out all of the unassigned props, and return only the one passed to the component.\n *\n * @param {object} props Object containing all the possible props.\n * @returns {object} Object containing only used props.\n */\nexport function filterPassedProps(props) {\n const filteredProps: VueProps<HotTableProps> = {};\n const columnSettingsProp = props.settings;\n\n if (columnSettingsProp !== unassignedPropSymbol) {\n // eslint-disable-next-line no-restricted-syntax\n for (const propName in columnSettingsProp) {\n if (hasOwnProperty(columnSettingsProp, propName) && columnSettingsProp[propName] !== unassignedPropSymbol) {\n filteredProps[propName] = columnSettingsProp[propName];\n }\n }\n }\n\n // eslint-disable-next-line no-restricted-syntax\n for (const propName in props) {\n if (hasOwnProperty(props, propName) && propName !== 'settings' && props[propName] !== unassignedPropSymbol) {\n filteredProps[propName] = props[propName];\n }\n }\n\n return filteredProps;\n}\n\n/**\n * Prepare the settings object to be used as the settings for Handsontable, based on the props provided to the component.\n *\n * @param {HotTableProps} props The props passed to the component.\n * @param {Handsontable.GridSettings} currentSettings The current Handsontable settings.\n * @returns {Handsontable.GridSettings} An object containing the properties, ready to be used within Handsontable.\n */\nexport function prepareSettings(props: HotTableProps, currentSettings?: Handsontable.GridSettings): HotTableProps {\n const assignedProps: VueProps<HotTableProps> = filterPassedProps(props);\n const hotSettingsInProps: Handsontable.GridSettings = props.settings ? props.settings : assignedProps;\n const additionalHotSettingsInProps: Handsontable.GridSettings = props.settings ? assignedProps : null;\n const initOnlySettingKeys: string[] =\n (currentSettings as any)?._initOnlySettings || [];\n const newSettings: Handsontable.GridSettings = {};\n\n // eslint-disable-next-line no-restricted-syntax\n for (const key in hotSettingsInProps) {\n if (\n hasOwnProperty(hotSettingsInProps, key) &&\n hotSettingsInProps[key] !== void 0 &&\n !initOnlySettingKeys.includes(key) &&\n ((currentSettings && key !== 'data') ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)\n ) {\n newSettings[key] = hotSettingsInProps[key];\n }\n }\n\n // eslint-disable-next-line no-restricted-syntax\n for (const key in additionalHotSettingsInProps) {\n if (\n hasOwnProperty(additionalHotSettingsInProps, key) &&\n key !== 'id' &&\n key !== 'settings' &&\n additionalHotSettingsInProps[key] !== void 0 &&\n !initOnlySettingKeys.includes(key) &&\n ((currentSettings && key !== 'data')\n ? !simpleEqual(currentSettings[key], additionalHotSettingsInProps[key]) : true)\n ) {\n newSettings[key] = additionalHotSettingsInProps[key];\n }\n }\n\n return newSettings;\n}\n\n/**\n * Compare two objects using `JSON.stringify`.\n * *Note: * As it's using the stringify function to compare objects, the property order in both objects is\n * important. It will return `false` for the same objects, if they're defined in a different order.\n *\n * @param {object} objectA First object to compare.\n * @param {object} objectB Second object to compare.\n * @returns {boolean} `true` if they're the same, `false` otherwise.\n */\nfunction simpleEqual(objectA, objectB) {\n // Shared across both stringify calls so the same Node/function instance maps\n // to the same identity token in objectA's string and objectB's string.\n const identityMap = new WeakMap<object, string>();\n let nextIdentityId = 0;\n\n const stringifyToJSON = (val) => {\n const seen = new WeakSet();\n\n return JSON.stringify(val, (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return undefined;\n }\n\n seen.add(value);\n\n // DOM nodes carry framework metadata as enumerable own properties\n // (e.g., Vue 3 attaches `_vnode` to the mount root). Recursing into them\n // can reach getters that throw - see GH #11220 - and produces noise that\n // is irrelevant to settings equality. Replace each Node with an identity\n // token so reference equality is still detected.\n if (typeof Node !== 'undefined' && value instanceof Node) {\n let id = identityMap.get(value);\n\n if (id === undefined) {\n nextIdentityId += 1;\n id = `__hot_node_${nextIdentityId}__`;\n identityMap.set(value, id);\n }\n\n return id;\n }\n }\n\n return value;\n });\n };\n\n if (typeof objectA === 'function' && typeof objectB === 'function') {\n return objectA.toString() === objectB.toString();\n\n } else if (typeof objectA !== typeof objectB) {\n return false;\n\n } else {\n try {\n return stringifyToJSON(objectA) === stringifyToJSON(objectB);\n } catch (e) {\n // If either side cannot be serialized (e.g., contains a throwing getter),\n // assume the values are not equal so the wrapper still updates settings.\n return false;\n }\n }\n}\n","<template>\n <div :id=\"id\" style=\"height: 100%\">\n <!-- `hot-column` children render invisible comment anchors in source order.\n Handsontable appends its own DOM to this container without clearing\n pre-existing nodes, so the anchors survive; the parent reads their\n document position to order the columns. -->\n <slot></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, VNode, markRaw } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport Handsontable from 'handsontable/base';\nimport {\n HOT_DESTROYED_WARNING,\n prepareSettings,\n propFactory,\n} from './helpers';\nimport {\n HotTableProps,\n} from './types';\nimport * as packageJson from '../package.json';\n\nconst HotTable = defineComponent({\n name: 'HotTable',\n props: propFactory('HotTable'),\n provide() {\n return {\n columnsCache: this.columnsCache,\n refreshColumns: this.refreshColumns,\n };\n },\n watch: {\n $props: {\n handler(props) {\n const settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);\n\n if (!this.hotInstance || settings === void 0) {\n return;\n }\n\n if (settings.data) {\n if (\n this.hotInstance.isColumnModificationAllowed() ||\n (\n !this.hotInstance.isColumnModificationAllowed() &&\n this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns\n )\n ) {\n // If the dataset dimensions change, update the index mappers.\n this.matchHotMappersSize();\n\n // Data is automatically synchronized by reference.\n delete settings.data;\n }\n }\n\n // If there are another options changed, update the HOT settings, render the table otherwise.\n if (Object.keys(settings).length) {\n this.hotInstance.updateSettings(settings);\n\n } else {\n this.hotInstance.render();\n }\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n deep: true,\n immediate: true,\n },\n },\n data() {\n return {\n /* eslint-disable vue/no-reserved-keys */\n __hotInstance: null as Handsontable,\n /* eslint-enable vue/no-reserved-keys */\n miscCache: {\n currentSourceColumns: null,\n },\n columnSettings: null as HotTableProps[],\n columnsCache: new Map<VNode, HotTableProps>(),\n columnsRefreshScheduled: false,\n get hotInstance(): Handsontable | null {\n if (!this.__hotInstance || (this.__hotInstance && !this.__hotInstance.isDestroyed)) {\n\n // Will return the Handsontable instance or `null` if it's not yet been created.\n return this.__hotInstance;\n\n } else {\n /* eslint-disable-next-line no-console */\n console.warn(HOT_DESTROYED_WARNING);\n\n return null;\n }\n },\n set hotInstance(hotInstance: Handsontable) {\n this.__hotInstance = hotInstance;\n },\n };\n },\n methods: {\n /**\n * Initialize Handsontable.\n */\n hotInit() {\n const newSettings = prepareSettings(this.$props);\n\n newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;\n\n this.hotInstance = markRaw<Handsontable>(new Handsontable.Core(this.$el, newSettings));\n this.hotInstance.init();\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n\n matchHotMappersSize(): void {\n if (!this.hotInstance) {\n return;\n }\n\n const data: Handsontable.CellValue[][] = this.hotInstance.getSourceData();\n const rowsToRemove: number[] = [];\n const columnsToRemove: number[] = [];\n const indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes();\n const isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed();\n let indexMapperColumnCount = 0;\n\n if (data && data.length !== indexMapperRowCount) {\n if (data.length < indexMapperRowCount) {\n for (let r = data.length; r < indexMapperRowCount; r++) {\n rowsToRemove.push(r);\n }\n }\n }\n\n if (isColumnModificationAllowed) {\n indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes();\n\n if (data && data[0] && data[0]?.length !== indexMapperColumnCount) {\n if (data[0].length < indexMapperColumnCount) {\n for (let c = data[0].length; c < indexMapperColumnCount; c++) {\n columnsToRemove.push(c);\n }\n }\n }\n }\n\n this.hotInstance.batch(() => {\n if (rowsToRemove.length > 0) {\n this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove);\n\n } else {\n this.hotInstance.rowIndexMapper\n .insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount);\n }\n\n if (isColumnModificationAllowed && data.length !== 0) {\n if (columnsToRemove.length > 0) {\n this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove);\n\n } else {\n this.hotInstance.columnIndexMapper\n .insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount);\n }\n }\n });\n },\n\n /**\n * Get settings for the columns provided in the `hot-column` components.\n *\n * The columns are ordered by the document position of each `hot-column`'s\n * anchor node, not by the `columnsCache` insertion order. This keeps the\n * order correct when columns are inserted in the middle, removed, or\n * reordered, and when a `hot-column` is nested inside a wrapper component.\n *\n * @returns {HotTableProps[] | undefined}\n */\n getColumnSettings(): HotTableProps[] | void {\n const orderedColumns = Array.from(this.columnsCache.entries())\n .sort(([columnA], [columnB]) => {\n const anchorA = (columnA as { $el?: Node }).$el;\n const anchorB = (columnB as { $el?: Node }).$el;\n\n if (!anchorA || !anchorB) {\n return 0;\n }\n\n const position = anchorA.compareDocumentPosition(anchorB);\n\n // eslint-disable-next-line no-bitwise\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n return -1;\n }\n\n // eslint-disable-next-line no-bitwise\n if (position & Node.DOCUMENT_POSITION_PRECEDING) {\n return 1;\n }\n\n return 0;\n })\n .map(([, columnSettings]) => columnSettings);\n\n return orderedColumns.length ? orderedColumns : void 0;\n },\n\n /**\n * Re-read the column settings declared by `hot-column` children and push them\n * to the Handsontable instance. Called by children on mount, prop change, and\n * unmount, and by the parent on reorder. Multiple notifications in the same\n * tick are coalesced into a single `updateSettings` call.\n */\n refreshColumns(): void {\n if (this.columnsRefreshScheduled) {\n return;\n }\n\n this.columnsRefreshScheduled = true;\n\n this.$nextTick(() => {\n this.columnsRefreshScheduled = false;\n\n if (!this.hotInstance) {\n return;\n }\n\n const newColumnSettings = this.getColumnSettings();\n const previousColumnSettings = this.columnSettings;\n\n // Each `hot-column` rebuilds its settings object whenever its props change,\n // so an unchanged column keeps the same object reference. Comparing the\n // arrays by reference and order is cheaper than a deep compare and avoids\n // an `updateSettings` call on unrelated re-renders (e.g. data-only updates).\n const isUnchanged =\n (!previousColumnSettings && !newColumnSettings) ||\n (!!previousColumnSettings && !!newColumnSettings &&\n previousColumnSettings.length === newColumnSettings.length &&\n previousColumnSettings.every((settings, index) => settings === newColumnSettings[index]));\n\n if (isUnchanged) {\n return;\n }\n\n this.columnSettings = newColumnSettings || null;\n this.hotInstance.updateSettings({ columns: newColumnSettings || void 0 });\n });\n },\n },\n mounted() {\n this.columnSettings = this.getColumnSettings();\n this.hotInit();\n },\n updated() {\n // Reordering keyed `hot-column` children reuses their instances and fires no\n // child lifecycle hook, so the children cannot notify on their own. The slot\n // vnodes do change, which re-renders `HotTable` - refresh from here to cover\n // reorders (coalesced with any child-triggered refresh).\n this.refreshColumns();\n },\n beforeUnmount() {\n if (this.hotInstance) {\n this.hotInstance.destroy();\n }\n },\n version: (packageJson as unknown as { version: string }).version,\n});\n\nexport default HotTable;\nexport { HotTable };\n</script>\n","<template>\n <div :id=\"id\" style=\"height: 100%\">\n <!-- `hot-column` children render invisible comment anchors in source order.\n Handsontable appends its own DOM to this container without clearing\n pre-existing nodes, so the anchors survive; the parent reads their\n document position to order the columns. -->\n <slot></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, VNode, markRaw } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport Handsontable from 'handsontable/base';\nimport {\n HOT_DESTROYED_WARNING,\n prepareSettings,\n propFactory,\n} from './helpers';\nimport {\n HotTableProps,\n} from './types';\nimport * as packageJson from '../package.json';\n\nconst HotTable = defineComponent({\n name: 'HotTable',\n props: propFactory('HotTable'),\n provide() {\n return {\n columnsCache: this.columnsCache,\n refreshColumns: this.refreshColumns,\n };\n },\n watch: {\n $props: {\n handler(props) {\n const settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);\n\n if (!this.hotInstance || settings === void 0) {\n return;\n }\n\n if (settings.data) {\n if (\n this.hotInstance.isColumnModificationAllowed() ||\n (\n !this.hotInstance.isColumnModificationAllowed() &&\n this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns\n )\n ) {\n // If the dataset dimensions change, update the index mappers.\n this.matchHotMappersSize();\n\n // Data is automatically synchronized by reference.\n delete settings.data;\n }\n }\n\n // If there are another options changed, update the HOT settings, render the table otherwise.\n if (Object.keys(settings).length) {\n this.hotInstance.updateSettings(settings);\n\n } else {\n this.hotInstance.render();\n }\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n deep: true,\n immediate: true,\n },\n },\n data() {\n return {\n /* eslint-disable vue/no-reserved-keys */\n __hotInstance: null as Handsontable,\n /* eslint-enable vue/no-reserved-keys */\n miscCache: {\n currentSourceColumns: null,\n },\n columnSettings: null as HotTableProps[],\n columnsCache: new Map<VNode, HotTableProps>(),\n columnsRefreshScheduled: false,\n get hotInstance(): Handsontable | null {\n if (!this.__hotInstance || (this.__hotInstance && !this.__hotInstance.isDestroyed)) {\n\n // Will return the Handsontable instance or `null` if it's not yet been created.\n return this.__hotInstance;\n\n } else {\n /* eslint-disable-next-line no-console */\n console.warn(HOT_DESTROYED_WARNING);\n\n return null;\n }\n },\n set hotInstance(hotInstance: Handsontable) {\n this.__hotInstance = hotInstance;\n },\n };\n },\n methods: {\n /**\n * Initialize Handsontable.\n */\n hotInit() {\n const newSettings = prepareSettings(this.$props);\n\n newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;\n\n this.hotInstance = markRaw<Handsontable>(new Handsontable.Core(this.$el, newSettings));\n this.hotInstance.init();\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n\n matchHotMappersSize(): void {\n if (!this.hotInstance) {\n return;\n }\n\n const data: Handsontable.CellValue[][] = this.hotInstance.getSourceData();\n const rowsToRemove: number[] = [];\n const columnsToRemove: number[] = [];\n const indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes();\n const isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed();\n let indexMapperColumnCount = 0;\n\n if (data && data.length !== indexMapperRowCount) {\n if (data.length < indexMapperRowCount) {\n for (let r = data.length; r < indexMapperRowCount; r++) {\n rowsToRemove.push(r);\n }\n }\n }\n\n if (isColumnModificationAllowed) {\n indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes();\n\n if (data && data[0] && data[0]?.length !== indexMapperColumnCount) {\n if (data[0].length < indexMapperColumnCount) {\n for (let c = data[0].length; c < indexMapperColumnCount; c++) {\n columnsToRemove.push(c);\n }\n }\n }\n }\n\n this.hotInstance.batch(() => {\n if (rowsToRemove.length > 0) {\n this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove);\n\n } else {\n this.hotInstance.rowIndexMapper\n .insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount);\n }\n\n if (isColumnModificationAllowed && data.length !== 0) {\n if (columnsToRemove.length > 0) {\n this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove);\n\n } else {\n this.hotInstance.columnIndexMapper\n .insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount);\n }\n }\n });\n },\n\n /**\n * Get settings for the columns provided in the `hot-column` components.\n *\n * The columns are ordered by the document position of each `hot-column`'s\n * anchor node, not by the `columnsCache` insertion order. This keeps the\n * order correct when columns are inserted in the middle, removed, or\n * reordered, and when a `hot-column` is nested inside a wrapper component.\n *\n * @returns {HotTableProps[] | undefined}\n */\n getColumnSettings(): HotTableProps[] | void {\n const orderedColumns = Array.from(this.columnsCache.entries())\n .sort(([columnA], [columnB]) => {\n const anchorA = (columnA as { $el?: Node }).$el;\n const anchorB = (columnB as { $el?: Node }).$el;\n\n if (!anchorA || !anchorB) {\n return 0;\n }\n\n const position = anchorA.compareDocumentPosition(anchorB);\n\n // eslint-disable-next-line no-bitwise\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n return -1;\n }\n\n // eslint-disable-next-line no-bitwise\n if (position & Node.DOCUMENT_POSITION_PRECEDING) {\n return 1;\n }\n\n return 0;\n })\n .map(([, columnSettings]) => columnSettings);\n\n return orderedColumns.length ? orderedColumns : void 0;\n },\n\n /**\n * Re-read the column settings declared by `hot-column` children and push them\n * to the Handsontable instance. Called by children on mount, prop change, and\n * unmount, and by the parent on reorder. Multiple notifications in the same\n * tick are coalesced into a single `updateSettings` call.\n */\n refreshColumns(): void {\n if (this.columnsRefreshScheduled) {\n return;\n }\n\n this.columnsRefreshScheduled = true;\n\n this.$nextTick(() => {\n this.columnsRefreshScheduled = false;\n\n if (!this.hotInstance) {\n return;\n }\n\n const newColumnSettings = this.getColumnSettings();\n const previousColumnSettings = this.columnSettings;\n\n // Each `hot-column` rebuilds its settings object whenever its props change,\n // so an unchanged column keeps the same object reference. Comparing the\n // arrays by reference and order is cheaper than a deep compare and avoids\n // an `updateSettings` call on unrelated re-renders (e.g. data-only updates).\n const isUnchanged =\n (!previousColumnSettings && !newColumnSettings) ||\n (!!previousColumnSettings && !!newColumnSettings &&\n previousColumnSettings.length === newColumnSettings.length &&\n previousColumnSettings.every((settings, index) => settings === newColumnSettings[index]));\n\n if (isUnchanged) {\n return;\n }\n\n this.columnSettings = newColumnSettings || null;\n this.hotInstance.updateSettings({ columns: newColumnSettings || void 0 });\n });\n },\n },\n mounted() {\n this.columnSettings = this.getColumnSettings();\n this.hotInit();\n },\n updated() {\n // Reordering keyed `hot-column` children reuses their instances and fires no\n // child lifecycle hook, so the children cannot notify on their own. The slot\n // vnodes do change, which re-renders `HotTable` - refresh from here to cover\n // reorders (coalesced with any child-triggered refresh).\n this.refreshColumns();\n },\n beforeUnmount() {\n if (this.hotInstance) {\n this.hotInstance.destroy();\n }\n },\n version: (packageJson as unknown as { version: string }).version,\n});\n\nexport default HotTable;\nexport { HotTable };\n</script>\n","<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, createCommentVNode } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport {\n propFactory,\n filterPassedProps\n} from './helpers';\n\nconst HotColumn = defineComponent({\n name: 'HotColumn',\n props: propFactory('HotColumn'),\n inject: ['columnsCache', 'refreshColumns'],\n methods: {\n /**\n * Create the column settings based on the data provided to the `hot-column`\n * component and it's child components.\n */\n createColumnSettings(): void {\n const assignedProps = filterPassedProps(this.$props);\n const columnSettings = { ...assignedProps };\n\n if (assignedProps.renderer) {\n columnSettings.renderer = assignedProps.renderer;\n }\n\n if (assignedProps.editor) {\n columnSettings.editor = assignedProps.editor;\n }\n\n this.columnsCache.set(this, columnSettings);\n }\n },\n watch: {\n $props: {\n handler() {\n this.createColumnSettings();\n this.refreshColumns();\n },\n deep: true,\n },\n },\n mounted() {\n this.createColumnSettings();\n this.refreshColumns();\n },\n unmounted() {\n this.columnsCache.delete(this);\n this.refreshColumns();\n },\n render() {\n // Render an (invisible) comment anchor instead of nothing, so the parent\n // `HotTable` can order columns by the anchors' document position. This keeps\n // ordering correct for dynamic inserts, removals, and reorders - and works\n // regardless of how deeply the `hot-column` is nested inside wrapper\n // components - because `provide`/`inject` and the anchor both cross nesting.\n return createCommentVNode('hot-column');\n }\n});\n\nexport default HotColumn;\nexport { HotColumn };\n</script>\n"],"names":["unassignedPropSymbol","Symbol","HOT_DESTROYED_WARNING","hasOwnProperty","object","key","Object","prototype","call","propFactory","source","registeredHooks","Handsontable","hooks","getRegistered","propSchema","assign","DefaultSettings","prop","i","length","settings","id","type","String","concat","Math","random","toString","substring","filterPassedProps","props","filteredProps","columnSettingsProp","propName","prepareSettings","currentSettings","assignedProps","hotSettingsInProps","additionalHotSettingsInProps","initOnlySettingKeys","_initOnlySettings","newSettings","includes","simpleEqual","objectA","objectB","identityMap","WeakMap","nextIdentityId","stringifyToJSON","val","seen","WeakSet","JSON","stringify","value","_typeof","has","undefined","add","Node","get","set","e","HotTable","defineComponent","name","provide","columnsCache","refreshColumns","watch","$props","handler","hotInstance","getSettings","data","isColumnModificationAllowed","countSourceCols","miscCache","currentSourceColumns","matchHotMappersSize","keys","updateSettings","render","deep","immediate","__hotInstance","columnSettings","Map","columnsRefreshScheduled","isDestroyed","console","warn","methods","hotInit","columns","markRaw","Core","$el","init","_this","getSourceData","rowsToRemove","columnsToRemove","indexMapperRowCount","rowIndexMapper","getNumberOfIndexes","indexMapperColumnCount","r","push","_data$","columnIndexMapper","c","batch","removeIndexes","insertIndexes","getColumnSettings","orderedColumns","Array","from","entries","sort","_ref","_ref2","_ref3","_slicedToArray","columnA","_ref4","columnB","anchorA","anchorB","position","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","map","_ref5","_ref6","_this2","$nextTick","newColumnSettings","previousColumnSettings","isUnchanged","every","index","mounted","updated","beforeUnmount","destroy","version","packageJson","_createElementBlock","_ctx","style","_createCommentVNode","_renderSlot","$slots","HotColumn","inject","createColumnSettings","_objectSpread","renderer","editor","unmounted","createCommentVNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAMA,oBAAoB,GAAGC,MAAM,CAAC,YAAY,CAAC;;AAEjD;AACA;AACA;AACO,IAAMC,qBAAqB,GAAG,+EAA+E,GAClH,iBAAiB;;AAEnB;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAACC,MAAe,EAAEC,GAAW,EAAW;EACpE,OAAOC,MAAM,CAACC,SAAS,CAACJ,cAAc,CAACK,IAAI,CAACJ,MAAM,EAAEC,GAAG,CAAC;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,WAAWA,CAACC,MAAgC,EAA2B;EACrF,IAAMC,eAAe,GAAGC,gCAAY,CAACC,KAAK,CAACC,aAAa,EAAE;EAC1D,IAAMC,UAAmC,GAAG,EAAE;EAE9CT,MAAM,CAACU,MAAM,CAACD,UAAU,EAAEH,gCAAY,CAACK,eAAe,CAAC;;AAEvD;AACA,EAAA,KAAK,IAAMC,IAAI,IAAIH,UAAU,EAAE;IAC7BA,UAAU,CAACG,IAAI,CAAC,GAAG;MACjB,SAAA,EAASlB;KACV;AACH,EAAA;AAEA,EAAA,KAAK,IAAImB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGR,eAAe,CAACS,MAAM,EAAED,CAAC,EAAE,EAAE;AAC/CJ,IAAAA,UAAU,CAACJ,eAAe,CAACQ,CAAC,CAAC,CAAC,GAAG;MAC/B,SAAA,EAASnB;KACV;AACH,E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
|
5
5
|
* Gdynia, Poland, at Aleja Zwyciestwa 96-98, registered by the District Court in Gdansk under number
|
|
6
|
-
* 538651, EU tax ID number: PL5862294002, share capital: PLN
|
|
6
|
+
* 538651, EU tax ID number: PL5862294002, share capital: PLN 67,200.00.
|
|
7
7
|
*
|
|
8
8
|
* This software is protected by applicable copyright laws, including international treaties, and dual-
|
|
9
9
|
* licensed - depending on whether your use for commercial purposes, meaning intended for or
|
|
@@ -25,7 +25,7 @@
|
|
|
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: 18.
|
|
28
|
+
* Version: 18.1.0-rc7 (built at Fri Aug 28 2026 07:03:31 GMT+0000 (Coordinated Universal Time))
|
|
29
29
|
*/
|
|
30
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue"),require("handsontable/base")):"function"==typeof define&&define.amd?define(["exports","vue","handsontable/base"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Handsontable=t.Handsontable||{},t.Handsontable.vue={}),t.Vue,t.Handsontable)}(this,function(t,e,n){"use strict";function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=o(n);function i(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function
|
|
30
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vue"),require("handsontable/base")):"function"==typeof define&&define.amd?define(["exports","vue","handsontable/base"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).Handsontable=t.Handsontable||{},t.Handsontable.vue={}),t.Vue,t.Handsontable)}(this,function(t,e,n){"use strict";function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=o(n);function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,o=Array(e);e>n;n++)o[n]=t[n];return o}function s(t,e,n){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var o=n.call(t,e);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,o)}return n}function c(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var o,r,i,s,u=[],c=!0,a=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(o=i.call(n)).done)&&(u.push(o.value),u.length!==e);c=!0);}catch(t){a=!0,r=t}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(a)throw r}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}var l=Symbol("unassigned");function h(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function f(t){var e=r.default.hooks.getRegistered(),n={};for(var o in Object.assign(n,r.default.DefaultSettings),n)n[o]={default:l};for(var i=0;e.length>i;i++)n[e[i]]={default:l};return n.settings={default:l},"HotTable"===t&&(n.id={type:String,default:"hot-".concat(Math.random().toString(36).substring(5))}),n}function d(t){var e={},n=t.settings;if(n!==l)for(var o in n)h(n,o)&&n[o]!==l&&(e[o]=n[o]);for(var r in t)h(t,r)&&"settings"!==r&&t[r]!==l&&(e[r]=t[r]);return e}function m(t,e){var n=d(t),o=t.settings?t.settings:n,r=t.settings?n:null,i=(null==e?void 0:e._initOnlySettings)||[],s={};for(var u in o)!h(o,u)||void 0===o[u]||i.includes(u)||e&&"data"!==u&&p(e[u],o[u])||(s[u]=o[u]);for(var c in r)!h(r,c)||"id"===c||"settings"===c||void 0===r[c]||i.includes(c)||e&&"data"!==c&&p(e[c],r[c])||(s[c]=r[c]);return s}function p(t,e){var n=new WeakMap,o=0,r=function(t){var e=new WeakSet;return JSON.stringify(t,function(t,r){if("object"===a(r)&&null!==r){if(e.has(r))return;if(e.add(r),"undefined"!=typeof Node&&r instanceof Node){var i=n.get(r);return void 0===i&&n.set(r,i="__hot_node_".concat(o+=1,"__")),i}}return r})};if("function"==typeof t&&"function"==typeof e)return""+t==""+e;if(a(t)!==a(e))return!1;try{return r(t)===r(e)}catch(t){return!1}}var g=e.defineComponent({name:"HotTable",props:f("HotTable"),provide:function(){return{columnsCache:this.columnsCache,refreshColumns:this.refreshColumns}},watch:{$props:{handler:function(t){var e=m(t,this.hotInstance?this.hotInstance.getSettings():void 0);this.hotInstance&&void 0!==e&&(e.data&&(this.hotInstance.isColumnModificationAllowed()||!this.hotInstance.isColumnModificationAllowed()&&this.hotInstance.countSourceCols()===this.miscCache.currentSourceColumns)&&(this.matchHotMappersSize(),delete e.data),Object.keys(e).length?this.hotInstance.updateSettings(e):this.hotInstance.render(),this.miscCache.currentSourceColumns=this.hotInstance.countSourceCols())},deep:!0,immediate:!0}},data:function(){return{__hotInstance:null,miscCache:{currentSourceColumns:null},columnSettings:null,columnsCache:new Map,columnsRefreshScheduled:!1,get hotInstance(){return!this.__hotInstance||this.__hotInstance&&!this.__hotInstance.isDestroyed?this.__hotInstance:(console.warn("The Handsontable instance bound to this component was destroyed and cannot be used properly."),null)},set hotInstance(t){this.__hotInstance=t}}},methods:{hotInit:function(){var t=m(this.$props);t.columns=this.columnSettings?this.columnSettings:t.columns,this.hotInstance=e.markRaw(new r.default.Core(this.$el,t)),this.hotInstance.init(),this.miscCache.currentSourceColumns=this.hotInstance.countSourceCols()},matchHotMappersSize:function(){var t=this;if(this.hotInstance){var e,n=this.hotInstance.getSourceData(),o=[],r=[],i=this.hotInstance.rowIndexMapper.getNumberOfIndexes(),s=this.hotInstance.isColumnModificationAllowed(),u=0;if(n&&n.length!==i&&i>n.length)for(var c=n.length;i>c;c++)o.push(c);if(s)if(u=this.hotInstance.columnIndexMapper.getNumberOfIndexes(),n&&n[0]&&(null===(e=n[0])||void 0===e?void 0:e.length)!==u&&u>n[0].length)for(var a=n[0].length;u>a;a++)r.push(a);this.hotInstance.batch(function(){o.length>0?t.hotInstance.rowIndexMapper.removeIndexes(o):t.hotInstance.rowIndexMapper.insertIndexes(i-1,n.length-i),s&&0!==n.length&&(r.length>0?t.hotInstance.columnIndexMapper.removeIndexes(r):t.hotInstance.columnIndexMapper.insertIndexes(u-1,n[0].length-u))})}},getColumnSettings:function(){var t=Array.from(this.columnsCache.entries()).sort(function(t,e){var n=c(t,1)[0],o=c(e,1),r=n.$el,i=o[0].$el;if(!r||!i)return 0;var s=r.compareDocumentPosition(i);return s&Node.DOCUMENT_POSITION_FOLLOWING?-1:s&Node.DOCUMENT_POSITION_PRECEDING?1:0}).map(function(t){return c(t,2)[1]});return t.length?t:void 0},refreshColumns:function(){var t=this;this.columnsRefreshScheduled||(this.columnsRefreshScheduled=!0,this.$nextTick(function(){if(t.columnsRefreshScheduled=!1,t.hotInstance){var e=t.getColumnSettings(),n=t.columnSettings;!n&&!e||!!n&&!!e&&n.length===e.length&&n.every(function(t,n){return t===e[n]})||(t.columnSettings=e||null,t.hotInstance.updateSettings({columns:e||void 0}))}}))}},mounted:function(){this.columnSettings=this.getColumnSettings(),this.hotInit()},updated:function(){this.refreshColumns()},beforeUnmount:function(){this.hotInstance&&this.hotInstance.destroy()},version:"18.1.0-rc7"}),v=["id"];g.render=function(t,n,o,r,i,s){return e.openBlock(),e.createElementBlock("div",{id:t.id,style:{height:"100%"}},[e.createCommentVNode(" `hot-column` children render invisible comment anchors in source order.\n Handsontable appends its own DOM to this container without clearing\n pre-existing nodes, so the anchors survive; the parent reads their\n document position to order the columns. "),e.renderSlot(t.$slots,"default")],8,v)},g.__file="src/HotTable.vue";var b=e.defineComponent({name:"HotColumn",props:f("HotColumn"),inject:["columnsCache","refreshColumns"],methods:{createColumnSettings:function(){var t=d(this.$props),e=function(t){for(var e=1;arguments.length>e;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?u(Object(n),!0).forEach(function(e){s(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}({},t);t.renderer&&(e.renderer=t.renderer),t.editor&&(e.editor=t.editor),this.columnsCache.set(this,e)}},watch:{$props:{handler:function(){this.createColumnSettings(),this.refreshColumns()},deep:!0}},mounted:function(){this.createColumnSettings(),this.refreshColumns()},unmounted:function(){this.columnsCache.delete(this),this.refreshColumns()},render:function(){return e.createCommentVNode("hot-column")}});b.__file="src/HotColumn.vue",t.HotColumn=b,t.HotTable=g,t.default=g,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
31
31
|
//# sourceMappingURL=vue-handsontable.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue-handsontable.min.js","sources":["../src/helpers.ts","../src/HotTable.vue","../src/HotTable.vue?vue&type=template&id=54bcc3fa&lang.js","../src/HotColumn.vue"],"sourcesContent":["import Handsontable from 'handsontable/base';\nimport { HotTableProps, VueProps } from './types';\n\nconst unassignedPropSymbol = Symbol('unassigned');\n\n/**\n * Message for the warning thrown if the Handsontable instance has been destroyed.\n */\nexport const HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' +\n ' used properly.';\n\n/**\n * Check if at specified `key` there is any value for `object`.\n *\n * @param {object} object Object to search value at specyfic key.\n * @param {string} key String key to check.\n * @returns {boolean}\n */\nexport function hasOwnProperty(object: unknown, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\n/**\n * Generate an object containing all the available Handsontable properties and plugin hooks.\n *\n * @param {string} source Source for the factory (either 'HotTable' or 'HotColumn').\n * @returns {object}\n */\nexport function propFactory(source: 'HotTable' | 'HotColumn'): VueProps<HotTableProps> {\n const registeredHooks = Handsontable.hooks.getRegistered();\n const propSchema: VueProps<HotTableProps> = {};\n\n Object.assign(propSchema, Handsontable.DefaultSettings);\n\n // eslint-disable-next-line no-restricted-syntax, guard-for-in\n for (const prop in propSchema) {\n propSchema[prop] = {\n default: unassignedPropSymbol\n };\n }\n\n for (let i = 0; i < registeredHooks.length; i++) {\n propSchema[registeredHooks[i]] = {\n default: unassignedPropSymbol\n };\n }\n\n propSchema.settings = {\n default: unassignedPropSymbol\n };\n\n if (source === 'HotTable') {\n propSchema.id = {\n type: String,\n default: `hot-${Math.random().toString(36).substring(5)}`\n };\n }\n\n return propSchema;\n}\n\n/**\n * Filter out all of the unassigned props, and return only the one passed to the component.\n *\n * @param {object} props Object containing all the possible props.\n * @returns {object} Object containing only used props.\n */\nexport function filterPassedProps(props) {\n const filteredProps: VueProps<HotTableProps> = {};\n const columnSettingsProp = props.settings;\n\n if (columnSettingsProp !== unassignedPropSymbol) {\n // eslint-disable-next-line no-restricted-syntax\n for (const propName in columnSettingsProp) {\n if (hasOwnProperty(columnSettingsProp, propName) && columnSettingsProp[propName] !== unassignedPropSymbol) {\n filteredProps[propName] = columnSettingsProp[propName];\n }\n }\n }\n\n // eslint-disable-next-line no-restricted-syntax\n for (const propName in props) {\n if (hasOwnProperty(props, propName) && propName !== 'settings' && props[propName] !== unassignedPropSymbol) {\n filteredProps[propName] = props[propName];\n }\n }\n\n return filteredProps;\n}\n\n/**\n * Prepare the settings object to be used as the settings for Handsontable, based on the props provided to the component.\n *\n * @param {HotTableProps} props The props passed to the component.\n * @param {Handsontable.GridSettings} currentSettings The current Handsontable settings.\n * @returns {Handsontable.GridSettings} An object containing the properties, ready to be used within Handsontable.\n */\nexport function prepareSettings(props: HotTableProps, currentSettings?: Handsontable.GridSettings): HotTableProps {\n const assignedProps: VueProps<HotTableProps> = filterPassedProps(props);\n const hotSettingsInProps: Handsontable.GridSettings = props.settings ? props.settings : assignedProps;\n const additionalHotSettingsInProps: Handsontable.GridSettings = props.settings ? assignedProps : null;\n const initOnlySettingKeys: string[] =\n (currentSettings as any)?._initOnlySettings || [];\n const newSettings: Handsontable.GridSettings = {};\n\n // eslint-disable-next-line no-restricted-syntax\n for (const key in hotSettingsInProps) {\n if (\n hasOwnProperty(hotSettingsInProps, key) &&\n hotSettingsInProps[key] !== void 0 &&\n !initOnlySettingKeys.includes(key) &&\n ((currentSettings && key !== 'data') ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)\n ) {\n newSettings[key] = hotSettingsInProps[key];\n }\n }\n\n // eslint-disable-next-line no-restricted-syntax\n for (const key in additionalHotSettingsInProps) {\n if (\n hasOwnProperty(additionalHotSettingsInProps, key) &&\n key !== 'id' &&\n key !== 'settings' &&\n additionalHotSettingsInProps[key] !== void 0 &&\n !initOnlySettingKeys.includes(key) &&\n ((currentSettings && key !== 'data')\n ? !simpleEqual(currentSettings[key], additionalHotSettingsInProps[key]) : true)\n ) {\n newSettings[key] = additionalHotSettingsInProps[key];\n }\n }\n\n return newSettings;\n}\n\n/**\n * Compare two objects using `JSON.stringify`.\n * *Note: * As it's using the stringify function to compare objects, the property order in both objects is\n * important. It will return `false` for the same objects, if they're defined in a different order.\n *\n * @param {object} objectA First object to compare.\n * @param {object} objectB Second object to compare.\n * @returns {boolean} `true` if they're the same, `false` otherwise.\n */\nfunction simpleEqual(objectA, objectB) {\n // Shared across both stringify calls so the same Node/function instance maps\n // to the same identity token in objectA's string and objectB's string.\n const identityMap = new WeakMap<object, string>();\n let nextIdentityId = 0;\n\n const stringifyToJSON = (val) => {\n const seen = new WeakSet();\n\n return JSON.stringify(val, (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return undefined;\n }\n\n seen.add(value);\n\n // DOM nodes carry framework metadata as enumerable own properties\n // (e.g., Vue 3 attaches `_vnode` to the mount root). Recursing into them\n // can reach getters that throw - see GH #11220 - and produces noise that\n // is irrelevant to settings equality. Replace each Node with an identity\n // token so reference equality is still detected.\n if (typeof Node !== 'undefined' && value instanceof Node) {\n let id = identityMap.get(value);\n\n if (id === undefined) {\n nextIdentityId += 1;\n id = `__hot_node_${nextIdentityId}__`;\n identityMap.set(value, id);\n }\n\n return id;\n }\n }\n\n return value;\n });\n };\n\n if (typeof objectA === 'function' && typeof objectB === 'function') {\n return objectA.toString() === objectB.toString();\n\n } else if (typeof objectA !== typeof objectB) {\n return false;\n\n } else {\n try {\n return stringifyToJSON(objectA) === stringifyToJSON(objectB);\n } catch (e) {\n // If either side cannot be serialized (e.g., contains a throwing getter),\n // assume the values are not equal so the wrapper still updates settings.\n return false;\n }\n }\n}\n","<template>\n <div :id=\"id\" style=\"height: 100%\">\n <slot></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, VNode, markRaw } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport Handsontable from 'handsontable/base';\nimport {\n HOT_DESTROYED_WARNING,\n prepareSettings,\n propFactory,\n} from './helpers';\nimport {\n HotTableProps,\n} from './types';\nimport * as packageJson from '../package.json';\n\nconst HotTable = defineComponent({\n name: 'HotTable',\n props: propFactory('HotTable'),\n provide() {\n return {\n columnsCache: this.columnsCache\n };\n },\n watch: {\n $props: {\n handler(props) {\n const settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);\n\n if (!this.hotInstance || settings === void 0) {\n return;\n }\n\n if (settings.data) {\n if (\n this.hotInstance.isColumnModificationAllowed() ||\n (\n !this.hotInstance.isColumnModificationAllowed() &&\n this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns\n )\n ) {\n // If the dataset dimensions change, update the index mappers.\n this.matchHotMappersSize();\n\n // Data is automatically synchronized by reference.\n delete settings.data;\n }\n }\n\n // If there are another options changed, update the HOT settings, render the table otherwise.\n if (Object.keys(settings).length) {\n this.hotInstance.updateSettings(settings);\n\n } else {\n this.hotInstance.render();\n }\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n deep: true,\n immediate: true,\n },\n },\n data() {\n return {\n /* eslint-disable vue/no-reserved-keys */\n __hotInstance: null as Handsontable,\n /* eslint-enable vue/no-reserved-keys */\n miscCache: {\n currentSourceColumns: null,\n },\n columnSettings: null as HotTableProps[],\n columnsCache: new Map<VNode, HotTableProps>(),\n get hotInstance(): Handsontable | null {\n if (!this.__hotInstance || (this.__hotInstance && !this.__hotInstance.isDestroyed)) {\n\n // Will return the Handsontable instance or `null` if it's not yet been created.\n return this.__hotInstance;\n\n } else {\n /* eslint-disable-next-line no-console */\n console.warn(HOT_DESTROYED_WARNING);\n\n return null;\n }\n },\n set hotInstance(hotInstance: Handsontable) {\n this.__hotInstance = hotInstance;\n },\n };\n },\n methods: {\n /**\n * Initialize Handsontable.\n */\n hotInit() {\n const newSettings = prepareSettings(this.$props);\n\n newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;\n\n this.hotInstance = markRaw<Handsontable>(new Handsontable.Core(this.$el, newSettings));\n this.hotInstance.init();\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n\n matchHotMappersSize(): void {\n if (!this.hotInstance) {\n return;\n }\n\n const data: Handsontable.CellValue[][] = this.hotInstance.getSourceData();\n const rowsToRemove: number[] = [];\n const columnsToRemove: number[] = [];\n const indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes();\n const isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed();\n let indexMapperColumnCount = 0;\n\n if (data && data.length !== indexMapperRowCount) {\n if (data.length < indexMapperRowCount) {\n for (let r = data.length; r < indexMapperRowCount; r++) {\n rowsToRemove.push(r);\n }\n }\n }\n\n if (isColumnModificationAllowed) {\n indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes();\n\n if (data && data[0] && data[0]?.length !== indexMapperColumnCount) {\n if (data[0].length < indexMapperColumnCount) {\n for (let c = data[0].length; c < indexMapperColumnCount; c++) {\n columnsToRemove.push(c);\n }\n }\n }\n }\n\n this.hotInstance.batch(() => {\n if (rowsToRemove.length > 0) {\n this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove);\n\n } else {\n this.hotInstance.rowIndexMapper\n .insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount);\n }\n\n if (isColumnModificationAllowed && data.length !== 0) {\n if (columnsToRemove.length > 0) {\n this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove);\n\n } else {\n this.hotInstance.columnIndexMapper\n .insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount);\n }\n }\n });\n },\n\n /**\n * Get settings for the columns provided in the `hot-column` components.\n *\n * @returns {HotTableProps[] | undefined}\n */\n getColumnSettings(): HotTableProps[] | void {\n const columnSettings: HotTableProps[] = Array.from(this.columnsCache.values());\n\n return columnSettings.length ? columnSettings : void 0;\n },\n },\n mounted() {\n this.columnSettings = this.getColumnSettings();\n this.hotInit();\n },\n beforeUnmount() {\n if (this.hotInstance) {\n this.hotInstance.destroy();\n }\n },\n version: (packageJson as unknown as { version: string }).version,\n});\n\nexport default HotTable;\nexport { HotTable };\n</script>\n","<template>\n <div :id=\"id\" style=\"height: 100%\">\n <slot></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, VNode, markRaw } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport Handsontable from 'handsontable/base';\nimport {\n HOT_DESTROYED_WARNING,\n prepareSettings,\n propFactory,\n} from './helpers';\nimport {\n HotTableProps,\n} from './types';\nimport * as packageJson from '../package.json';\n\nconst HotTable = defineComponent({\n name: 'HotTable',\n props: propFactory('HotTable'),\n provide() {\n return {\n columnsCache: this.columnsCache\n };\n },\n watch: {\n $props: {\n handler(props) {\n const settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);\n\n if (!this.hotInstance || settings === void 0) {\n return;\n }\n\n if (settings.data) {\n if (\n this.hotInstance.isColumnModificationAllowed() ||\n (\n !this.hotInstance.isColumnModificationAllowed() &&\n this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns\n )\n ) {\n // If the dataset dimensions change, update the index mappers.\n this.matchHotMappersSize();\n\n // Data is automatically synchronized by reference.\n delete settings.data;\n }\n }\n\n // If there are another options changed, update the HOT settings, render the table otherwise.\n if (Object.keys(settings).length) {\n this.hotInstance.updateSettings(settings);\n\n } else {\n this.hotInstance.render();\n }\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n deep: true,\n immediate: true,\n },\n },\n data() {\n return {\n /* eslint-disable vue/no-reserved-keys */\n __hotInstance: null as Handsontable,\n /* eslint-enable vue/no-reserved-keys */\n miscCache: {\n currentSourceColumns: null,\n },\n columnSettings: null as HotTableProps[],\n columnsCache: new Map<VNode, HotTableProps>(),\n get hotInstance(): Handsontable | null {\n if (!this.__hotInstance || (this.__hotInstance && !this.__hotInstance.isDestroyed)) {\n\n // Will return the Handsontable instance or `null` if it's not yet been created.\n return this.__hotInstance;\n\n } else {\n /* eslint-disable-next-line no-console */\n console.warn(HOT_DESTROYED_WARNING);\n\n return null;\n }\n },\n set hotInstance(hotInstance: Handsontable) {\n this.__hotInstance = hotInstance;\n },\n };\n },\n methods: {\n /**\n * Initialize Handsontable.\n */\n hotInit() {\n const newSettings = prepareSettings(this.$props);\n\n newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;\n\n this.hotInstance = markRaw<Handsontable>(new Handsontable.Core(this.$el, newSettings));\n this.hotInstance.init();\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n\n matchHotMappersSize(): void {\n if (!this.hotInstance) {\n return;\n }\n\n const data: Handsontable.CellValue[][] = this.hotInstance.getSourceData();\n const rowsToRemove: number[] = [];\n const columnsToRemove: number[] = [];\n const indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes();\n const isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed();\n let indexMapperColumnCount = 0;\n\n if (data && data.length !== indexMapperRowCount) {\n if (data.length < indexMapperRowCount) {\n for (let r = data.length; r < indexMapperRowCount; r++) {\n rowsToRemove.push(r);\n }\n }\n }\n\n if (isColumnModificationAllowed) {\n indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes();\n\n if (data && data[0] && data[0]?.length !== indexMapperColumnCount) {\n if (data[0].length < indexMapperColumnCount) {\n for (let c = data[0].length; c < indexMapperColumnCount; c++) {\n columnsToRemove.push(c);\n }\n }\n }\n }\n\n this.hotInstance.batch(() => {\n if (rowsToRemove.length > 0) {\n this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove);\n\n } else {\n this.hotInstance.rowIndexMapper\n .insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount);\n }\n\n if (isColumnModificationAllowed && data.length !== 0) {\n if (columnsToRemove.length > 0) {\n this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove);\n\n } else {\n this.hotInstance.columnIndexMapper\n .insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount);\n }\n }\n });\n },\n\n /**\n * Get settings for the columns provided in the `hot-column` components.\n *\n * @returns {HotTableProps[] | undefined}\n */\n getColumnSettings(): HotTableProps[] | void {\n const columnSettings: HotTableProps[] = Array.from(this.columnsCache.values());\n\n return columnSettings.length ? columnSettings : void 0;\n },\n },\n mounted() {\n this.columnSettings = this.getColumnSettings();\n this.hotInit();\n },\n beforeUnmount() {\n if (this.hotInstance) {\n this.hotInstance.destroy();\n }\n },\n version: (packageJson as unknown as { version: string }).version,\n});\n\nexport default HotTable;\nexport { HotTable };\n</script>\n","<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport {\n propFactory,\n filterPassedProps\n} from './helpers';\n\nconst HotColumn = defineComponent({\n name: 'HotColumn',\n props: propFactory('HotColumn'),\n inject: ['columnsCache'],\n methods: {\n /**\n * Create the column settings based on the data provided to the `hot-column`\n * component and it's child components.\n */\n createColumnSettings(): void {\n const assignedProps = filterPassedProps(this.$props);\n const columnSettings = { ...assignedProps };\n\n if (assignedProps.renderer) {\n columnSettings.renderer = assignedProps.renderer;\n }\n\n if (assignedProps.editor) {\n columnSettings.editor = assignedProps.editor;\n }\n\n this.columnsCache.set(this, columnSettings);\n }\n },\n mounted() {\n this.createColumnSettings();\n },\n unmounted() {\n this.columnsCache.delete(this);\n },\n render() {\n return null;\n }\n});\n\nexport default HotColumn;\nexport { HotColumn };\n</script>\n"],"names":["unassignedPropSymbol","Symbol","hasOwnProperty","object","key","Object","prototype","call","propFactory","source","registeredHooks","Handsontable","hooks","getRegistered","propSchema","prop","assign","DefaultSettings","default","i","length","settings","id","type","String","concat","Math","random","toString","substring","filterPassedProps","props","filteredProps","columnSettingsProp","propName","prepareSettings","currentSettings","assignedProps","hotSettingsInProps","additionalHotSettingsInProps","initOnlySettingKeys","_initOnlySettings","newSettings","includes","simpleEqual","objectA","objectB","identityMap","WeakMap","nextIdentityId","stringifyToJSON","val","seen","WeakSet","JSON","stringify","value","_typeof","has","add","Node","get","undefined","set","e","HotTable","defineComponent","name","provide","columnsCache","this","watch","$props","handler","hotInstance","getSettings","data","isColumnModificationAllowed","countSourceCols","miscCache","currentSourceColumns","matchHotMappersSize","keys","updateSettings","render","deep","immediate","__hotInstance","columnSettings","Map","isDestroyed","console","warn","methods","hotInit","columns","markRaw","Core","$el","init","_this","_data$","getSourceData","rowsToRemove","columnsToRemove","indexMapperRowCount","rowIndexMapper","getNumberOfIndexes","indexMapperColumnCount","r","push","columnIndexMapper","c","batch","removeIndexes","insertIndexes","getColumnSettings","Array","from","values","mounted","beforeUnmount","destroy","version","_createElementBlock","_ctx","style","height","_renderSlot","$slots","HotColumn","inject","createColumnSettings","_objectSpread","renderer","editor","unmounted"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;i0CAGA,IAAMA,EAAuBC,OAAO,cAe7B,SAASC,EAAeC,EAAiBC,GAC9C,OAAOC,OAAOC,UAAUJ,eAAeK,KAAKJ,EAAQC,EACtD,CAQO,SAASI,EAAYC,GAC1B,IAAMC,EAAkBC,EAAAA,QAAaC,MAAMC,gBACrCC,EAAsC,CAAA,EAK5C,IAAK,IAAMC,KAHXV,OAAOW,OAAOF,EAAYH,EAAAA,QAAaM,iBAGpBH,EACjBA,EAAWC,GAAQ,CACjBG,QAASlB,GAIb,IAAK,IAAImB,EAAI,EAAOT,EAAgBU,OAApBD,EAA4BA,IAC1CL,EAAWJ,EAAgBS,IAAM,CAC/BD,QA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ts","../src/HotTable.vue","../src/HotTable.vue?vue&type=template&id=54bcc3fa&lang.js","../src/HotColumn.vue"],"sourcesContent":["import Handsontable from 'handsontable/base';\nimport { HotTableProps, VueProps } from './types';\n\nconst unassignedPropSymbol = Symbol('unassigned');\n\n/**\n * Message for the warning thrown if the Handsontable instance has been destroyed.\n */\nexport const HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' +\n ' used properly.';\n\n/**\n * Check if at specified `key` there is any value for `object`.\n *\n * @param {object} object Object to search value at specyfic key.\n * @param {string} key String key to check.\n * @returns {boolean}\n */\nexport function hasOwnProperty(object: unknown, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\n/**\n * Generate an object containing all the available Handsontable properties and plugin hooks.\n *\n * @param {string} source Source for the factory (either 'HotTable' or 'HotColumn').\n * @returns {object}\n */\nexport function propFactory(source: 'HotTable' | 'HotColumn'): VueProps<HotTableProps> {\n const registeredHooks = Handsontable.hooks.getRegistered();\n const propSchema: VueProps<HotTableProps> = {};\n\n Object.assign(propSchema, Handsontable.DefaultSettings);\n\n // eslint-disable-next-line no-restricted-syntax, guard-for-in\n for (const prop in propSchema) {\n propSchema[prop] = {\n default: unassignedPropSymbol\n };\n }\n\n for (let i = 0; i < registeredHooks.length; i++) {\n propSchema[registeredHooks[i]] = {\n default: unassignedPropSymbol\n };\n }\n\n propSchema.settings = {\n default: unassignedPropSymbol\n };\n\n if (source === 'HotTable') {\n propSchema.id = {\n type: String,\n default: `hot-${Math.random().toString(36).substring(5)}`\n };\n }\n\n return propSchema;\n}\n\n/**\n * Filter out all of the unassigned props, and return only the one passed to the component.\n *\n * @param {object} props Object containing all the possible props.\n * @returns {object} Object containing only used props.\n */\nexport function filterPassedProps(props) {\n const filteredProps: VueProps<HotTableProps> = {};\n const columnSettingsProp = props.settings;\n\n if (columnSettingsProp !== unassignedPropSymbol) {\n // eslint-disable-next-line no-restricted-syntax\n for (const propName in columnSettingsProp) {\n if (hasOwnProperty(columnSettingsProp, propName) && columnSettingsProp[propName] !== unassignedPropSymbol) {\n filteredProps[propName] = columnSettingsProp[propName];\n }\n }\n }\n\n // eslint-disable-next-line no-restricted-syntax\n for (const propName in props) {\n if (hasOwnProperty(props, propName) && propName !== 'settings' && props[propName] !== unassignedPropSymbol) {\n filteredProps[propName] = props[propName];\n }\n }\n\n return filteredProps;\n}\n\n/**\n * Prepare the settings object to be used as the settings for Handsontable, based on the props provided to the component.\n *\n * @param {HotTableProps} props The props passed to the component.\n * @param {Handsontable.GridSettings} currentSettings The current Handsontable settings.\n * @returns {Handsontable.GridSettings} An object containing the properties, ready to be used within Handsontable.\n */\nexport function prepareSettings(props: HotTableProps, currentSettings?: Handsontable.GridSettings): HotTableProps {\n const assignedProps: VueProps<HotTableProps> = filterPassedProps(props);\n const hotSettingsInProps: Handsontable.GridSettings = props.settings ? props.settings : assignedProps;\n const additionalHotSettingsInProps: Handsontable.GridSettings = props.settings ? assignedProps : null;\n const initOnlySettingKeys: string[] =\n (currentSettings as any)?._initOnlySettings || [];\n const newSettings: Handsontable.GridSettings = {};\n\n // eslint-disable-next-line no-restricted-syntax\n for (const key in hotSettingsInProps) {\n if (\n hasOwnProperty(hotSettingsInProps, key) &&\n hotSettingsInProps[key] !== void 0 &&\n !initOnlySettingKeys.includes(key) &&\n ((currentSettings && key !== 'data') ? !simpleEqual(currentSettings[key], hotSettingsInProps[key]) : true)\n ) {\n newSettings[key] = hotSettingsInProps[key];\n }\n }\n\n // eslint-disable-next-line no-restricted-syntax\n for (const key in additionalHotSettingsInProps) {\n if (\n hasOwnProperty(additionalHotSettingsInProps, key) &&\n key !== 'id' &&\n key !== 'settings' &&\n additionalHotSettingsInProps[key] !== void 0 &&\n !initOnlySettingKeys.includes(key) &&\n ((currentSettings && key !== 'data')\n ? !simpleEqual(currentSettings[key], additionalHotSettingsInProps[key]) : true)\n ) {\n newSettings[key] = additionalHotSettingsInProps[key];\n }\n }\n\n return newSettings;\n}\n\n/**\n * Compare two objects using `JSON.stringify`.\n * *Note: * As it's using the stringify function to compare objects, the property order in both objects is\n * important. It will return `false` for the same objects, if they're defined in a different order.\n *\n * @param {object} objectA First object to compare.\n * @param {object} objectB Second object to compare.\n * @returns {boolean} `true` if they're the same, `false` otherwise.\n */\nfunction simpleEqual(objectA, objectB) {\n // Shared across both stringify calls so the same Node/function instance maps\n // to the same identity token in objectA's string and objectB's string.\n const identityMap = new WeakMap<object, string>();\n let nextIdentityId = 0;\n\n const stringifyToJSON = (val) => {\n const seen = new WeakSet();\n\n return JSON.stringify(val, (key, value) => {\n if (typeof value === 'object' && value !== null) {\n if (seen.has(value)) {\n return undefined;\n }\n\n seen.add(value);\n\n // DOM nodes carry framework metadata as enumerable own properties\n // (e.g., Vue 3 attaches `_vnode` to the mount root). Recursing into them\n // can reach getters that throw - see GH #11220 - and produces noise that\n // is irrelevant to settings equality. Replace each Node with an identity\n // token so reference equality is still detected.\n if (typeof Node !== 'undefined' && value instanceof Node) {\n let id = identityMap.get(value);\n\n if (id === undefined) {\n nextIdentityId += 1;\n id = `__hot_node_${nextIdentityId}__`;\n identityMap.set(value, id);\n }\n\n return id;\n }\n }\n\n return value;\n });\n };\n\n if (typeof objectA === 'function' && typeof objectB === 'function') {\n return objectA.toString() === objectB.toString();\n\n } else if (typeof objectA !== typeof objectB) {\n return false;\n\n } else {\n try {\n return stringifyToJSON(objectA) === stringifyToJSON(objectB);\n } catch (e) {\n // If either side cannot be serialized (e.g., contains a throwing getter),\n // assume the values are not equal so the wrapper still updates settings.\n return false;\n }\n }\n}\n","<template>\n <div :id=\"id\" style=\"height: 100%\">\n <!-- `hot-column` children render invisible comment anchors in source order.\n Handsontable appends its own DOM to this container without clearing\n pre-existing nodes, so the anchors survive; the parent reads their\n document position to order the columns. -->\n <slot></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, VNode, markRaw } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport Handsontable from 'handsontable/base';\nimport {\n HOT_DESTROYED_WARNING,\n prepareSettings,\n propFactory,\n} from './helpers';\nimport {\n HotTableProps,\n} from './types';\nimport * as packageJson from '../package.json';\n\nconst HotTable = defineComponent({\n name: 'HotTable',\n props: propFactory('HotTable'),\n provide() {\n return {\n columnsCache: this.columnsCache,\n refreshColumns: this.refreshColumns,\n };\n },\n watch: {\n $props: {\n handler(props) {\n const settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);\n\n if (!this.hotInstance || settings === void 0) {\n return;\n }\n\n if (settings.data) {\n if (\n this.hotInstance.isColumnModificationAllowed() ||\n (\n !this.hotInstance.isColumnModificationAllowed() &&\n this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns\n )\n ) {\n // If the dataset dimensions change, update the index mappers.\n this.matchHotMappersSize();\n\n // Data is automatically synchronized by reference.\n delete settings.data;\n }\n }\n\n // If there are another options changed, update the HOT settings, render the table otherwise.\n if (Object.keys(settings).length) {\n this.hotInstance.updateSettings(settings);\n\n } else {\n this.hotInstance.render();\n }\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n deep: true,\n immediate: true,\n },\n },\n data() {\n return {\n /* eslint-disable vue/no-reserved-keys */\n __hotInstance: null as Handsontable,\n /* eslint-enable vue/no-reserved-keys */\n miscCache: {\n currentSourceColumns: null,\n },\n columnSettings: null as HotTableProps[],\n columnsCache: new Map<VNode, HotTableProps>(),\n columnsRefreshScheduled: false,\n get hotInstance(): Handsontable | null {\n if (!this.__hotInstance || (this.__hotInstance && !this.__hotInstance.isDestroyed)) {\n\n // Will return the Handsontable instance or `null` if it's not yet been created.\n return this.__hotInstance;\n\n } else {\n /* eslint-disable-next-line no-console */\n console.warn(HOT_DESTROYED_WARNING);\n\n return null;\n }\n },\n set hotInstance(hotInstance: Handsontable) {\n this.__hotInstance = hotInstance;\n },\n };\n },\n methods: {\n /**\n * Initialize Handsontable.\n */\n hotInit() {\n const newSettings = prepareSettings(this.$props);\n\n newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;\n\n this.hotInstance = markRaw<Handsontable>(new Handsontable.Core(this.$el, newSettings));\n this.hotInstance.init();\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n\n matchHotMappersSize(): void {\n if (!this.hotInstance) {\n return;\n }\n\n const data: Handsontable.CellValue[][] = this.hotInstance.getSourceData();\n const rowsToRemove: number[] = [];\n const columnsToRemove: number[] = [];\n const indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes();\n const isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed();\n let indexMapperColumnCount = 0;\n\n if (data && data.length !== indexMapperRowCount) {\n if (data.length < indexMapperRowCount) {\n for (let r = data.length; r < indexMapperRowCount; r++) {\n rowsToRemove.push(r);\n }\n }\n }\n\n if (isColumnModificationAllowed) {\n indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes();\n\n if (data && data[0] && data[0]?.length !== indexMapperColumnCount) {\n if (data[0].length < indexMapperColumnCount) {\n for (let c = data[0].length; c < indexMapperColumnCount; c++) {\n columnsToRemove.push(c);\n }\n }\n }\n }\n\n this.hotInstance.batch(() => {\n if (rowsToRemove.length > 0) {\n this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove);\n\n } else {\n this.hotInstance.rowIndexMapper\n .insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount);\n }\n\n if (isColumnModificationAllowed && data.length !== 0) {\n if (columnsToRemove.length > 0) {\n this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove);\n\n } else {\n this.hotInstance.columnIndexMapper\n .insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount);\n }\n }\n });\n },\n\n /**\n * Get settings for the columns provided in the `hot-column` components.\n *\n * The columns are ordered by the document position of each `hot-column`'s\n * anchor node, not by the `columnsCache` insertion order. This keeps the\n * order correct when columns are inserted in the middle, removed, or\n * reordered, and when a `hot-column` is nested inside a wrapper component.\n *\n * @returns {HotTableProps[] | undefined}\n */\n getColumnSettings(): HotTableProps[] | void {\n const orderedColumns = Array.from(this.columnsCache.entries())\n .sort(([columnA], [columnB]) => {\n const anchorA = (columnA as { $el?: Node }).$el;\n const anchorB = (columnB as { $el?: Node }).$el;\n\n if (!anchorA || !anchorB) {\n return 0;\n }\n\n const position = anchorA.compareDocumentPosition(anchorB);\n\n // eslint-disable-next-line no-bitwise\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n return -1;\n }\n\n // eslint-disable-next-line no-bitwise\n if (position & Node.DOCUMENT_POSITION_PRECEDING) {\n return 1;\n }\n\n return 0;\n })\n .map(([, columnSettings]) => columnSettings);\n\n return orderedColumns.length ? orderedColumns : void 0;\n },\n\n /**\n * Re-read the column settings declared by `hot-column` children and push them\n * to the Handsontable instance. Called by children on mount, prop change, and\n * unmount, and by the parent on reorder. Multiple notifications in the same\n * tick are coalesced into a single `updateSettings` call.\n */\n refreshColumns(): void {\n if (this.columnsRefreshScheduled) {\n return;\n }\n\n this.columnsRefreshScheduled = true;\n\n this.$nextTick(() => {\n this.columnsRefreshScheduled = false;\n\n if (!this.hotInstance) {\n return;\n }\n\n const newColumnSettings = this.getColumnSettings();\n const previousColumnSettings = this.columnSettings;\n\n // Each `hot-column` rebuilds its settings object whenever its props change,\n // so an unchanged column keeps the same object reference. Comparing the\n // arrays by reference and order is cheaper than a deep compare and avoids\n // an `updateSettings` call on unrelated re-renders (e.g. data-only updates).\n const isUnchanged =\n (!previousColumnSettings && !newColumnSettings) ||\n (!!previousColumnSettings && !!newColumnSettings &&\n previousColumnSettings.length === newColumnSettings.length &&\n previousColumnSettings.every((settings, index) => settings === newColumnSettings[index]));\n\n if (isUnchanged) {\n return;\n }\n\n this.columnSettings = newColumnSettings || null;\n this.hotInstance.updateSettings({ columns: newColumnSettings || void 0 });\n });\n },\n },\n mounted() {\n this.columnSettings = this.getColumnSettings();\n this.hotInit();\n },\n updated() {\n // Reordering keyed `hot-column` children reuses their instances and fires no\n // child lifecycle hook, so the children cannot notify on their own. The slot\n // vnodes do change, which re-renders `HotTable` - refresh from here to cover\n // reorders (coalesced with any child-triggered refresh).\n this.refreshColumns();\n },\n beforeUnmount() {\n if (this.hotInstance) {\n this.hotInstance.destroy();\n }\n },\n version: (packageJson as unknown as { version: string }).version,\n});\n\nexport default HotTable;\nexport { HotTable };\n</script>\n","<template>\n <div :id=\"id\" style=\"height: 100%\">\n <!-- `hot-column` children render invisible comment anchors in source order.\n Handsontable appends its own DOM to this container without clearing\n pre-existing nodes, so the anchors survive; the parent reads their\n document position to order the columns. -->\n <slot></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, VNode, markRaw } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport Handsontable from 'handsontable/base';\nimport {\n HOT_DESTROYED_WARNING,\n prepareSettings,\n propFactory,\n} from './helpers';\nimport {\n HotTableProps,\n} from './types';\nimport * as packageJson from '../package.json';\n\nconst HotTable = defineComponent({\n name: 'HotTable',\n props: propFactory('HotTable'),\n provide() {\n return {\n columnsCache: this.columnsCache,\n refreshColumns: this.refreshColumns,\n };\n },\n watch: {\n $props: {\n handler(props) {\n const settings = prepareSettings(props, this.hotInstance ? this.hotInstance.getSettings() : void 0);\n\n if (!this.hotInstance || settings === void 0) {\n return;\n }\n\n if (settings.data) {\n if (\n this.hotInstance.isColumnModificationAllowed() ||\n (\n !this.hotInstance.isColumnModificationAllowed() &&\n this.hotInstance.countSourceCols() === this.miscCache.currentSourceColumns\n )\n ) {\n // If the dataset dimensions change, update the index mappers.\n this.matchHotMappersSize();\n\n // Data is automatically synchronized by reference.\n delete settings.data;\n }\n }\n\n // If there are another options changed, update the HOT settings, render the table otherwise.\n if (Object.keys(settings).length) {\n this.hotInstance.updateSettings(settings);\n\n } else {\n this.hotInstance.render();\n }\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n deep: true,\n immediate: true,\n },\n },\n data() {\n return {\n /* eslint-disable vue/no-reserved-keys */\n __hotInstance: null as Handsontable,\n /* eslint-enable vue/no-reserved-keys */\n miscCache: {\n currentSourceColumns: null,\n },\n columnSettings: null as HotTableProps[],\n columnsCache: new Map<VNode, HotTableProps>(),\n columnsRefreshScheduled: false,\n get hotInstance(): Handsontable | null {\n if (!this.__hotInstance || (this.__hotInstance && !this.__hotInstance.isDestroyed)) {\n\n // Will return the Handsontable instance or `null` if it's not yet been created.\n return this.__hotInstance;\n\n } else {\n /* eslint-disable-next-line no-console */\n console.warn(HOT_DESTROYED_WARNING);\n\n return null;\n }\n },\n set hotInstance(hotInstance: Handsontable) {\n this.__hotInstance = hotInstance;\n },\n };\n },\n methods: {\n /**\n * Initialize Handsontable.\n */\n hotInit() {\n const newSettings = prepareSettings(this.$props);\n\n newSettings.columns = this.columnSettings ? this.columnSettings : newSettings.columns;\n\n this.hotInstance = markRaw<Handsontable>(new Handsontable.Core(this.$el, newSettings));\n this.hotInstance.init();\n\n this.miscCache.currentSourceColumns = this.hotInstance.countSourceCols();\n },\n\n matchHotMappersSize(): void {\n if (!this.hotInstance) {\n return;\n }\n\n const data: Handsontable.CellValue[][] = this.hotInstance.getSourceData();\n const rowsToRemove: number[] = [];\n const columnsToRemove: number[] = [];\n const indexMapperRowCount = this.hotInstance.rowIndexMapper.getNumberOfIndexes();\n const isColumnModificationAllowed = this.hotInstance.isColumnModificationAllowed();\n let indexMapperColumnCount = 0;\n\n if (data && data.length !== indexMapperRowCount) {\n if (data.length < indexMapperRowCount) {\n for (let r = data.length; r < indexMapperRowCount; r++) {\n rowsToRemove.push(r);\n }\n }\n }\n\n if (isColumnModificationAllowed) {\n indexMapperColumnCount = this.hotInstance.columnIndexMapper.getNumberOfIndexes();\n\n if (data && data[0] && data[0]?.length !== indexMapperColumnCount) {\n if (data[0].length < indexMapperColumnCount) {\n for (let c = data[0].length; c < indexMapperColumnCount; c++) {\n columnsToRemove.push(c);\n }\n }\n }\n }\n\n this.hotInstance.batch(() => {\n if (rowsToRemove.length > 0) {\n this.hotInstance.rowIndexMapper.removeIndexes(rowsToRemove);\n\n } else {\n this.hotInstance.rowIndexMapper\n .insertIndexes(indexMapperRowCount - 1, data.length - indexMapperRowCount);\n }\n\n if (isColumnModificationAllowed && data.length !== 0) {\n if (columnsToRemove.length > 0) {\n this.hotInstance.columnIndexMapper.removeIndexes(columnsToRemove);\n\n } else {\n this.hotInstance.columnIndexMapper\n .insertIndexes(indexMapperColumnCount - 1, data[0].length - indexMapperColumnCount);\n }\n }\n });\n },\n\n /**\n * Get settings for the columns provided in the `hot-column` components.\n *\n * The columns are ordered by the document position of each `hot-column`'s\n * anchor node, not by the `columnsCache` insertion order. This keeps the\n * order correct when columns are inserted in the middle, removed, or\n * reordered, and when a `hot-column` is nested inside a wrapper component.\n *\n * @returns {HotTableProps[] | undefined}\n */\n getColumnSettings(): HotTableProps[] | void {\n const orderedColumns = Array.from(this.columnsCache.entries())\n .sort(([columnA], [columnB]) => {\n const anchorA = (columnA as { $el?: Node }).$el;\n const anchorB = (columnB as { $el?: Node }).$el;\n\n if (!anchorA || !anchorB) {\n return 0;\n }\n\n const position = anchorA.compareDocumentPosition(anchorB);\n\n // eslint-disable-next-line no-bitwise\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) {\n return -1;\n }\n\n // eslint-disable-next-line no-bitwise\n if (position & Node.DOCUMENT_POSITION_PRECEDING) {\n return 1;\n }\n\n return 0;\n })\n .map(([, columnSettings]) => columnSettings);\n\n return orderedColumns.length ? orderedColumns : void 0;\n },\n\n /**\n * Re-read the column settings declared by `hot-column` children and push them\n * to the Handsontable instance. Called by children on mount, prop change, and\n * unmount, and by the parent on reorder. Multiple notifications in the same\n * tick are coalesced into a single `updateSettings` call.\n */\n refreshColumns(): void {\n if (this.columnsRefreshScheduled) {\n return;\n }\n\n this.columnsRefreshScheduled = true;\n\n this.$nextTick(() => {\n this.columnsRefreshScheduled = false;\n\n if (!this.hotInstance) {\n return;\n }\n\n const newColumnSettings = this.getColumnSettings();\n const previousColumnSettings = this.columnSettings;\n\n // Each `hot-column` rebuilds its settings object whenever its props change,\n // so an unchanged column keeps the same object reference. Comparing the\n // arrays by reference and order is cheaper than a deep compare and avoids\n // an `updateSettings` call on unrelated re-renders (e.g. data-only updates).\n const isUnchanged =\n (!previousColumnSettings && !newColumnSettings) ||\n (!!previousColumnSettings && !!newColumnSettings &&\n previousColumnSettings.length === newColumnSettings.length &&\n previousColumnSettings.every((settings, index) => settings === newColumnSettings[index]));\n\n if (isUnchanged) {\n return;\n }\n\n this.columnSettings = newColumnSettings || null;\n this.hotInstance.updateSettings({ columns: newColumnSettings || void 0 });\n });\n },\n },\n mounted() {\n this.columnSettings = this.getColumnSettings();\n this.hotInit();\n },\n updated() {\n // Reordering keyed `hot-column` children reuses their instances and fires no\n // child lifecycle hook, so the children cannot notify on their own. The slot\n // vnodes do change, which re-renders `HotTable` - refresh from here to cover\n // reorders (coalesced with any child-triggered refresh).\n this.refreshColumns();\n },\n beforeUnmount() {\n if (this.hotInstance) {\n this.hotInstance.destroy();\n }\n },\n version: (packageJson as unknown as { version: string }).version,\n});\n\nexport default HotTable;\nexport { HotTable };\n</script>\n","<script lang=\"ts\">\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { defineComponent, createCommentVNode } from 'vue';\n// TODO: The line above is ts-ignored because rollup-plugin-typescript2 throws an error otherwise.\n// It's most probably caused by outdated rollup-plugin-vue which is no longer maintained.\n\nimport {\n propFactory,\n filterPassedProps\n} from './helpers';\n\nconst HotColumn = defineComponent({\n name: 'HotColumn',\n props: propFactory('HotColumn'),\n inject: ['columnsCache', 'refreshColumns'],\n methods: {\n /**\n * Create the column settings based on the data provided to the `hot-column`\n * component and it's child components.\n */\n createColumnSettings(): void {\n const assignedProps = filterPassedProps(this.$props);\n const columnSettings = { ...assignedProps };\n\n if (assignedProps.renderer) {\n columnSettings.renderer = assignedProps.renderer;\n }\n\n if (assignedProps.editor) {\n columnSettings.editor = assignedProps.editor;\n }\n\n this.columnsCache.set(this, columnSettings);\n }\n },\n watch: {\n $props: {\n handler() {\n this.createColumnSettings();\n this.refreshColumns();\n },\n deep: true,\n },\n },\n mounted() {\n this.createColumnSettings();\n this.refreshColumns();\n },\n unmounted() {\n this.columnsCache.delete(this);\n this.refreshColumns();\n },\n render() {\n // Render an (invisible) comment anchor instead of nothing, so the parent\n // `HotTable` can order columns by the anchors' document position. This keeps\n // ordering correct for dynamic inserts, removals, and reorders - and works\n // regardless of how deeply the `hot-column` is nested inside wrapper\n // components - because `provide`/`inject` and the anchor both cross nesting.\n return createCommentVNode('hot-column');\n }\n});\n\nexport default HotColumn;\nexport { HotColumn };\n</script>\n"],"names":["unassignedPropSymbol","Symbol","hasOwnProperty","object","key","Object","prototype","call","propFactory","source","registeredHooks","Handsontable","hooks","getRegistered","propSchema","prop","assign","DefaultSettings","default","i","length","settings","id","type","String","concat","Math","random","toString","substring","filterPassedProps","props","filteredProps","columnSettingsProp","propName","prepareSettings","currentSettings","assignedProps","hotSettingsInProps","additionalHotSettingsInProps","initOnlySettingKeys","_initOnlySettings","newSettings","includes","simpleEqual","objectA","objectB","identityMap","WeakMap","nextIdentityId","stringifyToJSON","val","seen","WeakSet","JSON","stringify","value","_typeof","has","add","Node","get","undefined","set","e","HotTable","defineComponent","name","provide","columnsCache","this","refreshColumns","watch","$props","handler","hotInstance","getSettings","data","isColumnModificationAllowed","countSourceCols","miscCache","currentSourceColumns","matchHotMappersSize","keys","updateSettings","render","deep","immediate","__hotInstance","columnSettings","Map","columnsRefreshScheduled","isDestroyed","console","warn","methods","hotInit","columns","markRaw","Core","$el","init","_this","_data$","getSourceData","rowsToRemove","columnsToRemove","indexMapperRowCount","rowIndexMapper","getNumberOfIndexes","indexMapperColumnCount","r","push","columnIndexMapper","c","batch","removeIndexes","insertIndexes","getColumnSettings","orderedColumns","Array","from","entries","sort","_ref","_ref2","columnA","_slicedToArray","_ref4","anchorA","anchorB","position","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","DOCUMENT_POSITION_PRECEDING","map","_ref5","_this2","$nextTick","newColumnSettings","previousColumnSettings","every","index","mounted","updated","beforeUnmount","destroy","version","_createElementBlock","_ctx","style","height","_createCommentVNode","_renderSlot","$slots","HotColumn","inject","createColumnSettings","_objectSpread","renderer","editor","unmounted","createCommentVNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;i0EAGA,IAAMA,EAAuBC,OAAO,cAe7B,SAASC,EAAeC,EAAiBC,GAC9C,OAAOC,OAAOC,UAAUJ,eAAeK,KAAKJ,EAAQC,EACtD,CAQO,SAASI,EAAYC,GAC1B,IAAMC,EAAkBC,EAAAA,QAAaC,MAAMC,gBACrCC,EAAsC,CAAA,EAK5C,IAAK,IAAMC,KAHXV,OAAOW,OAAOF,EAAYH,EAAAA,QAAaM,iBAGpBH,EACjBA,EAAWC,GAAQ,CACjBG,QAASlB,GAIb,IAAK,IAAImB,EAAI,EAAOT,EAAgBU,OAApBD,EAA4BA,IAC1CL,EAAWJ,EAAgBS,IAAM,CAC/BD,QAASlB,GAeb,OAXAc,EAAWO,SAAW,CACpBH,QAASlB,GAGI,aAAXS,IACFK,EAAWQ,GAAK,CACdC,KAAMC,OACNN,QAAA,OAAAO,OAAgBC,KAAKC,SAASC,SAAS,IAAIC,UAAU,MAIlDf,CACT,CAQO,SAASgB,EAAkBC,GAChC,IAAMC,EAAyC,CAAA,EACzCC,EAAqBF,EAAMV,SAEjC,GAAIY,IAAuBjC,EAEzB,IAAK,IAAMkC,KAAYD,EACjB/B,EAAe+B,EAAoBC,IAAaD,EAAmBC,KAAclC,IACnFgC,EAAcE,GAAYD,EAAmBC,IAMnD,IAAK,IAAMA,KAA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AK,OAAA,8CCMhB,IAAMC,EAAYzF,EAAAA,gBAAgB,CAChCC,KAAM,YACNpC,MAAOvB,EAAY,aACnBoJ,OAAQ,CAAC,eAAgB,kBACzB7D,QAAS,CAKP8D,qBAAoB,WAClB,IAAMxH,EAAgBP,EAAkBwC,KAAKG,QACvCgB,6VAAaqE,CAAA,CAAA,EAASzH,GAExBA,EAAc0H,WAChBtE,EAAesE,SAAW1H,EAAc0H,UAGtC1H,EAAc2H,SAChBvE,EAAeuE,OAAS3H,EAAc2H,QAGxC1F,KAAKD,aAAaN,IAAIO,KAAMmB,EAC9B,GAEFjB,MAAO,CACLC,OAAQ,CACNC,QAAO,WACLJ,KAAKuF,uBACLvF,KAAKC,gBACP,EACAe,MAAM,IAGVyD,QAAO,WACLzE,KAAKuF,uBACLvF,KAAKC,gBACP,EACA0F,UAAS,WACP3F,KAAKD,aAAY,OAAQC,MACzBA,KAAKC,gBACP,EACAc,OAAM,WAMJ,OAAO6E,EAAAA,mBAAmB,aAC5B"}
|
package/es/vue-handsontable.mjs
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { defineComponent, markRaw, openBlock, createElementBlock, renderSlot } from 'vue';
|
|
1
|
+
import { defineComponent, markRaw, openBlock, createElementBlock, createCommentVNode, renderSlot } from 'vue';
|
|
2
2
|
import Handsontable from 'handsontable/base';
|
|
3
3
|
|
|
4
|
+
function _arrayLikeToArray(r, a) {
|
|
5
|
+
(null == a || a > r.length) && (a = r.length);
|
|
6
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
7
|
+
return n;
|
|
8
|
+
}
|
|
9
|
+
function _arrayWithHoles(r) {
|
|
10
|
+
if (Array.isArray(r)) return r;
|
|
11
|
+
}
|
|
4
12
|
function _defineProperty(e, r, t) {
|
|
5
13
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
6
14
|
value: t,
|
|
@@ -9,6 +17,36 @@ function _defineProperty(e, r, t) {
|
|
|
9
17
|
writable: true
|
|
10
18
|
}) : e[r] = t, e;
|
|
11
19
|
}
|
|
20
|
+
function _iterableToArrayLimit(r, l) {
|
|
21
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
22
|
+
if (null != t) {
|
|
23
|
+
var e,
|
|
24
|
+
n,
|
|
25
|
+
i,
|
|
26
|
+
u,
|
|
27
|
+
a = [],
|
|
28
|
+
f = true,
|
|
29
|
+
o = false;
|
|
30
|
+
try {
|
|
31
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
32
|
+
if (Object(t) !== t) return;
|
|
33
|
+
f = !1;
|
|
34
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
35
|
+
} catch (r) {
|
|
36
|
+
o = true, n = r;
|
|
37
|
+
} finally {
|
|
38
|
+
try {
|
|
39
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
40
|
+
} finally {
|
|
41
|
+
if (o) throw n;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return a;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function _nonIterableRest() {
|
|
48
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
49
|
+
}
|
|
12
50
|
function ownKeys(e, r) {
|
|
13
51
|
var t = Object.keys(e);
|
|
14
52
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -30,6 +68,9 @@ function _objectSpread2(e) {
|
|
|
30
68
|
}
|
|
31
69
|
return e;
|
|
32
70
|
}
|
|
71
|
+
function _slicedToArray(r, e) {
|
|
72
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
73
|
+
}
|
|
33
74
|
function _toPrimitive(t, r) {
|
|
34
75
|
if ("object" != typeof t || !t) return t;
|
|
35
76
|
var e = t[Symbol.toPrimitive];
|
|
@@ -53,6 +94,13 @@ function _typeof(o) {
|
|
|
53
94
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
54
95
|
}, _typeof(o);
|
|
55
96
|
}
|
|
97
|
+
function _unsupportedIterableToArray(r, a) {
|
|
98
|
+
if (r) {
|
|
99
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
100
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
101
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
56
104
|
|
|
57
105
|
var unassignedPropSymbol = Symbol('unassigned');
|
|
58
106
|
|
|
@@ -219,16 +267,15 @@ function simpleEqual(objectA, objectB) {
|
|
|
219
267
|
}
|
|
220
268
|
}
|
|
221
269
|
|
|
222
|
-
var version="18.
|
|
270
|
+
var version="18.1.0-rc7";
|
|
223
271
|
|
|
224
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
225
|
-
// @ts-ignore
|
|
226
272
|
var HotTable = defineComponent({
|
|
227
273
|
name: 'HotTable',
|
|
228
274
|
props: propFactory('HotTable'),
|
|
229
275
|
provide: function provide() {
|
|
230
276
|
return {
|
|
231
|
-
columnsCache: this.columnsCache
|
|
277
|
+
columnsCache: this.columnsCache,
|
|
278
|
+
refreshColumns: this.refreshColumns
|
|
232
279
|
};
|
|
233
280
|
},
|
|
234
281
|
watch: {
|
|
@@ -270,6 +317,7 @@ var HotTable = defineComponent({
|
|
|
270
317
|
},
|
|
271
318
|
columnSettings: null,
|
|
272
319
|
columnsCache: new Map(),
|
|
320
|
+
columnsRefreshScheduled: false,
|
|
273
321
|
get hotInstance() {
|
|
274
322
|
if (!this.__hotInstance || this.__hotInstance && !this.__hotInstance.isDestroyed) {
|
|
275
323
|
// Will return the Handsontable instance or `null` if it's not yet been created.
|
|
@@ -343,17 +391,91 @@ var HotTable = defineComponent({
|
|
|
343
391
|
/**
|
|
344
392
|
* Get settings for the columns provided in the `hot-column` components.
|
|
345
393
|
*
|
|
394
|
+
* The columns are ordered by the document position of each `hot-column`'s
|
|
395
|
+
* anchor node, not by the `columnsCache` insertion order. This keeps the
|
|
396
|
+
* order correct when columns are inserted in the middle, removed, or
|
|
397
|
+
* reordered, and when a `hot-column` is nested inside a wrapper component.
|
|
398
|
+
*
|
|
346
399
|
* @returns {HotTableProps[] | undefined}
|
|
347
400
|
*/
|
|
348
401
|
getColumnSettings: function getColumnSettings() {
|
|
349
|
-
var
|
|
350
|
-
|
|
402
|
+
var orderedColumns = Array.from(this.columnsCache.entries()).sort(function (_ref, _ref2) {
|
|
403
|
+
var _ref3 = _slicedToArray(_ref, 1),
|
|
404
|
+
columnA = _ref3[0];
|
|
405
|
+
var _ref4 = _slicedToArray(_ref2, 1),
|
|
406
|
+
columnB = _ref4[0];
|
|
407
|
+
var anchorA = columnA.$el;
|
|
408
|
+
var anchorB = columnB.$el;
|
|
409
|
+
if (!anchorA || !anchorB) {
|
|
410
|
+
return 0;
|
|
411
|
+
}
|
|
412
|
+
var position = anchorA.compareDocumentPosition(anchorB);
|
|
413
|
+
|
|
414
|
+
// eslint-disable-next-line no-bitwise
|
|
415
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) {
|
|
416
|
+
return -1;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// eslint-disable-next-line no-bitwise
|
|
420
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
|
|
421
|
+
return 1;
|
|
422
|
+
}
|
|
423
|
+
return 0;
|
|
424
|
+
}).map(function (_ref5) {
|
|
425
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
426
|
+
columnSettings = _ref6[1];
|
|
427
|
+
return columnSettings;
|
|
428
|
+
});
|
|
429
|
+
return orderedColumns.length ? orderedColumns : void 0;
|
|
430
|
+
},
|
|
431
|
+
/**
|
|
432
|
+
* Re-read the column settings declared by `hot-column` children and push them
|
|
433
|
+
* to the Handsontable instance. Called by children on mount, prop change, and
|
|
434
|
+
* unmount, and by the parent on reorder. Multiple notifications in the same
|
|
435
|
+
* tick are coalesced into a single `updateSettings` call.
|
|
436
|
+
*/
|
|
437
|
+
refreshColumns: function refreshColumns() {
|
|
438
|
+
var _this2 = this;
|
|
439
|
+
if (this.columnsRefreshScheduled) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
this.columnsRefreshScheduled = true;
|
|
443
|
+
this.$nextTick(function () {
|
|
444
|
+
_this2.columnsRefreshScheduled = false;
|
|
445
|
+
if (!_this2.hotInstance) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
var newColumnSettings = _this2.getColumnSettings();
|
|
449
|
+
var previousColumnSettings = _this2.columnSettings;
|
|
450
|
+
|
|
451
|
+
// Each `hot-column` rebuilds its settings object whenever its props change,
|
|
452
|
+
// so an unchanged column keeps the same object reference. Comparing the
|
|
453
|
+
// arrays by reference and order is cheaper than a deep compare and avoids
|
|
454
|
+
// an `updateSettings` call on unrelated re-renders (e.g. data-only updates).
|
|
455
|
+
var isUnchanged = !previousColumnSettings && !newColumnSettings || !!previousColumnSettings && !!newColumnSettings && previousColumnSettings.length === newColumnSettings.length && previousColumnSettings.every(function (settings, index) {
|
|
456
|
+
return settings === newColumnSettings[index];
|
|
457
|
+
});
|
|
458
|
+
if (isUnchanged) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
_this2.columnSettings = newColumnSettings || null;
|
|
462
|
+
_this2.hotInstance.updateSettings({
|
|
463
|
+
columns: newColumnSettings || void 0
|
|
464
|
+
});
|
|
465
|
+
});
|
|
351
466
|
}
|
|
352
467
|
},
|
|
353
468
|
mounted: function mounted() {
|
|
354
469
|
this.columnSettings = this.getColumnSettings();
|
|
355
470
|
this.hotInit();
|
|
356
471
|
},
|
|
472
|
+
updated: function updated() {
|
|
473
|
+
// Reordering keyed `hot-column` children reuses their instances and fires no
|
|
474
|
+
// child lifecycle hook, so the children cannot notify on their own. The slot
|
|
475
|
+
// vnodes do change, which re-renders `HotTable` - refresh from here to cover
|
|
476
|
+
// reorders (coalesced with any child-triggered refresh).
|
|
477
|
+
this.refreshColumns();
|
|
478
|
+
},
|
|
357
479
|
beforeUnmount: function beforeUnmount() {
|
|
358
480
|
if (this.hotInstance) {
|
|
359
481
|
this.hotInstance.destroy();
|
|
@@ -369,7 +491,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
369
491
|
style: {
|
|
370
492
|
"height": "100%"
|
|
371
493
|
}
|
|
372
|
-
}, [renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1);
|
|
494
|
+
}, [createCommentVNode(" `hot-column` children render invisible comment anchors in source order.\n Handsontable appends its own DOM to this container without clearing\n pre-existing nodes, so the anchors survive; the parent reads their\n document position to order the columns. "), renderSlot(_ctx.$slots, "default")], 8 /* PROPS */, _hoisted_1);
|
|
373
495
|
}
|
|
374
496
|
|
|
375
497
|
HotTable.render = render;
|
|
@@ -378,7 +500,7 @@ HotTable.__file = "src/HotTable.vue";
|
|
|
378
500
|
var HotColumn = defineComponent({
|
|
379
501
|
name: 'HotColumn',
|
|
380
502
|
props: propFactory('HotColumn'),
|
|
381
|
-
inject: ['columnsCache'],
|
|
503
|
+
inject: ['columnsCache', 'refreshColumns'],
|
|
382
504
|
methods: {
|
|
383
505
|
/**
|
|
384
506
|
* Create the column settings based on the data provided to the `hot-column`
|
|
@@ -396,14 +518,30 @@ var HotColumn = defineComponent({
|
|
|
396
518
|
this.columnsCache.set(this, columnSettings);
|
|
397
519
|
}
|
|
398
520
|
},
|
|
521
|
+
watch: {
|
|
522
|
+
$props: {
|
|
523
|
+
handler: function handler() {
|
|
524
|
+
this.createColumnSettings();
|
|
525
|
+
this.refreshColumns();
|
|
526
|
+
},
|
|
527
|
+
deep: true
|
|
528
|
+
}
|
|
529
|
+
},
|
|
399
530
|
mounted: function mounted() {
|
|
400
531
|
this.createColumnSettings();
|
|
532
|
+
this.refreshColumns();
|
|
401
533
|
},
|
|
402
534
|
unmounted: function unmounted() {
|
|
403
535
|
this.columnsCache["delete"](this);
|
|
536
|
+
this.refreshColumns();
|
|
404
537
|
},
|
|
405
538
|
render: function render() {
|
|
406
|
-
|
|
539
|
+
// Render an (invisible) comment anchor instead of nothing, so the parent
|
|
540
|
+
// `HotTable` can order columns by the anchors' document position. This keeps
|
|
541
|
+
// ordering correct for dynamic inserts, removals, and reorders - and works
|
|
542
|
+
// regardless of how deeply the `hot-column` is nested inside wrapper
|
|
543
|
+
// components - because `provide`/`inject` and the anchor both cross nesting.
|
|
544
|
+
return createCommentVNode('hot-column');
|
|
407
545
|
}
|
|
408
546
|
});
|
|
409
547
|
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@handsontable/vue3",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.1.0-rc7",
|
|
4
4
|
"description": "Best Data Grid for Vue with Spreadsheet Look and Feel.",
|
|
5
5
|
"author": "Handsoncode <hello@handsoncode.net> (https://handsoncode.net)",
|
|
6
6
|
"homepage": "https://handsontable.com",
|