@handsontable/react-wrapper 0.0.0-next-7cc7ef7-20241028
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE.txt +25 -0
- package/README.md +136 -0
- package/commonjs/react-handsontable.js +2139 -0
- package/commonjs/src/helpers.d.ts +105 -0
- package/commonjs/src/hotColumn.d.ts +5 -0
- package/commonjs/src/hotColumnContext.d.ts +16 -0
- package/commonjs/src/hotEditor.d.ts +33 -0
- package/commonjs/src/hotTable.d.ts +29 -0
- package/commonjs/src/hotTableContext.d.ts +55 -0
- package/commonjs/src/hotTableInner.d.ts +5 -0
- package/commonjs/src/index.d.ts +5 -0
- package/commonjs/src/renderersPortalManager.d.ts +6 -0
- package/commonjs/src/settingsMapper.d.ts +18 -0
- package/commonjs/src/types.d.ts +78 -0
- package/dist/react-handsontable.js +1133 -0
- package/dist/react-handsontable.js.map +1 -0
- package/dist/react-handsontable.min.js +31 -0
- package/dist/react-handsontable.min.js.map +1 -0
- package/dist/src/helpers.d.ts +105 -0
- package/dist/src/hotColumn.d.ts +5 -0
- package/dist/src/hotColumnContext.d.ts +16 -0
- package/dist/src/hotEditor.d.ts +33 -0
- package/dist/src/hotTable.d.ts +29 -0
- package/dist/src/hotTableContext.d.ts +55 -0
- package/dist/src/hotTableInner.d.ts +5 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/renderersPortalManager.d.ts +6 -0
- package/dist/src/settingsMapper.d.ts +18 -0
- package/dist/src/types.d.ts +78 -0
- package/es/react-handsontable.mjs +2125 -0
- package/handsontable-non-commercial-license.pdf +0 -0
- package/helpers.d.ts +105 -0
- package/hotColumn.d.ts +5 -0
- package/hotColumnContext.d.ts +16 -0
- package/hotEditor.d.ts +33 -0
- package/hotTable.d.ts +29 -0
- package/hotTableContext.d.ts +55 -0
- package/hotTableInner.d.ts +5 -0
- package/index.d.ts +5 -0
- package/package.json +130 -0
- package/renderersPortalManager.d.ts +6 -0
- package/settingsMapper.d.ts +18 -0
- package/types.d.ts +78 -0
@@ -0,0 +1,1133 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright (c) HANDSONCODE sp. z o. o.
|
3
|
+
*
|
4
|
+
* HANDSONTABLE is a software distributed by HANDSONCODE sp. z o. o., a Polish corporation based in
|
5
|
+
* Gdynia, Poland, at Aleja Zwyciestwa 96-98, registered by the District Court in Gdansk under number
|
6
|
+
* 538651, EU tax ID number: PL5862294002, share capital: PLN 62,800.00.
|
7
|
+
*
|
8
|
+
* This software is protected by applicable copyright laws, including international treaties, and dual-
|
9
|
+
* licensed - depending on whether your use for commercial purposes, meaning intended for or
|
10
|
+
* resulting in commercial advantage or monetary compensation, or not.
|
11
|
+
*
|
12
|
+
* If your use is strictly personal or solely for evaluation purposes, meaning for the purposes of testing
|
13
|
+
* the suitability, performance, and usefulness of this software outside the production environment,
|
14
|
+
* you agree to be bound by the terms included in the "handsontable-non-commercial-license.pdf" file.
|
15
|
+
*
|
16
|
+
* Your use of this software for commercial purposes is subject to the terms included in an applicable
|
17
|
+
* license agreement.
|
18
|
+
*
|
19
|
+
* In any case, you must not make any such use of this software as to develop software which may be
|
20
|
+
* considered competitive with this software.
|
21
|
+
*
|
22
|
+
* UNLESS EXPRESSLY AGREED OTHERWISE, HANDSONCODE PROVIDES THIS SOFTWARE ON AN "AS IS"
|
23
|
+
* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, AND IN NO EVENT AND UNDER NO
|
24
|
+
* LEGAL THEORY, SHALL HANDSONCODE BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT,
|
25
|
+
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER ARISING FROM
|
26
|
+
* USE OR INABILITY TO USE THIS SOFTWARE.
|
27
|
+
*
|
28
|
+
* Version: 0.0.0-next-7cc7ef7-20241028 (built at Mon Oct 28 2024 11:28:18 GMT+0100 (Central European Standard Time))
|
29
|
+
*/
|
30
|
+
(function (global, factory) {
|
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')) :
|
32
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom', 'handsontable/base', 'handsontable/renderers/registry', 'handsontable/editors/registry'], factory) :
|
33
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Handsontable = global.Handsontable || {}, global.Handsontable.react = {}), global.React, global.ReactDOM, global.Handsontable, global.Handsontable.renderers, global.Handsontable.editors));
|
34
|
+
})(this, (function (exports, React, ReactDOM, Handsontable, registry, registry$1) { 'use strict';
|
35
|
+
|
36
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
37
|
+
|
38
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
39
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefaultCompat(ReactDOM);
|
40
|
+
var Handsontable__default = /*#__PURE__*/_interopDefaultCompat(Handsontable);
|
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) {
|
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
|
+
function _arrayLikeToArray(r, a) {
|
227
|
+
(null == a || a > r.length) && (a = r.length);
|
228
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
229
|
+
return n;
|
230
|
+
}
|
231
|
+
function _arrayWithHoles(r) {
|
232
|
+
if (Array.isArray(r)) return r;
|
233
|
+
}
|
234
|
+
function _arrayWithoutHoles(r) {
|
235
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
236
|
+
}
|
237
|
+
function _assertThisInitialized(e) {
|
238
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
239
|
+
return e;
|
240
|
+
}
|
241
|
+
function _callSuper(t, o, e) {
|
242
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
243
|
+
}
|
244
|
+
function _classCallCheck(a, n) {
|
245
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
246
|
+
}
|
247
|
+
function _defineProperties(e, r) {
|
248
|
+
for (var t = 0; t < r.length; t++) {
|
249
|
+
var o = r[t];
|
250
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
251
|
+
}
|
252
|
+
}
|
253
|
+
function _createClass(e, r, t) {
|
254
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
255
|
+
writable: !1
|
256
|
+
}), e;
|
257
|
+
}
|
258
|
+
function _defineProperty(e, r, t) {
|
259
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
260
|
+
value: t,
|
261
|
+
enumerable: !0,
|
262
|
+
configurable: !0,
|
263
|
+
writable: !0
|
264
|
+
}) : e[r] = t, e;
|
265
|
+
}
|
266
|
+
function _getPrototypeOf(t) {
|
267
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
268
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
269
|
+
}, _getPrototypeOf(t);
|
270
|
+
}
|
271
|
+
function _inherits(t, e) {
|
272
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
273
|
+
t.prototype = Object.create(e && e.prototype, {
|
274
|
+
constructor: {
|
275
|
+
value: t,
|
276
|
+
writable: !0,
|
277
|
+
configurable: !0
|
278
|
+
}
|
279
|
+
}), Object.defineProperty(t, "prototype", {
|
280
|
+
writable: !1
|
281
|
+
}), e && _setPrototypeOf(t, e);
|
282
|
+
}
|
283
|
+
function _isNativeReflectConstruct() {
|
284
|
+
try {
|
285
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
286
|
+
} catch (t) {}
|
287
|
+
return (_isNativeReflectConstruct = function () {
|
288
|
+
return !!t;
|
289
|
+
})();
|
290
|
+
}
|
291
|
+
function _iterableToArray(r) {
|
292
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
293
|
+
}
|
294
|
+
function _iterableToArrayLimit(r, l) {
|
295
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
296
|
+
if (null != t) {
|
297
|
+
var e,
|
298
|
+
n,
|
299
|
+
i,
|
300
|
+
u,
|
301
|
+
a = [],
|
302
|
+
f = !0,
|
303
|
+
o = !1;
|
304
|
+
try {
|
305
|
+
if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
306
|
+
} catch (r) {
|
307
|
+
o = !0, n = r;
|
308
|
+
} finally {
|
309
|
+
try {
|
310
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
311
|
+
} finally {
|
312
|
+
if (o) throw n;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
return a;
|
316
|
+
}
|
317
|
+
}
|
318
|
+
function _nonIterableRest() {
|
319
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
320
|
+
}
|
321
|
+
function _nonIterableSpread() {
|
322
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
323
|
+
}
|
324
|
+
function ownKeys(e, r) {
|
325
|
+
var t = Object.keys(e);
|
326
|
+
if (Object.getOwnPropertySymbols) {
|
327
|
+
var o = Object.getOwnPropertySymbols(e);
|
328
|
+
r && (o = o.filter(function (r) {
|
329
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
330
|
+
})), t.push.apply(t, o);
|
331
|
+
}
|
332
|
+
return t;
|
333
|
+
}
|
334
|
+
function _objectSpread2(e) {
|
335
|
+
for (var r = 1; r < arguments.length; r++) {
|
336
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
337
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
338
|
+
_defineProperty(e, r, t[r]);
|
339
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
340
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
341
|
+
});
|
342
|
+
}
|
343
|
+
return e;
|
344
|
+
}
|
345
|
+
function _objectWithoutProperties(e, t) {
|
346
|
+
if (null == e) return {};
|
347
|
+
var o,
|
348
|
+
r,
|
349
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
350
|
+
if (Object.getOwnPropertySymbols) {
|
351
|
+
var s = Object.getOwnPropertySymbols(e);
|
352
|
+
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
353
|
+
}
|
354
|
+
return i;
|
355
|
+
}
|
356
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
357
|
+
if (null == r) return {};
|
358
|
+
var t = {};
|
359
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
360
|
+
if (e.includes(n)) continue;
|
361
|
+
t[n] = r[n];
|
362
|
+
}
|
363
|
+
return t;
|
364
|
+
}
|
365
|
+
function _possibleConstructorReturn(t, e) {
|
366
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
367
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
368
|
+
return _assertThisInitialized(t);
|
369
|
+
}
|
370
|
+
function _setPrototypeOf(t, e) {
|
371
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
372
|
+
return t.__proto__ = e, t;
|
373
|
+
}, _setPrototypeOf(t, e);
|
374
|
+
}
|
375
|
+
function _slicedToArray(r, e) {
|
376
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
377
|
+
}
|
378
|
+
function _toConsumableArray(r) {
|
379
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
380
|
+
}
|
381
|
+
function _toPrimitive(t, r) {
|
382
|
+
if ("object" != typeof t || !t) return t;
|
383
|
+
var e = t[Symbol.toPrimitive];
|
384
|
+
if (void 0 !== e) {
|
385
|
+
var i = e.call(t, r || "default");
|
386
|
+
if ("object" != typeof i) return i;
|
387
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
388
|
+
}
|
389
|
+
return ("string" === r ? String : Number)(t);
|
390
|
+
}
|
391
|
+
function _toPropertyKey(t) {
|
392
|
+
var i = _toPrimitive(t, "string");
|
393
|
+
return "symbol" == typeof i ? i : i + "";
|
394
|
+
}
|
395
|
+
function _unsupportedIterableToArray(r, a) {
|
396
|
+
if (r) {
|
397
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
398
|
+
var t = {}.toString.call(r).slice(8, -1);
|
399
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
400
|
+
}
|
401
|
+
}
|
402
|
+
|
403
|
+
var SettingsMapper = /*#__PURE__*/function () {
|
404
|
+
function SettingsMapper() {
|
405
|
+
_classCallCheck(this, SettingsMapper);
|
406
|
+
}
|
407
|
+
return _createClass(SettingsMapper, null, [{
|
408
|
+
key: "getSettings",
|
409
|
+
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.
|
418
|
+
*/
|
419
|
+
function getSettings(properties) {
|
420
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
421
|
+
_ref$prevProps = _ref.prevProps,
|
422
|
+
prevProps = _ref$prevProps === void 0 ? {} : _ref$prevProps,
|
423
|
+
_ref$isInit = _ref.isInit,
|
424
|
+
isInit = _ref$isInit === void 0 ? false : _ref$isInit,
|
425
|
+
_ref$initOnlySettingK = _ref.initOnlySettingKeys,
|
426
|
+
initOnlySettingKeys = _ref$initOnlySettingK === void 0 ? [] : _ref$initOnlySettingK;
|
427
|
+
var shouldSkipProp = function shouldSkipProp(key) {
|
428
|
+
// Omit settings that can be set only during initialization and are intentionally modified.
|
429
|
+
if (!isInit && initOnlySettingKeys.includes(key)) {
|
430
|
+
return prevProps[key] === properties[key];
|
431
|
+
}
|
432
|
+
return false;
|
433
|
+
};
|
434
|
+
var newSettings = {};
|
435
|
+
for (var key in properties) {
|
436
|
+
if (key !== 'children' && !shouldSkipProp(key) && properties.hasOwnProperty(key)) {
|
437
|
+
newSettings[key] = properties[key];
|
438
|
+
}
|
439
|
+
}
|
440
|
+
return newSettings;
|
441
|
+
}
|
442
|
+
}]);
|
443
|
+
}();
|
444
|
+
|
445
|
+
var HotTableContext = React.createContext(undefined);
|
446
|
+
var HotTableContextProvider = function HotTableContextProvider(_ref) {
|
447
|
+
var children = _ref.children;
|
448
|
+
var columnsSettings = React.useRef([]);
|
449
|
+
var setHotColumnSettings = React.useCallback(function (columnSettings, columnIndex) {
|
450
|
+
columnsSettings.current[columnIndex] = columnSettings;
|
451
|
+
}, []);
|
452
|
+
var componentRendererColumns = React.useRef(new Map());
|
453
|
+
var renderedCellCache = React.useRef(new Map());
|
454
|
+
var clearRenderedCellCache = React.useCallback(function () {
|
455
|
+
return renderedCellCache.current.clear();
|
456
|
+
}, []);
|
457
|
+
var portalCache = React.useRef(new Map());
|
458
|
+
var clearPortalCache = React.useCallback(function () {
|
459
|
+
return portalCache.current.clear();
|
460
|
+
}, []);
|
461
|
+
var portalContainerCache = React.useRef(new Map());
|
462
|
+
var getRendererWrapper = React.useCallback(function (Renderer) {
|
463
|
+
return function __internalRenderer(instance, TD, row, col, prop, value, cellProperties) {
|
464
|
+
var key = "".concat(row, "-").concat(col);
|
465
|
+
// Handsontable.Core type is missing guid
|
466
|
+
var instanceGuid = instance.guid;
|
467
|
+
var portalContainerKey = "".concat(instanceGuid, "-").concat(key);
|
468
|
+
var portalKey = "".concat(key, "-").concat(instanceGuid);
|
469
|
+
if (renderedCellCache.current.has(key)) {
|
470
|
+
TD.innerHTML = renderedCellCache.current.get(key).innerHTML;
|
471
|
+
}
|
472
|
+
if (TD && !TD.getAttribute('ghost-table')) {
|
473
|
+
var cachedPortal = portalCache.current.get(portalKey);
|
474
|
+
var cachedPortalContainer = portalContainerCache.current.get(portalContainerKey);
|
475
|
+
while (TD.firstChild) {
|
476
|
+
TD.removeChild(TD.firstChild);
|
477
|
+
}
|
478
|
+
// if portal already exists, do not recreate
|
479
|
+
if (cachedPortal && cachedPortalContainer) {
|
480
|
+
TD.appendChild(cachedPortalContainer);
|
481
|
+
} else {
|
482
|
+
var rendererElement = React__default["default"].createElement(Renderer, {
|
483
|
+
instance: instance,
|
484
|
+
TD: TD,
|
485
|
+
row: row,
|
486
|
+
col: col,
|
487
|
+
prop: prop,
|
488
|
+
value: value,
|
489
|
+
cellProperties: cellProperties
|
490
|
+
});
|
491
|
+
var _createPortal = createPortal(rendererElement, TD.ownerDocument, portalKey, cachedPortalContainer),
|
492
|
+
portal = _createPortal.portal,
|
493
|
+
portalContainer = _createPortal.portalContainer;
|
494
|
+
portalContainerCache.current.set(portalContainerKey, portalContainer);
|
495
|
+
TD.appendChild(portalContainer);
|
496
|
+
portalCache.current.set(portalKey, portal);
|
497
|
+
}
|
498
|
+
}
|
499
|
+
renderedCellCache.current.set("".concat(row, "-").concat(col), TD);
|
500
|
+
return TD;
|
501
|
+
};
|
502
|
+
}, []);
|
503
|
+
var renderersPortalManager = React.useRef(function () {
|
504
|
+
return undefined;
|
505
|
+
});
|
506
|
+
var setRenderersPortalManagerRef = React.useCallback(function (pmComponent) {
|
507
|
+
renderersPortalManager.current = pmComponent;
|
508
|
+
}, []);
|
509
|
+
var pushCellPortalsIntoPortalManager = React.useCallback(function () {
|
510
|
+
renderersPortalManager.current(_toConsumableArray(portalCache.current.values()));
|
511
|
+
}, []);
|
512
|
+
var contextImpl = React.useMemo(function () {
|
513
|
+
return {
|
514
|
+
componentRendererColumns: componentRendererColumns.current,
|
515
|
+
columnsSettings: columnsSettings.current,
|
516
|
+
emitColumnSettings: setHotColumnSettings,
|
517
|
+
getRendererWrapper: getRendererWrapper,
|
518
|
+
clearPortalCache: clearPortalCache,
|
519
|
+
clearRenderedCellCache: clearRenderedCellCache,
|
520
|
+
setRenderersPortalManagerRef: setRenderersPortalManagerRef,
|
521
|
+
pushCellPortalsIntoPortalManager: pushCellPortalsIntoPortalManager
|
522
|
+
};
|
523
|
+
}, [setHotColumnSettings, getRendererWrapper, clearRenderedCellCache, setRenderersPortalManagerRef, pushCellPortalsIntoPortalManager]);
|
524
|
+
return React__default["default"].createElement(HotTableContext.Provider, {
|
525
|
+
value: contextImpl
|
526
|
+
}, children);
|
527
|
+
};
|
528
|
+
/**
|
529
|
+
* Exposes the table context object to components
|
530
|
+
*
|
531
|
+
* @returns HotTableContext
|
532
|
+
*/
|
533
|
+
function useHotTableContext() {
|
534
|
+
return React.useContext(HotTableContext);
|
535
|
+
}
|
536
|
+
|
537
|
+
var HotColumnContext = React.createContext(undefined);
|
538
|
+
var HotColumnContextProvider = function HotColumnContextProvider(_ref) {
|
539
|
+
var columnIndex = _ref.columnIndex,
|
540
|
+
getOwnerDocument = _ref.getOwnerDocument,
|
541
|
+
children = _ref.children;
|
542
|
+
var contextImpl = React.useMemo(function () {
|
543
|
+
return {
|
544
|
+
columnIndex: columnIndex,
|
545
|
+
getOwnerDocument: getOwnerDocument
|
546
|
+
};
|
547
|
+
}, [columnIndex, getOwnerDocument]);
|
548
|
+
return React__default["default"].createElement(HotColumnContext.Provider, {
|
549
|
+
value: contextImpl
|
550
|
+
}, children);
|
551
|
+
};
|
552
|
+
var useHotColumnContext = function useHotColumnContext() {
|
553
|
+
return React.useContext(HotColumnContext);
|
554
|
+
};
|
555
|
+
|
556
|
+
var AbstractMethods = ['close', 'focus', 'open'];
|
557
|
+
var ExcludedMethods = ['getValue', 'setValue'];
|
558
|
+
var MethodsMap = {
|
559
|
+
open: 'onOpen',
|
560
|
+
close: 'onClose',
|
561
|
+
prepare: 'onPrepare',
|
562
|
+
focus: 'onFocus'
|
563
|
+
};
|
564
|
+
/**
|
565
|
+
* Create a class to be passed to the Handsontable's settings.
|
566
|
+
*
|
567
|
+
* @param {RefObject<HotEditorHooks>} hooksRef Reference to component-based editor overridden hooks object.
|
568
|
+
* @param {RefObject} instanceRef Reference to Handsontable-native custom editor class instance.
|
569
|
+
* @returns {Function} A class to be passed to the Handsontable editor settings.
|
570
|
+
*/
|
571
|
+
function makeEditorClass(hooksRef, instanceRef) {
|
572
|
+
return /*#__PURE__*/function (_Handsontable$editors) {
|
573
|
+
function CustomEditor(hotInstance) {
|
574
|
+
var _this;
|
575
|
+
_classCallCheck(this, CustomEditor);
|
576
|
+
_this = _callSuper(this, CustomEditor, [hotInstance]);
|
577
|
+
instanceRef.current = _this;
|
578
|
+
Object.getOwnPropertyNames(Handsontable__default["default"].editors.BaseEditor.prototype).forEach(function (propName) {
|
579
|
+
if (propName === 'constructor' || ExcludedMethods.includes(propName)) {
|
580
|
+
return;
|
581
|
+
}
|
582
|
+
var baseMethod = Handsontable__default["default"].editors.BaseEditor.prototype[propName];
|
583
|
+
CustomEditor.prototype[propName] = function () {
|
584
|
+
var _hooksRef$current;
|
585
|
+
var result;
|
586
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
587
|
+
args[_key] = arguments[_key];
|
588
|
+
}
|
589
|
+
if (!AbstractMethods.includes(propName)) {
|
590
|
+
result = baseMethod.call.apply(baseMethod, [this].concat(args)); // call super
|
591
|
+
}
|
592
|
+
if (MethodsMap[propName] && (_hooksRef$current = hooksRef.current) !== null && _hooksRef$current !== void 0 && _hooksRef$current[MethodsMap[propName]]) {
|
593
|
+
var _hooksRef$current$Met;
|
594
|
+
result = (_hooksRef$current$Met = hooksRef.current[MethodsMap[propName]]).call.apply(_hooksRef$current$Met, [this].concat(args));
|
595
|
+
}
|
596
|
+
return result;
|
597
|
+
}.bind(_this);
|
598
|
+
});
|
599
|
+
return _this;
|
600
|
+
}
|
601
|
+
_inherits(CustomEditor, _Handsontable$editors);
|
602
|
+
return _createClass(CustomEditor, [{
|
603
|
+
key: "focus",
|
604
|
+
value: function focus() {}
|
605
|
+
}, {
|
606
|
+
key: "getValue",
|
607
|
+
value: function getValue() {
|
608
|
+
return this.value;
|
609
|
+
}
|
610
|
+
}, {
|
611
|
+
key: "setValue",
|
612
|
+
value: function setValue(newValue) {
|
613
|
+
this.value = newValue;
|
614
|
+
}
|
615
|
+
}, {
|
616
|
+
key: "open",
|
617
|
+
value: function open() {}
|
618
|
+
}, {
|
619
|
+
key: "close",
|
620
|
+
value: function close() {}
|
621
|
+
}]);
|
622
|
+
}(Handsontable__default["default"].editors.BaseEditor);
|
623
|
+
}
|
624
|
+
/**
|
625
|
+
* Context to provide Handsontable-native custom editor class instance to overridden hooks object.
|
626
|
+
*/
|
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.
|
634
|
+
*/
|
635
|
+
var EditorContextProvider = function EditorContextProvider(_ref) {
|
636
|
+
var hooksRef = _ref.hooksRef,
|
637
|
+
hotCustomEditorInstanceRef = _ref.hotCustomEditorInstanceRef,
|
638
|
+
children = _ref.children;
|
639
|
+
return React__default["default"].createElement(EditorContext.Provider, {
|
640
|
+
value: {
|
641
|
+
hooksRef: hooksRef,
|
642
|
+
hotCustomEditorInstanceRef: hotCustomEditorInstanceRef
|
643
|
+
}
|
644
|
+
}, children);
|
645
|
+
};
|
646
|
+
/**
|
647
|
+
* Hook that allows encapsulating custom behaviours of component-based editor by customizing passed ref with overridden hooks object.
|
648
|
+
*
|
649
|
+
* @param {HotEditorHooks} overriddenHooks Overrides specific for the custom editor.
|
650
|
+
* @param {DependencyList} deps Overridden hooks object React dependency list.
|
651
|
+
* @returns {UseHotEditorImpl} Editor API methods
|
652
|
+
*/
|
653
|
+
function useHotEditor(overriddenHooks, deps) {
|
654
|
+
var _useContext = React.useContext(EditorContext),
|
655
|
+
hooksRef = _useContext.hooksRef,
|
656
|
+
hotCustomEditorInstanceRef = _useContext.hotCustomEditorInstanceRef;
|
657
|
+
var _useState = React.useState(0),
|
658
|
+
_useState2 = _slicedToArray(_useState, 2),
|
659
|
+
rerenderTrigger = _useState2[0],
|
660
|
+
setRerenderTrigger = _useState2[1];
|
661
|
+
var _useState3 = React.useState(),
|
662
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
663
|
+
editorValue = _useState4[0],
|
664
|
+
setEditorValue = _useState4[1];
|
665
|
+
// return a deferred value that allows for optimizing performance by delaying the update of a value until the next render.
|
666
|
+
var deferredValue = React.useDeferredValue(editorValue);
|
667
|
+
React.useImperativeHandle(hooksRef, function () {
|
668
|
+
return _objectSpread2(_objectSpread2({}, overriddenHooks), {}, {
|
669
|
+
onOpen: function onOpen() {
|
670
|
+
var _hotCustomEditorInsta, _overriddenHooks$onOp;
|
671
|
+
setEditorValue((_hotCustomEditorInsta = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta === void 0 ? void 0 : _hotCustomEditorInsta.getValue());
|
672
|
+
overriddenHooks === null || overriddenHooks === void 0 || (_overriddenHooks$onOp = overriddenHooks.onOpen) === null || _overriddenHooks$onOp === void 0 || _overriddenHooks$onOp.call(overriddenHooks);
|
673
|
+
setRerenderTrigger(function (t) {
|
674
|
+
return t + 1;
|
675
|
+
});
|
676
|
+
}
|
677
|
+
});
|
678
|
+
}, deps);
|
679
|
+
return React.useMemo(function () {
|
680
|
+
return {
|
681
|
+
get value() {
|
682
|
+
return deferredValue;
|
683
|
+
},
|
684
|
+
setValue: function setValue(newValue) {
|
685
|
+
var _hotCustomEditorInsta2;
|
686
|
+
setEditorValue(newValue);
|
687
|
+
(_hotCustomEditorInsta2 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta2 === void 0 || _hotCustomEditorInsta2.setValue(newValue);
|
688
|
+
},
|
689
|
+
get isOpen() {
|
690
|
+
var _hotCustomEditorInsta3, _hotCustomEditorInsta4;
|
691
|
+
return (_hotCustomEditorInsta3 = (_hotCustomEditorInsta4 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta4 === void 0 ? void 0 : _hotCustomEditorInsta4.isOpened()) !== null && _hotCustomEditorInsta3 !== void 0 ? _hotCustomEditorInsta3 : false;
|
692
|
+
},
|
693
|
+
finishEditing: function finishEditing() {
|
694
|
+
var _hotCustomEditorInsta5;
|
695
|
+
(_hotCustomEditorInsta5 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta5 === void 0 || _hotCustomEditorInsta5.finishEditing();
|
696
|
+
},
|
697
|
+
get row() {
|
698
|
+
var _hotCustomEditorInsta6;
|
699
|
+
return (_hotCustomEditorInsta6 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta6 === void 0 ? void 0 : _hotCustomEditorInsta6.row;
|
700
|
+
},
|
701
|
+
get col() {
|
702
|
+
var _hotCustomEditorInsta7;
|
703
|
+
return (_hotCustomEditorInsta7 = hotCustomEditorInstanceRef.current) === null || _hotCustomEditorInsta7 === void 0 ? void 0 : _hotCustomEditorInsta7.col;
|
704
|
+
}
|
705
|
+
};
|
706
|
+
}, [rerenderTrigger, hotCustomEditorInstanceRef, deferredValue]);
|
707
|
+
}
|
708
|
+
|
709
|
+
var isHotColumn = function isHotColumn(childNode) {
|
710
|
+
return childNode.type === HotColumn;
|
711
|
+
};
|
712
|
+
var internalProps = ['_columnIndex', '_getOwnerDocument', 'children'];
|
713
|
+
var HotColumn = function HotColumn(props) {
|
714
|
+
var _useHotTableContext = useHotTableContext(),
|
715
|
+
componentRendererColumns = _useHotTableContext.componentRendererColumns,
|
716
|
+
emitColumnSettings = _useHotTableContext.emitColumnSettings,
|
717
|
+
getRendererWrapper = _useHotTableContext.getRendererWrapper;
|
718
|
+
var _useHotColumnContext = useHotColumnContext(),
|
719
|
+
columnIndex = _useHotColumnContext.columnIndex,
|
720
|
+
getOwnerDocument = _useHotColumnContext.getOwnerDocument;
|
721
|
+
/**
|
722
|
+
* Reference to component-based editor overridden hooks object.
|
723
|
+
*/
|
724
|
+
var localEditorHooksRef = React.useRef(null);
|
725
|
+
/**
|
726
|
+
* Reference to HOT-native custom editor class instance.
|
727
|
+
*/
|
728
|
+
var localEditorClassInstance = React.useRef(null);
|
729
|
+
/**
|
730
|
+
* Logic performed after mounting & updating of the HotColumn component.
|
731
|
+
*/
|
732
|
+
React.useEffect(function () {
|
733
|
+
/**
|
734
|
+
* Filter out all the internal properties and return an object with just the Handsontable-related props.
|
735
|
+
*
|
736
|
+
* @returns {Object}
|
737
|
+
*/
|
738
|
+
var getSettingsProps = function getSettingsProps() {
|
739
|
+
return Object.keys(props).filter(function (key) {
|
740
|
+
return !internalProps.includes(key);
|
741
|
+
}).reduce(function (obj, key) {
|
742
|
+
obj[key] = props[key];
|
743
|
+
return obj;
|
744
|
+
}, {});
|
745
|
+
};
|
746
|
+
/**
|
747
|
+
* Create the column settings based on the data provided to the `HotColumn` component and its child components.
|
748
|
+
*/
|
749
|
+
var createColumnSettings = function createColumnSettings() {
|
750
|
+
var columnSettings = SettingsMapper.getSettings(getSettingsProps());
|
751
|
+
if (props.renderer) {
|
752
|
+
columnSettings.renderer = getRendererWrapper(props.renderer);
|
753
|
+
componentRendererColumns.set(columnIndex, true);
|
754
|
+
} else if (props.hotRenderer) {
|
755
|
+
columnSettings.renderer = props.hotRenderer;
|
756
|
+
}
|
757
|
+
if (props.editor) {
|
758
|
+
columnSettings.editor = makeEditorClass(localEditorHooksRef, localEditorClassInstance);
|
759
|
+
} else if (props.hotEditor) {
|
760
|
+
columnSettings.editor = props.hotEditor;
|
761
|
+
}
|
762
|
+
return columnSettings;
|
763
|
+
};
|
764
|
+
var columnSettings = createColumnSettings();
|
765
|
+
emitColumnSettings(columnSettings, columnIndex);
|
766
|
+
if (!displayObsoleteRenderersEditorsWarning(props.children)) {
|
767
|
+
displayAnyChildrenWarning(props.children);
|
768
|
+
}
|
769
|
+
});
|
770
|
+
var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
|
771
|
+
/**
|
772
|
+
* Render the portals of the editors, if there are any.
|
773
|
+
*
|
774
|
+
* @returns {ReactElement}
|
775
|
+
*/
|
776
|
+
return React__default["default"].createElement(EditorContextProvider, {
|
777
|
+
hooksRef: localEditorHooksRef,
|
778
|
+
hotCustomEditorInstanceRef: localEditorClassInstance
|
779
|
+
}, editorPortal);
|
780
|
+
};
|
781
|
+
|
782
|
+
var version="0.0.0-next-7cc7ef7-20241028";
|
783
|
+
|
784
|
+
/**
|
785
|
+
* Component used to manage the renderer component portals.
|
786
|
+
*/
|
787
|
+
var RenderersPortalManager = React.forwardRef(function (_, ref) {
|
788
|
+
var _useState = React.useState([]),
|
789
|
+
_useState2 = _slicedToArray(_useState, 2),
|
790
|
+
portals = _useState2[0],
|
791
|
+
setPortals = _useState2[1];
|
792
|
+
React.useImperativeHandle(ref, function () {
|
793
|
+
return setPortals;
|
794
|
+
});
|
795
|
+
return React__default["default"].createElement(React.Fragment, null, portals);
|
796
|
+
});
|
797
|
+
|
798
|
+
function getDefaultExportFromCjs (x) {
|
799
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
800
|
+
}
|
801
|
+
|
802
|
+
var propTypes = {exports: {}};
|
803
|
+
|
804
|
+
/**
|
805
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
806
|
+
*
|
807
|
+
* This source code is licensed under the MIT license found in the
|
808
|
+
* LICENSE file in the root directory of this source tree.
|
809
|
+
*/
|
810
|
+
var ReactPropTypesSecret_1;
|
811
|
+
var hasRequiredReactPropTypesSecret;
|
812
|
+
function requireReactPropTypesSecret() {
|
813
|
+
if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
|
814
|
+
hasRequiredReactPropTypesSecret = 1;
|
815
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
816
|
+
ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
817
|
+
return ReactPropTypesSecret_1;
|
818
|
+
}
|
819
|
+
|
820
|
+
/**
|
821
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
822
|
+
*
|
823
|
+
* This source code is licensed under the MIT license found in the
|
824
|
+
* LICENSE file in the root directory of this source tree.
|
825
|
+
*/
|
826
|
+
var factoryWithThrowingShims;
|
827
|
+
var hasRequiredFactoryWithThrowingShims;
|
828
|
+
function requireFactoryWithThrowingShims() {
|
829
|
+
if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
|
830
|
+
hasRequiredFactoryWithThrowingShims = 1;
|
831
|
+
var ReactPropTypesSecret = requireReactPropTypesSecret();
|
832
|
+
function emptyFunction() {}
|
833
|
+
function emptyFunctionWithReset() {}
|
834
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
835
|
+
factoryWithThrowingShims = function factoryWithThrowingShims() {
|
836
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
837
|
+
if (secret === ReactPropTypesSecret) {
|
838
|
+
// It is still safe when called from React.
|
839
|
+
return;
|
840
|
+
}
|
841
|
+
var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');
|
842
|
+
err.name = 'Invariant Violation';
|
843
|
+
throw err;
|
844
|
+
}
|
845
|
+
shim.isRequired = shim;
|
846
|
+
function getShim() {
|
847
|
+
return shim;
|
848
|
+
}
|
849
|
+
// Important!
|
850
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
851
|
+
var ReactPropTypes = {
|
852
|
+
array: shim,
|
853
|
+
bigint: shim,
|
854
|
+
bool: shim,
|
855
|
+
func: shim,
|
856
|
+
number: shim,
|
857
|
+
object: shim,
|
858
|
+
string: shim,
|
859
|
+
symbol: shim,
|
860
|
+
any: shim,
|
861
|
+
arrayOf: getShim,
|
862
|
+
element: shim,
|
863
|
+
elementType: shim,
|
864
|
+
instanceOf: getShim,
|
865
|
+
node: shim,
|
866
|
+
objectOf: getShim,
|
867
|
+
oneOf: getShim,
|
868
|
+
oneOfType: getShim,
|
869
|
+
shape: getShim,
|
870
|
+
exact: getShim,
|
871
|
+
checkPropTypes: emptyFunctionWithReset,
|
872
|
+
resetWarningCache: emptyFunction
|
873
|
+
};
|
874
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
875
|
+
return ReactPropTypes;
|
876
|
+
};
|
877
|
+
return factoryWithThrowingShims;
|
878
|
+
}
|
879
|
+
|
880
|
+
/**
|
881
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
882
|
+
*
|
883
|
+
* This source code is licensed under the MIT license found in the
|
884
|
+
* LICENSE file in the root directory of this source tree.
|
885
|
+
*/
|
886
|
+
{
|
887
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
888
|
+
// http://fb.me/prop-types-in-prod
|
889
|
+
propTypes.exports = requireFactoryWithThrowingShims()();
|
890
|
+
}
|
891
|
+
var propTypesExports = propTypes.exports;
|
892
|
+
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
893
|
+
|
894
|
+
var HotTableInner = React.forwardRef(function (props, ref) {
|
895
|
+
/**
|
896
|
+
* Reference to the Handsontable instance.
|
897
|
+
*/
|
898
|
+
var __hotInstance = React.useRef(null);
|
899
|
+
/**
|
900
|
+
* Reference to the main Handsontable DOM element.
|
901
|
+
*/
|
902
|
+
var hotElementRef = React.useRef(null);
|
903
|
+
/**
|
904
|
+
* Reference to component-based editor overridden hooks object.
|
905
|
+
*/
|
906
|
+
var globalEditorHooksRef = React.useRef(null);
|
907
|
+
/**
|
908
|
+
* Reference to HOT-native custom editor class instance.
|
909
|
+
*/
|
910
|
+
var globalEditorClassInstance = React.useRef(null);
|
911
|
+
/**
|
912
|
+
* Reference to the previous props object.
|
913
|
+
*/
|
914
|
+
var prevProps = React.useRef();
|
915
|
+
/**
|
916
|
+
* HotTable context exposing helper functions.
|
917
|
+
*/
|
918
|
+
var context = useHotTableContext();
|
919
|
+
/**
|
920
|
+
* Getter for the property storing the Handsontable instance.
|
921
|
+
*/
|
922
|
+
var getHotInstance = React.useCallback(function () {
|
923
|
+
if (!__hotInstance.current || !__hotInstance.current.isDestroyed) {
|
924
|
+
// Will return the Handsontable instance or `null` if it's not yet been created.
|
925
|
+
return __hotInstance.current;
|
926
|
+
} else {
|
927
|
+
console.warn(HOT_DESTROYED_WARNING);
|
928
|
+
return null;
|
929
|
+
}
|
930
|
+
}, [__hotInstance]);
|
931
|
+
var isHotInstanceDestroyed = React.useCallback(function () {
|
932
|
+
return !__hotInstance.current || __hotInstance.current.isDestroyed;
|
933
|
+
}, [__hotInstance]);
|
934
|
+
/**
|
935
|
+
* Clear both the editor and the renderer cache.
|
936
|
+
*/
|
937
|
+
var clearCache = React.useCallback(function () {
|
938
|
+
context.clearRenderedCellCache();
|
939
|
+
context.componentRendererColumns.clear();
|
940
|
+
}, [context]);
|
941
|
+
/**
|
942
|
+
* Get the `Document` object corresponding to the main component element.
|
943
|
+
*
|
944
|
+
* @returns The `Document` object used by the component.
|
945
|
+
*/
|
946
|
+
var getOwnerDocument = React.useCallback(function () {
|
947
|
+
if (isCSR()) {
|
948
|
+
return hotElementRef.current ? hotElementRef.current.ownerDocument : document;
|
949
|
+
}
|
950
|
+
return null;
|
951
|
+
}, [hotElementRef]);
|
952
|
+
/**
|
953
|
+
* Create a new settings object containing the column settings and global editors and renderers.
|
954
|
+
*
|
955
|
+
* @returns {Handsontable.GridSettings} New global set of settings for Handsontable.
|
956
|
+
*/
|
957
|
+
var createNewGlobalSettings = function createNewGlobalSettings() {
|
958
|
+
var _getHotInstance;
|
959
|
+
var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
960
|
+
var prevProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
961
|
+
var initOnlySettingKeys = !isHotInstanceDestroyed() ?
|
962
|
+
// Needed for React's double-rendering.
|
963
|
+
((_getHotInstance = getHotInstance()) === null || _getHotInstance === void 0 || (_getHotInstance = _getHotInstance.getSettings()) === null || _getHotInstance === void 0 ? void 0 : _getHotInstance._initOnlySettings) || [] : [];
|
964
|
+
var newSettings = SettingsMapper.getSettings(props, {
|
965
|
+
prevProps: prevProps,
|
966
|
+
isInit: init,
|
967
|
+
initOnlySettingKeys: initOnlySettingKeys
|
968
|
+
});
|
969
|
+
newSettings.columns = context.columnsSettings.length ? context.columnsSettings : newSettings.columns;
|
970
|
+
if (props.renderer) {
|
971
|
+
newSettings.renderer = context.getRendererWrapper(props.renderer);
|
972
|
+
context.componentRendererColumns.set('global', true);
|
973
|
+
} else {
|
974
|
+
newSettings.renderer = props.hotRenderer || registry.getRenderer('text');
|
975
|
+
}
|
976
|
+
if (props.editor) {
|
977
|
+
newSettings.editor = makeEditorClass(globalEditorHooksRef, globalEditorClassInstance);
|
978
|
+
} else {
|
979
|
+
newSettings.editor = props.hotEditor || registry$1.getEditor('text');
|
980
|
+
}
|
981
|
+
return newSettings;
|
982
|
+
};
|
983
|
+
/**
|
984
|
+
* Detect if `autoRowSize` or `autoColumnSize` is defined, and if so, throw an incompatibility warning.
|
985
|
+
*/
|
986
|
+
var displayAutoSizeWarning = function displayAutoSizeWarning(hotInstance) {
|
987
|
+
var _hotInstance$getPlugi, _hotInstance$getPlugi2;
|
988
|
+
if (hotInstance && ((_hotInstance$getPlugi = hotInstance.getPlugin('autoRowSize')) !== null && _hotInstance$getPlugi !== void 0 && _hotInstance$getPlugi.enabled || (_hotInstance$getPlugi2 = hotInstance.getPlugin('autoColumnSize')) !== null && _hotInstance$getPlugi2 !== void 0 && _hotInstance$getPlugi2.enabled)) {
|
989
|
+
if (context.componentRendererColumns.size > 0) {
|
990
|
+
warn(AUTOSIZE_WARNING);
|
991
|
+
}
|
992
|
+
}
|
993
|
+
};
|
994
|
+
/**
|
995
|
+
* Initialize Handsontable after the component has mounted.
|
996
|
+
*/
|
997
|
+
React.useEffect(function () {
|
998
|
+
var newGlobalSettings = createNewGlobalSettings(true);
|
999
|
+
// Update prevProps with the current props
|
1000
|
+
prevProps.current = props;
|
1001
|
+
__hotInstance.current = new Handsontable__default["default"].Core(hotElementRef.current, newGlobalSettings);
|
1002
|
+
/**
|
1003
|
+
* Handsontable's `beforeViewRender` hook callback.
|
1004
|
+
*/
|
1005
|
+
__hotInstance.current.addHook('beforeViewRender', function () {
|
1006
|
+
context.clearPortalCache();
|
1007
|
+
context.clearRenderedCellCache();
|
1008
|
+
});
|
1009
|
+
/**
|
1010
|
+
* Handsontable's `afterViewRender` hook callback.
|
1011
|
+
*/
|
1012
|
+
__hotInstance.current.addHook('afterViewRender', function () {
|
1013
|
+
context.pushCellPortalsIntoPortalManager();
|
1014
|
+
});
|
1015
|
+
__hotInstance.current.init();
|
1016
|
+
displayAutoSizeWarning(__hotInstance.current);
|
1017
|
+
if (!displayObsoleteRenderersEditorsWarning(props.children)) {
|
1018
|
+
displayChildrenOfTypeWarning(props.children, HotColumn);
|
1019
|
+
}
|
1020
|
+
/**
|
1021
|
+
* Destroy the Handsontable instance when the parent component unmounts.
|
1022
|
+
*/
|
1023
|
+
return function () {
|
1024
|
+
var _getHotInstance2;
|
1025
|
+
clearCache();
|
1026
|
+
(_getHotInstance2 = getHotInstance()) === null || _getHotInstance2 === void 0 || _getHotInstance2.destroy();
|
1027
|
+
};
|
1028
|
+
}, []);
|
1029
|
+
/**
|
1030
|
+
* Logic performed after the component update.
|
1031
|
+
*/
|
1032
|
+
useUpdateEffect(function () {
|
1033
|
+
clearCache();
|
1034
|
+
var hotInstance = getHotInstance();
|
1035
|
+
var newGlobalSettings = createNewGlobalSettings(false, prevProps.current);
|
1036
|
+
// Update prevProps with the current props
|
1037
|
+
prevProps.current = props;
|
1038
|
+
hotInstance === null || hotInstance === void 0 || hotInstance.updateSettings(newGlobalSettings, false);
|
1039
|
+
displayAutoSizeWarning(hotInstance);
|
1040
|
+
displayObsoleteRenderersEditorsWarning(props.children);
|
1041
|
+
});
|
1042
|
+
/**
|
1043
|
+
* Interface exposed to parent components by HotTable instance via React ref
|
1044
|
+
*/
|
1045
|
+
React.useImperativeHandle(ref, function () {
|
1046
|
+
return {
|
1047
|
+
get hotElementRef() {
|
1048
|
+
return hotElementRef.current;
|
1049
|
+
},
|
1050
|
+
get hotInstance() {
|
1051
|
+
return getHotInstance();
|
1052
|
+
}
|
1053
|
+
};
|
1054
|
+
});
|
1055
|
+
/**
|
1056
|
+
* Render the component.
|
1057
|
+
*/
|
1058
|
+
var hotColumnWrapped = React.Children.toArray(props.children).filter(isHotColumn).map(function (childNode, columnIndex) {
|
1059
|
+
return React__default["default"].createElement(HotColumnContextProvider, {
|
1060
|
+
columnIndex: columnIndex,
|
1061
|
+
getOwnerDocument: getOwnerDocument,
|
1062
|
+
key: columnIndex
|
1063
|
+
}, childNode);
|
1064
|
+
});
|
1065
|
+
var containerProps = getContainerAttributesProps(props);
|
1066
|
+
var editorPortal = createEditorPortal(getOwnerDocument(), props.editor);
|
1067
|
+
return React__default["default"].createElement(React.Fragment, null, React__default["default"].createElement("div", Object.assign({
|
1068
|
+
ref: hotElementRef
|
1069
|
+
}, containerProps), hotColumnWrapped), React__default["default"].createElement(RenderersPortalManager, {
|
1070
|
+
ref: context.setRenderersPortalManagerRef
|
1071
|
+
}), React__default["default"].createElement(EditorContextProvider, {
|
1072
|
+
hooksRef: globalEditorHooksRef,
|
1073
|
+
hotCustomEditorInstanceRef: globalEditorClassInstance
|
1074
|
+
}, editorPortal));
|
1075
|
+
});
|
1076
|
+
/**
|
1077
|
+
* Prop types to be checked at runtime.
|
1078
|
+
*/
|
1079
|
+
HotTableInner.propTypes = {
|
1080
|
+
style: PropTypes.object,
|
1081
|
+
id: PropTypes.string,
|
1082
|
+
className: PropTypes.string
|
1083
|
+
};
|
1084
|
+
|
1085
|
+
var _excluded = ["children"];
|
1086
|
+
/**
|
1087
|
+
* A Handsontable-ReactJS wrapper.
|
1088
|
+
*
|
1089
|
+
* To implement, use the `HotTable` tag with properties corresponding to Handsontable options.
|
1090
|
+
* For example:
|
1091
|
+
*
|
1092
|
+
* ```js
|
1093
|
+
* <HotTable id="hot" data={dataObject} contextMenu={true} colHeaders={true} width={600} height={300} stretchH="all" />
|
1094
|
+
*
|
1095
|
+
* // is analogous to
|
1096
|
+
* let hot = new Handsontable(document.getElementById('hot'), {
|
1097
|
+
* data: dataObject,
|
1098
|
+
* contextMenu: true,
|
1099
|
+
* colHeaders: true,
|
1100
|
+
* width: 600
|
1101
|
+
* height: 300
|
1102
|
+
* });
|
1103
|
+
*
|
1104
|
+
* ```
|
1105
|
+
*/
|
1106
|
+
var HotTable = React.forwardRef(function (_ref, ref) {
|
1107
|
+
var _props$id;
|
1108
|
+
var children = _ref.children,
|
1109
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
1110
|
+
var componentId = (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : React.useId();
|
1111
|
+
return React__default["default"].createElement(HotTableContextProvider, null, React__default["default"].createElement(HotTableInner, Object.assign({
|
1112
|
+
id: componentId
|
1113
|
+
}, props, {
|
1114
|
+
ref: ref
|
1115
|
+
}), children));
|
1116
|
+
});
|
1117
|
+
/**
|
1118
|
+
* Package version.
|
1119
|
+
*
|
1120
|
+
* @returns The version number of the package.
|
1121
|
+
*/
|
1122
|
+
HotTable.version = version;
|
1123
|
+
|
1124
|
+
exports.HotColumn = HotColumn;
|
1125
|
+
exports.HotTable = HotTable;
|
1126
|
+
exports["default"] = HotTable;
|
1127
|
+
exports.isHotColumn = isHotColumn;
|
1128
|
+
exports.useHotEditor = useHotEditor;
|
1129
|
+
|
1130
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
1131
|
+
|
1132
|
+
}));
|
1133
|
+
//# sourceMappingURL=react-handsontable.js.map
|