@handsontable/react-wrapper 17.0.1 → 17.1.0-rc3
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
|
@@ -14,190 +14,6 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
14
14
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultCompat(ReactDOM);
|
|
15
15
|
var Handsontable__default = /*#__PURE__*/_interopDefaultCompat(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 {ReactNode} children Component children nodes
|
|
77
|
-
* @param {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 {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 {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 {ComponentType} Editor Editor component or render function.
|
|
122
|
-
* @returns {ReactPortal} The portal for the editor.
|
|
123
|
-
*/
|
|
124
|
-
function createEditorPortal(doc, Editor) {
|
|
125
|
-
if (!doc || !Editor || typeof Editor === 'boolean') {
|
|
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: 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
|
-
* A variant of useEffect hook that does not trigger on initial mount, only updates
|
|
186
|
-
*
|
|
187
|
-
* @param effect Effect function
|
|
188
|
-
* @param deps Effect dependencies
|
|
189
|
-
*/
|
|
190
|
-
function useUpdateEffect(effect, deps) {
|
|
191
|
-
var notInitialRender = React__default["default"].useRef(false);
|
|
192
|
-
React.useEffect(function () {
|
|
193
|
-
if (notInitialRender.current) {
|
|
194
|
-
return effect();
|
|
195
|
-
} else {
|
|
196
|
-
notInitialRender.current = true;
|
|
197
|
-
}
|
|
198
|
-
}, deps);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
17
|
function _arrayLikeToArray(r, a) {
|
|
202
18
|
(null == a || a > r.length) && (a = r.length);
|
|
203
19
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -238,6 +54,15 @@ function _defineProperty(e, r, t) {
|
|
|
238
54
|
writable: true
|
|
239
55
|
}) : e[r] = t, e;
|
|
240
56
|
}
|
|
57
|
+
function _extends() {
|
|
58
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
59
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
60
|
+
var t = arguments[e];
|
|
61
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
62
|
+
}
|
|
63
|
+
return n;
|
|
64
|
+
}, _extends.apply(null, arguments);
|
|
65
|
+
}
|
|
241
66
|
function _getPrototypeOf(t) {
|
|
242
67
|
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
243
68
|
return t.__proto__ || Object.getPrototypeOf(t);
|
|
@@ -384,6 +209,281 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
384
209
|
}
|
|
385
210
|
}
|
|
386
211
|
|
|
212
|
+
var bulkComponentContainer = null;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
|
|
216
|
+
*/
|
|
217
|
+
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.';
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Warning message for the `hot-renderer` obsolete renderer passing method.
|
|
221
|
+
*/
|
|
222
|
+
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.';
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Warning message for the `hot-editor` obsolete editor passing method.
|
|
226
|
+
*/
|
|
227
|
+
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.';
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Warning message for the unexpected children of HotTable component.
|
|
231
|
+
*/
|
|
232
|
+
var UNEXPECTED_HOTTABLE_CHILDREN_WARNING = 'Unexpected children nodes found in HotTable component. ' + 'Only HotColumn components are allowed.';
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Warning message for the unexpected children of HotColumn component.
|
|
236
|
+
*/
|
|
237
|
+
var UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING = 'Unexpected children nodes found in HotColumn component. ' + 'HotColumn components do not support any children.';
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Message for the warning thrown if the Handsontable instance has been destroyed.
|
|
241
|
+
*/
|
|
242
|
+
var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.';
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Default classname given to the wrapper container.
|
|
246
|
+
*/
|
|
247
|
+
var DEFAULT_CLASSNAME = 'hot-wrapper-editor-container';
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Logs warn to the console if the `console` object is exposed.
|
|
251
|
+
*
|
|
252
|
+
* @param {...*} args Values which will be logged.
|
|
253
|
+
*/
|
|
254
|
+
function warn() {
|
|
255
|
+
if (typeof console !== 'undefined') {
|
|
256
|
+
var _console;
|
|
257
|
+
(_console = console).warn.apply(_console, arguments);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Detect if `hot-renderer` or `hot-editor` is defined, and if so, throw an incompatibility warning.
|
|
263
|
+
*
|
|
264
|
+
* @returns {boolean} 'true' if the warning was issued
|
|
265
|
+
*/
|
|
266
|
+
function displayObsoleteRenderersEditorsWarning(children) {
|
|
267
|
+
if (hasChildElementOfType(children, 'hot-renderer')) {
|
|
268
|
+
warn(OBSOLETE_HOTRENDERER_WARNING);
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
if (hasChildElementOfType(children, 'hot-editor')) {
|
|
272
|
+
warn(OBSOLETE_HOTEDITOR_WARNING);
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Detect if children of specified type are defined, and if so, throw an incompatibility warning.
|
|
280
|
+
*
|
|
281
|
+
* @param {ReactNode} children Component children nodes
|
|
282
|
+
* @param {ComponentType} Component Component type to check
|
|
283
|
+
* @returns {boolean} 'true' if the warning was issued
|
|
284
|
+
*/
|
|
285
|
+
function displayChildrenOfTypeWarning(children, Component) {
|
|
286
|
+
var childrenArray = React__default["default"].Children.toArray(children);
|
|
287
|
+
if (childrenArray.some(function (child) {
|
|
288
|
+
return child.type !== Component;
|
|
289
|
+
})) {
|
|
290
|
+
warn(UNEXPECTED_HOTTABLE_CHILDREN_WARNING);
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Detect if children is defined, and if so, throw an incompatibility warning.
|
|
298
|
+
*
|
|
299
|
+
* @param {ReactNode} children Component children nodes
|
|
300
|
+
* @returns {boolean} 'true' if the warning was issued
|
|
301
|
+
*/
|
|
302
|
+
function displayAnyChildrenWarning(children) {
|
|
303
|
+
var childrenArray = React__default["default"].Children.toArray(children);
|
|
304
|
+
if (childrenArray.length) {
|
|
305
|
+
warn(UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING);
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Check the existence of elements of the provided `type` from the `HotColumn` component's children.
|
|
313
|
+
*
|
|
314
|
+
* @param {ReactNode} children HotTable children array.
|
|
315
|
+
* @param {String} type Either `'hot-renderer'` or `'hot-editor'`.
|
|
316
|
+
* @returns {boolean} `true` if the child of that type was found, `false` otherwise.
|
|
317
|
+
*/
|
|
318
|
+
function hasChildElementOfType(children, type) {
|
|
319
|
+
var childrenArray = React__default["default"].Children.toArray(children);
|
|
320
|
+
return childrenArray.some(function (child) {
|
|
321
|
+
return child.props[type] !== void 0;
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Create an editor portal.
|
|
327
|
+
*
|
|
328
|
+
* @param {Document} doc Document to be used.
|
|
329
|
+
* @param {ComponentType} Editor Editor component or render function.
|
|
330
|
+
* @returns {ReactPortal} The portal for the editor.
|
|
331
|
+
*/
|
|
332
|
+
function createEditorPortal(doc, Editor) {
|
|
333
|
+
if (!doc || !Editor || typeof Editor === 'boolean') {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
var editorElement = /*#__PURE__*/React__default["default"].createElement(Editor, null);
|
|
337
|
+
var containerProps = getContainerAttributesProps({}, false);
|
|
338
|
+
containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
|
|
339
|
+
return /*#__PURE__*/ReactDOM__default["default"].createPortal(/*#__PURE__*/React__default["default"].createElement("div", containerProps, editorElement), doc.body);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Render a cell component to an external DOM node.
|
|
344
|
+
*
|
|
345
|
+
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
346
|
+
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
347
|
+
* @param {String} portalKey The key to be used for the portal.
|
|
348
|
+
* @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
|
|
349
|
+
* @returns {{portal: ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
|
350
|
+
*/
|
|
351
|
+
function createPortal(rElement) {
|
|
352
|
+
var ownerDocument = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
353
|
+
var portalKey = arguments.length > 2 ? arguments[2] : undefined;
|
|
354
|
+
var cachedContainer = arguments.length > 3 ? arguments[3] : undefined;
|
|
355
|
+
if (!ownerDocument) {
|
|
356
|
+
ownerDocument = document;
|
|
357
|
+
}
|
|
358
|
+
if (!bulkComponentContainer) {
|
|
359
|
+
bulkComponentContainer = ownerDocument.createDocumentFragment();
|
|
360
|
+
}
|
|
361
|
+
var portalContainer = cachedContainer !== null && cachedContainer !== void 0 ? cachedContainer : ownerDocument.createElement('DIV');
|
|
362
|
+
bulkComponentContainer.appendChild(portalContainer);
|
|
363
|
+
return {
|
|
364
|
+
portal: /*#__PURE__*/ReactDOM__default["default"].createPortal(rElement, portalContainer, portalKey),
|
|
365
|
+
portalContainer: portalContainer
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Get an object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
371
|
+
* component.
|
|
372
|
+
*
|
|
373
|
+
* @param {HotTableProps} props Object containing the React element props.
|
|
374
|
+
* @param {Boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was present in the `prop` object.
|
|
375
|
+
* @returns An object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
376
|
+
* component.
|
|
377
|
+
*/
|
|
378
|
+
function getContainerAttributesProps(props) {
|
|
379
|
+
var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
380
|
+
return {
|
|
381
|
+
id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : undefined),
|
|
382
|
+
className: props.className || '',
|
|
383
|
+
style: props.style || {}
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Checks if the environment that the code runs in is a browser.
|
|
389
|
+
*
|
|
390
|
+
* @returns {boolean}
|
|
391
|
+
*/
|
|
392
|
+
function isCSR() {
|
|
393
|
+
return typeof window !== 'undefined';
|
|
394
|
+
}
|
|
395
|
+
function isObjectLike(value) {
|
|
396
|
+
return _typeof(value) === 'object' && value !== null;
|
|
397
|
+
}
|
|
398
|
+
function isPlainObject(value) {
|
|
399
|
+
if (!isObjectLike(value)) {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
var prototype = Object.getPrototypeOf(value);
|
|
403
|
+
return prototype === Object.prototype || prototype === null;
|
|
404
|
+
}
|
|
405
|
+
function isArray(value) {
|
|
406
|
+
return Array.isArray(value);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Deep-compare plain objects and arrays used by wrapper settings.
|
|
411
|
+
*
|
|
412
|
+
* @param {unknown} previousValue Previous value.
|
|
413
|
+
* @param {unknown} currentValue Current value.
|
|
414
|
+
* @returns {boolean} `true` if values are equivalent.
|
|
415
|
+
*/
|
|
416
|
+
function areEquivalentSettingsValue(previousValue, currentValue) {
|
|
417
|
+
if (previousValue === currentValue) {
|
|
418
|
+
return true;
|
|
419
|
+
}
|
|
420
|
+
if (previousValue instanceof RegExp || currentValue instanceof RegExp) {
|
|
421
|
+
if (!(previousValue instanceof RegExp) || !(currentValue instanceof RegExp)) {
|
|
422
|
+
return false;
|
|
423
|
+
}
|
|
424
|
+
return previousValue.source === currentValue.source && previousValue.flags === currentValue.flags;
|
|
425
|
+
}
|
|
426
|
+
if (isArray(previousValue) && isArray(currentValue)) {
|
|
427
|
+
if (previousValue.length !== currentValue.length) {
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
for (var index = 0; index < previousValue.length; index++) {
|
|
431
|
+
if (!areEquivalentSettingsValue(previousValue[index], currentValue[index])) {
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
if (isArray(previousValue) || isArray(currentValue)) {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
if (!isObjectLike(previousValue) || !isObjectLike(currentValue)) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
if (!isPlainObject(previousValue) || !isPlainObject(currentValue)) {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
var previousKeys = Object.keys(previousValue);
|
|
447
|
+
var currentKeys = Object.keys(currentValue);
|
|
448
|
+
if (previousKeys.length !== currentKeys.length) {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
for (var _i = 0, _previousKeys = previousKeys; _i < _previousKeys.length; _i++) {
|
|
452
|
+
var key = _previousKeys[_i];
|
|
453
|
+
if (!Object.prototype.hasOwnProperty.call(currentValue, key)) {
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
if (!areEquivalentSettingsValue(previousValue[key], currentValue[key])) {
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* A variant of useEffect hook that does not trigger on initial mount, only updates
|
|
465
|
+
*
|
|
466
|
+
* @param effect Effect function
|
|
467
|
+
* @param deps Effect dependencies
|
|
468
|
+
*/
|
|
469
|
+
function useUpdateEffect(effect, deps) {
|
|
470
|
+
var notInitialRender = React__default["default"].useRef(false);
|
|
471
|
+
React.useEffect(function () {
|
|
472
|
+
if (notInitialRender.current) {
|
|
473
|
+
return effect();
|
|
474
|
+
} else {
|
|
475
|
+
notInitialRender.current = true;
|
|
476
|
+
}
|
|
477
|
+
}, deps);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Only `dataSchema` and `columns` use deep comparison when diffing props for `updateSettings(false)`.
|
|
482
|
+
* Other object settings (for example `mergeCells`, `cell`, `nestedHeaders`, hooks) stay on strict
|
|
483
|
+
* reference equality so we avoid expensive deep walks and accidental false positives where functions
|
|
484
|
+
* or class instances would not compare meaningfully by keys alone.
|
|
485
|
+
*/
|
|
486
|
+
var DEEP_COMPARABLE_SETTINGS = ['dataSchema', 'columns'];
|
|
387
487
|
var SettingsMapper = /*#__PURE__*/function () {
|
|
388
488
|
function SettingsMapper() {
|
|
389
489
|
_classCallCheck(this, SettingsMapper);
|
|
@@ -391,14 +491,14 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
391
491
|
return _createClass(SettingsMapper, null, [{
|
|
392
492
|
key: "getSettings",
|
|
393
493
|
value:
|
|
394
|
-
/**
|
|
395
|
-
* Parse component settings into Handsontable-compatible settings.
|
|
396
|
-
*
|
|
397
|
-
* @param {Object} properties Object containing properties from the HotTable object.
|
|
398
|
-
* @param {Object} additionalSettings Additional settings.
|
|
399
|
-
* @param {boolean} additionalSettings.isInit Flag determining whether the settings are being set during initialization.
|
|
400
|
-
* @param {string[]} additionalSettings.initOnlySettingKeys Array of keys that can be set only during initialization.
|
|
401
|
-
* @returns {Object} Handsontable-compatible settings object.
|
|
494
|
+
/**
|
|
495
|
+
* Parse component settings into Handsontable-compatible settings.
|
|
496
|
+
*
|
|
497
|
+
* @param {Object} properties Object containing properties from the HotTable object.
|
|
498
|
+
* @param {Object} additionalSettings Additional settings.
|
|
499
|
+
* @param {boolean} additionalSettings.isInit Flag determining whether the settings are being set during initialization.
|
|
500
|
+
* @param {string[]} additionalSettings.initOnlySettingKeys Array of keys that can be set only during initialization.
|
|
501
|
+
* @returns {Object} Handsontable-compatible settings object.
|
|
402
502
|
*/
|
|
403
503
|
function getSettings(properties) {
|
|
404
504
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
@@ -409,9 +509,11 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
409
509
|
_ref$initOnlySettingK = _ref.initOnlySettingKeys,
|
|
410
510
|
initOnlySettingKeys = _ref$initOnlySettingK === void 0 ? [] : _ref$initOnlySettingK;
|
|
411
511
|
var shouldSkipProp = function shouldSkipProp(key) {
|
|
412
|
-
|
|
512
|
+
if (!isInit && DEEP_COMPARABLE_SETTINGS.includes(key)) {
|
|
513
|
+
return areEquivalentSettingsValue(prevProps[key], properties[key]);
|
|
514
|
+
}
|
|
413
515
|
if (!isInit && initOnlySettingKeys.includes(key)) {
|
|
414
|
-
return
|
|
516
|
+
return true;
|
|
415
517
|
}
|
|
416
518
|
return false;
|
|
417
519
|
};
|
|
@@ -426,7 +528,7 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
426
528
|
}]);
|
|
427
529
|
}();
|
|
428
530
|
|
|
429
|
-
var HotTableContext = React.createContext(undefined);
|
|
531
|
+
var HotTableContext = /*#__PURE__*/React.createContext(undefined);
|
|
430
532
|
var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
431
533
|
var children = _ref.children;
|
|
432
534
|
var columnsSettings = React.useRef([]);
|
|
@@ -446,6 +548,7 @@ var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
|
446
548
|
var getRendererWrapper = React.useCallback(function (Renderer) {
|
|
447
549
|
return function __internalRenderer(instance, TD, row, col, prop, value, cellProperties) {
|
|
448
550
|
var key = "".concat(row, "-").concat(col);
|
|
551
|
+
|
|
449
552
|
// Handsontable.Core type is missing guid
|
|
450
553
|
var instanceGuid = instance.guid;
|
|
451
554
|
var portalContainerKey = "".concat(instanceGuid, "-").concat(key);
|
|
@@ -459,11 +562,12 @@ var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
|
459
562
|
while (TD.firstChild) {
|
|
460
563
|
TD.removeChild(TD.firstChild);
|
|
461
564
|
}
|
|
565
|
+
|
|
462
566
|
// if portal already exists, do not recreate
|
|
463
567
|
if (cachedPortal && cachedPortalContainer) {
|
|
464
568
|
TD.appendChild(cachedPortalContainer);
|
|
465
569
|
} else {
|
|
466
|
-
var rendererElement = React__default["default"].createElement(Renderer, {
|
|
570
|
+
var rendererElement = /*#__PURE__*/React__default["default"].createElement(Renderer, {
|
|
467
571
|
instance: instance,
|
|
468
572
|
TD: TD,
|
|
469
573
|
row: row,
|
|
@@ -505,20 +609,21 @@ var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
|
505
609
|
pushCellPortalsIntoPortalManager: pushCellPortalsIntoPortalManager
|
|
506
610
|
};
|
|
507
611
|
}, [setHotColumnSettings, getRendererWrapper, clearRenderedCellCache, setRenderersPortalManagerRef, pushCellPortalsIntoPortalManager]);
|
|
508
|
-
return React__default["default"].createElement(HotTableContext.Provider, {
|
|
612
|
+
return /*#__PURE__*/React__default["default"].createElement(HotTableContext.Provider, {
|
|
509
613
|
value: contextImpl
|
|
510
614
|
}, children);
|
|
511
615
|
};
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
*
|
|
515
|
-
*
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Exposes the table context object to components
|
|
619
|
+
*
|
|
620
|
+
* @returns HotTableContext
|
|
516
621
|
*/
|
|
517
622
|
function useHotTableContext() {
|
|
518
623
|
return React.useContext(HotTableContext);
|
|
519
624
|
}
|
|
520
625
|
|
|
521
|
-
var HotColumnContext = React.createContext(undefined);
|
|
626
|
+
var HotColumnContext = /*#__PURE__*/React.createContext(undefined);
|
|
522
627
|
var HotColumnContextProvider = function HotColumnContextProvider(_ref) {
|
|
523
628
|
var columnIndex = _ref.columnIndex,
|
|
524
629
|
getOwnerDocument = _ref.getOwnerDocument,
|
|
@@ -529,7 +634,7 @@ var HotColumnContextProvider = function HotColumnContextProvider(_ref) {
|
|
|
529
634
|
getOwnerDocument: getOwnerDocument
|
|
530
635
|
};
|
|
531
636
|
}, [columnIndex, getOwnerDocument]);
|
|
532
|
-
return React__default["default"].createElement(HotColumnContext.Provider, {
|
|
637
|
+
return /*#__PURE__*/React__default["default"].createElement(HotColumnContext.Provider, {
|
|
533
638
|
value: contextImpl
|
|
534
639
|
}, children);
|
|
535
640
|
};
|
|
@@ -545,12 +650,13 @@ var MethodsMap = {
|
|
|
545
650
|
prepare: 'onPrepare',
|
|
546
651
|
focus: 'onFocus'
|
|
547
652
|
};
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
* @param {RefObject}
|
|
553
|
-
* @
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Create a class to be passed to the Handsontable's settings.
|
|
656
|
+
*
|
|
657
|
+
* @param {RefObject<HotEditorHooks>} hooksRef Reference to component-based editor overridden hooks object.
|
|
658
|
+
* @param {RefObject} instanceRef Reference to Handsontable-native custom editor class instance.
|
|
659
|
+
* @returns {Function} A class to be passed to the Handsontable editor settings.
|
|
554
660
|
*/
|
|
555
661
|
function makeEditorClass(hooksRef, instanceRef) {
|
|
556
662
|
return /*#__PURE__*/function (_Handsontable$editors) {
|
|
@@ -574,8 +680,8 @@ function makeEditorClass(hooksRef, instanceRef) {
|
|
|
574
680
|
result = baseMethod.call.apply(baseMethod, [this].concat(args)); // call super
|
|
575
681
|
}
|
|
576
682
|
if (MethodsMap[propName] && (_hooksRef$current = hooksRef.current) !== null && _hooksRef$current !== void 0 && _hooksRef$current[MethodsMap[propName]]) {
|
|
577
|
-
var
|
|
578
|
-
result = (
|
|
683
|
+
var _ref;
|
|
684
|
+
result = (_ref = hooksRef.current[MethodsMap[propName]]).call.apply(_ref, [this].concat(args));
|
|
579
685
|
}
|
|
580
686
|
return result;
|
|
581
687
|
}.bind(_this);
|
|
@@ -605,31 +711,31 @@ function makeEditorClass(hooksRef, instanceRef) {
|
|
|
605
711
|
}]);
|
|
606
712
|
}(Handsontable__default["default"].editors.BaseEditor);
|
|
607
713
|
}
|
|
608
|
-
/**
|
|
609
|
-
* Context to provide Handsontable-native custom editor class instance to overridden hooks object.
|
|
714
|
+
/**
|
|
715
|
+
* Context to provide Handsontable-native custom editor class instance to overridden hooks object.
|
|
610
716
|
*/
|
|
611
|
-
var EditorContext = React.createContext(undefined);
|
|
612
|
-
/**
|
|
613
|
-
* Provider of the context that exposes Handsontable-native editor instance and passes hooks object
|
|
614
|
-
* for custom editor components.
|
|
615
|
-
*
|
|
616
|
-
* @param {Ref} hooksRef Reference for component-based editor overridden hooks object.
|
|
617
|
-
* @param {RefObject} hotCustomEditorInstanceRef Reference to Handsontable-native editor instance.
|
|
717
|
+
var EditorContext = /*#__PURE__*/React.createContext(undefined);
|
|
718
|
+
/**
|
|
719
|
+
* Provider of the context that exposes Handsontable-native editor instance and passes hooks object
|
|
720
|
+
* for custom editor components.
|
|
721
|
+
*
|
|
722
|
+
* @param {Ref} hooksRef Reference for component-based editor overridden hooks object.
|
|
723
|
+
* @param {RefObject} hotCustomEditorInstanceRef Reference to Handsontable-native editor instance.
|
|
618
724
|
*/
|
|
619
|
-
var EditorContextProvider = function EditorContextProvider(
|
|
620
|
-
var hooksRef =
|
|
621
|
-
hotCustomEditorInstanceRef =
|
|
622
|
-
children =
|
|
623
|
-
return React__default["default"].createElement(EditorContext.Provider, {
|
|
725
|
+
var EditorContextProvider = function EditorContextProvider(_ref2) {
|
|
726
|
+
var hooksRef = _ref2.hooksRef,
|
|
727
|
+
hotCustomEditorInstanceRef = _ref2.hotCustomEditorInstanceRef,
|
|
728
|
+
children = _ref2.children;
|
|
729
|
+
return /*#__PURE__*/React__default["default"].createElement(EditorContext.Provider, {
|
|
624
730
|
value: {
|
|
625
731
|
hooksRef: hooksRef,
|
|
626
732
|
hotCustomEditorInstanceRef: hotCustomEditorInstanceRef
|
|
627
733
|
}
|
|
628
734
|
}, children);
|
|
629
735
|
};
|
|
630
|
-
/**
|
|
631
|
-
* Applies editor overlay position/dimensions to an element.
|
|
632
|
-
* @returns true if position was applied, false if editor should close (e.g. cell no longer available).
|
|
736
|
+
/**
|
|
737
|
+
* Applies editor overlay position/dimensions to an element.
|
|
738
|
+
* @returns true if position was applied, false if editor should close (e.g. cell no longer available).
|
|
633
739
|
*/
|
|
634
740
|
function applyEditorPosition(el, editor, hot, td) {
|
|
635
741
|
var _rootWindow$pageXOffs, _rootWindow$pageYOffs;
|
|
@@ -679,17 +785,18 @@ function applyEditorPosition(el, editor, hot, td) {
|
|
|
679
785
|
}
|
|
680
786
|
return false;
|
|
681
787
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
* @param {
|
|
687
|
-
* @
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Hook that allows encapsulating custom behaviours of component-based editor by customizing passed ref with overridden hooks object.
|
|
791
|
+
*
|
|
792
|
+
* @param {HotEditorHooks} overriddenHooks Overrides specific for the custom editor.
|
|
793
|
+
* @param {DependencyList} deps Overridden hooks object React dependency list.
|
|
794
|
+
* @returns {UseHotEditorImpl} Editor API methods
|
|
688
795
|
*/
|
|
689
796
|
function useHotEditor(overriddenHooks, deps) {
|
|
690
|
-
var
|
|
691
|
-
hooksRef =
|
|
692
|
-
hotCustomEditorInstanceRef =
|
|
797
|
+
var _ref3 = React.useContext(EditorContext),
|
|
798
|
+
hooksRef = _ref3.hooksRef,
|
|
799
|
+
hotCustomEditorInstanceRef = _ref3.hotCustomEditorInstanceRef;
|
|
693
800
|
var _useState = React.useState(0),
|
|
694
801
|
_useState2 = _slicedToArray(_useState, 2),
|
|
695
802
|
rerenderTrigger = _useState2[0],
|
|
@@ -698,6 +805,7 @@ function useHotEditor(overriddenHooks, deps) {
|
|
|
698
805
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
699
806
|
editorValue = _useState4[0],
|
|
700
807
|
setEditorValue = _useState4[1];
|
|
808
|
+
|
|
701
809
|
// return a deferred value that allows for optimizing performance by delaying the update of a value until the next render.
|
|
702
810
|
var deferredValue = React.useDeferredValue(editorValue);
|
|
703
811
|
React.useImperativeHandle(hooksRef, function () {
|
|
@@ -741,23 +849,28 @@ function useHotEditor(overriddenHooks, deps) {
|
|
|
741
849
|
};
|
|
742
850
|
}, [rerenderTrigger, hotCustomEditorInstanceRef, deferredValue]);
|
|
743
851
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
852
|
+
|
|
853
|
+
// Render prop function type
|
|
854
|
+
|
|
855
|
+
// EditorComponent props - children typed to work with JSX syntax
|
|
856
|
+
|
|
857
|
+
function EditorComponent(_ref4) {
|
|
858
|
+
var _onPrepare = _ref4.onPrepare,
|
|
859
|
+
_onClose = _ref4.onClose,
|
|
860
|
+
_onOpen = _ref4.onOpen,
|
|
861
|
+
_onFocus = _ref4.onFocus,
|
|
862
|
+
children = _ref4.children,
|
|
863
|
+
_ref4$shortcutsGroup = _ref4.shortcutsGroup,
|
|
864
|
+
shortcutsGroup = _ref4$shortcutsGroup === void 0 ? "custom-editor" : _ref4$shortcutsGroup,
|
|
865
|
+
shortcuts = _ref4.shortcuts;
|
|
753
866
|
var mainElementRef = React.useRef(null);
|
|
754
867
|
var currentValue = React.useRef(undefined);
|
|
755
868
|
var _useState5 = React.useState(),
|
|
756
869
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
757
870
|
themeClassName = _useState6[0],
|
|
758
871
|
setThemeClassName = _useState6[1];
|
|
759
|
-
var
|
|
760
|
-
hotCustomEditorInstanceRef =
|
|
872
|
+
var _ref5 = React.useContext(EditorContext),
|
|
873
|
+
hotCustomEditorInstanceRef = _ref5.hotCustomEditorInstanceRef;
|
|
761
874
|
var registerShortcuts = React.useCallback(function () {
|
|
762
875
|
var _hotCustomEditorInsta8, _hotCustomEditorInsta9, _hotCustomEditorInsta0;
|
|
763
876
|
if (!((_hotCustomEditorInsta8 = hotCustomEditorInstanceRef.current) !== null && _hotCustomEditorInsta8 !== void 0 && _hotCustomEditorInsta8.hot)) return;
|
|
@@ -860,7 +973,7 @@ function EditorComponent(_ref2) {
|
|
|
860
973
|
var stopMousedownPropagation = function stopMousedownPropagation(e) {
|
|
861
974
|
e.stopPropagation();
|
|
862
975
|
};
|
|
863
|
-
return React__default["default"].createElement("div", {
|
|
976
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
864
977
|
ref: mainElementRef,
|
|
865
978
|
className: themeClassName,
|
|
866
979
|
style: {
|
|
@@ -895,22 +1008,25 @@ var HotColumn = function HotColumn(props) {
|
|
|
895
1008
|
var _useHotColumnContext = useHotColumnContext(),
|
|
896
1009
|
columnIndex = _useHotColumnContext.columnIndex,
|
|
897
1010
|
getOwnerDocument = _useHotColumnContext.getOwnerDocument;
|
|
898
|
-
|
|
899
|
-
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Reference to component-based editor overridden hooks object.
|
|
900
1014
|
*/
|
|
901
1015
|
var localEditorHooksRef = React.useRef(null);
|
|
902
|
-
|
|
903
|
-
|
|
1016
|
+
|
|
1017
|
+
/**
|
|
1018
|
+
* Reference to HOT-native custom editor class instance.
|
|
904
1019
|
*/
|
|
905
1020
|
var localEditorClassInstance = React.useRef(null);
|
|
906
|
-
|
|
907
|
-
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Logic performed after mounting & updating of the HotColumn component.
|
|
908
1024
|
*/
|
|
909
1025
|
React.useEffect(function () {
|
|
910
|
-
/**
|
|
911
|
-
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
|
912
|
-
*
|
|
913
|
-
* @returns {Object}
|
|
1026
|
+
/**
|
|
1027
|
+
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
|
1028
|
+
*
|
|
1029
|
+
* @returns {Object}
|
|
914
1030
|
*/
|
|
915
1031
|
var getSettingsProps = function getSettingsProps() {
|
|
916
1032
|
return Object.keys(props).filter(function (key) {
|
|
@@ -920,8 +1036,9 @@ var HotColumn = function HotColumn(props) {
|
|
|
920
1036
|
return obj;
|
|
921
1037
|
}, {});
|
|
922
1038
|
};
|
|
923
|
-
|
|
924
|
-
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Create the column settings based on the data provided to the `HotColumn` component and its child components.
|
|
925
1042
|
*/
|
|
926
1043
|
var createColumnSettings = function createColumnSettings() {
|
|
927
1044
|
var columnSettings = SettingsMapper.getSettings(getSettingsProps());
|
|
@@ -945,23 +1062,24 @@ var HotColumn = function HotColumn(props) {
|
|
|
945
1062
|
}
|
|
946
1063
|
});
|
|
947
1064
|
var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
*
|
|
951
|
-
*
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Render the portals of the editors, if there are any.
|
|
1068
|
+
*
|
|
1069
|
+
* @returns {ReactElement}
|
|
952
1070
|
*/
|
|
953
|
-
return React__default["default"].createElement(EditorContextProvider, {
|
|
1071
|
+
return /*#__PURE__*/React__default["default"].createElement(EditorContextProvider, {
|
|
954
1072
|
hooksRef: localEditorHooksRef,
|
|
955
1073
|
hotCustomEditorInstanceRef: localEditorClassInstance
|
|
956
1074
|
}, editorPortal);
|
|
957
1075
|
};
|
|
958
1076
|
|
|
959
|
-
var version="17.0
|
|
1077
|
+
var version="17.1.0-rc3";
|
|
960
1078
|
|
|
961
|
-
/**
|
|
962
|
-
* Component used to manage the renderer component portals.
|
|
1079
|
+
/**
|
|
1080
|
+
* Component used to manage the renderer component portals.
|
|
963
1081
|
*/
|
|
964
|
-
var RenderersPortalManager = React.forwardRef(function (_, ref) {
|
|
1082
|
+
var RenderersPortalManager = /*#__PURE__*/React.forwardRef(function (_, ref) {
|
|
965
1083
|
var _useState = React.useState([]),
|
|
966
1084
|
_useState2 = _slicedToArray(_useState, 2),
|
|
967
1085
|
portals = _useState2[0],
|
|
@@ -969,7 +1087,7 @@ var RenderersPortalManager = React.forwardRef(function (_, ref) {
|
|
|
969
1087
|
React.useImperativeHandle(ref, function () {
|
|
970
1088
|
return setPortals;
|
|
971
1089
|
});
|
|
972
|
-
return React__default["default"].createElement(React.Fragment, null, portals);
|
|
1090
|
+
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, portals);
|
|
973
1091
|
});
|
|
974
1092
|
|
|
975
1093
|
function getDefaultExportFromCjs (x) {
|
|
@@ -2095,33 +2213,39 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
2095
2213
|
var propTypesExports = propTypes.exports;
|
|
2096
2214
|
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
2097
2215
|
|
|
2098
|
-
var HotTableInner = React.forwardRef(function (props, ref) {
|
|
2099
|
-
/**
|
|
2100
|
-
* Reference to the Handsontable instance.
|
|
2216
|
+
var HotTableInner = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
2217
|
+
/**
|
|
2218
|
+
* Reference to the Handsontable instance.
|
|
2101
2219
|
*/
|
|
2102
2220
|
var __hotInstance = React.useRef(null);
|
|
2103
|
-
|
|
2104
|
-
|
|
2221
|
+
|
|
2222
|
+
/**
|
|
2223
|
+
* Reference to the main Handsontable DOM element.
|
|
2105
2224
|
*/
|
|
2106
2225
|
var hotElementRef = React.useRef(null);
|
|
2107
|
-
|
|
2108
|
-
|
|
2226
|
+
|
|
2227
|
+
/**
|
|
2228
|
+
* Reference to component-based editor overridden hooks object.
|
|
2109
2229
|
*/
|
|
2110
2230
|
var globalEditorHooksRef = React.useRef(null);
|
|
2111
|
-
|
|
2112
|
-
|
|
2231
|
+
|
|
2232
|
+
/**
|
|
2233
|
+
* Reference to HOT-native custom editor class instance.
|
|
2113
2234
|
*/
|
|
2114
2235
|
var globalEditorClassInstance = React.useRef(null);
|
|
2115
|
-
|
|
2116
|
-
|
|
2236
|
+
|
|
2237
|
+
/**
|
|
2238
|
+
* Reference to the previous props object.
|
|
2117
2239
|
*/
|
|
2118
2240
|
var prevProps = React.useRef();
|
|
2119
|
-
|
|
2120
|
-
|
|
2241
|
+
|
|
2242
|
+
/**
|
|
2243
|
+
* HotTable context exposing helper functions.
|
|
2121
2244
|
*/
|
|
2122
2245
|
var context = useHotTableContext();
|
|
2123
|
-
|
|
2124
|
-
|
|
2246
|
+
|
|
2247
|
+
/**
|
|
2248
|
+
* Getter for the property storing the Handsontable instance.
|
|
2125
2249
|
*/
|
|
2126
2250
|
var getHotInstance = React.useCallback(function () {
|
|
2127
2251
|
if (!__hotInstance.current || !__hotInstance.current.isDestroyed) {
|
|
@@ -2135,17 +2259,19 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
2135
2259
|
var isHotInstanceDestroyed = React.useCallback(function () {
|
|
2136
2260
|
return !__hotInstance.current || __hotInstance.current.isDestroyed;
|
|
2137
2261
|
}, [__hotInstance]);
|
|
2138
|
-
|
|
2139
|
-
|
|
2262
|
+
|
|
2263
|
+
/**
|
|
2264
|
+
* Clear both the editor and the renderer cache.
|
|
2140
2265
|
*/
|
|
2141
2266
|
var clearCache = React.useCallback(function () {
|
|
2142
2267
|
context.clearRenderedCellCache();
|
|
2143
2268
|
context.componentRendererColumns.clear();
|
|
2144
2269
|
}, [context]);
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
*
|
|
2148
|
-
*
|
|
2270
|
+
|
|
2271
|
+
/**
|
|
2272
|
+
* Get the `Document` object corresponding to the main component element.
|
|
2273
|
+
*
|
|
2274
|
+
* @returns The `Document` object used by the component.
|
|
2149
2275
|
*/
|
|
2150
2276
|
var getOwnerDocument = React.useCallback(function () {
|
|
2151
2277
|
if (isCSR()) {
|
|
@@ -2153,10 +2279,11 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
2153
2279
|
}
|
|
2154
2280
|
return null;
|
|
2155
2281
|
}, [hotElementRef]);
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
*
|
|
2159
|
-
*
|
|
2282
|
+
|
|
2283
|
+
/**
|
|
2284
|
+
* Create a new settings object containing the column settings and global editors and renderers.
|
|
2285
|
+
*
|
|
2286
|
+
* @returns {Handsontable.GridSettings} New global set of settings for Handsontable.
|
|
2160
2287
|
*/
|
|
2161
2288
|
var createNewGlobalSettings = function createNewGlobalSettings() {
|
|
2162
2289
|
var _getHotInstance;
|
|
@@ -2186,8 +2313,9 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
2186
2313
|
}
|
|
2187
2314
|
return newSettings;
|
|
2188
2315
|
};
|
|
2189
|
-
|
|
2190
|
-
|
|
2316
|
+
|
|
2317
|
+
/**
|
|
2318
|
+
* Detect if `autoRowSize` or `autoColumnSize` is defined, and if so, throw an incompatibility warning.
|
|
2191
2319
|
*/
|
|
2192
2320
|
var displayAutoSizeWarning = function displayAutoSizeWarning(hotInstance) {
|
|
2193
2321
|
var _hotInstance$getPlugi, _hotInstance$getPlugi2;
|
|
@@ -2197,23 +2325,27 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
2197
2325
|
}
|
|
2198
2326
|
}
|
|
2199
2327
|
};
|
|
2200
|
-
|
|
2201
|
-
|
|
2328
|
+
|
|
2329
|
+
/**
|
|
2330
|
+
* Initialize Handsontable after the component has mounted.
|
|
2202
2331
|
*/
|
|
2203
2332
|
React.useEffect(function () {
|
|
2204
2333
|
var newGlobalSettings = createNewGlobalSettings(true);
|
|
2334
|
+
|
|
2205
2335
|
// Update prevProps with the current props
|
|
2206
2336
|
prevProps.current = props;
|
|
2207
2337
|
__hotInstance.current = new Handsontable__default["default"].Core(hotElementRef.current, newGlobalSettings);
|
|
2208
|
-
|
|
2209
|
-
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* Handsontable's `beforeViewRender` hook callback.
|
|
2210
2341
|
*/
|
|
2211
2342
|
__hotInstance.current.addHook('beforeViewRender', function () {
|
|
2212
2343
|
context.clearPortalCache();
|
|
2213
2344
|
context.clearRenderedCellCache();
|
|
2214
2345
|
});
|
|
2215
|
-
|
|
2216
|
-
|
|
2346
|
+
|
|
2347
|
+
/**
|
|
2348
|
+
* Handsontable's `afterViewRender` hook callback.
|
|
2217
2349
|
*/
|
|
2218
2350
|
__hotInstance.current.addHook('afterViewRender', function () {
|
|
2219
2351
|
context.pushCellPortalsIntoPortalManager();
|
|
@@ -2223,8 +2355,9 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
2223
2355
|
if (!displayObsoleteRenderersEditorsWarning(props.children)) {
|
|
2224
2356
|
displayChildrenOfTypeWarning(props.children, HotColumn);
|
|
2225
2357
|
}
|
|
2226
|
-
|
|
2227
|
-
|
|
2358
|
+
|
|
2359
|
+
/**
|
|
2360
|
+
* Destroy the Handsontable instance when the parent component unmounts.
|
|
2228
2361
|
*/
|
|
2229
2362
|
return function () {
|
|
2230
2363
|
var _getHotInstance2;
|
|
@@ -2232,21 +2365,24 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
2232
2365
|
(_getHotInstance2 = getHotInstance()) === null || _getHotInstance2 === void 0 || _getHotInstance2.destroy();
|
|
2233
2366
|
};
|
|
2234
2367
|
}, []);
|
|
2235
|
-
|
|
2236
|
-
|
|
2368
|
+
|
|
2369
|
+
/**
|
|
2370
|
+
* Logic performed after the component update.
|
|
2237
2371
|
*/
|
|
2238
2372
|
useUpdateEffect(function () {
|
|
2239
2373
|
clearCache();
|
|
2240
2374
|
var hotInstance = getHotInstance();
|
|
2241
2375
|
var newGlobalSettings = createNewGlobalSettings(false, prevProps.current);
|
|
2376
|
+
|
|
2242
2377
|
// Update prevProps with the current props
|
|
2243
2378
|
prevProps.current = props;
|
|
2244
2379
|
hotInstance === null || hotInstance === void 0 || hotInstance.updateSettings(newGlobalSettings, false);
|
|
2245
2380
|
displayAutoSizeWarning(hotInstance);
|
|
2246
2381
|
displayObsoleteRenderersEditorsWarning(props.children);
|
|
2247
2382
|
});
|
|
2248
|
-
|
|
2249
|
-
|
|
2383
|
+
|
|
2384
|
+
/**
|
|
2385
|
+
* Interface exposed to parent components by HotTable instance via React ref
|
|
2250
2386
|
*/
|
|
2251
2387
|
React.useImperativeHandle(ref, function () {
|
|
2252
2388
|
return {
|
|
@@ -2258,11 +2394,12 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
2258
2394
|
}
|
|
2259
2395
|
};
|
|
2260
2396
|
});
|
|
2261
|
-
|
|
2262
|
-
|
|
2397
|
+
|
|
2398
|
+
/**
|
|
2399
|
+
* Render the component.
|
|
2263
2400
|
*/
|
|
2264
2401
|
var hotColumnWrapped = React.Children.toArray(props.children).filter(isHotColumn).map(function (childNode, columnIndex) {
|
|
2265
|
-
return React__default["default"].createElement(HotColumnContextProvider, {
|
|
2402
|
+
return /*#__PURE__*/React__default["default"].createElement(HotColumnContextProvider, {
|
|
2266
2403
|
columnIndex: columnIndex,
|
|
2267
2404
|
getOwnerDocument: getOwnerDocument,
|
|
2268
2405
|
key: columnIndex
|
|
@@ -2270,17 +2407,18 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
2270
2407
|
});
|
|
2271
2408
|
var containerProps = getContainerAttributesProps(props);
|
|
2272
2409
|
var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
|
|
2273
|
-
return React__default["default"].createElement(React.Fragment, null, React__default["default"].createElement("div",
|
|
2410
|
+
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", _extends({
|
|
2274
2411
|
ref: hotElementRef
|
|
2275
|
-
}, containerProps), hotColumnWrapped), React__default["default"].createElement(RenderersPortalManager, {
|
|
2412
|
+
}, containerProps), hotColumnWrapped), /*#__PURE__*/React__default["default"].createElement(RenderersPortalManager, {
|
|
2276
2413
|
ref: context.setRenderersPortalManagerRef
|
|
2277
|
-
}), React__default["default"].createElement(EditorContextProvider, {
|
|
2414
|
+
}), /*#__PURE__*/React__default["default"].createElement(EditorContextProvider, {
|
|
2278
2415
|
hooksRef: globalEditorHooksRef,
|
|
2279
2416
|
hotCustomEditorInstanceRef: globalEditorClassInstance
|
|
2280
2417
|
}, editorPortal));
|
|
2281
2418
|
});
|
|
2282
|
-
|
|
2283
|
-
|
|
2419
|
+
|
|
2420
|
+
/**
|
|
2421
|
+
* Prop types to be checked at runtime.
|
|
2284
2422
|
*/
|
|
2285
2423
|
HotTableInner.propTypes = {
|
|
2286
2424
|
style: PropTypes.object,
|
|
@@ -2289,41 +2427,42 @@ HotTableInner.propTypes = {
|
|
|
2289
2427
|
};
|
|
2290
2428
|
|
|
2291
2429
|
var _excluded = ["children"];
|
|
2292
|
-
/**
|
|
2293
|
-
* A Handsontable-ReactJS wrapper.
|
|
2294
|
-
*
|
|
2295
|
-
* To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
|
|
2296
|
-
* For example:
|
|
2297
|
-
*
|
|
2298
|
-
* ```js
|
|
2299
|
-
* <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
|
|
2300
|
-
*
|
|
2301
|
-
* // is analogous to
|
|
2302
|
-
* let hot = new Handsontable(document.getElementById('hot'), {
|
|
2303
|
-
* data: dataObject,
|
|
2304
|
-
* contextMenu: true,
|
|
2305
|
-
* colHeaders: true,
|
|
2306
|
-
* width: 600
|
|
2307
|
-
* height: 300
|
|
2308
|
-
* });
|
|
2309
|
-
*
|
|
2310
|
-
* ```
|
|
2430
|
+
/**
|
|
2431
|
+
* A Handsontable-ReactJS wrapper.
|
|
2432
|
+
*
|
|
2433
|
+
* To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
|
|
2434
|
+
* For example:
|
|
2435
|
+
*
|
|
2436
|
+
* ```js
|
|
2437
|
+
* <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
|
|
2438
|
+
*
|
|
2439
|
+
* // is analogous to
|
|
2440
|
+
* let hot = new Handsontable(document.getElementById('hot'), {
|
|
2441
|
+
* data: dataObject,
|
|
2442
|
+
* contextMenu: true,
|
|
2443
|
+
* colHeaders: true,
|
|
2444
|
+
* width: 600
|
|
2445
|
+
* height: 300
|
|
2446
|
+
* });
|
|
2447
|
+
*
|
|
2448
|
+
* ```
|
|
2311
2449
|
*/
|
|
2312
|
-
var HotTable = React.forwardRef(function (_ref, ref) {
|
|
2450
|
+
var HotTable = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
2313
2451
|
var _props$id;
|
|
2314
2452
|
var children = _ref.children,
|
|
2315
2453
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
2316
2454
|
var componentId = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : React.useId();
|
|
2317
|
-
return React__default["default"].createElement(HotTableContextProvider, null, React__default["default"].createElement(HotTableInner,
|
|
2455
|
+
return /*#__PURE__*/React__default["default"].createElement(HotTableContextProvider, null, /*#__PURE__*/React__default["default"].createElement(HotTableInner, _extends({
|
|
2318
2456
|
id: componentId
|
|
2319
2457
|
}, props, {
|
|
2320
2458
|
ref: ref
|
|
2321
2459
|
}), children));
|
|
2322
2460
|
});
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
*
|
|
2326
|
-
*
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* Package version.
|
|
2464
|
+
*
|
|
2465
|
+
* @returns The version number of the package.
|
|
2327
2466
|
*/
|
|
2328
2467
|
HotTable.version = version;
|
|
2329
2468
|
|