@caqophony/ui 0.7.0 → 0.9.0
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/index.d.mts +55 -1
- package/dist/index.js +325 -55
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1125,6 +1125,33 @@ declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & Reac
|
|
|
1125
1125
|
* page. A picked option's label is kept, so the field still names it after the
|
|
1126
1126
|
* caller replaces `options` with another search's results.
|
|
1127
1127
|
*
|
|
1128
|
+
* In a form (#6524, kit 0.8.0): with `name`, the picked value is carried by a
|
|
1129
|
+
* hidden native `<select>` (`multiple` in multi mode), so `new FormData(form)`
|
|
1130
|
+
* reads it exactly as a native select's: one entry, `""` when cleared, in
|
|
1131
|
+
* single mode; one entry per value, none when empty, in multi mode. A pick or a
|
|
1132
|
+
* clear fires a bubbling `change` on that select, so the form's `onChange` sees
|
|
1133
|
+
* it as an edit; the start value never does. Without `value` the picker is
|
|
1134
|
+
* uncontrolled: it starts at `defaultValue` and returns to it on the form's
|
|
1135
|
+
* reset. `defaultLabel` names a start value that is not among `options` (a
|
|
1136
|
+
* record past a list's first page, named from its own detail read).
|
|
1137
|
+
*
|
|
1138
|
+
* Keyboard (#6699, kit 0.9.0), the WAI-ARIA APG select-only combobox
|
|
1139
|
+
* (https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/):
|
|
1140
|
+
* the trigger is a `<button role="combobox">` that takes `id`, so a
|
|
1141
|
+
* `<label htmlFor>` names and focuses it. Enter, Space and ArrowDown open it;
|
|
1142
|
+
* the rows are `role="option"` in a `role="listbox"`, walked by
|
|
1143
|
+
* `aria-activedescendant` (ArrowUp/ArrowDown, Home/End on the trigger); Enter
|
|
1144
|
+
* picks; Escape closes. After a pick or Escape focus is back on the trigger.
|
|
1145
|
+
* With a search box, focus moves into it on open and it takes the same keys;
|
|
1146
|
+
* Enter and Space open with no row active, so Enter in the search box picks
|
|
1147
|
+
* nothing until a row is arrowed to, and never submits the form. `size`,
|
|
1148
|
+
* `error` and `errorMessageId` draw the field as `Select` draws them.
|
|
1149
|
+
*
|
|
1150
|
+
* Load more (#6691): with `hasMore`, the list ends with a "Load more" option
|
|
1151
|
+
* (a button, reached by the arrows as a row) that calls `onLoadMore`; the
|
|
1152
|
+
* caller appends the next page to `options`, and the list stays open on the
|
|
1153
|
+
* first new row.
|
|
1154
|
+
*
|
|
1128
1155
|
* Issue #2633 — B-7: Advanced Form Family
|
|
1129
1156
|
* Authored by Caqophony
|
|
1130
1157
|
*/
|
|
@@ -1133,10 +1160,23 @@ interface ComboboxOption {
|
|
|
1133
1160
|
value: string;
|
|
1134
1161
|
label: string;
|
|
1135
1162
|
}
|
|
1136
|
-
interface ComboboxProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
1163
|
+
interface ComboboxProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {
|
|
1137
1164
|
options: ComboboxOption[];
|
|
1165
|
+
/** The picked value, controlled. Without it the picker keeps its own (`defaultValue`). */
|
|
1138
1166
|
value?: string | string[];
|
|
1139
1167
|
onChange?: (value: string | string[]) => void;
|
|
1168
|
+
/**
|
|
1169
|
+
* The form field name: the value is submitted under it, as a native select's
|
|
1170
|
+
* (one entry, `""` when cleared; in multi mode one per value, none when empty).
|
|
1171
|
+
*/
|
|
1172
|
+
name?: string;
|
|
1173
|
+
/** The uncontrolled start value, used when `value` is not given. */
|
|
1174
|
+
defaultValue?: string | string[];
|
|
1175
|
+
/**
|
|
1176
|
+
* The label of a start value that is not among `options`: one label in
|
|
1177
|
+
* single mode, labels by value in multi mode.
|
|
1178
|
+
*/
|
|
1179
|
+
defaultLabel?: string | Readonly<Record<string, string>>;
|
|
1140
1180
|
placeholder?: string;
|
|
1141
1181
|
multi?: boolean;
|
|
1142
1182
|
/** Filter `options` by the typed text here. Ignored with `onSearchChange`. */
|
|
@@ -1150,6 +1190,20 @@ interface ComboboxProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onCh
|
|
|
1150
1190
|
onSearchChange?: (text: string) => void;
|
|
1151
1191
|
/** How long typing pauses before `onSearchChange` is called (ms). */
|
|
1152
1192
|
searchDelayMs?: number;
|
|
1193
|
+
/** The id of the trigger (the focusable `role="combobox"`), for `<label htmlFor>`. */
|
|
1194
|
+
id?: string;
|
|
1195
|
+
/** The field's size, as `Select`'s. */
|
|
1196
|
+
size?: FieldSize;
|
|
1197
|
+
error?: boolean;
|
|
1198
|
+
/** ID of the element describing the error, for aria-describedby */
|
|
1199
|
+
errorMessageId?: string;
|
|
1200
|
+
/**
|
|
1201
|
+
* More rows exist past `options`: the list ends with a "Load more" option
|
|
1202
|
+
* that calls `onLoadMore`, and the caller appends the next page to `options`.
|
|
1203
|
+
*/
|
|
1204
|
+
hasMore?: boolean;
|
|
1205
|
+
/** Called by the "Load more" option (with `hasMore`). */
|
|
1206
|
+
onLoadMore?: () => void;
|
|
1153
1207
|
}
|
|
1154
1208
|
declare const Combobox: React.ForwardRefExoticComponent<ComboboxProps & React.RefAttributes<HTMLDivElement>>;
|
|
1155
1209
|
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,14 @@ var FIELD_HEIGHT = {
|
|
|
60
60
|
md: "h-11",
|
|
61
61
|
lg: "h-12"
|
|
62
62
|
};
|
|
63
|
+
var PICKER_CHEVRON = {
|
|
64
|
+
sm: { endPadding: "pr-8", inset: "right-2.5" },
|
|
65
|
+
md: { endPadding: "pr-9", inset: "right-3" },
|
|
66
|
+
lg: { endPadding: "pr-10", inset: "right-4" }
|
|
67
|
+
};
|
|
68
|
+
function pickerChevron(size) {
|
|
69
|
+
return PICKER_CHEVRON[size];
|
|
70
|
+
}
|
|
63
71
|
function fieldAria(error, errorMessageId) {
|
|
64
72
|
return {
|
|
65
73
|
"aria-invalid": error || void 0,
|
|
@@ -3329,25 +3337,47 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
3329
3337
|
|
|
3330
3338
|
// src/combobox.tsx
|
|
3331
3339
|
import * as React23 from "react";
|
|
3332
|
-
import { jsx as jsx34, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
3340
|
+
import { Fragment as Fragment7, jsx as jsx34, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
3333
3341
|
var SEARCH_DELAY_MS = 250;
|
|
3342
|
+
var MULTI_MIN_HEIGHT = {
|
|
3343
|
+
sm: "min-h-9",
|
|
3344
|
+
md: "min-h-11",
|
|
3345
|
+
lg: "min-h-12"
|
|
3346
|
+
};
|
|
3347
|
+
var NONE = -1;
|
|
3334
3348
|
var Combobox = React23.forwardRef(
|
|
3335
3349
|
({
|
|
3336
3350
|
className,
|
|
3337
3351
|
options,
|
|
3338
3352
|
value,
|
|
3339
3353
|
onChange,
|
|
3354
|
+
name,
|
|
3355
|
+
defaultValue,
|
|
3356
|
+
defaultLabel,
|
|
3340
3357
|
placeholder = "Select...",
|
|
3341
3358
|
multi = false,
|
|
3342
3359
|
filterable = true,
|
|
3343
3360
|
onSearchChange,
|
|
3344
3361
|
searchDelayMs = SEARCH_DELAY_MS,
|
|
3362
|
+
id,
|
|
3363
|
+
size = "md",
|
|
3364
|
+
error,
|
|
3365
|
+
errorMessageId,
|
|
3366
|
+
hasMore = false,
|
|
3367
|
+
onLoadMore,
|
|
3345
3368
|
...props
|
|
3346
3369
|
}, ref) => {
|
|
3347
3370
|
const [open, setOpen] = React23.useState(false);
|
|
3348
3371
|
const [search, setSearch] = React23.useState("");
|
|
3349
3372
|
const searchesOnServer = onSearchChange !== void 0;
|
|
3350
3373
|
const showsSearch = searchesOnServer || filterable;
|
|
3374
|
+
const autoId = React23.useId();
|
|
3375
|
+
const triggerId = id ?? `${autoId}-trigger`;
|
|
3376
|
+
const listboxId = `${triggerId}-listbox`;
|
|
3377
|
+
const optionId = (index) => `${listboxId}-option-${index}`;
|
|
3378
|
+
const loadMoreId = `${listboxId}-load-more`;
|
|
3379
|
+
const triggerRef = React23.useRef(null);
|
|
3380
|
+
const pressed = React23.useRef(false);
|
|
3351
3381
|
const onSearchRef = React23.useRef(onSearchChange);
|
|
3352
3382
|
onSearchRef.current = onSearchChange;
|
|
3353
3383
|
const sentRef = React23.useRef("");
|
|
@@ -3359,25 +3389,148 @@ var Combobox = React23.forwardRef(
|
|
|
3359
3389
|
}, searchDelayMs);
|
|
3360
3390
|
return () => clearTimeout(timer);
|
|
3361
3391
|
}, [search, searchesOnServer, searchDelayMs]);
|
|
3392
|
+
const controlled = value !== void 0;
|
|
3393
|
+
const [own, setOwn] = React23.useState(defaultValue);
|
|
3394
|
+
const current = controlled ? value : own;
|
|
3395
|
+
const interactive = !controlled || onChange !== void 0;
|
|
3396
|
+
const start = React23.useRef(controlled ? value : defaultValue);
|
|
3362
3397
|
const pickedLabels = React23.useRef(/* @__PURE__ */ new Map());
|
|
3363
|
-
const
|
|
3364
|
-
|
|
3398
|
+
const startLabelOf = (v) => {
|
|
3399
|
+
if (defaultLabel === void 0) return void 0;
|
|
3400
|
+
if (typeof defaultLabel === "string")
|
|
3401
|
+
return v === start.current ? defaultLabel : void 0;
|
|
3402
|
+
return Object.prototype.hasOwnProperty.call(defaultLabel, v) ? defaultLabel[v] : void 0;
|
|
3403
|
+
};
|
|
3404
|
+
const labelOf = (v) => options.find((o) => o.value === v)?.label ?? pickedLabels.current.get(v) ?? startLabelOf(v);
|
|
3405
|
+
const selected = multi ? Array.isArray(current) ? current : [] : typeof current === "string" ? current : "";
|
|
3406
|
+
const picks = Array.isArray(selected) ? selected : [];
|
|
3407
|
+
const pick = typeof selected === "string" ? selected : "";
|
|
3408
|
+
const formControl = React23.useRef(null);
|
|
3409
|
+
const announce = React23.useRef(false);
|
|
3410
|
+
const selectedKey = JSON.stringify(selected);
|
|
3411
|
+
React23.useEffect(() => {
|
|
3412
|
+
if (!announce.current) return;
|
|
3413
|
+
announce.current = false;
|
|
3414
|
+
formControl.current?.dispatchEvent(
|
|
3415
|
+
new Event("change", { bubbles: true })
|
|
3416
|
+
);
|
|
3417
|
+
}, [selectedKey]);
|
|
3418
|
+
React23.useEffect(() => {
|
|
3419
|
+
const form = formControl.current?.form;
|
|
3420
|
+
if (controlled || !form) return;
|
|
3421
|
+
const onReset = () => setOwn(start.current);
|
|
3422
|
+
form.addEventListener("reset", onReset);
|
|
3423
|
+
return () => form.removeEventListener("reset", onReset);
|
|
3424
|
+
}, [controlled]);
|
|
3425
|
+
const commit = (next) => {
|
|
3426
|
+
announce.current = name !== void 0 && JSON.stringify(next) !== selectedKey;
|
|
3427
|
+
if (!controlled) setOwn(next);
|
|
3428
|
+
onChange?.(next);
|
|
3429
|
+
};
|
|
3365
3430
|
const filtered = filterable && !searchesOnServer ? options.filter(
|
|
3366
3431
|
(o) => o.label.toLowerCase().includes(search.toLowerCase())
|
|
3367
3432
|
) : options;
|
|
3433
|
+
const rowCount = filtered.length + (hasMore ? 1 : 0);
|
|
3434
|
+
const [activeIndex, setActiveIndex] = React23.useState(NONE);
|
|
3435
|
+
const active = activeIndex < rowCount ? activeIndex : NONE;
|
|
3436
|
+
const activeId = !open || active === NONE ? void 0 : active === filtered.length ? loadMoreId : optionId(active);
|
|
3437
|
+
React23.useEffect(() => {
|
|
3438
|
+
if (activeId === void 0) return;
|
|
3439
|
+
document.getElementById(activeId)?.scrollIntoView({ block: "nearest" });
|
|
3440
|
+
}, [activeId]);
|
|
3441
|
+
const close = () => {
|
|
3442
|
+
setOpen(false);
|
|
3443
|
+
setActiveIndex(NONE);
|
|
3444
|
+
triggerRef.current?.focus();
|
|
3445
|
+
};
|
|
3446
|
+
const openList = (activeRow) => {
|
|
3447
|
+
setActiveIndex(activeRow);
|
|
3448
|
+
setOpen(true);
|
|
3449
|
+
};
|
|
3450
|
+
const pickedRow = () => {
|
|
3451
|
+
const at = filtered.findIndex((o) => o.value === pick);
|
|
3452
|
+
return at === NONE ? 0 : at;
|
|
3453
|
+
};
|
|
3454
|
+
const loadMore = () => {
|
|
3455
|
+
setActiveIndex(filtered.length);
|
|
3456
|
+
onLoadMore?.();
|
|
3457
|
+
};
|
|
3368
3458
|
const handleSelect = (optValue) => {
|
|
3369
|
-
if (!
|
|
3459
|
+
if (!interactive) return;
|
|
3370
3460
|
const picked = options.find((o) => o.value === optValue);
|
|
3371
3461
|
if (picked) pickedLabels.current.set(picked.value, picked.label);
|
|
3372
3462
|
if (multi) {
|
|
3373
3463
|
const arr = Array.isArray(selected) ? selected : [];
|
|
3374
|
-
|
|
3464
|
+
commit(
|
|
3375
3465
|
arr.includes(optValue) ? arr.filter((v) => v !== optValue) : [...arr, optValue]
|
|
3376
3466
|
);
|
|
3377
3467
|
} else {
|
|
3378
|
-
|
|
3379
|
-
setOpen(false);
|
|
3468
|
+
commit(optValue);
|
|
3380
3469
|
setSearch("");
|
|
3470
|
+
close();
|
|
3471
|
+
}
|
|
3472
|
+
};
|
|
3473
|
+
const chooseActive = () => {
|
|
3474
|
+
if (active === NONE) return;
|
|
3475
|
+
if (active === filtered.length) loadMore();
|
|
3476
|
+
else handleSelect(filtered[active].value);
|
|
3477
|
+
};
|
|
3478
|
+
const onListKey = (e, inSearch) => {
|
|
3479
|
+
const last = rowCount - 1;
|
|
3480
|
+
switch (e.key) {
|
|
3481
|
+
case "ArrowDown":
|
|
3482
|
+
e.preventDefault();
|
|
3483
|
+
setActiveIndex(active === NONE ? 0 : Math.min(active + 1, last));
|
|
3484
|
+
return;
|
|
3485
|
+
case "ArrowUp":
|
|
3486
|
+
e.preventDefault();
|
|
3487
|
+
setActiveIndex(active === NONE ? last : Math.max(active - 1, 0));
|
|
3488
|
+
return;
|
|
3489
|
+
case "Home":
|
|
3490
|
+
case "End":
|
|
3491
|
+
if (inSearch) return;
|
|
3492
|
+
e.preventDefault();
|
|
3493
|
+
setActiveIndex(e.key === "Home" ? 0 : last);
|
|
3494
|
+
return;
|
|
3495
|
+
case "Enter":
|
|
3496
|
+
e.preventDefault();
|
|
3497
|
+
chooseActive();
|
|
3498
|
+
return;
|
|
3499
|
+
case " ":
|
|
3500
|
+
if (inSearch) return;
|
|
3501
|
+
e.preventDefault();
|
|
3502
|
+
chooseActive();
|
|
3503
|
+
return;
|
|
3504
|
+
case "Escape":
|
|
3505
|
+
e.preventDefault();
|
|
3506
|
+
e.stopPropagation();
|
|
3507
|
+
close();
|
|
3508
|
+
return;
|
|
3509
|
+
default:
|
|
3510
|
+
return;
|
|
3511
|
+
}
|
|
3512
|
+
};
|
|
3513
|
+
const onTriggerKeyDown = (e) => {
|
|
3514
|
+
if (open) {
|
|
3515
|
+
onListKey(e, false);
|
|
3516
|
+
return;
|
|
3517
|
+
}
|
|
3518
|
+
switch (e.key) {
|
|
3519
|
+
case "Enter":
|
|
3520
|
+
case " ":
|
|
3521
|
+
e.preventDefault();
|
|
3522
|
+
openList(NONE);
|
|
3523
|
+
return;
|
|
3524
|
+
case "ArrowDown":
|
|
3525
|
+
e.preventDefault();
|
|
3526
|
+
openList(pickedRow());
|
|
3527
|
+
return;
|
|
3528
|
+
case "ArrowUp":
|
|
3529
|
+
e.preventDefault();
|
|
3530
|
+
openList(pick === "" ? Math.max(rowCount - 1, 0) : pickedRow());
|
|
3531
|
+
return;
|
|
3532
|
+
default:
|
|
3533
|
+
return;
|
|
3381
3534
|
}
|
|
3382
3535
|
};
|
|
3383
3536
|
const displayValue = multi || typeof selected !== "string" ? null : labelOf(selected);
|
|
@@ -3385,10 +3538,27 @@ var Combobox = React23.forwardRef(
|
|
|
3385
3538
|
/* @__PURE__ */ jsxs27(
|
|
3386
3539
|
"div",
|
|
3387
3540
|
{
|
|
3388
|
-
className:
|
|
3389
|
-
|
|
3541
|
+
className: cn(
|
|
3542
|
+
"relative flex cursor-pointer items-center gap-1",
|
|
3543
|
+
multi ? MULTI_MIN_HEIGHT[size] : FIELD_HEIGHT[size],
|
|
3544
|
+
fieldVariants({ size, error: Boolean(error) }),
|
|
3545
|
+
pickerChevron(size).endPadding,
|
|
3546
|
+
"has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-offset-2",
|
|
3547
|
+
error ? "has-[:focus-visible]:ring-intent-error" : "has-[:focus-visible]:ring-ring"
|
|
3548
|
+
),
|
|
3549
|
+
onPointerDown: () => {
|
|
3550
|
+
pressed.current = true;
|
|
3551
|
+
},
|
|
3552
|
+
onClick: () => {
|
|
3553
|
+
const byPointer = pressed.current;
|
|
3554
|
+
pressed.current = false;
|
|
3555
|
+
triggerRef.current?.focus();
|
|
3556
|
+
if (!byPointer) return;
|
|
3557
|
+
if (open) setActiveIndex(NONE);
|
|
3558
|
+
setOpen(!open);
|
|
3559
|
+
},
|
|
3390
3560
|
children: [
|
|
3391
|
-
multi &&
|
|
3561
|
+
multi && picks.length > 0 && /* @__PURE__ */ jsx34("div", { className: "flex flex-wrap gap-1", children: picks.map((v) => /* @__PURE__ */ jsxs27(
|
|
3392
3562
|
"span",
|
|
3393
3563
|
{
|
|
3394
3564
|
className: "text-primary-text inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-0.5 text-xs font-medium",
|
|
@@ -3398,8 +3568,10 @@ var Combobox = React23.forwardRef(
|
|
|
3398
3568
|
"button",
|
|
3399
3569
|
{
|
|
3400
3570
|
type: "button",
|
|
3571
|
+
"aria-label": `Remove ${labelOf(v) ?? v}`,
|
|
3401
3572
|
onClick: (e) => {
|
|
3402
3573
|
e.stopPropagation();
|
|
3574
|
+
pressed.current = false;
|
|
3403
3575
|
handleSelect(v);
|
|
3404
3576
|
},
|
|
3405
3577
|
className: "text-primary-text hover:opacity-80",
|
|
@@ -3409,20 +3581,77 @@ var Combobox = React23.forwardRef(
|
|
|
3409
3581
|
]
|
|
3410
3582
|
},
|
|
3411
3583
|
v
|
|
3412
|
-
)) })
|
|
3413
|
-
|
|
3584
|
+
)) }),
|
|
3585
|
+
/* @__PURE__ */ jsx34(
|
|
3586
|
+
"button",
|
|
3414
3587
|
{
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3588
|
+
ref: triggerRef,
|
|
3589
|
+
id: triggerId,
|
|
3590
|
+
type: "button",
|
|
3591
|
+
role: "combobox",
|
|
3592
|
+
"aria-expanded": open,
|
|
3593
|
+
"aria-controls": listboxId,
|
|
3594
|
+
"aria-haspopup": "listbox",
|
|
3595
|
+
"aria-activedescendant": activeId,
|
|
3596
|
+
...fieldAria(error, errorMessageId),
|
|
3597
|
+
className: "min-w-0 flex-1 cursor-pointer truncate text-left focus-visible:outline-none",
|
|
3598
|
+
onKeyDown: onTriggerKeyDown,
|
|
3599
|
+
children: multi ? picks.length > 0 ? /* @__PURE__ */ jsx34("span", { className: "sr-only", children: picks.map((v) => labelOf(v) ?? v).join(", ") }) : /* @__PURE__ */ jsx34("span", { className: "text-muted-foreground", children: placeholder }) : /* @__PURE__ */ jsx34(
|
|
3600
|
+
"span",
|
|
3601
|
+
{
|
|
3602
|
+
className: cn(
|
|
3603
|
+
displayValue ? "text-foreground" : "text-muted-foreground"
|
|
3604
|
+
),
|
|
3605
|
+
children: displayValue || placeholder
|
|
3606
|
+
}
|
|
3607
|
+
)
|
|
3608
|
+
}
|
|
3609
|
+
),
|
|
3610
|
+
!multi && interactive && selected !== "" && /* @__PURE__ */ jsx34(
|
|
3611
|
+
"button",
|
|
3612
|
+
{
|
|
3613
|
+
type: "button",
|
|
3614
|
+
"aria-label": "Clear",
|
|
3615
|
+
className: "text-xs text-muted-foreground hover:text-foreground",
|
|
3616
|
+
onClick: (e) => {
|
|
3617
|
+
e.stopPropagation();
|
|
3618
|
+
pressed.current = false;
|
|
3619
|
+
commit("");
|
|
3620
|
+
},
|
|
3621
|
+
children: "\u2715"
|
|
3420
3622
|
}
|
|
3421
3623
|
),
|
|
3422
|
-
/* @__PURE__ */ jsx34(
|
|
3624
|
+
/* @__PURE__ */ jsx34(
|
|
3625
|
+
Icon,
|
|
3626
|
+
{
|
|
3627
|
+
name: "chevron-down",
|
|
3628
|
+
size: "sm",
|
|
3629
|
+
className: cn(
|
|
3630
|
+
"pointer-events-none absolute top-1/2 -translate-y-1/2 text-muted-foreground",
|
|
3631
|
+
pickerChevron(size).inset
|
|
3632
|
+
)
|
|
3633
|
+
}
|
|
3634
|
+
)
|
|
3423
3635
|
]
|
|
3424
3636
|
}
|
|
3425
3637
|
),
|
|
3638
|
+
name !== void 0 && /* @__PURE__ */ jsx34(
|
|
3639
|
+
"select",
|
|
3640
|
+
{
|
|
3641
|
+
ref: formControl,
|
|
3642
|
+
name,
|
|
3643
|
+
multiple: multi,
|
|
3644
|
+
value: selected,
|
|
3645
|
+
onChange: () => void 0,
|
|
3646
|
+
hidden: true,
|
|
3647
|
+
"aria-hidden": true,
|
|
3648
|
+
tabIndex: -1,
|
|
3649
|
+
children: multi ? picks.map((v) => /* @__PURE__ */ jsx34("option", { value: v, children: v }, v)) : /* @__PURE__ */ jsxs27(Fragment7, { children: [
|
|
3650
|
+
/* @__PURE__ */ jsx34("option", { value: "" }),
|
|
3651
|
+
pick !== "" && /* @__PURE__ */ jsx34("option", { value: pick, children: pick }, pick)
|
|
3652
|
+
] })
|
|
3653
|
+
}
|
|
3654
|
+
),
|
|
3426
3655
|
open && /* @__PURE__ */ jsxs27("div", { className: "z-dropdown absolute mt-1 w-full rounded-md border border-border bg-card shadow-lg", children: [
|
|
3427
3656
|
showsSearch && /* @__PURE__ */ jsx34("div", { className: "border-b border-border p-2", children: /* @__PURE__ */ jsx34(
|
|
3428
3657
|
"input",
|
|
@@ -3430,31 +3659,82 @@ var Combobox = React23.forwardRef(
|
|
|
3430
3659
|
type: "text",
|
|
3431
3660
|
className: "w-full rounded border-0 bg-transparent px-2 py-1 text-sm text-foreground outline-none placeholder:text-muted-foreground",
|
|
3432
3661
|
placeholder: "Search...",
|
|
3662
|
+
"aria-label": "Search",
|
|
3663
|
+
"aria-controls": listboxId,
|
|
3664
|
+
"aria-autocomplete": "list",
|
|
3665
|
+
"aria-activedescendant": activeId,
|
|
3433
3666
|
value: search,
|
|
3434
|
-
onChange: (e) =>
|
|
3667
|
+
onChange: (e) => {
|
|
3668
|
+
setSearch(e.target.value);
|
|
3669
|
+
setActiveIndex(NONE);
|
|
3670
|
+
},
|
|
3671
|
+
onKeyDown: (e) => onListKey(e, true),
|
|
3435
3672
|
autoFocus: true
|
|
3436
3673
|
}
|
|
3437
3674
|
) }),
|
|
3438
|
-
/* @__PURE__ */
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3675
|
+
/* @__PURE__ */ jsxs27(
|
|
3676
|
+
"div",
|
|
3677
|
+
{
|
|
3678
|
+
id: listboxId,
|
|
3679
|
+
role: "listbox",
|
|
3680
|
+
"aria-multiselectable": multi || void 0,
|
|
3681
|
+
"aria-labelledby": triggerId,
|
|
3682
|
+
className: "max-h-60 overflow-y-auto p-1",
|
|
3683
|
+
children: [
|
|
3684
|
+
filtered.length === 0 && /* @__PURE__ */ jsx34(
|
|
3685
|
+
"div",
|
|
3686
|
+
{
|
|
3687
|
+
role: "presentation",
|
|
3688
|
+
className: "px-3 py-2 text-sm text-muted-foreground",
|
|
3689
|
+
children: "No results"
|
|
3690
|
+
}
|
|
3447
3691
|
),
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3692
|
+
filtered.map((option, index) => {
|
|
3693
|
+
const isSelected = multi ? picks.includes(option.value) : pick === option.value;
|
|
3694
|
+
return /* @__PURE__ */ jsxs27(
|
|
3695
|
+
"button",
|
|
3696
|
+
{
|
|
3697
|
+
id: optionId(index),
|
|
3698
|
+
type: "button",
|
|
3699
|
+
role: "option",
|
|
3700
|
+
"aria-selected": isSelected,
|
|
3701
|
+
tabIndex: -1,
|
|
3702
|
+
className: cn(
|
|
3703
|
+
"flex w-full items-center rounded-sm px-3 py-2 text-left text-sm transition-colors",
|
|
3704
|
+
isSelected ? "text-primary-text bg-primary/10 font-medium" : "text-foreground hover:bg-muted",
|
|
3705
|
+
index === active && "bg-muted"
|
|
3706
|
+
),
|
|
3707
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
3708
|
+
onClick: () => handleSelect(option.value),
|
|
3709
|
+
children: [
|
|
3710
|
+
multi && /* @__PURE__ */ jsx34("span", { className: "mr-2", children: isSelected ? "\u2611" : "\u2610" }),
|
|
3711
|
+
option.label,
|
|
3712
|
+
!multi && isSelected && /* @__PURE__ */ jsx34("span", { className: "text-primary-text ml-auto", children: "\u2713" })
|
|
3713
|
+
]
|
|
3714
|
+
},
|
|
3715
|
+
option.value
|
|
3716
|
+
);
|
|
3717
|
+
}),
|
|
3718
|
+
hasMore && /* @__PURE__ */ jsx34(
|
|
3719
|
+
"button",
|
|
3720
|
+
{
|
|
3721
|
+
id: loadMoreId,
|
|
3722
|
+
type: "button",
|
|
3723
|
+
role: "option",
|
|
3724
|
+
"aria-selected": false,
|
|
3725
|
+
tabIndex: -1,
|
|
3726
|
+
className: cn(
|
|
3727
|
+
"flex w-full items-center justify-center rounded-sm px-3 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
3728
|
+
active === filtered.length && "bg-muted text-foreground"
|
|
3729
|
+
),
|
|
3730
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
3731
|
+
onClick: loadMore,
|
|
3732
|
+
children: "Load more"
|
|
3733
|
+
}
|
|
3734
|
+
)
|
|
3735
|
+
]
|
|
3736
|
+
}
|
|
3737
|
+
)
|
|
3458
3738
|
] })
|
|
3459
3739
|
] });
|
|
3460
3740
|
}
|
|
@@ -4355,7 +4635,7 @@ function EmptyState({
|
|
|
4355
4635
|
|
|
4356
4636
|
// src/action-panel.tsx
|
|
4357
4637
|
import * as React34 from "react";
|
|
4358
|
-
import { Fragment as
|
|
4638
|
+
import { Fragment as Fragment8, jsx as jsx48, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
4359
4639
|
var BORDER_INTENT = {
|
|
4360
4640
|
default: "border-l-primary",
|
|
4361
4641
|
warning: "border-l-intent-warning",
|
|
@@ -4381,13 +4661,13 @@ var ActionPanel = React34.forwardRef(
|
|
|
4381
4661
|
className
|
|
4382
4662
|
),
|
|
4383
4663
|
...props,
|
|
4384
|
-
children: variant === "split" ? /* @__PURE__ */ jsxs38(
|
|
4664
|
+
children: variant === "split" ? /* @__PURE__ */ jsxs38(Fragment8, { children: [
|
|
4385
4665
|
/* @__PURE__ */ jsxs38("div", { className: "min-w-0", children: [
|
|
4386
4666
|
/* @__PURE__ */ jsx48("h3", { className: "font-semibold text-foreground", children: title }),
|
|
4387
4667
|
description && /* @__PURE__ */ jsx48("p", { className: "mt-1 text-sm text-muted-foreground", children: description })
|
|
4388
4668
|
] }),
|
|
4389
4669
|
action && /* @__PURE__ */ jsx48("div", { className: "flex-shrink-0", children: action })
|
|
4390
|
-
] }) : /* @__PURE__ */ jsxs38(
|
|
4670
|
+
] }) : /* @__PURE__ */ jsxs38(Fragment8, { children: [
|
|
4391
4671
|
/* @__PURE__ */ jsx48("h3", { className: "font-semibold text-foreground", children: title }),
|
|
4392
4672
|
description && /* @__PURE__ */ jsx48("p", { className: "mt-1 text-sm text-muted-foreground", children: description }),
|
|
4393
4673
|
action && /* @__PURE__ */ jsx48("div", { className: "mt-4", children: action })
|
|
@@ -4732,7 +5012,7 @@ SidePanelLayout.displayName = "SidePanelLayout";
|
|
|
4732
5012
|
|
|
4733
5013
|
// src/overflow-menu.tsx
|
|
4734
5014
|
import * as React39 from "react";
|
|
4735
|
-
import { Fragment as
|
|
5015
|
+
import { Fragment as Fragment9, jsx as jsx53, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
4736
5016
|
function OverflowMenu({
|
|
4737
5017
|
label,
|
|
4738
5018
|
items,
|
|
@@ -4763,7 +5043,7 @@ function OverflowMenu({
|
|
|
4763
5043
|
children: /* @__PURE__ */ jsx53(Icon, { name: "ellipsis", size: "sm" })
|
|
4764
5044
|
}
|
|
4765
5045
|
),
|
|
4766
|
-
open && /* @__PURE__ */ jsxs42(
|
|
5046
|
+
open && /* @__PURE__ */ jsxs42(Fragment9, { children: [
|
|
4767
5047
|
/* @__PURE__ */ jsx53(
|
|
4768
5048
|
"div",
|
|
4769
5049
|
{
|
|
@@ -4942,16 +5222,6 @@ Textarea.displayName = "Textarea";
|
|
|
4942
5222
|
// src/select.tsx
|
|
4943
5223
|
import * as React43 from "react";
|
|
4944
5224
|
import { jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
4945
|
-
var CHEVRON_END = {
|
|
4946
|
-
sm: "right-2.5",
|
|
4947
|
-
md: "right-3",
|
|
4948
|
-
lg: "right-4"
|
|
4949
|
-
};
|
|
4950
|
-
var END_PADDING = {
|
|
4951
|
-
sm: "pr-8",
|
|
4952
|
-
md: "pr-9",
|
|
4953
|
-
lg: "pr-10"
|
|
4954
|
-
};
|
|
4955
5225
|
var Select = React43.forwardRef(
|
|
4956
5226
|
({
|
|
4957
5227
|
className,
|
|
@@ -4982,7 +5252,7 @@ var Select = React43.forwardRef(
|
|
|
4982
5252
|
"scheme-light dark:scheme-dark block cursor-pointer appearance-none truncate",
|
|
4983
5253
|
FIELD_HEIGHT[size],
|
|
4984
5254
|
fieldVariants({ size, error: Boolean(error) }),
|
|
4985
|
-
|
|
5255
|
+
pickerChevron(size).endPadding,
|
|
4986
5256
|
'has-[option[value=""]:checked]:text-muted-foreground [&>option]:text-foreground',
|
|
4987
5257
|
className
|
|
4988
5258
|
),
|
|
@@ -5001,7 +5271,7 @@ var Select = React43.forwardRef(
|
|
|
5001
5271
|
size: "sm",
|
|
5002
5272
|
className: cn(
|
|
5003
5273
|
"pointer-events-none absolute top-1/2 -translate-y-1/2 text-muted-foreground",
|
|
5004
|
-
|
|
5274
|
+
pickerChevron(size).inset
|
|
5005
5275
|
)
|
|
5006
5276
|
}
|
|
5007
5277
|
)
|