@handsontable/react-wrapper 17.0.1-rc2 → 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
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM
|
|
26
26
|
* USE OR INABILITY TO USE THIS SOFTWARE.
|
|
27
27
|
*
|
|
28
|
-
* Version: 17.0
|
|
28
|
+
* Version: 17.1.0-rc1 (built at Wed Apr 22 2026 11:56:16 GMT+0000 (Coordinated Universal Time))
|
|
29
29
|
*/
|
|
30
30
|
(function (global, factory) {
|
|
31
31
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('handsontable/base'), require('handsontable/renderers/registry'), require('handsontable/editors/registry')) :
|
|
@@ -39,190 +39,6 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
39
39
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultCompat(ReactDOM);
|
|
40
40
|
var Handsontable__default = /*#__PURE__*/_interopDefaultCompat(Handsontable);
|
|
41
41
|
|
|
42
|
-
var bulkComponentContainer = null;
|
|
43
|
-
/**
|
|
44
|
-
* Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
|
|
45
|
-
*/
|
|
46
|
-
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.';
|
|
47
|
-
/**
|
|
48
|
-
* Warning message for the `hot-renderer` obsolete renderer passing method.
|
|
49
|
-
*/
|
|
50
|
-
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.';
|
|
51
|
-
/**
|
|
52
|
-
* Warning message for the `hot-editor` obsolete editor passing method.
|
|
53
|
-
*/
|
|
54
|
-
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.';
|
|
55
|
-
/**
|
|
56
|
-
* Warning message for the unexpected children of HotTable component.
|
|
57
|
-
*/
|
|
58
|
-
var UNEXPECTED_HOTTABLE_CHILDREN_WARNING = 'Unexpected children nodes found in HotTable component. ' + 'Only HotColumn components are allowed.';
|
|
59
|
-
/**
|
|
60
|
-
* Warning message for the unexpected children of HotColumn component.
|
|
61
|
-
*/
|
|
62
|
-
var UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING = 'Unexpected children nodes found in HotColumn component. ' + 'HotColumn components do not support any children.';
|
|
63
|
-
/**
|
|
64
|
-
* Message for the warning thrown if the Handsontable instance has been destroyed.
|
|
65
|
-
*/
|
|
66
|
-
var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.';
|
|
67
|
-
/**
|
|
68
|
-
* Default classname given to the wrapper container.
|
|
69
|
-
*/
|
|
70
|
-
var DEFAULT_CLASSNAME = 'hot-wrapper-editor-container';
|
|
71
|
-
/**
|
|
72
|
-
* Logs warn to the console if the `console` object is exposed.
|
|
73
|
-
*
|
|
74
|
-
* @param {...*} args Values which will be logged.
|
|
75
|
-
*/
|
|
76
|
-
function warn() {
|
|
77
|
-
if (typeof console !== 'undefined') {
|
|
78
|
-
var _console;
|
|
79
|
-
(_console = console).warn.apply(_console, arguments);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Detect if `hot-renderer` or `hot-editor` is defined, and if so, throw an incompatibility warning.
|
|
84
|
-
*
|
|
85
|
-
* @returns {boolean} 'true' if the warning was issued
|
|
86
|
-
*/
|
|
87
|
-
function displayObsoleteRenderersEditorsWarning(children) {
|
|
88
|
-
if (hasChildElementOfType(children, 'hot-renderer')) {
|
|
89
|
-
warn(OBSOLETE_HOTRENDERER_WARNING);
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
if (hasChildElementOfType(children, 'hot-editor')) {
|
|
93
|
-
warn(OBSOLETE_HOTEDITOR_WARNING);
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Detect if children of specified type are defined, and if so, throw an incompatibility warning.
|
|
100
|
-
*
|
|
101
|
-
* @param {ReactNode} children Component children nodes
|
|
102
|
-
* @param {ComponentType} Component Component type to check
|
|
103
|
-
* @returns {boolean} 'true' if the warning was issued
|
|
104
|
-
*/
|
|
105
|
-
function displayChildrenOfTypeWarning(children, Component) {
|
|
106
|
-
var childrenArray = React__default["default"].Children.toArray(children);
|
|
107
|
-
if (childrenArray.some(function (child) {
|
|
108
|
-
return child.type !== Component;
|
|
109
|
-
})) {
|
|
110
|
-
warn(UNEXPECTED_HOTTABLE_CHILDREN_WARNING);
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Detect if children is defined, and if so, throw an incompatibility warning.
|
|
117
|
-
*
|
|
118
|
-
* @param {ReactNode} children Component children nodes
|
|
119
|
-
* @returns {boolean} 'true' if the warning was issued
|
|
120
|
-
*/
|
|
121
|
-
function displayAnyChildrenWarning(children) {
|
|
122
|
-
var childrenArray = React__default["default"].Children.toArray(children);
|
|
123
|
-
if (childrenArray.length) {
|
|
124
|
-
warn(UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING);
|
|
125
|
-
return true;
|
|
126
|
-
}
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Check the existence of elements of the provided `type` from the `HotColumn` component's children.
|
|
131
|
-
*
|
|
132
|
-
* @param {ReactNode} children HotTable children array.
|
|
133
|
-
* @param {String} type Either `'hot-renderer'` or `'hot-editor'`.
|
|
134
|
-
* @returns {boolean} `true` if the child of that type was found, `false` otherwise.
|
|
135
|
-
*/
|
|
136
|
-
function hasChildElementOfType(children, type) {
|
|
137
|
-
var childrenArray = React__default["default"].Children.toArray(children);
|
|
138
|
-
return childrenArray.some(function (child) {
|
|
139
|
-
return child.props[type] !== void 0;
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Create an editor portal.
|
|
144
|
-
*
|
|
145
|
-
* @param {Document} doc Document to be used.
|
|
146
|
-
* @param {ComponentType} Editor Editor component or render function.
|
|
147
|
-
* @returns {ReactPortal} The portal for the editor.
|
|
148
|
-
*/
|
|
149
|
-
function createEditorPortal(doc, Editor) {
|
|
150
|
-
if (!doc || !Editor || typeof Editor === 'boolean') {
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
var editorElement = React__default["default"].createElement(Editor, null);
|
|
154
|
-
var containerProps = getContainerAttributesProps({}, false);
|
|
155
|
-
containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
|
|
156
|
-
return ReactDOM__default["default"].createPortal(React__default["default"].createElement("div", Object.assign({}, containerProps), editorElement), doc.body);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Render a cell component to an external DOM node.
|
|
160
|
-
*
|
|
161
|
-
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
162
|
-
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
163
|
-
* @param {String} portalKey The key to be used for the portal.
|
|
164
|
-
* @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
|
|
165
|
-
* @returns {{portal: ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
|
166
|
-
*/
|
|
167
|
-
function createPortal(rElement) {
|
|
168
|
-
var ownerDocument = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
169
|
-
var portalKey = arguments.length > 2 ? arguments[2] : undefined;
|
|
170
|
-
var cachedContainer = arguments.length > 3 ? arguments[3] : undefined;
|
|
171
|
-
if (!ownerDocument) {
|
|
172
|
-
ownerDocument = document;
|
|
173
|
-
}
|
|
174
|
-
if (!bulkComponentContainer) {
|
|
175
|
-
bulkComponentContainer = ownerDocument.createDocumentFragment();
|
|
176
|
-
}
|
|
177
|
-
var portalContainer = cachedContainer !== null && cachedContainer !== void 0 ? cachedContainer : ownerDocument.createElement('DIV');
|
|
178
|
-
bulkComponentContainer.appendChild(portalContainer);
|
|
179
|
-
return {
|
|
180
|
-
portal: ReactDOM__default["default"].createPortal(rElement, portalContainer, portalKey),
|
|
181
|
-
portalContainer: portalContainer
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Get an object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
186
|
-
* component.
|
|
187
|
-
*
|
|
188
|
-
* @param {HotTableProps} props Object containing the React element props.
|
|
189
|
-
* @param {Boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was present in the `prop` object.
|
|
190
|
-
* @returns An object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
191
|
-
* component.
|
|
192
|
-
*/
|
|
193
|
-
function getContainerAttributesProps(props) {
|
|
194
|
-
var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
195
|
-
return {
|
|
196
|
-
id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : undefined),
|
|
197
|
-
className: props.className || '',
|
|
198
|
-
style: props.style || {}
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Checks if the environment that the code runs in is a browser.
|
|
203
|
-
*
|
|
204
|
-
* @returns {boolean}
|
|
205
|
-
*/
|
|
206
|
-
function isCSR() {
|
|
207
|
-
return typeof window !== 'undefined';
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* A variant of useEffect hook that does not trigger on initial mount, only updates
|
|
211
|
-
*
|
|
212
|
-
* @param effect Effect function
|
|
213
|
-
* @param deps Effect dependencies
|
|
214
|
-
*/
|
|
215
|
-
function useUpdateEffect(effect, deps) {
|
|
216
|
-
var notInitialRender = React__default["default"].useRef(false);
|
|
217
|
-
React.useEffect(function () {
|
|
218
|
-
if (notInitialRender.current) {
|
|
219
|
-
return effect();
|
|
220
|
-
} else {
|
|
221
|
-
notInitialRender.current = true;
|
|
222
|
-
}
|
|
223
|
-
}, deps);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
42
|
function _arrayLikeToArray(r, a) {
|
|
227
43
|
(null == a || a > r.length) && (a = r.length);
|
|
228
44
|
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
@@ -263,6 +79,15 @@ function _defineProperty(e, r, t) {
|
|
|
263
79
|
writable: true
|
|
264
80
|
}) : e[r] = t, e;
|
|
265
81
|
}
|
|
82
|
+
function _extends() {
|
|
83
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
84
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
85
|
+
var t = arguments[e];
|
|
86
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
87
|
+
}
|
|
88
|
+
return n;
|
|
89
|
+
}, _extends.apply(null, arguments);
|
|
90
|
+
}
|
|
266
91
|
function _getPrototypeOf(t) {
|
|
267
92
|
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
268
93
|
return t.__proto__ || Object.getPrototypeOf(t);
|
|
@@ -392,6 +217,15 @@ function _toPropertyKey(t) {
|
|
|
392
217
|
var i = _toPrimitive(t, "string");
|
|
393
218
|
return "symbol" == typeof i ? i : i + "";
|
|
394
219
|
}
|
|
220
|
+
function _typeof(o) {
|
|
221
|
+
"@babel/helpers - typeof";
|
|
222
|
+
|
|
223
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
224
|
+
return typeof o;
|
|
225
|
+
} : function (o) {
|
|
226
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
227
|
+
}, _typeof(o);
|
|
228
|
+
}
|
|
395
229
|
function _unsupportedIterableToArray(r, a) {
|
|
396
230
|
if (r) {
|
|
397
231
|
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
@@ -400,6 +234,281 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
400
234
|
}
|
|
401
235
|
}
|
|
402
236
|
|
|
237
|
+
var bulkComponentContainer = null;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Warning message for the `autoRowSize`/`autoColumnSize` compatibility check.
|
|
241
|
+
*/
|
|
242
|
+
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.';
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Warning message for the `hot-renderer` obsolete renderer passing method.
|
|
246
|
+
*/
|
|
247
|
+
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.';
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Warning message for the `hot-editor` obsolete editor passing method.
|
|
251
|
+
*/
|
|
252
|
+
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.';
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Warning message for the unexpected children of HotTable component.
|
|
256
|
+
*/
|
|
257
|
+
var UNEXPECTED_HOTTABLE_CHILDREN_WARNING = 'Unexpected children nodes found in HotTable component. ' + 'Only HotColumn components are allowed.';
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Warning message for the unexpected children of HotColumn component.
|
|
261
|
+
*/
|
|
262
|
+
var UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING = 'Unexpected children nodes found in HotColumn component. ' + 'HotColumn components do not support any children.';
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Message for the warning thrown if the Handsontable instance has been destroyed.
|
|
266
|
+
*/
|
|
267
|
+
var HOT_DESTROYED_WARNING = 'The Handsontable instance bound to this component was destroyed and cannot be' + ' used properly.';
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Default classname given to the wrapper container.
|
|
271
|
+
*/
|
|
272
|
+
var DEFAULT_CLASSNAME = 'hot-wrapper-editor-container';
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Logs warn to the console if the `console` object is exposed.
|
|
276
|
+
*
|
|
277
|
+
* @param {...*} args Values which will be logged.
|
|
278
|
+
*/
|
|
279
|
+
function warn() {
|
|
280
|
+
if (typeof console !== 'undefined') {
|
|
281
|
+
var _console;
|
|
282
|
+
(_console = console).warn.apply(_console, arguments);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Detect if `hot-renderer` or `hot-editor` is defined, and if so, throw an incompatibility warning.
|
|
288
|
+
*
|
|
289
|
+
* @returns {boolean} 'true' if the warning was issued
|
|
290
|
+
*/
|
|
291
|
+
function displayObsoleteRenderersEditorsWarning(children) {
|
|
292
|
+
if (hasChildElementOfType(children, 'hot-renderer')) {
|
|
293
|
+
warn(OBSOLETE_HOTRENDERER_WARNING);
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
if (hasChildElementOfType(children, 'hot-editor')) {
|
|
297
|
+
warn(OBSOLETE_HOTEDITOR_WARNING);
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Detect if children of specified type are defined, and if so, throw an incompatibility warning.
|
|
305
|
+
*
|
|
306
|
+
* @param {ReactNode} children Component children nodes
|
|
307
|
+
* @param {ComponentType} Component Component type to check
|
|
308
|
+
* @returns {boolean} 'true' if the warning was issued
|
|
309
|
+
*/
|
|
310
|
+
function displayChildrenOfTypeWarning(children, Component) {
|
|
311
|
+
var childrenArray = React__default["default"].Children.toArray(children);
|
|
312
|
+
if (childrenArray.some(function (child) {
|
|
313
|
+
return child.type !== Component;
|
|
314
|
+
})) {
|
|
315
|
+
warn(UNEXPECTED_HOTTABLE_CHILDREN_WARNING);
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Detect if children is defined, and if so, throw an incompatibility warning.
|
|
323
|
+
*
|
|
324
|
+
* @param {ReactNode} children Component children nodes
|
|
325
|
+
* @returns {boolean} 'true' if the warning was issued
|
|
326
|
+
*/
|
|
327
|
+
function displayAnyChildrenWarning(children) {
|
|
328
|
+
var childrenArray = React__default["default"].Children.toArray(children);
|
|
329
|
+
if (childrenArray.length) {
|
|
330
|
+
warn(UNEXPECTED_HOTCOLUMN_CHILDREN_WARNING);
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Check the existence of elements of the provided `type` from the `HotColumn` component's children.
|
|
338
|
+
*
|
|
339
|
+
* @param {ReactNode} children HotTable children array.
|
|
340
|
+
* @param {String} type Either `'hot-renderer'` or `'hot-editor'`.
|
|
341
|
+
* @returns {boolean} `true` if the child of that type was found, `false` otherwise.
|
|
342
|
+
*/
|
|
343
|
+
function hasChildElementOfType(children, type) {
|
|
344
|
+
var childrenArray = React__default["default"].Children.toArray(children);
|
|
345
|
+
return childrenArray.some(function (child) {
|
|
346
|
+
return child.props[type] !== void 0;
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Create an editor portal.
|
|
352
|
+
*
|
|
353
|
+
* @param {Document} doc Document to be used.
|
|
354
|
+
* @param {ComponentType} Editor Editor component or render function.
|
|
355
|
+
* @returns {ReactPortal} The portal for the editor.
|
|
356
|
+
*/
|
|
357
|
+
function createEditorPortal(doc, Editor) {
|
|
358
|
+
if (!doc || !Editor || typeof Editor === 'boolean') {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
var editorElement = /*#__PURE__*/React__default["default"].createElement(Editor, null);
|
|
362
|
+
var containerProps = getContainerAttributesProps({}, false);
|
|
363
|
+
containerProps.className = "".concat(DEFAULT_CLASSNAME, " ").concat(containerProps.className);
|
|
364
|
+
return /*#__PURE__*/ReactDOM__default["default"].createPortal(/*#__PURE__*/React__default["default"].createElement("div", containerProps, editorElement), doc.body);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Render a cell component to an external DOM node.
|
|
369
|
+
*
|
|
370
|
+
* @param {React.ReactElement} rElement React element to be used as a base for the component.
|
|
371
|
+
* @param {Document} [ownerDocument] The owner document to set the portal up into.
|
|
372
|
+
* @param {String} portalKey The key to be used for the portal.
|
|
373
|
+
* @param {HTMLElement} [cachedContainer] The cached container to be used for the portal.
|
|
374
|
+
* @returns {{portal: ReactPortal, portalContainer: HTMLElement}} An object containing the portal and its container.
|
|
375
|
+
*/
|
|
376
|
+
function createPortal(rElement) {
|
|
377
|
+
var ownerDocument = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
|
|
378
|
+
var portalKey = arguments.length > 2 ? arguments[2] : undefined;
|
|
379
|
+
var cachedContainer = arguments.length > 3 ? arguments[3] : undefined;
|
|
380
|
+
if (!ownerDocument) {
|
|
381
|
+
ownerDocument = document;
|
|
382
|
+
}
|
|
383
|
+
if (!bulkComponentContainer) {
|
|
384
|
+
bulkComponentContainer = ownerDocument.createDocumentFragment();
|
|
385
|
+
}
|
|
386
|
+
var portalContainer = cachedContainer !== null && cachedContainer !== void 0 ? cachedContainer : ownerDocument.createElement('DIV');
|
|
387
|
+
bulkComponentContainer.appendChild(portalContainer);
|
|
388
|
+
return {
|
|
389
|
+
portal: /*#__PURE__*/ReactDOM__default["default"].createPortal(rElement, portalContainer, portalKey),
|
|
390
|
+
portalContainer: portalContainer
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Get an object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
396
|
+
* component.
|
|
397
|
+
*
|
|
398
|
+
* @param {HotTableProps} props Object containing the React element props.
|
|
399
|
+
* @param {Boolean} randomizeId If set to `true`, the function will randomize the `id` property when no `id` was present in the `prop` object.
|
|
400
|
+
* @returns An object containing the `id`, `className` and `style` keys, representing the corresponding props passed to the
|
|
401
|
+
* component.
|
|
402
|
+
*/
|
|
403
|
+
function getContainerAttributesProps(props) {
|
|
404
|
+
var randomizeId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
405
|
+
return {
|
|
406
|
+
id: props.id || (randomizeId ? 'hot-' + Math.random().toString(36).substring(5) : undefined),
|
|
407
|
+
className: props.className || '',
|
|
408
|
+
style: props.style || {}
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Checks if the environment that the code runs in is a browser.
|
|
414
|
+
*
|
|
415
|
+
* @returns {boolean}
|
|
416
|
+
*/
|
|
417
|
+
function isCSR() {
|
|
418
|
+
return typeof window !== 'undefined';
|
|
419
|
+
}
|
|
420
|
+
function isObjectLike(value) {
|
|
421
|
+
return _typeof(value) === 'object' && value !== null;
|
|
422
|
+
}
|
|
423
|
+
function isPlainObject(value) {
|
|
424
|
+
if (!isObjectLike(value)) {
|
|
425
|
+
return false;
|
|
426
|
+
}
|
|
427
|
+
var prototype = Object.getPrototypeOf(value);
|
|
428
|
+
return prototype === Object.prototype || prototype === null;
|
|
429
|
+
}
|
|
430
|
+
function isArray(value) {
|
|
431
|
+
return Array.isArray(value);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Deep-compare plain objects and arrays used by wrapper settings.
|
|
436
|
+
*
|
|
437
|
+
* @param {unknown} previousValue Previous value.
|
|
438
|
+
* @param {unknown} currentValue Current value.
|
|
439
|
+
* @returns {boolean} `true` if values are equivalent.
|
|
440
|
+
*/
|
|
441
|
+
function areEquivalentSettingsValue(previousValue, currentValue) {
|
|
442
|
+
if (previousValue === currentValue) {
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
if (previousValue instanceof RegExp || currentValue instanceof RegExp) {
|
|
446
|
+
if (!(previousValue instanceof RegExp) || !(currentValue instanceof RegExp)) {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
return previousValue.source === currentValue.source && previousValue.flags === currentValue.flags;
|
|
450
|
+
}
|
|
451
|
+
if (isArray(previousValue) && isArray(currentValue)) {
|
|
452
|
+
if (previousValue.length !== currentValue.length) {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
for (var index = 0; index < previousValue.length; index++) {
|
|
456
|
+
if (!areEquivalentSettingsValue(previousValue[index], currentValue[index])) {
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return true;
|
|
461
|
+
}
|
|
462
|
+
if (isArray(previousValue) || isArray(currentValue)) {
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
if (!isObjectLike(previousValue) || !isObjectLike(currentValue)) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
if (!isPlainObject(previousValue) || !isPlainObject(currentValue)) {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
var previousKeys = Object.keys(previousValue);
|
|
472
|
+
var currentKeys = Object.keys(currentValue);
|
|
473
|
+
if (previousKeys.length !== currentKeys.length) {
|
|
474
|
+
return false;
|
|
475
|
+
}
|
|
476
|
+
for (var _i = 0, _previousKeys = previousKeys; _i < _previousKeys.length; _i++) {
|
|
477
|
+
var key = _previousKeys[_i];
|
|
478
|
+
if (!Object.prototype.hasOwnProperty.call(currentValue, key)) {
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
481
|
+
if (!areEquivalentSettingsValue(previousValue[key], currentValue[key])) {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* A variant of useEffect hook that does not trigger on initial mount, only updates
|
|
490
|
+
*
|
|
491
|
+
* @param effect Effect function
|
|
492
|
+
* @param deps Effect dependencies
|
|
493
|
+
*/
|
|
494
|
+
function useUpdateEffect(effect, deps) {
|
|
495
|
+
var notInitialRender = React__default["default"].useRef(false);
|
|
496
|
+
React.useEffect(function () {
|
|
497
|
+
if (notInitialRender.current) {
|
|
498
|
+
return effect();
|
|
499
|
+
} else {
|
|
500
|
+
notInitialRender.current = true;
|
|
501
|
+
}
|
|
502
|
+
}, deps);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Only `dataSchema` and `columns` use deep comparison when diffing props for `updateSettings(false)`.
|
|
507
|
+
* Other object settings (for example `mergeCells`, `cell`, `nestedHeaders`, hooks) stay on strict
|
|
508
|
+
* reference equality so we avoid expensive deep walks and accidental false positives where functions
|
|
509
|
+
* or class instances would not compare meaningfully by keys alone.
|
|
510
|
+
*/
|
|
511
|
+
var DEEP_COMPARABLE_SETTINGS = ['dataSchema', 'columns'];
|
|
403
512
|
var SettingsMapper = /*#__PURE__*/function () {
|
|
404
513
|
function SettingsMapper() {
|
|
405
514
|
_classCallCheck(this, SettingsMapper);
|
|
@@ -407,14 +516,14 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
407
516
|
return _createClass(SettingsMapper, null, [{
|
|
408
517
|
key: "getSettings",
|
|
409
518
|
value:
|
|
410
|
-
/**
|
|
411
|
-
* Parse component settings into Handsontable-compatible settings.
|
|
412
|
-
*
|
|
413
|
-
* @param {Object} properties Object containing properties from the HotTable object.
|
|
414
|
-
* @param {Object} additionalSettings Additional settings.
|
|
415
|
-
* @param {boolean} additionalSettings.isInit Flag determining whether the settings are being set during initialization.
|
|
416
|
-
* @param {string[]} additionalSettings.initOnlySettingKeys Array of keys that can be set only during initialization.
|
|
417
|
-
* @returns {Object} Handsontable-compatible settings object.
|
|
519
|
+
/**
|
|
520
|
+
* Parse component settings into Handsontable-compatible settings.
|
|
521
|
+
*
|
|
522
|
+
* @param {Object} properties Object containing properties from the HotTable object.
|
|
523
|
+
* @param {Object} additionalSettings Additional settings.
|
|
524
|
+
* @param {boolean} additionalSettings.isInit Flag determining whether the settings are being set during initialization.
|
|
525
|
+
* @param {string[]} additionalSettings.initOnlySettingKeys Array of keys that can be set only during initialization.
|
|
526
|
+
* @returns {Object} Handsontable-compatible settings object.
|
|
418
527
|
*/
|
|
419
528
|
function getSettings(properties) {
|
|
420
529
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
@@ -425,9 +534,11 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
425
534
|
_ref$initOnlySettingK = _ref.initOnlySettingKeys,
|
|
426
535
|
initOnlySettingKeys = _ref$initOnlySettingK === void 0 ? [] : _ref$initOnlySettingK;
|
|
427
536
|
var shouldSkipProp = function shouldSkipProp(key) {
|
|
428
|
-
|
|
537
|
+
if (!isInit && DEEP_COMPARABLE_SETTINGS.includes(key)) {
|
|
538
|
+
return areEquivalentSettingsValue(prevProps[key], properties[key]);
|
|
539
|
+
}
|
|
429
540
|
if (!isInit && initOnlySettingKeys.includes(key)) {
|
|
430
|
-
return
|
|
541
|
+
return true;
|
|
431
542
|
}
|
|
432
543
|
return false;
|
|
433
544
|
};
|
|
@@ -442,7 +553,7 @@ var SettingsMapper = /*#__PURE__*/function () {
|
|
|
442
553
|
}]);
|
|
443
554
|
}();
|
|
444
555
|
|
|
445
|
-
var HotTableContext = React.createContext(undefined);
|
|
556
|
+
var HotTableContext = /*#__PURE__*/React.createContext(undefined);
|
|
446
557
|
var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
447
558
|
var children = _ref.children;
|
|
448
559
|
var columnsSettings = React.useRef([]);
|
|
@@ -462,6 +573,7 @@ var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
|
462
573
|
var getRendererWrapper = React.useCallback(function (Renderer) {
|
|
463
574
|
return function __internalRenderer(instance, TD, row, col, prop, value, cellProperties) {
|
|
464
575
|
var key = "".concat(row, "-").concat(col);
|
|
576
|
+
|
|
465
577
|
// Handsontable.Core type is missing guid
|
|
466
578
|
var instanceGuid = instance.guid;
|
|
467
579
|
var portalContainerKey = "".concat(instanceGuid, "-").concat(key);
|
|
@@ -475,11 +587,12 @@ var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
|
475
587
|
while (TD.firstChild) {
|
|
476
588
|
TD.removeChild(TD.firstChild);
|
|
477
589
|
}
|
|
590
|
+
|
|
478
591
|
// if portal already exists, do not recreate
|
|
479
592
|
if (cachedPortal && cachedPortalContainer) {
|
|
480
593
|
TD.appendChild(cachedPortalContainer);
|
|
481
594
|
} else {
|
|
482
|
-
var rendererElement = React__default["default"].createElement(Renderer, {
|
|
595
|
+
var rendererElement = /*#__PURE__*/React__default["default"].createElement(Renderer, {
|
|
483
596
|
instance: instance,
|
|
484
597
|
TD: TD,
|
|
485
598
|
row: row,
|
|
@@ -521,20 +634,21 @@ var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
|
|
521
634
|
pushCellPortalsIntoPortalManager: pushCellPortalsIntoPortalManager
|
|
522
635
|
};
|
|
523
636
|
}, [setHotColumnSettings, getRendererWrapper, clearRenderedCellCache, setRenderersPortalManagerRef, pushCellPortalsIntoPortalManager]);
|
|
524
|
-
return React__default["default"].createElement(HotTableContext.Provider, {
|
|
637
|
+
return /*#__PURE__*/React__default["default"].createElement(HotTableContext.Provider, {
|
|
525
638
|
value: contextImpl
|
|
526
639
|
}, children);
|
|
527
640
|
};
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
*
|
|
531
|
-
*
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Exposes the table context object to components
|
|
644
|
+
*
|
|
645
|
+
* @returns HotTableContext
|
|
532
646
|
*/
|
|
533
647
|
function useHotTableContext() {
|
|
534
648
|
return React.useContext(HotTableContext);
|
|
535
649
|
}
|
|
536
650
|
|
|
537
|
-
var HotColumnContext = React.createContext(undefined);
|
|
651
|
+
var HotColumnContext = /*#__PURE__*/React.createContext(undefined);
|
|
538
652
|
var HotColumnContextProvider = function HotColumnContextProvider(_ref) {
|
|
539
653
|
var columnIndex = _ref.columnIndex,
|
|
540
654
|
getOwnerDocument = _ref.getOwnerDocument,
|
|
@@ -545,7 +659,7 @@ var HotColumnContextProvider = function HotColumnContextProvider(_ref) {
|
|
|
545
659
|
getOwnerDocument: getOwnerDocument
|
|
546
660
|
};
|
|
547
661
|
}, [columnIndex, getOwnerDocument]);
|
|
548
|
-
return React__default["default"].createElement(HotColumnContext.Provider, {
|
|
662
|
+
return /*#__PURE__*/React__default["default"].createElement(HotColumnContext.Provider, {
|
|
549
663
|
value: contextImpl
|
|
550
664
|
}, children);
|
|
551
665
|
};
|
|
@@ -561,12 +675,13 @@ var MethodsMap = {
|
|
|
561
675
|
prepare: 'onPrepare',
|
|
562
676
|
focus: 'onFocus'
|
|
563
677
|
};
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
* @param {RefObject}
|
|
569
|
-
* @
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Create a class to be passed to the Handsontable's settings.
|
|
681
|
+
*
|
|
682
|
+
* @param {RefObject<HotEditorHooks>} hooksRef Reference to component-based editor overridden hooks object.
|
|
683
|
+
* @param {RefObject} instanceRef Reference to Handsontable-native custom editor class instance.
|
|
684
|
+
* @returns {Function} A class to be passed to the Handsontable editor settings.
|
|
570
685
|
*/
|
|
571
686
|
function makeEditorClass(hooksRef, instanceRef) {
|
|
572
687
|
return /*#__PURE__*/function (_Handsontable$editors) {
|
|
@@ -590,8 +705,8 @@ function makeEditorClass(hooksRef, instanceRef) {
|
|
|
590
705
|
result = baseMethod.call.apply(baseMethod, [this].concat(args)); // call super
|
|
591
706
|
}
|
|
592
707
|
if (MethodsMap[propName] && (_hooksRef$current = hooksRef.current) !== null && _hooksRef$current !== void 0 && _hooksRef$current[MethodsMap[propName]]) {
|
|
593
|
-
var
|
|
594
|
-
result = (
|
|
708
|
+
var _ref;
|
|
709
|
+
result = (_ref = hooksRef.current[MethodsMap[propName]]).call.apply(_ref, [this].concat(args));
|
|
595
710
|
}
|
|
596
711
|
return result;
|
|
597
712
|
}.bind(_this);
|
|
@@ -621,31 +736,31 @@ function makeEditorClass(hooksRef, instanceRef) {
|
|
|
621
736
|
}]);
|
|
622
737
|
}(Handsontable__default["default"].editors.BaseEditor);
|
|
623
738
|
}
|
|
624
|
-
/**
|
|
625
|
-
* Context to provide Handsontable-native custom editor class instance to overridden hooks object.
|
|
739
|
+
/**
|
|
740
|
+
* Context to provide Handsontable-native custom editor class instance to overridden hooks object.
|
|
626
741
|
*/
|
|
627
|
-
var EditorContext = React.createContext(undefined);
|
|
628
|
-
/**
|
|
629
|
-
* Provider of the context that exposes Handsontable-native editor instance and passes hooks object
|
|
630
|
-
* for custom editor components.
|
|
631
|
-
*
|
|
632
|
-
* @param {Ref} hooksRef Reference for component-based editor overridden hooks object.
|
|
633
|
-
* @param {RefObject} hotCustomEditorInstanceRef Reference to Handsontable-native editor instance.
|
|
742
|
+
var EditorContext = /*#__PURE__*/React.createContext(undefined);
|
|
743
|
+
/**
|
|
744
|
+
* Provider of the context that exposes Handsontable-native editor instance and passes hooks object
|
|
745
|
+
* for custom editor components.
|
|
746
|
+
*
|
|
747
|
+
* @param {Ref} hooksRef Reference for component-based editor overridden hooks object.
|
|
748
|
+
* @param {RefObject} hotCustomEditorInstanceRef Reference to Handsontable-native editor instance.
|
|
634
749
|
*/
|
|
635
|
-
var EditorContextProvider = function EditorContextProvider(
|
|
636
|
-
var hooksRef =
|
|
637
|
-
hotCustomEditorInstanceRef =
|
|
638
|
-
children =
|
|
639
|
-
return React__default["default"].createElement(EditorContext.Provider, {
|
|
750
|
+
var EditorContextProvider = function EditorContextProvider(_ref2) {
|
|
751
|
+
var hooksRef = _ref2.hooksRef,
|
|
752
|
+
hotCustomEditorInstanceRef = _ref2.hotCustomEditorInstanceRef,
|
|
753
|
+
children = _ref2.children;
|
|
754
|
+
return /*#__PURE__*/React__default["default"].createElement(EditorContext.Provider, {
|
|
640
755
|
value: {
|
|
641
756
|
hooksRef: hooksRef,
|
|
642
757
|
hotCustomEditorInstanceRef: hotCustomEditorInstanceRef
|
|
643
758
|
}
|
|
644
759
|
}, children);
|
|
645
760
|
};
|
|
646
|
-
/**
|
|
647
|
-
* Applies editor overlay position/dimensions to an element.
|
|
648
|
-
* @returns true if position was applied, false if editor should close (e.g. cell no longer available).
|
|
761
|
+
/**
|
|
762
|
+
* Applies editor overlay position/dimensions to an element.
|
|
763
|
+
* @returns true if position was applied, false if editor should close (e.g. cell no longer available).
|
|
649
764
|
*/
|
|
650
765
|
function applyEditorPosition(el, editor, hot, td) {
|
|
651
766
|
var _rootWindow$pageXOffs, _rootWindow$pageYOffs;
|
|
@@ -695,17 +810,18 @@ function applyEditorPosition(el, editor, hot, td) {
|
|
|
695
810
|
}
|
|
696
811
|
return false;
|
|
697
812
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
* @param {
|
|
703
|
-
* @
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Hook that allows encapsulating custom behaviours of component-based editor by customizing passed ref with overridden hooks object.
|
|
816
|
+
*
|
|
817
|
+
* @param {HotEditorHooks} overriddenHooks Overrides specific for the custom editor.
|
|
818
|
+
* @param {DependencyList} deps Overridden hooks object React dependency list.
|
|
819
|
+
* @returns {UseHotEditorImpl} Editor API methods
|
|
704
820
|
*/
|
|
705
821
|
function useHotEditor(overriddenHooks, deps) {
|
|
706
|
-
var
|
|
707
|
-
hooksRef =
|
|
708
|
-
hotCustomEditorInstanceRef =
|
|
822
|
+
var _ref3 = React.useContext(EditorContext),
|
|
823
|
+
hooksRef = _ref3.hooksRef,
|
|
824
|
+
hotCustomEditorInstanceRef = _ref3.hotCustomEditorInstanceRef;
|
|
709
825
|
var _useState = React.useState(0),
|
|
710
826
|
_useState2 = _slicedToArray(_useState, 2),
|
|
711
827
|
rerenderTrigger = _useState2[0],
|
|
@@ -714,6 +830,7 @@ function useHotEditor(overriddenHooks, deps) {
|
|
|
714
830
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
715
831
|
editorValue = _useState4[0],
|
|
716
832
|
setEditorValue = _useState4[1];
|
|
833
|
+
|
|
717
834
|
// return a deferred value that allows for optimizing performance by delaying the update of a value until the next render.
|
|
718
835
|
var deferredValue = React.useDeferredValue(editorValue);
|
|
719
836
|
React.useImperativeHandle(hooksRef, function () {
|
|
@@ -757,23 +874,28 @@ function useHotEditor(overriddenHooks, deps) {
|
|
|
757
874
|
};
|
|
758
875
|
}, [rerenderTrigger, hotCustomEditorInstanceRef, deferredValue]);
|
|
759
876
|
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
877
|
+
|
|
878
|
+
// Render prop function type
|
|
879
|
+
|
|
880
|
+
// EditorComponent props - children typed to work with JSX syntax
|
|
881
|
+
|
|
882
|
+
function EditorComponent(_ref4) {
|
|
883
|
+
var _onPrepare = _ref4.onPrepare,
|
|
884
|
+
_onClose = _ref4.onClose,
|
|
885
|
+
_onOpen = _ref4.onOpen,
|
|
886
|
+
_onFocus = _ref4.onFocus,
|
|
887
|
+
children = _ref4.children,
|
|
888
|
+
_ref4$shortcutsGroup = _ref4.shortcutsGroup,
|
|
889
|
+
shortcutsGroup = _ref4$shortcutsGroup === void 0 ? "custom-editor" : _ref4$shortcutsGroup,
|
|
890
|
+
shortcuts = _ref4.shortcuts;
|
|
769
891
|
var mainElementRef = React.useRef(null);
|
|
770
892
|
var currentValue = React.useRef(undefined);
|
|
771
893
|
var _useState5 = React.useState(),
|
|
772
894
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
773
895
|
themeClassName = _useState6[0],
|
|
774
896
|
setThemeClassName = _useState6[1];
|
|
775
|
-
var
|
|
776
|
-
hotCustomEditorInstanceRef =
|
|
897
|
+
var _ref5 = React.useContext(EditorContext),
|
|
898
|
+
hotCustomEditorInstanceRef = _ref5.hotCustomEditorInstanceRef;
|
|
777
899
|
var registerShortcuts = React.useCallback(function () {
|
|
778
900
|
var _hotCustomEditorInsta8, _hotCustomEditorInsta9, _hotCustomEditorInsta0;
|
|
779
901
|
if (!((_hotCustomEditorInsta8 = hotCustomEditorInstanceRef.current) !== null && _hotCustomEditorInsta8 !== void 0 && _hotCustomEditorInsta8.hot)) return;
|
|
@@ -876,7 +998,7 @@ function EditorComponent(_ref2) {
|
|
|
876
998
|
var stopMousedownPropagation = function stopMousedownPropagation(e) {
|
|
877
999
|
e.stopPropagation();
|
|
878
1000
|
};
|
|
879
|
-
return React__default["default"].createElement("div", {
|
|
1001
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
880
1002
|
ref: mainElementRef,
|
|
881
1003
|
className: themeClassName,
|
|
882
1004
|
style: {
|
|
@@ -911,22 +1033,25 @@ var HotColumn = function HotColumn(props) {
|
|
|
911
1033
|
var _useHotColumnContext = useHotColumnContext(),
|
|
912
1034
|
columnIndex = _useHotColumnContext.columnIndex,
|
|
913
1035
|
getOwnerDocument = _useHotColumnContext.getOwnerDocument;
|
|
914
|
-
|
|
915
|
-
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Reference to component-based editor overridden hooks object.
|
|
916
1039
|
*/
|
|
917
1040
|
var localEditorHooksRef = React.useRef(null);
|
|
918
|
-
|
|
919
|
-
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* Reference to HOT-native custom editor class instance.
|
|
920
1044
|
*/
|
|
921
1045
|
var localEditorClassInstance = React.useRef(null);
|
|
922
|
-
|
|
923
|
-
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Logic performed after mounting & updating of the HotColumn component.
|
|
924
1049
|
*/
|
|
925
1050
|
React.useEffect(function () {
|
|
926
|
-
/**
|
|
927
|
-
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
|
928
|
-
*
|
|
929
|
-
* @returns {Object}
|
|
1051
|
+
/**
|
|
1052
|
+
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
|
1053
|
+
*
|
|
1054
|
+
* @returns {Object}
|
|
930
1055
|
*/
|
|
931
1056
|
var getSettingsProps = function getSettingsProps() {
|
|
932
1057
|
return Object.keys(props).filter(function (key) {
|
|
@@ -936,8 +1061,9 @@ var HotColumn = function HotColumn(props) {
|
|
|
936
1061
|
return obj;
|
|
937
1062
|
}, {});
|
|
938
1063
|
};
|
|
939
|
-
|
|
940
|
-
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* Create the column settings based on the data provided to the `HotColumn` component and its child components.
|
|
941
1067
|
*/
|
|
942
1068
|
var createColumnSettings = function createColumnSettings() {
|
|
943
1069
|
var columnSettings = SettingsMapper.getSettings(getSettingsProps());
|
|
@@ -961,23 +1087,24 @@ var HotColumn = function HotColumn(props) {
|
|
|
961
1087
|
}
|
|
962
1088
|
});
|
|
963
1089
|
var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
*
|
|
967
|
-
*
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
* Render the portals of the editors, if there are any.
|
|
1093
|
+
*
|
|
1094
|
+
* @returns {ReactElement}
|
|
968
1095
|
*/
|
|
969
|
-
return React__default["default"].createElement(EditorContextProvider, {
|
|
1096
|
+
return /*#__PURE__*/React__default["default"].createElement(EditorContextProvider, {
|
|
970
1097
|
hooksRef: localEditorHooksRef,
|
|
971
1098
|
hotCustomEditorInstanceRef: localEditorClassInstance
|
|
972
1099
|
}, editorPortal);
|
|
973
1100
|
};
|
|
974
1101
|
|
|
975
|
-
var version="17.0
|
|
1102
|
+
var version="17.1.0-rc1";
|
|
976
1103
|
|
|
977
|
-
/**
|
|
978
|
-
* Component used to manage the renderer component portals.
|
|
1104
|
+
/**
|
|
1105
|
+
* Component used to manage the renderer component portals.
|
|
979
1106
|
*/
|
|
980
|
-
var RenderersPortalManager = React.forwardRef(function (_, ref) {
|
|
1107
|
+
var RenderersPortalManager = /*#__PURE__*/React.forwardRef(function (_, ref) {
|
|
981
1108
|
var _useState = React.useState([]),
|
|
982
1109
|
_useState2 = _slicedToArray(_useState, 2),
|
|
983
1110
|
portals = _useState2[0],
|
|
@@ -985,7 +1112,7 @@ var RenderersPortalManager = React.forwardRef(function (_, ref) {
|
|
|
985
1112
|
React.useImperativeHandle(ref, function () {
|
|
986
1113
|
return setPortals;
|
|
987
1114
|
});
|
|
988
|
-
return React__default["default"].createElement(React.Fragment, null, portals);
|
|
1115
|
+
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, portals);
|
|
989
1116
|
});
|
|
990
1117
|
|
|
991
1118
|
function getDefaultExportFromCjs (x) {
|
|
@@ -1084,33 +1211,39 @@ function requireFactoryWithThrowingShims() {
|
|
|
1084
1211
|
var propTypesExports = propTypes.exports;
|
|
1085
1212
|
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
1086
1213
|
|
|
1087
|
-
var HotTableInner = React.forwardRef(function (props, ref) {
|
|
1088
|
-
/**
|
|
1089
|
-
* Reference to the Handsontable instance.
|
|
1214
|
+
var HotTableInner = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
1215
|
+
/**
|
|
1216
|
+
* Reference to the Handsontable instance.
|
|
1090
1217
|
*/
|
|
1091
1218
|
var __hotInstance = React.useRef(null);
|
|
1092
|
-
|
|
1093
|
-
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Reference to the main Handsontable DOM element.
|
|
1094
1222
|
*/
|
|
1095
1223
|
var hotElementRef = React.useRef(null);
|
|
1096
|
-
|
|
1097
|
-
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* Reference to component-based editor overridden hooks object.
|
|
1098
1227
|
*/
|
|
1099
1228
|
var globalEditorHooksRef = React.useRef(null);
|
|
1100
|
-
|
|
1101
|
-
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* Reference to HOT-native custom editor class instance.
|
|
1102
1232
|
*/
|
|
1103
1233
|
var globalEditorClassInstance = React.useRef(null);
|
|
1104
|
-
|
|
1105
|
-
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* Reference to the previous props object.
|
|
1106
1237
|
*/
|
|
1107
1238
|
var prevProps = React.useRef();
|
|
1108
|
-
|
|
1109
|
-
|
|
1239
|
+
|
|
1240
|
+
/**
|
|
1241
|
+
* HotTable context exposing helper functions.
|
|
1110
1242
|
*/
|
|
1111
1243
|
var context = useHotTableContext();
|
|
1112
|
-
|
|
1113
|
-
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* Getter for the property storing the Handsontable instance.
|
|
1114
1247
|
*/
|
|
1115
1248
|
var getHotInstance = React.useCallback(function () {
|
|
1116
1249
|
if (!__hotInstance.current || !__hotInstance.current.isDestroyed) {
|
|
@@ -1124,17 +1257,19 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
1124
1257
|
var isHotInstanceDestroyed = React.useCallback(function () {
|
|
1125
1258
|
return !__hotInstance.current || __hotInstance.current.isDestroyed;
|
|
1126
1259
|
}, [__hotInstance]);
|
|
1127
|
-
|
|
1128
|
-
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* Clear both the editor and the renderer cache.
|
|
1129
1263
|
*/
|
|
1130
1264
|
var clearCache = React.useCallback(function () {
|
|
1131
1265
|
context.clearRenderedCellCache();
|
|
1132
1266
|
context.componentRendererColumns.clear();
|
|
1133
1267
|
}, [context]);
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1268
|
+
|
|
1269
|
+
/**
|
|
1270
|
+
* Get the `Document` object corresponding to the main component element.
|
|
1271
|
+
*
|
|
1272
|
+
* @returns The `Document` object used by the component.
|
|
1138
1273
|
*/
|
|
1139
1274
|
var getOwnerDocument = React.useCallback(function () {
|
|
1140
1275
|
if (isCSR()) {
|
|
@@ -1142,10 +1277,11 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
1142
1277
|
}
|
|
1143
1278
|
return null;
|
|
1144
1279
|
}, [hotElementRef]);
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* Create a new settings object containing the column settings and global editors and renderers.
|
|
1283
|
+
*
|
|
1284
|
+
* @returns {Handsontable.GridSettings} New global set of settings for Handsontable.
|
|
1149
1285
|
*/
|
|
1150
1286
|
var createNewGlobalSettings = function createNewGlobalSettings() {
|
|
1151
1287
|
var _getHotInstance;
|
|
@@ -1175,8 +1311,9 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
1175
1311
|
}
|
|
1176
1312
|
return newSettings;
|
|
1177
1313
|
};
|
|
1178
|
-
|
|
1179
|
-
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Detect if `autoRowSize` or `autoColumnSize` is defined, and if so, throw an incompatibility warning.
|
|
1180
1317
|
*/
|
|
1181
1318
|
var displayAutoSizeWarning = function displayAutoSizeWarning(hotInstance) {
|
|
1182
1319
|
var _hotInstance$getPlugi, _hotInstance$getPlugi2;
|
|
@@ -1186,23 +1323,27 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
1186
1323
|
}
|
|
1187
1324
|
}
|
|
1188
1325
|
};
|
|
1189
|
-
|
|
1190
|
-
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* Initialize Handsontable after the component has mounted.
|
|
1191
1329
|
*/
|
|
1192
1330
|
React.useEffect(function () {
|
|
1193
1331
|
var newGlobalSettings = createNewGlobalSettings(true);
|
|
1332
|
+
|
|
1194
1333
|
// Update prevProps with the current props
|
|
1195
1334
|
prevProps.current = props;
|
|
1196
1335
|
__hotInstance.current = new Handsontable__default["default"].Core(hotElementRef.current, newGlobalSettings);
|
|
1197
|
-
|
|
1198
|
-
|
|
1336
|
+
|
|
1337
|
+
/**
|
|
1338
|
+
* Handsontable's `beforeViewRender` hook callback.
|
|
1199
1339
|
*/
|
|
1200
1340
|
__hotInstance.current.addHook('beforeViewRender', function () {
|
|
1201
1341
|
context.clearPortalCache();
|
|
1202
1342
|
context.clearRenderedCellCache();
|
|
1203
1343
|
});
|
|
1204
|
-
|
|
1205
|
-
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* Handsontable's `afterViewRender` hook callback.
|
|
1206
1347
|
*/
|
|
1207
1348
|
__hotInstance.current.addHook('afterViewRender', function () {
|
|
1208
1349
|
context.pushCellPortalsIntoPortalManager();
|
|
@@ -1212,8 +1353,9 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
1212
1353
|
if (!displayObsoleteRenderersEditorsWarning(props.children)) {
|
|
1213
1354
|
displayChildrenOfTypeWarning(props.children, HotColumn);
|
|
1214
1355
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* Destroy the Handsontable instance when the parent component unmounts.
|
|
1217
1359
|
*/
|
|
1218
1360
|
return function () {
|
|
1219
1361
|
var _getHotInstance2;
|
|
@@ -1221,21 +1363,24 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
1221
1363
|
(_getHotInstance2 = getHotInstance()) === null || _getHotInstance2 === void 0 || _getHotInstance2.destroy();
|
|
1222
1364
|
};
|
|
1223
1365
|
}, []);
|
|
1224
|
-
|
|
1225
|
-
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* Logic performed after the component update.
|
|
1226
1369
|
*/
|
|
1227
1370
|
useUpdateEffect(function () {
|
|
1228
1371
|
clearCache();
|
|
1229
1372
|
var hotInstance = getHotInstance();
|
|
1230
1373
|
var newGlobalSettings = createNewGlobalSettings(false, prevProps.current);
|
|
1374
|
+
|
|
1231
1375
|
// Update prevProps with the current props
|
|
1232
1376
|
prevProps.current = props;
|
|
1233
1377
|
hotInstance === null || hotInstance === void 0 || hotInstance.updateSettings(newGlobalSettings, false);
|
|
1234
1378
|
displayAutoSizeWarning(hotInstance);
|
|
1235
1379
|
displayObsoleteRenderersEditorsWarning(props.children);
|
|
1236
1380
|
});
|
|
1237
|
-
|
|
1238
|
-
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* Interface exposed to parent components by HotTable instance via React ref
|
|
1239
1384
|
*/
|
|
1240
1385
|
React.useImperativeHandle(ref, function () {
|
|
1241
1386
|
return {
|
|
@@ -1247,11 +1392,12 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
1247
1392
|
}
|
|
1248
1393
|
};
|
|
1249
1394
|
});
|
|
1250
|
-
|
|
1251
|
-
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* Render the component.
|
|
1252
1398
|
*/
|
|
1253
1399
|
var hotColumnWrapped = React.Children.toArray(props.children).filter(isHotColumn).map(function (childNode, columnIndex) {
|
|
1254
|
-
return React__default["default"].createElement(HotColumnContextProvider, {
|
|
1400
|
+
return /*#__PURE__*/React__default["default"].createElement(HotColumnContextProvider, {
|
|
1255
1401
|
columnIndex: columnIndex,
|
|
1256
1402
|
getOwnerDocument: getOwnerDocument,
|
|
1257
1403
|
key: columnIndex
|
|
@@ -1259,17 +1405,18 @@ var HotTableInner = React.forwardRef(function (props, ref) {
|
|
|
1259
1405
|
});
|
|
1260
1406
|
var containerProps = getContainerAttributesProps(props);
|
|
1261
1407
|
var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
|
|
1262
|
-
return React__default["default"].createElement(React.Fragment, null, React__default["default"].createElement("div",
|
|
1408
|
+
return /*#__PURE__*/React__default["default"].createElement(React.Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", _extends({
|
|
1263
1409
|
ref: hotElementRef
|
|
1264
|
-
}, containerProps), hotColumnWrapped), React__default["default"].createElement(RenderersPortalManager, {
|
|
1410
|
+
}, containerProps), hotColumnWrapped), /*#__PURE__*/React__default["default"].createElement(RenderersPortalManager, {
|
|
1265
1411
|
ref: context.setRenderersPortalManagerRef
|
|
1266
|
-
}), React__default["default"].createElement(EditorContextProvider, {
|
|
1412
|
+
}), /*#__PURE__*/React__default["default"].createElement(EditorContextProvider, {
|
|
1267
1413
|
hooksRef: globalEditorHooksRef,
|
|
1268
1414
|
hotCustomEditorInstanceRef: globalEditorClassInstance
|
|
1269
1415
|
}, editorPortal));
|
|
1270
1416
|
});
|
|
1271
|
-
|
|
1272
|
-
|
|
1417
|
+
|
|
1418
|
+
/**
|
|
1419
|
+
* Prop types to be checked at runtime.
|
|
1273
1420
|
*/
|
|
1274
1421
|
HotTableInner.propTypes = {
|
|
1275
1422
|
style: PropTypes.object,
|
|
@@ -1278,41 +1425,42 @@ HotTableInner.propTypes = {
|
|
|
1278
1425
|
};
|
|
1279
1426
|
|
|
1280
1427
|
var _excluded = ["children"];
|
|
1281
|
-
/**
|
|
1282
|
-
* A Handsontable-ReactJS wrapper.
|
|
1283
|
-
*
|
|
1284
|
-
* To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
|
|
1285
|
-
* For example:
|
|
1286
|
-
*
|
|
1287
|
-
* ```js
|
|
1288
|
-
* <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
|
|
1289
|
-
*
|
|
1290
|
-
* // is analogous to
|
|
1291
|
-
* let hot = new Handsontable(document.getElementById('hot'), {
|
|
1292
|
-
* data: dataObject,
|
|
1293
|
-
* contextMenu: true,
|
|
1294
|
-
* colHeaders: true,
|
|
1295
|
-
* width: 600
|
|
1296
|
-
* height: 300
|
|
1297
|
-
* });
|
|
1298
|
-
*
|
|
1299
|
-
* ```
|
|
1428
|
+
/**
|
|
1429
|
+
* A Handsontable-ReactJS wrapper.
|
|
1430
|
+
*
|
|
1431
|
+
* To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
|
|
1432
|
+
* For example:
|
|
1433
|
+
*
|
|
1434
|
+
* ```js
|
|
1435
|
+
* <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
|
|
1436
|
+
*
|
|
1437
|
+
* // is analogous to
|
|
1438
|
+
* let hot = new Handsontable(document.getElementById('hot'), {
|
|
1439
|
+
* data: dataObject,
|
|
1440
|
+
* contextMenu: true,
|
|
1441
|
+
* colHeaders: true,
|
|
1442
|
+
* width: 600
|
|
1443
|
+
* height: 300
|
|
1444
|
+
* });
|
|
1445
|
+
*
|
|
1446
|
+
* ```
|
|
1300
1447
|
*/
|
|
1301
|
-
var HotTable = React.forwardRef(function (_ref, ref) {
|
|
1448
|
+
var HotTable = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
1302
1449
|
var _props$id;
|
|
1303
1450
|
var children = _ref.children,
|
|
1304
1451
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
1305
1452
|
var componentId = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : React.useId();
|
|
1306
|
-
return React__default["default"].createElement(HotTableContextProvider, null, React__default["default"].createElement(HotTableInner,
|
|
1453
|
+
return /*#__PURE__*/React__default["default"].createElement(HotTableContextProvider, null, /*#__PURE__*/React__default["default"].createElement(HotTableInner, _extends({
|
|
1307
1454
|
id: componentId
|
|
1308
1455
|
}, props, {
|
|
1309
1456
|
ref: ref
|
|
1310
1457
|
}), children));
|
|
1311
1458
|
});
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
*
|
|
1315
|
-
*
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
* Package version.
|
|
1462
|
+
*
|
|
1463
|
+
* @returns The version number of the package.
|
|
1316
1464
|
*/
|
|
1317
1465
|
HotTable.version = version;
|
|
1318
1466
|
|