@spear-ai/spectral 1.12.6 → 1.13.1
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/.js +41 -38
- package/dist/Button.d.ts +1 -1
- package/dist/Button.js +46 -45
- package/dist/Checkbox.js +6 -5
- package/dist/{Combobox-DCCcIDgq.js → Combobox-DRQqx0os.js} +9 -8
- package/dist/Combobox.js +1 -1
- package/dist/ControlGroup/ControlGroupSelect.d.ts +5 -1
- package/dist/ControlGroup/ControlGroupSelect.js +73 -67
- package/dist/ControlGroup.js +29 -24
- package/dist/DateTimePicker/TimePeriodSelect.js +1 -1
- package/dist/DateTimePicker.js +8 -7
- package/dist/DropdownMenu-BO_RPCVU.js +870 -0
- package/dist/DropdownMenu.d.ts +3 -2
- package/dist/DropdownMenu.js +2 -868
- package/dist/FormFieldMessage.d.ts +11 -0
- package/dist/FormFieldMessage.js +55 -0
- package/dist/Input.d.ts +1 -0
- package/dist/Input.js +68 -67
- package/dist/InputNumeric.js +3 -14
- package/dist/{InputOTP-DyhesOLs.js → InputOTP-DLn7ja7J.js} +5 -4
- package/dist/InputOTP.js +1 -1
- package/dist/MultiSelect/MultiSelectBase.js +105 -104
- package/dist/RadioButtonGroup/RadioButtonGroupBase.d.ts +2 -2
- package/dist/{RadioGroup-BsBK247l.js → RadioGroup-D-XjCU4Q.js} +33 -28
- package/dist/RadioGroup.js +1 -1
- package/dist/Select.js +21 -20
- package/dist/{Switch-Vep4hsq4.js → Switch-CSmXtkia.js} +26 -25
- package/dist/Switch.js +1 -1
- package/dist/Textarea/TextareaUtils.js +4 -8
- package/dist/Textarea.js +23 -22
- package/dist/Toggle.js +1 -1
- package/dist/ToggleGroup/ToggleGroup.context.d.ts +9 -0
- package/dist/ToggleGroup/ToggleGroup.context.js +11 -0
- package/dist/ToggleGroup/ToggleGroupItem.d.ts +15 -0
- package/dist/ToggleGroup/ToggleGroupItem.js +35 -0
- package/dist/ToggleGroup/ToggleGroupSplitMenuItem.d.ts +22 -0
- package/dist/ToggleGroup/ToggleGroupSplitMenuItem.js +114 -0
- package/dist/ToggleGroup.d.ts +6 -14
- package/dist/ToggleGroup.js +24 -46
- package/dist/Tooltip.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/primitives/select.d.ts +1 -1
- package/dist/primitives/select.d.ts.map +1 -1
- package/dist/primitives/select.js +1 -1
- package/dist/primitives/textarea.js +1 -1
- package/dist/{select-oAOoVl5g.js → select-DFE8xm1L.js} +230 -259
- package/dist/styles/spectral.css +1 -1
- package/dist/utils/formFieldUtils.d.ts +1 -13
- package/dist/utils/formFieldUtils.d.ts.map +1 -1
- package/dist/utils/formFieldUtils.js +48 -69
- package/package.json +1 -1
- /package/dist/{Tooltip-vEdD4f2U.js → Tooltip-CTjKOfvC.js} +0 -0
|
@@ -5,15 +5,16 @@ import { ChevronDownIcon as t } from "../Icons/ChevronDownIcon.js";
|
|
|
5
5
|
import { CloseIcon as n } from "../Icons/CloseIcon.js";
|
|
6
6
|
import { SearchIcon as r } from "../Icons/SearchIcon.js";
|
|
7
7
|
import { t as i } from "../twUtils-BpqlKSeB.js";
|
|
8
|
-
import {
|
|
8
|
+
import { ErrorMessage as a, WarningMessage as o } from "../FormFieldMessage.js";
|
|
9
|
+
import { EmptyState as s, LoadingState as c, getAriaProps as l, getDropdownSurfaceClasses as u, getDropdownWidthStyles as d, getErrorMessageId as f, getTriggerClasses as ee, useFormFieldId as te } from "../utils/formFieldUtils.js";
|
|
9
10
|
import { useUncontrolledState as ne } from "../hooks/useUncontrolledState.js";
|
|
10
11
|
import { Label as re } from "../Label.js";
|
|
11
12
|
import { useAutoDropdownHorizontalShift as ie } from "../utils/dropdownPositioning.js";
|
|
12
13
|
import { a as ae, i as oe, n as se, r as ce } from "../dist-B9w6c9RC.js";
|
|
13
14
|
import { useCallback as p, useEffect as le, useId as ue, useMemo as m, useRef as de, useState as h } from "react";
|
|
14
|
-
import { Fragment as
|
|
15
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
15
16
|
//#region src/components/MultiSelect/MultiSelectBase.tsx
|
|
16
|
-
var
|
|
17
|
+
var fe = "h-4 w-4", pe = () => i("max-h-80 z-50 overflow-hidden", u(), "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)"), me = (e, t, n, r, i, a, o, s, c) => {
|
|
17
18
|
let [l, u] = h(-1), d = m(() => {
|
|
18
19
|
let t = [];
|
|
19
20
|
return o && t.push({ type: "search" }), s && t.push({ type: "select-all" }), e.forEach((e, n) => {
|
|
@@ -102,21 +103,21 @@ var pe = "h-4 w-4", me = () => i("max-h-80 z-50 overflow-hidden", u(), "motion-s
|
|
|
102
103
|
return e.type === "option" ? e.value : null;
|
|
103
104
|
}, [l, d])
|
|
104
105
|
};
|
|
105
|
-
},
|
|
106
|
-
let
|
|
107
|
-
value:
|
|
106
|
+
}, y = ({ className: u, clearAllLabel: y = "Clear all", closeOnSelect: b = !1, dropdownWidth: x = "trigger", emptyMessage: he = "No options found", errorMessage: ge, defaultValue: _e = [], disabled: ve, id: S, label: C, loadingMessage: ye = "Loading options…", maxCount: w = 3, name: T, onChange: be, options: E = [], placeholder: xe = "Select options", ref: Se, searchPlaceholder: Ce = "Search options…", selectAllLabel: we = "Select all", showClearAll: Te = !0, showSearch: D = !0, showSelectAll: O = !0, sortAlphabetically: k = !1, state: A = "default", value: Ee, warningMessage: j, "aria-label": De, "aria-describedby": Oe, ...M }) => {
|
|
107
|
+
let ke = ue(), N = te(S, T ?? `multiselect-${ke}`), P = `${N}-listbox`, F = f(N), I = `${N}-warning`, Ae = A === "error" ? F : A === "warning" && j ? I : void 0, [L, R] = h(!1), { dropdownShiftStyle: je, setDropdownElement: Me } = ie(L), [z, Ne] = h(""), [B, V] = ne({
|
|
108
|
+
value: Ee,
|
|
108
109
|
defaultValue: _e,
|
|
109
|
-
onChange:
|
|
110
|
-
}), H = de(null), U = !!ve, Pe =
|
|
111
|
-
dropdownWidth:
|
|
110
|
+
onChange: be
|
|
111
|
+
}), H = de(null), U = !!ve, Pe = A === "loading", Fe = l(A, Oe, M.required, Ae), { dropdownOverflowStyle: Ie, dropdownWidthMode: W, resolvedDropdownWidth: Le } = d({
|
|
112
|
+
dropdownWidth: x,
|
|
112
113
|
triggerWidth: "var(--radix-popover-trigger-width)"
|
|
113
114
|
}), G = m(() => {
|
|
114
|
-
let e =
|
|
115
|
-
return
|
|
115
|
+
let e = E.filter((e) => e.label.toLowerCase().includes(z.toLowerCase()));
|
|
116
|
+
return k && (e = [...e].sort((e, t) => e.label.localeCompare(t.label))), e;
|
|
116
117
|
}, [
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
E,
|
|
119
|
+
z,
|
|
120
|
+
k
|
|
120
121
|
]), K = m(() => {
|
|
121
122
|
let e = {}, t = [];
|
|
122
123
|
return G.forEach((n) => {
|
|
@@ -127,43 +128,43 @@ var pe = "h-4 w-4", me = () => i("max-h-80 z-50 overflow-hidden", u(), "motion-s
|
|
|
127
128
|
hasGroups: Object.keys(e).length > 0
|
|
128
129
|
};
|
|
129
130
|
}, [G]), q = p((e) => {
|
|
130
|
-
|
|
131
|
+
E.find((t) => t.value === e)?.disabled || (V(B.includes(e) ? B.filter((t) => t !== e) : [...B, e]), b && R(!1));
|
|
131
132
|
}, [
|
|
132
|
-
|
|
133
|
-
|
|
133
|
+
b,
|
|
134
|
+
E,
|
|
134
135
|
V,
|
|
135
136
|
B
|
|
136
137
|
]), J = p(() => {
|
|
137
|
-
let e =
|
|
138
|
+
let e = E.filter((e) => !e.disabled).map((e) => e.value);
|
|
138
139
|
e.every((e) => B.includes(e)) ? V([]) : V(e);
|
|
139
140
|
}, [
|
|
140
|
-
|
|
141
|
+
E,
|
|
141
142
|
V,
|
|
142
143
|
B
|
|
143
144
|
]), Y = p(() => {
|
|
144
145
|
V([]);
|
|
145
|
-
}, [V]), X = m(() =>
|
|
146
|
+
}, [V]), X = m(() => E.filter((e) => !e.disabled).map((e) => e.value), [E]), Re = X.length > 0 && X.every((e) => B.includes(e)), { focusedOptionValue: Z, getOptionFocusIndex: ze, handleKeyDown: Be, isSelectAllFocused: Ve, setFocusedIndex: Q } = me(G, Y, () => R(!1), q, J, H, D, O, !1);
|
|
146
147
|
le(() => {
|
|
147
|
-
Q(
|
|
148
|
-
}, [
|
|
148
|
+
Q(L ? 0 : -1);
|
|
149
|
+
}, [L, Q]);
|
|
149
150
|
let He = p((e) => {
|
|
150
|
-
|
|
151
|
+
Ne(e.target.value);
|
|
151
152
|
}, []), Ue = () => {
|
|
152
|
-
if (B.length === 0) return /* @__PURE__ */
|
|
153
|
+
if (B.length === 0) return /* @__PURE__ */ _("span", {
|
|
153
154
|
className: "min-h-8 flex items-center text-input-text-placeholder",
|
|
154
|
-
children:
|
|
155
|
+
children: xe
|
|
155
156
|
});
|
|
156
|
-
let e = B.slice(0,
|
|
157
|
-
return /* @__PURE__ */
|
|
157
|
+
let e = B.slice(0, w), t = B.length - w;
|
|
158
|
+
return /* @__PURE__ */ v("div", {
|
|
158
159
|
className: "gap-1 flex flex-wrap items-center overflow-hidden",
|
|
159
160
|
children: [e.map((e) => {
|
|
160
|
-
let t =
|
|
161
|
-
return t ? /* @__PURE__ */
|
|
161
|
+
let t = E.find((t) => t.value === e);
|
|
162
|
+
return t ? /* @__PURE__ */ v("span", {
|
|
162
163
|
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",
|
|
163
|
-
children: [/* @__PURE__ */
|
|
164
|
+
children: [/* @__PURE__ */ _("span", {
|
|
164
165
|
className: "truncate",
|
|
165
166
|
children: t.label
|
|
166
|
-
}), /* @__PURE__ */
|
|
167
|
+
}), /* @__PURE__ */ _("span", {
|
|
167
168
|
"aria-hidden": "true",
|
|
168
169
|
className: "hover:text-danger rounded-sm cursor-pointer",
|
|
169
170
|
"data-testid": "spectral-multiselect-remove-item-button",
|
|
@@ -173,11 +174,11 @@ var pe = "h-4 w-4", me = () => i("max-h-80 z-50 overflow-hidden", u(), "motion-s
|
|
|
173
174
|
onPointerDown: (e) => {
|
|
174
175
|
e.stopPropagation();
|
|
175
176
|
},
|
|
176
|
-
children: /* @__PURE__ */
|
|
177
|
+
children: /* @__PURE__ */ _(n, { size: 12 })
|
|
177
178
|
})]
|
|
178
179
|
}, e) : null;
|
|
179
|
-
}), t > 0 && /* @__PURE__ */
|
|
180
|
-
className: "text-input-text-secondary text-xs py-1 flex items-center",
|
|
180
|
+
}), t > 0 && /* @__PURE__ */ v("span", {
|
|
181
|
+
className: "text-input-text-secondary text-xs py-1 flex items-center tabular-nums",
|
|
181
182
|
children: [
|
|
182
183
|
"+",
|
|
183
184
|
t,
|
|
@@ -186,55 +187,55 @@ var pe = "h-4 w-4", me = () => i("max-h-80 z-50 overflow-hidden", u(), "motion-s
|
|
|
186
187
|
})]
|
|
187
188
|
});
|
|
188
189
|
}, $ = (t, n) => {
|
|
189
|
-
let r = B.includes(t.value), a = ze(n), o = `${
|
|
190
|
-
return /* @__PURE__ */
|
|
190
|
+
let r = B.includes(t.value), a = ze(n), o = `${P}-option-${t.value}`;
|
|
191
|
+
return /* @__PURE__ */ v("button", {
|
|
191
192
|
"aria-selected": r,
|
|
192
|
-
className: i("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", a && "bg-input-bg--hover", r && "font-medium text-input-text"),
|
|
193
|
+
className: i("my-0.5 first:mt-0 last:mb-0 gap-3 rounded-sm 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", a && "bg-input-bg--hover", r && "font-medium text-input-text"),
|
|
193
194
|
disabled: t.disabled,
|
|
194
195
|
id: o,
|
|
195
196
|
onClick: () => q(t.value),
|
|
196
197
|
role: "option",
|
|
197
198
|
type: "button",
|
|
198
|
-
children: [/* @__PURE__ */
|
|
199
|
+
children: [/* @__PURE__ */ _("div", {
|
|
199
200
|
"data-testid": "spectral-multiselect-selected-indicator",
|
|
200
201
|
className: i("w-4 h-4 rounded flex items-center justify-center border border-input-border", r && "bg-primary border-primary"),
|
|
201
|
-
children: r && /* @__PURE__ */
|
|
202
|
-
}), /* @__PURE__ */
|
|
202
|
+
children: r && /* @__PURE__ */ _(e, { size: 12 })
|
|
203
|
+
}), /* @__PURE__ */ _("span", { children: t.label })]
|
|
203
204
|
}, t.value);
|
|
204
205
|
};
|
|
205
|
-
return /* @__PURE__ */
|
|
206
|
+
return /* @__PURE__ */ v("div", {
|
|
206
207
|
className: "w-full",
|
|
207
208
|
"data-testid": "spectral-multiselect-root",
|
|
208
209
|
children: [
|
|
209
|
-
|
|
210
|
+
C && /* @__PURE__ */ _(re, {
|
|
210
211
|
className: i("mb-2 block text-text-primary", U && "text-text-secondary"),
|
|
211
212
|
"data-testid": "spectral-multiselect-label",
|
|
212
|
-
htmlFor:
|
|
213
|
-
children:
|
|
213
|
+
htmlFor: N,
|
|
214
|
+
children: C
|
|
214
215
|
}),
|
|
215
|
-
/* @__PURE__ */
|
|
216
|
-
open:
|
|
217
|
-
onOpenChange:
|
|
218
|
-
children: /* @__PURE__ */
|
|
216
|
+
/* @__PURE__ */ _(oe, {
|
|
217
|
+
open: L,
|
|
218
|
+
onOpenChange: R,
|
|
219
|
+
children: /* @__PURE__ */ v("div", {
|
|
219
220
|
className: "relative",
|
|
220
221
|
"data-testid": "spectral-multiselect-wrapper",
|
|
221
|
-
onKeyDown:
|
|
222
|
+
onKeyDown: L ? Be : void 0,
|
|
222
223
|
role: "none",
|
|
223
224
|
children: [
|
|
224
|
-
/* @__PURE__ */
|
|
225
|
+
/* @__PURE__ */ _(ae, {
|
|
225
226
|
asChild: !0,
|
|
226
|
-
children: /* @__PURE__ */
|
|
227
|
-
"aria-activedescendant":
|
|
228
|
-
"aria-controls":
|
|
229
|
-
"aria-expanded":
|
|
230
|
-
"aria-label":
|
|
231
|
-
className: i(ee(
|
|
232
|
-
"data-state":
|
|
227
|
+
children: /* @__PURE__ */ v("button", {
|
|
228
|
+
"aria-activedescendant": L && Z ? `${P}-option-${Z}` : void 0,
|
|
229
|
+
"aria-controls": L ? P : void 0,
|
|
230
|
+
"aria-expanded": L,
|
|
231
|
+
"aria-label": De ?? C,
|
|
232
|
+
className: i(ee(L, A, u), "max-h-22 py-2 text-sm"),
|
|
233
|
+
"data-state": A,
|
|
233
234
|
"data-testid": "spectral-multiselect-trigger",
|
|
234
235
|
disabled: U,
|
|
235
|
-
id:
|
|
236
|
-
name:
|
|
237
|
-
ref:
|
|
236
|
+
id: N,
|
|
237
|
+
name: T,
|
|
238
|
+
ref: Se,
|
|
238
239
|
role: "combobox",
|
|
239
240
|
style: {
|
|
240
241
|
"--multiselect-border-radius": "0.5rem",
|
|
@@ -243,98 +244,98 @@ var pe = "h-4 w-4", me = () => i("max-h-80 z-50 overflow-hidden", u(), "motion-s
|
|
|
243
244
|
},
|
|
244
245
|
type: "button",
|
|
245
246
|
...Fe,
|
|
246
|
-
...
|
|
247
|
-
children: [/* @__PURE__ */
|
|
247
|
+
...M,
|
|
248
|
+
children: [/* @__PURE__ */ _("div", {
|
|
248
249
|
className: "min-w-0 flex-1 overflow-hidden",
|
|
249
250
|
"data-testid": "spectral-multiselect-selected-items",
|
|
250
251
|
children: Ue()
|
|
251
|
-
}), /* @__PURE__ */
|
|
252
|
+
}), /* @__PURE__ */ _("div", {
|
|
252
253
|
className: "gap-2 ml-2 flex shrink-0 items-center",
|
|
253
|
-
children: /* @__PURE__ */
|
|
254
|
-
className: i("text-input-icon transition-transform duration-200",
|
|
254
|
+
children: /* @__PURE__ */ _(t, {
|
|
255
|
+
className: i("text-input-icon transition-transform duration-200", L && "rotate-180"),
|
|
255
256
|
size: 20
|
|
256
257
|
})
|
|
257
258
|
})]
|
|
258
259
|
})
|
|
259
260
|
}),
|
|
260
|
-
|
|
261
|
+
Te && B.length > 0 && /* @__PURE__ */ _("button", {
|
|
261
262
|
"aria-label": "Clear all selections",
|
|
262
263
|
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",
|
|
263
264
|
"data-testid": "spectral-multiselect-clear-all-button",
|
|
264
265
|
disabled: U,
|
|
265
266
|
onClick: (e) => {
|
|
266
|
-
e.stopPropagation(), Y(), document.getElementById(
|
|
267
|
+
e.stopPropagation(), Y(), document.getElementById(N)?.focus();
|
|
267
268
|
},
|
|
268
269
|
type: "button",
|
|
269
|
-
children: /* @__PURE__ */
|
|
270
|
+
children: /* @__PURE__ */ _(n, { size: 12 })
|
|
270
271
|
}),
|
|
271
|
-
/* @__PURE__ */
|
|
272
|
+
/* @__PURE__ */ _(ce, { children: /* @__PURE__ */ _(se, {
|
|
272
273
|
align: "start",
|
|
273
274
|
avoidCollisions: !0,
|
|
274
|
-
className:
|
|
275
|
+
className: pe(),
|
|
275
276
|
collisionPadding: 10,
|
|
276
277
|
"data-dropdown-width-mode": W,
|
|
277
|
-
"data-dropdown-width-value": W === "custom" ?
|
|
278
|
+
"data-dropdown-width-value": W === "custom" ? x : void 0,
|
|
278
279
|
"data-testid": "spectral-multiselect-dropdown",
|
|
279
280
|
onOpenAutoFocus: (e) => {
|
|
280
|
-
e.preventDefault(),
|
|
281
|
+
e.preventDefault(), D && H.current?.focus();
|
|
281
282
|
},
|
|
282
283
|
side: "bottom",
|
|
283
284
|
sideOffset: 4,
|
|
284
|
-
ref:
|
|
285
|
+
ref: Me,
|
|
285
286
|
style: {
|
|
286
287
|
width: Le,
|
|
287
|
-
...
|
|
288
|
-
...
|
|
288
|
+
...x === "trigger" ? {} : Ie,
|
|
289
|
+
...je
|
|
289
290
|
},
|
|
290
|
-
children: /* @__PURE__ */
|
|
291
|
+
children: /* @__PURE__ */ v("div", {
|
|
291
292
|
className: "p-1",
|
|
292
|
-
children: [
|
|
293
|
+
children: [D && /* @__PURE__ */ v("div", {
|
|
293
294
|
className: "mb-2 relative",
|
|
294
|
-
children: [/* @__PURE__ */
|
|
295
|
+
children: [/* @__PURE__ */ _(r, { className: i(fe, "left-3 text-input-icon absolute top-1/2 -translate-y-1/2") }), /* @__PURE__ */ _("input", {
|
|
295
296
|
"aria-label": "Search options",
|
|
296
297
|
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",
|
|
297
298
|
"data-testid": "spectral-multiselect-search-input",
|
|
298
299
|
onChange: He,
|
|
299
|
-
placeholder:
|
|
300
|
+
placeholder: Ce,
|
|
300
301
|
ref: H,
|
|
301
302
|
type: "text",
|
|
302
|
-
value:
|
|
303
|
+
value: z
|
|
303
304
|
})]
|
|
304
|
-
}), /* @__PURE__ */
|
|
305
|
+
}), /* @__PURE__ */ _("div", {
|
|
305
306
|
className: "max-h-64 overflow-y-auto",
|
|
306
|
-
id:
|
|
307
|
+
id: P,
|
|
307
308
|
role: "listbox",
|
|
308
309
|
"aria-multiselectable": "true",
|
|
309
|
-
children: Pe ? /* @__PURE__ */
|
|
310
|
+
children: Pe ? /* @__PURE__ */ _(c, {
|
|
310
311
|
className: "text-sm",
|
|
311
|
-
message:
|
|
312
|
+
message: ye,
|
|
312
313
|
"data-testid": "spectral-multiselect-loading"
|
|
313
|
-
}) : G.length === 0 ? /* @__PURE__ */
|
|
314
|
+
}) : G.length === 0 ? /* @__PURE__ */ _(s, {
|
|
314
315
|
className: "text-sm",
|
|
315
316
|
"data-testid": "spectral-multiselect-empty-message",
|
|
316
|
-
message:
|
|
317
|
-
}) : /* @__PURE__ */
|
|
318
|
-
|
|
317
|
+
message: he
|
|
318
|
+
}) : /* @__PURE__ */ v(g, { children: [
|
|
319
|
+
O && /* @__PURE__ */ v("div", {
|
|
319
320
|
className: "mb-1",
|
|
320
|
-
children: [/* @__PURE__ */
|
|
321
|
-
className: i("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", Ve && "bg-input-bg--hover"),
|
|
321
|
+
children: [/* @__PURE__ */ _("button", {
|
|
322
|
+
className: i("my-0.5 first:mt-0 last:mb-0 gap-3 rounded-sm px-3 py-2 text-sm font-medium text-input-text-secondary flex w-full items-center hover:bg-input-bg--hover focus-visible:bg-input-bg--hover focus-visible:outline-none", Ve && "bg-input-bg--hover"),
|
|
322
323
|
"data-testid": "spectral-multiselect-select-all-button",
|
|
323
324
|
onClick: J,
|
|
324
325
|
type: "button",
|
|
325
|
-
children: Re ?
|
|
326
|
-
}), /* @__PURE__ */
|
|
326
|
+
children: Re ? y : we
|
|
327
|
+
}), /* @__PURE__ */ _("div", { className: "mx-3 my-1 h-px bg-input-border" })]
|
|
327
328
|
}),
|
|
328
|
-
K.ungrouped.length > 0 && /* @__PURE__ */
|
|
329
|
+
K.ungrouped.length > 0 && /* @__PURE__ */ _("div", {
|
|
329
330
|
className: "mb-1",
|
|
330
331
|
children: K.ungrouped.map((e, t) => $(e, t))
|
|
331
332
|
}),
|
|
332
|
-
Object.entries(K.groups).map(([e, t]) => /* @__PURE__ */
|
|
333
|
+
Object.entries(K.groups).map(([e, t]) => /* @__PURE__ */ v("div", {
|
|
333
334
|
className: "mb-1",
|
|
334
335
|
"data-testid": "spectral-multiselect-group",
|
|
335
336
|
children: [
|
|
336
|
-
(K.ungrouped.length > 0 || Object.keys(K.groups).indexOf(e) > 0) && /* @__PURE__ */
|
|
337
|
-
/* @__PURE__ */
|
|
337
|
+
(K.ungrouped.length > 0 || Object.keys(K.groups).indexOf(e) > 0) && /* @__PURE__ */ _("div", { className: "mx-3 my-1 h-px bg-input-border" }),
|
|
338
|
+
/* @__PURE__ */ _("div", {
|
|
338
339
|
"data-testid": "spectral-multiselect-group-name",
|
|
339
340
|
className: "px-3 py-1 text-xs font-semibold text-input-text-secondary tracking-wide uppercase",
|
|
340
341
|
children: e
|
|
@@ -349,19 +350,19 @@ var pe = "h-4 w-4", me = () => i("max-h-80 z-50 overflow-hidden", u(), "motion-s
|
|
|
349
350
|
]
|
|
350
351
|
})
|
|
351
352
|
}),
|
|
352
|
-
|
|
353
|
+
/* @__PURE__ */ _(a, {
|
|
353
354
|
dataTestId: "spectral-multiselect-error-message",
|
|
354
|
-
id:
|
|
355
|
-
message:
|
|
355
|
+
id: F,
|
|
356
|
+
message: A === "error" ? ge : null
|
|
356
357
|
}),
|
|
357
|
-
|
|
358
|
+
/* @__PURE__ */ _(o, {
|
|
358
359
|
dataTestId: "spectral-multiselect-warning-message",
|
|
359
|
-
id:
|
|
360
|
-
message: A
|
|
360
|
+
id: I,
|
|
361
|
+
message: A === "warning" ? j : null
|
|
361
362
|
})
|
|
362
363
|
]
|
|
363
364
|
});
|
|
364
365
|
};
|
|
365
|
-
|
|
366
|
+
y.displayName = "MultiSelectBase";
|
|
366
367
|
//#endregion
|
|
367
|
-
export {
|
|
368
|
+
export { y as MultiSelectBase };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { AsChildProp } from '../primitives/slot';
|
|
2
2
|
import { ButtonHTMLAttributes, ReactNode, Ref } from 'react';
|
|
3
3
|
export interface RadioButtonGroupProps {
|
|
4
|
-
'aria-label'?: string;
|
|
5
|
-
'aria-labelledby'?: string;
|
|
6
4
|
asChild?: boolean;
|
|
7
5
|
children: ReactNode;
|
|
8
6
|
className?: string;
|
|
@@ -10,6 +8,8 @@ export interface RadioButtonGroupProps {
|
|
|
10
8
|
isKeptActive?: boolean;
|
|
11
9
|
onValueChange?: (value: string) => void;
|
|
12
10
|
value?: string;
|
|
11
|
+
'aria-label'?: string;
|
|
12
|
+
'aria-labelledby'?: string;
|
|
13
13
|
}
|
|
14
14
|
export interface RadioButtonGroupItemProps extends AsChildProp, Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'onSelect' | 'type'> {
|
|
15
15
|
children: ReactNode;
|
|
@@ -3,7 +3,8 @@ import { a as e, d as t, l as n, r, t as i } from "./dist-DEkDg4Sk.js";
|
|
|
3
3
|
import { t as a } from "./dist-CcsVPym2.js";
|
|
4
4
|
import { t as o } from "./dist-D9FsQh8P.js";
|
|
5
5
|
import { t as s } from "./twUtils-BpqlKSeB.js";
|
|
6
|
-
import { ErrorMessage as c, WarningMessage as l
|
|
6
|
+
import { ErrorMessage as c, WarningMessage as l } from "./FormFieldMessage.js";
|
|
7
|
+
import { useFormFieldId as u } from "./utils/formFieldUtils.js";
|
|
7
8
|
import { Label as d } from "./Label.js";
|
|
8
9
|
import { t as f } from "./dist-PfrTYHr_.js";
|
|
9
10
|
import { t as p } from "./dist-s1uWaZYZ.js";
|
|
@@ -207,34 +208,38 @@ var J = w({
|
|
|
207
208
|
a,
|
|
208
209
|
x
|
|
209
210
|
]);
|
|
210
|
-
return /* @__PURE__ */
|
|
211
|
+
return /* @__PURE__ */ k(J.Provider, {
|
|
211
212
|
value: D,
|
|
212
|
-
children:
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
213
|
+
children: /* @__PURE__ */ A("div", {
|
|
214
|
+
"data-slot": "radio-group-field",
|
|
215
|
+
className: "space-y-1.5 w-full",
|
|
216
|
+
children: [
|
|
217
|
+
/* @__PURE__ */ k(ue, {
|
|
218
|
+
className: s("flex w-full text-text-primary", p === "vertical" ? "gap-4 flex-col" : "gap-5 flex-row", _ === "unstyled" && "gap-2.5 w-fit", n),
|
|
219
|
+
"data-state": g,
|
|
220
|
+
"data-testid": "spectral-radio-group",
|
|
221
|
+
id: S,
|
|
222
|
+
"aria-invalid": g === "error" ? !0 : void 0,
|
|
223
|
+
"aria-describedby": [T, y].filter(Boolean).join(" ") || void 0,
|
|
224
|
+
disabled: D.groupDisabled,
|
|
225
|
+
name: o,
|
|
226
|
+
onValueChange: E,
|
|
227
|
+
ref: m,
|
|
228
|
+
value: x,
|
|
229
|
+
...b
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ k(c, {
|
|
232
|
+
dataTestId: "spectral-radio-group-error-message",
|
|
233
|
+
id: C,
|
|
234
|
+
message: g === "error" ? i : null
|
|
235
|
+
}),
|
|
236
|
+
/* @__PURE__ */ k(l, {
|
|
237
|
+
dataTestId: "spectral-radio-group-warning-message",
|
|
238
|
+
id: w,
|
|
239
|
+
message: g === "warning" ? v : null
|
|
240
|
+
})
|
|
241
|
+
]
|
|
242
|
+
})
|
|
238
243
|
});
|
|
239
244
|
};
|
|
240
245
|
X.displayName = "RadioGroup";
|
package/dist/RadioGroup.js
CHANGED
package/dist/Select.js
CHANGED
|
@@ -4,30 +4,31 @@ import { CheckmarkIcon as e } from "./Icons/CheckmarkIcon.js";
|
|
|
4
4
|
import { ChevronDownIcon as t } from "./Icons/ChevronDownIcon.js";
|
|
5
5
|
import { LoaderIcon as n } from "./Icons/LoaderIcon.js";
|
|
6
6
|
import { t as r } from "./twUtils-BpqlKSeB.js";
|
|
7
|
-
import {
|
|
7
|
+
import { ErrorMessage as i, WarningMessage as a } from "./FormFieldMessage.js";
|
|
8
|
+
import { EmptyState as o, LoadingState as s, getAriaProps as c, getDropdownSurfaceClasses as l, getDropdownWidthStyles as ee, getErrorMessageId as te, getFormFieldCSSProperties as ne, getOptionClasses as re, getTriggerClasses as ie, groupOptions as ae, useFormFieldId as oe } from "./utils/formFieldUtils.js";
|
|
8
9
|
import { Label as u } from "./Label.js";
|
|
9
|
-
import { C as se, S as ce, _ as le, b as
|
|
10
|
+
import { C as se, S as ce, _ as le, b as d, d as f, f as ue, g as de, h as fe, m as pe, p as me, u as he, v as ge, x as p, y as _e } from "./select-DFE8xm1L.js";
|
|
10
11
|
import { useAutoDropdownHorizontalShift as ve } from "./utils/dropdownPositioning.js";
|
|
11
12
|
import { useState as ye } from "react";
|
|
12
13
|
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
13
14
|
//#region src/components/Select/Select.tsx
|
|
14
15
|
var _ = (_) => {
|
|
15
|
-
let v = "value" in _, { align: y = "start", alignOffset: b = 0, avoidCollisions: x = !0, className: S, collisionBoundary: C, collisionPadding: w = 10, defaultValue: T, dropdownWidth: E = "trigger", emptyMessage: D = "No options found", errorMessage: O, disabled: k, id: A, label: j, labelClassName: M, loadingMessage: N = "Loading…", name: P, onChange:
|
|
16
|
+
let v = "value" in _, { align: y = "start", alignOffset: b = 0, avoidCollisions: x = !0, className: S, collisionBoundary: C, collisionPadding: w = 10, defaultValue: T, dropdownWidth: E = "trigger", emptyMessage: D = "No options found", errorMessage: O, disabled: k, id: A, label: j, labelClassName: M, loadingMessage: N = "Loading…", name: P, onChange: F, onValueChange: be, options: I = [], placeholder: xe = "Select an option", position: L = "popper", ref: Se, required: R, side: Ce = "bottom", sideOffset: we = 4, state: z = "default", value: B, warningMessage: V, "aria-label": Te, "aria-describedby": Ee, ...De } = _, H = v ? B ?? "" : B, [U, Oe] = ye(!1), { dropdownShiftStyle: ke, setDropdownElement: Ae } = ve(U), W = oe(A, P), G = `${W}-listbox`, K = te(W), q = `${W}-warning`, je = z === "error" && O ? K : z === "warning" && V ? q : void 0, { dropdownWidthMode: J, dropdownWidthStyle: Me, resolvedDropdownWidth: Y } = ee({
|
|
16
17
|
dropdownWidth: E,
|
|
17
18
|
triggerWidth: "var(--radix-select-trigger-width)"
|
|
18
19
|
}), Ne = {
|
|
19
20
|
"--spectral-select-content-width": Y,
|
|
20
|
-
...
|
|
21
|
+
...L === "item-aligned" ? { width: Y } : {},
|
|
21
22
|
...Me,
|
|
22
23
|
...ke
|
|
23
|
-
}, X = !!k, Z = z === "loading", Pe = z === "error", Fe = c(z, Ee, R, je), { groups: Q, ungrouped: $ } = ae(
|
|
24
|
-
|
|
24
|
+
}, X = !!k, Z = z === "loading", Pe = z === "error", Fe = c(z, Ee, R, je), { groups: Q, ungrouped: $ } = ae(I), Ie = (e) => {
|
|
25
|
+
F?.(e), be?.(e);
|
|
25
26
|
}, Le = () => {
|
|
26
|
-
if (Z) return /* @__PURE__ */ h(
|
|
27
|
+
if (Z) return /* @__PURE__ */ h(s, {
|
|
27
28
|
"data-testid": "spectral-select-loading",
|
|
28
29
|
message: N
|
|
29
30
|
});
|
|
30
|
-
if (
|
|
31
|
+
if (I.length === 0) return /* @__PURE__ */ h(o, {
|
|
31
32
|
"data-testid": "spectral-select-empty",
|
|
32
33
|
message: D
|
|
33
34
|
});
|
|
@@ -55,7 +56,7 @@ var _ = (_) => {
|
|
|
55
56
|
return /* @__PURE__ */ g(m, { children: [$.length > 0 && /* @__PURE__ */ g(m, { children: [$.map(t), Object.keys(Q).length > 0 && /* @__PURE__ */ h(p, {
|
|
56
57
|
className: "-mx-1 my-1 h-px bg-border-secondary",
|
|
57
58
|
"data-testid": "spectral-select-separator"
|
|
58
|
-
})] }), Object.entries(Q).map(([e, n], i) => /* @__PURE__ */ g(
|
|
59
|
+
})] }), Object.entries(Q).map(([e, n], i) => /* @__PURE__ */ g(ue, {
|
|
59
60
|
"data-testid": "spectral-select-group",
|
|
60
61
|
children: [
|
|
61
62
|
i > 0 && /* @__PURE__ */ h(p, {
|
|
@@ -100,7 +101,7 @@ var _ = (_) => {
|
|
|
100
101
|
"data-state": z,
|
|
101
102
|
"data-testid": "spectral-select-trigger",
|
|
102
103
|
id: W,
|
|
103
|
-
ref:
|
|
104
|
+
ref: Se,
|
|
104
105
|
role: "combobox",
|
|
105
106
|
style: ne(),
|
|
106
107
|
...Fe,
|
|
@@ -111,7 +112,7 @@ var _ = (_) => {
|
|
|
111
112
|
disabled: X,
|
|
112
113
|
children: [/* @__PURE__ */ h(he, {
|
|
113
114
|
"data-testid": "spectral-select-value",
|
|
114
|
-
placeholder:
|
|
115
|
+
placeholder: xe
|
|
115
116
|
}), /* @__PURE__ */ h(me, {
|
|
116
117
|
asChild: !0,
|
|
117
118
|
children: /* @__PURE__ */ h("div", {
|
|
@@ -123,11 +124,11 @@ var _ = (_) => {
|
|
|
123
124
|
})
|
|
124
125
|
})]
|
|
125
126
|
})
|
|
126
|
-
}), /* @__PURE__ */ h(le, { children: /* @__PURE__ */ g(
|
|
127
|
+
}), /* @__PURE__ */ h(le, { children: /* @__PURE__ */ g(f, {
|
|
127
128
|
align: y,
|
|
128
129
|
alignOffset: b,
|
|
129
130
|
avoidCollisions: x,
|
|
130
|
-
className: r("relative z-50 motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=open]:animate-in", l(), "motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95", "max-h-[min(var(--radix-select-content-available-height),300px)] motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=top]:slide-in-from-bottom-2", "min-w-32 origin-(--radix-select-content-transform-origin) overflow-
|
|
131
|
+
className: r("relative z-50 motion-safe:data-[state=closed]:animate-out motion-safe:data-[state=open]:animate-in", l(), "motion-safe:data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95", "max-h-[min(var(--radix-select-content-available-height),300px)] motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=top]:slide-in-from-bottom-2", "min-w-32 origin-(--radix-select-content-transform-origin) overflow-hidden", L === "popper" && "data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1"),
|
|
131
132
|
collisionBoundary: C,
|
|
132
133
|
collisionPadding: w,
|
|
133
134
|
"data-dropdown-width-mode": J,
|
|
@@ -135,13 +136,13 @@ var _ = (_) => {
|
|
|
135
136
|
id: G,
|
|
136
137
|
"data-slot": "select-content",
|
|
137
138
|
"data-testid": "spectral-select-content",
|
|
138
|
-
position:
|
|
139
|
+
position: L,
|
|
139
140
|
ref: Ae,
|
|
140
141
|
side: Ce,
|
|
141
142
|
sideOffset: we,
|
|
142
143
|
style: Ne,
|
|
143
144
|
children: [
|
|
144
|
-
/* @__PURE__ */ h(
|
|
145
|
+
/* @__PURE__ */ h(d, {
|
|
145
146
|
className: "py-1 flex cursor-default items-center justify-center",
|
|
146
147
|
"data-testid": "spectral-select-scroll-up-button",
|
|
147
148
|
children: /* @__PURE__ */ h(t, {
|
|
@@ -153,7 +154,7 @@ var _ = (_) => {
|
|
|
153
154
|
/* @__PURE__ */ h(se, {
|
|
154
155
|
asChild: !0,
|
|
155
156
|
children: /* @__PURE__ */ h("div", {
|
|
156
|
-
className: r("p-1",
|
|
157
|
+
className: r("p-1 overflow-x-hidden overflow-y-auto", L === "popper" && (E === "trigger" ? "scroll-my-1 h-(--radix-select-trigger-height) w-(--spectral-select-content-width) min-w-(--spectral-select-content-width)" : "scroll-my-1 h-(--radix-select-trigger-height)")),
|
|
157
158
|
"data-testid": "spectral-select-items",
|
|
158
159
|
children: Le()
|
|
159
160
|
})
|
|
@@ -169,15 +170,15 @@ var _ = (_) => {
|
|
|
169
170
|
]
|
|
170
171
|
}) })]
|
|
171
172
|
}),
|
|
172
|
-
|
|
173
|
+
/* @__PURE__ */ h(i, {
|
|
173
174
|
dataTestId: "spectral-select-error-message",
|
|
174
175
|
id: K,
|
|
175
|
-
message: O
|
|
176
|
+
message: Pe ? O ?? null : null
|
|
176
177
|
}),
|
|
177
|
-
|
|
178
|
+
/* @__PURE__ */ h(a, {
|
|
178
179
|
dataTestId: "spectral-select-warning-message",
|
|
179
180
|
id: q,
|
|
180
|
-
message: V
|
|
181
|
+
message: z === "warning" ? V ?? null : null
|
|
181
182
|
})
|
|
182
183
|
]
|
|
183
184
|
});
|