@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.
Files changed (134) hide show
  1. package/README.md +7 -2
  2. package/dist/CatalogPicker/CatalogPicker.d.ts +7 -2
  3. package/dist/CatalogPicker/CatalogPicker.d.ts.map +1 -1
  4. package/dist/CatalogPicker/CatalogPicker.js +6 -3
  5. package/dist/CatalogPicker/CatalogPicker.js.map +1 -1
  6. package/dist/CatalogPicker/CatalogPickerOption.d.ts +1 -1
  7. package/dist/CatalogPicker/CatalogPickerOption.d.ts.map +1 -1
  8. package/dist/CatalogPicker/CatalogPickerOption.js +5 -4
  9. package/dist/CatalogPicker/CatalogPickerOption.js.map +1 -1
  10. package/dist/CatalogPicker/catalogPickerView.d.ts +13 -1
  11. package/dist/CatalogPicker/catalogPickerView.d.ts.map +1 -1
  12. package/dist/CatalogPicker/catalogPickerView.js +10 -0
  13. package/dist/CatalogPicker/catalogPickerView.js.map +1 -1
  14. package/docs/README.md +573 -0
  15. package/docs/building-an-app.md +231 -0
  16. package/docs/components/Accordion.md +106 -0
  17. package/docs/components/ActionMenu.md +63 -0
  18. package/docs/components/ActionTiles.md +233 -0
  19. package/docs/components/AdaptiveGrid.md +215 -0
  20. package/docs/components/Alert.md +99 -0
  21. package/docs/components/AnchorLink.md +23 -0
  22. package/docs/components/Avatar.md +153 -0
  23. package/docs/components/Badge.md +81 -0
  24. package/docs/components/BadgeButton.md +84 -0
  25. package/docs/components/Board.md +277 -0
  26. package/docs/components/Breadcrumbs.md +87 -0
  27. package/docs/components/Button.md +72 -0
  28. package/docs/components/ButtonLink.md +81 -0
  29. package/docs/components/Card.md +114 -0
  30. package/docs/components/CatalogPicker.md +250 -0
  31. package/docs/components/Chart.md +39 -0
  32. package/docs/components/Checkbox.md +197 -0
  33. package/docs/components/ColorPicker.md +99 -0
  34. package/docs/components/ColorSchemeSwitcher.md +92 -0
  35. package/docs/components/ColorSchemeToggle.md +98 -0
  36. package/docs/components/Combobox.md +175 -0
  37. package/docs/components/CommandPalette.md +120 -0
  38. package/docs/components/ComparisonChart.md +31 -0
  39. package/docs/components/CopyButton.md +112 -0
  40. package/docs/components/DataTable.md +170 -0
  41. package/docs/components/DatePicker.md +225 -0
  42. package/docs/components/Dialog.md +134 -0
  43. package/docs/components/DropRail.md +107 -0
  44. package/docs/components/EmptyState.md +65 -0
  45. package/docs/components/Field.md +215 -0
  46. package/docs/components/FieldGroup.md +45 -0
  47. package/docs/components/FileDropZone.md +98 -0
  48. package/docs/components/GroupedList.md +189 -0
  49. package/docs/components/Header.md +76 -0
  50. package/docs/components/HtmlEditor-html-editor.md +76 -0
  51. package/docs/components/HtmlView-html-editor.md +47 -0
  52. package/docs/components/HtmlView-html-view.md +47 -0
  53. package/docs/components/IconButton.md +52 -0
  54. package/docs/components/LaneTimeline.md +254 -0
  55. package/docs/components/Lightbox.md +101 -0
  56. package/docs/components/Listbox.md +109 -0
  57. package/docs/components/LiveStatusIndicator.md +60 -0
  58. package/docs/components/LogViewer.md +142 -0
  59. package/docs/components/Main.md +247 -0
  60. package/docs/components/MarkdownEditor.md +262 -0
  61. package/docs/components/MarkdownEditorCodeMirror-markdown-editor-codemirror.md +230 -0
  62. package/docs/components/MarkdownLine.md +187 -0
  63. package/docs/components/MarkdownView-markdown-editor-codemirror.md +235 -0
  64. package/docs/components/MediaTile.md +106 -0
  65. package/docs/components/Menu.md +209 -0
  66. package/docs/components/MetricCard.md +38 -0
  67. package/docs/components/Modal.md +89 -0
  68. package/docs/components/Nav.md +167 -0
  69. package/docs/components/NavBar.md +190 -0
  70. package/docs/components/Picker.md +132 -0
  71. package/docs/components/Popover.md +135 -0
  72. package/docs/components/PortraitTiles.md +169 -0
  73. package/docs/components/ProgressBar.md +70 -0
  74. package/docs/components/ProgressCard.md +65 -0
  75. package/docs/components/QueryBuilder.md +132 -0
  76. package/docs/components/RadioGroup.md +165 -0
  77. package/docs/components/Rail.md +79 -0
  78. package/docs/components/RangeSlider.md +144 -0
  79. package/docs/components/ReactRouterAdapter-react-router.md +27 -0
  80. package/docs/components/ReactRouterLink-react-router.md +23 -0
  81. package/docs/components/ReorderList.md +143 -0
  82. package/docs/components/RouterLinkProvider.md +33 -0
  83. package/docs/components/ScheduleBoard.md +41 -0
  84. package/docs/components/ScrollMemoryProvider.md +33 -0
  85. package/docs/components/SearchInput.md +46 -0
  86. package/docs/components/SegmentedControl.md +98 -0
  87. package/docs/components/Select.md +169 -0
  88. package/docs/components/Shell.md +162 -0
  89. package/docs/components/Skeleton.md +48 -0
  90. package/docs/components/Slider.md +128 -0
  91. package/docs/components/SortableTableHeader.md +84 -0
  92. package/docs/components/Spinner.md +50 -0
  93. package/docs/components/Stepper.md +121 -0
  94. package/docs/components/Swatch.md +79 -0
  95. package/docs/components/Switch.md +80 -0
  96. package/docs/components/TableColumns.md +29 -0
  97. package/docs/components/TableViewport.md +42 -0
  98. package/docs/components/Tabs.md +184 -0
  99. package/docs/components/TextLink.md +106 -0
  100. package/docs/components/TimecodeInput.md +222 -0
  101. package/docs/components/Toast.md +108 -0
  102. package/docs/components/ToastRegion.md +35 -0
  103. package/docs/components/Toolbar.md +118 -0
  104. package/docs/components/Tooltip.md +94 -0
  105. package/docs/components/UnstyledLink.md +21 -0
  106. package/docs/components/ValuePairs.md +30 -0
  107. package/docs/components/VirtualizedGrid.md +204 -0
  108. package/docs/components/VisuallyHidden.md +39 -0
  109. package/docs/components/WeekdayIndicator.md +39 -0
  110. package/docs/hooks/useAdaptiveColumns.md +111 -0
  111. package/docs/hooks/useCommandPalette.md +40 -0
  112. package/docs/hooks/useCommandPaletteHotkeys.md +33 -0
  113. package/docs/hooks/useDeploymentUpdate.md +39 -0
  114. package/docs/hooks/useLastPresentValue.md +23 -0
  115. package/docs/hooks/useListMotion.md +65 -0
  116. package/docs/hooks/useNavLayout.md +59 -0
  117. package/docs/hooks/usePresence.md +39 -0
  118. package/docs/hooks/useRouterLink.md +22 -0
  119. package/docs/hooks/useValueChangeMotion.md +28 -0
  120. package/package.json +7 -5
  121. package/skills/charcuterie/SKILL.md +17 -0
  122. package/skills/charcuterie/references/build-a-screen.md +6 -0
  123. package/skills/charcuterie/references/create-a-component.md +6 -0
  124. package/src/AdaptiveGrid/AdaptiveGrid.stories.tsx +1 -1
  125. package/src/CatalogPicker/CatalogPicker.mdx +36 -1
  126. package/src/CatalogPicker/CatalogPicker.test.tsx +264 -24
  127. package/src/CatalogPicker/CatalogPicker.tsx +14 -3
  128. package/src/CatalogPicker/CatalogPickerOption.tsx +19 -6
  129. package/src/CatalogPicker/catalogPickerView.test.ts +19 -0
  130. package/src/CatalogPicker/catalogPickerView.ts +20 -1
  131. package/src/Tabs/Tabs.stories.tsx +1 -1
  132. package/src/VirtualizedGrid/VirtualizedGrid.stories.tsx +65 -28
  133. package/src/VirtualizedGrid/VirtualizedGrid.test.tsx +29 -0
  134. package/src/shell.storyHelpers.tsx +3 -3
@@ -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
- * and the search field and the list are named `label`.
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. The picker
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
- aria-label={`${label}: ${triggerText}`}
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 type {
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
- {description === undefined ||
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
- /** The row's name and the trigger's text. Searched. */
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",
@@ -292,7 +292,7 @@ const ROUTED_STATE_TABS: TabLinkItem[] = [
292
292
  label: "Reports",
293
293
  },
294
294
  {
295
- href: "https://mkdocs.octen.dev/workspace/docket/",
295
+ href: "https://example.com/handbook/",
296
296
  isExternal: true,
297
297
  label: "Handbook",
298
298
  },
@@ -1,6 +1,6 @@
1
1
  import { playgroundParameters } from "@charcuterie/storybook-config/story-parameters"
2
2
  import type { Meta, StoryObj } from "@storybook/react"
3
- import { useState } from "react"
3
+ import { type ReactNode, useState } from "react"
4
4
 
5
5
  import { getColumnChoices } from "../AdaptiveGrid/chooseColumns.ts"
6
6
  import type { BlockSizeResolver } from "../AdaptiveGrid/useAdaptiveColumns.ts"
@@ -70,11 +70,32 @@ const Item = ({ label }: { label: string }) => (
70
70
  * matter.
71
71
  */}
72
72
  <p className="truncate text-content-muted text-sm">
73
- /mnt/Bunnies/Family/Media/very/long/unbroken/path/that/would/push/a/track/wide
73
+ /mnt/media/archive/videos/very/long/unbroken/path/that/would/push/a/track/wide
74
74
  </p>
75
75
  </Card>
76
76
  )
77
77
 
78
+ /**
79
+ * Give each long example a scroll window with a height before any rows
80
+ * mount. A max-height alone leaves the virtualizer an empty viewport.
81
+ */
82
+ const GridExampleWindow = ({
83
+ children,
84
+ label,
85
+ }: {
86
+ children: ReactNode
87
+ label: string
88
+ }) => (
89
+ <section
90
+ aria-label={label}
91
+ className="h-96 overflow-auto"
92
+ // biome-ignore lint/a11y/noNoninteractiveTabindex: Keyboard users need to focus the list's scroll region.
93
+ tabIndex={0}
94
+ >
95
+ {children}
96
+ </section>
97
+ )
98
+
78
99
  const meta = {
79
100
  title: "Components/Layout/VirtualizedGrid",
80
101
  component: VirtualizedGrid<Bay>,
@@ -110,6 +131,9 @@ type Story = StoryObj<typeof meta>
110
131
  */
111
132
  export const Playground: Story = {
112
133
  parameters: playgroundParameters,
134
+ // Preserve window scrolling here. VRT captures the browser viewport
135
+ // because the canvas includes the spacer for all 2,000 items.
136
+ tags: ["vrt:viewport"],
113
137
  }
114
138
 
115
139
  /**
@@ -225,12 +249,16 @@ export const AllVariants: Story = {
225
249
  {panel.label}
226
250
  </span>
227
251
 
228
- <VirtualizedGrid
229
- {...gridProps}
230
- blockSizeResolver={fixedBlockSize(
231
- panel.blockSize,
232
- )}
233
- />
252
+ <GridExampleWindow
253
+ label={`Bays at ${panel.blockSize}px window height`}
254
+ >
255
+ <VirtualizedGrid
256
+ {...gridProps}
257
+ blockSizeResolver={fixedBlockSize(
258
+ panel.blockSize,
259
+ )}
260
+ />
261
+ </GridExampleWindow>
234
262
  </div>
235
263
  ))}
236
264
  </StorySection>
@@ -265,10 +293,19 @@ export const AllStates: Story = {
265
293
  {panel.label}
266
294
  </span>
267
295
 
268
- <VirtualizedGrid
269
- {...gridProps}
270
- items={panel.items}
271
- />
296
+ {panel.items === MANY_ITEMS ? (
297
+ <GridExampleWindow label="2,000 bays">
298
+ <VirtualizedGrid
299
+ {...gridProps}
300
+ items={panel.items}
301
+ />
302
+ </GridExampleWindow>
303
+ ) : (
304
+ <VirtualizedGrid
305
+ {...gridProps}
306
+ items={panel.items}
307
+ />
308
+ )}
272
309
  </div>
273
310
  ))}
274
311
  </div>
@@ -286,12 +323,6 @@ export const Responsive: Story = {
286
323
  args: {
287
324
  blockSizeResolver: fixedBlockSize(600),
288
325
  minColumnInlineSize: 160,
289
- // Every row mounted. This story is about the column count, not
290
- // the window, and the VRT shot of the whole root is taller than
291
- // the viewport: the grids re-window while it is taken, so which
292
- // rows were drawn depended on the runner's timing (release PR
293
- // #319 drew 13 rows where the baseline drew 5).
294
- overscanRows: 60,
295
326
  },
296
327
  render: (gridProps) => (
297
328
  <div className="flex flex-wrap items-start gap-6">
@@ -311,10 +342,14 @@ export const Responsive: Story = {
311
342
  {panel.label}
312
343
  </span>
313
344
 
314
- <VirtualizedGrid
315
- {...gridProps}
316
- items={MANY_ITEMS.slice(0, 60)}
317
- />
345
+ <GridExampleWindow
346
+ label={`Bays in a ${panel.label}`}
347
+ >
348
+ <VirtualizedGrid
349
+ {...gridProps}
350
+ items={MANY_ITEMS.slice(0, 60)}
351
+ />
352
+ </GridExampleWindow>
318
353
  </div>
319
354
  ))}
320
355
  </div>
@@ -345,12 +380,14 @@ export const Interactive: Story = {
345
380
  selectedValue={choice}
346
381
  />
347
382
 
348
- <VirtualizedGrid
349
- {...gridProps}
350
- columns={
351
- choice === "auto" ? undefined : Number(choice)
352
- }
353
- />
383
+ <GridExampleWindow label="Bays with selectable column count">
384
+ <VirtualizedGrid
385
+ {...gridProps}
386
+ columns={
387
+ choice === "auto" ? undefined : Number(choice)
388
+ }
389
+ />
390
+ </GridExampleWindow>
354
391
  </StorySection>
355
392
  )
356
393
  },
@@ -38,6 +38,7 @@ import * as stories from "./VirtualizedGrid.stories.tsx"
38
38
 
39
39
  const {
40
40
  AllStates,
41
+ AllVariants,
41
42
  Playground,
42
43
  InHiddenTabPanel,
43
44
  InShellScrollRegion,
@@ -357,6 +358,34 @@ test("a screen reader is told the real length", async () => {
357
358
  ).toBe("1")
358
359
  })
359
360
 
361
+ test("each column variant shows a window of rows", async () => {
362
+ const { canvasElement } = await mountStory(AllVariants)
363
+
364
+ await waitFor(async () => {
365
+ const lists = getLists(canvasElement)
366
+ await expect(lists).toHaveLength(3)
367
+
368
+ for (const list of lists) {
369
+ const scrollRegion = list.closest(
370
+ "section[aria-label]",
371
+ )
372
+ await expect(scrollRegion).not.toBeNull()
373
+ await expect(
374
+ scrollRegion?.clientHeight,
375
+ ).toBeGreaterThan(0)
376
+ await expect(scrollRegion?.clientHeight).toBeLessThan(
377
+ 500,
378
+ )
379
+ await expect(
380
+ scrollRegion?.scrollHeight,
381
+ ).toBeGreaterThan(scrollRegion?.clientHeight ?? 0)
382
+ const cellCount = list.querySelectorAll("li").length
383
+ await expect(cellCount).toBeGreaterThan(0)
384
+ await expect(cellCount).toBeLessThan(100)
385
+ }
386
+ })
387
+ })
388
+
360
389
  test("an empty list reserves no space and mounts no rows", async () => {
361
390
  const { canvasElement } = await mountStory(AllStates)
362
391
 
@@ -232,7 +232,7 @@ export const ExternalLinkFooter = (): ReactNode => (
232
232
  export const OverflowingContent = (): ReactNode => (
233
233
  <>
234
234
  <p className="text-content-secondary text-sm">
235
- /mnt/Bunnies/Family/Media/Television/Some-Very-Long-Show-Name/Season-01/Some-Very-Long-Show-Name-S01E01-Pilot-2160p-HDR-DTS-HD-MA.mkv
235
+ /mnt/media/archive/videos/Television/Some-Very-Long-Show-Name/Season-01/Some-Very-Long-Show-Name-S01E01-Pilot-2160p-HDR-DTS-HD-MA.mkv
236
236
  </p>
237
237
 
238
238
  <section
@@ -270,8 +270,8 @@ export const OverflowingContent = (): ReactNode => (
270
270
  <tr>
271
271
  {[
272
272
  "21:04:11",
273
- "/mnt/Bunnies/Kevin/Incoming",
274
- "/mnt/Bunnies/Family/Media/Television",
273
+ "/mnt/media/staging/Incoming",
274
+ "/mnt/media/archive/videos/Television",
275
275
  "48,912,338,112",
276
276
  "612 MB/s",
277
277
  "sha256 ok",