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
package/README.md CHANGED
@@ -70,7 +70,7 @@ import SectionIntro from 'oneslash-design-system/components/sectionIntro';
70
70
 
71
71
  ## Design cases
72
72
 
73
- A case is one design situation with oneSlash's answer to it. A rule case has one answer, such as "an agent asks before a risky action". A design case has one to four options, each with a line on when to use it and a working example built only from this package. 2.18.0 has 74: eleven rules and 63 design cases for auth pages, confirms and modals, states, chat and agent interfaces, settings and menus.
73
+ A case is one design situation with oneSlash's answer to it. A rule case has one answer, such as "an agent asks before a risky action". A design case has one to four options, each with a line on when to use it and a working example built only from this package. 2.20.0 has 98: thirteen rules and 85 design cases for auth pages, confirms and modals, states, chat and agent interfaces, settings and menus, shells and navigation, dashboards and billing.
74
74
 
75
75
  - `oneslash-design-system/cases.json` lists every case with its rule text, options, Do and Don't lines, and the source of each example.
76
76
  - `oneslash-design-system/cases/<id>.md` is one case as text, and `oneslash-design-system/cases/<id>/<option>.jsx` is the example itself.
package/dist/DESIGN.md CHANGED
@@ -292,11 +292,13 @@ For each web component, the table gives the native control to use. System contro
292
292
  | ODS | SwiftUI | Compose | Note |
293
293
  | --- | --- | --- | --- |
294
294
  | alert | `ODSBanner` for an inline message; `.alert` for one that needs a decision | `OdsBanner` for an inline message; `AlertDialog` for one that needs a decision | ODS has no native toast: on Android use `Snackbar` in a `SnackbarHost`. |
295
+ | appShell | `NavigationSplitView` with the sidebar, the content and an `.inspector`; on iPhone a `NavigationStack`, or a `TabView` of five places or fewer | `NavigationSuiteScaffold`; on a phone a `ModalNavigationDrawer` around a `Scaffold` | The split view collapses to a stack on iPhone and shows and hides the sidebar itself. The skip link is web only. |
295
296
  | button | `Button` with `.odsProminentButton()` for accent (`.odsProminentButton(.glass)` for the glass style), `.bordered` for primary | `Button`, `OutlinedButton` | Tertiary and text-only: `.borderless` / `TextButton`. On Apple, apply `.odsProminentButton()` to every prominent button. Under `odsTheme` the label of a `.borderedProminent` or `.glassProminent` button takes `text.primary`, not the system white, which is below 4.5:1 on the accent in default dark, forest light, forest dark, clay dark, indigo light, indigo dark, wine light, wine dark. In forest light it is the same color as the fill, so the label cannot be seen. The modifier keeps the system style and sets the label to `accent.contrast`. Compose needs nothing: `onPrimary` is `accent.contrast`. |
296
297
  | brandIcon | the provider's own button where one exists (`SignInWithAppleButton`), else an asset in the app | an asset in the app | |
297
298
  | checkBox | `Toggle` (switch on iOS, `.toggleStyle(.checkbox)` on macOS) | `Checkbox` | |
298
299
  | composer | `TextField(_:text:axis: .vertical)` with `.lineLimit(1...6)` over a toolbar `HStack` of the tool `Button`s and a send `Button` | `OutlinedTextField` with `maxLines = 6` over a `Row` of the tool `IconButton`s and a send `IconButton` | On iPhone and Android, Return adds a line and the send button sends. While an agent works, send becomes Stop. |
299
300
  | copyField | A `LabeledContent` row with the value in a `Text` (`.textSelection(.enabled)`) and a `Button` that sets `UIPasteboard` / `NSPasteboard` | An `OutlinedTextField` with `readOnly = true` and a `trailingIcon` `TextButton` that calls `LocalClipboard` | Show "Copied" for 2 seconds only after the write succeeds. Announce it for VoiceOver / TalkBack. A secret shown once gets the line under it. |
301
+ | drawer | `.sheet` with `.presentationDetents` on iPhone; `.inspector` on iPad and Mac | `ModalNavigationDrawer` for `side="start"`; `ModalBottomSheet` for `side="end"` | The system sheet, inspector and drawer handle the scrim, swipe to close and focus. `ModalBottomSheet` needs `@OptIn(ExperimentalMaterial3Api::class)`. |
300
302
  | emptyBox | `ContentUnavailableView` | `OdsEmptyState` | The system has this control on Apple, so ODS adds no part there. Material has none, so ODS does. |
301
303
  | factsRow | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `LabeledContent` rows in a `Form` / `ListItem` rows. |
302
304
  | figure | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: an `Image` with a caption `Text` in the caption text style. |
@@ -319,30 +321,39 @@ For each web component, the table gives the native control to use. System contro
319
321
  | modal | `.sheet` or `.alert` | `ModalBottomSheet` or `AlertDialog` | `ModalBottomSheet` needs `@OptIn(ExperimentalMaterial3Api::class)`. |
320
322
  | navigation | `NavigationSplitView` with a sidebar `List` | `NavigationRail` or `ModalNavigationDrawer` with `NavigationDrawerItem` | |
321
323
  | numberedRow | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: rows of a `List` / `ListItem`s. |
324
+ | onThisPage | Not applicable: web page pattern | Not applicable: web page pattern | A site is web only. A long screen is a `List` in sections. |
322
325
  | pageHeader | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `.navigationTitle` / `TopAppBar`. |
323
326
  | pageShell | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: `NavigationStack` / `Scaffold`. |
324
327
  | paragraph | `Text` with `.font(.body)` | `Text` with `MaterialTheme.typography.bodyLarge` | |
328
+ | pagination | Not applicable: web page pattern | Not applicable: web page pattern | 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. |
325
329
  | popover | `.popover` | `DropdownMenu` | Larger anchored content on Android: `ModalBottomSheet`. |
330
+ | progress | `Gauge(value:in:)` with `.gaugeStyle(.accessoryLinearCapacity)`, or `ProgressView(value:)` with a `currentValueLabel` | `LinearProgressIndicator(progress = { … })` with `semantics { progressBarRangeInfo; stateDescription }` | 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. |
326
331
  | radioGroup | `Picker` (`.inline` on iOS, `.radioGroup` on macOS) | `RadioButton`s in a `Column` with `Modifier.selectableGroup()` | `variant="card"`: each option is a bordered card with the radio in it, a `Picker` with custom rows on iOS / selectable `Card`s with a `RadioButton` in a `selectableGroup` on Android. |
327
332
  | sectionIntro | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: a `Section` header in a `List` or `Form` / a heading `Text`. |
328
333
  | segmentedControl | `Picker` with `.pickerStyle(.segmented)` | `SingleChoiceSegmentedButtonRow` with `SegmentedButton` | It sets a value on the same screen. To switch panels use `TabView` / `PrimaryTabRow`. Give the picker an accessibility label. |
329
334
  | select | `Picker` or `Menu` | `ExposedDropdownMenuBox` | |
330
- | settingsSection | A `Section` with a header `Text` and footer `Text` in a grouped `Form` | A `Column` with a title `Text`, a supporting `Text` and the controls under a `HorizontalDivider` | 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`. |
335
+ | settingsSection | A `Section` with a header `Text` and footer `Text` in a grouped `Form` | A `Column` with a title `Text`, a supporting `Text` and the controls under a `HorizontalDivider` | 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`. |
336
+ | sidePane | `.inspector(isPresented:)` with `.inspectorColumnWidth(min:ideal:max:)` | `SupportingPaneScaffold` | 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)`. |
337
+ | siteFooter | Not applicable: web page pattern | Not applicable: web page pattern | A site is web only. An app has no footer: its links live in Settings, as rows. |
338
+ | siteHeader | Not applicable: web page pattern | Not applicable: web page pattern | A site is web only. In an app: `NavigationStack` with a toolbar, and a `TabView` or `NavigationSuiteScaffold` for the places. |
339
+ | skeleton | `.redacted(reason: .placeholder)` on the real view | A `Box` shape filled with `surfaceVariant` | 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. |
331
340
  | sourceCard | `Link` or `Button` with a `Label` (icon, title) and the meta as a secondary line | A `Card` with `onClick`, or a `ListItem` with a leading `Icon` | With no destination it is a plain `Label`, not a button. |
332
341
  | stepList | A `List` of `Label`s with an SF Symbol per status (`circle`, `checkmark.circle.fill`, `xmark.circle.fill`, `minus.circle`); `ProgressView` for the running one | A `Column` of `ListItem`s with an `Icon` per status; `CircularProgressIndicator` for the running one | Give each row a status text for VoiceOver / TalkBack, not color alone. |
333
342
  | surface | Not applicable: web page pattern | Not applicable: web page pattern | In an app screen: a `Form` section or `GroupBox` / `Card`. |
334
343
  | switch | `Toggle` in a `Form` row (`.toggleStyle(.switch)`); the description is the row's secondary line | `Switch` in a `ListItem` with `trailingContent` | While a change saves, disable the control or show a `ProgressView` / `CircularProgressIndicator` beside it and put the value back if it fails. |
344
+ | statTile | A `VStack` of `Text`s with `.accessibilityElement(children: .combine)` | A `Column` with `Modifier.semantics(mergeDescendants = true)` | Not colored by good or bad. Numbers: `.number.notation(.compactName)` / `.currency(code:)` on Apple; `CompactDecimalFormat` / `NumberFormat.getCurrencyInstance` on Android. Loading: `.redacted(reason: .placeholder)`. |
335
345
  | tab | `TabView` or segmented `Picker` | `PrimaryTabRow` | One `Tab` inside `TabView` or one segment / one `Tab`. `TabRow` is deprecated in Material 3. |
336
346
  | tableCell | A `TableColumn` content view | `Text` in a `Row` with `Modifier.weight` | Material 3 has no table. |
337
- | tableContainer | `Table` | `LazyColumn` of `Row`s | Material 3 has no table. A compact-width iPhone `Table` shows only its first column. |
347
+ | tableContainer | `Table` | `LazyColumn` of `Row`s | 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 }`. |
338
348
  | tableHeader | The `Table` column headers (`TableColumn` titles) | A header `Row` as the first `LazyColumn` item | Material 3 has no table. |
339
- | tableHeaderCell | A `TableColumn` title | `Text` in the header `Row` | Material 3 has no table. |
349
+ | tableHeaderCell | A `TableColumn` title | `Text` in the header `Row` | Material 3 has no table. `sort`: `TableColumn(…, sortUsing:)` with a `KeyPathComparator`; on Android a clickable header `Text` with `semantics { stateDescription = "Sorted ascending" }`. |
340
350
  | tableRow | `TableRow` | `Row` | Material 3 has no table. |
341
351
  | tabsContainer | `TabView` or segmented `Picker` | `PrimaryTabRow` | `TabRow` is deprecated in Material 3. |
342
352
  | tag | `ODSTag` | `OdsTag` | A count on a list row or tab stays `.badge` / `Badge`. A tag that acts: wrap `ODSTag` in a `Button` with the plain style; on Android use a Material `AssistChip` or `FilterChip`, which are made to be pressed. |
343
353
  | textarea | `TextField(_:text:axis: .vertical)` or `TextEditor` | `OutlinedTextField` with `minLines` | |
344
354
  | textField | `TextField` (`SecureField` for passwords) | `OutlinedTextField` or `TextField` | |
345
355
  | timeStamp | `Text(_:style:)` (`.relative`) or `Text(_:format:)` (`.dateTime`) | `Text` with `DateUtils.getRelativeTimeSpanString` or `DateTimeFormatter.ofLocalizedDateTime` | |
356
+ | titleBar | `.navigationTitle` with `.toolbar` items | `TopAppBar` with `navigationIcon` and `actions` | The main action stays in the toolbar; the rest go in a `Menu` / an overflow `DropdownMenu`. |
346
357
  | toaster | `ODSBanner` for an inline message; a system banner (a local notification) when the app is not in front | `Snackbar` in a `SnackbarHost` | SwiftUI has no toast, so ODS adds none: show the message in the screen. |
347
358
  | tooltip | `.help` | `TooltipBox` | `.help` shows on pointer hover only. `TooltipBox` needs `@OptIn(ExperimentalMaterial3Api::class)`. |
348
359
  | userImage | `ODSAvatar` | `OdsAvatar` | Load the picture yourself and pass it as an `Image` / a `Painter`. |
@@ -460,6 +471,22 @@ Answer: A problem with one field shows under that field, through the field's `er
460
471
 
461
472
  File: cases/form-errors.md
462
473
 
474
+ ### A number shows its unit and never shows 0 for unknown
475
+
476
+ A page shows counts, money, sizes, shares or changes.
477
+
478
+ Answer: Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. Money has its symbol and two decimals: '$1,240.00'. A cost under a cent reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. It has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.
479
+
480
+ File: cases/number-format.md
481
+
482
+ ### On a phone, a sidebar opens as a drawer and a list opens its detail
483
+
484
+ A layout with a sidebar, a list beside its detail, or a side pane meets a phone screen.
485
+
486
+ Answer: An app's sidebar opens in a `Drawer` from the start side, from a 'Menu' `IconButton` at the start of a top bar that names the place. `AppShell` does this. The Drawer closes on a choice, on Close, on Escape, on the scrim and when the window widens. A list beside its detail becomes two screens: the list, then the detail with a Back Button named for the list, as `SettingsLayout` does. A settings nav is such a list. A side pane takes the whole content area and has Close. It is never squeezed beside the content. A site's links go into the same kind of menu, and one main action may stay in the bar. Nothing is hidden on a phone without a way to reach it. There is no bottom tab bar on the web.
487
+
488
+ File: cases/phone-navigation.md
489
+
463
490
  ### A setting saves in place, or with one Save Button
464
491
 
465
492
  A person changes a setting.
@@ -486,15 +513,20 @@ File: cases/success-feedback.md
486
513
  | Agent question | The agent needs an answer from the person before it can go on. It needs a fact or a decision only the person has. For ways forward in its own work, see the case 'Agent options'. | cases/agent-question.md |
487
514
  | Agent settings | An admin sets which model the agent uses, how it picks one, what it should know about the team and how much it may spend. | cases/agent-settings.md |
488
515
  | API keys | A person makes keys that let a script or a service use the product as them, and revokes keys they no longer use. | cases/api-keys.md |
516
+ | App shell | A person opens the product and moves between its places, such as Inbox, Tasks and Settings, from every page. | cases/app-shell.md |
489
517
  | Document card | The agent made a document for the person, such as a plan or a report. | cases/artifact-card.md |
490
518
  | Login check loading | The app is checking whether the person is logged in, or running a step such as checking an invite, before it knows what to show. | cases/auth-gate-loading.md |
519
+ | Billing page | A workspace pays for a plan. One page says what it pays for, what it has used, how it pays and what it has paid. | cases/billing-page.md |
520
+ | Breakdown of a total | A page shows how a total splits into parts, such as responses by model or comments by project. | cases/breakdown-list.md |
491
521
  | Check your email | A person signed up, and the product sent a link to confirm their email. | cases/check-your-email.md |
492
522
  | Collapsible search | A person filters a list by a word, and the list should keep its room when they are not typing. | cases/collapsible-search.md |
493
- | Composer at a limit | The agent cannot be called from the composer because the workspace reached a limit, such as its agent replies for the month. | cases/composer-limit.md |
523
+ | Composer at a limit | The agent cannot be called from the composer because the workspace reached a limit, such as its AI agent responses for the month. | cases/composer-limit.md |
494
524
  | Delete confirm | A person asks to delete or remove something, and it cannot be undone. | cases/confirm-destructive-action.md |
495
525
  | Conversation starters | A thread has no messages yet, and the person may not know what to write first. | cases/conversation-starters.md |
496
526
  | Create modal | A person creates something new, such as a project or a task, and it needs a name before it exists. | cases/create-modal.md |
497
527
  | Danger zone | A settings page offers actions that are hard or impossible to undo, such as deleting an account or a workspace, or leaving one. | cases/danger-zone.md |
528
+ | Dashboard | A page that opens an app and says how things are going and what waits on the person. | cases/dashboard.md |
529
+ | Data table page | A page is one long table of records, such as invoices or customers, that a person searches, sorts and acts on. | cases/data-table-page.md |
498
530
  | Device login | A CLI, an editor or another app opened the browser so the person can log in, and the login must reach that app. | cases/device-login.md |
499
531
  | Email confirmed | A person opened the link that confirms their email. | cases/email-confirmed.md |
500
532
  | Empty list | A list has loaded, and there is nothing in it yet. | cases/empty-list.md |
@@ -508,9 +540,11 @@ File: cases/success-feedback.md
508
540
  | Form feedback | A person submits a small form, such as a settings field, and the request ends. The three options are the three outcomes of one save: it worked in place, it failed, or the result is elsewhere. | cases/inline-form-feedback.md |
509
541
  | Integrations | A person connects the product to other tools, sees which ones are connected and disconnects them. | cases/integrations-list.md |
510
542
  | Member invite | A person invites someone to join a workspace. | cases/invite-member.md |
543
+ | Invoices | A billing page lists what the workspace has paid, so an admin can find an invoice, check an amount and keep a copy. | cases/invoice-list.md |
511
544
  | Load failure | A list or a section could not load. | cases/load-failure.md |
512
545
  | Log-out confirm | A person chooses Log Out. | cases/log-out-confirm.md |
513
546
  | Login page | A person who already has an account opens the product and is not logged in. | cases/login-page.md |
547
+ | List and detail | A person opens an item from a list, such as a message or a report, and reads or acts on it. | cases/master-detail.md |
514
548
  | Members | An admin sees who is in the workspace, changes their roles, removes people and invites more. | cases/members-list.md |
515
549
  | Mention list | A person types @ in the message box to name someone, or the agent. | cases/mention-list.md |
516
550
  | Message actions | A person acts on one message: reacts to it, copies it, edits or deletes it. | cases/message-actions.md |
@@ -519,14 +553,21 @@ File: cases/success-feedback.md
519
553
  | Message edit | A person changes the text of a message they sent. | cases/message-edit.md |
520
554
  | Reactions | People answer a message with an emoji instead of a reply. | cases/message-reactions.md |
521
555
  | Message row | A thread shows messages from people, and sometimes from an agent. | cases/message-row.md |
556
+ | Menu on a phone | A site's links and actions do not fit in the bar on a phone, and the person still needs to reach every one. | cases/mobile-menu.md |
522
557
  | Page not found | A person opens a link to a page that does not exist. | cases/not-found-page.md |
523
558
  | Notification setting | A person chooses how much a channel or a thread notifies them. | cases/notification-menu.md |
524
559
  | OAuth consent | Another app, such as a CLI or an MCP client, asks to act for a person who is logged in, and the person must allow it. | cases/oauth-consent.md |
525
560
  | On and off settings | A person turns things on and off, such as which notifications they get. | cases/on-off-settings.md |
561
+ | On this page | A person reads a long page and wants to see its sections, jump to one and know which one they are in. | cases/on-this-page.md |
526
562
  | More menu | A person opens a menu of less common actions, behind one button, for a thing or for the page. | cases/overflow-menu.md |
563
+ | Page header with actions | A page names itself at the top and offers what the person can do with it. | cases/page-header.md |
564
+ | Short list on a dashboard | A dashboard section lists things that wait on the person, such as questions or comments, and the list may be longer than the section. | cases/paged-card.md |
565
+ | Payment method | A workspace pays by card. The admin sees which card, changes it or removes it. | cases/payment-method.md |
566
+ | Plan change confirm | An admin chose another plan. Before anything changes they need to know what it costs and when it starts. | cases/plan-change-confirm.md |
567
+ | Plan picker | An admin compares the plans a workspace can be on and chooses one. | cases/plan-picker.md |
527
568
  | Profile | A person changes how they appear and how they sign in: their picture, their name and their password. | cases/profile-form.md |
528
569
  | Quick switcher | A person jumps to a channel, task or document by typing part of its name, from anywhere in the product. | cases/quick-switcher.md |
529
- | Range switch | A person changes the time range of a chart or a list on the same page, such as Week, Month or Quarter. | cases/range-switch.md |
570
+ | Range switch | A person changes the time range of the numbers or a list on the same page, such as Week, Month or Quarter. | cases/range-switch.md |
530
571
  | Rename | A person renames something, such as a project or a channel. | cases/rename.md |
531
572
  | Reply feedback | The agent has replied, and the person can say whether the reply helped. | cases/reply-feedback.md |
532
573
  | Reply sources | The agent answered from things it read, and the person may want to check them. | cases/reply-sources.md |
@@ -534,10 +575,18 @@ File: cases/success-feedback.md
534
575
  | Scope picker | A person chooses where a search or a question looks, such as one workspace or all of them. | cases/scope-picker.md |
535
576
  | Set new password | A person opened the link to reset their password and now chooses a new one. | cases/set-new-password.md |
536
577
  | Settings page | A person opens the settings of the product and looks for one area, such as Profile or Billing. | cases/settings-page.md |
578
+ | Side pane | A person opens more about the page, such as its members, its history or a document, without leaving the page. | cases/side-pane.md |
579
+ | Sidebar with sections and counts | A person looks down the sidebar for a place, and for what has something new in it. | cases/sidebar-nav.md |
537
580
  | Sign-up page | A person who has no account yet opens the product and wants one. | cases/sign-up-page.md |
581
+ | Site footer | A person reaches the end of a site's page and looks for the pages that are not in the header, and who runs the site. | cases/site-footer.md |
582
+ | Site header | A site's pages name the site at the top and show the person where to go and what to do next. | cases/site-header.md |
538
583
  | Command list | A person types / at the start of the message box to run a command. | cases/slash-command-list.md |
584
+ | Stat row | A page opens with the few numbers that say how things are going, counted over one range. | cases/stat-row.md |
585
+ | Status in a row | A row in a table or a list says what state its thing is in, such as an invoice, a plan or a connection. ODS has no separate Badge part, because `Tag` does a Badge's job. | cases/status-label.md |
539
586
  | Tag filter | A person filters a list by a tag, and adds, renames and deletes the tags themselves. | cases/tag-filter.md |
587
+ | Theme switcher | A person chooses between a light page, a dark page, or the one their device uses. | cases/theme-switcher.md |
540
588
  | Type to confirm | A person asks to delete something large that cannot be brought back, such as a workspace or an account. | cases/type-to-confirm.md |
541
589
  | Typing line | Other people in the thread are writing a message that has not arrived yet. | cases/typing-and-status.md |
542
590
  | Unsaved changes | A person closes or leaves something they changed and did not save. | cases/unsaved-changes-guard.md |
543
591
  | Upgrade prompt | A person reaches something their plan does not include, or a limit of their plan. | cases/upgrade-prompt.md |
592
+ | Usage against limits | A plan limits some things, such as AI agent responses, members and storage. The admin checks how close the workspace is. | cases/usage-meters.md |
@@ -0,0 +1 @@
1
+ export default function AppShellSidebar(): import("react").JSX.Element;
@@ -0,0 +1,124 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import AppShell from '../../components/appShell';
4
+ import TitleBar from '../../components/titleBar';
5
+ import Navigation, { NavigationGroup } from '../../components/navigation';
6
+ import MenuItem from '../../components/menuItem';
7
+ import Modal from '../../components/modal';
8
+ import Heading from '../../components/heading';
9
+ import Paragraph from '../../components/paragraph';
10
+ import Button from '../../components/button';
11
+ import UserImage from '../../components/userImage';
12
+ import Popover from '../../components/popover';
13
+ import Menu from '../../components/menu';
14
+ import Line from '../../components/line';
15
+ import useHotkey from '../../components/useHotkey';
16
+ import { Center, Cluster, Stack } from '../../components/layout';
17
+ // The places. The top bar on a phone names the place; the page's own title is the level 1 heading, so a phone never shows the same words twice.
18
+ var places = [
19
+ { id: 'inbox', label: 'Inbox', icon: 'Inbox', group: 'Mail', page: 'Unread messages', text: 'Ben Carter shared the launch plan. Omar Reyes asked for the new screens by Friday.' },
20
+ { id: 'sent', label: 'Sent', icon: 'Send', group: 'Mail', page: 'Sent this week', text: 'You sent 4 messages this week.' },
21
+ { id: 'website', label: 'Website', icon: 'Globe', group: 'Projects', page: 'Home page redesign', text: '12 tasks are open. The next review is on Thursday.' },
22
+ { id: 'mobile', label: 'Mobile App', icon: 'Smartphone', group: 'Projects', page: 'Version 2 release', text: '5 tasks are open. Dana Lee owns the release.' },
23
+ ];
24
+ var groups = ['Mail', 'Projects'];
25
+ // A real app reads this from the session.
26
+ var me = 'Dana Lee';
27
+ export default function AppShellSidebar() {
28
+ var _a;
29
+ var _b = useState('inbox'), placeId = _b[0], setPlaceId = _b[1];
30
+ // Below md the sidebar is a Drawer; this says whether it is open.
31
+ var _c = useState(false), navOpen = _c[0], setNavOpen = _c[1];
32
+ // From md up the person can hide the column for room. The phone menu still has it.
33
+ var _d = useState(false), hidden = _d[0], setHidden = _d[1];
34
+ var _e = useState(null), accountAnchor = _e[0], setAccountAnchor = _e[1];
35
+ var _f = useState(false), accountOpen = _f[0], setAccountOpen = _f[1];
36
+ var _g = useState(false), confirming = _g[0], setConfirming = _g[1];
37
+ var _h = useState(false), loggingOut = _h[0], setLoggingOut = _h[1];
38
+ var _j = useState(false), loggedOut = _j[0], setLoggedOut = _j[1];
39
+ var timer = useRef();
40
+ var accountButton = useRef(null);
41
+ // Where focus goes after the next render, once the element it goes to is on screen.
42
+ var focusNext = useRef();
43
+ // Stops the request if the example goes away before it ends.
44
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
45
+ useEffect(function () {
46
+ var move = focusNext.current;
47
+ focusNext.current = undefined;
48
+ move === null || move === void 0 ? void 0 : move();
49
+ });
50
+ // Cmd+B, or Ctrl+B. It does nothing while the person types in a field, and nothing while the Log Out confirm is open.
51
+ useHotkey('b', function () {
52
+ if (!confirming)
53
+ setHidden(function (h) { return !h; });
54
+ });
55
+ var place = (_a = places.find(function (p) { return p.id === placeId; })) !== null && _a !== void 0 ? _a : places[0];
56
+ // Cancel, Escape and a click outside. 'Cancel' puts focus back on the account Button, inside the Drawer on a phone.
57
+ function cancelLogOut() {
58
+ if (loggingOut)
59
+ return;
60
+ setConfirming(false);
61
+ focusNext.current = function () { var _a; return (_a = accountButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
62
+ }
63
+ function logOut() {
64
+ if (loggingOut)
65
+ return;
66
+ setLoggingOut(true);
67
+ // Stands in for the request to the server.
68
+ timer.current = setTimeout(function () {
69
+ setLoggingOut(false);
70
+ setConfirming(false);
71
+ setLoggedOut(true);
72
+ }, 1200);
73
+ }
74
+ // A real app goes to its login page here. The example shows a short logged-out page instead.
75
+ if (loggedOut) {
76
+ return (<Center fill>
77
+ <Heading level={1} size="h5">You are logged out</Heading>
78
+ <Cluster>
79
+ <Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={function () { setLoggedOut(false); setPlaceId('inbox'); }}/>
80
+ </Cluster>
81
+ </Center>);
82
+ }
83
+ // The sidebar is mounted once: in the column from md up, in the Drawer below it. Its Modal lives inside it.
84
+ var sidebar = (<Navigation aria-label="Main">
85
+ <Paragraph size="body1" measure="none">Acme</Paragraph>
86
+ {groups.map(function (group) { return (<NavigationGroup key={group} label={group}>
87
+ {places.filter(function (p) { return p.group === group; }).map(function (p) { return (<MenuItem key={p.id} size="small" label={p.label} iconName={p.icon} href={"/".concat(p.id)} isSelected={p.id === place.id} aria-current={p.id === place.id ? 'page' : undefined} onClick={function (event) {
88
+ // A real app lets the link go to its page. The example keeps the choice in state.
89
+ event.preventDefault();
90
+ setPlaceId(p.id);
91
+ }}/>); })}
92
+ </NavigationGroup>); })}
93
+ <Line />
94
+ {/* The account menu is last. */}
95
+ <Cluster>
96
+ <Button ref={accountButton} size="small" type="tertiary" state={accountOpen ? 'selected' : 'enabled'} label={me} decoIcon={<UserImage userHandle={me} size={20} decorative/>} aria-label={"".concat(me, ", account menu")} aria-haspopup="menu" aria-expanded={accountOpen} onClickButton={function (e) {
97
+ setAccountAnchor(e.currentTarget);
98
+ setAccountOpen(function (o) { return !o; });
99
+ }}/>
100
+ </Cluster>
101
+ <Popover open={accountOpen} anchorEl={accountAnchor} onClose={function () { return setAccountOpen(false); }} returnFocus>
102
+ <Menu navigable aria-label="Account" width={200}>
103
+ {/* A choice in a Popover does not close the phone menu: close it here. */}
104
+ <MenuItem size="small" iconName="Settings" label="Settings" onClick={function () { setAccountOpen(false); setNavOpen(false); }}/>
105
+ <MenuItem size="small" iconName="CircleHelp" label="Help" onClick={function () { setAccountOpen(false); setNavOpen(false); }}/>
106
+ <Line />
107
+ <MenuItem size="small" iconName="LogOut" label="Log Out" onClick={function () { setAccountOpen(false); setConfirming(true); }}/>
108
+ </Menu>
109
+ </Popover>
110
+ <Modal isOpen={confirming} size="small" title="Log Out" onClose={cancelLogOut} actions={<>
111
+ <Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={cancelLogOut}/>
112
+ <Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={logOut}/>
113
+ </>}>
114
+ <Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
115
+ </Modal>
116
+ </Navigation>);
117
+ var newMessage = <Button size="medium" type="primary" state="enabled" label="New Message" decoIcon="Plus"/>;
118
+ return (<AppShell title={place.label} navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} sidebarHidden={hidden} onSidebarHiddenChange={setHidden}>
119
+ <Stack gap="large">
120
+ <TitleBar title={place.page} actions={newMessage}/>
121
+ <Paragraph tone="secondary" measure="none">{place.text}</Paragraph>
122
+ </Stack>
123
+ </AppShell>);
124
+ }
@@ -0,0 +1 @@
1
+ export default function AppShellTopTabs(): import("react").JSX.Element;
@@ -0,0 +1,106 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import TitleBar from '../../components/titleBar';
4
+ import TabsContainer from '../../components/tabsContainer';
5
+ import Tab from '../../components/tab';
6
+ import Modal from '../../components/modal';
7
+ import Heading from '../../components/heading';
8
+ import Paragraph from '../../components/paragraph';
9
+ import Button from '../../components/button';
10
+ import UserImage from '../../components/userImage';
11
+ import Popover from '../../components/popover';
12
+ import Menu from '../../components/menu';
13
+ import MenuItem from '../../components/menuItem';
14
+ import Line from '../../components/line';
15
+ import PageShell from '../../components/pageShell';
16
+ import { Center, Cluster, Stack } from '../../components/layout';
17
+ // Four fixed places, one short word each, so the tabs fit on a phone.
18
+ var places = [
19
+ { id: 'inbox', label: 'Inbox', page: 'Unread messages', text: 'Ben Carter shared the launch plan. Omar Reyes asked for the new screens by Friday.' },
20
+ { id: 'tasks', label: 'Tasks', page: 'My tasks', text: '7 tasks are open. 2 are due this week.' },
21
+ { id: 'files', label: 'Files', page: 'Recent files', text: 'Omar Reyes added the new screens an hour ago.' },
22
+ { id: 'team', label: 'Team', page: 'People and roles', text: 'Dana Lee, Ben Carter and Omar Reyes are in Acme.' },
23
+ ];
24
+ // A real app reads this from the session.
25
+ var me = 'Dana Lee';
26
+ export default function AppShellTopTabs() {
27
+ var _a;
28
+ var _b = useState('inbox'), placeId = _b[0], setPlaceId = _b[1];
29
+ var _c = useState(null), accountAnchor = _c[0], setAccountAnchor = _c[1];
30
+ var _d = useState(false), accountOpen = _d[0], setAccountOpen = _d[1];
31
+ var _e = useState(false), confirming = _e[0], setConfirming = _e[1];
32
+ var _f = useState(false), loggingOut = _f[0], setLoggingOut = _f[1];
33
+ var _g = useState(false), loggedOut = _g[0], setLoggedOut = _g[1];
34
+ var timer = useRef();
35
+ var accountButton = useRef(null);
36
+ // Where focus goes after the next render, once the element it goes to is on screen.
37
+ var focusNext = useRef();
38
+ // Stops the request if the example goes away before it ends.
39
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
40
+ useEffect(function () {
41
+ var move = focusNext.current;
42
+ focusNext.current = undefined;
43
+ move === null || move === void 0 ? void 0 : move();
44
+ });
45
+ var place = (_a = places.find(function (p) { return p.id === placeId; })) !== null && _a !== void 0 ? _a : places[0];
46
+ // A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open place.
47
+ var router = { push: function (url) { var _a; return setPlaceId((_a = url.split('/').pop()) !== null && _a !== void 0 ? _a : 'inbox'); } };
48
+ // 'Cancel' puts focus back on the account Button.
49
+ function cancelLogOut() {
50
+ if (loggingOut)
51
+ return;
52
+ setConfirming(false);
53
+ focusNext.current = function () { var _a; return (_a = accountButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
54
+ }
55
+ function logOut() {
56
+ if (loggingOut)
57
+ return;
58
+ setLoggingOut(true);
59
+ // Stands in for the request to the server.
60
+ timer.current = setTimeout(function () {
61
+ setLoggingOut(false);
62
+ setConfirming(false);
63
+ setLoggedOut(true);
64
+ }, 1200);
65
+ }
66
+ // A real app goes to its login page here. The example shows a short logged-out page instead.
67
+ if (loggedOut) {
68
+ return (<Center fill>
69
+ <Heading level={1} size="h5">You are logged out</Heading>
70
+ <Cluster>
71
+ <Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={function () { setLoggedOut(false); setPlaceId('inbox'); }}/>
72
+ </Cluster>
73
+ </Center>);
74
+ }
75
+ return (<PageShell>
76
+ <Stack gap="large">
77
+ {/* The app's name at the start, the account menu at the end. */}
78
+ <Cluster justify="between">
79
+ <Paragraph size="body1" measure="none">Acme</Paragraph>
80
+ <Button ref={accountButton} size="small" type="tertiary" state={accountOpen ? 'selected' : 'enabled'} label={me} decoIcon={<UserImage userHandle={me} size={20} decorative/>} aria-label={"".concat(me, ", account menu")} aria-haspopup="menu" aria-expanded={accountOpen} onClickButton={function (e) {
81
+ setAccountAnchor(e.currentTarget);
82
+ setAccountOpen(function (o) { return !o; });
83
+ }}/>
84
+ </Cluster>
85
+ <TabsContainer fill>
86
+ {places.map(function (p) { return (<Tab key={p.id} label={p.label} href={"/".concat(p.id)} router={router} isSelected={p.id === place.id} onClickTab={function () { return setPlaceId(p.id); }}/>); })}
87
+ </TabsContainer>
88
+ <TitleBar title={place.page} actions={<Button size="medium" type="primary" state="enabled" label="New Message" decoIcon="Plus"/>}/>
89
+ <Paragraph tone="secondary" measure="none">{place.text}</Paragraph>
90
+ </Stack>
91
+ <Popover open={accountOpen} anchorEl={accountAnchor} onClose={function () { return setAccountOpen(false); }} returnFocus>
92
+ <Menu navigable aria-label="Account" width={200}>
93
+ <MenuItem size="small" iconName="Settings" label="Settings" onClick={function () { return setAccountOpen(false); }}/>
94
+ <MenuItem size="small" iconName="CircleHelp" label="Help" onClick={function () { return setAccountOpen(false); }}/>
95
+ <Line />
96
+ <MenuItem size="small" iconName="LogOut" label="Log Out" onClick={function () { setAccountOpen(false); setConfirming(true); }}/>
97
+ </Menu>
98
+ </Popover>
99
+ <Modal isOpen={confirming} size="small" title="Log Out" onClose={cancelLogOut} actions={<>
100
+ <Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={cancelLogOut}/>
101
+ <Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={logOut}/>
102
+ </>}>
103
+ <Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
104
+ </Modal>
105
+ </PageShell>);
106
+ }