oneslash-design-system 2.18.0 → 2.20.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 (227) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +54 -5
  3. package/dist/cases/app-shell/sidebar.d.ts +1 -0
  4. package/dist/cases/app-shell/sidebar.jsx +124 -0
  5. package/dist/cases/app-shell/top-tabs.d.ts +1 -0
  6. package/dist/cases/app-shell/top-tabs.jsx +106 -0
  7. package/dist/cases/app-shell.md +364 -0
  8. package/dist/cases/artifact-card/card.jsx +32 -6
  9. package/dist/cases/artifact-card.md +55 -7
  10. package/dist/cases/billing-page/billed-elsewhere.d.ts +1 -0
  11. package/dist/cases/billing-page/billed-elsewhere.jsx +28 -0
  12. package/dist/cases/billing-page/self-serve.d.ts +1 -0
  13. package/dist/cases/billing-page/self-serve.jsx +134 -0
  14. package/dist/cases/billing-page.md +247 -0
  15. package/dist/cases/breakdown-list/bars.d.ts +1 -0
  16. package/dist/cases/breakdown-list/bars.jsx +47 -0
  17. package/dist/cases/breakdown-list/table.d.ts +1 -0
  18. package/dist/cases/breakdown-list/table.jsx +69 -0
  19. package/dist/cases/breakdown-list.md +158 -0
  20. package/dist/cases/composer-limit/notice-with-action.jsx +3 -3
  21. package/dist/cases/composer-limit/notice.jsx +3 -3
  22. package/dist/cases/composer-limit.md +8 -8
  23. package/dist/cases/dashboard/numbers-first.d.ts +1 -0
  24. package/dist/cases/dashboard/numbers-first.jsx +165 -0
  25. package/dist/cases/dashboard/work-first.d.ts +1 -0
  26. package/dist/cases/dashboard/work-first.jsx +165 -0
  27. package/dist/cases/dashboard.md +507 -0
  28. package/dist/cases/data-table-page/all-rows.d.ts +1 -0
  29. package/dist/cases/data-table-page/all-rows.jsx +226 -0
  30. package/dist/cases/data-table-page/paged.d.ts +1 -0
  31. package/dist/cases/data-table-page/paged.jsx +284 -0
  32. package/dist/cases/data-table-page.md +771 -0
  33. package/dist/cases/error-page/in-shell.jsx +26 -17
  34. package/dist/cases/error-page.md +42 -21
  35. package/dist/cases/invoice-list/table.d.ts +1 -0
  36. package/dist/cases/invoice-list/table.jsx +64 -0
  37. package/dist/cases/invoice-list/with-upcoming.d.ts +1 -0
  38. package/dist/cases/invoice-list/with-upcoming.jsx +75 -0
  39. package/dist/cases/invoice-list.md +237 -0
  40. package/dist/cases/load-failure/inline.jsx +2 -2
  41. package/dist/cases/load-failure.md +2 -2
  42. package/dist/cases/master-detail/list-then-page.d.ts +1 -0
  43. package/dist/cases/master-detail/list-then-page.jsx +65 -0
  44. package/dist/cases/master-detail/split.d.ts +1 -0
  45. package/dist/cases/master-detail/split.jsx +49 -0
  46. package/dist/cases/master-detail.md +213 -0
  47. package/dist/cases/members-list/rows.jsx +2 -1
  48. package/dist/cases/members-list/table.jsx +8 -9
  49. package/dist/cases/members-list.md +12 -13
  50. package/dist/cases/mobile-menu/links.d.ts +1 -0
  51. package/dist/cases/mobile-menu/links.jsx +24 -0
  52. package/dist/cases/mobile-menu/sections.d.ts +1 -0
  53. package/dist/cases/mobile-menu/sections.jsx +61 -0
  54. package/dist/cases/mobile-menu.md +170 -0
  55. package/dist/cases/not-found-page/in-shell.jsx +26 -17
  56. package/dist/cases/not-found-page.md +41 -20
  57. package/dist/cases/number-format.md +36 -0
  58. package/dist/cases/on-this-page/aside.d.ts +1 -0
  59. package/dist/cases/on-this-page/aside.jsx +39 -0
  60. package/dist/cases/on-this-page.md +80 -0
  61. package/dist/cases/page-header/actions.d.ts +1 -0
  62. package/dist/cases/page-header/actions.jsx +65 -0
  63. package/dist/cases/page-header/sub-page.d.ts +1 -0
  64. package/dist/cases/page-header/sub-page.jsx +37 -0
  65. package/dist/cases/page-header.md +195 -0
  66. package/dist/cases/paged-card/pager.d.ts +1 -0
  67. package/dist/cases/paged-card/pager.jsx +41 -0
  68. package/dist/cases/paged-card/see-all.d.ts +1 -0
  69. package/dist/cases/paged-card/see-all.jsx +34 -0
  70. package/dist/cases/paged-card.md +147 -0
  71. package/dist/cases/payment-method/none.d.ts +1 -0
  72. package/dist/cases/payment-method/none.jsx +17 -0
  73. package/dist/cases/payment-method/on-file.d.ts +1 -0
  74. package/dist/cases/payment-method/on-file.jsx +92 -0
  75. package/dist/cases/payment-method.md +182 -0
  76. package/dist/cases/phone-navigation.md +32 -0
  77. package/dist/cases/plan-change-confirm/blocked.d.ts +1 -0
  78. package/dist/cases/plan-change-confirm/blocked.jsx +48 -0
  79. package/dist/cases/plan-change-confirm/downgrade.d.ts +1 -0
  80. package/dist/cases/plan-change-confirm/downgrade.jsx +52 -0
  81. package/dist/cases/plan-change-confirm/upgrade.d.ts +1 -0
  82. package/dist/cases/plan-change-confirm/upgrade.jsx +51 -0
  83. package/dist/cases/plan-change-confirm.md +261 -0
  84. package/dist/cases/plan-picker/cards.d.ts +1 -0
  85. package/dist/cases/plan-picker/cards.jsx +97 -0
  86. package/dist/cases/plan-picker/list.d.ts +1 -0
  87. package/dist/cases/plan-picker/list.jsx +103 -0
  88. package/dist/cases/plan-picker.md +297 -0
  89. package/dist/cases/range-switch/segmented.jsx +11 -7
  90. package/dist/cases/range-switch.md +16 -11
  91. package/dist/cases/route-loading/region.jsx +27 -18
  92. package/dist/cases/route-loading.md +42 -21
  93. package/dist/cases/settings-page/top-tabs.jsx +4 -3
  94. package/dist/cases/settings-page.md +5 -4
  95. package/dist/cases/side-pane/beside.d.ts +1 -0
  96. package/dist/cases/side-pane/beside.jsx +79 -0
  97. package/dist/cases/side-pane/over.d.ts +1 -0
  98. package/dist/cases/side-pane/over.jsx +58 -0
  99. package/dist/cases/side-pane.md +238 -0
  100. package/dist/cases/sidebar-nav/flat.d.ts +1 -0
  101. package/dist/cases/sidebar-nav/flat.jsx +81 -0
  102. package/dist/cases/sidebar-nav/nested.d.ts +1 -0
  103. package/dist/cases/sidebar-nav/nested.jsx +122 -0
  104. package/dist/cases/sidebar-nav.md +261 -0
  105. package/dist/cases/site-footer/columns.d.ts +1 -0
  106. package/dist/cases/site-footer/columns.jsx +51 -0
  107. package/dist/cases/site-footer/simple.d.ts +1 -0
  108. package/dist/cases/site-footer/simple.jsx +24 -0
  109. package/dist/cases/site-footer.md +133 -0
  110. package/dist/cases/site-header/links.d.ts +1 -0
  111. package/dist/cases/site-header/links.jsx +26 -0
  112. package/dist/cases/site-header/sections.d.ts +1 -0
  113. package/dist/cases/site-header/sections.jsx +64 -0
  114. package/dist/cases/site-header.md +183 -0
  115. package/dist/cases/stat-row/featured.d.ts +1 -0
  116. package/dist/cases/stat-row/featured.jsx +17 -0
  117. package/dist/cases/stat-row/tiles.d.ts +1 -0
  118. package/dist/cases/stat-row/tiles.jsx +34 -0
  119. package/dist/cases/stat-row.md +104 -0
  120. package/dist/cases/status-label/dot.d.ts +1 -0
  121. package/dist/cases/status-label/dot.jsx +39 -0
  122. package/dist/cases/status-label/text.d.ts +1 -0
  123. package/dist/cases/status-label/text.jsx +44 -0
  124. package/dist/cases/status-label.md +143 -0
  125. package/dist/cases/theme-switcher/menu.d.ts +1 -0
  126. package/dist/cases/theme-switcher/menu.jsx +47 -0
  127. package/dist/cases/theme-switcher/segmented.d.ts +1 -0
  128. package/dist/cases/theme-switcher/segmented.jsx +26 -0
  129. package/dist/cases/theme-switcher.md +149 -0
  130. package/dist/cases/upgrade-prompt/inline.jsx +4 -2
  131. package/dist/cases/upgrade-prompt/modal.jsx +2 -1
  132. package/dist/cases/upgrade-prompt.md +10 -6
  133. package/dist/cases/usage-meters/by-person.d.ts +1 -0
  134. package/dist/cases/usage-meters/by-person.jsx +72 -0
  135. package/dist/cases/usage-meters/meters.d.ts +1 -0
  136. package/dist/cases/usage-meters/meters.jsx +49 -0
  137. package/dist/cases/usage-meters/with-cap.d.ts +1 -0
  138. package/dist/cases/usage-meters/with-cap.jsx +73 -0
  139. package/dist/cases/usage-meters.md +303 -0
  140. package/dist/cases.json +1756 -172
  141. package/dist/components/appShell.d.ts +44 -0
  142. package/dist/components/appShell.jsx +121 -0
  143. package/dist/components/button.d.ts +1 -1
  144. package/dist/components/button.jsx +11 -5
  145. package/dist/components/drawer.d.ts +31 -0
  146. package/dist/components/drawer.jsx +121 -0
  147. package/dist/components/formatNumber.d.ts +25 -0
  148. package/dist/components/formatNumber.js +125 -0
  149. package/dist/components/heading.d.ts +3 -1
  150. package/dist/components/heading.jsx +2 -2
  151. package/dist/components/iconButton.jsx +12 -7
  152. package/dist/components/link.d.ts +6 -1
  153. package/dist/components/link.jsx +11 -3
  154. package/dist/components/menuItem.d.ts +7 -1
  155. package/dist/components/menuItem.jsx +4 -3
  156. package/dist/components/modal.jsx +12 -23
  157. package/dist/components/onThisPage.d.ts +29 -0
  158. package/dist/components/onThisPage.jsx +151 -0
  159. package/dist/components/pageShell.d.ts +7 -1
  160. package/dist/components/pageShell.jsx +14 -1
  161. package/dist/components/pagination.d.ts +28 -0
  162. package/dist/components/pagination.jsx +89 -0
  163. package/dist/components/popover.jsx +4 -0
  164. package/dist/components/progress.d.ts +33 -0
  165. package/dist/components/progress.jsx +50 -0
  166. package/dist/components/settingsSection.d.ts +6 -1
  167. package/dist/components/settingsSection.jsx +10 -3
  168. package/dist/components/sidePane.d.ts +32 -0
  169. package/dist/components/sidePane.jsx +128 -0
  170. package/dist/components/siteFooter.d.ts +24 -0
  171. package/dist/components/siteFooter.jsx +48 -0
  172. package/dist/components/siteHeader.d.ts +55 -0
  173. package/dist/components/siteHeader.jsx +125 -0
  174. package/dist/components/skeleton.d.ts +21 -0
  175. package/dist/components/skeleton.jsx +41 -0
  176. package/dist/components/statTile.d.ts +32 -0
  177. package/dist/components/statTile.jsx +61 -0
  178. package/dist/components/tableContainer.d.ts +5 -1
  179. package/dist/components/tableContainer.jsx +9 -1
  180. package/dist/components/tableHeaderCell.d.ts +3 -1
  181. package/dist/components/tableHeaderCell.jsx +2 -2
  182. package/dist/components/titleBar.d.ts +19 -0
  183. package/dist/components/titleBar.jsx +18 -0
  184. package/dist/index.d.ts +12 -0
  185. package/dist/index.js +12 -0
  186. package/dist/internal/overlayStack.d.ts +24 -0
  187. package/dist/internal/overlayStack.js +71 -0
  188. package/dist/internal/resize.d.ts +9 -0
  189. package/dist/internal/resize.js +31 -0
  190. package/dist/internal/scrollSpy.d.ts +24 -0
  191. package/dist/internal/scrollSpy.js +53 -0
  192. package/dist/internal/siteBrand.d.ts +6 -0
  193. package/dist/internal/siteBrand.jsx +11 -0
  194. package/dist/native-mapping.json +69 -3
  195. package/dist/stories/AppShell.stories.d.ts +15 -0
  196. package/dist/stories/AppShell.stories.jsx +137 -0
  197. package/dist/stories/Button.stories.d.ts +1 -0
  198. package/dist/stories/Button.stories.jsx +19 -1
  199. package/dist/stories/Cases.generated.stories.d.ts +45 -0
  200. package/dist/stories/Cases.generated.stories.jsx +90 -0
  201. package/dist/stories/Drawer.stories.d.ts +10 -0
  202. package/dist/stories/Drawer.stories.jsx +123 -0
  203. package/dist/stories/Link.stories.d.ts +1 -0
  204. package/dist/stories/Link.stories.jsx +8 -0
  205. package/dist/stories/OnThisPage.stories.d.ts +10 -0
  206. package/dist/stories/OnThisPage.stories.jsx +105 -0
  207. package/dist/stories/Pagination.stories.d.ts +9 -0
  208. package/dist/stories/Pagination.stories.jsx +75 -0
  209. package/dist/stories/Progress.stories.d.ts +9 -0
  210. package/dist/stories/Progress.stories.jsx +43 -0
  211. package/dist/stories/SettingsSection.stories.d.ts +1 -0
  212. package/dist/stories/SettingsSection.stories.jsx +27 -0
  213. package/dist/stories/SidePane.stories.d.ts +6 -0
  214. package/dist/stories/SidePane.stories.jsx +37 -0
  215. package/dist/stories/SiteFooter.stories.d.ts +7 -0
  216. package/dist/stories/SiteFooter.stories.jsx +63 -0
  217. package/dist/stories/SiteHeader.stories.d.ts +10 -0
  218. package/dist/stories/SiteHeader.stories.jsx +94 -0
  219. package/dist/stories/Skeleton.stories.d.ts +7 -0
  220. package/dist/stories/Skeleton.stories.jsx +27 -0
  221. package/dist/stories/StatTile.stories.d.ts +10 -0
  222. package/dist/stories/StatTile.stories.jsx +55 -0
  223. package/dist/stories/Table.stories.d.ts +1 -0
  224. package/dist/stories/Table.stories.jsx +49 -1
  225. package/dist/stories/TitleBar.stories.d.ts +7 -0
  226. package/dist/stories/TitleBar.stories.jsx +41 -0
  227. package/package.json +5 -1
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ interface SidePaneProps {
3
+ /** Names the pane and shows in its title bar */
4
+ title: string;
5
+ /** Close and Escape call it; the page then removes the pane */
6
+ onClose: () => void;
7
+ children: React.ReactNode;
8
+ /** Buttons in the title bar, before Close */
9
+ actions?: React.ReactNode;
10
+ /** The width in px from lg up. Default 24rem. */
11
+ width?: number;
12
+ /** Makes the start edge a handle that resizes the pane, by pointer or by arrow keys */
13
+ onWidthChange?: (width: number) => void;
14
+ /** The smallest width in px. Default 320. */
15
+ minWidth?: number;
16
+ /** The largest width in px. Default 60% of the window. */
17
+ maxWidth?: number;
18
+ /** The Close button's name. Default 'Close <title>'. */
19
+ closeLabel?: string;
20
+ }
21
+ /** What a ref on SidePane gets: `focus()` moves focus to the pane's title, to bring an open pane forward */
22
+ export interface SidePaneHandle {
23
+ focus(): void;
24
+ }
25
+ /**
26
+ * A pane beside the page, not over it: no scrim, the page stays usable. Focus moves to its title on
27
+ * open and back to the opener on close. Escape closes it while focus is inside and no overlay is on top.
28
+ * Escape anywhere inside the pane closes it, including an Escape that hides a tooltip or clears a field.
29
+ */
30
+ declare const SidePane: React.ForwardRefExoticComponent<SidePaneProps & React.RefAttributes<SidePaneHandle>>;
31
+ export default SidePane;
32
+ export { SidePane };
@@ -0,0 +1,128 @@
1
+ 'use client';
2
+ import React, { forwardRef, useEffect, useId, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
3
+ import { X } from 'lucide-react';
4
+ import IconButton from './iconButton';
5
+ import TitleBar from './titleBar';
6
+ import { focusRing } from './sharedStyles';
7
+ import { claimEvent, isInTopOverlay } from '../internal/overlayStack';
8
+ import { clampWidth, dragWidth, keyWidth, paneLimits } from '../internal/resize';
9
+ // useLayoutEffect warns on a server render, where it cannot run; useEffect is the same there and silent
10
+ var useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
11
+ var DEFAULT_WIDTH = 384;
12
+ /**
13
+ * A pane beside the page, not over it: no scrim, the page stays usable. Focus moves to its title on
14
+ * open and back to the opener on close. Escape closes it while focus is inside and no overlay is on top.
15
+ * Escape anywhere inside the pane closes it, including an Escape that hides a tooltip or clears a field.
16
+ */
17
+ var SidePane = forwardRef(function SidePane(_a, ref) {
18
+ var title = _a.title, onClose = _a.onClose, children = _a.children, actions = _a.actions, width = _a.width, onWidthChange = _a.onWidthChange, _b = _a.minWidth, minWidth = _b === void 0 ? 320 : _b, maxWidth = _a.maxWidth, closeLabel = _a.closeLabel;
19
+ var asideRef = useRef(null);
20
+ var titleId = useId();
21
+ var onCloseRef = useRef(onClose);
22
+ onCloseRef.current = onClose;
23
+ var focusTitle = function () { var _a; return (_a = document.getElementById(titleId)) === null || _a === void 0 ? void 0 : _a.focus(); };
24
+ useImperativeHandle(ref, function () { return ({ focus: focusTitle }); });
25
+ // Focus the title on mount, and on unmount give focus back to what had it, if focus was in the pane.
26
+ // A layout effect, so the cleanup runs while the pane is still on the page and can tell.
27
+ var returnTo = useRef(null);
28
+ var mounted = useRef(false);
29
+ useIsomorphicLayoutEffect(function () {
30
+ mounted.current = true;
31
+ var aside = asideRef.current;
32
+ var active = document.activeElement;
33
+ // StrictMode runs this twice; the second run finds focus already in the pane and keeps the opener
34
+ if (active && !(aside === null || aside === void 0 ? void 0 : aside.contains(active)))
35
+ returnTo.current = active;
36
+ focusTitle();
37
+ return function () {
38
+ mounted.current = false;
39
+ if (!(aside === null || aside === void 0 ? void 0 : aside.contains(document.activeElement)))
40
+ return;
41
+ var target = returnTo.current;
42
+ // After the commit: the opener may be in content that shows again in the same update
43
+ // (AppShell hides main beside a pane below lg). A remount in StrictMode cancels it.
44
+ queueMicrotask(function () {
45
+ if (!mounted.current)
46
+ target === null || target === void 0 ? void 0 : target.focus();
47
+ });
48
+ };
49
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
50
+ // On window, after Popover's document listener, which keeps a menu's Escape to itself
51
+ useEffect(function () {
52
+ var handleKeyDown = function (e) {
53
+ if (e.key !== 'Escape' || e.defaultPrevented)
54
+ return;
55
+ var aside = asideRef.current;
56
+ if (!aside || !aside.contains(document.activeElement) || !isInTopOverlay(aside))
57
+ return;
58
+ if (claimEvent(e))
59
+ onCloseRef.current();
60
+ };
61
+ window.addEventListener('keydown', handleKeyDown);
62
+ return function () { return window.removeEventListener('keydown', handleKeyDown); };
63
+ }, []);
64
+ var resizable = !!onWidthChange;
65
+ var sized = resizable || width !== undefined;
66
+ // The default maximum needs the window, so it is known only after mount (the server uses the width)
67
+ var _c = useState(null), windowWidth = _c[0], setWindowWidth = _c[1];
68
+ useEffect(function () {
69
+ if (!sized || maxWidth !== undefined)
70
+ return;
71
+ var update = function () { return setWindowWidth(window.innerWidth); };
72
+ update();
73
+ window.addEventListener('resize', update);
74
+ return function () { return window.removeEventListener('resize', update); };
75
+ }, [sized, maxWidth]);
76
+ var limits = maxWidth !== undefined || windowWidth !== null
77
+ ? paneLimits(minWidth, maxWidth, windowWidth !== null && windowWidth !== void 0 ? windowWidth : 0)
78
+ : { min: minWidth, max: Math.max(minWidth, width !== null && width !== void 0 ? width : DEFAULT_WIDTH) };
79
+ var current = clampWidth(width !== null && width !== void 0 ? width : DEFAULT_WIDTH, limits.min, limits.max);
80
+ var drag = useRef(null);
81
+ var endDrag = function (e) {
82
+ var _a, _b;
83
+ drag.current = null;
84
+ if ((_b = (_a = e.currentTarget).hasPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, e.pointerId))
85
+ e.currentTarget.releasePointerCapture(e.pointerId);
86
+ };
87
+ return (<aside ref={asideRef} aria-labelledby={titleId} style={sized ? { '--side-pane-width': "".concat(current, "px") } : undefined} className={"relative flex w-full min-w-0 flex-col bg-background-default lg:h-full lg:shrink-0 lg:border-l lg:border-misc-divider ".concat(sized ? 'lg:w-[var(--side-pane-width)]' : 'lg:w-[24rem]')}>
88
+ {resizable && (<div role="separator" aria-orientation="vertical" aria-valuenow={current} aria-valuemin={limits.min} aria-valuemax={limits.max} aria-label={"Resize ".concat(title)} tabIndex={0} className={"group absolute inset-y-0 left-0 z-10 w-3 -translate-x-1/2 cursor-col-resize touch-none hidden lg:block ".concat(focusRing)} onKeyDown={function (e) {
89
+ var next = keyWidth(e.key, current, limits.min, limits.max);
90
+ if (next === null)
91
+ return;
92
+ e.preventDefault();
93
+ onWidthChange(next);
94
+ }} onPointerDown={function (e) {
95
+ var _a, _b;
96
+ if (e.button !== 0)
97
+ return;
98
+ // No text selection while dragging
99
+ e.preventDefault();
100
+ (_b = (_a = e.currentTarget).setPointerCapture) === null || _b === void 0 ? void 0 : _b.call(_a, e.pointerId);
101
+ drag.current = { x: e.clientX, width: current };
102
+ }} onPointerMove={function (e) {
103
+ if (!drag.current)
104
+ return;
105
+ // The button came up somewhere the up event never reached us
106
+ if (e.buttons === 0) {
107
+ drag.current = null;
108
+ return;
109
+ }
110
+ onWidthChange(dragWidth(drag.current.width, drag.current.x, e.clientX, limits.min, limits.max));
111
+ }} onPointerUp={endDrag} onPointerCancel={endDrag} onLostPointerCapture={function () {
112
+ drag.current = null;
113
+ }}>
114
+ <div className="mx-auto h-full w-0.5 group-hover:bg-fg-secondary group-active:bg-fg-primary"/>
115
+ </div>)}
116
+ <div className="shrink-0 border-b border-misc-divider py-2 pl-4 pr-2">
117
+ <TitleBar title={title} level={2} id={titleId} actions={<>
118
+ {actions}
119
+ <IconButton color="iconOnly" state="enabled" size="medium" icon={X} ariaLabel={closeLabel !== null && closeLabel !== void 0 ? closeLabel : "Close ".concat(title)} onClick={onClose}/>
120
+ </>}/>
121
+ </div>
122
+ <div className="min-h-0 flex-1 overflow-y-auto px-4 py-4 text-body1 text-fg-primary" style={{ scrollbarWidth: 'thin' }}>
123
+ {children}
124
+ </div>
125
+ </aside>);
126
+ });
127
+ export default SidePane;
128
+ export { SidePane };
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import type { SiteBrand } from './siteHeader';
3
+ export interface SiteFooterLink {
4
+ label: string;
5
+ href: string;
6
+ /** Opens in a new tab and says so: a small icon and the hidden words '(opens in a new tab)' */
7
+ external?: boolean;
8
+ }
9
+ export interface SiteFooterColumn {
10
+ title: string;
11
+ links: SiteFooterLink[];
12
+ }
13
+ interface SiteFooterProps {
14
+ brand?: SiteBrand;
15
+ /** Titled lists of links: two across on a phone, up to four from md */
16
+ columns?: SiteFooterColumn[];
17
+ /** Links without a column: one row that wraps */
18
+ links?: SiteFooterLink[];
19
+ /** The caption line, e.g. '© 2026 Acme' */
20
+ legal?: string;
21
+ }
22
+ /** A site's footer: the brand, a `<nav aria-label="Footer">` of linked columns and a row of links, and a legal line */
23
+ export default function SiteFooter({ brand, columns, links, legal }: SiteFooterProps): React.JSX.Element;
24
+ export { SiteFooter };
@@ -0,0 +1,48 @@
1
+ 'use client';
2
+ import React, { useId } from 'react';
3
+ import Link from './link';
4
+ import { SiteBrandLink } from '../internal/siteBrand';
5
+ // Written out whole so Tailwind finds them
6
+ var columnCount = ['md:grid-cols-1', 'md:grid-cols-1', 'md:grid-cols-2', 'md:grid-cols-3', 'md:grid-cols-4'];
7
+ var FooterLink = function (_a) {
8
+ var link = _a.link;
9
+ return (<Link href={link.href} size="body2" openInNewTab={link.external} announceNewTab={link.external}>
10
+ {link.label}
11
+ </Link>);
12
+ };
13
+ /** A site's footer: the brand, a `<nav aria-label="Footer">` of linked columns and a row of links, and a legal line */
14
+ export default function SiteFooter(_a) {
15
+ var brand = _a.brand, columns = _a.columns, links = _a.links, legal = _a.legal;
16
+ var hasNav = !!(columns === null || columns === void 0 ? void 0 : columns.length) || !!(links === null || links === void 0 ? void 0 : links.length);
17
+ return (<footer className="border-t border-misc-divider bg-background-default">
18
+ <div className="mx-auto flex w-full max-w-page-wide flex-col gap-xlarge px-xlarge py-xxlarge md:px-xxlarge">
19
+ {brand && <SiteBrandLink brand={brand}/>}
20
+ {hasNav && (<nav aria-label="Footer" className="flex flex-col gap-xlarge">
21
+ {!!(columns === null || columns === void 0 ? void 0 : columns.length) && (<div className={"grid grid-cols-2 gap-x-4 gap-y-xlarge ".concat(columnCount[Math.min(columns.length, 4)])}>
22
+ {columns.map(function (column) { return (<FooterColumn key={column.title} column={column}/>); })}
23
+ </div>)}
24
+ {!!(links === null || links === void 0 ? void 0 : links.length) && (<ul className="m-0 flex list-none flex-wrap gap-x-4 gap-y-2 p-0">
25
+ {links.map(function (link) { return (<li key={link.href + link.label}>
26
+ <FooterLink link={link}/>
27
+ </li>); })}
28
+ </ul>)}
29
+ </nav>)}
30
+ {legal && <p className="m-0 text-caption text-fg-secondary">{legal}</p>}
31
+ </div>
32
+ </footer>);
33
+ }
34
+ function FooterColumn(_a) {
35
+ var column = _a.column;
36
+ var titleId = useId();
37
+ return (<div className="flex min-w-0 flex-col gap-2">
38
+ <p id={titleId} className="m-0 text-subtitle2 text-fg-primary">
39
+ {column.title}
40
+ </p>
41
+ <ul aria-labelledby={titleId} className="m-0 flex list-none flex-col gap-2 p-0">
42
+ {column.links.map(function (link) { return (<li key={link.href + link.label}>
43
+ <FooterLink link={link}/>
44
+ </li>); })}
45
+ </ul>
46
+ </div>);
47
+ }
48
+ export { SiteFooter };
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ /** The site's name and its way home, shared by `SiteHeader` and `SiteFooter` */
3
+ export interface SiteBrand {
4
+ /** Where the brand goes: the home page */
5
+ href: string;
6
+ /** The site's name. It is the logo's alt text, and the text shown when there is no logo. */
7
+ name: string;
8
+ /** The logo's file. Without it the name is shown as text. */
9
+ src?: string;
10
+ /** The logo's size in px; set both so the bar keeps its height while the file loads. Default height 28. */
11
+ width?: number;
12
+ height?: number;
13
+ }
14
+ export interface SiteHeaderLink {
15
+ label: string;
16
+ href: string;
17
+ /** The page the reader is on: gets `aria-current="page"` */
18
+ current?: boolean;
19
+ }
20
+ interface SiteHeaderProps {
21
+ brand: SiteBrand;
22
+ /** The main places, in order. From md a row in the bar; below md in the menu. */
23
+ links: SiteHeaderLink[];
24
+ /**
25
+ * The secondary Buttons, e.g. 'Log In': at the end of the bar from md; below md under the links in the menu,
26
+ * and only there. A Button here that opens its own Modal or menu should be moved out: choosing in the menu closes it.
27
+ */
28
+ actions?: React.ReactNode;
29
+ /**
30
+ * The main action, e.g. 'Sign Up': last in the bar at every width, so below md it stays beside the brand and the
31
+ * Menu IconButton. It is not in the menu, so do not repeat it in `actions`.
32
+ */
33
+ phoneAction?: React.ReactNode;
34
+ /**
35
+ * A second row inside the bar at every width, under the brand and the actions: e.g. the section `Tab`s of a docs site.
36
+ * It never moves into the Menu, so keep it short enough for a phone.
37
+ */
38
+ nav?: React.ReactNode;
39
+ /** The Menu IconButton's name, and the Drawer's. Default 'Menu'. */
40
+ menuLabel?: string;
41
+ /** The skip link's text. Default 'Skip to content'. */
42
+ skipLabel?: string;
43
+ /** The id the skip link goes to. Default 'main'. Give `PageShell` (or your `<main>`) `id={mainId}` and `tabIndex={-1}`, so focus can move into it. */
44
+ mainId?: string;
45
+ }
46
+ /**
47
+ * A site's bar, sticky at the top: a skip link, the brand, the main links and the actions. Below md the
48
+ * links and `actions` move into a start Drawer a Menu IconButton opens; the brand and the `phoneAction` stay.
49
+ * With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer.
50
+ * While mounted it sets `--os-header-offset` (its height) on `<html>`; `PageShell` with `aside` gives its level 2 and 3 headings
51
+ * `scroll-margin-top: var(--os-header-offset, 0px)`, so a `#hash` link lands below the bar. Other headings need the same.
52
+ * Use one SiteHeader per page: there is one `--os-header-offset`, and unmounting any header removes it.
53
+ */
54
+ export default function SiteHeader({ brand, links, actions, phoneAction, nav, menuLabel, skipLabel, mainId, }: SiteHeaderProps): React.JSX.Element;
55
+ export { SiteHeader };
@@ -0,0 +1,125 @@
1
+ 'use client';
2
+ import React, { useEffect, useId, useRef, useState } from 'react';
3
+ import { Menu } from 'lucide-react';
4
+ import Drawer from './drawer';
5
+ import IconButton from './iconButton';
6
+ import { focusRing } from './sharedStyles';
7
+ import { SiteBrandLink } from '../internal/siteBrand';
8
+ // Tailwind's md breakpoint: the links are a row in the bar from here up
9
+ var WIDE = '(min-width: 768px)';
10
+ /**
11
+ * A site's bar, sticky at the top: a skip link, the brand, the main links and the actions. Below md the
12
+ * links and `actions` move into a start Drawer a Menu IconButton opens; the brand and the `phoneAction` stay.
13
+ * With no `links` and no `actions` there is no Main nav, no Menu IconButton and no Drawer.
14
+ * While mounted it sets `--os-header-offset` (its height) on `<html>`; `PageShell` with `aside` gives its level 2 and 3 headings
15
+ * `scroll-margin-top: var(--os-header-offset, 0px)`, so a `#hash` link lands below the bar. Other headings need the same.
16
+ * Use one SiteHeader per page: there is one `--os-header-offset`, and unmounting any header removes it.
17
+ */
18
+ export default function SiteHeader(_a) {
19
+ var brand = _a.brand, links = _a.links, actions = _a.actions, phoneAction = _a.phoneAction, nav = _a.nav, _b = _a.menuLabel, menuLabel = _b === void 0 ? 'Menu' : _b, _c = _a.skipLabel, skipLabel = _c === void 0 ? 'Skip to content' : _c, _d = _a.mainId, mainId = _d === void 0 ? 'main' : _d;
20
+ var drawerId = useId();
21
+ // Without links or actions there is nothing for a Menu to hold
22
+ var hasMenu = links.length > 0 || !!actions;
23
+ var _e = useState(false), menuOpen = _e[0], setMenuOpen = _e[1];
24
+ var barRef = useRef(null);
25
+ // Set when widening closes the Drawer while focus was in it: the Menu IconButton it would go back to is hidden from md up
26
+ var refocusAfterWiden = useRef(false);
27
+ // Publish the bar's height for what sticks or scrolls below it (PageShell's aside, OnThisPage, heading scroll-margin)
28
+ useEffect(function () {
29
+ var bar = barRef.current;
30
+ if (!bar)
31
+ return;
32
+ var root = document.documentElement;
33
+ var publish = function () { return root.style.setProperty('--os-header-offset', "".concat(bar.getBoundingClientRect().height, "px")); };
34
+ publish();
35
+ // On a server-rendered page the browser scrolled to the #hash before the offset existed, so the heading sits under
36
+ // the bar. Scroll to it once more, now with the scroll margin. Only on the first publish, never on a resize.
37
+ var target = null;
38
+ try {
39
+ target = location.hash.length > 1 ? document.getElementById(decodeURIComponent(location.hash.slice(1))) : null;
40
+ }
41
+ catch (_a) {
42
+ // a malformed hash names no heading
43
+ }
44
+ // Only a heading under the bar: one far above it means the person (or the browser's restore) scrolled on
45
+ var top = target === null || target === void 0 ? void 0 : target.getBoundingClientRect().top;
46
+ if (target && top !== undefined && top > -2 && top < bar.getBoundingClientRect().height) {
47
+ target.scrollIntoView({ block: 'start', behavior: 'instant' });
48
+ }
49
+ var observer = new ResizeObserver(publish);
50
+ observer.observe(bar);
51
+ return function () {
52
+ observer.disconnect();
53
+ root.style.removeProperty('--os-header-offset');
54
+ };
55
+ }, []);
56
+ // The Drawer is for a phone: widening past md closes it, so the page is never left locked under it
57
+ useEffect(function () {
58
+ if (!menuOpen)
59
+ return;
60
+ var wide = window.matchMedia(WIDE);
61
+ var closeIfWide = function () {
62
+ var _a;
63
+ if (!wide.matches)
64
+ return;
65
+ refocusAfterWiden.current = !!((_a = document.getElementById(drawerId)) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement));
66
+ setMenuOpen(false);
67
+ };
68
+ closeIfWide();
69
+ wide.addEventListener('change', closeIfWide);
70
+ return function () { return wide.removeEventListener('change', closeIfWide); };
71
+ }, [menuOpen]); // eslint-disable-line react-hooks/exhaustive-deps
72
+ // After the close commits (the Drawer's cleanup has already sent focus to the hidden Menu IconButton),
73
+ // focus the current link in the bar that is now on screen, or else the brand.
74
+ useEffect(function () {
75
+ var _a, _b, _c, _d;
76
+ if (menuOpen || !refocusAfterWiden.current)
77
+ return;
78
+ refocusAfterWiden.current = false;
79
+ (_d = ((_b = (_a = barRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('nav [aria-current]')) !== null && _b !== void 0 ? _b : (_c = barRef.current) === null || _c === void 0 ? void 0 : _c.querySelector('a[href]'))) === null || _d === void 0 ? void 0 : _d.focus();
80
+ }, [menuOpen]);
81
+ // A link or a Button in the menu closes it. A Button that opens its own menu (aria-haspopup) does not.
82
+ var closeOnChoice = function (e) {
83
+ var _a, _b;
84
+ var choice = (_b = (_a = e.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, 'a[href], button');
85
+ if (choice && e.currentTarget.contains(choice) && !choice.hasAttribute('aria-haspopup'))
86
+ setMenuOpen(false);
87
+ };
88
+ var linkList = function (vertical) { return (<nav aria-label="Main" className={vertical ? '' : 'hidden min-w-0 flex-1 md:block'}>
89
+ <ul className={"m-0 flex list-none p-0 ".concat(vertical ? 'flex-col gap-0.5' : 'flex-wrap items-center gap-x-1 gap-y-0.5')}>
90
+ {links.map(function (link) { return (<li key={link.href + link.label}>
91
+ <a href={link.href} aria-current={link.current ? 'page' : undefined} className={"block whitespace-nowrap rounded-control no-underline hover:bg-background-accent200 ".concat(vertical ? 'px-3 py-2.5 text-body1' : 'px-2 py-1.5 text-body2', " ").concat(link.current ? 'bg-background-accent100 text-fg-primary' : 'text-fg-secondary hover:text-fg-primary', " ").concat(focusRing)}>
92
+ {link.label}
93
+ </a>
94
+ </li>); })}
95
+ </ul>
96
+ </nav>); };
97
+ // The Drawer is a sibling of the header: a sticky header is a stacking context, and the panel must sit above the page
98
+ return (<>
99
+ <header ref={barRef} className="sticky top-0 z-10 border-b border-misc-divider bg-background-default">
100
+ <a href={"#".concat(mainId)} className={"sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-[var(--os-z-tooltip)] focus:rounded-control focus:bg-background-elevated focus:px-3 focus:py-2 focus:text-body2 focus:text-fg-primary focus:shadow-overlay ".concat(focusRing)}>
101
+ {skipLabel}
102
+ </a>
103
+ <div className="mx-auto flex w-full max-w-page-wide items-center gap-2 py-2 pl-2 pr-4 md:gap-4 md:px-xxlarge">
104
+ {hasMenu && (<div className="shrink-0 md:hidden">
105
+ <IconButton color="iconOnly" state="enabled" size="medium" icon={Menu} ariaLabel={menuLabel} aria-expanded={menuOpen} aria-controls={drawerId} onClick={function () { return setMenuOpen(true); }}/>
106
+ </div>)}
107
+ <SiteBrandLink brand={brand}/>
108
+ {/* Not while the menu is open, so the links and actions are mounted once. menuOpen is true only below md. */}
109
+ {!menuOpen && links.length > 0 && linkList(false)}
110
+ <div className="ml-auto flex shrink-0 items-center gap-2">
111
+ {actions && !menuOpen && <div className="hidden items-center gap-2 md:flex">{actions}</div>}
112
+ {phoneAction}
113
+ </div>
114
+ </div>
115
+ {nav && <div className="mx-auto w-full max-w-page-wide px-4 pb-2 md:px-xxlarge">{nav}</div>}
116
+ </header>
117
+ {hasMenu && (<Drawer id={drawerId} isOpen={menuOpen} onClose={function () { return setMenuOpen(false); }} aria-label={menuLabel} side="start" size="small">
118
+ <div onClick={closeOnChoice} className="flex flex-col gap-4">
119
+ {linkList(true)}
120
+ {actions && <div className="flex flex-col items-start gap-2">{actions}</div>}
121
+ </div>
122
+ </Drawer>)}
123
+ </>);
124
+ }
125
+ export { SiteHeader };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ type Width = 'full' | 'large' | 'medium' | 'small';
3
+ interface SkeletonProps {
4
+ /** The shape of what will load. `text` is one body line (`lines` stacks several), `block` a card or a row, `circle` an avatar. */
5
+ variant?: 'text' | 'block' | 'circle';
6
+ /** `full` is 100%, `large` 75%, `medium` 50%, `small` 25%. A `circle` ignores it. */
7
+ width?: Width;
8
+ /** For `text`: how many lines. The last one is shorter. */
9
+ lines?: number;
10
+ /** For `block`: 24px, 48px or 120px. */
11
+ height?: 'small' | 'medium' | 'large';
12
+ /** Names the loading for a screen reader, e.g. "Loading invoices", in a visually hidden `role="status"`. Without it the skeleton is silent. */
13
+ label?: string;
14
+ }
15
+ /**
16
+ * A still block in the shape of what will load, so a table or a tile keeps its size while it loads.
17
+ * It is hidden from the accessibility tree; give it a `label` once per region so the loading is announced once.
18
+ * The slow pulse stops under reduced motion. A status region announces most reliably when it stays mounted and its text changes.
19
+ */
20
+ export default function Skeleton({ variant, width, lines, height, label }: SkeletonProps): React.JSX.Element;
21
+ export {};
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ var widthClasses = { full: 'w-full', large: 'w-3/4', medium: 'w-1/2', small: 'w-1/4' };
3
+ var shorter = { full: 'large', large: 'medium', medium: 'small', small: 'small' };
4
+ var heightClasses = { small: 'h-6', medium: 'h-12', large: 'h-[120px]' };
5
+ var base = 'bg-fg-primary/10 animate-pulse motion-reduce:animate-none';
6
+ // A body line is 24px tall: each bar sits in a 24px slot so the text that replaces it does not move the page
7
+ var TextLine = function (_a) {
8
+ var width = _a.width;
9
+ return (<div className="flex h-6 items-center">
10
+ <div className={"".concat(widthClasses[width], " h-4 rounded-control ").concat(base)}/>
11
+ </div>);
12
+ };
13
+ /**
14
+ * A still block in the shape of what will load, so a table or a tile keeps its size while it loads.
15
+ * It is hidden from the accessibility tree; give it a `label` once per region so the loading is announced once.
16
+ * The slow pulse stops under reduced motion. A status region announces most reliably when it stays mounted and its text changes.
17
+ */
18
+ export default function Skeleton(_a) {
19
+ var _b = _a.variant, variant = _b === void 0 ? 'text' : _b, _c = _a.width, width = _c === void 0 ? 'full' : _c, _d = _a.lines, lines = _d === void 0 ? 1 : _d, _e = _a.height, height = _e === void 0 ? 'medium' : _e, label = _a.label;
20
+ var shape;
21
+ if (variant === 'circle') {
22
+ shape = <div aria-hidden="true" className={"h-7 w-7 shrink-0 rounded-full ".concat(base)}/>;
23
+ }
24
+ else if (variant === 'block') {
25
+ shape = <div aria-hidden="true" className={"".concat(widthClasses[width], " ").concat(heightClasses[height], " rounded-container ").concat(base)}/>;
26
+ }
27
+ else if (lines > 1) {
28
+ shape = (<div aria-hidden="true" className="flex flex-col w-full">
29
+ {Array.from({ length: lines }, function (_, i) { return (<TextLine key={i} width={i === lines - 1 ? shorter[width] : width}/>); })}
30
+ </div>);
31
+ }
32
+ else {
33
+ shape = <div aria-hidden="true" className="w-full"><TextLine width={width}/></div>;
34
+ }
35
+ if (!label)
36
+ return <>{shape}</>;
37
+ return (<>
38
+ {shape}
39
+ <span role="status" className="sr-only">{label}</span>
40
+ </>);
41
+ }
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { type ChangePeriod } from './formatNumber';
3
+ interface StatTileProps {
4
+ /** What the number is, e.g. "Responses". It is the tile's name. */
5
+ label: string;
6
+ /** The number. `null` means there is no data yet; it shows 'No data yet', never 0. A percent is a fraction (0.124 is 12%). */
7
+ value: number | null;
8
+ /** How the number reads: a count (default), money, a percent, bytes (base 1024) or a duration in milliseconds. */
9
+ format?: 'count' | 'money' | 'percent' | 'bytes' | 'duration';
10
+ /** For `money`: the currency code. Defaults to USD. */
11
+ currency?: string;
12
+ /** What is counted, e.g. "responses", set after the number. */
13
+ unit?: string;
14
+ /** The value for the period before, in the same unit. Gives the change line; without it there is none. */
15
+ previous?: number | null;
16
+ /** The period `previous` is from. Defaults to week. */
17
+ period?: ChangePeriod;
18
+ /** A line under the number, e.g. "7 of 8 seats used". */
19
+ caption?: string;
20
+ /** Shows a skeleton in place of the number and the change line, and marks the tile busy. */
21
+ loading?: boolean;
22
+ /** The number is h5 at every width. `large` sets it h4, and h3 from `md` up. */
23
+ size?: 'default' | 'large';
24
+ id?: string;
25
+ }
26
+ /**
27
+ * One headline number: a label, the number, how it changed and an optional note. From 10,000 up a count or an amount
28
+ * shows in its short form ('1.2M') and the exact number is in hidden text, so a screen reader hears '1,234,567'.
29
+ * The change line is never colored: more is not good or bad by itself. A row of tiles is `<Grid compact columns={4}>`.
30
+ */
31
+ export default function StatTile({ label, value, format, currency, unit, previous, period, caption, loading, size, id, }: StatTileProps): React.JSX.Element;
32
+ export {};
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { ArrowDown, ArrowUp } from 'lucide-react';
3
+ import Skeleton from './skeleton';
4
+ import { formatBytes, formatChange, formatCount, formatDuration, formatMoney, formatPercent, } from './formatNumber';
5
+ /**
6
+ * One headline number: a label, the number, how it changed and an optional note. From 10,000 up a count or an amount
7
+ * shows in its short form ('1.2M') and the exact number is in hidden text, so a screen reader hears '1,234,567'.
8
+ * The change line is never colored: more is not good or bad by itself. A row of tiles is `<Grid compact columns={4}>`.
9
+ */
10
+ export default function StatTile(_a) {
11
+ var label = _a.label, value = _a.value, _b = _a.format, format = _b === void 0 ? 'count' : _b, _c = _a.currency, currency = _c === void 0 ? 'USD' : _c, unit = _a.unit, previous = _a.previous, _d = _a.period, period = _d === void 0 ? 'week' : _d, caption = _a.caption, _e = _a.loading, loading = _e === void 0 ? false : _e, _f = _a.size, size = _f === void 0 ? 'default' : _f, id = _a.id;
12
+ // The default number is h5 at every width, so four tiles across keep '2 h 24 min' on one line
13
+ var valueSize = size === 'large' ? 'text-h4 md:text-h3' : 'text-h5';
14
+ // A line keeps its height while it loads, so the tile does not jump
15
+ var valueLine = size === 'large' ? 'min-h-[41px] md:min-h-[58px]' : 'min-h-[29px]';
16
+ var shown = null;
17
+ var exact = null;
18
+ if (value !== null) {
19
+ switch (format) {
20
+ case 'money':
21
+ exact = formatMoney(value, { currency: currency });
22
+ shown = formatMoney(value, { currency: currency, compact: true });
23
+ break;
24
+ case 'percent':
25
+ shown = formatPercent(value);
26
+ break;
27
+ case 'bytes':
28
+ shown = formatBytes(value);
29
+ break;
30
+ case 'duration':
31
+ shown = formatDuration(value);
32
+ break;
33
+ default:
34
+ exact = formatCount(value);
35
+ shown = formatCount(value, { compact: true });
36
+ }
37
+ }
38
+ var compact = shown !== null && exact !== null && shown !== exact;
39
+ var change = loading ? null : formatChange(value, previous, period);
40
+ return (<dl id={id} aria-busy={loading || undefined} className="flex min-w-0 flex-col gap-1">
41
+ <dt className="text-caption text-fg-secondary">{label}</dt>
42
+ <dd className={"flex items-center ".concat(valueLine)}>
43
+ {loading ? (<Skeleton width="medium" label={"Loading ".concat(label)}/>) : shown === null ? (<span className="text-body1 text-fg-secondary">No data yet</span>) : (<span className={"min-w-0 break-words font-mono tabular-nums text-fg-primary ".concat(valueSize)}>
44
+ {compact ? (<>
45
+ <span aria-hidden="true">{shown}</span>
46
+ <span className="sr-only">{exact}</span>
47
+ </>) : (shown)}
48
+ {unit && <span className="font-sans text-body2 text-fg-secondary">{' '}{unit}</span>}
49
+ </span>)}
50
+ </dd>
51
+ {loading ? (<dd className="m-0">
52
+ <Skeleton width="large"/>
53
+ </dd>) : (change &&
54
+ change.direction !== null && (<dd className="m-0 flex items-center gap-1 text-body2 text-fg-secondary">
55
+ {change.direction === 'up' && <ArrowUp aria-hidden="true" className="size-4 shrink-0"/>}
56
+ {change.direction === 'down' && <ArrowDown aria-hidden="true" className="size-4 shrink-0"/>}
57
+ {change.text}
58
+ </dd>))}
59
+ {caption && <dd className="m-0 text-body2 text-fg-secondary">{caption}</dd>}
60
+ </dl>);
61
+ }
@@ -1,6 +1,10 @@
1
1
  import React from 'react';
2
2
  interface TableContainerProps {
3
3
  children: React.ReactNode;
4
+ /** Names the table. Name it when it can overflow; a named table is a Tab stop. With a name the table sits in a scrollable `role="region"` of the same name that a keyboard can focus and scroll, for a table wider than a phone. */
5
+ 'aria-label'?: string;
6
+ /** With `aria-label`: the width the table keeps, e.g. '640px', so its columns do not squeeze and the region scrolls sideways. Ignored without a name. */
7
+ minWidth?: string;
4
8
  }
5
- export default function TableContainer({ children }: TableContainerProps): React.JSX.Element;
9
+ export default function TableContainer({ children, 'aria-label': ariaLabel, minWidth }: TableContainerProps): React.JSX.Element;
6
10
  export {};
@@ -1,7 +1,15 @@
1
1
  'use client';
2
2
  import React from 'react';
3
+ import { focusRing } from './sharedStyles';
3
4
  export default function TableContainer(_a) {
4
- var children = _a.children;
5
+ var children = _a.children, ariaLabel = _a["aria-label"], minWidth = _a.minWidth;
6
+ if (ariaLabel) {
7
+ return (<div role="region" aria-label={ariaLabel} tabIndex={0} className={"w-full overflow-x-auto bg-background-default rounded-control ".concat(focusRing)}>
8
+ <div role="table" aria-label={ariaLabel} className="w-full bg-background-default" style={minWidth ? { minWidth: minWidth } : undefined}>
9
+ {children}
10
+ </div>
11
+ </div>);
12
+ }
5
13
  return (<div role="table" className="w-full overflow-x-auto bg-background-default">
6
14
  {children}
7
15
  </div>);
@@ -4,6 +4,8 @@ interface TableHeaderCellProps {
4
4
  width?: string;
5
5
  minWidth?: string;
6
6
  align?: 'left' | 'center' | 'right';
7
+ /** Marks the column the table is sorted by. Set it on the one sorted column. Leave `sort` unset on the other columns. A sort Button inside is named by its label alone, and its arrow stays. */
8
+ sort?: 'ascending' | 'descending' | 'none';
7
9
  }
8
- export default function TableHeaderCell({ children, width, minWidth, align }: TableHeaderCellProps): React.JSX.Element;
10
+ export default function TableHeaderCell({ children, width, minWidth, align, sort }: TableHeaderCellProps): React.JSX.Element;
9
11
  export {};
@@ -1,11 +1,11 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  export default function TableHeaderCell(_a) {
4
- var children = _a.children, width = _a.width, minWidth = _a.minWidth, _b = _a.align, align = _b === void 0 ? 'left' : _b;
4
+ var children = _a.children, width = _a.width, minWidth = _a.minWidth, _b = _a.align, align = _b === void 0 ? 'left' : _b, sort = _a.sort;
5
5
  var alignClass = align === 'center' ? 'text-center' : align === 'right' ? 'text-right' : 'text-left';
6
6
  var widthStyle = width ? { width: width, minWidth: minWidth || width } : {};
7
7
  var flexClass = width ? '' : 'flex-1';
8
- return (<div role="columnheader" className={"".concat(flexClass, " p-2 text-body2 text-fg-secondary ").concat(alignClass)} style={widthStyle}>
8
+ return (<div role="columnheader" aria-sort={sort} className={"".concat(flexClass, " p-2 text-body2 text-fg-secondary ").concat(alignClass)} style={widthStyle}>
9
9
  {children}
10
10
  </div>);
11
11
  }