@handsontable/react 12.3.1 → 12.3.2-next-e75de58-20230322

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.
@@ -223,48 +223,22 @@ function getOriginalEditorClass(editorElement) {
223
223
  }
224
224
  return editorElement.type.WrappedComponent ? editorElement.type.WrappedComponent : editorElement.type;
225
225
  }
226
- /**
227
- * Remove editor containers from DOM.
228
- *
229
- * @param {Document} [doc] Document to be used.
230
- * @param {Map} editorCache The editor cache reference.
231
- */
232
- function removeEditorContainers() {
233
- var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
234
- doc.querySelectorAll("[class^=\"".concat(DEFAULT_CLASSNAME, "\"]")).forEach(function (domNode) {
235
- if (domNode.parentNode) {
236
- domNode.parentNode.removeChild(domNode);
237
- }
238
- });
239
- }
240
226
  /**
241
227
  * Create an editor portal.
242
228
  *
243
229
  * @param {Document} [doc] Document to be used.
244
230
  * @param {React.ReactElement} editorElement Editor's element.
245
- * @param {Map} editorCache The editor cache reference.
246
231
  * @returns {React.ReactPortal} The portal for the editor.
247
232
  */
248
233
  function createEditorPortal() {
249
234
  var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
250
235
  var editorElement = arguments.length > 1 ? arguments[1] : undefined;
251
236
  if (editorElement === null) {
252
- return;
253
- }
254
- var editorContainer = doc.createElement('DIV');
255
- var _getContainerAttribut = getContainerAttributesProps(editorElement.props, false),
256
- id = _getContainerAttribut.id,
257
- className = _getContainerAttribut.className,
258
- style = _getContainerAttribut.style;
259
- if (id) {
260
- editorContainer.id = id;
261
- }
262
- editorContainer.className = [DEFAULT_CLASSNAME, className].join(' ');
263
- if (style) {
264
- Object.assign(editorContainer.style, style);
237
+ return null;
265
238
  }
266
- doc.body.appendChild(editorContainer);
267
- return ReactDOM__default["default"].createPortal(editorElement, editorContainer);
239
+ var containerProps = getContainerAttributesProps(editorElement.props, false);
240
+ containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
241
+ return ReactDOM__default["default"].createPortal(React__default["default"].createElement("div", Object.assign({}, containerProps), editorElement), doc.body);
268
242
  }
269
243
  /**
270
244
  * Get an editor element extended with a instance-emitting method.
@@ -299,12 +273,11 @@ function getExtendedEditorElement(children, editorCache) {
299
273
  *
300
274
  * @param {React.ReactElement} rElement React element to be used as a base for the component.
301
275
  * @param {Object} props Props to be passed to the cloned element.
302
- * @param {Function} callback Callback to be called after the component has been mounted.
303
276
  * @param {Document} [ownerDocument] The owner document to set the portal up into.
304
277
  * @returns {{portal: React.ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
305
278
  */
306
- function createPortal(rElement, props, callback) {
307
- var ownerDocument = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : document;
279
+ function createPortal(rElement, props) {
280
+ var ownerDocument = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document;
308
281
  if (!ownerDocument) {
309
282
  ownerDocument = document;
310
283
  }
@@ -338,23 +311,6 @@ function getContainerAttributesProps(props) {
338
311
  style: props.style || {}
339
312
  };
340
313
  }
341
- /**
342
- * Add the `UNSAFE_` prefixes to the deprecated lifecycle methods for React >= 16.3.
343
- *
344
- * @param {Object} instance Instance to have the methods renamed.
345
- */
346
- function addUnsafePrefixes(instance) {
347
- var reactSemverArray = React__default["default"].version.split('.').map(function (v) {
348
- return parseInt(v);
349
- });
350
- var shouldPrefix = reactSemverArray[0] >= 16 && reactSemverArray[1] >= 3 || reactSemverArray[0] >= 17;
351
- if (shouldPrefix) {
352
- instance.UNSAFE_componentWillUpdate = instance.componentWillUpdate;
353
- instance.componentWillUpdate = void 0;
354
- instance.UNSAFE_componentWillMount = instance.componentWillMount;
355
- instance.componentWillMount = void 0;
356
- }
357
- }
358
314
 
359
315
  var SettingsMapper = /*#__PURE__*/function () {
360
316
  function SettingsMapper() {
@@ -390,48 +346,54 @@ var SettingsMapper = /*#__PURE__*/function () {
390
346
  return SettingsMapper;
391
347
  }();
392
348
 
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
+
393
373
  var HotColumn = /*#__PURE__*/function (_React$Component) {
394
374
  _inherits(HotColumn, _React$Component);
395
375
  var _super = _createSuper(HotColumn);
396
- /**
397
- * HotColumn class constructor.
398
- *
399
- * @param {HotColumnProps} props Component props.
400
- * @param {*} [context] Component context.
401
- */
402
- function HotColumn(props, context) {
376
+ function HotColumn() {
403
377
  var _this;
404
378
  _classCallCheck(this, HotColumn);
405
- _this = _super.call(this, props, context);
379
+ _this = _super.apply(this, arguments);
406
380
  /**
407
- * Local editor portal cache.
381
+ * Component used to manage the editor portals.
408
382
  *
409
- * @private
410
- * @type {ReactPortal}
383
+ * @type {React.Component}
411
384
  */
412
- _this.localEditorPortal = null;
413
- addUnsafePrefixes(_assertThisInitialized(_this));
385
+ _this.editorsPortalManager = null;
414
386
  return _this;
415
387
  }
416
388
  /**
417
- * Get the local editor portal cache property.
389
+ * Set the editors portal manager ref.
418
390
  *
419
- * @return {ReactPortal} Local editor portal.
391
+ * @param {React.ReactComponent} pmComponent The PortalManager component.
420
392
  */
421
393
  _createClass(HotColumn, [{
422
- key: "getLocalEditorPortal",
423
- value: function getLocalEditorPortal() {
424
- return this.localEditorPortal;
425
- }
426
- /**
427
- * Set the local editor portal cache property.
428
- *
429
- * @param {ReactPortal} portal Local editor portal.
430
- */
431
- }, {
432
- key: "setLocalEditorPortal",
433
- value: function setLocalEditorPortal(portal) {
434
- this.localEditorPortal = portal;
394
+ key: "setEditorsPortalManagerRef",
395
+ value: function setEditorsPortalManagerRef(pmComponent) {
396
+ this.editorsPortalManager = pmComponent;
435
397
  }
436
398
  /**
437
399
  * Filter out all the internal properties and return an object with just the Handsontable-related props.
@@ -442,7 +404,7 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
442
404
  key: "getSettingsProps",
443
405
  value: function getSettingsProps() {
444
406
  var _this2 = this;
445
- this.internalProps = ['__componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
407
+ this.internalProps = ['_componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
446
408
  return Object.keys(this.props).filter(function (key) {
447
409
  return !_this2.internalProps.includes(key);
448
410
  }).reduce(function (obj, key) {
@@ -478,19 +440,19 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
478
440
  }
479
441
  }
480
442
  /**
481
- * Create the local editor portal and its destination HTML element if needed.
443
+ * Creates the local editor portal and renders it within the editors portal manager component.
482
444
  *
483
- * @param {React.ReactNode} [children] Children of the HotTable instance. Defaults to `this.props.children`.
445
+ * @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
484
446
  */
485
447
  }, {
486
- key: "createLocalEditorPortal",
487
- value: function createLocalEditorPortal() {
488
- var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.children;
448
+ key: "renderLocalEditorPortal",
449
+ value: function renderLocalEditorPortal(callback) {
489
450
  var editorCache = this.props._getEditorCache();
490
- var localEditorElement = getExtendedEditorElement(children, editorCache, this.props._columnIndex);
491
- if (localEditorElement) {
492
- this.setLocalEditorPortal(createEditorPortal(this.props._getOwnerDocument(), localEditorElement, editorCache));
493
- }
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);
494
456
  }
495
457
  /**
496
458
  * Emit the column settings to the parent using a prop passed from the parent.
@@ -505,30 +467,17 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
505
467
  ------- React lifecycle methods -------
506
468
  ---------------------------------------
507
469
  */
508
- /**
509
- * Logic performed before the mounting of the HotColumn component.
510
- */
511
- }, {
512
- key: "componentWillMount",
513
- value: function componentWillMount() {
514
- this.createLocalEditorPortal();
515
- }
516
470
  /**
517
471
  * Logic performed after the mounting of the HotColumn component.
518
472
  */
519
473
  }, {
520
474
  key: "componentDidMount",
521
475
  value: function componentDidMount() {
522
- this.createColumnSettings();
523
- this.emitColumnSettings();
524
- }
525
- /**
526
- * Logic performed before the updating of the HotColumn component.
527
- */
528
- }, {
529
- key: "componentWillUpdate",
530
- value: function componentWillUpdate(nextProps, nextState, nextContext) {
531
- this.createLocalEditorPortal(nextProps.children);
476
+ var _this3 = this;
477
+ this.renderLocalEditorPortal(function () {
478
+ _this3.createColumnSettings();
479
+ _this3.emitColumnSettings();
480
+ });
532
481
  }
533
482
  /**
534
483
  * Logic performed after the updating of the HotColumn component.
@@ -536,8 +485,11 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
536
485
  }, {
537
486
  key: "componentDidUpdate",
538
487
  value: function componentDidUpdate() {
539
- this.createColumnSettings();
540
- this.emitColumnSettings();
488
+ var _this4 = this;
489
+ this.renderLocalEditorPortal(function () {
490
+ _this4.createColumnSettings();
491
+ _this4.emitColumnSettings();
492
+ });
541
493
  }
542
494
  /**
543
495
  * Render the portals of the editors, if there are any.
@@ -547,7 +499,9 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
547
499
  }, {
548
500
  key: "render",
549
501
  value: function render() {
550
- return React__default["default"].createElement(React__default["default"].Fragment, null, this.getLocalEditorPortal());
502
+ return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(EditorsPortalManager, {
503
+ ref: this.setEditorsPortalManagerRef.bind(this)
504
+ }));
551
505
  }
552
506
  }]);
553
507
  return HotColumn;
@@ -556,28 +510,28 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
556
510
  /**
557
511
  * Component class used to manage the renderer component portals.
558
512
  */
559
- var PortalManager = /*#__PURE__*/function (_React$Component) {
560
- _inherits(PortalManager, _React$Component);
561
- var _super = _createSuper(PortalManager);
562
- function PortalManager(props) {
513
+ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
514
+ _inherits(RenderersPortalManager, _React$Component);
515
+ var _super = _createSuper(RenderersPortalManager);
516
+ function RenderersPortalManager() {
563
517
  var _this;
564
- _classCallCheck(this, PortalManager);
565
- _this = _super.call(this, props);
518
+ _classCallCheck(this, RenderersPortalManager);
519
+ _this = _super.apply(this, arguments);
566
520
  _this.state = {
567
521
  portals: []
568
522
  };
569
523
  return _this;
570
524
  }
571
- _createClass(PortalManager, [{
525
+ _createClass(RenderersPortalManager, [{
572
526
  key: "render",
573
527
  value: function render() {
574
528
  return React__default["default"].createElement(React__default["default"].Fragment, null, this.state.portals);
575
529
  }
576
530
  }]);
577
- return PortalManager;
531
+ return RenderersPortalManager;
578
532
  }(React__default["default"].Component);
579
533
 
580
- var version="12.3.1";
534
+ var version="12.3.2-next-e75de58-20230322";
581
535
 
582
536
  function createCommonjsModule(fn, module) {
583
537
  return module = { exports: {} }, fn(module, module.exports), module.exports;
@@ -1723,16 +1677,10 @@ var PropTypes = propTypes;
1723
1677
  var HotTable = /*#__PURE__*/function (_React$Component) {
1724
1678
  _inherits(HotTable, _React$Component);
1725
1679
  var _super = _createSuper(HotTable);
1726
- /**
1727
- * HotTable class constructor.
1728
- *
1729
- * @param {HotTableProps} props Component props.
1730
- * @param {*} [context] Component context.
1731
- */
1732
- function HotTable(props, context) {
1680
+ function HotTable() {
1733
1681
  var _this;
1734
1682
  _classCallCheck(this, HotTable);
1735
- _this = _super.call(this, props, context);
1683
+ _this = _super.apply(this, arguments);
1736
1684
  /**
1737
1685
  * The `id` of the main Handsontable DOM element.
1738
1686
  *
@@ -1763,18 +1711,17 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1763
1711
  *
1764
1712
  * @type {React.Component}
1765
1713
  */
1766
- _this.portalManager = null;
1714
+ _this.renderersPortalManager = null;
1767
1715
  /**
1768
- * Array containing the portals cashed to be rendered in bulk after Handsontable's render cycle.
1716
+ * Component used to manage the editor portals.
1717
+ *
1718
+ * @type {React.Component}
1769
1719
  */
1770
- _this.portalCacheArray = [];
1720
+ _this.editorsPortalManager = null;
1771
1721
  /**
1772
- * Global editor portal cache.
1773
- *
1774
- * @private
1775
- * @type {React.ReactPortal}
1722
+ * Array containing the portals cashed to be rendered in bulk after Handsontable's render cycle.
1776
1723
  */
1777
- _this.globalEditorPortal = null;
1724
+ _this.portalCacheArray = [];
1778
1725
  /**
1779
1726
  * The rendered cells cache.
1780
1727
  *
@@ -1797,7 +1744,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1797
1744
  * @type {Map}
1798
1745
  */
1799
1746
  _this.componentRendererColumns = new Map();
1800
- addUnsafePrefixes(_assertThisInitialized(_this));
1801
1747
  return _this;
1802
1748
  }
1803
1749
  /**
@@ -1847,37 +1793,14 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1847
1793
  value: function getEditorCache() {
1848
1794
  return this.editorCache;
1849
1795
  }
1850
- /**
1851
- * Get the global editor portal property.
1852
- *
1853
- * @return {React.ReactPortal} The global editor portal.
1854
- */
1855
- }, {
1856
- key: "getGlobalEditorPortal",
1857
- value: function getGlobalEditorPortal() {
1858
- return this.globalEditorPortal;
1859
- }
1860
- /**
1861
- * Set the private editor portal cache property.
1862
- *
1863
- * @param {React.ReactPortal} portal Global editor portal.
1864
- */
1865
- }, {
1866
- key: "setGlobalEditorPortal",
1867
- value: function setGlobalEditorPortal(portal) {
1868
- this.globalEditorPortal = portal;
1869
- }
1870
1796
  /**
1871
1797
  * Clear both the editor and the renderer cache.
1872
1798
  */
1873
1799
  }, {
1874
1800
  key: "clearCache",
1875
1801
  value: function clearCache() {
1876
- var renderedCellCache = this.getRenderedCellCache();
1877
- this.setGlobalEditorPortal(null);
1878
- removeEditorContainers(this.getOwnerDocument());
1879
1802
  this.getEditorCache().clear();
1880
- renderedCellCache.clear();
1803
+ this.getRenderedCellCache().clear();
1881
1804
  this.componentRendererColumns.clear();
1882
1805
  }
1883
1806
  /**
@@ -1924,7 +1847,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1924
1847
  value: value,
1925
1848
  cellProperties: cellProperties,
1926
1849
  isRenderer: true
1927
- }, function () {}, TD.ownerDocument),
1850
+ }, TD.ownerDocument),
1928
1851
  portal = _createPortal.portal,
1929
1852
  portalContainer = _createPortal.portalContainer;
1930
1853
  while (TD.firstChild) {
@@ -1948,11 +1871,10 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1948
1871
  }, {
1949
1872
  key: "getEditorClass",
1950
1873
  value: function getEditorClass(editorElement) {
1951
- var _editorCache$get;
1874
+ var _this$getEditorCache$;
1952
1875
  var editorColumnScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GLOBAL_EDITOR_SCOPE;
1953
1876
  var editorClass = getOriginalEditorClass(editorElement);
1954
- var editorCache = this.getEditorCache();
1955
- var cachedComponent = (_editorCache$get = editorCache.get(editorClass)) === null || _editorCache$get === void 0 ? void 0 : _editorCache$get.get(editorColumnScope);
1877
+ var cachedComponent = (_this$getEditorCache$ = this.getEditorCache().get(editorClass)) === null || _this$getEditorCache$ === void 0 ? void 0 : _this$getEditorCache$.get(editorColumnScope);
1956
1878
  return this.makeEditorClass(cachedComponent);
1957
1879
  }
1958
1880
  /**
@@ -2016,8 +1938,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2016
1938
  }, {
2017
1939
  key: "getGlobalRendererElement",
2018
1940
  value: function getGlobalRendererElement() {
2019
- var hotTableSlots = this.props.children;
2020
- return getChildElementByType(hotTableSlots, 'hot-renderer');
1941
+ return getChildElementByType(this.props.children, 'hot-renderer');
2021
1942
  }
2022
1943
  /**
2023
1944
  * Get the editor element for the entire HotTable instance.
@@ -2028,22 +1949,21 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2028
1949
  }, {
2029
1950
  key: "getGlobalEditorElement",
2030
1951
  value: function getGlobalEditorElement() {
2031
- var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.children;
2032
- return getExtendedEditorElement(children, this.getEditorCache());
1952
+ return getExtendedEditorElement(this.props.children, this.getEditorCache());
2033
1953
  }
2034
1954
  /**
2035
- * Create the global editor portal and its destination HTML element if needed.
1955
+ * Creates the global editor portal and renders it within the editors portal manager component.
2036
1956
  *
2037
- * @param {React.ReactNode} [children] Children of the HotTable instance. Defaults to `this.props.children`.
1957
+ * @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
2038
1958
  */
2039
1959
  }, {
2040
- key: "createGlobalEditorPortal",
2041
- value: function createGlobalEditorPortal() {
2042
- var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.children;
2043
- var globalEditorElement = this.getGlobalEditorElement(children);
2044
- if (globalEditorElement) {
2045
- this.setGlobalEditorPortal(createEditorPortal(this.getOwnerDocument(), globalEditorElement, this.getEditorCache()));
2046
- }
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);
2047
1967
  }
2048
1968
  /**
2049
1969
  * Create a new settings object containing the column settings and global editors and renderers.
@@ -2111,7 +2031,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2111
2031
  key: "handsontableAfterViewRender",
2112
2032
  value: function handsontableAfterViewRender() {
2113
2033
  var _this3 = this;
2114
- this.portalManager.setState(function () {
2034
+ this.renderersPortalManager.setState(function () {
2115
2035
  return Object.assign({}, {
2116
2036
  portals: _this3.portalCacheArray
2117
2037
  });
@@ -2132,57 +2052,56 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2132
2052
  }
2133
2053
  }
2134
2054
  /**
2135
- * Set the portal manager ref.
2055
+ * Set the renderers portal manager ref.
2136
2056
  *
2137
2057
  * @param {React.ReactComponent} pmComponent The PortalManager component.
2138
2058
  */
2139
2059
  }, {
2140
- key: "setPortalManagerRef",
2141
- value: function setPortalManagerRef(pmComponent) {
2142
- this.portalManager = pmComponent;
2060
+ key: "setRenderersPortalManagerRef",
2061
+ value: function setRenderersPortalManagerRef(pmComponent) {
2062
+ this.renderersPortalManager = pmComponent;
2063
+ }
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;
2143
2073
  }
2144
2074
  /*
2145
2075
  ---------------------------------------
2146
2076
  ------- React lifecycle methods -------
2147
2077
  ---------------------------------------
2148
2078
  */
2149
- /**
2150
- * Logic performed before the mounting of the component.
2151
- */
2152
- }, {
2153
- key: "componentWillMount",
2154
- value: function componentWillMount() {
2155
- this.clearCache();
2156
- this.createGlobalEditorPortal();
2157
- }
2158
2079
  /**
2159
2080
  * Initialize Handsontable after the component has mounted.
2160
2081
  */
2161
2082
  }, {
2162
2083
  key: "componentDidMount",
2163
2084
  value: function componentDidMount() {
2164
- var hotTableComponent = this;
2165
- var newGlobalSettings = this.createNewGlobalSettings();
2166
- this.hotInstance = new Handsontable__default["default"].Core(this.hotElementRef, newGlobalSettings);
2167
- this.hotInstance.addHook('beforeViewRender', function (isForced) {
2168
- hotTableComponent.handsontableBeforeViewRender();
2169
- });
2170
- this.hotInstance.addHook('afterViewRender', function () {
2171
- hotTableComponent.handsontableAfterViewRender();
2172
- });
2173
- // `init` missing in Handsontable's type definitions.
2174
- this.hotInstance.init();
2175
- this.displayAutoSizeWarning(newGlobalSettings);
2176
- }
2177
- /**
2178
- * Logic performed before the component update.
2179
- */
2180
- }, {
2181
- key: "componentWillUpdate",
2182
- value: function componentWillUpdate(nextProps, nextState, nextContext) {
2085
+ var _this4 = this;
2183
2086
  this.clearCache();
2184
- removeEditorContainers(this.getOwnerDocument());
2185
- this.createGlobalEditorPortal(nextProps.children);
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);
2104
+ });
2186
2105
  }
2187
2106
  /**
2188
2107
  * Logic performed after the component update.
@@ -2190,9 +2109,13 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2190
2109
  }, {
2191
2110
  key: "componentDidUpdate",
2192
2111
  value: function componentDidUpdate() {
2193
- var newGlobalSettings = this.createNewGlobalSettings();
2194
- this.updateHot(newGlobalSettings);
2195
- this.displayAutoSizeWarning(newGlobalSettings);
2112
+ var _this5 = this;
2113
+ this.clearCache();
2114
+ this.renderGlobalEditorPortal(function () {
2115
+ var newGlobalSettings = _this5.createNewGlobalSettings();
2116
+ _this5.updateHot(newGlobalSettings);
2117
+ _this5.displayAutoSizeWarning(newGlobalSettings);
2118
+ });
2196
2119
  }
2197
2120
  /**
2198
2121
  * Destroy the Handsontable instance when the parent component unmounts.
@@ -2203,7 +2126,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2203
2126
  if (this.hotInstance) {
2204
2127
  this.hotInstance.destroy();
2205
2128
  }
2206
- removeEditorContainers(this.getOwnerDocument());
2207
2129
  }
2208
2130
  /**
2209
2131
  * Render the component.
@@ -2211,11 +2133,8 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2211
2133
  }, {
2212
2134
  key: "render",
2213
2135
  value: function render() {
2214
- var _this4 = this;
2215
- var _getContainerAttribut = getContainerAttributesProps(this.props),
2216
- id = _getContainerAttribut.id,
2217
- className = _getContainerAttribut.className,
2218
- style = _getContainerAttribut.style;
2136
+ var _this6 = this;
2137
+ var containerProps = getContainerAttributesProps(this.props);
2219
2138
  var isHotColumn = function isHotColumn(childNode) {
2220
2139
  return childNode.type === HotColumn;
2221
2140
  };
@@ -2227,26 +2146,23 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2227
2146
  // clone the HotColumn nodes and extend them with the callbacks
2228
2147
  var childClones = children.map(function (childNode, columnIndex) {
2229
2148
  return React__default["default"].cloneElement(childNode, {
2230
- _componentRendererColumns: _this4.componentRendererColumns,
2231
- _emitColumnSettings: _this4.setHotColumnSettings.bind(_this4),
2149
+ _componentRendererColumns: _this6.componentRendererColumns,
2150
+ _emitColumnSettings: _this6.setHotColumnSettings.bind(_this6),
2232
2151
  _columnIndex: columnIndex,
2233
- _getChildElementByType: getChildElementByType.bind(_this4),
2234
- _getRendererWrapper: _this4.getRendererWrapper.bind(_this4),
2235
- _getEditorClass: _this4.getEditorClass.bind(_this4),
2236
- _getOwnerDocument: _this4.getOwnerDocument.bind(_this4),
2237
- _getEditorCache: _this4.getEditorCache.bind(_this4),
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),
2238
2157
  children: childNode.props.children
2239
2158
  });
2240
2159
  });
2241
- // add the global editor to the list of children
2242
- childClones.push(this.getGlobalEditorPortal());
2243
- return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", {
2244
- ref: this.setHotElementRef.bind(this),
2245
- id: id,
2246
- className: className,
2247
- style: style
2248
- }, childClones), React__default["default"].createElement(PortalManager, {
2249
- ref: this.setPortalManagerRef.bind(this)
2160
+ return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", Object.assign({
2161
+ ref: this.setHotElementRef.bind(this)
2162
+ }, containerProps), childClones), React__default["default"].createElement(RenderersPortalManager, {
2163
+ ref: this.setRenderersPortalManagerRef.bind(this)
2164
+ }), React__default["default"].createElement(EditorsPortalManager, {
2165
+ ref: this.setEditorsPortalManagerRef.bind(this)
2250
2166
  }));
2251
2167
  }
2252
2168
  }], [{
@@ -2269,10 +2185,10 @@ HotTable.propTypes = {
2269
2185
  var BaseEditorComponent = /*#__PURE__*/function (_React$Component) {
2270
2186
  _inherits(BaseEditorComponent, _React$Component);
2271
2187
  var _super = _createSuper(BaseEditorComponent);
2272
- function BaseEditorComponent(props) {
2188
+ function BaseEditorComponent() {
2273
2189
  var _this;
2274
2190
  _classCallCheck(this, BaseEditorComponent);
2275
- _this = _super.call(this, props);
2191
+ _this = _super.apply(this, arguments);
2276
2192
  _this.name = 'BaseEditorComponent';
2277
2193
  _this.instance = null;
2278
2194
  _this.row = null;
@@ -2285,13 +2201,24 @@ var BaseEditorComponent = /*#__PURE__*/function (_React$Component) {
2285
2201
  _this.hotInstance = null;
2286
2202
  _this.hotCustomEditorInstance = null;
2287
2203
  _this.hot = null;
2288
- if (props.emitEditorInstance) {
2289
- props.emitEditorInstance(_assertThisInitialized(_this), props.editorColumnScope);
2290
- }
2291
2204
  return _this;
2292
2205
  }
2293
- // BaseEditor methods:
2294
2206
  _createClass(BaseEditorComponent, [{
2207
+ key: "componentDidMount",
2208
+ value: function componentDidMount() {
2209
+ if (this.props.emitEditorInstance) {
2210
+ this.props.emitEditorInstance(this, this.props.editorColumnScope);
2211
+ }
2212
+ }
2213
+ }, {
2214
+ key: "componentDidUpdate",
2215
+ value: function componentDidUpdate() {
2216
+ if (this.props.emitEditorInstance) {
2217
+ this.props.emitEditorInstance(this, this.props.editorColumnScope);
2218
+ }
2219
+ }
2220
+ // BaseEditor methods:
2221
+ }, {
2295
2222
  key: "_fireCallbacks",
2296
2223
  value: function _fireCallbacks() {
2297
2224
  var _Handsontable$editors;