@takeoff-ui/react-spar 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/agents/AGENTS.template.md +69 -0
- package/dist/index.cjs +2585 -221
- package/dist/index.d.cts +1536 -71
- package/dist/index.d.ts +1536 -71
- package/dist/index.mjs +2581 -224
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -6,13 +6,25 @@ var spar = require('@turkish-technology/spar');
|
|
|
6
6
|
var clsx = require('clsx');
|
|
7
7
|
var chevronBottom = require('@takeoff-icons/react/chevron-bottom');
|
|
8
8
|
var chevronTop = require('@takeoff-icons/react/chevron-top');
|
|
9
|
-
var
|
|
9
|
+
var close = require('@takeoff-icons/react/close');
|
|
10
10
|
var chevronRight = require('@takeoff-icons/react/chevron-right');
|
|
11
|
+
var check = require('@takeoff-icons/react/check');
|
|
12
|
+
var remove = require('@takeoff-icons/react/remove');
|
|
13
|
+
var info = require('@takeoff-icons/react/info');
|
|
14
|
+
var alertCircle = require('@takeoff-icons/react/alert-circle');
|
|
15
|
+
var eyeClosed = require('@takeoff-icons/react/eye-closed');
|
|
16
|
+
var eyeOpen = require('@takeoff-icons/react/eye-open');
|
|
17
|
+
var reactTable = require('@tanstack/react-table');
|
|
18
|
+
var arrowBottom = require('@takeoff-icons/react/arrow-bottom');
|
|
19
|
+
var arrowTop = require('@takeoff-icons/react/arrow-top');
|
|
11
20
|
var swap = require('@takeoff-icons/react/swap');
|
|
12
21
|
var search = require('@takeoff-icons/react/search');
|
|
13
|
-
var arrowLeft = require('@takeoff-icons/react/arrow-left');
|
|
14
|
-
var arrowRight = require('@takeoff-icons/react/arrow-right');
|
|
15
22
|
var chevronLeft = require('@takeoff-icons/react/chevron-left');
|
|
23
|
+
var doubleChevronLeft = require('@takeoff-icons/react/double-chevron-left');
|
|
24
|
+
var doubleChevronRight = require('@takeoff-icons/react/double-chevron-right');
|
|
25
|
+
var arrowDownload = require('@takeoff-icons/react/arrow-download');
|
|
26
|
+
var checkCircle = require('@takeoff-icons/react/check-circle');
|
|
27
|
+
var closeCircle = require('@takeoff-icons/react/close-circle');
|
|
16
28
|
|
|
17
29
|
// src/provider.tsx
|
|
18
30
|
|
|
@@ -146,6 +158,10 @@ var resolveDisclosureIndicator = (children, isOpen) => {
|
|
|
146
158
|
if (typeof children === "function") return children({ isOpen });
|
|
147
159
|
return children ?? (isOpen ? DEFAULT_DISCLOSURE_COLLAPSE_ICON : DEFAULT_DISCLOSURE_EXPAND_ICON);
|
|
148
160
|
};
|
|
161
|
+
var renderPointerArrow = () => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
162
|
+
/* @__PURE__ */ jsxRuntime.jsx("polygon", { className: "tk-arrow-border", points: "0,0 5,5 10,0" }),
|
|
163
|
+
/* @__PURE__ */ jsxRuntime.jsx("polygon", { className: "tk-arrow-fill", points: "-0.086,-1.5 5,3.586 10.086,-1.5" })
|
|
164
|
+
] });
|
|
149
165
|
|
|
150
166
|
// src/components/accordion/base.ts
|
|
151
167
|
var AccordionBase = createComponentBase({
|
|
@@ -196,6 +212,37 @@ function createSafeContext(displayName) {
|
|
|
196
212
|
};
|
|
197
213
|
return [Provider, useSafeContext];
|
|
198
214
|
}
|
|
215
|
+
var resolveStaticWidth = (mode) => {
|
|
216
|
+
if (mode === "trigger" || mode === "content") return void 0;
|
|
217
|
+
return typeof mode === "number" ? `${mode}px` : mode;
|
|
218
|
+
};
|
|
219
|
+
var useContentWidthStyle = (mode, triggerRef) => {
|
|
220
|
+
const [triggerWidth, setTriggerWidth] = react.useState(null);
|
|
221
|
+
react.useEffect(() => {
|
|
222
|
+
if (mode !== "trigger") return;
|
|
223
|
+
const node = triggerRef.current;
|
|
224
|
+
if (!node) return;
|
|
225
|
+
const measure = () => setTriggerWidth(Math.round(node.getBoundingClientRect().width));
|
|
226
|
+
measure();
|
|
227
|
+
let frame = 0;
|
|
228
|
+
const observer = new ResizeObserver(() => {
|
|
229
|
+
cancelAnimationFrame(frame);
|
|
230
|
+
frame = requestAnimationFrame(measure);
|
|
231
|
+
});
|
|
232
|
+
observer.observe(node);
|
|
233
|
+
return () => {
|
|
234
|
+
cancelAnimationFrame(frame);
|
|
235
|
+
observer.disconnect();
|
|
236
|
+
};
|
|
237
|
+
}, [mode, triggerRef]);
|
|
238
|
+
return react.useMemo(() => {
|
|
239
|
+
if (mode === "trigger") {
|
|
240
|
+
return triggerWidth != null ? { width: triggerWidth } : void 0;
|
|
241
|
+
}
|
|
242
|
+
const staticWidth = resolveStaticWidth(mode);
|
|
243
|
+
return staticWidth != null ? { width: staticWidth } : void 0;
|
|
244
|
+
}, [mode, triggerWidth]);
|
|
245
|
+
};
|
|
199
246
|
function useControllableState(controlledValue, defaultValue, onChange) {
|
|
200
247
|
const [uncontrolledValue, setUncontrolledValue] = react.useState(defaultValue);
|
|
201
248
|
const { current: isControlled } = react.useRef(controlledValue !== void 0);
|
|
@@ -209,7 +256,7 @@ function useControllableState(controlledValue, defaultValue, onChange) {
|
|
|
209
256
|
},
|
|
210
257
|
[isControlled, onChange]
|
|
211
258
|
);
|
|
212
|
-
return [value, setValue];
|
|
259
|
+
return [value, setValue, isControlled];
|
|
213
260
|
}
|
|
214
261
|
|
|
215
262
|
// src/components/accordion/context.ts
|
|
@@ -386,40 +433,6 @@ var AlertActions = (props) => {
|
|
|
386
433
|
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...actionsProps, ref, ...rootAttrs, children });
|
|
387
434
|
};
|
|
388
435
|
AlertActions.displayName = "Alert.Actions";
|
|
389
|
-
var baseSvgProps = {
|
|
390
|
-
"xmlns": "http://www.w3.org/2000/svg",
|
|
391
|
-
"width": "1em",
|
|
392
|
-
"height": "1em",
|
|
393
|
-
"viewBox": "0 0 24 24",
|
|
394
|
-
"fill": "none",
|
|
395
|
-
"stroke": "currentColor",
|
|
396
|
-
"strokeWidth": 2,
|
|
397
|
-
"strokeLinecap": "round",
|
|
398
|
-
"strokeLinejoin": "round",
|
|
399
|
-
"focusable": false,
|
|
400
|
-
"aria-hidden": true
|
|
401
|
-
};
|
|
402
|
-
var filledSvgProps = {
|
|
403
|
-
"xmlns": "http://www.w3.org/2000/svg",
|
|
404
|
-
"width": "1em",
|
|
405
|
-
"height": "1em",
|
|
406
|
-
"viewBox": "0 0 24 24",
|
|
407
|
-
"fill": "currentColor",
|
|
408
|
-
"focusable": false,
|
|
409
|
-
"aria-hidden": true
|
|
410
|
-
};
|
|
411
|
-
var PlaceholderChevronDown = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...baseSvgProps, "data-placeholder-icon": "chevron-down", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 9 6 6 6-6" }) });
|
|
412
|
-
var PlaceholderChevronUp = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...baseSvgProps, "data-placeholder-icon": "chevron-up", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m18 15-6-6-6 6" }) });
|
|
413
|
-
var PlaceholderClose = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { ...baseSvgProps, "data-placeholder-icon": "close", ...props, children: [
|
|
414
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6 6 18" }),
|
|
415
|
-
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "m6 6 12 12" })
|
|
416
|
-
] });
|
|
417
|
-
var PlaceholderInfo = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...filledSvgProps, "data-placeholder-icon": "info", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(2 2) scale(1.714)", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5.83333 0C2.61333 0 0 2.61333 0 5.83333C0 9.05333 2.61333 11.6667 5.83333 11.6667C9.05333 11.6667 11.6667 9.05333 11.6667 5.83333C11.6667 2.61333 9.05333 0 5.83333 0ZM5.83333 8.75C5.5125 8.75 5.25 8.4875 5.25 8.16667V5.83333C5.25 5.5125 5.5125 5.25 5.83333 5.25C6.15417 5.25 6.41667 5.5125 6.41667 5.83333V8.16667C6.41667 8.4875 6.15417 8.75 5.83333 8.75ZM6.41667 4.08333H5.25V2.91667H6.41667V4.08333Z" }) }) });
|
|
418
|
-
var PlaceholderError = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...filledSvgProps, "data-placeholder-icon": "error", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(2 2) scale(1.714)", fillRule: "evenodd", clipRule: "evenodd", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5.83333 0C2.61333 0 0 2.61333 0 5.83333C0 9.05333 2.61333 11.6667 5.83333 11.6667C9.05333 11.6667 11.6667 9.05333 11.6667 5.83333C11.6667 2.61333 9.05333 0 5.83333 0ZM5.83333 2.91667C6.15417 2.91667 6.41667 3.17917 6.41667 3.5V5.83333C6.41667 6.15417 6.15417 6.41667 5.83333 6.41667C5.5125 6.41667 5.25 6.15417 5.25 5.83333V3.5C5.25 3.17917 5.5125 2.91667 5.83333 2.91667ZM5.25 7.58333H6.41667V8.75H5.25V7.58333Z" }) }) });
|
|
419
|
-
var PlaceholderCheck = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...baseSvgProps, "data-placeholder-icon": "check", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 12l5 5L20 7" }) });
|
|
420
|
-
var PlaceholderRemove = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...baseSvgProps, "data-placeholder-icon": "remove", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 12h14" }) });
|
|
421
|
-
var PlaceholderEye = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...filledSvgProps, "data-placeholder-icon": "eye", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(1 4.5) scale(1.2)", fillRule: "evenodd", clipRule: "evenodd", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9.16667 1.66667C12.325 1.66667 15.1417 3.44167 16.5167 6.25C15.1417 9.05833 12.325 10.8333 9.16667 10.8333C6.00833 10.8333 3.19167 9.05833 1.81667 6.25C3.19167 3.44167 6.00833 1.66667 9.16667 1.66667ZM9.16667 0C5 0 1.44167 2.59167 0 6.25C1.44167 9.90833 5 12.5 9.16667 12.5C13.3333 12.5 16.8917 9.90833 18.3333 6.25C16.8917 2.59167 13.3333 0 9.16667 0ZM9.16667 4.16667C10.3167 4.16667 11.25 5.1 11.25 6.25C11.25 7.4 10.3167 8.33333 9.16667 8.33333C8.01667 8.33333 7.08333 7.4 7.08333 6.25C7.08333 5.1 8.01667 4.16667 9.16667 4.16667ZM9.16667 2.5C7.1 2.5 5.41667 4.18333 5.41667 6.25C5.41667 8.31667 7.1 10 9.16667 10C11.2333 10 12.9167 8.31667 12.9167 6.25C12.9167 4.18333 11.2333 2.5 9.16667 2.5Z" }) }) });
|
|
422
|
-
var PlaceholderEyeOff = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { ...filledSvgProps, "data-placeholder-icon": "eye-off", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("g", { transform: "translate(1 2.42) scale(1.2)", fillRule: "evenodd", clipRule: "evenodd", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9.16667 2.95833C12.325 2.95833 15.1417 4.73333 16.5167 7.54167C16.025 8.55833 15.3333 9.43333 14.5083 10.1417L15.6833 11.3167C16.8417 10.2917 17.7583 9.00833 18.3333 7.54167C16.8917 3.88333 13.3333 1.29167 9.16667 1.29167C8.10833 1.29167 7.09167 1.45833 6.13333 1.76667L7.50833 3.14167C8.05 3.03333 8.6 2.95833 9.16667 2.95833ZM8.275 3.90833L10 5.63333C10.475 5.84167 10.8583 6.225 11.0667 6.7L12.7917 8.425C12.8583 8.14167 12.9083 7.84167 12.9083 7.53333C12.9167 5.46667 11.2333 3.79167 9.16667 3.79167C8.85833 3.79167 8.56667 3.83333 8.275 3.90833ZM0.841667 1.18333L3.075 3.41667C1.71667 4.48333 0.641667 5.9 0 7.54167C1.44167 11.2 5 13.7917 9.16667 13.7917C10.4333 13.7917 11.65 13.55 12.7667 13.1083L15.6167 15.9583L16.7917 14.7833L2.01667 0L0.841667 1.18333ZM7.09167 7.43333L9.26667 9.60833C9.23333 9.61667 9.2 9.625 9.16667 9.625C8.01667 9.625 7.08333 8.69167 7.08333 7.54167C7.08333 7.5 7.09167 7.475 7.09167 7.43333ZM4.25833 4.6L5.71667 6.05833C5.525 6.51667 5.41667 7.01667 5.41667 7.54167C5.41667 9.60833 7.1 11.2917 9.16667 11.2917C9.69167 11.2917 10.1917 11.1833 10.6417 10.9917L11.4583 11.8083C10.725 12.0083 9.95833 12.125 9.16667 12.125C6.00833 12.125 3.19167 10.35 1.81667 7.54167C2.4 6.35 3.25 5.36667 4.25833 4.6Z" }) }) });
|
|
423
436
|
var AlertClose = (props) => {
|
|
424
437
|
const theme = useComponentTheme("AlertClose");
|
|
425
438
|
const { onClose } = useAlertContext("Alert.Close");
|
|
@@ -442,7 +455,7 @@ var AlertClose = (props) => {
|
|
|
442
455
|
"aria-label": ariaLabel ?? (hasCustomChildren ? void 0 : DEFAULT_CLOSE_LABEL),
|
|
443
456
|
onClick: handleClick,
|
|
444
457
|
...closeRootAttrs,
|
|
445
|
-
children: hasCustomChildren ? children : /* @__PURE__ */ jsxRuntime.jsx(
|
|
458
|
+
children: hasCustomChildren ? children : /* @__PURE__ */ jsxRuntime.jsx(close.CloseIconOutlinedRounded, {})
|
|
446
459
|
}
|
|
447
460
|
);
|
|
448
461
|
};
|
|
@@ -569,7 +582,6 @@ var [BreadcrumbProvider] = createSafeContext("BreadcrumbProvider");
|
|
|
569
582
|
// src/components/breadcrumb/defaults.ts
|
|
570
583
|
var DEFAULT_SIZE3 = "base";
|
|
571
584
|
var DEFAULT_TYPE2 = "basic";
|
|
572
|
-
var DEFAULT_SEPARATOR_VARIANT = "chevron";
|
|
573
585
|
var Breadcrumb = (props) => {
|
|
574
586
|
const theme = useComponentTheme("Breadcrumb");
|
|
575
587
|
const { rootAttrs, rest } = composeRootAttrs(BreadcrumbBase, props, theme, {
|
|
@@ -611,17 +623,11 @@ var BreadcrumbPage = (props) => {
|
|
|
611
623
|
return /* @__PURE__ */ jsxRuntime.jsx(spar.BreadcrumbPage, { ...spar$1, ref, ...rootAttrs, children });
|
|
612
624
|
};
|
|
613
625
|
BreadcrumbPage.displayName = "Breadcrumb.Page";
|
|
614
|
-
var DEFAULT_SEPARATOR_ICON = /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 4L10 8L6 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
615
626
|
var BreadcrumbSeparator = (props) => {
|
|
616
627
|
const theme = useComponentTheme("BreadcrumbSeparator");
|
|
617
|
-
const { rootAttrs, rest } = composeRootAttrs(BreadcrumbSeparatorBase, props, theme
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
})
|
|
621
|
-
});
|
|
622
|
-
const { variant = DEFAULT_SEPARATOR_VARIANT, children, ref, ...spar$1 } = rest;
|
|
623
|
-
const fallback = variant === "chevron" ? DEFAULT_SEPARATOR_ICON : null;
|
|
624
|
-
return /* @__PURE__ */ jsxRuntime.jsx(spar.BreadcrumbSeparator, { ...spar$1, ref, ...rootAttrs, children: children ?? fallback });
|
|
628
|
+
const { rootAttrs, rest } = composeRootAttrs(BreadcrumbSeparatorBase, props, theme);
|
|
629
|
+
const { children, ref, ...spar$1 } = rest;
|
|
630
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.BreadcrumbSeparator, { ...spar$1, ref, ...rootAttrs, children: children ?? /* @__PURE__ */ jsxRuntime.jsx(chevronRight.ChevronRightIconOutlinedRounded, { "aria-hidden": "true", focusable: "false" }) });
|
|
625
631
|
};
|
|
626
632
|
BreadcrumbSeparator.displayName = "Breadcrumb.Separator";
|
|
627
633
|
|
|
@@ -850,56 +856,47 @@ var Checkbox = (props) => {
|
|
|
850
856
|
// Visual props are consumed via `stateAttrs`; destructured to keep them
|
|
851
857
|
// off the rendered DOM where they would leak as raw HTML attributes.
|
|
852
858
|
size: _size,
|
|
853
|
-
// `invalid` is forwarded to Spar as `invalid` (same name).
|
|
854
|
-
invalid = false,
|
|
855
859
|
// takeoff-spar tri-state vocabulary; mapped to Spar's `CheckedState` below.
|
|
856
860
|
checked,
|
|
857
861
|
defaultChecked,
|
|
858
862
|
indeterminate = false,
|
|
859
863
|
onChange,
|
|
860
|
-
// Behavior props owned by Spar — defaults are restated here so they also
|
|
861
|
-
// flow into the context for compound sub-components (asterisk on Label).
|
|
862
|
-
disabled = false,
|
|
863
|
-
readOnly = false,
|
|
864
|
-
required = false,
|
|
865
864
|
children,
|
|
866
865
|
ref,
|
|
866
|
+
// `invalid`, `disabled`, `readOnly` and `required` are intentionally NOT
|
|
867
|
+
// destructured (so no eager `= false` default is applied) — they flow to
|
|
868
|
+
// Spar via `...sparProps` untouched. Defaulting them here would turn an
|
|
869
|
+
// omitted prop into an explicit `false`, defeating Spar's
|
|
870
|
+
// `prop ?? fieldCtx?.x` inheritance and silently overriding a wrapping
|
|
871
|
+
// `<Field disabled>`. Their resolved values are read back off Spar's
|
|
872
|
+
// render-prop `state` below for the compound context. See Radio/Input/
|
|
873
|
+
// Select wrappers for the same pass-through pattern.
|
|
867
874
|
...sparProps
|
|
868
875
|
} = rest;
|
|
869
876
|
const sparChecked = indeterminate ? "indeterminate" : checked;
|
|
870
877
|
const sparDefaultChecked = indeterminate ? "indeterminate" : defaultChecked;
|
|
871
878
|
const handleSparChange = onChange ? (next) => onChange(next === true) : void 0;
|
|
872
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
873
|
-
|
|
879
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.Checkbox, { ...sparProps, checked: sparChecked, defaultChecked: sparDefaultChecked, onChange: handleSparChange, ref, ...rootAttrs, children: (state) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
880
|
+
CheckboxProvider,
|
|
874
881
|
{
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
required,
|
|
892
|
-
invalid,
|
|
893
|
-
disabled: state.disabled,
|
|
894
|
-
readOnly: state.readOnly,
|
|
895
|
-
checked: state.checked === true,
|
|
896
|
-
indeterminate: state.checked === "indeterminate"
|
|
897
|
-
},
|
|
898
|
-
children: typeof children === "function" ? children(state) : children
|
|
899
|
-
}
|
|
900
|
-
)
|
|
882
|
+
value: {
|
|
883
|
+
classNames,
|
|
884
|
+
slotProps,
|
|
885
|
+
// Read the *resolved* behavior state off Spar's render-prop so the
|
|
886
|
+
// compound context reflects Field-inherited values, not the raw
|
|
887
|
+
// props. `state.required` / `state.invalid` already fold in
|
|
888
|
+
// `fieldCtx`, so `<Field disabled>` / `<Field invalid>` reach the
|
|
889
|
+
// Label asterisk and slotted styling correctly.
|
|
890
|
+
required: state.required,
|
|
891
|
+
invalid: state.invalid,
|
|
892
|
+
disabled: state.disabled,
|
|
893
|
+
readOnly: state.readOnly,
|
|
894
|
+
checked: state.checked === true,
|
|
895
|
+
indeterminate: state.checked === "indeterminate"
|
|
896
|
+
},
|
|
897
|
+
children: typeof children === "function" ? children(state) : children
|
|
901
898
|
}
|
|
902
|
-
);
|
|
899
|
+
) });
|
|
903
900
|
};
|
|
904
901
|
Checkbox.displayName = "Checkbox";
|
|
905
902
|
var CheckboxIndicator = (props) => {
|
|
@@ -918,7 +915,7 @@ var CheckboxIndicator = (props) => {
|
|
|
918
915
|
instanceSlotProps: slotProps,
|
|
919
916
|
instanceClassNames: classNames
|
|
920
917
|
});
|
|
921
|
-
const resolvedChildren = typeof children === "function" ? children({ checked, indeterminate }) : children ?? /* @__PURE__ */ jsxRuntime.jsx("span", { ...iconAttrs, "aria-hidden": true, children: indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
918
|
+
const resolvedChildren = typeof children === "function" ? children({ checked, indeterminate }) : children ?? /* @__PURE__ */ jsxRuntime.jsx("span", { ...iconAttrs, "aria-hidden": true, children: indeterminate ? /* @__PURE__ */ jsxRuntime.jsx(remove.RemoveIconOutlinedRounded, {}) : /* @__PURE__ */ jsxRuntime.jsx(check.CheckIconOutlinedRounded, {}) });
|
|
922
919
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...rest, ...indicatorAttrs, ref, children: resolvedChildren });
|
|
923
920
|
};
|
|
924
921
|
CheckboxIndicator.displayName = "Checkbox.Indicator";
|
|
@@ -1043,7 +1040,7 @@ var Chip = (props) => {
|
|
|
1043
1040
|
isRenderableNode(children) && /* @__PURE__ */ jsxRuntime.jsx("span", { ...labelSlotAttrs, children }),
|
|
1044
1041
|
removable && // The icon-only remove control needs an accessible name. Default it,
|
|
1045
1042
|
// but let `slotProps.remove` (spread after) override via `aria-label`.
|
|
1046
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { "aria-label": DEFAULT_REMOVE_LABEL, ...removeButtonAttrs, disabled, onClick: handleRemoveClick, type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1043
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { "aria-label": DEFAULT_REMOVE_LABEL, ...removeButtonAttrs, disabled, onClick: handleRemoveClick, type: "button", children: /* @__PURE__ */ jsxRuntime.jsx(close.CloseIconOutlinedRounded, {}) })
|
|
1047
1044
|
]
|
|
1048
1045
|
}
|
|
1049
1046
|
);
|
|
@@ -1058,6 +1055,7 @@ var DEFAULT_PLACEMENT = "right";
|
|
|
1058
1055
|
var DEFAULT_HEADER_TYPE2 = "basic";
|
|
1059
1056
|
var DEFAULT_FOOTER_TYPE2 = "basic";
|
|
1060
1057
|
var DEFAULT_INTENSITY = "base";
|
|
1058
|
+
var DEFAULT_CLOSE_LABEL2 = "Close";
|
|
1061
1059
|
var Drawer = (props) => {
|
|
1062
1060
|
const theme = useComponentTheme("Drawer");
|
|
1063
1061
|
const merged = { ...theme?.defaultProps, ...props };
|
|
@@ -1203,8 +1201,9 @@ DrawerFooter.displayName = "Drawer.Footer";
|
|
|
1203
1201
|
var DrawerClose = (props) => {
|
|
1204
1202
|
const theme = useComponentTheme("DrawerClose");
|
|
1205
1203
|
const { rootAttrs, rest } = composeRootAttrs(DrawerCloseBase, props, theme);
|
|
1206
|
-
const { children, ref, ...closeProps } = rest;
|
|
1207
|
-
|
|
1204
|
+
const { children, ref, "aria-label": ariaLabel, ...closeProps } = rest;
|
|
1205
|
+
const hasCustomChildren = typeof children === "function" || isRenderableNode(children);
|
|
1206
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DialogClose, { ...closeProps, "aria-label": ariaLabel ?? (hasCustomChildren ? void 0 : DEFAULT_CLOSE_LABEL2), ref, ...rootAttrs, children: hasCustomChildren ? children : /* @__PURE__ */ jsxRuntime.jsx(close.CloseIconOutlinedRounded, {}) });
|
|
1208
1207
|
};
|
|
1209
1208
|
DrawerClose.displayName = "Drawer.Close";
|
|
1210
1209
|
|
|
@@ -1307,6 +1306,7 @@ DialogTrigger.displayName = "Dialog.Trigger";
|
|
|
1307
1306
|
var DEFAULT_INTENSITY2 = "base";
|
|
1308
1307
|
var DEFAULT_HEADER_TYPE3 = "basic";
|
|
1309
1308
|
var DEFAULT_FOOTER_TYPE3 = "basic";
|
|
1309
|
+
var DEFAULT_CLOSE_LABEL3 = "Close";
|
|
1310
1310
|
var DialogOverlay = (props) => {
|
|
1311
1311
|
const theme = useComponentTheme("DialogOverlay");
|
|
1312
1312
|
const { rootAttrs, rest } = composeRootAttrs(DialogOverlayBase, props, theme, {
|
|
@@ -1382,8 +1382,9 @@ DialogFooter.displayName = "Dialog.Footer";
|
|
|
1382
1382
|
var DialogClose = (props) => {
|
|
1383
1383
|
const theme = useComponentTheme("DialogClose");
|
|
1384
1384
|
const { rootAttrs, rest } = composeRootAttrs(DialogCloseBase, props, theme);
|
|
1385
|
-
const { children, ref, ...sparProps } = rest;
|
|
1386
|
-
|
|
1385
|
+
const { children, ref, "aria-label": ariaLabel, ...sparProps } = rest;
|
|
1386
|
+
const hasCustomChildren = typeof children === "function" || isRenderableNode(children);
|
|
1387
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DialogClose, { ...sparProps, "aria-label": ariaLabel ?? (hasCustomChildren ? void 0 : DEFAULT_CLOSE_LABEL3), ...rootAttrs, ref, children: hasCustomChildren ? children : /* @__PURE__ */ jsxRuntime.jsx(close.CloseIconOutlinedRounded, {}) });
|
|
1387
1388
|
};
|
|
1388
1389
|
DialogClose.displayName = "Dialog.Close";
|
|
1389
1390
|
|
|
@@ -1400,6 +1401,182 @@ var Dialog2 = Object.assign(Dialog, {
|
|
|
1400
1401
|
Close: DialogClose
|
|
1401
1402
|
});
|
|
1402
1403
|
|
|
1404
|
+
// src/components/divider/base.ts
|
|
1405
|
+
var DividerBase = createComponentBase({
|
|
1406
|
+
name: "Divider",
|
|
1407
|
+
slots: ["root", "label"],
|
|
1408
|
+
classes: {
|
|
1409
|
+
root: "tk-divider",
|
|
1410
|
+
label: "tk-divider-label"
|
|
1411
|
+
}
|
|
1412
|
+
});
|
|
1413
|
+
|
|
1414
|
+
// src/components/divider/defaults.ts
|
|
1415
|
+
var DEFAULT_ORIENTATION = "horizontal";
|
|
1416
|
+
var DEFAULT_APPEARANCE5 = "solid";
|
|
1417
|
+
var DEFAULT_ALIGN = "center";
|
|
1418
|
+
var hasRenderableDividerLabel = (node) => Array.isArray(node) ? node.some(hasRenderableDividerLabel) : isRenderableNode(node);
|
|
1419
|
+
var Divider = (props) => {
|
|
1420
|
+
const theme = useComponentTheme("Divider");
|
|
1421
|
+
const { rootAttrs, rest } = composeRootAttrs(DividerBase, props, theme, {
|
|
1422
|
+
// role/aria-orientation live here alongside the data-* hooks so consumer
|
|
1423
|
+
// slotProps cannot silently strip the separator semantics.
|
|
1424
|
+
stateAttrs: ({ orientation: orientation2 = DEFAULT_ORIENTATION, appearance = DEFAULT_APPEARANCE5, align = DEFAULT_ALIGN, decorative: decorative2 = false }) => ({
|
|
1425
|
+
"role": decorative2 ? "none" : "separator",
|
|
1426
|
+
"data-orientation": orientation2,
|
|
1427
|
+
"data-type": appearance,
|
|
1428
|
+
"data-align": align
|
|
1429
|
+
})
|
|
1430
|
+
});
|
|
1431
|
+
const { orientation = DEFAULT_ORIENTATION, appearance: _appearance, align: _align, decorative = false, children, ref, ...nativeProps } = rest;
|
|
1432
|
+
const labelSlotAttrs = buildSlotAttrs(DividerBase.getSlotProps("label"), "label", {
|
|
1433
|
+
themeSlotProps: theme?.slotProps,
|
|
1434
|
+
themeClassNames: theme?.classNames,
|
|
1435
|
+
instanceSlotProps: props.slotProps,
|
|
1436
|
+
instanceClassNames: props.classNames
|
|
1437
|
+
});
|
|
1438
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...nativeProps, ...rootAttrs, "aria-orientation": decorative ? void 0 : orientation, ref, children: hasRenderableDividerLabel(children) && /* @__PURE__ */ jsxRuntime.jsx("span", { ...labelSlotAttrs, children }) });
|
|
1439
|
+
};
|
|
1440
|
+
Divider.displayName = "Divider";
|
|
1441
|
+
|
|
1442
|
+
// src/components/dropdown/context.ts
|
|
1443
|
+
var [DropdownProvider, useDropdownOwnContext] = createSafeContext("DropdownProvider");
|
|
1444
|
+
|
|
1445
|
+
// src/components/dropdown/defaults.ts
|
|
1446
|
+
var DEFAULT_SIZE7 = "base";
|
|
1447
|
+
var DEFAULT_CONTENT_WIDTH = "content";
|
|
1448
|
+
var Dropdown = (props) => {
|
|
1449
|
+
const theme = useComponentTheme("Dropdown");
|
|
1450
|
+
const merged = { ...theme?.defaultProps, ...props };
|
|
1451
|
+
const { size = DEFAULT_SIZE7, contentWidth = DEFAULT_CONTENT_WIDTH, children, ...sparProps } = merged;
|
|
1452
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DropdownProvider, { value: { size, contentWidth }, children: /* @__PURE__ */ jsxRuntime.jsx(spar.DropdownMenu, { ...sparProps, children }) });
|
|
1453
|
+
};
|
|
1454
|
+
Dropdown.displayName = "Dropdown";
|
|
1455
|
+
|
|
1456
|
+
// src/components/dropdown/base.ts
|
|
1457
|
+
var DropdownTriggerBase = createComponentBase({
|
|
1458
|
+
name: "DropdownTrigger",
|
|
1459
|
+
slots: ["root"],
|
|
1460
|
+
classes: { root: "tk-dropdown-trigger" }
|
|
1461
|
+
});
|
|
1462
|
+
var DropdownContentBase = createComponentBase({
|
|
1463
|
+
name: "DropdownContent",
|
|
1464
|
+
slots: ["root"],
|
|
1465
|
+
classes: { root: "tk-dropdown-content" }
|
|
1466
|
+
});
|
|
1467
|
+
var DropdownViewportBase = createComponentBase({
|
|
1468
|
+
name: "DropdownViewport",
|
|
1469
|
+
slots: ["root"],
|
|
1470
|
+
classes: { root: "tk-dropdown-viewport" }
|
|
1471
|
+
});
|
|
1472
|
+
var DropdownItemBase = createComponentBase({
|
|
1473
|
+
name: "DropdownItem",
|
|
1474
|
+
slots: ["root"],
|
|
1475
|
+
classes: { root: "tk-dropdown-item" }
|
|
1476
|
+
});
|
|
1477
|
+
var DropdownGroupBase = createComponentBase({
|
|
1478
|
+
name: "DropdownGroup",
|
|
1479
|
+
slots: ["root"],
|
|
1480
|
+
classes: { root: "tk-dropdown-group" }
|
|
1481
|
+
});
|
|
1482
|
+
var DropdownLabelBase = createComponentBase({
|
|
1483
|
+
name: "DropdownLabel",
|
|
1484
|
+
slots: ["root"],
|
|
1485
|
+
classes: { root: "tk-dropdown-label" }
|
|
1486
|
+
});
|
|
1487
|
+
var DropdownSeparatorBase = createComponentBase({
|
|
1488
|
+
name: "DropdownSeparator",
|
|
1489
|
+
slots: ["root"],
|
|
1490
|
+
classes: { root: "tk-dropdown-separator" }
|
|
1491
|
+
});
|
|
1492
|
+
var DropdownArrowBase = createComponentBase({
|
|
1493
|
+
name: "DropdownArrow",
|
|
1494
|
+
slots: ["root"],
|
|
1495
|
+
classes: { root: "tk-dropdown-arrow" }
|
|
1496
|
+
});
|
|
1497
|
+
var DropdownArrow = (props) => {
|
|
1498
|
+
const theme = useComponentTheme("DropdownArrow");
|
|
1499
|
+
const { rootAttrs, rest } = composeRootAttrs(DropdownArrowBase, props, theme);
|
|
1500
|
+
const { children, ref, ...sparProps } = rest;
|
|
1501
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DropdownMenuArrow, { ...sparProps, ...rootAttrs, ref, children: children ?? renderPointerArrow() });
|
|
1502
|
+
};
|
|
1503
|
+
DropdownArrow.displayName = "Dropdown.Arrow";
|
|
1504
|
+
var DropdownContent = (props) => {
|
|
1505
|
+
const theme = useComponentTheme("DropdownContent");
|
|
1506
|
+
const { size, contentWidth } = useDropdownOwnContext("Dropdown.Content");
|
|
1507
|
+
const { triggerRef } = spar.useDropdownMenuContext();
|
|
1508
|
+
const widthStyle = useContentWidthStyle(contentWidth, triggerRef);
|
|
1509
|
+
const { rootAttrs, rest } = composeRootAttrs(DropdownContentBase, props, theme, {
|
|
1510
|
+
stateAttrs: () => ({
|
|
1511
|
+
"data-size": size
|
|
1512
|
+
})
|
|
1513
|
+
});
|
|
1514
|
+
const { children, ref, style: userStyle, ...sparProps } = rest;
|
|
1515
|
+
const { style: rootStyle, ...rootRest } = rootAttrs;
|
|
1516
|
+
const mergedStyle = widthStyle || rootStyle || userStyle ? { ...widthStyle, ...rootStyle, ...userStyle } : void 0;
|
|
1517
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DropdownMenuContent, { ...sparProps, ...rootRest, ref, style: mergedStyle, children });
|
|
1518
|
+
};
|
|
1519
|
+
DropdownContent.displayName = "Dropdown.Content";
|
|
1520
|
+
var DropdownGroup = (props) => {
|
|
1521
|
+
const theme = useComponentTheme("DropdownGroup");
|
|
1522
|
+
const { rootAttrs, rest } = composeRootAttrs(DropdownGroupBase, props, theme);
|
|
1523
|
+
const { children, ref, ...sparProps } = rest;
|
|
1524
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DropdownMenuGroup, { ...sparProps, ...rootAttrs, ref, children });
|
|
1525
|
+
};
|
|
1526
|
+
DropdownGroup.displayName = "Dropdown.Group";
|
|
1527
|
+
var DropdownItem = (props) => {
|
|
1528
|
+
const theme = useComponentTheme("DropdownItem");
|
|
1529
|
+
const { rootAttrs, rest } = composeRootAttrs(DropdownItemBase, props, theme);
|
|
1530
|
+
const { children, ref, ...sparProps } = rest;
|
|
1531
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DropdownMenuItem, { ...sparProps, ...rootAttrs, ref, children });
|
|
1532
|
+
};
|
|
1533
|
+
DropdownItem.displayName = "Dropdown.Item";
|
|
1534
|
+
var DropdownLabel = (props) => {
|
|
1535
|
+
const theme = useComponentTheme("DropdownLabel");
|
|
1536
|
+
const { rootAttrs, rest } = composeRootAttrs(DropdownLabelBase, props, theme);
|
|
1537
|
+
const { children, ref, ...sparProps } = rest;
|
|
1538
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DropdownMenuLabel, { ...sparProps, ...rootAttrs, ref, children });
|
|
1539
|
+
};
|
|
1540
|
+
DropdownLabel.displayName = "Dropdown.Label";
|
|
1541
|
+
var DropdownSeparator = (props) => {
|
|
1542
|
+
const theme = useComponentTheme("DropdownSeparator");
|
|
1543
|
+
const { rootAttrs, rest } = composeRootAttrs(DropdownSeparatorBase, props, theme);
|
|
1544
|
+
const { children, ref, ...sparProps } = rest;
|
|
1545
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DropdownMenuSeparator, { ...sparProps, ...rootAttrs, ref, children });
|
|
1546
|
+
};
|
|
1547
|
+
DropdownSeparator.displayName = "Dropdown.Separator";
|
|
1548
|
+
var DropdownTrigger = (props) => {
|
|
1549
|
+
const theme = useComponentTheme("DropdownTrigger");
|
|
1550
|
+
const { size } = useDropdownOwnContext("Dropdown.Trigger");
|
|
1551
|
+
const { rootAttrs, rest } = composeRootAttrs(DropdownTriggerBase, props, theme, {
|
|
1552
|
+
stateAttrs: () => ({
|
|
1553
|
+
"data-size": size
|
|
1554
|
+
})
|
|
1555
|
+
});
|
|
1556
|
+
const { children, ref, ...sparProps } = rest;
|
|
1557
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DropdownMenuTrigger, { ...sparProps, ...rootAttrs, ref, children });
|
|
1558
|
+
};
|
|
1559
|
+
DropdownTrigger.displayName = "Dropdown.Trigger";
|
|
1560
|
+
var DropdownViewport = (props) => {
|
|
1561
|
+
const theme = useComponentTheme("DropdownViewport");
|
|
1562
|
+
const { rootAttrs, rest } = composeRootAttrs(DropdownViewportBase, props, theme);
|
|
1563
|
+
const { children, ref, ...sparProps } = rest;
|
|
1564
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.DropdownMenuViewport, { ...sparProps, ...rootAttrs, ref, children });
|
|
1565
|
+
};
|
|
1566
|
+
DropdownViewport.displayName = "Dropdown.Viewport";
|
|
1567
|
+
|
|
1568
|
+
// src/components/dropdown/index.ts
|
|
1569
|
+
var Dropdown2 = Object.assign(Dropdown, {
|
|
1570
|
+
Trigger: DropdownTrigger,
|
|
1571
|
+
Content: DropdownContent,
|
|
1572
|
+
Viewport: DropdownViewport,
|
|
1573
|
+
Item: DropdownItem,
|
|
1574
|
+
Group: DropdownGroup,
|
|
1575
|
+
Label: DropdownLabel,
|
|
1576
|
+
Separator: DropdownSeparator,
|
|
1577
|
+
Arrow: DropdownArrow
|
|
1578
|
+
});
|
|
1579
|
+
|
|
1403
1580
|
// src/components/field/base.ts
|
|
1404
1581
|
var FieldBase = createComponentBase({
|
|
1405
1582
|
name: "Field",
|
|
@@ -1457,7 +1634,7 @@ var FieldDescription = (props) => {
|
|
|
1457
1634
|
});
|
|
1458
1635
|
const hasContent = children != null && children !== "";
|
|
1459
1636
|
return /* @__PURE__ */ jsxRuntime.jsxs(spar.FieldDescription, { ...spar$1, ref, ...rootAttrs, children: [
|
|
1460
|
-
hasContent && /* @__PURE__ */ jsxRuntime.jsx("span", { ...iconAttrs, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1637
|
+
hasContent && /* @__PURE__ */ jsxRuntime.jsx("span", { ...iconAttrs, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(info.InfoIconFilledRounded, {}) }),
|
|
1461
1638
|
children
|
|
1462
1639
|
] });
|
|
1463
1640
|
};
|
|
@@ -1474,7 +1651,7 @@ var FieldErrorMessage = (props) => {
|
|
|
1474
1651
|
});
|
|
1475
1652
|
const hasContent = children != null && children !== "";
|
|
1476
1653
|
return /* @__PURE__ */ jsxRuntime.jsxs(spar.FieldErrorMessage, { ...spar$1, ref, ...rootAttrs, children: [
|
|
1477
|
-
hasContent && /* @__PURE__ */ jsxRuntime.jsx("span", { ...iconAttrs, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1654
|
+
hasContent && /* @__PURE__ */ jsxRuntime.jsx("span", { ...iconAttrs, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(alertCircle.AlertCircleIconFilledRounded, {}) }),
|
|
1478
1655
|
children
|
|
1479
1656
|
] });
|
|
1480
1657
|
};
|
|
@@ -1563,7 +1740,7 @@ var InputChipsBase = createComponentBase({
|
|
|
1563
1740
|
var [InputProvider, useInputOwnContext] = createSafeContext("InputProvider");
|
|
1564
1741
|
|
|
1565
1742
|
// src/components/input/defaults.ts
|
|
1566
|
-
var
|
|
1743
|
+
var DEFAULT_SIZE8 = "base";
|
|
1567
1744
|
var SEGMENT_COUNT = 4;
|
|
1568
1745
|
var computeStrength = (value) => {
|
|
1569
1746
|
let strength = 0;
|
|
@@ -1615,11 +1792,11 @@ var Input = (props) => {
|
|
|
1615
1792
|
for (const value of clearablesRef.current.values()) value.clear();
|
|
1616
1793
|
}, []);
|
|
1617
1794
|
const { rootAttrs, rest } = composeRootAttrs(InputBase, props, theme, {
|
|
1618
|
-
stateAttrs: ({ size: size2 =
|
|
1795
|
+
stateAttrs: ({ size: size2 = DEFAULT_SIZE8 }) => ({
|
|
1619
1796
|
"data-size": size2
|
|
1620
1797
|
})
|
|
1621
1798
|
});
|
|
1622
|
-
const { size =
|
|
1799
|
+
const { size = DEFAULT_SIZE8, children, ref, ...sparProps } = rest;
|
|
1623
1800
|
const contextValue = react.useMemo(
|
|
1624
1801
|
() => ({
|
|
1625
1802
|
size,
|
|
@@ -1803,7 +1980,7 @@ var InputClearButton = (props) => {
|
|
|
1803
1980
|
"aria-label": ariaLabel,
|
|
1804
1981
|
onClick: handleClick,
|
|
1805
1982
|
onKeyDown: handleKeyDown,
|
|
1806
|
-
startContent: children ?? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1983
|
+
startContent: children ?? /* @__PURE__ */ jsxRuntime.jsx(close.CloseIconOutlinedRounded, {})
|
|
1807
1984
|
}
|
|
1808
1985
|
);
|
|
1809
1986
|
};
|
|
@@ -1834,7 +2011,7 @@ var InputDecrement = (props) => {
|
|
|
1834
2011
|
disabled: disabled || readOnly,
|
|
1835
2012
|
"aria-label": ariaLabel,
|
|
1836
2013
|
onClick: handleClick,
|
|
1837
|
-
startContent: children ?? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2014
|
+
startContent: children ?? /* @__PURE__ */ jsxRuntime.jsx(chevronBottom.ChevronBottomIconOutlinedRounded, {})
|
|
1838
2015
|
}
|
|
1839
2016
|
);
|
|
1840
2017
|
};
|
|
@@ -1912,7 +2089,7 @@ var InputIncrement = (props) => {
|
|
|
1912
2089
|
disabled: disabled || readOnly,
|
|
1913
2090
|
"aria-label": ariaLabel,
|
|
1914
2091
|
onClick: handleClick,
|
|
1915
|
-
startContent: children ?? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2092
|
+
startContent: children ?? /* @__PURE__ */ jsxRuntime.jsx(chevronTop.ChevronTopIconOutlinedRounded, {})
|
|
1916
2093
|
}
|
|
1917
2094
|
);
|
|
1918
2095
|
};
|
|
@@ -1971,7 +2148,7 @@ var InputRevealButton = (props) => {
|
|
|
1971
2148
|
"aria-label": "Toggle password visibility",
|
|
1972
2149
|
"aria-pressed": revealed,
|
|
1973
2150
|
onClick: handleClick,
|
|
1974
|
-
startContent: children ?? (revealed ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2151
|
+
startContent: children ?? (revealed ? /* @__PURE__ */ jsxRuntime.jsx(eyeClosed.EyeClosedIconOutlinedRounded, {}) : /* @__PURE__ */ jsxRuntime.jsx(eyeOpen.EyeOpenIconOutlinedRounded, {}))
|
|
1975
2152
|
}
|
|
1976
2153
|
);
|
|
1977
2154
|
};
|
|
@@ -2075,19 +2252,19 @@ var RADIO_ITEM_CONTEXT_VALUE = { inside: true };
|
|
|
2075
2252
|
var [RadioItemProvider, useRadioItemOwnContext] = createSafeContext("RadioItemProvider");
|
|
2076
2253
|
|
|
2077
2254
|
// src/components/radio/defaults.ts
|
|
2078
|
-
var
|
|
2255
|
+
var DEFAULT_SIZE9 = "base";
|
|
2079
2256
|
var DEFAULT_POSITION = "left";
|
|
2080
2257
|
var Radio = (props) => {
|
|
2081
2258
|
const theme = useComponentTheme("Radio");
|
|
2082
2259
|
const { rootAttrs, rest } = composeRootAttrs(RadioBase, props, theme, {
|
|
2083
|
-
stateAttrs: ({ size: size2 =
|
|
2260
|
+
stateAttrs: ({ size: size2 = DEFAULT_SIZE9, position: position2 = DEFAULT_POSITION, spread }) => ({
|
|
2084
2261
|
"data-size": size2,
|
|
2085
2262
|
"data-position": position2,
|
|
2086
2263
|
"data-spread": spread ? "" : void 0
|
|
2087
2264
|
})
|
|
2088
2265
|
});
|
|
2089
2266
|
const {
|
|
2090
|
-
size =
|
|
2267
|
+
size = DEFAULT_SIZE9,
|
|
2091
2268
|
position = DEFAULT_POSITION,
|
|
2092
2269
|
invalid,
|
|
2093
2270
|
// `spread` is consumed only as a data-attr above; destructure to keep it
|
|
@@ -2206,6 +2383,7 @@ PopoverTrigger.displayName = "Popover.Trigger";
|
|
|
2206
2383
|
|
|
2207
2384
|
// src/components/popover/defaults.ts
|
|
2208
2385
|
var DEFAULT_VARIANT5 = "white";
|
|
2386
|
+
var DEFAULT_CLOSE_LABEL4 = "Close";
|
|
2209
2387
|
var PopoverContent = (props) => {
|
|
2210
2388
|
const theme = useComponentTheme("PopoverContent");
|
|
2211
2389
|
const { rootAttrs, rest } = composeRootAttrs(PopoverContentBase, props, theme, {
|
|
@@ -2234,15 +2412,16 @@ PopoverDescription.displayName = "Popover.Description";
|
|
|
2234
2412
|
var PopoverArrow = (props) => {
|
|
2235
2413
|
const theme = useComponentTheme("PopoverArrow");
|
|
2236
2414
|
const { rootAttrs, rest } = composeRootAttrs(PopoverArrowBase, props, theme);
|
|
2237
|
-
const { ref, ...sparProps } = rest;
|
|
2238
|
-
return /* @__PURE__ */ jsxRuntime.jsx(spar.PopoverArrow, { ...sparProps, ...rootAttrs, ref });
|
|
2415
|
+
const { ref, children, ...sparProps } = rest;
|
|
2416
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.PopoverArrow, { ...sparProps, ...rootAttrs, ref, children: children ?? renderPointerArrow() });
|
|
2239
2417
|
};
|
|
2240
2418
|
PopoverArrow.displayName = "Popover.Arrow";
|
|
2241
2419
|
var PopoverClose = (props) => {
|
|
2242
2420
|
const theme = useComponentTheme("PopoverClose");
|
|
2243
2421
|
const { rootAttrs, rest } = composeRootAttrs(PopoverCloseBase, props, theme);
|
|
2244
|
-
const { children, ref, ...sparProps } = rest;
|
|
2245
|
-
|
|
2422
|
+
const { children, ref, "aria-label": ariaLabel, ...sparProps } = rest;
|
|
2423
|
+
const hasCustomChildren = typeof children === "function" || isRenderableNode(children);
|
|
2424
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.PopoverClose, { ...sparProps, "aria-label": ariaLabel ?? (hasCustomChildren ? void 0 : DEFAULT_CLOSE_LABEL4), ...rootAttrs, ref, children: hasCustomChildren ? children : /* @__PURE__ */ jsxRuntime.jsx(close.CloseIconOutlinedRounded, {}) });
|
|
2246
2425
|
};
|
|
2247
2426
|
PopoverClose.displayName = "Popover.Close";
|
|
2248
2427
|
|
|
@@ -2256,6 +2435,193 @@ var Popover2 = Object.assign(Popover, {
|
|
|
2256
2435
|
Close: PopoverClose
|
|
2257
2436
|
});
|
|
2258
2437
|
|
|
2438
|
+
// src/components/progress/base.ts
|
|
2439
|
+
var ProgressBase = createComponentBase({
|
|
2440
|
+
name: "Progress",
|
|
2441
|
+
slots: ["root"],
|
|
2442
|
+
classes: { root: "tk-progress" }
|
|
2443
|
+
});
|
|
2444
|
+
var ProgressTrackBase = createComponentBase({
|
|
2445
|
+
name: "ProgressTrack",
|
|
2446
|
+
slots: ["root", "rail"],
|
|
2447
|
+
classes: { root: "tk-progress-track", rail: "tk-progress-rail" }
|
|
2448
|
+
});
|
|
2449
|
+
var ProgressIndicatorBase = createComponentBase({
|
|
2450
|
+
name: "ProgressIndicator",
|
|
2451
|
+
slots: ["root"],
|
|
2452
|
+
classes: { root: "tk-progress-indicator" }
|
|
2453
|
+
});
|
|
2454
|
+
var ProgressValueBase = createComponentBase({
|
|
2455
|
+
name: "ProgressValue",
|
|
2456
|
+
slots: ["root"],
|
|
2457
|
+
classes: { root: "tk-progress-value" }
|
|
2458
|
+
});
|
|
2459
|
+
|
|
2460
|
+
// src/components/progress/context.ts
|
|
2461
|
+
var [ProgressProvider, useProgressContext] = createSafeContext("ProgressProvider");
|
|
2462
|
+
|
|
2463
|
+
// src/components/progress/defaults.ts
|
|
2464
|
+
var DEFAULT_APPEARANCE6 = "linear";
|
|
2465
|
+
var DEFAULT_SIZE10 = "base";
|
|
2466
|
+
var DEFAULT_VARIANT6 = "primary";
|
|
2467
|
+
var DEFAULT_MIN = 0;
|
|
2468
|
+
var DEFAULT_MAX = 100;
|
|
2469
|
+
var DEFAULT_RANGE = 100;
|
|
2470
|
+
var DEFAULT_ARIA_LABEL = "Progress";
|
|
2471
|
+
var RING_VIEWBOX = "0 0 40 40";
|
|
2472
|
+
var RING_CENTER = 20;
|
|
2473
|
+
var RING_RADIUS = 18;
|
|
2474
|
+
var ProgressIndicator = (props) => {
|
|
2475
|
+
const theme = useComponentTheme("ProgressIndicator");
|
|
2476
|
+
const { value, min, max, appearance, indeterminate } = useProgressContext("Progress.Indicator");
|
|
2477
|
+
const percent = Math.min(100, Math.max(0, (value - min) * 100 / (max - min)));
|
|
2478
|
+
const { rootAttrs, rest } = composeRootAttrs(ProgressIndicatorBase, props, theme, {
|
|
2479
|
+
stateAttrs: () => ({
|
|
2480
|
+
"data-type": appearance,
|
|
2481
|
+
"data-indeterminate": indeterminate ? "" : void 0
|
|
2482
|
+
})
|
|
2483
|
+
});
|
|
2484
|
+
const { ref, style, ...nativeProps } = rest;
|
|
2485
|
+
const { style: slotStyle, ...slotAttrs } = rootAttrs;
|
|
2486
|
+
if (appearance === "circular") {
|
|
2487
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2488
|
+
"circle",
|
|
2489
|
+
{
|
|
2490
|
+
cx: RING_CENTER,
|
|
2491
|
+
cy: RING_CENTER,
|
|
2492
|
+
r: RING_RADIUS,
|
|
2493
|
+
...nativeProps,
|
|
2494
|
+
...slotAttrs,
|
|
2495
|
+
pathLength: "100",
|
|
2496
|
+
style: { ...style, ...slotStyle, strokeDasharray: 100, strokeDashoffset: indeterminate ? void 0 : 100 - percent },
|
|
2497
|
+
ref
|
|
2498
|
+
}
|
|
2499
|
+
);
|
|
2500
|
+
}
|
|
2501
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...nativeProps, ...slotAttrs, "aria-hidden": "true", style: { ...style, ...slotStyle, width: indeterminate ? void 0 : `${percent}%` }, ref });
|
|
2502
|
+
};
|
|
2503
|
+
ProgressIndicator.displayName = "Progress.Indicator";
|
|
2504
|
+
var ProgressTrack = (props) => {
|
|
2505
|
+
const theme = useComponentTheme("ProgressTrack");
|
|
2506
|
+
const { appearance } = useProgressContext("Progress.Track");
|
|
2507
|
+
const { rootAttrs, rest } = composeRootAttrs(ProgressTrackBase, props, theme, {
|
|
2508
|
+
stateAttrs: () => ({ "data-type": appearance })
|
|
2509
|
+
});
|
|
2510
|
+
const { children, ref, ...nativeProps } = rest;
|
|
2511
|
+
const content = children ?? /* @__PURE__ */ jsxRuntime.jsx(ProgressIndicator, {});
|
|
2512
|
+
if (appearance === "circular") {
|
|
2513
|
+
const railAttrs = buildSlotAttrs(ProgressTrackBase.getSlotProps("rail"), "rail", {
|
|
2514
|
+
themeSlotProps: theme?.slotProps,
|
|
2515
|
+
themeClassNames: theme?.classNames,
|
|
2516
|
+
instanceSlotProps: props.slotProps,
|
|
2517
|
+
instanceClassNames: props.classNames
|
|
2518
|
+
});
|
|
2519
|
+
return (
|
|
2520
|
+
// The decorative role and the ring geometry are design-system
|
|
2521
|
+
// invariants (the value is announced by the root; the viewBox must
|
|
2522
|
+
// agree with the rail/arc circles) — layered after the spreads so
|
|
2523
|
+
// neither instance nor slot props can override them.
|
|
2524
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { ...nativeProps, ...rootAttrs, "aria-hidden": "true", focusable: "false", viewBox: RING_VIEWBOX, ref, children: [
|
|
2525
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { ...railAttrs, cx: RING_CENTER, cy: RING_CENTER, r: RING_RADIUS }),
|
|
2526
|
+
content
|
|
2527
|
+
] })
|
|
2528
|
+
);
|
|
2529
|
+
}
|
|
2530
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...nativeProps, ...rootAttrs, ref, children: content });
|
|
2531
|
+
};
|
|
2532
|
+
ProgressTrack.displayName = "Progress.Track";
|
|
2533
|
+
var resolveRange = ({ value: rawValue, min: rawMin = DEFAULT_MIN, max: rawMax = DEFAULT_MAX }) => {
|
|
2534
|
+
const min = Number.isFinite(rawMin) ? rawMin : DEFAULT_MIN;
|
|
2535
|
+
const max = Number.isFinite(rawMax) && rawMax > min ? rawMax : min + DEFAULT_RANGE;
|
|
2536
|
+
const value = typeof rawValue === "number" && Number.isFinite(rawValue) ? Math.min(Math.max(rawValue, min), max) : min;
|
|
2537
|
+
return { min, max, value };
|
|
2538
|
+
};
|
|
2539
|
+
var warnedRanges = /* @__PURE__ */ new Set();
|
|
2540
|
+
var Progress = (props) => {
|
|
2541
|
+
const theme = useComponentTheme("Progress");
|
|
2542
|
+
const field = spar.useOptionalFieldContext();
|
|
2543
|
+
const resolveState = ({
|
|
2544
|
+
indeterminate: indeterminate2 = false,
|
|
2545
|
+
appearance: appearance2 = DEFAULT_APPEARANCE6,
|
|
2546
|
+
size: size2 = DEFAULT_SIZE10,
|
|
2547
|
+
variant: variant2 = DEFAULT_VARIANT6,
|
|
2548
|
+
disabled: disabled2 = field?.disabled ?? false
|
|
2549
|
+
}) => ({ indeterminate: indeterminate2, appearance: appearance2, size: size2, variant: variant2, disabled: disabled2 });
|
|
2550
|
+
const { rootAttrs, rest } = composeRootAttrs(ProgressBase, props, theme);
|
|
2551
|
+
const {
|
|
2552
|
+
// Consumed through resolveState/resolveRange (and as the root data-* hooks
|
|
2553
|
+
// below); destructured so the <div> doesn't receive unknown DOM
|
|
2554
|
+
// attributes.
|
|
2555
|
+
value: _value,
|
|
2556
|
+
min: _min,
|
|
2557
|
+
max: rawMax,
|
|
2558
|
+
indeterminate: _indeterminate,
|
|
2559
|
+
appearance: _appearance,
|
|
2560
|
+
disabled: _disabled,
|
|
2561
|
+
size: _size,
|
|
2562
|
+
variant: _variant,
|
|
2563
|
+
as,
|
|
2564
|
+
children,
|
|
2565
|
+
ref,
|
|
2566
|
+
...nativeProps
|
|
2567
|
+
} = rest;
|
|
2568
|
+
const { indeterminate, appearance, size, variant, disabled } = resolveState(rest);
|
|
2569
|
+
const { min, max, value } = resolveRange(rest);
|
|
2570
|
+
const dataAttrs = {
|
|
2571
|
+
"data-type": appearance,
|
|
2572
|
+
"data-size": size,
|
|
2573
|
+
"data-variant": variant,
|
|
2574
|
+
"data-disabled": disabled ? "" : void 0,
|
|
2575
|
+
"data-indeterminate": indeterminate ? "" : void 0,
|
|
2576
|
+
// Styling hook for the finished state (e.g. a success fill at 100%);
|
|
2577
|
+
// meaningless while indeterminate, so dropped alongside the value.
|
|
2578
|
+
"data-complete": !indeterminate && value === max ? "" : void 0
|
|
2579
|
+
};
|
|
2580
|
+
if (isDevelopment() && typeof rawMax === "number" && Number.isFinite(rawMax) && rawMax <= min) {
|
|
2581
|
+
const message = `[Progress] \`max\` (${rawMax}) must be greater than \`min\` (${min}); falling back to ${max}.`;
|
|
2582
|
+
if (!warnedRanges.has(message)) {
|
|
2583
|
+
warnedRanges.add(message);
|
|
2584
|
+
console.warn(message);
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
const consumerLabelledBy = nativeProps["aria-labelledby"];
|
|
2588
|
+
const accessibilityAttrs = {
|
|
2589
|
+
"role": nativeProps.role ?? "progressbar",
|
|
2590
|
+
"aria-valuemin": min,
|
|
2591
|
+
"aria-valuemax": max,
|
|
2592
|
+
// Per the progressbar pattern, an indeterminate bar exposes no
|
|
2593
|
+
// aria-valuenow — assistive tech then announces it as busy rather than
|
|
2594
|
+
// stuck at a bogus percentage.
|
|
2595
|
+
"aria-valuenow": indeterminate ? void 0 : value,
|
|
2596
|
+
// aria-valuetext accompanies aria-valuenow; drop it while indeterminate so
|
|
2597
|
+
// a consumer-formatted value can't linger next to a busy bar.
|
|
2598
|
+
"aria-valuetext": indeterminate ? void 0 : nativeProps["aria-valuetext"],
|
|
2599
|
+
"aria-labelledby": consumerLabelledBy ?? field?.labelId,
|
|
2600
|
+
"aria-label": nativeProps["aria-label"] ?? (consumerLabelledBy ? void 0 : DEFAULT_ARIA_LABEL),
|
|
2601
|
+
"aria-disabled": disabled || void 0
|
|
2602
|
+
};
|
|
2603
|
+
const Component = as ?? "div";
|
|
2604
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ProgressProvider, { value: { value, min, max, appearance, indeterminate }, children: /* @__PURE__ */ jsxRuntime.jsx(Component, { ...nativeProps, ...accessibilityAttrs, ...rootAttrs, ...dataAttrs, ref, children: children ?? /* @__PURE__ */ jsxRuntime.jsx(ProgressTrack, {}) }) });
|
|
2605
|
+
};
|
|
2606
|
+
Progress.displayName = "Progress";
|
|
2607
|
+
var ProgressValue = (props) => {
|
|
2608
|
+
const theme = useComponentTheme("ProgressValue");
|
|
2609
|
+
const { appearance } = useProgressContext("Progress.Value");
|
|
2610
|
+
const { rootAttrs, rest } = composeRootAttrs(ProgressValueBase, props, theme, {
|
|
2611
|
+
stateAttrs: () => ({ "data-type": appearance })
|
|
2612
|
+
});
|
|
2613
|
+
const { children, ref, ...nativeProps } = rest;
|
|
2614
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...nativeProps, ...rootAttrs, "aria-hidden": "true", ref, children });
|
|
2615
|
+
};
|
|
2616
|
+
ProgressValue.displayName = "Progress.Value";
|
|
2617
|
+
|
|
2618
|
+
// src/components/progress/index.ts
|
|
2619
|
+
var Progress2 = Object.assign(Progress, {
|
|
2620
|
+
Track: ProgressTrack,
|
|
2621
|
+
Indicator: ProgressIndicator,
|
|
2622
|
+
Value: ProgressValue
|
|
2623
|
+
});
|
|
2624
|
+
|
|
2259
2625
|
// src/components/select/base.ts
|
|
2260
2626
|
var SelectBase = createComponentBase({
|
|
2261
2627
|
name: "Select",
|
|
@@ -2286,6 +2652,11 @@ var SelectContentBase = createComponentBase({
|
|
|
2286
2652
|
slots: ["root"],
|
|
2287
2653
|
classes: { root: "tk-select-content" }
|
|
2288
2654
|
});
|
|
2655
|
+
var SelectViewportBase = createComponentBase({
|
|
2656
|
+
name: "SelectViewport",
|
|
2657
|
+
slots: ["root"],
|
|
2658
|
+
classes: { root: "tk-select-viewport" }
|
|
2659
|
+
});
|
|
2289
2660
|
var SelectItemBase = createComponentBase({
|
|
2290
2661
|
name: "SelectItem",
|
|
2291
2662
|
slots: ["root"],
|
|
@@ -2306,22 +2677,27 @@ var SelectSeparatorBase = createComponentBase({
|
|
|
2306
2677
|
slots: ["root"],
|
|
2307
2678
|
classes: { root: "tk-select-separator" }
|
|
2308
2679
|
});
|
|
2680
|
+
var SelectArrowBase = createComponentBase({
|
|
2681
|
+
name: "SelectArrow",
|
|
2682
|
+
slots: ["root"],
|
|
2683
|
+
classes: { root: "tk-select-arrow" }
|
|
2684
|
+
});
|
|
2309
2685
|
|
|
2310
2686
|
// src/components/select/context.ts
|
|
2311
2687
|
var [SelectProvider, useSelectOwnContext] = createSafeContext("SelectProvider");
|
|
2312
2688
|
|
|
2313
2689
|
// src/components/select/defaults.ts
|
|
2314
|
-
var
|
|
2315
|
-
var
|
|
2690
|
+
var DEFAULT_SIZE11 = "base";
|
|
2691
|
+
var DEFAULT_CONTENT_WIDTH2 = "trigger";
|
|
2316
2692
|
var Select = (props) => {
|
|
2317
2693
|
const theme = useComponentTheme("Select");
|
|
2318
2694
|
const { rootAttrs, rest } = composeRootAttrs(SelectBase, props, theme, {
|
|
2319
|
-
stateAttrs: ({ size: size2 =
|
|
2695
|
+
stateAttrs: ({ size: size2 = DEFAULT_SIZE11, invalid: invalid2 }) => ({
|
|
2320
2696
|
"data-size": size2,
|
|
2321
2697
|
"data-invalid": invalid2 ? "" : void 0
|
|
2322
2698
|
})
|
|
2323
2699
|
});
|
|
2324
|
-
const { size =
|
|
2700
|
+
const { size = DEFAULT_SIZE11, invalid = false, contentWidth = DEFAULT_CONTENT_WIDTH2, children, ref, ...sparProps } = rest;
|
|
2325
2701
|
return /* @__PURE__ */ jsxRuntime.jsx(SelectProvider, { value: { size, invalid, contentWidth }, children: /* @__PURE__ */ jsxRuntime.jsx(spar.Select, { ...sparProps, ref, ...rootAttrs, children }) });
|
|
2326
2702
|
};
|
|
2327
2703
|
Select.displayName = "Select";
|
|
@@ -2372,44 +2748,29 @@ var SelectIndicator = (props) => {
|
|
|
2372
2748
|
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...rendered, ref, "aria-hidden": "true", ...rootAttrs, children: resolved });
|
|
2373
2749
|
};
|
|
2374
2750
|
SelectIndicator.displayName = "Select.Indicator";
|
|
2375
|
-
var resolveStaticWidth = (mode) => {
|
|
2376
|
-
if (mode === "trigger" || mode === "content") return void 0;
|
|
2377
|
-
return typeof mode === "number" ? `${mode}px` : mode;
|
|
2378
|
-
};
|
|
2379
2751
|
var SelectContent = (props) => {
|
|
2380
2752
|
const theme = useComponentTheme("SelectContent");
|
|
2381
2753
|
const { size, contentWidth } = useSelectOwnContext("Select.Content");
|
|
2382
2754
|
const { triggerRef } = spar.useSelectContext();
|
|
2383
|
-
const
|
|
2384
|
-
react.useEffect(() => {
|
|
2385
|
-
if (contentWidth !== "trigger") return;
|
|
2386
|
-
const node = triggerRef.current;
|
|
2387
|
-
if (!node) return;
|
|
2388
|
-
setTriggerWidth(node.offsetWidth);
|
|
2389
|
-
const observer = new ResizeObserver((entries) => {
|
|
2390
|
-
const entry = entries[0];
|
|
2391
|
-
if (entry) setTriggerWidth(Math.round(entry.contentRect.width + 2));
|
|
2392
|
-
});
|
|
2393
|
-
observer.observe(node);
|
|
2394
|
-
return () => observer.disconnect();
|
|
2395
|
-
}, [contentWidth, triggerRef]);
|
|
2755
|
+
const widthStyle = useContentWidthStyle(contentWidth, triggerRef);
|
|
2396
2756
|
const { rootAttrs, rest } = composeRootAttrs(SelectContentBase, props, theme, {
|
|
2397
2757
|
stateAttrs: () => ({
|
|
2398
2758
|
"data-size": size
|
|
2399
2759
|
})
|
|
2400
2760
|
});
|
|
2401
2761
|
const { children, ref, style: userStyle, ...spar$1 } = rest;
|
|
2402
|
-
const
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
}
|
|
2406
|
-
const staticWidth = resolveStaticWidth(contentWidth);
|
|
2407
|
-
return staticWidth != null ? { width: staticWidth } : void 0;
|
|
2408
|
-
}, [contentWidth, triggerWidth]);
|
|
2409
|
-
const mergedStyle = widthStyle || userStyle ? { ...widthStyle, ...userStyle } : void 0;
|
|
2410
|
-
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectContent, { ...spar$1, ref, style: mergedStyle, ...rootAttrs, children });
|
|
2762
|
+
const { style: rootStyle, ...rootRest } = rootAttrs;
|
|
2763
|
+
const mergedStyle = widthStyle || rootStyle || userStyle ? { ...widthStyle, ...rootStyle, ...userStyle } : void 0;
|
|
2764
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectContent, { ...spar$1, ...rootRest, ref, style: mergedStyle, children });
|
|
2411
2765
|
};
|
|
2412
2766
|
SelectContent.displayName = "Select.Content";
|
|
2767
|
+
var SelectViewport = (props) => {
|
|
2768
|
+
const theme = useComponentTheme("SelectViewport");
|
|
2769
|
+
const { rootAttrs, rest } = composeRootAttrs(SelectViewportBase, props, theme);
|
|
2770
|
+
const { children, ref, ...spar$1 } = rest;
|
|
2771
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectViewport, { ...spar$1, ref, ...rootAttrs, children });
|
|
2772
|
+
};
|
|
2773
|
+
SelectViewport.displayName = "Select.Viewport";
|
|
2413
2774
|
var SelectItem = (props) => {
|
|
2414
2775
|
const theme = useComponentTheme("SelectItem");
|
|
2415
2776
|
const { rootAttrs, rest } = composeRootAttrs(SelectItemBase, props, theme);
|
|
@@ -2438,90 +2799,1007 @@ var SelectSeparator = (props) => {
|
|
|
2438
2799
|
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectSeparator, { ...spar$1, ref, ...rootAttrs, children });
|
|
2439
2800
|
};
|
|
2440
2801
|
SelectSeparator.displayName = "Select.Separator";
|
|
2802
|
+
var SelectArrow = (props) => {
|
|
2803
|
+
const theme = useComponentTheme("SelectArrow");
|
|
2804
|
+
const { rootAttrs, rest } = composeRootAttrs(SelectArrowBase, props, theme);
|
|
2805
|
+
const { children, ref, ...sparProps } = rest;
|
|
2806
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.SelectArrow, { ...sparProps, ...rootAttrs, ref, children: children ?? renderPointerArrow() });
|
|
2807
|
+
};
|
|
2808
|
+
SelectArrow.displayName = "Select.Arrow";
|
|
2441
2809
|
|
|
2442
2810
|
// src/components/select/index.ts
|
|
2443
2811
|
var Select2 = Object.assign(Select, {
|
|
2444
2812
|
Trigger: SelectTrigger,
|
|
2445
2813
|
Indicator: SelectIndicator,
|
|
2446
2814
|
Content: SelectContent,
|
|
2815
|
+
Viewport: SelectViewport,
|
|
2447
2816
|
Item: SelectItem,
|
|
2448
2817
|
Group: SelectGroup,
|
|
2449
2818
|
Label: SelectLabel,
|
|
2450
|
-
Separator: SelectSeparator
|
|
2819
|
+
Separator: SelectSeparator,
|
|
2820
|
+
Arrow: SelectArrow
|
|
2451
2821
|
});
|
|
2452
2822
|
|
|
2453
|
-
// src/components/
|
|
2454
|
-
var
|
|
2455
|
-
name: "
|
|
2456
|
-
slots: ["root"
|
|
2457
|
-
classes: {
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2823
|
+
// src/components/slider/base.ts
|
|
2824
|
+
var SliderBase = createComponentBase({
|
|
2825
|
+
name: "Slider",
|
|
2826
|
+
slots: ["root"],
|
|
2827
|
+
classes: { root: "tk-slider" }
|
|
2828
|
+
});
|
|
2829
|
+
var SliderTrackBase = createComponentBase({
|
|
2830
|
+
name: "SliderTrack",
|
|
2831
|
+
slots: ["root"],
|
|
2832
|
+
classes: { root: "tk-slider-track" }
|
|
2833
|
+
});
|
|
2834
|
+
var SliderRangeBase = createComponentBase({
|
|
2835
|
+
name: "SliderRange",
|
|
2836
|
+
slots: ["root"],
|
|
2837
|
+
classes: { root: "tk-slider-range" }
|
|
2838
|
+
});
|
|
2839
|
+
var SliderThumbBase = createComponentBase({
|
|
2840
|
+
name: "SliderThumb",
|
|
2841
|
+
slots: ["root", "tooltip", "arrow"],
|
|
2842
|
+
classes: { root: "tk-slider-thumb", tooltip: "tk-slider-tooltip", arrow: "tk-slider-arrow" }
|
|
2843
|
+
});
|
|
2844
|
+
var SliderTicksBase = createComponentBase({
|
|
2845
|
+
name: "SliderTicks",
|
|
2846
|
+
slots: ["root", "tick"],
|
|
2847
|
+
classes: { root: "tk-slider-ticks", tick: "tk-slider-tick" }
|
|
2848
|
+
});
|
|
2849
|
+
var SliderValueBase = createComponentBase({
|
|
2850
|
+
name: "SliderValue",
|
|
2851
|
+
slots: ["root"],
|
|
2852
|
+
classes: { root: "tk-slider-value" }
|
|
2461
2853
|
});
|
|
2462
2854
|
|
|
2463
|
-
// src/components/
|
|
2464
|
-
var
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
var
|
|
2468
|
-
var
|
|
2469
|
-
var
|
|
2470
|
-
var
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2855
|
+
// src/components/slider/context.ts
|
|
2856
|
+
var [SliderProvider, useSliderContext] = createSafeContext("SliderProvider");
|
|
2857
|
+
|
|
2858
|
+
// src/components/slider/defaults.ts
|
|
2859
|
+
var DEFAULT_ORIENTATION2 = "horizontal";
|
|
2860
|
+
var DEFAULT_SIZE12 = "base";
|
|
2861
|
+
var DEFAULT_VARIANT7 = "primary";
|
|
2862
|
+
var DEFAULT_TOOLTIP = "auto";
|
|
2863
|
+
var DEFAULT_TRACK = "normal";
|
|
2864
|
+
var DEFAULT_MIN_DISTANCE = 0;
|
|
2865
|
+
var DEFAULT_MIN2 = 0;
|
|
2866
|
+
var DEFAULT_MAX2 = 100;
|
|
2867
|
+
var DEFAULT_STEP = 1;
|
|
2868
|
+
var DEFAULT_SPAN = 100;
|
|
2869
|
+
var PAGE_STEP_MULTIPLIER = 10;
|
|
2870
|
+
var MAX_TICKS = 100;
|
|
2871
|
+
var RANGE_VALUE_SEPARATOR = " \u2013 ";
|
|
2872
|
+
var RANGE_THUMB_LABELS = ["Minimum", "Maximum"];
|
|
2873
|
+
|
|
2874
|
+
// src/components/slider/helpers.ts
|
|
2875
|
+
var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
2876
|
+
var decimalsOf = (value) => {
|
|
2877
|
+
if (!Number.isFinite(value)) return 0;
|
|
2878
|
+
const text = String(value);
|
|
2879
|
+
const exponent = text.indexOf("e-");
|
|
2880
|
+
if (exponent !== -1) {
|
|
2881
|
+
const fraction = text.slice(0, exponent).split(".")[1]?.length ?? 0;
|
|
2882
|
+
return fraction + Number(text.slice(exponent + 2));
|
|
2479
2883
|
}
|
|
2480
|
-
|
|
2481
|
-
|
|
2884
|
+
const dot = text.indexOf(".");
|
|
2885
|
+
return dot === -1 ? 0 : text.length - dot - 1;
|
|
2886
|
+
};
|
|
2887
|
+
var roundTo = (value, decimals) => decimals > 0 ? Number(value.toFixed(Math.min(decimals, 15))) : Math.round(value);
|
|
2888
|
+
var resolveBounds = (rawMin = DEFAULT_MIN2, rawMax = DEFAULT_MAX2, rawStep = DEFAULT_STEP) => {
|
|
2889
|
+
const min = Number.isFinite(rawMin) ? rawMin : DEFAULT_MIN2;
|
|
2890
|
+
const max = Number.isFinite(rawMax) && rawMax > min ? rawMax : min + DEFAULT_SPAN;
|
|
2891
|
+
const step = Number.isFinite(rawStep) && rawStep > 0 ? rawStep : DEFAULT_STEP;
|
|
2892
|
+
return { min, max, step };
|
|
2893
|
+
};
|
|
2894
|
+
var snap = (value, { min, max, step }) => {
|
|
2895
|
+
if (!Number.isFinite(value)) return min;
|
|
2896
|
+
const steps = Math.round((value - min) / step);
|
|
2897
|
+
const snapped = min + steps * step;
|
|
2898
|
+
return clamp(roundTo(snapped, Math.max(decimalsOf(step), decimalsOf(min))), min, max);
|
|
2899
|
+
};
|
|
2900
|
+
var toPercent = (value, { min, max }) => clamp((value - min) * 100 / (max - min), 0, 100);
|
|
2901
|
+
var fromRatio = (ratio, { min, max }) => min + ratio * (max - min);
|
|
2902
|
+
var pointerCoord = (event, orientation) => orientation === "vertical" ? event.clientY : event.clientX;
|
|
2903
|
+
var valueFromPointer = (rect, point, bounds, orientation) => {
|
|
2904
|
+
const ratio = orientation === "vertical" ? rect.height === 0 ? 0 : (rect.bottom - point) / rect.height : rect.width === 0 ? 0 : (point - rect.left) / rect.width;
|
|
2905
|
+
return snap(fromRatio(clamp(ratio, 0, 1), bounds), bounds);
|
|
2906
|
+
};
|
|
2907
|
+
var offsetStyle = (percent, orientation) => orientation === "vertical" ? { insetBlockEnd: `${percent}%` } : { insetInlineStart: `${percent}%` };
|
|
2908
|
+
var bandStyle = (start, end, orientation) => orientation === "vertical" ? { insetBlockEnd: `${start}%`, height: `${end - start}%` } : { insetInlineStart: `${start}%`, width: `${end - start}%` };
|
|
2909
|
+
var normalizeValues = (value, range, bounds) => {
|
|
2910
|
+
if (range) {
|
|
2911
|
+
const seeded = Array.isArray(value) && value.length >= 2 ? value : [bounds.min, bounds.max];
|
|
2912
|
+
return seeded.map((entry) => snap(entry, bounds)).sort((a, b) => a - b);
|
|
2482
2913
|
}
|
|
2483
|
-
|
|
2484
|
-
|
|
2914
|
+
return [snap(Array.isArray(value) ? value[0] : value ?? bounds.min, bounds)];
|
|
2915
|
+
};
|
|
2916
|
+
var toCommittedValue = (values, range) => range ? [...values] : values[0];
|
|
2917
|
+
var rangeInputName = (name, index, count) => count === 2 ? index === 0 ? `${name}-min` : `${name}-max` : `${name}-${index + 1}`;
|
|
2918
|
+
var valuesEqual = (a, b) => a.length === b.length && a.every((entry, index) => entry === b[index]);
|
|
2919
|
+
var thumbLabel = (index, count) => {
|
|
2920
|
+
if (count < 2) return void 0;
|
|
2921
|
+
if (count === 2) return RANGE_THUMB_LABELS[index];
|
|
2922
|
+
return `Value ${index + 1}`;
|
|
2923
|
+
};
|
|
2924
|
+
var closestThumbIndex = (values, target, disabled = []) => {
|
|
2925
|
+
let index = 0;
|
|
2926
|
+
let best = Infinity;
|
|
2927
|
+
let found = false;
|
|
2928
|
+
values.forEach((entry, current) => {
|
|
2929
|
+
if (disabled[current]) return;
|
|
2930
|
+
const distance = Math.abs(entry - target);
|
|
2931
|
+
if (distance <= best) {
|
|
2932
|
+
best = distance;
|
|
2933
|
+
index = current;
|
|
2934
|
+
found = true;
|
|
2935
|
+
}
|
|
2936
|
+
});
|
|
2937
|
+
if (found) return index;
|
|
2938
|
+
values.forEach((entry, current) => {
|
|
2939
|
+
const distance = Math.abs(entry - target);
|
|
2940
|
+
if (distance <= best) {
|
|
2941
|
+
best = distance;
|
|
2942
|
+
index = current;
|
|
2943
|
+
}
|
|
2944
|
+
});
|
|
2945
|
+
return index;
|
|
2946
|
+
};
|
|
2947
|
+
var thumbBounds = (values, index, bounds, minDistance = 0) => {
|
|
2948
|
+
const hardLower = index > 0 ? values[index - 1] : bounds.min;
|
|
2949
|
+
const hardUpper = index < values.length - 1 ? values[index + 1] : bounds.max;
|
|
2950
|
+
const lower = index > 0 ? hardLower + minDistance : bounds.min;
|
|
2951
|
+
const upper = index < values.length - 1 ? hardUpper - minDistance : bounds.max;
|
|
2952
|
+
return lower <= upper ? { min: lower, max: upper } : { min: hardLower, max: hardUpper };
|
|
2953
|
+
};
|
|
2954
|
+
var withThumbClamped = (values, index, next, bounds, minDistance = 0) => {
|
|
2955
|
+
const { min: lower, max: upper } = thumbBounds(values, index, bounds, minDistance);
|
|
2956
|
+
const updated = [...values];
|
|
2957
|
+
updated[index] = clamp(snap(next, bounds), lower, upper);
|
|
2958
|
+
return updated;
|
|
2959
|
+
};
|
|
2960
|
+
var withThumbSwapped = (values, index, next, bounds, minDistance = 0, disabled = []) => {
|
|
2961
|
+
const lowerBlocked = index > 0 && disabled[index - 1];
|
|
2962
|
+
const upperBlocked = index < values.length - 1 && disabled[index + 1];
|
|
2963
|
+
if (minDistance > 0 || lowerBlocked || upperBlocked) {
|
|
2964
|
+
const { min: lower, max: upper } = thumbBounds(values, index, bounds, minDistance);
|
|
2965
|
+
const updated2 = [...values];
|
|
2966
|
+
updated2[index] = clamp(snap(next, bounds), lower, upper);
|
|
2967
|
+
return { values: updated2, index };
|
|
2485
2968
|
}
|
|
2486
|
-
|
|
2487
|
-
|
|
2969
|
+
const updated = [...values];
|
|
2970
|
+
updated[index] = snap(next, bounds);
|
|
2971
|
+
let active = index;
|
|
2972
|
+
while (active > 0 && updated[active] < updated[active - 1]) {
|
|
2973
|
+
[updated[active], updated[active - 1]] = [updated[active - 1], updated[active]];
|
|
2974
|
+
active -= 1;
|
|
2488
2975
|
}
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
{
|
|
2493
|
-
clipRule: "evenodd",
|
|
2494
|
-
d: "M24 0C10.7452 0 0 10.7452 0 24C0 37.2548 10.7452 48 24 48C37.2548 48 48 37.2548 48 24V4C48 1.79086 46.2091 0 44 0H24ZM24 8C15.1634 8 8 15.1634 8 24C8 32.8366 15.1634 40 24 40C32.8366 40 40 32.8366 40 24C40 15.1634 32.8366 8 24 8Z",
|
|
2495
|
-
fillRule: "evenodd"
|
|
2496
|
-
}
|
|
2497
|
-
) });
|
|
2976
|
+
while (active < updated.length - 1 && updated[active] > updated[active + 1]) {
|
|
2977
|
+
[updated[active], updated[active + 1]] = [updated[active + 1], updated[active]];
|
|
2978
|
+
active += 1;
|
|
2498
2979
|
}
|
|
2499
|
-
return
|
|
2500
|
-
};
|
|
2501
|
-
var
|
|
2502
|
-
|
|
2503
|
-
const
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2980
|
+
return { values: updated, index: active };
|
|
2981
|
+
};
|
|
2982
|
+
var formatValueText = (value, formatValue) => formatValue?.(value) ?? String(value);
|
|
2983
|
+
var tickPercents = ({ min, max, step }, limit) => {
|
|
2984
|
+
const raw = (max - min) / step;
|
|
2985
|
+
const steps = Math.abs(raw - Math.round(raw)) < 1e-9 ? Math.round(raw) : Math.floor(raw);
|
|
2986
|
+
const count = steps + 1;
|
|
2987
|
+
if (count > limit) return null;
|
|
2988
|
+
return Array.from({ length: count }, (_, index) => toPercent(min + index * step, { min, max}));
|
|
2989
|
+
};
|
|
2990
|
+
var SliderRange = (props) => {
|
|
2991
|
+
const theme = useComponentTheme("SliderRange");
|
|
2992
|
+
const { values, bounds, range, orientation } = useSliderContext("Slider.Range");
|
|
2993
|
+
const start = range ? toPercent(values[0], bounds) : 0;
|
|
2994
|
+
const end = toPercent(range ? values[values.length - 1] : values[0], bounds);
|
|
2995
|
+
const { rootAttrs, rest } = composeRootAttrs(SliderRangeBase, props, theme);
|
|
2996
|
+
const { ref, style, ...nativeProps } = rest;
|
|
2997
|
+
const { style: slotStyle, ...slotAttrs } = rootAttrs;
|
|
2998
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...nativeProps, ...slotAttrs, "aria-hidden": "true", style: { ...style, ...slotStyle, ...bandStyle(start, end, orientation) }, ref });
|
|
2999
|
+
};
|
|
3000
|
+
SliderRange.displayName = "Slider.Range";
|
|
3001
|
+
var SliderThumb = (props) => {
|
|
3002
|
+
const theme = useComponentTheme("SliderThumb");
|
|
3003
|
+
const {
|
|
3004
|
+
values,
|
|
3005
|
+
bounds,
|
|
3006
|
+
range,
|
|
3007
|
+
minDistance,
|
|
3008
|
+
orientation,
|
|
3009
|
+
disabled,
|
|
3010
|
+
readOnly,
|
|
3011
|
+
invalid,
|
|
3012
|
+
required,
|
|
3013
|
+
draggingIndex,
|
|
3014
|
+
formatValue,
|
|
3015
|
+
setThumbValue,
|
|
3016
|
+
startDrag,
|
|
3017
|
+
thumbRefs,
|
|
3018
|
+
thumbDisabledRef,
|
|
3019
|
+
fieldId,
|
|
3020
|
+
labelId,
|
|
3021
|
+
describedBy,
|
|
3022
|
+
rootAriaLabel,
|
|
3023
|
+
rootAriaLabelledby
|
|
3024
|
+
} = useSliderContext("Slider.Thumb");
|
|
3025
|
+
const [isFocused, setIsFocused] = react.useState(false);
|
|
3026
|
+
const { rootAttrs, rest } = composeRootAttrs(SliderThumbBase, props, theme);
|
|
3027
|
+
const { index = 0, disabled: ownDisabled, children, ref, style, onKeyDown, onPointerDown, onFocus, onBlur, ...nativeProps } = rest;
|
|
3028
|
+
const value = values[index] ?? bounds.min;
|
|
3029
|
+
const isDragging = draggingIndex === index;
|
|
3030
|
+
const isDisabled = disabled || Boolean(ownDisabled);
|
|
3031
|
+
thumbDisabledRef.current[index] = isDisabled;
|
|
3032
|
+
const { min: lowerBound, max: upperBound } = thumbBounds(values, index, bounds, minDistance);
|
|
3033
|
+
const handleKeyDown = (event) => {
|
|
3034
|
+
onKeyDown?.(event);
|
|
3035
|
+
if (isDisabled || readOnly || event.defaultPrevented) return;
|
|
3036
|
+
const page = bounds.step * PAGE_STEP_MULTIPLIER;
|
|
3037
|
+
const next = {
|
|
3038
|
+
ArrowRight: value + bounds.step,
|
|
3039
|
+
ArrowUp: value + bounds.step,
|
|
3040
|
+
ArrowLeft: value - bounds.step,
|
|
3041
|
+
ArrowDown: value - bounds.step,
|
|
3042
|
+
PageUp: value + page,
|
|
3043
|
+
PageDown: value - page,
|
|
3044
|
+
Home: bounds.min,
|
|
3045
|
+
End: bounds.max
|
|
3046
|
+
}[event.key];
|
|
3047
|
+
if (next === void 0) return;
|
|
3048
|
+
event.preventDefault();
|
|
3049
|
+
setThumbValue(index, next);
|
|
3050
|
+
};
|
|
3051
|
+
const handlePointerDown = (event) => {
|
|
3052
|
+
onPointerDown?.(event);
|
|
3053
|
+
if (isDisabled || readOnly || event.defaultPrevented || event.button !== 0) return;
|
|
3054
|
+
event.preventDefault();
|
|
3055
|
+
event.stopPropagation();
|
|
3056
|
+
startDrag(index, pointerCoord(event, orientation), false, event.pointerId);
|
|
3057
|
+
};
|
|
3058
|
+
const tooltipAttrs = buildSlotAttrs(SliderThumbBase.getSlotProps("tooltip"), "tooltip", {
|
|
3059
|
+
themeSlotProps: theme?.slotProps,
|
|
3060
|
+
themeClassNames: theme?.classNames,
|
|
3061
|
+
instanceSlotProps: props.slotProps,
|
|
3062
|
+
instanceClassNames: props.classNames
|
|
2509
3063
|
});
|
|
2510
|
-
const
|
|
2511
|
-
const indicatorSlotAttrs = buildSlotAttrs(SpinnerBase.getSlotProps("indicator"), "indicator", {
|
|
3064
|
+
const arrowAttrs = buildSlotAttrs(SliderThumbBase.getSlotProps("arrow"), "arrow", {
|
|
2512
3065
|
themeSlotProps: theme?.slotProps,
|
|
2513
3066
|
themeClassNames: theme?.classNames,
|
|
2514
3067
|
instanceSlotProps: props.slotProps,
|
|
2515
3068
|
instanceClassNames: props.classNames
|
|
2516
3069
|
});
|
|
2517
|
-
const
|
|
2518
|
-
const
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
3070
|
+
const formattedText = formatValueText(value, formatValue);
|
|
3071
|
+
const formatted = formatValue ? formattedText : void 0;
|
|
3072
|
+
const { style: slotStyle, ...slotAttrs } = rootAttrs;
|
|
3073
|
+
const bubbleContent = children === void 0 ? formattedText : typeof children === "function" ? children({ value, formatted: formattedText, index, isDragging, isFocused }) : children;
|
|
3074
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3075
|
+
"span",
|
|
3076
|
+
{
|
|
3077
|
+
...nativeProps,
|
|
3078
|
+
...slotAttrs,
|
|
3079
|
+
role: "slider",
|
|
3080
|
+
tabIndex: isDisabled ? -1 : 0,
|
|
3081
|
+
"aria-valuemin": lowerBound,
|
|
3082
|
+
"aria-valuemax": upperBound,
|
|
3083
|
+
"aria-valuenow": value,
|
|
3084
|
+
"aria-valuetext": formatted,
|
|
3085
|
+
"aria-orientation": orientation,
|
|
3086
|
+
"aria-disabled": isDisabled || void 0,
|
|
3087
|
+
"aria-readonly": readOnly || void 0,
|
|
3088
|
+
"aria-invalid": invalid || void 0,
|
|
3089
|
+
"aria-required": required || void 0,
|
|
3090
|
+
"aria-label": nativeProps["aria-label"] ?? thumbLabel(index, values.length) ?? rootAriaLabel,
|
|
3091
|
+
"aria-labelledby": nativeProps["aria-labelledby"] ?? (range ? void 0 : rootAriaLabelledby ?? labelId),
|
|
3092
|
+
"aria-describedby": nativeProps["aria-describedby"] ?? describedBy,
|
|
3093
|
+
id: nativeProps.id ?? (index === 0 ? fieldId : void 0),
|
|
3094
|
+
"data-thumb": range ? index === 0 ? "min" : index === values.length - 1 ? "max" : void 0 : void 0,
|
|
3095
|
+
"data-dragging": isDragging ? "" : void 0,
|
|
3096
|
+
"data-focus": isFocused ? "" : void 0,
|
|
3097
|
+
"data-disabled": isDisabled ? "" : void 0,
|
|
3098
|
+
onKeyDown: handleKeyDown,
|
|
3099
|
+
onPointerDown: handlePointerDown,
|
|
3100
|
+
onFocus: (event) => {
|
|
3101
|
+
onFocus?.(event);
|
|
3102
|
+
setIsFocused(true);
|
|
3103
|
+
},
|
|
3104
|
+
onBlur: (event) => {
|
|
3105
|
+
onBlur?.(event);
|
|
3106
|
+
setIsFocused(false);
|
|
3107
|
+
},
|
|
3108
|
+
style: { ...style, ...slotStyle, ...offsetStyle(toPercent(value, bounds), orientation) },
|
|
3109
|
+
ref: (node) => {
|
|
3110
|
+
thumbRefs.current[index] = node;
|
|
3111
|
+
if (typeof ref === "function") ref(node);
|
|
3112
|
+
else if (ref) ref.current = node;
|
|
3113
|
+
},
|
|
3114
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("span", { ...tooltipAttrs, "aria-hidden": "true", children: [
|
|
3115
|
+
bubbleContent,
|
|
3116
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { ...arrowAttrs, "aria-hidden": "true" })
|
|
3117
|
+
] })
|
|
3118
|
+
}
|
|
3119
|
+
);
|
|
3120
|
+
};
|
|
3121
|
+
SliderThumb.displayName = "Slider.Thumb";
|
|
3122
|
+
var SliderTrack = (props) => {
|
|
3123
|
+
const theme = useComponentTheme("SliderTrack");
|
|
3124
|
+
const { values, disabled, readOnly, orientation, valueFromPoint, startDrag, trackRef, thumbDisabledRef } = useSliderContext("Slider.Track");
|
|
3125
|
+
const { rootAttrs, rest } = composeRootAttrs(SliderTrackBase, props, theme);
|
|
3126
|
+
const { children, ref, onPointerDown, ...nativeProps } = rest;
|
|
3127
|
+
const handlePointerDown = (event) => {
|
|
3128
|
+
onPointerDown?.(event);
|
|
3129
|
+
if (disabled || readOnly || event.defaultPrevented || event.button !== 0) return;
|
|
3130
|
+
event.preventDefault();
|
|
3131
|
+
const point = pointerCoord(event, orientation);
|
|
3132
|
+
startDrag(closestThumbIndex(values, valueFromPoint(point), thumbDisabledRef.current), point, true, event.pointerId);
|
|
3133
|
+
};
|
|
3134
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3135
|
+
"div",
|
|
3136
|
+
{
|
|
3137
|
+
...nativeProps,
|
|
3138
|
+
...rootAttrs,
|
|
3139
|
+
onPointerDown: handlePointerDown,
|
|
3140
|
+
ref: (node) => {
|
|
3141
|
+
trackRef.current = node;
|
|
3142
|
+
if (typeof ref === "function") ref(node);
|
|
3143
|
+
else if (ref) ref.current = node;
|
|
3144
|
+
},
|
|
3145
|
+
children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3146
|
+
/* @__PURE__ */ jsxRuntime.jsx(SliderRange, {}),
|
|
3147
|
+
values.map((_, index) => /* @__PURE__ */ jsxRuntime.jsx(SliderThumb, { index }, index))
|
|
3148
|
+
] })
|
|
3149
|
+
}
|
|
3150
|
+
);
|
|
3151
|
+
};
|
|
3152
|
+
SliderTrack.displayName = "Slider.Track";
|
|
3153
|
+
var warnedRanges2 = /* @__PURE__ */ new Set();
|
|
3154
|
+
var Slider = (props) => {
|
|
3155
|
+
const theme = useComponentTheme("Slider");
|
|
3156
|
+
const field = spar.useOptionalFieldContext();
|
|
3157
|
+
const { rootAttrs, rest } = composeRootAttrs(SliderBase, props, theme, {
|
|
3158
|
+
stateAttrs: (merged) => {
|
|
3159
|
+
const {
|
|
3160
|
+
size = DEFAULT_SIZE12,
|
|
3161
|
+
variant = DEFAULT_VARIANT7,
|
|
3162
|
+
orientation: orientation2 = DEFAULT_ORIENTATION2,
|
|
3163
|
+
tooltip = DEFAULT_TOOLTIP,
|
|
3164
|
+
track = DEFAULT_TRACK,
|
|
3165
|
+
range: range2,
|
|
3166
|
+
disabled: disabled2,
|
|
3167
|
+
readOnly: readOnly2,
|
|
3168
|
+
invalid: invalid2,
|
|
3169
|
+
required: required2
|
|
3170
|
+
} = merged;
|
|
3171
|
+
return {
|
|
3172
|
+
"data-size": size,
|
|
3173
|
+
"data-variant": variant,
|
|
3174
|
+
"data-orientation": orientation2,
|
|
3175
|
+
"data-tooltip": tooltip,
|
|
3176
|
+
"data-track": track,
|
|
3177
|
+
"data-range": range2 ? "" : void 0,
|
|
3178
|
+
"data-disabled": disabled2 ?? field?.disabled ? "" : void 0,
|
|
3179
|
+
"data-readonly": readOnly2 ?? field?.readOnly ? "" : void 0,
|
|
3180
|
+
"data-invalid": invalid2 ?? field?.invalid ? "" : void 0,
|
|
3181
|
+
"data-required": required2 ?? field?.required ? "" : void 0
|
|
3182
|
+
};
|
|
3183
|
+
}
|
|
3184
|
+
});
|
|
3185
|
+
const {
|
|
3186
|
+
// Consumed through the resolved state below (and as the root data-* hooks);
|
|
3187
|
+
// destructured so the <div> doesn't receive unknown DOM attributes.
|
|
3188
|
+
min: rawMin,
|
|
3189
|
+
max: rawMax,
|
|
3190
|
+
step: rawStep,
|
|
3191
|
+
range = false,
|
|
3192
|
+
value,
|
|
3193
|
+
defaultValue,
|
|
3194
|
+
onValueChange,
|
|
3195
|
+
onValueChangeEnd,
|
|
3196
|
+
disabled: ownDisabled,
|
|
3197
|
+
readOnly: ownReadOnly,
|
|
3198
|
+
invalid: ownInvalid,
|
|
3199
|
+
required: ownRequired,
|
|
3200
|
+
minDistance = DEFAULT_MIN_DISTANCE,
|
|
3201
|
+
orientation = DEFAULT_ORIENTATION2,
|
|
3202
|
+
size: _size,
|
|
3203
|
+
variant: _variant,
|
|
3204
|
+
// Consumed as the `data-tooltip` / `data-track` root hooks above (the recipe
|
|
3205
|
+
// drives the value bubble and the inverted/none fill off them); pulled out
|
|
3206
|
+
// so they never land on the <div> as unknown attributes.
|
|
3207
|
+
tooltip: _tooltip,
|
|
3208
|
+
track: _track,
|
|
3209
|
+
formatValue,
|
|
3210
|
+
name,
|
|
3211
|
+
form,
|
|
3212
|
+
as,
|
|
3213
|
+
children,
|
|
3214
|
+
ref,
|
|
3215
|
+
...nativeProps
|
|
3216
|
+
} = rest;
|
|
3217
|
+
const disabled = ownDisabled ?? field?.disabled ?? false;
|
|
3218
|
+
const readOnly = ownReadOnly ?? field?.readOnly ?? false;
|
|
3219
|
+
const invalid = ownInvalid ?? field?.invalid ?? false;
|
|
3220
|
+
const required = ownRequired ?? field?.required ?? false;
|
|
3221
|
+
const bounds = resolveBounds(rawMin, rawMax, rawStep);
|
|
3222
|
+
if (isDevelopment() && typeof rawMax === "number" && Number.isFinite(rawMax) && rawMax <= bounds.min) {
|
|
3223
|
+
const message = `[Slider] \`max\` (${rawMax}) must be greater than \`min\` (${bounds.min}); falling back to ${bounds.max}.`;
|
|
3224
|
+
if (!warnedRanges2.has("inverted-range")) {
|
|
3225
|
+
warnedRanges2.add("inverted-range");
|
|
3226
|
+
console.warn(message);
|
|
3227
|
+
}
|
|
3228
|
+
}
|
|
3229
|
+
const controlledValues = value === void 0 ? void 0 : normalizeValues(value, range, bounds);
|
|
3230
|
+
const initialValues = normalizeValues(defaultValue, range, bounds);
|
|
3231
|
+
const onValueChangeRef = react.useRef(onValueChange);
|
|
3232
|
+
onValueChangeRef.current = onValueChange;
|
|
3233
|
+
const handleCommit = react.useCallback((next) => onValueChangeRef.current?.(toCommittedValue(next, range)), [range]);
|
|
3234
|
+
const [rawValues = initialValues, setValues] = useControllableState(controlledValues, initialValues, handleCommit);
|
|
3235
|
+
const values = react.useMemo(() => normalizeValues(toCommittedValue(rawValues, range), range, bounds), [rawValues, range, bounds.min, bounds.max, bounds.step]);
|
|
3236
|
+
const onValueChangeEndRef = react.useRef(onValueChangeEnd);
|
|
3237
|
+
onValueChangeEndRef.current = onValueChangeEnd;
|
|
3238
|
+
const emitChangeEnd = react.useCallback((vals) => onValueChangeEndRef.current?.(toCommittedValue(vals, range)), [range]);
|
|
3239
|
+
const emitChangeEndRef = react.useRef(emitChangeEnd);
|
|
3240
|
+
emitChangeEndRef.current = emitChangeEnd;
|
|
3241
|
+
const [draggingIndex, setDraggingIndex] = react.useState(null);
|
|
3242
|
+
const trackRef = react.useRef(null);
|
|
3243
|
+
const thumbRefs = react.useRef([]);
|
|
3244
|
+
const thumbDisabledRef = react.useRef([]);
|
|
3245
|
+
const gestureStartRef = react.useRef(null);
|
|
3246
|
+
const dragPointerRef = react.useRef(null);
|
|
3247
|
+
const valuesRef = react.useRef(values);
|
|
3248
|
+
valuesRef.current = values;
|
|
3249
|
+
thumbDisabledRef.current.length = values.length;
|
|
3250
|
+
const valueFromPoint = react.useCallback(
|
|
3251
|
+
(point) => {
|
|
3252
|
+
const track = trackRef.current;
|
|
3253
|
+
if (!track) return bounds.min;
|
|
3254
|
+
return valueFromPointer(track.getBoundingClientRect(), point, bounds, orientation);
|
|
3255
|
+
},
|
|
3256
|
+
[bounds.min, bounds.max, bounds.step, orientation]
|
|
3257
|
+
);
|
|
3258
|
+
const commit = react.useCallback(
|
|
3259
|
+
(next) => {
|
|
3260
|
+
if (!valuesEqual(next, valuesRef.current)) setValues(next);
|
|
3261
|
+
},
|
|
3262
|
+
[setValues]
|
|
3263
|
+
);
|
|
3264
|
+
const setThumbValue = react.useCallback(
|
|
3265
|
+
(index, next) => {
|
|
3266
|
+
if (disabled || readOnly || thumbDisabledRef.current[index]) return;
|
|
3267
|
+
const before = valuesRef.current;
|
|
3268
|
+
const updated = withThumbClamped(before, index, next, bounds, minDistance);
|
|
3269
|
+
commit(updated);
|
|
3270
|
+
if (!valuesEqual(updated, before)) emitChangeEnd(updated);
|
|
3271
|
+
},
|
|
3272
|
+
[disabled, readOnly, commit, emitChangeEnd, minDistance, bounds.min, bounds.max, bounds.step]
|
|
3273
|
+
);
|
|
3274
|
+
const startDrag = react.useCallback(
|
|
3275
|
+
(index, point, seek, pointerId) => {
|
|
3276
|
+
if (disabled || readOnly || thumbDisabledRef.current[index]) return;
|
|
3277
|
+
gestureStartRef.current = valuesRef.current;
|
|
3278
|
+
dragPointerRef.current = pointerId;
|
|
3279
|
+
if (!seek) {
|
|
3280
|
+
setDraggingIndex(index);
|
|
3281
|
+
thumbRefs.current[index]?.focus();
|
|
3282
|
+
return;
|
|
3283
|
+
}
|
|
3284
|
+
const { values: next, index: active } = withThumbSwapped(valuesRef.current, index, valueFromPoint(point), bounds, minDistance, thumbDisabledRef.current);
|
|
3285
|
+
setDraggingIndex(active);
|
|
3286
|
+
thumbRefs.current[active]?.focus();
|
|
3287
|
+
commit(next);
|
|
3288
|
+
},
|
|
3289
|
+
[disabled, readOnly, commit, valueFromPoint, minDistance, bounds.min, bounds.max, bounds.step]
|
|
3290
|
+
);
|
|
3291
|
+
react.useEffect(() => {
|
|
3292
|
+
if (draggingIndex === null) return;
|
|
3293
|
+
const ownerId = dragPointerRef.current;
|
|
3294
|
+
const isOwner = (event) => ownerId === null || event.pointerId === ownerId;
|
|
3295
|
+
const settle = () => {
|
|
3296
|
+
setDraggingIndex(null);
|
|
3297
|
+
if (gestureStartRef.current && !valuesEqual(valuesRef.current, gestureStartRef.current)) emitChangeEnd(valuesRef.current);
|
|
3298
|
+
gestureStartRef.current = null;
|
|
3299
|
+
dragPointerRef.current = null;
|
|
3300
|
+
};
|
|
3301
|
+
const handleMove = (event) => {
|
|
3302
|
+
if (!isOwner(event)) return;
|
|
3303
|
+
if (event.buttons === 0) {
|
|
3304
|
+
settle();
|
|
3305
|
+
return;
|
|
3306
|
+
}
|
|
3307
|
+
const { values: next, index: active } = withThumbSwapped(
|
|
3308
|
+
valuesRef.current,
|
|
3309
|
+
draggingIndex,
|
|
3310
|
+
valueFromPoint(pointerCoord(event, orientation)),
|
|
3311
|
+
bounds,
|
|
3312
|
+
minDistance,
|
|
3313
|
+
thumbDisabledRef.current
|
|
3314
|
+
);
|
|
3315
|
+
if (active !== draggingIndex) {
|
|
3316
|
+
setDraggingIndex(active);
|
|
3317
|
+
thumbRefs.current[active]?.focus();
|
|
3318
|
+
}
|
|
3319
|
+
commit(next);
|
|
3320
|
+
};
|
|
3321
|
+
const handleEnd = (event) => {
|
|
3322
|
+
if (!isOwner(event)) return;
|
|
3323
|
+
settle();
|
|
3324
|
+
};
|
|
3325
|
+
document.addEventListener("pointermove", handleMove);
|
|
3326
|
+
document.addEventListener("pointerup", handleEnd);
|
|
3327
|
+
document.addEventListener("pointercancel", handleEnd);
|
|
3328
|
+
return () => {
|
|
3329
|
+
document.removeEventListener("pointermove", handleMove);
|
|
3330
|
+
document.removeEventListener("pointerup", handleEnd);
|
|
3331
|
+
document.removeEventListener("pointercancel", handleEnd);
|
|
3332
|
+
};
|
|
3333
|
+
}, [draggingIndex, valueFromPoint, commit, emitChangeEnd, minDistance, orientation, bounds.min, bounds.max, bounds.step]);
|
|
3334
|
+
react.useEffect(
|
|
3335
|
+
() => () => {
|
|
3336
|
+
if (gestureStartRef.current && !valuesEqual(valuesRef.current, gestureStartRef.current)) emitChangeEndRef.current(valuesRef.current);
|
|
3337
|
+
gestureStartRef.current = null;
|
|
3338
|
+
},
|
|
3339
|
+
[]
|
|
3340
|
+
);
|
|
3341
|
+
const Component = as ?? "div";
|
|
3342
|
+
const htmlProps = nativeProps;
|
|
3343
|
+
const groupAttrs = range ? {
|
|
3344
|
+
"role": htmlProps.role ?? "group",
|
|
3345
|
+
"aria-labelledby": htmlProps["aria-labelledby"] ?? field?.labelId
|
|
3346
|
+
} : {};
|
|
3347
|
+
const { "aria-label": rootAriaLabel, "aria-labelledby": rootAriaLabelledby, ...singleWrapperProps } = htmlProps;
|
|
3348
|
+
const wrapperProps = range ? nativeProps : singleWrapperProps;
|
|
3349
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3350
|
+
SliderProvider,
|
|
3351
|
+
{
|
|
3352
|
+
value: {
|
|
3353
|
+
values,
|
|
3354
|
+
bounds,
|
|
3355
|
+
range,
|
|
3356
|
+
minDistance,
|
|
3357
|
+
orientation,
|
|
3358
|
+
disabled,
|
|
3359
|
+
readOnly,
|
|
3360
|
+
invalid,
|
|
3361
|
+
required,
|
|
3362
|
+
draggingIndex,
|
|
3363
|
+
trackRef,
|
|
3364
|
+
thumbRefs,
|
|
3365
|
+
thumbDisabledRef,
|
|
3366
|
+
formatValue,
|
|
3367
|
+
setThumbValue,
|
|
3368
|
+
startDrag,
|
|
3369
|
+
valueFromPoint,
|
|
3370
|
+
fieldId: field?.fieldId,
|
|
3371
|
+
labelId: field?.labelId,
|
|
3372
|
+
describedBy: invalid ? field?.errorId : field?.descriptionId,
|
|
3373
|
+
// Only a single slider forwards the root name to its thumb; a range
|
|
3374
|
+
// carries it on the group wrapper above.
|
|
3375
|
+
rootAriaLabel: range ? void 0 : rootAriaLabel,
|
|
3376
|
+
rootAriaLabelledby: range ? void 0 : rootAriaLabelledby
|
|
3377
|
+
},
|
|
3378
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(Component, { ...wrapperProps, ...groupAttrs, ...rootAttrs, ref, children: [
|
|
3379
|
+
children ?? /* @__PURE__ */ jsxRuntime.jsx(SliderTrack, {}),
|
|
3380
|
+
name && !disabled && (range ? (
|
|
3381
|
+
// One input per handle so a 3+ thumb range submits every value; a
|
|
3382
|
+
// two-handle range keeps the conventional `-min` / `-max` pair.
|
|
3383
|
+
values.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(spar.InputField, { type: "hidden", name: rangeInputName(name, index, values.length), value: entry, form }, index))
|
|
3384
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(spar.InputField, { type: "hidden", name, value: values[0], form }))
|
|
3385
|
+
] })
|
|
3386
|
+
}
|
|
3387
|
+
);
|
|
3388
|
+
};
|
|
3389
|
+
Slider.displayName = "Slider";
|
|
3390
|
+
var warnedGrids = /* @__PURE__ */ new Set();
|
|
3391
|
+
var SliderTicks = (props) => {
|
|
3392
|
+
const theme = useComponentTheme("SliderTicks");
|
|
3393
|
+
const { bounds, orientation } = useSliderContext("Slider.Ticks");
|
|
3394
|
+
const { rootAttrs, rest } = composeRootAttrs(SliderTicksBase, props, theme);
|
|
3395
|
+
const { ref, ...nativeProps } = rest;
|
|
3396
|
+
const percents = tickPercents(bounds, MAX_TICKS);
|
|
3397
|
+
if (percents === null) {
|
|
3398
|
+
if (isDevelopment()) {
|
|
3399
|
+
const message = `[Slider.Ticks] needs at most ${MAX_TICKS} marks, but min ${bounds.min} / max ${bounds.max} / step ${bounds.step} produces more; the ticks are not rendered.`;
|
|
3400
|
+
if (!warnedGrids.has("ticks-too-dense")) {
|
|
3401
|
+
warnedGrids.add("ticks-too-dense");
|
|
3402
|
+
console.warn(message);
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
return null;
|
|
3406
|
+
}
|
|
3407
|
+
const tickAttrs = buildSlotAttrs(SliderTicksBase.getSlotProps("tick"), "tick", {
|
|
3408
|
+
themeSlotProps: theme?.slotProps,
|
|
3409
|
+
themeClassNames: theme?.classNames,
|
|
3410
|
+
instanceSlotProps: props.slotProps,
|
|
3411
|
+
instanceClassNames: props.classNames
|
|
3412
|
+
});
|
|
3413
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ...nativeProps, ...rootAttrs, "aria-hidden": "true", ref, children: percents.map((percent, index) => /* @__PURE__ */ jsxRuntime.jsx("span", { ...tickAttrs, style: offsetStyle(percent, orientation) }, index)) });
|
|
3414
|
+
};
|
|
3415
|
+
SliderTicks.displayName = "Slider.Ticks";
|
|
3416
|
+
var SliderValue = (props) => {
|
|
3417
|
+
const theme = useComponentTheme("SliderValue");
|
|
3418
|
+
const { values, range, formatValue } = useSliderContext("Slider.Value");
|
|
3419
|
+
const { rootAttrs, rest } = composeRootAttrs(SliderValueBase, props, theme);
|
|
3420
|
+
const { children, ref, ...nativeProps } = rest;
|
|
3421
|
+
const formatted = values.map((value) => formatValueText(value, formatValue));
|
|
3422
|
+
const state = { values, formatted, range };
|
|
3423
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...nativeProps, ...rootAttrs, "aria-hidden": "true", ref, children: typeof children === "function" ? children(state) : children ?? formatted.join(RANGE_VALUE_SEPARATOR) });
|
|
3424
|
+
};
|
|
3425
|
+
SliderValue.displayName = "Slider.Value";
|
|
3426
|
+
|
|
3427
|
+
// src/components/slider/index.ts
|
|
3428
|
+
var Slider2 = Object.assign(Slider, {
|
|
3429
|
+
Track: SliderTrack,
|
|
3430
|
+
Range: SliderRange,
|
|
3431
|
+
Thumb: SliderThumb,
|
|
3432
|
+
Ticks: SliderTicks,
|
|
3433
|
+
Value: SliderValue
|
|
3434
|
+
});
|
|
3435
|
+
|
|
3436
|
+
// src/components/spinner/base.ts
|
|
3437
|
+
var SpinnerBase = createComponentBase({
|
|
3438
|
+
name: "Spinner",
|
|
3439
|
+
slots: ["root", "indicator"],
|
|
3440
|
+
classes: {
|
|
3441
|
+
root: "tk-spinner",
|
|
3442
|
+
indicator: "tk-spinner-indicator"
|
|
3443
|
+
}
|
|
3444
|
+
});
|
|
3445
|
+
|
|
3446
|
+
// src/components/spinner/defaults.ts
|
|
3447
|
+
var DEFAULT_APPEARANCE7 = "rounded";
|
|
3448
|
+
var DEFAULT_SIZE13 = "base";
|
|
3449
|
+
var DEFAULT_VARIANT8 = "neutral";
|
|
3450
|
+
var DEFAULT_ARIA_LABEL2 = "Loading";
|
|
3451
|
+
var SPINNER_RADIAL_PARTS = 8;
|
|
3452
|
+
var SPINNER_THREE_DOT_PARTS = 3;
|
|
3453
|
+
var renderIndicatorContent = (appearance) => {
|
|
3454
|
+
if (appearance === "rounded") {
|
|
3455
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3456
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { "aria-hidden": "true", focusable: "false", viewBox: "0 0 40 40", children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "20", cy: "20", r: "16.6667" }) }),
|
|
3457
|
+
/* @__PURE__ */ jsxRuntime.jsx("svg", { "aria-hidden": "true", focusable: "false", viewBox: "0 0 40 40", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 3.3333A16.6667 16.6667 0 0 1 36.6667 20" }) })
|
|
3458
|
+
] });
|
|
3459
|
+
}
|
|
3460
|
+
if (appearance === "loader") {
|
|
3461
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { "aria-hidden": "true", focusable: "false", viewBox: "0 0 40 40", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 3.3333A16.6667 16.6667 0 0 1 31.7851 8.2149" }) });
|
|
3462
|
+
}
|
|
3463
|
+
if (appearance === "dots") {
|
|
3464
|
+
return Array.from({ length: SPINNER_RADIAL_PARTS }, (_, index) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tk-spinner-dot" }, index));
|
|
3465
|
+
}
|
|
3466
|
+
if (appearance === "lines") {
|
|
3467
|
+
return Array.from({ length: SPINNER_RADIAL_PARTS }, (_, index) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tk-spinner-line" }, index));
|
|
3468
|
+
}
|
|
3469
|
+
if (appearance === "threeDots") {
|
|
3470
|
+
return Array.from({ length: SPINNER_THREE_DOT_PARTS }, (_, index) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tk-spinner-dot" }, index));
|
|
3471
|
+
}
|
|
3472
|
+
if (appearance === "logo") {
|
|
3473
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { "aria-hidden": "true", focusable: "false", viewBox: "0 0 48 48", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3474
|
+
"path",
|
|
3475
|
+
{
|
|
3476
|
+
clipRule: "evenodd",
|
|
3477
|
+
d: "M24 0C10.7452 0 0 10.7452 0 24C0 37.2548 10.7452 48 24 48C37.2548 48 48 37.2548 48 24V4C48 1.79086 46.2091 0 44 0H24ZM24 8C15.1634 8 8 15.1634 8 24C8 32.8366 15.1634 40 24 40C32.8366 40 40 32.8366 40 24C40 15.1634 32.8366 8 24 8Z",
|
|
3478
|
+
fillRule: "evenodd"
|
|
3479
|
+
}
|
|
3480
|
+
) });
|
|
3481
|
+
}
|
|
3482
|
+
return null;
|
|
3483
|
+
};
|
|
3484
|
+
var Spinner = (props) => {
|
|
3485
|
+
const theme = useComponentTheme("Spinner");
|
|
3486
|
+
const { rootAttrs, rest } = composeRootAttrs(SpinnerBase, props, theme, {
|
|
3487
|
+
stateAttrs: ({ variant = DEFAULT_VARIANT8, size = DEFAULT_SIZE13, appearance: appearance2 = DEFAULT_APPEARANCE7 }) => ({
|
|
3488
|
+
"data-variant": variant,
|
|
3489
|
+
"data-size": size,
|
|
3490
|
+
"data-type": appearance2
|
|
3491
|
+
})
|
|
3492
|
+
});
|
|
3493
|
+
const { variant: _variant, size: _size, appearance = DEFAULT_APPEARANCE7, ref, ...nativeProps } = rest;
|
|
3494
|
+
const indicatorSlotAttrs = buildSlotAttrs(SpinnerBase.getSlotProps("indicator"), "indicator", {
|
|
3495
|
+
themeSlotProps: theme?.slotProps,
|
|
3496
|
+
themeClassNames: theme?.classNames,
|
|
3497
|
+
instanceSlotProps: props.slotProps,
|
|
3498
|
+
instanceClassNames: props.classNames
|
|
3499
|
+
});
|
|
3500
|
+
const isDecorative = nativeProps["aria-hidden"] === true || nativeProps["aria-hidden"] === "true";
|
|
3501
|
+
const accessibilityAttrs = isDecorative ? {} : {
|
|
3502
|
+
"role": nativeProps.role ?? "status",
|
|
3503
|
+
"aria-label": nativeProps["aria-label"] ?? (nativeProps["aria-labelledby"] ? void 0 : DEFAULT_ARIA_LABEL2)
|
|
3504
|
+
};
|
|
3505
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...accessibilityAttrs, ...nativeProps, ...rootAttrs, ref, children: /* @__PURE__ */ jsxRuntime.jsx("span", { ...indicatorSlotAttrs, "aria-hidden": "true", children: renderIndicatorContent(appearance) }) });
|
|
3506
|
+
};
|
|
3507
|
+
Spinner.displayName = "Spinner";
|
|
3508
|
+
|
|
3509
|
+
// src/components/stepper/base.ts
|
|
3510
|
+
var StepperBase = createComponentBase({
|
|
3511
|
+
name: "Stepper",
|
|
3512
|
+
slots: ["root"],
|
|
3513
|
+
classes: { root: "tk-stepper" }
|
|
3514
|
+
});
|
|
3515
|
+
var StepperItemBase = createComponentBase({
|
|
3516
|
+
name: "StepperItem",
|
|
3517
|
+
slots: ["root", "trigger", "rail", "indicator", "content"],
|
|
3518
|
+
classes: {
|
|
3519
|
+
root: "tk-stepper-item",
|
|
3520
|
+
trigger: "tk-stepper-trigger",
|
|
3521
|
+
rail: "tk-stepper-rail",
|
|
3522
|
+
indicator: "tk-stepper-indicator",
|
|
3523
|
+
content: "tk-stepper-content"
|
|
3524
|
+
}
|
|
3525
|
+
});
|
|
3526
|
+
var StepperTitleBase = createComponentBase({
|
|
3527
|
+
name: "StepperTitle",
|
|
3528
|
+
slots: ["root"],
|
|
3529
|
+
classes: { root: "tk-stepper-title" }
|
|
3530
|
+
});
|
|
3531
|
+
var StepperDescriptionBase = createComponentBase({
|
|
3532
|
+
name: "StepperDescription",
|
|
3533
|
+
slots: ["root"],
|
|
3534
|
+
classes: { root: "tk-stepper-description" }
|
|
3535
|
+
});
|
|
3536
|
+
|
|
3537
|
+
// src/components/stepper/context.ts
|
|
3538
|
+
var [StepperProvider, useStepperContext] = createSafeContext("StepperProvider");
|
|
3539
|
+
var [StepperItemIndexProvider, useStepperItemIndex] = createSafeContext("StepperItemIndexProvider");
|
|
3540
|
+
var [StepperItemProvider, useStepperItem] = createSafeContext("Stepper.Item");
|
|
3541
|
+
|
|
3542
|
+
// src/components/stepper/defaults.ts
|
|
3543
|
+
var DEFAULT_ORIENTATION3 = "horizontal";
|
|
3544
|
+
var DEFAULT_MODE2 = "default";
|
|
3545
|
+
var DEFAULT_SIZE14 = "base";
|
|
3546
|
+
var DEFAULT_ACTIVE = 0;
|
|
3547
|
+
var DEFAULT_COMPLETED_LABEL = "completed";
|
|
3548
|
+
var DEFAULT_ERROR_LABEL = "error";
|
|
3549
|
+
var FOCUSABLE_TRIGGER_SELECTOR = '.tk-stepper-trigger:not(:disabled):not([tabindex="-1"])';
|
|
3550
|
+
var Stepper = (props) => {
|
|
3551
|
+
const theme = useComponentTheme("Stepper");
|
|
3552
|
+
const { rootAttrs, rest } = composeRootAttrs(StepperBase, props, theme, {
|
|
3553
|
+
stateAttrs: ({ orientation: orientation2 = DEFAULT_ORIENTATION3, mode: mode2 = DEFAULT_MODE2, size = DEFAULT_SIZE14, linear: linear2 = false, reverse = false }) => ({
|
|
3554
|
+
"data-orientation": orientation2,
|
|
3555
|
+
"data-mode": mode2,
|
|
3556
|
+
"data-size": size,
|
|
3557
|
+
"data-linear": linear2 ? "" : void 0,
|
|
3558
|
+
"data-reverse": reverse ? "" : void 0
|
|
3559
|
+
})
|
|
3560
|
+
});
|
|
3561
|
+
const {
|
|
3562
|
+
active: controlledActive,
|
|
3563
|
+
defaultActive = DEFAULT_ACTIVE,
|
|
3564
|
+
onActiveChange,
|
|
3565
|
+
onStepClick,
|
|
3566
|
+
orientation = DEFAULT_ORIENTATION3,
|
|
3567
|
+
mode = DEFAULT_MODE2,
|
|
3568
|
+
// Consumed only as root data-* hooks above; destructured so the <ol>
|
|
3569
|
+
// doesn't receive unknown DOM attributes.
|
|
3570
|
+
size: _size,
|
|
3571
|
+
linear = false,
|
|
3572
|
+
reverse: _reverse,
|
|
3573
|
+
completedLabel = DEFAULT_COMPLETED_LABEL,
|
|
3574
|
+
errorLabel = DEFAULT_ERROR_LABEL,
|
|
3575
|
+
onKeyDown: nativeOnKeyDown,
|
|
3576
|
+
as,
|
|
3577
|
+
children,
|
|
3578
|
+
ref,
|
|
3579
|
+
...nativeProps
|
|
3580
|
+
} = rest;
|
|
3581
|
+
const onActiveChangeRef = react.useRef(onActiveChange);
|
|
3582
|
+
onActiveChangeRef.current = onActiveChange;
|
|
3583
|
+
const stableOnActiveChange = react.useCallback((index) => {
|
|
3584
|
+
onActiveChangeRef.current?.(index);
|
|
3585
|
+
}, []);
|
|
3586
|
+
const onStepClickRef = react.useRef(onStepClick);
|
|
3587
|
+
onStepClickRef.current = onStepClick;
|
|
3588
|
+
const stableOnStepClick = react.useCallback((detail) => {
|
|
3589
|
+
onStepClickRef.current?.(detail);
|
|
3590
|
+
}, []);
|
|
3591
|
+
const [activeValue, setActive] = useControllableState(controlledActive, defaultActive, stableOnActiveChange);
|
|
3592
|
+
const active = activeValue ?? DEFAULT_ACTIVE;
|
|
3593
|
+
const [stepsMeta, setStepsMeta] = react.useState(/* @__PURE__ */ new Map());
|
|
3594
|
+
const { items, renderStepsMeta } = react.useMemo(() => {
|
|
3595
|
+
const meta = /* @__PURE__ */ new Map();
|
|
3596
|
+
let stepIndex = 0;
|
|
3597
|
+
const items2 = react.Children.toArray(children).map((child) => {
|
|
3598
|
+
if (!react.isValidElement(child)) return child;
|
|
3599
|
+
const index = stepIndex++;
|
|
3600
|
+
const { error = false, disabled = false, isClickable = true } = child.props;
|
|
3601
|
+
meta.set(index, { error, disabled, isClickable });
|
|
3602
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StepperItemIndexProvider, { value: { index }, children: child }, child.key ?? index);
|
|
3603
|
+
});
|
|
3604
|
+
return { items: items2, renderStepsMeta: meta };
|
|
3605
|
+
}, [children]);
|
|
3606
|
+
const registerStep = react.useCallback((index, meta) => {
|
|
3607
|
+
setStepsMeta((previous) => new Map(previous).set(index, meta));
|
|
3608
|
+
return () => {
|
|
3609
|
+
setStepsMeta((previous) => {
|
|
3610
|
+
const next = new Map(previous);
|
|
3611
|
+
next.delete(index);
|
|
3612
|
+
return next;
|
|
3613
|
+
});
|
|
3614
|
+
};
|
|
3615
|
+
}, []);
|
|
3616
|
+
const contextValue = react.useMemo(() => {
|
|
3617
|
+
const canSelectStep = (index, selfMeta) => {
|
|
3618
|
+
const target = stepsMeta.get(index) ?? selfMeta ?? renderStepsMeta.get(index);
|
|
3619
|
+
if (!target || target.disabled || !target.isClickable) return false;
|
|
3620
|
+
if (!linear) return true;
|
|
3621
|
+
if (index < active) return true;
|
|
3622
|
+
if (index === active + 1) {
|
|
3623
|
+
const current = stepsMeta.get(active) ?? renderStepsMeta.get(active);
|
|
3624
|
+
return !current?.error && !current?.disabled;
|
|
3625
|
+
}
|
|
3626
|
+
return false;
|
|
3627
|
+
};
|
|
3628
|
+
const getStepStatus = (options) => {
|
|
3629
|
+
const { index } = options;
|
|
3630
|
+
if (index < active) return "completed";
|
|
3631
|
+
if (index === active) return "active";
|
|
3632
|
+
return "inactive";
|
|
3633
|
+
};
|
|
3634
|
+
return {
|
|
3635
|
+
active,
|
|
3636
|
+
mode,
|
|
3637
|
+
completedLabel,
|
|
3638
|
+
errorLabel,
|
|
3639
|
+
getStepStatus,
|
|
3640
|
+
registerStep,
|
|
3641
|
+
canSelectStep,
|
|
3642
|
+
selectStep: (index) => {
|
|
3643
|
+
if (index !== active && canSelectStep(index)) {
|
|
3644
|
+
setActive(index);
|
|
3645
|
+
}
|
|
3646
|
+
},
|
|
3647
|
+
emitStepClick: (detail) => {
|
|
3648
|
+
stableOnStepClick(detail);
|
|
3649
|
+
}
|
|
3650
|
+
};
|
|
3651
|
+
}, [active, mode, completedLabel, errorLabel, linear, stepsMeta, renderStepsMeta, registerStep, setActive, stableOnStepClick]);
|
|
3652
|
+
const { onKeyDown: slotOnKeyDown, ...restRootAttrs } = rootAttrs;
|
|
3653
|
+
const userOnKeyDown = slotOnKeyDown ?? nativeOnKeyDown;
|
|
3654
|
+
const handleKeyDown = (event) => {
|
|
3655
|
+
userOnKeyDown?.(event);
|
|
3656
|
+
if (event.defaultPrevented) return;
|
|
3657
|
+
const forwardKey = orientation === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
3658
|
+
const backwardKey = orientation === "horizontal" ? "ArrowLeft" : "ArrowUp";
|
|
3659
|
+
if (event.key !== forwardKey && event.key !== backwardKey && event.key !== "Home" && event.key !== "End") return;
|
|
3660
|
+
const pressedTrigger = event.target instanceof HTMLElement ? event.target.closest(".tk-stepper-trigger") : null;
|
|
3661
|
+
if (!pressedTrigger || pressedTrigger.closest(".tk-stepper") !== event.currentTarget) return;
|
|
3662
|
+
event.preventDefault();
|
|
3663
|
+
const triggers = Array.from(event.currentTarget.querySelectorAll(FOCUSABLE_TRIGGER_SELECTOR)).filter(
|
|
3664
|
+
(trigger) => trigger.closest(".tk-stepper") === event.currentTarget
|
|
3665
|
+
);
|
|
3666
|
+
const currentIndex = triggers.indexOf(pressedTrigger);
|
|
3667
|
+
if (triggers.length === 0 || currentIndex === -1 && event.key !== "Home" && event.key !== "End") return;
|
|
3668
|
+
const nextIndex = event.key === "Home" ? 0 : event.key === "End" ? triggers.length - 1 : event.key === forwardKey ? currentIndex + 1 : currentIndex - 1;
|
|
3669
|
+
triggers[nextIndex]?.focus();
|
|
3670
|
+
};
|
|
3671
|
+
const Component = as ?? "ol";
|
|
3672
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StepperProvider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(Component, { ...nativeProps, ...restRootAttrs, ref, onKeyDown: handleKeyDown, children: items }) });
|
|
3673
|
+
};
|
|
3674
|
+
Stepper.displayName = "Stepper";
|
|
3675
|
+
var StepperTitle = (props) => {
|
|
3676
|
+
const theme = useComponentTheme("StepperTitle");
|
|
3677
|
+
useStepperContext("Stepper.Title");
|
|
3678
|
+
const { rootAttrs, rest } = composeRootAttrs(StepperTitleBase, props, theme);
|
|
3679
|
+
const { as, children, ref, ...nativeProps } = rest;
|
|
3680
|
+
const Component = as ?? "span";
|
|
3681
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...nativeProps, ...rootAttrs, ref, children });
|
|
3682
|
+
};
|
|
3683
|
+
StepperTitle.displayName = "Stepper.Title";
|
|
3684
|
+
var visuallyHidden = {
|
|
3685
|
+
position: "absolute",
|
|
3686
|
+
width: 1,
|
|
3687
|
+
height: 1,
|
|
3688
|
+
margin: -1,
|
|
3689
|
+
padding: 0,
|
|
3690
|
+
overflow: "hidden",
|
|
3691
|
+
clip: "rect(0 0 0 0)",
|
|
3692
|
+
whiteSpace: "nowrap",
|
|
3693
|
+
border: 0
|
|
3694
|
+
};
|
|
3695
|
+
var StepperItem = (props) => {
|
|
3696
|
+
const theme = useComponentTheme("StepperItem");
|
|
3697
|
+
const { active, mode, completedLabel, errorLabel, getStepStatus, registerStep, canSelectStep, selectStep, emitStepClick } = useStepperContext("Stepper.Item");
|
|
3698
|
+
const { index } = useStepperItemIndex("Stepper.Item");
|
|
3699
|
+
const { rootAttrs, rest } = composeRootAttrs(StepperItemBase, props, theme, {
|
|
3700
|
+
stateAttrs: ({ error: error2 = false, disabled: disabled2 = false, isClickable: isClickable2 = true }) => ({
|
|
3701
|
+
"data-state": getStepStatus({ index }),
|
|
3702
|
+
"data-error": error2 ? "" : void 0,
|
|
3703
|
+
"data-disabled": disabled2 ? "" : void 0,
|
|
3704
|
+
// The active step is excluded: pressing it re-emits `onStepClick` but
|
|
3705
|
+
// can never change the selection, which is what this hook advertises.
|
|
3706
|
+
"data-clickable": index !== active && canSelectStep(index, { error: error2, disabled: disabled2, isClickable: isClickable2 }) ? "" : void 0
|
|
3707
|
+
})
|
|
3708
|
+
});
|
|
3709
|
+
const { error = false, disabled = false, isClickable = true, indicator, as, children, ref, ...nativeProps } = rest;
|
|
3710
|
+
react.useEffect(() => registerStep(index, { error, disabled, isClickable }), [registerStep, index, error, disabled, isClickable]);
|
|
3711
|
+
const status = getStepStatus({ index });
|
|
3712
|
+
const selectable = canSelectStep(index, { error, disabled, isClickable });
|
|
3713
|
+
const isActive = index === active;
|
|
3714
|
+
const ariaDisabled = selectable || isActive ? void 0 : true;
|
|
3715
|
+
const statusLabel = error ? errorLabel : status === "completed" ? completedLabel : void 0;
|
|
3716
|
+
const [descriptionId, setDescriptionId] = react.useState();
|
|
3717
|
+
const registerDescription = react.useCallback((id) => {
|
|
3718
|
+
setDescriptionId(id);
|
|
3719
|
+
return () => {
|
|
3720
|
+
setDescriptionId((current) => current === id ? void 0 : current);
|
|
3721
|
+
};
|
|
3722
|
+
}, []);
|
|
3723
|
+
const itemContextValue = react.useMemo(() => ({ registerDescription }), [registerDescription]);
|
|
3724
|
+
const slotLayering = {
|
|
3725
|
+
themeSlotProps: theme?.slotProps,
|
|
3726
|
+
themeClassNames: theme?.classNames,
|
|
3727
|
+
instanceSlotProps: props.slotProps,
|
|
3728
|
+
instanceClassNames: props.classNames
|
|
3729
|
+
};
|
|
3730
|
+
const triggerSlotAttrs = buildSlotAttrs(StepperItemBase.getSlotProps("trigger"), "trigger", slotLayering);
|
|
3731
|
+
const { onClick: triggerSlotOnClick, ...triggerAttrs } = triggerSlotAttrs;
|
|
3732
|
+
const railAttrs = buildSlotAttrs(StepperItemBase.getSlotProps("rail"), "rail", slotLayering);
|
|
3733
|
+
const indicatorAttrs = buildSlotAttrs(StepperItemBase.getSlotProps("indicator"), "indicator", slotLayering);
|
|
3734
|
+
const contentAttrs = buildSlotAttrs(StepperItemBase.getSlotProps("content"), "content", slotLayering);
|
|
3735
|
+
const resolvedIndicator = typeof indicator === "function" ? indicator({ status, index }) : indicator;
|
|
3736
|
+
let indicatorContent = null;
|
|
3737
|
+
if (!disabled) {
|
|
3738
|
+
if (resolvedIndicator != null) {
|
|
3739
|
+
indicatorContent = resolvedIndicator;
|
|
3740
|
+
} else if (error) {
|
|
3741
|
+
indicatorContent = /* @__PURE__ */ jsxRuntime.jsx(close.CloseIconOutlinedRounded, {});
|
|
3742
|
+
} else if (status === "completed") {
|
|
3743
|
+
indicatorContent = /* @__PURE__ */ jsxRuntime.jsx(check.CheckIconOutlinedRounded, {});
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3746
|
+
const handleTriggerClick = (event) => {
|
|
3747
|
+
triggerSlotOnClick?.(event);
|
|
3748
|
+
if (event.defaultPrevented) return;
|
|
3749
|
+
if (!selectable && !(isActive && isClickable)) return;
|
|
3750
|
+
emitStepClick({ index, status });
|
|
3751
|
+
selectStep(index);
|
|
3752
|
+
};
|
|
3753
|
+
const Component = as ?? "li";
|
|
3754
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StepperItemProvider, { value: itemContextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(Component, { ...nativeProps, ...rootAttrs, ref, children: [
|
|
3755
|
+
mode !== "compact" && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", ...railAttrs }),
|
|
3756
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3757
|
+
"button",
|
|
3758
|
+
{
|
|
3759
|
+
...triggerAttrs,
|
|
3760
|
+
type: "button",
|
|
3761
|
+
disabled,
|
|
3762
|
+
onClick: handleTriggerClick,
|
|
3763
|
+
"aria-current": isActive ? "step" : void 0,
|
|
3764
|
+
"aria-disabled": ariaDisabled,
|
|
3765
|
+
"aria-describedby": descriptionId,
|
|
3766
|
+
tabIndex: isClickable ? void 0 : -1,
|
|
3767
|
+
children: [
|
|
3768
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", ...indicatorAttrs, children: indicatorContent }),
|
|
3769
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { ...contentAttrs, children }),
|
|
3770
|
+
statusLabel ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: visuallyHidden, children: `, ${statusLabel}` }) : null
|
|
3771
|
+
]
|
|
3772
|
+
}
|
|
3773
|
+
)
|
|
3774
|
+
] }) });
|
|
3775
|
+
};
|
|
3776
|
+
StepperItem.displayName = "Stepper.Item";
|
|
3777
|
+
var StepperDescription = (props) => {
|
|
3778
|
+
const theme = useComponentTheme("StepperDescription");
|
|
3779
|
+
const { registerDescription } = useStepperItem("Stepper.Description");
|
|
3780
|
+
const { rootAttrs, rest } = composeRootAttrs(StepperDescriptionBase, props, theme);
|
|
3781
|
+
const { as, children, ref, id: idProp, ...nativeProps } = rest;
|
|
3782
|
+
const autoId = react.useId();
|
|
3783
|
+
const id = idProp ?? autoId;
|
|
3784
|
+
react.useEffect(() => registerDescription(id), [registerDescription, id]);
|
|
3785
|
+
const Component = as ?? "span";
|
|
3786
|
+
return (
|
|
3787
|
+
// Locked after the spread: the id must match the trigger's
|
|
3788
|
+
// `aria-describedby` registration, and `aria-hidden` keeps the description
|
|
3789
|
+
// out of the trigger's accessible NAME — it still reaches assistive
|
|
3790
|
+
// technology as the trigger's description, since `aria-describedby` may
|
|
3791
|
+
// reference hidden elements.
|
|
3792
|
+
/* @__PURE__ */ jsxRuntime.jsx(Component, { ...nativeProps, ...rootAttrs, ref, id, "aria-hidden": "true", children })
|
|
3793
|
+
);
|
|
3794
|
+
};
|
|
3795
|
+
StepperDescription.displayName = "Stepper.Description";
|
|
3796
|
+
|
|
3797
|
+
// src/components/stepper/index.ts
|
|
3798
|
+
var Stepper2 = Object.assign(Stepper, {
|
|
3799
|
+
Item: StepperItem,
|
|
3800
|
+
Title: StepperTitle,
|
|
3801
|
+
Description: StepperDescription
|
|
3802
|
+
});
|
|
2525
3803
|
|
|
2526
3804
|
// src/components/switch/base.ts
|
|
2527
3805
|
var SwitchBase = createComponentBase({
|
|
@@ -2540,12 +3818,12 @@ var SwitchBase = createComponentBase({
|
|
|
2540
3818
|
var [SwitchProvider, useSwitchOwnContext] = createSafeContext("SwitchProvider");
|
|
2541
3819
|
|
|
2542
3820
|
// src/components/switch/defaults.ts
|
|
2543
|
-
var
|
|
2544
|
-
var
|
|
3821
|
+
var DEFAULT_SIZE15 = "base";
|
|
3822
|
+
var DEFAULT_VARIANT9 = "info";
|
|
2545
3823
|
var Switch = (props) => {
|
|
2546
3824
|
const theme = useComponentTheme("Switch");
|
|
2547
3825
|
const { rootAttrs, rest } = composeRootAttrs(SwitchBase, props, theme, {
|
|
2548
|
-
stateAttrs: ({ size =
|
|
3826
|
+
stateAttrs: ({ size = DEFAULT_SIZE15, variant = DEFAULT_VARIANT9 }) => ({
|
|
2549
3827
|
"data-size": size,
|
|
2550
3828
|
"data-variant": variant
|
|
2551
3829
|
})
|
|
@@ -2556,13 +3834,17 @@ var Switch = (props) => {
|
|
|
2556
3834
|
// off the rendered DOM where they would leak as raw HTML attributes.
|
|
2557
3835
|
size: _size,
|
|
2558
3836
|
variant: _variant,
|
|
2559
|
-
// `invalid` is forwarded to Spar as `invalid` (same name).
|
|
2560
|
-
invalid = false,
|
|
2561
3837
|
children,
|
|
2562
3838
|
ref,
|
|
3839
|
+
// `invalid`, `disabled`, `readOnly` and `required` are intentionally NOT
|
|
3840
|
+
// destructured (so no eager `= false` default is applied) — they flow to
|
|
3841
|
+
// Spar via `...sparProps` untouched. Defaulting `invalid` here would turn
|
|
3842
|
+
// an omitted prop into an explicit `false`, defeating Spar's
|
|
3843
|
+
// `invalid ?? fieldCtx?.invalid` inheritance and silently overriding a
|
|
3844
|
+
// wrapping `<Field invalid>`. Mirrors the Radio/Input/Select pass-through.
|
|
2563
3845
|
...sparProps
|
|
2564
3846
|
} = rest;
|
|
2565
|
-
return /* @__PURE__ */ jsxRuntime.jsx(spar.Switch, { ...sparProps,
|
|
3847
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.Switch, { ...sparProps, ref, ...rootAttrs, children: (state) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2566
3848
|
SwitchProvider,
|
|
2567
3849
|
{
|
|
2568
3850
|
value: {
|
|
@@ -2668,7 +3950,7 @@ var TableBase = createComponentBase({
|
|
|
2668
3950
|
var [TableProvider, useTableContext] = createSafeContext("Table");
|
|
2669
3951
|
|
|
2670
3952
|
// src/components/table/defaults.ts
|
|
2671
|
-
var
|
|
3953
|
+
var DEFAULT_SIZE16 = "base";
|
|
2672
3954
|
var DEFAULT_PAGE_SIZE = 10;
|
|
2673
3955
|
var DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100];
|
|
2674
3956
|
var DEFAULT_COLUMN_WIDTH = 150;
|
|
@@ -3038,7 +4320,7 @@ var TableHeaderCell = ({ header }) => {
|
|
|
3038
4320
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ...slotAttrs("headerContent"), children: [
|
|
3039
4321
|
canSort ? /* @__PURE__ */ jsxRuntime.jsxs("button", { ...slotAttrs("sortTrigger"), type: "button", onClick: column.getToggleSortingHandler(), children: [
|
|
3040
4322
|
content,
|
|
3041
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { ...slotAttrs("sortIcon"), "data-direction": sorted || "none", "aria-hidden": "true", children: sorted === "asc" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
4323
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { ...slotAttrs("sortIcon"), "data-direction": sorted || "none", "aria-hidden": "true", children: sorted === "asc" ? /* @__PURE__ */ jsxRuntime.jsx(arrowTop.ArrowTopIconOutlinedRounded, {}) : sorted === "desc" ? /* @__PURE__ */ jsxRuntime.jsx(arrowBottom.ArrowBottomIconOutlinedRounded, {}) : /* @__PURE__ */ jsxRuntime.jsx(swap.SwapIconOutlinedRounded, {}) })
|
|
3042
4324
|
] }) : content,
|
|
3043
4325
|
canFilter && /* @__PURE__ */ jsxRuntime.jsx(TableColumnFilter, { header })
|
|
3044
4326
|
] })
|
|
@@ -3092,7 +4374,7 @@ var TablePagination = () => {
|
|
|
3092
4374
|
variant: "neutral",
|
|
3093
4375
|
appearance: "text",
|
|
3094
4376
|
"aria-label": "First page",
|
|
3095
|
-
startContent: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4377
|
+
startContent: /* @__PURE__ */ jsxRuntime.jsx(doubleChevronLeft.DoubleChevronLeftIconOutlinedRounded, {}),
|
|
3096
4378
|
disabled: !table.getCanPreviousPage(),
|
|
3097
4379
|
onClick: () => table.setPageIndex(0)
|
|
3098
4380
|
}
|
|
@@ -3149,7 +4431,7 @@ var TablePagination = () => {
|
|
|
3149
4431
|
variant: "neutral",
|
|
3150
4432
|
appearance: "text",
|
|
3151
4433
|
"aria-label": "Last page",
|
|
3152
|
-
startContent: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4434
|
+
startContent: /* @__PURE__ */ jsxRuntime.jsx(doubleChevronRight.DoubleChevronRightIconOutlinedRounded, {}),
|
|
3153
4435
|
disabled: !table.getCanNextPage() || pageCount <= 0,
|
|
3154
4436
|
onClick: () => table.setPageIndex(pageCount - 1)
|
|
3155
4437
|
}
|
|
@@ -3194,7 +4476,7 @@ var Table = (props) => {
|
|
|
3194
4476
|
// Visual vocabulary lives on the root so recipes cascade
|
|
3195
4477
|
// to the portal-free table descendants. `data-loading` mirrors the
|
|
3196
4478
|
// boolean-presence convention (rule 5).
|
|
3197
|
-
stateAttrs: ({ size: size2 =
|
|
4479
|
+
stateAttrs: ({ size: size2 = DEFAULT_SIZE16, striped: striped2, bordered: bordered2, stickyHeader: stickyHeader2, loading: loading2 }) => ({
|
|
3198
4480
|
"data-size": size2,
|
|
3199
4481
|
"data-striped": striped2 ? "" : void 0,
|
|
3200
4482
|
"data-bordered": bordered2 ? "" : void 0,
|
|
@@ -3208,7 +4490,7 @@ var Table = (props) => {
|
|
|
3208
4490
|
getRowId,
|
|
3209
4491
|
manual = false,
|
|
3210
4492
|
loading = false,
|
|
3211
|
-
size =
|
|
4493
|
+
size = DEFAULT_SIZE16,
|
|
3212
4494
|
striped = false,
|
|
3213
4495
|
bordered = false,
|
|
3214
4496
|
stickyHeader = false,
|
|
@@ -3408,19 +4690,19 @@ var TabsContentBase = createComponentBase({
|
|
|
3408
4690
|
var [TabsOwnProvider, useTabsOwnContext] = createSafeContext("Tabs");
|
|
3409
4691
|
|
|
3410
4692
|
// src/components/tabs/defaults.ts
|
|
3411
|
-
var
|
|
3412
|
-
var
|
|
3413
|
-
var
|
|
4693
|
+
var DEFAULT_SIZE17 = "base";
|
|
4694
|
+
var DEFAULT_VARIANT10 = "primary";
|
|
4695
|
+
var DEFAULT_APPEARANCE8 = "basic";
|
|
3414
4696
|
var Tabs = (props) => {
|
|
3415
4697
|
const theme = useComponentTheme("Tabs");
|
|
3416
4698
|
const { rootAttrs, rest } = composeRootAttrs(TabsBase, props, theme, {
|
|
3417
|
-
stateAttrs: ({ size: size2 =
|
|
4699
|
+
stateAttrs: ({ size: size2 = DEFAULT_SIZE17, variant: variant2 = DEFAULT_VARIANT10, appearance: appearance2 = DEFAULT_APPEARANCE8 }) => ({
|
|
3418
4700
|
"data-size": size2,
|
|
3419
4701
|
"data-variant": variant2,
|
|
3420
4702
|
"data-type": appearance2
|
|
3421
4703
|
})
|
|
3422
4704
|
});
|
|
3423
|
-
const { size =
|
|
4705
|
+
const { size = DEFAULT_SIZE17, variant = DEFAULT_VARIANT10, appearance = DEFAULT_APPEARANCE8, children, ref, ...sparProps } = rest;
|
|
3424
4706
|
return /* @__PURE__ */ jsxRuntime.jsx(TabsOwnProvider, { value: { size, variant, appearance }, children: /* @__PURE__ */ jsxRuntime.jsx(spar.Tabs, { ...sparProps, ...rootAttrs, ref, children }) });
|
|
3425
4707
|
};
|
|
3426
4708
|
Tabs.displayName = "Tabs";
|
|
@@ -3520,11 +4802,11 @@ var TooltipTrigger = (props) => {
|
|
|
3520
4802
|
TooltipTrigger.displayName = "Tooltip.Trigger";
|
|
3521
4803
|
|
|
3522
4804
|
// src/components/tooltip/defaults.ts
|
|
3523
|
-
var
|
|
4805
|
+
var DEFAULT_VARIANT11 = "white";
|
|
3524
4806
|
var TooltipContent = (props) => {
|
|
3525
4807
|
const theme = useComponentTheme("TooltipContent");
|
|
3526
4808
|
const { rootAttrs, rest } = composeRootAttrs(TooltipContentBase, props, theme, {
|
|
3527
|
-
stateAttrs: ({ variant =
|
|
4809
|
+
stateAttrs: ({ variant = DEFAULT_VARIANT11 }) => ({
|
|
3528
4810
|
"data-variant": variant
|
|
3529
4811
|
})
|
|
3530
4812
|
});
|
|
@@ -3549,8 +4831,8 @@ TooltipDescription.displayName = "Tooltip.Description";
|
|
|
3549
4831
|
var TooltipArrow = (props) => {
|
|
3550
4832
|
const theme = useComponentTheme("TooltipArrow");
|
|
3551
4833
|
const { rootAttrs, rest } = composeRootAttrs(TooltipArrowBase, props, theme);
|
|
3552
|
-
const { ref, ...sparProps } = rest;
|
|
3553
|
-
return /* @__PURE__ */ jsxRuntime.jsx(spar.TooltipArrow, { ...sparProps, ...rootAttrs, ref });
|
|
4834
|
+
const { ref, children, ...sparProps } = rest;
|
|
4835
|
+
return /* @__PURE__ */ jsxRuntime.jsx(spar.TooltipArrow, { ...sparProps, ...rootAttrs, ref, children: children ?? renderPointerArrow() });
|
|
3554
4836
|
};
|
|
3555
4837
|
TooltipArrow.displayName = "Tooltip.Arrow";
|
|
3556
4838
|
|
|
@@ -3582,7 +4864,7 @@ var ToastBase = createComponentBase({
|
|
|
3582
4864
|
|
|
3583
4865
|
// src/components/toast/defaults.ts
|
|
3584
4866
|
var DEFAULT_TOAST_APPEARANCE = "filled";
|
|
3585
|
-
var
|
|
4867
|
+
var DEFAULT_CLOSE_LABEL5 = "Dismiss notification";
|
|
3586
4868
|
|
|
3587
4869
|
// src/components/toast/utils.ts
|
|
3588
4870
|
var toastTypeToVariant = (type) => {
|
|
@@ -3603,7 +4885,7 @@ var toastTypeToVariant = (type) => {
|
|
|
3603
4885
|
var Toast = (props) => {
|
|
3604
4886
|
const theme = useComponentTheme("Toast");
|
|
3605
4887
|
const { rootAttrs, rest } = composeRootAttrs(ToastBase, props, theme);
|
|
3606
|
-
const { as, toast, toaster, appearance = DEFAULT_TOAST_APPEARANCE, closeLabel =
|
|
4888
|
+
const { as, toast, toaster, appearance = DEFAULT_TOAST_APPEARANCE, closeLabel = DEFAULT_CLOSE_LABEL5, children, ref, ...toastProps } = rest;
|
|
3607
4889
|
const Component = as ?? "div";
|
|
3608
4890
|
const variant = toastTypeToVariant(toast.type);
|
|
3609
4891
|
return /* @__PURE__ */ jsxRuntime.jsx(spar.Toast.Root, { ...toastProps, as: Component, ref, toast, toaster, ...rootAttrs, children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(Alert2, { variant, appearance, role: "presentation", children: [
|
|
@@ -3623,7 +4905,7 @@ var Toaster = (props) => {
|
|
|
3623
4905
|
"data-placement": toaster2.placement
|
|
3624
4906
|
})
|
|
3625
4907
|
});
|
|
3626
|
-
const { as, toaster, appearance = DEFAULT_TOAST_APPEARANCE, closeLabel =
|
|
4908
|
+
const { as, toaster, appearance = DEFAULT_TOAST_APPEARANCE, closeLabel = DEFAULT_CLOSE_LABEL5, overlap = false, children, ref, ...toasterProps } = rest;
|
|
3627
4909
|
const Component = as ?? "div";
|
|
3628
4910
|
return /* @__PURE__ */ jsxRuntime.jsx(spar.Toaster, { ...toasterProps, as: Component, ref, toaster, overlap, ...rootAttrs, children: (toast) => (
|
|
3629
4911
|
// Spar renders each item directly into a mapped array, so the key must
|
|
@@ -3634,6 +4916,1081 @@ var Toaster = (props) => {
|
|
|
3634
4916
|
};
|
|
3635
4917
|
Toaster.displayName = "Toaster";
|
|
3636
4918
|
|
|
4919
|
+
// src/components/skeleton/base.ts
|
|
4920
|
+
var SkeletonBase = createComponentBase({
|
|
4921
|
+
name: "Skeleton",
|
|
4922
|
+
slots: ["root", "shimmer"],
|
|
4923
|
+
classes: {
|
|
4924
|
+
root: "tk-skeleton",
|
|
4925
|
+
shimmer: "tk-skeleton-shimmer"
|
|
4926
|
+
}
|
|
4927
|
+
});
|
|
4928
|
+
|
|
4929
|
+
// src/components/skeleton/defaults.ts
|
|
4930
|
+
var DEFAULT_SHAPE = "rectangle";
|
|
4931
|
+
var DEFAULT_ANIMATION = "shimmer";
|
|
4932
|
+
var toCssSize = (value) => typeof value === "number" ? `${value}px` : value;
|
|
4933
|
+
var Skeleton = (props) => {
|
|
4934
|
+
const theme = useComponentTheme("Skeleton");
|
|
4935
|
+
const { rootAttrs, rest } = composeRootAttrs(SkeletonBase, props, theme, {
|
|
4936
|
+
stateAttrs: ({ shape = DEFAULT_SHAPE, animation = DEFAULT_ANIMATION }) => ({
|
|
4937
|
+
"data-type": shape,
|
|
4938
|
+
"data-animation": animation
|
|
4939
|
+
})
|
|
4940
|
+
});
|
|
4941
|
+
const { shape: _shape, animation: _animation, width, height, ref, style, ...nativeProps } = rest;
|
|
4942
|
+
const { style: slotStyle, ...slotAttrs } = rootAttrs;
|
|
4943
|
+
const shimmerSlotAttrs = buildSlotAttrs(SkeletonBase.getSlotProps("shimmer"), "shimmer", {
|
|
4944
|
+
themeSlotProps: theme?.slotProps,
|
|
4945
|
+
themeClassNames: theme?.classNames,
|
|
4946
|
+
instanceSlotProps: props.slotProps,
|
|
4947
|
+
instanceClassNames: props.classNames
|
|
4948
|
+
});
|
|
4949
|
+
const sizeVars = {
|
|
4950
|
+
...width !== void 0 && { "--tk-skeleton-width": toCssSize(width) },
|
|
4951
|
+
...height !== void 0 && { "--tk-skeleton-height": toCssSize(height) }
|
|
4952
|
+
};
|
|
4953
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", ...nativeProps, ...slotAttrs, style: { ...style, ...slotStyle, ...sizeVars }, ref, children: /* @__PURE__ */ jsxRuntime.jsx("span", { ...shimmerSlotAttrs, "aria-hidden": "true" }) });
|
|
4954
|
+
};
|
|
4955
|
+
Skeleton.displayName = "Skeleton";
|
|
4956
|
+
|
|
4957
|
+
// src/components/upload/base.ts
|
|
4958
|
+
var UploadBase = createComponentBase({
|
|
4959
|
+
name: "Upload",
|
|
4960
|
+
slots: ["root"],
|
|
4961
|
+
classes: { root: "tk-upload" }
|
|
4962
|
+
});
|
|
4963
|
+
var UploadDropzoneBase = createComponentBase({
|
|
4964
|
+
name: "UploadDropzone",
|
|
4965
|
+
slots: ["root"],
|
|
4966
|
+
classes: { root: "tk-upload-dropzone" }
|
|
4967
|
+
});
|
|
4968
|
+
var UploadActionsBase = createComponentBase({
|
|
4969
|
+
name: "UploadActions",
|
|
4970
|
+
slots: ["root"],
|
|
4971
|
+
classes: { root: "tk-upload-actions" }
|
|
4972
|
+
});
|
|
4973
|
+
var UploadTriggerBase = createComponentBase({
|
|
4974
|
+
name: "UploadTrigger",
|
|
4975
|
+
slots: ["root"],
|
|
4976
|
+
classes: { root: "tk-upload-trigger" }
|
|
4977
|
+
});
|
|
4978
|
+
var UploadSubmitBase = createComponentBase({
|
|
4979
|
+
name: "UploadSubmit",
|
|
4980
|
+
slots: ["root"],
|
|
4981
|
+
classes: { root: "tk-upload-submit" }
|
|
4982
|
+
});
|
|
4983
|
+
var UploadListBase = createComponentBase({
|
|
4984
|
+
name: "UploadList",
|
|
4985
|
+
slots: ["root"],
|
|
4986
|
+
classes: { root: "tk-upload-list" }
|
|
4987
|
+
});
|
|
4988
|
+
var UploadItemBase = createComponentBase({
|
|
4989
|
+
name: "UploadItem",
|
|
4990
|
+
slots: ["root"],
|
|
4991
|
+
classes: { root: "tk-upload-item" }
|
|
4992
|
+
});
|
|
4993
|
+
var UploadItemContentBase = createComponentBase({
|
|
4994
|
+
name: "UploadItemContent",
|
|
4995
|
+
slots: ["root", "name", "size", "status", "progress"],
|
|
4996
|
+
classes: {
|
|
4997
|
+
root: "tk-upload-item-content",
|
|
4998
|
+
name: "tk-upload-item-name",
|
|
4999
|
+
size: "tk-upload-item-size",
|
|
5000
|
+
status: "tk-upload-item-status",
|
|
5001
|
+
progress: "tk-upload-item-progress"
|
|
5002
|
+
}
|
|
5003
|
+
});
|
|
5004
|
+
var UploadItemPreviewBase = createComponentBase({
|
|
5005
|
+
name: "UploadItemPreview",
|
|
5006
|
+
slots: ["root", "image", "icon", "extension"],
|
|
5007
|
+
classes: {
|
|
5008
|
+
root: "tk-upload-item-preview",
|
|
5009
|
+
image: "tk-upload-item-preview-image",
|
|
5010
|
+
icon: "tk-upload-item-preview-icon",
|
|
5011
|
+
extension: "tk-upload-item-preview-extension"
|
|
5012
|
+
}
|
|
5013
|
+
});
|
|
5014
|
+
var UploadItemActionsBase = createComponentBase({
|
|
5015
|
+
name: "UploadItemActions",
|
|
5016
|
+
slots: ["root"],
|
|
5017
|
+
classes: { root: "tk-upload-item-actions" }
|
|
5018
|
+
});
|
|
5019
|
+
var UploadItemActionBase = createComponentBase({
|
|
5020
|
+
name: "UploadItemAction",
|
|
5021
|
+
slots: ["root"],
|
|
5022
|
+
classes: { root: "tk-upload-item-action" }
|
|
5023
|
+
});
|
|
5024
|
+
|
|
5025
|
+
// src/components/upload/context.ts
|
|
5026
|
+
var [UploadProvider, useUploadContext] = createSafeContext("UploadProvider");
|
|
5027
|
+
var [UploadItemProvider, useUploadItemContext] = createSafeContext("UploadItemProvider");
|
|
5028
|
+
|
|
5029
|
+
// src/components/upload/defaults.ts
|
|
5030
|
+
var DEFAULT_MULTIPLE = false;
|
|
5031
|
+
var DEFAULT_DIRECTORY = false;
|
|
5032
|
+
var DEFAULT_STATUS = "idle";
|
|
5033
|
+
var DEFAULT_UPLOADING_LABEL = "Uploading\u2026";
|
|
5034
|
+
var DEFAULT_PROCESSING_LABEL = "Processing\u2026";
|
|
5035
|
+
var DEFAULT_COMPLETED_LABEL2 = "Completed";
|
|
5036
|
+
var DEFAULT_ERROR_LABEL2 = "Failed";
|
|
5037
|
+
var DEFAULT_PROGRESS_LABEL = "{name} upload progress";
|
|
5038
|
+
var DEFAULT_DOWNLOAD_LABEL = "Download {name}";
|
|
5039
|
+
var DEFAULT_REMOVE_LABEL2 = "Remove {name}";
|
|
5040
|
+
|
|
5041
|
+
// src/components/upload/helpers.ts
|
|
5042
|
+
var fileKey = (file) => `${file.webkitRelativePath || file.name}:${file.size}:${file.lastModified}`;
|
|
5043
|
+
var idCounter = 0;
|
|
5044
|
+
var generateId = () => {
|
|
5045
|
+
const cryptoObj = typeof globalThis !== "undefined" ? globalThis.crypto : void 0;
|
|
5046
|
+
if (cryptoObj && typeof cryptoObj.randomUUID === "function") {
|
|
5047
|
+
try {
|
|
5048
|
+
return cryptoObj.randomUUID();
|
|
5049
|
+
} catch {
|
|
5050
|
+
}
|
|
5051
|
+
}
|
|
5052
|
+
idCounter += 1;
|
|
5053
|
+
return `tk-upload-${idCounter}-${Date.now().toString(36)}`;
|
|
5054
|
+
};
|
|
5055
|
+
var createUploadFile = (file) => ({
|
|
5056
|
+
id: generateId(),
|
|
5057
|
+
file,
|
|
5058
|
+
name: file.name,
|
|
5059
|
+
size: file.size,
|
|
5060
|
+
type: file.type,
|
|
5061
|
+
status: DEFAULT_STATUS
|
|
5062
|
+
});
|
|
5063
|
+
var fileName = (item) => item.name ?? item.file?.name ?? "";
|
|
5064
|
+
var fileSize = (item) => item.size ?? item.file?.size;
|
|
5065
|
+
var fileType = (item) => item.type ?? item.file?.type;
|
|
5066
|
+
var fileStatus = (item) => item.status ?? DEFAULT_STATUS;
|
|
5067
|
+
var formatFileLabel = (template, name) => template.split("{name}").join(name);
|
|
5068
|
+
var isConsumerVeto = (event, preventedOnEntry) => event.defaultPrevented && !preventedOnEntry;
|
|
5069
|
+
var SIZE_UNITS = ["byte", "kilobyte", "megabyte", "gigabyte", "terabyte"];
|
|
5070
|
+
var sizeFormatters = /* @__PURE__ */ new Map();
|
|
5071
|
+
var sizeFormatter = (exponent) => {
|
|
5072
|
+
let formatter = sizeFormatters.get(exponent);
|
|
5073
|
+
if (!formatter) {
|
|
5074
|
+
formatter = new Intl.NumberFormat(void 0, { style: "unit", unit: SIZE_UNITS[exponent], unitDisplay: "short" });
|
|
5075
|
+
sizeFormatters.set(exponent, formatter);
|
|
5076
|
+
}
|
|
5077
|
+
return formatter;
|
|
5078
|
+
};
|
|
5079
|
+
var roundForUnit = (value, exponent) => exponent === 0 || value >= 100 ? Math.round(value) : Math.round(value * 10) / 10;
|
|
5080
|
+
var formatFileSize = (bytes) => {
|
|
5081
|
+
if (!Number.isFinite(bytes) || bytes <= 0) return sizeFormatter(0).format(0);
|
|
5082
|
+
let exponent = Math.max(0, Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), SIZE_UNITS.length - 1));
|
|
5083
|
+
let rounded = roundForUnit(bytes / 1024 ** exponent, exponent);
|
|
5084
|
+
if (rounded >= 1024 && exponent < SIZE_UNITS.length - 1) {
|
|
5085
|
+
exponent += 1;
|
|
5086
|
+
rounded = roundForUnit(bytes / 1024 ** exponent, exponent);
|
|
5087
|
+
}
|
|
5088
|
+
return sizeFormatter(exponent).format(rounded);
|
|
5089
|
+
};
|
|
5090
|
+
var OBJECT_URL_TTL_MS = 1e3;
|
|
5091
|
+
var canSaveUploadFile = (item) => Boolean(item.file || item.url);
|
|
5092
|
+
var saveUploadFile = (item) => {
|
|
5093
|
+
const canCreate = typeof URL !== "undefined" && typeof URL.createObjectURL === "function";
|
|
5094
|
+
const objectUrl = item.file && canCreate ? URL.createObjectURL(item.file) : void 0;
|
|
5095
|
+
const href = objectUrl ?? item.url;
|
|
5096
|
+
if (!href) return;
|
|
5097
|
+
const link = document.createElement("a");
|
|
5098
|
+
link.href = href;
|
|
5099
|
+
link.download = fileName(item);
|
|
5100
|
+
document.body.append(link);
|
|
5101
|
+
link.click();
|
|
5102
|
+
link.remove();
|
|
5103
|
+
if (objectUrl) setTimeout(() => URL.revokeObjectURL(objectUrl), OBJECT_URL_TTL_MS);
|
|
5104
|
+
};
|
|
5105
|
+
var IMAGE_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/png", "image/gif", "image/webp", "image/avif", "image/svg+xml"]);
|
|
5106
|
+
var isImageType = (type) => type !== void 0 && IMAGE_TYPES.has(type);
|
|
5107
|
+
var nameExtension = (name) => {
|
|
5108
|
+
const dot = name.lastIndexOf(".");
|
|
5109
|
+
return dot > 0 ? name.slice(dot + 1).toUpperCase() : "";
|
|
5110
|
+
};
|
|
5111
|
+
var ICON_BY_EXTENSION = {
|
|
5112
|
+
DOC: "word",
|
|
5113
|
+
DOCX: "word",
|
|
5114
|
+
JPEG: "jpg",
|
|
5115
|
+
JPG: "jpg",
|
|
5116
|
+
MP4: "mp4",
|
|
5117
|
+
PDF: "pdf",
|
|
5118
|
+
PNG: "png",
|
|
5119
|
+
PPT: "powerpoint",
|
|
5120
|
+
PPTX: "powerpoint",
|
|
5121
|
+
TXT: "text",
|
|
5122
|
+
XLS: "excel",
|
|
5123
|
+
XLSX: "excel",
|
|
5124
|
+
ZIP: "zip"
|
|
5125
|
+
};
|
|
5126
|
+
var ICON_BY_TYPE = {
|
|
5127
|
+
"application/msword": "word",
|
|
5128
|
+
"application/pdf": "pdf",
|
|
5129
|
+
"application/vnd.ms-excel": "excel",
|
|
5130
|
+
"application/vnd.ms-powerpoint": "powerpoint",
|
|
5131
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation": "powerpoint",
|
|
5132
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "excel",
|
|
5133
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": "word",
|
|
5134
|
+
"application/zip": "zip",
|
|
5135
|
+
"image/jpeg": "jpg",
|
|
5136
|
+
"image/png": "png",
|
|
5137
|
+
"text/plain": "text",
|
|
5138
|
+
"video/mp4": "mp4"
|
|
5139
|
+
};
|
|
5140
|
+
var fileIconName = (item) => {
|
|
5141
|
+
const type = fileType(item);
|
|
5142
|
+
return ICON_BY_EXTENSION[nameExtension(fileName(item))] ?? (type ? ICON_BY_TYPE[type.toLowerCase()] : void 0);
|
|
5143
|
+
};
|
|
5144
|
+
var isWildcard = (token) => token === "*" || token === "*/*";
|
|
5145
|
+
var acceptTokens = (accept) => accept ? accept.split(",").map((token) => token.trim().toLowerCase()).filter((token) => token !== "") : [];
|
|
5146
|
+
var acceptsAnything = (tokens) => tokens.length === 0 || tokens.some(isWildcard);
|
|
5147
|
+
var tokenMatchesFile = (token, file) => {
|
|
5148
|
+
if (token.startsWith(".")) return file.name.toLowerCase().endsWith(token);
|
|
5149
|
+
const type = file.type.toLowerCase();
|
|
5150
|
+
if (token.endsWith("/*")) return type.startsWith(token.slice(0, -1));
|
|
5151
|
+
return type === token;
|
|
5152
|
+
};
|
|
5153
|
+
var matchesAccept = (file, accept) => {
|
|
5154
|
+
const tokens = acceptTokens(accept);
|
|
5155
|
+
if (acceptsAnything(tokens)) return true;
|
|
5156
|
+
return tokens.some((token) => tokenMatchesFile(token, file));
|
|
5157
|
+
};
|
|
5158
|
+
var acceptMatchesType = (type, accept) => {
|
|
5159
|
+
const tokens = acceptTokens(accept);
|
|
5160
|
+
if (acceptsAnything(tokens)) return true;
|
|
5161
|
+
const t = type.toLowerCase();
|
|
5162
|
+
let unjudgeable = false;
|
|
5163
|
+
for (const token of tokens) {
|
|
5164
|
+
if (token.startsWith(".")) {
|
|
5165
|
+
unjudgeable = true;
|
|
5166
|
+
continue;
|
|
5167
|
+
}
|
|
5168
|
+
if (token.endsWith("/*") ? t.startsWith(token.slice(0, -1)) : t === token) return true;
|
|
5169
|
+
}
|
|
5170
|
+
return unjudgeable;
|
|
5171
|
+
};
|
|
5172
|
+
var validateFiles = (incoming, options) => {
|
|
5173
|
+
const { accept, maxFileSize, maxFileCount, multiple, currentCount } = options;
|
|
5174
|
+
const accepted = [];
|
|
5175
|
+
const rejected = [];
|
|
5176
|
+
const limit = multiple ? maxFileCount : 1;
|
|
5177
|
+
let slots = limit === void 0 ? Number.POSITIVE_INFINITY : Math.max(0, limit - (multiple ? currentCount : 0));
|
|
5178
|
+
for (const file of incoming) {
|
|
5179
|
+
if (!matchesAccept(file, accept)) {
|
|
5180
|
+
rejected.push({ file, code: "file-invalid-type", accept });
|
|
5181
|
+
continue;
|
|
5182
|
+
}
|
|
5183
|
+
if (maxFileSize !== void 0 && file.size > maxFileSize) {
|
|
5184
|
+
rejected.push({ file, code: "file-too-large", maxFileSize });
|
|
5185
|
+
continue;
|
|
5186
|
+
}
|
|
5187
|
+
if (slots <= 0) {
|
|
5188
|
+
rejected.push({ file, code: "too-many-files", maxFileCount: limit });
|
|
5189
|
+
continue;
|
|
5190
|
+
}
|
|
5191
|
+
accepted.push(file);
|
|
5192
|
+
slots -= 1;
|
|
5193
|
+
}
|
|
5194
|
+
return { accepted, rejected };
|
|
5195
|
+
};
|
|
5196
|
+
var Upload = (props) => {
|
|
5197
|
+
const theme = useComponentTheme("Upload");
|
|
5198
|
+
const field = spar.useOptionalFieldContext();
|
|
5199
|
+
const inputRef = react.useRef(null);
|
|
5200
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadBase, props, theme);
|
|
5201
|
+
const {
|
|
5202
|
+
value,
|
|
5203
|
+
defaultValue,
|
|
5204
|
+
onValueChange,
|
|
5205
|
+
accept,
|
|
5206
|
+
multiple: ownMultiple = DEFAULT_MULTIPLE,
|
|
5207
|
+
directory = DEFAULT_DIRECTORY,
|
|
5208
|
+
maxFileSize,
|
|
5209
|
+
maxFileCount,
|
|
5210
|
+
onFileAccept,
|
|
5211
|
+
onFilesReject,
|
|
5212
|
+
// The status four resolve here, at the destructure site: `??`, so an empty
|
|
5213
|
+
// one is honoured and the support line goes away with its glyph.
|
|
5214
|
+
uploadingLabel = DEFAULT_UPLOADING_LABEL,
|
|
5215
|
+
processingLabel = DEFAULT_PROCESSING_LABEL,
|
|
5216
|
+
completedLabel = DEFAULT_COMPLETED_LABEL2,
|
|
5217
|
+
errorLabel = DEFAULT_ERROR_LABEL2,
|
|
5218
|
+
// The accessible-name three cannot resolve here — see below.
|
|
5219
|
+
progressLabel: ownProgressLabel,
|
|
5220
|
+
downloadLabel: ownDownloadLabel,
|
|
5221
|
+
removeLabel: ownRemoveLabel,
|
|
5222
|
+
disabled: ownDisabled,
|
|
5223
|
+
readOnly: ownReadOnly,
|
|
5224
|
+
invalid: ownInvalid,
|
|
5225
|
+
as,
|
|
5226
|
+
children,
|
|
5227
|
+
ref,
|
|
5228
|
+
...nativeProps
|
|
5229
|
+
} = rest;
|
|
5230
|
+
const multiple = ownMultiple || directory;
|
|
5231
|
+
const disabled = ownDisabled ?? field?.disabled ?? false;
|
|
5232
|
+
const readOnly = ownReadOnly ?? field?.readOnly ?? false;
|
|
5233
|
+
const invalid = ownInvalid ?? field?.invalid ?? false;
|
|
5234
|
+
const [files = [], setFiles, isControlled] = useControllableState(value, defaultValue ?? [], onValueChange);
|
|
5235
|
+
const latestFiles = react.useRef(files);
|
|
5236
|
+
latestFiles.current = files;
|
|
5237
|
+
const commitFiles = react.useCallback(
|
|
5238
|
+
(next) => {
|
|
5239
|
+
if (!isControlled) latestFiles.current = next;
|
|
5240
|
+
setFiles(next);
|
|
5241
|
+
},
|
|
5242
|
+
[isControlled, setFiles]
|
|
5243
|
+
);
|
|
5244
|
+
const processFiles = react.useCallback(
|
|
5245
|
+
(incoming) => {
|
|
5246
|
+
if (disabled || readOnly) return;
|
|
5247
|
+
const list = Array.from(incoming);
|
|
5248
|
+
if (list.length === 0) return;
|
|
5249
|
+
const current = latestFiles.current;
|
|
5250
|
+
const seen = new Set(current.filter((entry) => entry.file).map((entry) => fileKey(entry.file)));
|
|
5251
|
+
const fresh = list.filter((file) => {
|
|
5252
|
+
const key = fileKey(file);
|
|
5253
|
+
if (seen.has(key)) return false;
|
|
5254
|
+
seen.add(key);
|
|
5255
|
+
return true;
|
|
5256
|
+
});
|
|
5257
|
+
const { accepted, rejected } = validateFiles(fresh, { accept, maxFileSize, maxFileCount, multiple, currentCount: current.length });
|
|
5258
|
+
const added = accepted.map(createUploadFile);
|
|
5259
|
+
if (added.length > 0) {
|
|
5260
|
+
commitFiles(multiple ? [...current, ...added] : added);
|
|
5261
|
+
onFileAccept?.(added);
|
|
5262
|
+
}
|
|
5263
|
+
if (rejected.length > 0) {
|
|
5264
|
+
onFilesReject?.(rejected);
|
|
5265
|
+
}
|
|
5266
|
+
},
|
|
5267
|
+
[disabled, readOnly, accept, maxFileSize, maxFileCount, multiple, commitFiles, onFileAccept, onFilesReject]
|
|
5268
|
+
);
|
|
5269
|
+
const openFileDialog = react.useCallback(() => {
|
|
5270
|
+
if (disabled || readOnly) return;
|
|
5271
|
+
inputRef.current?.click();
|
|
5272
|
+
}, [disabled, readOnly]);
|
|
5273
|
+
const removeFile = react.useCallback(
|
|
5274
|
+
(id) => {
|
|
5275
|
+
if (disabled || readOnly) return;
|
|
5276
|
+
commitFiles(latestFiles.current.filter((entry) => entry.id !== id));
|
|
5277
|
+
if (inputRef.current) inputRef.current.value = "";
|
|
5278
|
+
},
|
|
5279
|
+
[disabled, readOnly, commitFiles]
|
|
5280
|
+
);
|
|
5281
|
+
const handleInputChange = (event) => {
|
|
5282
|
+
processFiles(event.target.files ?? []);
|
|
5283
|
+
event.target.value = "";
|
|
5284
|
+
};
|
|
5285
|
+
const progressLabel = ownProgressLabel || DEFAULT_PROGRESS_LABEL;
|
|
5286
|
+
const downloadLabel = ownDownloadLabel || DEFAULT_DOWNLOAD_LABEL;
|
|
5287
|
+
const removeLabel = ownRemoveLabel || DEFAULT_REMOVE_LABEL2;
|
|
5288
|
+
const contextValue = react.useMemo(
|
|
5289
|
+
() => ({
|
|
5290
|
+
files,
|
|
5291
|
+
disabled,
|
|
5292
|
+
readOnly,
|
|
5293
|
+
invalid,
|
|
5294
|
+
accept,
|
|
5295
|
+
multiple,
|
|
5296
|
+
openFileDialog,
|
|
5297
|
+
removeFile,
|
|
5298
|
+
processFiles,
|
|
5299
|
+
// Keyed by the status it stands for, so a row looks one up rather than
|
|
5300
|
+
// mapping names to states. Built inside this memo rather than one of its
|
|
5301
|
+
// own: it changes exactly when the four strings do, which is when the
|
|
5302
|
+
// context is rebuilt anyway.
|
|
5303
|
+
statusLabels: { uploading: uploadingLabel, processing: processingLabel, completed: completedLabel, error: errorLabel },
|
|
5304
|
+
progressLabel,
|
|
5305
|
+
downloadLabel,
|
|
5306
|
+
removeLabel
|
|
5307
|
+
}),
|
|
5308
|
+
[
|
|
5309
|
+
files,
|
|
5310
|
+
disabled,
|
|
5311
|
+
readOnly,
|
|
5312
|
+
invalid,
|
|
5313
|
+
accept,
|
|
5314
|
+
multiple,
|
|
5315
|
+
openFileDialog,
|
|
5316
|
+
removeFile,
|
|
5317
|
+
processFiles,
|
|
5318
|
+
uploadingLabel,
|
|
5319
|
+
processingLabel,
|
|
5320
|
+
completedLabel,
|
|
5321
|
+
errorLabel,
|
|
5322
|
+
progressLabel,
|
|
5323
|
+
downloadLabel,
|
|
5324
|
+
removeLabel
|
|
5325
|
+
]
|
|
5326
|
+
);
|
|
5327
|
+
const Component = as ?? "div";
|
|
5328
|
+
const htmlProps = nativeProps;
|
|
5329
|
+
const named = htmlProps["aria-label"] !== void 0 || htmlProps["aria-labelledby"] !== void 0;
|
|
5330
|
+
const groupAttrs = {
|
|
5331
|
+
"id": htmlProps.id ?? field?.fieldId,
|
|
5332
|
+
"role": htmlProps.role ?? "group",
|
|
5333
|
+
"aria-labelledby": named ? htmlProps["aria-labelledby"] : field?.labelId,
|
|
5334
|
+
// Mirrors Spar's own controls: the error message replaces the description
|
|
5335
|
+
// while invalid, rather than both being announced.
|
|
5336
|
+
"aria-describedby": htmlProps["aria-describedby"] ?? (invalid ? field?.errorId : field?.descriptionId)
|
|
5337
|
+
};
|
|
5338
|
+
const stateAttrs = {
|
|
5339
|
+
...disabled ? { "data-disabled": "" } : null,
|
|
5340
|
+
...readOnly ? { "data-readonly": "" } : null,
|
|
5341
|
+
...invalid ? { "data-invalid": "" } : null
|
|
5342
|
+
};
|
|
5343
|
+
return /* @__PURE__ */ jsxRuntime.jsx(UploadProvider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(Component, { ...nativeProps, ...groupAttrs, ...rootAttrs, ...stateAttrs, ref, children: [
|
|
5344
|
+
children,
|
|
5345
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5346
|
+
spar.InputField,
|
|
5347
|
+
{
|
|
5348
|
+
ref: inputRef,
|
|
5349
|
+
type: "file",
|
|
5350
|
+
accept,
|
|
5351
|
+
multiple,
|
|
5352
|
+
...directory ? { webkitdirectory: "" } : null,
|
|
5353
|
+
disabled: disabled || readOnly,
|
|
5354
|
+
onChange: handleInputChange,
|
|
5355
|
+
hidden: true,
|
|
5356
|
+
tabIndex: -1,
|
|
5357
|
+
"aria-hidden": "true"
|
|
5358
|
+
}
|
|
5359
|
+
)
|
|
5360
|
+
] }) });
|
|
5361
|
+
};
|
|
5362
|
+
Upload.displayName = "Upload";
|
|
5363
|
+
var UploadActions = (props) => {
|
|
5364
|
+
const theme = useComponentTheme("UploadActions");
|
|
5365
|
+
useUploadContext("Upload.Actions");
|
|
5366
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadActionsBase, props, theme);
|
|
5367
|
+
const { as, children, ref, ...nativeProps } = rest;
|
|
5368
|
+
const Component = as ?? "div";
|
|
5369
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...nativeProps, ...rootAttrs, ref, children });
|
|
5370
|
+
};
|
|
5371
|
+
UploadActions.displayName = "Upload.Actions";
|
|
5372
|
+
var dragStateFor = (event, accept) => {
|
|
5373
|
+
const items = event.dataTransfer?.items;
|
|
5374
|
+
if (!items || items.length === 0) return "accept";
|
|
5375
|
+
for (const item of Array.from(items)) {
|
|
5376
|
+
if (item.kind === "file" && !acceptMatchesType(item.type, accept)) return "reject";
|
|
5377
|
+
}
|
|
5378
|
+
return "accept";
|
|
5379
|
+
};
|
|
5380
|
+
var UploadDropzone = (props) => {
|
|
5381
|
+
const theme = useComponentTheme("UploadDropzone");
|
|
5382
|
+
const { disabled, readOnly, accept, processFiles } = useUploadContext("Upload.Dropzone");
|
|
5383
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadDropzoneBase, props, theme);
|
|
5384
|
+
const {
|
|
5385
|
+
onDragEnter: slotOnDragEnter,
|
|
5386
|
+
onDragOver: slotOnDragOver,
|
|
5387
|
+
onDragLeave: slotOnDragLeave,
|
|
5388
|
+
onDrop: slotOnDrop,
|
|
5389
|
+
...dropzoneRootAttrs
|
|
5390
|
+
} = rootAttrs;
|
|
5391
|
+
const { as, children, ref, onDragEnter, onDragOver, onDragLeave, onDrop, ...nativeProps } = rest;
|
|
5392
|
+
const [dragState, setDragState] = react.useState(null);
|
|
5393
|
+
const depth = react.useRef(0);
|
|
5394
|
+
const active = !disabled && !readOnly;
|
|
5395
|
+
const handleDragEnter = (event) => {
|
|
5396
|
+
onDragEnter?.(event);
|
|
5397
|
+
slotOnDragEnter?.(event);
|
|
5398
|
+
event.preventDefault();
|
|
5399
|
+
if (!active) return;
|
|
5400
|
+
depth.current += 1;
|
|
5401
|
+
setDragState(dragStateFor(event, accept));
|
|
5402
|
+
};
|
|
5403
|
+
const handleDragOver = (event) => {
|
|
5404
|
+
onDragOver?.(event);
|
|
5405
|
+
slotOnDragOver?.(event);
|
|
5406
|
+
event.preventDefault();
|
|
5407
|
+
if (!active) return;
|
|
5408
|
+
if (dragState === null) setDragState(dragStateFor(event, accept));
|
|
5409
|
+
};
|
|
5410
|
+
const handleDragLeave = (event) => {
|
|
5411
|
+
onDragLeave?.(event);
|
|
5412
|
+
slotOnDragLeave?.(event);
|
|
5413
|
+
depth.current = Math.max(0, depth.current - 1);
|
|
5414
|
+
if (depth.current === 0) setDragState(null);
|
|
5415
|
+
};
|
|
5416
|
+
const handleDrop = (event) => {
|
|
5417
|
+
onDrop?.(event);
|
|
5418
|
+
slotOnDrop?.(event);
|
|
5419
|
+
event.preventDefault();
|
|
5420
|
+
depth.current = 0;
|
|
5421
|
+
setDragState(null);
|
|
5422
|
+
if (!active) return;
|
|
5423
|
+
if (event.dataTransfer?.files?.length) processFiles(event.dataTransfer.files);
|
|
5424
|
+
};
|
|
5425
|
+
const Component = as ?? "div";
|
|
5426
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5427
|
+
Component,
|
|
5428
|
+
{
|
|
5429
|
+
...nativeProps,
|
|
5430
|
+
...dropzoneRootAttrs,
|
|
5431
|
+
"data-drag-state": dragState ?? void 0,
|
|
5432
|
+
onDragEnter: handleDragEnter,
|
|
5433
|
+
onDragOver: handleDragOver,
|
|
5434
|
+
onDragLeave: handleDragLeave,
|
|
5435
|
+
onDrop: handleDrop,
|
|
5436
|
+
ref,
|
|
5437
|
+
children
|
|
5438
|
+
}
|
|
5439
|
+
);
|
|
5440
|
+
};
|
|
5441
|
+
UploadDropzone.displayName = "Upload.Dropzone";
|
|
5442
|
+
var ACTION_ICON = {
|
|
5443
|
+
download: /* @__PURE__ */ jsxRuntime.jsx(arrowDownload.ArrowDownloadIconOutlinedRounded, { "aria-hidden": "true", focusable: "false" }),
|
|
5444
|
+
remove: /* @__PURE__ */ jsxRuntime.jsx(close.CloseIconOutlinedRounded, { "aria-hidden": "true", focusable: "false" })
|
|
5445
|
+
};
|
|
5446
|
+
var isBuiltInAction = (action) => action === "download" || action === "remove";
|
|
5447
|
+
var siblingRow = (row) => {
|
|
5448
|
+
const next = row.nextElementSibling;
|
|
5449
|
+
if (next?.matches(".tk-upload-item")) return next;
|
|
5450
|
+
const previous = row.previousElementSibling;
|
|
5451
|
+
return previous?.matches(".tk-upload-item") ? previous : null;
|
|
5452
|
+
};
|
|
5453
|
+
var moveFocusOffRow = (button) => {
|
|
5454
|
+
const row = button.closest(".tk-upload-item");
|
|
5455
|
+
const neighbour = row ? siblingRow(row) : null;
|
|
5456
|
+
const target = neighbour?.querySelector('[data-action="remove"]') ?? neighbour?.querySelector('button, [role="button"], a[href]') ?? button.closest(".tk-upload")?.querySelector(".tk-upload-trigger") ?? null;
|
|
5457
|
+
target?.focus();
|
|
5458
|
+
};
|
|
5459
|
+
var DEFAULT_ACTION_APPEARANCE = "outlined";
|
|
5460
|
+
var DEFAULT_ACTION_VARIANT = "neutral";
|
|
5461
|
+
var DEFAULT_ACTION_SIZE = "small";
|
|
5462
|
+
var UploadItemAction = (props) => {
|
|
5463
|
+
const theme = useComponentTheme("UploadItemAction");
|
|
5464
|
+
const { disabled, readOnly, removeFile, downloadLabel, removeLabel } = useUploadContext("Upload.ItemAction");
|
|
5465
|
+
const { item } = useUploadItemContext("Upload.ItemAction");
|
|
5466
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadItemActionBase, props, theme, {
|
|
5467
|
+
// Which action this is: documented for consumers styling one action out of a
|
|
5468
|
+
// row. The look itself comes from Button's variant, not from this hook.
|
|
5469
|
+
stateAttrs: (merged) => ({ "data-action": merged.action })
|
|
5470
|
+
});
|
|
5471
|
+
const { onClick: slotOnClick, ...actionRootAttrs } = rootAttrs;
|
|
5472
|
+
const {
|
|
5473
|
+
as,
|
|
5474
|
+
action,
|
|
5475
|
+
label,
|
|
5476
|
+
children,
|
|
5477
|
+
ref,
|
|
5478
|
+
href,
|
|
5479
|
+
role,
|
|
5480
|
+
onClick,
|
|
5481
|
+
"disabled": ownDisabled,
|
|
5482
|
+
"aria-label": ariaLabel,
|
|
5483
|
+
// An icon button in the row: the anatomy and the look come from Button, so
|
|
5484
|
+
// the appearance knobs live here rather than in the Upload recipe. Applied
|
|
5485
|
+
// at the destructure site (the coding-standards rule) rather than pinned
|
|
5486
|
+
// after the spread, so they layer as defaults — a theme's
|
|
5487
|
+
// `UploadItemAction.defaultProps` is already merged into `rest` by
|
|
5488
|
+
// `composeRootAttrs`, and a value pinned after the spread would silently
|
|
5489
|
+
// outrank it.
|
|
5490
|
+
"appearance": appearance = DEFAULT_ACTION_APPEARANCE,
|
|
5491
|
+
"variant": variant = DEFAULT_ACTION_VARIANT,
|
|
5492
|
+
"size": size = DEFAULT_ACTION_SIZE,
|
|
5493
|
+
...buttonProps
|
|
5494
|
+
} = rest;
|
|
5495
|
+
const isDisabled = disabled || ownDisabled === true;
|
|
5496
|
+
if (action === "remove" && readOnly) return null;
|
|
5497
|
+
const isButton = (as ?? "button") === "button";
|
|
5498
|
+
const hasHref = !isButton && href !== void 0;
|
|
5499
|
+
if (action === "download" && !canSaveUploadFile(item) && !hasHref && !onClick && !slotOnClick) return null;
|
|
5500
|
+
const nameTemplate = label || (action === "download" ? downloadLabel : action === "remove" ? removeLabel : void 0);
|
|
5501
|
+
const handleClick = (event) => {
|
|
5502
|
+
const button = event.currentTarget;
|
|
5503
|
+
const preventedOnEntry = event.defaultPrevented;
|
|
5504
|
+
onClick?.(event);
|
|
5505
|
+
slotOnClick?.(event);
|
|
5506
|
+
if (isConsumerVeto(event, preventedOnEntry)) return;
|
|
5507
|
+
if (action === "remove") {
|
|
5508
|
+
moveFocusOffRow(button);
|
|
5509
|
+
removeFile(item.id);
|
|
5510
|
+
} else if (action === "download" && !hasHref) saveUploadFile(item);
|
|
5511
|
+
};
|
|
5512
|
+
const renderedHref = isDisabled ? void 0 : href;
|
|
5513
|
+
const resolvedRole = role ?? (!isButton && as === "a" && renderedHref !== void 0 ? "link" : void 0);
|
|
5514
|
+
const roleProps = resolvedRole !== void 0 ? { role: resolvedRole } : void 0;
|
|
5515
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5516
|
+
Button,
|
|
5517
|
+
{
|
|
5518
|
+
...buttonProps,
|
|
5519
|
+
...isButton ? null : { href: renderedHref },
|
|
5520
|
+
...roleProps,
|
|
5521
|
+
...actionRootAttrs,
|
|
5522
|
+
as,
|
|
5523
|
+
appearance,
|
|
5524
|
+
variant,
|
|
5525
|
+
size,
|
|
5526
|
+
disabled: isDisabled,
|
|
5527
|
+
"aria-label": ariaLabel ?? (nameTemplate ? formatFileLabel(nameTemplate, fileName(item)) : void 0),
|
|
5528
|
+
onClick: handleClick,
|
|
5529
|
+
startContent: isRenderableNode(children) ? children : isBuiltInAction(action) ? ACTION_ICON[action] : null,
|
|
5530
|
+
ref
|
|
5531
|
+
}
|
|
5532
|
+
);
|
|
5533
|
+
};
|
|
5534
|
+
UploadItemAction.displayName = "Upload.ItemAction";
|
|
5535
|
+
var UploadItemActions = (props) => {
|
|
5536
|
+
const theme = useComponentTheme("UploadItemActions");
|
|
5537
|
+
const { readOnly } = useUploadContext("Upload.ItemActions");
|
|
5538
|
+
const { item } = useUploadItemContext("Upload.ItemActions");
|
|
5539
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadItemActionsBase, props, theme);
|
|
5540
|
+
const { as, children, ref, ...nativeProps } = rest;
|
|
5541
|
+
const Component = as ?? "div";
|
|
5542
|
+
const hasChildren = isRenderableNode(children);
|
|
5543
|
+
const showDownload = canSaveUploadFile(item);
|
|
5544
|
+
const showRemove = !readOnly;
|
|
5545
|
+
if (!hasChildren && !showDownload && !showRemove) return null;
|
|
5546
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...nativeProps, ...rootAttrs, ref, children: hasChildren ? children : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5547
|
+
showDownload && /* @__PURE__ */ jsxRuntime.jsx(UploadItemAction, { action: "download" }),
|
|
5548
|
+
showRemove && /* @__PURE__ */ jsxRuntime.jsx(UploadItemAction, { action: "remove" })
|
|
5549
|
+
] }) });
|
|
5550
|
+
};
|
|
5551
|
+
UploadItemActions.displayName = "Upload.ItemActions";
|
|
5552
|
+
var statusLabelOf = (status, statusLabels) => status === "idle" ? null : statusLabels[status];
|
|
5553
|
+
var statusIcon = (status) => {
|
|
5554
|
+
switch (status) {
|
|
5555
|
+
case "uploading":
|
|
5556
|
+
case "processing":
|
|
5557
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: "small", appearance: "rounded", variant: "info", "aria-hidden": "true" });
|
|
5558
|
+
case "completed":
|
|
5559
|
+
return /* @__PURE__ */ jsxRuntime.jsx(checkCircle.CheckCircleIconFilledRounded, { "aria-hidden": "true", focusable: "false" });
|
|
5560
|
+
case "error":
|
|
5561
|
+
return /* @__PURE__ */ jsxRuntime.jsx(closeCircle.CloseCircleIconFilledRounded, { "aria-hidden": "true", focusable: "false" });
|
|
5562
|
+
default:
|
|
5563
|
+
return null;
|
|
5564
|
+
}
|
|
5565
|
+
};
|
|
5566
|
+
var UploadItemContent = (props) => {
|
|
5567
|
+
const theme = useComponentTheme("UploadItemContent");
|
|
5568
|
+
const { item } = useUploadItemContext("Upload.ItemContent");
|
|
5569
|
+
const { statusLabels, progressLabel } = useUploadContext("Upload.ItemContent");
|
|
5570
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadItemContentBase, props, theme);
|
|
5571
|
+
const { as, children, ref, ...nativeProps } = rest;
|
|
5572
|
+
const slotAttrs = (slot) => buildSlotAttrs(UploadItemContentBase.getSlotProps(slot), slot, {
|
|
5573
|
+
themeSlotProps: theme?.slotProps,
|
|
5574
|
+
themeClassNames: theme?.classNames,
|
|
5575
|
+
instanceSlotProps: props.slotProps,
|
|
5576
|
+
instanceClassNames: props.classNames
|
|
5577
|
+
});
|
|
5578
|
+
const Component = as ?? "div";
|
|
5579
|
+
const name = fileName(item);
|
|
5580
|
+
const size = fileSize(item);
|
|
5581
|
+
const status = fileStatus(item);
|
|
5582
|
+
const icon = statusIcon(status);
|
|
5583
|
+
const statusLabel = statusLabelOf(status, statusLabels);
|
|
5584
|
+
const statusText = status === "error" ? item.error ?? statusLabel : statusLabel;
|
|
5585
|
+
const defaultContent = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5586
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { ...slotAttrs("name"), children: name }),
|
|
5587
|
+
size !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { ...slotAttrs("size"), children: formatFileSize(size) }),
|
|
5588
|
+
icon && statusText ? (
|
|
5589
|
+
// Icon plus its label, as one line: the glyph is decorative and the
|
|
5590
|
+
// text carries the meaning, so nothing here needs an aria-label of its
|
|
5591
|
+
// own. `title` keeps a long failure message reachable in full while the
|
|
5592
|
+
// line itself stays one row high.
|
|
5593
|
+
//
|
|
5594
|
+
// No text, no line — a status label emptied at the root takes the glyph
|
|
5595
|
+
// with it. The alternative is a lone `aria-hidden` icon: a mark that
|
|
5596
|
+
// says something to sighted users and nothing to anyone else, which is
|
|
5597
|
+
// the split this line exists to avoid.
|
|
5598
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { ...slotAttrs("status"), title: status === "error" ? item.error : void 0, children: [
|
|
5599
|
+
icon,
|
|
5600
|
+
statusText
|
|
5601
|
+
] })
|
|
5602
|
+
) : null,
|
|
5603
|
+
status === "uploading" && typeof item.progress === "number" && // The bar is the *determinate* face of uploading — it only appears once
|
|
5604
|
+
// there is a percentage to show. Without one, the spinner and its
|
|
5605
|
+
// "Uploading…" label above are already the indeterminate indicator, so
|
|
5606
|
+
// a second (looping) bar would say the same thing twice. `processing`
|
|
5607
|
+
// never gets one: a server-side step reports that it is running, not
|
|
5608
|
+
// how far along it is.
|
|
5609
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ...slotAttrs("progress"), children: /* @__PURE__ */ jsxRuntime.jsx(Progress2, { value: item.progress, size: "small", "aria-label": formatFileLabel(progressLabel, name) }) })
|
|
5610
|
+
] });
|
|
5611
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...nativeProps, ...rootAttrs, ref, children: isRenderableNode(children) ? children : defaultContent });
|
|
5612
|
+
};
|
|
5613
|
+
UploadItemContent.displayName = "Upload.ItemContent";
|
|
5614
|
+
var FileExcelIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", ...props, children: [
|
|
5615
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M28.75 1.25V9.58333C28.75 10.5042 29.4958 11.25 30.4167 11.25H38.75", stroke: "#CACFD8", strokeWidth: "1.875" }),
|
|
5616
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5617
|
+
"path",
|
|
5618
|
+
{
|
|
5619
|
+
d: "M15 0.9375H26.8936C28.634 0.937541 30.3035 1.6287 31.5342 2.85938L37.1406 8.46582C38.3713 9.69649 39.0625 11.366 39.0625 13.1064V32.5C39.0625 36.1244 36.1244 39.0625 32.5 39.0625H15C11.3756 39.0625 8.4375 36.1244 8.4375 32.5V7.5C8.4375 3.87563 11.3756 0.9375 15 0.9375Z",
|
|
5620
|
+
stroke: "#CACFD8",
|
|
5621
|
+
strokeWidth: "1.875"
|
|
5622
|
+
}
|
|
5623
|
+
),
|
|
5624
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { y: "15", width: "35", height: "20", rx: "5", fill: "#136C34" }),
|
|
5625
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5626
|
+
"path",
|
|
5627
|
+
{
|
|
5628
|
+
d: "M6.76722 29L9.49122 24.692L6.91122 20.6H8.51922L10.4572 23.702L12.5272 20.6H14.0872L11.3752 24.728L14.1652 29H12.5512L10.4032 25.694L8.33322 29H6.76722ZM15.5803 29V20.6H16.9243V27.764H20.5843V29H15.5803ZM24.8436 29.18C24.2636 29.18 23.6956 29.098 23.1396 28.934C22.5876 28.766 22.1216 28.526 21.7416 28.214L22.4016 27.188C22.6016 27.36 22.8336 27.508 23.0976 27.632C23.3656 27.756 23.6496 27.852 23.9496 27.92C24.2496 27.984 24.5496 28.016 24.8496 28.016C25.3976 28.016 25.8396 27.912 26.1756 27.704C26.5156 27.496 26.6856 27.192 26.6856 26.792C26.6856 26.492 26.5696 26.238 26.3376 26.03C26.1096 25.822 25.6856 25.63 25.0656 25.454L24.2016 25.202C23.4096 24.974 22.8316 24.672 22.4676 24.296C22.1076 23.92 21.9276 23.452 21.9276 22.892C21.9276 22.52 22.0016 22.184 22.1496 21.884C22.3016 21.584 22.5136 21.324 22.7856 21.104C23.0616 20.884 23.3856 20.716 23.7576 20.6C24.1296 20.484 24.5376 20.426 24.9816 20.426C25.5456 20.426 26.0696 20.508 26.5536 20.672C27.0376 20.836 27.4376 21.056 27.7536 21.332L27.0696 22.328C26.8976 22.172 26.6956 22.038 26.4636 21.926C26.2356 21.814 25.9896 21.728 25.7256 21.668C25.4616 21.608 25.1936 21.578 24.9216 21.578C24.5856 21.578 24.2876 21.628 24.0276 21.728C23.7716 21.824 23.5716 21.964 23.4276 22.148C23.2836 22.332 23.2116 22.556 23.2116 22.82C23.2116 23.012 23.2596 23.18 23.3556 23.324C23.4516 23.468 23.6156 23.6 23.8476 23.72C24.0836 23.836 24.4076 23.954 24.8196 24.074L25.7316 24.344C26.5076 24.572 27.0756 24.87 27.4356 25.238C27.7956 25.602 27.9756 26.076 27.9756 26.66C27.9756 27.16 27.8516 27.6 27.6036 27.98C27.3596 28.356 27.0036 28.65 26.5356 28.862C26.0676 29.074 25.5036 29.18 24.8436 29.18Z",
|
|
5629
|
+
fill: "white"
|
|
5630
|
+
}
|
|
5631
|
+
)
|
|
5632
|
+
] });
|
|
5633
|
+
var FileJpgIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", ...props, children: [
|
|
5634
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M28.75 1.25V9.58333C28.75 10.5042 29.4958 11.25 30.4167 11.25H38.75", stroke: "#CACFD8", strokeWidth: "1.875" }),
|
|
5635
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5636
|
+
"path",
|
|
5637
|
+
{
|
|
5638
|
+
d: "M15 0.9375H26.8936C28.634 0.937541 30.3035 1.6287 31.5342 2.85938L37.1406 8.46582C38.3713 9.69649 39.0625 11.366 39.0625 13.1064V32.5C39.0625 36.1244 36.1244 39.0625 32.5 39.0625H15C11.3756 39.0625 8.4375 36.1244 8.4375 32.5V7.5C8.4375 3.87563 11.3756 0.9375 15 0.9375Z",
|
|
5639
|
+
stroke: "#CACFD8",
|
|
5640
|
+
strokeWidth: "1.875"
|
|
5641
|
+
}
|
|
5642
|
+
),
|
|
5643
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { y: "15", width: "35", height: "20", rx: "5", fill: "#EAB308" }),
|
|
5644
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5645
|
+
"path",
|
|
5646
|
+
{
|
|
5647
|
+
d: "M8.38769 29.18C8.01169 29.18 7.65369 29.13 7.31369 29.03C6.97769 28.934 6.66169 28.798 6.36569 28.622L6.80369 27.518C7.03969 27.654 7.27369 27.76 7.50569 27.836C7.74169 27.908 7.97969 27.944 8.21969 27.944C8.72369 27.944 9.10969 27.824 9.37769 27.584C9.64569 27.344 9.77969 26.954 9.77969 26.414V20.6H11.1237V26.636C11.1237 27.148 11.0177 27.596 10.8057 27.98C10.5937 28.36 10.2837 28.656 9.87569 28.868C9.46769 29.076 8.97169 29.18 8.38769 29.18ZM13.2951 29V20.6H16.3371C16.9331 20.6 17.4591 20.704 17.9151 20.912C18.3751 21.116 18.7351 21.412 18.9951 21.8C19.2551 22.184 19.3851 22.646 19.3851 23.186C19.3851 23.742 19.2651 24.212 19.0251 24.596C18.7851 24.976 18.4351 25.266 17.9751 25.466C17.5191 25.662 16.9631 25.76 16.3071 25.76H14.6391V29H13.2951ZM14.6391 24.608H16.3251C16.8691 24.608 17.2911 24.494 17.5911 24.266C17.8911 24.034 18.0411 23.684 18.0411 23.216C18.0411 22.752 17.8871 22.396 17.5791 22.148C17.2711 21.9 16.8571 21.776 16.3371 21.776H14.6391V24.608ZM25.0706 29.18C24.4026 29.18 23.7846 29.078 23.2166 28.874C22.6486 28.67 22.1506 28.378 21.7226 27.998C21.2986 27.614 20.9686 27.154 20.7326 26.618C20.4966 26.082 20.3786 25.48 20.3786 24.812C20.3786 24.148 20.4926 23.548 20.7206 23.012C20.9486 22.472 21.2666 22.01 21.6746 21.626C22.0866 21.238 22.5686 20.94 23.1206 20.732C23.6766 20.524 24.2826 20.42 24.9386 20.42C25.2426 20.42 25.5506 20.444 25.8626 20.492C26.1746 20.54 26.4806 20.62 26.7806 20.732C27.0846 20.84 27.3726 20.988 27.6446 21.176L27.0566 22.232C26.7526 22.04 26.4226 21.896 26.0666 21.8C25.7146 21.704 25.3506 21.656 24.9746 21.656C24.4866 21.656 24.0446 21.73 23.6486 21.878C23.2526 22.022 22.9146 22.232 22.6346 22.508C22.3546 22.78 22.1386 23.11 21.9866 23.498C21.8386 23.886 21.7646 24.322 21.7646 24.806C21.7646 25.486 21.9086 26.064 22.1966 26.54C22.4846 27.016 22.8806 27.378 23.3846 27.626C23.8926 27.87 24.4766 27.992 25.1366 27.992C25.4606 27.992 25.7526 27.962 26.0126 27.902C26.2726 27.838 26.4826 27.766 26.6426 27.686V25.658H24.7346V24.542H27.8486V28.466C27.6286 28.614 27.3526 28.742 27.0206 28.85C26.6926 28.958 26.3526 29.04 26.0006 29.096C25.6526 29.152 25.3426 29.18 25.0706 29.18Z",
|
|
5648
|
+
fill: "white"
|
|
5649
|
+
}
|
|
5650
|
+
)
|
|
5651
|
+
] });
|
|
5652
|
+
var FileMp4Icon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", ...props, children: [
|
|
5653
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M28.75 1.25V9.58333C28.75 10.5042 29.4958 11.25 30.4167 11.25H38.75", stroke: "#CACFD8", strokeWidth: "1.875" }),
|
|
5654
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5655
|
+
"path",
|
|
5656
|
+
{
|
|
5657
|
+
d: "M15 0.9375H26.8936C28.634 0.937541 30.3035 1.6287 31.5342 2.85938L37.1406 8.46582C38.3713 9.69649 39.0625 11.366 39.0625 13.1064V32.5C39.0625 36.1244 36.1244 39.0625 32.5 39.0625H15C11.3756 39.0625 8.4375 36.1244 8.4375 32.5V7.5C8.4375 3.87563 11.3756 0.9375 15 0.9375Z",
|
|
5658
|
+
stroke: "#CACFD8",
|
|
5659
|
+
strokeWidth: "1.875"
|
|
5660
|
+
}
|
|
5661
|
+
),
|
|
5662
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { y: "15", width: "35", height: "20", rx: "5", fill: "#3B82F6" }),
|
|
5663
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5664
|
+
"path",
|
|
5665
|
+
{
|
|
5666
|
+
d: "M5.70138 29V20.6H7.00338L10.4294 26.174L9.90738 26.18L13.2074 20.6H14.4854V29H13.1714L13.1894 22.388L13.4474 22.478L10.5914 27.188H9.60738L6.69738 22.478L6.91338 22.388L6.93138 29H5.70138ZM16.6701 29V20.6H19.7121C20.3081 20.6 20.8341 20.704 21.2901 20.912C21.7501 21.116 22.1101 21.412 22.3701 21.8C22.6301 22.184 22.7601 22.646 22.7601 23.186C22.7601 23.742 22.6401 24.212 22.4001 24.596C22.1601 24.976 21.8101 25.266 21.3501 25.466C20.8941 25.662 20.3381 25.76 19.6821 25.76H18.0141V29H16.6701ZM18.0141 24.608H19.7001C20.2441 24.608 20.6661 24.494 20.9661 24.266C21.2661 24.034 21.4161 23.684 21.4161 23.216C21.4161 22.752 21.2621 22.396 20.9541 22.148C20.6461 21.9 20.2321 21.776 19.7121 21.776H18.0141V24.608ZM27.5756 29V27.278H23.3936V26.264L26.4056 20.6H27.7736L24.8036 26.156H27.5756V24.29H28.7336V26.156H30.0296V27.278H28.7336V29H27.5756Z",
|
|
5667
|
+
fill: "white"
|
|
5668
|
+
}
|
|
5669
|
+
)
|
|
5670
|
+
] });
|
|
5671
|
+
var FilePdfIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", ...props, children: [
|
|
5672
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M28.75 1.25V9.58333C28.75 10.5042 29.4958 11.25 30.4167 11.25H38.75", stroke: "#CACFD8", strokeWidth: "1.875" }),
|
|
5673
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5674
|
+
"path",
|
|
5675
|
+
{
|
|
5676
|
+
d: "M15 0.9375H26.8936C28.634 0.937541 30.3035 1.6287 31.5342 2.85938L37.1406 8.46582C38.3713 9.69649 39.0625 11.366 39.0625 13.1064V32.5C39.0625 36.1244 36.1244 39.0625 32.5 39.0625H15C11.3756 39.0625 8.4375 36.1244 8.4375 32.5V7.5C8.4375 3.87563 11.3756 0.9375 15 0.9375Z",
|
|
5677
|
+
stroke: "#CACFD8",
|
|
5678
|
+
strokeWidth: "1.875"
|
|
5679
|
+
}
|
|
5680
|
+
),
|
|
5681
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { y: "15", width: "35", height: "20", rx: "5", fill: "#C90019" }),
|
|
5682
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5683
|
+
"path",
|
|
5684
|
+
{
|
|
5685
|
+
d: "M7.03145 29V20.6H10.0735C10.6695 20.6 11.1955 20.704 11.6515 20.912C12.1115 21.116 12.4715 21.412 12.7315 21.8C12.9915 22.184 13.1215 22.646 13.1215 23.186C13.1215 23.742 13.0015 24.212 12.7615 24.596C12.5215 24.976 12.1715 25.266 11.7115 25.466C11.2555 25.662 10.6995 25.76 10.0435 25.76H8.37545V29H7.03145ZM8.37545 24.608H10.0615C10.6055 24.608 11.0275 24.494 11.3275 24.266C11.6275 24.034 11.7775 23.684 11.7775 23.216C11.7775 22.752 11.6235 22.396 11.3155 22.148C11.0075 21.9 10.5935 21.776 10.0735 21.776H8.37545V24.608ZM14.6369 29V20.6H17.2649C18.1009 20.6 18.8389 20.78 19.4789 21.14C20.1189 21.496 20.6189 21.99 20.9789 22.622C21.3429 23.254 21.5249 23.982 21.5249 24.806C21.5249 25.418 21.4209 25.982 21.2129 26.498C21.0089 27.01 20.7169 27.452 20.3369 27.824C19.9569 28.196 19.5069 28.486 18.9869 28.694C18.4669 28.898 17.8929 29 17.2649 29H14.6369ZM15.9809 27.746H17.1029C17.5549 27.746 17.9649 27.68 18.3329 27.548C18.7049 27.412 19.0229 27.216 19.2869 26.96C19.5549 26.704 19.7609 26.396 19.9049 26.036C20.0489 25.672 20.1209 25.262 20.1209 24.806C20.1209 24.194 19.9949 23.668 19.7429 23.228C19.4949 22.784 19.1449 22.444 18.6929 22.208C18.2409 21.968 17.7109 21.848 17.1029 21.848H15.9809V27.746ZM23.1916 29V20.6H28.3816V21.83H24.5356V24.248H28.0216V25.448H24.5356V29H23.1916Z",
|
|
5686
|
+
fill: "white"
|
|
5687
|
+
}
|
|
5688
|
+
)
|
|
5689
|
+
] });
|
|
5690
|
+
var FilePngIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", ...props, children: [
|
|
5691
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M28.75 1.25V9.58333C28.75 10.5042 29.4958 11.25 30.4167 11.25H38.75", stroke: "#CACFD8", strokeWidth: "1.875" }),
|
|
5692
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5693
|
+
"path",
|
|
5694
|
+
{
|
|
5695
|
+
d: "M15 0.9375H26.8936C28.634 0.937541 30.3035 1.6287 31.5342 2.85938L37.1406 8.46582C38.3713 9.69649 39.0625 11.366 39.0625 13.1064V32.5C39.0625 36.1244 36.1244 39.0625 32.5 39.0625H15C11.3756 39.0625 8.4375 36.1244 8.4375 32.5V7.5C8.4375 3.87563 11.3756 0.9375 15 0.9375Z",
|
|
5696
|
+
stroke: "#CACFD8",
|
|
5697
|
+
strokeWidth: "1.875"
|
|
5698
|
+
}
|
|
5699
|
+
),
|
|
5700
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { y: "15", width: "35", height: "20", rx: "5", fill: "#A47D06" }),
|
|
5701
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5702
|
+
"path",
|
|
5703
|
+
{
|
|
5704
|
+
d: "M5.77169 29V20.6H8.81369C9.40969 20.6 9.93569 20.704 10.3917 20.912C10.8517 21.116 11.2117 21.412 11.4717 21.8C11.7317 22.184 11.8617 22.646 11.8617 23.186C11.8617 23.742 11.7417 24.212 11.5017 24.596C11.2617 24.976 10.9117 25.266 10.4517 25.466C9.99569 25.662 9.43969 25.76 8.78369 25.76H7.11569V29H5.77169ZM7.11569 24.608H8.80169C9.34569 24.608 9.76769 24.494 10.0677 24.266C10.3677 24.034 10.5177 23.684 10.5177 23.216C10.5177 22.752 10.3637 22.396 10.0557 22.148C9.74769 21.9 9.33369 21.776 8.81369 21.776H7.11569V24.608ZM13.3772 29V20.6H14.6612L18.9032 26.702V20.6H20.2112V29H18.9272L14.6912 22.826V29H13.3772ZM26.5706 29.18C25.9026 29.18 25.2846 29.078 24.7166 28.874C24.1486 28.67 23.6506 28.378 23.2226 27.998C22.7986 27.614 22.4686 27.154 22.2326 26.618C21.9966 26.082 21.8786 25.48 21.8786 24.812C21.8786 24.148 21.9926 23.548 22.2206 23.012C22.4486 22.472 22.7666 22.01 23.1746 21.626C23.5866 21.238 24.0686 20.94 24.6206 20.732C25.1766 20.524 25.7826 20.42 26.4386 20.42C26.7426 20.42 27.0506 20.444 27.3626 20.492C27.6746 20.54 27.9806 20.62 28.2806 20.732C28.5846 20.84 28.8726 20.988 29.1446 21.176L28.5566 22.232C28.2526 22.04 27.9226 21.896 27.5666 21.8C27.2146 21.704 26.8506 21.656 26.4746 21.656C25.9866 21.656 25.5446 21.73 25.1486 21.878C24.7526 22.022 24.4146 22.232 24.1346 22.508C23.8546 22.78 23.6386 23.11 23.4866 23.498C23.3386 23.886 23.2646 24.322 23.2646 24.806C23.2646 25.486 23.4086 26.064 23.6966 26.54C23.9846 27.016 24.3806 27.378 24.8846 27.626C25.3926 27.87 25.9766 27.992 26.6366 27.992C26.9606 27.992 27.2526 27.962 27.5126 27.902C27.7726 27.838 27.9826 27.766 28.1426 27.686V25.658H26.2346V24.542H29.3486V28.466C29.1286 28.614 28.8526 28.742 28.5206 28.85C28.1926 28.958 27.8526 29.04 27.5006 29.096C27.1526 29.152 26.8426 29.18 26.5706 29.18Z",
|
|
5705
|
+
fill: "white"
|
|
5706
|
+
}
|
|
5707
|
+
)
|
|
5708
|
+
] });
|
|
5709
|
+
var FilePowerpointIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", ...props, children: [
|
|
5710
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M28.75 1.25V9.58333C28.75 10.5042 29.4958 11.25 30.4167 11.25H38.75", stroke: "#CACFD8", strokeWidth: "1.875" }),
|
|
5711
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5712
|
+
"path",
|
|
5713
|
+
{
|
|
5714
|
+
d: "M15 0.9375H26.8936C28.634 0.937541 30.3035 1.6287 31.5342 2.85938L37.1406 8.46582C38.3713 9.69649 39.0625 11.366 39.0625 13.1064V32.5C39.0625 36.1244 36.1244 39.0625 32.5 39.0625H15C11.3756 39.0625 8.4375 36.1244 8.4375 32.5V7.5C8.4375 3.87563 11.3756 0.9375 15 0.9375Z",
|
|
5715
|
+
stroke: "#CACFD8",
|
|
5716
|
+
strokeWidth: "1.875"
|
|
5717
|
+
}
|
|
5718
|
+
),
|
|
5719
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { y: "15", width: "35", height: "20", rx: "5", fill: "#FF6259" }),
|
|
5720
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5721
|
+
"path",
|
|
5722
|
+
{
|
|
5723
|
+
d: "M3.60958 29V20.6H6.65158C7.24758 20.6 7.77358 20.704 8.22958 20.912C8.68958 21.116 9.04958 21.412 9.30958 21.8C9.56958 22.184 9.69958 22.646 9.69958 23.186C9.69958 23.742 9.57958 24.212 9.33958 24.596C9.09958 24.976 8.74958 25.266 8.28958 25.466C7.83358 25.662 7.27758 25.76 6.62158 25.76H4.95358V29H3.60958ZM4.95358 24.608H6.63958C7.18358 24.608 7.60558 24.494 7.90558 24.266C8.20558 24.034 8.35558 23.684 8.35558 23.216C8.35558 22.752 8.20158 22.396 7.89358 22.148C7.58558 21.9 7.17158 21.776 6.65158 21.776H4.95358V24.608ZM11.215 29V20.6H14.257C14.853 20.6 15.379 20.704 15.835 20.912C16.295 21.116 16.655 21.412 16.915 21.8C17.175 22.184 17.305 22.646 17.305 23.186C17.305 23.742 17.185 24.212 16.945 24.596C16.705 24.976 16.355 25.266 15.895 25.466C15.439 25.662 14.883 25.76 14.227 25.76H12.559V29H11.215ZM12.559 24.608H14.245C14.789 24.608 15.211 24.494 15.511 24.266C15.811 24.034 15.961 23.684 15.961 23.216C15.961 22.752 15.807 22.396 15.499 22.148C15.191 21.9 14.777 21.776 14.257 21.776H12.559V24.608ZM20.4165 29V21.83H18.0525V20.6H24.1245V21.83H21.7605V29H20.4165ZM24.7614 29L27.4854 24.692L24.9054 20.6H26.5134L28.4514 23.702L30.5214 20.6H32.0814L29.3694 24.728L32.1594 29H30.5454L28.3974 25.694L26.3274 29H24.7614Z",
|
|
5724
|
+
fill: "white"
|
|
5725
|
+
}
|
|
5726
|
+
)
|
|
5727
|
+
] });
|
|
5728
|
+
var FileTextIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", ...props, children: [
|
|
5729
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M28.75 1.25V9.58333C28.75 10.5042 29.4958 11.25 30.4167 11.25H38.75", stroke: "#CACFD8", strokeWidth: "1.875" }),
|
|
5730
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5731
|
+
"path",
|
|
5732
|
+
{
|
|
5733
|
+
d: "M15 0.9375H26.8936C28.634 0.937541 30.3035 1.6287 31.5342 2.85938L37.1406 8.46582C38.3713 9.69649 39.0625 11.366 39.0625 13.1064V32.5C39.0625 36.1244 36.1244 39.0625 32.5 39.0625H15C11.3756 39.0625 8.4375 36.1244 8.4375 32.5V7.5C8.4375 3.87563 11.3756 0.9375 15 0.9375Z",
|
|
5734
|
+
stroke: "#CACFD8",
|
|
5735
|
+
strokeWidth: "1.875"
|
|
5736
|
+
}
|
|
5737
|
+
),
|
|
5738
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { y: "15", width: "35", height: "20", rx: "5", fill: "#3B82F6" }),
|
|
5739
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5740
|
+
"path",
|
|
5741
|
+
{
|
|
5742
|
+
d: "M9.45363 29V21.83H7.08963V20.6H13.1616V21.83H10.7976V29H9.45363ZM13.7985 29L16.5225 24.692L13.9425 20.6H15.5505L17.4885 23.702L19.5585 20.6H21.1185L18.4065 24.728L21.1965 29H19.5825L17.4345 25.694L15.3645 29H13.7985ZM24.2075 29V21.83H21.8435V20.6H27.9155V21.83H25.5515V29H24.2075Z",
|
|
5743
|
+
fill: "white"
|
|
5744
|
+
}
|
|
5745
|
+
)
|
|
5746
|
+
] });
|
|
5747
|
+
var FileWordIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", ...props, children: [
|
|
5748
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M28.75 1.25V9.58333C28.75 10.5042 29.4958 11.25 30.4167 11.25H38.75", stroke: "#CACFD8", strokeWidth: "1.875" }),
|
|
5749
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5750
|
+
"path",
|
|
5751
|
+
{
|
|
5752
|
+
d: "M15 0.9375H26.8936C28.634 0.937541 30.3035 1.6287 31.5342 2.85938L37.1406 8.46582C38.3713 9.69649 39.0625 11.366 39.0625 13.1064V32.5C39.0625 36.1244 36.1244 39.0625 32.5 39.0625H15C11.3756 39.0625 8.4375 36.1244 8.4375 32.5V7.5C8.4375 3.87563 11.3756 0.9375 15 0.9375Z",
|
|
5753
|
+
stroke: "#CACFD8",
|
|
5754
|
+
strokeWidth: "1.875"
|
|
5755
|
+
}
|
|
5756
|
+
),
|
|
5757
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { y: "15", width: "35", height: "20", rx: "5", fill: "#295BAC" }),
|
|
5758
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5759
|
+
"path",
|
|
5760
|
+
{
|
|
5761
|
+
d: "M5.02755 29V20.6H7.65555C8.49155 20.6 9.22955 20.78 9.86955 21.14C10.5095 21.496 11.0095 21.99 11.3695 22.622C11.7335 23.254 11.9155 23.982 11.9155 24.806C11.9155 25.418 11.8115 25.982 11.6035 26.498C11.3995 27.01 11.1075 27.452 10.7275 27.824C10.3475 28.196 9.89755 28.486 9.37755 28.694C8.85755 28.898 8.28355 29 7.65555 29H5.02755ZM6.37155 27.746H7.49355C7.94555 27.746 8.35555 27.68 8.72355 27.548C9.09555 27.412 9.41355 27.216 9.67755 26.96C9.94555 26.704 10.1515 26.396 10.2955 26.036C10.4395 25.672 10.5115 25.262 10.5115 24.806C10.5115 24.194 10.3855 23.668 10.1335 23.228C9.88555 22.784 9.53555 22.444 9.08355 22.208C8.63155 21.968 8.10155 21.848 7.49355 21.848H6.37155V27.746ZM17.5994 29.18C16.9674 29.18 16.3814 29.07 15.8414 28.85C15.3054 28.626 14.8374 28.316 14.4374 27.92C14.0414 27.524 13.7314 27.06 13.5074 26.528C13.2874 25.996 13.1774 25.42 13.1774 24.8C13.1774 24.176 13.2874 23.598 13.5074 23.066C13.7314 22.534 14.0414 22.07 14.4374 21.674C14.8374 21.278 15.3054 20.97 15.8414 20.75C16.3814 20.53 16.9674 20.42 17.5994 20.42C18.2274 20.42 18.8094 20.532 19.3454 20.756C19.8814 20.98 20.3494 21.292 20.7494 21.692C21.1494 22.092 21.4594 22.558 21.6794 23.09C21.9034 23.618 22.0154 24.188 22.0154 24.8C22.0154 25.42 21.9034 25.996 21.6794 26.528C21.4594 27.06 21.1494 27.524 20.7494 27.92C20.3494 28.316 19.8814 28.626 19.3454 28.85C18.8094 29.07 18.2274 29.18 17.5994 29.18ZM17.5994 27.908C18.0234 27.908 18.4174 27.836 18.7814 27.692C19.1494 27.544 19.4694 27.334 19.7414 27.062C20.0134 26.786 20.2254 26.458 20.3774 26.078C20.5334 25.694 20.6114 25.268 20.6114 24.8C20.6114 24.172 20.4774 23.626 20.2094 23.162C19.9454 22.694 19.5854 22.332 19.1294 22.076C18.6734 21.82 18.1634 21.692 17.5994 21.692C17.1754 21.692 16.7794 21.766 16.4114 21.914C16.0474 22.058 15.7274 22.266 15.4514 22.538C15.1794 22.81 14.9654 23.138 14.8094 23.522C14.6574 23.902 14.5814 24.328 14.5814 24.8C14.5814 25.428 14.7154 25.976 14.9834 26.444C15.2514 26.908 15.6114 27.268 16.0634 27.524C16.5194 27.78 17.0314 27.908 17.5994 27.908ZM27.6173 29.18C26.7453 29.18 25.9833 29 25.3313 28.64C24.6793 28.28 24.1713 27.772 23.8073 27.116C23.4473 26.456 23.2673 25.686 23.2673 24.806C23.2673 24.166 23.3733 23.58 23.5853 23.048C23.8013 22.512 24.1033 22.048 24.4913 21.656C24.8833 21.264 25.3453 20.96 25.8773 20.744C26.4093 20.528 26.9933 20.42 27.6293 20.42C28.2693 20.42 28.8213 20.5 29.2853 20.66C29.7533 20.82 30.1613 21.048 30.5093 21.344L29.8133 22.442C29.5493 22.198 29.2413 22.016 28.8893 21.896C28.5373 21.776 28.1493 21.716 27.7253 21.716C27.2573 21.716 26.8353 21.788 26.4593 21.932C26.0833 22.076 25.7613 22.282 25.4933 22.55C25.2293 22.814 25.0253 23.136 24.8813 23.516C24.7413 23.892 24.6713 24.318 24.6713 24.794C24.6713 25.442 24.7973 25.996 25.0493 26.456C25.3053 26.916 25.6653 27.268 26.1293 27.512C26.5973 27.752 27.1493 27.872 27.7853 27.872C28.2093 27.872 28.6173 27.81 29.0093 27.686C29.4053 27.558 29.7753 27.352 30.1193 27.068L30.7433 28.202C30.3393 28.518 29.8773 28.76 29.3573 28.928C28.8413 29.096 28.2613 29.18 27.6173 29.18Z",
|
|
5762
|
+
fill: "white"
|
|
5763
|
+
}
|
|
5764
|
+
)
|
|
5765
|
+
] });
|
|
5766
|
+
var FileZipIcon = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", focusable: "false", ...props, children: [
|
|
5767
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M28.75 1.25V9.58333C28.75 10.5042 29.4958 11.25 30.4167 11.25H38.75", stroke: "#CACFD8", strokeWidth: "1.875" }),
|
|
5768
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5769
|
+
"path",
|
|
5770
|
+
{
|
|
5771
|
+
d: "M15 0.9375H26.8936C28.634 0.937541 30.3035 1.6287 31.5342 2.85938L37.1406 8.46582C38.3713 9.69649 39.0625 11.366 39.0625 13.1064V32.5C39.0625 36.1244 36.1244 39.0625 32.5 39.0625H15C11.3756 39.0625 8.4375 36.1244 8.4375 32.5V7.5C8.4375 3.87563 11.3756 0.9375 15 0.9375Z",
|
|
5772
|
+
stroke: "#CACFD8",
|
|
5773
|
+
strokeWidth: "1.875"
|
|
5774
|
+
}
|
|
5775
|
+
),
|
|
5776
|
+
/* @__PURE__ */ jsxRuntime.jsx("rect", { y: "15", width: "35", height: "20", rx: "5", fill: "#79889A" }),
|
|
5777
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5778
|
+
"path",
|
|
5779
|
+
{
|
|
5780
|
+
d: "M8.97569 29V27.878L13.2777 21.83H9.11369V20.6H14.8977V21.716L10.6137 27.764H14.9337V29H8.97569ZM16.5178 29V20.6H17.8618V29H16.5178ZM20.0568 29V20.6H23.0988C23.6948 20.6 24.2208 20.704 24.6768 20.912C25.1368 21.116 25.4968 21.412 25.7568 21.8C26.0168 22.184 26.1468 22.646 26.1468 23.186C26.1468 23.742 26.0268 24.212 25.7868 24.596C25.5468 24.976 25.1968 25.266 24.7368 25.466C24.2808 25.662 23.7248 25.76 23.0688 25.76H21.4008V29H20.0568ZM21.4008 24.608H23.0868C23.6308 24.608 24.0528 24.494 24.3528 24.266C24.6528 24.034 24.8028 23.684 24.8028 23.216C24.8028 22.752 24.6488 22.396 24.3408 22.148C24.0328 21.9 23.6188 21.776 23.0988 21.776H21.4008V24.608Z",
|
|
5781
|
+
fill: "white"
|
|
5782
|
+
}
|
|
5783
|
+
)
|
|
5784
|
+
] });
|
|
5785
|
+
var FILE_ICONS = {
|
|
5786
|
+
excel: FileExcelIcon,
|
|
5787
|
+
jpg: FileJpgIcon,
|
|
5788
|
+
mp4: FileMp4Icon,
|
|
5789
|
+
pdf: FilePdfIcon,
|
|
5790
|
+
png: FilePngIcon,
|
|
5791
|
+
powerpoint: FilePowerpointIcon,
|
|
5792
|
+
text: FileTextIcon,
|
|
5793
|
+
word: FileWordIcon,
|
|
5794
|
+
zip: FileZipIcon
|
|
5795
|
+
};
|
|
5796
|
+
var NO_BROKEN_SRCS = [];
|
|
5797
|
+
var useImageObjectUrl = (file, type) => {
|
|
5798
|
+
const [objectUrl, setObjectUrl] = react.useState(null);
|
|
5799
|
+
react.useEffect(() => {
|
|
5800
|
+
const canCreate = typeof URL !== "undefined" && typeof URL.createObjectURL === "function";
|
|
5801
|
+
if (file && isImageType(type) && canCreate) {
|
|
5802
|
+
const url = URL.createObjectURL(file);
|
|
5803
|
+
setObjectUrl(url);
|
|
5804
|
+
return () => URL.revokeObjectURL(url);
|
|
5805
|
+
}
|
|
5806
|
+
setObjectUrl(null);
|
|
5807
|
+
}, [file, type]);
|
|
5808
|
+
return objectUrl;
|
|
5809
|
+
};
|
|
5810
|
+
var UploadItemPreview = (props) => {
|
|
5811
|
+
const theme = useComponentTheme("UploadItemPreview");
|
|
5812
|
+
const { item } = useUploadItemContext("Upload.ItemPreview");
|
|
5813
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadItemPreviewBase, props, theme);
|
|
5814
|
+
const { as, children, ref, ...nativeProps } = rest;
|
|
5815
|
+
const hasChildren = isRenderableNode(children);
|
|
5816
|
+
const sourceKey = `${item.id}\0${item.thumbUrl ?? ""}\0${item.url ?? ""}\0${item.file ? fileKey(item.file) : ""}`;
|
|
5817
|
+
const [broken, setBroken] = react.useState({ key: sourceKey, srcs: NO_BROKEN_SRCS });
|
|
5818
|
+
const brokenSrcs = broken.key === sourceKey ? broken.srcs : NO_BROKEN_SRCS;
|
|
5819
|
+
const markBroken = (src2) => setBroken((previous) => {
|
|
5820
|
+
if (previous.key !== sourceKey) return { key: sourceKey, srcs: [src2] };
|
|
5821
|
+
if (previous.srcs.includes(src2)) return previous;
|
|
5822
|
+
return { key: sourceKey, srcs: [...previous.srcs, src2] };
|
|
5823
|
+
});
|
|
5824
|
+
const thumbUsable = item.thumbUrl !== void 0 && !brokenSrcs.includes(item.thumbUrl);
|
|
5825
|
+
const objectUrl = useImageObjectUrl(hasChildren || thumbUsable ? void 0 : item.file, fileType(item));
|
|
5826
|
+
const slotAttrs = (slot) => buildSlotAttrs(UploadItemPreviewBase.getSlotProps(slot), slot, {
|
|
5827
|
+
themeSlotProps: theme?.slotProps,
|
|
5828
|
+
themeClassNames: theme?.classNames,
|
|
5829
|
+
instanceSlotProps: props.slotProps,
|
|
5830
|
+
instanceClassNames: props.classNames
|
|
5831
|
+
});
|
|
5832
|
+
const Component = as ?? "span";
|
|
5833
|
+
const remoteImage = item.url && isImageType(fileType(item)) ? item.url : void 0;
|
|
5834
|
+
const src = [item.thumbUrl, objectUrl ?? void 0, remoteImage].find((candidate) => candidate !== void 0 && !brokenSrcs.includes(candidate));
|
|
5835
|
+
const iconName = fileIconName(item);
|
|
5836
|
+
const FileIcon = iconName ? FILE_ICONS[iconName] : void 0;
|
|
5837
|
+
const { onError: slotOnError, ...imageAttrs } = slotAttrs("image");
|
|
5838
|
+
const defaultContent = src ? (
|
|
5839
|
+
// The defaults sit ahead of the slot layer so `slotProps.image` can still
|
|
5840
|
+
// override them — a consumer wanting a real `alt`, or eager loading for an
|
|
5841
|
+
// above-the-fold row, should not have to fight the part for it.
|
|
5842
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5843
|
+
"img",
|
|
5844
|
+
{
|
|
5845
|
+
alt: "",
|
|
5846
|
+
loading: "lazy",
|
|
5847
|
+
decoding: "async",
|
|
5848
|
+
...imageAttrs,
|
|
5849
|
+
src,
|
|
5850
|
+
onError: (event) => {
|
|
5851
|
+
markBroken(src);
|
|
5852
|
+
slotOnError?.(event);
|
|
5853
|
+
}
|
|
5854
|
+
}
|
|
5855
|
+
)
|
|
5856
|
+
) : FileIcon ? /* @__PURE__ */ jsxRuntime.jsx(FileIcon, { ...slotAttrs("icon") }) : /* @__PURE__ */ jsxRuntime.jsx("span", { ...slotAttrs("extension"), "aria-hidden": "true", children: nameExtension(fileName(item)) || "FILE" });
|
|
5857
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...nativeProps, ...rootAttrs, ref, children: hasChildren ? children : defaultContent });
|
|
5858
|
+
};
|
|
5859
|
+
UploadItemPreview.displayName = "Upload.ItemPreview";
|
|
5860
|
+
var flattenRowChildren = (children, out = []) => {
|
|
5861
|
+
react.Children.forEach(children, (child) => {
|
|
5862
|
+
if (react.isValidElement(child) && child.type === react.Fragment) flattenRowChildren(child.props.children, out);
|
|
5863
|
+
else out.push(child);
|
|
5864
|
+
});
|
|
5865
|
+
return out;
|
|
5866
|
+
};
|
|
5867
|
+
var UploadItem = (props) => {
|
|
5868
|
+
const theme = useComponentTheme("UploadItem");
|
|
5869
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadItemBase, props, theme);
|
|
5870
|
+
const { as, file: item, children, ref, ...nativeProps } = rest;
|
|
5871
|
+
const Component = as ?? "div";
|
|
5872
|
+
const previewNodes = [];
|
|
5873
|
+
const contentNodes = [];
|
|
5874
|
+
const actionsNodes = [];
|
|
5875
|
+
const looseNodes = [];
|
|
5876
|
+
for (const child of flattenRowChildren(children)) {
|
|
5877
|
+
const type = react.isValidElement(child) ? child.type : void 0;
|
|
5878
|
+
if (type === UploadItemPreview) previewNodes.push(child);
|
|
5879
|
+
else if (type === UploadItemContent) contentNodes.push(child);
|
|
5880
|
+
else if (type === UploadItemActions) actionsNodes.push(child);
|
|
5881
|
+
else looseNodes.push(child);
|
|
5882
|
+
}
|
|
5883
|
+
const hasComposedActions = actionsNodes.length > 0;
|
|
5884
|
+
const actionsRegion = hasComposedActions ? actionsNodes : /* @__PURE__ */ jsxRuntime.jsx(UploadItemActions, { children: looseNodes.length > 0 ? looseNodes : void 0 });
|
|
5885
|
+
return (
|
|
5886
|
+
// The row publishes its own file to its parts, so an `Upload.ItemAction`,
|
|
5887
|
+
// `Upload.ItemContent`, or `Upload.ItemPreview` needs no per-instance wiring
|
|
5888
|
+
// to know which entry it renders.
|
|
5889
|
+
/* @__PURE__ */ jsxRuntime.jsx(UploadItemProvider, { value: { item }, children: /* @__PURE__ */ jsxRuntime.jsxs(Component, { ...nativeProps, ...rootAttrs, "data-status": fileStatus(item), ref, children: [
|
|
5890
|
+
previewNodes.length > 0 ? previewNodes : /* @__PURE__ */ jsxRuntime.jsx(UploadItemPreview, {}),
|
|
5891
|
+
contentNodes.length > 0 ? contentNodes : /* @__PURE__ */ jsxRuntime.jsx(UploadItemContent, {}),
|
|
5892
|
+
hasComposedActions && looseNodes,
|
|
5893
|
+
actionsRegion
|
|
5894
|
+
] }) })
|
|
5895
|
+
);
|
|
5896
|
+
};
|
|
5897
|
+
UploadItem.displayName = "Upload.Item";
|
|
5898
|
+
var UploadList = (props) => {
|
|
5899
|
+
const theme = useComponentTheme("UploadList");
|
|
5900
|
+
const { files } = useUploadContext("Upload.List");
|
|
5901
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadListBase, props, theme);
|
|
5902
|
+
const { as, children, ref, ...nativeProps } = rest;
|
|
5903
|
+
if (files.length === 0) return null;
|
|
5904
|
+
const Component = as ?? "div";
|
|
5905
|
+
const rows = typeof children === "function" ? children(files) : isRenderableNode(children) ? children : files.map((item) => /* @__PURE__ */ jsxRuntime.jsx(UploadItem, { file: item }, item.id));
|
|
5906
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ...nativeProps, ...rootAttrs, ref, children: rows });
|
|
5907
|
+
};
|
|
5908
|
+
UploadList.displayName = "Upload.List";
|
|
5909
|
+
var DEFAULT_SUBMIT_APPEARANCE = "outlined";
|
|
5910
|
+
var DEFAULT_SUBMIT_VARIANT = "neutral";
|
|
5911
|
+
var UploadSubmit = (props) => {
|
|
5912
|
+
const theme = useComponentTheme("UploadSubmit");
|
|
5913
|
+
const { disabled, files } = useUploadContext("Upload.Submit");
|
|
5914
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadSubmitBase, props, theme);
|
|
5915
|
+
const { onClick: slotOnClick, ...submitRootAttrs } = rootAttrs;
|
|
5916
|
+
const {
|
|
5917
|
+
as,
|
|
5918
|
+
children,
|
|
5919
|
+
ref,
|
|
5920
|
+
disabled: ownDisabled,
|
|
5921
|
+
href,
|
|
5922
|
+
onClick,
|
|
5923
|
+
appearance = DEFAULT_SUBMIT_APPEARANCE,
|
|
5924
|
+
variant = DEFAULT_SUBMIT_VARIANT,
|
|
5925
|
+
...buttonProps
|
|
5926
|
+
} = rest;
|
|
5927
|
+
const handleClick = (event) => {
|
|
5928
|
+
onClick?.(event);
|
|
5929
|
+
slotOnClick?.(event);
|
|
5930
|
+
};
|
|
5931
|
+
const inFlight = files.some((entry) => {
|
|
5932
|
+
const status = fileStatus(entry);
|
|
5933
|
+
return status === "uploading" || status === "processing";
|
|
5934
|
+
});
|
|
5935
|
+
const isDisabled = disabled || ownDisabled || files.length === 0 || inFlight;
|
|
5936
|
+
const isButton = (as ?? "button") === "button";
|
|
5937
|
+
const linkProps = isButton ? void 0 : { href: isDisabled ? void 0 : href };
|
|
5938
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Button, { ...buttonProps, ...linkProps, ...submitRootAttrs, as, appearance, variant, disabled: isDisabled, onClick: handleClick, ref, children });
|
|
5939
|
+
};
|
|
5940
|
+
UploadSubmit.displayName = "Upload.Submit";
|
|
5941
|
+
var DEFAULT_TRIGGER_APPEARANCE = "outlined";
|
|
5942
|
+
var DEFAULT_TRIGGER_VARIANT = "neutral";
|
|
5943
|
+
var UploadTrigger = (props) => {
|
|
5944
|
+
const theme = useComponentTheme("UploadTrigger");
|
|
5945
|
+
const { disabled, readOnly, openFileDialog } = useUploadContext("Upload.Trigger");
|
|
5946
|
+
const { rootAttrs, rest } = composeRootAttrs(UploadTriggerBase, props, theme);
|
|
5947
|
+
const { onClick: slotOnClick, ...triggerRootAttrs } = rootAttrs;
|
|
5948
|
+
const {
|
|
5949
|
+
as,
|
|
5950
|
+
children,
|
|
5951
|
+
ref,
|
|
5952
|
+
disabled: ownDisabled,
|
|
5953
|
+
href,
|
|
5954
|
+
onClick,
|
|
5955
|
+
appearance = DEFAULT_TRIGGER_APPEARANCE,
|
|
5956
|
+
variant = DEFAULT_TRIGGER_VARIANT,
|
|
5957
|
+
...buttonProps
|
|
5958
|
+
} = rest;
|
|
5959
|
+
const isDisabled = disabled || readOnly || ownDisabled;
|
|
5960
|
+
const isButton = (as ?? "button") === "button";
|
|
5961
|
+
const linkProps = isButton ? void 0 : { href: isDisabled ? void 0 : href };
|
|
5962
|
+
const handleClick = (event) => {
|
|
5963
|
+
const preventedOnEntry = event.defaultPrevented;
|
|
5964
|
+
onClick?.(event);
|
|
5965
|
+
slotOnClick?.(event);
|
|
5966
|
+
if (isConsumerVeto(event, preventedOnEntry)) return;
|
|
5967
|
+
openFileDialog();
|
|
5968
|
+
};
|
|
5969
|
+
return (
|
|
5970
|
+
// Read-only freezes the Trigger rather than unmounting it, which is the
|
|
5971
|
+
// opposite of what the ItemAction's remove does under the same state. The
|
|
5972
|
+
// asymmetry is the point: a file row without its remove still reads as a
|
|
5973
|
+
// whole row, but the zone's browse button is most of what the zone shows —
|
|
5974
|
+
// drop it and a dashed box is left offering a drop that never lands.
|
|
5975
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { ...buttonProps, ...linkProps, ...triggerRootAttrs, as, appearance, variant, disabled: isDisabled, onClick: handleClick, ref, children })
|
|
5976
|
+
);
|
|
5977
|
+
};
|
|
5978
|
+
UploadTrigger.displayName = "Upload.Trigger";
|
|
5979
|
+
|
|
5980
|
+
// src/components/upload/index.ts
|
|
5981
|
+
var Upload2 = Object.assign(Upload, {
|
|
5982
|
+
Dropzone: UploadDropzone,
|
|
5983
|
+
Actions: UploadActions,
|
|
5984
|
+
Trigger: UploadTrigger,
|
|
5985
|
+
Submit: UploadSubmit,
|
|
5986
|
+
List: UploadList,
|
|
5987
|
+
Item: UploadItem,
|
|
5988
|
+
ItemPreview: UploadItemPreview,
|
|
5989
|
+
ItemContent: UploadItemContent,
|
|
5990
|
+
ItemActions: UploadItemActions,
|
|
5991
|
+
ItemAction: UploadItemAction
|
|
5992
|
+
});
|
|
5993
|
+
|
|
3637
5994
|
Object.defineProperty(exports, "createToaster", {
|
|
3638
5995
|
enumerable: true,
|
|
3639
5996
|
get: function () { return spar.createToaster; }
|
|
@@ -3647,14 +6004,20 @@ exports.Card = Card2;
|
|
|
3647
6004
|
exports.Checkbox = Checkbox2;
|
|
3648
6005
|
exports.Chip = Chip;
|
|
3649
6006
|
exports.Dialog = Dialog2;
|
|
6007
|
+
exports.Divider = Divider;
|
|
3650
6008
|
exports.Drawer = Drawer2;
|
|
6009
|
+
exports.Dropdown = Dropdown2;
|
|
3651
6010
|
exports.Field = Field2;
|
|
3652
6011
|
exports.Input = Input2;
|
|
3653
6012
|
exports.Label = Label;
|
|
3654
6013
|
exports.Popover = Popover2;
|
|
6014
|
+
exports.Progress = Progress2;
|
|
3655
6015
|
exports.Radio = Radio2;
|
|
3656
6016
|
exports.Select = Select2;
|
|
6017
|
+
exports.Skeleton = Skeleton;
|
|
6018
|
+
exports.Slider = Slider2;
|
|
3657
6019
|
exports.Spinner = Spinner;
|
|
6020
|
+
exports.Stepper = Stepper2;
|
|
3658
6021
|
exports.Switch = Switch2;
|
|
3659
6022
|
exports.Table = Table;
|
|
3660
6023
|
exports.Tabs = Tabs2;
|
|
@@ -3662,6 +6025,7 @@ exports.TakeoffSparProvider = TakeoffSparProvider;
|
|
|
3662
6025
|
exports.Toast = Toast;
|
|
3663
6026
|
exports.Toaster = Toaster;
|
|
3664
6027
|
exports.Tooltip = Tooltip2;
|
|
6028
|
+
exports.Upload = Upload2;
|
|
3665
6029
|
exports.getExportRows = getExportRows;
|
|
3666
6030
|
exports.useComponentTheme = useComponentTheme;
|
|
3667
6031
|
exports.useTheme = useTheme;
|