@handsontable/react 0.0.0-next-d26e81f-20231213 → 0.0.0-next-ae2e00f-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,34 +1,7 @@
1
- import React, { useState, useEffect } from 'react';
1
+ import React 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
- }
32
5
  function ownKeys(e, r) {
33
6
  var t = Object.keys(e);
34
7
  if (Object.getOwnPropertySymbols) {
@@ -50,20 +23,6 @@ function _objectSpread2(e) {
50
23
  }
51
24
  return e;
52
25
  }
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
- }
67
26
  function _typeof(o) {
68
27
  "@babel/helpers - typeof";
69
28
 
@@ -177,18 +136,12 @@ function _createSuper(Derived) {
177
136
  return _possibleConstructorReturn(this, result);
178
137
  };
179
138
  }
180
- function _slicedToArray(arr, i) {
181
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
182
- }
183
139
  function _toConsumableArray(arr) {
184
140
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
185
141
  }
186
142
  function _arrayWithoutHoles(arr) {
187
143
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
188
144
  }
189
- function _arrayWithHoles(arr) {
190
- if (Array.isArray(arr)) return arr;
191
- }
192
145
  function _iterableToArray(iter) {
193
146
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
194
147
  }
@@ -208,12 +161,22 @@ function _arrayLikeToArray(arr, len) {
208
161
  function _nonIterableSpread() {
209
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.");
210
163
  }
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.");
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);
213
177
  }
214
178
 
215
179
  var bulkComponentContainer = null;
216
- var hasIdWarningBeenPrinted = false;
217
180
  /**
218
181
  * Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
219
182
  */
@@ -278,12 +241,14 @@ function getOriginalEditorClass(editorElement) {
278
241
  /**
279
242
  * Create an editor portal.
280
243
  *
281
- * @param {Document} doc Document to be used.
244
+ * @param {Document} [doc] Document to be used.
282
245
  * @param {React.ReactElement} editorElement Editor's element.
283
246
  * @returns {React.ReactPortal} The portal for the editor.
284
247
  */
285
- function createEditorPortal(doc, editorElement) {
286
- if (typeof doc === 'undefined' || editorElement === null) {
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) {
287
252
  return null;
288
253
  }
289
254
  var containerProps = getContainerAttributesProps(editorElement.props, false);
@@ -355,47 +320,12 @@ function createPortal(rElement, props) {
355
320
  */
356
321
  function getContainerAttributesProps(props) {
357
322
  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
- }
362
323
  return {
363
324
  id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : void 0),
364
325
  className: props.className || '',
365
326
  style: props.style || {}
366
327
  };
367
328
  }
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
- };
399
329
 
400
330
  var SettingsMapper = /*#__PURE__*/function () {
401
331
  function SettingsMapper() {
@@ -431,6 +361,105 @@ var SettingsMapper = /*#__PURE__*/function () {
431
361
  return SettingsMapper;
432
362
  }();
433
363
 
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
+
434
463
  /**
435
464
  * Component class used to manage the renderer component portals.
436
465
  */
@@ -455,7 +484,7 @@ var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
455
484
  return RenderersPortalManager;
456
485
  }(React.Component);
457
486
 
458
- var version="0.0.0-next-d26e81f-20231213";
487
+ var version="0.0.0-next-ae2e00f-20231213";
459
488
 
460
489
  function createCommonjsModule(fn, module) {
461
490
  return module = { exports: {} }, fn(module, module.exports), module.exports;
@@ -1576,13 +1605,6 @@ var propTypes = createCommonjsModule(function (module) {
1576
1605
  });
1577
1606
  var PropTypes = propTypes;
1578
1607
 
1579
- var Test = function Test() {
1580
- useEffect(function () {
1581
- console.log("hello world");
1582
- }, []);
1583
- return React.createElement("div", null);
1584
- };
1585
-
1586
1608
  /**
1587
1609
  * A Handsontable-ReactJS wrapper.
1588
1610
  *
@@ -1735,10 +1757,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
1735
1757
  }, {
1736
1758
  key: "getOwnerDocument",
1737
1759
  value: function getOwnerDocument() {
1738
- if (isCSR()) {
1739
- return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
1740
- }
1741
- return null;
1760
+ return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
1742
1761
  }
1743
1762
  /**
1744
1763
  * Set the reference to the main Handsontable DOM element.
@@ -2025,6 +2044,7 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2025
2044
  key: "render",
2026
2045
  value: function render() {
2027
2046
  var _this5 = this;
2047
+ var containerProps = getContainerAttributesProps(this.props);
2028
2048
  var isHotColumn = function isHotColumn(childNode) {
2029
2049
  return childNode.type === HotColumn;
2030
2050
  };
@@ -2033,17 +2053,6 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2033
2053
  var hotColumnClones = children.filter(function (childNode) {
2034
2054
  return isHotColumn(childNode);
2035
2055
  }).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
- });
2047
2056
  return React.cloneElement(childNode, {
2048
2057
  _componentRendererColumns: _this5.componentRendererColumns,
2049
2058
  _emitColumnSettings: _this5.setHotColumnSettings.bind(_this5),
@@ -2056,13 +2065,12 @@ var HotTable = /*#__PURE__*/function (_React$Component) {
2056
2065
  children: childNode.props.children
2057
2066
  });
2058
2067
  });
2059
- var containerProps = getContainerAttributesProps(this.props);
2060
2068
  var editorPortal = createEditorPortal(this.getOwnerDocument(), this.getGlobalEditorElement());
2061
2069
  return React.createElement(React.Fragment, null, React.createElement("div", Object.assign({
2062
2070
  ref: this.setHotElementRef.bind(this)
2063
2071
  }, containerProps), hotColumnClones), React.createElement(RenderersPortalManager, {
2064
2072
  ref: this.setRenderersPortalManagerRef.bind(this)
2065
- }), editorPortal, React.createElement(Test, null));
2073
+ }), editorPortal);
2066
2074
  }
2067
2075
  }], [{
2068
2076
  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,9 +81,3 @@ 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,17 +1,42 @@
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;
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;
14
41
  }
15
- declare const HotColumn: (props: HotColumnProps) => React.JSX.Element;
16
- export default HotColumn;
17
42
  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 | null;
137
+ getOwnerDocument(): Document;
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-d26e81f-20231213",
3
+ "version": "0.0.0-next-ae2e00f-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": "^ 18.2.17",
65
- "@types/react-redux": "^ 7.1.33",
66
- "@types/react": "^18.2.45",
64
+ "@types/react-dom": "^16.9.1",
65
+ "@types/react-redux": "^7.1.7",
66
+ "@types/react": "^16.9.5",
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-d26e81f-20231213",
70
+ "handsontable": "0.0.0-next-ae2e00f-20231213",
71
71
  "jest": "^25.1.0",
72
72
  "prop-types": "^15.7.2",
73
- "react-dom": "^18.2.0",
74
- "react-redux": "^9.0.4",
75
- "react": "^18.2.0",
76
- "redux": "^5.0.0",
73
+ "react-dom": "^16.10.2",
74
+ "react-redux": "^7.1.1",
75
+ "react": "^16.10.2",
76
+ "redux": "^4.0.4",
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-d26e81f-20231213"
91
+ "handsontable": "0.0.0-next-ae2e00f-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,3 +33,17 @@ 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
+ }
package/Test.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import React from "react";
2
- export declare const Test: () => React.JSX.Element;