@handsontable/react-wrapper 17.0.1 → 17.1.0-rc1
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.
- package/commonjs/react-handsontable.js +482 -343
- package/dist/react-handsontable.js +492 -344
- package/dist/react-handsontable.js.map +1 -1
- package/dist/react-handsontable.min.js +2 -2
- package/dist/react-handsontable.min.js.map +1 -1
- package/es/react-handsontable.mjs +483 -344
- package/helpers.d.ts +113 -105
- package/hotColumn.d.ts +5 -5
- package/hotColumnContext.d.ts +16 -16
- package/hotEditor.d.ts +73 -73
- package/hotTable.d.ts +29 -29
- package/hotTableContext.d.ts +55 -55
- package/hotTableInner.d.ts +5 -5
- package/index.d.ts +5 -5
- package/package.json +3 -4
- package/renderersPortalManager.d.ts +6 -6
- package/settingsMapper.d.ts +18 -18
- package/types.d.ts +78 -78
|
@@ -1,193 +1,9 @@
|
|
|
1
|
-
import React, { useEffect,
|
|
1
|
+
import React, { useEffect, useContext, createContext, useRef, useCallback, useMemo, useState, useDeferredValue, useImperativeHandle, forwardRef, Fragment, Children, useId } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import Handsontable from 'handsontable/base';
|
|
4
4
|
import { getRenderer } from 'handsontable/renderers/registry';
|
|
5
5
|
import { getEditor } from 'handsontable/editors/registry';
|
|
6
6
|
|
|
7
|
-
var bulkComponentContainer = null;
|
|
8
|
-
/**
|
|
9
|
-
* Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
|
|
10
|
-
*/
|
|
11
|
-
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.';
|
|
12
|
-
/**
|
|
13
|
-
* Warning message for the `hot-renderer` obsolete renderer passing method.
|
|
14
|
-
*/
|
|
15
|
-
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.';
|
|
16
|
-
/**
|
|
17
|
-
* Warning message for the `hot-editor` obsolete editor passing method.
|
|
18
|
-
*/
|
|
19
|
-
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.';
|
|
20
|
-
/**
|
|
21
|
-
* Warning message for the unexpected children of HotTable component.
|
|
22
|
-
*/
|
|
23
|
-
var UNEXPECTED_HOTTABLE_CHILDREN_WARNING = 'Unexpected children nodes found in HotTable component. ' + 'Only HotColumn components are allowed.';
|
|
24
|
-
/**
|
|
25
|
-
* Warning message for the unexpected children of HotColumn component.
|
|
26
|
-
*/
|
|
27
|
-
var UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING = 'Unexpected children nodes found in HotColumn component. ' + 'HotColumn components do not support any children.';
|
|
28
|
-
/**
|
|
29
|
-
* Message for the warning thrown if the Handsontable instance has been destroyed.
|
|
30
|
-
*/
|
|
31
|
-
var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.';
|
|
32
|
-
/**
|
|
33
|
-
* Default classname given to the wrapper container.
|
|
34
|
-
*/
|
|
35
|
-
var DEFAULT_CLASSNAME = 'hot-wrapper-editor-container';
|
|
36
|
-
/**
|
|
37
|
-
* Logs warn to the console if the `console` object is exposed.
|
|
38
|
-
*
|
|
39
|
-
* @param {...*} args Values which will be logged.
|
|
40
|
-
*/
|
|
41
|
-
function warn() {
|
|
42
|
-
if (typeof console !== 'undefined') {
|
|
43
|
-
var _console;
|
|
44
|
-
(_console = console).warn.apply(_console, arguments);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Detect if `hot-renderer` or `hot-editor` is defined, and if so, throw an incompatibility warning.
|
|
49
|
-
*
|
|
50
|
-
* @returns {boolean} 'true' if the warning was issued
|
|
51
|
-
*/
|
|
52
|
-
function displayObsoleteRenderersEditorsWarning(children) {
|
|
53
|
-
if (hasChildElementOfType(children, 'hot-renderer')) {
|
|
54
|
-
warn(OBSOLETE_HOTRENDERER_WARNING);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
if (hasChildElementOfType(children, 'hot-editor')) {
|
|
58
|
-
warn(OBSOLETE_HOTEDITOR_WARNING);
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Detect if children of specified type are defined, and if so, throw an incompatibility warning.
|
|
65
|
-
*
|
|
66
|
-
* @param {ReactNode} children Component children nodes
|
|
67
|
-
* @param {ComponentType} Component Component type to check
|
|
68
|
-
* @returns {boolean} 'true' if the warning was issued
|
|
69
|
-
*/
|
|
70
|
-
function displayChildrenOfTypeWarning(children, Component) {
|
|
71
|
-
var childrenArray = React.Children.toArray(children);
|
|
72
|
-
if (childrenArray.some(function (child) {
|
|
73
|
-
return child.type !== Component;
|
|
74
|
-
})) {
|
|
75
|
-
warn(UNEXPECTED_HOTTABLE_CHILDREN_WARNING);
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Detect if children is defined, and if so, throw an incompatibility warning.
|
|
82
|
-
*
|
|
83
|
-
* @param {ReactNode} children Component children nodes
|
|
84
|
-
* @returns {boolean} 'true' if the warning was issued
|
|
85
|
-
*/
|
|
86
|
-
function displayAnyChildrenWarning(children) {
|
|
87
|
-
var childrenArray = React.Children.toArray(children);
|
|
88
|
-
if (childrenArray.length) {
|
|
89
|
-
warn(UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING);
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Check the existence of elements of the provided `type` from the `HotColumn` component's children.
|
|
96
|
-
*
|
|
97
|
-
* @param {ReactNode} children HotTable children array.
|
|
98
|
-
* @param {String} type Either `'hot-renderer'` or `'hot-editor'`.
|
|
99
|
-
* @returns {boolean} `true` if the child of that type was found, `false` otherwise.
|
|
100
|
-
*/
|
|
101
|
-
function hasChildElementOfType(children, type) {
|
|
102
|
-
var childrenArray = React.Children.toArray(children);
|
|
103
|
-
return childrenArray.some(function (child) {
|
|
104
|
-
return child.props[type] !== void 0;
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Create an editor portal.
|
|
109
|
-
*
|
|
110
|
-
* @param {Document} doc Document to be used.
|
|
111
|
-
* @param {ComponentType} Editor Editor component or render function.
|
|
112
|
-
* @returns {ReactPortal} The portal for the editor.
|
|
113
|
-
*/
|
|
114
|
-
function createEditorPortal(doc, Editor) {
|
|
115
|
-
if (!doc || !Editor || typeof Editor === 'boolean') {
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
var editorElement = React.createElement(Editor, null);
|
|
119
|
-
var containerProps = getContainerAttributesProps({}, false);
|
|
120
|
-
containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
|
|
121
|
-
return ReactDOM.createPortal(React.createElement("div", Object.assign({}, containerProps), editorElement), doc.body);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Render a cell component to an external DOM node.
|
|
125
|
-
*
|
|
126
|
-
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
127
|
-
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
128
|
-
* @param {String} portalKey The key to be used for the portal.
|
|
129
|
-
* @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
|
|
130
|
-
* @returns {{portal: ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
|
131
|
-
*/
|
|
132
|
-
function createPortal(rElement) {
|
|
133
|
-
var ownerDocument = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
134
|
-
var portalKey = arguments.length > 2 ? arguments[2] : undefined;
|
|
135
|
-
var cachedContainer = arguments.length > 3 ? arguments[3] : undefined;
|
|
136
|
-
if (!ownerDocument) {
|
|
137
|
-
ownerDocument = document;
|
|
138
|
-
}
|
|
139
|
-
if (!bulkComponentContainer) {
|
|
140
|
-
bulkComponentContainer = ownerDocument.createDocumentFragment();
|
|
141
|
-
}
|
|
142
|
-
var portalContainer = cachedContainer !== null && cachedContainer !== void 0 ? cachedContainer : ownerDocument.createElement('DIV');
|
|
143
|
-
bulkComponentContainer.appendChild(portalContainer);
|
|
144
|
-
return {
|
|
145
|
-
portal: ReactDOM.createPortal(rElement, portalContainer, portalKey),
|
|
146
|
-
portalContainer: portalContainer
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Get an object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
151
|
-
* component.
|
|
152
|
-
*
|
|
153
|
-
* @param {HotTableProps} props Object containing the React element props.
|
|
154
|
-
* @param {Boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was present in the `prop` object.
|
|
155
|
-
* @returns An object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
156
|
-
* component.
|
|
157
|
-
*/
|
|
158
|
-
function getContainerAttributesProps(props) {
|
|
159
|
-
var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
160
|
-
return {
|
|
161
|
-
id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : undefined),
|
|
162
|
-
className: props.className || '',
|
|
163
|
-
style: props.style || {}
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Checks if the environment that the code runs in is a browser.
|
|
168
|
-
*
|
|
169
|
-
* @returns {boolean}
|
|
170
|
-
*/
|
|
171
|
-
function isCSR() {
|
|
172
|
-
return typeof window !== 'undefined';
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* A variant of useEffect hook that does not trigger on initial mount, only updates
|
|
176
|
-
*
|
|
177
|
-
* @param effect Effect function
|
|
178
|
-
* @param deps Effect dependencies
|
|
179
|
-
*/
|
|
180
|
-
function useUpdateEffect(effect, deps) {
|
|
181
|
-
var notInitialRender = React.useRef(false);
|
|
182
|
-
useEffect(function () {
|
|
183
|
-
if (notInitialRender.current) {
|
|
184
|
-
return effect();
|
|
185
|
-
} else {
|
|
186
|
-
notInitialRender.current = true;
|
|
187
|
-
}
|
|
188
|
-
}, deps);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
7
|
function _arrayLikeToArray(r, a) {
|
|
192
8
|
(null == a || a > r.length) && (a = r.length);
|
|
193
9
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -228,6 +44,15 @@ function _defineProperty(e, r, t) {
|
|
|
228
44
|
writable: true
|
|
229
45
|
}) : e[r] = t, e;
|
|
230
46
|
}
|
|
47
|
+
function _extends() {
|
|
48
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
49
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
50
|
+
var t = arguments[e];
|
|
51
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
52
|
+
}
|
|
53
|
+
return n;
|
|
54
|
+
}, _extends.apply(null, arguments);
|
|
55
|
+
}
|
|
231
56
|
function _getPrototypeOf(t) {
|
|
232
57
|
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
233
58
|
return t.__proto__ || Object.getPrototypeOf(t);
|
|
@@ -374,6 +199,281 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
374
199
|
}
|
|
375
200
|
}
|
|
376
201
|
|
|
202
|
+
var bulkComponentContainer = null;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
|
|
206
|
+
*/
|
|
207
|
+
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.';
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Warning message for the `hot-renderer` obsolete renderer passing method.
|
|
211
|
+
*/
|
|
212
|
+
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.';
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Warning message for the `hot-editor` obsolete editor passing method.
|
|
216
|
+
*/
|
|
217
|
+
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.';
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Warning message for the unexpected children of HotTable component.
|
|
221
|
+
*/
|
|
222
|
+
var UNEXPECTED_HOTTABLE_CHILDREN_WARNING = 'Unexpected children nodes found in HotTable component. ' + 'Only HotColumn components are allowed.';
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Warning message for the unexpected children of HotColumn component.
|
|
226
|
+
*/
|
|
227
|
+
var UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING = 'Unexpected children nodes found in HotColumn component. ' + 'HotColumn components do not support any children.';
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Message for the warning thrown if the Handsontable instance has been destroyed.
|
|
231
|
+
*/
|
|
232
|
+
var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.';
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Default classname given to the wrapper container.
|
|
236
|
+
*/
|
|
237
|
+
var DEFAULT_CLASSNAME = 'hot-wrapper-editor-container';
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Logs warn to the console if the `console` object is exposed.
|
|
241
|
+
*
|
|
242
|
+
* @param {...*} args Values which will be logged.
|
|
243
|
+
*/
|
|
244
|
+
function warn() {
|
|
245
|
+
if (typeof console !== 'undefined') {
|
|
246
|
+
var _console;
|
|
247
|
+
(_console = console).warn.apply(_console, arguments);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Detect if `hot-renderer` or `hot-editor` is defined, and if so, throw an incompatibility warning.
|
|
253
|
+
*
|
|
254
|
+
* @returns {boolean} 'true' if the warning was issued
|
|
255
|
+
*/
|
|
256
|
+
function displayObsoleteRenderersEditorsWarning(children) {
|
|
257
|
+
if (hasChildElementOfType(children, 'hot-renderer')) {
|
|
258
|
+
warn(OBSOLETE_HOTRENDERER_WARNING);
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
if (hasChildElementOfType(children, 'hot-editor')) {
|
|
262
|
+
warn(OBSOLETE_HOTEDITOR_WARNING);
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Detect if children of specified type are defined, and if so, throw an incompatibility warning.
|
|
270
|
+
*
|
|
271
|
+
* @param {ReactNode} children Component children nodes
|
|
272
|
+
* @param {ComponentType} Component Component type to check
|
|
273
|
+
* @returns {boolean} 'true' if the warning was issued
|
|
274
|
+
*/
|
|
275
|
+
function displayChildrenOfTypeWarning(children, Component) {
|
|
276
|
+
var childrenArray = React.Children.toArray(children);
|
|
277
|
+
if (childrenArray.some(function (child) {
|
|
278
|
+
return child.type !== Component;
|
|
279
|
+
})) {
|
|
280
|
+
warn(UNEXPECTED_HOTTABLE_CHILDREN_WARNING);
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Detect if children is defined, and if so, throw an incompatibility warning.
|
|
288
|
+
*
|
|
289
|
+
* @param {ReactNode} children Component children nodes
|
|
290
|
+
* @returns {boolean} 'true' if the warning was issued
|
|
291
|
+
*/
|
|
292
|
+
function displayAnyChildrenWarning(children) {
|
|
293
|
+
var childrenArray = React.Children.toArray(children);
|
|
294
|
+
if (childrenArray.length) {
|
|
295
|
+
warn(UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING);
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Check the existence of elements of the provided `type` from the `HotColumn` component's children.
|
|
303
|
+
*
|
|
304
|
+
* @param {ReactNode} children HotTable children array.
|
|
305
|
+
* @param {String} type Either `'hot-renderer'` or `'hot-editor'`.
|
|
306
|
+
* @returns {boolean} `true` if the child of that type was found, `false` otherwise.
|
|
307
|
+
*/
|
|
308
|
+
function hasChildElementOfType(children, type) {
|
|
309
|
+
var childrenArray = React.Children.toArray(children);
|
|
310
|
+
return childrenArray.some(function (child) {
|
|
311
|
+
return child.props[type] !== void 0;
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Create an editor portal.
|
|
317
|
+
*
|
|
318
|
+
* @param {Document} doc Document to be used.
|
|
319
|
+
* @param {ComponentType} Editor Editor component or render function.
|
|
320
|
+
* @returns {ReactPortal} The portal for the editor.
|
|
321
|
+
*/
|
|
322
|
+
function createEditorPortal(doc, Editor) {
|
|
323
|
+
if (!doc || !Editor || typeof Editor === 'boolean') {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
var editorElement = /*#__PURE__*/React.createElement(Editor, null);
|
|
327
|
+
var containerProps = getContainerAttributesProps({}, false);
|
|
328
|
+
containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
|
|
329
|
+
return /*#__PURE__*/ReactDOM.createPortal(/*#__PURE__*/React.createElement("div", containerProps, editorElement), doc.body);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Render a cell component to an external DOM node.
|
|
334
|
+
*
|
|
335
|
+
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
336
|
+
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
337
|
+
* @param {String} portalKey The key to be used for the portal.
|
|
338
|
+
* @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
|
|
339
|
+
* @returns {{portal: ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
|
340
|
+
*/
|
|
341
|
+
function createPortal(rElement) {
|
|
342
|
+
var ownerDocument = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
343
|
+
var portalKey = arguments.length > 2 ? arguments[2] : undefined;
|
|
344
|
+
var cachedContainer = arguments.length > 3 ? arguments[3] : undefined;
|
|
345
|
+
if (!ownerDocument) {
|
|
346
|
+
ownerDocument = document;
|
|
347
|
+
}
|
|
348
|
+
if (!bulkComponentContainer) {
|
|
349
|
+
bulkComponentContainer = ownerDocument.createDocumentFragment();
|
|
350
|
+
}
|
|
351
|
+
var portalContainer = cachedContainer !== null && cachedContainer !== void 0 ? cachedContainer : ownerDocument.createElement('DIV');
|
|
352
|
+
bulkComponentContainer.appendChild(portalContainer);
|
|
353
|
+
return {
|
|
354
|
+
portal: /*#__PURE__*/ReactDOM.createPortal(rElement, portalContainer, portalKey),
|
|
355
|
+
portalContainer: portalContainer
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Get an object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
361
|
+
* component.
|
|
362
|
+
*
|
|
363
|
+
* @param {HotTableProps} props Object containing the React element props.
|
|
364
|
+
* @param {Boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was present in the `prop` object.
|
|
365
|
+
* @returns An object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
366
|
+
* component.
|
|
367
|
+
*/
|
|
368
|
+
function getContainerAttributesProps(props) {
|
|
369
|
+
var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
370
|
+
return {
|
|
371
|
+
id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : undefined),
|
|
372
|
+
className: props.className || '',
|
|
373
|
+
style: props.style || {}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Checks if the environment that the code runs in is a browser.
|
|
379
|
+
*
|
|
380
|
+
* @returns {boolean}
|
|
381
|
+
*/
|
|
382
|
+
function isCSR() {
|
|
383
|
+
return typeof window !== 'undefined';
|
|
384
|
+
}
|
|
385
|
+
function isObjectLike(value) {
|
|
386
|
+
return _typeof(value) === 'object' && value !== null;
|
|
387
|
+
}
|
|
388
|
+
function isPlainObject(value) {
|
|
389
|
+
if (!isObjectLike(value)) {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
var prototype = Object.getPrototypeOf(value);
|
|
393
|
+
return prototype === Object.prototype || prototype === null;
|
|
394
|
+
}
|
|
395
|
+
function isArray(value) {
|
|
396
|
+
return Array.isArray(value);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Deep-compare plain objects and arrays used by wrapper settings.
|
|
401
|
+
*
|
|
402
|
+
* @param {unknown} previousValue Previous value.
|
|
403
|
+
* @param {unknown} currentValue Current value.
|
|
404
|
+
* @returns {boolean} `true` if values are equivalent.
|
|
405
|
+
*/
|
|
406
|
+
function areEquivalentSettingsValue(previousValue, currentValue) {
|
|
407
|
+
if (previousValue === currentValue) {
|
|
408
|
+
return true;
|
|
409
|
+
}
|
|
410
|
+
if (previousValue instanceof RegExp || currentValue instanceof RegExp) {
|
|
411
|
+
if (!(previousValue instanceof RegExp) || !(currentValue instanceof RegExp)) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
return previousValue.source === currentValue.source && previousValue.flags === currentValue.flags;
|
|
415
|
+
}
|
|
416
|
+
if (isArray(previousValue) && isArray(currentValue)) {
|
|
417
|
+
if (previousValue.length !== currentValue.length) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
for (var index = 0; index < previousValue.length; index++) {
|
|
421
|
+
if (!areEquivalentSettingsValue(previousValue[index], currentValue[index])) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
if (isArray(previousValue) || isArray(currentValue)) {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
if (!isObjectLike(previousValue) || !isObjectLike(currentValue)) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
if (!isPlainObject(previousValue) || !isPlainObject(currentValue)) {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
var previousKeys = Object.keys(previousValue);
|
|
437
|
+
var currentKeys = Object.keys(currentValue);
|
|
438
|
+
if (previousKeys.length !== currentKeys.length) {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
for (var _i = 0, _previousKeys = previousKeys; _i < _previousKeys.length; _i++) {
|
|
442
|
+
var key = _previousKeys[_i];
|
|
443
|
+
if (!Object.prototype.hasOwnProperty.call(currentValue, key)) {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
if (!areEquivalentSettingsValue(previousValue[key], currentValue[key])) {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return true;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* A variant of useEffect hook that does not trigger on initial mount, only updates
|
|
455
|
+
*
|
|
456
|
+
* @param effect Effect function
|
|
457
|
+
* @param deps Effect dependencies
|
|
458
|
+
*/
|
|
459
|
+
function useUpdateEffect(effect, deps) {
|
|
460
|
+
var notInitialRender = React.useRef(false);
|
|
461
|
+
useEffect(function () {
|
|
462
|
+
if (notInitialRender.current) {
|
|
463
|
+
return effect();
|
|
464
|
+
} else {
|
|
465
|
+
notInitialRender.current = true;
|
|
466
|
+
}
|
|
467
|
+
}, deps);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Only `dataSchema` and `columns` use deep comparison when diffing props for `updateSettings(false)`.
|
|
472
|
+
* Other object settings (for example `mergeCells`, `cell`, `nestedHeaders`, hooks) stay on strict
|
|
473
|
+
* reference equality so we avoid expensive deep walks and accidental false positives where functions
|
|
474
|
+
* or class instances would not compare meaningfully by keys alone.
|
|
475
|
+
*/
|
|
476
|
+
var DEEP_COMPARABLE_SETTINGS = ['dataSchema', 'columns'];
|
|
377
477
|
var SettingsMapper = /*#__PURE__*/function () {
|
|
378
478
|
function SettingsMapper() {
|
|
379
479
|
_classCallCheck(this, SettingsMapper);
|
|
@@ -381,14 +481,14 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
381
481
|
return _createClass(SettingsMapper, null, [{
|
|
382
482
|
key: "getSettings",
|
|
383
483
|
value:
|
|
384
|
-
/**
|
|
385
|
-
* Parse component settings into Handsontable-compatible settings.
|
|
386
|
-
*
|
|
387
|
-
* @param {Object} properties Object containing properties from the HotTable object.
|
|
388
|
-
* @param {Object} additionalSettings Additional settings.
|
|
389
|
-
* @param {boolean} additionalSettings.isInit Flag determining whether the settings are being set during initialization.
|
|
390
|
-
* @param {string[]} additionalSettings.initOnlySettingKeys Array of keys that can be set only during initialization.
|
|
391
|
-
* @returns {Object} Handsontable-compatible settings object.
|
|
484
|
+
/**
|
|
485
|
+
* Parse component settings into Handsontable-compatible settings.
|
|
486
|
+
*
|
|
487
|
+
* @param {Object} properties Object containing properties from the HotTable object.
|
|
488
|
+
* @param {Object} additionalSettings Additional settings.
|
|
489
|
+
* @param {boolean} additionalSettings.isInit Flag determining whether the settings are being set during initialization.
|
|
490
|
+
* @param {string[]} additionalSettings.initOnlySettingKeys Array of keys that can be set only during initialization.
|
|
491
|
+
* @returns {Object} Handsontable-compatible settings object.
|
|
392
492
|
*/
|
|
393
493
|
function getSettings(properties) {
|
|
394
494
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
@@ -399,9 +499,11 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
399
499
|
_ref$initOnlySettingK = _ref.initOnlySettingKeys,
|
|
400
500
|
initOnlySettingKeys = _ref$initOnlySettingK === void 0 ? [] : _ref$initOnlySettingK;
|
|
401
501
|
var shouldSkipProp = function shouldSkipProp(key) {
|
|
402
|
-
|
|
502
|
+
if (!isInit && DEEP_COMPARABLE_SETTINGS.includes(key)) {
|
|
503
|
+
return areEquivalentSettingsValue(prevProps[key], properties[key]);
|
|
504
|
+
}
|
|
403
505
|
if (!isInit && initOnlySettingKeys.includes(key)) {
|
|
404
|
-
return
|
|
506
|
+
return true;
|
|
405
507
|
}
|
|
406
508
|
return false;
|
|
407
509
|
};
|
|
@@ -416,7 +518,7 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
416
518
|
}]);
|
|
417
519
|
}();
|
|
418
520
|
|
|
419
|
-
var HotTableContext = createContext(undefined);
|
|
521
|
+
var HotTableContext = /*#__PURE__*/createContext(undefined);
|
|
420
522
|
var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
421
523
|
var children = _ref.children;
|
|
422
524
|
var columnsSettings = useRef([]);
|
|
@@ -436,6 +538,7 @@ var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
|
436
538
|
var getRendererWrapper = useCallback(function (Renderer) {
|
|
437
539
|
return function __internalRenderer(instance, TD, row, col, prop, value, cellProperties) {
|
|
438
540
|
var key = "".concat(row, "-").concat(col);
|
|
541
|
+
|
|
439
542
|
// Handsontable.Core type is missing guid
|
|
440
543
|
var instanceGuid = instance.guid;
|
|
441
544
|
var portalContainerKey = "".concat(instanceGuid, "-").concat(key);
|
|
@@ -449,11 +552,12 @@ var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
|
449
552
|
while (TD.firstChild) {
|
|
450
553
|
TD.removeChild(TD.firstChild);
|
|
451
554
|
}
|
|
555
|
+
|
|
452
556
|
// if portal already exists, do not recreate
|
|
453
557
|
if (cachedPortal && cachedPortalContainer) {
|
|
454
558
|
TD.appendChild(cachedPortalContainer);
|
|
455
559
|
} else {
|
|
456
|
-
var rendererElement = React.createElement(Renderer, {
|
|
560
|
+
var rendererElement = /*#__PURE__*/React.createElement(Renderer, {
|
|
457
561
|
instance: instance,
|
|
458
562
|
TD: TD,
|
|
459
563
|
row: row,
|
|
@@ -495,20 +599,21 @@ var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
|
495
599
|
pushCellPortalsIntoPortalManager: pushCellPortalsIntoPortalManager
|
|
496
600
|
};
|
|
497
601
|
}, [setHotColumnSettings, getRendererWrapper, clearRenderedCellCache, setRenderersPortalManagerRef, pushCellPortalsIntoPortalManager]);
|
|
498
|
-
return React.createElement(HotTableContext.Provider, {
|
|
602
|
+
return /*#__PURE__*/React.createElement(HotTableContext.Provider, {
|
|
499
603
|
value: contextImpl
|
|
500
604
|
}, children);
|
|
501
605
|
};
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
*
|
|
505
|
-
*
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Exposes the table context object to components
|
|
609
|
+
*
|
|
610
|
+
* @returns HotTableContext
|
|
506
611
|
*/
|
|
507
612
|
function useHotTableContext() {
|
|
508
613
|
return useContext(HotTableContext);
|
|
509
614
|
}
|
|
510
615
|
|
|
511
|
-
var HotColumnContext = createContext(undefined);
|
|
616
|
+
var HotColumnContext = /*#__PURE__*/createContext(undefined);
|
|
512
617
|
var HotColumnContextProvider = function HotColumnContextProvider(_ref) {
|
|
513
618
|
var columnIndex = _ref.columnIndex,
|
|
514
619
|
getOwnerDocument = _ref.getOwnerDocument,
|
|
@@ -519,7 +624,7 @@ var HotColumnContextProvider = function HotColumnContextProvider(_ref) {
|
|
|
519
624
|
getOwnerDocument: getOwnerDocument
|
|
520
625
|
};
|
|
521
626
|
}, [columnIndex, getOwnerDocument]);
|
|
522
|
-
return React.createElement(HotColumnContext.Provider, {
|
|
627
|
+
return /*#__PURE__*/React.createElement(HotColumnContext.Provider, {
|
|
523
628
|
value: contextImpl
|
|
524
629
|
}, children);
|
|
525
630
|
};
|
|
@@ -535,12 +640,13 @@ var MethodsMap = {
|
|
|
535
640
|
prepare: 'onPrepare',
|
|
536
641
|
focus: 'onFocus'
|
|
537
642
|
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
* @param {RefObject}
|
|
543
|
-
* @
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Create a class to be passed to the Handsontable's settings.
|
|
646
|
+
*
|
|
647
|
+
* @param {RefObject<HotEditorHooks>} hooksRef Reference to component-based editor overridden hooks object.
|
|
648
|
+
* @param {RefObject} instanceRef Reference to Handsontable-native custom editor class instance.
|
|
649
|
+
* @returns {Function} A class to be passed to the Handsontable editor settings.
|
|
544
650
|
*/
|
|
545
651
|
function makeEditorClass(hooksRef, instanceRef) {
|
|
546
652
|
return /*#__PURE__*/function (_Handsontable$editors) {
|
|
@@ -564,8 +670,8 @@ function makeEditorClass(hooksRef, instanceRef) {
|
|
|
564
670
|
result = baseMethod.call.apply(baseMethod, [this].concat(args)); // call super
|
|
565
671
|
}
|
|
566
672
|
if (MethodsMap[propName] && (_hooksRef$current = hooksRef.current) !== null && _hooksRef$current !== void 0 && _hooksRef$current[MethodsMap[propName]]) {
|
|
567
|
-
var
|
|
568
|
-
result = (
|
|
673
|
+
var _ref;
|
|
674
|
+
result = (_ref = hooksRef.current[MethodsMap[propName]]).call.apply(_ref, [this].concat(args));
|
|
569
675
|
}
|
|
570
676
|
return result;
|
|
571
677
|
}.bind(_this);
|
|
@@ -595,31 +701,31 @@ function makeEditorClass(hooksRef, instanceRef) {
|
|
|
595
701
|
}]);
|
|
596
702
|
}(Handsontable.editors.BaseEditor);
|
|
597
703
|
}
|
|
598
|
-
/**
|
|
599
|
-
* Context to provide Handsontable-native custom editor class instance to overridden hooks object.
|
|
704
|
+
/**
|
|
705
|
+
* Context to provide Handsontable-native custom editor class instance to overridden hooks object.
|
|
600
706
|
*/
|
|
601
|
-
var EditorContext = 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 {Ref} hooksRef Reference for component-based editor overridden hooks object.
|
|
607
|
-
* @param {RefObject} hotCustomEditorInstanceRef Reference to Handsontable-native editor instance.
|
|
707
|
+
var EditorContext = /*#__PURE__*/createContext(undefined);
|
|
708
|
+
/**
|
|
709
|
+
* Provider of the context that exposes Handsontable-native editor instance and passes hooks object
|
|
710
|
+
* for custom editor components.
|
|
711
|
+
*
|
|
712
|
+
* @param {Ref} hooksRef Reference for component-based editor overridden hooks object.
|
|
713
|
+
* @param {RefObject} hotCustomEditorInstanceRef Reference to Handsontable-native editor instance.
|
|
608
714
|
*/
|
|
609
|
-
var EditorContextProvider = function EditorContextProvider(
|
|
610
|
-
var hooksRef =
|
|
611
|
-
hotCustomEditorInstanceRef =
|
|
612
|
-
children =
|
|
613
|
-
return React.createElement(EditorContext.Provider, {
|
|
715
|
+
var EditorContextProvider = function EditorContextProvider(_ref2) {
|
|
716
|
+
var hooksRef = _ref2.hooksRef,
|
|
717
|
+
hotCustomEditorInstanceRef = _ref2.hotCustomEditorInstanceRef,
|
|
718
|
+
children = _ref2.children;
|
|
719
|
+
return /*#__PURE__*/React.createElement(EditorContext.Provider, {
|
|
614
720
|
value: {
|
|
615
721
|
hooksRef: hooksRef,
|
|
616
722
|
hotCustomEditorInstanceRef: hotCustomEditorInstanceRef
|
|
617
723
|
}
|
|
618
724
|
}, children);
|
|
619
725
|
};
|
|
620
|
-
/**
|
|
621
|
-
* Applies editor overlay position/dimensions to an element.
|
|
622
|
-
* @returns true if position was applied, false if editor should close (e.g. cell no longer available).
|
|
726
|
+
/**
|
|
727
|
+
* Applies editor overlay position/dimensions to an element.
|
|
728
|
+
* @returns true if position was applied, false if editor should close (e.g. cell no longer available).
|
|
623
729
|
*/
|
|
624
730
|
function applyEditorPosition(el, editor, hot, td) {
|
|
625
731
|
var _rootWindow$pageXOffs, _rootWindow$pageYOffs;
|
|
@@ -669,17 +775,18 @@ function applyEditorPosition(el, editor, hot, td) {
|
|
|
669
775
|
}
|
|
670
776
|
return false;
|
|
671
777
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
* @param {
|
|
677
|
-
* @
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Hook that allows encapsulating custom behaviours of component-based editor by customizing passed ref with overridden hooks object.
|
|
781
|
+
*
|
|
782
|
+
* @param {HotEditorHooks} overriddenHooks Overrides specific for the custom editor.
|
|
783
|
+
* @param {DependencyList} deps Overridden hooks object React dependency list.
|
|
784
|
+
* @returns {UseHotEditorImpl} Editor API methods
|
|
678
785
|
*/
|
|
679
786
|
function useHotEditor(overriddenHooks, deps) {
|
|
680
|
-
var
|
|
681
|
-
hooksRef =
|
|
682
|
-
hotCustomEditorInstanceRef =
|
|
787
|
+
var _ref3 = useContext(EditorContext),
|
|
788
|
+
hooksRef = _ref3.hooksRef,
|
|
789
|
+
hotCustomEditorInstanceRef = _ref3.hotCustomEditorInstanceRef;
|
|
683
790
|
var _useState = useState(0),
|
|
684
791
|
_useState2 = _slicedToArray(_useState, 2),
|
|
685
792
|
rerenderTrigger = _useState2[0],
|
|
@@ -688,6 +795,7 @@ function useHotEditor(overriddenHooks, deps) {
|
|
|
688
795
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
689
796
|
editorValue = _useState4[0],
|
|
690
797
|
setEditorValue = _useState4[1];
|
|
798
|
+
|
|
691
799
|
// return a deferred value that allows for optimizing performance by delaying the update of a value until the next render.
|
|
692
800
|
var deferredValue = useDeferredValue(editorValue);
|
|
693
801
|
useImperativeHandle(hooksRef, function () {
|
|
@@ -731,23 +839,28 @@ function useHotEditor(overriddenHooks, deps) {
|
|
|
731
839
|
};
|
|
732
840
|
}, [rerenderTrigger, hotCustomEditorInstanceRef, deferredValue]);
|
|
733
841
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
842
|
+
|
|
843
|
+
// Render prop function type
|
|
844
|
+
|
|
845
|
+
// EditorComponent props - children typed to work with JSX syntax
|
|
846
|
+
|
|
847
|
+
function EditorComponent(_ref4) {
|
|
848
|
+
var _onPrepare = _ref4.onPrepare,
|
|
849
|
+
_onClose = _ref4.onClose,
|
|
850
|
+
_onOpen = _ref4.onOpen,
|
|
851
|
+
_onFocus = _ref4.onFocus,
|
|
852
|
+
children = _ref4.children,
|
|
853
|
+
_ref4$shortcutsGroup = _ref4.shortcutsGroup,
|
|
854
|
+
shortcutsGroup = _ref4$shortcutsGroup === void 0 ? "custom-editor" : _ref4$shortcutsGroup,
|
|
855
|
+
shortcuts = _ref4.shortcuts;
|
|
743
856
|
var mainElementRef = useRef(null);
|
|
744
857
|
var currentValue = useRef(undefined);
|
|
745
858
|
var _useState5 = useState(),
|
|
746
859
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
747
860
|
themeClassName = _useState6[0],
|
|
748
861
|
setThemeClassName = _useState6[1];
|
|
749
|
-
var
|
|
750
|
-
hotCustomEditorInstanceRef =
|
|
862
|
+
var _ref5 = useContext(EditorContext),
|
|
863
|
+
hotCustomEditorInstanceRef = _ref5.hotCustomEditorInstanceRef;
|
|
751
864
|
var registerShortcuts = useCallback(function () {
|
|
752
865
|
var _hotCustomEditorInsta8, _hotCustomEditorInsta9, _hotCustomEditorInsta0;
|
|
753
866
|
if (!((_hotCustomEditorInsta8 = hotCustomEditorInstanceRef.current) !== null && _hotCustomEditorInsta8 !== void 0 && _hotCustomEditorInsta8.hot)) return;
|
|
@@ -850,7 +963,7 @@ function EditorComponent(_ref2) {
|
|
|
850
963
|
var stopMousedownPropagation = function stopMousedownPropagation(e) {
|
|
851
964
|
e.stopPropagation();
|
|
852
965
|
};
|
|
853
|
-
return React.createElement("div", {
|
|
966
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
854
967
|
ref: mainElementRef,
|
|
855
968
|
className: themeClassName,
|
|
856
969
|
style: {
|
|
@@ -885,22 +998,25 @@ var HotColumn = function HotColumn(props) {
|
|
|
885
998
|
var _useHotColumnContext = useHotColumnContext(),
|
|
886
999
|
columnIndex = _useHotColumnContext.columnIndex,
|
|
887
1000
|
getOwnerDocument = _useHotColumnContext.getOwnerDocument;
|
|
888
|
-
|
|
889
|
-
|
|
1001
|
+
|
|
1002
|
+
/**
|
|
1003
|
+
* Reference to component-based editor overridden hooks object.
|
|
890
1004
|
*/
|
|
891
1005
|
var localEditorHooksRef = useRef(null);
|
|
892
|
-
|
|
893
|
-
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Reference to HOT-native custom editor class instance.
|
|
894
1009
|
*/
|
|
895
1010
|
var localEditorClassInstance = useRef(null);
|
|
896
|
-
|
|
897
|
-
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Logic performed after mounting & updating of the HotColumn component.
|
|
898
1014
|
*/
|
|
899
1015
|
useEffect(function () {
|
|
900
|
-
/**
|
|
901
|
-
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
|
902
|
-
*
|
|
903
|
-
* @returns {Object}
|
|
1016
|
+
/**
|
|
1017
|
+
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
|
1018
|
+
*
|
|
1019
|
+
* @returns {Object}
|
|
904
1020
|
*/
|
|
905
1021
|
var getSettingsProps = function getSettingsProps() {
|
|
906
1022
|
return Object.keys(props).filter(function (key) {
|
|
@@ -910,8 +1026,9 @@ var HotColumn = function HotColumn(props) {
|
|
|
910
1026
|
return obj;
|
|
911
1027
|
}, {});
|
|
912
1028
|
};
|
|
913
|
-
|
|
914
|
-
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Create the column settings based on the data provided to the `HotColumn` component and its child components.
|
|
915
1032
|
*/
|
|
916
1033
|
var createColumnSettings = function createColumnSettings() {
|
|
917
1034
|
var columnSettings = SettingsMapper.getSettings(getSettingsProps());
|
|
@@ -935,23 +1052,24 @@ var HotColumn = function HotColumn(props) {
|
|
|
935
1052
|
}
|
|
936
1053
|
});
|
|
937
1054
|
var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
*
|
|
941
|
-
*
|
|
1055
|
+
|
|
1056
|
+
/**
|
|
1057
|
+
* Render the portals of the editors, if there are any.
|
|
1058
|
+
*
|
|
1059
|
+
* @returns {ReactElement}
|
|
942
1060
|
*/
|
|
943
|
-
return React.createElement(EditorContextProvider, {
|
|
1061
|
+
return /*#__PURE__*/React.createElement(EditorContextProvider, {
|
|
944
1062
|
hooksRef: localEditorHooksRef,
|
|
945
1063
|
hotCustomEditorInstanceRef: localEditorClassInstance
|
|
946
1064
|
}, editorPortal);
|
|
947
1065
|
};
|
|
948
1066
|
|
|
949
|
-
var version="17.0
|
|
1067
|
+
var version="17.1.0-rc1";
|
|
950
1068
|
|
|
951
|
-
/**
|
|
952
|
-
* Component used to manage the renderer component portals.
|
|
1069
|
+
/**
|
|
1070
|
+
* Component used to manage the renderer component portals.
|
|
953
1071
|
*/
|
|
954
|
-
var RenderersPortalManager = forwardRef(function (_, ref) {
|
|
1072
|
+
var RenderersPortalManager = /*#__PURE__*/forwardRef(function (_, ref) {
|
|
955
1073
|
var _useState = useState([]),
|
|
956
1074
|
_useState2 = _slicedToArray(_useState, 2),
|
|
957
1075
|
portals = _useState2[0],
|
|
@@ -959,7 +1077,7 @@ var RenderersPortalManager = forwardRef(function (_, ref) {
|
|
|
959
1077
|
useImperativeHandle(ref, function () {
|
|
960
1078
|
return setPortals;
|
|
961
1079
|
});
|
|
962
|
-
return React.createElement(Fragment, null, portals);
|
|
1080
|
+
return /*#__PURE__*/React.createElement(Fragment, null, portals);
|
|
963
1081
|
});
|
|
964
1082
|
|
|
965
1083
|
function getDefaultExportFromCjs (x) {
|
|
@@ -2085,33 +2203,39 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
2085
2203
|
var propTypesExports = propTypes.exports;
|
|
2086
2204
|
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
2087
2205
|
|
|
2088
|
-
var HotTableInner = forwardRef(function (props, ref) {
|
|
2089
|
-
/**
|
|
2090
|
-
* Reference to the Handsontable instance.
|
|
2206
|
+
var HotTableInner = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
2207
|
+
/**
|
|
2208
|
+
* Reference to the Handsontable instance.
|
|
2091
2209
|
*/
|
|
2092
2210
|
var __hotInstance = useRef(null);
|
|
2093
|
-
|
|
2094
|
-
|
|
2211
|
+
|
|
2212
|
+
/**
|
|
2213
|
+
* Reference to the main Handsontable DOM element.
|
|
2095
2214
|
*/
|
|
2096
2215
|
var hotElementRef = useRef(null);
|
|
2097
|
-
|
|
2098
|
-
|
|
2216
|
+
|
|
2217
|
+
/**
|
|
2218
|
+
* Reference to component-based editor overridden hooks object.
|
|
2099
2219
|
*/
|
|
2100
2220
|
var globalEditorHooksRef = useRef(null);
|
|
2101
|
-
|
|
2102
|
-
|
|
2221
|
+
|
|
2222
|
+
/**
|
|
2223
|
+
* Reference to HOT-native custom editor class instance.
|
|
2103
2224
|
*/
|
|
2104
2225
|
var globalEditorClassInstance = useRef(null);
|
|
2105
|
-
|
|
2106
|
-
|
|
2226
|
+
|
|
2227
|
+
/**
|
|
2228
|
+
* Reference to the previous props object.
|
|
2107
2229
|
*/
|
|
2108
2230
|
var prevProps = useRef();
|
|
2109
|
-
|
|
2110
|
-
|
|
2231
|
+
|
|
2232
|
+
/**
|
|
2233
|
+
* HotTable context exposing helper functions.
|
|
2111
2234
|
*/
|
|
2112
2235
|
var context = useHotTableContext();
|
|
2113
|
-
|
|
2114
|
-
|
|
2236
|
+
|
|
2237
|
+
/**
|
|
2238
|
+
* Getter for the property storing the Handsontable instance.
|
|
2115
2239
|
*/
|
|
2116
2240
|
var getHotInstance = useCallback(function () {
|
|
2117
2241
|
if (!__hotInstance.current || !__hotInstance.current.isDestroyed) {
|
|
@@ -2125,17 +2249,19 @@ var HotTableInner = forwardRef(function (props, ref) {
|
|
|
2125
2249
|
var isHotInstanceDestroyed = useCallback(function () {
|
|
2126
2250
|
return !__hotInstance.current || __hotInstance.current.isDestroyed;
|
|
2127
2251
|
}, [__hotInstance]);
|
|
2128
|
-
|
|
2129
|
-
|
|
2252
|
+
|
|
2253
|
+
/**
|
|
2254
|
+
* Clear both the editor and the renderer cache.
|
|
2130
2255
|
*/
|
|
2131
2256
|
var clearCache = useCallback(function () {
|
|
2132
2257
|
context.clearRenderedCellCache();
|
|
2133
2258
|
context.componentRendererColumns.clear();
|
|
2134
2259
|
}, [context]);
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
*
|
|
2138
|
-
*
|
|
2260
|
+
|
|
2261
|
+
/**
|
|
2262
|
+
* Get the `Document` object corresponding to the main component element.
|
|
2263
|
+
*
|
|
2264
|
+
* @returns The `Document` object used by the component.
|
|
2139
2265
|
*/
|
|
2140
2266
|
var getOwnerDocument = useCallback(function () {
|
|
2141
2267
|
if (isCSR()) {
|
|
@@ -2143,10 +2269,11 @@ var HotTableInner = forwardRef(function (props, ref) {
|
|
|
2143
2269
|
}
|
|
2144
2270
|
return null;
|
|
2145
2271
|
}, [hotElementRef]);
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
*
|
|
2149
|
-
*
|
|
2272
|
+
|
|
2273
|
+
/**
|
|
2274
|
+
* Create a new settings object containing the column settings and global editors and renderers.
|
|
2275
|
+
*
|
|
2276
|
+
* @returns {Handsontable.GridSettings} New global set of settings for Handsontable.
|
|
2150
2277
|
*/
|
|
2151
2278
|
var createNewGlobalSettings = function createNewGlobalSettings() {
|
|
2152
2279
|
var _getHotInstance;
|
|
@@ -2176,8 +2303,9 @@ var HotTableInner = forwardRef(function (props, ref) {
|
|
|
2176
2303
|
}
|
|
2177
2304
|
return newSettings;
|
|
2178
2305
|
};
|
|
2179
|
-
|
|
2180
|
-
|
|
2306
|
+
|
|
2307
|
+
/**
|
|
2308
|
+
* Detect if `autoRowSize` or `autoColumnSize` is defined, and if so, throw an incompatibility warning.
|
|
2181
2309
|
*/
|
|
2182
2310
|
var displayAutoSizeWarning = function displayAutoSizeWarning(hotInstance) {
|
|
2183
2311
|
var _hotInstance$getPlugi, _hotInstance$getPlugi2;
|
|
@@ -2187,23 +2315,27 @@ var HotTableInner = forwardRef(function (props, ref) {
|
|
|
2187
2315
|
}
|
|
2188
2316
|
}
|
|
2189
2317
|
};
|
|
2190
|
-
|
|
2191
|
-
|
|
2318
|
+
|
|
2319
|
+
/**
|
|
2320
|
+
* Initialize Handsontable after the component has mounted.
|
|
2192
2321
|
*/
|
|
2193
2322
|
useEffect(function () {
|
|
2194
2323
|
var newGlobalSettings = createNewGlobalSettings(true);
|
|
2324
|
+
|
|
2195
2325
|
// Update prevProps with the current props
|
|
2196
2326
|
prevProps.current = props;
|
|
2197
2327
|
__hotInstance.current = new Handsontable.Core(hotElementRef.current, newGlobalSettings);
|
|
2198
|
-
|
|
2199
|
-
|
|
2328
|
+
|
|
2329
|
+
/**
|
|
2330
|
+
* Handsontable's `beforeViewRender` hook callback.
|
|
2200
2331
|
*/
|
|
2201
2332
|
__hotInstance.current.addHook('beforeViewRender', function () {
|
|
2202
2333
|
context.clearPortalCache();
|
|
2203
2334
|
context.clearRenderedCellCache();
|
|
2204
2335
|
});
|
|
2205
|
-
|
|
2206
|
-
|
|
2336
|
+
|
|
2337
|
+
/**
|
|
2338
|
+
* Handsontable's `afterViewRender` hook callback.
|
|
2207
2339
|
*/
|
|
2208
2340
|
__hotInstance.current.addHook('afterViewRender', function () {
|
|
2209
2341
|
context.pushCellPortalsIntoPortalManager();
|
|
@@ -2213,8 +2345,9 @@ var HotTableInner = forwardRef(function (props, ref) {
|
|
|
2213
2345
|
if (!displayObsoleteRenderersEditorsWarning(props.children)) {
|
|
2214
2346
|
displayChildrenOfTypeWarning(props.children, HotColumn);
|
|
2215
2347
|
}
|
|
2216
|
-
|
|
2217
|
-
|
|
2348
|
+
|
|
2349
|
+
/**
|
|
2350
|
+
* Destroy the Handsontable instance when the parent component unmounts.
|
|
2218
2351
|
*/
|
|
2219
2352
|
return function () {
|
|
2220
2353
|
var _getHotInstance2;
|
|
@@ -2222,21 +2355,24 @@ var HotTableInner = forwardRef(function (props, ref) {
|
|
|
2222
2355
|
(_getHotInstance2 = getHotInstance()) === null || _getHotInstance2 === void 0 || _getHotInstance2.destroy();
|
|
2223
2356
|
};
|
|
2224
2357
|
}, []);
|
|
2225
|
-
|
|
2226
|
-
|
|
2358
|
+
|
|
2359
|
+
/**
|
|
2360
|
+
* Logic performed after the component update.
|
|
2227
2361
|
*/
|
|
2228
2362
|
useUpdateEffect(function () {
|
|
2229
2363
|
clearCache();
|
|
2230
2364
|
var hotInstance = getHotInstance();
|
|
2231
2365
|
var newGlobalSettings = createNewGlobalSettings(false, prevProps.current);
|
|
2366
|
+
|
|
2232
2367
|
// Update prevProps with the current props
|
|
2233
2368
|
prevProps.current = props;
|
|
2234
2369
|
hotInstance === null || hotInstance === void 0 || hotInstance.updateSettings(newGlobalSettings, false);
|
|
2235
2370
|
displayAutoSizeWarning(hotInstance);
|
|
2236
2371
|
displayObsoleteRenderersEditorsWarning(props.children);
|
|
2237
2372
|
});
|
|
2238
|
-
|
|
2239
|
-
|
|
2373
|
+
|
|
2374
|
+
/**
|
|
2375
|
+
* Interface exposed to parent components by HotTable instance via React ref
|
|
2240
2376
|
*/
|
|
2241
2377
|
useImperativeHandle(ref, function () {
|
|
2242
2378
|
return {
|
|
@@ -2248,11 +2384,12 @@ var HotTableInner = forwardRef(function (props, ref) {
|
|
|
2248
2384
|
}
|
|
2249
2385
|
};
|
|
2250
2386
|
});
|
|
2251
|
-
|
|
2252
|
-
|
|
2387
|
+
|
|
2388
|
+
/**
|
|
2389
|
+
* Render the component.
|
|
2253
2390
|
*/
|
|
2254
2391
|
var hotColumnWrapped = Children.toArray(props.children).filter(isHotColumn).map(function (childNode, columnIndex) {
|
|
2255
|
-
return React.createElement(HotColumnContextProvider, {
|
|
2392
|
+
return /*#__PURE__*/React.createElement(HotColumnContextProvider, {
|
|
2256
2393
|
columnIndex: columnIndex,
|
|
2257
2394
|
getOwnerDocument: getOwnerDocument,
|
|
2258
2395
|
key: columnIndex
|
|
@@ -2260,17 +2397,18 @@ var HotTableInner = forwardRef(function (props, ref) {
|
|
|
2260
2397
|
});
|
|
2261
2398
|
var containerProps = getContainerAttributesProps(props);
|
|
2262
2399
|
var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
|
|
2263
|
-
return React.createElement(Fragment, null, React.createElement("div",
|
|
2400
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", _extends({
|
|
2264
2401
|
ref: hotElementRef
|
|
2265
|
-
}, containerProps), hotColumnWrapped), React.createElement(RenderersPortalManager, {
|
|
2402
|
+
}, containerProps), hotColumnWrapped), /*#__PURE__*/React.createElement(RenderersPortalManager, {
|
|
2266
2403
|
ref: context.setRenderersPortalManagerRef
|
|
2267
|
-
}), React.createElement(EditorContextProvider, {
|
|
2404
|
+
}), /*#__PURE__*/React.createElement(EditorContextProvider, {
|
|
2268
2405
|
hooksRef: globalEditorHooksRef,
|
|
2269
2406
|
hotCustomEditorInstanceRef: globalEditorClassInstance
|
|
2270
2407
|
}, editorPortal));
|
|
2271
2408
|
});
|
|
2272
|
-
|
|
2273
|
-
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* Prop types to be checked at runtime.
|
|
2274
2412
|
*/
|
|
2275
2413
|
HotTableInner.propTypes = {
|
|
2276
2414
|
style: PropTypes.object,
|
|
@@ -2279,41 +2417,42 @@ HotTableInner.propTypes = {
|
|
|
2279
2417
|
};
|
|
2280
2418
|
|
|
2281
2419
|
var _excluded = ["children"];
|
|
2282
|
-
/**
|
|
2283
|
-
* A Handsontable-ReactJS wrapper.
|
|
2284
|
-
*
|
|
2285
|
-
* To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
|
|
2286
|
-
* For example:
|
|
2287
|
-
*
|
|
2288
|
-
* ```js
|
|
2289
|
-
* <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
|
|
2290
|
-
*
|
|
2291
|
-
* // is analogous to
|
|
2292
|
-
* let hot = new Handsontable(document.getElementById('hot'), {
|
|
2293
|
-
* data: dataObject,
|
|
2294
|
-
* contextMenu: true,
|
|
2295
|
-
* colHeaders: true,
|
|
2296
|
-
* width: 600
|
|
2297
|
-
* height: 300
|
|
2298
|
-
* });
|
|
2299
|
-
*
|
|
2300
|
-
* ```
|
|
2420
|
+
/**
|
|
2421
|
+
* A Handsontable-ReactJS wrapper.
|
|
2422
|
+
*
|
|
2423
|
+
* To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
|
|
2424
|
+
* For example:
|
|
2425
|
+
*
|
|
2426
|
+
* ```js
|
|
2427
|
+
* <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
|
|
2428
|
+
*
|
|
2429
|
+
* // is analogous to
|
|
2430
|
+
* let hot = new Handsontable(document.getElementById('hot'), {
|
|
2431
|
+
* data: dataObject,
|
|
2432
|
+
* contextMenu: true,
|
|
2433
|
+
* colHeaders: true,
|
|
2434
|
+
* width: 600
|
|
2435
|
+
* height: 300
|
|
2436
|
+
* });
|
|
2437
|
+
*
|
|
2438
|
+
* ```
|
|
2301
2439
|
*/
|
|
2302
|
-
var HotTable = forwardRef(function (_ref, ref) {
|
|
2440
|
+
var HotTable = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
2303
2441
|
var _props$id;
|
|
2304
2442
|
var children = _ref.children,
|
|
2305
2443
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
2306
2444
|
var componentId = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : useId();
|
|
2307
|
-
return React.createElement(HotTableContextProvider, null, React.createElement(HotTableInner,
|
|
2445
|
+
return /*#__PURE__*/React.createElement(HotTableContextProvider, null, /*#__PURE__*/React.createElement(HotTableInner, _extends({
|
|
2308
2446
|
id: componentId
|
|
2309
2447
|
}, props, {
|
|
2310
2448
|
ref: ref
|
|
2311
2449
|
}), children));
|
|
2312
2450
|
});
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
*
|
|
2316
|
-
*
|
|
2451
|
+
|
|
2452
|
+
/**
|
|
2453
|
+
* Package version.
|
|
2454
|
+
*
|
|
2455
|
+
* @returns The version number of the package.
|
|
2317
2456
|
*/
|
|
2318
2457
|
HotTable.version = version;
|
|
2319
2458
|
|