oneslash-design-system 2.17.0 → 2.19.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 (282) hide show
  1. package/README.md +2 -2
  2. package/dist/DESIGN.md +55 -14
  3. package/dist/cases/accept-invite.md +1 -5
  4. package/dist/cases/account-menu/menu.d.ts +1 -0
  5. package/dist/cases/account-menu/menu.jsx +99 -0
  6. package/dist/cases/account-menu.md +164 -0
  7. package/dist/cases/agent-asks-before-risky-action.md +0 -4
  8. package/dist/cases/agent-cancels-when-unanswered.md +0 -4
  9. package/dist/cases/agent-options.md +0 -4
  10. package/dist/cases/agent-pending-reply.md +0 -4
  11. package/dist/cases/agent-plan-proposal.md +0 -4
  12. package/dist/cases/agent-question.md +0 -4
  13. package/dist/cases/agent-refuses-clearly.md +0 -4
  14. package/dist/cases/agent-says-what-it-is.md +0 -2
  15. package/dist/cases/agent-settings/form.d.ts +1 -0
  16. package/dist/cases/agent-settings/form.jsx +164 -0
  17. package/dist/cases/agent-settings.md +259 -0
  18. package/dist/cases/agent-shows-progress.md +0 -2
  19. package/dist/cases/agent-shows-sources.md +0 -2
  20. package/dist/cases/api-keys/list.d.ts +1 -0
  21. package/dist/cases/api-keys/list.jsx +162 -0
  22. package/dist/cases/api-keys.md +229 -0
  23. package/dist/cases/app-shell/sidebar.d.ts +1 -0
  24. package/dist/cases/app-shell/sidebar.jsx +124 -0
  25. package/dist/cases/app-shell/top-tabs.d.ts +1 -0
  26. package/dist/cases/app-shell/top-tabs.jsx +106 -0
  27. package/dist/cases/app-shell.md +364 -0
  28. package/dist/cases/artifact-card/card.jsx +32 -6
  29. package/dist/cases/artifact-card.md +55 -11
  30. package/dist/cases/auth-gate-loading.md +0 -4
  31. package/dist/cases/check-your-email.md +0 -4
  32. package/dist/cases/collapsible-search/popover.d.ts +1 -0
  33. package/dist/cases/collapsible-search/popover.jsx +74 -0
  34. package/dist/cases/collapsible-search.md +143 -0
  35. package/dist/cases/composer-limit.md +0 -4
  36. package/dist/cases/confirm-destructive-action.md +0 -4
  37. package/dist/cases/confirm-dialogs.md +0 -4
  38. package/dist/cases/conversation-starters.md +0 -4
  39. package/dist/cases/create-modal.md +0 -4
  40. package/dist/cases/danger-zone/collapsed.d.ts +1 -0
  41. package/dist/cases/danger-zone/collapsed.jsx +75 -0
  42. package/dist/cases/danger-zone/shown.d.ts +1 -0
  43. package/dist/cases/danger-zone/shown.jsx +95 -0
  44. package/dist/cases/danger-zone.md +263 -0
  45. package/dist/cases/device-login.md +0 -4
  46. package/dist/cases/email-confirmed.md +0 -4
  47. package/dist/cases/empty-list.md +0 -4
  48. package/dist/cases/empty-lists.md +0 -4
  49. package/dist/cases/empty-not-set-up.md +0 -4
  50. package/dist/cases/empty-search.md +0 -4
  51. package/dist/cases/error-page/in-shell.jsx +26 -17
  52. package/dist/cases/error-page.md +42 -25
  53. package/dist/cases/feedback-form.md +0 -4
  54. package/dist/cases/filter-menu/presets.d.ts +1 -0
  55. package/dist/cases/filter-menu/presets.jsx +53 -0
  56. package/dist/cases/filter-menu/with-clear.d.ts +1 -0
  57. package/dist/cases/filter-menu/with-clear.jsx +56 -0
  58. package/dist/cases/filter-menu.md +204 -0
  59. package/dist/cases/forgot-password.md +0 -4
  60. package/dist/cases/form-errors.md +0 -4
  61. package/dist/cases/import-checklist.md +0 -4
  62. package/dist/cases/inline-form-feedback.md +0 -4
  63. package/dist/cases/integrations-list/nested.d.ts +1 -0
  64. package/dist/cases/integrations-list/nested.jsx +164 -0
  65. package/dist/cases/integrations-list/rows.d.ts +1 -0
  66. package/dist/cases/integrations-list/rows.jsx +134 -0
  67. package/dist/cases/integrations-list.md +379 -0
  68. package/dist/cases/invite-member.md +0 -4
  69. package/dist/cases/load-failure.md +0 -4
  70. package/dist/cases/log-out-confirm.md +0 -4
  71. package/dist/cases/login-page.md +0 -4
  72. package/dist/cases/master-detail/list-then-page.d.ts +1 -0
  73. package/dist/cases/master-detail/list-then-page.jsx +65 -0
  74. package/dist/cases/master-detail/split.d.ts +1 -0
  75. package/dist/cases/master-detail/split.jsx +49 -0
  76. package/dist/cases/master-detail.md +213 -0
  77. package/dist/cases/members-list/rows.d.ts +1 -0
  78. package/dist/cases/members-list/rows.jsx +318 -0
  79. package/dist/cases/members-list/table.d.ts +1 -0
  80. package/dist/cases/members-list/table.jsx +351 -0
  81. package/dist/cases/members-list.md +799 -0
  82. package/dist/cases/mention-list.md +0 -4
  83. package/dist/cases/message-actions.md +0 -4
  84. package/dist/cases/message-attachments.md +0 -4
  85. package/dist/cases/message-composer.md +0 -4
  86. package/dist/cases/message-edit.md +0 -4
  87. package/dist/cases/message-reactions.md +0 -4
  88. package/dist/cases/message-row.md +0 -4
  89. package/dist/cases/mobile-menu/links.d.ts +1 -0
  90. package/dist/cases/mobile-menu/links.jsx +24 -0
  91. package/dist/cases/mobile-menu/sections.d.ts +1 -0
  92. package/dist/cases/mobile-menu/sections.jsx +61 -0
  93. package/dist/cases/mobile-menu.md +170 -0
  94. package/dist/cases/not-found-page/in-shell.jsx +26 -17
  95. package/dist/cases/not-found-page.md +41 -24
  96. package/dist/cases/notification-menu/menu.d.ts +1 -0
  97. package/dist/cases/notification-menu/menu.jsx +74 -0
  98. package/dist/cases/notification-menu.md +135 -0
  99. package/dist/cases/oauth-consent.md +0 -4
  100. package/dist/cases/on-off-settings/list.d.ts +1 -0
  101. package/dist/cases/on-off-settings/list.jsx +97 -0
  102. package/dist/cases/on-off-settings.md +116 -0
  103. package/dist/cases/on-this-page/aside.d.ts +1 -0
  104. package/dist/cases/on-this-page/aside.jsx +39 -0
  105. package/dist/cases/on-this-page.md +80 -0
  106. package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
  107. package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
  108. package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
  109. package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
  110. package/dist/cases/overflow-menu.md +410 -0
  111. package/dist/cases/page-header/actions.d.ts +1 -0
  112. package/dist/cases/page-header/actions.jsx +65 -0
  113. package/dist/cases/page-header/sub-page.d.ts +1 -0
  114. package/dist/cases/page-header/sub-page.jsx +37 -0
  115. package/dist/cases/page-header.md +195 -0
  116. package/dist/cases/phone-navigation.md +32 -0
  117. package/dist/cases/profile-form/form.d.ts +1 -0
  118. package/dist/cases/profile-form/form.jsx +153 -0
  119. package/dist/cases/profile-form.md +236 -0
  120. package/dist/cases/quick-switcher/modal.d.ts +1 -0
  121. package/dist/cases/quick-switcher/modal.jsx +114 -0
  122. package/dist/cases/quick-switcher.md +205 -0
  123. package/dist/cases/range-switch/segmented.d.ts +1 -0
  124. package/dist/cases/range-switch/segmented.jsx +30 -0
  125. package/dist/cases/range-switch.md +67 -0
  126. package/dist/cases/rename.md +0 -4
  127. package/dist/cases/reply-feedback.md +0 -4
  128. package/dist/cases/reply-sources.md +0 -4
  129. package/dist/cases/route-loading/region.jsx +27 -18
  130. package/dist/cases/route-loading.md +42 -23
  131. package/dist/cases/scope-picker/menu.d.ts +1 -0
  132. package/dist/cases/scope-picker/menu.jsx +47 -0
  133. package/dist/cases/scope-picker.md +97 -0
  134. package/dist/cases/set-new-password.md +0 -4
  135. package/dist/cases/settings-page/side-nav.d.ts +1 -0
  136. package/dist/cases/settings-page/side-nav.jsx +171 -0
  137. package/dist/cases/settings-page/top-tabs.d.ts +1 -0
  138. package/dist/cases/settings-page/top-tabs.jsx +129 -0
  139. package/dist/cases/settings-page.md +378 -0
  140. package/dist/cases/settings-save.md +35 -0
  141. package/dist/cases/side-pane/beside.d.ts +1 -0
  142. package/dist/cases/side-pane/beside.jsx +79 -0
  143. package/dist/cases/side-pane/over.d.ts +1 -0
  144. package/dist/cases/side-pane/over.jsx +58 -0
  145. package/dist/cases/side-pane.md +238 -0
  146. package/dist/cases/sidebar-nav/flat.d.ts +1 -0
  147. package/dist/cases/sidebar-nav/flat.jsx +81 -0
  148. package/dist/cases/sidebar-nav/nested.d.ts +1 -0
  149. package/dist/cases/sidebar-nav/nested.jsx +122 -0
  150. package/dist/cases/sidebar-nav.md +261 -0
  151. package/dist/cases/sign-up-page.md +1 -5
  152. package/dist/cases/site-footer/columns.d.ts +1 -0
  153. package/dist/cases/site-footer/columns.jsx +51 -0
  154. package/dist/cases/site-footer/simple.d.ts +1 -0
  155. package/dist/cases/site-footer/simple.jsx +24 -0
  156. package/dist/cases/site-footer.md +133 -0
  157. package/dist/cases/site-header/links.d.ts +1 -0
  158. package/dist/cases/site-header/links.jsx +26 -0
  159. package/dist/cases/site-header/sections.d.ts +1 -0
  160. package/dist/cases/site-header/sections.jsx +64 -0
  161. package/dist/cases/site-header.md +183 -0
  162. package/dist/cases/slash-command-list.md +0 -4
  163. package/dist/cases/success-feedback.md +0 -4
  164. package/dist/cases/tag-filter/tags.d.ts +1 -0
  165. package/dist/cases/tag-filter/tags.jsx +226 -0
  166. package/dist/cases/tag-filter.md +298 -0
  167. package/dist/cases/theme-switcher/menu.d.ts +1 -0
  168. package/dist/cases/theme-switcher/menu.jsx +47 -0
  169. package/dist/cases/theme-switcher/segmented.d.ts +1 -0
  170. package/dist/cases/theme-switcher/segmented.jsx +26 -0
  171. package/dist/cases/theme-switcher.md +149 -0
  172. package/dist/cases/type-to-confirm.md +0 -4
  173. package/dist/cases/typing-and-status.md +0 -4
  174. package/dist/cases/unsaved-changes-guard.md +0 -4
  175. package/dist/cases/upgrade-prompt.md +0 -4
  176. package/dist/cases.json +1737 -315
  177. package/dist/components/alert.d.ts +3 -1
  178. package/dist/components/alert.jsx +2 -2
  179. package/dist/components/appShell.d.ts +44 -0
  180. package/dist/components/appShell.jsx +121 -0
  181. package/dist/components/button.jsx +5 -2
  182. package/dist/components/checkBox.d.ts +5 -1
  183. package/dist/components/checkBox.jsx +2 -2
  184. package/dist/components/copyField.d.ts +20 -0
  185. package/dist/components/copyField.jsx +99 -0
  186. package/dist/components/drawer.d.ts +31 -0
  187. package/dist/components/drawer.jsx +121 -0
  188. package/dist/components/formField.d.ts +34 -0
  189. package/dist/components/formField.jsx +28 -0
  190. package/dist/components/heading.d.ts +5 -1
  191. package/dist/components/heading.jsx +2 -2
  192. package/dist/components/link.d.ts +6 -1
  193. package/dist/components/link.jsx +11 -3
  194. package/dist/components/menu.jsx +2 -2
  195. package/dist/components/menuItem.d.ts +10 -2
  196. package/dist/components/menuItem.jsx +4 -3
  197. package/dist/components/modal.jsx +12 -23
  198. package/dist/components/navigation.d.ts +9 -1
  199. package/dist/components/navigation.jsx +15 -3
  200. package/dist/components/onThisPage.d.ts +29 -0
  201. package/dist/components/onThisPage.jsx +151 -0
  202. package/dist/components/pageShell.d.ts +7 -1
  203. package/dist/components/pageShell.jsx +14 -1
  204. package/dist/components/popover.jsx +4 -0
  205. package/dist/components/radioGroup.d.ts +5 -1
  206. package/dist/components/radioGroup.jsx +2 -2
  207. package/dist/components/segmentedControl.d.ts +22 -0
  208. package/dist/components/segmentedControl.jsx +54 -0
  209. package/dist/components/select.d.ts +5 -1
  210. package/dist/components/select.jsx +2 -2
  211. package/dist/components/settingsSection.d.ts +36 -0
  212. package/dist/components/settingsSection.jsx +65 -0
  213. package/dist/components/sidePane.d.ts +32 -0
  214. package/dist/components/sidePane.jsx +128 -0
  215. package/dist/components/siteFooter.d.ts +24 -0
  216. package/dist/components/siteFooter.jsx +48 -0
  217. package/dist/components/siteHeader.d.ts +55 -0
  218. package/dist/components/siteHeader.jsx +125 -0
  219. package/dist/components/slidingIndicator.d.ts +50 -0
  220. package/dist/components/slidingIndicator.jsx +102 -0
  221. package/dist/components/switch.d.ts +25 -0
  222. package/dist/components/switch.jsx +55 -0
  223. package/dist/components/tab.jsx +5 -11
  224. package/dist/components/tabsContainer.jsx +5 -67
  225. package/dist/components/textField.d.ts +12 -2
  226. package/dist/components/textField.jsx +11 -4
  227. package/dist/components/textarea.d.ts +5 -1
  228. package/dist/components/textarea.jsx +3 -3
  229. package/dist/components/titleBar.d.ts +17 -0
  230. package/dist/components/titleBar.jsx +17 -0
  231. package/dist/components/useHotkey.d.ts +7 -0
  232. package/dist/components/useHotkey.js +24 -0
  233. package/dist/index.d.ts +13 -0
  234. package/dist/index.js +13 -0
  235. package/dist/internal/copyField.d.ts +5 -0
  236. package/dist/internal/copyField.js +61 -0
  237. package/dist/internal/hotkey.d.ts +16 -0
  238. package/dist/internal/hotkey.js +20 -0
  239. package/dist/internal/overlayStack.d.ts +24 -0
  240. package/dist/internal/overlayStack.js +71 -0
  241. package/dist/internal/resize.d.ts +9 -0
  242. package/dist/internal/resize.js +31 -0
  243. package/dist/internal/scrollSpy.d.ts +24 -0
  244. package/dist/internal/scrollSpy.js +53 -0
  245. package/dist/internal/siteBrand.d.ts +6 -0
  246. package/dist/internal/siteBrand.jsx +11 -0
  247. package/dist/internal/switch.d.ts +5 -0
  248. package/dist/internal/switch.js +9 -0
  249. package/dist/native-mapping.json +72 -0
  250. package/dist/stories/AppShell.stories.d.ts +15 -0
  251. package/dist/stories/AppShell.stories.jsx +137 -0
  252. package/dist/stories/Cases.generated.stories.d.ts +42 -0
  253. package/dist/stories/Cases.generated.stories.jsx +84 -0
  254. package/dist/stories/CopyField.stories.d.ts +11 -0
  255. package/dist/stories/CopyField.stories.jsx +65 -0
  256. package/dist/stories/Drawer.stories.d.ts +10 -0
  257. package/dist/stories/Drawer.stories.jsx +123 -0
  258. package/dist/stories/FormField.stories.d.ts +6 -0
  259. package/dist/stories/FormField.stories.jsx +44 -0
  260. package/dist/stories/Link.stories.d.ts +1 -0
  261. package/dist/stories/Link.stories.jsx +8 -0
  262. package/dist/stories/Navigation.stories.d.ts +1 -0
  263. package/dist/stories/Navigation.stories.jsx +17 -1
  264. package/dist/stories/OnThisPage.stories.d.ts +10 -0
  265. package/dist/stories/OnThisPage.stories.jsx +105 -0
  266. package/dist/stories/SegmentedControl.stories.d.ts +8 -0
  267. package/dist/stories/SegmentedControl.stories.jsx +33 -0
  268. package/dist/stories/SettingsSection.stories.d.ts +12 -0
  269. package/dist/stories/SettingsSection.stories.jsx +91 -0
  270. package/dist/stories/SidePane.stories.d.ts +6 -0
  271. package/dist/stories/SidePane.stories.jsx +37 -0
  272. package/dist/stories/SiteFooter.stories.d.ts +7 -0
  273. package/dist/stories/SiteFooter.stories.jsx +63 -0
  274. package/dist/stories/SiteHeader.stories.d.ts +10 -0
  275. package/dist/stories/SiteHeader.stories.jsx +94 -0
  276. package/dist/stories/Switch.stories.d.ts +14 -0
  277. package/dist/stories/Switch.stories.jsx +87 -0
  278. package/dist/stories/TextField.stories.d.ts +1 -0
  279. package/dist/stories/TextField.stories.jsx +13 -0
  280. package/dist/stories/TitleBar.stories.d.ts +6 -0
  281. package/dist/stories/TitleBar.stories.jsx +34 -0
  282. package/package.json +5 -1
@@ -0,0 +1,183 @@
1
+ # Site header
2
+
3
+ A site's pages name the site at the top and show the person where to go and what to do next.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail': below `md` the links go into a menu and one main action stays in the bar.
8
+ - Use `SiteHeader` for a few pages. Pass the brand, at most five `links`, and mark the page the person is on with `current`.
9
+ - Pass what must stay in the bar on a phone as `phoneAction`. On a product site that is the main action, named 'Open App' or 'Sign Up'. It is last at every width. Do not repeat it in `actions`.
10
+ - Pass the secondary Buttons, such as 'Log In', as `actions`. They go into the menu on a phone.
11
+ - Give `PageShell` `id` and `tabIndex={-1}` to match `mainId`, so the 'Skip to content' link moves focus into the page.
12
+ - Give a site with sections one `TabsContainer` of `Tab`s with `href`, four sections or fewer and one short word each. Pass it as `nav` to `SiteHeader` with `links` empty: it is a second row of the bar at every width.
13
+ - Pass search and the theme menu as `phoneAction`, so they stay at the end of the bar on a phone. With no `links` and no `actions` there is no menu.
14
+ - Keep the section tabs in the bar, so no section is hidden. On a phone, put the pages of the open section in a menu, as the case 'Menu on a phone' shows in 'Sections with their pages'.
15
+ - Open the theme menu as the case 'Theme switcher' says, and name the search `IconButton` 'Search'.
16
+
17
+ ## Don't
18
+
19
+ - Do not show more than five links in the bar.
20
+ - Do not show two primary Buttons in the bar.
21
+ - Do not hide a link on a phone without a menu that holds it.
22
+ - Do not put a Button that opens a Modal in `actions`. On a phone the menu closes when it is chosen, so the Modal has no Button to give focus back to. Link to a page instead.
23
+ - Do not turn a product site's few pages into tabs. Use `links`. Tabs are for sections that each hold many pages.
24
+
25
+ ## Option: Links and one main action
26
+
27
+ Use when: A product site has a few pages and one main action, such as 'Sign Up'.
28
+
29
+ Uses: `Button`, `Heading`, `PageShell`, `Paragraph`, `SiteHeader`, `Stack`
30
+
31
+ ```tsx
32
+ 'use client';
33
+ import SiteHeader from 'oneslash-design-system/components/siteHeader';
34
+ import PageShell from 'oneslash-design-system/components/pageShell';
35
+ import Button from 'oneslash-design-system/components/button';
36
+ import Heading from 'oneslash-design-system/components/heading';
37
+ import Paragraph from 'oneslash-design-system/components/paragraph';
38
+ import { Stack } from 'oneslash-design-system/components/layout';
39
+
40
+ const links = [
41
+ { label: 'Features', href: '#features' },
42
+ { label: 'Pricing', href: '#pricing', current: true },
43
+ { label: 'Changelog', href: '#changelog' },
44
+ { label: 'Docs', href: '#docs' },
45
+ ];
46
+
47
+ export default function SiteHeaderLinks() {
48
+ return (
49
+ <>
50
+ {/* From md the links are a row in the bar. Below md they and 'Log In' are in the Menu; Sign Up stays beside it. */}
51
+ <SiteHeader
52
+ brand={{ href: '#top', name: 'Acme' }}
53
+ links={links}
54
+ actions={<Button size="medium" type="tertiary" state="enabled" label="Log In" href="#log-in" />}
55
+ phoneAction={<Button size="medium" type="primary" state="enabled" label="Sign Up" href="#sign-up" />}
56
+ mainId="site-header-main"
57
+ />
58
+ {/* The skip link goes here: the id matches mainId, and tabIndex -1 lets focus move in. */}
59
+ <PageShell id="site-header-main" tabIndex={-1}>
60
+ <Stack gap="large">
61
+ <Heading level={1} size="h5">Pricing</Heading>
62
+ <Paragraph tone="secondary" measure="none">Acme is free for up to three people. Add more people when your team grows.</Paragraph>
63
+ </Stack>
64
+ </PageShell>
65
+ </>
66
+ );
67
+ }
68
+ ```
69
+
70
+ ## Option: Sections with their own tabs
71
+
72
+ Use when: A docs site has sections that each hold many pages.
73
+
74
+ Uses: `Heading`, `IconButton`, `Menu`, `MenuItem`, `PageShell`, `Paragraph`, `Popover`, `SiteHeader`, `Stack`, `Tab`, `TabsContainer`, `Tooltip`
75
+
76
+ ```tsx
77
+ 'use client';
78
+ import { useState } from 'react';
79
+ import SiteHeader from 'oneslash-design-system/components/siteHeader';
80
+ import TabsContainer from 'oneslash-design-system/components/tabsContainer';
81
+ import Tab from 'oneslash-design-system/components/tab';
82
+ import IconButton from 'oneslash-design-system/components/iconButton';
83
+ import Tooltip from 'oneslash-design-system/components/tooltip';
84
+ import Popover from 'oneslash-design-system/components/popover';
85
+ import Menu from 'oneslash-design-system/components/menu';
86
+ import MenuItem from 'oneslash-design-system/components/menuItem';
87
+ import PageShell from 'oneslash-design-system/components/pageShell';
88
+ import Heading from 'oneslash-design-system/components/heading';
89
+ import Paragraph from 'oneslash-design-system/components/paragraph';
90
+ import { Stack } from 'oneslash-design-system/components/layout';
91
+
92
+ type Mode = 'light' | 'dark' | 'system';
93
+
94
+ // Four sections, one short word each. Each holds many pages.
95
+ const sections = [
96
+ { id: 'start', label: 'Start', page: 'Start here' },
97
+ { id: 'guides', label: 'Guides', page: 'Guides' },
98
+ { id: 'reference', label: 'API', page: 'API reference' },
99
+ { id: 'updates', label: 'News', page: 'News' },
100
+ ];
101
+
102
+ const modes: { value: Mode; label: string; icon: 'Sun' | 'Moon' | 'Monitor' }[] = [
103
+ { value: 'light', label: 'Light', icon: 'Sun' },
104
+ { value: 'dark', label: 'Dark', icon: 'Moon' },
105
+ { value: 'system', label: 'System', icon: 'Monitor' },
106
+ ];
107
+
108
+ export default function SiteHeaderSections() {
109
+ const [sectionId, setSectionId] = useState('guides');
110
+ const [mode, setMode] = useState<Mode>('system');
111
+ const [anchor, setAnchor] = useState<HTMLElement | null>(null);
112
+ const [open, setOpen] = useState(false);
113
+ const section = sections.find((s) => s.id === sectionId) ?? sections[0];
114
+ const current = modes.find((m) => m.value === mode) ?? modes[2];
115
+ // A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open section.
116
+ const router = { push: (url: string) => setSectionId(url.split('/').pop() ?? 'start') };
117
+
118
+ return (
119
+ <>
120
+ {/* The brand, then search and the theme menu as `phoneAction`, so they stay in the bar at every width. The section Tabs are `nav`, a second row of the bar. */}
121
+ <SiteHeader
122
+ brand={{ href: '#top', name: 'Acme Docs' }}
123
+ links={[]}
124
+ phoneAction={
125
+ <>
126
+ <Tooltip title="Search">
127
+ <IconButton color="iconOnly" state="enabled" size="medium" iconName="Search" ariaLabel="Search" />
128
+ </Tooltip>
129
+ <Tooltip title={`Theme: ${current.label}`}>
130
+ <IconButton
131
+ color="iconOnly"
132
+ state={open ? 'selected' : 'enabled'}
133
+ size="medium"
134
+ iconName={current.icon}
135
+ ariaLabel={`Theme: ${current.label}`}
136
+ aria-haspopup="menu"
137
+ aria-expanded={open}
138
+ onClick={(e: { currentTarget: HTMLElement }) => {
139
+ setAnchor(e.currentTarget);
140
+ setOpen((o) => !o);
141
+ }}
142
+ />
143
+ </Tooltip>
144
+ </>
145
+ }
146
+ nav={
147
+ <TabsContainer fill>
148
+ {sections.map((s) => (
149
+ <Tab key={s.id} label={s.label} href={`/${s.id}`} router={router} isSelected={s.id === section.id} onClickTab={() => setSectionId(s.id)} />
150
+ ))}
151
+ </TabsContainer>
152
+ }
153
+ mainId="site-header-sections-main"
154
+ />
155
+ <PageShell id="site-header-sections-main" tabIndex={-1}>
156
+ <Stack gap="large">
157
+ <Heading level={1} size="h5">{section.page}</Heading>
158
+ <Paragraph tone="secondary" measure="none">The pages in {section.label} are listed beside this page on a wide screen, and in the menu on a phone.</Paragraph>
159
+ </Stack>
160
+ </PageShell>
161
+ <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>
162
+ <Menu navigable aria-label="Theme" width={180}>
163
+ {modes.map((m) => (
164
+ <MenuItem
165
+ key={m.value}
166
+ size="small"
167
+ iconName={m.icon}
168
+ label={m.label}
169
+ isSelected={m.value === mode}
170
+ role="menuitemradio"
171
+ onClick={() => { setMode(m.value); setOpen(false); }}
172
+ />
173
+ ))}
174
+ </Menu>
175
+ </Popover>
176
+ </>
177
+ );
178
+ }
179
+ ```
180
+
181
+ ## Native
182
+
183
+ On Apple a site header has no counterpart: an app uses a `NavigationStack` with a navigation bar. On Android use a top app bar.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A person types / at the start of the message box to run a command.
4
4
 
5
- **Not built yet:** Scindo on the web builds its list from buttons, so a screen reader in the field does not hear which command is highlighted. Both Scindo apps run a command with no argument as soon as it is picked.
6
-
7
5
  ## Do
8
6
 
9
7
  - Open the list when the text starts with /. A bare / opens it, each letter after it narrows it, and a space closes it.
@@ -243,5 +241,3 @@ export default function SlashCommandListInComposer() {
243
241
  ## Native
244
242
 
245
243
  On Apple the list shows above the field with the command, what it does and, when it takes an argument, its usage. Escape closes the list on a Mac.
246
-
247
- Seen in: Scindo.
@@ -6,8 +6,6 @@ Something the person did has worked.
6
6
 
7
7
  The feedback depends on where the result shows. A Button that is `loading` keeps its label, and the spinner shows that it is working. Only success changes a label, and there are three success labels: 'Saved', 'Copied' and 'Sent', each for 2 seconds. When a form saves in place, its Button is `loading`, then reads 'Saved' for 2 seconds, then its own label again. There is no toast. Sometimes the result is somewhere else or gone. Something was deleted, sent, moved or duplicated somewhere else, or a long job has finished. Then call `toast({ type: 'success', message: '…' })` with one short sentence in the past tense, in sentence case. It closes after 5 seconds. When something is copied to the clipboard, a Button reads 'Copied' for 2 seconds, and an IconButton swaps its icon to `Check` for 2 seconds. When Copy is a menu item, the menu closes, so a toast says 'Message copied.' instead. When a Button sends an email again, it reads 'Sent' for 2 seconds. The message names the thing and does not say 'successfully'.
8
8
 
9
- **Not built yet:** Scindo on the web has no toast. It shows success in five ways: a 'Saved' Button label, a green caption, an inline Alert, a thank-you that replaces a dialog and a 'Copied' label. The timed ones clear after 1.5, 2, 3 or 4 seconds. Commentify shows toasts through `Alert`, one at a time, and many of them say 'successfully'.
10
-
11
9
  ## Why
12
10
 
13
11
  Feedback belongs where the person is looking. A change they can see needs only a word on the Button, and a result they cannot see needs a short message that names it.
@@ -31,5 +29,3 @@ Feedback belongs where the person is looking. A change they can see needs only a
31
29
  ## Native
32
30
 
33
31
  On Apple there is no toast. Show the result in place.
34
-
35
- Seen in: Commentify, Scindo.
@@ -0,0 +1 @@
1
+ export default function TagFilterTags(): import("react").JSX.Element;
@@ -0,0 +1,226 @@
1
+ 'use client';
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ import { useEffect, useRef, useState } from 'react';
23
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
24
+ import Modal from '../../components/modal';
25
+ import Heading from '../../components/heading';
26
+ import Paragraph from '../../components/paragraph';
27
+ import TextField from '../../components/textField';
28
+ import Tag from '../../components/tag';
29
+ import Button from '../../components/button';
30
+ import IconButton from '../../components/iconButton';
31
+ import Tooltip from '../../components/tooltip';
32
+ import Popover from '../../components/popover';
33
+ import Menu from '../../components/menu';
34
+ import MenuItem from '../../components/menuItem';
35
+ import EmptyBox from '../../components/emptyBox';
36
+ import TableContainer from '../../components/tableContainer';
37
+ import TableRow from '../../components/tableRow';
38
+ import TableCell from '../../components/tableCell';
39
+ import { Center, Cluster, Stack } from '../../components/layout';
40
+ var firstTags = [
41
+ { id: 'design', name: 'Design' },
42
+ { id: 'research', name: 'Research' },
43
+ { id: 'ideas', name: 'Ideas' },
44
+ ];
45
+ var firstItems = [
46
+ { id: 'i1', title: 'Pricing page teardown', tagId: 'research' },
47
+ { id: 'i2', title: 'Color tokens for dark mode', tagId: 'design' },
48
+ { id: 'i3', title: 'Onboarding checklist patterns', tagId: 'design' },
49
+ { id: 'i4', title: 'Interview notes, March', tagId: 'research' },
50
+ { id: 'i5', title: 'A weekly digest email', tagId: 'ideas' },
51
+ { id: 'i6', title: 'Keyboard shortcut cheat sheet', tagId: null },
52
+ ];
53
+ export default function TagFilterTags() {
54
+ var _a = useState(firstTags), tags = _a[0], setTags = _a[1];
55
+ var _b = useState(firstItems), items = _b[0], setItems = _b[1];
56
+ // null is 'All'.
57
+ var _c = useState('design'), selected = _c[0], setSelected = _c[1];
58
+ var _d = useState(null), editing = _d[0], setEditing = _d[1];
59
+ var _e = useState(''), draft = _e[0], setDraft = _e[1];
60
+ var _f = useState(false), taken = _f[0], setTaken = _f[1];
61
+ var _g = useState(null), menuAnchor = _g[0], setMenuAnchor = _g[1];
62
+ var _h = useState(false), menuOpen = _h[0], setMenuOpen = _h[1];
63
+ var _j = useState(false), confirming = _j[0], setConfirming = _j[1];
64
+ var _k = useState(false), deleting = _k[0], setDeleting = _k[1];
65
+ // The tag the confirm is about, kept until the Modal is closed, so its text stays while it fades out.
66
+ var _l = useState({ name: '', count: 0 }), doomed = _l[0], setDoomed = _l[1];
67
+ var timer = useRef();
68
+ var toastIds = useRef([]);
69
+ var moreButton = useRef(null);
70
+ var addButton = useRef(null);
71
+ // Enter and Escape end the edit before the field goes away, so its blur must not save again.
72
+ var ended = useRef(false);
73
+ // Where focus goes after the next render, once the element it goes to is on screen.
74
+ var focusNext = useRef();
75
+ var tag = tags.find(function (t) { return t.id === selected; });
76
+ var shown = selected === null ? items : items.filter(function (i) { return i.tagId === selected; });
77
+ var nameOf = function (tagId) { var _a, _b; return (_b = (_a = tags.find(function (t) { return t.id === tagId; })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'No tag'; };
78
+ // On unmount it stops the request and closes every toast it opened.
79
+ useEffect(function () { return function () {
80
+ clearTimeout(timer.current);
81
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
82
+ toastIds.current = [];
83
+ }; }, []);
84
+ useEffect(function () {
85
+ var move = focusNext.current;
86
+ focusNext.current = undefined;
87
+ move === null || move === void 0 ? void 0 : move();
88
+ });
89
+ function startEditing(kind) {
90
+ ended.current = false;
91
+ setDraft(kind === 'rename' && tag ? tag.name : '');
92
+ setTaken(false);
93
+ setEditing(kind);
94
+ }
95
+ // Enter and a click away save. An empty or unchanged name cancels. A name that is taken stays in the field with
96
+ // the error, so what the person typed is not lost. `byKey` is true for Enter, where focus goes back to where it was.
97
+ function finish(byKey) {
98
+ if (ended.current || !editing)
99
+ return;
100
+ var name = draft.trim();
101
+ var unchanged = editing === 'rename' && name === (tag === null || tag === void 0 ? void 0 : tag.name);
102
+ if (!name || unchanged)
103
+ return cancel(byKey);
104
+ if (tags.some(function (t) { return !(editing === 'rename' && t.id === selected) && t.name.toLowerCase() === name.toLowerCase(); })) {
105
+ setTaken(true);
106
+ return;
107
+ }
108
+ ended.current = true;
109
+ // A real app sends the name to the server here and shows it at once.
110
+ if (editing === 'rename') {
111
+ setTags(function (list) { return list.map(function (t) { return (t.id === selected ? __assign(__assign({}, t), { name: name }) : t); }); });
112
+ }
113
+ else {
114
+ var id_1 = "tag-".concat(name.toLowerCase().replace(/\s+/g, '-'));
115
+ setTags(function (list) { return __spreadArray(__spreadArray([], list, true), [{ id: id_1, name: name }], false); });
116
+ setSelected(id_1);
117
+ }
118
+ leave(byKey);
119
+ }
120
+ function cancel(byKey) {
121
+ if (ended.current)
122
+ return;
123
+ ended.current = true;
124
+ leave(byKey);
125
+ }
126
+ function leave(byKey) {
127
+ var kind = editing;
128
+ setEditing(null);
129
+ setTaken(false);
130
+ if (byKey)
131
+ focusNext.current = function () { var _a; return (_a = (kind === 'rename' ? moreButton.current : addButton.current)) === null || _a === void 0 ? void 0 : _a.focus(); };
132
+ }
133
+ function openMenu(anchorEl) {
134
+ setMenuAnchor(anchorEl);
135
+ setMenuOpen(function (o) { return !o; });
136
+ }
137
+ // The menu closes on any choice. Its Popover gives focus back to the More button.
138
+ function rename() {
139
+ setMenuOpen(false);
140
+ startEditing('rename');
141
+ }
142
+ function askToDelete() {
143
+ setMenuOpen(false);
144
+ if (tag)
145
+ setDoomed({ name: tag.name, count: items.filter(function (i) { return i.tagId === tag.id; }).length });
146
+ setConfirming(true);
147
+ }
148
+ // 'Cancel' ends the confirm; the More button is still there, so focus goes back to it.
149
+ function keepTag() {
150
+ if (deleting)
151
+ return;
152
+ setConfirming(false);
153
+ focusNext.current = function () { var _a; return (_a = moreButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
154
+ }
155
+ // The items keep their place in 'All' and lose the tag. The tag and its More button are gone, so focus goes to 'Add Tag'.
156
+ function confirmDelete() {
157
+ if (deleting || !tag)
158
+ return;
159
+ var gone = tag;
160
+ setDeleting(true);
161
+ // Stands in for the request to the server.
162
+ timer.current = setTimeout(function () {
163
+ setDeleting(false);
164
+ setConfirming(false);
165
+ setTags(function (list) { return list.filter(function (t) { return t.id !== gone.id; }); });
166
+ setItems(function (list) { return list.map(function (i) { return (i.tagId === gone.id ? __assign(__assign({}, i), { tagId: null }) : i); }); });
167
+ setSelected(null);
168
+ toastIds.current.push(toast({ type: 'success', message: "".concat(gone.name, " tag deleted.") }));
169
+ focusNext.current = function () { var _a; return (_a = addButton.current) === null || _a === void 0 ? void 0 : _a.focus(); };
170
+ }, 1200);
171
+ }
172
+ return (<Center width="page">
173
+ {/* A real app mounts one Toaster near its root. */}
174
+ <Toaster />
175
+ <Stack gap="large">
176
+ <Heading level={1} size="h5">Reading list</Heading>
177
+ {editing ? (
178
+ // The row of tags becomes the field, as the case 'Rename' says for a name that is on screen. Enter and a click away save, Escape cancels.
179
+ <TextField key={editing} id="tag-filter-name" size="small" autoFocus aria-label={editing === 'rename' ? "Rename tag ".concat(tag === null || tag === void 0 ? void 0 : tag.name) : 'New tag name'} placeholder={editing === 'add' ? 'Tag name' : undefined} value={draft} error={taken} errorText="A tag with this name already exists." onChange={function (e) {
180
+ setDraft(e.target.value);
181
+ setTaken(false);
182
+ }} onKeyDown={function (e) {
183
+ if (e.key === 'Enter') {
184
+ e.preventDefault();
185
+ finish(true);
186
+ }
187
+ else if (e.key === 'Escape') {
188
+ e.preventDefault();
189
+ cancel(true);
190
+ }
191
+ }} onBlur={function () { return finish(false); }}/>) : (
192
+ // Tags that people add, rename and delete are not a fixed short set, so they are toggle Tags in a row that wraps.
193
+ <Cluster gap="small">
194
+ <Tag variant="contained" size="medium" label="All" state={selected === null ? 'selected' : 'enabled'} onClick={function () { return setSelected(null); }}/>
195
+ {tags.map(function (t) { return (<Tag key={t.id} variant="contained" size="medium" label={t.name} state={t.id === selected ? 'selected' : 'enabled'} onClick={function () { return setSelected(t.id); }}/>); })}
196
+ {/* One More button, for the tag that is selected, so the row has one extra stop and not one per tag. */}
197
+ {tag && (<Tooltip title="More">
198
+ <IconButton ref={moreButton} color="iconOnly" state={menuOpen ? 'selected' : 'enabled'} size="small" iconName="Ellipsis" ariaLabel={"More actions for tag ".concat(tag.name)} aria-haspopup="menu" aria-expanded={menuOpen} onClick={function (e) { return openMenu(e.currentTarget); }}/>
199
+ </Tooltip>)}
200
+ <Button ref={addButton} size="small" type="tertiary" state="enabled" label="Add Tag" decoIcon="Plus" onClickButton={function () { return startEditing('add'); }}/>
201
+ </Cluster>)}
202
+ {shown.length > 0 ? (<TableContainer>
203
+ {shown.map(function (i) { return (<TableRow key={i.id}>
204
+ <TableCell>{i.title}</TableCell>
205
+ <TableCell width="120px">{nameOf(i.tagId)}</TableCell>
206
+ </TableRow>); })}
207
+ </TableContainer>) : (<EmptyBox size="small" icon="Tag" text={"No items tagged '".concat(tag === null || tag === void 0 ? void 0 : tag.name, "'")} secondText="Items you tag appear here."/>)}
208
+ </Stack>
209
+ <Popover open={menuOpen} anchorEl={menuAnchor} onClose={function () { return setMenuOpen(false); }} returnFocus>
210
+ <Menu navigable aria-label="Tag actions" width={180}>
211
+ <MenuItem size="small" iconName="Pencil" label="Rename" onClick={rename}/>
212
+ {/* Delete is last, and danger. */}
213
+ <MenuItem size="small" color="danger" iconName="Trash2" label="Delete" onClick={askToDelete}/>
214
+ </Menu>
215
+ </Popover>
216
+ <Modal isOpen={confirming} size="small" title="Delete Tag" onClose={keepTag} actions={<>
217
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={keepTag}/>
218
+ <Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={confirmDelete}/>
219
+ </>}>
220
+ <Paragraph measure="none">{"This deletes the tag '".concat(doomed.name, "'.")}</Paragraph>
221
+ <Paragraph tone="secondary" size="body2" measure="none">
222
+ {doomed.count === 1 ? 'Its 1 item stays in All, with no tag.' : "Its ".concat(doomed.count, " items stay in All, with no tag.")}
223
+ </Paragraph>
224
+ </Modal>
225
+ </Center>);
226
+ }