@spear-ai/spectral 1.11.2 → 1.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Combobox.js +90 -85
- package/dist/ControlGroup/ControlGroupSelect.js +1 -1
- package/dist/MultiSelect/MultiSelectBase.js +87 -82
- package/dist/Select.js +58 -55
- package/dist/primitives/select.d.ts.map +1 -1
- package/dist/primitives/select.js +51 -48
- package/dist/styles/spectral.css +1 -1
- package/dist/utils/dropdownPositioning.d.ts +13 -0
- package/dist/utils/dropdownPositioning.d.ts.map +1 -0
- package/dist/utils/dropdownPositioning.js +43 -0
- package/dist/utils/dropdownPositioning.test.d.ts +2 -0
- package/dist/utils/dropdownPositioning.test.d.ts.map +1 -0
- package/dist/utils/dropdownPositioning.test.js +21 -0
- package/package.json +1 -1
package/dist/Combobox.js
CHANGED
|
@@ -3,136 +3,141 @@ import "./styles/main.css";
|
|
|
3
3
|
import { ChevronDownIcon as e } from "./Icons/ChevronDownIcon.js";
|
|
4
4
|
import { LoaderIcon as t } from "./Icons/LoaderIcon.js";
|
|
5
5
|
import { t as n } from "./twUtils-VNWgstKL.js";
|
|
6
|
-
import { EmptyState as ee, ErrorMessage as
|
|
7
|
-
import { useUncontrolledState as
|
|
8
|
-
import { Label as
|
|
9
|
-
import { InputGroup as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
6
|
+
import { EmptyState as ee, ErrorMessage as te, LoadingState as ne, WarningMessage as re, getAriaProps as ie, getDropdownSurfaceClasses as ae, getErrorMessageId as oe, getFormFieldCSSProperties as se, getOptionClasses as ce, getTriggerClasses as r, useFormFieldId as i, useFormFieldState as a } from "./utils/formFieldUtils.js";
|
|
7
|
+
import { useUncontrolledState as o } from "./hooks/useUncontrolledState.js";
|
|
8
|
+
import { Label as s } from "./Label.js";
|
|
9
|
+
import { InputGroup as c, InputGroupAddon as l } from "./primitives/input-group.js";
|
|
10
|
+
import { useAutoDropdownHorizontalShift as u } from "./utils/dropdownPositioning.js";
|
|
11
|
+
import { a as d, i as f, n as p, o as m } from "./ComboboxBase-qX-mQhT6.js";
|
|
12
|
+
import { useCallback as le, useRef as h, useState as g } from "react";
|
|
13
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
13
14
|
//#region src/components/Combobox/Combobox.tsx
|
|
14
|
-
var
|
|
15
|
-
process.env.NODE_ENV !== "production" && !
|
|
16
|
-
let
|
|
17
|
-
value:
|
|
18
|
-
defaultValue:
|
|
19
|
-
onChange:
|
|
20
|
-
}),
|
|
15
|
+
var y = ({ className: y, disabled: ue, defaultValue: de = "", dropdownWidth: b = "trigger", emptyMessage: x = "No options found.", errorMessage: S, id: C, label: w, labelClassName: T, loadingMessage: E = "Loading…", name: D, onValueChange: O, options: k = [], placeholder: A = "Search…", ref: j, required: M, state: N = "default", value: P, warningMessage: F, "aria-describedby": I, "aria-label": L }) => {
|
|
16
|
+
process.env.NODE_ENV !== "production" && !w && !L && console.warn("Combobox: provide either `label` or `aria-label` for an accessible name.");
|
|
17
|
+
let R = h(null), z = h(null), B = i(C, D), V = `${B}-listbox`, H = oe(B), U = `${B}-warning`, fe = N === "error" ? H : N === "warning" && F ? U : void 0, { isDisabled: W, isLoading: G, isInvalid: pe } = a(ue, N), me = ie(N, I, M, fe), [K, q] = g(!1), { dropdownShiftStyle: he, setDropdownElement: ge } = u(K), [J, Y] = g(""), [X, _e] = o({
|
|
18
|
+
value: P,
|
|
19
|
+
defaultValue: de,
|
|
20
|
+
onChange: O
|
|
21
|
+
}), Z = k.find((e) => e.value === X), ve = !!(Z && J.length === 0), Q = b === "trigger" || b === "content" ? b : "custom", $ = {
|
|
21
22
|
maxWidth: "calc(100vw - 2rem)",
|
|
22
23
|
overflowX: "auto",
|
|
23
24
|
overflowY: "auto"
|
|
24
|
-
},
|
|
25
|
+
}, ye = b === "trigger" ? { width: "100%" } : b === "content" ? {
|
|
25
26
|
minWidth: "max-content",
|
|
26
27
|
width: "max-content",
|
|
27
28
|
...$
|
|
28
29
|
} : {
|
|
29
|
-
width:
|
|
30
|
+
width: b,
|
|
30
31
|
...$
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
e.key === "Escape" &&
|
|
35
|
-
},
|
|
32
|
+
}, be = (e) => {
|
|
33
|
+
_e(e === X ? "" : e), Y(""), q(!1);
|
|
34
|
+
}, xe = (e) => {
|
|
35
|
+
e.key === "Escape" && q(!1);
|
|
36
|
+
}, Se = le(() => {
|
|
36
37
|
requestAnimationFrame(() => {
|
|
37
|
-
|
|
38
|
+
z.current?.contains(document.activeElement) || (q(!1), Y(""));
|
|
38
39
|
});
|
|
39
|
-
}, []),
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
id:
|
|
40
|
+
}, []), Ce = () => {
|
|
41
|
+
W || G || (R.current?.focus(), q(!0));
|
|
42
|
+
}, we = () => G ? /* @__PURE__ */ _("div", {
|
|
43
|
+
id: V,
|
|
43
44
|
role: "listbox",
|
|
44
|
-
children: /* @__PURE__ */
|
|
45
|
-
}) :
|
|
46
|
-
id:
|
|
45
|
+
children: /* @__PURE__ */ _(ne, { message: E })
|
|
46
|
+
}) : k.length === 0 ? /* @__PURE__ */ _("div", {
|
|
47
|
+
id: V,
|
|
47
48
|
role: "listbox",
|
|
48
|
-
children: /* @__PURE__ */
|
|
49
|
-
}) : /* @__PURE__ */
|
|
50
|
-
id:
|
|
51
|
-
children: [/* @__PURE__ */
|
|
52
|
-
className: n(
|
|
53
|
-
"data-checked":
|
|
49
|
+
children: /* @__PURE__ */ _(ee, { message: x })
|
|
50
|
+
}) : /* @__PURE__ */ v(d, {
|
|
51
|
+
id: V,
|
|
52
|
+
children: [/* @__PURE__ */ _(p, { children: x }), k.map((e) => /* @__PURE__ */ _(f, {
|
|
53
|
+
className: n(ce(!!e.disabled, !1, X === e.value), "group/command-item relative flex w-full items-center data-[selected=true]:bg-input-bg--hover"),
|
|
54
|
+
"data-checked": X === e.value || void 0,
|
|
54
55
|
disabled: e.disabled,
|
|
55
56
|
onMouseDown: (e) => e.preventDefault(),
|
|
56
|
-
onSelect: () =>
|
|
57
|
+
onSelect: () => be(e.value),
|
|
57
58
|
value: e.label,
|
|
58
|
-
children: /* @__PURE__ */
|
|
59
|
+
children: /* @__PURE__ */ _("span", {
|
|
59
60
|
className: "min-w-0 flex-1 truncate whitespace-nowrap",
|
|
60
61
|
children: e.label
|
|
61
62
|
})
|
|
62
63
|
}, e.value))]
|
|
63
64
|
});
|
|
64
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ v("div", {
|
|
65
66
|
className: "w-full",
|
|
66
|
-
ref:
|
|
67
|
+
ref: j,
|
|
67
68
|
children: [
|
|
68
|
-
|
|
69
|
+
D && /* @__PURE__ */ _("input", {
|
|
69
70
|
type: "hidden",
|
|
70
|
-
name:
|
|
71
|
-
value:
|
|
72
|
-
disabled:
|
|
71
|
+
name: D,
|
|
72
|
+
value: X,
|
|
73
|
+
disabled: W
|
|
73
74
|
}),
|
|
74
|
-
|
|
75
|
-
className: n("mb-2 block text-text-primary",
|
|
75
|
+
w && /* @__PURE__ */ _(s, {
|
|
76
|
+
className: n("mb-2 block text-text-primary", T, W && "text-text-secondary"),
|
|
76
77
|
"data-testid": "spectral-combobox-label",
|
|
77
|
-
htmlFor:
|
|
78
|
-
children:
|
|
78
|
+
htmlFor: B,
|
|
79
|
+
children: w
|
|
79
80
|
}),
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
ref:
|
|
82
|
-
label:
|
|
83
|
-
onKeyDown:
|
|
81
|
+
/* @__PURE__ */ v(m, {
|
|
82
|
+
ref: z,
|
|
83
|
+
label: L ?? w,
|
|
84
|
+
onKeyDown: xe,
|
|
84
85
|
className: "relative w-full",
|
|
85
|
-
children: [/* @__PURE__ */
|
|
86
|
+
children: [/* @__PURE__ */ v(c, {
|
|
86
87
|
"data-slot": "combobox-content",
|
|
87
|
-
"data-state":
|
|
88
|
+
"data-state": N,
|
|
88
89
|
"data-testid": "spectral-combobox-trigger",
|
|
89
|
-
className: n(
|
|
90
|
-
onClick:
|
|
91
|
-
style:
|
|
92
|
-
children: [/* @__PURE__ */
|
|
93
|
-
ref:
|
|
90
|
+
className: n(r(K, N), "ring-0!", W && "pointer-events-none cursor-not-allowed", y),
|
|
91
|
+
onClick: Ce,
|
|
92
|
+
style: se(),
|
|
93
|
+
children: [/* @__PURE__ */ _(m.Input, {
|
|
94
|
+
ref: R,
|
|
94
95
|
autoComplete: "off",
|
|
95
96
|
"data-slot": "input-group-control",
|
|
96
|
-
"aria-controls":
|
|
97
|
-
"aria-expanded":
|
|
98
|
-
"aria-label":
|
|
99
|
-
className: "min-w-0 px-3 py-1 text-base flex-1 truncate overflow-hidden border-0 bg-transparent whitespace-nowrap text-input-text outline-hidden placeholder:
|
|
100
|
-
disabled:
|
|
101
|
-
id:
|
|
102
|
-
onBlur:
|
|
103
|
-
onFocus: () => !
|
|
104
|
-
onValueChange:
|
|
105
|
-
placeholder:
|
|
97
|
+
"aria-controls": V,
|
|
98
|
+
"aria-expanded": K,
|
|
99
|
+
"aria-label": L ?? w,
|
|
100
|
+
className: n("min-w-0 px-3 py-1 text-base flex-1 truncate overflow-hidden border-0 bg-transparent whitespace-nowrap text-input-text outline-hidden placeholder:opacity-100 focus-visible:ring-0 focus-visible:outline-none", ve ? "placeholder:text-input-text!" : "placeholder:text-input-text-placeholder!"),
|
|
101
|
+
disabled: W,
|
|
102
|
+
id: B,
|
|
103
|
+
onBlur: Se,
|
|
104
|
+
onFocus: () => !W && !G && q(!0),
|
|
105
|
+
onValueChange: Y,
|
|
106
|
+
placeholder: Z?.label ?? A,
|
|
106
107
|
role: "combobox",
|
|
107
|
-
value:
|
|
108
|
-
...
|
|
109
|
-
}), /* @__PURE__ */
|
|
108
|
+
value: J,
|
|
109
|
+
...me
|
|
110
|
+
}), /* @__PURE__ */ _(l, {
|
|
110
111
|
align: "inline-end",
|
|
111
112
|
className: "cursor-pointer",
|
|
112
|
-
children:
|
|
113
|
+
children: G ? /* @__PURE__ */ _(t, { className: "size-5 motion-safe:animate-spin" }) : /* @__PURE__ */ _(e, { className: n("size-5 shrink-0 transition-transform duration-200", K && "rotate-180") })
|
|
113
114
|
})]
|
|
114
|
-
}), /* @__PURE__ */
|
|
115
|
-
className: n("left-0 mt-1 p-1 absolute top-full z-50 w-full",
|
|
115
|
+
}), /* @__PURE__ */ _("div", {
|
|
116
|
+
className: n("left-0 mt-1 p-1 absolute top-full z-50 w-full", ae(), "motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-2 motion-safe:zoom-in-95", !K && "hidden"),
|
|
116
117
|
"data-dropdown-width-mode": Q,
|
|
117
|
-
"data-dropdown-width-value": Q === "custom" ?
|
|
118
|
+
"data-dropdown-width-value": Q === "custom" ? b : void 0,
|
|
118
119
|
"data-testid": "spectral-combobox-content",
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
ref: ge,
|
|
121
|
+
style: {
|
|
122
|
+
...ye,
|
|
123
|
+
...he
|
|
124
|
+
},
|
|
125
|
+
children: we()
|
|
121
126
|
})]
|
|
122
127
|
}),
|
|
123
|
-
|
|
128
|
+
pe && S && /* @__PURE__ */ _(te, {
|
|
124
129
|
dataTestId: "spectral-combobox-error-message",
|
|
125
|
-
id:
|
|
126
|
-
message:
|
|
130
|
+
id: H,
|
|
131
|
+
message: S
|
|
127
132
|
}),
|
|
128
|
-
|
|
133
|
+
N === "warning" && F && /* @__PURE__ */ _(re, {
|
|
129
134
|
dataTestId: "spectral-combobox-warning-message",
|
|
130
|
-
id:
|
|
131
|
-
message:
|
|
135
|
+
id: U,
|
|
136
|
+
message: F
|
|
132
137
|
})
|
|
133
138
|
]
|
|
134
139
|
});
|
|
135
140
|
};
|
|
136
|
-
|
|
141
|
+
y.displayName = "Combobox";
|
|
137
142
|
//#endregion
|
|
138
|
-
export {
|
|
143
|
+
export { y as Combobox };
|
|
@@ -81,7 +81,7 @@ var g = "placeholder:text-small! [appearance:textfield] [&::-webkit-inner-spin-b
|
|
|
81
81
|
id: B ? L : void 0,
|
|
82
82
|
style: R ? { minWidth: R } : void 0,
|
|
83
83
|
children: /* @__PURE__ */ m(c, {
|
|
84
|
-
className: "min-w-0 block max-w-full truncate text-left whitespace-nowrap text-input-text! data-placeholder:text-input-text!",
|
|
84
|
+
className: "min-w-0 block max-w-full truncate text-left whitespace-nowrap text-input-text! data-placeholder:text-input-text-placeholder!",
|
|
85
85
|
placeholder: j
|
|
86
86
|
})
|
|
87
87
|
});
|
|
@@ -8,17 +8,18 @@ import { SearchIcon as i } from "../Icons/SearchIcon.js";
|
|
|
8
8
|
import { t as a } from "../twUtils-VNWgstKL.js";
|
|
9
9
|
import { ErrorMessage as o, getDropdownSurfaceClasses as s } from "../utils/formFieldUtils.js";
|
|
10
10
|
import { useUncontrolledState as c } from "../hooks/useUncontrolledState.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { useAutoDropdownHorizontalShift as l } from "../utils/dropdownPositioning.js";
|
|
12
|
+
import { a as u, i as d, n as f, r as ee } from "../dist-BtdmHAzK.js";
|
|
13
|
+
import { useCallback as p, useEffect as te, useId as ne, useMemo as m, useRef as re, useState as h } from "react";
|
|
14
|
+
import { Fragment as ie, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
14
15
|
//#region src/components/MultiSelect/MultiSelectBase.tsx
|
|
15
|
-
var
|
|
16
|
+
var v = "h-4 w-4", y = (e) => ({
|
|
16
17
|
error: "border-danger hover:border-danger focus-visible:border-danger focus-visible:ring-danger",
|
|
17
18
|
loading: "cursor-wait border-input-border--disabled",
|
|
18
19
|
disabled: "cursor-not-allowed opacity-50 border-input-border--disabled bg-input-bg--disabled",
|
|
19
20
|
default: ""
|
|
20
|
-
})[e],
|
|
21
|
-
let [l, u] =
|
|
21
|
+
})[e], b = (e, t, n) => a("min-h-12 rounded-lg px-4 py-2 text-sm flex max-h-[5.5rem] w-full items-center justify-between border border-input-border bg-input-bg", "hover:border-input-border--hover focus-visible:border-input-border--focus", "focus:outline-none focus-visible:outline focus-visible:outline-offset-2 focus-visible:outline-accent", "disabled:cursor-not-allowed disabled:border-input-border--disabled disabled:bg-input-bg--disabled disabled:opacity-50", "overflow-hidden text-input-text transition duration-200", t && "border-input-border--focus", y(e), n), ae = () => a("max-h-80 z-50 overflow-hidden", s(), "motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=open]:animate-in", "motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:fade-in-0", "motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:zoom-in-95", "motion-safe:data-[side=bottom]:slide-in-from-top-2", "motion-safe:data-[side=top]:slide-in-from-bottom-2", "origin-(--radix-popover-content-transform-origin)"), oe = (e, t, n, r, i, a, o, s, c) => {
|
|
22
|
+
let [l, u] = h(-1), d = m(() => {
|
|
22
23
|
let t = [];
|
|
23
24
|
return o && t.push({ type: "search" }), s && t.push({ type: "select-all" }), e.forEach((e, n) => {
|
|
24
25
|
e.disabled || t.push({
|
|
@@ -97,23 +98,23 @@ var re = "h-4 w-4", y = (e) => ({
|
|
|
97
98
|
let t = d[l];
|
|
98
99
|
return t.type === "option" && t.index === e;
|
|
99
100
|
}, [l, d]),
|
|
100
|
-
isSearchFocused:
|
|
101
|
-
isSelectAllFocused:
|
|
102
|
-
isClearAllFocused:
|
|
101
|
+
isSearchFocused: m(() => l < 0 || l >= d.length ? !1 : d[l].type === "search", [l, d]),
|
|
102
|
+
isSelectAllFocused: m(() => l < 0 || l >= d.length ? !1 : d[l].type === "select-all", [l, d]),
|
|
103
|
+
isClearAllFocused: m(() => l < 0 || l >= d.length ? !1 : d[l].type === "clear-all", [l, d])
|
|
103
104
|
};
|
|
104
|
-
},
|
|
105
|
-
let P =
|
|
106
|
-
value:
|
|
105
|
+
}, x = ({ className: s, clearAllLabel: y = "Clear all", closeOnSelect: x = !1, dropdownWidth: S = "trigger", emptyMessage: se = "No options found", errorMessage: C, defaultValue: ce = [], id: le, label: ue, loadingMessage: de = "Loading options…", maxCount: w = 3, name: T, onChange: fe, options: E = [], placeholder: D = "Select options", ref: pe, searchPlaceholder: me = "Search options…", selectAllLabel: he = "Select all", showClearAll: ge = !0, showSearch: O = !0, showSelectAll: k = !0, sortAlphabetically: A = !1, state: j = "default", value: _e, "aria-label": ve, "aria-describedby": M, ...N }) => {
|
|
106
|
+
let P = ne(), F = le ?? `${T}-${P}`, I = `${F}-listbox`, L = `${F}-error`, [R, z] = h(!1), { dropdownShiftStyle: ye, setDropdownElement: be } = l(R), [B, xe] = h(""), [V, H] = c({
|
|
107
|
+
value: _e,
|
|
107
108
|
defaultValue: ce,
|
|
108
|
-
onChange:
|
|
109
|
-
}), U =
|
|
109
|
+
onChange: fe
|
|
110
|
+
}), U = re(null), W = N.disabled ?? j === "disabled", Se = j === "loading", Ce = j === "error", we = S === "trigger" ? "var(--radix-popover-trigger-width)" : S === "content" ? "max-content" : S, G = S === "trigger" || S === "content" ? S : "custom", K = m(() => {
|
|
110
111
|
let e = E.filter((e) => e.label.toLowerCase().includes(B.toLowerCase()));
|
|
111
|
-
return
|
|
112
|
+
return A && (e = [...e].sort((e, t) => e.label.localeCompare(t.label))), e;
|
|
112
113
|
}, [
|
|
113
114
|
E,
|
|
114
115
|
B,
|
|
115
|
-
|
|
116
|
-
]), q =
|
|
116
|
+
A
|
|
117
|
+
]), q = m(() => {
|
|
117
118
|
let e = {}, t = [];
|
|
118
119
|
return K.forEach((n) => {
|
|
119
120
|
n.group ? (e[n.group] || (e[n.group] = []), e[n.group].push(n)) : t.push(n);
|
|
@@ -123,9 +124,9 @@ var re = "h-4 w-4", y = (e) => ({
|
|
|
123
124
|
hasGroups: Object.keys(e).length > 0
|
|
124
125
|
};
|
|
125
126
|
}, [K]), J = p((e) => {
|
|
126
|
-
E.find((t) => t.value === e)?.disabled || (H(V.includes(e) ? V.filter((t) => t !== e) : [...V, e]),
|
|
127
|
+
E.find((t) => t.value === e)?.disabled || (H(V.includes(e) ? V.filter((t) => t !== e) : [...V, e]), x && z(!1));
|
|
127
128
|
}, [
|
|
128
|
-
|
|
129
|
+
x,
|
|
129
130
|
E,
|
|
130
131
|
H,
|
|
131
132
|
V
|
|
@@ -138,28 +139,28 @@ var re = "h-4 w-4", y = (e) => ({
|
|
|
138
139
|
V
|
|
139
140
|
]), X = p(() => {
|
|
140
141
|
H([]);
|
|
141
|
-
}, [H]), Z =
|
|
142
|
-
|
|
142
|
+
}, [H]), Z = m(() => E.filter((e) => !e.disabled).map((e) => e.value), [E]), Te = Z.length > 0 && Z.every((e) => V.includes(e)), { getOptionFocusIndex: Ee, handleKeyDown: De, isSelectAllFocused: Oe, setFocusedIndex: Q } = oe(K, X, () => z(!1), J, Y, U, O, k, !1);
|
|
143
|
+
te(() => {
|
|
143
144
|
Q(R ? 0 : -1);
|
|
144
145
|
}, [R, Q]);
|
|
145
|
-
let
|
|
146
|
-
|
|
147
|
-
}, []),
|
|
148
|
-
if (V.length === 0) return /* @__PURE__ */
|
|
146
|
+
let ke = p((e) => {
|
|
147
|
+
xe(e.target.value);
|
|
148
|
+
}, []), Ae = () => {
|
|
149
|
+
if (V.length === 0) return /* @__PURE__ */ g("span", {
|
|
149
150
|
className: "min-h-8 flex items-center text-input-text-placeholder",
|
|
150
151
|
children: D
|
|
151
152
|
});
|
|
152
153
|
let e = V.slice(0, w), t = V.length - w;
|
|
153
|
-
return /* @__PURE__ */
|
|
154
|
+
return /* @__PURE__ */ _("div", {
|
|
154
155
|
className: "gap-1 flex flex-wrap items-center overflow-hidden",
|
|
155
156
|
children: [e.map((e) => {
|
|
156
157
|
let t = E.find((t) => t.value === e);
|
|
157
|
-
return t ? /* @__PURE__ */
|
|
158
|
+
return t ? /* @__PURE__ */ _("span", {
|
|
158
159
|
className: "gap-1 px-2 py-1 rounded-md text-xs max-w-48 inline-flex items-center bg-input-bg--selected text-input-text",
|
|
159
|
-
children: [/* @__PURE__ */
|
|
160
|
+
children: [/* @__PURE__ */ g("span", {
|
|
160
161
|
className: "truncate",
|
|
161
162
|
children: t.label
|
|
162
|
-
}), /* @__PURE__ */
|
|
163
|
+
}), /* @__PURE__ */ g("button", {
|
|
163
164
|
"aria-label": `Remove ${t.label}`,
|
|
164
165
|
className: "hover:text-danger rounded-sm cursor-pointer",
|
|
165
166
|
"data-testid": "spectral-multiselect-remove-item-button",
|
|
@@ -170,10 +171,10 @@ var re = "h-4 w-4", y = (e) => ({
|
|
|
170
171
|
e.stopPropagation();
|
|
171
172
|
},
|
|
172
173
|
type: "button",
|
|
173
|
-
children: /* @__PURE__ */
|
|
174
|
+
children: /* @__PURE__ */ g(n, { size: 12 })
|
|
174
175
|
})]
|
|
175
176
|
}, e) : null;
|
|
176
|
-
}), t > 0 && /* @__PURE__ */
|
|
177
|
+
}), t > 0 && /* @__PURE__ */ _("span", {
|
|
177
178
|
className: "text-input-text-secondary text-xs py-1 flex items-center",
|
|
178
179
|
children: [
|
|
179
180
|
"+",
|
|
@@ -184,66 +185,66 @@ var re = "h-4 w-4", y = (e) => ({
|
|
|
184
185
|
});
|
|
185
186
|
}, $ = (t, n) => {
|
|
186
187
|
let r = V.includes(t.value);
|
|
187
|
-
return /* @__PURE__ */
|
|
188
|
-
className: a("gap-3 px-3 py-2 text-sm flex w-full items-center text-left hover:bg-input-bg--hover focus-visible:bg-input-bg--hover focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
188
|
+
return /* @__PURE__ */ _("button", {
|
|
189
|
+
className: a("gap-3 px-3 py-2 text-sm flex w-full items-center text-left hover:bg-input-bg--hover focus-visible:bg-input-bg--hover focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50", Ee(n) && "bg-input-bg--hover", r && "font-medium text-input-text"),
|
|
189
190
|
disabled: t.disabled,
|
|
190
191
|
onClick: () => J(t.value),
|
|
191
192
|
type: "button",
|
|
192
|
-
children: [/* @__PURE__ */
|
|
193
|
+
children: [/* @__PURE__ */ g("div", {
|
|
193
194
|
"data-testid": "spectral-multiselect-selected-indicator",
|
|
194
195
|
className: a("w-4 h-4 rounded flex items-center justify-center border border-input-border", r && "bg-primary border-primary"),
|
|
195
|
-
children: r && /* @__PURE__ */
|
|
196
|
-
}), /* @__PURE__ */
|
|
196
|
+
children: r && /* @__PURE__ */ g(e, { size: 12 })
|
|
197
|
+
}), /* @__PURE__ */ g("span", { children: t.label })]
|
|
197
198
|
}, t.value);
|
|
198
|
-
},
|
|
199
|
+
}, je = () => ({
|
|
199
200
|
"--multiselect-border-radius": "0.5rem",
|
|
200
201
|
"--multiselect-trigger-height": "3rem",
|
|
201
202
|
"--multiselect-dropdown-max-height": "20rem"
|
|
202
203
|
});
|
|
203
|
-
return /* @__PURE__ */
|
|
204
|
+
return /* @__PURE__ */ _("div", {
|
|
204
205
|
className: "w-full",
|
|
205
206
|
"data-testid": "spectral-multiselect-root",
|
|
206
|
-
children: [/* @__PURE__ */
|
|
207
|
+
children: [/* @__PURE__ */ g(d, {
|
|
207
208
|
open: R,
|
|
208
209
|
onOpenChange: z,
|
|
209
|
-
children: /* @__PURE__ */
|
|
210
|
+
children: /* @__PURE__ */ _("div", {
|
|
210
211
|
className: "relative",
|
|
211
212
|
"data-testid": "spectral-multiselect-wrapper",
|
|
212
|
-
onKeyDown: R ?
|
|
213
|
+
onKeyDown: R ? De : void 0,
|
|
213
214
|
role: "none",
|
|
214
215
|
children: [
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ g(u, {
|
|
216
217
|
asChild: !0,
|
|
217
|
-
children: /* @__PURE__ */
|
|
218
|
+
children: /* @__PURE__ */ _("button", {
|
|
218
219
|
"aria-controls": R ? I : void 0,
|
|
219
|
-
"aria-describedby": [
|
|
220
|
+
"aria-describedby": [Ce ? L : null, M].filter(Boolean).join(" ") || void 0,
|
|
220
221
|
"aria-expanded": R,
|
|
221
|
-
"aria-label":
|
|
222
|
-
className:
|
|
223
|
-
"data-state":
|
|
222
|
+
"aria-label": ve ?? ue,
|
|
223
|
+
className: b(j, R, s),
|
|
224
|
+
"data-state": j,
|
|
224
225
|
"data-testid": "spectral-multiselect-trigger",
|
|
225
226
|
disabled: W,
|
|
226
227
|
id: F,
|
|
227
228
|
name: T,
|
|
228
|
-
ref:
|
|
229
|
+
ref: pe,
|
|
229
230
|
role: "combobox",
|
|
230
|
-
style:
|
|
231
|
+
style: je(),
|
|
231
232
|
type: "button",
|
|
232
233
|
...N,
|
|
233
|
-
children: [/* @__PURE__ */
|
|
234
|
+
children: [/* @__PURE__ */ g("div", {
|
|
234
235
|
className: "min-w-0 flex-1 overflow-hidden",
|
|
235
236
|
"data-testid": "spectral-multiselect-selected-items",
|
|
236
|
-
children:
|
|
237
|
-
}), /* @__PURE__ */
|
|
237
|
+
children: Ae()
|
|
238
|
+
}), /* @__PURE__ */ g("div", {
|
|
238
239
|
className: "gap-2 ml-2 flex shrink-0 items-center",
|
|
239
|
-
children: /* @__PURE__ */
|
|
240
|
+
children: /* @__PURE__ */ g(t, {
|
|
240
241
|
className: a("text-input-icon transition-transform duration-200", R && "rotate-180"),
|
|
241
242
|
size: 20
|
|
242
243
|
})
|
|
243
244
|
})]
|
|
244
245
|
})
|
|
245
246
|
}),
|
|
246
|
-
|
|
247
|
+
ge && V.length > 0 && /* @__PURE__ */ g("button", {
|
|
247
248
|
"aria-label": "Clear all selections",
|
|
248
249
|
className: "right-10 text-input-icon hover:text-input-icon--hover rounded-sm absolute top-1/2 z-10 -translate-y-1/2 cursor-pointer focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-1 disabled:pointer-events-none disabled:opacity-50",
|
|
249
250
|
"data-testid": "spectral-multiselect-clear-all-button",
|
|
@@ -252,70 +253,74 @@ var re = "h-4 w-4", y = (e) => ({
|
|
|
252
253
|
e.stopPropagation(), X(), document.getElementById(F)?.focus();
|
|
253
254
|
},
|
|
254
255
|
type: "button",
|
|
255
|
-
children: /* @__PURE__ */
|
|
256
|
+
children: /* @__PURE__ */ g(n, { size: 12 })
|
|
256
257
|
}),
|
|
257
|
-
/* @__PURE__ */
|
|
258
|
+
/* @__PURE__ */ g(ee, { children: /* @__PURE__ */ g(f, {
|
|
258
259
|
align: "start",
|
|
259
260
|
avoidCollisions: !0,
|
|
260
261
|
className: ae(),
|
|
261
262
|
collisionPadding: 10,
|
|
262
263
|
"data-dropdown-width-mode": G,
|
|
263
|
-
"data-dropdown-width-value": G === "custom" ?
|
|
264
|
+
"data-dropdown-width-value": G === "custom" ? S : void 0,
|
|
264
265
|
"data-testid": "spectral-multiselect-dropdown",
|
|
265
266
|
onOpenAutoFocus: (e) => {
|
|
266
|
-
e.preventDefault(),
|
|
267
|
+
e.preventDefault(), O && U.current?.focus();
|
|
267
268
|
},
|
|
268
269
|
side: "bottom",
|
|
269
270
|
sideOffset: 4,
|
|
270
|
-
|
|
271
|
-
|
|
271
|
+
ref: be,
|
|
272
|
+
style: {
|
|
273
|
+
width: we,
|
|
274
|
+
...ye
|
|
275
|
+
},
|
|
276
|
+
children: /* @__PURE__ */ _("div", {
|
|
272
277
|
className: "p-1",
|
|
273
|
-
children: [
|
|
278
|
+
children: [O && /* @__PURE__ */ _("div", {
|
|
274
279
|
className: "mb-2 relative",
|
|
275
|
-
children: [/* @__PURE__ */
|
|
280
|
+
children: [/* @__PURE__ */ g(i, { className: a(v, "left-3 text-input-icon absolute top-1/2 -translate-y-1/2") }), /* @__PURE__ */ g("input", {
|
|
276
281
|
"aria-label": "Search options",
|
|
277
282
|
className: "pl-9 pr-3 py-2 text-sm rounded-md focus-visible:ring-black w-full border border-input-border bg-input-bg focus-visible:border-input-border--focus focus-visible:ring-1 focus-visible:outline-none",
|
|
278
283
|
"data-testid": "spectral-multiselect-search-input",
|
|
279
|
-
onChange:
|
|
280
|
-
placeholder:
|
|
284
|
+
onChange: ke,
|
|
285
|
+
placeholder: me,
|
|
281
286
|
ref: U,
|
|
282
287
|
type: "text",
|
|
283
288
|
value: B
|
|
284
289
|
})]
|
|
285
|
-
}), /* @__PURE__ */
|
|
290
|
+
}), /* @__PURE__ */ g("div", {
|
|
286
291
|
className: "max-h-64 overflow-y-auto",
|
|
287
292
|
id: I,
|
|
288
293
|
role: "listbox",
|
|
289
294
|
"aria-multiselectable": "true",
|
|
290
|
-
children:
|
|
295
|
+
children: Se ? /* @__PURE__ */ _("div", {
|
|
291
296
|
"data-testid": "spectral-multiselect-loading",
|
|
292
297
|
className: "gap-2 py-6 text-sm text-input-text-secondary flex items-center justify-center",
|
|
293
|
-
children: [/* @__PURE__ */
|
|
294
|
-
}) : K.length === 0 ? /* @__PURE__ */
|
|
298
|
+
children: [/* @__PURE__ */ g(r, {}), de]
|
|
299
|
+
}) : K.length === 0 ? /* @__PURE__ */ g("div", {
|
|
295
300
|
"data-testid": "spectral-multiselect-empty-message",
|
|
296
301
|
className: "py-6 text-sm text-input-text-secondary text-center",
|
|
297
302
|
children: se
|
|
298
|
-
}) : /* @__PURE__ */
|
|
299
|
-
|
|
303
|
+
}) : /* @__PURE__ */ _(ie, { children: [
|
|
304
|
+
k && /* @__PURE__ */ _("div", {
|
|
300
305
|
className: "mb-1",
|
|
301
|
-
children: [/* @__PURE__ */
|
|
302
|
-
className: a("gap-3 px-3 py-2 text-sm font-medium text-input-text-secondary flex w-full items-center hover:bg-input-bg--hover focus:outline-none",
|
|
306
|
+
children: [/* @__PURE__ */ g("button", {
|
|
307
|
+
className: a("gap-3 px-3 py-2 text-sm font-medium text-input-text-secondary flex w-full items-center hover:bg-input-bg--hover focus:outline-none", Oe && "bg-input-bg--hover"),
|
|
303
308
|
"data-testid": "spectral-multiselect-select-all-button",
|
|
304
309
|
onClick: Y,
|
|
305
310
|
type: "button",
|
|
306
|
-
children:
|
|
307
|
-
}), /* @__PURE__ */
|
|
311
|
+
children: Te ? y : he
|
|
312
|
+
}), /* @__PURE__ */ g("div", { className: "mx-3 my-1 h-px bg-input-border" })]
|
|
308
313
|
}),
|
|
309
|
-
q.ungrouped.length > 0 && /* @__PURE__ */
|
|
314
|
+
q.ungrouped.length > 0 && /* @__PURE__ */ g("div", {
|
|
310
315
|
className: "mb-1",
|
|
311
316
|
children: q.ungrouped.map((e, t) => $(e, t))
|
|
312
317
|
}),
|
|
313
|
-
Object.entries(q.groups).map(([e, t]) => /* @__PURE__ */
|
|
318
|
+
Object.entries(q.groups).map(([e, t]) => /* @__PURE__ */ _("div", {
|
|
314
319
|
className: "mb-1",
|
|
315
320
|
"data-testid": "spectral-multiselect-group",
|
|
316
321
|
children: [
|
|
317
|
-
(q.ungrouped.length > 0 || Object.keys(q.groups).indexOf(e) > 0) && /* @__PURE__ */
|
|
318
|
-
/* @__PURE__ */
|
|
322
|
+
(q.ungrouped.length > 0 || Object.keys(q.groups).indexOf(e) > 0) && /* @__PURE__ */ g("div", { className: "mx-3 my-1 h-px bg-input-border" }),
|
|
323
|
+
/* @__PURE__ */ g("div", {
|
|
319
324
|
"data-testid": "spectral-multiselect-group-name",
|
|
320
325
|
className: "px-3 py-1 text-xs font-semibold text-input-text-secondary tracking-wide uppercase",
|
|
321
326
|
children: e
|
|
@@ -329,13 +334,13 @@ var re = "h-4 w-4", y = (e) => ({
|
|
|
329
334
|
}) })
|
|
330
335
|
]
|
|
331
336
|
})
|
|
332
|
-
}),
|
|
337
|
+
}), j === "error" && C && /* @__PURE__ */ g(o, {
|
|
333
338
|
dataTestId: "spectral-multiselect-error-message",
|
|
334
339
|
id: L,
|
|
335
|
-
message:
|
|
340
|
+
message: C
|
|
336
341
|
})]
|
|
337
342
|
});
|
|
338
343
|
};
|
|
339
|
-
|
|
344
|
+
x.displayName = "MultiSelectBase";
|
|
340
345
|
//#endregion
|
|
341
|
-
export {
|
|
346
|
+
export { x as MultiSelectBase };
|