@charcuterie/ui 4.29.0 → 4.31.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/README.md +7 -2
- 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/docs/README.md +573 -0
- package/docs/building-an-app.md +231 -0
- package/docs/components/Accordion.md +106 -0
- package/docs/components/ActionMenu.md +63 -0
- package/docs/components/ActionTiles.md +233 -0
- package/docs/components/AdaptiveGrid.md +215 -0
- package/docs/components/Alert.md +99 -0
- package/docs/components/AnchorLink.md +23 -0
- package/docs/components/Avatar.md +153 -0
- package/docs/components/Badge.md +81 -0
- package/docs/components/BadgeButton.md +84 -0
- package/docs/components/Board.md +277 -0
- package/docs/components/Breadcrumbs.md +87 -0
- package/docs/components/Button.md +72 -0
- package/docs/components/ButtonLink.md +81 -0
- package/docs/components/Card.md +114 -0
- package/docs/components/CatalogPicker.md +250 -0
- package/docs/components/Chart.md +39 -0
- package/docs/components/Checkbox.md +197 -0
- package/docs/components/ColorPicker.md +99 -0
- package/docs/components/ColorSchemeSwitcher.md +92 -0
- package/docs/components/ColorSchemeToggle.md +98 -0
- package/docs/components/Combobox.md +175 -0
- package/docs/components/CommandPalette.md +120 -0
- package/docs/components/ComparisonChart.md +31 -0
- package/docs/components/CopyButton.md +112 -0
- package/docs/components/DataTable.md +170 -0
- package/docs/components/DatePicker.md +225 -0
- package/docs/components/Dialog.md +134 -0
- package/docs/components/DropRail.md +107 -0
- package/docs/components/EmptyState.md +65 -0
- package/docs/components/Field.md +215 -0
- package/docs/components/FieldGroup.md +45 -0
- package/docs/components/FileDropZone.md +98 -0
- package/docs/components/GroupedList.md +189 -0
- package/docs/components/Header.md +76 -0
- package/docs/components/HtmlEditor-html-editor.md +76 -0
- package/docs/components/HtmlView-html-editor.md +47 -0
- package/docs/components/HtmlView-html-view.md +47 -0
- package/docs/components/IconButton.md +52 -0
- package/docs/components/LaneTimeline.md +254 -0
- package/docs/components/Lightbox.md +101 -0
- package/docs/components/Listbox.md +109 -0
- package/docs/components/LiveStatusIndicator.md +60 -0
- package/docs/components/LogViewer.md +142 -0
- package/docs/components/Main.md +247 -0
- package/docs/components/MarkdownEditor.md +262 -0
- package/docs/components/MarkdownEditorCodeMirror-markdown-editor-codemirror.md +230 -0
- package/docs/components/MarkdownLine.md +187 -0
- package/docs/components/MarkdownView-markdown-editor-codemirror.md +235 -0
- package/docs/components/MediaTile.md +106 -0
- package/docs/components/Menu.md +209 -0
- package/docs/components/MetricCard.md +38 -0
- package/docs/components/Modal.md +89 -0
- package/docs/components/Nav.md +167 -0
- package/docs/components/NavBar.md +190 -0
- package/docs/components/Picker.md +132 -0
- package/docs/components/Popover.md +135 -0
- package/docs/components/PortraitTiles.md +169 -0
- package/docs/components/ProgressBar.md +70 -0
- package/docs/components/ProgressCard.md +65 -0
- package/docs/components/QueryBuilder.md +132 -0
- package/docs/components/RadioGroup.md +165 -0
- package/docs/components/Rail.md +79 -0
- package/docs/components/RangeSlider.md +144 -0
- package/docs/components/ReactRouterAdapter-react-router.md +27 -0
- package/docs/components/ReactRouterLink-react-router.md +23 -0
- package/docs/components/ReorderList.md +143 -0
- package/docs/components/RouterLinkProvider.md +33 -0
- package/docs/components/ScheduleBoard.md +41 -0
- package/docs/components/ScrollMemoryProvider.md +33 -0
- package/docs/components/SearchInput.md +46 -0
- package/docs/components/SegmentedControl.md +98 -0
- package/docs/components/Select.md +169 -0
- package/docs/components/Shell.md +162 -0
- package/docs/components/Skeleton.md +48 -0
- package/docs/components/Slider.md +128 -0
- package/docs/components/SortableTableHeader.md +84 -0
- package/docs/components/Spinner.md +50 -0
- package/docs/components/Stepper.md +121 -0
- package/docs/components/Swatch.md +79 -0
- package/docs/components/Switch.md +80 -0
- package/docs/components/TableColumns.md +29 -0
- package/docs/components/TableViewport.md +42 -0
- package/docs/components/Tabs.md +184 -0
- package/docs/components/TextLink.md +106 -0
- package/docs/components/TimecodeInput.md +222 -0
- package/docs/components/Toast.md +108 -0
- package/docs/components/ToastRegion.md +35 -0
- package/docs/components/Toolbar.md +118 -0
- package/docs/components/Tooltip.md +94 -0
- package/docs/components/UnstyledLink.md +21 -0
- package/docs/components/ValuePairs.md +30 -0
- package/docs/components/VirtualizedGrid.md +204 -0
- package/docs/components/VisuallyHidden.md +39 -0
- package/docs/components/WeekdayIndicator.md +39 -0
- package/docs/hooks/useAdaptiveColumns.md +111 -0
- package/docs/hooks/useCommandPalette.md +40 -0
- package/docs/hooks/useCommandPaletteHotkeys.md +33 -0
- package/docs/hooks/useDeploymentUpdate.md +39 -0
- package/docs/hooks/useLastPresentValue.md +23 -0
- package/docs/hooks/useListMotion.md +65 -0
- package/docs/hooks/useNavLayout.md +59 -0
- package/docs/hooks/usePresence.md +39 -0
- package/docs/hooks/useRouterLink.md +22 -0
- package/docs/hooks/useValueChangeMotion.md +28 -0
- package/package.json +7 -5
- package/skills/charcuterie/SKILL.md +17 -0
- package/skills/charcuterie/references/build-a-screen.md +6 -0
- package/skills/charcuterie/references/create-a-component.md +6 -0
- package/src/AdaptiveGrid/AdaptiveGrid.stories.tsx +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
- package/src/Tabs/Tabs.stories.tsx +1 -1
- package/src/VirtualizedGrid/VirtualizedGrid.stories.tsx +65 -28
- package/src/VirtualizedGrid/VirtualizedGrid.test.tsx +29 -0
- package/src/shell.storyHelpers.tsx +3 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# usePresence
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { usePresence } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Use this to keep one app-owned element mounted during its exit. Use `useListMotion` for a collection. Pair it with the shipped motion classes and hide exiting content from assistive technology.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { toFadeMotionClass } from "@charcuterie/ui"
|
|
11
|
+
|
|
12
|
+
function Details({ isVisible }: { isVisible: boolean }) {
|
|
13
|
+
const { isMounted, isExiting, presenceRef } = usePresence<HTMLDivElement>(isVisible)
|
|
14
|
+
return isMounted ? (
|
|
15
|
+
<div aria-hidden={isExiting} className={toFadeMotionClass(isExiting)} inert={isExiting} ref={presenceRef}>
|
|
16
|
+
Details
|
|
17
|
+
</div>
|
|
18
|
+
) : null
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Published TypeScript API
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
const usePresence: <Element extends HTMLElement = HTMLElement>(isVisible: boolean) => UsePresenceResult<Element>
|
|
26
|
+
|
|
27
|
+
type UsePresenceResult<Element extends HTMLElement = HTMLElement> = {
|
|
28
|
+
/** Mounted, but closed: make it `inert` and give it the exit class. */
|
|
29
|
+
isExiting: boolean;
|
|
30
|
+
/** Whether to render the element at all. */
|
|
31
|
+
isMounted: boolean;
|
|
32
|
+
/** Attach to the element whose exit animation ends the presence. */
|
|
33
|
+
presenceRef: RefObject<Element | null>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
Element extends HTMLElement = HTMLElement
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
[Full declarations](../../dist/Motion/usePresence.d.ts)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# useRouterLink
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { useRouterLink } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Use this when implementing a custom link that must use the current router adapter. Use `TextLink`, `ButtonLink`, or `UnstyledLink` for ordinary application links. Pass an href and visible text and keep the link's native keyboard and modifier-click behavior.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
const Link = useRouterLink()
|
|
11
|
+
return <Link href="/settings">Settings</Link>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Published TypeScript API
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
const useRouterLink: () => RouterLinkComponent
|
|
18
|
+
|
|
19
|
+
type RouterLinkComponent = ComponentType<RouterLinkProps>;
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
[Full declarations](../../dist/RouterLink/RouterLinkProvider.d.ts)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# useValueChangeMotion
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { useValueChangeMotion } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Use this to highlight a changing value. Use `useListMotion` for added, removed, or reordered items. If a value needs to be announced, use a suitable live region independently of the animation.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
function JobTotal({ total }: { total: number }) {
|
|
11
|
+
const motion = useValueChangeMotion(total)
|
|
12
|
+
return <span {...motion}>Total: {total}</span>
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Published TypeScript API
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
const useValueChangeMotion: (value: unknown) => ValueChangeMotionProps
|
|
20
|
+
|
|
21
|
+
type ValueChangeMotionProps = {
|
|
22
|
+
/** The pop class while the pop runs; `undefined` otherwise. */
|
|
23
|
+
className: string | undefined;
|
|
24
|
+
onAnimationEnd: (event: AnimationEvent<HTMLElement>) => void;
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
[Full declarations](../../dist/Motion/useValueChangeMotion.d.ts)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@charcuterie/ui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.31.0",
|
|
4
4
|
"description": "The Charcuterie components. Tokens for look, @charcuterie/logic for state, ARIA that agents can actually drive.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -53,12 +53,14 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"files": [
|
|
56
|
+
"docs",
|
|
57
|
+
"skills",
|
|
56
58
|
"dist",
|
|
57
59
|
"src"
|
|
58
60
|
],
|
|
59
61
|
"dependencies": {
|
|
60
|
-
"@charcuterie/logic": "2.
|
|
61
|
-
"@charcuterie/tokens": "1.
|
|
62
|
+
"@charcuterie/logic": "2.13.0",
|
|
63
|
+
"@charcuterie/tokens": "1.11.0",
|
|
62
64
|
"@floating-ui/react": "^0.27.20",
|
|
63
65
|
"@tanstack/react-virtual": "^3.13.12",
|
|
64
66
|
"tailwind-merge": "^3.6.0"
|
|
@@ -130,7 +132,7 @@
|
|
|
130
132
|
}
|
|
131
133
|
},
|
|
132
134
|
"devDependencies": {
|
|
133
|
-
"@charcuterie/storybook-config": "0.4.
|
|
135
|
+
"@charcuterie/storybook-config": "0.4.5",
|
|
134
136
|
"@charcuterie/vitest-config": "^2.0.0",
|
|
135
137
|
"@codemirror/commands": "^6",
|
|
136
138
|
"@codemirror/lang-markdown": "^6",
|
|
@@ -166,7 +168,7 @@
|
|
|
166
168
|
"directory": "packages/ui"
|
|
167
169
|
},
|
|
168
170
|
"scripts": {
|
|
169
|
-
"build": "tsc -p tsconfig.build.json && node scripts/copyStyles.ts",
|
|
171
|
+
"build": "tsc -p tsconfig.build.json && node scripts/copyStyles.ts && node ../../scripts/packageDocs.mjs",
|
|
170
172
|
"test": "vitest",
|
|
171
173
|
"typecheck": "tsc --noEmit"
|
|
172
174
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: charcuterie
|
|
3
|
+
description: Choose and compose Charcuterie React components for app screens, use the installed library APIs, or add a shared component in the Charcuterie repository. Use when an app depends on @charcuterie/ui or the task names Charcuterie.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Build with Charcuterie
|
|
7
|
+
|
|
8
|
+
Start with the [installed UI docs](../../docs/README.md). Their API and examples match this package's version. If this skill was copied into an agent's skill directory, open `node_modules/@charcuterie/ui/docs/README.md` from the app instead and follow its links.
|
|
9
|
+
|
|
10
|
+
- For a new screen or an app setup, use the [screen workflow](references/build-a-screen.md).
|
|
11
|
+
- To choose a component, use the [component-choice table](../../docs/building-an-app.md#the-component-choice-table), then read the selected component's page for props and accessible behavior.
|
|
12
|
+
- To add a shared component in the library repository, use the [component authoring workflow](references/create-a-component.md).
|
|
13
|
+
- To work directly with state, read `node_modules/@charcuterie/logic/docs/README.md` if the app installs logic directly. For tokens, start at `node_modules/@charcuterie/tokens/docs/README.md`.
|
|
14
|
+
|
|
15
|
+
Use the package entry named on each component page. Check the installed declaration linked there when you need a type the example does not cover.
|
|
16
|
+
|
|
17
|
+
The app ESLint preset enables the picker rules. Opt into the rest of the component-choice rules with `componentChoice: "all"` and the flex-overflow rules with `flexOverflow: "warn"`. See [app setup](../../docs/building-an-app.md#3-adopt-the-house-lint-config).
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Build a screen
|
|
2
|
+
|
|
3
|
+
1. Read the [app setup and component-choice table](../../../docs/building-an-app.md). Match the screen to the existing app's stylesheet, adapter, and lint setup. For a new app, follow the Tailwind source and stylesheet instructions in the guide.
|
|
4
|
+
2. Choose the screen structure with `Shell`, `Header`, `Rail`, and `Main`. Pick links for destinations and buttons for actions. For each form control, decide whether it needs `Field` for a label and error. Use `Picker` for a short options list, `Listbox` for a custom trigger, and `Combobox` for type-to-search. Native `Select` is deprecated.
|
|
5
|
+
3. Read the matching pages in the [UI index](../../../docs/README.md). Apply their naming, focus, keyboard, and dismissal contracts. Keep data and routing decisions in the app. The app supplies icons.
|
|
6
|
+
4. Test the primary task using accessible role and name queries. Test keyboard operation, dismissal and focus return where relevant, and the layout at a narrow container width.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Add a shared component
|
|
2
|
+
|
|
3
|
+
1. Compare the needed behavior with the [component-choice table](../../../docs/building-an-app.md#the-component-choice-table) and the [UI index](../../../docs/README.md). Check sibling components before adding a new public shape.
|
|
4
|
+
2. In a Charcuterie checkout, read the repository's `AGENTS.md`, decision index, and the [UI component checklist](../../../README.md#adding-a-component). Put rendering and ARIA in UI. Use the state kinds in logic where they fit. State-hook options initialize once. Keep tokens independent of UI and logic.
|
|
5
|
+
3. Put the component, Storybook MDX, stories, and tests in the same component directory. Export the component and its public types from the intended entry. Include a short example and explain what the caller must supply for names, focus, keyboard interaction, or announcements. The package build uses that MDX, the story, and the emitted declarations to generate its page.
|
|
6
|
+
4. Exercise the named role and keyboard path with the library test harness. Run the package build, check the generated page, and verify the tarball through the package documentation test.
|
|
@@ -63,7 +63,7 @@ const Item = ({ label }: { label: string }) => (
|
|
|
63
63
|
* the clipping to matter.
|
|
64
64
|
*/}
|
|
65
65
|
<p className="truncate text-content-muted text-sm">
|
|
66
|
-
/mnt/
|
|
66
|
+
/mnt/media/archive/videos/very/long/unbroken/path/that/would/push/a/track/wide
|
|
67
67
|
</p>
|
|
68
68
|
</Card>
|
|
69
69
|
)
|
|
@@ -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
|
+
})
|