@handsontable/react 0.0.0-next-e2b07e5-20231213 → 0.0.0-next-d26e81f-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/Test.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const Test: () => React.JSX.Element;
@@ -12,6 +12,33 @@ 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
+ }
15
42
  function ownKeys(e, r) {
16
43
  var t = Object.keys(e);
17
44
  if (Object.getOwnPropertySymbols) {
@@ -33,6 +60,20 @@ function _objectSpread2(e) {
33
60
  }
34
61
  return e;
35
62
  }
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
+ }
36
77
  function _typeof(o) {
37
78
  "@babel/helpers - typeof";
38
79
 
@@ -146,12 +187,18 @@ function _createSuper(Derived) {
146
187
  return _possibleConstructorReturn(this, result);
147
188
  };
148
189
  }
190
+ function _slicedToArray(arr, i) {
191
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
192
+ }
149
193
  function _toConsumableArray(arr) {
150
194
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
151
195
  }
152
196
  function _arrayWithoutHoles(arr) {
153
197
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
154
198
  }
199
+ function _arrayWithHoles(arr) {
200
+ if (Array.isArray(arr)) return arr;
201
+ }
155
202
  function _iterableToArray(iter) {
156
203
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
157
204
  }
@@ -171,22 +218,12 @@ function _arrayLikeToArray(arr, len) {
171
218
  function _nonIterableSpread() {
172
219
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
173
220
  }
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);
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.");
187
223
  }
188
224
 
189
225
  var bulkComponentContainer = null;
226
+ var hasIdWarningBeenPrinted = false;
190
227
  /**
191
228
  * Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
192
229
  */
@@ -251,14 +288,12 @@ function getOriginalEditorClass(editorElement) {
251
288
  /**
252
289
  * Create an editor portal.
253
290
  *
254
- * @param {Document} [doc] Document to be used.
291
+ * @param {Document} doc Document to be used.
255
292
  * @param {React.ReactElement} editorElement Editor's element.
256
293
  * @returns {React.ReactPortal} The portal for the editor.
257
294
  */
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) {
295
+ function createEditorPortal(doc, editorElement) {
296
+ if (typeof doc === 'undefined' || editorElement === null) {
262
297
  return null;
263
298
  }
264
299
  var containerProps = getContainerAttributesProps(editorElement.props, false);
@@ -330,12 +365,47 @@ function createPortal(rElement, props) {
330
365
  */
331
366
  function getContainerAttributesProps(props) {
332
367
  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
+ }
333
372
  return {
334
373
  id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : void 0),
335
374
  className: props.className || '',
336
375
  style: props.style || {}
337
376
  };
338
377
  }
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
+ };
339
409
 
340
410
  var SettingsMapper = /*#__PURE__*/function () {
341
411
  function SettingsMapper() {
@@ -371,105 +441,6 @@ var SettingsMapper = /*#__PURE__*/function () {
371
441
  return SettingsMapper;
372
442
  }();
373
443
 
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
-
473
444
  /**
474
445
  * Component class used to manage the renderer component portals.
475
446
  */
@@ -494,7 +465,7 @@ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
494
465
  return RenderersPortalManager;
495
466
  }(React__default["default"].Component);
496
467
 
497
- var version="0.0.0-next-e2b07e5-20231213";
468
+ var version="0.0.0-next-d26e81f-20231213";
498
469
 
499
470
  function createCommonjsModule(fn, module) {
500
471
  return module = { exports: {} }, fn(module, module.exports), module.exports;
@@ -1615,6 +1586,13 @@ var propTypes = createCommonjsModule(function (module) {
1615
1586
  });
1616
1587
  var PropTypes = propTypes;
1617
1588
 
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
+
1618
1596
  /**
1619
1597
  * A Handsontable-ReactJS wrapper.
1620
1598
  *
@@ -1767,7 +1745,10 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1767
1745
  }, {
1768
1746
  key: "getOwnerDocument",
1769
1747
  value: function getOwnerDocument() {
1770
- return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
1748
+ if (isCSR()) {
1749
+ return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
1750
+ }
1751
+ return null;
1771
1752
  }
1772
1753
  /**
1773
1754
  * Set the reference to the main Handsontable DOM element.
@@ -2054,7 +2035,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2054
2035
  key: "render",
2055
2036
  value: function render() {
2056
2037
  var _this5 = this;
2057
- var containerProps = getContainerAttributesProps(this.props);
2058
2038
  var isHotColumn = function isHotColumn(childNode) {
2059
2039
  return childNode.type === HotColumn;
2060
2040
  };
@@ -2063,6 +2043,17 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2063
2043
  var hotColumnClones = children.filter(function (childNode) {
2064
2044
  return isHotColumn(childNode);
2065
2045
  }).map(function (childNode, columnIndex) {
2046
+ ({
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
+ });
2066
2057
  return React__default["default"].cloneElement(childNode, {
2067
2058
  _componentRendererColumns: _this5.componentRendererColumns,
2068
2059
  _emitColumnSettings: _this5.setHotColumnSettings.bind(_this5),
@@ -2075,12 +2066,13 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2075
2066
  children: childNode.props.children
2076
2067
  });
2077
2068
  });
2069
+ var containerProps = getContainerAttributesProps(this.props);
2078
2070
  var editorPortal = createEditorPortal(this.getOwnerDocument(), this.getGlobalEditorElement());
2079
2071
  return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", Object.assign({
2080
2072
  ref: this.setHotElementRef.bind(this)
2081
2073
  }, containerProps), hotColumnClones), React__default["default"].createElement(RenderersPortalManager, {
2082
2074
  ref: this.setRenderersPortalManagerRef.bind(this)
2083
- }), editorPortal);
2075
+ }), editorPortal, React__default["default"].createElement(Test, null));
2084
2076
  }
2085
2077
  }], [{
2086
2078
  key: "version",