@wow-two-beta/ui 0.0.8 → 0.0.9

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.
Files changed (64) hide show
  1. package/dist/chunk-3KGYKBW6.js +697 -0
  2. package/dist/chunk-3KGYKBW6.js.map +1 -0
  3. package/dist/{chunk-7SGLT2LM.js → chunk-55Y2JOBV.js} +3 -3
  4. package/dist/{chunk-7SGLT2LM.js.map → chunk-55Y2JOBV.js.map} +1 -1
  5. package/dist/{chunk-SL5YJADS.js → chunk-CZ6FQILQ.js} +30 -5
  6. package/dist/chunk-CZ6FQILQ.js.map +1 -0
  7. package/dist/{chunk-X2LTOZ7F.js → chunk-SBVWECJP.js} +921 -6
  8. package/dist/chunk-SBVWECJP.js.map +1 -0
  9. package/dist/display/index.js +2 -3
  10. package/dist/forms/combobox/Combobox.d.ts +55 -0
  11. package/dist/forms/combobox/Combobox.d.ts.map +1 -0
  12. package/dist/forms/combobox/index.d.ts +2 -0
  13. package/dist/forms/combobox/index.d.ts.map +1 -0
  14. package/dist/forms/index.d.ts +4 -0
  15. package/dist/forms/index.d.ts.map +1 -1
  16. package/dist/forms/index.js +3 -2
  17. package/dist/forms/listbox/Listbox.d.ts +44 -0
  18. package/dist/forms/listbox/Listbox.d.ts.map +1 -0
  19. package/dist/forms/listbox/Listbox.variants.d.ts +58 -0
  20. package/dist/forms/listbox/Listbox.variants.d.ts.map +1 -0
  21. package/dist/forms/listbox/index.d.ts +2 -0
  22. package/dist/forms/listbox/index.d.ts.map +1 -0
  23. package/dist/forms/multiSelect/MultiSelect.d.ts +47 -0
  24. package/dist/forms/multiSelect/MultiSelect.d.ts.map +1 -0
  25. package/dist/forms/multiSelect/index.d.ts +2 -0
  26. package/dist/forms/multiSelect/index.d.ts.map +1 -0
  27. package/dist/forms/select/Select.d.ts +55 -0
  28. package/dist/forms/select/Select.d.ts.map +1 -0
  29. package/dist/forms/select/Select.variants.d.ts +74 -0
  30. package/dist/forms/select/Select.variants.d.ts.map +1 -0
  31. package/dist/forms/select/index.d.ts +2 -0
  32. package/dist/forms/select/index.d.ts.map +1 -0
  33. package/dist/index.js +4 -5
  34. package/dist/nav/contextMenu/ContextMenu.d.ts +31 -0
  35. package/dist/nav/contextMenu/ContextMenu.d.ts.map +1 -0
  36. package/dist/nav/contextMenu/index.d.ts +2 -0
  37. package/dist/nav/contextMenu/index.d.ts.map +1 -0
  38. package/dist/nav/dropdownMenu/DropdownMenu.d.ts +34 -0
  39. package/dist/nav/dropdownMenu/DropdownMenu.d.ts.map +1 -0
  40. package/dist/nav/dropdownMenu/index.d.ts +2 -0
  41. package/dist/nav/dropdownMenu/index.d.ts.map +1 -0
  42. package/dist/nav/index.d.ts +4 -0
  43. package/dist/nav/index.d.ts.map +1 -1
  44. package/dist/nav/index.js +3 -3
  45. package/dist/nav/menu/Menu.d.ts +38 -0
  46. package/dist/nav/menu/Menu.d.ts.map +1 -0
  47. package/dist/nav/menu/Menu.variants.d.ts +50 -0
  48. package/dist/nav/menu/Menu.variants.d.ts.map +1 -0
  49. package/dist/nav/menu/index.d.ts +3 -0
  50. package/dist/nav/menu/index.d.ts.map +1 -0
  51. package/dist/nav/menubar/Menubar.d.ts +40 -0
  52. package/dist/nav/menubar/Menubar.d.ts.map +1 -0
  53. package/dist/nav/menubar/Menubar.variants.d.ts +5 -0
  54. package/dist/nav/menubar/Menubar.variants.d.ts.map +1 -0
  55. package/dist/nav/menubar/index.d.ts +2 -0
  56. package/dist/nav/menubar/index.d.ts.map +1 -0
  57. package/dist/primitives/index.js +1 -2
  58. package/package.json +1 -1
  59. package/dist/chunk-L32PXXQL.js +0 -126
  60. package/dist/chunk-L32PXXQL.js.map +0 -1
  61. package/dist/chunk-SL5YJADS.js.map +0 -1
  62. package/dist/chunk-WEM32VIJ.js +0 -34
  63. package/dist/chunk-WEM32VIJ.js.map +0 -1
  64. package/dist/chunk-X2LTOZ7F.js.map +0 -1
@@ -1,13 +1,15 @@
1
- import { useFormControl, FormControlProvider } from './chunk-WEM32VIJ.js';
1
+ import { useFormControl, FormControlProvider, Portal, AnchoredPositioner, DismissableLayer } from './chunk-CZ6FQILQ.js';
2
2
  import { useControlled } from './chunk-4P2TFUVW.js';
3
3
  import { useId } from './chunk-KDXJQNB6.js';
4
4
  import { tv } from './chunk-BMBIZLO4.js';
5
5
  import { Icon } from './chunk-TDX22OWF.js';
6
+ import { composeRefs } from './chunk-DN7WBRIV.js';
6
7
  import { cn } from './chunk-KZ4VFY2T.js';
7
8
  import * as React from 'react';
8
- import { forwardRef, useRef, useImperativeHandle, useState, Children, isValidElement, cloneElement, useId as useId$1 } from 'react';
9
+ import { forwardRef, useRef, useImperativeHandle, useState, Children, isValidElement, cloneElement, useId as useId$1, createContext, useMemo, useCallback, useEffect, useContext } from 'react';
9
10
  import { jsxs, jsx } from 'react/jsx-runtime';
10
- import { Minus, Plus, EyeOff, Eye, Search, X, Check, Upload } from 'lucide-react';
11
+ import { Minus, Plus, EyeOff, Eye, Search, X, Check, Upload, ChevronDown } from 'lucide-react';
12
+ import { FocusScope } from '@radix-ui/react-focus-scope';
11
13
 
12
14
  var Label = forwardRef(
13
15
  ({ className, required, htmlFor, id, children, ...props }, ref) => {
@@ -1114,6 +1116,919 @@ var FilePicker = forwardRef(
1114
1116
  );
1115
1117
  FilePicker.displayName = "FilePicker";
1116
1118
 
1117
- export { CharacterCount, Checkbox, CheckboxField, CheckboxGroup, ChoiceCard, CurrencyInput, EmailInput, Fieldset, FilePicker, FormErrorMessage, FormField, FormHelperText, InputAddon, InputGroup, Label, LabeledInput, Legend, MaskedInput, NumberInput, PasswordInput, PasswordStrength, PercentInput, PinInput, Radio, RadioField, RadioGroup, SearchInput, Slider, Switch, SwitchField, TelInput, TextInput, Textarea, UrlInput };
1118
- //# sourceMappingURL=chunk-X2LTOZ7F.js.map
1119
- //# sourceMappingURL=chunk-X2LTOZ7F.js.map
1119
+ // src/forms/listbox/Listbox.variants.ts
1120
+ var listboxVariants = tv({
1121
+ base: "flex max-h-72 flex-col gap-0.5 overflow-y-auto rounded-md border border-border bg-popover p-1 text-sm text-popover-foreground shadow-md outline-none"
1122
+ });
1123
+ var listboxItemVariants = tv({
1124
+ base: "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",
1125
+ variants: {
1126
+ state: {
1127
+ default: "text-popover-foreground",
1128
+ active: "bg-muted text-foreground",
1129
+ selected: "bg-primary-soft text-primary-soft-foreground",
1130
+ disabled: "pointer-events-none opacity-50"
1131
+ }
1132
+ },
1133
+ defaultVariants: { state: "default" }
1134
+ });
1135
+ var listboxGroupLabelVariants = tv({
1136
+ base: "px-2 py-1.5 text-xs font-semibold text-muted-foreground"
1137
+ });
1138
+ var listboxSeparatorVariants = tv({
1139
+ base: "-mx-1 my-1 h-px bg-border"
1140
+ });
1141
+ var listboxEmptyVariants = tv({
1142
+ base: "px-2 py-6 text-center text-sm text-muted-foreground"
1143
+ });
1144
+ var ListboxContext = createContext(null);
1145
+ function useListboxContext() {
1146
+ const ctx = useContext(ListboxContext);
1147
+ if (!ctx) throw new Error("Listbox.Item / Group / Separator must be used inside <Listbox>");
1148
+ return ctx;
1149
+ }
1150
+ var Listbox = forwardRef(function Listbox2(props, ref) {
1151
+ const {
1152
+ multiple = false,
1153
+ value,
1154
+ defaultValue,
1155
+ onValueChange,
1156
+ disabled,
1157
+ className,
1158
+ children,
1159
+ onKeyDown,
1160
+ ...rest
1161
+ } = props;
1162
+ const initial = defaultValue ?? (multiple ? [] : "");
1163
+ const [current, setCurrent] = useControlled({
1164
+ controlled: value,
1165
+ default: initial,
1166
+ onChange: onValueChange
1167
+ });
1168
+ const values = useMemo(
1169
+ () => Array.isArray(current) ? current : current ? [current] : [],
1170
+ [current]
1171
+ );
1172
+ const items = useRef([]);
1173
+ const [activeId, setActiveId] = useState(null);
1174
+ const registerItem = useCallback((entry) => {
1175
+ if (!items.current.some((i) => i.id === entry.id)) items.current.push(entry);
1176
+ }, []);
1177
+ const updateItem = useCallback((entry) => {
1178
+ const idx = items.current.findIndex((i) => i.id === entry.id);
1179
+ if (idx >= 0) items.current[idx] = entry;
1180
+ }, []);
1181
+ const unregisterItem = useCallback((id) => {
1182
+ items.current = items.current.filter((i) => i.id !== id);
1183
+ }, []);
1184
+ const onItemSelect = useCallback(
1185
+ (next) => {
1186
+ if (multiple) {
1187
+ const cur = Array.isArray(current) ? current : [];
1188
+ const has = cur.includes(next);
1189
+ setCurrent(has ? cur.filter((v) => v !== next) : [...cur, next]);
1190
+ } else {
1191
+ setCurrent(next);
1192
+ }
1193
+ },
1194
+ [multiple, current, setCurrent]
1195
+ );
1196
+ useEffect(() => {
1197
+ if (activeId) return;
1198
+ const firstSelected = items.current.find(
1199
+ (i) => !i.disabled && values.includes(i.value)
1200
+ );
1201
+ const firstEnabled = items.current.find((i) => !i.disabled);
1202
+ setActiveId((firstSelected ?? firstEnabled)?.id ?? null);
1203
+ }, []);
1204
+ const moveActive = useCallback(
1205
+ (direction, jump = 1) => {
1206
+ const list = items.current.filter((i) => !i.disabled);
1207
+ if (list.length === 0) return;
1208
+ const currentIdx = list.findIndex((i) => i.id === activeId);
1209
+ let nextIdx = currentIdx + direction * jump;
1210
+ if (currentIdx === -1) nextIdx = direction === 1 ? 0 : list.length - 1;
1211
+ if (nextIdx < 0) nextIdx = 0;
1212
+ if (nextIdx >= list.length) nextIdx = list.length - 1;
1213
+ const nextEntry = list[nextIdx];
1214
+ if (nextEntry) setActiveId(nextEntry.id);
1215
+ },
1216
+ [activeId]
1217
+ );
1218
+ const handleKeyDown = useCallback(
1219
+ (event) => {
1220
+ onKeyDown?.(event);
1221
+ if (event.defaultPrevented || disabled) return;
1222
+ switch (event.key) {
1223
+ case "ArrowDown":
1224
+ event.preventDefault();
1225
+ moveActive(1);
1226
+ break;
1227
+ case "ArrowUp":
1228
+ event.preventDefault();
1229
+ moveActive(-1);
1230
+ break;
1231
+ case "Home":
1232
+ event.preventDefault();
1233
+ moveActive(-1, items.current.length);
1234
+ break;
1235
+ case "End":
1236
+ event.preventDefault();
1237
+ moveActive(1, items.current.length);
1238
+ break;
1239
+ case "PageDown":
1240
+ event.preventDefault();
1241
+ moveActive(1, 10);
1242
+ break;
1243
+ case "PageUp":
1244
+ event.preventDefault();
1245
+ moveActive(-1, 10);
1246
+ break;
1247
+ case "Enter":
1248
+ case " ": {
1249
+ if (!activeId) return;
1250
+ const entry = items.current.find((i) => i.id === activeId);
1251
+ if (!entry || entry.disabled) return;
1252
+ event.preventDefault();
1253
+ onItemSelect(entry.value);
1254
+ break;
1255
+ }
1256
+ }
1257
+ },
1258
+ [activeId, disabled, moveActive, onItemSelect, onKeyDown]
1259
+ );
1260
+ const ctx = useMemo(
1261
+ () => ({
1262
+ multiple,
1263
+ values,
1264
+ activeId,
1265
+ onItemSelect,
1266
+ registerItem: (e) => {
1267
+ const existing = items.current.find((i) => i.id === e.id);
1268
+ if (existing) updateItem(e);
1269
+ else registerItem(e);
1270
+ },
1271
+ unregisterItem,
1272
+ setActiveId
1273
+ }),
1274
+ [multiple, values, activeId, onItemSelect, registerItem, unregisterItem, updateItem]
1275
+ );
1276
+ return /* @__PURE__ */ jsx(ListboxContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
1277
+ "div",
1278
+ {
1279
+ ref,
1280
+ role: "listbox",
1281
+ tabIndex: disabled ? -1 : 0,
1282
+ "aria-multiselectable": multiple || void 0,
1283
+ "aria-activedescendant": activeId ?? void 0,
1284
+ "aria-disabled": disabled || void 0,
1285
+ onKeyDown: handleKeyDown,
1286
+ className: cn(listboxVariants(), className),
1287
+ ...rest,
1288
+ children
1289
+ }
1290
+ ) });
1291
+ });
1292
+ var ListboxItem = forwardRef(function ListboxItem2({ value, disabled = false, className, children, onClick, onPointerEnter, ...rest }, forwardedRef) {
1293
+ const ctx = useListboxContext();
1294
+ const id = useId$1();
1295
+ const ref = useRef(null);
1296
+ useEffect(() => {
1297
+ ctx.registerItem({ id, value, disabled, ref: ref.current });
1298
+ return () => ctx.unregisterItem(id);
1299
+ }, [ctx, id, value, disabled]);
1300
+ const isSelected = ctx.values.includes(value);
1301
+ const isActive = ctx.activeId === id;
1302
+ const state = disabled ? "disabled" : isSelected ? "selected" : isActive ? "active" : "default";
1303
+ const setRefs = (node) => {
1304
+ ref.current = node;
1305
+ if (typeof forwardedRef === "function") forwardedRef(node);
1306
+ else if (forwardedRef) forwardedRef.current = node;
1307
+ };
1308
+ return /* @__PURE__ */ jsxs(
1309
+ "div",
1310
+ {
1311
+ ref: setRefs,
1312
+ id,
1313
+ role: "option",
1314
+ "aria-selected": isSelected,
1315
+ "aria-disabled": disabled || void 0,
1316
+ "data-active": isActive ? "" : void 0,
1317
+ "data-selected": isSelected ? "" : void 0,
1318
+ "data-disabled": disabled ? "" : void 0,
1319
+ onClick: (e) => {
1320
+ onClick?.(e);
1321
+ if (e.defaultPrevented || disabled) return;
1322
+ ctx.onItemSelect(value);
1323
+ },
1324
+ onPointerEnter: (e) => {
1325
+ onPointerEnter?.(e);
1326
+ if (!disabled) ctx.setActiveId(id);
1327
+ },
1328
+ className: cn(listboxItemVariants({ state }), className),
1329
+ ...rest,
1330
+ children: [
1331
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children }),
1332
+ ctx.multiple && isSelected && /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }),
1333
+ !ctx.multiple && isSelected && /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 opacity-80" })
1334
+ ]
1335
+ }
1336
+ );
1337
+ });
1338
+ function ListboxGroup({ label, children, className, ...rest }) {
1339
+ const labelId = useId$1();
1340
+ return /* @__PURE__ */ jsxs("div", { role: "group", "aria-labelledby": label ? labelId : void 0, className, ...rest, children: [
1341
+ label && /* @__PURE__ */ jsx("div", { id: labelId, className: listboxGroupLabelVariants(), children: label }),
1342
+ children
1343
+ ] });
1344
+ }
1345
+ function ListboxSeparator(props) {
1346
+ return /* @__PURE__ */ jsx("div", { role: "separator", className: listboxSeparatorVariants(), ...props });
1347
+ }
1348
+ function ListboxEmpty({ children, className, ...rest }) {
1349
+ return /* @__PURE__ */ jsx("div", { role: "presentation", className: cn(listboxEmptyVariants(), className), ...rest, children });
1350
+ }
1351
+ Listbox.Item = ListboxItem;
1352
+ Listbox.Group = ListboxGroup;
1353
+ Listbox.Separator = ListboxSeparator;
1354
+ Listbox.Empty = ListboxEmpty;
1355
+
1356
+ // src/forms/select/Select.variants.ts
1357
+ var selectTriggerVariants = tv({
1358
+ base: "flex w-full items-center justify-between gap-2 rounded-md border bg-background text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 data-[state=open]:border-border-strong",
1359
+ variants: {
1360
+ size: {
1361
+ sm: "h-8 px-2.5 text-sm",
1362
+ md: "h-10 px-3 text-sm",
1363
+ lg: "h-12 px-4 text-base"
1364
+ },
1365
+ state: {
1366
+ default: "border-input hover:border-border-strong",
1367
+ invalid: "border-destructive focus-visible:ring-destructive"
1368
+ }
1369
+ },
1370
+ defaultVariants: {
1371
+ size: "md",
1372
+ state: "default"
1373
+ }
1374
+ });
1375
+ var SelectContext = createContext(null);
1376
+ function useSelectContext() {
1377
+ const ctx = useContext(SelectContext);
1378
+ if (!ctx) throw new Error("Select.* must be used inside <Select>");
1379
+ return ctx;
1380
+ }
1381
+ function Select({
1382
+ value,
1383
+ defaultValue,
1384
+ onValueChange,
1385
+ disabled = false,
1386
+ name,
1387
+ invalid,
1388
+ defaultOpen = false,
1389
+ open: openProp,
1390
+ onOpenChange,
1391
+ children
1392
+ }) {
1393
+ const [openState, setOpenState] = useControlled({
1394
+ controlled: openProp,
1395
+ default: defaultOpen,
1396
+ onChange: onOpenChange
1397
+ });
1398
+ const [valueState, setValueState] = useControlled({
1399
+ controlled: value,
1400
+ default: defaultValue ?? "",
1401
+ onChange: onValueChange
1402
+ });
1403
+ const triggerRef = useRef(null);
1404
+ const [labels, setLabels] = useState({});
1405
+ const registerLabel = useCallback((v, label) => {
1406
+ setLabels((prev) => prev[v] === label ? prev : { ...prev, [v]: label });
1407
+ }, []);
1408
+ const unregisterLabel = useCallback((v) => {
1409
+ setLabels((prev) => {
1410
+ if (!(v in prev)) return prev;
1411
+ const next = { ...prev };
1412
+ delete next[v];
1413
+ return next;
1414
+ });
1415
+ }, []);
1416
+ const onSelect = useCallback(
1417
+ (next) => {
1418
+ setValueState(next);
1419
+ setOpenState(false);
1420
+ requestAnimationFrame(() => triggerRef.current?.focus());
1421
+ },
1422
+ [setValueState, setOpenState]
1423
+ );
1424
+ const ctx = useMemo(
1425
+ () => ({
1426
+ open: openState,
1427
+ setOpen: setOpenState,
1428
+ value: valueState,
1429
+ onSelect,
1430
+ triggerRef,
1431
+ labels,
1432
+ registerLabel,
1433
+ unregisterLabel,
1434
+ disabled,
1435
+ name,
1436
+ invalid
1437
+ }),
1438
+ [
1439
+ openState,
1440
+ setOpenState,
1441
+ valueState,
1442
+ onSelect,
1443
+ labels,
1444
+ registerLabel,
1445
+ unregisterLabel,
1446
+ disabled,
1447
+ name,
1448
+ invalid
1449
+ ]
1450
+ );
1451
+ return /* @__PURE__ */ jsx(SelectContext.Provider, { value: ctx, children });
1452
+ }
1453
+ var SelectTrigger = forwardRef(
1454
+ function SelectTrigger2({ size, state, className, onClick, children, ...rest }, forwardedRef) {
1455
+ const ctx = useSelectContext();
1456
+ const triggerState = state ?? (ctx.invalid ? "invalid" : "default");
1457
+ return /* @__PURE__ */ jsxs(
1458
+ "button",
1459
+ {
1460
+ ref: composeRefs(forwardedRef, ctx.triggerRef),
1461
+ type: "button",
1462
+ "aria-haspopup": "listbox",
1463
+ "aria-expanded": ctx.open,
1464
+ "data-state": ctx.open ? "open" : "closed",
1465
+ disabled: ctx.disabled,
1466
+ onClick: (e) => {
1467
+ onClick?.(e);
1468
+ if (e.defaultPrevented) return;
1469
+ ctx.setOpen(!ctx.open);
1470
+ },
1471
+ className: cn(selectTriggerVariants({ size, state: triggerState }), className),
1472
+ ...rest,
1473
+ children: [
1474
+ children ?? /* @__PURE__ */ jsx(SelectValue, {}),
1475
+ /* @__PURE__ */ jsx(
1476
+ ChevronDown,
1477
+ {
1478
+ className: cn(
1479
+ "h-4 w-4 text-muted-foreground transition-transform",
1480
+ ctx.open && "rotate-180"
1481
+ )
1482
+ }
1483
+ )
1484
+ ]
1485
+ }
1486
+ );
1487
+ }
1488
+ );
1489
+ function SelectValue({ placeholder, children }) {
1490
+ const ctx = useSelectContext();
1491
+ if (children) return /* @__PURE__ */ jsx("span", { className: "truncate", children });
1492
+ const label = ctx.value ? ctx.labels[ctx.value] ?? ctx.value : null;
1493
+ return /* @__PURE__ */ jsx("span", { className: cn("truncate", !label && "text-subtle-foreground"), children: label ?? placeholder });
1494
+ }
1495
+ function SelectContent({
1496
+ className,
1497
+ placement = "bottom",
1498
+ offset = 6,
1499
+ children
1500
+ }) {
1501
+ const ctx = useSelectContext();
1502
+ if (!ctx.open) return null;
1503
+ return /* @__PURE__ */ jsxs(Portal, { children: [
1504
+ /* @__PURE__ */ jsx(AnchoredPositioner, { anchor: ctx.triggerRef.current, placement, offset, children: /* @__PURE__ */ jsx(FocusScope, { asChild: true, trapped: true, loop: true, children: /* @__PURE__ */ jsx(
1505
+ DismissableLayer,
1506
+ {
1507
+ onEscape: () => ctx.setOpen(false),
1508
+ onOutsidePointerDown: (e) => {
1509
+ if (ctx.triggerRef.current?.contains(e.target)) return;
1510
+ ctx.setOpen(false);
1511
+ },
1512
+ children: /* @__PURE__ */ jsx(
1513
+ Listbox,
1514
+ {
1515
+ value: ctx.value,
1516
+ onValueChange: (v) => ctx.onSelect(v),
1517
+ className: cn("min-w-[var(--radix-anchor-width)]", className),
1518
+ style: ctx.triggerRef.current ? { minWidth: ctx.triggerRef.current.offsetWidth } : void 0,
1519
+ children
1520
+ }
1521
+ )
1522
+ }
1523
+ ) }) }),
1524
+ ctx.name && /* @__PURE__ */ jsx("input", { type: "hidden", name: ctx.name, value: ctx.value })
1525
+ ] });
1526
+ }
1527
+ var SelectItem = forwardRef(function SelectItem2(props, ref) {
1528
+ const ctx = useSelectContext();
1529
+ useEffect(() => {
1530
+ ctx.registerLabel(props.value, props.children);
1531
+ return () => ctx.unregisterLabel(props.value);
1532
+ }, [ctx, props.value, props.children]);
1533
+ return /* @__PURE__ */ jsx(ListboxItem, { ref, ...props });
1534
+ });
1535
+ Select.Trigger = SelectTrigger;
1536
+ Select.Value = SelectValue;
1537
+ Select.Content = SelectContent;
1538
+ Select.Item = SelectItem;
1539
+ Select.Group = ListboxGroup;
1540
+ Select.Separator = ListboxSeparator;
1541
+ Select.Empty = ListboxEmpty;
1542
+ var MultiSelectContext = createContext(null);
1543
+ function useMultiSelectContext() {
1544
+ const ctx = useContext(MultiSelectContext);
1545
+ if (!ctx) throw new Error("MultiSelect.* must be used inside <MultiSelect>");
1546
+ return ctx;
1547
+ }
1548
+ function MultiSelect({
1549
+ value,
1550
+ defaultValue,
1551
+ onValueChange,
1552
+ disabled = false,
1553
+ name,
1554
+ invalid,
1555
+ defaultOpen = false,
1556
+ open: openProp,
1557
+ onOpenChange,
1558
+ children
1559
+ }) {
1560
+ const [openState, setOpenState] = useControlled({
1561
+ controlled: openProp,
1562
+ default: defaultOpen,
1563
+ onChange: onOpenChange
1564
+ });
1565
+ const [valuesState, setValuesState] = useControlled({
1566
+ controlled: value,
1567
+ default: defaultValue ?? [],
1568
+ onChange: onValueChange
1569
+ });
1570
+ const triggerRef = useRef(null);
1571
+ const [labels, setLabels] = useState({});
1572
+ const registerLabel = useCallback((v, label) => {
1573
+ setLabels((prev) => prev[v] === label ? prev : { ...prev, [v]: label });
1574
+ }, []);
1575
+ const unregisterLabel = useCallback((v) => {
1576
+ setLabels((prev) => {
1577
+ if (!(v in prev)) return prev;
1578
+ const next = { ...prev };
1579
+ delete next[v];
1580
+ return next;
1581
+ });
1582
+ }, []);
1583
+ const ctx = useMemo(
1584
+ () => ({
1585
+ open: openState,
1586
+ setOpen: setOpenState,
1587
+ values: valuesState,
1588
+ setValues: setValuesState,
1589
+ triggerRef,
1590
+ labels,
1591
+ registerLabel,
1592
+ unregisterLabel,
1593
+ disabled,
1594
+ name,
1595
+ invalid
1596
+ }),
1597
+ [
1598
+ openState,
1599
+ setOpenState,
1600
+ valuesState,
1601
+ setValuesState,
1602
+ labels,
1603
+ registerLabel,
1604
+ unregisterLabel,
1605
+ disabled,
1606
+ name,
1607
+ invalid
1608
+ ]
1609
+ );
1610
+ return /* @__PURE__ */ jsx(MultiSelectContext.Provider, { value: ctx, children });
1611
+ }
1612
+ var MultiSelectTrigger = forwardRef(
1613
+ function MultiSelectTrigger2({ size, state, className, onClick, onKeyDown, children, ...rest }, forwardedRef) {
1614
+ const ctx = useMultiSelectContext();
1615
+ const triggerState = state ?? (ctx.invalid ? "invalid" : "default");
1616
+ return /* @__PURE__ */ jsxs(
1617
+ "button",
1618
+ {
1619
+ ref: composeRefs(forwardedRef, ctx.triggerRef),
1620
+ type: "button",
1621
+ "aria-haspopup": "listbox",
1622
+ "aria-expanded": ctx.open,
1623
+ "data-state": ctx.open ? "open" : "closed",
1624
+ disabled: ctx.disabled,
1625
+ onClick: (e) => {
1626
+ onClick?.(e);
1627
+ if (e.defaultPrevented) return;
1628
+ ctx.setOpen(!ctx.open);
1629
+ },
1630
+ onKeyDown: (e) => {
1631
+ onKeyDown?.(e);
1632
+ if (e.defaultPrevented) return;
1633
+ if (e.key === "Backspace" && ctx.values.length > 0) {
1634
+ ctx.setValues(ctx.values.slice(0, -1));
1635
+ }
1636
+ },
1637
+ className: cn(
1638
+ selectTriggerVariants({ size, state: triggerState }),
1639
+ "h-auto min-h-10 flex-wrap py-1.5",
1640
+ className
1641
+ ),
1642
+ ...rest,
1643
+ children: [
1644
+ children ?? /* @__PURE__ */ jsx(MultiSelectTags, {}),
1645
+ /* @__PURE__ */ jsx(
1646
+ ChevronDown,
1647
+ {
1648
+ className: cn(
1649
+ "h-4 w-4 shrink-0 self-center text-muted-foreground transition-transform",
1650
+ ctx.open && "rotate-180"
1651
+ )
1652
+ }
1653
+ )
1654
+ ]
1655
+ }
1656
+ );
1657
+ }
1658
+ );
1659
+ function MultiSelectTags({ placeholder }) {
1660
+ const ctx = useMultiSelectContext();
1661
+ if (ctx.values.length === 0) {
1662
+ return /* @__PURE__ */ jsx("span", { className: "text-subtle-foreground", children: placeholder });
1663
+ }
1664
+ return /* @__PURE__ */ jsx("span", { className: "flex flex-1 flex-wrap items-center gap-1", children: ctx.values.map((v) => /* @__PURE__ */ jsxs(
1665
+ "span",
1666
+ {
1667
+ className: "inline-flex items-center gap-1 rounded-sm bg-muted px-1.5 py-0.5 text-xs",
1668
+ children: [
1669
+ ctx.labels[v] ?? v,
1670
+ !ctx.disabled && /* @__PURE__ */ jsx(
1671
+ "span",
1672
+ {
1673
+ role: "button",
1674
+ tabIndex: -1,
1675
+ "aria-label": `Remove ${typeof ctx.labels[v] === "string" ? ctx.labels[v] : v}`,
1676
+ onClick: (e) => {
1677
+ e.stopPropagation();
1678
+ ctx.setValues(ctx.values.filter((x) => x !== v));
1679
+ },
1680
+ onPointerDown: (e) => e.stopPropagation(),
1681
+ className: "cursor-pointer rounded-sm p-0.5 hover:bg-border",
1682
+ children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
1683
+ }
1684
+ )
1685
+ ]
1686
+ },
1687
+ v
1688
+ )) });
1689
+ }
1690
+ function MultiSelectContent({
1691
+ className,
1692
+ placement = "bottom",
1693
+ offset = 6,
1694
+ children
1695
+ }) {
1696
+ const ctx = useMultiSelectContext();
1697
+ if (!ctx.open) return null;
1698
+ return /* @__PURE__ */ jsxs(Portal, { children: [
1699
+ /* @__PURE__ */ jsx(AnchoredPositioner, { anchor: ctx.triggerRef.current, placement, offset, children: /* @__PURE__ */ jsx(FocusScope, { asChild: true, trapped: true, loop: true, children: /* @__PURE__ */ jsx(
1700
+ DismissableLayer,
1701
+ {
1702
+ onEscape: () => {
1703
+ ctx.setOpen(false);
1704
+ requestAnimationFrame(() => ctx.triggerRef.current?.focus());
1705
+ },
1706
+ onOutsidePointerDown: (e) => {
1707
+ if (ctx.triggerRef.current?.contains(e.target)) return;
1708
+ ctx.setOpen(false);
1709
+ },
1710
+ children: /* @__PURE__ */ jsx(
1711
+ Listbox,
1712
+ {
1713
+ multiple: true,
1714
+ value: ctx.values,
1715
+ onValueChange: (v) => ctx.setValues(v),
1716
+ className: cn(className),
1717
+ style: ctx.triggerRef.current ? { minWidth: ctx.triggerRef.current.offsetWidth } : void 0,
1718
+ children
1719
+ }
1720
+ )
1721
+ }
1722
+ ) }) }),
1723
+ ctx.name && ctx.values.map((v) => /* @__PURE__ */ jsx("input", { type: "hidden", name: ctx.name, value: v }, v))
1724
+ ] });
1725
+ }
1726
+ var MultiSelectItem = forwardRef(
1727
+ function MultiSelectItem2(props, ref) {
1728
+ const ctx = useMultiSelectContext();
1729
+ useEffect(() => {
1730
+ ctx.registerLabel(props.value, props.children);
1731
+ return () => ctx.unregisterLabel(props.value);
1732
+ }, [ctx, props.value, props.children]);
1733
+ return /* @__PURE__ */ jsx(ListboxItem, { ref, ...props });
1734
+ }
1735
+ );
1736
+ MultiSelect.Trigger = MultiSelectTrigger;
1737
+ MultiSelect.Tags = MultiSelectTags;
1738
+ MultiSelect.Content = MultiSelectContent;
1739
+ MultiSelect.Item = MultiSelectItem;
1740
+ MultiSelect.Group = ListboxGroup;
1741
+ MultiSelect.Separator = ListboxSeparator;
1742
+ MultiSelect.Empty = ListboxEmpty;
1743
+ var ComboboxContext = createContext(null);
1744
+ function useComboboxContext() {
1745
+ const ctx = useContext(ComboboxContext);
1746
+ if (!ctx) throw new Error("Combobox.* must be used inside <Combobox>");
1747
+ return ctx;
1748
+ }
1749
+ function Combobox({
1750
+ value,
1751
+ defaultValue,
1752
+ onValueChange,
1753
+ inputValue,
1754
+ defaultInputValue,
1755
+ onInputChange,
1756
+ disabled = false,
1757
+ invalid,
1758
+ name,
1759
+ defaultOpen = false,
1760
+ open: openProp,
1761
+ onOpenChange,
1762
+ fillInputOnSelect = true,
1763
+ children
1764
+ }) {
1765
+ const [openState, setOpenState] = useControlled({
1766
+ controlled: openProp,
1767
+ default: defaultOpen,
1768
+ onChange: onOpenChange
1769
+ });
1770
+ const [valueState, setValueState] = useControlled({
1771
+ controlled: value,
1772
+ default: defaultValue ?? "",
1773
+ onChange: onValueChange
1774
+ });
1775
+ const [inputState, setInputState] = useControlled({
1776
+ controlled: inputValue,
1777
+ default: defaultInputValue ?? "",
1778
+ onChange: onInputChange
1779
+ });
1780
+ const itemsRef = useRef([]);
1781
+ const inputRef = useRef(null);
1782
+ const [activeId, setActiveId] = useState(null);
1783
+ const listboxId = useId$1();
1784
+ const registerItem = useCallback((entry) => {
1785
+ const idx = itemsRef.current.findIndex((i) => i.id === entry.id);
1786
+ if (idx >= 0) itemsRef.current[idx] = entry;
1787
+ else itemsRef.current.push(entry);
1788
+ }, []);
1789
+ const unregisterItem = useCallback((id) => {
1790
+ itemsRef.current = itemsRef.current.filter((i) => i.id !== id);
1791
+ }, []);
1792
+ const selectItem = useCallback(
1793
+ (entry, opts) => {
1794
+ setValueState(entry.value);
1795
+ if (fillInputOnSelect) {
1796
+ const text = typeof entry.label === "string" ? entry.label : entry.value;
1797
+ setInputState(text);
1798
+ }
1799
+ if (opts?.close ?? true) setOpenState(false);
1800
+ },
1801
+ [setValueState, setInputState, setOpenState, fillInputOnSelect]
1802
+ );
1803
+ const ctx = useMemo(
1804
+ () => ({
1805
+ open: openState,
1806
+ setOpen: setOpenState,
1807
+ value: valueState,
1808
+ setValue: setValueState,
1809
+ inputValue: inputState,
1810
+ setInputValue: setInputState,
1811
+ activeId,
1812
+ setActiveId,
1813
+ registerItem,
1814
+ unregisterItem,
1815
+ itemsRef,
1816
+ inputRef,
1817
+ listboxId,
1818
+ disabled,
1819
+ invalid,
1820
+ selectItem
1821
+ }),
1822
+ [
1823
+ openState,
1824
+ setOpenState,
1825
+ valueState,
1826
+ setValueState,
1827
+ inputState,
1828
+ setInputState,
1829
+ activeId,
1830
+ registerItem,
1831
+ unregisterItem,
1832
+ listboxId,
1833
+ disabled,
1834
+ invalid,
1835
+ selectItem
1836
+ ]
1837
+ );
1838
+ return /* @__PURE__ */ jsxs(ComboboxContext.Provider, { value: ctx, children: [
1839
+ children,
1840
+ name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: valueState })
1841
+ ] });
1842
+ }
1843
+ var ComboboxInput = forwardRef(
1844
+ function ComboboxInput2({ className, size, state, onKeyDown, onFocus, ...rest }, forwardedRef) {
1845
+ const ctx = useComboboxContext();
1846
+ const inputState = state ?? (ctx.invalid ? "invalid" : "default");
1847
+ const moveActive = useCallback(
1848
+ (direction) => {
1849
+ const list = ctx.itemsRef.current.filter((i) => !i.disabled);
1850
+ if (list.length === 0) return;
1851
+ const idx = list.findIndex((i) => i.id === ctx.activeId);
1852
+ let nextIdx = idx + direction;
1853
+ if (idx === -1) nextIdx = direction === 1 ? 0 : list.length - 1;
1854
+ if (nextIdx < 0) nextIdx = list.length - 1;
1855
+ if (nextIdx >= list.length) nextIdx = 0;
1856
+ const next = list[nextIdx];
1857
+ if (next) ctx.setActiveId(next.id);
1858
+ },
1859
+ [ctx]
1860
+ );
1861
+ const handleKeyDown = (e) => {
1862
+ onKeyDown?.(e);
1863
+ if (e.defaultPrevented || ctx.disabled) return;
1864
+ switch (e.key) {
1865
+ case "ArrowDown":
1866
+ e.preventDefault();
1867
+ if (!ctx.open) ctx.setOpen(true);
1868
+ else moveActive(1);
1869
+ break;
1870
+ case "ArrowUp":
1871
+ e.preventDefault();
1872
+ if (!ctx.open) ctx.setOpen(true);
1873
+ else moveActive(-1);
1874
+ break;
1875
+ case "Home":
1876
+ if (ctx.open) {
1877
+ e.preventDefault();
1878
+ const first = ctx.itemsRef.current.find((i) => !i.disabled);
1879
+ if (first) ctx.setActiveId(first.id);
1880
+ }
1881
+ break;
1882
+ case "End":
1883
+ if (ctx.open) {
1884
+ e.preventDefault();
1885
+ const list = ctx.itemsRef.current.filter((i) => !i.disabled);
1886
+ const last = list[list.length - 1];
1887
+ if (last) ctx.setActiveId(last.id);
1888
+ }
1889
+ break;
1890
+ case "Enter": {
1891
+ if (!ctx.open || !ctx.activeId) return;
1892
+ const entry = ctx.itemsRef.current.find((i) => i.id === ctx.activeId);
1893
+ if (!entry || entry.disabled) return;
1894
+ e.preventDefault();
1895
+ ctx.selectItem(entry);
1896
+ break;
1897
+ }
1898
+ case "Escape":
1899
+ if (ctx.open) {
1900
+ e.preventDefault();
1901
+ ctx.setOpen(false);
1902
+ } else if (ctx.inputValue) {
1903
+ e.preventDefault();
1904
+ ctx.setInputValue("");
1905
+ ctx.setValue("");
1906
+ }
1907
+ break;
1908
+ }
1909
+ };
1910
+ return /* @__PURE__ */ jsx(
1911
+ "input",
1912
+ {
1913
+ ref: composeRefs(forwardedRef, ctx.inputRef),
1914
+ type: "text",
1915
+ role: "combobox",
1916
+ "aria-expanded": ctx.open,
1917
+ "aria-controls": ctx.listboxId,
1918
+ "aria-activedescendant": ctx.activeId ?? void 0,
1919
+ "aria-autocomplete": "list",
1920
+ "aria-disabled": ctx.disabled || void 0,
1921
+ disabled: ctx.disabled,
1922
+ value: ctx.inputValue,
1923
+ onChange: (e) => {
1924
+ ctx.setInputValue(e.target.value);
1925
+ if (!ctx.open) ctx.setOpen(true);
1926
+ ctx.setActiveId(null);
1927
+ },
1928
+ onFocus: (e) => {
1929
+ onFocus?.(e);
1930
+ if (!ctx.open) ctx.setOpen(true);
1931
+ },
1932
+ onKeyDown: handleKeyDown,
1933
+ className: cn(inputBaseVariants({ size, state: inputState }), className),
1934
+ ...rest
1935
+ }
1936
+ );
1937
+ }
1938
+ );
1939
+ function ComboboxContent({
1940
+ className,
1941
+ placement = "bottom",
1942
+ offset = 6,
1943
+ children
1944
+ }) {
1945
+ const ctx = useComboboxContext();
1946
+ if (!ctx.open) return null;
1947
+ return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(AnchoredPositioner, { anchor: ctx.inputRef.current, placement, offset, children: /* @__PURE__ */ jsx(
1948
+ DismissableLayer,
1949
+ {
1950
+ onEscape: () => ctx.setOpen(false),
1951
+ onOutsidePointerDown: (e) => {
1952
+ if (ctx.inputRef.current?.contains(e.target)) return;
1953
+ ctx.setOpen(false);
1954
+ },
1955
+ children: /* @__PURE__ */ jsx(
1956
+ "div",
1957
+ {
1958
+ id: ctx.listboxId,
1959
+ role: "listbox",
1960
+ className: cn(listboxVariants(), className),
1961
+ style: ctx.inputRef.current ? { minWidth: ctx.inputRef.current.offsetWidth } : void 0,
1962
+ children
1963
+ }
1964
+ )
1965
+ }
1966
+ ) }) });
1967
+ }
1968
+ var ComboboxItem = forwardRef(function ComboboxItem2({ value, disabled = false, className, children, onClick, onPointerEnter, ...rest }, forwardedRef) {
1969
+ const ctx = useComboboxContext();
1970
+ const id = useId$1();
1971
+ useEffect(() => {
1972
+ ctx.registerItem({ id, value, disabled, label: children });
1973
+ return () => ctx.unregisterItem(id);
1974
+ }, [ctx, id, value, disabled, children]);
1975
+ useEffect(() => {
1976
+ if (!ctx.activeId) {
1977
+ const list = ctx.itemsRef.current.filter((i) => !i.disabled);
1978
+ if (list[0]) ctx.setActiveId(list[0].id);
1979
+ }
1980
+ }, [ctx]);
1981
+ const isSelected = ctx.value === value;
1982
+ const isActive = ctx.activeId === id;
1983
+ const state = disabled ? "disabled" : isSelected ? "selected" : isActive ? "active" : "default";
1984
+ return /* @__PURE__ */ jsxs(
1985
+ "div",
1986
+ {
1987
+ ref: forwardedRef,
1988
+ id,
1989
+ role: "option",
1990
+ "aria-selected": isSelected,
1991
+ "aria-disabled": disabled || void 0,
1992
+ "data-active": isActive ? "" : void 0,
1993
+ "data-selected": isSelected ? "" : void 0,
1994
+ onClick: (e) => {
1995
+ onClick?.(e);
1996
+ if (e.defaultPrevented || disabled) return;
1997
+ ctx.selectItem({ id, value, disabled, label: children });
1998
+ },
1999
+ onPointerEnter: (e) => {
2000
+ onPointerEnter?.(e);
2001
+ if (!disabled) ctx.setActiveId(id);
2002
+ },
2003
+ className: cn(listboxItemVariants({ state }), className),
2004
+ ...rest,
2005
+ children: [
2006
+ /* @__PURE__ */ jsx("span", { className: "flex-1", children }),
2007
+ isSelected && /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 opacity-80" })
2008
+ ]
2009
+ }
2010
+ );
2011
+ });
2012
+ function ComboboxGroup({ label, children, className, ...rest }) {
2013
+ const labelId = useId$1();
2014
+ return /* @__PURE__ */ jsxs("div", { role: "group", "aria-labelledby": label ? labelId : void 0, className, ...rest, children: [
2015
+ label && /* @__PURE__ */ jsx("div", { id: labelId, className: listboxGroupLabelVariants(), children: label }),
2016
+ children
2017
+ ] });
2018
+ }
2019
+ function ComboboxSeparator(props) {
2020
+ return /* @__PURE__ */ jsx("div", { role: "separator", className: listboxSeparatorVariants(), ...props });
2021
+ }
2022
+ function ComboboxEmpty({ children, className, ...rest }) {
2023
+ return /* @__PURE__ */ jsx("div", { role: "presentation", className: cn(listboxEmptyVariants(), className), ...rest, children });
2024
+ }
2025
+ Combobox.Input = ComboboxInput;
2026
+ Combobox.Content = ComboboxContent;
2027
+ Combobox.Item = ComboboxItem;
2028
+ Combobox.Group = ComboboxGroup;
2029
+ Combobox.Separator = ComboboxSeparator;
2030
+ Combobox.Empty = ComboboxEmpty;
2031
+
2032
+ export { CharacterCount, Checkbox, CheckboxField, CheckboxGroup, ChoiceCard, Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxSeparator, CurrencyInput, EmailInput, Fieldset, FilePicker, FormErrorMessage, FormField, FormHelperText, InputAddon, InputGroup, Label, LabeledInput, Legend, Listbox, ListboxEmpty, ListboxGroup, ListboxItem, ListboxSeparator, MaskedInput, MultiSelect, MultiSelectContent, MultiSelectItem, MultiSelectTags, MultiSelectTrigger, NumberInput, PasswordInput, PasswordStrength, PercentInput, PinInput, Radio, RadioField, RadioGroup, SearchInput, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider, Switch, SwitchField, TelInput, TextInput, Textarea, UrlInput };
2033
+ //# sourceMappingURL=chunk-SBVWECJP.js.map
2034
+ //# sourceMappingURL=chunk-SBVWECJP.js.map