@handsontable/react 0.0.0-next-0eba994-20231213 → 0.0.0-next-ae2e00f-20231213
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/commonjs/react-handsontable.js +132 -114
- package/dist/react-handsontable.js +133 -115
- package/dist/react-handsontable.js.map +1 -1
- package/dist/react-handsontable.min.js +2 -2
- package/dist/react-handsontable.min.js.map +1 -1
- package/es/react-handsontable.mjs +133 -115
- package/helpers.d.ts +1 -7
- package/hotColumn.d.ts +40 -15
- package/hotTable.d.ts +1 -1
- package/package.json +10 -10
- package/types.d.ts +14 -0
- package/Test.d.ts +0 -2
|
@@ -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: 0.0.0-next-
|
|
28
|
+
* Version: 0.0.0-next-ae2e00f-20231213 (built at Wed Dec 13 2023 14:07:04 GMT+0000 (Coordinated Universal Time))
|
|
29
29
|
*/
|
|
30
30
|
(function (global, factory) {
|
|
31
31
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('handsontable/base')) :
|
|
@@ -39,33 +39,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
39
39
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
40
40
|
var Handsontable__default = /*#__PURE__*/_interopDefaultLegacy(Handsontable);
|
|
41
41
|
|
|
42
|
-
function _iterableToArrayLimit(r, l) {
|
|
43
|
-
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
44
|
-
if (null != t) {
|
|
45
|
-
var e,
|
|
46
|
-
n,
|
|
47
|
-
i,
|
|
48
|
-
u,
|
|
49
|
-
a = [],
|
|
50
|
-
f = !0,
|
|
51
|
-
o = !1;
|
|
52
|
-
try {
|
|
53
|
-
if (i = (t = t.call(r)).next, 0 === l) {
|
|
54
|
-
if (Object(t) !== t) return;
|
|
55
|
-
f = !1;
|
|
56
|
-
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
57
|
-
} catch (r) {
|
|
58
|
-
o = !0, n = r;
|
|
59
|
-
} finally {
|
|
60
|
-
try {
|
|
61
|
-
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
62
|
-
} finally {
|
|
63
|
-
if (o) throw n;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return a;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
42
|
function ownKeys(e, r) {
|
|
70
43
|
var t = Object.keys(e);
|
|
71
44
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -87,20 +60,6 @@ function _objectSpread2(e) {
|
|
|
87
60
|
}
|
|
88
61
|
return e;
|
|
89
62
|
}
|
|
90
|
-
function _toPrimitive(t, r) {
|
|
91
|
-
if ("object" != typeof t || !t) return t;
|
|
92
|
-
var e = t[Symbol.toPrimitive];
|
|
93
|
-
if (void 0 !== e) {
|
|
94
|
-
var i = e.call(t, r || "default");
|
|
95
|
-
if ("object" != typeof i) return i;
|
|
96
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
97
|
-
}
|
|
98
|
-
return ("string" === r ? String : Number)(t);
|
|
99
|
-
}
|
|
100
|
-
function _toPropertyKey(t) {
|
|
101
|
-
var i = _toPrimitive(t, "string");
|
|
102
|
-
return "symbol" == typeof i ? i : String(i);
|
|
103
|
-
}
|
|
104
63
|
function _typeof(o) {
|
|
105
64
|
"@babel/helpers - typeof";
|
|
106
65
|
|
|
@@ -214,18 +173,12 @@ function _createSuper(Derived) {
|
|
|
214
173
|
return _possibleConstructorReturn(this, result);
|
|
215
174
|
};
|
|
216
175
|
}
|
|
217
|
-
function _slicedToArray(arr, i) {
|
|
218
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
219
|
-
}
|
|
220
176
|
function _toConsumableArray(arr) {
|
|
221
177
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
222
178
|
}
|
|
223
179
|
function _arrayWithoutHoles(arr) {
|
|
224
180
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
225
181
|
}
|
|
226
|
-
function _arrayWithHoles(arr) {
|
|
227
|
-
if (Array.isArray(arr)) return arr;
|
|
228
|
-
}
|
|
229
182
|
function _iterableToArray(iter) {
|
|
230
183
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
231
184
|
}
|
|
@@ -245,12 +198,22 @@ function _arrayLikeToArray(arr, len) {
|
|
|
245
198
|
function _nonIterableSpread() {
|
|
246
199
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
247
200
|
}
|
|
248
|
-
function
|
|
249
|
-
|
|
201
|
+
function _toPrimitive(input, hint) {
|
|
202
|
+
if (typeof input !== "object" || input === null) return input;
|
|
203
|
+
var prim = input[Symbol.toPrimitive];
|
|
204
|
+
if (prim !== undefined) {
|
|
205
|
+
var res = prim.call(input, hint || "default");
|
|
206
|
+
if (typeof res !== "object") return res;
|
|
207
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
208
|
+
}
|
|
209
|
+
return (hint === "string" ? String : Number)(input);
|
|
210
|
+
}
|
|
211
|
+
function _toPropertyKey(arg) {
|
|
212
|
+
var key = _toPrimitive(arg, "string");
|
|
213
|
+
return typeof key === "symbol" ? key : String(key);
|
|
250
214
|
}
|
|
251
215
|
|
|
252
216
|
var bulkComponentContainer = null;
|
|
253
|
-
var hasIdWarningBeenPrinted = false;
|
|
254
217
|
/**
|
|
255
218
|
* Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
|
|
256
219
|
*/
|
|
@@ -315,12 +278,14 @@ function getOriginalEditorClass(editorElement) {
|
|
|
315
278
|
/**
|
|
316
279
|
* Create an editor portal.
|
|
317
280
|
*
|
|
318
|
-
* @param {Document} doc Document to be used.
|
|
281
|
+
* @param {Document} [doc] Document to be used.
|
|
319
282
|
* @param {React.ReactElement} editorElement Editor's element.
|
|
320
283
|
* @returns {React.ReactPortal} The portal for the editor.
|
|
321
284
|
*/
|
|
322
|
-
function createEditorPortal(
|
|
323
|
-
|
|
285
|
+
function createEditorPortal() {
|
|
286
|
+
var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
|
|
287
|
+
var editorElement = arguments.length > 1 ? arguments[1] : undefined;
|
|
288
|
+
if (editorElement === null) {
|
|
324
289
|
return null;
|
|
325
290
|
}
|
|
326
291
|
var containerProps = getContainerAttributesProps(editorElement.props, false);
|
|
@@ -392,47 +357,12 @@ function createPortal(rElement, props) {
|
|
|
392
357
|
*/
|
|
393
358
|
function getContainerAttributesProps(props) {
|
|
394
359
|
var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
395
|
-
if (!hasIdWarningBeenPrinted && !props.id && randomizeId) {
|
|
396
|
-
hasIdWarningBeenPrinted = true;
|
|
397
|
-
warn('You have to provide an `id` property for the `HotTable` component.');
|
|
398
|
-
}
|
|
399
360
|
return {
|
|
400
361
|
id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : void 0),
|
|
401
362
|
className: props.className || '',
|
|
402
363
|
style: props.style || {}
|
|
403
364
|
};
|
|
404
365
|
}
|
|
405
|
-
/**
|
|
406
|
-
* Checks if the environment that the code runs in is a browser.
|
|
407
|
-
*
|
|
408
|
-
* @returns {boolean}
|
|
409
|
-
*/
|
|
410
|
-
function isCSR() {
|
|
411
|
-
return typeof window !== 'undefined';
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
var HotColumn = function HotColumn(props) {
|
|
415
|
-
var _useState = React.useState(getExtendedEditorElement(props.children, props.getEditorCache(), props.columnIndex)),
|
|
416
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
417
|
-
editorElement = _useState2[0],
|
|
418
|
-
setEditorElement = _useState2[1];
|
|
419
|
-
React.useEffect(function () {
|
|
420
|
-
var rendererElement = props.getChildElementByType(props.children, "hot-renderer");
|
|
421
|
-
setEditorElement(getExtendedEditorElement(props.children, props.getEditorCache(), props.columnIndex));
|
|
422
|
-
var columnSettings = {};
|
|
423
|
-
if (rendererElement !== null) {
|
|
424
|
-
columnSettings.renderer = props.getRendererWrapper(rendererElement);
|
|
425
|
-
props.componentRendererColumns.set(props.columnIndex, true);
|
|
426
|
-
}
|
|
427
|
-
if (editorElement !== null) {
|
|
428
|
-
columnSettings.editor = props.getEditorClass(editorElement, props.columnIndex);
|
|
429
|
-
}
|
|
430
|
-
props.onColumnSettingsChange(columnSettings, props.columnIndex);
|
|
431
|
-
}, [props.getChildElementByType, props.children, props.columnIndex, props.getRendererWrapper, props.componentRendererColumns, props.getEditorCache]);
|
|
432
|
-
var ownerDocument = props.getOwnerDocument();
|
|
433
|
-
var editorPortal = createEditorPortal(ownerDocument, editorElement);
|
|
434
|
-
return React__default["default"].createElement(React__default["default"].Fragment, null, editorPortal);
|
|
435
|
-
};
|
|
436
366
|
|
|
437
367
|
var SettingsMapper = /*#__PURE__*/function () {
|
|
438
368
|
function SettingsMapper() {
|
|
@@ -468,6 +398,105 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
468
398
|
return SettingsMapper;
|
|
469
399
|
}();
|
|
470
400
|
|
|
401
|
+
var HotColumn = /*#__PURE__*/function (_React$Component) {
|
|
402
|
+
_inherits(HotColumn, _React$Component);
|
|
403
|
+
var _super = _createSuper(HotColumn);
|
|
404
|
+
function HotColumn() {
|
|
405
|
+
_classCallCheck(this, HotColumn);
|
|
406
|
+
return _super.apply(this, arguments);
|
|
407
|
+
}
|
|
408
|
+
_createClass(HotColumn, [{
|
|
409
|
+
key: "getSettingsProps",
|
|
410
|
+
value:
|
|
411
|
+
/**
|
|
412
|
+
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
|
413
|
+
*
|
|
414
|
+
* @returns {Object}
|
|
415
|
+
*/
|
|
416
|
+
function getSettingsProps() {
|
|
417
|
+
var _this = this;
|
|
418
|
+
this.internalProps = ['_componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
|
|
419
|
+
return Object.keys(this.props).filter(function (key) {
|
|
420
|
+
return !_this.internalProps.includes(key);
|
|
421
|
+
}).reduce(function (obj, key) {
|
|
422
|
+
obj[key] = _this.props[key];
|
|
423
|
+
return obj;
|
|
424
|
+
}, {});
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Get the editor element for the current column.
|
|
428
|
+
*
|
|
429
|
+
* @returns {React.ReactElement} React editor component element.
|
|
430
|
+
*/
|
|
431
|
+
}, {
|
|
432
|
+
key: "getLocalEditorElement",
|
|
433
|
+
value: function getLocalEditorElement() {
|
|
434
|
+
return getExtendedEditorElement(this.props.children, this.props._getEditorCache(), this.props._columnIndex);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Create the column settings based on the data provided to the `HotColumn` component and it's child components.
|
|
438
|
+
*/
|
|
439
|
+
}, {
|
|
440
|
+
key: "createColumnSettings",
|
|
441
|
+
value: function createColumnSettings() {
|
|
442
|
+
var rendererElement = this.props._getChildElementByType(this.props.children, 'hot-renderer');
|
|
443
|
+
var editorElement = this.getLocalEditorElement();
|
|
444
|
+
this.columnSettings = SettingsMapper.getSettings(this.getSettingsProps());
|
|
445
|
+
if (rendererElement !== null) {
|
|
446
|
+
this.columnSettings.renderer = this.props._getRendererWrapper(rendererElement);
|
|
447
|
+
this.props._componentRendererColumns.set(this.props._columnIndex, true);
|
|
448
|
+
}
|
|
449
|
+
if (editorElement !== null) {
|
|
450
|
+
this.columnSettings.editor = this.props._getEditorClass(editorElement, this.props._columnIndex);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Emit the column settings to the parent using a prop passed from the parent.
|
|
455
|
+
*/
|
|
456
|
+
}, {
|
|
457
|
+
key: "emitColumnSettings",
|
|
458
|
+
value: function emitColumnSettings() {
|
|
459
|
+
this.props._emitColumnSettings(this.columnSettings, this.props._columnIndex);
|
|
460
|
+
}
|
|
461
|
+
/*
|
|
462
|
+
---------------------------------------
|
|
463
|
+
------- React lifecycle methods -------
|
|
464
|
+
---------------------------------------
|
|
465
|
+
*/
|
|
466
|
+
/**
|
|
467
|
+
* Logic performed after the mounting of the HotColumn component.
|
|
468
|
+
*/
|
|
469
|
+
}, {
|
|
470
|
+
key: "componentDidMount",
|
|
471
|
+
value: function componentDidMount() {
|
|
472
|
+
this.createColumnSettings();
|
|
473
|
+
this.emitColumnSettings();
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Logic performed after the updating of the HotColumn component.
|
|
477
|
+
*/
|
|
478
|
+
}, {
|
|
479
|
+
key: "componentDidUpdate",
|
|
480
|
+
value: function componentDidUpdate() {
|
|
481
|
+
this.createColumnSettings();
|
|
482
|
+
this.emitColumnSettings();
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Render the portals of the editors, if there are any.
|
|
486
|
+
*
|
|
487
|
+
* @returns {React.ReactElement}
|
|
488
|
+
*/
|
|
489
|
+
}, {
|
|
490
|
+
key: "render",
|
|
491
|
+
value: function render() {
|
|
492
|
+
var ownerDocument = this.props._getOwnerDocument();
|
|
493
|
+
var editorPortal = createEditorPortal(ownerDocument, this.getLocalEditorElement());
|
|
494
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, editorPortal);
|
|
495
|
+
}
|
|
496
|
+
}]);
|
|
497
|
+
return HotColumn;
|
|
498
|
+
}(React__default["default"].Component);
|
|
499
|
+
|
|
471
500
|
/**
|
|
472
501
|
* Component class used to manage the renderer component portals.
|
|
473
502
|
*/
|
|
@@ -492,7 +521,7 @@ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
|
|
|
492
521
|
return RenderersPortalManager;
|
|
493
522
|
}(React__default["default"].Component);
|
|
494
523
|
|
|
495
|
-
var version="0.0.0-next-
|
|
524
|
+
var version="0.0.0-next-ae2e00f-20231213";
|
|
496
525
|
|
|
497
526
|
function createCommonjsModule(fn, module) {
|
|
498
527
|
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
@@ -835,13 +864,6 @@ var propTypes = createCommonjsModule(function (module) {
|
|
|
835
864
|
});
|
|
836
865
|
var PropTypes = propTypes;
|
|
837
866
|
|
|
838
|
-
var Test = function Test() {
|
|
839
|
-
React.useEffect(function () {
|
|
840
|
-
console.log("hello world");
|
|
841
|
-
}, []);
|
|
842
|
-
return React__default["default"].createElement("div", null);
|
|
843
|
-
};
|
|
844
|
-
|
|
845
867
|
/**
|
|
846
868
|
* A Handsontable-ReactJS wrapper.
|
|
847
869
|
*
|
|
@@ -994,10 +1016,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
994
1016
|
}, {
|
|
995
1017
|
key: "getOwnerDocument",
|
|
996
1018
|
value: function getOwnerDocument() {
|
|
997
|
-
|
|
998
|
-
return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
|
|
999
|
-
}
|
|
1000
|
-
return null;
|
|
1019
|
+
return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
|
|
1001
1020
|
}
|
|
1002
1021
|
/**
|
|
1003
1022
|
* Set the reference to the main Handsontable DOM element.
|
|
@@ -1284,6 +1303,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1284
1303
|
key: "render",
|
|
1285
1304
|
value: function render() {
|
|
1286
1305
|
var _this5 = this;
|
|
1306
|
+
var containerProps = getContainerAttributesProps(this.props);
|
|
1287
1307
|
var isHotColumn = function isHotColumn(childNode) {
|
|
1288
1308
|
return childNode.type === HotColumn;
|
|
1289
1309
|
};
|
|
@@ -1292,26 +1312,24 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
|
|
|
1292
1312
|
var hotColumnClones = children.filter(function (childNode) {
|
|
1293
1313
|
return isHotColumn(childNode);
|
|
1294
1314
|
}).map(function (childNode, columnIndex) {
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
};
|
|
1306
|
-
return React__default["default"].cloneElement(childNode, hotColumnProps);
|
|
1315
|
+
return React__default["default"].cloneElement(childNode, {
|
|
1316
|
+
_componentRendererColumns: _this5.componentRendererColumns,
|
|
1317
|
+
_emitColumnSettings: _this5.setHotColumnSettings.bind(_this5),
|
|
1318
|
+
_columnIndex: columnIndex,
|
|
1319
|
+
_getChildElementByType: getChildElementByType.bind(_this5),
|
|
1320
|
+
_getRendererWrapper: _this5.getRendererWrapper.bind(_this5),
|
|
1321
|
+
_getEditorClass: _this5.getEditorClass.bind(_this5),
|
|
1322
|
+
_getOwnerDocument: _this5.getOwnerDocument.bind(_this5),
|
|
1323
|
+
_getEditorCache: _this5.getEditorCache.bind(_this5),
|
|
1324
|
+
children: childNode.props.children
|
|
1325
|
+
});
|
|
1307
1326
|
});
|
|
1308
|
-
var containerProps = getContainerAttributesProps(this.props);
|
|
1309
1327
|
var editorPortal = createEditorPortal(this.getOwnerDocument(), this.getGlobalEditorElement());
|
|
1310
1328
|
return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", Object.assign({
|
|
1311
1329
|
ref: this.setHotElementRef.bind(this)
|
|
1312
1330
|
}, containerProps), hotColumnClones), React__default["default"].createElement(RenderersPortalManager, {
|
|
1313
1331
|
ref: this.setRenderersPortalManagerRef.bind(this)
|
|
1314
|
-
}), editorPortal
|
|
1332
|
+
}), editorPortal);
|
|
1315
1333
|
}
|
|
1316
1334
|
}], [{
|
|
1317
1335
|
key: "version",
|