@handsontable/react 12.3.2 → 12.3.3-next-018f495-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.
@@ -136,6 +136,31 @@ function _createSuper(Derived) {
136
136
  return _possibleConstructorReturn(this, result);
137
137
  };
138
138
  }
139
+ function _toConsumableArray(arr) {
140
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
141
+ }
142
+ function _arrayWithoutHoles(arr) {
143
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
144
+ }
145
+ function _iterableToArray(iter) {
146
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
147
+ }
148
+ function _unsupportedIterableToArray(o, minLen) {
149
+ if (!o) return;
150
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
151
+ var n = Object.prototype.toString.call(o).slice(8, -1);
152
+ if (n === "Object" && o.constructor) n = o.constructor.name;
153
+ if (n === "Map" || n === "Set") return Array.from(o);
154
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
155
+ }
156
+ function _arrayLikeToArray(arr, len) {
157
+ if (len == null || len > arr.length) len = arr.length;
158
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
159
+ return arr2;
160
+ }
161
+ function _nonIterableSpread() {
162
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
163
+ }
139
164
  function _toPrimitive(input, hint) {
140
165
  if (typeof input !== "object" || input === null) return input;
141
166
  var prim = input[Symbol.toPrimitive];
@@ -336,69 +361,28 @@ var SettingsMapper = /*#__PURE__*/function () {
336
361
  return SettingsMapper;
337
362
  }();
338
363
 
339
- /**
340
- * Component class used to manage the editor component portals.
341
- */
342
- var EditorsPortalManager = /*#__PURE__*/function (_React$Component) {
343
- _inherits(EditorsPortalManager, _React$Component);
344
- var _super = _createSuper(EditorsPortalManager);
345
- function EditorsPortalManager() {
346
- var _this;
347
- _classCallCheck(this, EditorsPortalManager);
348
- _this = _super.apply(this, arguments);
349
- _this.state = {
350
- portals: []
351
- };
352
- return _this;
353
- }
354
- _createClass(EditorsPortalManager, [{
355
- key: "render",
356
- value: function render() {
357
- return React.createElement(React.Fragment, null, this.state.portals);
358
- }
359
- }]);
360
- return EditorsPortalManager;
361
- }(React.Component);
362
-
363
364
  var HotColumn = /*#__PURE__*/function (_React$Component) {
364
365
  _inherits(HotColumn, _React$Component);
365
366
  var _super = _createSuper(HotColumn);
366
367
  function HotColumn() {
367
- var _this;
368
368
  _classCallCheck(this, HotColumn);
369
- _this = _super.apply(this, arguments);
370
- /**
371
- * Component used to manage the editor portals.
372
- *
373
- * @type {React.Component}
374
- */
375
- _this.editorsPortalManager = null;
376
- return _this;
369
+ return _super.apply(this, arguments);
377
370
  }
378
- /**
379
- * Set the editors portal manager ref.
380
- *
381
- * @param {React.ReactComponent} pmComponent The PortalManager component.
382
- */
383
371
  _createClass(HotColumn, [{
384
- key: "setEditorsPortalManagerRef",
385
- value: function setEditorsPortalManagerRef(pmComponent) {
386
- this.editorsPortalManager = pmComponent;
387
- }
372
+ key: "getSettingsProps",
373
+ value:
388
374
  /**
389
375
  * Filter out all the internal properties and return an object with just the Handsontable-related props.
390
376
  *
391
377
  * @returns {Object}
392
378
  */
393
- }, {
394
- key: "getSettingsProps",
395
- value: function getSettingsProps() {
396
- var _this2 = this;
379
+ function getSettingsProps() {
380
+ var _this = this;
397
381
  this.internalProps = ['_componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
398
382
  return Object.keys(this.props).filter(function (key) {
399
- return !_this2.internalProps.includes(key);
383
+ return !_this.internalProps.includes(key);
400
384
  }).reduce(function (obj, key) {
401
- obj[key] = _this2.props[key];
385
+ obj[key] = _this.props[key];
402
386
  return obj;
403
387
  }, {});
404
388
  }
@@ -429,21 +413,6 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
429
413
  this.columnSettings.editor = this.props._getEditorClass(editorElement, this.props._columnIndex);
430
414
  }
431
415
  }
432
- /**
433
- * Creates the local editor portal and renders it within the editors portal manager component.
434
- *
435
- * @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
436
- */
437
- }, {
438
- key: "renderLocalEditorPortal",
439
- value: function renderLocalEditorPortal(callback) {
440
- var editorCache = this.props._getEditorCache();
441
- var localEditorElement = getExtendedEditorElement(this.props.children, editorCache, this.props._columnIndex);
442
- var editorPortal = createEditorPortal(this.props._getOwnerDocument(), localEditorElement);
443
- this.editorsPortalManager.setState({
444
- portals: [editorPortal]
445
- }, callback);
446
- }
447
416
  /**
448
417
  * Emit the column settings to the parent using a prop passed from the parent.
449
418
  */
@@ -463,11 +432,8 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
463
432
  }, {
464
433
  key: "componentDidMount",
465
434
  value: function componentDidMount() {
466
- var _this3 = this;
467
- this.renderLocalEditorPortal(function () {
468
- _this3.createColumnSettings();
469
- _this3.emitColumnSettings();
470
- });
435
+ this.createColumnSettings();
436
+ this.emitColumnSettings();
471
437
  }
472
438
  /**
473
439
  * Logic performed after the updating of the HotColumn component.
@@ -475,11 +441,8 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
475
441
  }, {
476
442
  key: "componentDidUpdate",
477
443
  value: function componentDidUpdate() {
478
- var _this4 = this;
479
- this.renderLocalEditorPortal(function () {
480
- _this4.createColumnSettings();
481
- _this4.emitColumnSettings();
482
- });
444
+ this.createColumnSettings();
445
+ this.emitColumnSettings();
483
446
  }
484
447
  /**
485
448
  * Render the portals of the editors, if there are any.
@@ -489,9 +452,9 @@ var HotColumn = /*#__PURE__*/function (_React$Component) {
489
452
  }, {
490
453
  key: "render",
491
454
  value: function render() {
492
- return React.createElement(React.Fragment, null, React.createElement(EditorsPortalManager, {
493
- ref: this.setEditorsPortalManagerRef.bind(this)
494
- }));
455
+ var ownerDocument = this.props._getOwnerDocument();
456
+ var editorPortal = createEditorPortal(ownerDocument, this.getLocalEditorElement());
457
+ return React.createElement(React.Fragment, null, editorPortal);
495
458
  }
496
459
  }]);
497
460
  return HotColumn;
@@ -521,7 +484,7 @@ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
521
484
  return RenderersPortalManager;
522
485
  }(React.Component);
523
486
 
524
- var version="12.3.2";
487
+ var version="12.3.3-next-018f495-20230327";
525
488
 
526
489
  function createCommonjsModule(fn, module) {
527
490
  return module = { exports: {} }, fn(module, module.exports), module.exports;
@@ -1702,12 +1665,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1702
1665
  * @type {React.Component}
1703
1666
  */
1704
1667
  _this.renderersPortalManager = null;
1705
- /**
1706
- * Component used to manage the editor portals.
1707
- *
1708
- * @type {React.Component}
1709
- */
1710
- _this.editorsPortalManager = null;
1711
1668
  /**
1712
1669
  * Array containing the portals cashed to be rendered in bulk after Handsontable's render cycle.
1713
1670
  */
@@ -1789,7 +1746,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1789
1746
  }, {
1790
1747
  key: "clearCache",
1791
1748
  value: function clearCache() {
1792
- this.getEditorCache().clear();
1793
1749
  this.getRenderedCellCache().clear();
1794
1750
  this.componentRendererColumns.clear();
1795
1751
  }
@@ -1941,20 +1897,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1941
1897
  value: function getGlobalEditorElement() {
1942
1898
  return getExtendedEditorElement(this.props.children, this.getEditorCache());
1943
1899
  }
1944
- /**
1945
- * Creates the global editor portal and renders it within the editors portal manager component.
1946
- *
1947
- * @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
1948
- */
1949
- }, {
1950
- key: "renderGlobalEditorPortal",
1951
- value: function renderGlobalEditorPortal(callback) {
1952
- var globalEditorElement = this.getGlobalEditorElement();
1953
- var editorPortal = createEditorPortal(this.getOwnerDocument(), globalEditorElement);
1954
- this.editorsPortalManager.setState({
1955
- portals: [editorPortal]
1956
- }, callback);
1957
- }
1958
1900
  /**
1959
1901
  * Create a new settings object containing the column settings and global editors and renderers.
1960
1902
  *
@@ -2021,12 +1963,10 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2021
1963
  key: "handsontableAfterViewRender",
2022
1964
  value: function handsontableAfterViewRender() {
2023
1965
  var _this3 = this;
2024
- this.renderersPortalManager.setState(function () {
2025
- return Object.assign({}, {
2026
- portals: _this3.portalCacheArray
2027
- });
1966
+ this.renderersPortalManager.setState({
1967
+ portals: _toConsumableArray(this.portalCacheArray)
2028
1968
  }, function () {
2029
- _this3.portalCacheArray.length = 0;
1969
+ _this3.portalCacheArray = [];
2030
1970
  });
2031
1971
  }
2032
1972
  /**
@@ -2051,16 +1991,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2051
1991
  value: function setRenderersPortalManagerRef(pmComponent) {
2052
1992
  this.renderersPortalManager = pmComponent;
2053
1993
  }
2054
- /**
2055
- * Set the editors portal manager ref.
2056
- *
2057
- * @param {React.ReactComponent} pmComponent The PortalManager component.
2058
- */
2059
- }, {
2060
- key: "setEditorsPortalManagerRef",
2061
- value: function setEditorsPortalManagerRef(pmComponent) {
2062
- this.editorsPortalManager = pmComponent;
2063
- }
2064
1994
  /*
2065
1995
  ---------------------------------------
2066
1996
  ------- React lifecycle methods -------
@@ -2073,25 +2003,17 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2073
2003
  key: "componentDidMount",
2074
2004
  value: function componentDidMount() {
2075
2005
  var _this4 = this;
2076
- this.clearCache();
2077
- this.renderGlobalEditorPortal(function () {
2078
- // In React strict mode the mount/unmount is triggered twice. The `if` prevents
2079
- // creating two Handsontable instances for the same component in that mode.
2080
- if (_this4.hotInstance) {
2081
- return;
2082
- }
2083
- var newGlobalSettings = _this4.createNewGlobalSettings();
2084
- _this4.hotInstance = new Handsontable.Core(_this4.hotElementRef, newGlobalSettings);
2085
- _this4.hotInstance.addHook('beforeViewRender', function () {
2086
- return _this4.handsontableBeforeViewRender();
2087
- });
2088
- _this4.hotInstance.addHook('afterViewRender', function () {
2089
- return _this4.handsontableAfterViewRender();
2090
- });
2091
- // `init` missing in Handsontable's type definitions.
2092
- _this4.hotInstance.init();
2093
- _this4.displayAutoSizeWarning(newGlobalSettings);
2006
+ var newGlobalSettings = this.createNewGlobalSettings();
2007
+ this.hotInstance = new Handsontable.Core(this.hotElementRef, newGlobalSettings);
2008
+ this.hotInstance.addHook('beforeViewRender', function () {
2009
+ return _this4.handsontableBeforeViewRender();
2010
+ });
2011
+ this.hotInstance.addHook('afterViewRender', function () {
2012
+ return _this4.handsontableAfterViewRender();
2094
2013
  });
2014
+ // `init` missing in Handsontable's type definitions.
2015
+ this.hotInstance.init();
2016
+ this.displayAutoSizeWarning(newGlobalSettings);
2095
2017
  }
2096
2018
  /**
2097
2019
  * Logic performed after the component update.
@@ -2099,13 +2021,10 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2099
2021
  }, {
2100
2022
  key: "componentDidUpdate",
2101
2023
  value: function componentDidUpdate() {
2102
- var _this5 = this;
2103
2024
  this.clearCache();
2104
- this.renderGlobalEditorPortal(function () {
2105
- var newGlobalSettings = _this5.createNewGlobalSettings();
2106
- _this5.updateHot(newGlobalSettings);
2107
- _this5.displayAutoSizeWarning(newGlobalSettings);
2108
- });
2025
+ var newGlobalSettings = this.createNewGlobalSettings();
2026
+ this.updateHot(newGlobalSettings);
2027
+ this.displayAutoSizeWarning(newGlobalSettings);
2109
2028
  }
2110
2029
  /**
2111
2030
  * Destroy the Handsontable instance when the parent component unmounts.
@@ -2113,6 +2032,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2113
2032
  }, {
2114
2033
  key: "componentWillUnmount",
2115
2034
  value: function componentWillUnmount() {
2035
+ this.clearCache();
2116
2036
  if (this.hotInstance) {
2117
2037
  this.hotInstance.destroy();
2118
2038
  }
@@ -2123,37 +2043,34 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2123
2043
  }, {
2124
2044
  key: "render",
2125
2045
  value: function render() {
2126
- var _this6 = this;
2046
+ var _this5 = this;
2127
2047
  var containerProps = getContainerAttributesProps(this.props);
2128
2048
  var isHotColumn = function isHotColumn(childNode) {
2129
2049
  return childNode.type === HotColumn;
2130
2050
  };
2131
2051
  var children = React.Children.toArray(this.props.children);
2132
- // filter out anything that's not a HotColumn
2133
- children = children.filter(function (childNode) {
2134
- return isHotColumn(childNode);
2135
- });
2136
2052
  // clone the HotColumn nodes and extend them with the callbacks
2137
- var childClones = children.map(function (childNode, columnIndex) {
2053
+ var hotColumnClones = children.filter(function (childNode) {
2054
+ return isHotColumn(childNode);
2055
+ }).map(function (childNode, columnIndex) {
2138
2056
  return React.cloneElement(childNode, {
2139
- _componentRendererColumns: _this6.componentRendererColumns,
2140
- _emitColumnSettings: _this6.setHotColumnSettings.bind(_this6),
2057
+ _componentRendererColumns: _this5.componentRendererColumns,
2058
+ _emitColumnSettings: _this5.setHotColumnSettings.bind(_this5),
2141
2059
  _columnIndex: columnIndex,
2142
- _getChildElementByType: getChildElementByType.bind(_this6),
2143
- _getRendererWrapper: _this6.getRendererWrapper.bind(_this6),
2144
- _getEditorClass: _this6.getEditorClass.bind(_this6),
2145
- _getOwnerDocument: _this6.getOwnerDocument.bind(_this6),
2146
- _getEditorCache: _this6.getEditorCache.bind(_this6),
2060
+ _getChildElementByType: getChildElementByType.bind(_this5),
2061
+ _getRendererWrapper: _this5.getRendererWrapper.bind(_this5),
2062
+ _getEditorClass: _this5.getEditorClass.bind(_this5),
2063
+ _getOwnerDocument: _this5.getOwnerDocument.bind(_this5),
2064
+ _getEditorCache: _this5.getEditorCache.bind(_this5),
2147
2065
  children: childNode.props.children
2148
2066
  });
2149
2067
  });
2068
+ var editorPortal = createEditorPortal(this.getOwnerDocument(), this.getGlobalEditorElement());
2150
2069
  return React.createElement(React.Fragment, null, React.createElement("div", Object.assign({
2151
2070
  ref: this.setHotElementRef.bind(this)
2152
- }, containerProps), childClones), React.createElement(RenderersPortalManager, {
2071
+ }, containerProps), hotColumnClones), React.createElement(RenderersPortalManager, {
2153
2072
  ref: this.setRenderersPortalManagerRef.bind(this)
2154
- }), React.createElement(EditorsPortalManager, {
2155
- ref: this.setEditorsPortalManagerRef.bind(this)
2156
- }));
2073
+ }), editorPortal);
2157
2074
  }
2158
2075
  }], [{
2159
2076
  key: "version",
package/hotColumn.d.ts CHANGED
@@ -4,18 +4,6 @@ import Handsontable from 'handsontable/base';
4
4
  declare class HotColumn extends React.Component<HotColumnProps, {}> {
5
5
  internalProps: string[];
6
6
  columnSettings: Handsontable.ColumnSettings;
7
- /**
8
- * Component used to manage the editor portals.
9
- *
10
- * @type {React.Component}
11
- */
12
- private editorsPortalManager;
13
- /**
14
- * Set the editors portal manager ref.
15
- *
16
- * @param {React.ReactComponent} pmComponent The PortalManager component.
17
- */
18
- private setEditorsPortalManagerRef;
19
7
  /**
20
8
  * Filter out all the internal properties and return an object with just the Handsontable-related props.
21
9
  *
@@ -32,12 +20,6 @@ declare class HotColumn extends React.Component<HotColumnProps, {}> {
32
20
  * Create the column settings based on the data provided to the `HotColumn` component and it's child components.
33
21
  */
34
22
  createColumnSettings(): void;
35
- /**
36
- * Creates the local editor portal and renders it within the editors portal manager component.
37
- *
38
- * @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
39
- */
40
- renderLocalEditorPortal(callback: () => void): void;
41
23
  /**
42
24
  * Emit the column settings to the parent using a prop passed from the parent.
43
25
  */
package/hotTable.d.ts CHANGED
@@ -68,12 +68,6 @@ declare class HotTable extends React.Component<HotTableProps, {}> {
68
68
  * @type {React.Component}
69
69
  */
70
70
  renderersPortalManager: RenderersPortalManager;
71
- /**
72
- * Component used to manage the editor portals.
73
- *
74
- * @type {React.Component}
75
- */
76
- private editorsPortalManager;
77
71
  /**
78
72
  * Array containing the portals cashed to be rendered in bulk after Handsontable's render cycle.
79
73
  */
@@ -183,12 +177,6 @@ declare class HotTable extends React.Component<HotTableProps, {}> {
183
177
  * @returns {React.ReactElement} React editor component element.
184
178
  */
185
179
  getGlobalEditorElement(): HotEditorElement | null;
186
- /**
187
- * Creates the global editor portal and renders it within the editors portal manager component.
188
- *
189
- * @param {Function} callback Callback to call which is triggered after the editors portal is rendered.
190
- */
191
- renderGlobalEditorPortal(callback: () => void): void;
192
180
  /**
193
181
  * Create a new settings object containing the column settings and global editors and renderers.
194
182
  *
@@ -228,12 +216,6 @@ declare class HotTable extends React.Component<HotTableProps, {}> {
228
216
  * @param {React.ReactComponent} pmComponent The PortalManager component.
229
217
  */
230
218
  private setRenderersPortalManagerRef;
231
- /**
232
- * Set the editors portal manager ref.
233
- *
234
- * @param {React.ReactComponent} pmComponent The PortalManager component.
235
- */
236
- private setEditorsPortalManagerRef;
237
219
  /**
238
220
  * Initialize Handsontable after the component has mounted.
239
221
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@handsontable/react",
3
- "version": "12.3.2",
3
+ "version": "12.3.3-next-018f495-20230327",
4
4
  "description": "Best Data Grid for React with Spreadsheet Look and Feel.",
5
5
  "author": "Handsoncode <hello@handsoncode.net> (https://handsoncode.net)",
6
6
  "homepage": "https://handsontable.com",
@@ -66,7 +66,7 @@
66
66
  "babel-core": "^7.0.0-bridge.0",
67
67
  "cpy-cli": "^3.1.1",
68
68
  "cross-env": "^7.0.3",
69
- "handsontable": "^12.0.0",
69
+ "handsontable": "12.3.3-next-018f495-20230327",
70
70
  "jest": "^25.1.0",
71
71
  "prop-types": "^15.7.2",
72
72
  "react-dom": "^16.10.2",
@@ -87,7 +87,7 @@
87
87
  "uglify-js": "^3.4.9"
88
88
  },
89
89
  "peerDependencies": {
90
- "handsontable": ">=12.0.0"
90
+ "handsontable": "12.3.3-next-018f495-20230327"
91
91
  },
92
92
  "scripts": {
93
93
  "build": "npm run clean && npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:min",
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- /**
3
- * Component class used to manage the editor component portals.
4
- */
5
- export declare class EditorsPortalManager extends React.Component<{}, {
6
- portals?: React.ReactElement[];
7
- }> {
8
- state: {
9
- portals: any[];
10
- };
11
- render(): JSX.Element;
12
- }