@handsontable/react 12.3.2 → 12.3.3-next-629d606-20230327

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.
@@ -146,6 +146,31 @@ function _createSuper(Derived) {
146
146
  return _possibleConstructorReturn(this, result);
147
147
  };
148
148
  }
149
+ function _toConsumableArray(arr) {
150
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
151
+ }
152
+ function _arrayWithoutHoles(arr) {
153
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
154
+ }
155
+ function _iterableToArray(iter) {
156
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
157
+ }
158
+ function _unsupportedIterableToArray(o, minLen) {
159
+ if (!o) return;
160
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
161
+ var n = Object.prototype.toString.call(o).slice(8, -1);
162
+ if (n === "Object" && o.constructor) n = o.constructor.name;
163
+ if (n === "Map" || n === "Set") return Array.from(o);
164
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
165
+ }
166
+ function _arrayLikeToArray(arr, len) {
167
+ if (len == null || len > arr.length) len = arr.length;
168
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
169
+ return arr2;
170
+ }
171
+ function _nonIterableSpread() {
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.");
173
+ }
149
174
  function _toPrimitive(input, hint) {
150
175
  if (typeof input !== "object" || input === null) return input;
151
176
  var prim = input[Symbol.toPrimitive];
@@ -346,69 +371,28 @@ var SettingsMapper = /*#__PURE__*/function () {
346
371
  return SettingsMapper;
347
372
  }();
348
373
 
349
- /**
350
- * Component class used to manage the editor component portals.
351
- */
352
- var EditorsPortalManager = /*#__PURE__*/function (_React$Component) {
353
- _inherits(EditorsPortalManager, _React$Component);
354
- var _super = _createSuper(EditorsPortalManager);
355
- function EditorsPortalManager() {
356
- var _this;
357
- _classCallCheck(this, EditorsPortalManager);
358
- _this = _super.apply(this, arguments);
359
- _this.state = {
360
- portals: []
361
- };
362
- return _this;
363
- }
364
- _createClass(EditorsPortalManager, [{
365
- key: "render",
366
- value: function render() {
367
- return React__default["default"].createElement(React__default["default"].Fragment, null, this.state.portals);
368
- }
369
- }]);
370
- return EditorsPortalManager;
371
- }(React__default["default"].Component);
372
-
373
374
  var HotColumn = /*#__PURE__*/function (_React$Component) {
374
375
  _inherits(HotColumn, _React$Component);
375
376
  var _super = _createSuper(HotColumn);
376
377
  function HotColumn() {
377
- var _this;
378
378
  _classCallCheck(this, HotColumn);
379
- _this = _super.apply(this, arguments);
380
- /**
381
- * Component used to manage the editor portals.
382
- *
383
- * @type {React.Component}
384
- */
385
- _this.editorsPortalManager = null;
386
- return _this;
379
+ return _super.apply(this, arguments);
387
380
  }
388
- /**
389
- * Set the editors portal manager ref.
390
- *
391
- * @param {React.ReactComponent} pmComponent The PortalManager component.
392
- */
393
381
  _createClass(HotColumn, [{
394
- key: "setEditorsPortalManagerRef",
395
- value: function setEditorsPortalManagerRef(pmComponent) {
396
- this.editorsPortalManager = pmComponent;
397
- }
382
+ key: "getSettingsProps",
383
+ value:
398
384
  /**
399
385
  * Filter out all the internal properties and return an object with just the Handsontable-related props.
400
386
  *
401
387
  * @returns {Object}
402
388
  */
403
- }, {
404
- key: "getSettingsProps",
405
- value: function getSettingsProps() {
406
- var _this2 = this;
389
+ function getSettingsProps() {
390
+ var _this = this;
407
391
  this.internalProps = ['_componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
408
392
  return Object.keys(this.props).filter(function (key) {
409
- return !_this2.internalProps.includes(key);
393
+ return !_this.internalProps.includes(key);
410
394
  }).reduce(function (obj, key) {
411
- obj[key] = _this2.props[key];
395
+ obj[key] = _this.props[key];
412
396
  return obj;
413
397
  }, {});
414
398
  }
@@ -439,21 +423,6 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
439
423
  this.columnSettings.editor = this.props._getEditorClass(editorElement, this.props._columnIndex);
440
424
  }
441
425
  }
442
- /**
443
- * Creates the local editor portal and renders it within the editors portal manager component.
444
- *
445
- * @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
446
- */
447
- }, {
448
- key: "renderLocalEditorPortal",
449
- value: function renderLocalEditorPortal(callback) {
450
- var editorCache = this.props._getEditorCache();
451
- var localEditorElement = getExtendedEditorElement(this.props.children, editorCache, this.props._columnIndex);
452
- var editorPortal = createEditorPortal(this.props._getOwnerDocument(), localEditorElement);
453
- this.editorsPortalManager.setState({
454
- portals: [editorPortal]
455
- }, callback);
456
- }
457
426
  /**
458
427
  * Emit the column settings to the parent using a prop passed from the parent.
459
428
  */
@@ -473,11 +442,8 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
473
442
  }, {
474
443
  key: "componentDidMount",
475
444
  value: function componentDidMount() {
476
- var _this3 = this;
477
- this.renderLocalEditorPortal(function () {
478
- _this3.createColumnSettings();
479
- _this3.emitColumnSettings();
480
- });
445
+ this.createColumnSettings();
446
+ this.emitColumnSettings();
481
447
  }
482
448
  /**
483
449
  * Logic performed after the updating of the HotColumn component.
@@ -485,11 +451,8 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
485
451
  }, {
486
452
  key: "componentDidUpdate",
487
453
  value: function componentDidUpdate() {
488
- var _this4 = this;
489
- this.renderLocalEditorPortal(function () {
490
- _this4.createColumnSettings();
491
- _this4.emitColumnSettings();
492
- });
454
+ this.createColumnSettings();
455
+ this.emitColumnSettings();
493
456
  }
494
457
  /**
495
458
  * Render the portals of the editors, if there are any.
@@ -499,9 +462,9 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
499
462
  }, {
500
463
  key: "render",
501
464
  value: function render() {
502
- return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(EditorsPortalManager, {
503
- ref: this.setEditorsPortalManagerRef.bind(this)
504
- }));
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);
505
468
  }
506
469
  }]);
507
470
  return HotColumn;
@@ -531,7 +494,7 @@ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
531
494
  return RenderersPortalManager;
532
495
  }(React__default["default"].Component);
533
496
 
534
- var version="12.3.2";
497
+ var version="12.3.3-next-629d606-20230327";
535
498
 
536
499
  function createCommonjsModule(fn, module) {
537
500
  return module = { exports: {} }, fn(module, module.exports), module.exports;
@@ -1712,12 +1675,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1712
1675
  * @type {React.Component}
1713
1676
  */
1714
1677
  _this.renderersPortalManager = null;
1715
- /**
1716
- * Component used to manage the editor portals.
1717
- *
1718
- * @type {React.Component}
1719
- */
1720
- _this.editorsPortalManager = null;
1721
1678
  /**
1722
1679
  * Array containing the portals cashed to be rendered in bulk after Handsontable's render cycle.
1723
1680
  */
@@ -1799,7 +1756,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1799
1756
  }, {
1800
1757
  key: "clearCache",
1801
1758
  value: function clearCache() {
1802
- this.getEditorCache().clear();
1803
1759
  this.getRenderedCellCache().clear();
1804
1760
  this.componentRendererColumns.clear();
1805
1761
  }
@@ -1951,20 +1907,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1951
1907
  value: function getGlobalEditorElement() {
1952
1908
  return getExtendedEditorElement(this.props.children, this.getEditorCache());
1953
1909
  }
1954
- /**
1955
- * Creates the global editor portal and renders it within the editors portal manager component.
1956
- *
1957
- * @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
1958
- */
1959
- }, {
1960
- key: "renderGlobalEditorPortal",
1961
- value: function renderGlobalEditorPortal(callback) {
1962
- var globalEditorElement = this.getGlobalEditorElement();
1963
- var editorPortal = createEditorPortal(this.getOwnerDocument(), globalEditorElement);
1964
- this.editorsPortalManager.setState({
1965
- portals: [editorPortal]
1966
- }, callback);
1967
- }
1968
1910
  /**
1969
1911
  * Create a new settings object containing the column settings and global editors and renderers.
1970
1912
  *
@@ -2031,12 +1973,10 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2031
1973
  key: "handsontableAfterViewRender",
2032
1974
  value: function handsontableAfterViewRender() {
2033
1975
  var _this3 = this;
2034
- this.renderersPortalManager.setState(function () {
2035
- return Object.assign({}, {
2036
- portals: _this3.portalCacheArray
2037
- });
1976
+ this.renderersPortalManager.setState({
1977
+ portals: _toConsumableArray(this.portalCacheArray)
2038
1978
  }, function () {
2039
- _this3.portalCacheArray.length = 0;
1979
+ _this3.portalCacheArray = [];
2040
1980
  });
2041
1981
  }
2042
1982
  /**
@@ -2061,16 +2001,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2061
2001
  value: function setRenderersPortalManagerRef(pmComponent) {
2062
2002
  this.renderersPortalManager = pmComponent;
2063
2003
  }
2064
- /**
2065
- * Set the editors portal manager ref.
2066
- *
2067
- * @param {React.ReactComponent} pmComponent The PortalManager component.
2068
- */
2069
- }, {
2070
- key: "setEditorsPortalManagerRef",
2071
- value: function setEditorsPortalManagerRef(pmComponent) {
2072
- this.editorsPortalManager = pmComponent;
2073
- }
2074
2004
  /*
2075
2005
  ---------------------------------------
2076
2006
  ------- React lifecycle methods -------
@@ -2083,25 +2013,17 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2083
2013
  key: "componentDidMount",
2084
2014
  value: function componentDidMount() {
2085
2015
  var _this4 = this;
2086
- this.clearCache();
2087
- this.renderGlobalEditorPortal(function () {
2088
- // In React strict mode the mount/unmount is triggered twice. The `if` prevents
2089
- // creating two Handsontable instances for the same component in that mode.
2090
- if (_this4.hotInstance) {
2091
- return;
2092
- }
2093
- var newGlobalSettings = _this4.createNewGlobalSettings();
2094
- _this4.hotInstance = new Handsontable__default["default"].Core(_this4.hotElementRef, newGlobalSettings);
2095
- _this4.hotInstance.addHook('beforeViewRender', function () {
2096
- return _this4.handsontableBeforeViewRender();
2097
- });
2098
- _this4.hotInstance.addHook('afterViewRender', function () {
2099
- return _this4.handsontableAfterViewRender();
2100
- });
2101
- // `init` missing in Handsontable's type definitions.
2102
- _this4.hotInstance.init();
2103
- _this4.displayAutoSizeWarning(newGlobalSettings);
2016
+ var newGlobalSettings = this.createNewGlobalSettings();
2017
+ this.hotInstance = new Handsontable__default["default"].Core(this.hotElementRef, newGlobalSettings);
2018
+ this.hotInstance.addHook('beforeViewRender', function () {
2019
+ return _this4.handsontableBeforeViewRender();
2020
+ });
2021
+ this.hotInstance.addHook('afterViewRender', function () {
2022
+ return _this4.handsontableAfterViewRender();
2104
2023
  });
2024
+ // `init` missing in Handsontable's type definitions.
2025
+ this.hotInstance.init();
2026
+ this.displayAutoSizeWarning(newGlobalSettings);
2105
2027
  }
2106
2028
  /**
2107
2029
  * Logic performed after the component update.
@@ -2109,13 +2031,10 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2109
2031
  }, {
2110
2032
  key: "componentDidUpdate",
2111
2033
  value: function componentDidUpdate() {
2112
- var _this5 = this;
2113
2034
  this.clearCache();
2114
- this.renderGlobalEditorPortal(function () {
2115
- var newGlobalSettings = _this5.createNewGlobalSettings();
2116
- _this5.updateHot(newGlobalSettings);
2117
- _this5.displayAutoSizeWarning(newGlobalSettings);
2118
- });
2035
+ var newGlobalSettings = this.createNewGlobalSettings();
2036
+ this.updateHot(newGlobalSettings);
2037
+ this.displayAutoSizeWarning(newGlobalSettings);
2119
2038
  }
2120
2039
  /**
2121
2040
  * Destroy the Handsontable instance when the parent component unmounts.
@@ -2123,6 +2042,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2123
2042
  }, {
2124
2043
  key: "componentWillUnmount",
2125
2044
  value: function componentWillUnmount() {
2045
+ this.clearCache();
2126
2046
  if (this.hotInstance) {
2127
2047
  this.hotInstance.destroy();
2128
2048
  }
@@ -2133,37 +2053,34 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2133
2053
  }, {
2134
2054
  key: "render",
2135
2055
  value: function render() {
2136
- var _this6 = this;
2056
+ var _this5 = this;
2137
2057
  var containerProps = getContainerAttributesProps(this.props);
2138
2058
  var isHotColumn = function isHotColumn(childNode) {
2139
2059
  return childNode.type === HotColumn;
2140
2060
  };
2141
2061
  var children = React__default["default"].Children.toArray(this.props.children);
2142
- // filter out anything that's not a HotColumn
2143
- children = children.filter(function (childNode) {
2144
- return isHotColumn(childNode);
2145
- });
2146
2062
  // clone the HotColumn nodes and extend them with the callbacks
2147
- var childClones = children.map(function (childNode, columnIndex) {
2063
+ var hotColumnClones = children.filter(function (childNode) {
2064
+ return isHotColumn(childNode);
2065
+ }).map(function (childNode, columnIndex) {
2148
2066
  return React__default["default"].cloneElement(childNode, {
2149
- _componentRendererColumns: _this6.componentRendererColumns,
2150
- _emitColumnSettings: _this6.setHotColumnSettings.bind(_this6),
2067
+ _componentRendererColumns: _this5.componentRendererColumns,
2068
+ _emitColumnSettings: _this5.setHotColumnSettings.bind(_this5),
2151
2069
  _columnIndex: columnIndex,
2152
- _getChildElementByType: getChildElementByType.bind(_this6),
2153
- _getRendererWrapper: _this6.getRendererWrapper.bind(_this6),
2154
- _getEditorClass: _this6.getEditorClass.bind(_this6),
2155
- _getOwnerDocument: _this6.getOwnerDocument.bind(_this6),
2156
- _getEditorCache: _this6.getEditorCache.bind(_this6),
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),
2157
2075
  children: childNode.props.children
2158
2076
  });
2159
2077
  });
2078
+ var editorPortal = createEditorPortal(this.getOwnerDocument(), this.getGlobalEditorElement());
2160
2079
  return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", Object.assign({
2161
2080
  ref: this.setHotElementRef.bind(this)
2162
- }, containerProps), childClones), React__default["default"].createElement(RenderersPortalManager, {
2081
+ }, containerProps), hotColumnClones), React__default["default"].createElement(RenderersPortalManager, {
2163
2082
  ref: this.setRenderersPortalManagerRef.bind(this)
2164
- }), React__default["default"].createElement(EditorsPortalManager, {
2165
- ref: this.setEditorsPortalManagerRef.bind(this)
2166
- }));
2083
+ }), editorPortal);
2167
2084
  }
2168
2085
  }], [{
2169
2086
  key: "version",