@charcuterie/ui 4.30.0 → 4.31.1

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 (117) hide show
  1. package/README.md +7 -2
  2. package/docs/README.md +573 -0
  3. package/docs/building-an-app.md +231 -0
  4. package/docs/components/Accordion.md +106 -0
  5. package/docs/components/ActionMenu.md +63 -0
  6. package/docs/components/ActionTiles.md +233 -0
  7. package/docs/components/AdaptiveGrid.md +215 -0
  8. package/docs/components/Alert.md +99 -0
  9. package/docs/components/AnchorLink.md +23 -0
  10. package/docs/components/Avatar.md +153 -0
  11. package/docs/components/Badge.md +81 -0
  12. package/docs/components/BadgeButton.md +84 -0
  13. package/docs/components/Board.md +277 -0
  14. package/docs/components/Breadcrumbs.md +87 -0
  15. package/docs/components/Button.md +72 -0
  16. package/docs/components/ButtonLink.md +81 -0
  17. package/docs/components/Card.md +114 -0
  18. package/docs/components/CatalogPicker.md +250 -0
  19. package/docs/components/Chart.md +39 -0
  20. package/docs/components/Checkbox.md +197 -0
  21. package/docs/components/ColorPicker.md +99 -0
  22. package/docs/components/ColorSchemeSwitcher.md +92 -0
  23. package/docs/components/ColorSchemeToggle.md +98 -0
  24. package/docs/components/Combobox.md +175 -0
  25. package/docs/components/CommandPalette.md +120 -0
  26. package/docs/components/ComparisonChart.md +31 -0
  27. package/docs/components/CopyButton.md +112 -0
  28. package/docs/components/DataTable.md +170 -0
  29. package/docs/components/DatePicker.md +225 -0
  30. package/docs/components/Dialog.md +134 -0
  31. package/docs/components/DropRail.md +107 -0
  32. package/docs/components/EmptyState.md +65 -0
  33. package/docs/components/Field.md +215 -0
  34. package/docs/components/FieldGroup.md +45 -0
  35. package/docs/components/FileDropZone.md +98 -0
  36. package/docs/components/GroupedList.md +189 -0
  37. package/docs/components/Header.md +76 -0
  38. package/docs/components/HtmlEditor-html-editor.md +76 -0
  39. package/docs/components/HtmlView-html-editor.md +47 -0
  40. package/docs/components/HtmlView-html-view.md +47 -0
  41. package/docs/components/IconButton.md +52 -0
  42. package/docs/components/LaneTimeline.md +254 -0
  43. package/docs/components/Lightbox.md +101 -0
  44. package/docs/components/Listbox.md +109 -0
  45. package/docs/components/LiveStatusIndicator.md +60 -0
  46. package/docs/components/LogViewer.md +142 -0
  47. package/docs/components/Main.md +247 -0
  48. package/docs/components/MarkdownEditor.md +262 -0
  49. package/docs/components/MarkdownEditorCodeMirror-markdown-editor-codemirror.md +230 -0
  50. package/docs/components/MarkdownLine.md +187 -0
  51. package/docs/components/MarkdownView-markdown-editor-codemirror.md +235 -0
  52. package/docs/components/MediaTile.md +106 -0
  53. package/docs/components/Menu.md +209 -0
  54. package/docs/components/MetricCard.md +38 -0
  55. package/docs/components/Modal.md +89 -0
  56. package/docs/components/Nav.md +167 -0
  57. package/docs/components/NavBar.md +190 -0
  58. package/docs/components/Picker.md +132 -0
  59. package/docs/components/Popover.md +135 -0
  60. package/docs/components/PortraitTiles.md +169 -0
  61. package/docs/components/ProgressBar.md +70 -0
  62. package/docs/components/ProgressCard.md +65 -0
  63. package/docs/components/QueryBuilder.md +132 -0
  64. package/docs/components/RadioGroup.md +165 -0
  65. package/docs/components/Rail.md +79 -0
  66. package/docs/components/RangeSlider.md +144 -0
  67. package/docs/components/ReactRouterAdapter-react-router.md +27 -0
  68. package/docs/components/ReactRouterLink-react-router.md +23 -0
  69. package/docs/components/ReorderList.md +143 -0
  70. package/docs/components/RouterLinkProvider.md +33 -0
  71. package/docs/components/ScheduleBoard.md +41 -0
  72. package/docs/components/ScrollMemoryProvider.md +33 -0
  73. package/docs/components/SearchInput.md +46 -0
  74. package/docs/components/SegmentedControl.md +98 -0
  75. package/docs/components/Select.md +169 -0
  76. package/docs/components/Shell.md +162 -0
  77. package/docs/components/Skeleton.md +48 -0
  78. package/docs/components/Slider.md +128 -0
  79. package/docs/components/SortableTableHeader.md +84 -0
  80. package/docs/components/Spinner.md +50 -0
  81. package/docs/components/Stepper.md +121 -0
  82. package/docs/components/Swatch.md +79 -0
  83. package/docs/components/Switch.md +80 -0
  84. package/docs/components/TableColumns.md +29 -0
  85. package/docs/components/TableViewport.md +42 -0
  86. package/docs/components/Tabs.md +184 -0
  87. package/docs/components/TextLink.md +106 -0
  88. package/docs/components/TimecodeInput.md +222 -0
  89. package/docs/components/Toast.md +108 -0
  90. package/docs/components/ToastRegion.md +35 -0
  91. package/docs/components/Toolbar.md +118 -0
  92. package/docs/components/Tooltip.md +94 -0
  93. package/docs/components/UnstyledLink.md +21 -0
  94. package/docs/components/ValuePairs.md +30 -0
  95. package/docs/components/VirtualizedGrid.md +204 -0
  96. package/docs/components/VisuallyHidden.md +39 -0
  97. package/docs/components/WeekdayIndicator.md +39 -0
  98. package/docs/hooks/useAdaptiveColumns.md +111 -0
  99. package/docs/hooks/useCommandPalette.md +40 -0
  100. package/docs/hooks/useCommandPaletteHotkeys.md +33 -0
  101. package/docs/hooks/useDeploymentUpdate.md +39 -0
  102. package/docs/hooks/useLastPresentValue.md +23 -0
  103. package/docs/hooks/useListMotion.md +65 -0
  104. package/docs/hooks/useNavLayout.md +59 -0
  105. package/docs/hooks/usePresence.md +39 -0
  106. package/docs/hooks/useRouterLink.md +22 -0
  107. package/docs/hooks/useValueChangeMotion.md +28 -0
  108. package/package.json +7 -5
  109. package/skills/charcuterie/SKILL.md +17 -0
  110. package/skills/charcuterie/references/build-a-screen.md +6 -0
  111. package/skills/charcuterie/references/create-a-component.md +6 -0
  112. package/src/AdaptiveGrid/AdaptiveGrid.stories.tsx +1 -1
  113. package/src/Tabs/Tabs.stories.tsx +1 -1
  114. package/src/VirtualizedGrid/VirtualizedGrid.stories.tsx +65 -28
  115. package/src/VirtualizedGrid/VirtualizedGrid.test.tsx +29 -0
  116. package/src/shell.storyHelpers.tsx +3 -3
  117. package/src/sourceRules.test.ts +16 -2
@@ -0,0 +1,204 @@
1
+ # VirtualizedGrid
2
+
3
+ ```ts
4
+ import { VirtualizedGrid } from "@charcuterie/ui"
5
+ ```
6
+
7
+ **`AdaptiveGrid`, with only the rows you can see mounted.** Same column rule, same
8
+ two-box structure, same content cap. The one difference is that a list of 2,000 costs
9
+ about as much as a list of 40.
10
+
11
+ ## When to reach for it
12
+
13
+ Not by default. `AdaptiveGrid` renders everything it is handed, and that is the right
14
+ behaviour: the DOM is searchable with `Ctrl+F`, `Ctrl+End` goes where you expect, and
15
+ nothing has to be measured. Reach for this one when the item count is genuinely
16
+ unbounded — a library listing, an inbox, a backlog that grows.
17
+
18
+ The number that prompted it, measured on QueuePilot's Pending page:
19
+
20
+ | | Every item rendered |
21
+ | --- | --- |
22
+ | Items | 2,162 |
23
+ | DOM nodes | 19,933 |
24
+ | `<img>` elements | 2,162 |
25
+ | `<button>` elements | 4,371 |
26
+ | Time to settle | 7.8 s |
27
+ | Scroll rate | ~43 fps |
28
+
29
+ Nothing about that page was wrong except how much of it existed at once.
30
+
31
+ ## Rows are the unit
32
+
33
+ The virtualizer counts **rows**, not items. An item-level virtualizer would have to place
34
+ every item on both axes; a row-level one gets the inline axis from CSS grid for free and
35
+ only ever answers "how far down".
36
+
37
+ So `itemBlockSize` is a row-height estimate, and unlike `AdaptiveGrid`'s it is not a
38
+ commitment — every mounted row is measured and the estimate corrected. It still wants to
39
+ be close, because it is what the scrollbar is sized from before anything has been
40
+ measured. A bad guess makes the bar jump under the thumb on the first scroll.
41
+
42
+ ## It follows the page's scroll region
43
+
44
+ The grid never creates a scroll box. It follows the nearest ancestor whose vertical
45
+ overflow is `auto` or `scroll`. Inside `Shell`, that is `Main`, so the header and rail stay
46
+ available while the grid scrolls. A standalone grid falls back to the browser window.
47
+
48
+ The cost is that the grid has to know how far down its scroll region it starts. It measures
49
+ that offset in a layout effect and feeds it to the virtualizer as `scrollMargin`. Get that
50
+ wrong and every row is offset by the chrome above it.
51
+
52
+ ## It waits for a box before it measures anything
53
+
54
+ `display: none` gives an element no boxes, and the `hidden` attribute is `display: none`.
55
+ So a grid inside a hidden tab panel, a collapsed disclosure or a closed `<details>` cannot
56
+ be measured at all: its container reads 0px wide and every mounted row reads 0px tall.
57
+
58
+ That is the absence of a measurement, not a measurement of zero, and the difference is not
59
+ academic. Revealing the panel corrects every one of those numbers at once, and a
60
+ virtualizer is entitled to read a correction as a **resize** — the one event it may move
61
+ the scroll position for. It then compensates for growth that never happened and scrolls the
62
+ page. Docket's Triage bar is where this was found: switching tabs moved `Main` by up to
63
+ 1,190px and took the tab bar off the top of the screen.
64
+
65
+ So the grid mounts nothing until its container has a box. Put a grid in a tab panel and the
66
+ panel holds no rows while it is put away; the rows arrive with the box and are measured once,
67
+ correctly. The cost is that a revealed grid re-measures from its estimate rather than
68
+ resuming a cache, which is exactly what a routed tab already does.
69
+
70
+ ## The column rule is inherited, not reimplemented
71
+
72
+ Columns come from `useAdaptiveColumns` — the identical hook `AdaptiveGrid` calls. The
73
+ consequence that reads backwards holds here too: a **taller** window takes **fewer**
74
+ columns, because height is what a column is bought with.
75
+
76
+ This is deliberate. A second column heuristic that windowed lists followed and flow lists
77
+ did not would be a fleet where the same content lays out two ways depending on how many
78
+ of it there are.
79
+
80
+ ## The states that are easy to miss
81
+
82
+ An empty list draws a zero-height box and no rows — a windowed grid must not reserve
83
+ space for a list that is not there, and it is the state a filter lands on. One item is
84
+ one column, the same answer `AdaptiveGrid` gives.
85
+
86
+ ## It is still read from the container
87
+
88
+ The browser never moves and the column count still falls. Inline size comes off a
89
+ `ResizeObserver` on the container, so a grid beside a rail gets the room it actually has
90
+ rather than the room the window claims.
91
+
92
+ ## Accessibility
93
+
94
+ A mounted window is a lie about length, so the true length is stated rather than implied:
95
+
96
+ - `role="list"` on the grid, with the `label` prop as its accessible name.
97
+ - `aria-setsize` on every cell, carrying the **full** item count.
98
+ - `aria-posinset` naming each cell's real position in that full list.
99
+ - `role="presentation"` on the row wrappers — they are a positioning device and have no
100
+ business appearing in the structure.
101
+
102
+ Without `aria-setsize` a screen reader announces "list, 40 items" on a list of 2,000.
103
+
104
+ Two things windowing genuinely costs, and neither has a fix at this layer: the browser's
105
+ `Ctrl+F` only searches what is mounted, and so does "select all". A page that needs
106
+ either owes its users a search field of its own.
107
+
108
+ ## `getItemKey`
109
+
110
+ Pass one. Without it the key is the array index, which is wrong the moment the list is
111
+ filtered or an item is removed from the middle — React reuses the mounted subtree and the
112
+ wrong tile inherits the wrong open menu. That is not hypothetical; it is what a
113
+ dismiss-an-item list does on every interaction.
114
+
115
+ ```tsx
116
+ import { Card } from "@charcuterie/ui"
117
+
118
+ <VirtualizedGrid itemBlockSize={128} label="Projects"
119
+ items={[{ id: "plan", name: "Planning" }, { id: "build", name: "Implementation" }]}
120
+ getItemKey={(project) => project.id}
121
+ renderItem={(project) => <Card heading={project.name} />} />
122
+ ```
123
+
124
+ ## Published TypeScript API
125
+
126
+ ```ts
127
+ const VirtualizedGrid: <Item>({ blockSizeResolver, chromeBlockSize, className, columns, gap, getItemKey, itemBlockSize, items, label, layout: gridLayout, maxColumns, minColumnInlineSize, overscanRows, renderItem, storageKey, }: VirtualizedGridProps<Item>) => ReactNode
128
+
129
+ type VirtualizedGridProps<Item> = {
130
+ /**
131
+ * Where the available block size is read from. Defaults to the
132
+ * viewport, which is the only thing that can answer "will this
133
+ * scroll".
134
+ */
135
+ blockSizeResolver?: BlockSizeResolver;
136
+ /**
137
+ * Everything down the page that is not this grid, in CSS px —
138
+ * header, rails, filter rows. Subtracted before asking how many
139
+ * items stack.
140
+ */
141
+ chromeBlockSize?: number;
142
+ className?: string;
143
+ /**
144
+ * Draw this many columns instead of the automatic answer — the
145
+ * manual override, for a page that hoisted `useAdaptiveColumns`
146
+ * itself.
147
+ */
148
+ columns?: number;
149
+ /** The gap between tracks and rows, in CSS px. */
150
+ gap?: number;
151
+ /**
152
+ * A stable identity per item. Without one the key is the index,
153
+ * which is wrong the moment the list is filtered or an item
154
+ * leaves the middle — React reuses the mounted subtree and the
155
+ * wrong tile inherits the wrong open menu.
156
+ */
157
+ getItemKey?: (item: Item, index: number) => string | number;
158
+ /**
159
+ * One row's block size in CSS px, as a starting guess.
160
+ *
161
+ * Unlike `AdaptiveGrid`'s, this is an *estimate* and not a
162
+ * commitment: every mounted row is measured and the estimate
163
+ * corrected. It still wants to be close, because it is what the
164
+ * scrollbar is sized from before anything has been measured — a
165
+ * bad guess makes the bar jump under the thumb on first scroll.
166
+ */
167
+ itemBlockSize: number;
168
+ /** Every item, mounted or not. */
169
+ items: readonly Item[];
170
+ /**
171
+ * An accessible name for the list. Worth giving: a windowed list
172
+ * is one whose length a reader cannot count for itself.
173
+ */
174
+ label?: string;
175
+ /** Opt in to width-first media layout. */
176
+ layout?: GridLayout;
177
+ /** The most columns the automatic answer will take. */
178
+ maxColumns?: number;
179
+ /** The narrowest a column may be, in CSS px. */
180
+ minColumnInlineSize?: number;
181
+ /**
182
+ * How many rows to mount above and below the viewport.
183
+ *
184
+ * Four rather than `@tanstack/react-virtual`'s default of one:
185
+ * these are media tiles whose images load over the network, and
186
+ * a row that mounts at the moment it becomes visible shows a
187
+ * blank box while the image arrives. Overscan buys the load a
188
+ * head start.
189
+ */
190
+ overscanRows?: number;
191
+ /** Draw one item. */
192
+ renderItem: (item: Item, index: number) => ReactNode;
193
+ /**
194
+ * The `localStorage` key a manual column choice is remembered
195
+ * under. Namespace it to the app; omit it and nothing is
196
+ * written.
197
+ */
198
+ storageKey?: string;
199
+ };
200
+
201
+ Item
202
+ ```
203
+
204
+ [Full declarations](../../dist/VirtualizedGrid/VirtualizedGrid.d.ts)
@@ -0,0 +1,39 @@
1
+ # VisuallyHidden
2
+
3
+ ```ts
4
+ import { VisuallyHidden } from "@charcuterie/ui"
5
+ ```
6
+
7
+ Text for assistive technology and for nobody else. A Layer-0 primitive, and the one every
8
+ other component in M3 leans on: it is how a `Spinner` says "Loading…" without printing it,
9
+ how a `ProgressBar`'s label stays discoverable when the design does not show it, and how an
10
+ `IconButton`'s glyph gets a name.
11
+
12
+ ## Nothing to own
13
+
14
+ `sr-only` is Tailwind's own — the clip-rect technique, unchanged since it was
15
+ `.visuallyhidden` in HTML5 Boilerplate. Never `display: none` and never
16
+ `visibility: hidden`: both remove the node from the accessibility tree, which is the exact
17
+ opposite of the requirement. The `Interactive` story asserts both halves — present to a
18
+ query, one pixel to the layout.
19
+
20
+ This component's story set is deliberately short. It has no variants, no states, and no
21
+ container-query behaviour; the mandated five would be four empty boards.
22
+
23
+ ```tsx
24
+ import { Button } from "@charcuterie/ui"
25
+
26
+ <Button>Retry<VisuallyHidden> upload</VisuallyHidden></Button>
27
+ ```
28
+
29
+ ## Published TypeScript API
30
+
31
+ ```ts
32
+ const VisuallyHidden: ({ children, className, ...spanProps }: VisuallyHiddenProps) => ReactNode
33
+
34
+ type VisuallyHiddenProps = ComponentPropsWithRef<"span"> & {
35
+ children: ReactNode;
36
+ };
37
+ ```
38
+
39
+ [Full declarations](../../dist/VisuallyHidden/VisuallyHidden.d.ts)
@@ -0,0 +1,39 @@
1
+ # WeekdayIndicator
2
+
3
+ ```ts
4
+ import { WeekdayIndicator } from "@charcuterie/ui"
5
+ ```
6
+
7
+ Seven labeled circles in Monday-first order. Pass zero-based weekday offsets (Monday 0, Sunday 6). The accessible name spells out selected days. The app decides whether the pattern is a recurrence rule or only the weekdays observed in the displayed period, and supplies the label accordingly. This is a display, not a weekday picker.
8
+
9
+ ## Layouts and states
10
+
11
+ ## Narrow containers
12
+
13
+ ## Keyboard interaction
14
+
15
+ Tab reaches each action. Enter or Space activates it. The display itself adds no tab stops.
16
+
17
+ ## Example from the stories
18
+
19
+ See the full [story example](../../src/WeekdayIndicator/WeekdayIndicator.stories.tsx).
20
+
21
+ ```tsx
22
+ <WeekdayIndicator days={[]} />
23
+ ```
24
+
25
+ ## Published TypeScript API
26
+
27
+ ```ts
28
+ const WeekdayIndicator: ({ days, categorical, className, label, }: WeekdayIndicatorProps) => ReactNode
29
+
30
+ type WeekdayIndicatorProps = {
31
+ /** Monday is 0, Sunday is 6. These are observed weekdays, not an RRULE. */
32
+ days: readonly number[];
33
+ categorical?: CategoricalIndex;
34
+ className?: string;
35
+ label?: string;
36
+ };
37
+ ```
38
+
39
+ [Full declarations](../../dist/WeekdayIndicator/WeekdayIndicator.d.ts)
@@ -0,0 +1,111 @@
1
+ # useAdaptiveColumns
2
+
3
+ ```ts
4
+ import { useAdaptiveColumns } from "@charcuterie/ui"
5
+ ```
6
+
7
+ Use this to calculate the library's column count and content width for a custom grid. Use `AdaptiveGrid` for a complete layout. Mount the returned ref on the measured container and preserve logical item order as the columns reflow.
8
+
9
+ ```tsx
10
+ const { containerRef, columns } = useAdaptiveColumns({ itemCount: 3, itemBlockSize: 180 })
11
+ const grid = <div ref={containerRef} style={{ gridTemplateColumns: `repeat(${columns}, 1fr)` }} />
12
+ ```
13
+
14
+ ## Published TypeScript API
15
+
16
+ ```ts
17
+ const useAdaptiveColumns: <ContainerElement extends HTMLElement = HTMLDivElement>({ blockSizeResolver, chromeBlockSize, columnInlineSize, gutterInlineSize, gap, itemBlockSize, itemCount, layout, maxAutoColumns, maxManualColumns, minColumnInlineSize, persistence, singleInlineSize, storageKey, }: {
18
+ /** @see BlockSizeResolver. Defaults to the viewport. */
19
+ blockSizeResolver?: BlockSizeResolver;
20
+ /** Everything down the page that is not this grid, in CSS px. */
21
+ chromeBlockSize?: number;
22
+ /** Override `contentInlineSize.column`. */
23
+ columnInlineSize?: string;
24
+ /** Override `contentInlineSize.gutter`. */
25
+ gutterInlineSize?: string;
26
+ /** Space between tracks for the fill layout. */
27
+ gap?: number;
28
+ /** One item's block size in CSS px. Measure it; err high. */
29
+ itemBlockSize: number;
30
+ /** How many items the grid is being asked to fit. */
31
+ itemCount: number;
32
+ /** Opt in to width-first media layout. */
33
+ layout?: GridLayout;
34
+ /** The most columns the automatic answer will take. */
35
+ maxAutoColumns?: number;
36
+ /** The most a person may ask for. One above the auto cap. */
37
+ maxManualColumns?: number;
38
+ /** The narrowest a column may be, in CSS px. */
39
+ minColumnInlineSize?: number;
40
+ /**
41
+ * Where a manual choice is remembered. Defaults to
42
+ * `localStorage` when `storageKey` is given, and to nothing at
43
+ * all when it is not — a grid with no key keeps a choice for the
44
+ * session and writes nowhere.
45
+ */
46
+ persistence?: ColumnPersistence;
47
+ /** Override `contentInlineSize.single`. */
48
+ singleInlineSize?: string;
49
+ /**
50
+ * The `localStorage` key a manual choice is remembered under.
51
+ *
52
+ * **Caller-supplied and namespaced by the app** — one origin
53
+ * often serves several things that would each like a `columns`
54
+ * key, and a shared library has no business picking that name.
55
+ */
56
+ storageKey?: string;
57
+ }) => {
58
+ /** What the automatic rule wants right now. */
59
+ autoColumns: number;
60
+ /** What to draw. */
61
+ columns: number;
62
+ /**
63
+ * The cap for the content around the grid, as a CSS length. Hand
64
+ * it to a shell's main region.
65
+ */
66
+ contentMaxInlineSize: string;
67
+ /**
68
+ * Attach to the element whose inline size the grid may spend.
69
+ *
70
+ * ⚠️ Never the element `contentMaxInlineSize` is applied to.
71
+ */
72
+ containerRef: RefObject<ContainerElement | null>;
73
+ /**
74
+ * Has the container been given a box yet?
75
+ *
76
+ * False in two situations that look identical from here and are
77
+ * both "no measurement has happened": the frame before
78
+ * `ResizeObserver` delivers its first record, and any time the
79
+ * container sits inside a `display: none` ancestor — which is
80
+ * what the `hidden` attribute is, and what a tab panel, a
81
+ * collapsed disclosure and a closed `<details>` all use.
82
+ *
83
+ * The distinction matters because a zero inline size is not a
84
+ * measurement of zero. It is the absence of one, and a consumer
85
+ * that treats it as a number lays out for a 0px container and
86
+ * then reads the correction as a change.
87
+ */
88
+ isLaidOut: boolean;
89
+ /** What was picked, `"auto"` included. */
90
+ choice: ColumnChoice;
91
+ setChoice: (choice: ColumnChoice) => void;
92
+ }
93
+
94
+ type BlockSizeResolver = {
95
+ get: () => number;
96
+ subscribe: (listener: () => void) => () => void;
97
+ };
98
+
99
+ type GridLayout = "height-first" | "fill";
100
+
101
+ type ColumnPersistence = {
102
+ read: () => string | null;
103
+ write: (value: string) => void;
104
+ };
105
+
106
+ ContainerElement extends HTMLElement = HTMLDivElement
107
+
108
+ type ColumnChoice = "auto" | number;
109
+ ```
110
+
111
+ [Full declarations](../../dist/AdaptiveGrid/useAdaptiveColumns.d.ts)
@@ -0,0 +1,40 @@
1
+ # useCommandPalette
2
+
3
+ ```ts
4
+ import { useCommandPalette } from "@charcuterie/ui"
5
+ ```
6
+
7
+ Use this to wire the default open state, initial query, and keyboard shortcuts for `CommandPalette`. Use `useCommandPaletteHotkeys` when the app already owns that state. Keep a named trigger so the palette can be opened without knowing a shortcut.
8
+
9
+ ```tsx
10
+ import { Button } from "@charcuterie/ui"
11
+
12
+ const palette = useCommandPalette()
13
+ return <Button onClick={() => palette.open()}>Search commands</Button>
14
+ ```
15
+
16
+ ## Published TypeScript API
17
+
18
+ ```ts
19
+ const useCommandPalette: ({ hasHotkeys, isOpenedByTyping, }?: UseCommandPaletteOptions) => UseCommandPaletteResult
20
+
21
+ type UseCommandPaletteOptions = Pick<CommandPaletteHotkeysOptions, "isOpenedByTyping"> & {
22
+ /** Register the global keys (`useCommandPaletteHotkeys`). Default `true`. */
23
+ hasHotkeys?: boolean;
24
+ };
25
+
26
+ type UseCommandPaletteResult = {
27
+ close: () => void;
28
+ isVisible: boolean;
29
+ /** Open it, optionally with text already in the field. */
30
+ open: (initialQuery?: string) => void;
31
+ /** Spread onto `CommandPalette`. */
32
+ paletteProps: {
33
+ defaultQuery: string;
34
+ isVisible: boolean;
35
+ onClose: () => void;
36
+ };
37
+ };
38
+ ```
39
+
40
+ [Full declarations](../../dist/CommandPalette/useCommandPalette.d.ts)
@@ -0,0 +1,33 @@
1
+ # useCommandPaletteHotkeys
2
+
3
+ ```ts
4
+ import { useCommandPaletteHotkeys } from "@charcuterie/ui"
5
+ ```
6
+
7
+ Use this to connect palette shortcuts to app-owned state. Use `useCommandPalette` when you also want the library to manage opening and closing. Keep a named trigger and disable the shortcut listener while the palette is open.
8
+
9
+ ```tsx
10
+ function useSearchShortcut(isVisible: boolean, openPalette: (query?: string) => void) {
11
+ useCommandPaletteHotkeys({ isEnabled: !isVisible, onOpen: openPalette })
12
+ }
13
+ ```
14
+
15
+ ## Published TypeScript API
16
+
17
+ ```ts
18
+ const useCommandPaletteHotkeys: ({ isEnabled, isOpenedByTyping, onOpen, }: CommandPaletteHotkeysOptions) => void
19
+
20
+ type CommandPaletteHotkeysOptions = {
21
+ /** Off while the palette is open, or on a page that should not take the keys. Default `true`. */
22
+ isEnabled?: boolean;
23
+ /**
24
+ * A printable key typed outside an editable field opens the palette
25
+ * with that character as the query. Default `true`.
26
+ */
27
+ isOpenedByTyping?: boolean;
28
+ /** Receives the text the palette should open with: `""`, or the character typed. */
29
+ onOpen: (initialQuery: string) => void;
30
+ };
31
+ ```
32
+
33
+ [Full declarations](../../dist/CommandPalette/useCommandPaletteHotkeys.d.ts)
@@ -0,0 +1,39 @@
1
+ # useDeploymentUpdate
2
+
3
+ ```ts
4
+ import { useDeploymentUpdate } from "@charcuterie/ui"
5
+ ```
6
+
7
+ Use this when a deployed web app needs to signal that a new build is available. Use a normal status control for other network activity. Offer a named reload action and keep the current page available so readers can finish their work.
8
+
9
+ ```tsx
10
+ import { Button } from "@charcuterie/ui"
11
+
12
+ const { isUpdateAvailable, reload } = useDeploymentUpdate()
13
+ return isUpdateAvailable ? <Button onClick={reload}>Reload to update</Button> : null
14
+ ```
15
+
16
+ ## Published TypeScript API
17
+
18
+ ```ts
19
+ const useDeploymentUpdate: ({ deploymentEventsPath, deploymentPath, isEventSourceEnabled, pollIntervalMs, }?: UseDeploymentUpdateOptions) => DeploymentUpdate
20
+
21
+ type UseDeploymentUpdateOptions = {
22
+ deploymentPath?: string;
23
+ deploymentEventsPath?: string;
24
+ /** `0` disables polling. SSE is normally enough. */
25
+ pollIntervalMs?: number;
26
+ /** Disable when an app calls `checkForUpdate` after its own SSE reconnects. */
27
+ isEventSourceEnabled?: boolean;
28
+ };
29
+
30
+ type DeploymentUpdate = {
31
+ isUpdateAvailable: boolean;
32
+ /** Revalidate the marker now. Safe to call after an app SSE reconnects. */
33
+ checkForUpdate: () => Promise<boolean>;
34
+ /** Reload after the user has saved or finished their current work. */
35
+ reload: () => void;
36
+ };
37
+ ```
38
+
39
+ [Full declarations](../../dist/DeploymentUpdate/useDeploymentUpdate.d.ts)
@@ -0,0 +1,23 @@
1
+ # useLastPresentValue
2
+
3
+ ```ts
4
+ import { useLastPresentValue } from "@charcuterie/ui"
5
+ ```
6
+
7
+ Use this to keep the last selected content available while an overlay closes. Use `usePresence` to manage when an element can leave the DOM. Let the overlay hide its exiting content from assistive technology after dismissal.
8
+
9
+ ```tsx
10
+ function useDialogItem<Item>(selectedItem: Item | null) {
11
+ return useLastPresentValue(selectedItem)
12
+ }
13
+ ```
14
+
15
+ ## Published TypeScript API
16
+
17
+ ```ts
18
+ const useLastPresentValue: <Value>(value: Value | null | undefined) => Value | undefined
19
+
20
+ Value
21
+ ```
22
+
23
+ [Full declarations](../../dist/Motion/useLastPresentValue.d.ts)
@@ -0,0 +1,65 @@
1
+ # useListMotion
2
+
3
+ ```ts
4
+ import { useListMotion } from "@charcuterie/ui"
5
+ ```
6
+
7
+ Use this to animate items entering, leaving, or moving in an app-owned list. Use `usePresence` for one element. Spread the motion props on a wrapper that the hook owns and keep the stable key.
8
+
9
+ ```tsx
10
+ function ProjectList({ projects }: { projects: readonly { id: string; label: string }[] }) {
11
+ const { entries } = useListMotion({ items: projects, getKey: (project) => project.id })
12
+ return <ul>{entries.map(({ key, item, motionProps }) =>
13
+ <li key={key} {...motionProps}>{item.label}</li>)}</ul>
14
+ }
15
+ ```
16
+
17
+ ## Published TypeScript API
18
+
19
+ ```ts
20
+ const useListMotion: <Item>({ getKey, items, layoutKey, onExitEnd, }: UseListMotionOptions<Item>) => {
21
+ entries: ListMotionEntry<Item>[];
22
+ }
23
+
24
+ type UseListMotionOptions<Item> = {
25
+ getKey: (item: Item) => string;
26
+ items: readonly Item[];
27
+ /**
28
+ * Anything else that changes the items' sizes, so the items after
29
+ * a changed one slide to their new places too. Without it, only a
30
+ * change in the order of keys slides anything.
31
+ *
32
+ * `GroupedList` passes each group's row keys: a row added to one
33
+ * group makes the groups below it taller or shorter, and they slide
34
+ * rather than jump.
35
+ */
36
+ layoutKey?: string;
37
+ /**
38
+ * Called when a leaving item has finished leaving and is about to be
39
+ * removed, which closes the gap it held. A parent whose own layout
40
+ * that gap changes sets state here: React renders the parent and
41
+ * this list in one batch, so the parent measures before the gap
42
+ * closes and can slide what it moves. `GroupedList` does, so the
43
+ * groups below a group that lost a row slide up.
44
+ */
45
+ onExitEnd?: () => void;
46
+ };
47
+
48
+ Item
49
+
50
+ type ListMotionEntry<Item> = {
51
+ /**
52
+ * The item's index in `items`. A leaving item keeps the index it had
53
+ * when it was removed, so a row that shows its position does not
54
+ * read "0" while it leaves.
55
+ */
56
+ index: number;
57
+ /** Removed, and leaving. Already `inert` through `motionProps`. */
58
+ isExiting: boolean;
59
+ item: Item;
60
+ key: string;
61
+ motionProps: ListMotionProps;
62
+ };
63
+ ```
64
+
65
+ [Full declarations](../../dist/Motion/useListMotion.d.ts)
@@ -0,0 +1,59 @@
1
+ # useNavLayout
2
+
3
+ ```ts
4
+ import { useNavLayout } from "@charcuterie/ui"
5
+ ```
6
+
7
+ Use this to select a rail, compact rail, or menu layout for `Nav` and persist the user's preference. Use a fixed bar layout when it already fits your navigation. Give compact rail destinations icons and keep their accessible labels.
8
+
9
+ ```ts
10
+ const nav = useNavLayout({ storageKey: "app-navigation" })
11
+ // Render Nav with nav.layout, and call nav.toggle from a named control.
12
+ ```
13
+
14
+ ## Published TypeScript API
15
+
16
+ ```ts
17
+ const useNavLayout: ({ iconsBelow, menuBelow, storageKey, }?: UseNavLayoutOptions) => NavLayoutState
18
+
19
+ type UseNavLayoutOptions = {
20
+ /**
21
+ * Below this width the rail drops its labels. Default `64rem`,
22
+ * which is `screen.lg`.
23
+ */
24
+ iconsBelow?: string;
25
+ /**
26
+ * Below this width there is no rail at all. Default `48rem`, which
27
+ * is `screen.md` — and the same step `Rail` itself collapses at,
28
+ * so the two cannot disagree.
29
+ */
30
+ menuBelow?: string;
31
+ /**
32
+ * Where the manual choice is remembered. Omit and the override
33
+ * lasts until the tab is closed.
34
+ *
35
+ * Name it for the app (`"queuepilot-nav"`), not for this library:
36
+ * two apps on the same origin share `localStorage`, and this
37
+ * fleet's dev servers all sit on `localhost`.
38
+ */
39
+ storageKey?: string;
40
+ };
41
+
42
+ type NavLayoutState = {
43
+ /** `true` in `railIcons`. The rail's own collapse control reads it. */
44
+ isCollapsed: boolean;
45
+ /** What to pass to `Nav`'s `layout`. */
46
+ layout: ResolvedNavLayout;
47
+ mode: NavLayoutMode;
48
+ setMode: (mode: NavLayoutMode) => void;
49
+ /**
50
+ * Expanded ⇄ collapsed. From `auto` it goes to whichever of the two
51
+ * is **not** on screen now, so the first press always visibly does
52
+ * something — which "toggle" has to mean or the control reads as
53
+ * broken.
54
+ */
55
+ toggle: () => void;
56
+ };
57
+ ```
58
+
59
+ [Full declarations](../../dist/Nav/useNavLayout.d.ts)