@burdenoff/fe-libs 2026.1119.1 → 2026.1119.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FocusEventHandler, Ref } from 'react';
|
|
2
|
+
import { ThemedSelectModel } from './themed-select-options';
|
|
3
|
+
export interface ThemedSelectMenuProps {
|
|
4
|
+
model: ThemedSelectModel;
|
|
5
|
+
contentRef: Ref<HTMLDivElement>;
|
|
6
|
+
/** The control's focus handlers: a pointer opens the menu without focusing the button. */
|
|
7
|
+
onFocus: FocusEventHandler<HTMLElement>;
|
|
8
|
+
onBlur: FocusEventHandler<HTMLElement>;
|
|
9
|
+
}
|
|
10
|
+
export declare function ThemedSelectMenu({ model, contentRef, onFocus, onBlur }: ThemedSelectMenuProps): import('react').JSX.Element;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Fragment as e } from "react";
|
|
2
|
+
import { Check as t } from "lucide-react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
import * as i from "@radix-ui/react-select";
|
|
5
|
+
// src/ui/themed-select-menu.tsx
|
|
6
|
+
var a = "relative z-50 max-h-[min(22.5rem,var(--radix-select-content-available-height))] min-w-[var(--radix-select-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-card border border-border-subtle bg-bg-elevated text-text-primary shadow-elevation-3 motion-safe:data-[state=open]:animate-in motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2", o = "scrollbar-slim scrollbar-box overscroll-contain p-1", s = "relative flex min-h-11 w-full cursor-default select-none items-center rounded-lg py-1.5 ps-8 pe-2 text-sm text-text-primary outline-none motion-safe:transition-colors focus:bg-[var(--color-accent-soft)] focus:text-text-primary data-[state=checked]:bg-action-primary-bg/10 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 sm:min-h-0", c = "-mx-1 my-1 h-px bg-border-subtle", l = "px-3 pb-1 pt-2 text-[11px] font-semibold uppercase tracking-wider text-text-muted";
|
|
7
|
+
function u(e) {
|
|
8
|
+
e.stopPropagation();
|
|
9
|
+
}
|
|
10
|
+
function d(e) {
|
|
11
|
+
e.stopPropagation();
|
|
12
|
+
}
|
|
13
|
+
function f(e) {
|
|
14
|
+
return /* @__PURE__ */ r(i.Item, {
|
|
15
|
+
value: String(e.index),
|
|
16
|
+
disabled: e.disabled,
|
|
17
|
+
textValue: e.label,
|
|
18
|
+
className: s,
|
|
19
|
+
"data-slot": "themed-select-item",
|
|
20
|
+
children: [/* @__PURE__ */ n("span", {
|
|
21
|
+
className: "absolute start-2 flex size-4 items-center justify-center",
|
|
22
|
+
children: /* @__PURE__ */ n(i.ItemIndicator, { children: /* @__PURE__ */ n(t, {
|
|
23
|
+
className: "size-4 text-action-primary-bg",
|
|
24
|
+
"aria-hidden": "true"
|
|
25
|
+
}) })
|
|
26
|
+
}), /* @__PURE__ */ n(i.ItemText, { children: e.label })]
|
|
27
|
+
}, e.index);
|
|
28
|
+
}
|
|
29
|
+
function p(e) {
|
|
30
|
+
return e.entries.flatMap((e) => {
|
|
31
|
+
if (e.kind === "option") return e.option.hidden ? [] : [e];
|
|
32
|
+
let t = e.options.filter((e) => !e.hidden);
|
|
33
|
+
return t.length > 0 ? [{
|
|
34
|
+
...e,
|
|
35
|
+
options: t
|
|
36
|
+
}] : [];
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function m({ model: t, contentRef: s, onFocus: m, onBlur: h }) {
|
|
40
|
+
let g = p(t);
|
|
41
|
+
return /* @__PURE__ */ n(i.Portal, { children: /* @__PURE__ */ n(i.Content, {
|
|
42
|
+
ref: s,
|
|
43
|
+
position: "popper",
|
|
44
|
+
side: "bottom",
|
|
45
|
+
align: "start",
|
|
46
|
+
sideOffset: 6,
|
|
47
|
+
collisionPadding: 8,
|
|
48
|
+
className: a,
|
|
49
|
+
"data-slot": "themed-select-content",
|
|
50
|
+
onFocus: m,
|
|
51
|
+
onBlur: h,
|
|
52
|
+
onKeyDown: u,
|
|
53
|
+
onEscapeKeyDown: d,
|
|
54
|
+
children: /* @__PURE__ */ n(i.Viewport, {
|
|
55
|
+
className: o,
|
|
56
|
+
children: g.map((t, a) => {
|
|
57
|
+
let o = a > 0 && (t.kind === "group" || g[a - 1]?.kind === "group") ? /* @__PURE__ */ n(i.Separator, { className: c }) : null;
|
|
58
|
+
return t.kind === "option" ? o ? /* @__PURE__ */ r(e, { children: [o, f(t.option)] }, t.option.index) : f(t.option) : /* @__PURE__ */ r(i.Group, { children: [
|
|
59
|
+
o,
|
|
60
|
+
t.label ? /* @__PURE__ */ n(i.Label, {
|
|
61
|
+
className: l,
|
|
62
|
+
children: t.label
|
|
63
|
+
}) : null,
|
|
64
|
+
t.options.map(f)
|
|
65
|
+
] }, `group-${t.options[0]?.index ?? a}`);
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}) });
|
|
69
|
+
}
|
|
70
|
+
export { m as ThemedSelectMenu };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { FocusEvent as ReactFocusEvent, FocusEventHandler, ReactNode, RefObject, SelectHTMLAttributes } from 'react';
|
|
2
|
+
import { ThemedSelectModel, ThemedSelectOption } from './themed-select-options';
|
|
3
|
+
type SelectAttributes = SelectHTMLAttributes<HTMLSelectElement>;
|
|
4
|
+
export interface ThemedSelectChoiceInput {
|
|
5
|
+
model: ThemedSelectModel;
|
|
6
|
+
value: SelectAttributes['value'];
|
|
7
|
+
defaultValue: SelectAttributes['defaultValue'];
|
|
8
|
+
/** The options as the page rendered them: a new value whenever they may have changed. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** The `form` attribute: the form the select resets with can change with it. */
|
|
11
|
+
form: SelectAttributes['form'];
|
|
12
|
+
selectRef: RefObject<HTMLSelectElement | null>;
|
|
13
|
+
}
|
|
14
|
+
export interface ThemedSelectChoice {
|
|
15
|
+
controlled: boolean;
|
|
16
|
+
/** The option the button shows, which is the one the native select holds. */
|
|
17
|
+
selected: ThemedSelectOption | undefined;
|
|
18
|
+
/** A pick in the menu, by its Radix value (the option's index). */
|
|
19
|
+
choose: (key: string) => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Which option is chosen. A controlled select shows the option its `value` names, by
|
|
23
|
+
* React's rule for a select. An uncontrolled one shows the option its native select
|
|
24
|
+
* holds, read back whenever that can change: a pick, a form reset, new options.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useThemedSelectChoice({ model, value, defaultValue, children, form, selectRef, }: ThemedSelectChoiceInput): ThemedSelectChoice;
|
|
27
|
+
export interface ControlFocusInput {
|
|
28
|
+
selectRef: RefObject<HTMLSelectElement | null>;
|
|
29
|
+
triggerRef: RefObject<HTMLButtonElement | null>;
|
|
30
|
+
contentRef: RefObject<HTMLDivElement | null>;
|
|
31
|
+
/** The page's own handlers, which the native select fires as the control's. */
|
|
32
|
+
onFocus: FocusEventHandler<HTMLSelectElement> | undefined;
|
|
33
|
+
onBlur: FocusEventHandler<HTMLSelectElement> | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The control's focus, as a native select's: the button and its open menu are one
|
|
37
|
+
* control, which gains focus once and loses it once, on the native select.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useControlFocus({ selectRef, triggerRef, contentRef, onFocus, onBlur, }: ControlFocusInput): {
|
|
40
|
+
handleFocusIn: (event: ReactFocusEvent<HTMLElement>) => void;
|
|
41
|
+
handleFocusOut: (event: ReactFocusEvent<HTMLElement>) => void;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { selectValueString as e, selectedOptionIndex as t } from "./themed-select-options.js";
|
|
2
|
+
import { useEffect as n, useEffectEvent as r, useLayoutEffect as i, useRef as a, useState as o } from "react";
|
|
3
|
+
// src/ui/themed-select-state.ts
|
|
4
|
+
function s({ model: s, value: c, defaultValue: l, children: u, form: d, selectRef: f }) {
|
|
5
|
+
let p = a(!1), m = c !== void 0, [h, g] = o(() => {
|
|
6
|
+
let n = t(s.options, e(l));
|
|
7
|
+
return {
|
|
8
|
+
value: s.options[n]?.value,
|
|
9
|
+
index: n
|
|
10
|
+
};
|
|
11
|
+
}), _ = m ? t(s.options, e(c)) : h.value !== void 0 && s.options[h.index]?.value === h.value ? h.index : t(s.options, h.value);
|
|
12
|
+
i(() => {
|
|
13
|
+
let e = f.current;
|
|
14
|
+
if (m || !e) return;
|
|
15
|
+
let { selectedIndex: t, value: n } = e;
|
|
16
|
+
g((e) => e.index === t && e.value === n ? e : {
|
|
17
|
+
value: n,
|
|
18
|
+
index: t
|
|
19
|
+
});
|
|
20
|
+
}, [
|
|
21
|
+
m,
|
|
22
|
+
u,
|
|
23
|
+
f
|
|
24
|
+
]);
|
|
25
|
+
let v = (e) => {
|
|
26
|
+
if (p.current) return;
|
|
27
|
+
let t = s.options[Number(e)], n = f.current;
|
|
28
|
+
t && n && (m || g({
|
|
29
|
+
value: t.value,
|
|
30
|
+
index: t.index
|
|
31
|
+
}), n.selectedIndex !== t.index && (n.selectedIndex = t.index, n.dispatchEvent(new Event("input", { bubbles: !0 })), n.dispatchEvent(new Event("change", { bubbles: !0 }))));
|
|
32
|
+
}, y = r(() => {
|
|
33
|
+
p.current = !1;
|
|
34
|
+
let e = f.current;
|
|
35
|
+
e && (m ? _ >= 0 && e.selectedIndex !== _ && (e.selectedIndex = _) : g({
|
|
36
|
+
value: e.value,
|
|
37
|
+
index: e.selectedIndex
|
|
38
|
+
}));
|
|
39
|
+
});
|
|
40
|
+
return n(() => {
|
|
41
|
+
let e = f.current?.form;
|
|
42
|
+
if (!e) return;
|
|
43
|
+
let t, n = () => {
|
|
44
|
+
p.current = !0, clearTimeout(t), t = setTimeout(() => y(), 0);
|
|
45
|
+
};
|
|
46
|
+
return e.addEventListener("reset", n, !0), () => {
|
|
47
|
+
e.removeEventListener("reset", n, !0), clearTimeout(t), p.current = !1;
|
|
48
|
+
};
|
|
49
|
+
}, [d, f]), {
|
|
50
|
+
controlled: m,
|
|
51
|
+
selected: _ >= 0 ? s.options[_] : void 0,
|
|
52
|
+
choose: v
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function c(e, t, n) {
|
|
56
|
+
let r = n instanceof Element ? n : null;
|
|
57
|
+
e.dispatchEvent(new FocusEvent(t, {
|
|
58
|
+
bubbles: !0,
|
|
59
|
+
relatedTarget: r
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
function l({ selectRef: e, triggerRef: t, contentRef: n, onFocus: r, onBlur: i }) {
|
|
63
|
+
let o = a(!1), s = (e) => e instanceof Node && (!!t.current?.contains(e) || !!n.current?.contains(e));
|
|
64
|
+
return {
|
|
65
|
+
handleFocusIn: (t) => {
|
|
66
|
+
o.current || (o.current = !0, r && e.current && c(e.current, "focusin", t.relatedTarget));
|
|
67
|
+
},
|
|
68
|
+
handleFocusOut: (t) => {
|
|
69
|
+
o.current && !s(t.relatedTarget) && (o.current = !1, i && e.current && c(e.current, "focusout", t.relatedTarget));
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export { l as useControlFocus, s as useThemedSelectChoice };
|
package/dist/ui/themed-select.js
CHANGED
|
@@ -1,234 +1,176 @@
|
|
|
1
1
|
import { cn as e } from "../shared-utils.js";
|
|
2
2
|
import { useThemedSelects as t } from "./themed-select-context.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
3
|
+
import { ThemedSelectMenu as n } from "./themed-select-menu.js";
|
|
4
|
+
import { readThemedSelectChildren as r } from "./themed-select-options.js";
|
|
5
|
+
import { useControlFocus as i, useThemedSelectChoice as a } from "./themed-select-state.js";
|
|
6
|
+
import { useCallback as o, useRef as s, useState as c } from "react";
|
|
7
|
+
import { ChevronDown as l } from "lucide-react";
|
|
8
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
9
|
+
import * as p from "@radix-ui/react-select";
|
|
8
10
|
// src/ui/themed-select.tsx
|
|
9
|
-
var
|
|
11
|
+
var m = /* @__PURE__ */ new Set([
|
|
10
12
|
"onChange",
|
|
11
13
|
"onInput",
|
|
12
14
|
"onInvalid",
|
|
13
15
|
"onFocus",
|
|
14
16
|
"onBlur"
|
|
15
17
|
]);
|
|
16
|
-
function
|
|
18
|
+
function h(e) {
|
|
17
19
|
return Object.entries(e);
|
|
18
20
|
}
|
|
19
|
-
function
|
|
21
|
+
function g(e) {
|
|
20
22
|
return e.startsWith("aria-") || e.startsWith("data-");
|
|
21
23
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
+
function _(e) {
|
|
25
|
+
return h(e).some(([e, t]) => /^on[A-Z]/.test(e) && !m.has(e) && t !== void 0);
|
|
24
26
|
}
|
|
25
|
-
function
|
|
27
|
+
function v(e) {
|
|
26
28
|
let t = {};
|
|
27
|
-
for (let [n, r] of
|
|
29
|
+
for (let [n, r] of h(e)) g(n) && (t[n] = r);
|
|
28
30
|
return t;
|
|
29
31
|
}
|
|
30
|
-
function
|
|
31
|
-
return e.multiple || typeof e.size == "number" && e.size > 1 || e.ref && e.value === void 0 ||
|
|
32
|
+
function y(e) {
|
|
33
|
+
return e.multiple || typeof e.size == "number" && e.size > 1 || e.ref && e.value === void 0 || _(e) ? null : r(e.children);
|
|
32
34
|
}
|
|
33
|
-
function
|
|
35
|
+
function b(e, t) {
|
|
34
36
|
if (typeof e == "function") {
|
|
35
37
|
let n = e(t);
|
|
36
38
|
return typeof n == "function" ? n : void 0;
|
|
37
39
|
}
|
|
38
40
|
e && (e.current = t);
|
|
39
41
|
}
|
|
40
|
-
function
|
|
42
|
+
function x(e) {
|
|
41
43
|
e.ctrlKey || e.metaKey || e.altKey || e.key !== "Escape" && e.key !== "Tab" && e.stopPropagation();
|
|
42
44
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"data-slot": "themed-select-item",
|
|
64
|
-
children: [/* @__PURE__ */ u("span", {
|
|
65
|
-
className: "absolute start-2 flex size-4 items-center justify-center",
|
|
66
|
-
children: /* @__PURE__ */ u(f.ItemIndicator, { children: /* @__PURE__ */ u(c, {
|
|
67
|
-
className: "size-4 text-action-primary-bg",
|
|
45
|
+
var S = "inline-block cursor-default text-start disabled:cursor-not-allowed disabled:opacity-60";
|
|
46
|
+
function C({ options: e, selected: t, arrow: n }) {
|
|
47
|
+
let r = e.filter((e) => !e.hidden);
|
|
48
|
+
return /* @__PURE__ */ f("span", {
|
|
49
|
+
className: "flex w-full min-w-0 items-center gap-2",
|
|
50
|
+
children: [/* @__PURE__ */ f("span", {
|
|
51
|
+
className: "grid min-w-0 flex-1",
|
|
52
|
+
children: [/* @__PURE__ */ d("span", {
|
|
53
|
+
className: "col-start-1 row-start-1 min-w-0 truncate",
|
|
54
|
+
"data-slot": "themed-select-value",
|
|
55
|
+
children: /* @__PURE__ */ d(p.Value, { children: t?.label ?? "" })
|
|
56
|
+
}), r.map((e) => /* @__PURE__ */ d("span", {
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
className: "invisible col-start-1 row-start-1 h-0 min-w-0 overflow-hidden whitespace-nowrap",
|
|
59
|
+
children: e.label
|
|
60
|
+
}, e.index))]
|
|
61
|
+
}), n ? /* @__PURE__ */ d(p.Icon, {
|
|
62
|
+
asChild: !0,
|
|
63
|
+
children: /* @__PURE__ */ d(l, {
|
|
64
|
+
className: "size-4 shrink-0 text-text-muted",
|
|
68
65
|
"aria-hidden": "true"
|
|
69
|
-
}) })
|
|
70
|
-
}), /* @__PURE__ */ u(f.ItemText, { children: e.label })]
|
|
71
|
-
}, e.index);
|
|
72
|
-
}
|
|
73
|
-
function D({ model: t, ref: n, id: c, className: p, style: m, title: h, hidden: g, lang: _, dir: C, tabIndex: D, autoFocus: O, name: le, form: k, required: A, autoComplete: ue, value: j, defaultValue: M, onChange: N, onInput: P, onInvalid: F, onFocus: I, onBlur: L, disabled: R, children: z, ...B }) {
|
|
74
|
-
let V = o(null), H = o(null), U = o(null), W = o(!1), G = o(!1), [de, fe] = s(!1), K = j !== void 0, [q, J] = s(() => {
|
|
75
|
-
let e = i(t.options, r(M));
|
|
76
|
-
return {
|
|
77
|
-
value: t.options[e]?.value,
|
|
78
|
-
index: e
|
|
79
|
-
};
|
|
80
|
-
}), Y = K ? i(t.options, r(j)) : q.value !== void 0 && t.options[q.index]?.value === q.value ? q.index : i(t.options, q.value), X = Y >= 0 ? t.options[Y] : void 0, pe = JSON.stringify(t.options.map((e) => e.value)), me = typeof p == "string" && /(^|\s)appearance-none(\s|$)/.test(p), he = t.options.filter((e) => !e.hidden), Z = t.entries.flatMap((e) => {
|
|
81
|
-
if (e.kind === "option") return e.option.hidden ? [] : [e];
|
|
82
|
-
let t = e.options.filter((e) => !e.hidden);
|
|
83
|
-
return t.length > 0 ? [{
|
|
84
|
-
...e,
|
|
85
|
-
options: t
|
|
86
|
-
}] : [];
|
|
87
|
-
}), ge = a((e) => {
|
|
88
|
-
V.current = e;
|
|
89
|
-
let t = v(n, e);
|
|
90
|
-
return () => {
|
|
91
|
-
V.current = null, t ? t() : v(n, null);
|
|
92
|
-
};
|
|
93
|
-
}, [n]);
|
|
94
|
-
re(() => {
|
|
95
|
-
let e = V.current;
|
|
96
|
-
!K && e && J((t) => t.index === e.selectedIndex && t.value === e.value ? t : {
|
|
97
|
-
value: e.value,
|
|
98
|
-
index: e.selectedIndex
|
|
99
|
-
});
|
|
100
|
-
}, [K, pe]);
|
|
101
|
-
let _e = (e) => {
|
|
102
|
-
if (G.current) return;
|
|
103
|
-
let n = t.options[Number(e)], r = V.current;
|
|
104
|
-
n && r && (K || J({
|
|
105
|
-
value: n.value,
|
|
106
|
-
index: n.index
|
|
107
|
-
}), r.selectedIndex !== n.index && (r.selectedIndex = n.index, r.dispatchEvent(new Event("input", { bubbles: !0 })), r.dispatchEvent(new Event("change", { bubbles: !0 }))));
|
|
108
|
-
}, ve = ne(() => {
|
|
109
|
-
G.current = !1;
|
|
110
|
-
let e = V.current;
|
|
111
|
-
e && (K ? Y >= 0 && e.selectedIndex !== Y && (e.selectedIndex = Y) : J({
|
|
112
|
-
value: e.value,
|
|
113
|
-
index: e.selectedIndex
|
|
114
|
-
}));
|
|
115
|
-
});
|
|
116
|
-
te(() => {
|
|
117
|
-
let e = V.current?.form;
|
|
118
|
-
if (!e) return;
|
|
119
|
-
let t, n = () => {
|
|
120
|
-
G.current = !0, clearTimeout(t), t = setTimeout(() => ve(), 0);
|
|
121
|
-
};
|
|
122
|
-
return e.addEventListener("reset", n, !0), () => {
|
|
123
|
-
e.removeEventListener("reset", n, !0), clearTimeout(t), G.current = !1;
|
|
124
|
-
};
|
|
125
|
-
}, [k]);
|
|
126
|
-
let ye = (e) => e instanceof Node && (!!H.current?.contains(e) || !!U.current?.contains(e)), Q = (e) => {
|
|
127
|
-
W.current || (W.current = !0, I && V.current && x(V.current, "focusin", e.relatedTarget));
|
|
128
|
-
}, $ = (e) => {
|
|
129
|
-
W.current && !ye(e.relatedTarget) && (W.current = !1, L && V.current && x(V.current, "focusout", e.relatedTarget));
|
|
130
|
-
};
|
|
131
|
-
return /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ d(f.Root, {
|
|
132
|
-
value: X ? String(X.index) : "",
|
|
133
|
-
onValueChange: _e,
|
|
134
|
-
open: de,
|
|
135
|
-
onOpenChange: fe,
|
|
136
|
-
disabled: R,
|
|
137
|
-
dir: C === "rtl" || C === "ltr" ? C : void 0,
|
|
138
|
-
children: [/* @__PURE__ */ u(f.Trigger, {
|
|
139
|
-
ref: H,
|
|
140
|
-
id: c,
|
|
141
|
-
title: h,
|
|
142
|
-
hidden: g,
|
|
143
|
-
lang: _,
|
|
144
|
-
tabIndex: D,
|
|
145
|
-
autoFocus: O,
|
|
146
|
-
style: m,
|
|
147
|
-
"aria-required": A ? !0 : void 0,
|
|
148
|
-
...ae(B),
|
|
149
|
-
"data-slot": "themed-select-trigger",
|
|
150
|
-
className: e(S, p),
|
|
151
|
-
onFocus: Q,
|
|
152
|
-
onBlur: $,
|
|
153
|
-
onKeyDown: y,
|
|
154
|
-
children: /* @__PURE__ */ d("span", {
|
|
155
|
-
className: "flex w-full min-w-0 items-center gap-2",
|
|
156
|
-
children: [/* @__PURE__ */ d("span", {
|
|
157
|
-
className: "grid min-w-0 flex-1",
|
|
158
|
-
children: [/* @__PURE__ */ u("span", {
|
|
159
|
-
className: "col-start-1 row-start-1 min-w-0 truncate",
|
|
160
|
-
"data-slot": "themed-select-value",
|
|
161
|
-
children: /* @__PURE__ */ u(f.Value, { children: X?.label ?? "" })
|
|
162
|
-
}), he.map((e) => /* @__PURE__ */ u("span", {
|
|
163
|
-
"aria-hidden": "true",
|
|
164
|
-
className: "invisible col-start-1 row-start-1 h-0 min-w-0 overflow-hidden whitespace-nowrap",
|
|
165
|
-
children: e.label
|
|
166
|
-
}, e.index))]
|
|
167
|
-
}), me ? null : /* @__PURE__ */ u(f.Icon, {
|
|
168
|
-
asChild: !0,
|
|
169
|
-
children: /* @__PURE__ */ u(ie, {
|
|
170
|
-
className: "size-4 shrink-0 text-text-muted",
|
|
171
|
-
"aria-hidden": "true"
|
|
172
|
-
})
|
|
173
|
-
})]
|
|
174
|
-
})
|
|
175
|
-
}), /* @__PURE__ */ u(f.Portal, { children: /* @__PURE__ */ u(f.Content, {
|
|
176
|
-
ref: U,
|
|
177
|
-
position: "popper",
|
|
178
|
-
side: "bottom",
|
|
179
|
-
align: "start",
|
|
180
|
-
sideOffset: 6,
|
|
181
|
-
collisionPadding: 8,
|
|
182
|
-
className: se,
|
|
183
|
-
"data-slot": "themed-select-content",
|
|
184
|
-
onFocus: Q,
|
|
185
|
-
onBlur: $,
|
|
186
|
-
onKeyDown: b,
|
|
187
|
-
onEscapeKeyDown: oe,
|
|
188
|
-
children: /* @__PURE__ */ u(f.Viewport, {
|
|
189
|
-
className: ce,
|
|
190
|
-
children: Z.map((e, t) => {
|
|
191
|
-
let n = t > 0 && (e.kind === "group" || Z[t - 1]?.kind === "group") ? /* @__PURE__ */ u(f.Separator, { className: w }) : null;
|
|
192
|
-
return e.kind === "option" ? n ? /* @__PURE__ */ d(ee, { children: [n, E(e.option)] }, e.option.index) : E(e.option) : /* @__PURE__ */ d(f.Group, { children: [
|
|
193
|
-
n,
|
|
194
|
-
e.label ? /* @__PURE__ */ u(f.Label, {
|
|
195
|
-
className: T,
|
|
196
|
-
children: e.label
|
|
197
|
-
}) : null,
|
|
198
|
-
e.options.map(E)
|
|
199
|
-
] }, `group-${e.options[0]?.index ?? t}`);
|
|
200
|
-
})
|
|
201
66
|
})
|
|
202
|
-
})
|
|
203
|
-
})
|
|
204
|
-
|
|
67
|
+
}) : null]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function w({ nodeRef: e, triggerRef: t, controlled: n, name: r, form: i, required: a, autoComplete: o, disabled: s, value: c, defaultValue: l, onChange: u, onInput: f, onInvalid: p, onFocus: m, onBlur: h, children: g }) {
|
|
71
|
+
return /* @__PURE__ */ d("select", {
|
|
72
|
+
ref: e,
|
|
205
73
|
"aria-hidden": "true",
|
|
206
74
|
tabIndex: -1,
|
|
207
75
|
className: "sr-only pointer-events-none",
|
|
208
76
|
"data-slot": "themed-select-native",
|
|
209
|
-
name:
|
|
210
|
-
form:
|
|
211
|
-
required:
|
|
212
|
-
autoComplete:
|
|
213
|
-
disabled:
|
|
214
|
-
...
|
|
215
|
-
onChange:
|
|
216
|
-
onInput:
|
|
217
|
-
onInvalid:
|
|
77
|
+
name: r,
|
|
78
|
+
form: i,
|
|
79
|
+
required: a,
|
|
80
|
+
autoComplete: o,
|
|
81
|
+
disabled: s,
|
|
82
|
+
...n ? { value: c } : { defaultValue: l },
|
|
83
|
+
onChange: u,
|
|
84
|
+
onInput: f,
|
|
85
|
+
onInvalid: p,
|
|
218
86
|
onFocus: (e) => {
|
|
219
|
-
e.nativeEvent.isTrusted ?
|
|
87
|
+
e.nativeEvent.isTrusted ? t.current?.focus() : (e.stopPropagation(), m?.(e));
|
|
220
88
|
},
|
|
221
89
|
onBlur: (e) => {
|
|
222
|
-
e.nativeEvent.isTrusted || (e.stopPropagation(),
|
|
90
|
+
e.nativeEvent.isTrusted || (e.stopPropagation(), h?.(e));
|
|
223
91
|
},
|
|
224
|
-
children:
|
|
92
|
+
children: g
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function T({ model: t, ref: r, id: l, className: m, style: h, title: g, hidden: _, lang: y, dir: T, tabIndex: E, autoFocus: D, name: O, form: k, required: A, autoComplete: j, value: M, defaultValue: N, onChange: P, onInput: F, onInvalid: I, onFocus: L, onBlur: R, disabled: z, children: B, ...V }) {
|
|
96
|
+
let H = s(null), U = s(null), W = s(null), [G, K] = c(!1), { controlled: q, selected: J, choose: Y } = a({
|
|
97
|
+
model: t,
|
|
98
|
+
value: M,
|
|
99
|
+
defaultValue: N,
|
|
100
|
+
children: B,
|
|
101
|
+
form: k,
|
|
102
|
+
selectRef: H
|
|
103
|
+
}), { handleFocusIn: X, handleFocusOut: Z } = i({
|
|
104
|
+
selectRef: H,
|
|
105
|
+
triggerRef: U,
|
|
106
|
+
contentRef: W,
|
|
107
|
+
onFocus: L,
|
|
108
|
+
onBlur: R
|
|
109
|
+
}), Q = typeof m == "string" && /(^|\s)appearance-none(\s|$)/.test(m), $ = o((e) => {
|
|
110
|
+
H.current = e;
|
|
111
|
+
let t = b(r, e);
|
|
112
|
+
return () => {
|
|
113
|
+
H.current = null, t ? t() : b(r, null);
|
|
114
|
+
};
|
|
115
|
+
}, [r]);
|
|
116
|
+
return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ f(p.Root, {
|
|
117
|
+
value: J ? String(J.index) : "",
|
|
118
|
+
onValueChange: Y,
|
|
119
|
+
open: G,
|
|
120
|
+
onOpenChange: K,
|
|
121
|
+
disabled: z,
|
|
122
|
+
dir: T === "rtl" || T === "ltr" ? T : void 0,
|
|
123
|
+
children: [/* @__PURE__ */ d(p.Trigger, {
|
|
124
|
+
ref: U,
|
|
125
|
+
id: l,
|
|
126
|
+
title: g,
|
|
127
|
+
hidden: _,
|
|
128
|
+
lang: y,
|
|
129
|
+
tabIndex: E,
|
|
130
|
+
autoFocus: D,
|
|
131
|
+
style: h,
|
|
132
|
+
"aria-required": A ? !0 : void 0,
|
|
133
|
+
...v(V),
|
|
134
|
+
"data-slot": "themed-select-trigger",
|
|
135
|
+
className: e(S, m),
|
|
136
|
+
onFocus: X,
|
|
137
|
+
onBlur: Z,
|
|
138
|
+
onKeyDown: x,
|
|
139
|
+
children: /* @__PURE__ */ d(C, {
|
|
140
|
+
options: t.options,
|
|
141
|
+
selected: J,
|
|
142
|
+
arrow: !Q
|
|
143
|
+
})
|
|
144
|
+
}), /* @__PURE__ */ d(n, {
|
|
145
|
+
model: t,
|
|
146
|
+
contentRef: W,
|
|
147
|
+
onFocus: X,
|
|
148
|
+
onBlur: Z
|
|
149
|
+
})]
|
|
150
|
+
}), /* @__PURE__ */ d(w, {
|
|
151
|
+
nodeRef: $,
|
|
152
|
+
triggerRef: U,
|
|
153
|
+
controlled: q,
|
|
154
|
+
name: O,
|
|
155
|
+
form: k,
|
|
156
|
+
required: A,
|
|
157
|
+
autoComplete: j,
|
|
158
|
+
disabled: z,
|
|
159
|
+
value: M,
|
|
160
|
+
defaultValue: N,
|
|
161
|
+
onChange: P,
|
|
162
|
+
onInput: F,
|
|
163
|
+
onInvalid: I,
|
|
164
|
+
onFocus: L,
|
|
165
|
+
onBlur: R,
|
|
166
|
+
children: B
|
|
225
167
|
})] });
|
|
226
168
|
}
|
|
227
|
-
function
|
|
228
|
-
let n = t() ?
|
|
229
|
-
return n ? /* @__PURE__ */
|
|
169
|
+
function E(e) {
|
|
170
|
+
let n = t() ? y(e) : null;
|
|
171
|
+
return n ? /* @__PURE__ */ d(T, {
|
|
230
172
|
...e,
|
|
231
173
|
model: n
|
|
232
|
-
}) : /* @__PURE__ */
|
|
174
|
+
}) : /* @__PURE__ */ d("select", { ...e });
|
|
233
175
|
}
|
|
234
|
-
export {
|
|
176
|
+
export { E as ThemedSelect };
|