@asup/tree-of-nodes 1.0.1 → 1.0.3

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