@charcuterie/ui 4.29.0 → 4.30.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/CatalogPicker/CatalogPicker.d.ts +7 -2
- package/dist/CatalogPicker/CatalogPicker.d.ts.map +1 -1
- package/dist/CatalogPicker/CatalogPicker.js +6 -3
- package/dist/CatalogPicker/CatalogPicker.js.map +1 -1
- package/dist/CatalogPicker/CatalogPickerOption.d.ts +1 -1
- package/dist/CatalogPicker/CatalogPickerOption.d.ts.map +1 -1
- package/dist/CatalogPicker/CatalogPickerOption.js +5 -4
- package/dist/CatalogPicker/CatalogPickerOption.js.map +1 -1
- package/dist/CatalogPicker/catalogPickerView.d.ts +13 -1
- package/dist/CatalogPicker/catalogPickerView.d.ts.map +1 -1
- package/dist/CatalogPicker/catalogPickerView.js +10 -0
- package/dist/CatalogPicker/catalogPickerView.js.map +1 -1
- package/package.json +1 -1
- package/src/CatalogPicker/CatalogPicker.mdx +36 -1
- package/src/CatalogPicker/CatalogPicker.test.tsx +264 -24
- package/src/CatalogPicker/CatalogPicker.tsx +14 -3
- package/src/CatalogPicker/CatalogPickerOption.tsx +19 -6
- package/src/CatalogPicker/catalogPickerView.test.ts +19 -0
- package/src/CatalogPicker/catalogPickerView.ts +20 -1
|
@@ -34,7 +34,9 @@ export type CatalogPickerProps = Omit<ComponentPropsWithRef<"button">, "children
|
|
|
34
34
|
/**
|
|
35
35
|
* What the control is FOR — "Agent", "Model". Not the current value.
|
|
36
36
|
* The trigger is named `"<label>: <chosen label>"`, as in `Picker`,
|
|
37
|
-
*
|
|
37
|
+
* then `", <group label>"` when the chosen item's group has a label
|
|
38
|
+
* that is not blank; the
|
|
39
|
+
* search field and the list are named `label`.
|
|
38
40
|
*/
|
|
39
41
|
label: string;
|
|
40
42
|
onChange: (value: string) => void;
|
|
@@ -75,7 +77,10 @@ export type CatalogPickerProps = Omit<ComponentPropsWithRef<"button">, "children
|
|
|
75
77
|
* `aria-activedescendant` — the `Combobox` contract. The rail is a
|
|
76
78
|
* vertical `role="toolbar"` of `aria-pressed` buttons, and Tab moves
|
|
77
79
|
* between the field, its clear button and the rail. Escape clears a
|
|
78
|
-
* query, then closes, and focus returns to the trigger.
|
|
80
|
+
* query, then closes, and focus returns to the trigger. A row is
|
|
81
|
+
* named by its label, its description and then its group's label (when
|
|
82
|
+
* not blank), and the trigger by the chosen row's label and group: the mark is decorative,
|
|
83
|
+
* so two groups' same-label rows must not read alike. The picker
|
|
79
84
|
* consumes every Escape it handles, so one inside a `Dialog` never
|
|
80
85
|
* closes the dialog too.
|
|
81
86
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogPicker.d.ts","sourceRoot":"","sources":["../../src/CatalogPicker/CatalogPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAKnD,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAA;AAUd,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"CatalogPicker.d.ts","sourceRoot":"","sources":["../../src/CatalogPicker/CatalogPicker.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAKnD,OAAO,KAAK,EACV,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAA;AAUd,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAGvB,MAAM,wBAAwB,CAAA;AAE/B,YAAY,EACV,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,wBAAwB,CAAA;AAwB/B,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,qBAAqB,CAAC,QAAQ,CAAC,EAC/B,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAC/C,GAAG;IACF;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,8FAA8F;IAC9F,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IAC7B,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;OAIG;IACH,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAA;IACrC,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAA;IACnC;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,iDAAiD;IACjD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,yEAAyE;IACzE,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,yDAAyD;IACzD,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,gFAAgF;IAChF,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,eAAO,MAAM,aAAa,GAAI,8MAiB3B,kBAAkB,KAAG,SA0MvB,CAAA"}
|
|
@@ -9,7 +9,7 @@ import { usePanelItemSize } from "../Overlay/usePanelItemSize.js";
|
|
|
9
9
|
import { toClassName } from "../toClassName.js";
|
|
10
10
|
import { CatalogPickerMark } from "./CatalogPickerMark.js";
|
|
11
11
|
import { CatalogPickerPanel } from "./CatalogPickerPanel.js";
|
|
12
|
-
import { toUniqueCatalog, } from "./catalogPickerView.js";
|
|
12
|
+
import { toGroupedName, toUniqueCatalog, } from "./catalogPickerView.js";
|
|
13
13
|
/**
|
|
14
14
|
* A constant element rather than a component, as in `Picker`: a
|
|
15
15
|
* second component in this file trips the house rule, and this never
|
|
@@ -47,7 +47,10 @@ const PANEL_MAX_WIDTH_PX = 416;
|
|
|
47
47
|
* `aria-activedescendant` — the `Combobox` contract. The rail is a
|
|
48
48
|
* vertical `role="toolbar"` of `aria-pressed` buttons, and Tab moves
|
|
49
49
|
* between the field, its clear button and the rail. Escape clears a
|
|
50
|
-
* query, then closes, and focus returns to the trigger.
|
|
50
|
+
* query, then closes, and focus returns to the trigger. A row is
|
|
51
|
+
* named by its label, its description and then its group's label (when
|
|
52
|
+
* not blank), and the trigger by the chosen row's label and group: the mark is decorative,
|
|
53
|
+
* so two groups' same-label rows must not read alike. The picker
|
|
51
54
|
* consumes every Escape it handles, so one inside a `Dialog` never
|
|
52
55
|
* closes the dialog too.
|
|
53
56
|
*
|
|
@@ -135,7 +138,7 @@ export const CatalogPicker = ({ className, clearIcon, emptyLabel = "No matches",
|
|
|
135
138
|
onDismiss: hide,
|
|
136
139
|
placement,
|
|
137
140
|
role: "dialog",
|
|
138
|
-
trigger: (_jsx(Button, { ...buttonProps, appearance: "outline", "aria-label": `${label}: ${triggerText}`, className: toClassName("justify-between", className), iconEnd: CHEVRON_DOWN, intent: "neutral", isDisabled: isDisabled, onClick: (clickEvent) => {
|
|
141
|
+
trigger: (_jsx(Button, { ...buttonProps, appearance: "outline", "aria-label": toGroupedName(`${label}: ${triggerText}`, chosenGroup), className: toClassName("justify-between", className), iconEnd: CHEVRON_DOWN, intent: "neutral", isDisabled: isDisabled, onClick: (clickEvent) => {
|
|
139
142
|
buttonProps.onClick?.(clickEvent);
|
|
140
143
|
toggle();
|
|
141
144
|
}, size: size, type: "button", children: triggerText === "" && !hasChosenMark ? null : (_jsxs("span", { className: "flex min-w-0 grow items-center gap-2", children: [hasChosenMark ? (_jsx(CatalogPickerMark, { accentColor: chosenGroup?.accentColor, icon: chosen?.icon ?? chosenGroup?.icon, initialsOf: chosenGroup?.label, size: "sm" })) : null, _jsx("span", { className: "-mx-1 min-w-0 grow overflow-x-clip px-1 text-start text-ellipsis whitespace-nowrap", children: triggerText })] })) })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogPicker.js","sourceRoot":"","sources":["../../src/CatalogPicker/CatalogPicker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EACL,oBAAoB,EACpB,cAAc,GACf,MAAM,oBAAoB,CAAA;AAK3B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAsB,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAA0B,CAAA;AAC7D,OAAO,EAGL,eAAe,GAChB,MAAM,wBAAwB,CAAA;AAO/B;;;;GAIG;AACH,MAAM,YAAY,GAAG,CACnB,6BACc,MAAM,EAClB,SAAS,EAAC,QAAQ,EAClB,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,KAAK,EAChB,MAAM,EAAC,cAAc,EACrB,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EACtB,WAAW,EAAE,IAAI,EACjB,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,4BAA4B,YAElC,eAAM,CAAC,EAAC,cAAc,GAAG,GACrB,CACP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actNode } from "react";
|
|
3
|
-
import type
|
|
3
|
+
import { type CatalogPickerGroup, type CatalogPickerItem } from "./catalogPickerView.ts";
|
|
4
4
|
export type CatalogPickerOptionProps = {
|
|
5
5
|
group: CatalogPickerGroup | undefined;
|
|
6
6
|
/** The DOM id the search field's `aria-activedescendant` points at. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogPickerOption.d.ts","sourceRoot":"","sources":["../../src/CatalogPicker/CatalogPickerOption.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAStC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"CatalogPickerOption.d.ts","sourceRoot":"","sources":["../../src/CatalogPicker/CatalogPickerOption.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAStC,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAA;AAE/B,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAA;IACrC,uEAAuE;IACvE,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,OAAO,CAAA;IACjB,UAAU,EAAE,OAAO,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,iBAAiB,CAAA;IACvB,qEAAqE;IACrE,QAAQ,EAAE,WAAW,CAAA;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,sCAAsC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,mBAAmB,GAAI,qFAUjC,wBAAwB,KAAG,SAwF7B,CAAA"}
|
|
@@ -3,6 +3,7 @@ import { PANEL_ITEM_SIZE_CLASS } from "../controlStyles.js";
|
|
|
3
3
|
import { toClassName } from "../toClassName.js";
|
|
4
4
|
import { CatalogPickerMark } from "./CatalogPickerMark.js";
|
|
5
5
|
import { CHOSEN_CHECK, ROW_FAVORITE_STAR, } from "./catalogPickerDrawings.js";
|
|
6
|
+
import { toGroupedName, } from "./catalogPickerView.js";
|
|
6
7
|
/**
|
|
7
8
|
* One row of the catalog's listbox: the mark, the label, the optional
|
|
8
9
|
* description, a star on a favorite, and the check gutter.
|
|
@@ -26,7 +27,8 @@ import { CHOSEN_CHECK, ROW_FAVORITE_STAR, } from "./catalogPickerDrawings.js";
|
|
|
26
27
|
*/
|
|
27
28
|
export const CatalogPickerOption = ({ group, id, isActive, isFavorite, isSelected, item, itemSize, onChoose, onPoint, }) => {
|
|
28
29
|
const { description, icon, isDisabled = false, label, value, } = item;
|
|
29
|
-
|
|
30
|
+
const hasDescription = description !== undefined && description.trim() !== "";
|
|
31
|
+
return (_jsxs("button", { "aria-label": toGroupedName(`${label}${hasDescription ? ` ${description}` : ""}`, group), "aria-selected": isSelected, className: toClassName("flex w-full cursor-pointer items-center rounded-sm text-start", PANEL_ITEM_SIZE_CLASS[itemSize], isDisabled
|
|
30
32
|
? "cursor-not-allowed text-content-disabled"
|
|
31
33
|
: "text-content-primary", isActive && "bg-intent-neutral-surface-hover", isSelected &&
|
|
32
34
|
!isActive &&
|
|
@@ -34,9 +36,8 @@ export const CatalogPickerOption = ({ group, id, isActive, isFavorite, isSelecte
|
|
|
34
36
|
onChoose(value);
|
|
35
37
|
}, onMouseDown: (mouseEvent) => {
|
|
36
38
|
mouseEvent.preventDefault();
|
|
37
|
-
}, onPointerMove: onPoint, role: "option", tabIndex: -1, type: "button", children: [_jsx(CatalogPickerMark, { accentColor: group?.accentColor, icon: icon ?? group?.icon, initialsOf: group?.label, size: itemSize }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-wrap items-baseline gap-x-2", children: [_jsx("span", { className: "min-w-0 wrap-anywhere", children: label }),
|
|
38
|
-
description === "" ? null : (_jsx("span", { className: toClassName("min-w-0 text-sm wrap-anywhere", isDisabled
|
|
39
|
+
}, onPointerMove: onPoint, role: "option", tabIndex: -1, type: "button", children: [_jsx(CatalogPickerMark, { accentColor: group?.accentColor, icon: icon ?? group?.icon, initialsOf: group?.label, size: itemSize }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-wrap items-baseline gap-x-2", children: [_jsx("span", { className: "min-w-0 wrap-anywhere", children: label }), hasDescription ? (_jsx("span", { className: toClassName("min-w-0 text-sm wrap-anywhere", isDisabled
|
|
39
40
|
? "text-content-disabled"
|
|
40
|
-
: "text-content-muted"), children: description }))] }), isFavorite ? ROW_FAVORITE_STAR : null, _jsx("span", { "aria-hidden": "true", className: toClassName("flex w-4 shrink-0 items-center justify-center text-intent-accent-content", !isSelected && "invisible"), children: CHOSEN_CHECK })] }));
|
|
41
|
+
: "text-content-muted"), children: description })) : null] }), isFavorite ? ROW_FAVORITE_STAR : null, _jsx("span", { "aria-hidden": "true", className: toClassName("flex w-4 shrink-0 items-center justify-center text-intent-accent-content", !isSelected && "invisible"), children: CHOSEN_CHECK })] }));
|
|
41
42
|
};
|
|
42
43
|
//# sourceMappingURL=CatalogPickerOption.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogPickerOption.js","sourceRoot":"","sources":["../../src/CatalogPicker/CatalogPickerOption.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAyB,CAAA;AAC3D,OAAO,EACL,YAAY,EACZ,iBAAiB,GAClB,MAAM,4BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"CatalogPickerOption.js","sourceR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,WAAW,EAAE,CAAC,UAAU,EAAE,EAAE;YAC1B,UAAU,CAAC,cAAc,EAAE,CAAA;QAC7B,CAAC,EACD,aAAa,EAAE,OAAO,EACtB,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,EACZ,IAAI,EAAC,QAAQ,aAEb,KAAC,iBAAiB,IAChB,WAAW,EAAE,KAAK,EAAE,WAAW,EAC/B,IAAI,EAAE,IAAI,IAAI,KAAK,EAAE,IAAI,EACzB,UAAU,EAAE,KAAK,EAAE,KAAK,EACxB,IAAI,EAAE,QAAQ,GACd,EAEF,gBAAM,SAAS,EAAC,sDAAsD,aACpE,eAAM,SAAS,EAAC,uBAAuB,YACpC,KAAK,GACD,EAEN,cAAc,CAAC,CAAC,CAAC,CAChB,eACE,SAAS,EAAE,WAAW,CACpB,+BAA+B,EAC/B,UAAU;4BACR,CAAC,CAAC,uBAAuB;4BACzB,CAAC,CAAC,oBAAoB,CACzB,YAEA,WAAW,GACP,CACR,CAAC,CAAC,CAAC,IAAI,IACH,EAEN,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,EAEtC,8BACc,MAAM,EAClB,SAAS,EAAE,WAAW,CACpB,0EAA0E,EAC1E,CAAC,UAAU,IAAI,WAAW,CAC3B,YAEA,YAAY,GACR,IACA,CACV,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -30,7 +30,11 @@ export type CatalogPickerItem = {
|
|
|
30
30
|
/** Overrides the group's icon or badge for this row. */
|
|
31
31
|
icon?: ReactNode;
|
|
32
32
|
isDisabled?: boolean;
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* The row's visible label and the trigger's text, and the first part
|
|
35
|
+
* of the row's accessible name (then the description, then the
|
|
36
|
+
* group). Searched.
|
|
37
|
+
*/
|
|
34
38
|
label: string;
|
|
35
39
|
/**
|
|
36
40
|
* Shown at the top (`"start"`) or the bottom (`"end"`) of every rail
|
|
@@ -164,6 +168,14 @@ export declare const buildCatalogSections: ({ favorites, groups, items, query, t
|
|
|
164
168
|
query: string;
|
|
165
169
|
tab: CatalogPickerTab | undefined;
|
|
166
170
|
}) => CatalogPickerSection[];
|
|
171
|
+
/**
|
|
172
|
+
* A row's or the trigger's accessible name: its text, then the group
|
|
173
|
+
* in words — `"Opus, Team Two"`. The text's trailing spaces go, so the
|
|
174
|
+
* comma this adds never follows a space; no group, or a group whose
|
|
175
|
+
* label is blank, leaves the text as it is, so this never adds a bare
|
|
176
|
+
* comma.
|
|
177
|
+
*/
|
|
178
|
+
export declare const toGroupedName: (text: string, group: CatalogPickerGroup | undefined) => string;
|
|
167
179
|
/**
|
|
168
180
|
* A badge's text: the first letter or digit of each of the first two
|
|
169
181
|
* words that have one, so "Northwind" is "N", "Contoso Labs" is "CL",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogPickerView.d.ts","sourceRoot":"","sources":["../../src/CatalogPicker/catalogPickerView.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gGAAgG;IAChG,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,0GAA0G;IAC1G,EAAE,EAAE,MAAM,CAAA;IACV,oGAAoG;IACpG,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;OAKG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,wDAAwD;IACxD,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB
|
|
1
|
+
{"version":3,"file":"catalogPickerView.d.ts","sourceRoot":"","sources":["../../src/CatalogPicker/catalogPickerView.ts"],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,SAAS,CAAA;CAC1B,KAAG,MAAM,GAAG,SAkCZ,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAAI,2CAMlC;IACD,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5B,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAA;IACrC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAA;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,gBAAgB,GAAG,SAAS,CAAA;CAClC,KAAG,oBAAoB,EAyFvB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,EACZ,OAAO,kBAAkB,GAAG,SAAS,WAIE,CAAA;AAEzC;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,WAOtB,CAAA"}
|
|
@@ -220,6 +220,16 @@ export const buildCatalogSections = ({ favorites, groups, items, query, tab, })
|
|
|
220
220
|
{ items: pinnedEnd, key: "pinned-end" },
|
|
221
221
|
].filter((section) => section.items.length > 0);
|
|
222
222
|
};
|
|
223
|
+
/**
|
|
224
|
+
* A row's or the trigger's accessible name: its text, then the group
|
|
225
|
+
* in words — `"Opus, Team Two"`. The text's trailing spaces go, so the
|
|
226
|
+
* comma this adds never follows a space; no group, or a group whose
|
|
227
|
+
* label is blank, leaves the text as it is, so this never adds a bare
|
|
228
|
+
* comma.
|
|
229
|
+
*/
|
|
230
|
+
export const toGroupedName = (text, group) => group === undefined || group.label.trim() === ""
|
|
231
|
+
? text
|
|
232
|
+
: `${text.trimEnd()}, ${group.label}`;
|
|
223
233
|
/**
|
|
224
234
|
* A badge's text: the first letter or digit of each of the first two
|
|
225
235
|
* words that have one, so "Northwind" is "N", "Contoso Labs" is "CL",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogPickerView.js","sourceRoot":"","sources":["../../src/CatalogPicker/catalogPickerView.ts"],"names":[],"mappings":"
|
|
1
|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AC,CAAC,CAAC,CAAC;KAC/C,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,SAAS,CAAC;KAC1C,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;KACX,IAAI,CAAC,EAAE,CAAC;KACR,WAAW,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -28,7 +28,8 @@ name" without making the person know the provider first.
|
|
|
28
28
|
## The shape
|
|
29
29
|
|
|
30
30
|
- **The trigger** shows the chosen item's mark and label, and is named
|
|
31
|
-
`"<label>: <chosen label>"`, as `Picker`'s is
|
|
31
|
+
`"<label>: <chosen label>"`, as `Picker`'s is, then `", <group label>"` when the chosen
|
|
32
|
+
item's group has a label that is not blank — `"Agent: Lumen 4, Contoso"`. Query it as
|
|
32
33
|
`getByRole("button", { name: /^Agent: / })`.
|
|
33
34
|
- **The rail**, on the inline start: a **Favorites** star first (only when `favorites`
|
|
34
35
|
resolves to at least one item, a pinned one included), then one button per group, in
|
|
@@ -131,6 +132,40 @@ the arrows move, Enter and Space press.
|
|
|
131
132
|
A mouse click on a rail button does not take focus from the search field, so a person can
|
|
132
133
|
click a group and keep typing or arrowing.
|
|
133
134
|
|
|
135
|
+
### A row's name says its group
|
|
136
|
+
|
|
137
|
+
The mark beside a row is decorative, so the group is said in words, from its label. A row is named by its
|
|
138
|
+
label, then its description, then its group: `"Lumen 4 ct-lumen-4, Contoso"` and
|
|
139
|
+
`"Lumen 4 Work account, Contoso (Work)"`. Two accounts that both star "Opus" give Favorites
|
|
140
|
+
two rows that look the same and are named apart — `"Opus, Team One"` and
|
|
141
|
+
`"Opus, Team Two"` — and the trigger names the chosen one's group the same way. A row with no
|
|
142
|
+
group, a missing group, or a group whose label is blank has no suffix.
|
|
143
|
+
|
|
144
|
+
The name is an `aria-label`: the row's label and description, in the order the row shows
|
|
145
|
+
them, then the group's label. The mark beside them is decorative, whether it is the group's
|
|
146
|
+
badge or icon or the item's own. It is not a `VisuallyHidden` suffix: an `sr-only` span is
|
|
147
|
+
laid out as a block, so Chromium and Testing Library name the row `"Opus , Team Two"`, with
|
|
148
|
+
a space before the comma, and an exact query misses it.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
// Testing Library matches a string name whole.
|
|
152
|
+
getByRole("option", { name: "Opus, Team Two" })
|
|
153
|
+
getByRole("button", { name: "Agent: Opus, Team Two" })
|
|
154
|
+
|
|
155
|
+
// Playwright matches a substring unless told otherwise: "Opus, Team Two" would also find
|
|
156
|
+
// "Opus, Team Two Work".
|
|
157
|
+
page.getByRole("option", { exact: true, name: "Opus, Team Two" })
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The group usually tells same-label rows in differently labelled groups apart. It does not
|
|
161
|
+
make every name unique: two names collide whenever their whole text matches, and a label,
|
|
162
|
+
description, or group label can contain any text, commas included. A catalog that needs
|
|
163
|
+
unique names checks the whole names. Two groups both
|
|
164
|
+
labelled `"Work"` make two `"Opus, Work"` rows; `"Opus"` with the description `"Preview"`
|
|
165
|
+
reads the same as `"Opus Preview"` with none; and an ungrouped `"Opus, Team Two"` reads the
|
|
166
|
+
same as `"Opus"` in Team Two. The trigger does not say the description, so give such rows,
|
|
167
|
+
or their groups, distinct labels. A blank group label or description adds nothing to a name.
|
|
168
|
+
|
|
134
169
|
## Icons, badges and accent colors
|
|
135
170
|
|
|
136
171
|
Charcuterie ships no icons. Pass the app's own provider logos as `icon` on a group (or on
|
|
@@ -84,7 +84,7 @@ test("the trigger is named by its label and the chosen item, and opens a dialog"
|
|
|
84
84
|
await mountStory(Playground)
|
|
85
85
|
|
|
86
86
|
const trigger = expectAgentDrivable(canvas, {
|
|
87
|
-
name: "Agent: Lumen 4",
|
|
87
|
+
name: "Agent: Lumen 4, Contoso",
|
|
88
88
|
role: "button",
|
|
89
89
|
})
|
|
90
90
|
|
|
@@ -103,11 +103,11 @@ test("the trigger is named by its label and the chosen item, and opens a dialog"
|
|
|
103
103
|
test("opening on a favorite lands on Favorites with the chosen row active", async () => {
|
|
104
104
|
const { body, dialog, input } = await openPicker(
|
|
105
105
|
Playground,
|
|
106
|
-
"Agent: Lumen 4",
|
|
106
|
+
"Agent: Lumen 4, Contoso",
|
|
107
107
|
)
|
|
108
108
|
|
|
109
109
|
await expect(dialog).toHaveAccessibleName(
|
|
110
|
-
"Agent: Lumen 4",
|
|
110
|
+
"Agent: Lumen 4, Contoso",
|
|
111
111
|
)
|
|
112
112
|
|
|
113
113
|
await expect(
|
|
@@ -153,7 +153,7 @@ test("opening on a favorite lands on Favorites with the chosen row active", asyn
|
|
|
153
153
|
test("opening on a non-favorite lands on its group and centres the chosen row", async () => {
|
|
154
154
|
const { body, input } = await openPicker(
|
|
155
155
|
Interactive,
|
|
156
|
-
"Agent: Harbor 4",
|
|
156
|
+
"Agent: Harbor 4, Northwind",
|
|
157
157
|
)
|
|
158
158
|
|
|
159
159
|
await expect(
|
|
@@ -193,7 +193,7 @@ test("opening on a non-favorite lands on its group and centres the chosen row",
|
|
|
193
193
|
test("without favorites there is no Favorites tab, and a group with no rows is left off", async () => {
|
|
194
194
|
const { body } = await openPicker(
|
|
195
195
|
WithoutFavorites,
|
|
196
|
-
"Agent without favorites: Margin 2",
|
|
196
|
+
"Agent without favorites: Margin 2, Litware",
|
|
197
197
|
)
|
|
198
198
|
|
|
199
199
|
await expect(
|
|
@@ -235,7 +235,7 @@ test("without favorites there is no Favorites tab, and a group with no rows is l
|
|
|
235
235
|
test("a rail click shows that group, pinned rows included, and keeps focus in the search", async () => {
|
|
236
236
|
const { body, input } = await openPicker(
|
|
237
237
|
Playground,
|
|
238
|
-
"Agent: Lumen 4",
|
|
238
|
+
"Agent: Lumen 4, Contoso",
|
|
239
239
|
)
|
|
240
240
|
|
|
241
241
|
await userEvent.click(railButton(body, "Fabrikam"))
|
|
@@ -264,7 +264,7 @@ test("a rail click shows that group, pinned rows included, and keeps focus in th
|
|
|
264
264
|
test("typing searches every group under headings, and no tab is current", async () => {
|
|
265
265
|
const { body, input } = await openPicker(
|
|
266
266
|
Playground,
|
|
267
|
-
"Agent: Lumen 4",
|
|
267
|
+
"Agent: Lumen 4, Contoso",
|
|
268
268
|
)
|
|
269
269
|
|
|
270
270
|
await userEvent.keyboard("LUMEN")
|
|
@@ -302,7 +302,7 @@ test("typing searches every group under headings, and no tab is current", async
|
|
|
302
302
|
test("every word must match, against the label, the description, or the group", async () => {
|
|
303
303
|
const { body } = await openPicker(
|
|
304
304
|
Playground,
|
|
305
|
-
"Agent: Lumen 4",
|
|
305
|
+
"Agent: Lumen 4, Contoso",
|
|
306
306
|
)
|
|
307
307
|
|
|
308
308
|
// "work" is the Work account's description and group label; the
|
|
@@ -339,7 +339,7 @@ test("every word must match, against the label, the description, or the group",
|
|
|
339
339
|
test("a search with no match shows the empty label", async () => {
|
|
340
340
|
const { body, input } = await openPicker(
|
|
341
341
|
Playground,
|
|
342
|
-
"Agent: Lumen 4",
|
|
342
|
+
"Agent: Lumen 4, Contoso",
|
|
343
343
|
)
|
|
344
344
|
|
|
345
345
|
await userEvent.keyboard("zzz")
|
|
@@ -361,7 +361,7 @@ test("a search with no match shows the empty label", async () => {
|
|
|
361
361
|
test("the arrows skip a disabled row, and stop at either end", async () => {
|
|
362
362
|
const { body, input } = await openPicker(
|
|
363
363
|
Playground,
|
|
364
|
-
"Agent: Lumen 4",
|
|
364
|
+
"Agent: Lumen 4, Contoso",
|
|
365
365
|
)
|
|
366
366
|
|
|
367
367
|
await userEvent.click(railButton(body, "Fabrikam"))
|
|
@@ -411,7 +411,7 @@ test("the arrows skip a disabled row, and stop at either end", async () => {
|
|
|
411
411
|
test("Enter chooses the active row, closes, and returns focus to the trigger", async () => {
|
|
412
412
|
const { body, canvas, input } = await openPicker(
|
|
413
413
|
Interactive,
|
|
414
|
-
"Agent: Harbor 4",
|
|
414
|
+
"Agent: Harbor 4, Northwind",
|
|
415
415
|
)
|
|
416
416
|
|
|
417
417
|
await userEvent.keyboard("weave 1")
|
|
@@ -431,7 +431,7 @@ test("Enter chooses the active row, closes, and returns focus to the trigger", a
|
|
|
431
431
|
})
|
|
432
432
|
|
|
433
433
|
const trigger = expectAgentDrivable(canvas, {
|
|
434
|
-
name: "Agent: Weave Code 1",
|
|
434
|
+
name: "Agent: Weave Code 1, Fabrikam",
|
|
435
435
|
role: "button",
|
|
436
436
|
})
|
|
437
437
|
|
|
@@ -443,7 +443,7 @@ test("Enter chooses the active row, closes, and returns focus to the trigger", a
|
|
|
443
443
|
test("a click on a row chooses it and closes", async () => {
|
|
444
444
|
const { body, canvas } = await openPicker(
|
|
445
445
|
Interactive,
|
|
446
|
-
"Agent: Harbor 4",
|
|
446
|
+
"Agent: Harbor 4, Northwind",
|
|
447
447
|
)
|
|
448
448
|
|
|
449
449
|
await userEvent.click(
|
|
@@ -457,7 +457,7 @@ test("a click on a row chooses it and closes", async () => {
|
|
|
457
457
|
})
|
|
458
458
|
|
|
459
459
|
expectAgentDrivable(canvas, {
|
|
460
|
-
name: "Agent: Atlas 2 Reasoning",
|
|
460
|
+
name: "Agent: Atlas 2 Reasoning, Northwind",
|
|
461
461
|
role: "button",
|
|
462
462
|
})
|
|
463
463
|
})
|
|
@@ -465,7 +465,7 @@ test("a click on a row chooses it and closes", async () => {
|
|
|
465
465
|
test("Escape clears the query first, then closes and returns focus to the trigger", async () => {
|
|
466
466
|
const { body, input, trigger } = await openPicker(
|
|
467
467
|
Interactive,
|
|
468
|
-
"Agent: Harbor 4",
|
|
468
|
+
"Agent: Harbor 4, Northwind",
|
|
469
469
|
)
|
|
470
470
|
|
|
471
471
|
await userEvent.keyboard("glide")
|
|
@@ -499,7 +499,7 @@ test("Escape clears the query first, then closes and returns focus to the trigge
|
|
|
499
499
|
test("Tab moves between the search and the rail, where the arrows choose a group", async () => {
|
|
500
500
|
const { body, input } = await openPicker(
|
|
501
501
|
Interactive,
|
|
502
|
-
"Agent: Harbor 4",
|
|
502
|
+
"Agent: Harbor 4, Northwind",
|
|
503
503
|
)
|
|
504
504
|
|
|
505
505
|
await userEvent.keyboard("{Tab}")
|
|
@@ -570,7 +570,7 @@ test("Tab moves between the search and the rail, where the arrows choose a group
|
|
|
570
570
|
test("the panel fits the window, rail and all", async () => {
|
|
571
571
|
const { body, dialog } = await openPicker(
|
|
572
572
|
Interactive,
|
|
573
|
-
"Agent: Harbor 4",
|
|
573
|
+
"Agent: Harbor 4, Northwind",
|
|
574
574
|
)
|
|
575
575
|
|
|
576
576
|
await waitFor(() => {
|
|
@@ -604,7 +604,7 @@ test("a disabled picker does not open", async () => {
|
|
|
604
604
|
const { body, canvas } = await mountStory(AllStates)
|
|
605
605
|
|
|
606
606
|
const trigger = expectAgentDrivable(canvas, {
|
|
607
|
-
name: "Disabled agent: Lumen 4",
|
|
607
|
+
name: "Disabled agent: Lumen 4, Contoso",
|
|
608
608
|
role: "button",
|
|
609
609
|
})
|
|
610
610
|
|
|
@@ -637,7 +637,7 @@ test("a stretched trigger keeps the chevron inside and ends a long name in an el
|
|
|
637
637
|
const { canvas } = await mountStory(Responsive)
|
|
638
638
|
|
|
639
639
|
const trigger = expectAgentDrivable(canvas, {
|
|
640
|
-
name: "Long agent at 15rem: Tailwind Research Preview With A Very Long Name",
|
|
640
|
+
name: "Long agent at 15rem: Tailwind Research Preview With A Very Long Name, Tailspin Labs",
|
|
641
641
|
role: "button",
|
|
642
642
|
})
|
|
643
643
|
|
|
@@ -843,7 +843,7 @@ test("a catalog refresh keeps each row's button, so a half-done click stays on i
|
|
|
843
843
|
const { body, render } = await openSmallPicker()
|
|
844
844
|
|
|
845
845
|
const alphaButton = body.getByRole("option", {
|
|
846
|
-
name: "Alpha",
|
|
846
|
+
name: "Alpha, Provider One",
|
|
847
847
|
})
|
|
848
848
|
|
|
849
849
|
// A pointer pressed on Alpha, then the rows swap under it: the
|
|
@@ -863,7 +863,7 @@ test("a catalog refresh keeps each row's button, so a half-done click stays on i
|
|
|
863
863
|
test("a refresh during a search reseeds to the chosen row when it is shown", async () => {
|
|
864
864
|
const { chosen, input, render } = await openSmallPicker(
|
|
865
865
|
{ value: "gamma" },
|
|
866
|
-
"Model: Gamma",
|
|
866
|
+
"Model: Gamma, Second Source",
|
|
867
867
|
)
|
|
868
868
|
|
|
869
869
|
// Every label has an "a": a live query takes the top match.
|
|
@@ -1031,7 +1031,7 @@ test("Escape inside a Dialog clears, then closes the picker, and never closes th
|
|
|
1031
1031
|
test("a rail button that leaves while it has focus hands focus to the rail that is left", async () => {
|
|
1032
1032
|
const { body, render } = await openSmallPicker(
|
|
1033
1033
|
{ value: "gamma" },
|
|
1034
|
-
"Model: Gamma",
|
|
1034
|
+
"Model: Gamma, Second Source",
|
|
1035
1035
|
)
|
|
1036
1036
|
|
|
1037
1037
|
await userEvent.keyboard("{Tab}")
|
|
@@ -1076,7 +1076,7 @@ test("a repeated value is one row, the first wins everywhere, and the picker war
|
|
|
1076
1076
|
],
|
|
1077
1077
|
value: "alpha",
|
|
1078
1078
|
},
|
|
1079
|
-
"Model: Alpha",
|
|
1079
|
+
"Model: Alpha, Provider One",
|
|
1080
1080
|
)
|
|
1081
1081
|
|
|
1082
1082
|
await expect(warn).toHaveBeenCalledWith(
|
|
@@ -1245,7 +1245,7 @@ test("a picker reopened while it is still fading out starts a fresh search", asy
|
|
|
1245
1245
|
{
|
|
1246
1246
|
value: "gamma",
|
|
1247
1247
|
},
|
|
1248
|
-
"Model: Gamma",
|
|
1248
|
+
"Model: Gamma, Second Source",
|
|
1249
1249
|
)
|
|
1250
1250
|
|
|
1251
1251
|
await userEvent.keyboard("al")
|
|
@@ -1350,3 +1350,243 @@ test("an ungrouped chosen row is in the opening view, and a pinned favorite is a
|
|
|
1350
1350
|
body.getAllByRole("option", { name: /^Default/u }),
|
|
1351
1351
|
).toHaveLength(1)
|
|
1352
1352
|
})
|
|
1353
|
+
|
|
1354
|
+
// ---------------------------------------------------------------------
|
|
1355
|
+
// A row's group badge is decorative, so the group is in the row's name
|
|
1356
|
+
// and the trigger's in words. Invented: two accounts of one provider,
|
|
1357
|
+
// each with its own "Alpha".
|
|
1358
|
+
// ---------------------------------------------------------------------
|
|
1359
|
+
|
|
1360
|
+
const ALPHA_SECOND: CatalogPickerItem = {
|
|
1361
|
+
groupId: "second",
|
|
1362
|
+
label: "Alpha",
|
|
1363
|
+
value: "alpha-second",
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
const LOOSE: CatalogPickerItem = {
|
|
1367
|
+
groupId: null,
|
|
1368
|
+
label: "Loose End",
|
|
1369
|
+
value: "loose",
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/** A `groupId` that names no group: listed on every tab, as `LOOSE` is. */
|
|
1373
|
+
const STRAY: CatalogPickerItem = {
|
|
1374
|
+
groupId: "gone",
|
|
1375
|
+
label: "Stray",
|
|
1376
|
+
value: "stray",
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
const SAME_LABEL_PROPS: SmallPickerProps = {
|
|
1380
|
+
favorites: ["alpha", "alpha-second"],
|
|
1381
|
+
items: [ALPHA, BETA, GAMMA, ALPHA_SECOND, LOOSE, STRAY],
|
|
1382
|
+
value: "alpha-second",
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
/** Every option's computed accessible name, in order, as an agent's `getByRole` sees it. */
|
|
1386
|
+
const expectOptionNames = (
|
|
1387
|
+
body: ReturnType<typeof within>,
|
|
1388
|
+
names: readonly string[],
|
|
1389
|
+
) => {
|
|
1390
|
+
const options = body.getAllByRole("option")
|
|
1391
|
+
|
|
1392
|
+
expect(options).toHaveLength(names.length)
|
|
1393
|
+
|
|
1394
|
+
names.forEach((name, index) => {
|
|
1395
|
+
expect(options[index]).toHaveAccessibleName(name)
|
|
1396
|
+
})
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
test("two groups' favorites with the same label have distinct names", async () => {
|
|
1400
|
+
const { body, input } = await openSmallPicker(
|
|
1401
|
+
SAME_LABEL_PROPS,
|
|
1402
|
+
"Model: Alpha, Second Source",
|
|
1403
|
+
)
|
|
1404
|
+
|
|
1405
|
+
await expect(
|
|
1406
|
+
body.getByRole("button", { name: "Favorites" }),
|
|
1407
|
+
).toHaveAttribute("aria-pressed", "true")
|
|
1408
|
+
|
|
1409
|
+
// Rows with no group come first on every tab. The two Alphas'
|
|
1410
|
+
// visible text is the same; their names are not.
|
|
1411
|
+
await expect(
|
|
1412
|
+
body.getAllByRole("option").map(visibleName),
|
|
1413
|
+
).toEqual(["Loose End", "Stray", "Alpha", "Alpha"])
|
|
1414
|
+
|
|
1415
|
+
for (const name of [
|
|
1416
|
+
"Alpha, Provider One",
|
|
1417
|
+
"Alpha, Second Source",
|
|
1418
|
+
]) {
|
|
1419
|
+
await expect(
|
|
1420
|
+
body.getAllByRole("option", { name }),
|
|
1421
|
+
).toHaveLength(1)
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
// An exact name is the whole name: "Alpha" alone matches neither.
|
|
1425
|
+
await expect(
|
|
1426
|
+
body.queryAllByRole("option", { name: "Alpha" }),
|
|
1427
|
+
).toHaveLength(0)
|
|
1428
|
+
|
|
1429
|
+
const chosen = body.getByRole("option", {
|
|
1430
|
+
selected: true,
|
|
1431
|
+
})
|
|
1432
|
+
|
|
1433
|
+
await expect(chosen).toHaveAccessibleName(
|
|
1434
|
+
"Alpha, Second Source",
|
|
1435
|
+
)
|
|
1436
|
+
await expect(input).toHaveAttribute(
|
|
1437
|
+
"aria-activedescendant",
|
|
1438
|
+
chosen.id,
|
|
1439
|
+
)
|
|
1440
|
+
|
|
1441
|
+
// A search lists both under their headings, still told apart.
|
|
1442
|
+
await userEvent.keyboard("alpha")
|
|
1443
|
+
|
|
1444
|
+
await waitFor(() => {
|
|
1445
|
+
expectOptionNames(body, [
|
|
1446
|
+
"Alpha, Provider One",
|
|
1447
|
+
"Alpha, Second Source",
|
|
1448
|
+
])
|
|
1449
|
+
})
|
|
1450
|
+
})
|
|
1451
|
+
|
|
1452
|
+
test("the trigger names the chosen row's group, and so does the dialog it opens", async () => {
|
|
1453
|
+
const { body, chosen, render, trigger } =
|
|
1454
|
+
await openSmallPicker(
|
|
1455
|
+
SAME_LABEL_PROPS,
|
|
1456
|
+
"Model: Alpha, Second Source",
|
|
1457
|
+
)
|
|
1458
|
+
|
|
1459
|
+
await expect(
|
|
1460
|
+
body.getByRole("dialog"),
|
|
1461
|
+
).toHaveAccessibleName("Model: Alpha, Second Source")
|
|
1462
|
+
|
|
1463
|
+
await userEvent.click(
|
|
1464
|
+
body.getByRole("option", {
|
|
1465
|
+
name: "Alpha, Provider One",
|
|
1466
|
+
}),
|
|
1467
|
+
)
|
|
1468
|
+
|
|
1469
|
+
await waitFor(() => {
|
|
1470
|
+
expect(body.queryByRole("dialog")).toBeNull()
|
|
1471
|
+
})
|
|
1472
|
+
|
|
1473
|
+
await expect(chosen).toEqual(["alpha"])
|
|
1474
|
+
|
|
1475
|
+
// This harness does not feed the choice back; the app would.
|
|
1476
|
+
render({ value: "alpha" })
|
|
1477
|
+
|
|
1478
|
+
await waitFor(() => {
|
|
1479
|
+
expect(trigger).toHaveAccessibleName(
|
|
1480
|
+
"Model: Alpha, Provider One",
|
|
1481
|
+
)
|
|
1482
|
+
})
|
|
1483
|
+
})
|
|
1484
|
+
|
|
1485
|
+
test("a row with no group, or whose group is missing, has no group in its name", async () => {
|
|
1486
|
+
const { body, render, trigger } = await openSmallPicker(
|
|
1487
|
+
{ ...SAME_LABEL_PROPS, value: "loose" },
|
|
1488
|
+
"Model: Loose End",
|
|
1489
|
+
)
|
|
1490
|
+
|
|
1491
|
+
// Both are listed on every tab, so on Favorites too.
|
|
1492
|
+
for (const name of ["Loose End", "Stray"]) {
|
|
1493
|
+
await expect(
|
|
1494
|
+
body.getAllByRole("option", { name }),
|
|
1495
|
+
).toHaveLength(1)
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
await expect(
|
|
1499
|
+
body.getByRole("option", { selected: true }),
|
|
1500
|
+
).toHaveAccessibleName("Loose End")
|
|
1501
|
+
|
|
1502
|
+
await userEvent.keyboard("{Escape}")
|
|
1503
|
+
|
|
1504
|
+
await waitFor(() => {
|
|
1505
|
+
expect(body.queryByRole("dialog")).toBeNull()
|
|
1506
|
+
})
|
|
1507
|
+
|
|
1508
|
+
render({ value: "stray" })
|
|
1509
|
+
|
|
1510
|
+
await waitFor(() => {
|
|
1511
|
+
expect(trigger).toHaveAccessibleName("Model: Stray")
|
|
1512
|
+
})
|
|
1513
|
+
})
|
|
1514
|
+
|
|
1515
|
+
test("a trailing space in a description or a label leaves no space before the group's comma", async () => {
|
|
1516
|
+
const { body, render, trigger } = await openSmallPicker(
|
|
1517
|
+
{
|
|
1518
|
+
items: [
|
|
1519
|
+
{ ...ALPHA, description: "Preview " },
|
|
1520
|
+
{ ...BETA, label: "Beta " },
|
|
1521
|
+
],
|
|
1522
|
+
value: "alpha",
|
|
1523
|
+
},
|
|
1524
|
+
"Model: Alpha, Provider One",
|
|
1525
|
+
)
|
|
1526
|
+
|
|
1527
|
+
await expect(
|
|
1528
|
+
body.getByRole("option", { selected: true }),
|
|
1529
|
+
).toHaveAccessibleName("Alpha Preview, Provider One")
|
|
1530
|
+
|
|
1531
|
+
await userEvent.keyboard("{Escape}")
|
|
1532
|
+
|
|
1533
|
+
await waitFor(() => {
|
|
1534
|
+
expect(body.queryByRole("dialog")).toBeNull()
|
|
1535
|
+
})
|
|
1536
|
+
|
|
1537
|
+
render({ value: "beta" })
|
|
1538
|
+
|
|
1539
|
+
await waitFor(() => {
|
|
1540
|
+
expect(trigger).toHaveAccessibleName(
|
|
1541
|
+
"Model: Beta, Provider One",
|
|
1542
|
+
)
|
|
1543
|
+
})
|
|
1544
|
+
})
|
|
1545
|
+
|
|
1546
|
+
test("a blank description adds nothing to a name", async () => {
|
|
1547
|
+
const { body } = await openSmallPicker(
|
|
1548
|
+
{
|
|
1549
|
+
items: [{ ...ALPHA, description: " " }],
|
|
1550
|
+
value: "alpha",
|
|
1551
|
+
},
|
|
1552
|
+
"Model: Alpha, Provider One",
|
|
1553
|
+
)
|
|
1554
|
+
|
|
1555
|
+
await expect(
|
|
1556
|
+
body.getByRole("option", { selected: true }),
|
|
1557
|
+
).toHaveAccessibleName("Alpha, Provider One")
|
|
1558
|
+
})
|
|
1559
|
+
|
|
1560
|
+
test("a group with a blank label adds nothing to a name", async () => {
|
|
1561
|
+
const { body } = await openSmallPicker(
|
|
1562
|
+
{
|
|
1563
|
+
groups: [{ id: "provider one", label: " " }],
|
|
1564
|
+
items: [ALPHA],
|
|
1565
|
+
value: "alpha",
|
|
1566
|
+
},
|
|
1567
|
+
"Model: Alpha",
|
|
1568
|
+
)
|
|
1569
|
+
|
|
1570
|
+
await expect(
|
|
1571
|
+
body.getByRole("option", { selected: true }),
|
|
1572
|
+
).toHaveAccessibleName("Alpha")
|
|
1573
|
+
})
|
|
1574
|
+
|
|
1575
|
+
test("a row's name is its label, its description, then its group", async () => {
|
|
1576
|
+
const { body } = await openPicker(
|
|
1577
|
+
Playground,
|
|
1578
|
+
"Agent: Lumen 4, Contoso",
|
|
1579
|
+
)
|
|
1580
|
+
|
|
1581
|
+
// The Favorites tab: a pinned row has no group; the two Lumen 4
|
|
1582
|
+
// rows differ by description and by group.
|
|
1583
|
+
expectOptionNames(body, [
|
|
1584
|
+
"Default Whatever the app picks",
|
|
1585
|
+
"Lumen 4 ct-lumen-4, Contoso",
|
|
1586
|
+
"Swift 3 nw-swift-3, Northwind",
|
|
1587
|
+
"Lumen 4 Work account, Contoso (Work)",
|
|
1588
|
+
// The "TL" initials badge is decorative; the group says it.
|
|
1589
|
+
"Glide 2 ts-glide-2, Tailspin Labs",
|
|
1590
|
+
"Choose per task Ask every time",
|
|
1591
|
+
])
|
|
1592
|
+
})
|
|
@@ -21,6 +21,7 @@ import { CatalogPickerPanel } from "./CatalogPickerPanel.tsx"
|
|
|
21
21
|
import {
|
|
22
22
|
type CatalogPickerGroup,
|
|
23
23
|
type CatalogPickerItem,
|
|
24
|
+
toGroupedName,
|
|
24
25
|
toUniqueCatalog,
|
|
25
26
|
} from "./catalogPickerView.ts"
|
|
26
27
|
|
|
@@ -85,7 +86,9 @@ export type CatalogPickerProps = Omit<
|
|
|
85
86
|
/**
|
|
86
87
|
* What the control is FOR — "Agent", "Model". Not the current value.
|
|
87
88
|
* The trigger is named `"<label>: <chosen label>"`, as in `Picker`,
|
|
88
|
-
*
|
|
89
|
+
* then `", <group label>"` when the chosen item's group has a label
|
|
90
|
+
* that is not blank; the
|
|
91
|
+
* search field and the list are named `label`.
|
|
89
92
|
*/
|
|
90
93
|
label: string
|
|
91
94
|
onChange: (value: string) => void
|
|
@@ -133,7 +136,10 @@ const PANEL_MAX_WIDTH_PX = 416
|
|
|
133
136
|
* `aria-activedescendant` — the `Combobox` contract. The rail is a
|
|
134
137
|
* vertical `role="toolbar"` of `aria-pressed` buttons, and Tab moves
|
|
135
138
|
* between the field, its clear button and the rail. Escape clears a
|
|
136
|
-
* query, then closes, and focus returns to the trigger.
|
|
139
|
+
* query, then closes, and focus returns to the trigger. A row is
|
|
140
|
+
* named by its label, its description and then its group's label (when
|
|
141
|
+
* not blank), and the trigger by the chosen row's label and group: the mark is decorative,
|
|
142
|
+
* so two groups' same-label rows must not read alike. The picker
|
|
137
143
|
* consumes every Escape it handles, so one inside a `Dialog` never
|
|
138
144
|
* closes the dialog too.
|
|
139
145
|
*
|
|
@@ -279,7 +285,12 @@ export const CatalogPicker = ({
|
|
|
279
285
|
<Button
|
|
280
286
|
{...buttonProps}
|
|
281
287
|
appearance="outline"
|
|
282
|
-
|
|
288
|
+
// The chosen row's group in words, as the row says it: the
|
|
289
|
+
// badge beside the text is decorative.
|
|
290
|
+
aria-label={toGroupedName(
|
|
291
|
+
`${label}: ${triggerText}`,
|
|
292
|
+
chosenGroup,
|
|
293
|
+
)}
|
|
283
294
|
className={toClassName(
|
|
284
295
|
"justify-between",
|
|
285
296
|
className,
|
|
@@ -8,9 +8,10 @@ import {
|
|
|
8
8
|
CHOSEN_CHECK,
|
|
9
9
|
ROW_FAVORITE_STAR,
|
|
10
10
|
} from "./catalogPickerDrawings.tsx"
|
|
11
|
-
import
|
|
12
|
-
CatalogPickerGroup,
|
|
13
|
-
CatalogPickerItem,
|
|
11
|
+
import {
|
|
12
|
+
type CatalogPickerGroup,
|
|
13
|
+
type CatalogPickerItem,
|
|
14
|
+
toGroupedName,
|
|
14
15
|
} from "./catalogPickerView.ts"
|
|
15
16
|
|
|
16
17
|
export type CatalogPickerOptionProps = {
|
|
@@ -68,8 +69,21 @@ export const CatalogPickerOption = ({
|
|
|
68
69
|
value,
|
|
69
70
|
} = item
|
|
70
71
|
|
|
72
|
+
const hasDescription =
|
|
73
|
+
description !== undefined && description.trim() !== ""
|
|
74
|
+
|
|
71
75
|
return (
|
|
72
76
|
<button
|
|
77
|
+
// The row's text, then its group in words: the badge is
|
|
78
|
+
// decorative, and two groups' "Opus" in Favorites must not read
|
|
79
|
+
// alike. An `aria-label`, not a `VisuallyHidden` suffix: an
|
|
80
|
+
// `sr-only` span is laid out as a block, so Chromium, Playwright,
|
|
81
|
+
// and Testing Library named the row "Opus , Team", with a space
|
|
82
|
+
// before the comma.
|
|
83
|
+
aria-label={toGroupedName(
|
|
84
|
+
`${label}${hasDescription ? ` ${description}` : ""}`,
|
|
85
|
+
group,
|
|
86
|
+
)}
|
|
73
87
|
aria-selected={isSelected}
|
|
74
88
|
className={toClassName(
|
|
75
89
|
"flex w-full cursor-pointer items-center rounded-sm text-start",
|
|
@@ -107,8 +121,7 @@ export const CatalogPickerOption = ({
|
|
|
107
121
|
{label}
|
|
108
122
|
</span>
|
|
109
123
|
|
|
110
|
-
{
|
|
111
|
-
description === "" ? null : (
|
|
124
|
+
{hasDescription ? (
|
|
112
125
|
<span
|
|
113
126
|
className={toClassName(
|
|
114
127
|
"min-w-0 text-sm wrap-anywhere",
|
|
@@ -119,7 +132,7 @@ export const CatalogPickerOption = ({
|
|
|
119
132
|
>
|
|
120
133
|
{description}
|
|
121
134
|
</span>
|
|
122
|
-
)}
|
|
135
|
+
) : null}
|
|
123
136
|
</span>
|
|
124
137
|
|
|
125
138
|
{isFavorite ? ROW_FAVORITE_STAR : null}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
isCatalogItemMatch,
|
|
10
10
|
pickInitialTabKey,
|
|
11
11
|
resolveFavoriteItems,
|
|
12
|
+
toGroupedName,
|
|
12
13
|
toGroupTabKey,
|
|
13
14
|
toInitials,
|
|
14
15
|
toUniqueCatalog,
|
|
@@ -344,3 +345,21 @@ test("initials are the first letter or digit of the first two words", () => {
|
|
|
344
345
|
expect(toInitials(" Contoso (Work) ")).toBe("CW")
|
|
345
346
|
expect(toInitials("4 Seasons")).toBe("4S")
|
|
346
347
|
})
|
|
348
|
+
|
|
349
|
+
test("a name says its group after a comma, with no space before it, and says nothing for no group or a blank label", () => {
|
|
350
|
+
const TEAM_TWO = { id: "two", label: "Team Two" }
|
|
351
|
+
|
|
352
|
+
expect(toGroupedName("Opus", TEAM_TWO)).toBe(
|
|
353
|
+
"Opus, Team Two",
|
|
354
|
+
)
|
|
355
|
+
expect(toGroupedName("Opus Preview ", TEAM_TWO)).toBe(
|
|
356
|
+
"Opus Preview, Team Two",
|
|
357
|
+
)
|
|
358
|
+
expect(toGroupedName("Opus", undefined)).toBe("Opus")
|
|
359
|
+
expect(
|
|
360
|
+
toGroupedName("Opus", { id: "blank", label: "" }),
|
|
361
|
+
).toBe("Opus")
|
|
362
|
+
expect(
|
|
363
|
+
toGroupedName("Opus", { id: "space", label: " " }),
|
|
364
|
+
).toBe("Opus")
|
|
365
|
+
})
|
|
@@ -32,7 +32,11 @@ export type CatalogPickerItem = {
|
|
|
32
32
|
/** Overrides the group's icon or badge for this row. */
|
|
33
33
|
icon?: ReactNode
|
|
34
34
|
isDisabled?: boolean
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* The row's visible label and the trigger's text, and the first part
|
|
37
|
+
* of the row's accessible name (then the description, then the
|
|
38
|
+
* group). Searched.
|
|
39
|
+
*/
|
|
36
40
|
label: string
|
|
37
41
|
/**
|
|
38
42
|
* Shown at the top (`"start"`) or the bottom (`"end"`) of every rail
|
|
@@ -442,6 +446,21 @@ export const buildCatalogSections = ({
|
|
|
442
446
|
].filter((section) => section.items.length > 0)
|
|
443
447
|
}
|
|
444
448
|
|
|
449
|
+
/**
|
|
450
|
+
* A row's or the trigger's accessible name: its text, then the group
|
|
451
|
+
* in words — `"Opus, Team Two"`. The text's trailing spaces go, so the
|
|
452
|
+
* comma this adds never follows a space; no group, or a group whose
|
|
453
|
+
* label is blank, leaves the text as it is, so this never adds a bare
|
|
454
|
+
* comma.
|
|
455
|
+
*/
|
|
456
|
+
export const toGroupedName = (
|
|
457
|
+
text: string,
|
|
458
|
+
group: CatalogPickerGroup | undefined,
|
|
459
|
+
) =>
|
|
460
|
+
group === undefined || group.label.trim() === ""
|
|
461
|
+
? text
|
|
462
|
+
: `${text.trimEnd()}, ${group.label}`
|
|
463
|
+
|
|
445
464
|
/**
|
|
446
465
|
* A badge's text: the first letter or digit of each of the first two
|
|
447
466
|
* words that have one, so "Northwind" is "N", "Contoso Labs" is "CL",
|