@slashsuite/ui-react 0.0.0-stage → 0.12.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 (304) hide show
  1. package/LICENSE +21 -0
  2. package/MIGRATING.md +540 -0
  3. package/README.md +549 -2
  4. package/dist/AppShell.d.ts +127 -0
  5. package/dist/AppShell.js +119 -0
  6. package/dist/AppShellMenu.d.ts +26 -0
  7. package/dist/AppShellMenu.js +66 -0
  8. package/dist/Avatar.d.ts +75 -0
  9. package/dist/Avatar.js +95 -0
  10. package/dist/AvatarStack.d.ts +31 -0
  11. package/dist/AvatarStack.js +34 -0
  12. package/dist/Badge.d.ts +15 -0
  13. package/dist/Badge.js +15 -0
  14. package/dist/BottomSheet.d.ts +36 -0
  15. package/dist/BottomSheet.js +142 -0
  16. package/dist/Breadcrumbs.d.ts +27 -0
  17. package/dist/Breadcrumbs.js +29 -0
  18. package/dist/BulletList.d.ts +18 -0
  19. package/dist/BulletList.js +18 -0
  20. package/dist/Button.d.ts +121 -0
  21. package/dist/Button.js +182 -0
  22. package/dist/ButtonGroup.d.ts +15 -0
  23. package/dist/ButtonGroup.js +10 -0
  24. package/dist/Callout.d.ts +43 -0
  25. package/dist/Callout.js +45 -0
  26. package/dist/Card.d.ts +148 -0
  27. package/dist/Card.js +171 -0
  28. package/dist/CardBadge.d.ts +7 -0
  29. package/dist/CardBadge.js +12 -0
  30. package/dist/CardBody.d.ts +28 -0
  31. package/dist/CardBody.js +30 -0
  32. package/dist/CardGrid.d.ts +53 -0
  33. package/dist/CardGrid.js +52 -0
  34. package/dist/CardParts.d.ts +40 -0
  35. package/dist/CardParts.js +41 -0
  36. package/dist/ChatComposer.d.ts +35 -0
  37. package/dist/ChatComposer.js +50 -0
  38. package/dist/ChatMessage.d.ts +26 -0
  39. package/dist/ChatMessage.js +21 -0
  40. package/dist/ChatThread.d.ts +25 -0
  41. package/dist/ChatThread.js +60 -0
  42. package/dist/Checkbox.d.ts +42 -0
  43. package/dist/Checkbox.js +63 -0
  44. package/dist/Chevron.d.ts +5 -0
  45. package/dist/Chevron.js +6 -0
  46. package/dist/Cluster.d.ts +70 -0
  47. package/dist/Cluster.js +47 -0
  48. package/dist/Code.d.ts +6 -0
  49. package/dist/Code.js +5 -0
  50. package/dist/CodeBlock.d.ts +46 -0
  51. package/dist/CodeBlock.js +21 -0
  52. package/dist/CodeBody.d.ts +20 -0
  53. package/dist/CodeBody.js +38 -0
  54. package/dist/CodeExample.d.ts +25 -0
  55. package/dist/CodeExample.js +17 -0
  56. package/dist/CodeText.d.ts +11 -0
  57. package/dist/CodeText.js +64 -0
  58. package/dist/ColourSchemeToggle.d.ts +36 -0
  59. package/dist/ColourSchemeToggle.js +64 -0
  60. package/dist/Container.d.ts +22 -0
  61. package/dist/Container.js +26 -0
  62. package/dist/CopyButton.d.ts +17 -0
  63. package/dist/CopyButton.js +39 -0
  64. package/dist/CopyLine.d.ts +9 -0
  65. package/dist/CopyLine.js +7 -0
  66. package/dist/DateCalendar.d.ts +23 -0
  67. package/dist/DateCalendar.js +89 -0
  68. package/dist/DateField.d.ts +124 -0
  69. package/dist/DateField.js +111 -0
  70. package/dist/DateFieldCalendar.d.ts +24 -0
  71. package/dist/DateFieldCalendar.js +50 -0
  72. package/dist/DateRangePicker.d.ts +47 -0
  73. package/dist/DateRangePicker.js +44 -0
  74. package/dist/Dialog.d.ts +56 -0
  75. package/dist/Dialog.js +94 -0
  76. package/dist/Disclosure.d.ts +29 -0
  77. package/dist/Disclosure.js +23 -0
  78. package/dist/Divider.d.ts +4 -0
  79. package/dist/Divider.js +5 -0
  80. package/dist/DocsLayout.d.ts +69 -0
  81. package/dist/DocsLayout.js +64 -0
  82. package/dist/Drawer.d.ts +30 -0
  83. package/dist/Drawer.js +24 -0
  84. package/dist/EmptyState.d.ts +47 -0
  85. package/dist/EmptyState.js +34 -0
  86. package/dist/Field.d.ts +44 -0
  87. package/dist/Field.js +51 -0
  88. package/dist/FieldDialog.d.ts +26 -0
  89. package/dist/FieldDialog.js +31 -0
  90. package/dist/Fieldset.d.ts +21 -0
  91. package/dist/Fieldset.js +22 -0
  92. package/dist/FileDrop.d.ts +17 -0
  93. package/dist/FileDrop.js +14 -0
  94. package/dist/FormRow.d.ts +46 -0
  95. package/dist/FormRow.js +39 -0
  96. package/dist/Hero.d.ts +23 -0
  97. package/dist/Hero.js +28 -0
  98. package/dist/Icon.d.ts +40 -0
  99. package/dist/Icon.js +30 -0
  100. package/dist/IconButton.d.ts +72 -0
  101. package/dist/IconButton.js +65 -0
  102. package/dist/Image.d.ts +58 -0
  103. package/dist/Image.js +69 -0
  104. package/dist/InlineEdit.d.ts +22 -0
  105. package/dist/InlineEdit.js +60 -0
  106. package/dist/Input.d.ts +40 -0
  107. package/dist/Input.js +42 -0
  108. package/dist/InputShell.d.ts +24 -0
  109. package/dist/InputShell.js +40 -0
  110. package/dist/Kbd.d.ts +6 -0
  111. package/dist/Kbd.js +5 -0
  112. package/dist/KeyValueList.d.ts +34 -0
  113. package/dist/KeyValueList.js +35 -0
  114. package/dist/Lightbox.d.ts +45 -0
  115. package/dist/Lightbox.js +46 -0
  116. package/dist/ListRow.d.ts +26 -0
  117. package/dist/ListRow.js +151 -0
  118. package/dist/Markdown.d.ts +11 -0
  119. package/dist/Markdown.js +49 -0
  120. package/dist/MediaTile.d.ts +66 -0
  121. package/dist/MediaTile.js +50 -0
  122. package/dist/Menu.d.ts +64 -0
  123. package/dist/Menu.js +86 -0
  124. package/dist/MetaList.d.ts +23 -0
  125. package/dist/MetaList.js +20 -0
  126. package/dist/Morph.d.ts +41 -0
  127. package/dist/Morph.js +107 -0
  128. package/dist/NavigationProgress.d.ts +20 -0
  129. package/dist/NavigationProgress.js +26 -0
  130. package/dist/OutlineRegion.d.ts +60 -0
  131. package/dist/OutlineRegion.js +51 -0
  132. package/dist/PageFade.d.ts +30 -0
  133. package/dist/PageFade.js +46 -0
  134. package/dist/PageHeader.d.ts +26 -0
  135. package/dist/PageHeader.js +18 -0
  136. package/dist/PageLayouts.d.ts +100 -0
  137. package/dist/PageLayouts.js +78 -0
  138. package/dist/Pagination.d.ts +38 -0
  139. package/dist/Pagination.js +65 -0
  140. package/dist/Pill.d.ts +79 -0
  141. package/dist/Pill.js +121 -0
  142. package/dist/ProgressBar.d.ts +47 -0
  143. package/dist/ProgressBar.js +47 -0
  144. package/dist/RadioGroup.d.ts +55 -0
  145. package/dist/RadioGroup.js +53 -0
  146. package/dist/ScrollStrip.d.ts +21 -0
  147. package/dist/ScrollStrip.js +12 -0
  148. package/dist/SearchInput.d.ts +9 -0
  149. package/dist/SearchInput.js +55 -0
  150. package/dist/Section.d.ts +93 -0
  151. package/dist/Section.js +55 -0
  152. package/dist/SegmentedControl.d.ts +47 -0
  153. package/dist/SegmentedControl.js +78 -0
  154. package/dist/Select.d.ts +28 -0
  155. package/dist/Select.js +19 -0
  156. package/dist/Show.d.ts +33 -0
  157. package/dist/Show.js +27 -0
  158. package/dist/SideColumn.d.ts +50 -0
  159. package/dist/SideColumn.js +45 -0
  160. package/dist/SidebarLayout.d.ts +32 -0
  161. package/dist/SidebarLayout.js +77 -0
  162. package/dist/SiteFooter.d.ts +31 -0
  163. package/dist/SiteFooter.js +24 -0
  164. package/dist/SiteSearch.d.ts +40 -0
  165. package/dist/SiteSearch.js +150 -0
  166. package/dist/SortableList.d.ts +86 -0
  167. package/dist/SortableList.js +191 -0
  168. package/dist/SplitBar.d.ts +29 -0
  169. package/dist/SplitBar.js +22 -0
  170. package/dist/Stack.d.ts +114 -0
  171. package/dist/Stack.js +76 -0
  172. package/dist/StackedBar.d.ts +64 -0
  173. package/dist/StackedBar.js +58 -0
  174. package/dist/StatTile.d.ts +33 -0
  175. package/dist/StatTile.js +44 -0
  176. package/dist/StatusPages.d.ts +49 -0
  177. package/dist/StatusPages.js +63 -0
  178. package/dist/Steps.d.ts +29 -0
  179. package/dist/Steps.js +43 -0
  180. package/dist/StickyBar.d.ts +12 -0
  181. package/dist/StickyBar.js +10 -0
  182. package/dist/Switch.d.ts +56 -0
  183. package/dist/Switch.js +91 -0
  184. package/dist/Table.d.ts +92 -0
  185. package/dist/Table.js +92 -0
  186. package/dist/TableCells.d.ts +97 -0
  187. package/dist/TableCells.js +104 -0
  188. package/dist/TableEditCell.d.ts +31 -0
  189. package/dist/TableEditCell.js +17 -0
  190. package/dist/TableExpandCell.d.ts +25 -0
  191. package/dist/TableExpandCell.js +15 -0
  192. package/dist/Tabs.d.ts +38 -0
  193. package/dist/Tabs.js +46 -0
  194. package/dist/TextLink.d.ts +51 -0
  195. package/dist/TextLink.js +38 -0
  196. package/dist/Textarea.d.ts +11 -0
  197. package/dist/Textarea.js +11 -0
  198. package/dist/Timeline.d.ts +31 -0
  199. package/dist/Timeline.js +38 -0
  200. package/dist/ToastRegion.d.ts +44 -0
  201. package/dist/ToastRegion.js +37 -0
  202. package/dist/Tooltip.d.ts +46 -0
  203. package/dist/Tooltip.js +181 -0
  204. package/dist/TrendChart.d.ts +36 -0
  205. package/dist/TrendChart.js +58 -0
  206. package/dist/Video.d.ts +13 -0
  207. package/dist/Video.js +9 -0
  208. package/dist/blocked.d.ts +31 -0
  209. package/dist/blocked.js +31 -0
  210. package/dist/cardContext.d.ts +8 -0
  211. package/dist/cardContext.js +14 -0
  212. package/dist/cardWait.d.ts +13 -0
  213. package/dist/cardWait.js +16 -0
  214. package/dist/colourScheme.d.ts +22 -0
  215. package/dist/colourScheme.js +53 -0
  216. package/dist/control.d.ts +29 -0
  217. package/dist/control.js +37 -0
  218. package/dist/copyScript.d.ts +13 -0
  219. package/dist/copyScript.js +13 -0
  220. package/dist/cx.d.ts +19 -0
  221. package/dist/cx.js +21 -0
  222. package/dist/density.d.ts +38 -0
  223. package/dist/density.js +77 -0
  224. package/dist/emptySlot.d.ts +11 -0
  225. package/dist/emptySlot.js +16 -0
  226. package/dist/fieldControl.d.ts +23 -0
  227. package/dist/fieldControl.js +24 -0
  228. package/dist/fieldWait.d.ts +30 -0
  229. package/dist/fieldWait.js +27 -0
  230. package/dist/foldedColumn.d.ts +18 -0
  231. package/dist/foldedColumn.js +51 -0
  232. package/dist/headingLevel.d.ts +10 -0
  233. package/dist/headingLevel.js +18 -0
  234. package/dist/highlight.d.ts +18 -0
  235. package/dist/highlight.js +306 -0
  236. package/dist/highlightConsole.d.ts +9 -0
  237. package/dist/highlightConsole.js +42 -0
  238. package/dist/highlightHtml.d.ts +7 -0
  239. package/dist/highlightHtml.js +132 -0
  240. package/dist/highlightKit.d.ts +16 -0
  241. package/dist/highlightKit.js +23 -0
  242. package/dist/highlightYaml.d.ts +3 -0
  243. package/dist/highlightYaml.js +143 -0
  244. package/dist/icons.d.ts +16 -0
  245. package/dist/icons.js +108 -0
  246. package/dist/index.d.ts +99 -0
  247. package/dist/index.js +92 -0
  248. package/dist/isoDate.d.ts +5 -0
  249. package/dist/isoDate.js +16 -0
  250. package/dist/labelWords.d.ts +20 -0
  251. package/dist/labelWords.js +28 -0
  252. package/dist/layoutWait.d.ts +15 -0
  253. package/dist/layoutWait.js +18 -0
  254. package/dist/link.d.ts +82 -0
  255. package/dist/link.js +68 -0
  256. package/dist/listRowProps.d.ts +108 -0
  257. package/dist/listRowProps.js +1 -0
  258. package/dist/listRowWait.d.ts +6 -0
  259. package/dist/listRowWait.js +14 -0
  260. package/dist/modal.d.ts +25 -0
  261. package/dist/modal.js +61 -0
  262. package/dist/navFold.d.ts +15 -0
  263. package/dist/navFold.js +46 -0
  264. package/dist/pillTip.d.ts +8 -0
  265. package/dist/pillTip.js +25 -0
  266. package/dist/props.d.ts +26 -0
  267. package/dist/props.js +14 -0
  268. package/dist/scrollEdges.d.ts +12 -0
  269. package/dist/scrollEdges.js +40 -0
  270. package/dist/scrollStop.d.ts +32 -0
  271. package/dist/scrollStop.js +79 -0
  272. package/dist/sheetSnap.d.ts +27 -0
  273. package/dist/sheetSnap.js +45 -0
  274. package/dist/shownDate.d.ts +88 -0
  275. package/dist/shownDate.js +186 -0
  276. package/dist/size.d.ts +45 -0
  277. package/dist/size.js +12 -0
  278. package/dist/skeleton.d.ts +83 -0
  279. package/dist/skeleton.js +88 -0
  280. package/dist/stackGap.d.ts +9 -0
  281. package/dist/stackGap.js +16 -0
  282. package/dist/stickyColumn.d.ts +38 -0
  283. package/dist/stickyColumn.js +38 -0
  284. package/dist/switcher.d.ts +93 -0
  285. package/dist/switcher.js +78 -0
  286. package/dist/tableColumns.d.ts +31 -0
  287. package/dist/tableColumns.js +72 -0
  288. package/dist/tableEmpty.d.ts +15 -0
  289. package/dist/tableEmpty.js +26 -0
  290. package/dist/tableRow.d.ts +67 -0
  291. package/dist/tableRow.js +49 -0
  292. package/dist/tableSort.d.ts +22 -0
  293. package/dist/tableSort.js +19 -0
  294. package/dist/textBox.d.ts +10 -0
  295. package/dist/textBox.js +23 -0
  296. package/dist/tone.d.ts +11 -0
  297. package/dist/tone.js +1 -0
  298. package/dist/trend.d.ts +26 -0
  299. package/dist/trend.js +64 -0
  300. package/dist/typography.d.ts +203 -0
  301. package/dist/typography.js +242 -0
  302. package/dist/useImageFailed.d.ts +19 -0
  303. package/dist/useImageFailed.js +21 -0
  304. package/package.json +84 -4
@@ -0,0 +1,9 @@
1
+ import { type ComponentPropsWithoutRef, type ReactElement, type ReactNode, type Ref } from "react";
2
+ import { type ControlProps } from "./control.js";
3
+ import type { Unstyled } from "./props.js";
4
+ /** `Input` for `type="search"`: native search look reset, and a clear button named `clearLabel` at the trailing edge while the field has a value. */
5
+ export declare function SearchInput({ icon, size, width, clearLabel, onChange, ref, ...rest }: {
6
+ icon?: ReactNode;
7
+ clearLabel: string;
8
+ ref?: Ref<HTMLInputElement> | undefined;
9
+ } & ControlProps & Unstyled<Omit<ComponentPropsWithoutRef<"input">, "size" | "width">>): ReactElement;
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useRef, useState, } from "react";
3
+ import { controlClass } from "./control.js";
4
+ import { cx, focusRing } from "./cx.js";
5
+ import { useTypeStep } from "./density.js";
6
+ import { InputShell } from "./InputShell.js";
7
+ import { Tipped } from "./Tooltip.js";
8
+ /** The browser's own search look is reset: no `searchfield` appearance, no cancel button or decoration. The clear button below replaces them. */
9
+ const SEARCH_RESET = "appearance-none [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden [&::-webkit-search-results-button]:hidden [&::-webkit-search-results-decoration]:hidden";
10
+ /** A search field's padding: the leading side as a plain field or with an icon, the trailing side clear of the clear button. */
11
+ const SEARCH_PAD = {
12
+ sm: { plain: "pl-2 pr-7", icon: "pl-7 pr-7" },
13
+ md: { plain: "pl-3 pr-9", icon: "pl-9 pr-9" },
14
+ lg: { plain: "pl-4 pr-11", icon: "pl-11 pr-11" },
15
+ };
16
+ /** The clear button's place and box, and its icon, by the field's size. */
17
+ const CLEAR_SIZE = {
18
+ sm: { box: "right-1 h-5 w-5", icon: "h-3 w-3" },
19
+ md: { box: "right-2 h-6 w-6", icon: "h-3.5 w-3.5" },
20
+ lg: { box: "right-2.5 h-7 w-7", icon: "h-4 w-4" },
21
+ };
22
+ const CLEAR_BUTTON = `absolute top-1/2 -translate-y-1/2 inline-flex items-center justify-center rounded text-slate-500 hover:bg-slate-100 ${focusRing}`;
23
+ /** Set `value` the way a keystroke does (past React's value tracker), so `onChange` fires for a controlled and an uncontrolled field alike. */
24
+ function clearValue(input) {
25
+ const descriptor = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value");
26
+ descriptor?.set?.call(input, "");
27
+ input.dispatchEvent(new Event("input", { bubbles: true }));
28
+ input.focus();
29
+ }
30
+ function ClearButton({ size, label, onClear, }) {
31
+ return (_jsx(Tipped, { text: label, describes: false, own: {}, children: (tip) => (_jsx("button", { type: "button", "aria-label": label, ...tip, onClick: onClear, className: cx(CLEAR_BUTTON, CLEAR_SIZE[size].box), children: _jsx("svg", { viewBox: "0 0 20 20", fill: "currentColor", "aria-hidden": "true", className: CLEAR_SIZE[size].icon, children: _jsx("path", { d: "M5.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 10l-4.72 4.72a.75.75 0 1 0 1.06 1.06L10 11.06l4.72 4.72a.75.75 0 1 0 1.06-1.06L11.06 10l4.72-4.72a.75.75 0 0 0-1.06-1.06L10 8.94 5.28 4.22Z" }) }) })) }));
32
+ }
33
+ /** Sets both the field's own ref and the consumer's. */
34
+ function bothRefs(own, theirs) {
35
+ return (el) => {
36
+ own.current = el;
37
+ if (typeof theirs === "function")
38
+ theirs(el);
39
+ else if (theirs)
40
+ theirs.current = el;
41
+ };
42
+ }
43
+ /** `Input` for `type="search"`: native search look reset, and a clear button named `clearLabel` at the trailing edge while the field has a value. */
44
+ export function SearchInput({ icon, size = "md", width = "full", clearLabel, onChange, ref, ...rest }) {
45
+ const step = useTypeStep();
46
+ const inputRef = useRef(null);
47
+ // One callback for the life of the ref, so a caller's function ref is not called on every keystroke.
48
+ const attach = useMemo(() => bothRefs(inputRef, ref), [ref]);
49
+ const [typed, setTyped] = useState(() => String(rest.value ?? rest.defaultValue ?? "") !== "");
50
+ const filled = rest.value !== undefined ? String(rest.value) !== "" : typed;
51
+ return (_jsxs(InputShell, { icon: icon, size: size, width: width, children: [_jsx("input", { ...rest, ref: attach, onChange: (event) => {
52
+ setTyped(event.currentTarget.value !== "");
53
+ onChange?.(event);
54
+ }, className: cx(controlClass(size, width === "auto" ? "auto" : "full", step), SEARCH_PAD[size][icon === undefined ? "plain" : "icon"], SEARCH_RESET) }), filled && !rest.disabled && !rest.readOnly && (_jsx(ClearButton, { size: size, label: clearLabel, onClear: () => inputRef.current && clearValue(inputRef.current) }))] }));
55
+ }
@@ -0,0 +1,93 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ import { type HeadingLevel } from "./headingLevel.js";
3
+ import type { Passthrough } from "./props.js";
4
+ import type { Size } from "./size.js";
5
+ import { type StackGap, type StackWidth } from "./Stack.js";
6
+ /** A `Section`'s scale: `sm` a small titled group, `md` a page's section, `lg` a landing page's section. */
7
+ export type SectionSize = Size;
8
+ type SectionBase = {
9
+ /**
10
+ * Makes the section a link target: `#<id>` scrolls to its heading, which stops below the sticky
11
+ * AppShell header, as every `id` inside the shell does; write no `scroll-margin`. Needs a `title`:
12
+ * with no title the heading that carries it is not rendered.
13
+ */
14
+ id?: string | undefined;
15
+ /** The heading at the top, which names the section. */
16
+ title?: ReactNode;
17
+ /** Buttons or links: at the end of the title row, or under the description at `size="lg"`. */
18
+ actions?: ReactNode;
19
+ /**
20
+ * The title's heading level, 2 to 6. It does not change how the title looks.
21
+ * @default one below the heading that holds the section: 2 on the page
22
+ */
23
+ level?: HeadingLevel | undefined;
24
+ /**
25
+ * The space between blocks: `xs` gap-2, `sm` gap-4, `md` gap-6, `lg` gap-8, `xl` gap-12 (gap-16 from `sm`).
26
+ * @default xs at `size="sm"`, lg at `size="lg"`; else xs inside a `Card`, `Dialog`, `Drawer`, `BottomSheet`, `Callout` or `ListRow`, else md
27
+ */
28
+ gap?: StackGap | undefined;
29
+ /**
30
+ * Caps the column: `compact` max-w-md (one card or one picture's column), `narrow` max-w-3xl (a
31
+ * reading measure), `wide` max-w-5xl, `full` the parent's whole width, `default` sets nothing.
32
+ * @default default
33
+ */
34
+ width?: StackWidth | undefined;
35
+ children?: ReactNode;
36
+ } & Passthrough;
37
+ /** The opening a page or landing section takes over its title: a kicker and a line under it. */
38
+ type Opening = {
39
+ /** A small label above the title, in the same `<header>` (mono at `size="lg"`). Needs a `title`. */
40
+ overline?: ReactNode;
41
+ /** The line under the title, outside the heading: a muted line at `md`, a `Lead` at `lg`. */
42
+ description?: ReactNode;
43
+ };
44
+ type SectionProps = SectionBase & (({
45
+ /**
46
+ * `sm` a small titled group inside a page, a card or a panel, its title small and all-caps
47
+ * and its blocks `xs` apart; `md` a page's section; `lg` a landing page's section, a display
48
+ * title under a mono kicker, a `Lead`, then its calls to action.
49
+ *
50
+ * A landing page's section under the `Hero` is `size="lg"`: its opening is capped at the
51
+ * reading measure at the start edge and its blocks sit `lg` apart. A feature card in it is
52
+ * a `Card href icon titleStyle="name"` in a `CardGrid`; text beside code is a `SideColumn`.
53
+ * @default md
54
+ */
55
+ size?: "md" | undefined;
56
+ /**
57
+ * A hairline under the title row across the section's width, `actions` included. Needs a
58
+ * `title` or `actions`.
59
+ * @default false
60
+ */
61
+ rule?: boolean | undefined;
62
+ } & Opening) | {
63
+ size: "sm";
64
+ /**
65
+ * A hairline under the title row across the section's width, `actions` included. Needs a
66
+ * `title` or `actions`.
67
+ */
68
+ rule?: boolean | undefined;
69
+ overline?: never;
70
+ description?: never;
71
+ } | ({
72
+ size: "lg";
73
+ rule?: never;
74
+ } & Opening));
75
+ /**
76
+ * A `<section>` Stack with an optional title (which names it) and `actions`. Its blocks are `gap`
77
+ * apart, from where it sits as in a `Stack`. `level` is the title's heading level, one below the
78
+ * heading that holds the section (an `h2` on the page), and a heading inside it (a `Card`'s title)
79
+ * is one below that. A line between two sections is a `Divider` in the `Stack` that holds them.
80
+ *
81
+ * `size` picks the scale:
82
+ * - `md` (default): a page's section. A `SectionHeading` title with `actions` at the end of its row;
83
+ * `rule` draws a hairline under the row, `overline` a small label above the title and
84
+ * `description` a muted line under it.
85
+ * - `sm`: the small titled group inside a page, a card, a drawer or a side panel (a panel's "Flaky"
86
+ * block, a card's "Ignore areas"): the title small and all-caps like a `Card`'s, the blocks `xs`
87
+ * apart. Never build one from a `Stack as="section"` and an `Overline`.
88
+ * - `lg`: a landing page's section under the `Hero`: a mono `overline` kicker, the title at display
89
+ * size, `description` as a `Lead` and `actions` under it as its calls to action, the opening
90
+ * capped at the reading measure at the start edge, the blocks `lg` apart. It ignores the prose scale.
91
+ */
92
+ export declare function Section({ id, title, actions, rule, overline, description, level, size, gap, width, children, ...rest }: SectionProps): ReactElement;
93
+ export {};
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { Cluster } from "./Cluster.js";
4
+ import { cx } from "./cx.js";
5
+ import { HeadingLevelProvider, useHeadingLevel } from "./headingLevel.js";
6
+ import { Stack } from "./Stack.js";
7
+ import { CardOverline, Display, Lead, Overline, SectionHeading } from "./typography.js";
8
+ /** The id a `Section`'s heading takes: the caller's, or one of React's. */
9
+ function useHeadingId(id) {
10
+ const generated = useId();
11
+ return id ?? generated;
12
+ }
13
+ /**
14
+ * A `<section>` Stack with an optional title (which names it) and `actions`. Its blocks are `gap`
15
+ * apart, from where it sits as in a `Stack`. `level` is the title's heading level, one below the
16
+ * heading that holds the section (an `h2` on the page), and a heading inside it (a `Card`'s title)
17
+ * is one below that. A line between two sections is a `Divider` in the `Stack` that holds them.
18
+ *
19
+ * `size` picks the scale:
20
+ * - `md` (default): a page's section. A `SectionHeading` title with `actions` at the end of its row;
21
+ * `rule` draws a hairline under the row, `overline` a small label above the title and
22
+ * `description` a muted line under it.
23
+ * - `sm`: the small titled group inside a page, a card, a drawer or a side panel (a panel's "Flaky"
24
+ * block, a card's "Ignore areas"): the title small and all-caps like a `Card`'s, the blocks `xs`
25
+ * apart. Never build one from a `Stack as="section"` and an `Overline`.
26
+ * - `lg`: a landing page's section under the `Hero`: a mono `overline` kicker, the title at display
27
+ * size, `description` as a `Lead` and `actions` under it as its calls to action, the opening
28
+ * capped at the reading measure at the start edge, the blocks `lg` apart. It ignores the prose scale.
29
+ */
30
+ export function Section({ id, title, actions, rule = false, overline, description, level, size = "md", gap, width = "default", children, ...rest }) {
31
+ const titleId = useHeadingId(id);
32
+ const own = useHeadingLevel(level);
33
+ const head = { title, actions, id: titleId, level: own };
34
+ return (_jsxs(Stack, { as: "section", ...rest, gap: gap ?? DEFAULT_GAP[size], width: width, "aria-labelledby": title ? titleId : rest["aria-labelledby"], children: [size === "lg" ? (_jsx(LandingOpening, { ...head, overline: overline, description: description })) : (_jsx(TitleRow, { ...head, small: size === "sm", rule: rule, overline: overline, description: description })), title ? _jsx(HeadingLevelProvider, { level: own, children: children }) : children] }));
35
+ }
36
+ const DEFAULT_GAP = {
37
+ sm: "xs",
38
+ md: undefined,
39
+ lg: "lg",
40
+ };
41
+ const present = (node) => node != null && node !== false;
42
+ /** A `sm` or `md` section's title row: its heading, then `actions` at the end. Nothing without either. */
43
+ function TitleRow({ title, actions, id, level, small, rule, overline, description, }) {
44
+ if (!title && !actions)
45
+ return null;
46
+ const heading = small ? (_jsx(CardOverline, { id: id, level: level, faint: false, children: title })) : (_jsx(SectionHeading, { as: `h${level}`, id: id, description: description, children: title }));
47
+ return (_jsxs("div", { className: cx("flex items-center justify-between", small ? "gap-2" : "gap-4", rule && "border-b border-slate-200/70 pb-2"), children: [title &&
48
+ (present(overline) ? (_jsxs("header", { className: "flex flex-col gap-1", children: [_jsx(Overline, { children: overline }), heading] })) : (heading)), actions && _jsx("div", { className: "ml-auto flex items-center gap-2", children: actions })] }));
49
+ }
50
+ /** A `lg` section's opening: the kicker and the display title in one `<header>`, the lede, the calls to action. */
51
+ function LandingOpening({ title, actions, id, level, overline, description, }) {
52
+ if (!title && !actions)
53
+ return null;
54
+ return (_jsxs("div", { className: "flex max-w-3xl flex-col gap-4", children: [title && (_jsxs("header", { children: [present(overline) && _jsx(Overline, { mono: true, children: overline }), _jsx(Display, { as: `h${level}`, id: id, children: title })] })), title && present(description) && _jsx(Lead, { children: description }), actions && _jsx(Cluster, { children: actions })] }));
55
+ }
@@ -0,0 +1,47 @@
1
+ import type { ReactElement } from "react";
2
+ import { type ResponsiveSize, type Size } from "./size.js";
3
+ import { type SwitchItem, type SwitchProps } from "./switcher.js";
4
+ /** One option of a SegmentedControl: a button with a `value`, or a link with an `href`; never both kinds in one group. */
5
+ export type Segment = SwitchItem;
6
+ /** The padding table and its `md:` twin, for the data test. */
7
+ export declare const segmentSizeTables: {
8
+ size: Record<Size, string>;
9
+ sizeMd: Record<Size, string>;
10
+ };
11
+ /**
12
+ * A joined pill group where one option is filled: a mode or a range chosen in place. `items` are
13
+ * `{ value, label }` buttons (`value` and `onChange` are the caller's state; the arrow keys, Home
14
+ * and End move the choice) or links (`href`, an in-app one drawn by the app's router `<Link>` through `LinkProvider`;
15
+ * `value` marks the current one, which gets `aria-current`). An item may carry a `count`, and a
16
+ * button one `disabledReason` (it stays reachable by the arrows and its reason is a tooltip) or a bare `disabled`; `disabled` on the group disables every
17
+ * option. `label` names the group. `size` matches the height of a `Button` of the same size, and
18
+ * `{ base, md }` changes it at 48rem.
19
+ * `fill` stretches the options across the group's width; `wrap` lets them wrap into full rows of a
20
+ * box, always or (`"narrow"`) only while the group is under 32rem wide.
21
+ */
22
+ export declare function SegmentedControl({ size, fill, wrap, ...props }: SwitchProps & {
23
+ /**
24
+ * The control's height and text, on the scale of a `Button`. `{ base: "md", md: "lg" }` changes
25
+ * size at the `md` breakpoint (48rem), in CSS.
26
+ *
27
+ * Give it the same value as a responsive `Button` in the same row.
28
+ * @default md
29
+ */
30
+ size?: Size | ResponsiveSize;
31
+ /**
32
+ * The group takes its parent's full width and the options grow to share it, so the border ends
33
+ * at the last option. Still a pill.
34
+ * @default false
35
+ */
36
+ fill?: boolean;
37
+ /**
38
+ * The options wrap onto full rows of at most three (five are 3 then 2) in a box with rounded
39
+ * corners and a line between options, instead of a pill. `"narrow"`: the box only while the group
40
+ * itself is under 32rem wide (a container query, so it follows the column it sits in), and a
41
+ * filled pill from 32rem up. Implies `fill`.
42
+ *
43
+ * For five options that will not fit one row.
44
+ * @default false
45
+ */
46
+ wrap?: boolean | "narrow";
47
+ }): ReactElement;
@@ -0,0 +1,78 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from "./cx.js";
3
+ import { controlText, useTypeStep } from "./density.js";
4
+ import { sizeClass } from "./size.js";
5
+ import { Switcher } from "./switcher.js";
6
+ // The focus ring sits inside the option, since the group's rounded edge would clip an outer one.
7
+ const RING = "focus-visible:outline-2 focus-visible:outline-violet-600";
8
+ const BASE = `border-l border-slate-300 transition first:rounded-l-full first:border-l-0 last:rounded-r-full ${RING} focus-visible:-outline-offset-2`;
9
+ /**
10
+ * An option's padding, by `size`; its text is a control's (`controlText`). With the group's border,
11
+ * the heights of a `Button`.
12
+ */
13
+ const SIZE = {
14
+ sm: "px-2.5 py-1",
15
+ md: "px-3 py-2",
16
+ lg: "px-4 py-2.5",
17
+ };
18
+ /** `SIZE` from the `md` breakpoint up, for a responsive size. */
19
+ const SIZE_MD = {
20
+ sm: "md:px-2.5 md:py-1",
21
+ md: "md:px-3 md:py-2",
22
+ lg: "md:px-4 md:py-2.5",
23
+ };
24
+ /** The padding table and its `md:` twin, for the data test. */
25
+ export const segmentSizeTables = { size: SIZE, sizeMd: SIZE_MD };
26
+ const ON = "bg-violet-600 font-medium text-violet-50";
27
+ const OFF = "bg-white text-slate-600";
28
+ const OFF_LIVE = "hover:bg-violet-50 hover:text-violet-700";
29
+ const ROOT = {
30
+ inline: "inline-flex rounded-full border border-slate-300",
31
+ fill: "flex w-full rounded-full border border-slate-300",
32
+ // The box clips each option's top and left line where it meets the group's own border.
33
+ wrap: "flex w-full flex-wrap overflow-hidden rounded-2xl border border-slate-300",
34
+ narrow: "flex w-full border border-slate-300 @min-[32rem]:rounded-full @max-[32rem]:flex-wrap @max-[32rem]:overflow-hidden @max-[32rem]:rounded-2xl",
35
+ };
36
+ /**
37
+ * An option's own lines. In the box each option draws its top and left line one pixel up and left,
38
+ * over its neighbour's edge, so the lines between options are one pixel and the outer ones fall
39
+ * under the group's border. A row holds at most three (`30%` each), and they grow to fill it. The
40
+ * box clips that pixel, so its ring sits one pixel further in.
41
+ */
42
+ const OPTION = {
43
+ inline: BASE,
44
+ fill: cx(BASE, "flex-auto text-center"),
45
+ wrap: cx("border-slate-300 text-center transition", RING, "-mt-px -ml-px flex-[1_1_30%] border-t border-l focus-visible:-outline-offset-3"),
46
+ narrow: cx("border-slate-300 text-center transition", RING, "@min-[32rem]:flex-auto @min-[32rem]:border-l @min-[32rem]:first:rounded-l-full @min-[32rem]:first:border-l-0 @min-[32rem]:last:rounded-r-full @min-[32rem]:focus-visible:-outline-offset-2", "@max-[32rem]:-mt-px @max-[32rem]:-ml-px @max-[32rem]:flex-[1_1_30%] @max-[32rem]:border-t @max-[32rem]:border-l @max-[32rem]:focus-visible:-outline-offset-3"),
47
+ };
48
+ function layout(fill, wrap) {
49
+ if (wrap === "narrow")
50
+ return "narrow";
51
+ if (wrap)
52
+ return "wrap";
53
+ return fill ? "fill" : "inline";
54
+ }
55
+ /**
56
+ * A joined pill group where one option is filled: a mode or a range chosen in place. `items` are
57
+ * `{ value, label }` buttons (`value` and `onChange` are the caller's state; the arrow keys, Home
58
+ * and End move the choice) or links (`href`, an in-app one drawn by the app's router `<Link>` through `LinkProvider`;
59
+ * `value` marks the current one, which gets `aria-current`). An item may carry a `count`, and a
60
+ * button one `disabledReason` (it stays reachable by the arrows and its reason is a tooltip) or a bare `disabled`; `disabled` on the group disables every
61
+ * option. `label` names the group. `size` matches the height of a `Button` of the same size, and
62
+ * `{ base, md }` changes it at 48rem.
63
+ * `fill` stretches the options across the group's width; `wrap` lets them wrap into full rows of a
64
+ * box, always or (`"narrow"`) only while the group is under 32rem wide.
65
+ */
66
+ export function SegmentedControl({ size = "md", fill = false, wrap = false, ...props }) {
67
+ const text = controlText(size, useTypeStep(), false);
68
+ const shape = layout(fill, wrap);
69
+ const group = (_jsx(Switcher, { ...props, parts: {
70
+ group: "radiogroup",
71
+ item: "radio",
72
+ vertical: true,
73
+ root: ROOT[shape],
74
+ option: (active, disabled) => cx(OPTION[shape], sizeClass(SIZE, SIZE_MD, size), text, active ? ON : OFF, !active && !disabled && OFF_LIVE),
75
+ } }));
76
+ // A container query needs an element around the group; every attribute stays on the group itself.
77
+ return shape === "narrow" ? _jsx("div", { className: "@container w-full", children: group }) : group;
78
+ }
@@ -0,0 +1,28 @@
1
+ import { type ComponentPropsWithoutRef, type ReactElement, type Ref } from "react";
2
+ import { type ControlProps } from "./control.js";
3
+ import type { Unstyled } from "./props.js";
4
+ /** One choice of a `Select`. */
5
+ export type SelectItem = {
6
+ /** What the form posts and `onChange` reads. */
7
+ value: string;
8
+ /** What the list shows. */
9
+ label: string;
10
+ /** Shown but not choosable. */
11
+ disabled?: boolean | undefined;
12
+ };
13
+ /**
14
+ * A native `<select>` styled like `Input`, keeping the browser's own arrow, over its `items`. Takes
15
+ * `size` and `width` too: inside a `Field` it fills the row, and on its own it is as wide as its
16
+ * longest choice. The `ref` reaches the `<select>`.
17
+ */
18
+ export declare function Select({ items, size, width, ...own }: Omit<ControlProps, "width"> & {
19
+ /** The choices, in order. */
20
+ items: readonly SelectItem[];
21
+ /**
22
+ * As an `Input`'s `width`.
23
+ * @default full inside a `Field`, `auto` outside one
24
+ */
25
+ width?: ControlProps["width"];
26
+ /** The `<select>` itself, for focus control. */
27
+ ref?: Ref<HTMLSelectElement> | undefined;
28
+ } & Unstyled<Omit<ComponentPropsWithoutRef<"select">, "size" | "width" | "children">>): ReactElement;
package/dist/Select.js ADDED
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext } from "react";
3
+ import { CONTROL_PAD, controlClass } from "./control.js";
4
+ import { cx } from "./cx.js";
5
+ import { useTypeStep } from "./density.js";
6
+ import { FieldContext, useFieldControl } from "./fieldControl.js";
7
+ /** The height of a `Select` by `size`, the `Input`'s 26px, 38px and 46px: a native `<select>` sizes its text from the font and ignores the line height, so padding alone falls short at `md` and `lg`. */
8
+ const SELECT_HEIGHT = { sm: "h-6.5", md: "h-9.5", lg: "h-11.5" };
9
+ /**
10
+ * A native `<select>` styled like `Input`, keeping the browser's own arrow, over its `items`. Takes
11
+ * `size` and `width` too: inside a `Field` it fills the row, and on its own it is as wide as its
12
+ * longest choice. The `ref` reaches the `<select>`.
13
+ */
14
+ export function Select({ items, size = "md", width, ...own }) {
15
+ const step = useTypeStep();
16
+ const inField = useContext(FieldContext) !== undefined;
17
+ const field = useFieldControl(own);
18
+ return (_jsx("select", { ...own, ...field, className: cx(controlClass(size, width ?? (inField ? "full" : "auto"), step), SELECT_HEIGHT[size], CONTROL_PAD[size].x), children: items.map((item) => (_jsx("option", { value: item.value, disabled: item.disabled, children: item.label }, item.value))) }));
19
+ }
package/dist/Show.d.ts ADDED
@@ -0,0 +1,33 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import type { Passthrough } from "./props.js";
3
+ /** A width step: `sm` 640px, `md` 768px, `lg` 1024px. */
4
+ export type Breakpoint = "sm" | "md" | "lg";
5
+ type ShowWhen = {
6
+ /** Shown from this width up, gone below it. */
7
+ from: Breakpoint;
8
+ below?: never;
9
+ } | {
10
+ /** Shown below this width, gone from it up. */
11
+ below: Breakpoint;
12
+ from?: never;
13
+ };
14
+ /**
15
+ * Shows its children only from a width up (`from`) or only below it (`below`), by CSS alone: the
16
+ * same markup on the server and the client, with no script. Hidden is `display: none`, so the
17
+ * content is out of the accessibility tree and the tab order too. Shown, the wrapper adds no box,
18
+ * so the children sit in the parent's row, grid or Stack and take its gap.
19
+ *
20
+ * Content that only fits a wide screen is in a `Show from`; its narrow-screen form is in a
21
+ * `Show below` at the same breakpoint. Hidden content stays mounted, so two `Show`s of the same
22
+ * content mount it twice: a stateful panel shown at every width with a fold is a
23
+ * `SideColumn asideLabel`. `as="span"` is for phrasing content (inside a `<p>` or a button row).
24
+ */
25
+ export declare function Show({ from, below, as: Tag, children, ...rest }: ShowWhen & {
26
+ /**
27
+ * The element: `div`, or `span` inside phrasing content.
28
+ * @default div
29
+ */
30
+ as?: "div" | "span" | undefined;
31
+ children: ReactNode;
32
+ } & Passthrough): ReactElement;
33
+ export {};
package/dist/Show.js ADDED
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Each class is written out whole, so Tailwind sees it. Shown is `display: contents`, so the wrapper
3
+ // adds no box and its children sit in the parent's row, grid or Stack, spaced by its gap.
4
+ const FROM = {
5
+ sm: "hidden sm:contents",
6
+ md: "hidden md:contents",
7
+ lg: "hidden lg:contents",
8
+ };
9
+ const BELOW = {
10
+ sm: "contents sm:hidden",
11
+ md: "contents md:hidden",
12
+ lg: "contents lg:hidden",
13
+ };
14
+ /**
15
+ * Shows its children only from a width up (`from`) or only below it (`below`), by CSS alone: the
16
+ * same markup on the server and the client, with no script. Hidden is `display: none`, so the
17
+ * content is out of the accessibility tree and the tab order too. Shown, the wrapper adds no box,
18
+ * so the children sit in the parent's row, grid or Stack and take its gap.
19
+ *
20
+ * Content that only fits a wide screen is in a `Show from`; its narrow-screen form is in a
21
+ * `Show below` at the same breakpoint. Hidden content stays mounted, so two `Show`s of the same
22
+ * content mount it twice: a stateful panel shown at every width with a fold is a
23
+ * `SideColumn asideLabel`. `as="span"` is for phrasing content (inside a `<p>` or a button row).
24
+ */
25
+ export function Show({ from, below, as: Tag = "div", children, ...rest }) {
26
+ return (_jsx(Tag, { ...rest, className: from ? FROM[from] : BELOW[below ?? "sm"], children: children }));
27
+ }
@@ -0,0 +1,50 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import type { Passthrough } from "./props.js";
3
+ /** How wide a `SideColumn`'s aside is from `lg`: `sm` 18rem, `md` 24rem, or `third` a third of the row. */
4
+ export type SideColumnWidth = "sm" | "md" | "third";
5
+ /**
6
+ * A main area beside a side column, in the Container the page already has: from `lg` the `aside`
7
+ * is `asideWidth` on the right and `children` take the room left; below `lg` the aside stacks under
8
+ * `children`. It sets no page width, padding or header of its own, so it sits inside a layout, a
9
+ * `Card` or a panel. `asideWidth` is `sm` (18rem), `md` (24rem) or `third` (one third of the row,
10
+ * the main area two thirds: the split `DetailLayout` draws). A rail of links on the left is
11
+ * `SidebarLayout`.
12
+ *
13
+ * `asideLabel` is for an aside that should not take the phone's screen: below `lg` it folds,
14
+ * closed, behind a native disclosure of that name, and from `lg` it is the same column, always
15
+ * shown. The aside stays mounted while folded, so a conversation or a draft inside it is kept.
16
+ *
17
+ * `sticky` keeps the aside in view from `lg` as a long page scrolls: it sticks under AppShell's
18
+ * header and, if it is taller than the room left, scrolls itself (a tab stop named by `asideLabel`)
19
+ * so its end stays reachable.
20
+ */
21
+ export declare function SideColumn({ asideLabel, ...props }: {
22
+ /** The side column: `asideWidth` wide on the right from `lg`, under `children` below it. */
23
+ aside: ReactNode;
24
+ /**
25
+ * The aside's width from `lg`: `sm` 18rem, `md` 24rem, or `third`, one third of the row.
26
+ * @default md
27
+ */
28
+ asideWidth?: SideColumnWidth | undefined;
29
+ /** Folds the aside behind a disclosure with this name below `lg`, and names the `<aside>` landmark. Left out, the aside is always shown and unnamed. */
30
+ asideLabel?: string | undefined;
31
+ /**
32
+ * From `lg`, keeps the aside in view under the header as the page scrolls; an aside taller than
33
+ * the screen scrolls inside itself.
34
+ * @default false
35
+ */
36
+ sticky?: boolean | undefined;
37
+ children: ReactNode;
38
+ } & Passthrough): ReactElement;
39
+ /**
40
+ * The one two-column split: `SideColumn`, and `DetailLayout`'s columns, whose `asideLabel` names
41
+ * the aside without folding it. Internal.
42
+ */
43
+ export declare function SplitColumns({ aside, asideWidth, label, fold, sticky, children, ...rest }: {
44
+ aside: ReactNode;
45
+ asideWidth?: SideColumnWidth | undefined;
46
+ label: string | undefined;
47
+ fold: boolean;
48
+ sticky?: boolean | undefined;
49
+ children: ReactNode;
50
+ } & Passthrough): ReactElement;
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx } from "./cx.js";
3
+ import { FoldedColumn } from "./foldedColumn.js";
4
+ import { useScrollEdges } from "./scrollEdges.js";
5
+ import { scrollStopProps, useScrollStop } from "./scrollStop.js";
6
+ import { STICKY_ASIDE_LG, STICKY_FADE_LG, STICKY_SCROLL_LG } from "./stickyColumn.js";
7
+ /**
8
+ * The grid from `lg`, and the main area's share of it: `sm` and `md` give the aside exactly that
9
+ * width and the main area the room left; `third` gives the aside one third and the main area two.
10
+ */
11
+ const COLUMNS = {
12
+ sm: { grid: "lg:grid-cols-[minmax(0,1fr)_18rem]", main: "" },
13
+ md: { grid: "lg:grid-cols-[minmax(0,1fr)_24rem]", main: "" },
14
+ third: { grid: "lg:grid-cols-3", main: "lg:col-span-2" },
15
+ };
16
+ /**
17
+ * A main area beside a side column, in the Container the page already has: from `lg` the `aside`
18
+ * is `asideWidth` on the right and `children` take the room left; below `lg` the aside stacks under
19
+ * `children`. It sets no page width, padding or header of its own, so it sits inside a layout, a
20
+ * `Card` or a panel. `asideWidth` is `sm` (18rem), `md` (24rem) or `third` (one third of the row,
21
+ * the main area two thirds: the split `DetailLayout` draws). A rail of links on the left is
22
+ * `SidebarLayout`.
23
+ *
24
+ * `asideLabel` is for an aside that should not take the phone's screen: below `lg` it folds,
25
+ * closed, behind a native disclosure of that name, and from `lg` it is the same column, always
26
+ * shown. The aside stays mounted while folded, so a conversation or a draft inside it is kept.
27
+ *
28
+ * `sticky` keeps the aside in view from `lg` as a long page scrolls: it sticks under AppShell's
29
+ * header and, if it is taller than the room left, scrolls itself (a tab stop named by `asideLabel`)
30
+ * so its end stays reachable.
31
+ */
32
+ export function SideColumn({ asideLabel, ...props }) {
33
+ return _jsx(SplitColumns, { ...props, label: asideLabel, fold: asideLabel !== undefined });
34
+ }
35
+ /**
36
+ * The one two-column split: `SideColumn`, and `DetailLayout`'s columns, whose `asideLabel` names
37
+ * the aside without folding it. Internal.
38
+ */
39
+ export function SplitColumns({ aside, asideWidth = "md", label, fold, sticky = false, children, ...rest }) {
40
+ const { element, attach, stop } = useScrollStop();
41
+ useScrollEdges(element, "y");
42
+ const { props, ring } = scrollStopProps(sticky && stop, { label });
43
+ const columns = COLUMNS[asideWidth];
44
+ return (_jsxs("div", { ...rest, className: cx("grid grid-cols-1 gap-6", columns.grid), children: [_jsx("div", { className: cx("min-w-0", columns.main), children: children }), _jsx("aside", { className: cx("min-w-0", sticky && STICKY_ASIDE_LG), "aria-label": label, children: _jsx("div", { ref: sticky ? attach : undefined, ...props, className: sticky ? cx(STICKY_SCROLL_LG, STICKY_FADE_LG, ring) : undefined, children: fold && label !== undefined ? (_jsx(FoldedColumn, { from: "lg", label: label, children: aside })) : (aside) }) })] }));
45
+ }
@@ -0,0 +1,32 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ import type { Passthrough } from "./props.js";
3
+ import { type LoadingProps } from "./skeleton.js";
4
+ /**
5
+ * An `aside` of links (the rail) beside the `children` canvas, in the Container the shell already gives every
6
+ * page (a plain `<AppShell>`, no `bleed`): the rail starts at the header logo's x and the canvas
7
+ * ends at the header's right edge. The rail has no background and no border, so it is a list of
8
+ * links on the page; a `Tabs orientation="vertical"` is its content. From `md` it is `w-56` with
9
+ * the canvas filling the rest, and it stays in view under the shell's header as a long page scrolls;
10
+ * a rail taller than the screen scrolls itself, so its last link is reachable. Below `md` it stacks
11
+ * above the canvas and nothing sticks. A long rail sets `asideLabel`:
12
+ * below `md` it then folds behind a disclosure of that name, closed, so the page comes first on a
13
+ * phone, and from `md` it is the same rail; `asideLabel` also names the rail's `<aside>` landmark.
14
+ * Once the page has
15
+ * loaded, a rail that scrolls shows its current link (the one with `aria-current`) in view, and the
16
+ * folded disclosure reads `asideLabel` and the current link's name ("All components: Button"); both
17
+ * need the layout to hydrate.
18
+ * While `loading` the canvas waits (the rail is navigation, drawn as itself) and the layout owns
19
+ * the wait.
20
+ */
21
+ export declare function SidebarLayout({ aside, asideLabel, loading, loadingLabel, children, ...rest }: {
22
+ /** The links beside the canvas, usually a `Tabs orientation="vertical"`. */
23
+ aside: ReactNode;
24
+ /**
25
+ * Folds the rail behind a disclosure with this name below `md` (a long rail), and names the rail's
26
+ * `<aside>` landmark. Left out, the rail is always open and the aside is unnamed.
27
+ *
28
+ * Folded, the page comes first on a phone; from `md` it is the same rail.
29
+ */
30
+ asideLabel?: string | undefined;
31
+ children: ReactNode;
32
+ } & LoadingProps & Passthrough): ReactElement;