@slashsuite/ui-react 0.0.0-stage → 0.11.3

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 +548 -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,22 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ import type { Align } from "./tableRow.js";
3
+ /** Where a sortable column stands: ARIA's own words. `none` is a column the table is not sorted by. */
4
+ export type TableSort = "ascending" | "descending" | "none";
5
+ /** The props of a sortable `TableHeaderCell`: the column's `sort` and what a click asks for. */
6
+ export type SortProps = {
7
+ /**
8
+ * Where this column stands: `ascending`, `descending`, or `none` when the table is sorted by
9
+ * another column. The app sorts its rows and passes it back; one sorted column at a time.
10
+ *
11
+ * With `onSort` the title becomes a button that asks for the next direction. The table never
12
+ * sorts, filters or pages.
13
+ */
14
+ sort: TableSort;
15
+ /** Called with the next direction on a click: `none` goes to `ascending`, then each click flips it. */
16
+ onSort: (next: "ascending" | "descending") => void;
17
+ };
18
+ /** A sortable column's title: a native button that fills the cell, named by the title. */
19
+ export declare function SortButton({ sort, onSort, align, children, }: SortProps & {
20
+ align: Align;
21
+ children: ReactNode;
22
+ }): ReactElement;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cx, focusRing } from "./cx.js";
3
+ /** The direction a click asks for: `ascending` first, then it flips. */
4
+ function nextSort(sort) {
5
+ return sort === "ascending" ? "descending" : "ascending";
6
+ }
7
+ const JUSTIFY = {
8
+ start: "justify-start",
9
+ center: "justify-center",
10
+ end: "justify-end",
11
+ };
12
+ /** The arrow beside a sortable title: up, down, or both, faint, on a column not sorted by. */
13
+ function SortArrow({ sort }) {
14
+ return (_jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 12 12", className: cx("size-3 shrink-0", sort === "none" ? "text-slate-300" : "text-slate-600"), fill: "currentColor", children: [sort !== "descending" && _jsx("path", { d: "M6 1.5 9 5H3z" }), sort !== "ascending" && _jsx("path", { d: "M6 10.5 3 7h6z" })] }));
15
+ }
16
+ /** A sortable column's title: a native button that fills the cell, named by the title. */
17
+ export function SortButton({ sort, onSort, align, children, }) {
18
+ return (_jsxs("button", { type: "button", onClick: () => onSort(nextSort(sort)), className: cx("inline-flex w-full cursor-pointer items-center gap-1 rounded-sm uppercase tracking-wide hover:text-violet-700", JUSTIFY[align], focusRing), children: [children, _jsx(SortArrow, { sort: sort })] }));
19
+ }
@@ -0,0 +1,10 @@
1
+ /** Where a run of text sits across its block. */
2
+ export type TextAlign = "start" | "center" | "end";
3
+ /** How many lines a clamped run shows before it ends in an ellipsis. */
4
+ export type TextLines = 1 | 2 | 3 | 4;
5
+ /**
6
+ * The alignment, and the box it needs. An aligned run is block-level, so text-align has a box to set
7
+ * the text in. A run cut to one line clips: inline-block by default, a block when it is aligned too.
8
+ * Internal to the typography roles.
9
+ */
10
+ export declare function layoutClass(align: TextAlign | undefined, lines: TextLines | undefined): string;
@@ -0,0 +1,23 @@
1
+ import { cx } from "./cx.js";
2
+ const ALIGN = {
3
+ start: "text-start",
4
+ center: "text-center",
5
+ end: "text-end",
6
+ };
7
+ /** A run clamped to 2, 3 or 4 lines: `line-clamp` is a box of its own. */
8
+ const CLAMP = {
9
+ 2: "line-clamp-2",
10
+ 3: "line-clamp-3",
11
+ 4: "line-clamp-4",
12
+ };
13
+ /**
14
+ * The alignment, and the box it needs. An aligned run is block-level, so text-align has a box to set
15
+ * the text in. A run cut to one line clips: inline-block by default, a block when it is aligned too.
16
+ * Internal to the typography roles.
17
+ */
18
+ export function layoutClass(align, lines) {
19
+ const box = lines === 1
20
+ ? cx("min-w-0 truncate align-bottom", align ? "block" : "inline-block")
21
+ : (lines && CLAMP[lines]) || (align && "block");
22
+ return cx(align && ALIGN[align], box);
23
+ }
package/dist/tone.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The one tone vocabulary of the library: what a thing means, not what colour it is. `neutral`
3
+ * (no meaning, the role's own ink or surface) is every component's default, `info` is a note,
4
+ * `positive` a success, `warn` a caution and `danger` an error or a destructive act.
5
+ *
6
+ * A component extends it outward only where it has a real use, and says so beside its own type:
7
+ * the text roles add `muted` (a quieter line) and `accent` (the theme's accent ink), `Pill` and the
8
+ * charts add `accent` for a category that is none of the five meanings. No component renames a
9
+ * tone (`negative`, `default`, `slate` and the colour names are gone), and no scale skips `neutral`.
10
+ */
11
+ export type Tone = "neutral" | "info" | "positive" | "warn" | "danger";
package/dist/tone.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The scale shared by `TrendChart` and the `StatTile` sparkline. Internal: not exported from
3
+ * `index.ts`.
4
+ */
5
+ /**
6
+ * The top of a y-axis that starts at 0: the smallest of 2, 4 or 10 times a whole power of ten
7
+ * (1, 10, 100, …) that is at least `top`. Its half is then a whole number: 1 gives 2, 3 gives
8
+ * 4, 5 gives 10, 13 gives 20. Nothing above 0 gives 2.
9
+ */
10
+ export declare function scaleMax(top: number): number;
11
+ /** A value as drawn: a negative one is 0, and a missing or non-finite one is `null`. */
12
+ export declare function drawn(value: number | null | undefined): number | null;
13
+ /** The largest drawn value of every list, or 0. */
14
+ export declare function largest(lists: readonly (readonly (number | null)[])[]): number;
15
+ /** `value` as a height on a 0 to 100 plot, measured down from the top (SVG's y). */
16
+ export declare function plotY(value: number, max: number): number;
17
+ /**
18
+ * The polylines of a line through `points`, broken at every missing one: one `points` string per
19
+ * run of present values. A run of one point repeats it, so a round cap draws it as a dot.
20
+ */
21
+ export declare function runs(points: readonly ({
22
+ x: number;
23
+ y: number;
24
+ } | null)[]): string[];
25
+ /** Four decimals, so the markup stays short and stable. */
26
+ export declare function round(n: number): number;
package/dist/trend.js ADDED
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The scale shared by `TrendChart` and the `StatTile` sparkline. Internal: not exported from
3
+ * `index.ts`.
4
+ */
5
+ /**
6
+ * The top of a y-axis that starts at 0: the smallest of 2, 4 or 10 times a whole power of ten
7
+ * (1, 10, 100, …) that is at least `top`. Its half is then a whole number: 1 gives 2, 3 gives
8
+ * 4, 5 gives 10, 13 gives 20. Nothing above 0 gives 2.
9
+ */
10
+ export function scaleMax(top) {
11
+ for (let power = 1;; power *= 10) {
12
+ for (const step of [2, 4, 10]) {
13
+ if (step * power >= top)
14
+ return step * power;
15
+ }
16
+ }
17
+ }
18
+ /** A value as drawn: a negative one is 0, and a missing or non-finite one is `null`. */
19
+ export function drawn(value) {
20
+ if (value == null || !Number.isFinite(value))
21
+ return null;
22
+ return Math.max(0, value);
23
+ }
24
+ /** The largest drawn value of every list, or 0. */
25
+ export function largest(lists) {
26
+ let top = 0;
27
+ for (const list of lists) {
28
+ for (const value of list)
29
+ top = Math.max(top, drawn(value) ?? 0);
30
+ }
31
+ return top;
32
+ }
33
+ /** `value` as a height on a 0 to 100 plot, measured down from the top (SVG's y). */
34
+ export function plotY(value, max) {
35
+ return 100 - (value / max) * 100;
36
+ }
37
+ /**
38
+ * The polylines of a line through `points`, broken at every missing one: one `points` string per
39
+ * run of present values. A run of one point repeats it, so a round cap draws it as a dot.
40
+ */
41
+ export function runs(points) {
42
+ const out = [];
43
+ let run = [];
44
+ const close = () => {
45
+ const [only] = run;
46
+ if (run.length === 1 && only !== undefined)
47
+ run.push(only);
48
+ if (run.length > 0)
49
+ out.push(run.join(" "));
50
+ run = [];
51
+ };
52
+ for (const point of points) {
53
+ if (point === null)
54
+ close();
55
+ else
56
+ run.push(`${round(point.x)},${round(point.y)}`);
57
+ }
58
+ close();
59
+ return out;
60
+ }
61
+ /** Four decimals, so the markup stays short and stable. */
62
+ export function round(n) {
63
+ return Math.round(n * 10000) / 10000;
64
+ }
@@ -0,0 +1,203 @@
1
+ import { type ComponentPropsWithoutRef, type ElementType, type ReactElement, type ReactNode } from "react";
2
+ import { type TextAlign, type TextLines } from "./textBox.js";
3
+ import type { Passthrough } from "./props.js";
4
+ import { type LoadingProps } from "./skeleton.js";
5
+ import type { Size } from "./size.js";
6
+ import type { Tone } from "./tone.js";
7
+ export type { TextAlign, TextLines } from "./textBox.js";
8
+ /**
9
+ * The meaning of a run of inline text: the library's `Tone`, plus `muted` for a quieter line and
10
+ * `accent` for the theme's accent ink. `neutral` (the default) is the role's own ink. Colour alone
11
+ * does not say a meaning, so the words do too.
12
+ */
13
+ export type TextTone = Tone | "muted" | "accent";
14
+ /** Tone → text utility, for every tone that is not the role's own ink. Shared with `Table`'s cells. */
15
+ export declare const TEXT_TONE: Record<Exclude<TextTone, "neutral">, string>;
16
+ /** The utility of a tone, or none for `neutral` (and no tone), which keeps the role's own ink. */
17
+ export declare function textToneClass(tone: TextTone | undefined): string | undefined;
18
+ /**
19
+ * Own props shared by every typography component; the rest follow the rendered element. While
20
+ * `loading` with no `children`, a heading draws one bone at its line height, a paragraph three
21
+ * lines of bones and an inline run one word-sized bone.
22
+ */
23
+ type OwnProps = {
24
+ children?: ReactNode;
25
+ } & LoadingProps;
26
+ /** The opt-in props of the inline roles (`Text`, `Caption`, `Overline`). */
27
+ type InlineOwnProps = {
28
+ /**
29
+ * The ink: `neutral`, the default, is the role's own; `muted` and `accent` set the hierarchy of
30
+ * the text; `positive`, `warn`, `danger` and `info` say what a run means (see `TextTone`).
31
+ */
32
+ tone?: TextTone | undefined;
33
+ /** Tabular figures, so a column of amounts lines up. */
34
+ numeric?: boolean | undefined;
35
+ /** The monospace face, for an id, a path or a command. */
36
+ mono?: boolean | undefined;
37
+ /**
38
+ * Set the text at `start`, `center` or `end` of its block. The run becomes block-level, so the
39
+ * alignment has a box to act on (a table header cell, a right-hand column).
40
+ */
41
+ align?: TextAlign | undefined;
42
+ };
43
+ /** The opt-in props of `Text` and `Caption` only: the face of the run, not a label's. */
44
+ type RunOwnProps = {
45
+ /**
46
+ * Show at most this many lines (1 to 4) and end in an ellipsis: `1` cuts the run where its
47
+ * container ends, `2` to `4` wrap and stop. With plain-text content the full text becomes the
48
+ * `title`. A "Show all" toggle is the app's own state: `lines={open ? undefined : 3}`.
49
+ */
50
+ lines?: TextLines | undefined;
51
+ /** Italic: a muted hint or a caption. */
52
+ italic?: boolean | undefined;
53
+ /** Break a long unbroken string (a URL, a token) where the container ends, instead of overflowing. */
54
+ breakWords?: boolean | undefined;
55
+ };
56
+ type Own = OwnProps & InlineOwnProps;
57
+ /** Polymorphic props: own props + `as` + the intrinsic props of whichever element `as` selects. */
58
+ type TypographyProps<E extends ElementType> = OwnProps & {
59
+ /** The element to render (each role has a semantic default); the other props follow it. */
60
+ as?: E;
61
+ } & Omit<ComponentPropsWithoutRef<E>, keyof OwnProps | "as" | "className" | "style" | "color">;
62
+ /**
63
+ * The props of an inline role: `TypographyProps` plus `tone`, `numeric`, `mono` and `align`.
64
+ * Spelled out like `TypographyProps`, not as an `Omit` of it, so the docs read its real types.
65
+ */
66
+ export type InlineTypographyProps<E extends ElementType> = Own & {
67
+ /** The element to render (each role has a semantic default); the other props follow it. */
68
+ as?: E;
69
+ } & Omit<ComponentPropsWithoutRef<E>, keyof Own | "as" | "className" | "style" | "color">;
70
+ /**
71
+ * Marketing-scale headline: the one line at the top of a public page. `h1`,
72
+ * text-4xl/tight semibold, primary text, growing to text-6xl on wider screens.
73
+ * `PageHeading` is the title of an ordinary page, a step below; a brochure hero needs a display
74
+ * scale, so it gets its own pinned role rather than callers overriding PageHeading's size.
75
+ */
76
+ export declare const Display: {
77
+ <E extends ElementType = "h1">(props: TypographyProps<E>): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
78
+ displayName: string;
79
+ };
80
+ /** The supporting sentence under a `Display`. `p`, text-lg/7 normal, secondary. */
81
+ export declare const Lead: {
82
+ <E extends ElementType = "p">(props: TypographyProps<E>): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
83
+ displayName: string;
84
+ };
85
+ /**
86
+ * Page title. `h1`, text-3xl/9 bold (text-4xl/10 from `sm`), tight, primary text: well above the
87
+ * `Lead` under it and the body text after it, so the page's title reads first.
88
+ */
89
+ export declare const PageHeading: {
90
+ <E extends ElementType = "h1">(props: TypographyProps<E>): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
91
+ displayName: string;
92
+ };
93
+ /** True inside a `Prose`, where the text roles take the long-form scale. Internal. */
94
+ export declare function useProse(): boolean;
95
+ /**
96
+ * Sets the text roles back to the app scale around what a component renders itself (a `Dialog`, a
97
+ * `Drawer`, an `EmptyState`), so one opened from a docs page looks as it does anywhere else.
98
+ * Renders no element. Internal: not exported from the package.
99
+ */
100
+ export declare function AppScale({ children }: {
101
+ children?: ReactNode;
102
+ }): ReactElement;
103
+ /**
104
+ * Long-form content, for a docs page or an article. A block (`div`) that sets the long line height
105
+ * (leading-7) on itself and puts the text roles inside it on the prose scale: `Text` text-base/7
106
+ * (the size it is outside, on a longer line), `SectionHeading` text-2xl/8, `SubsectionHeading` `lg` text-2xl/8,
107
+ * `md` text-xl/7 and `sm` text-base/7 (a semibold line at body size), and the box of a `Callout`
108
+ * text-base/7. Every other role keeps its size. Nothing outside a `Prose` changes, and a `Dialog`,
109
+ * `Drawer` or `EmptyState` inside one is back on the app scale. An app screen never uses it: wrap the
110
+ * body of a docs page or an article, inside a `ProseLayout`, a `SidebarLayout` or anywhere else.
111
+ * Its blocks (`Section`s, paragraphs) are a `Stack`'s gap apart, as they would be in a `Stack`.
112
+ */
113
+ export declare function Prose({ children, ...rest }: {
114
+ children?: ReactNode;
115
+ } & Passthrough): ReactElement;
116
+ /**
117
+ * Top-level section header. `h2`, text-xl/7 semibold, primary text (text-base/6 under an
118
+ * `AppShell density="compact"`, text-2xl/8 semibold tight inside a `Prose`). `rule` sets
119
+ * a hairline under it (the `Divider` line colour) with the space either side of
120
+ * the line built in. `description` is a muted line under the heading, outside the `<h2>`, so the
121
+ * heading's name stays the title; the rule then sits under the description.
122
+ */
123
+ export declare function SectionHeading<E extends ElementType = "h2">({ rule, description, ...props }: TypographyProps<E> & {
124
+ /** A hairline under the heading, with the space either side of it built in. */
125
+ rule?: boolean;
126
+ /** A muted line under the heading that says more. It is a paragraph beside the heading, not part of its name. */
127
+ description?: ReactNode;
128
+ }): ReactElement;
129
+ /** A SubsectionHeading's type size: `sm` a form-group caption, `md` a card title, `lg` a drawer title. */
130
+ export type SubsectionHeadingSize = Size;
131
+ /**
132
+ * Nested header. `h3`, text-lg/7 semibold, primary text. `size` steps it down to `sm` (text-base,
133
+ * body size set apart by its weight) for a form-group caption or a dense card, or up to `lg`
134
+ * (text-xl) for a drawer title; `md` is the default. Under an `AppShell density="compact"` each is one step down. Inside a `Prose`
135
+ * `md` is text-xl/7 (the h3 of a doc), `sm` text-base/7 (the h4: body size, set apart by its weight)
136
+ * and `lg` text-2xl/8, the size of a `SectionHeading` there. `truncate` keeps it on
137
+ * one line and cuts it with an ellipsis where its container ends, the full text as the `title`.
138
+ */
139
+ export declare function SubsectionHeading<E extends ElementType = "h3">({ size, truncate, ...props }: TypographyProps<E> & {
140
+ /**
141
+ * The heading's type size: `sm` is text-base/6, `md` text-lg/7 and `lg` text-xl/7 (one step down
142
+ * each under an `AppShell density="compact"`).
143
+ * @default md
144
+ */
145
+ size?: SubsectionHeadingSize;
146
+ /** One line, cut with an ellipsis where the container ends; the full text becomes the `title`. */
147
+ truncate?: boolean | undefined;
148
+ }): ReactElement;
149
+ /**
150
+ * Small all-caps label above a group. `span`, text-xs semibold uppercase, tertiary. `tone`,
151
+ * `numeric`, `mono` and `align` are opt-in, as on `Text`.
152
+ */
153
+ export declare const Overline: {
154
+ <E extends ElementType = "span">(props: InlineTypographyProps<E>): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
155
+ displayName: string;
156
+ };
157
+ /**
158
+ * A card title drawn as an `Overline`, in the tertiary ink or, bare, the faint one. Internal: the
159
+ * inks are the card's, never a consumer's.
160
+ */
161
+ export declare function CardOverline({ faint, level, ...props }: {
162
+ faint: boolean;
163
+ level: 2 | 3 | 4 | 5 | 6;
164
+ id?: string | undefined;
165
+ children?: ReactNode;
166
+ }): ReactElement;
167
+ /** A fixed width for a run of text: `amount` is a money figure, right-aligned, at a width that lines a column up. */
168
+ export type TextMinWidth = "amount";
169
+ /**
170
+ * Running text. A paragraph (`p`; `as="span"` for a run inside a row, a cell or a sentence),
171
+ * text-base/6 normal, secondary (text-sm/5 under an `AppShell density="compact"`, text-base/7 inside
172
+ * a `Prose`). A block of it
173
+ * stops at a readable line length (`max-w-[72ch]`), wherever it sits. `strong` emphasises it:
174
+ * font-medium in the primary ink, unless `tone` says otherwise.
175
+ * `preserveNewlines` keeps the line breaks in the text (a user-typed note); runs of spaces still collapse.
176
+ * `tone` colours it by meaning (`positive` for "Saved.", `danger` for an error, `muted` for a quieter line),
177
+ * `numeric` sets tabular figures, `mono` the monospace face, and `lines` shows at most 1 to 4 lines,
178
+ * ending in an ellipsis (the full text becomes its `title`). `align` sets it at `start`, `center` or `end`.
179
+ * `italic` slants it, `breakWords` breaks a long unbroken string at the edge of its box, and `minWidth="amount"`
180
+ * fixes a width and right-aligns the figure in it (a column of amounts lines up); it does not take `align`.
181
+ */
182
+ export declare function Text<E extends ElementType = "p">({ strong, preserveNewlines, minWidth, italic, breakWords, ...props }: InlineTypographyProps<E> & RunOwnProps & {
183
+ /** Emphasis: font-medium in the primary ink (`tone` still wins). */
184
+ strong?: boolean | undefined;
185
+ /** Keep the line breaks in the text (a user-typed note); runs of spaces still collapse. */
186
+ preserveNewlines?: boolean;
187
+ /** A fixed width: `amount` is a right-aligned money figure, min-w-24, in tabular figures. */
188
+ minWidth?: TextMinWidth | undefined;
189
+ }): ReactElement;
190
+ /**
191
+ * The supporting line under a `Dialog` title: `Text` without the measure, so
192
+ * it runs the width of its dialog. Internal; not exported from the package.
193
+ */
194
+ export declare function HeaderText({ children }: {
195
+ children: ReactNode;
196
+ }): ReactElement;
197
+ /**
198
+ * Fine print / metadata. A paragraph (`p`; `as="span"` inline), text-sm/5 normal, tertiary
199
+ * (text-xs/4 under an `AppShell density="compact"`). Takes `tone`,
200
+ * `numeric`, `mono`, `lines` and `align` like `Text`, and `italic` for a muted hint and `breakWords`
201
+ * for a long unbroken string such as a URL.
202
+ */
203
+ export declare function Caption<E extends ElementType = "p">({ italic, breakWords, ...props }: InlineTypographyProps<E> & RunOwnProps): ReactElement;
@@ -0,0 +1,242 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Children, createContext, useContext, } from "react";
3
+ import { cx } from "./cx.js";
4
+ import { useStackGap } from "./stackGap.js";
5
+ import { useTypeStep } from "./density.js";
6
+ import { layoutClass } from "./textBox.js";
7
+ import { useTextWait } from "./skeleton.js";
8
+ /** Ink → slate utility, which a theme remaps. `faint` is the quietest, for a card's bare overline. */
9
+ const INK = {
10
+ default: "text-slate-900",
11
+ secondary: "text-slate-600",
12
+ tertiary: "text-slate-500",
13
+ faint: "text-slate-400",
14
+ };
15
+ /** Tone → text utility, for every tone that is not the role's own ink. Shared with `Table`'s cells. */
16
+ export const TEXT_TONE = {
17
+ muted: "text-slate-500",
18
+ accent: "text-violet-600",
19
+ info: "text-blue-700",
20
+ positive: "text-emerald-700",
21
+ warn: "text-amber-700",
22
+ danger: "text-red-700",
23
+ };
24
+ /** The utility of a tone, or none for `neutral` (and no tone), which keeps the role's own ink. */
25
+ export function textToneClass(tone) {
26
+ return tone === undefined || tone === "neutral" ? undefined : TEXT_TONE[tone];
27
+ }
28
+ /**
29
+ * Build a semantic component that pins `variantClass` (size + weight + tracking)
30
+ * and an ink. The scale/weight for each role therefore lives in exactly
31
+ * one place (the call below), and callers can only vary the element (and, on an inline role, the
32
+ * tone), never the pinned size, weight or ink, and never with a class.
33
+ */
34
+ function typography(displayName, defaultAs, variantClass, ink) {
35
+ function Typography(props) {
36
+ return pinned(defaultAs, variantClass, ink, props);
37
+ }
38
+ Typography.displayName = displayName;
39
+ return Typography;
40
+ }
41
+ /** `typography` for the inline roles, which also take `tone`, `numeric`, `mono` and `align`. */
42
+ function inlineRole(displayName, defaultAs, variantClass, ink) {
43
+ function Inline(props) {
44
+ return pinned(defaultAs, variantClass, ink, props);
45
+ }
46
+ Inline.displayName = displayName;
47
+ return Inline;
48
+ }
49
+ /**
50
+ * The one place a pinned role renders. The few roles with an opt-in prop of their own are
51
+ * written by hand, not by `typography`, and call this too.
52
+ */
53
+ function pinned(defaultAs, variantClass, ink, { as, tone, numeric, mono, lines, align, loading, loadingLabel, children, ...rest }) {
54
+ const Tag = as ?? defaultAs;
55
+ const wait = useTextWait(Tag, { loading, loadingLabel, children });
56
+ return (_jsx(Tag, { ...rest, ...wait.attrs, ...(lines && !wait.bones ? { title: rest.title ?? plainText(children) } : {}), className: cx(variantClass, textToneClass(tone) ?? INK[ink], numeric && "tabular-nums", mono && "font-mono", layoutClass(align, lines)), children: wait.body }));
57
+ }
58
+ /** The text of `children` when it is all strings and numbers: what a truncated run shows on hover. */
59
+ function plainText(children) {
60
+ const parts = Children.toArray(children);
61
+ return parts.every((part) => typeof part === "string" || typeof part === "number")
62
+ ? parts.join("")
63
+ : undefined;
64
+ }
65
+ // --- Structural roles (block by default) -----------------------------------
66
+ /**
67
+ * Marketing-scale headline: the one line at the top of a public page. `h1`,
68
+ * text-4xl/tight semibold, primary text, growing to text-6xl on wider screens.
69
+ * `PageHeading` is the title of an ordinary page, a step below; a brochure hero needs a display
70
+ * scale, so it gets its own pinned role rather than callers overriding PageHeading's size.
71
+ */
72
+ export const Display = typography("Display", "h1", "text-4xl/[1.1] font-semibold tracking-tight sm:text-5xl/[1.05] lg:text-6xl/[1.05]", "default");
73
+ /** The supporting sentence under a `Display`. `p`, text-lg/7 normal, secondary. */
74
+ export const Lead = typography("Lead", "p", "text-lg/7 font-normal sm:text-xl/8", "secondary");
75
+ /**
76
+ * Page title. `h1`, text-3xl/9 bold (text-4xl/10 from `sm`), tight, primary text: well above the
77
+ * `Lead` under it and the body text after it, so the page's title reads first.
78
+ */
79
+ export const PageHeading = typography("PageHeading", "h1", "text-3xl/9 font-bold tracking-tight sm:text-4xl/10", "default");
80
+ // --- Prose: the long-form scale ---------------------------------------------
81
+ /**
82
+ * Whether the text roles below are in a `Prose`. `Text`, `SectionHeading`, `SubsectionHeading` and
83
+ * `Callout` read it and pick their prose size; outside a `Prose` it is false and nothing changes.
84
+ * Internal: not exported from the package.
85
+ */
86
+ const ProseContext = createContext(false);
87
+ /** True inside a `Prose`, where the text roles take the long-form scale. Internal. */
88
+ export function useProse() {
89
+ return useContext(ProseContext);
90
+ }
91
+ /**
92
+ * Sets the text roles back to the app scale around what a component renders itself (a `Dialog`, a
93
+ * `Drawer`, an `EmptyState`), so one opened from a docs page looks as it does anywhere else.
94
+ * Renders no element. Internal: not exported from the package.
95
+ */
96
+ export function AppScale({ children }) {
97
+ return _jsx(ProseContext.Provider, { value: false, children: children });
98
+ }
99
+ /**
100
+ * The space between a `Prose`'s blocks: a `Stack`'s gap where it sits (`md` on a page, `xs` in a
101
+ * `Card`), as a top margin on every block after the first. A margin and not a flex gap, so text and
102
+ * links written straight into a `Prose` stay one line.
103
+ */
104
+ const PROSE_FLOW = {
105
+ xs: "*:not-first:mt-2",
106
+ sm: "*:not-first:mt-4",
107
+ md: "*:not-first:mt-6",
108
+ lg: "*:not-first:mt-8",
109
+ xl: "*:not-first:mt-12 sm:*:not-first:mt-16",
110
+ };
111
+ /**
112
+ * Long-form content, for a docs page or an article. A block (`div`) that sets the long line height
113
+ * (leading-7) on itself and puts the text roles inside it on the prose scale: `Text` text-base/7
114
+ * (the size it is outside, on a longer line), `SectionHeading` text-2xl/8, `SubsectionHeading` `lg` text-2xl/8,
115
+ * `md` text-xl/7 and `sm` text-base/7 (a semibold line at body size), and the box of a `Callout`
116
+ * text-base/7. Every other role keeps its size. Nothing outside a `Prose` changes, and a `Dialog`,
117
+ * `Drawer` or `EmptyState` inside one is back on the app scale. An app screen never uses it: wrap the
118
+ * body of a docs page or an article, inside a `ProseLayout`, a `SidebarLayout` or anywhere else.
119
+ * Its blocks (`Section`s, paragraphs) are a `Stack`'s gap apart, as they would be in a `Stack`.
120
+ */
121
+ export function Prose({ children, ...rest }) {
122
+ const flow = PROSE_FLOW[useStackGap(undefined)];
123
+ return (_jsx(ProseContext.Provider, { value: true, children: _jsx("div", { ...rest, className: cx("leading-7", flow), children: children }) }));
124
+ }
125
+ const SECTION = {
126
+ app: "text-xl/7 font-semibold",
127
+ compact: "text-base/6 font-semibold",
128
+ prose: "text-2xl/8 font-semibold tracking-tight",
129
+ };
130
+ /** The class of a role on the scale in force: the Prose one inside a `Prose`, else the type step's. */
131
+ function useScale(scale) {
132
+ const prose = useProse();
133
+ const step = useTypeStep();
134
+ if (prose)
135
+ return scale.prose;
136
+ return step === "compact" ? scale.compact : scale.app;
137
+ }
138
+ /** The offset an anchored heading keeps from the top, so the sticky header does not cover it. */
139
+ const SCROLL_TARGET = "scroll-mt-[calc(var(--app-header,0px)+1rem)]";
140
+ /**
141
+ * Top-level section header. `h2`, text-xl/7 semibold, primary text (text-base/6 under an
142
+ * `AppShell density="compact"`, text-2xl/8 semibold tight inside a `Prose`). `rule` sets
143
+ * a hairline under it (the `Divider` line colour) with the space either side of
144
+ * the line built in. `description` is a muted line under the heading, outside the `<h2>`, so the
145
+ * heading's name stays the title; the rule then sits under the description.
146
+ */
147
+ export function SectionHeading({ rule, description, ...props }) {
148
+ const hairline = "mb-4 border-b border-slate-200/70 pb-2";
149
+ const size = useScale(SECTION);
150
+ const hasDescription = description != null && description !== false;
151
+ // An `id` makes the heading a link target, so an anchor jump leaves it clear of the sticky header.
152
+ const scroll = props.id === undefined ? undefined : SCROLL_TARGET;
153
+ if (!hasDescription) {
154
+ return pinned("h2", cx(rule && hairline, size, scroll), "default", props);
155
+ }
156
+ return (_jsxs("div", { className: cx("flex flex-col gap-1", rule && hairline), children: [pinned("h2", cx(size, scroll), "default", props), _jsx(Text, { tone: "muted", children: description })] }));
157
+ }
158
+ const SUBSECTION_SIZE = {
159
+ sm: {
160
+ app: "text-base/6 font-semibold",
161
+ compact: "text-sm/5 font-semibold",
162
+ prose: "text-base/7 font-semibold",
163
+ },
164
+ md: {
165
+ app: "text-lg/7 font-semibold",
166
+ compact: "text-base/6 font-semibold",
167
+ prose: "text-xl/7 font-semibold",
168
+ },
169
+ lg: {
170
+ app: "text-xl/7 font-semibold",
171
+ compact: "text-lg/7 font-semibold",
172
+ prose: "text-2xl/8 font-semibold tracking-tight",
173
+ },
174
+ };
175
+ /**
176
+ * Nested header. `h3`, text-lg/7 semibold, primary text. `size` steps it down to `sm` (text-base,
177
+ * body size set apart by its weight) for a form-group caption or a dense card, or up to `lg`
178
+ * (text-xl) for a drawer title; `md` is the default. Under an `AppShell density="compact"` each is one step down. Inside a `Prose`
179
+ * `md` is text-xl/7 (the h3 of a doc), `sm` text-base/7 (the h4: body size, set apart by its weight)
180
+ * and `lg` text-2xl/8, the size of a `SectionHeading` there. `truncate` keeps it on
181
+ * one line and cuts it with an ellipsis where its container ends, the full text as the `title`.
182
+ */
183
+ export function SubsectionHeading({ size = "md", truncate, ...props }) {
184
+ return pinned("h3", useScale(SUBSECTION_SIZE[size]), "default", {
185
+ ...props,
186
+ lines: truncate ? 1 : undefined,
187
+ });
188
+ }
189
+ // --- Inline roles -------------------------------------------------------------
190
+ const OVERLINE = "text-xs font-semibold uppercase tracking-wide";
191
+ /**
192
+ * Small all-caps label above a group. `span`, text-xs semibold uppercase, tertiary. `tone`,
193
+ * `numeric`, `mono` and `align` are opt-in, as on `Text`.
194
+ */
195
+ export const Overline = inlineRole("Overline", "span", OVERLINE, "tertiary");
196
+ /**
197
+ * A card title drawn as an `Overline`, in the tertiary ink or, bare, the faint one. Internal: the
198
+ * inks are the card's, never a consumer's.
199
+ */
200
+ export function CardOverline({ faint, level, ...props }) {
201
+ return pinned(`h${level}`, OVERLINE, faint ? "faint" : "tertiary", props);
202
+ }
203
+ /**
204
+ * Running text. A paragraph (`p`; `as="span"` for a run inside a row, a cell or a sentence),
205
+ * text-base/6 normal, secondary (text-sm/5 under an `AppShell density="compact"`, text-base/7 inside
206
+ * a `Prose`). A block of it
207
+ * stops at a readable line length (`max-w-[72ch]`), wherever it sits. `strong` emphasises it:
208
+ * font-medium in the primary ink, unless `tone` says otherwise.
209
+ * `preserveNewlines` keeps the line breaks in the text (a user-typed note); runs of spaces still collapse.
210
+ * `tone` colours it by meaning (`positive` for "Saved.", `danger` for an error, `muted` for a quieter line),
211
+ * `numeric` sets tabular figures, `mono` the monospace face, and `lines` shows at most 1 to 4 lines,
212
+ * ending in an ellipsis (the full text becomes its `title`). `align` sets it at `start`, `center` or `end`.
213
+ * `italic` slants it, `breakWords` breaks a long unbroken string at the edge of its box, and `minWidth="amount"`
214
+ * fixes a width and right-aligns the figure in it (a column of amounts lines up); it does not take `align`.
215
+ */
216
+ export function Text({ strong, preserveNewlines, minWidth, italic, breakWords, ...props }) {
217
+ const scale = useScale(TEXT);
218
+ return pinned("p", cx(textVariant(strong, preserveNewlines, true, scale), italic && "italic", breakWords && "break-words", minWidth === "amount" && "inline-block min-w-24 text-end"), strong ? "default" : "secondary",
219
+ // An amount is always in tabular figures, so it lines up; `numeric` already emits them.
220
+ { ...props, numeric: props.numeric || minWidth === "amount" });
221
+ }
222
+ /**
223
+ * The supporting line under a `Dialog` title: `Text` without the measure, so
224
+ * it runs the width of its dialog. Internal; not exported from the package.
225
+ */
226
+ export function HeaderText({ children }) {
227
+ return pinned("p", textVariant(false, false, false, useScale(TEXT)), "secondary", { children });
228
+ }
229
+ const TEXT = { app: "text-base/6", compact: "text-sm/5", prose: "text-base/7" };
230
+ function textVariant(strong, preserveNewlines, measure, size) {
231
+ return cx(preserveNewlines && "whitespace-pre-line", measure && "max-w-[72ch]", size, strong ? "font-medium" : "font-normal");
232
+ }
233
+ /**
234
+ * Fine print / metadata. A paragraph (`p`; `as="span"` inline), text-sm/5 normal, tertiary
235
+ * (text-xs/4 under an `AppShell density="compact"`). Takes `tone`,
236
+ * `numeric`, `mono`, `lines` and `align` like `Text`, and `italic` for a muted hint and `breakWords`
237
+ * for a long unbroken string such as a URL.
238
+ */
239
+ export function Caption({ italic, breakWords, ...props }) {
240
+ const size = useTypeStep() === "compact" ? "text-xs/4" : "text-sm/5";
241
+ return pinned("p", cx(size, "font-normal", italic && "italic", breakWords && "break-words"), "tertiary", props);
242
+ }
@@ -0,0 +1,19 @@
1
+ import { type RefObject } from "react";
2
+ /**
3
+ * Whether the picture at `src` has failed to load, for `Avatar` and `Image`, which swap a failed
4
+ * picture for a fallback. A new `src` gets its own try, so a broken one never sticks.
5
+ *
6
+ * A failure is caught two ways. `markFailed` is the img's `onError`, for a picture that fails
7
+ * after React has attached. On a server-rendered page the browser can fail the picture before
8
+ * hydration, when the `error` event is already gone, so once the img mounts it is checked as well:
9
+ * finished (`complete`) with no width (`naturalWidth` 0) means it failed. A picture still loading
10
+ * or already loaded is left alone.
11
+ */
12
+ export declare function useImageFailed(src: string | undefined): {
13
+ /** Pass to the <img>. */
14
+ ref: RefObject<HTMLImageElement | null>;
15
+ /** True when there is no `src`, or this `src` has failed. */
16
+ failed: boolean;
17
+ /** Pass to the <img>'s `onError`. */
18
+ markFailed: () => void;
19
+ };