@asup/tree-of-nodes 0.9.0

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.
@@ -0,0 +1,1730 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+
6
+ function _interopNamespaceDefault(e) {
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
24
+
25
+ const ContextMenu = React.forwardRef(({ entries, visible, xPos, yPos }, ref) => {
26
+ ContextMenu.displayName = 'ContextMenu';
27
+ return (jsxRuntime.jsx("div", { ref: ref, className: `context-menu ${visible ? 'visible' : ''}`, style: {
28
+ top: `${yPos}px`,
29
+ left: `${xPos}px`,
30
+ }, children: entries.map((e, i) => (jsxRuntime.jsx("div", { className: 'context-menu-item', onClick: () => {
31
+ if (typeof e.action === 'function')
32
+ e.action();
33
+ }, children: e.label ?? '' }, i))) }));
34
+ });
35
+
36
+ const MenuContext = React.createContext({});
37
+ const ContextMenuProvider = ({ children }) => {
38
+ // Menu resources
39
+ const divRef = React.useRef(null);
40
+ const menuRef = React.useRef(null);
41
+ const [menuXPos, setMenuXPos] = React.useState(0);
42
+ const [menuYPos, setMenuYPos] = React.useState(0);
43
+ const [menuVisible, setMenuVisible] = React.useState(false);
44
+ const [menuItems, setMenuItems] = React.useState([]);
45
+ // Update menu items
46
+ const updateMenu = React.useCallback((ret) => {
47
+ if (!divRef.current)
48
+ return;
49
+ if (ret.visible !== undefined)
50
+ setMenuVisible(ret.visible);
51
+ if (ret.x !== undefined)
52
+ setMenuXPos(ret.x - window.scrollX - divRef.current.getBoundingClientRect().x);
53
+ if (ret.y !== undefined)
54
+ setMenuYPos(ret.y - window.scrollX - divRef.current.getBoundingClientRect().y);
55
+ if (ret.menuItems !== undefined)
56
+ setMenuItems(ret.menuItems);
57
+ }, []);
58
+ // Handle click off the menu
59
+ const handleClick = React.useCallback((e) => {
60
+ if (menuRef.current &&
61
+ ((e.target instanceof Element && !menuRef.current?.contains(e.target)) ||
62
+ !(e.target instanceof Element))) {
63
+ setMenuVisible(false);
64
+ }
65
+ }, []);
66
+ // Update the document click handler
67
+ React.useEffect(() => {
68
+ if (menuVisible)
69
+ document.addEventListener('mousedown', handleClick);
70
+ else
71
+ document.removeEventListener('mousedown', handleClick);
72
+ return () => {
73
+ document.removeEventListener('mousedown', handleClick);
74
+ };
75
+ }, [handleClick, menuVisible]);
76
+ return (jsxRuntime.jsx(MenuContext.Provider, { value: {
77
+ visible: menuVisible,
78
+ x: menuXPos,
79
+ y: menuYPos,
80
+ set: updateMenu,
81
+ }, children: jsxRuntime.jsxs("div", { className: 'menu-context-provider', style: { position: 'relative' }, ref: divRef, children: [children, jsxRuntime.jsx(ContextMenu, { ref: menuRef, entries: menuItems, visible: menuVisible, xPos: menuXPos, yPos: menuYPos })] }) }));
82
+ };
83
+
84
+ var classnames = {exports: {}};
85
+
86
+ /*!
87
+ Copyright (c) 2018 Jed Watson.
88
+ Licensed under the MIT License (MIT), see
89
+ http://jedwatson.github.io/classnames
90
+ */
91
+
92
+ (function (module) {
93
+ /* global define */
94
+
95
+ (function () {
96
+
97
+ var hasOwn = {}.hasOwnProperty;
98
+
99
+ function classNames() {
100
+ var classes = [];
101
+
102
+ for (var i = 0; i < arguments.length; i++) {
103
+ var arg = arguments[i];
104
+ if (!arg) continue;
105
+
106
+ var argType = typeof arg;
107
+
108
+ if (argType === 'string' || argType === 'number') {
109
+ classes.push(arg);
110
+ } else if (Array.isArray(arg)) {
111
+ if (arg.length) {
112
+ var inner = classNames.apply(null, arg);
113
+ if (inner) {
114
+ classes.push(inner);
115
+ }
116
+ }
117
+ } else if (argType === 'object') {
118
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
119
+ classes.push(arg.toString());
120
+ continue;
121
+ }
122
+
123
+ for (var key in arg) {
124
+ if (hasOwn.call(arg, key) && arg[key]) {
125
+ classes.push(key);
126
+ }
127
+ }
128
+ }
129
+ }
130
+
131
+ return classes.join(' ');
132
+ }
133
+
134
+ if (module.exports) {
135
+ classNames.default = classNames;
136
+ module.exports = classNames;
137
+ } else {
138
+ window.classNames = classNames;
139
+ }
140
+ }());
141
+ } (classnames));
142
+
143
+ var classNames = classnames.exports;
144
+
145
+ const DEFAULT_BREAKPOINTS = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs'];
146
+ const DEFAULT_MIN_BREAKPOINT = 'xs';
147
+ const ThemeContext = /*#__PURE__*/React__namespace.createContext({
148
+ prefixes: {},
149
+ breakpoints: DEFAULT_BREAKPOINTS,
150
+ minBreakpoint: DEFAULT_MIN_BREAKPOINT
151
+ });
152
+
153
+ function useBootstrapPrefix(prefix, defaultPrefix) {
154
+ const {
155
+ prefixes
156
+ } = React.useContext(ThemeContext);
157
+ return prefix || prefixes[defaultPrefix] || defaultPrefix;
158
+ }
159
+
160
+ var propTypes = {exports: {}};
161
+
162
+ var reactIs = {exports: {}};
163
+
164
+ var reactIs_production_min = {};
165
+
166
+ /** @license React v16.13.1
167
+ * react-is.production.min.js
168
+ *
169
+ * Copyright (c) Facebook, Inc. and its affiliates.
170
+ *
171
+ * This source code is licensed under the MIT license found in the
172
+ * LICENSE file in the root directory of this source tree.
173
+ */
174
+
175
+ var hasRequiredReactIs_production_min;
176
+
177
+ function requireReactIs_production_min () {
178
+ if (hasRequiredReactIs_production_min) return reactIs_production_min;
179
+ hasRequiredReactIs_production_min = 1;
180
+ var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
181
+ Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
182
+ function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min.AsyncMode=l;reactIs_production_min.ConcurrentMode=m;reactIs_production_min.ContextConsumer=k;reactIs_production_min.ContextProvider=h;reactIs_production_min.Element=c;reactIs_production_min.ForwardRef=n;reactIs_production_min.Fragment=e;reactIs_production_min.Lazy=t;reactIs_production_min.Memo=r;reactIs_production_min.Portal=d;
183
+ reactIs_production_min.Profiler=g;reactIs_production_min.StrictMode=f;reactIs_production_min.Suspense=p;reactIs_production_min.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min.isConcurrentMode=A;reactIs_production_min.isContextConsumer=function(a){return z(a)===k};reactIs_production_min.isContextProvider=function(a){return z(a)===h};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min.isForwardRef=function(a){return z(a)===n};reactIs_production_min.isFragment=function(a){return z(a)===e};reactIs_production_min.isLazy=function(a){return z(a)===t};
184
+ reactIs_production_min.isMemo=function(a){return z(a)===r};reactIs_production_min.isPortal=function(a){return z(a)===d};reactIs_production_min.isProfiler=function(a){return z(a)===g};reactIs_production_min.isStrictMode=function(a){return z(a)===f};reactIs_production_min.isSuspense=function(a){return z(a)===p};
185
+ reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min.typeOf=z;
186
+ return reactIs_production_min;
187
+ }
188
+
189
+ var reactIs_development = {};
190
+
191
+ /** @license React v16.13.1
192
+ * react-is.development.js
193
+ *
194
+ * Copyright (c) Facebook, Inc. and its affiliates.
195
+ *
196
+ * This source code is licensed under the MIT license found in the
197
+ * LICENSE file in the root directory of this source tree.
198
+ */
199
+
200
+ var hasRequiredReactIs_development;
201
+
202
+ function requireReactIs_development () {
203
+ if (hasRequiredReactIs_development) return reactIs_development;
204
+ hasRequiredReactIs_development = 1;
205
+
206
+
207
+
208
+ if (process.env.NODE_ENV !== "production") {
209
+ (function() {
210
+
211
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
212
+ // nor polyfill, then a plain number is used for performance.
213
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
214
+ var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
215
+ var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
216
+ var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
217
+ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
218
+ var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
219
+ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
220
+ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
221
+ // (unstable) APIs that have been removed. Can we remove the symbols?
222
+
223
+ var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
224
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
225
+ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
226
+ var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
227
+ var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
228
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
229
+ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
230
+ var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
231
+ var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
232
+ var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
233
+ var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
234
+
235
+ function isValidElementType(type) {
236
+ return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
237
+ type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
238
+ }
239
+
240
+ function typeOf(object) {
241
+ if (typeof object === 'object' && object !== null) {
242
+ var $$typeof = object.$$typeof;
243
+
244
+ switch ($$typeof) {
245
+ case REACT_ELEMENT_TYPE:
246
+ var type = object.type;
247
+
248
+ switch (type) {
249
+ case REACT_ASYNC_MODE_TYPE:
250
+ case REACT_CONCURRENT_MODE_TYPE:
251
+ case REACT_FRAGMENT_TYPE:
252
+ case REACT_PROFILER_TYPE:
253
+ case REACT_STRICT_MODE_TYPE:
254
+ case REACT_SUSPENSE_TYPE:
255
+ return type;
256
+
257
+ default:
258
+ var $$typeofType = type && type.$$typeof;
259
+
260
+ switch ($$typeofType) {
261
+ case REACT_CONTEXT_TYPE:
262
+ case REACT_FORWARD_REF_TYPE:
263
+ case REACT_LAZY_TYPE:
264
+ case REACT_MEMO_TYPE:
265
+ case REACT_PROVIDER_TYPE:
266
+ return $$typeofType;
267
+
268
+ default:
269
+ return $$typeof;
270
+ }
271
+
272
+ }
273
+
274
+ case REACT_PORTAL_TYPE:
275
+ return $$typeof;
276
+ }
277
+ }
278
+
279
+ return undefined;
280
+ } // AsyncMode is deprecated along with isAsyncMode
281
+
282
+ var AsyncMode = REACT_ASYNC_MODE_TYPE;
283
+ var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
284
+ var ContextConsumer = REACT_CONTEXT_TYPE;
285
+ var ContextProvider = REACT_PROVIDER_TYPE;
286
+ var Element = REACT_ELEMENT_TYPE;
287
+ var ForwardRef = REACT_FORWARD_REF_TYPE;
288
+ var Fragment = REACT_FRAGMENT_TYPE;
289
+ var Lazy = REACT_LAZY_TYPE;
290
+ var Memo = REACT_MEMO_TYPE;
291
+ var Portal = REACT_PORTAL_TYPE;
292
+ var Profiler = REACT_PROFILER_TYPE;
293
+ var StrictMode = REACT_STRICT_MODE_TYPE;
294
+ var Suspense = REACT_SUSPENSE_TYPE;
295
+ var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
296
+
297
+ function isAsyncMode(object) {
298
+ {
299
+ if (!hasWarnedAboutDeprecatedIsAsyncMode) {
300
+ hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
301
+
302
+ console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
303
+ }
304
+ }
305
+
306
+ return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
307
+ }
308
+ function isConcurrentMode(object) {
309
+ return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
310
+ }
311
+ function isContextConsumer(object) {
312
+ return typeOf(object) === REACT_CONTEXT_TYPE;
313
+ }
314
+ function isContextProvider(object) {
315
+ return typeOf(object) === REACT_PROVIDER_TYPE;
316
+ }
317
+ function isElement(object) {
318
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
319
+ }
320
+ function isForwardRef(object) {
321
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
322
+ }
323
+ function isFragment(object) {
324
+ return typeOf(object) === REACT_FRAGMENT_TYPE;
325
+ }
326
+ function isLazy(object) {
327
+ return typeOf(object) === REACT_LAZY_TYPE;
328
+ }
329
+ function isMemo(object) {
330
+ return typeOf(object) === REACT_MEMO_TYPE;
331
+ }
332
+ function isPortal(object) {
333
+ return typeOf(object) === REACT_PORTAL_TYPE;
334
+ }
335
+ function isProfiler(object) {
336
+ return typeOf(object) === REACT_PROFILER_TYPE;
337
+ }
338
+ function isStrictMode(object) {
339
+ return typeOf(object) === REACT_STRICT_MODE_TYPE;
340
+ }
341
+ function isSuspense(object) {
342
+ return typeOf(object) === REACT_SUSPENSE_TYPE;
343
+ }
344
+
345
+ reactIs_development.AsyncMode = AsyncMode;
346
+ reactIs_development.ConcurrentMode = ConcurrentMode;
347
+ reactIs_development.ContextConsumer = ContextConsumer;
348
+ reactIs_development.ContextProvider = ContextProvider;
349
+ reactIs_development.Element = Element;
350
+ reactIs_development.ForwardRef = ForwardRef;
351
+ reactIs_development.Fragment = Fragment;
352
+ reactIs_development.Lazy = Lazy;
353
+ reactIs_development.Memo = Memo;
354
+ reactIs_development.Portal = Portal;
355
+ reactIs_development.Profiler = Profiler;
356
+ reactIs_development.StrictMode = StrictMode;
357
+ reactIs_development.Suspense = Suspense;
358
+ reactIs_development.isAsyncMode = isAsyncMode;
359
+ reactIs_development.isConcurrentMode = isConcurrentMode;
360
+ reactIs_development.isContextConsumer = isContextConsumer;
361
+ reactIs_development.isContextProvider = isContextProvider;
362
+ reactIs_development.isElement = isElement;
363
+ reactIs_development.isForwardRef = isForwardRef;
364
+ reactIs_development.isFragment = isFragment;
365
+ reactIs_development.isLazy = isLazy;
366
+ reactIs_development.isMemo = isMemo;
367
+ reactIs_development.isPortal = isPortal;
368
+ reactIs_development.isProfiler = isProfiler;
369
+ reactIs_development.isStrictMode = isStrictMode;
370
+ reactIs_development.isSuspense = isSuspense;
371
+ reactIs_development.isValidElementType = isValidElementType;
372
+ reactIs_development.typeOf = typeOf;
373
+ })();
374
+ }
375
+ return reactIs_development;
376
+ }
377
+
378
+ var hasRequiredReactIs;
379
+
380
+ function requireReactIs () {
381
+ if (hasRequiredReactIs) return reactIs.exports;
382
+ hasRequiredReactIs = 1;
383
+ (function (module) {
384
+
385
+ if (process.env.NODE_ENV === 'production') {
386
+ module.exports = requireReactIs_production_min();
387
+ } else {
388
+ module.exports = requireReactIs_development();
389
+ }
390
+ } (reactIs));
391
+ return reactIs.exports;
392
+ }
393
+
394
+ /*
395
+ object-assign
396
+ (c) Sindre Sorhus
397
+ @license MIT
398
+ */
399
+
400
+ var objectAssign;
401
+ var hasRequiredObjectAssign;
402
+
403
+ function requireObjectAssign () {
404
+ if (hasRequiredObjectAssign) return objectAssign;
405
+ hasRequiredObjectAssign = 1;
406
+ /* eslint-disable no-unused-vars */
407
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
408
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
409
+ var propIsEnumerable = Object.prototype.propertyIsEnumerable;
410
+
411
+ function toObject(val) {
412
+ if (val === null || val === undefined) {
413
+ throw new TypeError('Object.assign cannot be called with null or undefined');
414
+ }
415
+
416
+ return Object(val);
417
+ }
418
+
419
+ function shouldUseNative() {
420
+ try {
421
+ if (!Object.assign) {
422
+ return false;
423
+ }
424
+
425
+ // Detect buggy property enumeration order in older V8 versions.
426
+
427
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
428
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
429
+ test1[5] = 'de';
430
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
431
+ return false;
432
+ }
433
+
434
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
435
+ var test2 = {};
436
+ for (var i = 0; i < 10; i++) {
437
+ test2['_' + String.fromCharCode(i)] = i;
438
+ }
439
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
440
+ return test2[n];
441
+ });
442
+ if (order2.join('') !== '0123456789') {
443
+ return false;
444
+ }
445
+
446
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
447
+ var test3 = {};
448
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
449
+ test3[letter] = letter;
450
+ });
451
+ if (Object.keys(Object.assign({}, test3)).join('') !==
452
+ 'abcdefghijklmnopqrst') {
453
+ return false;
454
+ }
455
+
456
+ return true;
457
+ } catch (err) {
458
+ // We don't expect any of the above to throw, but better to be safe.
459
+ return false;
460
+ }
461
+ }
462
+
463
+ objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
464
+ var from;
465
+ var to = toObject(target);
466
+ var symbols;
467
+
468
+ for (var s = 1; s < arguments.length; s++) {
469
+ from = Object(arguments[s]);
470
+
471
+ for (var key in from) {
472
+ if (hasOwnProperty.call(from, key)) {
473
+ to[key] = from[key];
474
+ }
475
+ }
476
+
477
+ if (getOwnPropertySymbols) {
478
+ symbols = getOwnPropertySymbols(from);
479
+ for (var i = 0; i < symbols.length; i++) {
480
+ if (propIsEnumerable.call(from, symbols[i])) {
481
+ to[symbols[i]] = from[symbols[i]];
482
+ }
483
+ }
484
+ }
485
+ }
486
+
487
+ return to;
488
+ };
489
+ return objectAssign;
490
+ }
491
+
492
+ /**
493
+ * Copyright (c) 2013-present, Facebook, Inc.
494
+ *
495
+ * This source code is licensed under the MIT license found in the
496
+ * LICENSE file in the root directory of this source tree.
497
+ */
498
+
499
+ var ReactPropTypesSecret_1;
500
+ var hasRequiredReactPropTypesSecret;
501
+
502
+ function requireReactPropTypesSecret () {
503
+ if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
504
+ hasRequiredReactPropTypesSecret = 1;
505
+
506
+ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
507
+
508
+ ReactPropTypesSecret_1 = ReactPropTypesSecret;
509
+ return ReactPropTypesSecret_1;
510
+ }
511
+
512
+ var has;
513
+ var hasRequiredHas;
514
+
515
+ function requireHas () {
516
+ if (hasRequiredHas) return has;
517
+ hasRequiredHas = 1;
518
+ has = Function.call.bind(Object.prototype.hasOwnProperty);
519
+ return has;
520
+ }
521
+
522
+ /**
523
+ * Copyright (c) 2013-present, Facebook, Inc.
524
+ *
525
+ * This source code is licensed under the MIT license found in the
526
+ * LICENSE file in the root directory of this source tree.
527
+ */
528
+
529
+ var checkPropTypes_1;
530
+ var hasRequiredCheckPropTypes;
531
+
532
+ function requireCheckPropTypes () {
533
+ if (hasRequiredCheckPropTypes) return checkPropTypes_1;
534
+ hasRequiredCheckPropTypes = 1;
535
+
536
+ var printWarning = function() {};
537
+
538
+ if (process.env.NODE_ENV !== 'production') {
539
+ var ReactPropTypesSecret = requireReactPropTypesSecret();
540
+ var loggedTypeFailures = {};
541
+ var has = requireHas();
542
+
543
+ printWarning = function(text) {
544
+ var message = 'Warning: ' + text;
545
+ if (typeof console !== 'undefined') {
546
+ console.error(message);
547
+ }
548
+ try {
549
+ // --- Welcome to debugging React ---
550
+ // This error was thrown as a convenience so that you can use this stack
551
+ // to find the callsite that caused this warning to fire.
552
+ throw new Error(message);
553
+ } catch (x) { /**/ }
554
+ };
555
+ }
556
+
557
+ /**
558
+ * Assert that the values match with the type specs.
559
+ * Error messages are memorized and will only be shown once.
560
+ *
561
+ * @param {object} typeSpecs Map of name to a ReactPropType
562
+ * @param {object} values Runtime values that need to be type-checked
563
+ * @param {string} location e.g. "prop", "context", "child context"
564
+ * @param {string} componentName Name of the component for error messages.
565
+ * @param {?Function} getStack Returns the component stack.
566
+ * @private
567
+ */
568
+ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
569
+ if (process.env.NODE_ENV !== 'production') {
570
+ for (var typeSpecName in typeSpecs) {
571
+ if (has(typeSpecs, typeSpecName)) {
572
+ var error;
573
+ // Prop type validation may throw. In case they do, we don't want to
574
+ // fail the render phase where it didn't fail before. So we log it.
575
+ // After these have been cleaned up, we'll let them throw.
576
+ try {
577
+ // This is intentionally an invariant that gets caught. It's the same
578
+ // behavior as without this statement except with a better message.
579
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
580
+ var err = Error(
581
+ (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
582
+ 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' +
583
+ 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.'
584
+ );
585
+ err.name = 'Invariant Violation';
586
+ throw err;
587
+ }
588
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
589
+ } catch (ex) {
590
+ error = ex;
591
+ }
592
+ if (error && !(error instanceof Error)) {
593
+ printWarning(
594
+ (componentName || 'React class') + ': type specification of ' +
595
+ location + ' `' + typeSpecName + '` is invalid; the type checker ' +
596
+ 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
597
+ 'You may have forgotten to pass an argument to the type checker ' +
598
+ 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
599
+ 'shape all require an argument).'
600
+ );
601
+ }
602
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
603
+ // Only monitor this failure once because there tends to be a lot of the
604
+ // same error.
605
+ loggedTypeFailures[error.message] = true;
606
+
607
+ var stack = getStack ? getStack() : '';
608
+
609
+ printWarning(
610
+ 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
611
+ );
612
+ }
613
+ }
614
+ }
615
+ }
616
+ }
617
+
618
+ /**
619
+ * Resets warning cache when testing.
620
+ *
621
+ * @private
622
+ */
623
+ checkPropTypes.resetWarningCache = function() {
624
+ if (process.env.NODE_ENV !== 'production') {
625
+ loggedTypeFailures = {};
626
+ }
627
+ };
628
+
629
+ checkPropTypes_1 = checkPropTypes;
630
+ return checkPropTypes_1;
631
+ }
632
+
633
+ /**
634
+ * Copyright (c) 2013-present, Facebook, Inc.
635
+ *
636
+ * This source code is licensed under the MIT license found in the
637
+ * LICENSE file in the root directory of this source tree.
638
+ */
639
+
640
+ var factoryWithTypeCheckers;
641
+ var hasRequiredFactoryWithTypeCheckers;
642
+
643
+ function requireFactoryWithTypeCheckers () {
644
+ if (hasRequiredFactoryWithTypeCheckers) return factoryWithTypeCheckers;
645
+ hasRequiredFactoryWithTypeCheckers = 1;
646
+
647
+ var ReactIs = requireReactIs();
648
+ var assign = requireObjectAssign();
649
+
650
+ var ReactPropTypesSecret = requireReactPropTypesSecret();
651
+ var has = requireHas();
652
+ var checkPropTypes = requireCheckPropTypes();
653
+
654
+ var printWarning = function() {};
655
+
656
+ if (process.env.NODE_ENV !== 'production') {
657
+ printWarning = function(text) {
658
+ var message = 'Warning: ' + text;
659
+ if (typeof console !== 'undefined') {
660
+ console.error(message);
661
+ }
662
+ try {
663
+ // --- Welcome to debugging React ---
664
+ // This error was thrown as a convenience so that you can use this stack
665
+ // to find the callsite that caused this warning to fire.
666
+ throw new Error(message);
667
+ } catch (x) {}
668
+ };
669
+ }
670
+
671
+ function emptyFunctionThatReturnsNull() {
672
+ return null;
673
+ }
674
+
675
+ factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
676
+ /* global Symbol */
677
+ var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
678
+ var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
679
+
680
+ /**
681
+ * Returns the iterator method function contained on the iterable object.
682
+ *
683
+ * Be sure to invoke the function with the iterable as context:
684
+ *
685
+ * var iteratorFn = getIteratorFn(myIterable);
686
+ * if (iteratorFn) {
687
+ * var iterator = iteratorFn.call(myIterable);
688
+ * ...
689
+ * }
690
+ *
691
+ * @param {?object} maybeIterable
692
+ * @return {?function}
693
+ */
694
+ function getIteratorFn(maybeIterable) {
695
+ var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
696
+ if (typeof iteratorFn === 'function') {
697
+ return iteratorFn;
698
+ }
699
+ }
700
+
701
+ /**
702
+ * Collection of methods that allow declaration and validation of props that are
703
+ * supplied to React components. Example usage:
704
+ *
705
+ * var Props = require('ReactPropTypes');
706
+ * var MyArticle = React.createClass({
707
+ * propTypes: {
708
+ * // An optional string prop named "description".
709
+ * description: Props.string,
710
+ *
711
+ * // A required enum prop named "category".
712
+ * category: Props.oneOf(['News','Photos']).isRequired,
713
+ *
714
+ * // A prop named "dialog" that requires an instance of Dialog.
715
+ * dialog: Props.instanceOf(Dialog).isRequired
716
+ * },
717
+ * render: function() { ... }
718
+ * });
719
+ *
720
+ * A more formal specification of how these methods are used:
721
+ *
722
+ * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
723
+ * decl := ReactPropTypes.{type}(.isRequired)?
724
+ *
725
+ * Each and every declaration produces a function with the same signature. This
726
+ * allows the creation of custom validation functions. For example:
727
+ *
728
+ * var MyLink = React.createClass({
729
+ * propTypes: {
730
+ * // An optional string or URI prop named "href".
731
+ * href: function(props, propName, componentName) {
732
+ * var propValue = props[propName];
733
+ * if (propValue != null && typeof propValue !== 'string' &&
734
+ * !(propValue instanceof URI)) {
735
+ * return new Error(
736
+ * 'Expected a string or an URI for ' + propName + ' in ' +
737
+ * componentName
738
+ * );
739
+ * }
740
+ * }
741
+ * },
742
+ * render: function() {...}
743
+ * });
744
+ *
745
+ * @internal
746
+ */
747
+
748
+ var ANONYMOUS = '<<anonymous>>';
749
+
750
+ // Important!
751
+ // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
752
+ var ReactPropTypes = {
753
+ array: createPrimitiveTypeChecker('array'),
754
+ bigint: createPrimitiveTypeChecker('bigint'),
755
+ bool: createPrimitiveTypeChecker('boolean'),
756
+ func: createPrimitiveTypeChecker('function'),
757
+ number: createPrimitiveTypeChecker('number'),
758
+ object: createPrimitiveTypeChecker('object'),
759
+ string: createPrimitiveTypeChecker('string'),
760
+ symbol: createPrimitiveTypeChecker('symbol'),
761
+
762
+ any: createAnyTypeChecker(),
763
+ arrayOf: createArrayOfTypeChecker,
764
+ element: createElementTypeChecker(),
765
+ elementType: createElementTypeTypeChecker(),
766
+ instanceOf: createInstanceTypeChecker,
767
+ node: createNodeChecker(),
768
+ objectOf: createObjectOfTypeChecker,
769
+ oneOf: createEnumTypeChecker,
770
+ oneOfType: createUnionTypeChecker,
771
+ shape: createShapeTypeChecker,
772
+ exact: createStrictShapeTypeChecker,
773
+ };
774
+
775
+ /**
776
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
777
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
778
+ */
779
+ /*eslint-disable no-self-compare*/
780
+ function is(x, y) {
781
+ // SameValue algorithm
782
+ if (x === y) {
783
+ // Steps 1-5, 7-10
784
+ // Steps 6.b-6.e: +0 != -0
785
+ return x !== 0 || 1 / x === 1 / y;
786
+ } else {
787
+ // Step 6.a: NaN == NaN
788
+ return x !== x && y !== y;
789
+ }
790
+ }
791
+ /*eslint-enable no-self-compare*/
792
+
793
+ /**
794
+ * We use an Error-like object for backward compatibility as people may call
795
+ * PropTypes directly and inspect their output. However, we don't use real
796
+ * Errors anymore. We don't inspect their stack anyway, and creating them
797
+ * is prohibitively expensive if they are created too often, such as what
798
+ * happens in oneOfType() for any type before the one that matched.
799
+ */
800
+ function PropTypeError(message, data) {
801
+ this.message = message;
802
+ this.data = data && typeof data === 'object' ? data: {};
803
+ this.stack = '';
804
+ }
805
+ // Make `instanceof Error` still work for returned errors.
806
+ PropTypeError.prototype = Error.prototype;
807
+
808
+ function createChainableTypeChecker(validate) {
809
+ if (process.env.NODE_ENV !== 'production') {
810
+ var manualPropTypeCallCache = {};
811
+ var manualPropTypeWarningCount = 0;
812
+ }
813
+ function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
814
+ componentName = componentName || ANONYMOUS;
815
+ propFullName = propFullName || propName;
816
+
817
+ if (secret !== ReactPropTypesSecret) {
818
+ if (throwOnDirectAccess) {
819
+ // New behavior only for users of `prop-types` package
820
+ var err = new Error(
821
+ 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
822
+ 'Use `PropTypes.checkPropTypes()` to call them. ' +
823
+ 'Read more at http://fb.me/use-check-prop-types'
824
+ );
825
+ err.name = 'Invariant Violation';
826
+ throw err;
827
+ } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
828
+ // Old behavior for people using React.PropTypes
829
+ var cacheKey = componentName + ':' + propName;
830
+ if (
831
+ !manualPropTypeCallCache[cacheKey] &&
832
+ // Avoid spamming the console because they are often not actionable except for lib authors
833
+ manualPropTypeWarningCount < 3
834
+ ) {
835
+ printWarning(
836
+ 'You are manually calling a React.PropTypes validation ' +
837
+ 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
838
+ 'and will throw in the standalone `prop-types` package. ' +
839
+ 'You may be seeing this warning due to a third-party PropTypes ' +
840
+ 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
841
+ );
842
+ manualPropTypeCallCache[cacheKey] = true;
843
+ manualPropTypeWarningCount++;
844
+ }
845
+ }
846
+ }
847
+ if (props[propName] == null) {
848
+ if (isRequired) {
849
+ if (props[propName] === null) {
850
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
851
+ }
852
+ return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
853
+ }
854
+ return null;
855
+ } else {
856
+ return validate(props, propName, componentName, location, propFullName);
857
+ }
858
+ }
859
+
860
+ var chainedCheckType = checkType.bind(null, false);
861
+ chainedCheckType.isRequired = checkType.bind(null, true);
862
+
863
+ return chainedCheckType;
864
+ }
865
+
866
+ function createPrimitiveTypeChecker(expectedType) {
867
+ function validate(props, propName, componentName, location, propFullName, secret) {
868
+ var propValue = props[propName];
869
+ var propType = getPropType(propValue);
870
+ if (propType !== expectedType) {
871
+ // `propValue` being instance of, say, date/regexp, pass the 'object'
872
+ // check, but we can offer a more precise error message here rather than
873
+ // 'of type `object`'.
874
+ var preciseType = getPreciseType(propValue);
875
+
876
+ return new PropTypeError(
877
+ 'Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'),
878
+ {expectedType: expectedType}
879
+ );
880
+ }
881
+ return null;
882
+ }
883
+ return createChainableTypeChecker(validate);
884
+ }
885
+
886
+ function createAnyTypeChecker() {
887
+ return createChainableTypeChecker(emptyFunctionThatReturnsNull);
888
+ }
889
+
890
+ function createArrayOfTypeChecker(typeChecker) {
891
+ function validate(props, propName, componentName, location, propFullName) {
892
+ if (typeof typeChecker !== 'function') {
893
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
894
+ }
895
+ var propValue = props[propName];
896
+ if (!Array.isArray(propValue)) {
897
+ var propType = getPropType(propValue);
898
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
899
+ }
900
+ for (var i = 0; i < propValue.length; i++) {
901
+ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
902
+ if (error instanceof Error) {
903
+ return error;
904
+ }
905
+ }
906
+ return null;
907
+ }
908
+ return createChainableTypeChecker(validate);
909
+ }
910
+
911
+ function createElementTypeChecker() {
912
+ function validate(props, propName, componentName, location, propFullName) {
913
+ var propValue = props[propName];
914
+ if (!isValidElement(propValue)) {
915
+ var propType = getPropType(propValue);
916
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
917
+ }
918
+ return null;
919
+ }
920
+ return createChainableTypeChecker(validate);
921
+ }
922
+
923
+ function createElementTypeTypeChecker() {
924
+ function validate(props, propName, componentName, location, propFullName) {
925
+ var propValue = props[propName];
926
+ if (!ReactIs.isValidElementType(propValue)) {
927
+ var propType = getPropType(propValue);
928
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
929
+ }
930
+ return null;
931
+ }
932
+ return createChainableTypeChecker(validate);
933
+ }
934
+
935
+ function createInstanceTypeChecker(expectedClass) {
936
+ function validate(props, propName, componentName, location, propFullName) {
937
+ if (!(props[propName] instanceof expectedClass)) {
938
+ var expectedClassName = expectedClass.name || ANONYMOUS;
939
+ var actualClassName = getClassName(props[propName]);
940
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
941
+ }
942
+ return null;
943
+ }
944
+ return createChainableTypeChecker(validate);
945
+ }
946
+
947
+ function createEnumTypeChecker(expectedValues) {
948
+ if (!Array.isArray(expectedValues)) {
949
+ if (process.env.NODE_ENV !== 'production') {
950
+ if (arguments.length > 1) {
951
+ printWarning(
952
+ 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
953
+ 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
954
+ );
955
+ } else {
956
+ printWarning('Invalid argument supplied to oneOf, expected an array.');
957
+ }
958
+ }
959
+ return emptyFunctionThatReturnsNull;
960
+ }
961
+
962
+ function validate(props, propName, componentName, location, propFullName) {
963
+ var propValue = props[propName];
964
+ for (var i = 0; i < expectedValues.length; i++) {
965
+ if (is(propValue, expectedValues[i])) {
966
+ return null;
967
+ }
968
+ }
969
+
970
+ var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
971
+ var type = getPreciseType(value);
972
+ if (type === 'symbol') {
973
+ return String(value);
974
+ }
975
+ return value;
976
+ });
977
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
978
+ }
979
+ return createChainableTypeChecker(validate);
980
+ }
981
+
982
+ function createObjectOfTypeChecker(typeChecker) {
983
+ function validate(props, propName, componentName, location, propFullName) {
984
+ if (typeof typeChecker !== 'function') {
985
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
986
+ }
987
+ var propValue = props[propName];
988
+ var propType = getPropType(propValue);
989
+ if (propType !== 'object') {
990
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
991
+ }
992
+ for (var key in propValue) {
993
+ if (has(propValue, key)) {
994
+ var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
995
+ if (error instanceof Error) {
996
+ return error;
997
+ }
998
+ }
999
+ }
1000
+ return null;
1001
+ }
1002
+ return createChainableTypeChecker(validate);
1003
+ }
1004
+
1005
+ function createUnionTypeChecker(arrayOfTypeCheckers) {
1006
+ if (!Array.isArray(arrayOfTypeCheckers)) {
1007
+ process.env.NODE_ENV !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
1008
+ return emptyFunctionThatReturnsNull;
1009
+ }
1010
+
1011
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1012
+ var checker = arrayOfTypeCheckers[i];
1013
+ if (typeof checker !== 'function') {
1014
+ printWarning(
1015
+ 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
1016
+ 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
1017
+ );
1018
+ return emptyFunctionThatReturnsNull;
1019
+ }
1020
+ }
1021
+
1022
+ function validate(props, propName, componentName, location, propFullName) {
1023
+ var expectedTypes = [];
1024
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1025
+ var checker = arrayOfTypeCheckers[i];
1026
+ var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
1027
+ if (checkerResult == null) {
1028
+ return null;
1029
+ }
1030
+ if (checkerResult.data && has(checkerResult.data, 'expectedType')) {
1031
+ expectedTypes.push(checkerResult.data.expectedType);
1032
+ }
1033
+ }
1034
+ var expectedTypesMessage = (expectedTypes.length > 0) ? ', expected one of type [' + expectedTypes.join(', ') + ']': '';
1035
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`' + expectedTypesMessage + '.'));
1036
+ }
1037
+ return createChainableTypeChecker(validate);
1038
+ }
1039
+
1040
+ function createNodeChecker() {
1041
+ function validate(props, propName, componentName, location, propFullName) {
1042
+ if (!isNode(props[propName])) {
1043
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
1044
+ }
1045
+ return null;
1046
+ }
1047
+ return createChainableTypeChecker(validate);
1048
+ }
1049
+
1050
+ function invalidValidatorError(componentName, location, propFullName, key, type) {
1051
+ return new PropTypeError(
1052
+ (componentName || 'React class') + ': ' + location + ' type `' + propFullName + '.' + key + '` is invalid; ' +
1053
+ 'it must be a function, usually from the `prop-types` package, but received `' + type + '`.'
1054
+ );
1055
+ }
1056
+
1057
+ function createShapeTypeChecker(shapeTypes) {
1058
+ function validate(props, propName, componentName, location, propFullName) {
1059
+ var propValue = props[propName];
1060
+ var propType = getPropType(propValue);
1061
+ if (propType !== 'object') {
1062
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1063
+ }
1064
+ for (var key in shapeTypes) {
1065
+ var checker = shapeTypes[key];
1066
+ if (typeof checker !== 'function') {
1067
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1068
+ }
1069
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1070
+ if (error) {
1071
+ return error;
1072
+ }
1073
+ }
1074
+ return null;
1075
+ }
1076
+ return createChainableTypeChecker(validate);
1077
+ }
1078
+
1079
+ function createStrictShapeTypeChecker(shapeTypes) {
1080
+ function validate(props, propName, componentName, location, propFullName) {
1081
+ var propValue = props[propName];
1082
+ var propType = getPropType(propValue);
1083
+ if (propType !== 'object') {
1084
+ return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1085
+ }
1086
+ // We need to check all keys in case some are required but missing from props.
1087
+ var allKeys = assign({}, props[propName], shapeTypes);
1088
+ for (var key in allKeys) {
1089
+ var checker = shapeTypes[key];
1090
+ if (has(shapeTypes, key) && typeof checker !== 'function') {
1091
+ return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
1092
+ }
1093
+ if (!checker) {
1094
+ return new PropTypeError(
1095
+ 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
1096
+ '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
1097
+ '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
1098
+ );
1099
+ }
1100
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1101
+ if (error) {
1102
+ return error;
1103
+ }
1104
+ }
1105
+ return null;
1106
+ }
1107
+
1108
+ return createChainableTypeChecker(validate);
1109
+ }
1110
+
1111
+ function isNode(propValue) {
1112
+ switch (typeof propValue) {
1113
+ case 'number':
1114
+ case 'string':
1115
+ case 'undefined':
1116
+ return true;
1117
+ case 'boolean':
1118
+ return !propValue;
1119
+ case 'object':
1120
+ if (Array.isArray(propValue)) {
1121
+ return propValue.every(isNode);
1122
+ }
1123
+ if (propValue === null || isValidElement(propValue)) {
1124
+ return true;
1125
+ }
1126
+
1127
+ var iteratorFn = getIteratorFn(propValue);
1128
+ if (iteratorFn) {
1129
+ var iterator = iteratorFn.call(propValue);
1130
+ var step;
1131
+ if (iteratorFn !== propValue.entries) {
1132
+ while (!(step = iterator.next()).done) {
1133
+ if (!isNode(step.value)) {
1134
+ return false;
1135
+ }
1136
+ }
1137
+ } else {
1138
+ // Iterator will provide entry [k,v] tuples rather than values.
1139
+ while (!(step = iterator.next()).done) {
1140
+ var entry = step.value;
1141
+ if (entry) {
1142
+ if (!isNode(entry[1])) {
1143
+ return false;
1144
+ }
1145
+ }
1146
+ }
1147
+ }
1148
+ } else {
1149
+ return false;
1150
+ }
1151
+
1152
+ return true;
1153
+ default:
1154
+ return false;
1155
+ }
1156
+ }
1157
+
1158
+ function isSymbol(propType, propValue) {
1159
+ // Native Symbol.
1160
+ if (propType === 'symbol') {
1161
+ return true;
1162
+ }
1163
+
1164
+ // falsy value can't be a Symbol
1165
+ if (!propValue) {
1166
+ return false;
1167
+ }
1168
+
1169
+ // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
1170
+ if (propValue['@@toStringTag'] === 'Symbol') {
1171
+ return true;
1172
+ }
1173
+
1174
+ // Fallback for non-spec compliant Symbols which are polyfilled.
1175
+ if (typeof Symbol === 'function' && propValue instanceof Symbol) {
1176
+ return true;
1177
+ }
1178
+
1179
+ return false;
1180
+ }
1181
+
1182
+ // Equivalent of `typeof` but with special handling for array and regexp.
1183
+ function getPropType(propValue) {
1184
+ var propType = typeof propValue;
1185
+ if (Array.isArray(propValue)) {
1186
+ return 'array';
1187
+ }
1188
+ if (propValue instanceof RegExp) {
1189
+ // Old webkits (at least until Android 4.0) return 'function' rather than
1190
+ // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
1191
+ // passes PropTypes.object.
1192
+ return 'object';
1193
+ }
1194
+ if (isSymbol(propType, propValue)) {
1195
+ return 'symbol';
1196
+ }
1197
+ return propType;
1198
+ }
1199
+
1200
+ // This handles more types than `getPropType`. Only used for error messages.
1201
+ // See `createPrimitiveTypeChecker`.
1202
+ function getPreciseType(propValue) {
1203
+ if (typeof propValue === 'undefined' || propValue === null) {
1204
+ return '' + propValue;
1205
+ }
1206
+ var propType = getPropType(propValue);
1207
+ if (propType === 'object') {
1208
+ if (propValue instanceof Date) {
1209
+ return 'date';
1210
+ } else if (propValue instanceof RegExp) {
1211
+ return 'regexp';
1212
+ }
1213
+ }
1214
+ return propType;
1215
+ }
1216
+
1217
+ // Returns a string that is postfixed to a warning about an invalid type.
1218
+ // For example, "undefined" or "of type array"
1219
+ function getPostfixForTypeWarning(value) {
1220
+ var type = getPreciseType(value);
1221
+ switch (type) {
1222
+ case 'array':
1223
+ case 'object':
1224
+ return 'an ' + type;
1225
+ case 'boolean':
1226
+ case 'date':
1227
+ case 'regexp':
1228
+ return 'a ' + type;
1229
+ default:
1230
+ return type;
1231
+ }
1232
+ }
1233
+
1234
+ // Returns class name of the object, if any.
1235
+ function getClassName(propValue) {
1236
+ if (!propValue.constructor || !propValue.constructor.name) {
1237
+ return ANONYMOUS;
1238
+ }
1239
+ return propValue.constructor.name;
1240
+ }
1241
+
1242
+ ReactPropTypes.checkPropTypes = checkPropTypes;
1243
+ ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
1244
+ ReactPropTypes.PropTypes = ReactPropTypes;
1245
+
1246
+ return ReactPropTypes;
1247
+ };
1248
+ return factoryWithTypeCheckers;
1249
+ }
1250
+
1251
+ /**
1252
+ * Copyright (c) 2013-present, Facebook, Inc.
1253
+ *
1254
+ * This source code is licensed under the MIT license found in the
1255
+ * LICENSE file in the root directory of this source tree.
1256
+ */
1257
+
1258
+ var factoryWithThrowingShims;
1259
+ var hasRequiredFactoryWithThrowingShims;
1260
+
1261
+ function requireFactoryWithThrowingShims () {
1262
+ if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims;
1263
+ hasRequiredFactoryWithThrowingShims = 1;
1264
+
1265
+ var ReactPropTypesSecret = requireReactPropTypesSecret();
1266
+
1267
+ function emptyFunction() {}
1268
+ function emptyFunctionWithReset() {}
1269
+ emptyFunctionWithReset.resetWarningCache = emptyFunction;
1270
+
1271
+ factoryWithThrowingShims = function() {
1272
+ function shim(props, propName, componentName, location, propFullName, secret) {
1273
+ if (secret === ReactPropTypesSecret) {
1274
+ // It is still safe when called from React.
1275
+ return;
1276
+ }
1277
+ var err = new Error(
1278
+ 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
1279
+ 'Use PropTypes.checkPropTypes() to call them. ' +
1280
+ 'Read more at http://fb.me/use-check-prop-types'
1281
+ );
1282
+ err.name = 'Invariant Violation';
1283
+ throw err;
1284
+ } shim.isRequired = shim;
1285
+ function getShim() {
1286
+ return shim;
1287
+ } // Important!
1288
+ // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
1289
+ var ReactPropTypes = {
1290
+ array: shim,
1291
+ bigint: shim,
1292
+ bool: shim,
1293
+ func: shim,
1294
+ number: shim,
1295
+ object: shim,
1296
+ string: shim,
1297
+ symbol: shim,
1298
+
1299
+ any: shim,
1300
+ arrayOf: getShim,
1301
+ element: shim,
1302
+ elementType: shim,
1303
+ instanceOf: getShim,
1304
+ node: shim,
1305
+ objectOf: getShim,
1306
+ oneOf: getShim,
1307
+ oneOfType: getShim,
1308
+ shape: getShim,
1309
+ exact: getShim,
1310
+
1311
+ checkPropTypes: emptyFunctionWithReset,
1312
+ resetWarningCache: emptyFunction
1313
+ };
1314
+
1315
+ ReactPropTypes.PropTypes = ReactPropTypes;
1316
+
1317
+ return ReactPropTypes;
1318
+ };
1319
+ return factoryWithThrowingShims;
1320
+ }
1321
+
1322
+ /**
1323
+ * Copyright (c) 2013-present, Facebook, Inc.
1324
+ *
1325
+ * This source code is licensed under the MIT license found in the
1326
+ * LICENSE file in the root directory of this source tree.
1327
+ */
1328
+
1329
+ if (process.env.NODE_ENV !== 'production') {
1330
+ var ReactIs = requireReactIs();
1331
+
1332
+ // By explicitly using `prop-types` you are opting into new development behavior.
1333
+ // http://fb.me/prop-types-in-prod
1334
+ var throwOnDirectAccess = true;
1335
+ propTypes.exports = requireFactoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
1336
+ } else {
1337
+ // By explicitly using `prop-types` you are opting into new production behavior.
1338
+ // http://fb.me/prop-types-in-prod
1339
+ propTypes.exports = requireFactoryWithThrowingShims()();
1340
+ }
1341
+
1342
+ const Spinner = /*#__PURE__*/React__namespace.forwardRef(({
1343
+ bsPrefix,
1344
+ variant,
1345
+ animation,
1346
+ size,
1347
+ // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
1348
+ as: Component = 'div',
1349
+ className,
1350
+ ...props
1351
+ }, ref) => {
1352
+ bsPrefix = useBootstrapPrefix(bsPrefix, 'spinner');
1353
+ const bsSpinnerPrefix = `${bsPrefix}-${animation}`;
1354
+ return /*#__PURE__*/jsxRuntime.jsx(Component, {
1355
+ ref: ref,
1356
+ ...props,
1357
+ className: classNames(className, bsSpinnerPrefix, size && `${bsSpinnerPrefix}-${size}`, variant && `text-${variant}`)
1358
+ });
1359
+ });
1360
+ Spinner.displayName = 'Spinner';
1361
+ var Spinner$1 = Spinner;
1362
+
1363
+ var _excluded$3 = ["color", "size", "title"];
1364
+
1365
+ function _extends$3() { _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
1366
+
1367
+ function _objectWithoutProperties$3(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$3(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
1368
+
1369
+ function _objectWithoutPropertiesLoose$3(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
1370
+ var CaretDownFill = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1371
+ var color = _ref.color,
1372
+ size = _ref.size,
1373
+ title = _ref.title,
1374
+ rest = _objectWithoutProperties$3(_ref, _excluded$3);
1375
+
1376
+ return /*#__PURE__*/React.createElement("svg", _extends$3({
1377
+ ref: ref,
1378
+ xmlns: "http://www.w3.org/2000/svg",
1379
+ viewBox: "0 0 16 16",
1380
+ width: size,
1381
+ height: size,
1382
+ fill: color
1383
+ }, rest), title ? /*#__PURE__*/React.createElement("title", null, title) : null, /*#__PURE__*/React.createElement("path", {
1384
+ d: "M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"
1385
+ }));
1386
+ });
1387
+ CaretDownFill.propTypes = {
1388
+ color: propTypes.exports.string,
1389
+ size: propTypes.exports.oneOfType([propTypes.exports.string, propTypes.exports.number]),
1390
+ title: propTypes.exports.string
1391
+ };
1392
+ CaretDownFill.defaultProps = {
1393
+ color: 'currentColor',
1394
+ size: '1em',
1395
+ title: null
1396
+ };
1397
+ var CaretDownFill$1 = CaretDownFill;
1398
+
1399
+ var _excluded$2 = ["color", "size", "title"];
1400
+
1401
+ function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
1402
+
1403
+ function _objectWithoutProperties$2(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$2(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
1404
+
1405
+ function _objectWithoutPropertiesLoose$2(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
1406
+ var CaretRightFill = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1407
+ var color = _ref.color,
1408
+ size = _ref.size,
1409
+ title = _ref.title,
1410
+ rest = _objectWithoutProperties$2(_ref, _excluded$2);
1411
+
1412
+ return /*#__PURE__*/React.createElement("svg", _extends$2({
1413
+ ref: ref,
1414
+ xmlns: "http://www.w3.org/2000/svg",
1415
+ viewBox: "0 0 16 16",
1416
+ width: size,
1417
+ height: size,
1418
+ fill: color
1419
+ }, rest), title ? /*#__PURE__*/React.createElement("title", null, title) : null, /*#__PURE__*/React.createElement("path", {
1420
+ d: "m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z"
1421
+ }));
1422
+ });
1423
+ CaretRightFill.propTypes = {
1424
+ color: propTypes.exports.string,
1425
+ size: propTypes.exports.oneOfType([propTypes.exports.string, propTypes.exports.number]),
1426
+ title: propTypes.exports.string
1427
+ };
1428
+ CaretRightFill.defaultProps = {
1429
+ color: 'currentColor',
1430
+ size: '1em',
1431
+ title: null
1432
+ };
1433
+ var CaretRightFill$1 = CaretRightFill;
1434
+
1435
+ var _excluded$1 = ["color", "size", "title"];
1436
+
1437
+ function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
1438
+
1439
+ function _objectWithoutProperties$1(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$1(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
1440
+
1441
+ function _objectWithoutPropertiesLoose$1(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
1442
+ var CaretRight = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1443
+ var color = _ref.color,
1444
+ size = _ref.size,
1445
+ title = _ref.title,
1446
+ rest = _objectWithoutProperties$1(_ref, _excluded$1);
1447
+
1448
+ return /*#__PURE__*/React.createElement("svg", _extends$1({
1449
+ ref: ref,
1450
+ xmlns: "http://www.w3.org/2000/svg",
1451
+ viewBox: "0 0 16 16",
1452
+ width: size,
1453
+ height: size,
1454
+ fill: color
1455
+ }, rest), title ? /*#__PURE__*/React.createElement("title", null, title) : null, /*#__PURE__*/React.createElement("path", {
1456
+ d: "M6 12.796V3.204L11.481 8 6 12.796zm.659.753 5.48-4.796a1 1 0 0 0 0-1.506L6.66 2.451C6.011 1.885 5 2.345 5 3.204v9.592a1 1 0 0 0 1.659.753z"
1457
+ }));
1458
+ });
1459
+ CaretRight.propTypes = {
1460
+ color: propTypes.exports.string,
1461
+ size: propTypes.exports.oneOfType([propTypes.exports.string, propTypes.exports.number]),
1462
+ title: propTypes.exports.string
1463
+ };
1464
+ CaretRight.defaultProps = {
1465
+ color: 'currentColor',
1466
+ size: '1em',
1467
+ title: null
1468
+ };
1469
+ var CaretRight$1 = CaretRight;
1470
+
1471
+ var _excluded = ["color", "size", "title"];
1472
+
1473
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1474
+
1475
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
1476
+
1477
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
1478
+ var ExclamationCircleFill = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
1479
+ var color = _ref.color,
1480
+ size = _ref.size,
1481
+ title = _ref.title,
1482
+ rest = _objectWithoutProperties(_ref, _excluded);
1483
+
1484
+ return /*#__PURE__*/React.createElement("svg", _extends({
1485
+ ref: ref,
1486
+ xmlns: "http://www.w3.org/2000/svg",
1487
+ viewBox: "0 0 16 16",
1488
+ width: size,
1489
+ height: size,
1490
+ fill: color
1491
+ }, rest), title ? /*#__PURE__*/React.createElement("title", null, title) : null, /*#__PURE__*/React.createElement("path", {
1492
+ d: "M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8 4a.905.905 0 0 0-.9.995l.35 3.507a.552.552 0 0 0 1.1 0l.35-3.507A.905.905 0 0 0 8 4zm.002 6a1 1 0 1 0 0 2 1 1 0 0 0 0-2z"
1493
+ }));
1494
+ });
1495
+ ExclamationCircleFill.propTypes = {
1496
+ color: propTypes.exports.string,
1497
+ size: propTypes.exports.oneOfType([propTypes.exports.string, propTypes.exports.number]),
1498
+ title: propTypes.exports.string
1499
+ };
1500
+ ExclamationCircleFill.defaultProps = {
1501
+ color: 'currentColor',
1502
+ size: '1em',
1503
+ title: null
1504
+ };
1505
+ var ExclamationCircleFill$1 = ExclamationCircleFill;
1506
+
1507
+ const TreeOfNodesContext = React.createContext({
1508
+ nodeList: [],
1509
+ });
1510
+ const TreeOfNodes = ({ nodeList, roots,
1511
+ // canAddRoot = false,
1512
+ canRemoveRoot = false, canRenameRoot = false, canAddChildren = false, canRemoveChildren = false, canRenameChildren = false, selectedId, handleSelect = () => {
1513
+ return;
1514
+ }, onAdd, onRename, onRemove, }) => {
1515
+ const [expandedNodes, setExpandedNodes] = React.useState([]);
1516
+ // Change expansion and update context
1517
+ const changeExpand = React.useCallback((eKey, force) => {
1518
+ const newExpandedNodes = [...expandedNodes];
1519
+ const ix = newExpandedNodes.findIndex((nKey) => nKey === eKey);
1520
+ if ((ix === -1 && force === undefined) || force === true)
1521
+ newExpandedNodes.push(eKey);
1522
+ else
1523
+ newExpandedNodes.splice(ix, 1);
1524
+ setExpandedNodes(newExpandedNodes);
1525
+ }, [expandedNodes]);
1526
+ return (jsxRuntime.jsx(ContextMenuProvider, { children: jsxRuntime.jsx(TreeOfNodesContext.Provider, { value: {
1527
+ nodeList,
1528
+ selectedId,
1529
+ handleSelect,
1530
+ expandedNodes,
1531
+ handleExpandClick: (r, f) => changeExpand(r, f),
1532
+ onAddChild: onAdd,
1533
+ onRename,
1534
+ onRemove,
1535
+ }, children: roots.map((r) => (jsxRuntime.jsx(TreeNode, { id: r, canRemove: canRemoveRoot, canAddChildren: canAddChildren, canRename: canRenameRoot, canRemoveChildren: canRemoveChildren, canRenameChildren: canRenameChildren }, r))) }) }));
1536
+ };
1537
+
1538
+ const WordEntry = React.forwardRef(({ id, value, editing, saving, setValue, sendEscape, style }, ref) => {
1539
+ const [currentStyle, setCurrentStyle] = React.useState({
1540
+ display: 'inline-block',
1541
+ });
1542
+ WordEntry.displayName = 'WordEntry';
1543
+ const [currentValue, setCurrentValue] = React.useState(value ?? '');
1544
+ React.useEffect(() => {
1545
+ setCurrentValue(value ?? '');
1546
+ }, [value]);
1547
+ const returnData = React.useCallback(() => {
1548
+ if (typeof setValue !== 'function')
1549
+ return;
1550
+ setValue(currentValue);
1551
+ }, [currentValue, setValue]);
1552
+ const keyPress = React.useCallback((e) => {
1553
+ if (e.code === 'Escape') {
1554
+ setCurrentValue(value ?? '');
1555
+ if (typeof sendEscape === 'function')
1556
+ sendEscape();
1557
+ }
1558
+ else if (e.code === 'Enter') {
1559
+ returnData();
1560
+ }
1561
+ }, [returnData, sendEscape, value]);
1562
+ React.useEffect(() => {
1563
+ setCurrentStyle({
1564
+ padding: '1px',
1565
+ paddingLeft: '3px',
1566
+ paddingRight: '3px',
1567
+ border: '1px',
1568
+ borderRadius: '3px',
1569
+ ...style,
1570
+ display: 'inline-block',
1571
+ });
1572
+ }, [style]);
1573
+ // Simple if not editing
1574
+ if (!editing) {
1575
+ return jsxRuntime.jsx("span", { style: currentStyle, children: value });
1576
+ }
1577
+ return (jsxRuntime.jsxs("div", { style: currentStyle, id: id, children: [saving && (jsxRuntime.jsx(Spinner$1, { id: id ? `${id}-spinner` : undefined, size: 'sm', animation: 'border' })), jsxRuntime.jsx("input", { id: id ? `${id}-input` : undefined, ref: ref, type: 'text', style: {
1578
+ lineHeight: '0.75rem',
1579
+ border: editing ? '1px dotted black' : saving ? '' : '1px dotted grey',
1580
+ margin: !saving && !editing ? '1px' : '',
1581
+ width: 'auto',
1582
+ minWidth: '0',
1583
+ }, value: currentValue, disabled: saving, onChange: (e) => setCurrentValue(e.currentTarget.value), onBlur: returnData, onKeyDownCapture: keyPress })] }));
1584
+ });
1585
+
1586
+ const TreeNode = ({ id, canRemove, canRename, canAddChildren, canRemoveChildren, canRenameChildren, }) => {
1587
+ // Contexts
1588
+ const treeContext = React.useContext(TreeOfNodesContext);
1589
+ const menuContext = React.useContext(MenuContext);
1590
+ // Node information
1591
+ const thisNode = React.useMemo(() => treeContext.nodeList.find((n) => n.id === id), [id, treeContext.nodeList]);
1592
+ const childNodes = React.useMemo(() => treeContext.nodeList.filter((n) => n.parentId === id), [id, treeContext.nodeList]);
1593
+ // Axios state
1594
+ const loading = React.useMemo(() => treeContext.nodeList.findIndex((n) => n.id === id) === -1, [id, treeContext.nodeList]);
1595
+ const [error, setError] = React.useState(false);
1596
+ const [errorText, setErrotText] = React.useState(null);
1597
+ const expanded = React.useMemo(() => {
1598
+ return (treeContext.expandedNodes?.findIndex((e) => e === id) ?? -1) > -1;
1599
+ }, [id, treeContext.expandedNodes]);
1600
+ // // Apply selected borer
1601
+ const currentBorder = React.useMemo(() => {
1602
+ return id === treeContext.selectedId ? '1px solid black' : '';
1603
+ }, [id, treeContext.selectedId]);
1604
+ // New node parameters
1605
+ const newNameRef = React.useRef(null);
1606
+ const [showNewNode, setShowNewNode] = React.useState(false);
1607
+ const [savingNewNode, setSavingNewNode] = React.useState(false);
1608
+ // Rename parameters
1609
+ const currentNameRef = React.useRef(null);
1610
+ const [renaming, setRenaming] = React.useState(false);
1611
+ const [updatingNode, setUpdatingNode] = React.useState(false);
1612
+ // Context functions
1613
+ const handleReturn = React.useCallback((ret) => {
1614
+ if (!ret.success) {
1615
+ setError(true);
1616
+ setErrotText(ret.ErrorText ?? 'An unknown error has occured');
1617
+ }
1618
+ else {
1619
+ setError(false);
1620
+ setErrotText(null);
1621
+ }
1622
+ }, []);
1623
+ const confirmNewNode = React.useCallback(async (label) => {
1624
+ setSavingNewNode(true);
1625
+ if (treeContext.onAddChild) {
1626
+ handleReturn(await treeContext.onAddChild(id, label));
1627
+ }
1628
+ setSavingNewNode(false);
1629
+ setShowNewNode(false);
1630
+ }, [handleReturn, id, treeContext]);
1631
+ const renameNode = React.useCallback(async (newLabel) => {
1632
+ setRenaming(false);
1633
+ setUpdatingNode(true);
1634
+ if (treeContext.onRename) {
1635
+ handleReturn(await treeContext.onRename(id, newLabel));
1636
+ }
1637
+ setUpdatingNode(false);
1638
+ }, [handleReturn, id, treeContext]);
1639
+ const deleteThis = React.useCallback(async () => {
1640
+ setUpdatingNode(true);
1641
+ if (thisNode === undefined)
1642
+ return;
1643
+ if (treeContext.onRemove) {
1644
+ handleReturn(await treeContext.onRemove(id));
1645
+ }
1646
+ setUpdatingNode(false);
1647
+ }, [handleReturn, id, thisNode, treeContext]);
1648
+ // // Context actions
1649
+ const addChild = React.useCallback(() => {
1650
+ if (menuContext.set) {
1651
+ menuContext.set({ visible: false });
1652
+ setShowNewNode(true);
1653
+ treeContext.handleExpandClick && treeContext.handleExpandClick(id, true);
1654
+ }
1655
+ }, [id, menuContext, treeContext]);
1656
+ React.useEffect(() => {
1657
+ if (showNewNode === true && newNameRef.current)
1658
+ newNameRef.current.focus();
1659
+ }, [showNewNode]);
1660
+ const renameThis = React.useCallback(() => {
1661
+ if (menuContext.set) {
1662
+ menuContext.set({ visible: false });
1663
+ setRenaming(true);
1664
+ }
1665
+ }, [menuContext]);
1666
+ React.useEffect(() => {
1667
+ if (renaming === true && currentNameRef.current)
1668
+ currentNameRef.current.focus();
1669
+ }, [renaming]);
1670
+ const removeThis = React.useCallback(() => {
1671
+ if (menuContext.set) {
1672
+ menuContext.set({ visible: false });
1673
+ deleteThis();
1674
+ }
1675
+ }, [menuContext, deleteThis]);
1676
+ // Context menu
1677
+ const showMenu = React.useCallback((e) => {
1678
+ e.preventDefault();
1679
+ e.stopPropagation();
1680
+ const menuItems = [];
1681
+ if (canAddChildren)
1682
+ menuItems.push({ label: 'Add directory', action: addChild });
1683
+ if (canRename)
1684
+ menuItems.push({ label: 'Rename', action: renameThis });
1685
+ if (canRemove && (childNodes === undefined || childNodes.length === 0))
1686
+ menuItems.push({ label: 'Delete', action: removeThis });
1687
+ if (typeof menuContext.set === 'function') {
1688
+ menuContext.set({
1689
+ visible: true,
1690
+ y: e.pageY,
1691
+ x: e.pageX,
1692
+ menuItems: menuItems,
1693
+ });
1694
+ }
1695
+ }, [
1696
+ addChild,
1697
+ canAddChildren,
1698
+ canRemove,
1699
+ canRename,
1700
+ childNodes,
1701
+ menuContext,
1702
+ removeThis,
1703
+ renameThis,
1704
+ ]);
1705
+ // Return node
1706
+ return (jsxRuntime.jsxs("div", { className: 'hierarchy-node', onClickCapture: () => treeContext.handleSelect && treeContext.handleSelect(id), onContextMenuCapture: () => treeContext.handleSelect && treeContext.handleSelect(id), onFocusCapture: () => treeContext.handleSelect && treeContext.handleSelect(id), children: [error ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExclamationCircleFill$1, { color: 'var(--bs-danger)' }), ' ', errorText && errorText !== '' ? errorText : 'An unknown error has occured'] })) : loading ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Spinner$1, { size: 'sm', animation: 'border' }), ' ', "Loading..."] })) : (jsxRuntime.jsxs("span", { onContextMenu: showMenu, children: [childNodes !== undefined && childNodes.length > 0 ? (!expanded ? (jsxRuntime.jsx(CaretRightFill$1, { id: `hierarchynode-caret-${id}`, onClick: () => treeContext.handleExpandClick && treeContext.handleExpandClick(id) })) : (jsxRuntime.jsx(CaretDownFill$1, { id: `hierarchynode-caret-${id}`, onClick: () => treeContext.handleExpandClick && treeContext.handleExpandClick(id) }))) : (jsxRuntime.jsx(CaretRight$1, {})), thisNode !== undefined ? (jsxRuntime.jsx(WordEntry, { id: id ? `treenode-word-${id}` : undefined, ref: currentNameRef, value: thisNode.label, editing: renaming, saving: updatingNode, setValue: (ret) => renameNode(ret), style: {
1707
+ border: currentBorder,
1708
+ margin: currentBorder === '' ? '1px' : '',
1709
+ backgroundColor: currentBorder === '' ? '' : 'lightgrey',
1710
+ } })) : (jsxRuntime.jsx("i", { children: "No name" }))] })), childNodes !== undefined && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: childNodes.map((h) => (jsxRuntime.jsx("span", { style: {
1711
+ marginLeft: '16px',
1712
+ display: 'block',
1713
+ maxHeight: expanded ? '99999px' : '0px',
1714
+ height: expanded ? 'auto' : '0px',
1715
+ overflowY: 'hidden',
1716
+ visibility: expanded ? 'inherit' : 'hidden',
1717
+ opacity: expanded ? 1 : 0,
1718
+ transition: 'visibility .3s, opacity .3s ease-in-out, max-height 0.3s ease-in-out',
1719
+ }, children: jsxRuntime.jsx(TreeNode, { id: h.id, canRemove: canRemoveChildren, canRename: canRenameChildren, canAddChildren: canAddChildren, canRemoveChildren: canRemoveChildren, canRenameChildren: canRenameChildren }) }, h.id))) })), showNewNode && (jsxRuntime.jsx("div", { children: jsxRuntime.jsx(WordEntry, { id: id ? `hierarchynode-new-${id}` : undefined, ref: newNameRef, editing: true, setValue: (ret) => {
1720
+ confirmNewNode(ret);
1721
+ }, saving: savingNewNode, sendEscape: () => {
1722
+ setShowNewNode(false);
1723
+ } }) }))] }));
1724
+ };
1725
+
1726
+ exports.ContextMenu = ContextMenu;
1727
+ exports.ContextMenuProvider = ContextMenuProvider;
1728
+ exports.TreeNode = TreeNode;
1729
+ exports.TreeOfNodes = TreeOfNodes;
1730
+ exports.WordEntry = WordEntry;