@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,88 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Children, createContext, useContext, } from "react";
3
+ import { cx } from "./cx.js";
4
+ const LoadingContext = createContext(false);
5
+ /** Whether a part is loading (its own prop, else its ancestors'), and whether it owns the wait. */
6
+ export function useLoading(own) {
7
+ const inherited = useContext(LoadingContext);
8
+ return { loading: own ?? inherited, owner: own === true };
9
+ }
10
+ /** Passes `loading` down to every part inside. Renders no element. */
11
+ export function LoadingScope({ loading, children, }) {
12
+ return _jsx(LoadingContext.Provider, { value: loading, children: children });
13
+ }
14
+ /**
15
+ * A slot with nothing in it: `null`, `undefined`, `false`, an empty string or an empty array. A
16
+ * number is a value, `0` included.
17
+ */
18
+ export function isEmptySlot(value) {
19
+ return Children.toArray(value).every((part) => part === "");
20
+ }
21
+ /** The owner's root attribute: `aria-busy` while it waits, nothing otherwise. */
22
+ export function busy(owner, loading) {
23
+ return owner && loading ? { "aria-busy": true } : {};
24
+ }
25
+ /** The owner's one visually hidden announcement. Renders nothing for a part that inherits. */
26
+ export function BusyLabel({ owner, loading, label, }) {
27
+ if (!owner || !loading)
28
+ return null;
29
+ return _jsx("span", { className: "sr-only", children: label ?? "Loading" });
30
+ }
31
+ /**
32
+ * One bone: the skeleton colour, pulsing unless the reader asked for less motion, hidden from
33
+ * assistive tech. `shape` is its size and corners, chosen by the part that draws it.
34
+ */
35
+ export function Bone({ shape }) {
36
+ return (_jsx("span", { "aria-hidden": "true", "data-skeleton": "", className: cx("bg-slate-200 motion-safe:animate-pulse", shape) }));
37
+ }
38
+ const WIDTH = {
39
+ full: "w-full",
40
+ "3/4": "w-3/4",
41
+ "3/5": "w-3/5",
42
+ "1/2": "w-1/2",
43
+ "1/3": "w-1/3",
44
+ };
45
+ /**
46
+ * Lines of text bones, each a rounded bar inside its own line height, so they take the room the
47
+ * text would. The last of several is shorter, as a paragraph's last line is.
48
+ */
49
+ export function BoneLines({ count = 3, width = "full", }) {
50
+ return (_jsx("span", { "aria-hidden": "true", className: "flex flex-col gap-[0.4lh] py-[0.2lh]", children: Array.from({ length: count }, (_, i) => (_jsx(Bone, { shape: cx("block h-[0.6lh] rounded", count > 1 && i === count - 1 ? "w-3/5" : WIDTH[width]) }, i))) }));
51
+ }
52
+ /** One word-sized bone inside a line of text: a figure, a name, a label not here yet. */
53
+ function InlineBone({ wide = false }) {
54
+ return _jsx(Bone, { shape: cx("inline-block h-[0.6lh] rounded align-middle", wide ? "w-28" : "w-16") });
55
+ }
56
+ /** The bones of a text role with nothing in it yet, shaped by its element. */
57
+ function TextBones({ tag }) {
58
+ if (tag === "span")
59
+ return _jsx(InlineBone, {});
60
+ if (typeof tag === "string" && /^h[1-6]$/.test(tag))
61
+ return _jsx(BoneLines, { count: 1, width: "1/2" });
62
+ return _jsx(BoneLines, {});
63
+ }
64
+ /**
65
+ * A text role's wait: its root's `aria-busy`, and what it holds (its children, or bones of its
66
+ * element's shape when it has none yet, then the owner's label). `bones` says which.
67
+ */
68
+ export function useTextWait(tag, { loading: own, loadingLabel, children }) {
69
+ const { loading, owner } = useLoading(own);
70
+ const bones = loading && isEmptySlot(children);
71
+ return {
72
+ attrs: busy(owner, loading),
73
+ bones,
74
+ body: (_jsxs(_Fragment, { children: [bones ? _jsx(TextBones, { tag: tag }) : children, _jsx(BusyLabel, { owner: owner, loading: loading, label: loadingLabel })] })),
75
+ };
76
+ }
77
+ /**
78
+ * A part that is all bone while it waits (a count, a pill with no text yet): a root carrying the
79
+ * part's passthrough props and the owner's `aria-busy`, the one bone, and the owner's label.
80
+ */
81
+ export function WaitingBone({ own, label, shape, root, attrs, }) {
82
+ const { loading, owner } = useLoading(own);
83
+ return (_jsxs("span", { ...attrs, ...busy(owner, loading), className: root, children: [_jsx(Bone, { shape: shape }), _jsx(BusyLabel, { owner: owner, loading: loading, label: label })] }));
84
+ }
85
+ /** The `id`, `data-*` and `aria-*` of a part's props: what its root takes through. */
86
+ export function passthroughOf(props) {
87
+ return Object.fromEntries(Object.entries(props).filter(([key]) => key === "id" || /^(?:data|aria)-/.test(key)));
88
+ }
@@ -0,0 +1,9 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ import type { StackGap } from "./Stack.js";
3
+ /** Sets the gap of a `Stack` inside it that names none. */
4
+ export declare function GapProvider({ gap, children, }: {
5
+ gap: StackGap;
6
+ children: ReactNode;
7
+ }): ReactElement;
8
+ /** A `Stack`'s gap: its own, else its container's, else `md`. */
9
+ export declare function useStackGap(gap: StackGap | undefined): StackGap;
@@ -0,0 +1,16 @@
1
+ import { createContext, createElement, useContext } from "react";
2
+ /**
3
+ * The gap a `Stack` or `Section` takes when it sets none, from the container it sits in: a `Card`,
4
+ * `Dialog`, `Drawer`, `BottomSheet`, `Callout` or `ListRow` sets `xs`, and at page level there is
5
+ * none, so it is `md`. Internal: not exported from the package.
6
+ */
7
+ const GapContext = createContext(undefined);
8
+ /** Sets the gap of a `Stack` inside it that names none. */
9
+ export function GapProvider({ gap, children, }) {
10
+ return createElement(GapContext.Provider, { value: gap }, children);
11
+ }
12
+ /** A `Stack`'s gap: its own, else its container's, else `md`. */
13
+ export function useStackGap(gap) {
14
+ const container = useContext(GapContext);
15
+ return gap ?? container ?? "md";
16
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * A column that stays in view as the page scrolls (`SidebarLayout`'s rail from `md`, `DetailLayout`'s
3
+ * aside from `lg` when asked). The `<aside>` sticks directly under AppShell's header (`--app-header`,
4
+ * as `StickyBar` does; 0 outside a shell) and is as tall as its content. A sticky `top` also pushes a
5
+ * column that starts above it down, so it is exactly the header and no gap: a gap would move a rail
6
+ * rendered at the top of its box. Inside it the scroller is capped at the viewport less the header
7
+ * and 2rem (the room the Container's `py-8` leaves at the page's end, so the column is never pushed
8
+ * up under the header there), so a column taller than that scrolls itself and its end stays
9
+ * reachable. `overflow` clips, which would cut a keyboard focus ring (an outline 4px out) at the
10
+ * scroller's edges, so it is padded 4px (`p-1`) and pulled back out by the same (`-m-1`): the ring
11
+ * has room and the column stays on the page's edges. Each variant is written out whole, so Tailwind
12
+ * sees every class.
13
+ */
14
+ export declare const STICKY_ASIDE_MD = "md:sticky md:top-[var(--app-header,0px)] md:self-start";
15
+ export declare const STICKY_SCROLL_MD = "md:-m-1 md:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] md:overflow-y-auto md:p-1";
16
+ /**
17
+ * The thin themed scrollbar (`themedScrollbar` in `cx.ts`) on a rail's scroller from `md`, where it
18
+ * scrolls, instead of the heavy native one with arrow buttons. Its thumb is the scroller's own text
19
+ * colour, so the rail's real ink goes back on an inner box (`STICKY_INK_MD`), the colour the shell
20
+ * gives every page.
21
+ */
22
+ export declare const STICKY_BAR_MD = "md:text-slate-400 md:[scrollbar-width:thin] md:[scrollbar-color:currentColor_transparent]";
23
+ export declare const STICKY_INK_MD = "md:text-slate-900";
24
+ export declare const STICKY_ASIDE_LG = "lg:sticky lg:top-[var(--app-header,0px)] lg:self-start";
25
+ export declare const STICKY_SCROLL_LG = "lg:-m-1 lg:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] lg:overflow-y-auto lg:p-1";
26
+ export declare const STICKY_ASIDE_XL = "xl:sticky xl:top-[var(--app-header,0px)] xl:self-start";
27
+ export declare const STICKY_SCROLL_XL = "xl:-m-1 xl:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] xl:overflow-y-auto xl:p-1";
28
+ /**
29
+ * While a sticky column's scroller has more to scroll to on a side, that edge fades out (a mask, so
30
+ * it follows any theme), the way AppShell's header row does. `useScrollEdges` sets `data-more-start`
31
+ * / `data-more-end` (and `data-more` for either); a column that fits has none and is untouched.
32
+ * Each is prefixed with its breakpoint, below which the column neither sticks nor scrolls and gets
33
+ * no mask. While the scroller itself holds the keyboard's tab stop (`focus-visible`) the mask is
34
+ * off, since it would hide the focus ring (an outline) at the faded edges.
35
+ */
36
+ export declare const STICKY_FADE_MD = "md:data-more-start:[--fade-start:1.5rem] md:data-more-end:[--fade-end:1.5rem] md:data-more:[mask-image:linear-gradient(to_bottom,transparent,#000_var(--fade-start,0px),#000_calc(100%_-_var(--fade-end,0px)),transparent)] md:data-more:focus-visible:[mask-image:none]";
37
+ export declare const STICKY_FADE_LG = "lg:data-more-start:[--fade-start:1.5rem] lg:data-more-end:[--fade-end:1.5rem] lg:data-more:[mask-image:linear-gradient(to_bottom,transparent,#000_var(--fade-start,0px),#000_calc(100%_-_var(--fade-end,0px)),transparent)] lg:data-more:focus-visible:[mask-image:none]";
38
+ export declare const STICKY_FADE_XL = "xl:data-more-start:[--fade-start:1.5rem] xl:data-more-end:[--fade-end:1.5rem] xl:data-more:[mask-image:linear-gradient(to_bottom,transparent,#000_var(--fade-start,0px),#000_calc(100%_-_var(--fade-end,0px)),transparent)] xl:data-more:focus-visible:[mask-image:none]";
@@ -0,0 +1,38 @@
1
+ /**
2
+ * A column that stays in view as the page scrolls (`SidebarLayout`'s rail from `md`, `DetailLayout`'s
3
+ * aside from `lg` when asked). The `<aside>` sticks directly under AppShell's header (`--app-header`,
4
+ * as `StickyBar` does; 0 outside a shell) and is as tall as its content. A sticky `top` also pushes a
5
+ * column that starts above it down, so it is exactly the header and no gap: a gap would move a rail
6
+ * rendered at the top of its box. Inside it the scroller is capped at the viewport less the header
7
+ * and 2rem (the room the Container's `py-8` leaves at the page's end, so the column is never pushed
8
+ * up under the header there), so a column taller than that scrolls itself and its end stays
9
+ * reachable. `overflow` clips, which would cut a keyboard focus ring (an outline 4px out) at the
10
+ * scroller's edges, so it is padded 4px (`p-1`) and pulled back out by the same (`-m-1`): the ring
11
+ * has room and the column stays on the page's edges. Each variant is written out whole, so Tailwind
12
+ * sees every class.
13
+ */
14
+ export const STICKY_ASIDE_MD = "md:sticky md:top-[var(--app-header,0px)] md:self-start";
15
+ export const STICKY_SCROLL_MD = "md:-m-1 md:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] md:overflow-y-auto md:p-1";
16
+ /**
17
+ * The thin themed scrollbar (`themedScrollbar` in `cx.ts`) on a rail's scroller from `md`, where it
18
+ * scrolls, instead of the heavy native one with arrow buttons. Its thumb is the scroller's own text
19
+ * colour, so the rail's real ink goes back on an inner box (`STICKY_INK_MD`), the colour the shell
20
+ * gives every page.
21
+ */
22
+ export const STICKY_BAR_MD = "md:text-slate-400 md:[scrollbar-width:thin] md:[scrollbar-color:currentColor_transparent]";
23
+ export const STICKY_INK_MD = "md:text-slate-900";
24
+ export const STICKY_ASIDE_LG = "lg:sticky lg:top-[var(--app-header,0px)] lg:self-start";
25
+ export const STICKY_SCROLL_LG = "lg:-m-1 lg:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] lg:overflow-y-auto lg:p-1";
26
+ export const STICKY_ASIDE_XL = "xl:sticky xl:top-[var(--app-header,0px)] xl:self-start";
27
+ export const STICKY_SCROLL_XL = "xl:-m-1 xl:max-h-[calc(100dvh-var(--app-header,0px)-2rem)] xl:overflow-y-auto xl:p-1";
28
+ /**
29
+ * While a sticky column's scroller has more to scroll to on a side, that edge fades out (a mask, so
30
+ * it follows any theme), the way AppShell's header row does. `useScrollEdges` sets `data-more-start`
31
+ * / `data-more-end` (and `data-more` for either); a column that fits has none and is untouched.
32
+ * Each is prefixed with its breakpoint, below which the column neither sticks nor scrolls and gets
33
+ * no mask. While the scroller itself holds the keyboard's tab stop (`focus-visible`) the mask is
34
+ * off, since it would hide the focus ring (an outline) at the faded edges.
35
+ */
36
+ export const STICKY_FADE_MD = "md:data-more-start:[--fade-start:1.5rem] md:data-more-end:[--fade-end:1.5rem] md:data-more:[mask-image:linear-gradient(to_bottom,transparent,#000_var(--fade-start,0px),#000_calc(100%_-_var(--fade-end,0px)),transparent)] md:data-more:focus-visible:[mask-image:none]";
37
+ export const STICKY_FADE_LG = "lg:data-more-start:[--fade-start:1.5rem] lg:data-more-end:[--fade-end:1.5rem] lg:data-more:[mask-image:linear-gradient(to_bottom,transparent,#000_var(--fade-start,0px),#000_calc(100%_-_var(--fade-end,0px)),transparent)] lg:data-more:focus-visible:[mask-image:none]";
38
+ export const STICKY_FADE_XL = "xl:data-more-start:[--fade-start:1.5rem] xl:data-more-end:[--fade-end:1.5rem] xl:data-more:[mask-image:linear-gradient(to_bottom,transparent,#000_var(--fade-start,0px),#000_calc(100%_-_var(--fade-end,0px)),transparent)] xl:data-more:focus-visible:[mask-image:none]";
@@ -0,0 +1,93 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ import type { Passthrough } from "./props.js";
3
+ import { type DataAttributes } from "./link.js";
4
+ type Option = DataAttributes & {
5
+ label: ReactNode;
6
+ /** A small muted count after the label, part of the accessible name ("Shots 12"). */
7
+ count?: number;
8
+ /**
9
+ * A tooltip on hover and keyboard focus, read out as the option's description; on a disabled
10
+ * option it is the reason. A native `title` on a link option.
11
+ */
12
+ title?: string;
13
+ };
14
+ /** An option that is a button: it calls `onChange(value)`. */
15
+ export type SwitchButton = Option & {
16
+ /** What `value` is set to when this option is current. */
17
+ value: string;
18
+ /**
19
+ * Not chosen by click or arrow key. The button stays in the page as `aria-disabled`, so its
20
+ * `title` still shows as its tooltip and is read out.
21
+ */
22
+ disabled?: boolean;
23
+ /**
24
+ * Why this option cannot be chosen: it is disabled as `disabled` is, but the arrow keys still
25
+ * reach it (focus lands on it and chooses nothing), and the reason is its tooltip on hover,
26
+ * keyboard focus and a tap, read out as its description.
27
+ */
28
+ disabledReason?: string;
29
+ /** The id of the element this option controls (a tab's panel). */
30
+ controls?: string;
31
+ href?: undefined;
32
+ external?: undefined;
33
+ };
34
+ /**
35
+ * An option that is a link: `href`, drawn by the app's router link through `LinkProvider`. The router
36
+ * changes the page; `selected` on the item, or a `value` equal to the group's, marks the current one.
37
+ * `external` opens a new tab.
38
+ */
39
+ export type SwitchLink = Option & {
40
+ /** Marks this link current when it equals the group's `value`. */
41
+ value?: string;
42
+ /** This link is the current page. */
43
+ selected?: boolean;
44
+ disabled?: undefined;
45
+ disabledReason?: undefined;
46
+ controls?: undefined;
47
+ external?: boolean;
48
+ /** Where the option links. */
49
+ href: string;
50
+ };
51
+ /** One option of a Tabs or SegmentedControl: a button or a link, never both in one group. */
52
+ export type SwitchItem = SwitchButton | SwitchLink;
53
+ type Shared = {
54
+ /** The accessible name of the group. */
55
+ label: string;
56
+ } & Passthrough;
57
+ export type SwitchProps = Shared & ({
58
+ /** The options in order: `{ value, label }` buttons, or links (`href`), the current link marked by its `selected` or by a `value` equal to the group's. Either may carry a `count`; a button may be `disabled`. */
59
+ items: SwitchButton[];
60
+ /** The `value` of the current option; for links, an alternative to `selected` on the item. */
61
+ value: string;
62
+ /** Called with the option's `value` when one is chosen, by click or arrow key. */
63
+ onChange: (value: string) => void;
64
+ /** Every option is disabled, e.g. until the page has hydrated. */
65
+ disabled?: boolean;
66
+ } | {
67
+ /** The options in order: `{ value, label }` buttons, or links (`href`), the current link marked by its `selected` or by a `value` equal to the group's. Either may carry a `count`; a button may be `disabled`. */
68
+ items: SwitchLink[];
69
+ /** The `value` of the current option; for links, an alternative to `selected` on the item. */
70
+ value?: string;
71
+ onChange?: undefined;
72
+ disabled?: undefined;
73
+ });
74
+ type Parts = {
75
+ /** The roles of a group of buttons; a group with links is a `<nav>` instead. */
76
+ group: "tablist" | "radiogroup";
77
+ item: "tab" | "radio";
78
+ /** The vertical arrows move too, as in a radio group. */
79
+ vertical: boolean;
80
+ /** The options stack in a column: a tablist says so with `aria-orientation`. */
81
+ stacked?: boolean;
82
+ root: string;
83
+ option: (active: boolean, disabled: boolean) => string;
84
+ };
85
+ /**
86
+ * The shared body of Tabs and SegmentedControl: a row of options with one current. Buttons form a
87
+ * `tablist` or `radiogroup` with a single tab stop and arrow-key movement (the arrow focuses and
88
+ * chooses); links form a `<nav>` with `aria-current="page"` on the current one.
89
+ */
90
+ export declare function Switcher({ items, value, onChange, disabled: groupDisabled, label, parts, ...rest }: SwitchProps & {
91
+ parts: Parts;
92
+ }): ReactElement;
93
+ export {};
@@ -0,0 +1,78 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import {} from "react";
3
+ import { cx } from "./cx.js";
4
+ import { dataAttributes, renderLink } from "./link.js";
5
+ import { Tipped } from "./Tooltip.js";
6
+ import { hasReason } from "./blocked.js";
7
+ /** The index a key moves to from `at` among `count` enabled options, wrapping; -1 for a key that does not move. */
8
+ function target(key, at, count, vertical) {
9
+ if (key === "ArrowRight" || (vertical && key === "ArrowDown"))
10
+ return (at + 1) % count;
11
+ if (key === "ArrowLeft" || (vertical && key === "ArrowUp"))
12
+ return (at - 1 + count) % count;
13
+ if (key === "Home")
14
+ return 0;
15
+ if (key === "End")
16
+ return count - 1;
17
+ return -1;
18
+ }
19
+ /** The label with its count after it; the plain-space text node keeps the name "Shots 12". */
20
+ function Label({ item }) {
21
+ if (item.count === undefined)
22
+ return _jsx(_Fragment, { children: item.label });
23
+ return (_jsxs(_Fragment, { children: [item.label, " ", _jsx("span", { className: "ml-0.5 text-xs tabular-nums opacity-70", children: item.count })] }));
24
+ }
25
+ const isLinks = (items) => items.some((item) => item.href !== undefined);
26
+ const isCurrent = (item, value) => item.selected === true || (item.value !== undefined && item.value === value);
27
+ function SwitchLinkItem({ item, current, parts, }) {
28
+ return renderLink({
29
+ ...dataAttributes(item),
30
+ href: item.href,
31
+ external: item.external,
32
+ className: parts.option(current, false),
33
+ "aria-current": current ? "page" : undefined,
34
+ ...(item.title === undefined ? {} : { title: item.title }),
35
+ children: _jsx(Label, { item: item }),
36
+ });
37
+ }
38
+ /**
39
+ * The arrow keys, Home and End on a button group: focus the next option and choose it. An option
40
+ * with a reason is reached but not chosen, so the keyboard finds out why.
41
+ */
42
+ function moveByArrows(event, vertical) {
43
+ const buttons = [
44
+ ...event.currentTarget.querySelectorAll("button:not([aria-disabled=true]), button[data-hc-reason]"),
45
+ ];
46
+ const at = buttons.findIndex((button) => button === event.target);
47
+ if (at < 0)
48
+ return;
49
+ const button = buttons[target(event.key, at, buttons.length, vertical)];
50
+ if (!(button instanceof HTMLButtonElement))
51
+ return;
52
+ event.preventDefault();
53
+ button.focus();
54
+ if (!button.hasAttribute("data-hc-reason"))
55
+ button.click();
56
+ }
57
+ /**
58
+ * The shared body of Tabs and SegmentedControl: a row of options with one current. Buttons form a
59
+ * `tablist` or `radiogroup` with a single tab stop and arrow-key movement (the arrow focuses and
60
+ * chooses); links form a `<nav>` with `aria-current="page"` on the current one.
61
+ */
62
+ export function Switcher({ items, value, onChange, disabled: groupDisabled, label, parts, ...rest }) {
63
+ const root = parts.root;
64
+ if (isLinks(items)) {
65
+ return (_jsx("nav", { ...rest, "aria-label": label, className: root, children: items.map((item, index) => (_jsx(SwitchLinkItem, { item: item, current: isCurrent(item, value), parts: parts }, item.value ?? item.href ?? index))) }));
66
+ }
67
+ const off = (item) => groupDisabled === true || item.disabled === true || hasReason(item.disabledReason);
68
+ // An option with a reason stays reachable by the arrow keys, so the keyboard finds out why.
69
+ const reasoned = (item) => groupDisabled !== true && hasReason(item.disabledReason);
70
+ const enabled = items.filter((item) => !off(item));
71
+ const stop = enabled.some((item) => item.value === value) ? value : enabled[0]?.value;
72
+ return (_jsx("div", { ...rest, role: parts.group, "aria-label": label, ...(parts.stacked ? { "aria-orientation": "vertical" } : {}), ...(groupDisabled ? { "aria-disabled": true } : {}), onKeyDown: (event) => moveByArrows(event, parts.vertical), className: root, children: items.map((item) => (_jsx(Tipped, { text: hasReason(item.disabledReason) ? item.disabledReason : item.title, describes: true, tap: off(item), own: {}, children: (tip) => (_jsx("button", { ...dataAttributes(item), type: "button", role: parts.item, ...(parts.item === "tab"
73
+ ? { "aria-selected": item.value === value }
74
+ : { "aria-checked": item.value === value }), ...(item.controls === undefined ? {} : { "aria-controls": item.controls }), tabIndex: item.value === stop ? 0 : -1, ...(off(item) ? { "aria-disabled": true } : {}), ...(reasoned(item) ? { "data-hc-reason": "" } : {}), ...tip, onClick: () => {
75
+ if (!off(item))
76
+ onChange?.(item.value);
77
+ }, className: cx(parts.option(item.value === value, off(item)), off(item) && "cursor-not-allowed opacity-50"), children: _jsx(Label, { item: item }) })) }, item.value))) }));
78
+ }
@@ -0,0 +1,31 @@
1
+ import { type ReactNode } from "react";
2
+ import type { Size } from "./size.js";
3
+ /**
4
+ * What a `Table` tells the rows and cells inside it: whether it sits in a card (plain), its row
5
+ * density, and which columns its head declares numeric. Internal: not exported from the package.
6
+ */
7
+ type TableSetting = {
8
+ plain: boolean;
9
+ size: Size;
10
+ numeric: readonly boolean[];
11
+ /** How many columns the head declares, or `undefined` with no `TableHead`. */
12
+ columns: number | undefined;
13
+ };
14
+ export declare const TableContext: import("react").Context<TableSetting>;
15
+ /**
16
+ * Which columns the head declares numeric, read from the element props of the table's first head
17
+ * row (`head` and `row` are the `TableHead` and `TableRow` components). A head row drawn by an app's
18
+ * own component is not seen; its body cells then say `numeric` themselves.
19
+ */
20
+ export declare function numericColumns(children: ReactNode, head: unknown, row: unknown): boolean[];
21
+ /**
22
+ * How many columns the table has: the largest total of `colSpan`s (one each when unset) over the
23
+ * rows of its `TableHead`, read through arrays and fragments. `undefined` when there is no head;
24
+ * a head drawn by an app's own component is not seen either.
25
+ */
26
+ export declare function columnCount(children: ReactNode, head: unknown, row: unknown): number | undefined;
27
+ /** A row's cells, each told the column it starts at (counting `colSpan`). */
28
+ export declare function withColumns(children: ReactNode): ReactNode[];
29
+ /** Whether the head declared this cell's column numeric. */
30
+ export declare function useNumericColumn(): boolean;
31
+ export {};
@@ -0,0 +1,72 @@
1
+ import { Children, createContext, createElement, Fragment, isValidElement, useContext, } from "react";
2
+ export const TableContext = createContext({
3
+ plain: false,
4
+ size: "sm",
5
+ numeric: [],
6
+ columns: undefined,
7
+ });
8
+ /** The column a cell starts at, set by its `TableRow`. */
9
+ const ColumnContext = createContext(undefined);
10
+ /** The children as one flat list: arrays and fragments are opened, so a mapped or grouped list counts as its items. */
11
+ function flat(children) {
12
+ return Children.toArray(children).flatMap((child) => isValidElement(child) && child.type === Fragment
13
+ ? flat(child.props.children)
14
+ : [child]);
15
+ }
16
+ /** How many columns an element takes: its `colSpan`, else one. */
17
+ function span(props) {
18
+ return typeof props.colSpan === "number" && props.colSpan > 0 ? props.colSpan : 1;
19
+ }
20
+ /** The first child of the given component type. */
21
+ function first(children, type) {
22
+ return flat(children).find((child) => isValidElement(child) && child.type === type);
23
+ }
24
+ /**
25
+ * Which columns the head declares numeric, read from the element props of the table's first head
26
+ * row (`head` and `row` are the `TableHead` and `TableRow` components). A head row drawn by an app's
27
+ * own component is not seen; its body cells then say `numeric` themselves.
28
+ */
29
+ export function numericColumns(children, head, row) {
30
+ const headElement = first(children, head);
31
+ if (!isValidElement(headElement))
32
+ return [];
33
+ const rowElement = first(headElement.props.children, row);
34
+ if (!isValidElement(rowElement))
35
+ return [];
36
+ return flat(rowElement.props.children).flatMap((cell) => isValidElement(cell)
37
+ ? Array.from({ length: span(cell.props) }, () => cell.props.numeric === true)
38
+ : []);
39
+ }
40
+ /**
41
+ * How many columns the table has: the largest total of `colSpan`s (one each when unset) over the
42
+ * rows of its `TableHead`, read through arrays and fragments. `undefined` when there is no head;
43
+ * a head drawn by an app's own component is not seen either.
44
+ */
45
+ export function columnCount(children, head, row) {
46
+ const headElement = first(children, head);
47
+ if (!isValidElement(headElement))
48
+ return undefined;
49
+ const totals = flat(headElement.props.children)
50
+ .filter((child) => isValidElement(child) && child.type === row)
51
+ .map((rowElement) => isValidElement(rowElement)
52
+ ? flat(rowElement.props.children).reduce((sum, cell) => sum + (isValidElement(cell) ? span(cell.props) : 0), 0)
53
+ : 0);
54
+ return totals.length === 0 ? undefined : Math.max(...totals);
55
+ }
56
+ /** A row's cells, each told the column it starts at (counting `colSpan`). */
57
+ export function withColumns(children) {
58
+ let column = 0;
59
+ return flat(children).map((child) => {
60
+ if (!isValidElement(child))
61
+ return child;
62
+ const at = column;
63
+ column += span(child.props);
64
+ return createElement(ColumnContext.Provider, { key: at, value: at }, child);
65
+ });
66
+ }
67
+ /** Whether the head declared this cell's column numeric. */
68
+ export function useNumericColumn() {
69
+ const at = useContext(ColumnContext);
70
+ const { numeric } = useContext(TableContext);
71
+ return at !== undefined && numeric[at] === true;
72
+ }
@@ -0,0 +1,15 @@
1
+ import { type ReactElement, type ReactNode } from "react";
2
+ /**
3
+ * A table body's one row when it has no rows: a cell across every column the head declares, holding
4
+ * `empty` at the slot's small size. Internal to `TableBody`.
5
+ */
6
+ export declare function EmptyRow({ children }: {
7
+ children: ReactNode;
8
+ }): ReactElement;
9
+ /** The bones of a body cell: one line of text not here yet. */
10
+ export declare const CELL_BONE = "block h-[0.6lh] w-3/4 rounded";
11
+ /**
12
+ * A loading table body's rows when it has none yet: five, each with one bone cell per column the
13
+ * head declares (one across the row with no head). Internal to `TableBody`.
14
+ */
15
+ export declare function BoneRows(): ReactElement;
@@ -0,0 +1,26 @@
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext } from "react";
3
+ import { cx } from "./cx.js";
4
+ import { EmptySlot } from "./emptySlot.js";
5
+ import { TableContext } from "./tableColumns.js";
6
+ import { BODY_LINE, PAD } from "./tableRow.js";
7
+ import { Bone } from "./skeleton.js";
8
+ /**
9
+ * A table body's one row when it has no rows: a cell across every column the head declares, holding
10
+ * `empty` at the slot's small size. Internal to `TableBody`.
11
+ */
12
+ export function EmptyRow({ children }) {
13
+ const { columns, size } = useContext(TableContext);
14
+ return (_jsx("tr", { className: BODY_LINE, children: _jsx("td", { colSpan: columns ?? 1, className: cx(PAD[size].cell, "text-center"), children: _jsx(EmptySlot, { size: "sm", children: children }) }) }));
15
+ }
16
+ /** The bones of a body cell: one line of text not here yet. */
17
+ export const CELL_BONE = "block h-[0.6lh] w-3/4 rounded";
18
+ /**
19
+ * A loading table body's rows when it has none yet: five, each with one bone cell per column the
20
+ * head declares (one across the row with no head). Internal to `TableBody`.
21
+ */
22
+ export function BoneRows() {
23
+ const { columns, size } = useContext(TableContext);
24
+ const cells = Array.from({ length: columns ?? 1 }, (_, i) => i);
25
+ return (_jsx(_Fragment, { children: [0, 1, 2, 3, 4].map((row) => (_jsx("tr", { className: BODY_LINE, children: cells.map((cell) => (_jsx("td", { className: PAD[size].cell, children: _jsx(Bone, { shape: CELL_BONE }) }, cell))) }, row))) }));
26
+ }
@@ -0,0 +1,67 @@
1
+ import { type ComponentPropsWithoutRef } from "react";
2
+ import type { Size } from "./size.js";
3
+ import { type TextTone } from "./typography.js";
4
+ /** The selected row's fill, the one `ListRow` uses. */
5
+ export declare const SELECTED = "bg-violet-50 hover:bg-violet-50";
6
+ /**
7
+ * The status of a row: the Callout's tones, plus `muted`. A toned row gets a stripe on its leading
8
+ * edge and the tone's soft fill; `muted` fades the row instead, for one that matters less. The
9
+ * stripe takes the tone's text colour, which every theme already remaps, so no new palette entry.
10
+ */
11
+ export type RowTone = "neutral" | "info" | "positive" | "warn" | "danger" | "muted";
12
+ /** The row's mark: a `tone` (stripe and fill, or faded), a `stripe` alone or `emphasis`, only one of them. */
13
+ export type RowMark = {
14
+ /** The row's status: a stripe on the leading edge plus the tone's soft fill, or `muted` to fade the row. Give only one of `tone`, `stripe` and `emphasis`. */
15
+ tone?: RowTone | undefined;
16
+ /** A stripe on the leading edge in this tone, with no fill. Give only one of `tone`, `stripe` and `emphasis`. */
17
+ stripe?: undefined;
18
+ /**
19
+ * A subtotal in the body: the look of a `TableFoot` row, with strong cells, a firmer line
20
+ * above and no hover. Give only one of `tone`, `stripe` and `emphasis`.
21
+ *
22
+ * A sign row or a subtotal needs no other part.
23
+ */
24
+ emphasis?: false | undefined;
25
+ } | {
26
+ /** A stripe on the leading edge in this tone, with no fill. Give only one of `tone`, `stripe` and `emphasis`. */
27
+ stripe?: Exclude<TextTone, "neutral"> | undefined;
28
+ /** The row's status: a stripe on the leading edge plus the tone's soft fill, or `muted` to fade the row. Give only one of `tone`, `stripe` and `emphasis`. */
29
+ tone?: undefined;
30
+ /**
31
+ * A subtotal in the body: the look of a `TableFoot` row, with strong cells, a firmer line
32
+ * above and no hover. Give only one of `tone`, `stripe` and `emphasis`.
33
+ *
34
+ * A sign row or a subtotal needs no other part.
35
+ */
36
+ emphasis?: false | undefined;
37
+ } | {
38
+ /**
39
+ * A subtotal in the body: the look of a `TableFoot` row, with strong cells, a firmer line
40
+ * above and no hover. Give only one of `tone`, `stripe` and `emphasis`.
41
+ *
42
+ * A sign row or a subtotal needs no other part.
43
+ */
44
+ emphasis: boolean;
45
+ /** The row's status: a stripe on the leading edge plus the tone's soft fill, or `muted` to fade the row. Give only one of `tone`, `stripe` and `emphasis`. */
46
+ tone?: undefined;
47
+ /** A stripe on the leading edge in this tone, with no fill. Give only one of `tone`, `stripe` and `emphasis`. */
48
+ stripe?: undefined;
49
+ };
50
+ export declare const BODY_LINE: string;
51
+ /** The classes of a row: a line above in the body and the foot, the hover fill and the tone's or stripe's look in the body only. */
52
+ export declare function rowClass(section: "head" | "body" | "foot" | undefined, plain: boolean, tone: RowTone | undefined, stripe: Exclude<TextTone, "neutral"> | undefined): string;
53
+ /** The padding of a head cell, a body or foot cell, and a group row, by the table's `size`. */
54
+ export declare const PAD: Record<Size, {
55
+ head: string;
56
+ cell: string;
57
+ group: string;
58
+ }>;
59
+ export type Align = "start" | "center" | "end";
60
+ export declare const ALIGN: Record<Align, string>;
61
+ /**
62
+ * Whether a `TableRow` sits in the body (a line above, a hover fill), the foot (a firmer line above,
63
+ * strong cells) or the head or nowhere (neither).
64
+ */
65
+ export declare const SectionContext: import("react").Context<"body" | "foot" | "head" | undefined>;
66
+ /** What an element passes through (`data-*`, `aria-*`, `id`, …): the layout and the children stay the component's. */
67
+ export type Rest<Tag extends "table" | "thead" | "tbody" | "tfoot" | "tr" | "th" | "td", Own extends string = never> = Omit<ComponentPropsWithoutRef<Tag>, "className" | "style" | "children" | Own>;
@@ -0,0 +1,49 @@
1
+ import { createContext } from "react";
2
+ import { cx, liftInteractive } from "./cx.js";
3
+ import { TEXT_TONE } from "./typography.js";
4
+ // How a `TableRow` looks: its status tone, its stripe and the selected fill. Only `RowTone` is
5
+ // exported from the package.
6
+ /** The selected row's fill, the one `ListRow` uses. */
7
+ export const SELECTED = "bg-violet-50 hover:bg-violet-50";
8
+ const ROW_TONE = {
9
+ neutral: "bg-slate-50 text-slate-500",
10
+ info: "bg-blue-50 text-blue-700",
11
+ positive: "bg-emerald-50 text-emerald-700",
12
+ warn: "bg-amber-50 text-amber-700",
13
+ danger: "bg-red-50 text-red-700",
14
+ muted: "opacity-60",
15
+ };
16
+ const STRIPE = "shadow-[inset_4px_0_0_0_currentColor]";
17
+ export const BODY_LINE = cx("relative border-t border-slate-200/70", liftInteractive);
18
+ /** The classes of a row: a line above in the body and the foot, the hover fill and the tone's or stripe's look in the body only. */
19
+ export function rowClass(section, plain, tone, stripe) {
20
+ if (section === "foot")
21
+ return cx("relative border-t border-slate-300", liftInteractive);
22
+ if (section !== "body")
23
+ return cx("relative", liftInteractive);
24
+ const line = BODY_LINE;
25
+ const hover = !plain && "hover:bg-slate-50";
26
+ if (stripe !== undefined)
27
+ return cx(line, hover, TEXT_TONE[stripe], STRIPE);
28
+ if (tone === undefined)
29
+ return cx(line, hover);
30
+ if (tone === "muted")
31
+ return cx(line, hover, ROW_TONE.muted);
32
+ return cx(line, ROW_TONE[tone], STRIPE);
33
+ }
34
+ /** The padding of a head cell, a body or foot cell, and a group row, by the table's `size`. */
35
+ export const PAD = {
36
+ sm: { head: "px-4 py-2.5", cell: "px-4 py-3", group: "px-4 py-2" },
37
+ md: { head: "px-5 py-3", cell: "px-5 py-4", group: "px-5 py-2.5" },
38
+ lg: { head: "px-6 py-3.5", cell: "px-6 py-5", group: "px-6 py-3" },
39
+ };
40
+ export const ALIGN = {
41
+ start: "text-left",
42
+ center: "text-center",
43
+ end: "text-right",
44
+ };
45
+ /**
46
+ * Whether a `TableRow` sits in the body (a line above, a hover fill), the foot (a firmer line above,
47
+ * strong cells) or the head or nowhere (neither).
48
+ */
49
+ export const SectionContext = createContext(undefined);