@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.
@@ -12,33 +12,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
12
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
13
13
  var Handsontable__default = /*#__PURE__*/_interopDefaultLegacy(Handsontable);
14
14
 
15
- function _iterableToArrayLimit(r, l) {
16
- var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
17
- if (null != t) {
18
- var e,
19
- n,
20
- i,
21
- u,
22
- a = [],
23
- f = !0,
24
- o = !1;
25
- try {
26
- if (i = (t = t.call(r)).next, 0 === l) {
27
- if (Object(t) !== t) return;
28
- f = !1;
29
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
30
- } catch (r) {
31
- o = !0, n = r;
32
- } finally {
33
- try {
34
- if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
35
- } finally {
36
- if (o) throw n;
37
- }
38
- }
39
- return a;
40
- }
41
- }
42
15
  function ownKeys(e, r) {
43
16
  var t = Object.keys(e);
44
17
  if (Object.getOwnPropertySymbols) {
@@ -60,20 +33,6 @@ function _objectSpread2(e) {
60
33
  }
61
34
  return e;
62
35
  }
63
- function _toPrimitive(t, r) {
64
- if ("object" != typeof t || !t) return t;
65
- var e = t[Symbol.toPrimitive];
66
- if (void 0 !== e) {
67
- var i = e.call(t, r || "default");
68
- if ("object" != typeof i) return i;
69
- throw new TypeError("@@toPrimitive must return a primitive value.");
70
- }
71
- return ("string" === r ? String : Number)(t);
72
- }
73
- function _toPropertyKey(t) {
74
- var i = _toPrimitive(t, "string");
75
- return "symbol" == typeof i ? i : String(i);
76
- }
77
36
  function _typeof(o) {
78
37
  "@babel/helpers - typeof";
79
38
 
@@ -187,18 +146,12 @@ function _createSuper(Derived) {
187
146
  return _possibleConstructorReturn(this, result);
188
147
  };
189
148
  }
190
- function _slicedToArray(arr, i) {
191
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
192
- }
193
149
  function _toConsumableArray(arr) {
194
150
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
195
151
  }
196
152
  function _arrayWithoutHoles(arr) {
197
153
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
198
154
  }
199
- function _arrayWithHoles(arr) {
200
- if (Array.isArray(arr)) return arr;
201
- }
202
155
  function _iterableToArray(iter) {
203
156
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
204
157
  }
@@ -218,12 +171,22 @@ function _arrayLikeToArray(arr, len) {
218
171
  function _nonIterableSpread() {
219
172
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
220
173
  }
221
- function _nonIterableRest() {
222
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
174
+ function _toPrimitive(input, hint) {
175
+ if (typeof input !== "object" || input === null) return input;
176
+ var prim = input[Symbol.toPrimitive];
177
+ if (prim !== undefined) {
178
+ var res = prim.call(input, hint || "default");
179
+ if (typeof res !== "object") return res;
180
+ throw new TypeError("@@toPrimitive must return a primitive value.");
181
+ }
182
+ return (hint === "string" ? String : Number)(input);
183
+ }
184
+ function _toPropertyKey(arg) {
185
+ var key = _toPrimitive(arg, "string");
186
+ return typeof key === "symbol" ? key : String(key);
223
187
  }
224
188
 
225
189
  var bulkComponentContainer = null;
226
- var hasIdWarningBeenPrinted = false;
227
190
  /**
228
191
  * Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
229
192
  */
@@ -288,12 +251,14 @@ function getOriginalEditorClass(editorElement) {
288
251
  /**
289
252
  * Create an editor portal.
290
253
  *
291
- * @param {Document} doc Document to be used.
254
+ * @param {Document} [doc] Document to be used.
292
255
  * @param {React.ReactElement} editorElement Editor's element.
293
256
  * @returns {React.ReactPortal} The portal for the editor.
294
257
  */
295
- function createEditorPortal(doc, editorElement) {
296
- if (typeof doc === 'undefined' || editorElement === null) {
258
+ function createEditorPortal() {
259
+ var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
260
+ var editorElement = arguments.length > 1 ? arguments[1] : undefined;
261
+ if (editorElement === null) {
297
262
  return null;
298
263
  }
299
264
  var containerProps = getContainerAttributesProps(editorElement.props, false);
@@ -365,47 +330,12 @@ function createPortal(rElement, props) {
365
330
  */
366
331
  function getContainerAttributesProps(props) {
367
332
  var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
368
- if (!hasIdWarningBeenPrinted && !props.id && randomizeId) {
369
- hasIdWarningBeenPrinted = true;
370
- warn('You have to provide an `id` property for the `HotTable` component.');
371
- }
372
333
  return {
373
334
  id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : void 0),
374
335
  className: props.className || '',
375
336
  style: props.style || {}
376
337
  };
377
338
  }
378
- /**
379
- * Checks if the environment that the code runs in is a browser.
380
- *
381
- * @returns {boolean}
382
- */
383
- function isCSR() {
384
- return typeof window !== 'undefined';
385
- }
386
-
387
- var HotColumn = function HotColumn(props) {
388
- var _useState = React.useState(getExtendedEditorElement(props.children, props.getEditorCache(), props.columnIndex)),
389
- _useState2 = _slicedToArray(_useState, 2),
390
- editorElement = _useState2[0],
391
- setEditorElement = _useState2[1];
392
- React.useEffect(function () {
393
- var rendererElement = props.getChildElementByType(props.children, "hot-renderer");
394
- setEditorElement(getExtendedEditorElement(props.children, props.getEditorCache(), props.columnIndex));
395
- var columnSettings = {};
396
- if (rendererElement !== null) {
397
- columnSettings.renderer = props.getRendererWrapper(rendererElement);
398
- props.componentRendererColumns.set(props.columnIndex, true);
399
- }
400
- if (editorElement !== null) {
401
- columnSettings.editor = props.getEditorClass(editorElement, props.columnIndex);
402
- }
403
- props.onColumnSettingsChange(columnSettings, props.columnIndex);
404
- }, [props.getChildElementByType, props.children, props.columnIndex, props.getRendererWrapper, props.componentRendererColumns, props.getEditorCache]);
405
- var ownerDocument = props.getOwnerDocument();
406
- var editorPortal = createEditorPortal(ownerDocument, editorElement);
407
- return React__default["default"].createElement(React__default["default"].Fragment, null, editorPortal);
408
- };
409
339
 
410
340
  var SettingsMapper = /*#__PURE__*/function () {
411
341
  function SettingsMapper() {
@@ -441,6 +371,105 @@ var SettingsMapper = /*#__PURE__*/function () {
441
371
  return SettingsMapper;
442
372
  }();
443
373
 
374
+ var HotColumn = /*#__PURE__*/function (_React$Component) {
375
+ _inherits(HotColumn, _React$Component);
376
+ var _super = _createSuper(HotColumn);
377
+ function HotColumn() {
378
+ _classCallCheck(this, HotColumn);
379
+ return _super.apply(this, arguments);
380
+ }
381
+ _createClass(HotColumn, [{
382
+ key: "getSettingsProps",
383
+ value:
384
+ /**
385
+ * Filter out all the internal properties and return an object with just the Handsontable-related props.
386
+ *
387
+ * @returns {Object}
388
+ */
389
+ function getSettingsProps() {
390
+ var _this = this;
391
+ this.internalProps = ['_componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
392
+ return Object.keys(this.props).filter(function (key) {
393
+ return !_this.internalProps.includes(key);
394
+ }).reduce(function (obj, key) {
395
+ obj[key] = _this.props[key];
396
+ return obj;
397
+ }, {});
398
+ }
399
+ /**
400
+ * Get the editor element for the current column.
401
+ *
402
+ * @returns {React.ReactElement} React editor component element.
403
+ */
404
+ }, {
405
+ key: "getLocalEditorElement",
406
+ value: function getLocalEditorElement() {
407
+ return getExtendedEditorElement(this.props.children, this.props._getEditorCache(), this.props._columnIndex);
408
+ }
409
+ /**
410
+ * Create the column settings based on the data provided to the `HotColumn` component and it's child components.
411
+ */
412
+ }, {
413
+ key: "createColumnSettings",
414
+ value: function createColumnSettings() {
415
+ var rendererElement = this.props._getChildElementByType(this.props.children, 'hot-renderer');
416
+ var editorElement = this.getLocalEditorElement();
417
+ this.columnSettings = SettingsMapper.getSettings(this.getSettingsProps());
418
+ if (rendererElement !== null) {
419
+ this.columnSettings.renderer = this.props._getRendererWrapper(rendererElement);
420
+ this.props._componentRendererColumns.set(this.props._columnIndex, true);
421
+ }
422
+ if (editorElement !== null) {
423
+ this.columnSettings.editor = this.props._getEditorClass(editorElement, this.props._columnIndex);
424
+ }
425
+ }
426
+ /**
427
+ * Emit the column settings to the parent using a prop passed from the parent.
428
+ */
429
+ }, {
430
+ key: "emitColumnSettings",
431
+ value: function emitColumnSettings() {
432
+ this.props._emitColumnSettings(this.columnSettings, this.props._columnIndex);
433
+ }
434
+ /*
435
+ ---------------------------------------
436
+ ------- React lifecycle methods -------
437
+ ---------------------------------------
438
+ */
439
+ /**
440
+ * Logic performed after the mounting of the HotColumn component.
441
+ */
442
+ }, {
443
+ key: "componentDidMount",
444
+ value: function componentDidMount() {
445
+ this.createColumnSettings();
446
+ this.emitColumnSettings();
447
+ }
448
+ /**
449
+ * Logic performed after the updating of the HotColumn component.
450
+ */
451
+ }, {
452
+ key: "componentDidUpdate",
453
+ value: function componentDidUpdate() {
454
+ this.createColumnSettings();
455
+ this.emitColumnSettings();
456
+ }
457
+ /**
458
+ * Render the portals of the editors, if there are any.
459
+ *
460
+ * @returns {React.ReactElement}
461
+ */
462
+ }, {
463
+ key: "render",
464
+ value: function render() {
465
+ var ownerDocument = this.props._getOwnerDocument();
466
+ var editorPortal = createEditorPortal(ownerDocument, this.getLocalEditorElement());
467
+ return React__default["default"].createElement(React__default["default"].Fragment, null, editorPortal);
468
+ }
469
+ }]);
470
+ return HotColumn;
471
+ }(React__default["default"].Component);
472
+
444
473
  /**
445
474
  * Component class used to manage the renderer component portals.
446
475
  */
@@ -465,7 +494,7 @@ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
465
494
  return RenderersPortalManager;
466
495
  }(React__default["default"].Component);
467
496
 
468
- var version="0.0.0-next-0eba994-20231213";
497
+ var version="0.0.0-next-ae2e00f-20231213";
469
498
 
470
499
  function createCommonjsModule(fn, module) {
471
500
  return module = { exports: {} }, fn(module, module.exports), module.exports;
@@ -1586,13 +1615,6 @@ var propTypes = createCommonjsModule(function (module) {
1586
1615
  });
1587
1616
  var PropTypes = propTypes;
1588
1617
 
1589
- var Test = function Test() {
1590
- React.useEffect(function () {
1591
- console.log("hello world");
1592
- }, []);
1593
- return React__default["default"].createElement("div", null);
1594
- };
1595
-
1596
1618
  /**
1597
1619
  * A Handsontable-ReactJS wrapper.
1598
1620
  *
@@ -1745,10 +1767,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1745
1767
  }, {
1746
1768
  key: "getOwnerDocument",
1747
1769
  value: function getOwnerDocument() {
1748
- if (isCSR()) {
1749
- return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
1750
- }
1751
- return null;
1770
+ return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
1752
1771
  }
1753
1772
  /**
1754
1773
  * Set the reference to the main Handsontable DOM element.
@@ -2035,6 +2054,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2035
2054
  key: "render",
2036
2055
  value: function render() {
2037
2056
  var _this5 = this;
2057
+ var containerProps = getContainerAttributesProps(this.props);
2038
2058
  var isHotColumn = function isHotColumn(childNode) {
2039
2059
  return childNode.type === HotColumn;
2040
2060
  };
@@ -2043,26 +2063,24 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2043
2063
  var hotColumnClones = children.filter(function (childNode) {
2044
2064
  return isHotColumn(childNode);
2045
2065
  }).map(function (childNode, columnIndex) {
2046
- var hotColumnProps = {
2047
- columnIndex: columnIndex,
2048
- children: childNode.props.children,
2049
- onColumnSettingsChange: _this5.setHotColumnSettings.bind(_this5),
2050
- componentRendererColumns: _this5.componentRendererColumns,
2051
- getChildElementByType: getChildElementByType.bind(_this5),
2052
- getRendererWrapper: _this5.getEditorClass.bind(_this5),
2053
- getEditorClass: _this5.getEditorClass.bind(_this5),
2054
- getEditorCache: _this5.getEditorCache.bind(_this5),
2055
- getOwnerDocument: _this5.getOwnerDocument.bind(_this5)
2056
- };
2057
- return React__default["default"].cloneElement(childNode, hotColumnProps);
2066
+ return React__default["default"].cloneElement(childNode, {
2067
+ _componentRendererColumns: _this5.componentRendererColumns,
2068
+ _emitColumnSettings: _this5.setHotColumnSettings.bind(_this5),
2069
+ _columnIndex: columnIndex,
2070
+ _getChildElementByType: getChildElementByType.bind(_this5),
2071
+ _getRendererWrapper: _this5.getRendererWrapper.bind(_this5),
2072
+ _getEditorClass: _this5.getEditorClass.bind(_this5),
2073
+ _getOwnerDocument: _this5.getOwnerDocument.bind(_this5),
2074
+ _getEditorCache: _this5.getEditorCache.bind(_this5),
2075
+ children: childNode.props.children
2076
+ });
2058
2077
  });
2059
- var containerProps = getContainerAttributesProps(this.props);
2060
2078
  var editorPortal = createEditorPortal(this.getOwnerDocument(), this.getGlobalEditorElement());
2061
2079
  return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", Object.assign({
2062
2080
  ref: this.setHotElementRef.bind(this)
2063
2081
  }, containerProps), hotColumnClones), React__default["default"].createElement(RenderersPortalManager, {
2064
2082
  ref: this.setRenderersPortalManagerRef.bind(this)
2065
- }), editorPortal, React__default["default"].createElement(Test, null));
2083
+ }), editorPortal);
2066
2084
  }
2067
2085
  }], [{
2068
2086
  key: "version",