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,19 @@
1
+ import React from 'react';
2
+ interface TitleBarProps {
3
+ /** The page's or the pane's name */
4
+ title: string;
5
+ /** The heading's element. Default 1, for a page; a pane takes 2. */
6
+ level?: 1 | 2 | 3 | 4;
7
+ /** A Button before the title that goes one step up, e.g. 'Back to Inbox' */
8
+ back?: React.ReactNode;
9
+ /** Buttons at the end of the row. They never shrink; a long title wraps instead. */
10
+ actions?: React.ReactNode;
11
+ /** Below md the `actions` take their own line under the title, as `back` does above it, for a control too wide to sit beside the title (a range switch). From md up nothing changes. Ignored with `phoneActions`. */
12
+ actionsBelow?: boolean;
13
+ /** Below md these replace `actions`: the main action and a More menu holding the rest */
14
+ phoneActions?: React.ReactNode;
15
+ /** The heading's id */
16
+ id?: string;
17
+ }
18
+ export default function TitleBar({ title, level, back, actions, actionsBelow, phoneActions, id }: TitleBarProps): React.JSX.Element;
19
+ export { TitleBar };
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import Heading from './heading';
3
+ // One row from md up: back, the title, then the actions. Below md Back takes its own line above the title.
4
+ // A row without Back is one row at every width. The heading takes tabIndex -1 so a page or a pane can
5
+ // move focus to it (a pane does on open) without adding it to the tab order.
6
+ export default function TitleBar(_a) {
7
+ var title = _a.title, _b = _a.level, level = _b === void 0 ? 1 : _b, back = _a.back, actions = _a.actions, _c = _a.actionsBelow, actionsBelow = _c === void 0 ? false : _c, phoneActions = _a.phoneActions, id = _a.id;
8
+ var below = actionsBelow && !phoneActions;
9
+ return (<div className={"flex min-w-0 items-center gap-2".concat(back || below ? ' flex-wrap md:flex-nowrap' : '')}>
10
+ {back && <div className="flex shrink-0 basis-full items-center md:basis-auto">{back}</div>}
11
+ <Heading level={level} size="h5" id={id} tabIndex={-1} className="min-w-0 flex-1 break-words outline-none">
12
+ {title}
13
+ </Heading>
14
+ {actions && <div className={"".concat(phoneActions ? 'hidden md:flex' : 'flex', " shrink-0 items-center gap-2").concat(below ? ' basis-full md:basis-auto' : '')}>{actions}</div>}
15
+ {phoneActions && <div className="flex shrink-0 items-center gap-2 md:hidden">{phoneActions}</div>}
16
+ </div>);
17
+ }
18
+ export { TitleBar };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import './designTokens';
2
2
  export * from './components/alert';
3
+ export * from './components/appShell';
3
4
  export * from './components/button';
4
5
  export * from './components/checkBox';
5
6
  export * from './components/copyField';
7
+ export * from './components/drawer';
6
8
  export * from './components/emptyBox';
7
9
  export * from './components/formField';
10
+ export * from './components/formatNumber';
8
11
  export * from './components/iconButton';
9
12
  export * from './components/layout';
10
13
  export * from './components/loadingScreen';
@@ -12,12 +15,20 @@ export * from './components/menu';
12
15
  export * from './components/menuItem';
13
16
  export * from './components/modal';
14
17
  export * from './components/navigation';
18
+ export * from './components/onThisPage';
19
+ export * from './components/pagination';
15
20
  export * from './components/popover';
21
+ export * from './components/progress';
16
22
  export * from './components/radioGroup';
17
23
  export * from './components/sectionIntro';
18
24
  export * from './components/segmentedControl';
19
25
  export * from './components/select';
20
26
  export * from './components/settingsSection';
27
+ export * from './components/sidePane';
28
+ export * from './components/siteFooter';
29
+ export * from './components/siteHeader';
30
+ export * from './components/skeleton';
31
+ export * from './components/statTile';
21
32
  export * from './components/switch';
22
33
  export * from './components/tab';
23
34
  export * from './components/tableCell';
@@ -30,6 +41,7 @@ export * from './components/tag';
30
41
  export * from './components/textarea';
31
42
  export * from './components/textField';
32
43
  export * from './components/timeStamp';
44
+ export * from './components/titleBar';
33
45
  export * from './components/tooltip';
34
46
  export * from './components/userImage';
35
47
  export { default as useDarkMode, resolveDarkMode } from './components/useDarkMode';
package/dist/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import './designTokens';
2
2
  export * from './components/alert';
3
+ export * from './components/appShell';
3
4
  export * from './components/button';
4
5
  export * from './components/checkBox';
5
6
  export * from './components/copyField';
7
+ export * from './components/drawer';
6
8
  export * from './components/emptyBox';
7
9
  export * from './components/formField';
10
+ export * from './components/formatNumber';
8
11
  export * from './components/iconButton';
9
12
  export * from './components/layout';
10
13
  export * from './components/loadingScreen';
@@ -12,12 +15,20 @@ export * from './components/menu';
12
15
  export * from './components/menuItem';
13
16
  export * from './components/modal';
14
17
  export * from './components/navigation';
18
+ export * from './components/onThisPage';
19
+ export * from './components/pagination';
15
20
  export * from './components/popover';
21
+ export * from './components/progress';
16
22
  export * from './components/radioGroup';
17
23
  export * from './components/sectionIntro';
18
24
  export * from './components/segmentedControl';
19
25
  export * from './components/select';
20
26
  export * from './components/settingsSection';
27
+ export * from './components/sidePane';
28
+ export * from './components/siteFooter';
29
+ export * from './components/siteHeader';
30
+ export * from './components/skeleton';
31
+ export * from './components/statTile';
21
32
  export * from './components/switch';
22
33
  export * from './components/tab';
23
34
  export * from './components/tableCell';
@@ -30,6 +41,7 @@ export * from './components/tag';
30
41
  export * from './components/textarea';
31
42
  export * from './components/textField';
32
43
  export * from './components/timeStamp';
44
+ export * from './components/titleBar';
33
45
  export * from './components/tooltip';
34
46
  export * from './components/userImage';
35
47
  export { default as useDarkMode, resolveDarkMode } from './components/useDarkMode';
@@ -0,0 +1,24 @@
1
+ type Overlay = {
2
+ id: string;
3
+ panel?: {
4
+ contains(node: unknown): boolean;
5
+ } | null;
6
+ };
7
+ export declare function pushOverlay(id: string, panel?: Overlay['panel']): void;
8
+ export declare function popOverlay(id: string): void;
9
+ export declare function isTopOverlay(id: string): boolean;
10
+ export declare function isInTopOverlay(node: unknown): boolean;
11
+ export declare function claimEvent(event: object): boolean;
12
+ export declare function lockScroll(): void;
13
+ export declare function unlockScroll(): void;
14
+ export declare const PICKABLE: string;
15
+ type Focusable = {
16
+ focus(): void;
17
+ };
18
+ export declare function trapTab(panel: {
19
+ querySelectorAll(selector: string): ArrayLike<Focusable> | Iterable<Focusable>;
20
+ }, event: {
21
+ shiftKey: boolean;
22
+ preventDefault(): void;
23
+ }): void;
24
+ export {};
@@ -0,0 +1,71 @@
1
+ // One stack for the overlays that cover the page (Modal, Drawer), kept out of the public API.
2
+ // The newest open overlay is on top: only it acts on Escape, Tab and a scrim click, so a Modal
3
+ // opened from a Drawer closes alone. Nothing here touches the document until an effect calls it.
4
+ var stack = [];
5
+ // Puts an overlay on top. Pass its panel so a Popover can tell whether it sits in the top overlay.
6
+ export function pushOverlay(id, panel) {
7
+ popOverlay(id);
8
+ stack.push({ id: id, panel: panel });
9
+ }
10
+ // Takes an overlay off the stack wherever it is, so one below can close first
11
+ export function popOverlay(id) {
12
+ var index = stack.findIndex(function (o) { return o.id === id; });
13
+ if (index >= 0)
14
+ stack.splice(index, 1);
15
+ }
16
+ export function isTopOverlay(id) {
17
+ return stack.length > 0 && stack[stack.length - 1].id === id;
18
+ }
19
+ // True when no overlay is open or the top one holds `node`; false when a newer overlay covers it
20
+ export function isInTopOverlay(node) {
21
+ var top = stack[stack.length - 1];
22
+ return !(top === null || top === void 0 ? void 0 : top.panel) || top.panel.contains(node);
23
+ }
24
+ // Every overlay hears the same keydown on window. A browser runs React's update between two
25
+ // listeners, so the top overlay may already be gone when the next one asks: the first to claim
26
+ // an event acts on it, and the others leave it.
27
+ var claimed = new WeakSet();
28
+ export function claimEvent(event) {
29
+ if (claimed.has(event))
30
+ return false;
31
+ claimed.add(event);
32
+ return true;
33
+ }
34
+ // Counted, so stacked overlays lock the page once and give the page its own overflow back once
35
+ var locks = 0;
36
+ var savedOverflow = '';
37
+ export function lockScroll() {
38
+ if (locks++ === 0) {
39
+ savedOverflow = document.body.style.overflow;
40
+ document.body.style.overflow = 'hidden';
41
+ }
42
+ }
43
+ export function unlockScroll() {
44
+ if (locks === 0)
45
+ return;
46
+ if (--locks === 0)
47
+ document.body.style.overflow = savedOverflow;
48
+ }
49
+ var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
50
+ // For the first focus and the Tab trap: the same, minus a hidden input, which matches but cannot take focus
51
+ export var PICKABLE = FOCUSABLE.replace('input:not([disabled])', 'input:not([disabled]):not([type="hidden"])');
52
+ // Keeps Tab and Shift+Tab inside the panel: from the last element to the first and back.
53
+ // With nothing to focus, Tab does nothing.
54
+ export function trapTab(panel, event) {
55
+ var focusable = Array.from(panel.querySelectorAll(PICKABLE));
56
+ if (focusable.length === 0) {
57
+ event.preventDefault();
58
+ return;
59
+ }
60
+ var first = focusable[0];
61
+ var last = focusable[focusable.length - 1];
62
+ var active = document.activeElement;
63
+ if (event.shiftKey && active === first) {
64
+ event.preventDefault();
65
+ last.focus();
66
+ }
67
+ else if (!event.shiftKey && active === last) {
68
+ event.preventDefault();
69
+ first.focus();
70
+ }
71
+ }
@@ -0,0 +1,9 @@
1
+ /** One arrow key press moves the edge this far */
2
+ export declare const KEY_STEP = 16;
3
+ export declare function clampWidth(width: number, min: number, max: number): number;
4
+ export declare function paneLimits(minWidth: number, maxWidth: number | undefined, windowWidth: number): {
5
+ min: number;
6
+ max: number;
7
+ };
8
+ export declare function keyWidth(key: string, width: number, min: number, max: number): number | null;
9
+ export declare function dragWidth(startWidth: number, startX: number, x: number, min: number, max: number): number;
@@ -0,0 +1,31 @@
1
+ // Width math for a pane resized from its start edge (SidePane). Pure, so it is tested without a page.
2
+ /** One arrow key press moves the edge this far */
3
+ export var KEY_STEP = 16;
4
+ export function clampWidth(width, min, max) {
5
+ return Math.min(max, Math.max(min, width));
6
+ }
7
+ // The default maximum is 60% of the window, and the maximum is never under the minimum
8
+ export function paneLimits(minWidth, maxWidth, windowWidth) {
9
+ var max = maxWidth !== null && maxWidth !== void 0 ? maxWidth : Math.round(windowWidth * 0.6);
10
+ return { min: minWidth, max: Math.max(minWidth, max) };
11
+ }
12
+ // The edge is on the pane's start side: Left widens the pane, Right narrows it, Home and End go to
13
+ // the smallest and largest width. Any other key gives null.
14
+ export function keyWidth(key, width, min, max) {
15
+ switch (key) {
16
+ case 'ArrowLeft':
17
+ return clampWidth(width + KEY_STEP, min, max);
18
+ case 'ArrowRight':
19
+ return clampWidth(width - KEY_STEP, min, max);
20
+ case 'Home':
21
+ return min;
22
+ case 'End':
23
+ return max;
24
+ default:
25
+ return null;
26
+ }
27
+ }
28
+ // Dragging the edge left by some pixels widens the pane by as many
29
+ export function dragWidth(startWidth, startX, x, min, max) {
30
+ return clampWidth(startWidth + (startX - x), min, max);
31
+ }
@@ -0,0 +1,24 @@
1
+ /** How close to the end of the scroll counts as the end, in px */
2
+ export declare const BOTTOM_SLACK = 2;
3
+ /** The window to read from: its scroll position and sizes */
4
+ export interface ScrollMetrics {
5
+ scrollTop: number;
6
+ clientHeight: number;
7
+ scrollHeight: number;
8
+ }
9
+ /**
10
+ * Whether the scroll is at its end. A page that does not scroll is not at its end: its last
11
+ * section would otherwise be current on a short page.
12
+ */
13
+ export declare function isAtBottom({ scrollTop, clientHeight, scrollHeight }: ScrollMetrics): boolean;
14
+ /**
15
+ * The index of the current item. `tops` holds each heading's distance from the top of the scroll
16
+ * area (null for a heading that is not on the page yet).
17
+ * - At the end of the scroll, the last item: a last section shorter than the window never reaches the offset.
18
+ * - Otherwise the last heading at or above `offset`.
19
+ * - Above every heading, the first item.
20
+ * - -1 when no heading is on the page.
21
+ */
22
+ export declare function pickCurrent(tops: (number | null)[], offset: number, atBottom: boolean): number;
23
+ /** The id a `#hash` names, when it is one of the items; else null. Reads `#a%20b` as `a b`. */
24
+ export declare function hashId(hash: string, ids: string[]): string | null;
@@ -0,0 +1,53 @@
1
+ // Which heading a long page is "at", for OnThisPage. Pure, so it is tested without a page.
2
+ /** How close to the end of the scroll counts as the end, in px */
3
+ export var BOTTOM_SLACK = 2;
4
+ /**
5
+ * Whether the scroll is at its end. A page that does not scroll is not at its end: its last
6
+ * section would otherwise be current on a short page.
7
+ */
8
+ export function isAtBottom(_a) {
9
+ var scrollTop = _a.scrollTop, clientHeight = _a.clientHeight, scrollHeight = _a.scrollHeight;
10
+ if (scrollHeight <= clientHeight + BOTTOM_SLACK)
11
+ return false;
12
+ return scrollTop + clientHeight >= scrollHeight - BOTTOM_SLACK;
13
+ }
14
+ /**
15
+ * The index of the current item. `tops` holds each heading's distance from the top of the scroll
16
+ * area (null for a heading that is not on the page yet).
17
+ * - At the end of the scroll, the last item: a last section shorter than the window never reaches the offset.
18
+ * - Otherwise the last heading at or above `offset`.
19
+ * - Above every heading, the first item.
20
+ * - -1 when no heading is on the page.
21
+ */
22
+ export function pickCurrent(tops, offset, atBottom) {
23
+ var first = -1;
24
+ var last = -1;
25
+ var passed = -1;
26
+ tops.forEach(function (top, i) {
27
+ if (top === null)
28
+ return;
29
+ if (first < 0)
30
+ first = i;
31
+ last = i;
32
+ if (top <= offset)
33
+ passed = i;
34
+ });
35
+ if (first < 0)
36
+ return -1;
37
+ if (atBottom)
38
+ return last;
39
+ return passed >= 0 ? passed : first;
40
+ }
41
+ /** The id a `#hash` names, when it is one of the items; else null. Reads `#a%20b` as `a b`. */
42
+ export function hashId(hash, ids) {
43
+ if (!hash || hash === '#')
44
+ return null;
45
+ var id = hash.startsWith('#') ? hash.slice(1) : hash;
46
+ try {
47
+ id = decodeURIComponent(id);
48
+ }
49
+ catch (_a) {
50
+ // keep the raw text
51
+ }
52
+ return ids.includes(id) ? id : null;
53
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { SiteBrand } from '../components/siteHeader';
3
+ /** The brand as a link home: the logo named by the site, or the name as text. Shared by `SiteHeader` and `SiteFooter`, not public. */
4
+ export declare function SiteBrandLink({ brand }: {
5
+ brand: SiteBrand;
6
+ }): React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import Image from '../components/image';
3
+ import { focusRing } from '../components/sharedStyles';
4
+ /** The brand as a link home: the logo named by the site, or the name as text. Shared by `SiteHeader` and `SiteFooter`, not public. */
5
+ export function SiteBrandLink(_a) {
6
+ var _b;
7
+ var brand = _a.brand;
8
+ return (<a href={brand.href} className={"flex shrink-0 items-center rounded-control text-subtitle1 text-fg-primary no-underline ".concat(focusRing)}>
9
+ {brand.src ? <Image src={brand.src} alt={brand.name} width={brand.width} height={(_b = brand.height) !== null && _b !== void 0 ? _b : 28}/> : brand.name}
10
+ </a>);
11
+ }
@@ -6,6 +6,12 @@
6
6
  "compose": "`OdsBanner` for an inline message; `AlertDialog` for one that needs a decision",
7
7
  "note": "ODS has no native toast: on Android use `Snackbar` in a `SnackbarHost`."
8
8
  },
9
+ {
10
+ "ods": "appShell",
11
+ "swiftui": "`NavigationSplitView` with the sidebar, the content and an `.inspector`; on iPhone a `NavigationStack`, or a `TabView` of five places or fewer",
12
+ "compose": "`NavigationSuiteScaffold`; on a phone a `ModalNavigationDrawer` around a `Scaffold`",
13
+ "note": "The split view collapses to a stack on iPhone and shows and hides the sidebar itself. The skip link is web only."
14
+ },
9
15
  {
10
16
  "ods": "button",
11
17
  "swiftui": "`Button` with `.odsProminentButton()` for accent (`.odsProminentButton(.glass)` for the glass style), `.bordered` for primary",
@@ -34,6 +40,12 @@
34
40
  "compose": "An `OutlinedTextField` with `readOnly = true` and a `trailingIcon` `TextButton` that calls `LocalClipboard`",
35
41
  "note": "Show \"Copied\" for 2 seconds only after the write succeeds. Announce it for VoiceOver / TalkBack. A secret shown once gets the line under it."
36
42
  },
43
+ {
44
+ "ods": "drawer",
45
+ "swiftui": "`.sheet` with `.presentationDetents` on iPhone; `.inspector` on iPad and Mac",
46
+ "compose": "`ModalNavigationDrawer` for `side=\"start\"`; `ModalBottomSheet` for `side=\"end\"`",
47
+ "note": "The system sheet, inspector and drawer handle the scrim, swipe to close and focus. `ModalBottomSheet` needs `@OptIn(ExperimentalMaterial3Api::class)`."
48
+ },
37
49
  {
38
50
  "ods": "emptyBox",
39
51
  "swiftui": "`ContentUnavailableView`",
@@ -157,6 +169,12 @@
157
169
  "compose": "Not applicable: web page pattern",
158
170
  "note": "In an app screen: rows of a `List` / `ListItem`s."
159
171
  },
172
+ {
173
+ "ods": "onThisPage",
174
+ "swiftui": "Not applicable: web page pattern",
175
+ "compose": "Not applicable: web page pattern",
176
+ "note": "A site is web only. A long screen is a `List` in sections."
177
+ },
160
178
  {
161
179
  "ods": "pageHeader",
162
180
  "swiftui": "Not applicable: web page pattern",
@@ -174,12 +192,24 @@
174
192
  "swiftui": "`Text` with `.font(.body)`",
175
193
  "compose": "`Text` with `MaterialTheme.typography.bodyLarge`"
176
194
  },
195
+ {
196
+ "ods": "pagination",
197
+ "swiftui": "Not applicable: web page pattern",
198
+ "compose": "Not applicable: web page pattern",
199
+ "note": "A list loads more as it scrolls: a `List` with `.onAppear` on the last row on Apple, Paging with a `LazyColumn` on Android. No page buttons in an app."
200
+ },
177
201
  {
178
202
  "ods": "popover",
179
203
  "swiftui": "`.popover`",
180
204
  "compose": "`DropdownMenu`",
181
205
  "note": "Larger anchored content on Android: `ModalBottomSheet`."
182
206
  },
207
+ {
208
+ "ods": "progress",
209
+ "swiftui": "`Gauge(value:in:)` with `.gaugeStyle(.accessoryLinearCapacity)`, or `ProgressView(value:)` with a `currentValueLabel`",
210
+ "compose": "`LinearProgressIndicator(progress = { … })` with `semantics { progressBarRangeInfo; stateDescription }`",
211
+ "note": "A meter of use against a limit, not a task progress bar. Say \"Almost at the limit\" and \"Limit reached\" in words, not by color alone. With no limit show the text only. Numbers: `.number.notation(.compactName)` / `.currency(code:)` / `ByteCountFormatStyle(style: .memory)` on Apple; `CompactDecimalFormat` / `NumberFormat.getCurrencyInstance` / `Formatter.formatShortFileSize` on Android."
212
+ },
183
213
  {
184
214
  "ods": "radioGroup",
185
215
  "swiftui": "`Picker` (`.inline` on iOS, `.radioGroup` on macOS)",
@@ -207,7 +237,31 @@
207
237
  "ods": "settingsSection",
208
238
  "swiftui": "A `Section` with a header `Text` and footer `Text` in a grouped `Form`",
209
239
  "compose": "A `Column` with a title `Text`, a supporting `Text` and the controls under a `HorizontalDivider`",
210
- "note": "A danger zone gets its own `Section` with the error color on the header. Settings Columns is a screen layout: one column on a phone. For Settings Layout, on a phone the nav is its own screen, pushed with `NavigationStack` / `NavHost`."
240
+ "note": "A danger zone gets its own `Section` with the error color on the header. Settings Columns is a screen layout: one column on a phone. For Settings Layout, on a phone the nav is its own screen, pushed with `NavigationStack` / `NavHost`. `navWidth=\"wide\"` (a list beside its detail) is a `NavigationSplitView` list column / `ListDetailPaneScaffold`."
241
+ },
242
+ {
243
+ "ods": "sidePane",
244
+ "swiftui": "`.inspector(isPresented:)` with `.inspectorColumnWidth(min:ideal:max:)`",
245
+ "compose": "`SupportingPaneScaffold`",
246
+ "note": "The system resizes the inspector on iPad and Mac and shows it as a sheet on iPhone. `SupportingPaneScaffold` is in the Material 3 adaptive library and needs `@OptIn(ExperimentalMaterial3AdaptiveApi::class)`."
247
+ },
248
+ {
249
+ "ods": "siteFooter",
250
+ "swiftui": "Not applicable: web page pattern",
251
+ "compose": "Not applicable: web page pattern",
252
+ "note": "A site is web only. An app has no footer: its links live in Settings, as rows."
253
+ },
254
+ {
255
+ "ods": "siteHeader",
256
+ "swiftui": "Not applicable: web page pattern",
257
+ "compose": "Not applicable: web page pattern",
258
+ "note": "A site is web only. In an app: `NavigationStack` with a toolbar, and a `TabView` or `NavigationSuiteScaffold` for the places."
259
+ },
260
+ {
261
+ "ods": "skeleton",
262
+ "swiftui": "`.redacted(reason: .placeholder)` on the real view",
263
+ "compose": "A `Box` shape filled with `surfaceVariant`",
264
+ "note": "Compose has no stock part. No shimmer: keep it still, or a slow pulse that stops with reduced motion. Hide it from TalkBack and announce the loading once for the region."
211
265
  },
212
266
  {
213
267
  "ods": "sourceCard",
@@ -233,6 +287,12 @@
233
287
  "compose": "`Switch` in a `ListItem` with `trailingContent`",
234
288
  "note": "While a change saves, disable the control or show a `ProgressView` / `CircularProgressIndicator` beside it and put the value back if it fails."
235
289
  },
290
+ {
291
+ "ods": "statTile",
292
+ "swiftui": "A `VStack` of `Text`s with `.accessibilityElement(children: .combine)`",
293
+ "compose": "A `Column` with `Modifier.semantics(mergeDescendants = true)`",
294
+ "note": "Not colored by good or bad. Numbers: `.number.notation(.compactName)` / `.currency(code:)` on Apple; `CompactDecimalFormat` / `NumberFormat.getCurrencyInstance` on Android. Loading: `.redacted(reason: .placeholder)`."
295
+ },
236
296
  {
237
297
  "ods": "tab",
238
298
  "swiftui": "`TabView` or segmented `Picker`",
@@ -249,7 +309,7 @@
249
309
  "ods": "tableContainer",
250
310
  "swiftui": "`Table`",
251
311
  "compose": "`LazyColumn` of `Row`s",
252
- "note": "Material 3 has no table. A compact-width iPhone `Table` shows only its first column."
312
+ "note": "Material 3 has no table. A compact-width iPhone `Table` shows only its first column. `aria-label` names it: `.accessibilityLabel`. `minWidth` makes it scroll sideways inside its region: a horizontal `ScrollView` / `Modifier.horizontalScroll`. A sorted column uses `TableColumn(…, sortUsing:)` / `semantics { stateDescription }`."
253
313
  },
254
314
  {
255
315
  "ods": "tableHeader",
@@ -261,7 +321,7 @@
261
321
  "ods": "tableHeaderCell",
262
322
  "swiftui": "A `TableColumn` title",
263
323
  "compose": "`Text` in the header `Row`",
264
- "note": "Material 3 has no table."
324
+ "note": "Material 3 has no table. `sort`: `TableColumn(…, sortUsing:)` with a `KeyPathComparator`; on Android a clickable header `Text` with `semantics { stateDescription = \"Sorted ascending\" }`."
265
325
  },
266
326
  {
267
327
  "ods": "tableRow",
@@ -296,6 +356,12 @@
296
356
  "swiftui": "`Text(_:style:)` (`.relative`) or `Text(_:format:)` (`.dateTime`)",
297
357
  "compose": "`Text` with `DateUtils.getRelativeTimeSpanString` or `DateTimeFormatter.ofLocalizedDateTime`"
298
358
  },
359
+ {
360
+ "ods": "titleBar",
361
+ "swiftui": "`.navigationTitle` with `.toolbar` items",
362
+ "compose": "`TopAppBar` with `navigationIcon` and `actions`",
363
+ "note": "The main action stays in the toolbar; the rest go in a `Menu` / an overflow `DropdownMenu`."
364
+ },
299
365
  {
300
366
  "ods": "toaster",
301
367
  "swiftui": "`ODSBanner` for an inline message; a system banner (a local notification) when the app is not in front",
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import AppShell from "../components/appShell";
4
+ declare const meta: Meta<typeof AppShell>;
5
+ export default meta;
6
+ declare function ShellBox({ initialNav, initialPane, resizable }: {
7
+ initialNav?: boolean;
8
+ initialPane?: boolean;
9
+ resizable?: boolean;
10
+ }): React.JSX.Element;
11
+ type Story = StoryObj<typeof ShellBox>;
12
+ export declare const Default: Story;
13
+ export declare const WithPane: Story;
14
+ export declare const Phone: Story;
15
+ export declare const Probe: Story;