@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.
@@ -1,7 +1,34 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import ReactDOM from 'react-dom';
3
3
  import Handsontable from 'handsontable/base';
4
4
 
5
+ function _iterableToArrayLimit(r, l) {
6
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
7
+ if (null != t) {
8
+ var e,
9
+ n,
10
+ i,
11
+ u,
12
+ a = [],
13
+ f = !0,
14
+ o = !1;
15
+ try {
16
+ if (i = (t = t.call(r)).next, 0 === l) {
17
+ if (Object(t) !== t) return;
18
+ f = !1;
19
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
20
+ } catch (r) {
21
+ o = !0, n = r;
22
+ } finally {
23
+ try {
24
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
25
+ } finally {
26
+ if (o) throw n;
27
+ }
28
+ }
29
+ return a;
30
+ }
31
+ }
5
32
  function ownKeys(e, r) {
6
33
  var t = Object.keys(e);
7
34
  if (Object.getOwnPropertySymbols) {
@@ -23,6 +50,20 @@ function _objectSpread2(e) {
23
50
  }
24
51
  return e;
25
52
  }
53
+ function _toPrimitive(t, r) {
54
+ if ("object" != typeof t || !t) return t;
55
+ var e = t[Symbol.toPrimitive];
56
+ if (void 0 !== e) {
57
+ var i = e.call(t, r || "default");
58
+ if ("object" != typeof i) return i;
59
+ throw new TypeError("@@toPrimitive must return a primitive value.");
60
+ }
61
+ return ("string" === r ? String : Number)(t);
62
+ }
63
+ function _toPropertyKey(t) {
64
+ var i = _toPrimitive(t, "string");
65
+ return "symbol" == typeof i ? i : String(i);
66
+ }
26
67
  function _typeof(o) {
27
68
  "@babel/helpers - typeof";
28
69
 
@@ -136,12 +177,18 @@ function _createSuper(Derived) {
136
177
  return _possibleConstructorReturn(this, result);
137
178
  };
138
179
  }
180
+ function _slicedToArray(arr, i) {
181
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
182
+ }
139
183
  function _toConsumableArray(arr) {
140
184
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
141
185
  }
142
186
  function _arrayWithoutHoles(arr) {
143
187
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
144
188
  }
189
+ function _arrayWithHoles(arr) {
190
+ if (Array.isArray(arr)) return arr;
191
+ }
145
192
  function _iterableToArray(iter) {
146
193
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
147
194
  }
@@ -161,22 +208,12 @@ function _arrayLikeToArray(arr, len) {
161
208
  function _nonIterableSpread() {
162
209
  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
210
  }
164
- function _toPrimitive(input, hint) {
165
- if (typeof input !== "object" || input === null) return input;
166
- var prim = input[Symbol.toPrimitive];
167
- if (prim !== undefined) {
168
- var res = prim.call(input, hint || "default");
169
- if (typeof res !== "object") return res;
170
- throw new TypeError("@@toPrimitive must return a primitive value.");
171
- }
172
- return (hint === "string" ? String : Number)(input);
173
- }
174
- function _toPropertyKey(arg) {
175
- var key = _toPrimitive(arg, "string");
176
- return typeof key === "symbol" ? key : String(key);
211
+ function _nonIterableRest() {
212
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
177
213
  }
178
214
 
179
215
  var bulkComponentContainer = null;
216
+ var hasIdWarningBeenPrinted = false;
180
217
  /**
181
218
  * Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
182
219
  */
@@ -241,14 +278,12 @@ function getOriginalEditorClass(editorElement) {
241
278
  /**
242
279
  * Create an editor portal.
243
280
  *
244
- * @param {Document} [doc] Document to be used.
281
+ * @param {Document} doc Document to be used.
245
282
  * @param {React.ReactElement} editorElement Editor's element.
246
283
  * @returns {React.ReactPortal} The portal for the editor.
247
284
  */
248
- function createEditorPortal() {
249
- var doc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document;
250
- var editorElement = arguments.length > 1 ? arguments[1] : undefined;
251
- if (editorElement === null) {
285
+ function createEditorPortal(doc, editorElement) {
286
+ if (typeof doc === 'undefined' || editorElement === null) {
252
287
  return null;
253
288
  }
254
289
  var containerProps = getContainerAttributesProps(editorElement.props, false);
@@ -320,12 +355,47 @@ function createPortal(rElement, props) {
320
355
  */
321
356
  function getContainerAttributesProps(props) {
322
357
  var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
358
+ if (!hasIdWarningBeenPrinted && !props.id && randomizeId) {
359
+ hasIdWarningBeenPrinted = true;
360
+ warn('You have to provide an `id` property for the `HotTable` component.');
361
+ }
323
362
  return {
324
363
  id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : void 0),
325
364
  className: props.className || '',
326
365
  style: props.style || {}
327
366
  };
328
367
  }
368
+ /**
369
+ * Checks if the environment that the code runs in is a browser.
370
+ *
371
+ * @returns {boolean}
372
+ */
373
+ function isCSR() {
374
+ return typeof window !== 'undefined';
375
+ }
376
+
377
+ var HotColumn = function HotColumn(props) {
378
+ var _useState = useState(getExtendedEditorElement(props.children, props.getEditorCache(), props.columnIndex)),
379
+ _useState2 = _slicedToArray(_useState, 2),
380
+ editorElement = _useState2[0],
381
+ setEditorElement = _useState2[1];
382
+ useEffect(function () {
383
+ var rendererElement = props.getChildElementByType(props.children, "hot-renderer");
384
+ setEditorElement(getExtendedEditorElement(props.children, props.getEditorCache(), props.columnIndex));
385
+ var columnSettings = {};
386
+ if (rendererElement !== null) {
387
+ columnSettings.renderer = props.getRendererWrapper(rendererElement);
388
+ props.componentRendererColumns.set(props.columnIndex, true);
389
+ }
390
+ if (editorElement !== null) {
391
+ columnSettings.editor = props.getEditorClass(editorElement, props.columnIndex);
392
+ }
393
+ props.onColumnSettingsChange(columnSettings, props.columnIndex);
394
+ }, [props.getChildElementByType, props.children, props.columnIndex, props.getRendererWrapper, props.componentRendererColumns, props.getEditorCache]);
395
+ var ownerDocument = props.getOwnerDocument();
396
+ var editorPortal = createEditorPortal(ownerDocument, editorElement);
397
+ return React.createElement(React.Fragment, null, editorPortal);
398
+ };
329
399
 
330
400
  var SettingsMapper = /*#__PURE__*/function () {
331
401
  function SettingsMapper() {
@@ -361,105 +431,6 @@ var SettingsMapper = /*#__PURE__*/function () {
361
431
  return SettingsMapper;
362
432
  }();
363
433
 
364
- var HotColumn = /*#__PURE__*/function (_React$Component) {
365
- _inherits(HotColumn, _React$Component);
366
- var _super = _createSuper(HotColumn);
367
- function HotColumn() {
368
- _classCallCheck(this, HotColumn);
369
- return _super.apply(this, arguments);
370
- }
371
- _createClass(HotColumn, [{
372
- key: "getSettingsProps",
373
- value:
374
- /**
375
- * Filter out all the internal properties and return an object with just the Handsontable-related props.
376
- *
377
- * @returns {Object}
378
- */
379
- function getSettingsProps() {
380
- var _this = this;
381
- this.internalProps = ['_componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
382
- return Object.keys(this.props).filter(function (key) {
383
- return !_this.internalProps.includes(key);
384
- }).reduce(function (obj, key) {
385
- obj[key] = _this.props[key];
386
- return obj;
387
- }, {});
388
- }
389
- /**
390
- * Get the editor element for the current column.
391
- *
392
- * @returns {React.ReactElement} React editor component element.
393
- */
394
- }, {
395
- key: "getLocalEditorElement",
396
- value: function getLocalEditorElement() {
397
- return getExtendedEditorElement(this.props.children, this.props._getEditorCache(), this.props._columnIndex);
398
- }
399
- /**
400
- * Create the column settings based on the data provided to the `HotColumn` component and it's child components.
401
- */
402
- }, {
403
- key: "createColumnSettings",
404
- value: function createColumnSettings() {
405
- var rendererElement = this.props._getChildElementByType(this.props.children, 'hot-renderer');
406
- var editorElement = this.getLocalEditorElement();
407
- this.columnSettings = SettingsMapper.getSettings(this.getSettingsProps());
408
- if (rendererElement !== null) {
409
- this.columnSettings.renderer = this.props._getRendererWrapper(rendererElement);
410
- this.props._componentRendererColumns.set(this.props._columnIndex, true);
411
- }
412
- if (editorElement !== null) {
413
- this.columnSettings.editor = this.props._getEditorClass(editorElement, this.props._columnIndex);
414
- }
415
- }
416
- /**
417
- * Emit the column settings to the parent using a prop passed from the parent.
418
- */
419
- }, {
420
- key: "emitColumnSettings",
421
- value: function emitColumnSettings() {
422
- this.props._emitColumnSettings(this.columnSettings, this.props._columnIndex);
423
- }
424
- /*
425
- ---------------------------------------
426
- ------- React lifecycle methods -------
427
- ---------------------------------------
428
- */
429
- /**
430
- * Logic performed after the mounting of the HotColumn component.
431
- */
432
- }, {
433
- key: "componentDidMount",
434
- value: function componentDidMount() {
435
- this.createColumnSettings();
436
- this.emitColumnSettings();
437
- }
438
- /**
439
- * Logic performed after the updating of the HotColumn component.
440
- */
441
- }, {
442
- key: "componentDidUpdate",
443
- value: function componentDidUpdate() {
444
- this.createColumnSettings();
445
- this.emitColumnSettings();
446
- }
447
- /**
448
- * Render the portals of the editors, if there are any.
449
- *
450
- * @returns {React.ReactElement}
451
- */
452
- }, {
453
- key: "render",
454
- value: function render() {
455
- var ownerDocument = this.props._getOwnerDocument();
456
- var editorPortal = createEditorPortal(ownerDocument, this.getLocalEditorElement());
457
- return React.createElement(React.Fragment, null, editorPortal);
458
- }
459
- }]);
460
- return HotColumn;
461
- }(React.Component);
462
-
463
434
  /**
464
435
  * Component class used to manage the renderer component portals.
465
436
  */
@@ -484,7 +455,7 @@ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
484
455
  return RenderersPortalManager;
485
456
  }(React.Component);
486
457
 
487
- var version="0.0.0-next-e2b07e5-20231213";
458
+ var version="0.0.0-next-d26e81f-20231213";
488
459
 
489
460
  function createCommonjsModule(fn, module) {
490
461
  return module = { exports: {} }, fn(module, module.exports), module.exports;
@@ -1605,6 +1576,13 @@ var propTypes = createCommonjsModule(function (module) {
1605
1576
  });
1606
1577
  var PropTypes = propTypes;
1607
1578
 
1579
+ var Test = function Test() {
1580
+ useEffect(function () {
1581
+ console.log("hello world");
1582
+ }, []);
1583
+ return React.createElement("div", null);
1584
+ };
1585
+
1608
1586
  /**
1609
1587
  * A Handsontable-ReactJS wrapper.
1610
1588
  *
@@ -1757,7 +1735,10 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1757
1735
  }, {
1758
1736
  key: "getOwnerDocument",
1759
1737
  value: function getOwnerDocument() {
1760
- return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
1738
+ if (isCSR()) {
1739
+ return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
1740
+ }
1741
+ return null;
1761
1742
  }
1762
1743
  /**
1763
1744
  * Set the reference to the main Handsontable DOM element.
@@ -2044,7 +2025,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2044
2025
  key: "render",
2045
2026
  value: function render() {
2046
2027
  var _this5 = this;
2047
- var containerProps = getContainerAttributesProps(this.props);
2048
2028
  var isHotColumn = function isHotColumn(childNode) {
2049
2029
  return childNode.type === HotColumn;
2050
2030
  };
@@ -2053,6 +2033,17 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2053
2033
  var hotColumnClones = children.filter(function (childNode) {
2054
2034
  return isHotColumn(childNode);
2055
2035
  }).map(function (childNode, columnIndex) {
2036
+ ({
2037
+ columnIndex: columnIndex,
2038
+ children: childNode.props.children,
2039
+ onColumnSettingsChange: _this5.setHotColumnSettings.bind(_this5),
2040
+ componentRendererColumns: _this5.componentRendererColumns,
2041
+ getChildElementByType: getChildElementByType.bind(_this5),
2042
+ getRendererWrapper: _this5.getEditorClass.bind(_this5),
2043
+ getEditorClass: _this5.getEditorClass.bind(_this5),
2044
+ getEditorCache: _this5.getEditorCache.bind(_this5),
2045
+ getOwnerDocument: _this5.getOwnerDocument.bind(_this5)
2046
+ });
2056
2047
  return React.cloneElement(childNode, {
2057
2048
  _componentRendererColumns: _this5.componentRendererColumns,
2058
2049
  _emitColumnSettings: _this5.setHotColumnSettings.bind(_this5),
@@ -2065,12 +2056,13 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2065
2056
  children: childNode.props.children
2066
2057
  });
2067
2058
  });
2059
+ var containerProps = getContainerAttributesProps(this.props);
2068
2060
  var editorPortal = createEditorPortal(this.getOwnerDocument(), this.getGlobalEditorElement());
2069
2061
  return React.createElement(React.Fragment, null, React.createElement("div", Object.assign({
2070
2062
  ref: this.setHotElementRef.bind(this)
2071
2063
  }, containerProps), hotColumnClones), React.createElement(RenderersPortalManager, {
2072
2064
  ref: this.setRenderersPortalManagerRef.bind(this)
2073
- }), editorPortal);
2065
+ }), editorPortal, React.createElement(Test, null));
2074
2066
  }
2075
2067
  }], [{
2076
2068
  key: "version",
package/helpers.d.ts CHANGED
@@ -40,7 +40,7 @@ export declare function getOriginalEditorClass(editorElement: HotEditorElement):
40
40
  /**
41
41
  * Create an editor portal.
42
42
  *
43
- * @param {Document} [doc] Document to be used.
43
+ * @param {Document} doc Document to be used.
44
44
  * @param {React.ReactElement} editorElement Editor's element.
45
45
  * @returns {React.ReactPortal} The portal for the editor.
46
46
  */
@@ -81,3 +81,9 @@ export declare function getContainerAttributesProps(props: any, randomizeId?: bo
81
81
  className: string;
82
82
  style: object;
83
83
  };
84
+ /**
85
+ * Checks if the environment that the code runs in is a browser.
86
+ *
87
+ * @returns {boolean}
88
+ */
89
+ export declare function isCSR(): boolean;
package/hotColumn.d.ts CHANGED
@@ -1,42 +1,17 @@
1
- import React from 'react';
2
- import { HotTableProps, HotColumnProps } from './types';
3
- import Handsontable from 'handsontable/base';
4
- declare class HotColumn extends React.Component<HotColumnProps, {}> {
5
- internalProps: string[];
6
- columnSettings: Handsontable.ColumnSettings;
7
- /**
8
- * Filter out all the internal properties and return an object with just the Handsontable-related props.
9
- *
10
- * @returns {Object}
11
- */
12
- getSettingsProps(): HotTableProps;
13
- /**
14
- * Get the editor element for the current column.
15
- *
16
- * @returns {React.ReactElement} React editor component element.
17
- */
18
- getLocalEditorElement(): React.ReactElement | null;
19
- /**
20
- * Create the column settings based on the data provided to the `HotColumn` component and it's child components.
21
- */
22
- createColumnSettings(): void;
23
- /**
24
- * Emit the column settings to the parent using a prop passed from the parent.
25
- */
26
- emitColumnSettings(): void;
27
- /**
28
- * Logic performed after the mounting of the HotColumn component.
29
- */
30
- componentDidMount(): void;
31
- /**
32
- * Logic performed after the updating of the HotColumn component.
33
- */
34
- componentDidUpdate(): void;
35
- /**
36
- * Render the portals of the editors, if there are any.
37
- *
38
- * @returns {React.ReactElement}
39
- */
40
- render(): React.ReactElement;
1
+ import React from "react";
2
+ import { HotEditorCache, EditorScopeIdentifier } from "./types";
3
+ import Handsontable from "handsontable/base";
4
+ export interface HotColumnProps {
5
+ columnIndex: number;
6
+ children: React.ReactNode;
7
+ onColumnSettingsChange: (columnSettings: Handsontable.ColumnSettings, columnIndex: number) => void;
8
+ componentRendererColumns?: Map<number | string, boolean>;
9
+ getChildElementByType?: (children: React.ReactNode, type: string) => React.ReactElement;
10
+ getRendererWrapper?: (rendererNode: React.ReactElement) => typeof Handsontable.renderers.BaseRenderer;
11
+ getEditorClass?: (editorElement: React.ReactElement, editorColumnScope: EditorScopeIdentifier) => typeof Handsontable.editors.BaseEditor;
12
+ getEditorCache?: () => HotEditorCache;
13
+ getOwnerDocument?: () => Document;
41
14
  }
15
+ declare const HotColumn: (props: HotColumnProps) => React.JSX.Element;
16
+ export default HotColumn;
42
17
  export { HotColumn };
package/hotTable.d.ts CHANGED
@@ -134,7 +134,7 @@ declare class HotTable extends React.Component<HotTableProps, {}> {
134
134
  *
135
135
  * @returns The `Document` object used by the component.
136
136
  */
137
- getOwnerDocument(): Document;
137
+ getOwnerDocument(): Document | null;
138
138
  /**
139
139
  * Set the reference to the main Handsontable DOM element.
140
140
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@handsontable/react",
3
- "version": "0.0.0-next-e2b07e5-20231213",
3
+ "version": "0.0.0-next-d26e81f-20231213",
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",
@@ -61,19 +61,19 @@
61
61
  "@babel/preset-react": "^7.9.4",
62
62
  "@babel/preset-typescript": "^7.9.0",
63
63
  "@babel/runtime": "^7.9.2",
64
- "@types/react-dom": "^16.9.1",
65
- "@types/react-redux": "^7.1.7",
66
- "@types/react": "^16.9.5",
64
+ "@types/react-dom": "^ 18.2.17",
65
+ "@types/react-redux": "^ 7.1.33",
66
+ "@types/react": "^18.2.45",
67
67
  "babel-core": "^7.0.0-bridge.0",
68
68
  "cpy-cli": "^3.1.1",
69
69
  "cross-env": "^7.0.3",
70
- "handsontable": "0.0.0-next-e2b07e5-20231213",
70
+ "handsontable": "0.0.0-next-d26e81f-20231213",
71
71
  "jest": "^25.1.0",
72
72
  "prop-types": "^15.7.2",
73
- "react-dom": "^16.10.2",
74
- "react-redux": "^7.1.1",
75
- "react": "^16.10.2",
76
- "redux": "^4.0.4",
73
+ "react-dom": "^18.2.0",
74
+ "react-redux": "^9.0.4",
75
+ "react": "^18.2.0",
76
+ "redux": "^5.0.0",
77
77
  "rimraf": "^3.0.2",
78
78
  "rollup-plugin-alias": "^1.5.2",
79
79
  "rollup-plugin-babel": "^4.3.3",
@@ -88,7 +88,7 @@
88
88
  "uglify-js": "^3.4.9"
89
89
  },
90
90
  "peerDependencies": {
91
- "handsontable": "0.0.0-next-e2b07e5-20231213"
91
+ "handsontable": "0.0.0-next-d26e81f-20231213"
92
92
  },
93
93
  "scripts": {
94
94
  "build": "npm run clean && npm run build:commonjs && npm run build:es && npm run build:umd && npm run build:min",
package/types.d.ts CHANGED
@@ -33,17 +33,3 @@ export interface HotEditorProps {
33
33
  className?: string;
34
34
  style?: React.CSSProperties;
35
35
  }
36
- /**
37
- * Properties related to the HotColumn architecture.
38
- */
39
- export interface HotColumnProps extends Handsontable.ColumnSettings {
40
- _componentRendererColumns?: Map<number | string, boolean>;
41
- _emitColumnSettings?: (columnSettings: Handsontable.ColumnSettings, columnIndex: number) => void;
42
- _columnIndex?: number;
43
- _getChildElementByType?: (children: React.ReactNode, type: string) => React.ReactElement;
44
- _getRendererWrapper?: (rendererNode: React.ReactElement) => typeof Handsontable.renderers.BaseRenderer;
45
- _getEditorClass?: (editorElement: React.ReactElement, editorColumnScope: EditorScopeIdentifier) => typeof Handsontable.editors.BaseEditor;
46
- _getEditorCache?: () => HotEditorCache;
47
- _getOwnerDocument?: () => Document;
48
- children?: React.ReactNode;
49
- }