@octaviaflow/core 3.1.0-beta.72 → 3.1.0-beta.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-CDM7AEPZ.js +5700 -0
- package/dist/chunk-CDM7AEPZ.js.map +1 -0
- package/dist/chunk-CRDYAV5R.js +2755 -0
- package/dist/chunk-CRDYAV5R.js.map +1 -0
- package/dist/chunk-DDVOFKLY.js +1682 -0
- package/dist/chunk-DDVOFKLY.js.map +1 -0
- package/dist/components/AuthScreen/AuthScreen.d.ts +146 -0
- package/dist/components/AuthScreen/AuthScreen.d.ts.map +1 -0
- package/dist/components/AuthScreen/index.d.ts +2 -0
- package/dist/components/AuthScreen/index.d.ts.map +1 -0
- package/dist/components/DataMapper/DataMapper.d.ts +8 -0
- package/dist/components/DataMapper/DataMapper.d.ts.map +1 -1
- package/dist/components/FlowDoctor/FlowDoctor.d.ts +45 -0
- package/dist/components/FlowDoctor/FlowDoctor.d.ts.map +1 -0
- package/dist/components/FlowDoctor/index.d.ts +2 -0
- package/dist/components/FlowDoctor/index.d.ts.map +1 -0
- package/dist/components/FlowToolbar/FlowToolbar.d.ts +6 -12
- package/dist/components/FlowToolbar/FlowToolbar.d.ts.map +1 -1
- package/dist/index.cjs +6973 -6045
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16456 -15522
- package/dist/index.js.map +1 -1
- package/dist/marketing.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/workflow.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,2755 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-ZAUUGK2Y.js";
|
|
4
|
+
|
|
5
|
+
// src/components/Accordion/Accordion.tsx
|
|
6
|
+
import { ChevronDownIcon } from "@octaviaflow/icons";
|
|
7
|
+
import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
|
|
8
|
+
import {
|
|
9
|
+
forwardRef,
|
|
10
|
+
useCallback,
|
|
11
|
+
useId,
|
|
12
|
+
useState
|
|
13
|
+
} from "react";
|
|
14
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
var Accordion = forwardRef(
|
|
16
|
+
function Accordion2({
|
|
17
|
+
items,
|
|
18
|
+
mode = "single",
|
|
19
|
+
value: controlledValue,
|
|
20
|
+
defaultValue,
|
|
21
|
+
onValueChange,
|
|
22
|
+
collapsible = true,
|
|
23
|
+
variant = "default",
|
|
24
|
+
size = "md",
|
|
25
|
+
disabled = false,
|
|
26
|
+
id: providedId,
|
|
27
|
+
className,
|
|
28
|
+
...rest
|
|
29
|
+
}, ref) {
|
|
30
|
+
const reactId = useId();
|
|
31
|
+
const baseId = providedId ?? `ods-accordion-${reactId}`;
|
|
32
|
+
const reducedMotion = useReducedMotion();
|
|
33
|
+
const [internalValue, setInternalValue] = useState(
|
|
34
|
+
defaultValue ?? []
|
|
35
|
+
);
|
|
36
|
+
const isControlled = controlledValue !== void 0;
|
|
37
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
38
|
+
const valueSet = new Set(value);
|
|
39
|
+
const setValue = useCallback(
|
|
40
|
+
(next) => {
|
|
41
|
+
if (!isControlled) setInternalValue(next);
|
|
42
|
+
onValueChange?.(next);
|
|
43
|
+
},
|
|
44
|
+
[isControlled, onValueChange]
|
|
45
|
+
);
|
|
46
|
+
const toggleItem = useCallback(
|
|
47
|
+
(id) => {
|
|
48
|
+
const isOpen = valueSet.has(id);
|
|
49
|
+
if (mode === "multiple") {
|
|
50
|
+
const next = isOpen ? value.filter((v) => v !== id) : [...value, id];
|
|
51
|
+
setValue(next);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (isOpen) {
|
|
55
|
+
if (collapsible) setValue([]);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
setValue([id]);
|
|
59
|
+
},
|
|
60
|
+
[collapsible, mode, setValue, value, valueSet]
|
|
61
|
+
);
|
|
62
|
+
const handleKeyDown = (e, index) => {
|
|
63
|
+
const enabledIdx = items.map((it, i) => it.disabled ? -1 : i).filter((i) => i !== -1);
|
|
64
|
+
const curr = enabledIdx.indexOf(index);
|
|
65
|
+
const focusIdx = (i) => {
|
|
66
|
+
const target = enabledIdx[i];
|
|
67
|
+
if (target === void 0) return;
|
|
68
|
+
const btn = document.getElementById(
|
|
69
|
+
`${baseId}-trigger-${items[target].id}`
|
|
70
|
+
);
|
|
71
|
+
btn?.focus();
|
|
72
|
+
};
|
|
73
|
+
if (e.key === "ArrowDown") {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
focusIdx((curr + 1) % enabledIdx.length);
|
|
76
|
+
} else if (e.key === "ArrowUp") {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
focusIdx((curr - 1 + enabledIdx.length) % enabledIdx.length);
|
|
79
|
+
} else if (e.key === "Home") {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
focusIdx(0);
|
|
82
|
+
} else if (e.key === "End") {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
focusIdx(enabledIdx.length - 1);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return /* @__PURE__ */ jsx(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
...rest,
|
|
91
|
+
ref,
|
|
92
|
+
id: baseId,
|
|
93
|
+
className: cn(
|
|
94
|
+
"ods-accordion",
|
|
95
|
+
`ods-accordion--${variant}`,
|
|
96
|
+
`ods-accordion--${size}`,
|
|
97
|
+
disabled && "ods-accordion--disabled",
|
|
98
|
+
className
|
|
99
|
+
),
|
|
100
|
+
children: items.map((item, i) => {
|
|
101
|
+
const isOpen = valueSet.has(item.id);
|
|
102
|
+
const itemDisabled = item.disabled || disabled;
|
|
103
|
+
const triggerId = `${baseId}-trigger-${item.id}`;
|
|
104
|
+
const panelId = `${baseId}-panel-${item.id}`;
|
|
105
|
+
return /* @__PURE__ */ jsxs(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
className: cn(
|
|
109
|
+
"ods-accordion__item",
|
|
110
|
+
isOpen && "ods-accordion__item--open",
|
|
111
|
+
itemDisabled && "ods-accordion__item--disabled"
|
|
112
|
+
),
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ jsxs(
|
|
115
|
+
"button",
|
|
116
|
+
{
|
|
117
|
+
id: triggerId,
|
|
118
|
+
type: "button",
|
|
119
|
+
className: "ods-accordion__trigger",
|
|
120
|
+
"aria-expanded": isOpen,
|
|
121
|
+
"aria-controls": panelId,
|
|
122
|
+
disabled: itemDisabled,
|
|
123
|
+
onClick: () => toggleItem(item.id),
|
|
124
|
+
onKeyDown: (e) => handleKeyDown(e, i),
|
|
125
|
+
children: [
|
|
126
|
+
item.icon && /* @__PURE__ */ jsx(
|
|
127
|
+
"span",
|
|
128
|
+
{
|
|
129
|
+
className: "ods-accordion__icon",
|
|
130
|
+
"aria-hidden": "true",
|
|
131
|
+
children: item.icon
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
/* @__PURE__ */ jsxs("span", { className: "ods-accordion__label-wrap", children: [
|
|
135
|
+
/* @__PURE__ */ jsx("span", { className: "ods-accordion__label", children: item.label }),
|
|
136
|
+
item.description && /* @__PURE__ */ jsx("span", { className: "ods-accordion__description", children: item.description })
|
|
137
|
+
] }),
|
|
138
|
+
item.trailing && /* @__PURE__ */ jsx(
|
|
139
|
+
"span",
|
|
140
|
+
{
|
|
141
|
+
className: "ods-accordion__trailing",
|
|
142
|
+
onClick: (e) => e.stopPropagation(),
|
|
143
|
+
children: item.trailing
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
/* @__PURE__ */ jsx(
|
|
147
|
+
"span",
|
|
148
|
+
{
|
|
149
|
+
className: cn(
|
|
150
|
+
"ods-accordion__chevron",
|
|
151
|
+
isOpen && "ods-accordion__chevron--open"
|
|
152
|
+
),
|
|
153
|
+
"aria-hidden": "true",
|
|
154
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: "sm", "aria-hidden": true })
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
/* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: isOpen && /* @__PURE__ */ jsx(
|
|
161
|
+
motion.div,
|
|
162
|
+
{
|
|
163
|
+
role: "region",
|
|
164
|
+
id: panelId,
|
|
165
|
+
"aria-labelledby": triggerId,
|
|
166
|
+
className: "ods-accordion__panel",
|
|
167
|
+
initial: reducedMotion ? false : { height: 0, opacity: 0 },
|
|
168
|
+
animate: reducedMotion ? void 0 : { height: "auto", opacity: 1 },
|
|
169
|
+
exit: reducedMotion ? void 0 : { height: 0, opacity: 0 },
|
|
170
|
+
transition: reducedMotion ? { duration: 0 } : { duration: 0.18 },
|
|
171
|
+
style: { overflow: "hidden" },
|
|
172
|
+
children: /* @__PURE__ */ jsx("div", { className: "ods-accordion__content", children: item.content })
|
|
173
|
+
}
|
|
174
|
+
) })
|
|
175
|
+
]
|
|
176
|
+
},
|
|
177
|
+
item.id
|
|
178
|
+
);
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
Accordion.displayName = "Accordion";
|
|
185
|
+
|
|
186
|
+
// src/components/Button/Button.tsx
|
|
187
|
+
import { motion as motion2, useReducedMotion as useReducedMotion2 } from "framer-motion";
|
|
188
|
+
import {
|
|
189
|
+
forwardRef as forwardRef3,
|
|
190
|
+
useImperativeHandle,
|
|
191
|
+
useRef
|
|
192
|
+
} from "react";
|
|
193
|
+
import { useButton } from "react-aria";
|
|
194
|
+
|
|
195
|
+
// src/utils/a11y.ts
|
|
196
|
+
import { isValidElement } from "react";
|
|
197
|
+
function hasRenderableText(node) {
|
|
198
|
+
if (node === null || node === void 0 || typeof node === "boolean") return false;
|
|
199
|
+
if (typeof node === "string") return node.trim().length > 0;
|
|
200
|
+
if (typeof node === "number") return true;
|
|
201
|
+
if (Array.isArray(node)) return node.some(hasRenderableText);
|
|
202
|
+
if (isValidElement(node)) {
|
|
203
|
+
return hasRenderableText(node.props.children);
|
|
204
|
+
}
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
function getRenderableText(node) {
|
|
208
|
+
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
209
|
+
if (typeof node === "string") return node;
|
|
210
|
+
if (typeof node === "number") return String(node);
|
|
211
|
+
if (Array.isArray(node)) return node.map(getRenderableText).join("");
|
|
212
|
+
if (isValidElement(node)) {
|
|
213
|
+
return getRenderableText(node.props.children);
|
|
214
|
+
}
|
|
215
|
+
return "";
|
|
216
|
+
}
|
|
217
|
+
function resolveAccessibleName(input) {
|
|
218
|
+
if (input.ariaLabelledby) {
|
|
219
|
+
return { "aria-labelledby": input.ariaLabelledby };
|
|
220
|
+
}
|
|
221
|
+
if (input.ariaLabel) {
|
|
222
|
+
return { "aria-label": input.ariaLabel };
|
|
223
|
+
}
|
|
224
|
+
if (typeof input.label === "string" && input.label.trim().length > 0) {
|
|
225
|
+
return { "aria-label": input.label };
|
|
226
|
+
}
|
|
227
|
+
for (const candidate of input.fallbacks ?? []) {
|
|
228
|
+
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
229
|
+
return { "aria-label": candidate };
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (process.env.NODE_ENV !== "production") {
|
|
233
|
+
console.error(
|
|
234
|
+
`[@octaviaflow/core ${input.componentName}] No accessible name. Pass a string \`label\`, or \`aria-label\`, or \`aria-labelledby\` so screen readers can announce this control.`
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
return { "aria-label": `Unlabeled ${input.componentName}` };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/utils/Slot.tsx
|
|
241
|
+
import {
|
|
242
|
+
Children,
|
|
243
|
+
cloneElement,
|
|
244
|
+
forwardRef as forwardRef2,
|
|
245
|
+
isValidElement as isValidElement2
|
|
246
|
+
} from "react";
|
|
247
|
+
|
|
248
|
+
// src/utils/composeRefs.ts
|
|
249
|
+
function composeRefs(...refs) {
|
|
250
|
+
return (node) => {
|
|
251
|
+
for (const ref of refs) {
|
|
252
|
+
if (typeof ref === "function") {
|
|
253
|
+
ref(node);
|
|
254
|
+
} else if (ref != null) {
|
|
255
|
+
ref.current = node;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// src/utils/Slot.tsx
|
|
262
|
+
var Slot = forwardRef2(function Slot2({ children, ...slotProps }, forwardedRef) {
|
|
263
|
+
if (!isValidElement2(children)) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
const child = Children.only(children);
|
|
267
|
+
const childProps = child.props ?? {};
|
|
268
|
+
const childRef = child.ref;
|
|
269
|
+
return cloneElement(child, {
|
|
270
|
+
...mergeProps(slotProps, childProps),
|
|
271
|
+
ref: forwardedRef ? composeRefs(forwardedRef, childRef) : childRef
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
function mergeProps(slotProps, childProps) {
|
|
275
|
+
const merged = { ...slotProps, ...childProps };
|
|
276
|
+
for (const key of Object.keys(slotProps)) {
|
|
277
|
+
const slotValue = slotProps[key];
|
|
278
|
+
const childValue = childProps[key];
|
|
279
|
+
if (/^on[A-Z]/.test(key) && typeof slotValue === "function" && typeof childValue === "function") {
|
|
280
|
+
merged[key] = (...args) => {
|
|
281
|
+
slotValue(...args);
|
|
282
|
+
const event = args[0];
|
|
283
|
+
if (event?.defaultPrevented) return;
|
|
284
|
+
childValue(...args);
|
|
285
|
+
};
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (key === "className") {
|
|
289
|
+
merged.className = [slotValue, childValue].filter(Boolean).join(" ");
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (key === "style") {
|
|
293
|
+
merged.style = {
|
|
294
|
+
...slotValue,
|
|
295
|
+
...childValue
|
|
296
|
+
};
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return merged;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/components/Button/Button.tsx
|
|
304
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
305
|
+
var Button = forwardRef3(function Button2({
|
|
306
|
+
variant = "primary",
|
|
307
|
+
size = "md",
|
|
308
|
+
loading = false,
|
|
309
|
+
loadingText,
|
|
310
|
+
loadingLabel = "Loading",
|
|
311
|
+
disabled = false,
|
|
312
|
+
leftIcon,
|
|
313
|
+
rightIcon,
|
|
314
|
+
fullWidth = false,
|
|
315
|
+
pressed,
|
|
316
|
+
asChild = false,
|
|
317
|
+
className,
|
|
318
|
+
children,
|
|
319
|
+
type,
|
|
320
|
+
cursor,
|
|
321
|
+
style,
|
|
322
|
+
...props
|
|
323
|
+
}, forwardedRef) {
|
|
324
|
+
const ref = useRef(null);
|
|
325
|
+
useImperativeHandle(forwardedRef, () => ref.current);
|
|
326
|
+
const isDisabled = disabled || loading;
|
|
327
|
+
const prefersReducedMotion = useReducedMotion2();
|
|
328
|
+
const hasAction = Boolean(props.onClick) || type === "submit" || type === "reset";
|
|
329
|
+
const resolvedCursor = cursor ?? (disabled ? "not-allowed" : loading ? "progress" : hasAction ? "pointer" : "default");
|
|
330
|
+
const resolvedType = type ?? "button";
|
|
331
|
+
const hasVisibleText = hasRenderableText(children);
|
|
332
|
+
const needsAriaName = !hasVisibleText && !asChild;
|
|
333
|
+
const ariaNameProps = needsAriaName ? resolveAccessibleName({
|
|
334
|
+
ariaLabel: props["aria-label"],
|
|
335
|
+
ariaLabelledby: props["aria-labelledby"],
|
|
336
|
+
componentName: "Button"
|
|
337
|
+
}) : void 0;
|
|
338
|
+
const { buttonProps } = useButton(
|
|
339
|
+
{
|
|
340
|
+
isDisabled,
|
|
341
|
+
onPress: props.onClick,
|
|
342
|
+
type: resolvedType,
|
|
343
|
+
...ariaNameProps ?? {}
|
|
344
|
+
},
|
|
345
|
+
ref
|
|
346
|
+
);
|
|
347
|
+
const { onDrag, onDragStart, onDragEnd, onAnimationStart, ...safeButtonProps } = buttonProps;
|
|
348
|
+
const {
|
|
349
|
+
onClick: _onClick,
|
|
350
|
+
onKeyDown: _onKeyDown,
|
|
351
|
+
onKeyUp: _onKeyUp,
|
|
352
|
+
onMouseDown: _onMouseDown,
|
|
353
|
+
onPointerDown: _onPointerDown,
|
|
354
|
+
onPointerUp: _onPointerUp,
|
|
355
|
+
onFocus: _onFocus,
|
|
356
|
+
onBlur: _onBlur,
|
|
357
|
+
...passthroughProps
|
|
358
|
+
} = props;
|
|
359
|
+
const rootClassName = cn(
|
|
360
|
+
"ods-btn",
|
|
361
|
+
`ods-btn--${variant}`,
|
|
362
|
+
`ods-btn--${size}`,
|
|
363
|
+
loading && "ods-btn--loading",
|
|
364
|
+
fullWidth && "ods-btn--full",
|
|
365
|
+
pressed && "ods-btn--pressed",
|
|
366
|
+
className
|
|
367
|
+
);
|
|
368
|
+
if (asChild) {
|
|
369
|
+
return /* @__PURE__ */ jsx2(
|
|
370
|
+
Slot,
|
|
371
|
+
{
|
|
372
|
+
...passthroughProps,
|
|
373
|
+
ref: forwardedRef,
|
|
374
|
+
className: rootClassName,
|
|
375
|
+
style: { cursor: resolvedCursor, ...style },
|
|
376
|
+
"aria-pressed": pressed,
|
|
377
|
+
"aria-disabled": isDisabled || void 0,
|
|
378
|
+
children
|
|
379
|
+
}
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
const visibleLabel = loading && loadingText !== void 0 ? loadingText : children;
|
|
383
|
+
return /* @__PURE__ */ jsx2(
|
|
384
|
+
motion2.button,
|
|
385
|
+
{
|
|
386
|
+
...passthroughProps,
|
|
387
|
+
...safeButtonProps,
|
|
388
|
+
type: resolvedType,
|
|
389
|
+
ref,
|
|
390
|
+
className: rootClassName,
|
|
391
|
+
style: { cursor: resolvedCursor, ...style },
|
|
392
|
+
"data-loading": loading || void 0,
|
|
393
|
+
"aria-busy": loading || void 0,
|
|
394
|
+
"aria-pressed": pressed,
|
|
395
|
+
whileTap: isDisabled || prefersReducedMotion ? void 0 : { scale: 0.97 },
|
|
396
|
+
transition: { duration: 0.1 },
|
|
397
|
+
children: /* @__PURE__ */ jsxs2("span", { className: "ods-btn__content", children: [
|
|
398
|
+
loading ? /* @__PURE__ */ jsx2(
|
|
399
|
+
"span",
|
|
400
|
+
{
|
|
401
|
+
className: "ods-btn__icon ods-btn__icon--left ods-btn__icon--spinner",
|
|
402
|
+
role: "status",
|
|
403
|
+
"aria-label": loadingLabel,
|
|
404
|
+
children: /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(
|
|
405
|
+
"circle",
|
|
406
|
+
{
|
|
407
|
+
cx: "12",
|
|
408
|
+
cy: "12",
|
|
409
|
+
r: "10",
|
|
410
|
+
fill: "none",
|
|
411
|
+
stroke: "currentColor",
|
|
412
|
+
strokeWidth: "2.5",
|
|
413
|
+
strokeLinecap: "round",
|
|
414
|
+
strokeDasharray: "32",
|
|
415
|
+
strokeDashoffset: "12"
|
|
416
|
+
}
|
|
417
|
+
) })
|
|
418
|
+
}
|
|
419
|
+
) : leftIcon && /* @__PURE__ */ jsx2("span", { className: "ods-btn__icon ods-btn__icon--left", children: leftIcon }),
|
|
420
|
+
visibleLabel != null && visibleLabel !== false && /* @__PURE__ */ jsx2("span", { className: "ods-btn__label", children: visibleLabel }),
|
|
421
|
+
rightIcon && !loading && /* @__PURE__ */ jsx2("span", { className: "ods-btn__icon ods-btn__icon--right", children: rightIcon })
|
|
422
|
+
] })
|
|
423
|
+
}
|
|
424
|
+
);
|
|
425
|
+
});
|
|
426
|
+
Button.displayName = "Button";
|
|
427
|
+
|
|
428
|
+
// src/components/Input/Input.tsx
|
|
429
|
+
import { CloseIcon } from "@octaviaflow/icons";
|
|
430
|
+
import {
|
|
431
|
+
forwardRef as forwardRef4,
|
|
432
|
+
useId as useId2,
|
|
433
|
+
useImperativeHandle as useImperativeHandle2,
|
|
434
|
+
useRef as useRef2
|
|
435
|
+
} from "react";
|
|
436
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
437
|
+
var CLEAR_GLYPH = /* @__PURE__ */ jsx3(CloseIcon, { width: 12, height: 12, "aria-hidden": "true" });
|
|
438
|
+
var Input = forwardRef4(
|
|
439
|
+
({
|
|
440
|
+
type = "text",
|
|
441
|
+
size = "md",
|
|
442
|
+
error = false,
|
|
443
|
+
errorMessage,
|
|
444
|
+
label,
|
|
445
|
+
helperText,
|
|
446
|
+
leftIcon,
|
|
447
|
+
rightIcon,
|
|
448
|
+
clearable,
|
|
449
|
+
onClear,
|
|
450
|
+
shortcutHint,
|
|
451
|
+
disabled = false,
|
|
452
|
+
required,
|
|
453
|
+
id,
|
|
454
|
+
className,
|
|
455
|
+
value,
|
|
456
|
+
defaultValue,
|
|
457
|
+
onChange,
|
|
458
|
+
onKeyDown,
|
|
459
|
+
...props
|
|
460
|
+
}, forwardedRef) => {
|
|
461
|
+
const innerRef = useRef2(null);
|
|
462
|
+
useImperativeHandle2(forwardedRef, () => innerRef.current);
|
|
463
|
+
const reactId = useId2();
|
|
464
|
+
const inputId = id ?? `${reactId}-input`;
|
|
465
|
+
const errorId = `${reactId}-err`;
|
|
466
|
+
const helperId = `${reactId}-help`;
|
|
467
|
+
const isControlled = value !== void 0;
|
|
468
|
+
const isClearable = (clearable ?? type === "search") && !disabled;
|
|
469
|
+
const isSearch = type === "search";
|
|
470
|
+
const currentValue = isControlled ? String(value ?? "") : innerRef.current?.value ?? String(defaultValue ?? "");
|
|
471
|
+
const showClear = isClearable && currentValue.length > 0;
|
|
472
|
+
const clearValue = () => {
|
|
473
|
+
const el = innerRef.current;
|
|
474
|
+
if (el && !isControlled) {
|
|
475
|
+
const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set;
|
|
476
|
+
setter?.call(el, "");
|
|
477
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
478
|
+
}
|
|
479
|
+
onClear?.();
|
|
480
|
+
el?.focus();
|
|
481
|
+
};
|
|
482
|
+
const handleClear = (e) => {
|
|
483
|
+
e.preventDefault();
|
|
484
|
+
e.stopPropagation();
|
|
485
|
+
clearValue();
|
|
486
|
+
};
|
|
487
|
+
const handleKeyDown = (e) => {
|
|
488
|
+
onKeyDown?.(e);
|
|
489
|
+
if (e.defaultPrevented) return;
|
|
490
|
+
if (isClearable && isSearch && e.key === "Escape" && currentValue) {
|
|
491
|
+
e.preventDefault();
|
|
492
|
+
clearValue();
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
const describedBy = error && errorMessage ? errorId : helperText ? helperId : void 0;
|
|
496
|
+
return /* @__PURE__ */ jsxs3(
|
|
497
|
+
"div",
|
|
498
|
+
{
|
|
499
|
+
className: cn(
|
|
500
|
+
"ods-input",
|
|
501
|
+
`ods-input--${size}`,
|
|
502
|
+
error && "ods-input--error",
|
|
503
|
+
disabled && "ods-input--disabled",
|
|
504
|
+
isSearch && "ods-input--search",
|
|
505
|
+
className
|
|
506
|
+
),
|
|
507
|
+
children: [
|
|
508
|
+
label && /* @__PURE__ */ jsxs3("label", { htmlFor: inputId, className: "ods-input__label", children: [
|
|
509
|
+
label,
|
|
510
|
+
required && /* @__PURE__ */ jsx3("span", { className: "ods-input__required", "aria-hidden": "true", children: "*" })
|
|
511
|
+
] }),
|
|
512
|
+
/* @__PURE__ */ jsxs3("div", { className: "ods-input__wrapper", children: [
|
|
513
|
+
leftIcon && /* @__PURE__ */ jsx3("span", { className: "ods-input__icon--left", "aria-hidden": "true", children: leftIcon }),
|
|
514
|
+
/* @__PURE__ */ jsx3(
|
|
515
|
+
"input",
|
|
516
|
+
{
|
|
517
|
+
...props,
|
|
518
|
+
id: inputId,
|
|
519
|
+
ref: innerRef,
|
|
520
|
+
type,
|
|
521
|
+
disabled,
|
|
522
|
+
required,
|
|
523
|
+
value,
|
|
524
|
+
defaultValue,
|
|
525
|
+
onChange,
|
|
526
|
+
onKeyDown: handleKeyDown,
|
|
527
|
+
className: cn(
|
|
528
|
+
"ods-input__field",
|
|
529
|
+
leftIcon && "ods-input__field--with-left-icon",
|
|
530
|
+
(rightIcon || showClear || shortcutHint) && "ods-input__field--with-right-icon",
|
|
531
|
+
showClear && shortcutHint && "ods-input__field--with-right-actions"
|
|
532
|
+
),
|
|
533
|
+
"aria-invalid": error || void 0,
|
|
534
|
+
"aria-required": required || void 0,
|
|
535
|
+
"aria-describedby": describedBy
|
|
536
|
+
}
|
|
537
|
+
),
|
|
538
|
+
/* @__PURE__ */ jsxs3("span", { className: "ods-input__right", children: [
|
|
539
|
+
showClear && /* @__PURE__ */ jsx3(
|
|
540
|
+
"button",
|
|
541
|
+
{
|
|
542
|
+
type: "button",
|
|
543
|
+
className: "ods-input__clear",
|
|
544
|
+
onClick: handleClear,
|
|
545
|
+
"aria-label": "Clear",
|
|
546
|
+
tabIndex: -1,
|
|
547
|
+
children: CLEAR_GLYPH
|
|
548
|
+
}
|
|
549
|
+
),
|
|
550
|
+
shortcutHint && !showClear && /* @__PURE__ */ jsx3("span", { className: "ods-input__kbd", "aria-hidden": "true", children: shortcutHint }),
|
|
551
|
+
rightIcon && !showClear && !shortcutHint && /* @__PURE__ */ jsx3("span", { className: "ods-input__icon--right", "aria-hidden": "true", children: rightIcon })
|
|
552
|
+
] })
|
|
553
|
+
] }),
|
|
554
|
+
error && errorMessage && /* @__PURE__ */ jsx3("div", { id: errorId, className: "ods-input__error-message", role: "alert", children: errorMessage }),
|
|
555
|
+
!error && helperText && /* @__PURE__ */ jsx3("div", { id: helperId, className: "ods-input__helper", children: helperText })
|
|
556
|
+
]
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
);
|
|
561
|
+
Input.displayName = "Input";
|
|
562
|
+
|
|
563
|
+
// src/components/Tooltip/Tooltip.tsx
|
|
564
|
+
import { AnimatePresence as AnimatePresence2, motion as motion3 } from "framer-motion";
|
|
565
|
+
import {
|
|
566
|
+
cloneElement as cloneElement2,
|
|
567
|
+
isValidElement as isValidElement3,
|
|
568
|
+
useCallback as useCallback2,
|
|
569
|
+
useEffect,
|
|
570
|
+
useId as useId3,
|
|
571
|
+
useLayoutEffect,
|
|
572
|
+
useRef as useRef3,
|
|
573
|
+
useState as useState2
|
|
574
|
+
} from "react";
|
|
575
|
+
import { useTooltip, useTooltipTrigger } from "react-aria";
|
|
576
|
+
import { createPortal } from "react-dom";
|
|
577
|
+
|
|
578
|
+
// ../../node_modules/react-stately/dist/private/utils/useControlledState.mjs
|
|
579
|
+
import $1CcWn$react, { useState as $1CcWn$useState, useRef as $1CcWn$useRef, useEffect as $1CcWn$useEffect, useReducer as $1CcWn$useReducer, useCallback as $1CcWn$useCallback } from "react";
|
|
580
|
+
var $3e6197669829fe11$var$useEarlyEffect = typeof document !== "undefined" ? (0, $1CcWn$react)["useInsertionEffect"] ?? (0, $1CcWn$react).useLayoutEffect : () => {
|
|
581
|
+
};
|
|
582
|
+
function $3e6197669829fe11$export$40bfa8c7b0832715(value, defaultValue, onChange) {
|
|
583
|
+
let [stateValue, setStateValue] = (0, $1CcWn$useState)(value || defaultValue);
|
|
584
|
+
let valueRef = (0, $1CcWn$useRef)(stateValue);
|
|
585
|
+
let isControlledRef = (0, $1CcWn$useRef)(value !== void 0);
|
|
586
|
+
let isControlled = value !== void 0;
|
|
587
|
+
(0, $1CcWn$useEffect)(() => {
|
|
588
|
+
let wasControlled = isControlledRef.current;
|
|
589
|
+
if (wasControlled !== isControlled && process.env.NODE_ENV !== "production") console.warn(`WARN: A component changed from ${wasControlled ? "controlled" : "uncontrolled"} to ${isControlled ? "controlled" : "uncontrolled"}.`);
|
|
590
|
+
isControlledRef.current = isControlled;
|
|
591
|
+
}, [
|
|
592
|
+
isControlled
|
|
593
|
+
]);
|
|
594
|
+
let currentValue = isControlled ? value : stateValue;
|
|
595
|
+
$3e6197669829fe11$var$useEarlyEffect(() => {
|
|
596
|
+
valueRef.current = currentValue;
|
|
597
|
+
});
|
|
598
|
+
let [, forceUpdate] = (0, $1CcWn$useReducer)(() => ({}), {});
|
|
599
|
+
let setValue = (0, $1CcWn$useCallback)((value2, ...args) => {
|
|
600
|
+
let newValue = typeof value2 === "function" ? value2(valueRef.current) : value2;
|
|
601
|
+
if (!Object.is(valueRef.current, newValue)) {
|
|
602
|
+
valueRef.current = newValue;
|
|
603
|
+
setStateValue(newValue);
|
|
604
|
+
forceUpdate();
|
|
605
|
+
onChange?.(newValue, ...args);
|
|
606
|
+
}
|
|
607
|
+
}, [
|
|
608
|
+
onChange
|
|
609
|
+
]);
|
|
610
|
+
return [
|
|
611
|
+
currentValue,
|
|
612
|
+
setValue
|
|
613
|
+
];
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// ../../node_modules/react-stately/dist/private/form/useFormValidationState.mjs
|
|
617
|
+
import { createContext as $8AuPP$createContext, useMemo as $8AuPP$useMemo, useContext as $8AuPP$useContext, useState as $8AuPP$useState, useRef as $8AuPP$useRef, useEffect as $8AuPP$useEffect } from "react";
|
|
618
|
+
var $fd2148440a13ec26$export$aca958c65c314e6c = {
|
|
619
|
+
badInput: false,
|
|
620
|
+
customError: false,
|
|
621
|
+
patternMismatch: false,
|
|
622
|
+
rangeOverflow: false,
|
|
623
|
+
rangeUnderflow: false,
|
|
624
|
+
stepMismatch: false,
|
|
625
|
+
tooLong: false,
|
|
626
|
+
tooShort: false,
|
|
627
|
+
typeMismatch: false,
|
|
628
|
+
valueMissing: false,
|
|
629
|
+
valid: true
|
|
630
|
+
};
|
|
631
|
+
var $fd2148440a13ec26$var$CUSTOM_VALIDITY_STATE = {
|
|
632
|
+
...$fd2148440a13ec26$export$aca958c65c314e6c,
|
|
633
|
+
customError: true,
|
|
634
|
+
valid: false
|
|
635
|
+
};
|
|
636
|
+
var $fd2148440a13ec26$export$dad6ae84456c676a = {
|
|
637
|
+
isInvalid: false,
|
|
638
|
+
validationDetails: $fd2148440a13ec26$export$aca958c65c314e6c,
|
|
639
|
+
validationErrors: []
|
|
640
|
+
};
|
|
641
|
+
var $fd2148440a13ec26$export$571b5131b7e65c11 = (0, $8AuPP$createContext)({});
|
|
642
|
+
var $fd2148440a13ec26$export$a763b9476acd3eb = "__reactAriaFormValidationState";
|
|
643
|
+
function $fd2148440a13ec26$export$fc1a364ae1f3ff10(props) {
|
|
644
|
+
if (props[$fd2148440a13ec26$export$a763b9476acd3eb]) {
|
|
645
|
+
let { realtimeValidation, displayValidation, updateValidation, resetValidation, commitValidation } = props[$fd2148440a13ec26$export$a763b9476acd3eb];
|
|
646
|
+
return {
|
|
647
|
+
realtimeValidation,
|
|
648
|
+
displayValidation,
|
|
649
|
+
updateValidation,
|
|
650
|
+
resetValidation,
|
|
651
|
+
commitValidation
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
return $fd2148440a13ec26$var$useFormValidationStateImpl(props);
|
|
655
|
+
}
|
|
656
|
+
function $fd2148440a13ec26$var$useFormValidationStateImpl(props) {
|
|
657
|
+
let { isInvalid, validationState, name, value, builtinValidation, validate, validationBehavior = "aria" } = props;
|
|
658
|
+
if (validationState) isInvalid ||= validationState === "invalid";
|
|
659
|
+
let controlledError = isInvalid !== void 0 ? {
|
|
660
|
+
isInvalid,
|
|
661
|
+
validationErrors: [],
|
|
662
|
+
validationDetails: $fd2148440a13ec26$var$CUSTOM_VALIDITY_STATE
|
|
663
|
+
} : null;
|
|
664
|
+
let clientError = (0, $8AuPP$useMemo)(() => {
|
|
665
|
+
if (!validate || value == null) return null;
|
|
666
|
+
let validateErrors = $fd2148440a13ec26$var$runValidate(validate, value);
|
|
667
|
+
return $fd2148440a13ec26$var$getValidationResult(validateErrors);
|
|
668
|
+
}, [
|
|
669
|
+
validate,
|
|
670
|
+
value
|
|
671
|
+
]);
|
|
672
|
+
if (builtinValidation?.validationDetails.valid) builtinValidation = void 0;
|
|
673
|
+
let serverErrors = (0, $8AuPP$useContext)($fd2148440a13ec26$export$571b5131b7e65c11);
|
|
674
|
+
let serverErrorMessages = (0, $8AuPP$useMemo)(() => {
|
|
675
|
+
if (name) return Array.isArray(name) ? name.flatMap((name2) => $fd2148440a13ec26$var$asArray(serverErrors[name2])) : $fd2148440a13ec26$var$asArray(serverErrors[name]);
|
|
676
|
+
return [];
|
|
677
|
+
}, [
|
|
678
|
+
serverErrors,
|
|
679
|
+
name
|
|
680
|
+
]);
|
|
681
|
+
let [lastServerErrors, setLastServerErrors] = (0, $8AuPP$useState)(serverErrors);
|
|
682
|
+
let [isServerErrorCleared, setServerErrorCleared] = (0, $8AuPP$useState)(false);
|
|
683
|
+
if (serverErrors !== lastServerErrors) {
|
|
684
|
+
setLastServerErrors(serverErrors);
|
|
685
|
+
setServerErrorCleared(false);
|
|
686
|
+
}
|
|
687
|
+
let serverError = (0, $8AuPP$useMemo)(() => $fd2148440a13ec26$var$getValidationResult(isServerErrorCleared ? [] : serverErrorMessages), [
|
|
688
|
+
isServerErrorCleared,
|
|
689
|
+
serverErrorMessages
|
|
690
|
+
]);
|
|
691
|
+
let nextValidation = (0, $8AuPP$useRef)($fd2148440a13ec26$export$dad6ae84456c676a);
|
|
692
|
+
let [currentValidity, setCurrentValidity] = (0, $8AuPP$useState)($fd2148440a13ec26$export$dad6ae84456c676a);
|
|
693
|
+
let lastError = (0, $8AuPP$useRef)($fd2148440a13ec26$export$dad6ae84456c676a);
|
|
694
|
+
let commitValidation = () => {
|
|
695
|
+
if (!commitQueued) return;
|
|
696
|
+
setCommitQueued(false);
|
|
697
|
+
let error = clientError || builtinValidation || nextValidation.current;
|
|
698
|
+
if (!$fd2148440a13ec26$var$isEqualValidation(error, lastError.current)) {
|
|
699
|
+
lastError.current = error;
|
|
700
|
+
setCurrentValidity(error);
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
let [commitQueued, setCommitQueued] = (0, $8AuPP$useState)(false);
|
|
704
|
+
(0, $8AuPP$useEffect)(commitValidation);
|
|
705
|
+
let realtimeValidation = controlledError || serverError || clientError || builtinValidation || $fd2148440a13ec26$export$dad6ae84456c676a;
|
|
706
|
+
let displayValidation = validationBehavior === "native" ? controlledError || serverError || currentValidity : controlledError || serverError || clientError || builtinValidation || currentValidity;
|
|
707
|
+
return {
|
|
708
|
+
realtimeValidation,
|
|
709
|
+
displayValidation,
|
|
710
|
+
updateValidation(value2) {
|
|
711
|
+
if (validationBehavior === "aria" && !$fd2148440a13ec26$var$isEqualValidation(currentValidity, value2)) setCurrentValidity(value2);
|
|
712
|
+
else nextValidation.current = value2;
|
|
713
|
+
},
|
|
714
|
+
resetValidation() {
|
|
715
|
+
let error = $fd2148440a13ec26$export$dad6ae84456c676a;
|
|
716
|
+
if (!$fd2148440a13ec26$var$isEqualValidation(error, lastError.current)) {
|
|
717
|
+
lastError.current = error;
|
|
718
|
+
setCurrentValidity(error);
|
|
719
|
+
}
|
|
720
|
+
if (validationBehavior === "native") setCommitQueued(false);
|
|
721
|
+
setServerErrorCleared(true);
|
|
722
|
+
},
|
|
723
|
+
commitValidation() {
|
|
724
|
+
if (validationBehavior === "native") setCommitQueued(true);
|
|
725
|
+
setServerErrorCleared(true);
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
function $fd2148440a13ec26$var$asArray(v) {
|
|
730
|
+
if (!v) return [];
|
|
731
|
+
return Array.isArray(v) ? v : [
|
|
732
|
+
v
|
|
733
|
+
];
|
|
734
|
+
}
|
|
735
|
+
function $fd2148440a13ec26$var$runValidate(validate, value) {
|
|
736
|
+
if (typeof validate === "function") {
|
|
737
|
+
let e = validate(value);
|
|
738
|
+
if (e && typeof e !== "boolean") return $fd2148440a13ec26$var$asArray(e);
|
|
739
|
+
}
|
|
740
|
+
return [];
|
|
741
|
+
}
|
|
742
|
+
function $fd2148440a13ec26$var$getValidationResult(errors) {
|
|
743
|
+
return errors.length ? {
|
|
744
|
+
isInvalid: true,
|
|
745
|
+
validationErrors: errors,
|
|
746
|
+
validationDetails: $fd2148440a13ec26$var$CUSTOM_VALIDITY_STATE
|
|
747
|
+
} : null;
|
|
748
|
+
}
|
|
749
|
+
function $fd2148440a13ec26$var$isEqualValidation(a, b) {
|
|
750
|
+
if (a === b) return true;
|
|
751
|
+
return !!a && !!b && a.isInvalid === b.isInvalid && a.validationErrors.length === b.validationErrors.length && a.validationErrors.every((a2, i) => a2 === b.validationErrors[i]) && Object.entries(a.validationDetails).every(([k, v]) => b.validationDetails[k] === v);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// ../../node_modules/react-stately/dist/private/collections/getChildNodes.mjs
|
|
755
|
+
function $cd5ea4b915021f1d$export$1005530eda016c13(node, collection) {
|
|
756
|
+
if (typeof collection.getChildren === "function") return collection.getChildren(node.key);
|
|
757
|
+
return node.childNodes;
|
|
758
|
+
}
|
|
759
|
+
function $cd5ea4b915021f1d$export$fbdeaa6a76694f71(iterable) {
|
|
760
|
+
return $cd5ea4b915021f1d$export$5f3398f8733f90e2(iterable, 0);
|
|
761
|
+
}
|
|
762
|
+
function $cd5ea4b915021f1d$export$5f3398f8733f90e2(iterable, index) {
|
|
763
|
+
if (index < 0) return void 0;
|
|
764
|
+
let i = 0;
|
|
765
|
+
for (let item of iterable) {
|
|
766
|
+
if (i === index) return item;
|
|
767
|
+
i++;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
function $cd5ea4b915021f1d$export$8c434b3a7a4dad6(collection, a, b) {
|
|
771
|
+
if (a.parentKey === b.parentKey) return a.index - b.index;
|
|
772
|
+
let aAncestors = [
|
|
773
|
+
...$cd5ea4b915021f1d$var$getAncestors(collection, a),
|
|
774
|
+
a
|
|
775
|
+
];
|
|
776
|
+
let bAncestors = [
|
|
777
|
+
...$cd5ea4b915021f1d$var$getAncestors(collection, b),
|
|
778
|
+
b
|
|
779
|
+
];
|
|
780
|
+
let firstNonMatchingAncestor = aAncestors.slice(0, bAncestors.length).findIndex((a2, i) => a2 !== bAncestors[i]);
|
|
781
|
+
if (firstNonMatchingAncestor !== -1) {
|
|
782
|
+
a = aAncestors[firstNonMatchingAncestor];
|
|
783
|
+
b = bAncestors[firstNonMatchingAncestor];
|
|
784
|
+
return a.index - b.index;
|
|
785
|
+
}
|
|
786
|
+
if (aAncestors.findIndex((node) => node === b) >= 0) return 1;
|
|
787
|
+
else if (bAncestors.findIndex((node) => node === a) >= 0) return -1;
|
|
788
|
+
return -1;
|
|
789
|
+
}
|
|
790
|
+
function $cd5ea4b915021f1d$var$getAncestors(collection, node) {
|
|
791
|
+
let parents = [];
|
|
792
|
+
let currNode = node;
|
|
793
|
+
while (currNode?.parentKey != null) {
|
|
794
|
+
currNode = collection.getItem(currNode.parentKey);
|
|
795
|
+
if (currNode) parents.unshift(currNode);
|
|
796
|
+
}
|
|
797
|
+
return parents;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
// ../../node_modules/react-stately/dist/private/list/ListCollection.mjs
|
|
801
|
+
var $f664a81d022446b5$export$d085fb9e920b5ca7 = class {
|
|
802
|
+
constructor(nodes) {
|
|
803
|
+
this.keyMap = /* @__PURE__ */ new Map();
|
|
804
|
+
this.firstKey = null;
|
|
805
|
+
this.lastKey = null;
|
|
806
|
+
this.iterable = nodes;
|
|
807
|
+
let visit = (node) => {
|
|
808
|
+
this.keyMap.set(node.key, node);
|
|
809
|
+
if (node.childNodes && node.type === "section") for (let child of node.childNodes) visit(child);
|
|
810
|
+
};
|
|
811
|
+
for (let node of nodes) visit(node);
|
|
812
|
+
let last = null;
|
|
813
|
+
let index = 0;
|
|
814
|
+
let size = 0;
|
|
815
|
+
for (let [key, node] of this.keyMap) {
|
|
816
|
+
if (last) {
|
|
817
|
+
last.nextKey = key;
|
|
818
|
+
node.prevKey = last.key;
|
|
819
|
+
} else {
|
|
820
|
+
this.firstKey = key;
|
|
821
|
+
node.prevKey = void 0;
|
|
822
|
+
}
|
|
823
|
+
if (node.type === "item") node.index = index++;
|
|
824
|
+
if (node.type === "section" || node.type === "item") size++;
|
|
825
|
+
last = node;
|
|
826
|
+
last.nextKey = void 0;
|
|
827
|
+
}
|
|
828
|
+
this._size = size;
|
|
829
|
+
this.lastKey = last?.key ?? null;
|
|
830
|
+
}
|
|
831
|
+
*[Symbol.iterator]() {
|
|
832
|
+
yield* this.iterable;
|
|
833
|
+
}
|
|
834
|
+
get size() {
|
|
835
|
+
return this._size;
|
|
836
|
+
}
|
|
837
|
+
getKeys() {
|
|
838
|
+
return this.keyMap.keys();
|
|
839
|
+
}
|
|
840
|
+
getKeyBefore(key) {
|
|
841
|
+
let node = this.keyMap.get(key);
|
|
842
|
+
return node ? node.prevKey ?? null : null;
|
|
843
|
+
}
|
|
844
|
+
getKeyAfter(key) {
|
|
845
|
+
let node = this.keyMap.get(key);
|
|
846
|
+
return node ? node.nextKey ?? null : null;
|
|
847
|
+
}
|
|
848
|
+
getFirstKey() {
|
|
849
|
+
return this.firstKey;
|
|
850
|
+
}
|
|
851
|
+
getLastKey() {
|
|
852
|
+
return this.lastKey;
|
|
853
|
+
}
|
|
854
|
+
getItem(key) {
|
|
855
|
+
return this.keyMap.get(key) ?? null;
|
|
856
|
+
}
|
|
857
|
+
at(idx) {
|
|
858
|
+
const keys = [
|
|
859
|
+
...this.getKeys()
|
|
860
|
+
];
|
|
861
|
+
return this.getItem(keys[idx]);
|
|
862
|
+
}
|
|
863
|
+
getChildren(key) {
|
|
864
|
+
let node = this.keyMap.get(key);
|
|
865
|
+
return node?.childNodes || [];
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
// ../../node_modules/react-stately/dist/private/selection/Selection.mjs
|
|
870
|
+
var $8b2540e09867b15e$export$52baac22726c72bf = class _$8b2540e09867b15e$export$52baac22726c72bf extends Set {
|
|
871
|
+
constructor(keys, anchorKey, currentKey) {
|
|
872
|
+
super(keys);
|
|
873
|
+
if (keys instanceof _$8b2540e09867b15e$export$52baac22726c72bf) {
|
|
874
|
+
this.anchorKey = anchorKey ?? keys.anchorKey;
|
|
875
|
+
this.currentKey = currentKey ?? keys.currentKey;
|
|
876
|
+
} else {
|
|
877
|
+
this.anchorKey = anchorKey ?? null;
|
|
878
|
+
this.currentKey = currentKey ?? null;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// ../../node_modules/react-stately/dist/private/selection/useMultipleSelectionState.mjs
|
|
884
|
+
import { useRef as $7w3VE$useRef, useState as $7w3VE$useState, useMemo as $7w3VE$useMemo, useEffect as $7w3VE$useEffect } from "react";
|
|
885
|
+
function $60f19cefd567a3e4$var$equalSets(setA, setB) {
|
|
886
|
+
if (setA.size !== setB.size) return false;
|
|
887
|
+
for (let item of setA) {
|
|
888
|
+
if (!setB.has(item)) return false;
|
|
889
|
+
}
|
|
890
|
+
return true;
|
|
891
|
+
}
|
|
892
|
+
function $60f19cefd567a3e4$export$253fe78d46329472(props) {
|
|
893
|
+
let { selectionMode = "none", disallowEmptySelection = false, allowDuplicateSelectionEvents, selectionBehavior: selectionBehaviorProp = "toggle", disabledBehavior = "all" } = props;
|
|
894
|
+
let isFocusedRef = (0, $7w3VE$useRef)(false);
|
|
895
|
+
let [, setFocused] = (0, $7w3VE$useState)(false);
|
|
896
|
+
let focusedKeyRef = (0, $7w3VE$useRef)(null);
|
|
897
|
+
let childFocusStrategyRef = (0, $7w3VE$useRef)(null);
|
|
898
|
+
let [, setFocusedKey] = (0, $7w3VE$useState)(null);
|
|
899
|
+
let selectedKeysProp = (0, $7w3VE$useMemo)(() => $60f19cefd567a3e4$var$convertSelection(props.selectedKeys), [
|
|
900
|
+
props.selectedKeys
|
|
901
|
+
]);
|
|
902
|
+
let defaultSelectedKeys = (0, $7w3VE$useMemo)(() => $60f19cefd567a3e4$var$convertSelection(props.defaultSelectedKeys, new (0, $8b2540e09867b15e$export$52baac22726c72bf)()), [
|
|
903
|
+
props.defaultSelectedKeys
|
|
904
|
+
]);
|
|
905
|
+
let [selectedKeys, setSelectedKeys] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(selectedKeysProp, defaultSelectedKeys, props.onSelectionChange);
|
|
906
|
+
let disabledKeysProp = (0, $7w3VE$useMemo)(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
|
|
907
|
+
props.disabledKeys
|
|
908
|
+
]);
|
|
909
|
+
let [selectionBehavior, setSelectionBehavior] = (0, $7w3VE$useState)(selectionBehaviorProp);
|
|
910
|
+
if (selectionBehaviorProp === "replace" && selectionBehavior === "toggle" && typeof selectedKeys === "object" && selectedKeys.size === 0) setSelectionBehavior("replace");
|
|
911
|
+
let lastSelectionBehavior = (0, $7w3VE$useRef)(selectionBehaviorProp);
|
|
912
|
+
(0, $7w3VE$useEffect)(() => {
|
|
913
|
+
if (selectionBehaviorProp !== lastSelectionBehavior.current) {
|
|
914
|
+
setSelectionBehavior(selectionBehaviorProp);
|
|
915
|
+
lastSelectionBehavior.current = selectionBehaviorProp;
|
|
916
|
+
}
|
|
917
|
+
}, [
|
|
918
|
+
selectionBehaviorProp
|
|
919
|
+
]);
|
|
920
|
+
return {
|
|
921
|
+
selectionMode,
|
|
922
|
+
disallowEmptySelection,
|
|
923
|
+
selectionBehavior,
|
|
924
|
+
setSelectionBehavior,
|
|
925
|
+
get isFocused() {
|
|
926
|
+
return isFocusedRef.current;
|
|
927
|
+
},
|
|
928
|
+
setFocused(f) {
|
|
929
|
+
isFocusedRef.current = f;
|
|
930
|
+
setFocused(f);
|
|
931
|
+
},
|
|
932
|
+
get focusedKey() {
|
|
933
|
+
return focusedKeyRef.current;
|
|
934
|
+
},
|
|
935
|
+
get childFocusStrategy() {
|
|
936
|
+
return childFocusStrategyRef.current;
|
|
937
|
+
},
|
|
938
|
+
setFocusedKey(k, childFocusStrategy = "first") {
|
|
939
|
+
focusedKeyRef.current = k;
|
|
940
|
+
childFocusStrategyRef.current = childFocusStrategy;
|
|
941
|
+
setFocusedKey(k);
|
|
942
|
+
},
|
|
943
|
+
selectedKeys,
|
|
944
|
+
setSelectedKeys(keys) {
|
|
945
|
+
if (allowDuplicateSelectionEvents || !$60f19cefd567a3e4$var$equalSets(keys, selectedKeys)) setSelectedKeys(keys);
|
|
946
|
+
},
|
|
947
|
+
disabledKeys: disabledKeysProp,
|
|
948
|
+
disabledBehavior
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
function $60f19cefd567a3e4$var$convertSelection(selection, defaultValue) {
|
|
952
|
+
if (!selection) return defaultValue;
|
|
953
|
+
return selection === "all" ? "all" : new (0, $8b2540e09867b15e$export$52baac22726c72bf)(selection);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// ../../node_modules/react-stately/dist/private/selection/SelectionManager.mjs
|
|
957
|
+
var $4a07ac835f260f78$export$6c8a5aaad13c9852 = class _$4a07ac835f260f78$export$6c8a5aaad13c9852 {
|
|
958
|
+
constructor(collection, state, options) {
|
|
959
|
+
this.collection = collection;
|
|
960
|
+
this.state = state;
|
|
961
|
+
this.allowsCellSelection = options?.allowsCellSelection ?? false;
|
|
962
|
+
this._isSelectAll = null;
|
|
963
|
+
this.layoutDelegate = options?.layoutDelegate || null;
|
|
964
|
+
this.fullCollection = options?.fullCollection || null;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* The type of selection that is allowed in the collection.
|
|
968
|
+
*/
|
|
969
|
+
get selectionMode() {
|
|
970
|
+
return this.state.selectionMode;
|
|
971
|
+
}
|
|
972
|
+
/**
|
|
973
|
+
* Whether the collection allows empty selection.
|
|
974
|
+
*/
|
|
975
|
+
get disallowEmptySelection() {
|
|
976
|
+
return this.state.disallowEmptySelection;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* The selection behavior for the collection.
|
|
980
|
+
*/
|
|
981
|
+
get selectionBehavior() {
|
|
982
|
+
return this.state.selectionBehavior;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Sets the selection behavior for the collection.
|
|
986
|
+
*/
|
|
987
|
+
setSelectionBehavior(selectionBehavior) {
|
|
988
|
+
this.state.setSelectionBehavior(selectionBehavior);
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Whether the collection is currently focused.
|
|
992
|
+
*/
|
|
993
|
+
get isFocused() {
|
|
994
|
+
return this.state.isFocused;
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Sets whether the collection is focused.
|
|
998
|
+
*/
|
|
999
|
+
setFocused(isFocused) {
|
|
1000
|
+
this.state.setFocused(isFocused);
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* The current focused key in the collection.
|
|
1004
|
+
*/
|
|
1005
|
+
get focusedKey() {
|
|
1006
|
+
return this.state.focusedKey;
|
|
1007
|
+
}
|
|
1008
|
+
/** Whether the first or last child of the focused key should receive focus. */
|
|
1009
|
+
get childFocusStrategy() {
|
|
1010
|
+
return this.state.childFocusStrategy;
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Sets the focused key.
|
|
1014
|
+
*/
|
|
1015
|
+
setFocusedKey(key, childFocusStrategy) {
|
|
1016
|
+
if (key == null || this.collection.getItem(key)) this.state.setFocusedKey(key, childFocusStrategy);
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* The currently selected keys in the collection.
|
|
1020
|
+
*/
|
|
1021
|
+
get selectedKeys() {
|
|
1022
|
+
return this.state.selectedKeys === "all" ? new Set(this.getSelectAllKeys()) : this.state.selectedKeys;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* The raw selection value for the collection.
|
|
1026
|
+
* Either 'all' for select all, or a set of keys.
|
|
1027
|
+
*/
|
|
1028
|
+
get rawSelection() {
|
|
1029
|
+
return this.state.selectedKeys;
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Returns whether a key is selected.
|
|
1033
|
+
*/
|
|
1034
|
+
isSelected(key) {
|
|
1035
|
+
if (this.state.selectionMode === "none") return false;
|
|
1036
|
+
let mappedKey = this.getKey(key);
|
|
1037
|
+
if (mappedKey == null) return false;
|
|
1038
|
+
return this.state.selectedKeys === "all" ? this.canSelectItem(mappedKey) : this.state.selectedKeys.has(mappedKey);
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* Whether the selection is empty.
|
|
1042
|
+
*/
|
|
1043
|
+
get isEmpty() {
|
|
1044
|
+
return this.state.selectedKeys !== "all" && this.state.selectedKeys.size === 0;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Whether all items in the collection are selected.
|
|
1048
|
+
*/
|
|
1049
|
+
get isSelectAll() {
|
|
1050
|
+
if (this.isEmpty) return false;
|
|
1051
|
+
if (this.state.selectedKeys === "all") return true;
|
|
1052
|
+
if (this._isSelectAll != null) return this._isSelectAll;
|
|
1053
|
+
let allKeys = this.getSelectAllKeys();
|
|
1054
|
+
let selectedKeys = this.state.selectedKeys;
|
|
1055
|
+
this._isSelectAll = allKeys.every((k) => selectedKeys.has(k));
|
|
1056
|
+
return this._isSelectAll;
|
|
1057
|
+
}
|
|
1058
|
+
get firstSelectedKey() {
|
|
1059
|
+
let first = null;
|
|
1060
|
+
for (let key of this.state.selectedKeys) {
|
|
1061
|
+
let item = this.collection.getItem(key);
|
|
1062
|
+
if (!first || item && (0, $cd5ea4b915021f1d$export$8c434b3a7a4dad6)(this.collection, item, first) < 0) first = item;
|
|
1063
|
+
}
|
|
1064
|
+
return first?.key ?? null;
|
|
1065
|
+
}
|
|
1066
|
+
get lastSelectedKey() {
|
|
1067
|
+
let last = null;
|
|
1068
|
+
for (let key of this.state.selectedKeys) {
|
|
1069
|
+
let item = this.collection.getItem(key);
|
|
1070
|
+
if (!last || item && (0, $cd5ea4b915021f1d$export$8c434b3a7a4dad6)(this.collection, item, last) > 0) last = item;
|
|
1071
|
+
}
|
|
1072
|
+
return last?.key ?? null;
|
|
1073
|
+
}
|
|
1074
|
+
get disabledKeys() {
|
|
1075
|
+
return this.state.disabledKeys;
|
|
1076
|
+
}
|
|
1077
|
+
get disabledBehavior() {
|
|
1078
|
+
return this.state.disabledBehavior;
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* Extends the selection to the given key.
|
|
1082
|
+
*/
|
|
1083
|
+
extendSelection(toKey) {
|
|
1084
|
+
if (this.selectionMode === "none") return;
|
|
1085
|
+
if (this.selectionMode === "single") {
|
|
1086
|
+
this.replaceSelection(toKey);
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
let mappedToKey = this.getKey(toKey);
|
|
1090
|
+
if (mappedToKey == null) return;
|
|
1091
|
+
let selection;
|
|
1092
|
+
if (this.state.selectedKeys === "all") selection = new (0, $8b2540e09867b15e$export$52baac22726c72bf)([
|
|
1093
|
+
mappedToKey
|
|
1094
|
+
], mappedToKey, mappedToKey);
|
|
1095
|
+
else {
|
|
1096
|
+
let selectedKeys = this.state.selectedKeys;
|
|
1097
|
+
let anchorKey = selectedKeys.anchorKey ?? mappedToKey;
|
|
1098
|
+
selection = new (0, $8b2540e09867b15e$export$52baac22726c72bf)(selectedKeys, anchorKey, mappedToKey);
|
|
1099
|
+
for (let key of this.getKeyRange(anchorKey, selectedKeys.currentKey ?? mappedToKey)) selection.delete(key);
|
|
1100
|
+
for (let key of this.getKeyRange(mappedToKey, anchorKey)) if (this.canSelectItem(key)) selection.add(key);
|
|
1101
|
+
}
|
|
1102
|
+
this.state.setSelectedKeys(selection);
|
|
1103
|
+
}
|
|
1104
|
+
getKeyRange(from, to) {
|
|
1105
|
+
let fromItem = this.collection.getItem(from);
|
|
1106
|
+
let toItem = this.collection.getItem(to);
|
|
1107
|
+
if (fromItem && toItem) {
|
|
1108
|
+
if ((0, $cd5ea4b915021f1d$export$8c434b3a7a4dad6)(this.collection, fromItem, toItem) <= 0) return this.getKeyRangeInternal(from, to);
|
|
1109
|
+
return this.getKeyRangeInternal(to, from);
|
|
1110
|
+
}
|
|
1111
|
+
return [];
|
|
1112
|
+
}
|
|
1113
|
+
getKeyRangeInternal(from, to) {
|
|
1114
|
+
if (this.layoutDelegate?.getKeyRange) return this.layoutDelegate.getKeyRange(from, to);
|
|
1115
|
+
let keys = [];
|
|
1116
|
+
let key = from;
|
|
1117
|
+
while (key != null) {
|
|
1118
|
+
let item = this.collection.getItem(key);
|
|
1119
|
+
if (item && (item.type === "item" || item.type === "cell" && this.allowsCellSelection)) keys.push(key);
|
|
1120
|
+
if (key === to) return keys;
|
|
1121
|
+
key = this.collection.getKeyAfter(key);
|
|
1122
|
+
}
|
|
1123
|
+
return [];
|
|
1124
|
+
}
|
|
1125
|
+
getKey(key) {
|
|
1126
|
+
let item = this.collection.getItem(key);
|
|
1127
|
+
if (!item)
|
|
1128
|
+
return key;
|
|
1129
|
+
if (item.type === "cell" && this.allowsCellSelection) return key;
|
|
1130
|
+
while (item && item.type !== "item" && item.parentKey != null) item = this.collection.getItem(item.parentKey);
|
|
1131
|
+
if (!item || item.type !== "item") return null;
|
|
1132
|
+
return item.key;
|
|
1133
|
+
}
|
|
1134
|
+
/**
|
|
1135
|
+
* Toggles whether the given key is selected.
|
|
1136
|
+
*/
|
|
1137
|
+
toggleSelection(key) {
|
|
1138
|
+
if (this.selectionMode === "none") return;
|
|
1139
|
+
if (this.selectionMode === "single" && !this.isSelected(key)) {
|
|
1140
|
+
this.replaceSelection(key);
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
let mappedKey = this.getKey(key);
|
|
1144
|
+
if (mappedKey == null) return;
|
|
1145
|
+
let keys = new (0, $8b2540e09867b15e$export$52baac22726c72bf)(this.state.selectedKeys === "all" ? this.getSelectAllKeys() : this.state.selectedKeys);
|
|
1146
|
+
if (keys.has(mappedKey)) keys.delete(mappedKey);
|
|
1147
|
+
else if (this.canSelectItem(mappedKey)) {
|
|
1148
|
+
keys.add(mappedKey);
|
|
1149
|
+
keys.anchorKey = mappedKey;
|
|
1150
|
+
keys.currentKey = mappedKey;
|
|
1151
|
+
}
|
|
1152
|
+
if (this.disallowEmptySelection && keys.size === 0) return;
|
|
1153
|
+
this.state.setSelectedKeys(keys);
|
|
1154
|
+
}
|
|
1155
|
+
/**
|
|
1156
|
+
* Replaces the selection with only the given key.
|
|
1157
|
+
*/
|
|
1158
|
+
replaceSelection(key) {
|
|
1159
|
+
if (this.selectionMode === "none") return;
|
|
1160
|
+
let mappedKey = this.getKey(key);
|
|
1161
|
+
if (mappedKey == null) return;
|
|
1162
|
+
let selection = this.canSelectItem(mappedKey) ? new (0, $8b2540e09867b15e$export$52baac22726c72bf)([
|
|
1163
|
+
mappedKey
|
|
1164
|
+
], mappedKey, mappedKey) : new (0, $8b2540e09867b15e$export$52baac22726c72bf)();
|
|
1165
|
+
this.state.setSelectedKeys(selection);
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Replaces the selection with the given keys.
|
|
1169
|
+
*/
|
|
1170
|
+
setSelectedKeys(keys) {
|
|
1171
|
+
if (this.selectionMode === "none") return;
|
|
1172
|
+
let selection = new (0, $8b2540e09867b15e$export$52baac22726c72bf)();
|
|
1173
|
+
for (let key of keys) {
|
|
1174
|
+
let mappedKey = this.getKey(key);
|
|
1175
|
+
if (mappedKey != null) {
|
|
1176
|
+
selection.add(mappedKey);
|
|
1177
|
+
if (this.selectionMode === "single") break;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
this.state.setSelectedKeys(selection);
|
|
1181
|
+
}
|
|
1182
|
+
getSelectAllKeys() {
|
|
1183
|
+
let collection = this.fullCollection ?? this.collection;
|
|
1184
|
+
let keys = [];
|
|
1185
|
+
let addKeys = (key) => {
|
|
1186
|
+
while (key != null) {
|
|
1187
|
+
if (this.canSelectItemIn(key, collection)) {
|
|
1188
|
+
let item = collection.getItem(key);
|
|
1189
|
+
if (item?.type === "item") keys.push(key);
|
|
1190
|
+
if (item?.hasChildNodes && (this.allowsCellSelection || item.type !== "item")) addKeys((0, $cd5ea4b915021f1d$export$fbdeaa6a76694f71)((0, $cd5ea4b915021f1d$export$1005530eda016c13)(item, collection))?.key ?? null);
|
|
1191
|
+
}
|
|
1192
|
+
key = collection.getKeyAfter(key);
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
addKeys(collection.getFirstKey());
|
|
1196
|
+
return keys;
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Selects all items in the collection.
|
|
1200
|
+
*/
|
|
1201
|
+
selectAll() {
|
|
1202
|
+
if (!this.isSelectAll && this.selectionMode === "multiple") this.state.setSelectedKeys("all");
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Removes all keys from the selection.
|
|
1206
|
+
*/
|
|
1207
|
+
clearSelection() {
|
|
1208
|
+
if (!this.disallowEmptySelection && (this.state.selectedKeys === "all" || this.state.selectedKeys.size > 0)) this.state.setSelectedKeys(new (0, $8b2540e09867b15e$export$52baac22726c72bf)());
|
|
1209
|
+
}
|
|
1210
|
+
/**
|
|
1211
|
+
* Toggles between select all and an empty selection.
|
|
1212
|
+
*/
|
|
1213
|
+
toggleSelectAll() {
|
|
1214
|
+
if (this.isSelectAll) this.clearSelection();
|
|
1215
|
+
else this.selectAll();
|
|
1216
|
+
}
|
|
1217
|
+
select(key, e) {
|
|
1218
|
+
if (this.selectionMode === "none") return;
|
|
1219
|
+
if (this.selectionMode === "single") {
|
|
1220
|
+
if (this.isSelected(key) && !this.disallowEmptySelection) this.toggleSelection(key);
|
|
1221
|
+
else this.replaceSelection(key);
|
|
1222
|
+
} else if (this.selectionBehavior === "toggle" || e && (e.pointerType === "touch" || e.pointerType === "virtual"))
|
|
1223
|
+
this.toggleSelection(key);
|
|
1224
|
+
else this.replaceSelection(key);
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Returns whether the current selection is equal to the given selection.
|
|
1228
|
+
*/
|
|
1229
|
+
isSelectionEqual(selection) {
|
|
1230
|
+
if (selection === this.state.selectedKeys) return true;
|
|
1231
|
+
let selectedKeys = this.selectedKeys;
|
|
1232
|
+
if (selection.size !== selectedKeys.size) return false;
|
|
1233
|
+
for (let key of selection) {
|
|
1234
|
+
if (!selectedKeys.has(key)) return false;
|
|
1235
|
+
}
|
|
1236
|
+
for (let key of selectedKeys) {
|
|
1237
|
+
if (!selection.has(key)) return false;
|
|
1238
|
+
}
|
|
1239
|
+
return true;
|
|
1240
|
+
}
|
|
1241
|
+
canSelectItem(key) {
|
|
1242
|
+
return this.canSelectItemIn(key, this.collection);
|
|
1243
|
+
}
|
|
1244
|
+
canSelectItemIn(key, collection) {
|
|
1245
|
+
if (this.state.selectionMode === "none" || this.state.disabledKeys.has(key)) return false;
|
|
1246
|
+
let item = collection.getItem(key);
|
|
1247
|
+
if (!item || item?.props?.isDisabled || item.type === "cell" && !this.allowsCellSelection) return false;
|
|
1248
|
+
return true;
|
|
1249
|
+
}
|
|
1250
|
+
isDisabled(key) {
|
|
1251
|
+
return this.state.disabledBehavior === "all" && (this.state.disabledKeys.has(key) || !!this.collection.getItem(key)?.props?.isDisabled);
|
|
1252
|
+
}
|
|
1253
|
+
isLink(key) {
|
|
1254
|
+
return !!this.collection.getItem(key)?.props?.href;
|
|
1255
|
+
}
|
|
1256
|
+
getItemProps(key) {
|
|
1257
|
+
return this.collection.getItem(key)?.props;
|
|
1258
|
+
}
|
|
1259
|
+
withCollection(collection) {
|
|
1260
|
+
return new _$4a07ac835f260f78$export$6c8a5aaad13c9852(collection, this.state, {
|
|
1261
|
+
allowsCellSelection: this.allowsCellSelection,
|
|
1262
|
+
layoutDelegate: this.layoutDelegate || void 0,
|
|
1263
|
+
fullCollection: this.fullCollection ?? this.collection
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
// ../../node_modules/react-stately/dist/private/collections/CollectionBuilder.mjs
|
|
1269
|
+
import $jO8i1$react from "react";
|
|
1270
|
+
var $bda7a7e55e1ff206$export$bf788dd355e3a401 = class {
|
|
1271
|
+
build(props, context) {
|
|
1272
|
+
this.context = context;
|
|
1273
|
+
return $bda7a7e55e1ff206$var$iterable(() => this.iterateCollection(props));
|
|
1274
|
+
}
|
|
1275
|
+
*iterateCollection(props) {
|
|
1276
|
+
let { children, items } = props;
|
|
1277
|
+
if ((0, $jO8i1$react).isValidElement(children) && children.type === (0, $jO8i1$react).Fragment) yield* this.iterateCollection({
|
|
1278
|
+
children: children.props.children,
|
|
1279
|
+
items
|
|
1280
|
+
});
|
|
1281
|
+
else if (typeof children === "function") {
|
|
1282
|
+
if (!items) throw new Error("props.children was a function but props.items is missing");
|
|
1283
|
+
let index = 0;
|
|
1284
|
+
for (let item of items) {
|
|
1285
|
+
yield* this.getFullNode({
|
|
1286
|
+
value: item,
|
|
1287
|
+
index
|
|
1288
|
+
}, {
|
|
1289
|
+
renderer: children
|
|
1290
|
+
});
|
|
1291
|
+
index++;
|
|
1292
|
+
}
|
|
1293
|
+
} else {
|
|
1294
|
+
let items2 = [];
|
|
1295
|
+
(0, $jO8i1$react).Children.forEach(children, (child) => {
|
|
1296
|
+
if (child) items2.push(child);
|
|
1297
|
+
});
|
|
1298
|
+
let index = 0;
|
|
1299
|
+
for (let item of items2) {
|
|
1300
|
+
let nodes = this.getFullNode({
|
|
1301
|
+
element: item,
|
|
1302
|
+
index
|
|
1303
|
+
}, {});
|
|
1304
|
+
for (let node of nodes) {
|
|
1305
|
+
index++;
|
|
1306
|
+
yield node;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
getKey(item, partialNode, state, parentKey) {
|
|
1312
|
+
if (item.key != null) return item.key;
|
|
1313
|
+
if (partialNode.type === "cell" && partialNode.key != null) return `${parentKey}${partialNode.key}`;
|
|
1314
|
+
let v = partialNode.value;
|
|
1315
|
+
if (v != null) {
|
|
1316
|
+
let key = v.key ?? v.id;
|
|
1317
|
+
if (key == null) throw new Error("No key found for item");
|
|
1318
|
+
return key;
|
|
1319
|
+
}
|
|
1320
|
+
return parentKey ? `${parentKey}.${partialNode.index}` : `$.${partialNode.index}`;
|
|
1321
|
+
}
|
|
1322
|
+
getChildState(state, partialNode) {
|
|
1323
|
+
return {
|
|
1324
|
+
renderer: partialNode.renderer || state.renderer
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
*getFullNode(partialNode, state, parentKey, parentNode) {
|
|
1328
|
+
if ((0, $jO8i1$react).isValidElement(partialNode.element) && partialNode.element.type === (0, $jO8i1$react).Fragment) {
|
|
1329
|
+
let children = [];
|
|
1330
|
+
(0, $jO8i1$react).Children.forEach(partialNode.element.props.children, (child) => {
|
|
1331
|
+
children.push(child);
|
|
1332
|
+
});
|
|
1333
|
+
let index = partialNode.index ?? 0;
|
|
1334
|
+
for (const child of children) yield* this.getFullNode({
|
|
1335
|
+
element: child,
|
|
1336
|
+
index: index++
|
|
1337
|
+
}, state, parentKey, parentNode);
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
let element = partialNode.element;
|
|
1341
|
+
if (!element && partialNode.value && state && state.renderer) {
|
|
1342
|
+
let cached = this.cache.get(partialNode.value);
|
|
1343
|
+
if (cached && (!cached.shouldInvalidate || !cached.shouldInvalidate(this.context))) {
|
|
1344
|
+
cached.index = partialNode.index;
|
|
1345
|
+
cached.parentKey = parentNode ? parentNode.key : null;
|
|
1346
|
+
yield cached;
|
|
1347
|
+
return;
|
|
1348
|
+
}
|
|
1349
|
+
element = state.renderer(partialNode.value);
|
|
1350
|
+
}
|
|
1351
|
+
if ((0, $jO8i1$react).isValidElement(element)) {
|
|
1352
|
+
let type = element.type;
|
|
1353
|
+
if (typeof type !== "function" && typeof type.getCollectionNode !== "function") {
|
|
1354
|
+
let name = element.type;
|
|
1355
|
+
throw new Error(`Unknown element <${name}> in collection.`);
|
|
1356
|
+
}
|
|
1357
|
+
let childNodes = type.getCollectionNode(element.props, this.context);
|
|
1358
|
+
let index = partialNode.index ?? 0;
|
|
1359
|
+
let result = childNodes.next();
|
|
1360
|
+
while (!result.done && result.value) {
|
|
1361
|
+
let childNode = result.value;
|
|
1362
|
+
partialNode.index = index;
|
|
1363
|
+
let nodeKey = childNode.key ?? null;
|
|
1364
|
+
if (nodeKey == null) nodeKey = childNode.element ? null : this.getKey(element, partialNode, state, parentKey);
|
|
1365
|
+
let nodes = this.getFullNode({
|
|
1366
|
+
...childNode,
|
|
1367
|
+
key: nodeKey,
|
|
1368
|
+
index,
|
|
1369
|
+
wrapper: $bda7a7e55e1ff206$var$compose(partialNode.wrapper, childNode.wrapper)
|
|
1370
|
+
}, this.getChildState(state, childNode), parentKey ? `${parentKey}${element.key}` : element.key, parentNode);
|
|
1371
|
+
let children = [
|
|
1372
|
+
...nodes
|
|
1373
|
+
];
|
|
1374
|
+
for (let node2 of children) {
|
|
1375
|
+
node2.value = childNode.value ?? partialNode.value ?? null;
|
|
1376
|
+
if (node2.value) this.cache.set(node2.value, node2);
|
|
1377
|
+
if (partialNode.type && node2.type !== partialNode.type) throw new Error(`Unsupported type <${$bda7a7e55e1ff206$var$capitalize(node2.type)}> in <${$bda7a7e55e1ff206$var$capitalize(parentNode?.type ?? "unknown parent type")}>. Only <${$bda7a7e55e1ff206$var$capitalize(partialNode.type)}> is supported.`);
|
|
1378
|
+
index++;
|
|
1379
|
+
yield node2;
|
|
1380
|
+
}
|
|
1381
|
+
result = childNodes.next(children);
|
|
1382
|
+
}
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
if (partialNode.key == null || partialNode.type == null) return;
|
|
1386
|
+
let builder = this;
|
|
1387
|
+
let node = {
|
|
1388
|
+
type: partialNode.type,
|
|
1389
|
+
props: partialNode.props,
|
|
1390
|
+
key: partialNode.key,
|
|
1391
|
+
parentKey: parentNode ? parentNode.key : null,
|
|
1392
|
+
value: partialNode.value ?? null,
|
|
1393
|
+
level: (parentNode?.level ?? 0) + (parentNode?.type === "item" ? 1 : 0),
|
|
1394
|
+
index: partialNode.index,
|
|
1395
|
+
rendered: partialNode.rendered,
|
|
1396
|
+
textValue: partialNode.textValue ?? "",
|
|
1397
|
+
"aria-label": partialNode["aria-label"],
|
|
1398
|
+
wrapper: partialNode.wrapper,
|
|
1399
|
+
shouldInvalidate: partialNode.shouldInvalidate,
|
|
1400
|
+
hasChildNodes: partialNode.hasChildNodes || false,
|
|
1401
|
+
childNodes: $bda7a7e55e1ff206$var$iterable(function* () {
|
|
1402
|
+
if (!partialNode.hasChildNodes || !partialNode.childNodes) return;
|
|
1403
|
+
let index = 0;
|
|
1404
|
+
for (let child of partialNode.childNodes()) {
|
|
1405
|
+
if (child.key != null)
|
|
1406
|
+
child.key = `${node.key}${child.key}`;
|
|
1407
|
+
let nodes = builder.getFullNode({
|
|
1408
|
+
...child,
|
|
1409
|
+
index
|
|
1410
|
+
}, builder.getChildState(state, child), node.key, node);
|
|
1411
|
+
for (let node2 of nodes) {
|
|
1412
|
+
index++;
|
|
1413
|
+
yield node2;
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
})
|
|
1417
|
+
};
|
|
1418
|
+
yield node;
|
|
1419
|
+
}
|
|
1420
|
+
constructor() {
|
|
1421
|
+
this.cache = /* @__PURE__ */ new WeakMap();
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
function $bda7a7e55e1ff206$var$iterable(iterator) {
|
|
1425
|
+
let cache = [];
|
|
1426
|
+
let iterable = null;
|
|
1427
|
+
return {
|
|
1428
|
+
*[Symbol.iterator]() {
|
|
1429
|
+
for (let item of cache) yield item;
|
|
1430
|
+
if (!iterable) iterable = iterator();
|
|
1431
|
+
for (let item of iterable) {
|
|
1432
|
+
cache.push(item);
|
|
1433
|
+
yield item;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
function $bda7a7e55e1ff206$var$compose(outer, inner) {
|
|
1439
|
+
if (outer && inner) return (element) => outer(inner(element));
|
|
1440
|
+
if (outer) return outer;
|
|
1441
|
+
if (inner) return inner;
|
|
1442
|
+
}
|
|
1443
|
+
function $bda7a7e55e1ff206$var$capitalize(str) {
|
|
1444
|
+
return str[0].toUpperCase() + str.slice(1);
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
// ../../node_modules/react-stately/dist/private/collections/useCollection.mjs
|
|
1448
|
+
import { useMemo as $emYU7$useMemo } from "react";
|
|
1449
|
+
function $d03379b88399b8c5$export$6cd28814d92fa9c9(props, factory, context) {
|
|
1450
|
+
let builder = (0, $emYU7$useMemo)(() => new (0, $bda7a7e55e1ff206$export$bf788dd355e3a401)(), []);
|
|
1451
|
+
let { children, items, collection } = props;
|
|
1452
|
+
let result = (0, $emYU7$useMemo)(() => {
|
|
1453
|
+
if (collection) return collection;
|
|
1454
|
+
let nodes = builder.build({
|
|
1455
|
+
children,
|
|
1456
|
+
items
|
|
1457
|
+
}, context);
|
|
1458
|
+
return factory(nodes);
|
|
1459
|
+
}, [
|
|
1460
|
+
builder,
|
|
1461
|
+
children,
|
|
1462
|
+
items,
|
|
1463
|
+
collection,
|
|
1464
|
+
context,
|
|
1465
|
+
factory
|
|
1466
|
+
]);
|
|
1467
|
+
return result;
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
// ../../node_modules/react-stately/dist/private/list/useListState.mjs
|
|
1471
|
+
import { useMemo as $3yt54$useMemo, useCallback as $3yt54$useCallback, useRef as $3yt54$useRef, useEffect as $3yt54$useEffect } from "react";
|
|
1472
|
+
function $b14b6f590b50af39$export$2f645645f7bca764(props) {
|
|
1473
|
+
let { filter, layoutDelegate } = props;
|
|
1474
|
+
let selectionState = (0, $60f19cefd567a3e4$export$253fe78d46329472)(props);
|
|
1475
|
+
let disabledKeys = (0, $3yt54$useMemo)(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
|
|
1476
|
+
props.disabledKeys
|
|
1477
|
+
]);
|
|
1478
|
+
let factory = (0, $3yt54$useCallback)((nodes) => filter ? new (0, $f664a81d022446b5$export$d085fb9e920b5ca7)(filter(nodes)) : new (0, $f664a81d022446b5$export$d085fb9e920b5ca7)(nodes), [
|
|
1479
|
+
filter
|
|
1480
|
+
]);
|
|
1481
|
+
let context = (0, $3yt54$useMemo)(() => ({
|
|
1482
|
+
suppressTextValueWarning: props.suppressTextValueWarning
|
|
1483
|
+
}), [
|
|
1484
|
+
props.suppressTextValueWarning
|
|
1485
|
+
]);
|
|
1486
|
+
let collection = (0, $d03379b88399b8c5$export$6cd28814d92fa9c9)(props, factory, context);
|
|
1487
|
+
let selectionManager = (0, $3yt54$useMemo)(() => new (0, $4a07ac835f260f78$export$6c8a5aaad13c9852)(collection, selectionState, {
|
|
1488
|
+
layoutDelegate
|
|
1489
|
+
}), [
|
|
1490
|
+
collection,
|
|
1491
|
+
selectionState,
|
|
1492
|
+
layoutDelegate
|
|
1493
|
+
]);
|
|
1494
|
+
$b14b6f590b50af39$var$useFocusedKeyReset(collection, selectionManager);
|
|
1495
|
+
return {
|
|
1496
|
+
collection,
|
|
1497
|
+
disabledKeys,
|
|
1498
|
+
selectionManager
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
function $b14b6f590b50af39$var$useFocusedKeyReset(collection, selectionManager) {
|
|
1502
|
+
const cachedCollection = (0, $3yt54$useRef)(null);
|
|
1503
|
+
(0, $3yt54$useEffect)(() => {
|
|
1504
|
+
if (selectionManager.focusedKey != null && !collection.getItem(selectionManager.focusedKey) && cachedCollection.current) {
|
|
1505
|
+
let key = cachedCollection.current.getKeyAfter(selectionManager.focusedKey);
|
|
1506
|
+
let nextFocusedKey = null;
|
|
1507
|
+
while (key != null) {
|
|
1508
|
+
let node = collection.getItem(key);
|
|
1509
|
+
if (node && node.type === "item" && !selectionManager.isDisabled(key)) {
|
|
1510
|
+
nextFocusedKey = key;
|
|
1511
|
+
break;
|
|
1512
|
+
}
|
|
1513
|
+
key = cachedCollection.current.getKeyAfter(key);
|
|
1514
|
+
}
|
|
1515
|
+
if (nextFocusedKey == null) {
|
|
1516
|
+
key = cachedCollection.current.getKeyBefore(selectionManager.focusedKey);
|
|
1517
|
+
while (key != null) {
|
|
1518
|
+
let node = collection.getItem(key);
|
|
1519
|
+
if (node && node.type === "item" && !selectionManager.isDisabled(key)) {
|
|
1520
|
+
nextFocusedKey = key;
|
|
1521
|
+
break;
|
|
1522
|
+
}
|
|
1523
|
+
key = cachedCollection.current.getKeyBefore(key);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
selectionManager.setFocusedKey(nextFocusedKey);
|
|
1527
|
+
}
|
|
1528
|
+
cachedCollection.current = collection;
|
|
1529
|
+
}, [
|
|
1530
|
+
collection,
|
|
1531
|
+
selectionManager
|
|
1532
|
+
]);
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
// ../../node_modules/react-stately/dist/private/overlays/useOverlayTriggerState.mjs
|
|
1536
|
+
import { useCallback as $kE40A$useCallback } from "react";
|
|
1537
|
+
function $f11fb0bcf1b2687a$export$61c6a8c84e605fb6(props) {
|
|
1538
|
+
let [isOpen, setOpen] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.isOpen, props.defaultOpen || false, props.onOpenChange);
|
|
1539
|
+
const open = (0, $kE40A$useCallback)(() => {
|
|
1540
|
+
setOpen(true);
|
|
1541
|
+
}, [
|
|
1542
|
+
setOpen
|
|
1543
|
+
]);
|
|
1544
|
+
const close = (0, $kE40A$useCallback)(() => {
|
|
1545
|
+
setOpen(false);
|
|
1546
|
+
}, [
|
|
1547
|
+
setOpen
|
|
1548
|
+
]);
|
|
1549
|
+
const toggle = (0, $kE40A$useCallback)(() => {
|
|
1550
|
+
setOpen(!isOpen);
|
|
1551
|
+
}, [
|
|
1552
|
+
setOpen,
|
|
1553
|
+
isOpen
|
|
1554
|
+
]);
|
|
1555
|
+
return {
|
|
1556
|
+
isOpen,
|
|
1557
|
+
setOpen,
|
|
1558
|
+
open,
|
|
1559
|
+
close,
|
|
1560
|
+
toggle
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
// ../../node_modules/react-stately/dist/private/collections/Item.mjs
|
|
1565
|
+
import $dJmKC$react from "react";
|
|
1566
|
+
function $05678f3aee5e7d1a$var$Item(props) {
|
|
1567
|
+
return null;
|
|
1568
|
+
}
|
|
1569
|
+
$05678f3aee5e7d1a$var$Item.getCollectionNode = function* getCollectionNode(props, context) {
|
|
1570
|
+
let { childItems, title, children } = props;
|
|
1571
|
+
let rendered = props.title || props.children;
|
|
1572
|
+
let textValue = props.textValue || (typeof rendered === "string" ? rendered : "") || props["aria-label"] || "";
|
|
1573
|
+
if (!textValue && !context?.suppressTextValueWarning && process.env.NODE_ENV !== "production") console.warn("<Item> with non-plain text contents is unsupported by type to select for accessibility. Please add a `textValue` prop.");
|
|
1574
|
+
yield {
|
|
1575
|
+
type: "item",
|
|
1576
|
+
props,
|
|
1577
|
+
rendered,
|
|
1578
|
+
textValue,
|
|
1579
|
+
"aria-label": props["aria-label"],
|
|
1580
|
+
hasChildNodes: $05678f3aee5e7d1a$var$hasChildItems(props),
|
|
1581
|
+
*childNodes() {
|
|
1582
|
+
if (childItems) for (let child of childItems) yield {
|
|
1583
|
+
type: "item",
|
|
1584
|
+
value: child
|
|
1585
|
+
};
|
|
1586
|
+
else if (title) {
|
|
1587
|
+
let items = [];
|
|
1588
|
+
(0, $dJmKC$react).Children.forEach(children, (child) => {
|
|
1589
|
+
items.push({
|
|
1590
|
+
type: "item",
|
|
1591
|
+
element: child
|
|
1592
|
+
});
|
|
1593
|
+
});
|
|
1594
|
+
yield* items;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
};
|
|
1599
|
+
function $05678f3aee5e7d1a$var$hasChildItems(props) {
|
|
1600
|
+
if (props.hasChildItems != null) return props.hasChildItems;
|
|
1601
|
+
if (props.childItems) return true;
|
|
1602
|
+
if (props.title && (0, $dJmKC$react).Children.count(props.children) > 0) return true;
|
|
1603
|
+
return false;
|
|
1604
|
+
}
|
|
1605
|
+
var $05678f3aee5e7d1a$export$6d08773d2e66f8f2 = $05678f3aee5e7d1a$var$Item;
|
|
1606
|
+
|
|
1607
|
+
// ../../node_modules/react-stately/dist/private/list/useSingleSelectListState.mjs
|
|
1608
|
+
import { useMemo as $jhfZc$useMemo } from "react";
|
|
1609
|
+
function $0fdb127d377ffd84$export$e7f05e985daf4b5f(props) {
|
|
1610
|
+
let [selectedKey, setSelectedKey] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.selectedKey, props.defaultSelectedKey ?? null, props.onSelectionChange);
|
|
1611
|
+
let selectedKeys = (0, $jhfZc$useMemo)(() => selectedKey != null ? [
|
|
1612
|
+
selectedKey
|
|
1613
|
+
] : [], [
|
|
1614
|
+
selectedKey
|
|
1615
|
+
]);
|
|
1616
|
+
let { collection, disabledKeys, selectionManager } = (0, $b14b6f590b50af39$export$2f645645f7bca764)({
|
|
1617
|
+
...props,
|
|
1618
|
+
selectionMode: "single",
|
|
1619
|
+
disallowEmptySelection: true,
|
|
1620
|
+
allowDuplicateSelectionEvents: true,
|
|
1621
|
+
selectedKeys,
|
|
1622
|
+
onSelectionChange: (keys) => {
|
|
1623
|
+
if (keys === "all") return;
|
|
1624
|
+
let key = keys.values().next().value ?? null;
|
|
1625
|
+
if (key === selectedKey && props.onSelectionChange) props.onSelectionChange(key);
|
|
1626
|
+
setSelectedKey(key);
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
let selectedItem = selectedKey != null ? collection.getItem(selectedKey) : null;
|
|
1630
|
+
return {
|
|
1631
|
+
collection,
|
|
1632
|
+
disabledKeys,
|
|
1633
|
+
selectionManager,
|
|
1634
|
+
selectedKey,
|
|
1635
|
+
setSelectedKey,
|
|
1636
|
+
selectedItem
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// ../../node_modules/react-stately/dist/private/menu/useMenuTriggerState.mjs
|
|
1641
|
+
import { useState as $aoDK0$useState } from "react";
|
|
1642
|
+
function $e3403870bfb691da$export$79fefeb1c2091ac3(props) {
|
|
1643
|
+
let overlayTriggerState = (0, $f11fb0bcf1b2687a$export$61c6a8c84e605fb6)(props);
|
|
1644
|
+
let [focusStrategy, setFocusStrategy] = (0, $aoDK0$useState)(null);
|
|
1645
|
+
let [expandedKeysStack, setExpandedKeysStack] = (0, $aoDK0$useState)([]);
|
|
1646
|
+
let closeAll = () => {
|
|
1647
|
+
setExpandedKeysStack([]);
|
|
1648
|
+
overlayTriggerState.close();
|
|
1649
|
+
};
|
|
1650
|
+
let openSubmenu = (triggerKey, level) => {
|
|
1651
|
+
setExpandedKeysStack((oldStack) => {
|
|
1652
|
+
if (level > oldStack.length) return oldStack;
|
|
1653
|
+
return [
|
|
1654
|
+
...oldStack.slice(0, level),
|
|
1655
|
+
triggerKey
|
|
1656
|
+
];
|
|
1657
|
+
});
|
|
1658
|
+
};
|
|
1659
|
+
let closeSubmenu = (triggerKey, level) => {
|
|
1660
|
+
setExpandedKeysStack((oldStack) => {
|
|
1661
|
+
let key = oldStack[level];
|
|
1662
|
+
if (key === triggerKey) return oldStack.slice(0, level);
|
|
1663
|
+
else return oldStack;
|
|
1664
|
+
});
|
|
1665
|
+
};
|
|
1666
|
+
return {
|
|
1667
|
+
focusStrategy,
|
|
1668
|
+
...overlayTriggerState,
|
|
1669
|
+
open(focusStrategy2 = null) {
|
|
1670
|
+
setFocusStrategy(focusStrategy2);
|
|
1671
|
+
overlayTriggerState.open();
|
|
1672
|
+
},
|
|
1673
|
+
toggle(focusStrategy2 = null) {
|
|
1674
|
+
setFocusStrategy(focusStrategy2);
|
|
1675
|
+
overlayTriggerState.toggle();
|
|
1676
|
+
},
|
|
1677
|
+
close() {
|
|
1678
|
+
closeAll();
|
|
1679
|
+
},
|
|
1680
|
+
expandedKeysStack,
|
|
1681
|
+
openSubmenu,
|
|
1682
|
+
closeSubmenu
|
|
1683
|
+
};
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
// ../../node_modules/react-stately/dist/private/radio/useRadioGroupState.mjs
|
|
1687
|
+
import { useMemo as $6Hs9a$useMemo, useState as $6Hs9a$useState } from "react";
|
|
1688
|
+
var $384704861d32dbed$var$instance = Math.round(Math.random() * 1e10);
|
|
1689
|
+
var $384704861d32dbed$var$i = 0;
|
|
1690
|
+
function $384704861d32dbed$export$bca9d026f8e704eb(props) {
|
|
1691
|
+
let name = (0, $6Hs9a$useMemo)(() => props.name || `radio-group-${$384704861d32dbed$var$instance}-${++$384704861d32dbed$var$i}`, [
|
|
1692
|
+
props.name
|
|
1693
|
+
]);
|
|
1694
|
+
let [selectedValue, setSelected] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.value, props.defaultValue ?? null, props.onChange);
|
|
1695
|
+
let [initialValue] = (0, $6Hs9a$useState)(selectedValue);
|
|
1696
|
+
let [lastFocusedValue, setLastFocusedValue] = (0, $6Hs9a$useState)(null);
|
|
1697
|
+
let validation = (0, $fd2148440a13ec26$export$fc1a364ae1f3ff10)({
|
|
1698
|
+
...props,
|
|
1699
|
+
value: selectedValue
|
|
1700
|
+
});
|
|
1701
|
+
let setSelectedValue = (value) => {
|
|
1702
|
+
if (!props.isReadOnly && !props.isDisabled) {
|
|
1703
|
+
setSelected(value);
|
|
1704
|
+
validation.commitValidation();
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
let isInvalid = validation.displayValidation.isInvalid;
|
|
1708
|
+
return {
|
|
1709
|
+
...validation,
|
|
1710
|
+
name,
|
|
1711
|
+
selectedValue,
|
|
1712
|
+
defaultSelectedValue: props.value !== void 0 ? initialValue : props.defaultValue ?? null,
|
|
1713
|
+
setSelectedValue,
|
|
1714
|
+
lastFocusedValue,
|
|
1715
|
+
setLastFocusedValue,
|
|
1716
|
+
isDisabled: props.isDisabled || false,
|
|
1717
|
+
isReadOnly: props.isReadOnly || false,
|
|
1718
|
+
isRequired: props.isRequired || false,
|
|
1719
|
+
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
1720
|
+
isInvalid
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
// ../../node_modules/react-stately/dist/private/select/useSelectState.mjs
|
|
1725
|
+
import { useState as $5t5rb$useState, useMemo as $5t5rb$useMemo } from "react";
|
|
1726
|
+
function $29256f53a2edafe9$export$5159ec8b34d4ec12(props) {
|
|
1727
|
+
let { selectionMode = "single", shouldCloseOnSelect = selectionMode === "single" } = props;
|
|
1728
|
+
let triggerState = (0, $f11fb0bcf1b2687a$export$61c6a8c84e605fb6)(props);
|
|
1729
|
+
let [focusStrategy, setFocusStrategy] = (0, $5t5rb$useState)(null);
|
|
1730
|
+
let defaultValue = (0, $5t5rb$useMemo)(() => {
|
|
1731
|
+
return props.defaultValue !== void 0 ? props.defaultValue : selectionMode === "single" ? props.defaultSelectedKey ?? null : [];
|
|
1732
|
+
}, [
|
|
1733
|
+
props.defaultValue,
|
|
1734
|
+
props.defaultSelectedKey,
|
|
1735
|
+
selectionMode
|
|
1736
|
+
]);
|
|
1737
|
+
let value = (0, $5t5rb$useMemo)(() => {
|
|
1738
|
+
return props.value !== void 0 ? props.value : selectionMode === "single" ? props.selectedKey : void 0;
|
|
1739
|
+
}, [
|
|
1740
|
+
props.value,
|
|
1741
|
+
props.selectedKey,
|
|
1742
|
+
selectionMode
|
|
1743
|
+
]);
|
|
1744
|
+
let [controlledValue, setControlledValue] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(value, defaultValue, props.onChange);
|
|
1745
|
+
let displayValue = selectionMode === "single" && Array.isArray(controlledValue) ? controlledValue[0] : controlledValue;
|
|
1746
|
+
let setValue = (value2) => {
|
|
1747
|
+
if (selectionMode === "single") {
|
|
1748
|
+
let key = Array.isArray(value2) ? value2[0] ?? null : value2;
|
|
1749
|
+
setControlledValue(key);
|
|
1750
|
+
if (key !== displayValue) props.onSelectionChange?.(key);
|
|
1751
|
+
} else {
|
|
1752
|
+
let keys = [];
|
|
1753
|
+
if (Array.isArray(value2)) keys = value2;
|
|
1754
|
+
else if (value2 != null) keys = [
|
|
1755
|
+
value2
|
|
1756
|
+
];
|
|
1757
|
+
setControlledValue(keys);
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
let listState = (0, $b14b6f590b50af39$export$2f645645f7bca764)({
|
|
1761
|
+
...props,
|
|
1762
|
+
selectionMode,
|
|
1763
|
+
disallowEmptySelection: selectionMode === "single",
|
|
1764
|
+
allowDuplicateSelectionEvents: true,
|
|
1765
|
+
selectedKeys: (0, $5t5rb$useMemo)(() => $29256f53a2edafe9$var$convertValue(displayValue), [
|
|
1766
|
+
displayValue
|
|
1767
|
+
]),
|
|
1768
|
+
onSelectionChange: (keys) => {
|
|
1769
|
+
if (keys === "all") return;
|
|
1770
|
+
if (selectionMode === "single") {
|
|
1771
|
+
let key = keys.values().next().value ?? null;
|
|
1772
|
+
setValue(key);
|
|
1773
|
+
} else setValue([
|
|
1774
|
+
...keys
|
|
1775
|
+
]);
|
|
1776
|
+
if (shouldCloseOnSelect) triggerState.close();
|
|
1777
|
+
validationState.commitValidation();
|
|
1778
|
+
}
|
|
1779
|
+
});
|
|
1780
|
+
let selectedKey = listState.selectionManager.firstSelectedKey;
|
|
1781
|
+
let selectedItems = (0, $5t5rb$useMemo)(() => {
|
|
1782
|
+
return [
|
|
1783
|
+
...listState.selectionManager.selectedKeys
|
|
1784
|
+
].map((key) => listState.collection.getItem(key)).filter((item) => item != null);
|
|
1785
|
+
}, [
|
|
1786
|
+
listState.selectionManager.selectedKeys,
|
|
1787
|
+
listState.collection
|
|
1788
|
+
]);
|
|
1789
|
+
let validationState = (0, $fd2148440a13ec26$export$fc1a364ae1f3ff10)({
|
|
1790
|
+
...props,
|
|
1791
|
+
value: Array.isArray(displayValue) && displayValue.length === 0 ? null : displayValue
|
|
1792
|
+
});
|
|
1793
|
+
let [isFocused, setFocused] = (0, $5t5rb$useState)(false);
|
|
1794
|
+
let [initialValue] = (0, $5t5rb$useState)(displayValue);
|
|
1795
|
+
return {
|
|
1796
|
+
...validationState,
|
|
1797
|
+
...listState,
|
|
1798
|
+
...triggerState,
|
|
1799
|
+
value: displayValue,
|
|
1800
|
+
defaultValue: defaultValue ?? initialValue,
|
|
1801
|
+
setValue,
|
|
1802
|
+
selectedKey,
|
|
1803
|
+
setSelectedKey: setValue,
|
|
1804
|
+
selectedItem: selectedItems[0] ?? null,
|
|
1805
|
+
selectedItems,
|
|
1806
|
+
defaultSelectedKey: props.defaultSelectedKey ?? (props.selectionMode === "single" ? initialValue : null),
|
|
1807
|
+
focusStrategy,
|
|
1808
|
+
open(focusStrategy2 = null) {
|
|
1809
|
+
if (listState.collection.size !== 0 || props.allowsEmptyCollection) {
|
|
1810
|
+
setFocusStrategy(focusStrategy2);
|
|
1811
|
+
triggerState.open();
|
|
1812
|
+
}
|
|
1813
|
+
},
|
|
1814
|
+
toggle(focusStrategy2 = null) {
|
|
1815
|
+
if (listState.collection.size !== 0 || props.allowsEmptyCollection) {
|
|
1816
|
+
setFocusStrategy(focusStrategy2);
|
|
1817
|
+
triggerState.toggle();
|
|
1818
|
+
}
|
|
1819
|
+
},
|
|
1820
|
+
isFocused,
|
|
1821
|
+
setFocused
|
|
1822
|
+
};
|
|
1823
|
+
}
|
|
1824
|
+
function $29256f53a2edafe9$var$convertValue(value) {
|
|
1825
|
+
if (value === void 0) return void 0;
|
|
1826
|
+
if (value === null) return [];
|
|
1827
|
+
return Array.isArray(value) ? value : [
|
|
1828
|
+
value
|
|
1829
|
+
];
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
// ../../node_modules/react-stately/dist/private/tabs/useTabListState.mjs
|
|
1833
|
+
import { useRef as $eOo4G$useRef, useEffect as $eOo4G$useEffect } from "react";
|
|
1834
|
+
function $caeb030f09a278a1$export$4ba071daf4e486(props) {
|
|
1835
|
+
let state = (0, $0fdb127d377ffd84$export$e7f05e985daf4b5f)({
|
|
1836
|
+
...props,
|
|
1837
|
+
onSelectionChange: props.onSelectionChange ? (key) => {
|
|
1838
|
+
if (key != null) props.onSelectionChange?.(key);
|
|
1839
|
+
} : void 0,
|
|
1840
|
+
suppressTextValueWarning: true,
|
|
1841
|
+
defaultSelectedKey: props.defaultSelectedKey ?? $caeb030f09a278a1$var$findDefaultSelectedKey(props.collection, props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set()) ?? void 0
|
|
1842
|
+
});
|
|
1843
|
+
let { selectionManager, collection, selectedKey: currentSelectedKey } = state;
|
|
1844
|
+
let lastSelectedKey = (0, $eOo4G$useRef)(currentSelectedKey);
|
|
1845
|
+
(0, $eOo4G$useEffect)(() => {
|
|
1846
|
+
let selectedKey = currentSelectedKey;
|
|
1847
|
+
if (props.selectedKey == null && (selectionManager.isEmpty || selectedKey == null || !collection.getItem(selectedKey))) {
|
|
1848
|
+
selectedKey = $caeb030f09a278a1$var$findDefaultSelectedKey(collection, state.disabledKeys);
|
|
1849
|
+
if (selectedKey != null)
|
|
1850
|
+
selectionManager.setSelectedKeys([
|
|
1851
|
+
selectedKey
|
|
1852
|
+
]);
|
|
1853
|
+
}
|
|
1854
|
+
if (selectedKey != null && selectionManager.focusedKey == null || !selectionManager.isFocused && selectedKey !== lastSelectedKey.current) selectionManager.setFocusedKey(selectedKey);
|
|
1855
|
+
lastSelectedKey.current = selectedKey;
|
|
1856
|
+
});
|
|
1857
|
+
return {
|
|
1858
|
+
...state,
|
|
1859
|
+
isDisabled: props.isDisabled || false
|
|
1860
|
+
};
|
|
1861
|
+
}
|
|
1862
|
+
function $caeb030f09a278a1$var$findDefaultSelectedKey(collection, disabledKeys) {
|
|
1863
|
+
let selectedKey = null;
|
|
1864
|
+
if (collection) {
|
|
1865
|
+
selectedKey = collection.getFirstKey();
|
|
1866
|
+
while (selectedKey != null && (disabledKeys.has(selectedKey) || collection.getItem(selectedKey)?.props?.isDisabled) && selectedKey !== collection.getLastKey()) selectedKey = collection.getKeyAfter(selectedKey);
|
|
1867
|
+
if (selectedKey != null && (disabledKeys.has(selectedKey) || collection.getItem(selectedKey)?.props?.isDisabled) && selectedKey === collection.getLastKey()) selectedKey = collection.getFirstKey();
|
|
1868
|
+
}
|
|
1869
|
+
return selectedKey;
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
// ../../node_modules/react-stately/dist/private/toggle/useToggleState.mjs
|
|
1873
|
+
import { useState as $dAajM$useState } from "react";
|
|
1874
|
+
function $fd3c5e01e837dc20$export$8042c6c013fd5226(props = {}) {
|
|
1875
|
+
let { isReadOnly } = props;
|
|
1876
|
+
let [isSelected, setSelected] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.isSelected, props.defaultSelected || false, props.onChange);
|
|
1877
|
+
let [initialValue] = (0, $dAajM$useState)(isSelected);
|
|
1878
|
+
function updateSelected(value) {
|
|
1879
|
+
if (!isReadOnly) setSelected(value);
|
|
1880
|
+
}
|
|
1881
|
+
function toggleState() {
|
|
1882
|
+
if (!isReadOnly) setSelected(!isSelected);
|
|
1883
|
+
}
|
|
1884
|
+
return {
|
|
1885
|
+
isSelected,
|
|
1886
|
+
defaultSelected: props.defaultSelected ?? initialValue,
|
|
1887
|
+
setSelected: updateSelected,
|
|
1888
|
+
toggle: toggleState
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
// ../../node_modules/react-stately/dist/private/tooltip/useTooltipTriggerState.mjs
|
|
1893
|
+
import { useMemo as $auOuY$useMemo, useRef as $auOuY$useRef, useEffect as $auOuY$useEffect } from "react";
|
|
1894
|
+
var $3834487504f4fc00$var$TOOLTIP_DELAY = 1500;
|
|
1895
|
+
var $3834487504f4fc00$var$TOOLTIP_COOLDOWN = 500;
|
|
1896
|
+
var $3834487504f4fc00$var$tooltips = {};
|
|
1897
|
+
var $3834487504f4fc00$var$tooltipId = 0;
|
|
1898
|
+
var $3834487504f4fc00$var$globalWarmedUp = false;
|
|
1899
|
+
var $3834487504f4fc00$var$globalWarmUpTimeout = null;
|
|
1900
|
+
var $3834487504f4fc00$var$globalCooldownTimeout = null;
|
|
1901
|
+
function $3834487504f4fc00$export$4d40659c25ecb50b(props = {}) {
|
|
1902
|
+
let { delay = $3834487504f4fc00$var$TOOLTIP_DELAY, closeDelay = $3834487504f4fc00$var$TOOLTIP_COOLDOWN } = props;
|
|
1903
|
+
let { isOpen, open, close } = (0, $f11fb0bcf1b2687a$export$61c6a8c84e605fb6)(props);
|
|
1904
|
+
let id = (0, $auOuY$useMemo)(() => `${++$3834487504f4fc00$var$tooltipId}`, []);
|
|
1905
|
+
let closeTimeout = (0, $auOuY$useRef)(null);
|
|
1906
|
+
let closeCallback = (0, $auOuY$useRef)(close);
|
|
1907
|
+
let ensureTooltipEntry = () => {
|
|
1908
|
+
$3834487504f4fc00$var$tooltips[id] = hideTooltip;
|
|
1909
|
+
};
|
|
1910
|
+
let closeOpenTooltips = () => {
|
|
1911
|
+
for (let hideTooltipId in $3834487504f4fc00$var$tooltips) if (hideTooltipId !== id) {
|
|
1912
|
+
$3834487504f4fc00$var$tooltips[hideTooltipId](true);
|
|
1913
|
+
delete $3834487504f4fc00$var$tooltips[hideTooltipId];
|
|
1914
|
+
}
|
|
1915
|
+
};
|
|
1916
|
+
let showTooltip = () => {
|
|
1917
|
+
if (closeTimeout.current) clearTimeout(closeTimeout.current);
|
|
1918
|
+
closeTimeout.current = null;
|
|
1919
|
+
closeOpenTooltips();
|
|
1920
|
+
ensureTooltipEntry();
|
|
1921
|
+
$3834487504f4fc00$var$globalWarmedUp = true;
|
|
1922
|
+
open();
|
|
1923
|
+
if ($3834487504f4fc00$var$globalWarmUpTimeout) {
|
|
1924
|
+
clearTimeout($3834487504f4fc00$var$globalWarmUpTimeout);
|
|
1925
|
+
$3834487504f4fc00$var$globalWarmUpTimeout = null;
|
|
1926
|
+
}
|
|
1927
|
+
if ($3834487504f4fc00$var$globalCooldownTimeout) {
|
|
1928
|
+
clearTimeout($3834487504f4fc00$var$globalCooldownTimeout);
|
|
1929
|
+
$3834487504f4fc00$var$globalCooldownTimeout = null;
|
|
1930
|
+
}
|
|
1931
|
+
};
|
|
1932
|
+
let hideTooltip = (immediate) => {
|
|
1933
|
+
if (immediate || closeDelay <= 0) {
|
|
1934
|
+
if (closeTimeout.current) clearTimeout(closeTimeout.current);
|
|
1935
|
+
closeTimeout.current = null;
|
|
1936
|
+
closeCallback.current();
|
|
1937
|
+
} else if (!closeTimeout.current) closeTimeout.current = setTimeout(() => {
|
|
1938
|
+
closeTimeout.current = null;
|
|
1939
|
+
closeCallback.current();
|
|
1940
|
+
}, closeDelay);
|
|
1941
|
+
if ($3834487504f4fc00$var$globalWarmUpTimeout) {
|
|
1942
|
+
clearTimeout($3834487504f4fc00$var$globalWarmUpTimeout);
|
|
1943
|
+
$3834487504f4fc00$var$globalWarmUpTimeout = null;
|
|
1944
|
+
}
|
|
1945
|
+
if ($3834487504f4fc00$var$globalWarmedUp) {
|
|
1946
|
+
if ($3834487504f4fc00$var$globalCooldownTimeout) clearTimeout($3834487504f4fc00$var$globalCooldownTimeout);
|
|
1947
|
+
$3834487504f4fc00$var$globalCooldownTimeout = setTimeout(() => {
|
|
1948
|
+
delete $3834487504f4fc00$var$tooltips[id];
|
|
1949
|
+
$3834487504f4fc00$var$globalCooldownTimeout = null;
|
|
1950
|
+
$3834487504f4fc00$var$globalWarmedUp = false;
|
|
1951
|
+
}, Math.max($3834487504f4fc00$var$TOOLTIP_COOLDOWN, closeDelay));
|
|
1952
|
+
}
|
|
1953
|
+
};
|
|
1954
|
+
let warmupTooltip = () => {
|
|
1955
|
+
closeOpenTooltips();
|
|
1956
|
+
ensureTooltipEntry();
|
|
1957
|
+
if (!isOpen && !$3834487504f4fc00$var$globalWarmedUp) {
|
|
1958
|
+
if ($3834487504f4fc00$var$globalWarmUpTimeout) clearTimeout($3834487504f4fc00$var$globalWarmUpTimeout);
|
|
1959
|
+
$3834487504f4fc00$var$globalWarmUpTimeout = setTimeout(() => {
|
|
1960
|
+
$3834487504f4fc00$var$globalWarmUpTimeout = null;
|
|
1961
|
+
$3834487504f4fc00$var$globalWarmedUp = true;
|
|
1962
|
+
showTooltip();
|
|
1963
|
+
}, delay);
|
|
1964
|
+
} else if (!isOpen) showTooltip();
|
|
1965
|
+
};
|
|
1966
|
+
(0, $auOuY$useEffect)(() => {
|
|
1967
|
+
closeCallback.current = close;
|
|
1968
|
+
}, [
|
|
1969
|
+
close
|
|
1970
|
+
]);
|
|
1971
|
+
(0, $auOuY$useEffect)(() => {
|
|
1972
|
+
return () => {
|
|
1973
|
+
if (closeTimeout.current) clearTimeout(closeTimeout.current);
|
|
1974
|
+
let tooltip = $3834487504f4fc00$var$tooltips[id];
|
|
1975
|
+
if (tooltip) delete $3834487504f4fc00$var$tooltips[id];
|
|
1976
|
+
};
|
|
1977
|
+
}, [
|
|
1978
|
+
id
|
|
1979
|
+
]);
|
|
1980
|
+
return {
|
|
1981
|
+
isOpen,
|
|
1982
|
+
open: (immediate) => {
|
|
1983
|
+
if (!immediate && delay > 0 && !closeTimeout.current) warmupTooltip();
|
|
1984
|
+
else showTooltip();
|
|
1985
|
+
},
|
|
1986
|
+
close: hideTooltip
|
|
1987
|
+
};
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
// ../../node_modules/react-stately/dist/private/tree/TreeCollection.mjs
|
|
1991
|
+
var $df1fcc684d3b021a$export$863faf230ee2118a = class {
|
|
1992
|
+
constructor(nodes, { expandedKeys } = {}) {
|
|
1993
|
+
this.keyMap = /* @__PURE__ */ new Map();
|
|
1994
|
+
this.firstKey = null;
|
|
1995
|
+
this.lastKey = null;
|
|
1996
|
+
this.iterable = nodes;
|
|
1997
|
+
expandedKeys = expandedKeys || /* @__PURE__ */ new Set();
|
|
1998
|
+
let visit = (node) => {
|
|
1999
|
+
this.keyMap.set(node.key, node);
|
|
2000
|
+
if (node.childNodes && (node.type === "section" || expandedKeys.has(node.key))) for (let child of node.childNodes) visit(child);
|
|
2001
|
+
};
|
|
2002
|
+
for (let node of nodes) visit(node);
|
|
2003
|
+
let last = null;
|
|
2004
|
+
let index = 0;
|
|
2005
|
+
for (let [key, node] of this.keyMap) {
|
|
2006
|
+
if (last) {
|
|
2007
|
+
last.nextKey = key;
|
|
2008
|
+
node.prevKey = last.key;
|
|
2009
|
+
} else {
|
|
2010
|
+
this.firstKey = key;
|
|
2011
|
+
node.prevKey = void 0;
|
|
2012
|
+
}
|
|
2013
|
+
if (node.type === "item") node.index = index++;
|
|
2014
|
+
last = node;
|
|
2015
|
+
last.nextKey = void 0;
|
|
2016
|
+
}
|
|
2017
|
+
this.lastKey = last?.key ?? null;
|
|
2018
|
+
}
|
|
2019
|
+
*[Symbol.iterator]() {
|
|
2020
|
+
yield* this.iterable;
|
|
2021
|
+
}
|
|
2022
|
+
get size() {
|
|
2023
|
+
return this.keyMap.size;
|
|
2024
|
+
}
|
|
2025
|
+
getKeys() {
|
|
2026
|
+
return this.keyMap.keys();
|
|
2027
|
+
}
|
|
2028
|
+
getKeyBefore(key) {
|
|
2029
|
+
let node = this.keyMap.get(key);
|
|
2030
|
+
return node ? node.prevKey ?? null : null;
|
|
2031
|
+
}
|
|
2032
|
+
getKeyAfter(key) {
|
|
2033
|
+
let node = this.keyMap.get(key);
|
|
2034
|
+
return node ? node.nextKey ?? null : null;
|
|
2035
|
+
}
|
|
2036
|
+
getFirstKey() {
|
|
2037
|
+
return this.firstKey;
|
|
2038
|
+
}
|
|
2039
|
+
getLastKey() {
|
|
2040
|
+
return this.lastKey;
|
|
2041
|
+
}
|
|
2042
|
+
getItem(key) {
|
|
2043
|
+
return this.keyMap.get(key) ?? null;
|
|
2044
|
+
}
|
|
2045
|
+
at(idx) {
|
|
2046
|
+
const keys = [
|
|
2047
|
+
...this.getKeys()
|
|
2048
|
+
];
|
|
2049
|
+
return this.getItem(keys[idx]);
|
|
2050
|
+
}
|
|
2051
|
+
};
|
|
2052
|
+
|
|
2053
|
+
// ../../node_modules/react-stately/dist/private/tree/useTreeState.mjs
|
|
2054
|
+
import { useMemo as $aXIpm$useMemo, useCallback as $aXIpm$useCallback, useEffect as $aXIpm$useEffect } from "react";
|
|
2055
|
+
function $6b915bde6cd300dd$export$728d6ba534403756(props) {
|
|
2056
|
+
let { onExpandedChange } = props;
|
|
2057
|
+
let [expandedKeys, setExpandedKeys] = (0, $3e6197669829fe11$export$40bfa8c7b0832715)(props.expandedKeys ? new Set(props.expandedKeys) : void 0, props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : /* @__PURE__ */ new Set(), onExpandedChange);
|
|
2058
|
+
let selectionState = (0, $60f19cefd567a3e4$export$253fe78d46329472)(props);
|
|
2059
|
+
let disabledKeys = (0, $aXIpm$useMemo)(() => props.disabledKeys ? new Set(props.disabledKeys) : /* @__PURE__ */ new Set(), [
|
|
2060
|
+
props.disabledKeys
|
|
2061
|
+
]);
|
|
2062
|
+
let tree = (0, $d03379b88399b8c5$export$6cd28814d92fa9c9)(props, (0, $aXIpm$useCallback)((nodes) => new (0, $df1fcc684d3b021a$export$863faf230ee2118a)(nodes, {
|
|
2063
|
+
expandedKeys
|
|
2064
|
+
}), [
|
|
2065
|
+
expandedKeys
|
|
2066
|
+
]), null);
|
|
2067
|
+
(0, $aXIpm$useEffect)(() => {
|
|
2068
|
+
if (selectionState.focusedKey != null && !tree.getItem(selectionState.focusedKey)) selectionState.setFocusedKey(null);
|
|
2069
|
+
}, [
|
|
2070
|
+
tree,
|
|
2071
|
+
selectionState.focusedKey
|
|
2072
|
+
]);
|
|
2073
|
+
let onToggle = (key) => {
|
|
2074
|
+
setExpandedKeys($6b915bde6cd300dd$var$toggleKey(expandedKeys, key));
|
|
2075
|
+
};
|
|
2076
|
+
return {
|
|
2077
|
+
collection: tree,
|
|
2078
|
+
expandedKeys,
|
|
2079
|
+
disabledKeys,
|
|
2080
|
+
toggleKey: onToggle,
|
|
2081
|
+
setExpandedKeys,
|
|
2082
|
+
selectionManager: new (0, $4a07ac835f260f78$export$6c8a5aaad13c9852)(tree, selectionState)
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2085
|
+
function $6b915bde6cd300dd$var$toggleKey(set, key) {
|
|
2086
|
+
let res = new Set(set);
|
|
2087
|
+
if (res.has(key)) res.delete(key);
|
|
2088
|
+
else res.add(key);
|
|
2089
|
+
return res;
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
// src/components/Tooltip/Tooltip.tsx
|
|
2093
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2094
|
+
var FLIP = {
|
|
2095
|
+
top: "bottom",
|
|
2096
|
+
bottom: "top",
|
|
2097
|
+
left: "right",
|
|
2098
|
+
right: "left"
|
|
2099
|
+
};
|
|
2100
|
+
function placeOn(rect, tipRect, position, offset) {
|
|
2101
|
+
const cx = rect.left + rect.width / 2;
|
|
2102
|
+
const cy = rect.top + rect.height / 2;
|
|
2103
|
+
switch (position) {
|
|
2104
|
+
case "top":
|
|
2105
|
+
return {
|
|
2106
|
+
top: rect.top - tipRect.height - offset,
|
|
2107
|
+
left: cx - tipRect.width / 2
|
|
2108
|
+
};
|
|
2109
|
+
case "bottom":
|
|
2110
|
+
return { top: rect.bottom + offset, left: cx - tipRect.width / 2 };
|
|
2111
|
+
case "left":
|
|
2112
|
+
return {
|
|
2113
|
+
top: cy - tipRect.height / 2,
|
|
2114
|
+
left: rect.left - tipRect.width - offset
|
|
2115
|
+
};
|
|
2116
|
+
case "right":
|
|
2117
|
+
return { top: cy - tipRect.height / 2, left: rect.right + offset };
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
function computePosition(rect, tipRect, position, offset, viewport) {
|
|
2121
|
+
const tryAt = (p) => {
|
|
2122
|
+
const c = placeOn(rect, tipRect, p, offset);
|
|
2123
|
+
const fits = c.top >= 0 && c.left >= 0 && c.top + tipRect.height <= viewport.height && c.left + tipRect.width <= viewport.width;
|
|
2124
|
+
return { ...c, position: p, fits };
|
|
2125
|
+
};
|
|
2126
|
+
const preferred = tryAt(position);
|
|
2127
|
+
if (preferred.fits) return preferred;
|
|
2128
|
+
const flipped = tryAt(FLIP[position]);
|
|
2129
|
+
if (flipped.fits) return flipped;
|
|
2130
|
+
const fallback = preferred;
|
|
2131
|
+
const clampedLeft = Math.max(
|
|
2132
|
+
4,
|
|
2133
|
+
Math.min(fallback.left, viewport.width - tipRect.width - 4)
|
|
2134
|
+
);
|
|
2135
|
+
const clampedTop = Math.max(
|
|
2136
|
+
4,
|
|
2137
|
+
Math.min(fallback.top, viewport.height - tipRect.height - 4)
|
|
2138
|
+
);
|
|
2139
|
+
return { top: clampedTop, left: clampedLeft, position: fallback.position };
|
|
2140
|
+
}
|
|
2141
|
+
var animVariants = {
|
|
2142
|
+
top: { initial: { opacity: 0, y: 4 }, animate: { opacity: 1, y: 0 } },
|
|
2143
|
+
bottom: { initial: { opacity: 0, y: -4 }, animate: { opacity: 1, y: 0 } },
|
|
2144
|
+
left: { initial: { opacity: 0, x: 4 }, animate: { opacity: 1, x: 0 } },
|
|
2145
|
+
right: { initial: { opacity: 0, x: -4 }, animate: { opacity: 1, x: 0 } }
|
|
2146
|
+
};
|
|
2147
|
+
function TooltipContent({
|
|
2148
|
+
state,
|
|
2149
|
+
content,
|
|
2150
|
+
position,
|
|
2151
|
+
triggerRef,
|
|
2152
|
+
className,
|
|
2153
|
+
offset,
|
|
2154
|
+
tooltipId
|
|
2155
|
+
}) {
|
|
2156
|
+
const { tooltipProps } = useTooltip({ isOpen: state.isOpen }, state);
|
|
2157
|
+
const tipRef = useRef3(null);
|
|
2158
|
+
const [coords, setCoords] = useState2(null);
|
|
2159
|
+
const reposition = useCallback2(() => {
|
|
2160
|
+
if (!triggerRef.current || !tipRef.current) return;
|
|
2161
|
+
const trigRect = triggerRef.current.getBoundingClientRect();
|
|
2162
|
+
const tipRect = tipRef.current.getBoundingClientRect();
|
|
2163
|
+
const viewport = {
|
|
2164
|
+
width: window.innerWidth || document.documentElement.clientWidth,
|
|
2165
|
+
height: window.innerHeight || document.documentElement.clientHeight
|
|
2166
|
+
};
|
|
2167
|
+
setCoords(computePosition(trigRect, tipRect, position, offset, viewport));
|
|
2168
|
+
}, [triggerRef, position, offset]);
|
|
2169
|
+
useLayoutEffect(() => {
|
|
2170
|
+
if (!state.isOpen) return;
|
|
2171
|
+
reposition();
|
|
2172
|
+
const id = requestAnimationFrame(reposition);
|
|
2173
|
+
return () => cancelAnimationFrame(id);
|
|
2174
|
+
}, [state.isOpen, reposition]);
|
|
2175
|
+
useEffect(() => {
|
|
2176
|
+
if (!state.isOpen) return;
|
|
2177
|
+
const handler = () => reposition();
|
|
2178
|
+
window.addEventListener("scroll", handler, true);
|
|
2179
|
+
window.addEventListener("resize", handler);
|
|
2180
|
+
return () => {
|
|
2181
|
+
window.removeEventListener("scroll", handler, true);
|
|
2182
|
+
window.removeEventListener("resize", handler);
|
|
2183
|
+
};
|
|
2184
|
+
}, [state.isOpen, reposition]);
|
|
2185
|
+
const resolvedPos = coords?.position ?? position;
|
|
2186
|
+
const variants = animVariants[resolvedPos];
|
|
2187
|
+
const {
|
|
2188
|
+
onDrag: _onDrag,
|
|
2189
|
+
onDragStart: _onDragStart,
|
|
2190
|
+
onDragEnd: _onDragEnd,
|
|
2191
|
+
onAnimationStart: _onAnimationStart,
|
|
2192
|
+
...safeTipProps
|
|
2193
|
+
} = tooltipProps;
|
|
2194
|
+
const portalContent = /* @__PURE__ */ jsx4(AnimatePresence2, { children: state.isOpen && /* @__PURE__ */ jsx4(
|
|
2195
|
+
"div",
|
|
2196
|
+
{
|
|
2197
|
+
className: "ods-tooltip__wrapper",
|
|
2198
|
+
style: {
|
|
2199
|
+
position: "fixed",
|
|
2200
|
+
zIndex: 1500,
|
|
2201
|
+
top: coords?.top ?? -9999,
|
|
2202
|
+
left: coords?.left ?? -9999,
|
|
2203
|
+
visibility: coords ? "visible" : "hidden",
|
|
2204
|
+
pointerEvents: "none"
|
|
2205
|
+
},
|
|
2206
|
+
children: /* @__PURE__ */ jsxs4(
|
|
2207
|
+
motion3.div,
|
|
2208
|
+
{
|
|
2209
|
+
ref: tipRef,
|
|
2210
|
+
...safeTipProps,
|
|
2211
|
+
id: tooltipId,
|
|
2212
|
+
role: "tooltip",
|
|
2213
|
+
"data-position": resolvedPos,
|
|
2214
|
+
className: cn("ods-tooltip", className),
|
|
2215
|
+
initial: variants.initial,
|
|
2216
|
+
animate: variants.animate,
|
|
2217
|
+
exit: { opacity: 0 },
|
|
2218
|
+
transition: { duration: 0.15, ease: "easeOut" },
|
|
2219
|
+
children: [
|
|
2220
|
+
content,
|
|
2221
|
+
/* @__PURE__ */ jsx4("span", { className: "ods-tooltip__arrow", "aria-hidden": "true" })
|
|
2222
|
+
]
|
|
2223
|
+
}
|
|
2224
|
+
)
|
|
2225
|
+
}
|
|
2226
|
+
) });
|
|
2227
|
+
if (typeof document === "undefined") return null;
|
|
2228
|
+
return createPortal(portalContent, document.body);
|
|
2229
|
+
}
|
|
2230
|
+
function mergeRefs(...refs) {
|
|
2231
|
+
return (node) => {
|
|
2232
|
+
for (const r of refs) {
|
|
2233
|
+
if (!r) continue;
|
|
2234
|
+
if (typeof r === "function") r(node);
|
|
2235
|
+
else r.current = node;
|
|
2236
|
+
}
|
|
2237
|
+
};
|
|
2238
|
+
}
|
|
2239
|
+
function mergeHandler(childHandler, ariaHandler) {
|
|
2240
|
+
if (!childHandler && !ariaHandler) return void 0;
|
|
2241
|
+
return (e) => {
|
|
2242
|
+
childHandler?.(e);
|
|
2243
|
+
if (!e.defaultPrevented) ariaHandler?.(e);
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
function Tooltip({
|
|
2247
|
+
content,
|
|
2248
|
+
position = "top",
|
|
2249
|
+
delay = 200,
|
|
2250
|
+
offset = 8,
|
|
2251
|
+
disabled = false,
|
|
2252
|
+
id: providedId,
|
|
2253
|
+
children,
|
|
2254
|
+
className
|
|
2255
|
+
}) {
|
|
2256
|
+
const reactId = useId3();
|
|
2257
|
+
const tooltipId = providedId ?? `ods-tooltip-${reactId}`;
|
|
2258
|
+
const triggerRef = useRef3(null);
|
|
2259
|
+
const state = $3834487504f4fc00$export$4d40659c25ecb50b({ delay });
|
|
2260
|
+
const { triggerProps } = useTooltipTrigger(
|
|
2261
|
+
{ delay, isDisabled: disabled },
|
|
2262
|
+
state,
|
|
2263
|
+
triggerRef
|
|
2264
|
+
);
|
|
2265
|
+
if (!isValidElement3(children)) {
|
|
2266
|
+
return /* @__PURE__ */ jsx4(Fragment, { children });
|
|
2267
|
+
}
|
|
2268
|
+
const childProps = children.props;
|
|
2269
|
+
const childRef = childProps.ref ?? children.ref;
|
|
2270
|
+
const merged = { ...childProps };
|
|
2271
|
+
for (const [key, value] of Object.entries(
|
|
2272
|
+
triggerProps
|
|
2273
|
+
)) {
|
|
2274
|
+
if (key.startsWith("on") && typeof value === "function") {
|
|
2275
|
+
merged[key] = mergeHandler(
|
|
2276
|
+
childProps[key],
|
|
2277
|
+
value
|
|
2278
|
+
);
|
|
2279
|
+
} else {
|
|
2280
|
+
merged[key] = value;
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
merged.ref = mergeRefs(triggerRef, childRef);
|
|
2284
|
+
merged["aria-describedby"] = [childProps["aria-describedby"], tooltipId].filter(Boolean).join(" ");
|
|
2285
|
+
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
2286
|
+
cloneElement2(children, merged),
|
|
2287
|
+
!disabled && /* @__PURE__ */ jsx4(
|
|
2288
|
+
TooltipContent,
|
|
2289
|
+
{
|
|
2290
|
+
state,
|
|
2291
|
+
content,
|
|
2292
|
+
position,
|
|
2293
|
+
triggerRef,
|
|
2294
|
+
offset,
|
|
2295
|
+
className,
|
|
2296
|
+
tooltipId
|
|
2297
|
+
}
|
|
2298
|
+
)
|
|
2299
|
+
] });
|
|
2300
|
+
}
|
|
2301
|
+
Tooltip.displayName = "Tooltip";
|
|
2302
|
+
|
|
2303
|
+
// src/components/Select/Select.tsx
|
|
2304
|
+
import { AnimatePresence as AnimatePresence3, motion as motion4 } from "framer-motion";
|
|
2305
|
+
import {
|
|
2306
|
+
forwardRef as forwardRef5,
|
|
2307
|
+
useCallback as useCallback3,
|
|
2308
|
+
useEffect as useEffect2,
|
|
2309
|
+
useId as useId4,
|
|
2310
|
+
useMemo,
|
|
2311
|
+
useRef as useRef4,
|
|
2312
|
+
useState as useState3
|
|
2313
|
+
} from "react";
|
|
2314
|
+
import { HiddenSelect, useButton as useButton2, useListBox, useOption, useSelect } from "react-aria";
|
|
2315
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
2316
|
+
import { CheckmarkIcon, ChevronDownIcon as ChevronDownIcon2 } from "@octaviaflow/icons";
|
|
2317
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2318
|
+
function OverflowTooltip({
|
|
2319
|
+
enabled,
|
|
2320
|
+
content,
|
|
2321
|
+
children
|
|
2322
|
+
}) {
|
|
2323
|
+
if (!enabled || content == null || content === "") return children;
|
|
2324
|
+
return /* @__PURE__ */ jsx5(Tooltip, { content, children });
|
|
2325
|
+
}
|
|
2326
|
+
function ListBox(props) {
|
|
2327
|
+
const ref = useRef4(null);
|
|
2328
|
+
const {
|
|
2329
|
+
listBoxRef = ref,
|
|
2330
|
+
state,
|
|
2331
|
+
showCheckmark,
|
|
2332
|
+
showOverflowTooltips
|
|
2333
|
+
} = props;
|
|
2334
|
+
const { listBoxProps } = useListBox(props, state, listBoxRef);
|
|
2335
|
+
return /* @__PURE__ */ jsx5("ul", { ...listBoxProps, ref: listBoxRef, className: "ods-select__options", children: [...state.collection].map((item) => /* @__PURE__ */ jsx5(
|
|
2336
|
+
Option,
|
|
2337
|
+
{
|
|
2338
|
+
item,
|
|
2339
|
+
state,
|
|
2340
|
+
showCheckmark,
|
|
2341
|
+
showOverflowTooltips
|
|
2342
|
+
},
|
|
2343
|
+
item.key
|
|
2344
|
+
)) });
|
|
2345
|
+
}
|
|
2346
|
+
function Option({
|
|
2347
|
+
item,
|
|
2348
|
+
state,
|
|
2349
|
+
showCheckmark,
|
|
2350
|
+
showOverflowTooltips
|
|
2351
|
+
}) {
|
|
2352
|
+
const ref = useRef4(null);
|
|
2353
|
+
const { optionProps, isSelected, isFocused, isDisabled } = useOption(
|
|
2354
|
+
{ key: item.key },
|
|
2355
|
+
state,
|
|
2356
|
+
ref
|
|
2357
|
+
);
|
|
2358
|
+
const raw = item.value;
|
|
2359
|
+
const option = raw?.value ?? raw;
|
|
2360
|
+
const tooltipContent = option?.description ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
2361
|
+
/* @__PURE__ */ jsx5("span", { children: option.label }),
|
|
2362
|
+
/* @__PURE__ */ jsx5("br", {}),
|
|
2363
|
+
/* @__PURE__ */ jsx5("span", { style: { opacity: 0.75 }, children: option.description })
|
|
2364
|
+
] }) : option?.label;
|
|
2365
|
+
return /* @__PURE__ */ jsx5(
|
|
2366
|
+
OverflowTooltip,
|
|
2367
|
+
{
|
|
2368
|
+
enabled: !!showOverflowTooltips,
|
|
2369
|
+
content: tooltipContent,
|
|
2370
|
+
children: /* @__PURE__ */ jsxs5(
|
|
2371
|
+
"li",
|
|
2372
|
+
{
|
|
2373
|
+
...optionProps,
|
|
2374
|
+
ref,
|
|
2375
|
+
className: cn(
|
|
2376
|
+
"ods-select__option",
|
|
2377
|
+
isFocused && "ods-select__option--highlighted",
|
|
2378
|
+
isSelected && "ods-select__option--selected",
|
|
2379
|
+
isDisabled && "ods-select__option--disabled"
|
|
2380
|
+
),
|
|
2381
|
+
children: [
|
|
2382
|
+
option?.icon && /* @__PURE__ */ jsx5("span", { className: "ods-select__option-icon", children: option.icon }),
|
|
2383
|
+
/* @__PURE__ */ jsxs5("span", { className: "ods-select__option-text", children: [
|
|
2384
|
+
/* @__PURE__ */ jsx5("span", { className: "ods-select__option-label", children: item.rendered }),
|
|
2385
|
+
option?.description && /* @__PURE__ */ jsx5("span", { className: "ods-select__option-desc", children: option.description })
|
|
2386
|
+
] }),
|
|
2387
|
+
isSelected && showCheckmark && /* @__PURE__ */ jsx5("span", { className: "ods-select__check", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(CheckmarkIcon, { size: "xs", tone: "accent" }) })
|
|
2388
|
+
]
|
|
2389
|
+
}
|
|
2390
|
+
)
|
|
2391
|
+
}
|
|
2392
|
+
);
|
|
2393
|
+
}
|
|
2394
|
+
var DEFAULT_SELECT_PLACEHOLDER = "Select an option...";
|
|
2395
|
+
var Select = forwardRef5(function Select2({
|
|
2396
|
+
options,
|
|
2397
|
+
value,
|
|
2398
|
+
defaultValue,
|
|
2399
|
+
onChange,
|
|
2400
|
+
placeholder = DEFAULT_SELECT_PLACEHOLDER,
|
|
2401
|
+
searchable = false,
|
|
2402
|
+
label,
|
|
2403
|
+
error = false,
|
|
2404
|
+
errorMessage,
|
|
2405
|
+
helperText,
|
|
2406
|
+
disabled = false,
|
|
2407
|
+
size = "md",
|
|
2408
|
+
className,
|
|
2409
|
+
name,
|
|
2410
|
+
required,
|
|
2411
|
+
id: providedId,
|
|
2412
|
+
form,
|
|
2413
|
+
autoFocus,
|
|
2414
|
+
"aria-label": ariaLabel,
|
|
2415
|
+
"aria-labelledby": ariaLabelledBy,
|
|
2416
|
+
"aria-describedby": consumerDescribedBy,
|
|
2417
|
+
showCheckmark = false,
|
|
2418
|
+
closeOnOutsideClick = true,
|
|
2419
|
+
showOverflowTooltips = false,
|
|
2420
|
+
dropdownMinWidth
|
|
2421
|
+
}, forwardedRef) {
|
|
2422
|
+
const triggerRef = useRef4(null);
|
|
2423
|
+
const listBoxRef = useRef4(null);
|
|
2424
|
+
const dropdownRef = useRef4(null);
|
|
2425
|
+
const searchRef = useRef4(null);
|
|
2426
|
+
const [searchQuery, setSearchQuery] = useState3("");
|
|
2427
|
+
const [dropdownPos, setDropdownPos] = useState3({ left: 0, width: 0, maxHeight: 240, direction: "down" });
|
|
2428
|
+
const setTriggerRef = (node) => {
|
|
2429
|
+
triggerRef.current = node;
|
|
2430
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
2431
|
+
else if (forwardedRef)
|
|
2432
|
+
forwardedRef.current = node;
|
|
2433
|
+
};
|
|
2434
|
+
const reactId = useId4();
|
|
2435
|
+
const baseId = providedId ?? `ods-select-${reactId}`;
|
|
2436
|
+
const hintId = error || helperText ? `${baseId}-hint` : void 0;
|
|
2437
|
+
const describedBy = [consumerDescribedBy, hintId].filter(Boolean).join(" ") || void 0;
|
|
2438
|
+
const filteredOptions = useMemo(() => {
|
|
2439
|
+
if (!searchable || !searchQuery) return options;
|
|
2440
|
+
const q = searchQuery.toLowerCase();
|
|
2441
|
+
return options.filter(
|
|
2442
|
+
(o) => o.label.toLowerCase().includes(q) || o.description?.toLowerCase().includes(q)
|
|
2443
|
+
);
|
|
2444
|
+
}, [options, searchQuery, searchable]);
|
|
2445
|
+
const ariaNameProps = useMemo(
|
|
2446
|
+
() => resolveAccessibleName({
|
|
2447
|
+
label,
|
|
2448
|
+
ariaLabel,
|
|
2449
|
+
ariaLabelledby: ariaLabelledBy,
|
|
2450
|
+
componentName: "Select",
|
|
2451
|
+
fallbacks: [
|
|
2452
|
+
placeholder && placeholder !== DEFAULT_SELECT_PLACEHOLDER ? placeholder : void 0
|
|
2453
|
+
]
|
|
2454
|
+
}),
|
|
2455
|
+
[label, ariaLabel, ariaLabelledBy, placeholder]
|
|
2456
|
+
);
|
|
2457
|
+
const ariaProps = useMemo(() => {
|
|
2458
|
+
const items = filteredOptions.map((o) => ({
|
|
2459
|
+
key: o.value,
|
|
2460
|
+
label: o.label,
|
|
2461
|
+
value: o,
|
|
2462
|
+
isDisabled: o.disabled
|
|
2463
|
+
}));
|
|
2464
|
+
const props = {
|
|
2465
|
+
// Visible string label when present; otherwise rely on the aria-*
|
|
2466
|
+
// props for screen-reader name.
|
|
2467
|
+
label: typeof label === "string" ? label : void 0,
|
|
2468
|
+
...ariaNameProps,
|
|
2469
|
+
items,
|
|
2470
|
+
children: (item) => /* @__PURE__ */ jsx5($05678f3aee5e7d1a$export$6d08773d2e66f8f2, { textValue: item.label, children: item.label }, item.key),
|
|
2471
|
+
isDisabled: disabled,
|
|
2472
|
+
onSelectionChange: (key) => {
|
|
2473
|
+
onChange?.(String(key));
|
|
2474
|
+
setSearchQuery("");
|
|
2475
|
+
}
|
|
2476
|
+
};
|
|
2477
|
+
if (value !== void 0) {
|
|
2478
|
+
props.selectedKey = value;
|
|
2479
|
+
}
|
|
2480
|
+
if (defaultValue !== void 0) {
|
|
2481
|
+
props.defaultSelectedKey = defaultValue;
|
|
2482
|
+
}
|
|
2483
|
+
return props;
|
|
2484
|
+
}, [filteredOptions, label, disabled, value, defaultValue, onChange, ariaNameProps]);
|
|
2485
|
+
const state = $29256f53a2edafe9$export$5159ec8b34d4ec12(ariaProps);
|
|
2486
|
+
const { triggerProps, menuProps } = useSelect(ariaProps, state, triggerRef);
|
|
2487
|
+
const { buttonProps } = useButton2(triggerProps, triggerRef);
|
|
2488
|
+
const updatePosition = useCallback3(() => {
|
|
2489
|
+
if (!triggerRef.current) return;
|
|
2490
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
2491
|
+
const viewportH = window.innerHeight;
|
|
2492
|
+
const margin = 8;
|
|
2493
|
+
const gap = 4;
|
|
2494
|
+
const spaceBelow = viewportH - rect.bottom - gap - margin;
|
|
2495
|
+
const spaceAbove = rect.top - gap - margin;
|
|
2496
|
+
const PREFERRED_MIN = 200;
|
|
2497
|
+
const openUp = spaceBelow < PREFERRED_MIN && spaceAbove > spaceBelow;
|
|
2498
|
+
setDropdownPos({
|
|
2499
|
+
...openUp ? { bottom: viewportH - rect.top + gap } : { top: rect.bottom + gap },
|
|
2500
|
+
left: rect.left,
|
|
2501
|
+
width: rect.width,
|
|
2502
|
+
maxHeight: Math.max(120, openUp ? spaceAbove : spaceBelow),
|
|
2503
|
+
direction: openUp ? "up" : "down"
|
|
2504
|
+
});
|
|
2505
|
+
}, []);
|
|
2506
|
+
useEffect2(() => {
|
|
2507
|
+
if (state.isOpen) {
|
|
2508
|
+
updatePosition();
|
|
2509
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
2510
|
+
window.addEventListener("resize", updatePosition);
|
|
2511
|
+
return () => {
|
|
2512
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
2513
|
+
window.removeEventListener("resize", updatePosition);
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
}, [state.isOpen, updatePosition]);
|
|
2517
|
+
useEffect2(() => {
|
|
2518
|
+
if (state.isOpen && searchable && searchRef.current) {
|
|
2519
|
+
requestAnimationFrame(() => searchRef.current?.focus());
|
|
2520
|
+
}
|
|
2521
|
+
}, [state.isOpen, searchable]);
|
|
2522
|
+
useEffect2(() => {
|
|
2523
|
+
if (!state.isOpen || !closeOnOutsideClick) return;
|
|
2524
|
+
const onPointer = (e) => {
|
|
2525
|
+
const target = e.target;
|
|
2526
|
+
if (dropdownRef.current?.contains(target)) return;
|
|
2527
|
+
if (triggerRef.current?.contains(target)) return;
|
|
2528
|
+
state.close();
|
|
2529
|
+
};
|
|
2530
|
+
const onKey = (e) => {
|
|
2531
|
+
if (e.key === "Escape") state.close();
|
|
2532
|
+
};
|
|
2533
|
+
document.addEventListener("mousedown", onPointer);
|
|
2534
|
+
document.addEventListener("keydown", onKey);
|
|
2535
|
+
return () => {
|
|
2536
|
+
document.removeEventListener("mousedown", onPointer);
|
|
2537
|
+
document.removeEventListener("keydown", onKey);
|
|
2538
|
+
};
|
|
2539
|
+
}, [state.isOpen, state.close, closeOnOutsideClick]);
|
|
2540
|
+
const selectedOption = options.find((o) => o.value === String(state.selectedKey ?? ""));
|
|
2541
|
+
const wasOpenBeforePressRef = useRef4(false);
|
|
2542
|
+
const handleTriggerPointerDown = (e) => {
|
|
2543
|
+
wasOpenBeforePressRef.current = state.isOpen;
|
|
2544
|
+
const baseHandler = buttonProps.onPointerDown;
|
|
2545
|
+
baseHandler?.(e);
|
|
2546
|
+
};
|
|
2547
|
+
const handleTriggerClick = (e) => {
|
|
2548
|
+
const baseHandler = buttonProps.onClick;
|
|
2549
|
+
baseHandler?.(e);
|
|
2550
|
+
if (wasOpenBeforePressRef.current && state.isOpen) {
|
|
2551
|
+
state.close();
|
|
2552
|
+
}
|
|
2553
|
+
wasOpenBeforePressRef.current = false;
|
|
2554
|
+
};
|
|
2555
|
+
return /* @__PURE__ */ jsxs5(
|
|
2556
|
+
"div",
|
|
2557
|
+
{
|
|
2558
|
+
className: cn(
|
|
2559
|
+
"ods-select",
|
|
2560
|
+
`ods-select--${size}`,
|
|
2561
|
+
error && "ods-select--error",
|
|
2562
|
+
disabled && "ods-select--disabled",
|
|
2563
|
+
className
|
|
2564
|
+
),
|
|
2565
|
+
children: [
|
|
2566
|
+
label && /* @__PURE__ */ jsx5("label", { className: "ods-select__label", htmlFor: baseId, children: label }),
|
|
2567
|
+
/* @__PURE__ */ jsx5(HiddenSelect, { state, triggerRef, label, name }),
|
|
2568
|
+
/* @__PURE__ */ jsxs5(
|
|
2569
|
+
"button",
|
|
2570
|
+
{
|
|
2571
|
+
...buttonProps,
|
|
2572
|
+
onPointerDown: handleTriggerPointerDown,
|
|
2573
|
+
onClick: handleTriggerClick,
|
|
2574
|
+
ref: setTriggerRef,
|
|
2575
|
+
id: baseId,
|
|
2576
|
+
form,
|
|
2577
|
+
autoFocus,
|
|
2578
|
+
"aria-label": ariaLabel,
|
|
2579
|
+
"aria-labelledby": ariaLabelledBy,
|
|
2580
|
+
"aria-describedby": describedBy,
|
|
2581
|
+
"aria-required": required || void 0,
|
|
2582
|
+
"aria-invalid": error ? true : void 0,
|
|
2583
|
+
className: cn("ods-select__trigger", state.isOpen && "ods-select__trigger--open"),
|
|
2584
|
+
children: [
|
|
2585
|
+
/* @__PURE__ */ jsx5("span", { className: "ods-select__value", children: selectedOption ? /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
2586
|
+
selectedOption.icon && /* @__PURE__ */ jsx5("span", { className: "ods-select__value-icon", children: selectedOption.icon }),
|
|
2587
|
+
selectedOption.label
|
|
2588
|
+
] }) : /* @__PURE__ */ jsx5("span", { className: "ods-select__placeholder", children: placeholder }) }),
|
|
2589
|
+
/* @__PURE__ */ jsx5(
|
|
2590
|
+
"span",
|
|
2591
|
+
{
|
|
2592
|
+
className: cn(
|
|
2593
|
+
"ods-select__chevron",
|
|
2594
|
+
state.isOpen && "ods-select__chevron--open"
|
|
2595
|
+
),
|
|
2596
|
+
"aria-hidden": "true",
|
|
2597
|
+
children: /* @__PURE__ */ jsx5(ChevronDownIcon2, { size: "xs" })
|
|
2598
|
+
}
|
|
2599
|
+
)
|
|
2600
|
+
]
|
|
2601
|
+
}
|
|
2602
|
+
),
|
|
2603
|
+
typeof document !== "undefined" && createPortal2(
|
|
2604
|
+
/* @__PURE__ */ jsx5(AnimatePresence3, { children: state.isOpen && /* @__PURE__ */ jsxs5(
|
|
2605
|
+
motion4.div,
|
|
2606
|
+
{
|
|
2607
|
+
ref: dropdownRef,
|
|
2608
|
+
className: "ods-select__dropdown",
|
|
2609
|
+
style: {
|
|
2610
|
+
position: "fixed",
|
|
2611
|
+
...dropdownPos.top !== void 0 && { top: dropdownPos.top },
|
|
2612
|
+
...dropdownPos.bottom !== void 0 && { bottom: dropdownPos.bottom },
|
|
2613
|
+
left: dropdownPos.left,
|
|
2614
|
+
// `minWidth` (not `width`) keeps the popover at
|
|
2615
|
+
// least as wide as the trigger — preserves visual
|
|
2616
|
+
// alignment — but allows the consumer to widen it
|
|
2617
|
+
// explicitly when option labels demand more room
|
|
2618
|
+
// (pass `dropdownMinWidth` to set a higher floor).
|
|
2619
|
+
// Avoids the previous `max-content` recipe which
|
|
2620
|
+
// made the popover grow uncomfortably wide on
|
|
2621
|
+
// searchable / long-option menus.
|
|
2622
|
+
minWidth: Math.max(dropdownPos.width, dropdownMinWidth ?? 0),
|
|
2623
|
+
// Bound the popover to the available viewport edge so
|
|
2624
|
+
// it never spills off-screen on tall pages. Pairs with
|
|
2625
|
+
// `overflow-y: auto` from the .ods-select__dropdown
|
|
2626
|
+
// SCSS so long option lists scroll internally.
|
|
2627
|
+
maxHeight: dropdownPos.maxHeight
|
|
2628
|
+
},
|
|
2629
|
+
initial: { opacity: 0, scale: 0.95 },
|
|
2630
|
+
animate: { opacity: 1, scale: 1 },
|
|
2631
|
+
exit: { opacity: 0, scale: 0.95 },
|
|
2632
|
+
transition: { duration: 0.2, ease: [0.16, 1, 0.3, 1] },
|
|
2633
|
+
children: [
|
|
2634
|
+
searchable && /* @__PURE__ */ jsx5("div", { className: "ods-select__search-wrap", children: /* @__PURE__ */ jsx5(
|
|
2635
|
+
"input",
|
|
2636
|
+
{
|
|
2637
|
+
ref: searchRef,
|
|
2638
|
+
className: "ods-select__search",
|
|
2639
|
+
type: "text",
|
|
2640
|
+
placeholder: "Search...",
|
|
2641
|
+
value: searchQuery,
|
|
2642
|
+
onChange: (e) => setSearchQuery(e.target.value),
|
|
2643
|
+
"aria-label": "Search options",
|
|
2644
|
+
onKeyDown: (e) => {
|
|
2645
|
+
if (e.key === "Escape") {
|
|
2646
|
+
state.close();
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
) }),
|
|
2651
|
+
/* @__PURE__ */ jsx5(
|
|
2652
|
+
ListBox,
|
|
2653
|
+
{
|
|
2654
|
+
...menuProps,
|
|
2655
|
+
listBoxRef,
|
|
2656
|
+
state,
|
|
2657
|
+
showCheckmark,
|
|
2658
|
+
showOverflowTooltips
|
|
2659
|
+
}
|
|
2660
|
+
),
|
|
2661
|
+
filteredOptions.length === 0 && /* @__PURE__ */ jsx5("div", { className: "ods-select__empty", children: "No results found" })
|
|
2662
|
+
]
|
|
2663
|
+
}
|
|
2664
|
+
) }),
|
|
2665
|
+
document.body
|
|
2666
|
+
),
|
|
2667
|
+
error && errorMessage ? /* @__PURE__ */ jsx5(
|
|
2668
|
+
"span",
|
|
2669
|
+
{
|
|
2670
|
+
id: hintId,
|
|
2671
|
+
className: "ods-select__error",
|
|
2672
|
+
role: "alert",
|
|
2673
|
+
children: errorMessage
|
|
2674
|
+
}
|
|
2675
|
+
) : helperText ? /* @__PURE__ */ jsx5("span", { id: hintId, className: "ods-select__hint", children: helperText }) : null
|
|
2676
|
+
]
|
|
2677
|
+
}
|
|
2678
|
+
);
|
|
2679
|
+
});
|
|
2680
|
+
Select.displayName = "Select";
|
|
2681
|
+
|
|
2682
|
+
// src/components/Spinner/Spinner.tsx
|
|
2683
|
+
import {
|
|
2684
|
+
forwardRef as forwardRef6
|
|
2685
|
+
} from "react";
|
|
2686
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2687
|
+
var SIZE_PX = {
|
|
2688
|
+
sm: 16,
|
|
2689
|
+
md: 24,
|
|
2690
|
+
lg: 32,
|
|
2691
|
+
xl: 48
|
|
2692
|
+
};
|
|
2693
|
+
var Spinner = forwardRef6(function Spinner2({
|
|
2694
|
+
size = "md",
|
|
2695
|
+
tone = "accent",
|
|
2696
|
+
label = "Loading",
|
|
2697
|
+
className,
|
|
2698
|
+
style,
|
|
2699
|
+
...rest
|
|
2700
|
+
}, ref) {
|
|
2701
|
+
const px = typeof size === "number" ? size : SIZE_PX[size];
|
|
2702
|
+
const isKeyword = typeof size === "string";
|
|
2703
|
+
return /* @__PURE__ */ jsx6(
|
|
2704
|
+
"svg",
|
|
2705
|
+
{
|
|
2706
|
+
...rest,
|
|
2707
|
+
ref,
|
|
2708
|
+
className: cn(
|
|
2709
|
+
"ods-spinner",
|
|
2710
|
+
isKeyword && `ods-spinner--${size}`,
|
|
2711
|
+
`ods-spinner--${tone}`,
|
|
2712
|
+
className
|
|
2713
|
+
),
|
|
2714
|
+
width: px,
|
|
2715
|
+
height: px,
|
|
2716
|
+
viewBox: "0 0 24 24",
|
|
2717
|
+
fill: "none",
|
|
2718
|
+
role: "status",
|
|
2719
|
+
"aria-label": label,
|
|
2720
|
+
style,
|
|
2721
|
+
children: /* @__PURE__ */ jsx6(
|
|
2722
|
+
"circle",
|
|
2723
|
+
{
|
|
2724
|
+
cx: "12",
|
|
2725
|
+
cy: "12",
|
|
2726
|
+
r: "10",
|
|
2727
|
+
strokeWidth: "3",
|
|
2728
|
+
strokeLinecap: "round",
|
|
2729
|
+
strokeDasharray: "31.4 31.4",
|
|
2730
|
+
className: "ods-spinner__circle"
|
|
2731
|
+
}
|
|
2732
|
+
)
|
|
2733
|
+
}
|
|
2734
|
+
);
|
|
2735
|
+
});
|
|
2736
|
+
Spinner.displayName = "Spinner";
|
|
2737
|
+
|
|
2738
|
+
export {
|
|
2739
|
+
Accordion,
|
|
2740
|
+
Slot,
|
|
2741
|
+
$05678f3aee5e7d1a$export$6d08773d2e66f8f2,
|
|
2742
|
+
$e3403870bfb691da$export$79fefeb1c2091ac3,
|
|
2743
|
+
$384704861d32dbed$export$bca9d026f8e704eb,
|
|
2744
|
+
$caeb030f09a278a1$export$4ba071daf4e486,
|
|
2745
|
+
$fd3c5e01e837dc20$export$8042c6c013fd5226,
|
|
2746
|
+
$6b915bde6cd300dd$export$728d6ba534403756,
|
|
2747
|
+
getRenderableText,
|
|
2748
|
+
resolveAccessibleName,
|
|
2749
|
+
Button,
|
|
2750
|
+
Input,
|
|
2751
|
+
Tooltip,
|
|
2752
|
+
Select,
|
|
2753
|
+
Spinner
|
|
2754
|
+
};
|
|
2755
|
+
//# sourceMappingURL=chunk-CRDYAV5R.js.map
|