@stanfordspezi/spezi-web-design-system
Version:
Stanford Biodesign Digital Health Spezi Web Design System
951 lines (950 loc) • 33.7 kB
JavaScript
import { jsx as c, jsxs as G, Fragment as de } from "react/jsx-runtime";
import { c as j } from "./index-2NvaPZWc.mjs";
import { c as _e } from "./createLucideIcon-C8GTh_Qx.mjs";
import { C as it } from "./check-spSolxBo.mjs";
import * as n from "react";
import * as Me from "react-dom";
import { a as Ne, c as dt, u as q, d as N, b as ut } from "./index-DqbtYIhp.mjs";
import { u as pt, c as ft } from "./index-B__yqZ4y.mjs";
import { u as V, c as mt } from "./index-Bytw4Lqn.mjs";
import { D as ht } from "./index-C9uNU7u7.mjs";
import { P as vt, h as gt, u as St, R as wt, F as xt } from "./index-DdcLbo-g.mjs";
import { u as be } from "./index-BR4tIz6o.mjs";
import { c as Ae, R as yt, A as Ct, C as It, a as Tt } from "./index-D3lfN3hi.mjs";
import { P as M } from "./index-WWNfSPCj.mjs";
import { u as bt } from "./index-BZPx6jYI.mjs";
import { V as Pt } from "./index-D6Zqau5G.mjs";
function Re(t, [o, e]) {
return Math.min(e, Math.max(o, t));
}
var Nt = [" ", "Enter", "ArrowUp", "ArrowDown"], Rt = [" ", "Enter"], le = "Select", [ue, pe, Et] = ft(le), [oe, Po] = dt(le, [
Et,
Ae
]), fe = Ae(), [_t, Y] = oe(le), [Mt, At] = oe(le), Oe = (t) => {
const {
__scopeSelect: o,
children: e,
open: a,
defaultOpen: i,
onOpenChange: p,
value: s,
defaultValue: l,
onValueChange: r,
dir: f,
name: g,
autoComplete: x,
disabled: b,
required: P,
form: T
} = t, d = fe(o), [v, y] = n.useState(null), [u, h] = n.useState(null), [A, O] = n.useState(!1), ne = pt(f), [R = !1, L] = Ne({
prop: a,
defaultProp: i,
onChange: p
}), [K, Z] = Ne({
prop: s,
defaultProp: l,
onChange: r
}), B = n.useRef(null), H = v ? T || !!v.closest("form") : !0, [$, F] = n.useState(/* @__PURE__ */ new Set()), W = Array.from($).map((E) => E.props.value).join(";");
return /* @__PURE__ */ c(yt, { ...d, children: /* @__PURE__ */ G(
_t,
{
required: P,
scope: o,
trigger: v,
onTriggerChange: y,
valueNode: u,
onValueNodeChange: h,
valueNodeHasChildren: A,
onValueNodeHasChildrenChange: O,
contentId: be(),
value: K,
onValueChange: Z,
open: R,
onOpenChange: L,
dir: ne,
triggerPointerDownPosRef: B,
disabled: b,
children: [
/* @__PURE__ */ c(ue.Provider, { scope: o, children: /* @__PURE__ */ c(
Mt,
{
scope: t.__scopeSelect,
onNativeOptionAdd: n.useCallback((E) => {
F((k) => new Set(k).add(E));
}, []),
onNativeOptionRemove: n.useCallback((E) => {
F((k) => {
const U = new Set(k);
return U.delete(E), U;
});
}, []),
children: e
}
) }),
H ? /* @__PURE__ */ G(
st,
{
"aria-hidden": !0,
required: P,
tabIndex: -1,
name: g,
autoComplete: x,
value: K,
onChange: (E) => Z(E.target.value),
disabled: b,
form: T,
children: [
K === void 0 ? /* @__PURE__ */ c("option", { value: "" }) : null,
Array.from($)
]
},
W
) : null
]
}
) });
};
Oe.displayName = le;
var De = "SelectTrigger", Le = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, disabled: a = !1, ...i } = t, p = fe(e), s = Y(De, e), l = s.disabled || a, r = V(o, s.onTriggerChange), f = pe(e), g = n.useRef("touch"), [x, b, P] = lt((d) => {
const v = f().filter((h) => !h.disabled), y = v.find((h) => h.value === s.value), u = ct(v, d, y);
u !== void 0 && s.onValueChange(u.value);
}), T = (d) => {
l || (s.onOpenChange(!0), P()), d && (s.triggerPointerDownPosRef.current = {
x: Math.round(d.pageX),
y: Math.round(d.pageY)
});
};
return /* @__PURE__ */ c(Ct, { asChild: !0, ...p, children: /* @__PURE__ */ c(
M.button,
{
type: "button",
role: "combobox",
"aria-controls": s.contentId,
"aria-expanded": s.open,
"aria-required": s.required,
"aria-autocomplete": "none",
dir: s.dir,
"data-state": s.open ? "open" : "closed",
disabled: l,
"data-disabled": l ? "" : void 0,
"data-placeholder": rt(s.value) ? "" : void 0,
...i,
ref: r,
onClick: N(i.onClick, (d) => {
d.currentTarget.focus(), g.current !== "mouse" && T(d);
}),
onPointerDown: N(i.onPointerDown, (d) => {
g.current = d.pointerType;
const v = d.target;
v.hasPointerCapture(d.pointerId) && v.releasePointerCapture(d.pointerId), d.button === 0 && d.ctrlKey === !1 && d.pointerType === "mouse" && (T(d), d.preventDefault());
}),
onKeyDown: N(i.onKeyDown, (d) => {
const v = x.current !== "";
!(d.ctrlKey || d.altKey || d.metaKey) && d.key.length === 1 && b(d.key), !(v && d.key === " ") && Nt.includes(d.key) && (T(), d.preventDefault());
})
}
) });
}
);
Le.displayName = De;
var ke = "SelectValue", Ve = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, className: a, style: i, children: p, placeholder: s = "", ...l } = t, r = Y(ke, e), { onValueNodeHasChildrenChange: f } = r, g = p !== void 0, x = V(o, r.onValueNodeChange);
return q(() => {
f(g);
}, [f, g]), /* @__PURE__ */ c(
M.span,
{
...l,
ref: x,
style: { pointerEvents: "none" },
children: rt(r.value) ? /* @__PURE__ */ c(de, { children: s }) : p
}
);
}
);
Ve.displayName = ke;
var Ot = "SelectIcon", Be = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, children: a, ...i } = t;
return /* @__PURE__ */ c(M.span, { "aria-hidden": !0, ...i, ref: o, children: a || "▼" });
}
);
Be.displayName = Ot;
var Dt = "SelectPortal", He = (t) => /* @__PURE__ */ c(vt, { asChild: !0, ...t });
He.displayName = Dt;
var ee = "SelectContent", Fe = n.forwardRef(
(t, o) => {
const e = Y(ee, t.__scopeSelect), [a, i] = n.useState();
if (q(() => {
i(new DocumentFragment());
}, []), !e.open) {
const p = a;
return p ? Me.createPortal(
/* @__PURE__ */ c(We, { scope: t.__scopeSelect, children: /* @__PURE__ */ c(ue.Slot, { scope: t.__scopeSelect, children: /* @__PURE__ */ c("div", { children: t.children }) }) }),
p
) : null;
}
return /* @__PURE__ */ c(Ue, { ...t, ref: o });
}
);
Fe.displayName = ee;
var D = 10, [We, X] = oe(ee), Lt = "SelectContentImpl", kt = mt("SelectContent.RemoveScroll"), Ue = n.forwardRef(
(t, o) => {
const {
__scopeSelect: e,
position: a = "item-aligned",
onCloseAutoFocus: i,
onEscapeKeyDown: p,
onPointerDownOutside: s,
//
// PopperContent props
side: l,
sideOffset: r,
align: f,
alignOffset: g,
arrowPadding: x,
collisionBoundary: b,
collisionPadding: P,
sticky: T,
hideWhenDetached: d,
avoidCollisions: v,
//
...y
} = t, u = Y(ee, e), [h, A] = n.useState(null), [O, ne] = n.useState(null), R = V(o, (m) => A(m)), [L, K] = n.useState(null), [Z, B] = n.useState(
null
), H = pe(e), [$, F] = n.useState(!1), W = n.useRef(!1);
n.useEffect(() => {
if (h) return gt(h);
}, [h]), St();
const E = n.useCallback(
(m) => {
const [I, ..._] = H().map((w) => w.ref.current), [C] = _.slice(-1), S = document.activeElement;
for (const w of m)
if (w === S || (w == null || w.scrollIntoView({ block: "nearest" }), w === I && O && (O.scrollTop = 0), w === C && O && (O.scrollTop = O.scrollHeight), w == null || w.focus(), document.activeElement !== S)) return;
},
[H, O]
), k = n.useCallback(
() => E([L, h]),
[E, L, h]
);
n.useEffect(() => {
$ && k();
}, [$, k]);
const { onOpenChange: U, triggerPointerDownPosRef: z } = u;
n.useEffect(() => {
if (h) {
let m = { x: 0, y: 0 };
const I = (C) => {
var S, w;
m = {
x: Math.abs(Math.round(C.pageX) - (((S = z.current) == null ? void 0 : S.x) ?? 0)),
y: Math.abs(Math.round(C.pageY) - (((w = z.current) == null ? void 0 : w.y) ?? 0))
};
}, _ = (C) => {
m.x <= 10 && m.y <= 10 ? C.preventDefault() : h.contains(C.target) || U(!1), document.removeEventListener("pointermove", I), z.current = null;
};
return z.current !== null && (document.addEventListener("pointermove", I), document.addEventListener("pointerup", _, { capture: !0, once: !0 })), () => {
document.removeEventListener("pointermove", I), document.removeEventListener("pointerup", _, { capture: !0 });
};
}
}, [h, U, z]), n.useEffect(() => {
const m = () => U(!1);
return window.addEventListener("blur", m), window.addEventListener("resize", m), () => {
window.removeEventListener("blur", m), window.removeEventListener("resize", m);
};
}, [U]);
const [me, ce] = lt((m) => {
const I = H().filter((S) => !S.disabled), _ = I.find((S) => S.ref.current === document.activeElement), C = ct(I, m, _);
C && setTimeout(() => C.ref.current.focus());
}), he = n.useCallback(
(m, I, _) => {
const C = !W.current && !_;
(u.value !== void 0 && u.value === I || C) && (K(m), C && (W.current = !0));
},
[u.value]
), ve = n.useCallback(() => h == null ? void 0 : h.focus(), [h]), te = n.useCallback(
(m, I, _) => {
const C = !W.current && !_;
(u.value !== void 0 && u.value === I || C) && B(m);
},
[u.value]
), ae = a === "popper" ? xe : Ke, re = ae === xe ? {
side: l,
sideOffset: r,
align: f,
alignOffset: g,
arrowPadding: x,
collisionBoundary: b,
collisionPadding: P,
sticky: T,
hideWhenDetached: d,
avoidCollisions: v
} : {};
return /* @__PURE__ */ c(
We,
{
scope: e,
content: h,
viewport: O,
onViewportChange: ne,
itemRefCallback: he,
selectedItem: L,
onItemLeave: ve,
itemTextRefCallback: te,
focusSelectedItem: k,
selectedItemText: Z,
position: a,
isPositioned: $,
searchRef: me,
children: /* @__PURE__ */ c(wt, { as: kt, allowPinchZoom: !0, children: /* @__PURE__ */ c(
xt,
{
asChild: !0,
trapped: u.open,
onMountAutoFocus: (m) => {
m.preventDefault();
},
onUnmountAutoFocus: N(i, (m) => {
var I;
(I = u.trigger) == null || I.focus({ preventScroll: !0 }), m.preventDefault();
}),
children: /* @__PURE__ */ c(
ht,
{
asChild: !0,
disableOutsidePointerEvents: !0,
onEscapeKeyDown: p,
onPointerDownOutside: s,
onFocusOutside: (m) => m.preventDefault(),
onDismiss: () => u.onOpenChange(!1),
children: /* @__PURE__ */ c(
ae,
{
role: "listbox",
id: u.contentId,
"data-state": u.open ? "open" : "closed",
dir: u.dir,
onContextMenu: (m) => m.preventDefault(),
...y,
...re,
onPlaced: () => F(!0),
ref: R,
style: {
// flex layout so we can place the scroll buttons properly
display: "flex",
flexDirection: "column",
// reset the outline by default as the content MAY get focused
outline: "none",
...y.style
},
onKeyDown: N(y.onKeyDown, (m) => {
const I = m.ctrlKey || m.altKey || m.metaKey;
if (m.key === "Tab" && m.preventDefault(), !I && m.key.length === 1 && ce(m.key), ["ArrowUp", "ArrowDown", "Home", "End"].includes(m.key)) {
let C = H().filter((S) => !S.disabled).map((S) => S.ref.current);
if (["ArrowUp", "End"].includes(m.key) && (C = C.slice().reverse()), ["ArrowUp", "ArrowDown"].includes(m.key)) {
const S = m.target, w = C.indexOf(S);
C = C.slice(w + 1);
}
setTimeout(() => E(C)), m.preventDefault();
}
})
}
)
}
)
}
) })
}
);
}
);
Ue.displayName = Lt;
var Vt = "SelectItemAlignedPosition", Ke = n.forwardRef((t, o) => {
const { __scopeSelect: e, onPlaced: a, ...i } = t, p = Y(ee, e), s = X(ee, e), [l, r] = n.useState(null), [f, g] = n.useState(null), x = V(o, (R) => g(R)), b = pe(e), P = n.useRef(!1), T = n.useRef(!0), { viewport: d, selectedItem: v, selectedItemText: y, focusSelectedItem: u } = s, h = n.useCallback(() => {
if (p.trigger && p.valueNode && l && f && d && v && y) {
const R = p.trigger.getBoundingClientRect(), L = f.getBoundingClientRect(), K = p.valueNode.getBoundingClientRect(), Z = y.getBoundingClientRect();
if (p.dir !== "rtl") {
const S = Z.left - L.left, w = K.left - S, J = R.left - w, Q = R.width + J, ge = Math.max(Q, L.width), Se = window.innerWidth - D, we = Re(w, [
D,
// Prevents the content from going off the starting edge of the
// viewport. It may still go off the ending edge, but this can be
// controlled by the user since they may want to manage overflow in a
// specific way.
// https://github.com/radix-ui/primitives/issues/2049
Math.max(D, Se - ge)
]);
l.style.minWidth = Q + "px", l.style.left = we + "px";
} else {
const S = L.right - Z.right, w = window.innerWidth - K.right - S, J = window.innerWidth - R.right - w, Q = R.width + J, ge = Math.max(Q, L.width), Se = window.innerWidth - D, we = Re(w, [
D,
Math.max(D, Se - ge)
]);
l.style.minWidth = Q + "px", l.style.right = we + "px";
}
const B = b(), H = window.innerHeight - D * 2, $ = d.scrollHeight, F = window.getComputedStyle(f), W = parseInt(F.borderTopWidth, 10), E = parseInt(F.paddingTop, 10), k = parseInt(F.borderBottomWidth, 10), U = parseInt(F.paddingBottom, 10), z = W + E + $ + U + k, me = Math.min(v.offsetHeight * 5, z), ce = window.getComputedStyle(d), he = parseInt(ce.paddingTop, 10), ve = parseInt(ce.paddingBottom, 10), te = R.top + R.height / 2 - D, ae = H - te, re = v.offsetHeight / 2, m = v.offsetTop + re, I = W + E + m, _ = z - I;
if (I <= te) {
const S = B.length > 0 && v === B[B.length - 1].ref.current;
l.style.bottom = "0px";
const w = f.clientHeight - d.offsetTop - d.offsetHeight, J = Math.max(
ae,
re + // viewport might have padding bottom, include it to avoid a scrollable viewport
(S ? ve : 0) + w + k
), Q = I + J;
l.style.height = Q + "px";
} else {
const S = B.length > 0 && v === B[0].ref.current;
l.style.top = "0px";
const J = Math.max(
te,
W + d.offsetTop + // viewport might have padding top, include it to avoid a scrollable viewport
(S ? he : 0) + re
) + _;
l.style.height = J + "px", d.scrollTop = I - te + d.offsetTop;
}
l.style.margin = `${D}px 0`, l.style.minHeight = me + "px", l.style.maxHeight = H + "px", a == null || a(), requestAnimationFrame(() => P.current = !0);
}
}, [
b,
p.trigger,
p.valueNode,
l,
f,
d,
v,
y,
p.dir,
a
]);
q(() => h(), [h]);
const [A, O] = n.useState();
q(() => {
f && O(window.getComputedStyle(f).zIndex);
}, [f]);
const ne = n.useCallback(
(R) => {
R && T.current === !0 && (h(), u == null || u(), T.current = !1);
},
[h, u]
);
return /* @__PURE__ */ c(
Ht,
{
scope: e,
contentWrapper: l,
shouldExpandOnScrollRef: P,
onScrollButtonChange: ne,
children: /* @__PURE__ */ c(
"div",
{
ref: r,
style: {
display: "flex",
flexDirection: "column",
position: "fixed",
zIndex: A
},
children: /* @__PURE__ */ c(
M.div,
{
...i,
ref: x,
style: {
// When we get the height of the content, it includes borders. If we were to set
// the height without having `boxSizing: 'border-box'` it would be too big.
boxSizing: "border-box",
// We need to ensure the content doesn't get taller than the wrapper
maxHeight: "100%",
...i.style
}
}
)
}
)
}
);
});
Ke.displayName = Vt;
var Bt = "SelectPopperPosition", xe = n.forwardRef((t, o) => {
const {
__scopeSelect: e,
align: a = "start",
collisionPadding: i = D,
...p
} = t, s = fe(e);
return /* @__PURE__ */ c(
It,
{
...s,
...p,
ref: o,
align: a,
collisionPadding: i,
style: {
// Ensure border-box for floating-ui calculations
boxSizing: "border-box",
...p.style,
"--radix-select-content-transform-origin": "var(--radix-popper-transform-origin)",
"--radix-select-content-available-width": "var(--radix-popper-available-width)",
"--radix-select-content-available-height": "var(--radix-popper-available-height)",
"--radix-select-trigger-width": "var(--radix-popper-anchor-width)",
"--radix-select-trigger-height": "var(--radix-popper-anchor-height)"
}
}
);
});
xe.displayName = Bt;
var [Ht, Pe] = oe(ee, {}), ye = "SelectViewport", $e = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, nonce: a, ...i } = t, p = X(ye, e), s = Pe(ye, e), l = V(o, p.onViewportChange), r = n.useRef(0);
return /* @__PURE__ */ G(de, { children: [
/* @__PURE__ */ c(
"style",
{
dangerouslySetInnerHTML: {
__html: "[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"
},
nonce: a
}
),
/* @__PURE__ */ c(ue.Slot, { scope: e, children: /* @__PURE__ */ c(
M.div,
{
"data-radix-select-viewport": "",
role: "presentation",
...i,
ref: l,
style: {
// we use position: 'relative' here on the `viewport` so that when we call
// `selectedItem.offsetTop` in calculations, the offset is relative to the viewport
// (independent of the scrollUpButton).
position: "relative",
flex: 1,
// Viewport should only be scrollable in the vertical direction.
// This won't work in vertical writing modes, so we'll need to
// revisit this if/when that is supported
// https://developer.chrome.com/blog/vertical-form-controls
overflow: "hidden auto",
...i.style
},
onScroll: N(i.onScroll, (f) => {
const g = f.currentTarget, { contentWrapper: x, shouldExpandOnScrollRef: b } = s;
if (b != null && b.current && x) {
const P = Math.abs(r.current - g.scrollTop);
if (P > 0) {
const T = window.innerHeight - D * 2, d = parseFloat(x.style.minHeight), v = parseFloat(x.style.height), y = Math.max(d, v);
if (y < T) {
const u = y + P, h = Math.min(T, u), A = u - h;
x.style.height = h + "px", x.style.bottom === "0px" && (g.scrollTop = A > 0 ? A : 0, x.style.justifyContent = "flex-end");
}
}
}
r.current = g.scrollTop;
})
}
) })
] });
}
);
$e.displayName = ye;
var ze = "SelectGroup", [Ft, Wt] = oe(ze), Ge = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, ...a } = t, i = be();
return /* @__PURE__ */ c(Ft, { scope: e, id: i, children: /* @__PURE__ */ c(M.div, { role: "group", "aria-labelledby": i, ...a, ref: o }) });
}
);
Ge.displayName = ze;
var je = "SelectLabel", qe = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, ...a } = t, i = Wt(je, e);
return /* @__PURE__ */ c(M.div, { id: i.id, ...a, ref: o });
}
);
qe.displayName = je;
var ie = "SelectItem", [Ut, Ye] = oe(ie), Xe = n.forwardRef(
(t, o) => {
const {
__scopeSelect: e,
value: a,
disabled: i = !1,
textValue: p,
...s
} = t, l = Y(ie, e), r = X(ie, e), f = l.value === a, [g, x] = n.useState(p ?? ""), [b, P] = n.useState(!1), T = V(
o,
(u) => {
var h;
return (h = r.itemRefCallback) == null ? void 0 : h.call(r, u, a, i);
}
), d = be(), v = n.useRef("touch"), y = () => {
i || (l.onValueChange(a), l.onOpenChange(!1));
};
if (a === "")
throw new Error(
"A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder."
);
return /* @__PURE__ */ c(
Ut,
{
scope: e,
value: a,
disabled: i,
textId: d,
isSelected: f,
onItemTextChange: n.useCallback((u) => {
x((h) => h || ((u == null ? void 0 : u.textContent) ?? "").trim());
}, []),
children: /* @__PURE__ */ c(
ue.ItemSlot,
{
scope: e,
value: a,
disabled: i,
textValue: g,
children: /* @__PURE__ */ c(
M.div,
{
role: "option",
"aria-labelledby": d,
"data-highlighted": b ? "" : void 0,
"aria-selected": f && b,
"data-state": f ? "checked" : "unchecked",
"aria-disabled": i || void 0,
"data-disabled": i ? "" : void 0,
tabIndex: i ? void 0 : -1,
...s,
ref: T,
onFocus: N(s.onFocus, () => P(!0)),
onBlur: N(s.onBlur, () => P(!1)),
onClick: N(s.onClick, () => {
v.current !== "mouse" && y();
}),
onPointerUp: N(s.onPointerUp, () => {
v.current === "mouse" && y();
}),
onPointerDown: N(s.onPointerDown, (u) => {
v.current = u.pointerType;
}),
onPointerMove: N(s.onPointerMove, (u) => {
var h;
v.current = u.pointerType, i ? (h = r.onItemLeave) == null || h.call(r) : v.current === "mouse" && u.currentTarget.focus({ preventScroll: !0 });
}),
onPointerLeave: N(s.onPointerLeave, (u) => {
var h;
u.currentTarget === document.activeElement && ((h = r.onItemLeave) == null || h.call(r));
}),
onKeyDown: N(s.onKeyDown, (u) => {
var A;
((A = r.searchRef) == null ? void 0 : A.current) !== "" && u.key === " " || (Rt.includes(u.key) && y(), u.key === " " && u.preventDefault());
})
}
)
}
)
}
);
}
);
Xe.displayName = ie;
var se = "SelectItemText", Ze = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, className: a, style: i, ...p } = t, s = Y(se, e), l = X(se, e), r = Ye(se, e), f = At(se, e), [g, x] = n.useState(null), b = V(
o,
(y) => x(y),
r.onItemTextChange,
(y) => {
var u;
return (u = l.itemTextRefCallback) == null ? void 0 : u.call(l, y, r.value, r.disabled);
}
), P = g == null ? void 0 : g.textContent, T = n.useMemo(
() => /* @__PURE__ */ c("option", { value: r.value, disabled: r.disabled, children: P }, r.value),
[r.disabled, r.value, P]
), { onNativeOptionAdd: d, onNativeOptionRemove: v } = f;
return q(() => (d(T), () => v(T)), [d, v, T]), /* @__PURE__ */ G(de, { children: [
/* @__PURE__ */ c(M.span, { id: r.textId, ...p, ref: b }),
r.isSelected && s.valueNode && !s.valueNodeHasChildren ? Me.createPortal(p.children, s.valueNode) : null
] });
}
);
Ze.displayName = se;
var Je = "SelectItemIndicator", Qe = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, ...a } = t;
return Ye(Je, e).isSelected ? /* @__PURE__ */ c(M.span, { "aria-hidden": !0, ...a, ref: o }) : null;
}
);
Qe.displayName = Je;
var Ce = "SelectScrollUpButton", et = n.forwardRef((t, o) => {
const e = X(Ce, t.__scopeSelect), a = Pe(Ce, t.__scopeSelect), [i, p] = n.useState(!1), s = V(o, a.onScrollButtonChange);
return q(() => {
if (e.viewport && e.isPositioned) {
let l = function() {
const f = r.scrollTop > 0;
p(f);
};
const r = e.viewport;
return l(), r.addEventListener("scroll", l), () => r.removeEventListener("scroll", l);
}
}, [e.viewport, e.isPositioned]), i ? /* @__PURE__ */ c(
ot,
{
...t,
ref: s,
onAutoScroll: () => {
const { viewport: l, selectedItem: r } = e;
l && r && (l.scrollTop = l.scrollTop - r.offsetHeight);
}
}
) : null;
});
et.displayName = Ce;
var Ie = "SelectScrollDownButton", tt = n.forwardRef((t, o) => {
const e = X(Ie, t.__scopeSelect), a = Pe(Ie, t.__scopeSelect), [i, p] = n.useState(!1), s = V(o, a.onScrollButtonChange);
return q(() => {
if (e.viewport && e.isPositioned) {
let l = function() {
const f = r.scrollHeight - r.clientHeight, g = Math.ceil(r.scrollTop) < f;
p(g);
};
const r = e.viewport;
return l(), r.addEventListener("scroll", l), () => r.removeEventListener("scroll", l);
}
}, [e.viewport, e.isPositioned]), i ? /* @__PURE__ */ c(
ot,
{
...t,
ref: s,
onAutoScroll: () => {
const { viewport: l, selectedItem: r } = e;
l && r && (l.scrollTop = l.scrollTop + r.offsetHeight);
}
}
) : null;
});
tt.displayName = Ie;
var ot = n.forwardRef((t, o) => {
const { __scopeSelect: e, onAutoScroll: a, ...i } = t, p = X("SelectScrollButton", e), s = n.useRef(null), l = pe(e), r = n.useCallback(() => {
s.current !== null && (window.clearInterval(s.current), s.current = null);
}, []);
return n.useEffect(() => () => r(), [r]), q(() => {
var g;
const f = l().find((x) => x.ref.current === document.activeElement);
(g = f == null ? void 0 : f.ref.current) == null || g.scrollIntoView({ block: "nearest" });
}, [l]), /* @__PURE__ */ c(
M.div,
{
"aria-hidden": !0,
...i,
ref: o,
style: { flexShrink: 0, ...i.style },
onPointerDown: N(i.onPointerDown, () => {
s.current === null && (s.current = window.setInterval(a, 50));
}),
onPointerMove: N(i.onPointerMove, () => {
var f;
(f = p.onItemLeave) == null || f.call(p), s.current === null && (s.current = window.setInterval(a, 50));
}),
onPointerLeave: N(i.onPointerLeave, () => {
r();
})
}
);
}), Kt = "SelectSeparator", nt = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, ...a } = t;
return /* @__PURE__ */ c(M.div, { "aria-hidden": !0, ...a, ref: o });
}
);
nt.displayName = Kt;
var Te = "SelectArrow", $t = n.forwardRef(
(t, o) => {
const { __scopeSelect: e, ...a } = t, i = fe(e), p = Y(Te, e), s = X(Te, e);
return p.open && s.position === "popper" ? /* @__PURE__ */ c(Tt, { ...i, ...a, ref: o }) : null;
}
);
$t.displayName = Te;
function rt(t) {
return t === "" || t === void 0;
}
var st = n.forwardRef(
(t, o) => {
const { value: e, ...a } = t, i = n.useRef(null), p = V(o, i), s = bt(e);
return n.useEffect(() => {
const l = i.current, r = window.HTMLSelectElement.prototype, g = Object.getOwnPropertyDescriptor(
r,
"value"
).set;
if (s !== e && g) {
const x = new Event("change", { bubbles: !0 });
g.call(l, e), l.dispatchEvent(x);
}
}, [s, e]), /* @__PURE__ */ c(Pt, { asChild: !0, children: /* @__PURE__ */ c("select", { ...a, ref: p, defaultValue: e }) });
}
);
st.displayName = "BubbleSelect";
function lt(t) {
const o = ut(t), e = n.useRef(""), a = n.useRef(0), i = n.useCallback(
(s) => {
const l = e.current + s;
o(l), function r(f) {
e.current = f, window.clearTimeout(a.current), f !== "" && (a.current = window.setTimeout(() => r(""), 1e3));
}(l);
},
[o]
), p = n.useCallback(() => {
e.current = "", window.clearTimeout(a.current);
}, []);
return n.useEffect(() => () => window.clearTimeout(a.current), []), [e, i, p];
}
function ct(t, o, e) {
const i = o.length > 1 && Array.from(o).every((f) => f === o[0]) ? o[0] : o, p = e ? t.indexOf(e) : -1;
let s = zt(t, Math.max(p, 0));
i.length === 1 && (s = s.filter((f) => f !== e));
const r = s.find(
(f) => f.textValue.toLowerCase().startsWith(i.toLowerCase())
);
return r !== e ? r : void 0;
}
function zt(t, o) {
return t.map((e, a) => t[(o + a) % t.length]);
}
var Gt = Oe, jt = Le, qt = Ve, Yt = Be, Xt = He, Zt = Fe, Jt = $e, Qt = Ge, eo = qe, to = Xe, Ee = Ze, oo = Qe, no = et, ro = tt, so = nt;
/**
* @license lucide-react v0.488.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const lo = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], at = _e("chevron-down", lo);
/**
* @license lucide-react v0.488.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const co = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]], ao = _e("chevron-up", co), No = Gt, Ro = Qt, Eo = qt, _o = ({
className: t,
children: o,
...e
}) => /* @__PURE__ */ G(
jt,
{
className: j(
"border-input bg-surface-primary ring-offset-surface placeholder:text-muted-foreground focus:ring-ring flex h-10 w-full items-center justify-between rounded-md border px-3 py-2 text-sm focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1 [&>span]:text-left",
t
),
...e,
children: [
o,
/* @__PURE__ */ c(Yt, { asChild: !0, children: /* @__PURE__ */ c(at, { className: "size-4 opacity-50" }) })
]
}
), io = ({
className: t,
...o
}) => /* @__PURE__ */ c(
no,
{
className: j(
"flex cursor-default items-center justify-center py-1",
t
),
...o,
children: /* @__PURE__ */ c(ao, { className: "size-4" })
}
), uo = ({
className: t,
...o
}) => /* @__PURE__ */ c(
ro,
{
className: j(
"flex cursor-default items-center justify-center py-1",
t
),
...o,
children: /* @__PURE__ */ c(at, { className: "size-4" })
}
), Mo = ({
className: t,
children: o,
position: e = "popper",
...a
}) => /* @__PURE__ */ c(Xt, { children: /* @__PURE__ */ G(
Zt,
{
className: j(
"animate-entrance-fade-slide bg-popover text-popover-foreground relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md",
e === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
t
),
position: e,
...a,
children: [
/* @__PURE__ */ c(io, {}),
/* @__PURE__ */ c(
Jt,
{
className: j(
"p-1",
e === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
),
children: o
}
),
/* @__PURE__ */ c(uo, {})
]
}
) }), Ao = ({
className: t,
...o
}) => /* @__PURE__ */ c(
eo,
{
className: j("py-1.5 pr-2 pl-8 text-sm font-semibold", t),
...o
}
), Oo = ({
className: t,
children: o,
itemText: e,
...a
}) => /* @__PURE__ */ G(
to,
{
className: j(
"focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default items-center rounded-xs py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50",
t
),
...a,
children: [
/* @__PURE__ */ c("span", { className: "absolute top-0 left-2 flex h-full w-3.5 items-center justify-center", children: /* @__PURE__ */ c(oo, { children: /* @__PURE__ */ c(it, { className: "size-4" }) }) }),
e ? /* @__PURE__ */ G(de, { children: [
o,
/* @__PURE__ */ c("div", { className: "hidden", children: /* @__PURE__ */ c(Ee, { className: "hidden", children: e }) })
] }) : /* @__PURE__ */ c(Ee, { children: o })
]
}
), Do = ({
className: t,
...o
}) => /* @__PURE__ */ c(
so,
{
className: j("bg-muted -mx-1 my-1 h-px", t),
...o
}
);
export {
No as S,
Ro as a,
Eo as b,
_o as c,
io as d,
uo as e,
Mo as f,
Ao as g,
Oo as h,
Do as i
};