@handsontable/react 0.0.0-next-9f2f898-20240306 → 0.0.0-next-d093c11-20240307

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.
Files changed (36) hide show
  1. package/commonjs/react-handsontable.js +698 -1088
  2. package/commonjs/src/helpers.d.ts +112 -0
  3. package/commonjs/src/hotColumn.d.ts +5 -0
  4. package/commonjs/src/hotColumnContext.d.ts +16 -0
  5. package/commonjs/src/hotEditor.d.ts +34 -0
  6. package/commonjs/src/hotTable.d.ts +29 -0
  7. package/commonjs/src/hotTableContext.d.ts +55 -0
  8. package/commonjs/src/hotTableInner.d.ts +5 -0
  9. package/{index.d.ts → commonjs/src/index.d.ts} +1 -2
  10. package/commonjs/src/renderersPortalManager.d.ts +6 -0
  11. package/{settingsMapper.d.ts → commonjs/src/settingsMapper.d.ts} +1 -1
  12. package/commonjs/src/types.d.ts +64 -0
  13. package/dist/react-handsontable.js +696 -1086
  14. package/dist/react-handsontable.js.map +1 -1
  15. package/dist/react-handsontable.min.js +2 -2
  16. package/dist/react-handsontable.min.js.map +1 -1
  17. package/dist/src/helpers.d.ts +112 -0
  18. package/dist/src/hotColumn.d.ts +5 -0
  19. package/dist/src/hotColumnContext.d.ts +16 -0
  20. package/dist/src/hotEditor.d.ts +34 -0
  21. package/dist/src/hotTable.d.ts +29 -0
  22. package/dist/src/hotTableContext.d.ts +55 -0
  23. package/dist/src/hotTableInner.d.ts +5 -0
  24. package/dist/src/index.d.ts +5 -0
  25. package/dist/src/renderersPortalManager.d.ts +6 -0
  26. package/dist/src/settingsMapper.d.ts +11 -0
  27. package/dist/src/types.d.ts +64 -0
  28. package/es/react-handsontable.mjs +695 -1085
  29. package/package.json +3 -4
  30. package/baseEditorComponent.d.ts +0 -50
  31. package/helpers.d.ts +0 -91
  32. package/hotColumn.d.ts +0 -42
  33. package/hotTable.d.ts +0 -10
  34. package/hotTableClass.d.ts +0 -251
  35. package/renderersPortalManager.d.ts +0 -12
  36. package/types.d.ts +0 -50
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var React = require('react');
6
6
  var ReactDOM = require('react-dom');
7
7
  var Handsontable = require('handsontable/base');
8
- var registry$1 = require('handsontable/renderers/registry');
9
- var registry = require('handsontable/editors/registry');
8
+ var registry = require('handsontable/renderers/registry');
9
+ var registry$1 = require('handsontable/editors/registry');
10
10
 
11
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
12
 
@@ -14,6 +14,208 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
14
14
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
15
15
  var Handsontable__default = /*#__PURE__*/_interopDefaultLegacy(Handsontable);
16
16
 
17
+ var bulkComponentContainer = null;
18
+ /**
19
+ * Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
20
+ */
21
+ var AUTOSIZE_WARNING = 'Your `HotTable` configuration includes `autoRowSize`/`autoColumnSize` options, which are not compatible with ' + ' the component-based renderers`. Disable `autoRowSize` and `autoColumnSize` to prevent row and column misalignment.';
22
+ /**
23
+ * Warning message for the `hot-renderer` obsolete renderer passing method.
24
+ */
25
+ var OBSOLETE_HOTRENDERER_WARNING = 'Providing a component-based renderer using `hot-renderer`-annotated component is no longer supported. ' + 'Pass your component using `renderer` prop of the `HotTable` or `HotColumn` component instead.';
26
+ /**
27
+ * Warning message for the `hot-editor` obsolete editor passing method.
28
+ */
29
+ var OBSOLETE_HOTEDITOR_WARNING = 'Providing a component-based editor using `hot-editor`-annotated component is no longer supported. ' + 'Pass your component using `editor` prop of the `HotTable` or `HotColumn` component instead.';
30
+ /**
31
+ * Warning message for the unexpected children of HotTable component.
32
+ */
33
+ var UNEXPECTED_HOTTABLE_CHILDREN_WARNING = 'Unexpected children nodes found in HotTable component. ' + 'Only HotColumn components are allowed.';
34
+ /**
35
+ * Warning message for the unexpected children of HotColumn component.
36
+ */
37
+ var UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING = 'Unexpected children nodes found in HotColumn component. ' + 'HotColumn components do not support any children.';
38
+ /**
39
+ * Message for the warning thrown if the Handsontable instance has been destroyed.
40
+ */
41
+ var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.';
42
+ /**
43
+ * Default classname given to the wrapper container.
44
+ */
45
+ var DEFAULT_CLASSNAME = 'hot-wrapper-editor-container';
46
+ /**
47
+ * Logs warn to the console if the `console` object is exposed.
48
+ *
49
+ * @param {...*} args Values which will be logged.
50
+ */
51
+ function warn() {
52
+ if (typeof console !== 'undefined') {
53
+ var _console;
54
+ (_console = console).warn.apply(_console, arguments);
55
+ }
56
+ }
57
+ /**
58
+ * Detect if `hot-renderer` or `hot-editor` is defined, and if so, throw an incompatibility warning.
59
+ *
60
+ * @returns {boolean} 'true' if the warning was issued
61
+ */
62
+ function displayObsoleteRenderersEditorsWarning(children) {
63
+ if (hasChildElementOfType(children, 'hot-renderer')) {
64
+ warn(OBSOLETE_HOTRENDERER_WARNING);
65
+ return true;
66
+ }
67
+ if (hasChildElementOfType(children, 'hot-editor')) {
68
+ warn(OBSOLETE_HOTEDITOR_WARNING);
69
+ return true;
70
+ }
71
+ return false;
72
+ }
73
+ /**
74
+ * Detect if children of specified type are defined, and if so, throw an incompatibility warning.
75
+ *
76
+ * @param {React.ReactNode} children Component children nodes
77
+ * @param {React.ComponentType} Component Component type to check
78
+ * @returns {boolean} 'true' if the warning was issued
79
+ */
80
+ function displayChildrenOfTypeWarning(children, Component) {
81
+ var childrenArray = React__default["default"].Children.toArray(children);
82
+ if (childrenArray.some(function (child) {
83
+ return child.type !== Component;
84
+ })) {
85
+ warn(UNEXPECTED_HOTTABLE_CHILDREN_WARNING);
86
+ return true;
87
+ }
88
+ return false;
89
+ }
90
+ /**
91
+ * Detect if children is defined, and if so, throw an incompatibility warning.
92
+ *
93
+ * @param {React.ReactNode} children Component children nodes
94
+ * @returns {boolean} 'true' if the warning was issued
95
+ */
96
+ function displayAnyChildrenWarning(children) {
97
+ var childrenArray = React__default["default"].Children.toArray(children);
98
+ if (childrenArray.length) {
99
+ warn(UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING);
100
+ return true;
101
+ }
102
+ return false;
103
+ }
104
+ /**
105
+ * Check the existence of elements of the provided `type` from the `HotColumn` component's children.
106
+ *
107
+ * @param {React.ReactNode} children HotTable children array.
108
+ * @param {String} type Either `'hot-renderer'` or `'hot-editor'`.
109
+ * @returns {boolean} `true` if the child of that type was found, `false` otherwise.
110
+ */
111
+ function hasChildElementOfType(children, type) {
112
+ var childrenArray = React__default["default"].Children.toArray(children);
113
+ return childrenArray.some(function (child) {
114
+ return child.props[type] !== void 0;
115
+ });
116
+ }
117
+ /**
118
+ * Create an editor portal.
119
+ *
120
+ * @param {Document} doc Document to be used.
121
+ * @param {React.ComponentType} Editor Editor component or render function.
122
+ * @returns {React.ReactPortal} The portal for the editor.
123
+ */
124
+ function createEditorPortal(doc, Editor) {
125
+ if (!doc || !Editor) {
126
+ return null;
127
+ }
128
+ var editorElement = React__default["default"].createElement(Editor, null);
129
+ var containerProps = getContainerAttributesProps({}, false);
130
+ containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
131
+ return ReactDOM__default["default"].createPortal(React__default["default"].createElement("div", Object.assign({}, containerProps), editorElement), doc.body);
132
+ }
133
+ /**
134
+ * Render a cell component to an external DOM node.
135
+ *
136
+ * @param {React.ReactElement} rElement React element to be used as a base for the component.
137
+ * @param {Document} [ownerDocument] The owner document to set the portal up into.
138
+ * @param {String} portalKey The key to be used for the portal.
139
+ * @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
140
+ * @returns {{portal: React.ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
141
+ */
142
+ function createPortal(rElement) {
143
+ var ownerDocument = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
144
+ var portalKey = arguments.length > 2 ? arguments[2] : undefined;
145
+ var cachedContainer = arguments.length > 3 ? arguments[3] : undefined;
146
+ if (!ownerDocument) {
147
+ ownerDocument = document;
148
+ }
149
+ if (!bulkComponentContainer) {
150
+ bulkComponentContainer = ownerDocument.createDocumentFragment();
151
+ }
152
+ var portalContainer = cachedContainer !== null && cachedContainer !== void 0 ? cachedContainer : ownerDocument.createElement('DIV');
153
+ bulkComponentContainer.appendChild(portalContainer);
154
+ return {
155
+ portal: ReactDOM__default["default"].createPortal(rElement, portalContainer, portalKey),
156
+ portalContainer: portalContainer
157
+ };
158
+ }
159
+ /**
160
+ * Get an object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
161
+ * component.
162
+ *
163
+ * @param {HotTableProps} props Object containing the React element props.
164
+ * @param {Boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was present in the `prop` object.
165
+ * @returns An object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
166
+ * component.
167
+ */
168
+ function getContainerAttributesProps(props) {
169
+ var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
170
+ return {
171
+ id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : undefined),
172
+ className: props.className || '',
173
+ style: props.style || {}
174
+ };
175
+ }
176
+ /**
177
+ * Checks if the environment that the code runs in is a browser.
178
+ *
179
+ * @returns {boolean}
180
+ */
181
+ function isCSR() {
182
+ return typeof window !== 'undefined';
183
+ }
184
+ /**
185
+ * Creates a copy of the class instance that is still bound to this but allows calling its super (prototype) methods.
186
+ *
187
+ * @param {T} that An instance to look for prototype methods.
188
+ * @returns {T} Copy of the instance with super methods access.
189
+ */
190
+ function superBound(that) {
191
+ var proto = Object.getPrototypeOf(Object.getPrototypeOf(that));
192
+ var superBoundObj = {};
193
+ Object.getOwnPropertyNames(proto).forEach(function (key) {
194
+ if (typeof proto[key] === 'function') {
195
+ superBoundObj[key] = proto[key].bind(that);
196
+ } else {
197
+ superBoundObj[key] = proto[key];
198
+ }
199
+ });
200
+ return superBoundObj;
201
+ }
202
+ /**
203
+ * A variant of React.useEffect hook that does not trigger on initial mount, only updates
204
+ *
205
+ * @param effect Effect function
206
+ * @param deps Effect dependencies
207
+ */
208
+ function useUpdateEffect(effect, deps) {
209
+ var notInitialRender = React__default["default"].useRef(false);
210
+ React__default["default"].useEffect(function () {
211
+ if (notInitialRender.current) {
212
+ return effect();
213
+ } else {
214
+ notInitialRender.current = true;
215
+ }
216
+ }, deps);
217
+ }
218
+
17
219
  function _callSuper(t, o, e) {
18
220
  return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
19
221
  }
@@ -25,26 +227,32 @@ function _isNativeReflectConstruct() {
25
227
  return !!t;
26
228
  })();
27
229
  }
28
- function ownKeys(e, r) {
29
- var t = Object.keys(e);
30
- if (Object.getOwnPropertySymbols) {
31
- var o = Object.getOwnPropertySymbols(e);
32
- r && (o = o.filter(function (r) {
33
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
34
- })), t.push.apply(t, o);
35
- }
36
- return t;
37
- }
38
- function _objectSpread2(e) {
39
- for (var r = 1; r < arguments.length; r++) {
40
- var t = null != arguments[r] ? arguments[r] : {};
41
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
42
- _defineProperty(e, r, t[r]);
43
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
44
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
45
- });
230
+ function _iterableToArrayLimit(r, l) {
231
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
232
+ if (null != t) {
233
+ var e,
234
+ n,
235
+ i,
236
+ u,
237
+ a = [],
238
+ f = !0,
239
+ o = !1;
240
+ try {
241
+ if (i = (t = t.call(r)).next, 0 === l) {
242
+ if (Object(t) !== t) return;
243
+ f = !1;
244
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
245
+ } catch (r) {
246
+ o = !0, n = r;
247
+ } finally {
248
+ try {
249
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
250
+ } finally {
251
+ if (o) throw n;
252
+ }
253
+ }
254
+ return a;
46
255
  }
47
- return e;
48
256
  }
49
257
  function _toPrimitive(t, r) {
50
258
  if ("object" != typeof t || !t) return t;
@@ -91,20 +299,6 @@ function _createClass(Constructor, protoProps, staticProps) {
91
299
  });
92
300
  return Constructor;
93
301
  }
94
- function _defineProperty(obj, key, value) {
95
- key = _toPropertyKey(key);
96
- if (key in obj) {
97
- Object.defineProperty(obj, key, {
98
- value: value,
99
- enumerable: true,
100
- configurable: true,
101
- writable: true
102
- });
103
- } else {
104
- obj[key] = value;
105
- }
106
- return obj;
107
- }
108
302
  function _inherits(subClass, superClass) {
109
303
  if (typeof superClass !== "function" && superClass !== null) {
110
304
  throw new TypeError("Super expression must either be null or a function");
@@ -175,12 +369,18 @@ function _possibleConstructorReturn(self, call) {
175
369
  }
176
370
  return _assertThisInitialized(self);
177
371
  }
372
+ function _slicedToArray(arr, i) {
373
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
374
+ }
178
375
  function _toConsumableArray(arr) {
179
376
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
180
377
  }
181
378
  function _arrayWithoutHoles(arr) {
182
379
  if (Array.isArray(arr)) return _arrayLikeToArray(arr);
183
380
  }
381
+ function _arrayWithHoles(arr) {
382
+ if (Array.isArray(arr)) return arr;
383
+ }
184
384
  function _iterableToArray(iter) {
185
385
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
186
386
  }
@@ -200,166 +400,8 @@ function _arrayLikeToArray(arr, len) {
200
400
  function _nonIterableSpread() {
201
401
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
202
402
  }
203
-
204
- var bulkComponentContainer = null;
205
- /**
206
- * Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
207
- */
208
- var AUTOSIZE_WARNING = 'Your `HotTable` configuration includes `autoRowSize`/`autoColumnSize` options, which are not compatible with ' + ' the component-based renderers`. Disable `autoRowSize` and `autoColumnSize` to prevent row and column misalignment.';
209
- /**
210
- * Message for the warning thrown if the Handsontable instance has been destroyed.
211
- */
212
- var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.';
213
- /**
214
- * String identifier for the global-scoped editor components.
215
- */
216
- var GLOBAL_EDITOR_SCOPE = 'global';
217
- /**
218
- * Default classname given to the wrapper container.
219
- */
220
- var DEFAULT_CLASSNAME = 'hot-wrapper-editor-container';
221
- /**
222
- * Logs warn to the console if the `console` object is exposed.
223
- *
224
- * @param {...*} args Values which will be logged.
225
- */
226
- function warn() {
227
- if (typeof console !== 'undefined') {
228
- var _console;
229
- (_console = console).warn.apply(_console, arguments);
230
- }
231
- }
232
- /**
233
- * Filter out and return elements of the provided `type` from the `HotColumn` component's children.
234
- *
235
- * @param {React.ReactNode} children HotTable children array.
236
- * @param {String} type Either `'hot-renderer'` or `'hot-editor'`.
237
- * @returns {Object|null} A child (React node) or `null`, if no child of that type was found.
238
- */
239
- function getChildElementByType(children, type) {
240
- var childrenArray = React__default["default"].Children.toArray(children);
241
- var childrenCount = React__default["default"].Children.count(children);
242
- var wantedChild = null;
243
- if (childrenCount !== 0) {
244
- if (childrenCount === 1 && childrenArray[0].props[type]) {
245
- wantedChild = childrenArray[0];
246
- } else {
247
- wantedChild = childrenArray.find(function (child) {
248
- return child.props[type] !== void 0;
249
- });
250
- }
251
- }
252
- return wantedChild || null;
253
- }
254
- /**
255
- * Get the reference to the original editor class.
256
- *
257
- * @param {React.ReactElement} editorElement React element of the editor class.
258
- * @returns {Function} Original class of the editor component.
259
- */
260
- function getOriginalEditorClass(editorElement) {
261
- if (!editorElement) {
262
- return null;
263
- }
264
- return editorElement.type.WrappedComponent ? editorElement.type.WrappedComponent : editorElement.type;
265
- }
266
- /**
267
- * Create an editor portal.
268
- *
269
- * @param {Document} doc Document to be used.
270
- * @param {React.ReactElement} editorElement Editor's element.
271
- * @returns {React.ReactPortal} The portal for the editor.
272
- */
273
- function createEditorPortal(doc, editorElement) {
274
- if (typeof doc === 'undefined' || editorElement === null) {
275
- return null;
276
- }
277
- var containerProps = getContainerAttributesProps(editorElement.props, false);
278
- containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
279
- return ReactDOM__default["default"].createPortal(React__default["default"].createElement("div", Object.assign({}, containerProps), editorElement), doc.body);
280
- }
281
- /**
282
- * Get an editor element extended with an instance-emitting method.
283
- *
284
- * @param {React.ReactNode} children Component children.
285
- * @param {Map} editorCache Component's editor cache.
286
- * @param {EditorScopeIdentifier} [editorColumnScope] The editor scope (column index or a 'global' string). Defaults to
287
- * 'global'.
288
- * @returns {React.ReactElement} An editor element containing the additional methods.
289
- */
290
- function getExtendedEditorElement(children, editorCache) {
291
- var editorColumnScope = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : GLOBAL_EDITOR_SCOPE;
292
- var editorElement = getChildElementByType(children, 'hot-editor');
293
- var editorClass = getOriginalEditorClass(editorElement);
294
- if (!editorElement) {
295
- return null;
296
- }
297
- return React__default["default"].cloneElement(editorElement, {
298
- emitEditorInstance: function emitEditorInstance(editorInstance, editorColumnScope) {
299
- if (!editorCache.get(editorClass)) {
300
- editorCache.set(editorClass, new Map());
301
- }
302
- var cacheEntry = editorCache.get(editorClass);
303
- cacheEntry.set(editorColumnScope !== null && editorColumnScope !== void 0 ? editorColumnScope : GLOBAL_EDITOR_SCOPE, editorInstance);
304
- },
305
- editorColumnScope: editorColumnScope,
306
- isEditor: true
307
- });
308
- }
309
- /**
310
- * Create a react component and render it to an external DOM done.
311
- *
312
- * @param {React.ReactElement} rElement React element to be used as a base for the component.
313
- * @param {Object} props Props to be passed to the cloned element.
314
- * @param {Document} [ownerDocument] The owner document to set the portal up into.
315
- * @param {String} portalKey The key to be used for the portal.
316
- * @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
317
- * @returns {{portal: React.ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
318
- */
319
- function createPortal(rElement, props) {
320
- var ownerDocument = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document;
321
- var portalKey = arguments.length > 3 ? arguments[3] : undefined;
322
- var cachedContainer = arguments.length > 4 ? arguments[4] : undefined;
323
- if (!ownerDocument) {
324
- ownerDocument = document;
325
- }
326
- if (!bulkComponentContainer) {
327
- bulkComponentContainer = ownerDocument.createDocumentFragment();
328
- }
329
- var portalContainer = cachedContainer !== null && cachedContainer !== void 0 ? cachedContainer : ownerDocument.createElement('DIV');
330
- bulkComponentContainer.appendChild(portalContainer);
331
- var extendedRendererElement = React__default["default"].cloneElement(rElement, _objectSpread2({
332
- key: "".concat(props.row, "-").concat(props.col)
333
- }, props));
334
- return {
335
- portal: ReactDOM__default["default"].createPortal(extendedRendererElement, portalContainer, portalKey),
336
- portalContainer: portalContainer
337
- };
338
- }
339
- /**
340
- * Get an object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
341
- * component.
342
- *
343
- * @param {Object} props Object containing the react element props.
344
- * @param {Boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was present in the `prop` object.
345
- * @returns An object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
346
- * component.
347
- */
348
- function getContainerAttributesProps(props) {
349
- var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
350
- return {
351
- id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : undefined),
352
- className: props.className || '',
353
- style: props.style || {}
354
- };
355
- }
356
- /**
357
- * Checks if the environment that the code runs in is a browser.
358
- *
359
- * @returns {boolean}
360
- */
361
- function isCSR() {
362
- return typeof window !== 'undefined';
403
+ function _nonIterableRest() {
404
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
363
405
  }
364
406
 
365
407
  var SettingsMapper = /*#__PURE__*/function () {
@@ -370,24 +412,16 @@ var SettingsMapper = /*#__PURE__*/function () {
370
412
  key: "getSettings",
371
413
  value:
372
414
  /**
373
- * Parse component settings into Handosntable-compatible settings.
415
+ * Parse component settings into Handsontable-compatible settings.
374
416
  *
375
417
  * @param {Object} properties Object containing properties from the HotTable object.
376
418
  * @returns {Object} Handsontable-compatible settings object.
377
419
  */
378
420
  function getSettings(properties) {
379
421
  var newSettings = {};
380
- if (properties.settings) {
381
- var settings = properties.settings;
382
- for (var key in settings) {
383
- if (settings.hasOwnProperty(key)) {
384
- newSettings[key] = settings[key];
385
- }
386
- }
387
- }
388
- for (var _key in properties) {
389
- if (_key !== 'settings' && _key !== 'children' && properties.hasOwnProperty(_key)) {
390
- newSettings[_key] = properties[_key];
422
+ for (var key in properties) {
423
+ if (key !== 'children' && properties.hasOwnProperty(key)) {
424
+ newSettings[key] = properties[key];
391
425
  }
392
426
  }
393
427
  return newSettings;
@@ -396,128 +430,302 @@ var SettingsMapper = /*#__PURE__*/function () {
396
430
  return SettingsMapper;
397
431
  }();
398
432
 
399
- var HotColumn = /*#__PURE__*/function (_React$Component) {
400
- _inherits(HotColumn, _React$Component);
401
- function HotColumn() {
402
- _classCallCheck(this, HotColumn);
403
- return _callSuper(this, HotColumn, arguments);
404
- }
405
- _createClass(HotColumn, [{
406
- key: "getSettingsProps",
407
- value:
408
- /**
409
- * Filter out all the internal properties and return an object with just the Handsontable-related props.
410
- *
433
+ var HotTableContext = React__default["default"].createContext(undefined);
434
+ var HotTableContextProvider = function HotTableContextProvider(_ref) {
435
+ var children = _ref.children;
436
+ var columnsSettings = React__default["default"].useRef([]);
437
+ var setHotColumnSettings = React__default["default"].useCallback(function (columnSettings, columnIndex) {
438
+ columnsSettings.current[columnIndex] = columnSettings;
439
+ }, []);
440
+ var componentRendererColumns = React__default["default"].useRef(new Map());
441
+ var renderedCellCache = React__default["default"].useRef(new Map());
442
+ var clearRenderedCellCache = React__default["default"].useCallback(function () {
443
+ return renderedCellCache.current.clear();
444
+ }, []);
445
+ var portalCache = React__default["default"].useRef(new Map());
446
+ var clearPortalCache = React__default["default"].useCallback(function () {
447
+ return portalCache.current.clear();
448
+ }, []);
449
+ var portalContainerCache = React__default["default"].useRef(new Map());
450
+ var getRendererWrapper = React__default["default"].useCallback(function (Renderer) {
451
+ return function __internalRenderer(instance, TD, row, col, prop, value, cellProperties) {
452
+ var key = "".concat(row, "-").concat(col);
453
+ // Handsontable.Core type is missing guid
454
+ var instanceGuid = instance.guid;
455
+ var portalContainerKey = "".concat(instanceGuid, "-").concat(key);
456
+ var portalKey = "".concat(key, "-").concat(instanceGuid);
457
+ if (renderedCellCache.current.has(key)) {
458
+ TD.innerHTML = renderedCellCache.current.get(key).innerHTML;
459
+ }
460
+ if (TD && !TD.getAttribute('ghost-table')) {
461
+ var cachedPortal = portalCache.current.get(portalKey);
462
+ var cachedPortalContainer = portalContainerCache.current.get(portalContainerKey);
463
+ while (TD.firstChild) {
464
+ TD.removeChild(TD.firstChild);
465
+ }
466
+ // if portal already exists, do not recreate
467
+ if (cachedPortal && cachedPortalContainer) {
468
+ TD.appendChild(cachedPortalContainer);
469
+ } else {
470
+ var rendererElement = React__default["default"].createElement(Renderer, {
471
+ instance: instance,
472
+ TD: TD,
473
+ row: row,
474
+ col: col,
475
+ prop: prop,
476
+ value: value,
477
+ cellProperties: cellProperties
478
+ });
479
+ var _createPortal = createPortal(rendererElement, TD.ownerDocument, portalKey, cachedPortalContainer),
480
+ portal = _createPortal.portal,
481
+ portalContainer = _createPortal.portalContainer;
482
+ portalContainerCache.current.set(portalContainerKey, portalContainer);
483
+ TD.appendChild(portalContainer);
484
+ portalCache.current.set(portalKey, portal);
485
+ }
486
+ }
487
+ renderedCellCache.current.set("".concat(row, "-").concat(col), TD);
488
+ return TD;
489
+ };
490
+ }, []);
491
+ var renderersPortalManager = React__default["default"].useRef(function () {
492
+ return undefined;
493
+ });
494
+ var setRenderersPortalManagerRef = React__default["default"].useCallback(function (pmComponent) {
495
+ renderersPortalManager.current = pmComponent;
496
+ }, []);
497
+ var pushCellPortalsIntoPortalManager = React__default["default"].useCallback(function () {
498
+ renderersPortalManager.current(_toConsumableArray(portalCache.current.values()));
499
+ }, []);
500
+ var contextImpl = React__default["default"].useMemo(function () {
501
+ return {
502
+ componentRendererColumns: componentRendererColumns.current,
503
+ columnsSettings: columnsSettings.current,
504
+ emitColumnSettings: setHotColumnSettings,
505
+ getRendererWrapper: getRendererWrapper,
506
+ clearPortalCache: clearPortalCache,
507
+ clearRenderedCellCache: clearRenderedCellCache,
508
+ setRenderersPortalManagerRef: setRenderersPortalManagerRef,
509
+ pushCellPortalsIntoPortalManager: pushCellPortalsIntoPortalManager
510
+ };
511
+ }, [setHotColumnSettings, getRendererWrapper, clearRenderedCellCache, setRenderersPortalManagerRef, pushCellPortalsIntoPortalManager]);
512
+ return React__default["default"].createElement(HotTableContext.Provider, {
513
+ value: contextImpl
514
+ }, children);
515
+ };
516
+ /**
517
+ * Exposes the table context object to components
518
+ *
519
+ * @returns HotTableContext
520
+ */
521
+ function useHotTableContext() {
522
+ return React__default["default"].useContext(HotTableContext);
523
+ }
524
+
525
+ var HotColumnContext = React__default["default"].createContext(undefined);
526
+ var HotColumnContextProvider = function HotColumnContextProvider(_ref) {
527
+ var columnIndex = _ref.columnIndex,
528
+ getOwnerDocument = _ref.getOwnerDocument,
529
+ children = _ref.children;
530
+ var contextImpl = React__default["default"].useMemo(function () {
531
+ return {
532
+ columnIndex: columnIndex,
533
+ getOwnerDocument: getOwnerDocument
534
+ };
535
+ }, [columnIndex, getOwnerDocument]);
536
+ return React__default["default"].createElement(HotColumnContext.Provider, {
537
+ value: contextImpl
538
+ }, children);
539
+ };
540
+ var useHotColumnContext = function useHotColumnContext() {
541
+ return React__default["default"].useContext(HotColumnContext);
542
+ };
543
+
544
+ /**
545
+ * Create a class to be passed to the Handsontable's settings.
546
+ *
547
+ * @param {React.RefObject<HotEditorHooks>} hooksRef Reference to component-based editor overridden hooks object.
548
+ * @param {React.RefObject} instanceRef Reference to Handsontable-native custom editor class instance.
549
+ * @returns {Function} A class to be passed to the Handsontable editor settings.
550
+ */
551
+ function makeEditorClass(hooksRef, instanceRef) {
552
+ return /*#__PURE__*/function (_Handsontable$editors) {
553
+ _inherits(CustomEditor, _Handsontable$editors);
554
+ function CustomEditor(hotInstance) {
555
+ var _this;
556
+ _classCallCheck(this, CustomEditor);
557
+ _this = _callSuper(this, CustomEditor, [hotInstance]);
558
+ instanceRef.current = _assertThisInitialized(_this);
559
+ Object.getOwnPropertyNames(Handsontable__default["default"].editors.BaseEditor.prototype).forEach(function (propName) {
560
+ if (propName === 'constructor') {
561
+ return;
562
+ }
563
+ var baseMethod = Handsontable__default["default"].editors.BaseEditor.prototype[propName];
564
+ CustomEditor.prototype[propName] = function () {
565
+ var _hooksRef$current;
566
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
567
+ args[_key] = arguments[_key];
568
+ }
569
+ if ((_hooksRef$current = hooksRef.current) !== null && _hooksRef$current !== void 0 && _hooksRef$current[propName]) {
570
+ var _hooksRef$current$pro;
571
+ return (_hooksRef$current$pro = hooksRef.current[propName]).call.apply(_hooksRef$current$pro, [this].concat(args));
572
+ } else {
573
+ return baseMethod.call.apply(baseMethod, [this].concat(args));
574
+ }
575
+ }.bind(_assertThisInitialized(_this));
576
+ });
577
+ return _this;
578
+ }
579
+ _createClass(CustomEditor, [{
580
+ key: "focus",
581
+ value: function focus() {}
582
+ }, {
583
+ key: "getValue",
584
+ value: function getValue() {}
585
+ }, {
586
+ key: "setValue",
587
+ value: function setValue() {}
588
+ }, {
589
+ key: "open",
590
+ value: function open() {}
591
+ }, {
592
+ key: "close",
593
+ value: function close() {}
594
+ }]);
595
+ return CustomEditor;
596
+ }(Handsontable__default["default"].editors.BaseEditor);
597
+ }
598
+ /**
599
+ * Context to provide Handsontable-native custom editor class instance to overridden hooks object.
600
+ */
601
+ var EditorContext = React__default["default"].createContext(undefined);
602
+ /**
603
+ * Provider of the context that exposes Handsontable-native editor instance and passes hooks object
604
+ * for custom editor components.
605
+ *
606
+ * @param {React.Ref} hooksRef Reference for component-based editor overridden hooks object.
607
+ * @param {React.RefObject} hotCustomEditorInstanceRef Reference to Handsontable-native editor instance.
608
+ */
609
+ var EditorContextProvider = function EditorContextProvider(_ref) {
610
+ var hooksRef = _ref.hooksRef,
611
+ hotCustomEditorInstanceRef = _ref.hotCustomEditorInstanceRef,
612
+ children = _ref.children;
613
+ return React__default["default"].createElement(EditorContext.Provider, {
614
+ value: {
615
+ hooksRef: hooksRef,
616
+ hotCustomEditorInstanceRef: hotCustomEditorInstanceRef
617
+ }
618
+ }, children);
619
+ };
620
+ /**
621
+ * Hook that allows encapsulating custom behaviours of component-based editor by customizing passed ref with overridden hooks object.
622
+ *
623
+ * @param {Function} overriddenHooks Function that provides the overrides specific for the custom editor.
624
+ * It gets an object that emulates super calls to BaseEditor methods, if needed.
625
+ * @param {React.DependencyList} deps Overridden hooks object React dependency list.
626
+ * @returns {React.RefObject} Reference to Handsontable-native editor instance.
627
+ */
628
+ function useHotEditor(overriddenHooks, deps) {
629
+ var _React$useContext = React__default["default"].useContext(EditorContext),
630
+ hooksRef = _React$useContext.hooksRef,
631
+ hotCustomEditorInstanceRef = _React$useContext.hotCustomEditorInstanceRef;
632
+ var runSuper = function runSuper() {
633
+ return superBound(hotCustomEditorInstanceRef.current);
634
+ };
635
+ React__default["default"].useImperativeHandle(hooksRef, function () {
636
+ return (overriddenHooks === null || overriddenHooks === void 0 ? void 0 : overriddenHooks(runSuper)) || {};
637
+ }, deps);
638
+ return hotCustomEditorInstanceRef;
639
+ }
640
+
641
+ var isHotColumn = function isHotColumn(childNode) {
642
+ return childNode.type === HotColumn;
643
+ };
644
+ var internalProps = ['_columnIndex', '_getOwnerDocument', 'children'];
645
+ var HotColumn = function HotColumn(props) {
646
+ var _useHotTableContext = useHotTableContext(),
647
+ componentRendererColumns = _useHotTableContext.componentRendererColumns,
648
+ emitColumnSettings = _useHotTableContext.emitColumnSettings,
649
+ getRendererWrapper = _useHotTableContext.getRendererWrapper;
650
+ var _useHotColumnContext = useHotColumnContext(),
651
+ columnIndex = _useHotColumnContext.columnIndex,
652
+ getOwnerDocument = _useHotColumnContext.getOwnerDocument;
653
+ /**
654
+ * Reference to component-based editor overridden hooks object.
655
+ */
656
+ var localEditorHooksRef = React__default["default"].useRef(null);
657
+ /**
658
+ * Reference to HOT-native custom editor class instance.
659
+ */
660
+ var localEditorClassInstance = React__default["default"].useRef(null);
661
+ /**
662
+ * Logic performed after mounting & updating of the HotColumn component.
663
+ */
664
+ React__default["default"].useEffect(function () {
665
+ /**
666
+ * Filter out all the internal properties and return an object with just the Handsontable-related props.
667
+ *
411
668
  * @returns {Object}
412
669
  */
413
- function getSettingsProps() {
414
- var _this = this;
415
- this.internalProps = ['_componentRendererColumns', '_emitColumnSettings', '_columnIndex', '_getChildElementByType', '_getRendererWrapper', '_getEditorClass', '_getEditorCache', '_getOwnerDocument', 'hot-renderer', 'hot-editor', 'children'];
416
- return Object.keys(this.props).filter(function (key) {
417
- return !_this.internalProps.includes(key);
670
+ var getSettingsProps = function getSettingsProps() {
671
+ return Object.keys(props).filter(function (key) {
672
+ return !internalProps.includes(key);
418
673
  }).reduce(function (obj, key) {
419
- obj[key] = _this.props[key];
674
+ obj[key] = props[key];
420
675
  return obj;
421
676
  }, {});
422
- }
423
- /**
424
- * Get the editor element for the current column.
425
- *
426
- * @returns {React.ReactElement} React editor component element.
427
- */
428
- }, {
429
- key: "getLocalEditorElement",
430
- value: function getLocalEditorElement() {
431
- return getExtendedEditorElement(this.props.children, this.props._getEditorCache(), this.props._columnIndex);
432
- }
433
- /**
434
- * Create the column settings based on the data provided to the `HotColumn` component and it's child components.
435
- */
436
- }, {
437
- key: "createColumnSettings",
438
- value: function createColumnSettings() {
439
- var rendererElement = this.props._getChildElementByType(this.props.children, 'hot-renderer');
440
- var editorElement = this.getLocalEditorElement();
441
- this.columnSettings = SettingsMapper.getSettings(this.getSettingsProps());
442
- if (rendererElement !== null) {
443
- this.columnSettings.renderer = this.props._getRendererWrapper(rendererElement);
444
- this.props._componentRendererColumns.set(this.props._columnIndex, true);
445
- }
446
- if (editorElement !== null) {
447
- this.columnSettings.editor = this.props._getEditorClass(editorElement, this.props._columnIndex);
448
- }
449
- }
450
- /**
451
- * Emit the column settings to the parent using a prop passed from the parent.
452
- */
453
- }, {
454
- key: "emitColumnSettings",
455
- value: function emitColumnSettings() {
456
- this.props._emitColumnSettings(this.columnSettings, this.props._columnIndex);
457
- }
458
- /*
459
- ---------------------------------------
460
- ------- React lifecycle methods -------
461
- ---------------------------------------
462
- */
463
- /**
464
- * Logic performed after the mounting of the HotColumn component.
465
- */
466
- }, {
467
- key: "componentDidMount",
468
- value: function componentDidMount() {
469
- this.createColumnSettings();
470
- this.emitColumnSettings();
471
- }
472
- /**
473
- * Logic performed after the updating of the HotColumn component.
474
- */
475
- }, {
476
- key: "componentDidUpdate",
477
- value: function componentDidUpdate() {
478
- this.createColumnSettings();
479
- this.emitColumnSettings();
480
- }
677
+ };
481
678
  /**
482
- * Render the portals of the editors, if there are any.
483
- *
484
- * @returns {React.ReactElement}
679
+ * Create the column settings based on the data provided to the `HotColumn` component and its child components.
485
680
  */
486
- }, {
487
- key: "render",
488
- value: function render() {
489
- var ownerDocument = this.props._getOwnerDocument();
490
- var editorPortal = createEditorPortal(ownerDocument, this.getLocalEditorElement());
491
- return React__default["default"].createElement(React__default["default"].Fragment, null, editorPortal);
681
+ var createColumnSettings = function createColumnSettings() {
682
+ var columnSettings = SettingsMapper.getSettings(getSettingsProps());
683
+ if (props.renderer) {
684
+ columnSettings.renderer = getRendererWrapper(props.renderer);
685
+ componentRendererColumns.set(columnIndex, true);
686
+ } else if (props.hotRenderer) {
687
+ columnSettings.renderer = props.hotRenderer;
688
+ }
689
+ if (props.editor) {
690
+ columnSettings.editor = makeEditorClass(localEditorHooksRef, localEditorClassInstance);
691
+ } else if (props.hotEditor) {
692
+ columnSettings.editor = props.hotEditor;
693
+ }
694
+ return columnSettings;
695
+ };
696
+ var columnSettings = createColumnSettings();
697
+ emitColumnSettings(columnSettings, columnIndex);
698
+ if (!displayObsoleteRenderersEditorsWarning(props.children)) {
699
+ displayAnyChildrenWarning(props.children);
492
700
  }
493
- }]);
494
- return HotColumn;
495
- }(React__default["default"].Component);
701
+ });
702
+ var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
703
+ /**
704
+ * Render the portals of the editors, if there are any.
705
+ *
706
+ * @returns {React.ReactElement}
707
+ */
708
+ return React__default["default"].createElement(EditorContextProvider, {
709
+ hooksRef: localEditorHooksRef,
710
+ hotCustomEditorInstanceRef: localEditorClassInstance
711
+ }, editorPortal);
712
+ };
713
+
714
+ var version="0.0.0-next-d093c11-20240307";
496
715
 
497
716
  /**
498
- * Component class used to manage the renderer component portals.
717
+ * Component used to manage the renderer component portals.
499
718
  */
500
- var RenderersPortalManager = /*#__PURE__*/function (_React$Component) {
501
- _inherits(RenderersPortalManager, _React$Component);
502
- function RenderersPortalManager() {
503
- var _this;
504
- _classCallCheck(this, RenderersPortalManager);
505
- _this = _callSuper(this, RenderersPortalManager, arguments);
506
- _this.state = {
507
- portals: []
508
- };
509
- return _this;
510
- }
511
- _createClass(RenderersPortalManager, [{
512
- key: "render",
513
- value: function render() {
514
- return React__default["default"].createElement(React__default["default"].Fragment, null, this.state.portals);
515
- }
516
- }]);
517
- return RenderersPortalManager;
518
- }(React__default["default"].Component);
519
-
520
- var version="0.0.0-next-9f2f898-20240306";
719
+ var RenderersPortalManager = React__default["default"].forwardRef(function (_, ref) {
720
+ var _React$useState = React__default["default"].useState([]),
721
+ _React$useState2 = _slicedToArray(_React$useState, 2),
722
+ portals = _React$useState2[0],
723
+ setPortals = _React$useState2[1];
724
+ React__default["default"].useImperativeHandle(ref, function () {
725
+ return setPortals;
726
+ });
727
+ return React__default["default"].createElement(React__default["default"].Fragment, null, portals);
728
+ });
521
729
 
522
730
  function createCommonjsModule(fn, module) {
523
731
  return module = { exports: {} }, fn(module, module.exports), module.exports;
@@ -1638,816 +1846,218 @@ var propTypes = createCommonjsModule(function (module) {
1638
1846
  });
1639
1847
  var PropTypes = propTypes;
1640
1848
 
1641
- /**
1642
- * A Handsontable-ReactJS wrapper.
1643
- *
1644
- * To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
1645
- * For example:
1646
- *
1647
- * ```js
1648
- * <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
1649
- *
1650
- * // is analogous to
1651
- * let hot = new Handsontable(document.getElementById('hot'), {
1652
- * data: dataObject,
1653
- * contextMenu: true,
1654
- * colHeaders: true,
1655
- * width: 600
1656
- * height: 300
1657
- * });
1658
- *
1659
- * ```
1660
- *
1661
- * @class HotTableCB
1662
- */
1663
- var HotTableClass = /*#__PURE__*/function (_React$Component) {
1664
- _inherits(HotTableClass, _React$Component);
1665
- function HotTableClass() {
1666
- var _this;
1667
- _classCallCheck(this, HotTableClass);
1668
- _this = _callSuper(this, HotTableClass, arguments);
1669
- /**
1670
- * The `id` of the main Handsontable DOM element.
1671
- *
1672
- * @type {String}
1673
- */
1674
- _this.id = null;
1675
- /**
1676
- * Reference to the Handsontable instance.
1677
- *
1678
- * @private
1679
- * @type {Object}
1680
- */
1681
- _this.__hotInstance = null;
1682
- /**
1683
- * Reference to the main Handsontable DOM element.
1684
- *
1685
- * @type {HTMLElement}
1686
- */
1687
- _this.hotElementRef = null;
1688
- /**
1689
- * Array of object containing the column settings.
1690
- *
1691
- * @type {Array}
1692
- */
1693
- _this.columnSettings = [];
1694
- /**
1695
- * Component used to manage the renderer portals.
1696
- *
1697
- * @type {React.Component}
1698
- */
1699
- _this.renderersPortalManager = null;
1700
- /**
1701
- * Map that stores React portals.
1702
- * @type {Map<string, React.ReactPortal>}
1703
- */
1704
- _this.portalCache = new Map();
1705
- /**
1706
- * Portal Container Cache
1707
- *
1708
- * @private
1709
- * @type {Map}
1710
- */
1711
- _this.portalContainerCache = new Map();
1712
- /**
1713
- * The rendered cells cache.
1714
- *
1715
- * @private
1716
- * @type {Map}
1717
- */
1718
- _this.renderedCellCache = new Map();
1719
- /**
1720
- * Editor cache.
1721
- *
1722
- * @private
1723
- * @type {Map}
1724
- */
1725
- _this.editorCache = new Map();
1726
- /**
1727
- * Map with column indexes (or a string = 'global') as keys, and booleans as values. Each key represents a component-based editor
1728
- * declared for the used column index, or a global one, if the key is the `global` string.
1729
- *
1730
- * @private
1731
- * @type {Map}
1732
- */
1733
- _this.componentRendererColumns = new Map();
1734
- return _this;
1735
- }
1849
+ var HotTableInner = React__default["default"].forwardRef(function (props, ref) {
1736
1850
  /**
1737
- * Package version getter.
1738
- *
1739
- * @returns The version number of the package.
1851
+ * Reference to the Handsontable instance.
1740
1852
  */
1741
- _createClass(HotTableClass, [{
1742
- key: "hotInstance",
1743
- get:
1744
- /**
1745
- * Getter for the property storing the Handsontable instance.
1746
- */
1747
- function get() {
1748
- if (!this.__hotInstance || this.__hotInstance && !this.__hotInstance.isDestroyed) {
1749
- // Will return the Handsontable instance or `null` if it's not yet been created.
1750
- return this.__hotInstance;
1751
- } else {
1752
- console.warn(HOT_DESTROYED_WARNING);
1753
- return null;
1754
- }
1755
- }
1756
- /**
1757
- * Setter for the property storing the Handsontable instance.
1758
- * @param {Handsontable} hotInstance The Handsontable instance.
1759
- */,
1760
- set: function set(hotInstance) {
1761
- this.__hotInstance = hotInstance;
1762
- }
1763
- /**
1764
- * Get Portal Container Cache
1765
- *
1766
- * @returns {Map}
1767
- */
1768
- }, {
1769
- key: "getPortalContainerCache",
1770
- value: function getPortalContainerCache() {
1771
- return this.portalContainerCache;
1772
- }
1773
- /**
1774
- * Get the rendered table cell cache.
1775
- *
1776
- * @returns {Map}
1777
- */
1778
- }, {
1779
- key: "getRenderedCellCache",
1780
- value: function getRenderedCellCache() {
1781
- return this.renderedCellCache;
1782
- }
1783
- /**
1784
- * Get the editor cache and return it.
1785
- *
1786
- * @returns {Map}
1787
- */
1788
- }, {
1789
- key: "getEditorCache",
1790
- value: function getEditorCache() {
1791
- return this.editorCache;
1792
- }
1793
- /**
1794
- * Clear both the editor and the renderer cache.
1795
- */
1796
- }, {
1797
- key: "clearCache",
1798
- value: function clearCache() {
1799
- this.getRenderedCellCache().clear();
1800
- this.componentRendererColumns.clear();
1801
- }
1802
- /**
1803
- * Get the `Document` object corresponding to the main component element.
1804
- *
1805
- * @returns The `Document` object used by the component.
1806
- */
1807
- }, {
1808
- key: "getOwnerDocument",
1809
- value: function getOwnerDocument() {
1810
- if (isCSR()) {
1811
- return this.hotElementRef ? this.hotElementRef.ownerDocument : document;
1812
- }
1853
+ var __hotInstance = React__default["default"].useRef(null);
1854
+ /**
1855
+ * Reference to the main Handsontable DOM element.
1856
+ */
1857
+ var hotElementRef = React__default["default"].useRef(null);
1858
+ /**
1859
+ * Reference to component-based editor overridden hooks object.
1860
+ */
1861
+ var globalEditorHooksRef = React__default["default"].useRef(null);
1862
+ /**
1863
+ * Reference to HOT-native custom editor class instance.
1864
+ */
1865
+ var globalEditorClassInstance = React__default["default"].useRef(null);
1866
+ /**
1867
+ * HotTable context exposing helper functions.
1868
+ */
1869
+ var context = useHotTableContext();
1870
+ /**
1871
+ * Getter for the property storing the Handsontable instance.
1872
+ */
1873
+ var getHotInstance = React__default["default"].useCallback(function () {
1874
+ if (!__hotInstance.current || !__hotInstance.current.isDestroyed) {
1875
+ // Will return the Handsontable instance or `null` if it's not yet been created.
1876
+ return __hotInstance.current;
1877
+ } else {
1878
+ console.warn(HOT_DESTROYED_WARNING);
1813
1879
  return null;
1814
1880
  }
1815
- /**
1816
- * Set the reference to the main Handsontable DOM element.
1817
- *
1818
- * @param {HTMLElement} element The main Handsontable DOM element.
1819
- */
1820
- }, {
1821
- key: "setHotElementRef",
1822
- value: function setHotElementRef(element) {
1823
- this.hotElementRef = element;
1824
- }
1825
- /**
1826
- * Return a renderer wrapper function for the provided renderer component.
1827
- *
1828
- * @param {React.ReactElement} rendererElement React renderer component.
1829
- * @returns {Handsontable.renderers.Base} The Handsontable rendering function.
1830
- */
1831
- }, {
1832
- key: "getRendererWrapper",
1833
- value: function getRendererWrapper(rendererElement) {
1834
- var hotTableComponent = this;
1835
- return function __internalRenderer(instance, TD, row, col, prop, value, cellProperties) {
1836
- var renderedCellCache = hotTableComponent.getRenderedCellCache();
1837
- var portalContainerCache = hotTableComponent.getPortalContainerCache();
1838
- var key = "".concat(row, "-").concat(col);
1839
- // Handsontable.Core type is missing guid
1840
- var instanceGuid = instance.guid;
1841
- var portalContainerKey = "".concat(instanceGuid, "-").concat(key);
1842
- var portalKey = "".concat(key, "-").concat(instanceGuid);
1843
- if (renderedCellCache.has(key)) {
1844
- TD.innerHTML = renderedCellCache.get(key).innerHTML;
1845
- }
1846
- if (TD && !TD.getAttribute('ghost-table')) {
1847
- var cachedPortal = hotTableComponent.portalCache.get(portalKey);
1848
- var cachedPortalContainer = portalContainerCache.get(portalContainerKey);
1849
- while (TD.firstChild) {
1850
- TD.removeChild(TD.firstChild);
1851
- }
1852
- // if portal already exists, do not recreate
1853
- if (cachedPortal && cachedPortalContainer) {
1854
- TD.appendChild(cachedPortalContainer);
1855
- } else {
1856
- var _createPortal = createPortal(rendererElement, {
1857
- TD: TD,
1858
- row: row,
1859
- col: col,
1860
- prop: prop,
1861
- value: value,
1862
- cellProperties: cellProperties,
1863
- isRenderer: true
1864
- }, TD.ownerDocument, portalKey, cachedPortalContainer),
1865
- portal = _createPortal.portal,
1866
- portalContainer = _createPortal.portalContainer;
1867
- portalContainerCache.set(portalContainerKey, portalContainer);
1868
- TD.appendChild(portalContainer);
1869
- hotTableComponent.portalCache.set(portalKey, portal);
1870
- }
1871
- }
1872
- renderedCellCache.set(key, TD);
1873
- return TD;
1874
- };
1875
- }
1876
- /**
1877
- * Create a fresh class to be used as an editor, based on the provided editor React element.
1878
- *
1879
- * @param {React.ReactElement} editorElement React editor component.
1880
- * @param {string|number} [editorColumnScope] The editor scope (column index or a 'global' string). Defaults to
1881
- * 'global'.
1882
- * @returns {Function} A class to be passed to the Handsontable editor settings.
1883
- */
1884
- }, {
1885
- key: "getEditorClass",
1886
- value: function getEditorClass(editorElement) {
1887
- var _this$getEditorCache$;
1888
- var editorColumnScope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : GLOBAL_EDITOR_SCOPE;
1889
- var editorClass = getOriginalEditorClass(editorElement);
1890
- var cachedComponent = (_this$getEditorCache$ = this.getEditorCache().get(editorClass)) === null || _this$getEditorCache$ === void 0 ? void 0 : _this$getEditorCache$.get(editorColumnScope);
1891
- return this.makeEditorClass(cachedComponent);
1892
- }
1893
- /**
1894
- * Create a class to be passed to the Handsontable's settings.
1895
- *
1896
- * @param {React.ReactElement} editorComponent React editor component.
1897
- * @returns {Function} A class to be passed to the Handsontable editor settings.
1898
- */
1899
- }, {
1900
- key: "makeEditorClass",
1901
- value: function makeEditorClass(editorComponent) {
1902
- var customEditorClass = /*#__PURE__*/function (_Handsontable$editors) {
1903
- _inherits(CustomEditor, _Handsontable$editors);
1904
- function CustomEditor(hotInstance) {
1905
- var _this2;
1906
- _classCallCheck(this, CustomEditor);
1907
- _this2 = _callSuper(this, CustomEditor, [hotInstance]);
1908
- editorComponent.hotCustomEditorInstance = _assertThisInitialized(_this2);
1909
- _this2.editorComponent = editorComponent;
1910
- return _this2;
1911
- }
1912
- _createClass(CustomEditor, [{
1913
- key: "focus",
1914
- value: function focus() {}
1915
- }, {
1916
- key: "getValue",
1917
- value: function getValue() {}
1918
- }, {
1919
- key: "setValue",
1920
- value: function setValue() {}
1921
- }, {
1922
- key: "open",
1923
- value: function open() {}
1924
- }, {
1925
- key: "close",
1926
- value: function close() {}
1927
- }]);
1928
- return CustomEditor;
1929
- }(Handsontable__default["default"].editors.BaseEditor);
1930
- // Fill with the rest of the BaseEditor methods
1931
- Object.getOwnPropertyNames(Handsontable__default["default"].editors.BaseEditor.prototype).forEach(function (propName) {
1932
- if (propName === 'constructor') {
1933
- return;
1934
- }
1935
- customEditorClass.prototype[propName] = function () {
1936
- var _editorComponent$prop;
1937
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1938
- args[_key] = arguments[_key];
1939
- }
1940
- return (_editorComponent$prop = editorComponent[propName]).call.apply(_editorComponent$prop, [editorComponent].concat(args));
1941
- };
1942
- });
1943
- return customEditorClass;
1944
- }
1945
- /**
1946
- * Get the renderer element for the entire HotTable instance.
1947
- *
1948
- * @returns {React.ReactElement} React renderer component element.
1949
- */
1950
- }, {
1951
- key: "getGlobalRendererElement",
1952
- value: function getGlobalRendererElement() {
1953
- return getChildElementByType(this.props.children, 'hot-renderer');
1881
+ }, [__hotInstance]);
1882
+ /**
1883
+ * Clear both the editor and the renderer cache.
1884
+ */
1885
+ var clearCache = React__default["default"].useCallback(function () {
1886
+ context.clearRenderedCellCache();
1887
+ context.componentRendererColumns.clear();
1888
+ }, [context]);
1889
+ /**
1890
+ * Get the `Document` object corresponding to the main component element.
1891
+ *
1892
+ * @returns The `Document` object used by the component.
1893
+ */
1894
+ var getOwnerDocument = React__default["default"].useCallback(function () {
1895
+ if (isCSR()) {
1896
+ return hotElementRef.current ? hotElementRef.current.ownerDocument : document;
1954
1897
  }
1955
- /**
1956
- * Get the editor element for the entire HotTable instance.
1957
- *
1958
- * @param {React.ReactNode} [children] Children of the HotTable instance. Defaults to `this.props.children`.
1959
- * @returns {React.ReactElement} React editor component element.
1960
- */
1961
- }, {
1962
- key: "getGlobalEditorElement",
1963
- value: function getGlobalEditorElement() {
1964
- return getExtendedEditorElement(this.props.children, this.getEditorCache());
1898
+ return null;
1899
+ }, [hotElementRef]);
1900
+ /**
1901
+ * Create a new settings object containing the column settings and global editors and renderers.
1902
+ *
1903
+ * @returns {Handsontable.GridSettings} New global set of settings for Handsontable.
1904
+ */
1905
+ var createNewGlobalSettings = function createNewGlobalSettings() {
1906
+ var newSettings = SettingsMapper.getSettings(props);
1907
+ newSettings.columns = context.columnsSettings.length ? context.columnsSettings : newSettings.columns;
1908
+ if (props.renderer) {
1909
+ newSettings.renderer = context.getRendererWrapper(props.renderer);
1910
+ context.componentRendererColumns.set('global', true);
1911
+ } else {
1912
+ newSettings.renderer = props.hotRenderer || registry.getRenderer('text');
1965
1913
  }
1966
- /**
1967
- * Create a new settings object containing the column settings and global editors and renderers.
1968
- *
1969
- * @returns {Handsontable.GridSettings} New global set of settings for Handsontable.
1970
- */
1971
- }, {
1972
- key: "createNewGlobalSettings",
1973
- value: function createNewGlobalSettings() {
1974
- var newSettings = SettingsMapper.getSettings(this.props);
1975
- var globalRendererNode = this.getGlobalRendererElement();
1976
- var globalEditorNode = this.getGlobalEditorElement();
1977
- newSettings.columns = this.columnSettings.length ? this.columnSettings : newSettings.columns;
1978
- if (globalEditorNode) {
1979
- newSettings.editor = this.getEditorClass(globalEditorNode, GLOBAL_EDITOR_SCOPE);
1980
- } else {
1981
- var _this$props$settings;
1982
- if (this.props.editor || (_this$props$settings = this.props.settings) !== null && _this$props$settings !== void 0 && _this$props$settings.editor) {
1983
- newSettings.editor = this.props.editor || this.props.settings.editor;
1984
- } else {
1985
- newSettings.editor = registry.getEditor('text');
1986
- }
1987
- }
1988
- if (globalRendererNode) {
1989
- newSettings.renderer = this.getRendererWrapper(globalRendererNode);
1990
- this.componentRendererColumns.set('global', true);
1991
- } else {
1992
- var _this$props$settings2;
1993
- if (this.props.renderer || (_this$props$settings2 = this.props.settings) !== null && _this$props$settings2 !== void 0 && _this$props$settings2.renderer) {
1994
- newSettings.renderer = this.props.renderer || this.props.settings.renderer;
1995
- } else {
1996
- newSettings.renderer = registry$1.getRenderer('text');
1997
- }
1998
- }
1999
- return newSettings;
1914
+ if (props.editor) {
1915
+ newSettings.editor = makeEditorClass(globalEditorHooksRef, globalEditorClassInstance);
1916
+ } else {
1917
+ newSettings.editor = props.hotEditor || registry$1.getEditor('text');
2000
1918
  }
2001
- /**
2002
- * Detect if `autoRowSize` or `autoColumnSize` is defined, and if so, throw an incompatibility warning.
2003
- *
2004
- * @param {Handsontable.GridSettings} newGlobalSettings New global settings passed as Handsontable config.
2005
- */
2006
- }, {
2007
- key: "displayAutoSizeWarning",
2008
- value: function displayAutoSizeWarning(newGlobalSettings) {
2009
- var _this$hotInstance$get, _this$hotInstance$get2;
2010
- if (this.hotInstance && ((_this$hotInstance$get = this.hotInstance.getPlugin('autoRowSize')) !== null && _this$hotInstance$get !== void 0 && _this$hotInstance$get.enabled || (_this$hotInstance$get2 = this.hotInstance.getPlugin('autoColumnSize')) !== null && _this$hotInstance$get2 !== void 0 && _this$hotInstance$get2.enabled)) {
2011
- if (this.componentRendererColumns.size > 0) {
2012
- warn(AUTOSIZE_WARNING);
2013
- }
1919
+ return newSettings;
1920
+ };
1921
+ /**
1922
+ * Detect if `autoRowSize` or `autoColumnSize` is defined, and if so, throw an incompatibility warning.
1923
+ */
1924
+ var displayAutoSizeWarning = function displayAutoSizeWarning(hotInstance) {
1925
+ var _hotInstance$getPlugi, _hotInstance$getPlugi2;
1926
+ if (hotInstance && ((_hotInstance$getPlugi = hotInstance.getPlugin('autoRowSize')) !== null && _hotInstance$getPlugi !== void 0 && _hotInstance$getPlugi.enabled || (_hotInstance$getPlugi2 = hotInstance.getPlugin('autoColumnSize')) !== null && _hotInstance$getPlugi2 !== void 0 && _hotInstance$getPlugi2.enabled)) {
1927
+ if (context.componentRendererColumns.size > 0) {
1928
+ warn(AUTOSIZE_WARNING);
2014
1929
  }
2015
1930
  }
2016
- /**
2017
- * Sets the column settings based on information received from HotColumn.
2018
- *
2019
- * @param {HotTableProps} columnSettings Column settings object.
2020
- * @param {Number} columnIndex Column index.
2021
- */
2022
- }, {
2023
- key: "setHotColumnSettings",
2024
- value: function setHotColumnSettings(columnSettings, columnIndex) {
2025
- this.columnSettings[columnIndex] = columnSettings;
2026
- }
1931
+ };
1932
+ /**
1933
+ * Initialize Handsontable after the component has mounted.
1934
+ */
1935
+ React__default["default"].useEffect(function () {
1936
+ var newGlobalSettings = createNewGlobalSettings();
1937
+ __hotInstance.current = new Handsontable__default["default"].Core(hotElementRef.current, newGlobalSettings);
2027
1938
  /**
2028
1939
  * Handsontable's `beforeViewRender` hook callback.
2029
1940
  */
2030
- }, {
2031
- key: "handsontableBeforeViewRender",
2032
- value: function handsontableBeforeViewRender() {
2033
- this.portalCache.clear();
2034
- this.getRenderedCellCache().clear();
2035
- }
1941
+ __hotInstance.current.addHook('beforeViewRender', function () {
1942
+ context.clearPortalCache();
1943
+ context.clearRenderedCellCache();
1944
+ });
2036
1945
  /**
2037
1946
  * Handsontable's `afterViewRender` hook callback.
2038
1947
  */
2039
- }, {
2040
- key: "handsontableAfterViewRender",
2041
- value: function handsontableAfterViewRender() {
2042
- this.renderersPortalManager.setState({
2043
- portals: _toConsumableArray(this.portalCache.values())
2044
- });
2045
- }
2046
- /**
2047
- * Call the `updateSettings` method for the Handsontable instance.
2048
- *
2049
- * @param {Object} newSettings The settings object.
2050
- */
2051
- }, {
2052
- key: "updateHot",
2053
- value: function updateHot(newSettings) {
2054
- if (this.hotInstance) {
2055
- this.hotInstance.updateSettings(newSettings, false);
2056
- }
2057
- }
2058
- /**
2059
- * Set the renderers portal manager ref.
2060
- *
2061
- * @param {React.ReactComponent} pmComponent The PortalManager component.
2062
- */
2063
- }, {
2064
- key: "setRenderersPortalManagerRef",
2065
- value: function setRenderersPortalManagerRef(pmComponent) {
2066
- this.renderersPortalManager = pmComponent;
2067
- }
2068
- /*
2069
- ---------------------------------------
2070
- ------- React lifecycle methods -------
2071
- ---------------------------------------
2072
- */
2073
- /**
2074
- * Initialize Handsontable after the component has mounted.
2075
- */
2076
- }, {
2077
- key: "componentDidMount",
2078
- value: function componentDidMount() {
2079
- var _this3 = this;
2080
- var newGlobalSettings = this.createNewGlobalSettings();
2081
- this.hotInstance = new Handsontable__default["default"].Core(this.hotElementRef, newGlobalSettings);
2082
- this.hotInstance.addHook('beforeViewRender', function () {
2083
- return _this3.handsontableBeforeViewRender();
2084
- });
2085
- this.hotInstance.addHook('afterViewRender', function () {
2086
- return _this3.handsontableAfterViewRender();
2087
- });
2088
- // `init` missing in Handsontable's type definitions.
2089
- this.hotInstance.init();
2090
- this.displayAutoSizeWarning(newGlobalSettings);
2091
- }
2092
- /**
2093
- * Logic performed after the component update.
2094
- */
2095
- }, {
2096
- key: "componentDidUpdate",
2097
- value: function componentDidUpdate() {
2098
- this.clearCache();
2099
- var newGlobalSettings = this.createNewGlobalSettings();
2100
- this.updateHot(newGlobalSettings);
2101
- this.displayAutoSizeWarning(newGlobalSettings);
1948
+ __hotInstance.current.addHook('afterViewRender', function () {
1949
+ context.pushCellPortalsIntoPortalManager();
1950
+ });
1951
+ __hotInstance.current.init();
1952
+ displayAutoSizeWarning(__hotInstance.current);
1953
+ if (!displayObsoleteRenderersEditorsWarning(props.children)) {
1954
+ displayChildrenOfTypeWarning(props.children, HotColumn);
2102
1955
  }
2103
1956
  /**
2104
1957
  * Destroy the Handsontable instance when the parent component unmounts.
2105
1958
  */
2106
- }, {
2107
- key: "componentWillUnmount",
2108
- value: function componentWillUnmount() {
2109
- this.clearCache();
2110
- if (this.hotInstance) {
2111
- this.hotInstance.destroy();
1959
+ return function () {
1960
+ var _getHotInstance;
1961
+ clearCache();
1962
+ (_getHotInstance = getHotInstance()) === null || _getHotInstance === void 0 || _getHotInstance.destroy();
1963
+ };
1964
+ }, []);
1965
+ /**
1966
+ * Logic performed after the component update.
1967
+ */
1968
+ useUpdateEffect(function () {
1969
+ clearCache();
1970
+ var hotInstance = getHotInstance();
1971
+ var newGlobalSettings = createNewGlobalSettings();
1972
+ hotInstance === null || hotInstance === void 0 || hotInstance.updateSettings(newGlobalSettings, false);
1973
+ displayAutoSizeWarning(hotInstance);
1974
+ displayObsoleteRenderersEditorsWarning(props.children);
1975
+ });
1976
+ /**
1977
+ * Interface exposed to parent components by HotTable instance via React ref
1978
+ */
1979
+ React__default["default"].useImperativeHandle(ref, function () {
1980
+ return {
1981
+ get hotElementRef() {
1982
+ return hotElementRef.current;
1983
+ },
1984
+ get hotInstance() {
1985
+ return getHotInstance();
2112
1986
  }
2113
- }
2114
- /**
2115
- * Render the component.
2116
- */
2117
- }, {
2118
- key: "render",
2119
- value: function render() {
2120
- var _this4 = this;
2121
- var isHotColumn = function isHotColumn(childNode) {
2122
- return childNode.type === HotColumn;
2123
- };
2124
- var children = React__default["default"].Children.toArray(this.props.children);
2125
- // clone the HotColumn nodes and extend them with the callbacks
2126
- var hotColumnClones = children.filter(function (childNode) {
2127
- return isHotColumn(childNode);
2128
- }).map(function (childNode, columnIndex) {
2129
- return React__default["default"].cloneElement(childNode, {
2130
- _componentRendererColumns: _this4.componentRendererColumns,
2131
- _emitColumnSettings: _this4.setHotColumnSettings.bind(_this4),
2132
- _columnIndex: columnIndex,
2133
- _getChildElementByType: getChildElementByType.bind(_this4),
2134
- _getRendererWrapper: _this4.getRendererWrapper.bind(_this4),
2135
- _getEditorClass: _this4.getEditorClass.bind(_this4),
2136
- _getOwnerDocument: _this4.getOwnerDocument.bind(_this4),
2137
- _getEditorCache: _this4.getEditorCache.bind(_this4),
2138
- children: childNode.props.children
2139
- });
2140
- });
2141
- var containerProps = getContainerAttributesProps(this.props);
2142
- var editorPortal = createEditorPortal(this.getOwnerDocument(), this.getGlobalEditorElement());
2143
- return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", Object.assign({
2144
- ref: this.setHotElementRef.bind(this)
2145
- }, containerProps), hotColumnClones), React__default["default"].createElement(RenderersPortalManager, {
2146
- ref: this.setRenderersPortalManagerRef.bind(this)
2147
- }), editorPortal);
2148
- }
2149
- }], [{
2150
- key: "version",
2151
- get: function get() {
2152
- return version;
2153
- }
2154
- }]);
2155
- return HotTableClass;
2156
- }(React__default["default"].Component);
1987
+ };
1988
+ });
1989
+ /**
1990
+ * Render the component.
1991
+ */
1992
+ var hotColumnWrapped = React__default["default"].Children.toArray(props.children).filter(isHotColumn).map(function (childNode, columnIndex) {
1993
+ return React__default["default"].createElement(HotColumnContextProvider, {
1994
+ columnIndex: columnIndex,
1995
+ getOwnerDocument: getOwnerDocument,
1996
+ key: columnIndex
1997
+ }, childNode);
1998
+ });
1999
+ var containerProps = getContainerAttributesProps(props);
2000
+ var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
2001
+ return React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement("div", Object.assign({
2002
+ ref: hotElementRef
2003
+ }, containerProps), hotColumnWrapped), React__default["default"].createElement(RenderersPortalManager, {
2004
+ ref: context.setRenderersPortalManagerRef
2005
+ }), React__default["default"].createElement(EditorContextProvider, {
2006
+ hooksRef: globalEditorHooksRef,
2007
+ hotCustomEditorInstanceRef: globalEditorClassInstance
2008
+ }, editorPortal));
2009
+ });
2157
2010
  /**
2158
2011
  * Prop types to be checked at runtime.
2159
2012
  */
2160
- HotTableClass.propTypes = {
2013
+ HotTableInner.propTypes = {
2161
2014
  style: PropTypes.object,
2162
2015
  id: PropTypes.string,
2163
2016
  className: PropTypes.string
2164
2017
  };
2165
2018
 
2166
2019
  var _excluded = ["children"];
2167
- // Use global React variable for `forwardRef` access (React 16 support)
2020
+ /**
2021
+ * A Handsontable-ReactJS wrapper.
2022
+ *
2023
+ * To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
2024
+ * For example:
2025
+ *
2026
+ * ```js
2027
+ * <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
2028
+ *
2029
+ * // is analogous to
2030
+ * let hot = new Handsontable(document.getElementById('hot'), {
2031
+ * data: dataObject,
2032
+ * contextMenu: true,
2033
+ * colHeaders: true,
2034
+ * width: 600
2035
+ * height: 300
2036
+ * });
2037
+ *
2038
+ * ```
2039
+ */
2168
2040
  var HotTable = React__default["default"].forwardRef(function (_ref, ref) {
2169
2041
  var _props$id;
2170
2042
  var children = _ref.children,
2171
2043
  props = _objectWithoutProperties(_ref, _excluded);
2172
2044
  var generatedId = typeof React__default["default"].useId === 'function' ? React__default["default"].useId() : undefined;
2173
2045
  var componentId = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : generatedId;
2174
- return React__default["default"].createElement(HotTableClass, Object.assign({
2046
+ return React__default["default"].createElement(HotTableContextProvider, null, React__default["default"].createElement(HotTableInner, Object.assign({
2175
2047
  id: componentId
2176
2048
  }, props, {
2177
2049
  ref: ref
2178
- }), children);
2050
+ }), children));
2179
2051
  });
2180
- HotTable.version = HotTableClass.version;
2181
-
2182
- var BaseEditorComponent = /*#__PURE__*/function (_React$Component) {
2183
- _inherits(BaseEditorComponent, _React$Component);
2184
- function BaseEditorComponent() {
2185
- var _this;
2186
- _classCallCheck(this, BaseEditorComponent);
2187
- _this = _callSuper(this, BaseEditorComponent, arguments);
2188
- _this.name = 'BaseEditorComponent';
2189
- _this.instance = null;
2190
- _this.row = null;
2191
- _this.col = null;
2192
- _this.prop = null;
2193
- _this.TD = null;
2194
- _this.originalValue = null;
2195
- _this.cellProperties = null;
2196
- _this.state = null;
2197
- _this.hotInstance = null;
2198
- _this.hotCustomEditorInstance = null;
2199
- _this.hot = null;
2200
- return _this;
2201
- }
2202
- _createClass(BaseEditorComponent, [{
2203
- key: "componentDidMount",
2204
- value: function componentDidMount() {
2205
- if (this.props.emitEditorInstance) {
2206
- this.props.emitEditorInstance(this, this.props.editorColumnScope);
2207
- }
2208
- }
2209
- }, {
2210
- key: "componentDidUpdate",
2211
- value: function componentDidUpdate() {
2212
- if (this.props.emitEditorInstance) {
2213
- this.props.emitEditorInstance(this, this.props.editorColumnScope);
2214
- }
2215
- }
2216
- // BaseEditor methods:
2217
- }, {
2218
- key: "_fireCallbacks",
2219
- value: function _fireCallbacks() {
2220
- var _Handsontable$editors;
2221
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2222
- args[_key] = arguments[_key];
2223
- }
2224
- (_Handsontable$editors = Handsontable__default["default"].editors.BaseEditor.prototype._fireCallbacks).call.apply(_Handsontable$editors, [this.hotCustomEditorInstance].concat(args));
2225
- }
2226
- }, {
2227
- key: "beginEditing",
2228
- value: function beginEditing() {
2229
- var _Handsontable$editors2;
2230
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2231
- args[_key2] = arguments[_key2];
2232
- }
2233
- return (_Handsontable$editors2 = Handsontable__default["default"].editors.BaseEditor.prototype.beginEditing).call.apply(_Handsontable$editors2, [this.hotCustomEditorInstance].concat(args));
2234
- }
2235
- }, {
2236
- key: "cancelChanges",
2237
- value: function cancelChanges() {
2238
- var _Handsontable$editors3;
2239
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
2240
- args[_key3] = arguments[_key3];
2241
- }
2242
- return (_Handsontable$editors3 = Handsontable__default["default"].editors.BaseEditor.prototype.cancelChanges).call.apply(_Handsontable$editors3, [this.hotCustomEditorInstance].concat(args));
2243
- }
2244
- }, {
2245
- key: "checkEditorSection",
2246
- value: function checkEditorSection() {
2247
- var _Handsontable$editors4;
2248
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2249
- args[_key4] = arguments[_key4];
2250
- }
2251
- return (_Handsontable$editors4 = Handsontable__default["default"].editors.BaseEditor.prototype.checkEditorSection).call.apply(_Handsontable$editors4, [this.hotCustomEditorInstance].concat(args));
2252
- }
2253
- }, {
2254
- key: "close",
2255
- value: function close() {
2256
- var _Handsontable$editors5;
2257
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
2258
- args[_key5] = arguments[_key5];
2259
- }
2260
- return (_Handsontable$editors5 = Handsontable__default["default"].editors.BaseEditor.prototype.close).call.apply(_Handsontable$editors5, [this.hotCustomEditorInstance].concat(args));
2261
- }
2262
- }, {
2263
- key: "discardEditor",
2264
- value: function discardEditor() {
2265
- var _Handsontable$editors6;
2266
- for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
2267
- args[_key6] = arguments[_key6];
2268
- }
2269
- return (_Handsontable$editors6 = Handsontable__default["default"].editors.BaseEditor.prototype.discardEditor).call.apply(_Handsontable$editors6, [this.hotCustomEditorInstance].concat(args));
2270
- }
2271
- }, {
2272
- key: "enableFullEditMode",
2273
- value: function enableFullEditMode() {
2274
- var _Handsontable$editors7;
2275
- for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
2276
- args[_key7] = arguments[_key7];
2277
- }
2278
- return (_Handsontable$editors7 = Handsontable__default["default"].editors.BaseEditor.prototype.enableFullEditMode).call.apply(_Handsontable$editors7, [this.hotCustomEditorInstance].concat(args));
2279
- }
2280
- }, {
2281
- key: "extend",
2282
- value: function extend() {
2283
- var _Handsontable$editors8;
2284
- for (var _len8 = arguments.length, args = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
2285
- args[_key8] = arguments[_key8];
2286
- }
2287
- return (_Handsontable$editors8 = Handsontable__default["default"].editors.BaseEditor.prototype.extend).call.apply(_Handsontable$editors8, [this.hotCustomEditorInstance].concat(args));
2288
- }
2289
- }, {
2290
- key: "finishEditing",
2291
- value: function finishEditing() {
2292
- var _Handsontable$editors9;
2293
- for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
2294
- args[_key9] = arguments[_key9];
2295
- }
2296
- return (_Handsontable$editors9 = Handsontable__default["default"].editors.BaseEditor.prototype.finishEditing).call.apply(_Handsontable$editors9, [this.hotCustomEditorInstance].concat(args));
2297
- }
2298
- }, {
2299
- key: "focus",
2300
- value: function focus() {
2301
- var _Handsontable$editors10;
2302
- for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
2303
- args[_key10] = arguments[_key10];
2304
- }
2305
- return (_Handsontable$editors10 = Handsontable__default["default"].editors.BaseEditor.prototype.focus).call.apply(_Handsontable$editors10, [this.hotCustomEditorInstance].concat(args));
2306
- }
2307
- }, {
2308
- key: "getValue",
2309
- value: function getValue() {
2310
- var _Handsontable$editors11;
2311
- for (var _len11 = arguments.length, args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
2312
- args[_key11] = arguments[_key11];
2313
- }
2314
- return (_Handsontable$editors11 = Handsontable__default["default"].editors.BaseEditor.prototype.getValue).call.apply(_Handsontable$editors11, [this.hotCustomEditorInstance].concat(args));
2315
- }
2316
- }, {
2317
- key: "init",
2318
- value: function init() {
2319
- var _Handsontable$editors12;
2320
- for (var _len12 = arguments.length, args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
2321
- args[_key12] = arguments[_key12];
2322
- }
2323
- return (_Handsontable$editors12 = Handsontable__default["default"].editors.BaseEditor.prototype.init).call.apply(_Handsontable$editors12, [this.hotCustomEditorInstance].concat(args));
2324
- }
2325
- }, {
2326
- key: "isInFullEditMode",
2327
- value: function isInFullEditMode() {
2328
- var _Handsontable$editors13;
2329
- for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
2330
- args[_key13] = arguments[_key13];
2331
- }
2332
- return (_Handsontable$editors13 = Handsontable__default["default"].editors.BaseEditor.prototype.isInFullEditMode).call.apply(_Handsontable$editors13, [this.hotCustomEditorInstance].concat(args));
2333
- }
2334
- }, {
2335
- key: "isOpened",
2336
- value: function isOpened() {
2337
- var _Handsontable$editors14;
2338
- for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
2339
- args[_key14] = arguments[_key14];
2340
- }
2341
- return (_Handsontable$editors14 = Handsontable__default["default"].editors.BaseEditor.prototype.isOpened).call.apply(_Handsontable$editors14, [this.hotCustomEditorInstance].concat(args));
2342
- }
2343
- }, {
2344
- key: "isWaiting",
2345
- value: function isWaiting() {
2346
- var _Handsontable$editors15;
2347
- for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
2348
- args[_key15] = arguments[_key15];
2349
- }
2350
- return (_Handsontable$editors15 = Handsontable__default["default"].editors.BaseEditor.prototype.isWaiting).call.apply(_Handsontable$editors15, [this.hotCustomEditorInstance].concat(args));
2351
- }
2352
- }, {
2353
- key: "open",
2354
- value: function open() {
2355
- var _Handsontable$editors16;
2356
- for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
2357
- args[_key16] = arguments[_key16];
2358
- }
2359
- return (_Handsontable$editors16 = Handsontable__default["default"].editors.BaseEditor.prototype.open).call.apply(_Handsontable$editors16, [this.hotCustomEditorInstance].concat(args));
2360
- }
2361
- }, {
2362
- key: "prepare",
2363
- value: function prepare(row, col, prop, TD, originalValue, cellProperties) {
2364
- this.hotInstance = cellProperties.instance;
2365
- this.row = row;
2366
- this.col = col;
2367
- this.prop = prop;
2368
- this.TD = TD;
2369
- this.originalValue = originalValue;
2370
- this.cellProperties = cellProperties;
2371
- return Handsontable__default["default"].editors.BaseEditor.prototype.prepare.call(this.hotCustomEditorInstance, row, col, prop, TD, originalValue, cellProperties);
2372
- }
2373
- }, {
2374
- key: "saveValue",
2375
- value: function saveValue() {
2376
- var _Handsontable$editors17;
2377
- for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
2378
- args[_key17] = arguments[_key17];
2379
- }
2380
- return (_Handsontable$editors17 = Handsontable__default["default"].editors.BaseEditor.prototype.saveValue).call.apply(_Handsontable$editors17, [this.hotCustomEditorInstance].concat(args));
2381
- }
2382
- }, {
2383
- key: "setValue",
2384
- value: function setValue() {
2385
- var _Handsontable$editors18;
2386
- for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
2387
- args[_key18] = arguments[_key18];
2388
- }
2389
- return (_Handsontable$editors18 = Handsontable__default["default"].editors.BaseEditor.prototype.setValue).call.apply(_Handsontable$editors18, [this.hotCustomEditorInstance].concat(args));
2390
- }
2391
- }, {
2392
- key: "addHook",
2393
- value: function addHook() {
2394
- var _Handsontable$editors19;
2395
- for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
2396
- args[_key19] = arguments[_key19];
2397
- }
2398
- return (_Handsontable$editors19 = Handsontable__default["default"].editors.BaseEditor.prototype.addHook).call.apply(_Handsontable$editors19, [this.hotCustomEditorInstance].concat(args));
2399
- }
2400
- }, {
2401
- key: "removeHooksByKey",
2402
- value: function removeHooksByKey() {
2403
- var _Handsontable$editors20;
2404
- for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
2405
- args[_key20] = arguments[_key20];
2406
- }
2407
- return (_Handsontable$editors20 = Handsontable__default["default"].editors.BaseEditor.prototype.removeHooksByKey).call.apply(_Handsontable$editors20, [this.hotCustomEditorInstance].concat(args));
2408
- }
2409
- }, {
2410
- key: "clearHooks",
2411
- value: function clearHooks() {
2412
- var _Handsontable$editors21;
2413
- for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
2414
- args[_key21] = arguments[_key21];
2415
- }
2416
- return (_Handsontable$editors21 = Handsontable__default["default"].editors.BaseEditor.prototype.clearHooks).call.apply(_Handsontable$editors21, [this.hotCustomEditorInstance].concat(args));
2417
- }
2418
- }, {
2419
- key: "getEditedCell",
2420
- value: function getEditedCell() {
2421
- var _Handsontable$editors22;
2422
- for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
2423
- args[_key22] = arguments[_key22];
2424
- }
2425
- return (_Handsontable$editors22 = Handsontable__default["default"].editors.BaseEditor.prototype.getEditedCell).call.apply(_Handsontable$editors22, [this.hotCustomEditorInstance].concat(args));
2426
- }
2427
- }, {
2428
- key: "getEditedCellRect",
2429
- value: function getEditedCellRect() {
2430
- var _Handsontable$editors23;
2431
- for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
2432
- args[_key23] = arguments[_key23];
2433
- }
2434
- return (_Handsontable$editors23 = Handsontable__default["default"].editors.BaseEditor.prototype.getEditedCellRect).call.apply(_Handsontable$editors23, [this.hotCustomEditorInstance].concat(args));
2435
- }
2436
- }, {
2437
- key: "getEditedCellsZIndex",
2438
- value: function getEditedCellsZIndex() {
2439
- var _Handsontable$editors24;
2440
- for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
2441
- args[_key24] = arguments[_key24];
2442
- }
2443
- return (_Handsontable$editors24 = Handsontable__default["default"].editors.BaseEditor.prototype.getEditedCellsZIndex).call.apply(_Handsontable$editors24, [this.hotCustomEditorInstance].concat(args));
2444
- }
2445
- }]);
2446
- return BaseEditorComponent;
2447
- }(React__default["default"].Component);
2052
+ /**
2053
+ * Package version.
2054
+ *
2055
+ * @returns The version number of the package.
2056
+ */
2057
+ HotTable.version = version;
2448
2058
 
2449
- exports.BaseEditorComponent = BaseEditorComponent;
2450
2059
  exports.HotColumn = HotColumn;
2451
2060
  exports.HotTable = HotTable;
2452
- exports.HotTableClass = HotTableClass;
2453
2061
  exports["default"] = HotTable;
2062
+ exports.isHotColumn = isHotColumn;
2063
+ exports.useHotEditor = useHotEditor;