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
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
  interface AlertProps {
3
+ /** Lets a control point at the alert with `aria-describedby`, such as a Select whose save failed. */
4
+ id?: string;
3
5
  open?: boolean;
4
6
  type: 'success' | 'warning' | 'error' | 'info' | 'default';
5
7
  message: string;
@@ -10,5 +12,5 @@ interface AlertProps {
10
12
  /** Not set: the alert dismisses itself after 5 seconds unless it has a close button. `false` keeps it open; `true` dismisses it even with a close button. */
11
13
  autoDismiss?: boolean;
12
14
  }
13
- export default function Alert({ open, type, message, secondMessage, onClose, showCloseButton, variant, autoDismiss, }: AlertProps): React.JSX.Element | null;
15
+ export default function Alert({ id, open, type, message, secondMessage, onClose, showCloseButton, variant, autoDismiss, }: AlertProps): React.JSX.Element | null;
14
16
  export {};
@@ -18,7 +18,7 @@ var motionClasses = {
18
18
  };
19
19
  export default function Alert(_a) {
20
20
  var _b;
21
- var _c = _a.open, open = _c === void 0 ? true : _c, type = _a.type, message = _a.message, secondMessage = _a.secondMessage, onClose = _a.onClose, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.variant, variant = _e === void 0 ? 'toast' : _e, autoDismiss = _a.autoDismiss;
21
+ var id = _a.id, _c = _a.open, open = _c === void 0 ? true : _c, type = _a.type, message = _a.message, secondMessage = _a.secondMessage, onClose = _a.onClose, _d = _a.showCloseButton, showCloseButton = _d === void 0 ? false : _d, _e = _a.variant, variant = _e === void 0 ? 'toast' : _e, autoDismiss = _a.autoDismiss;
22
22
  var _f = useState(false), isVisible = _f[0], setIsVisible = _f[1];
23
23
  var _g = useState(false), shouldRender = _g[0], setShouldRender = _g[1];
24
24
  // Auto-dismiss pauses while the toast is hovered or focused
@@ -66,7 +66,7 @@ export default function Alert(_a) {
66
66
  var bgClasses = (_b = bgClassMap[type]) !== null && _b !== void 0 ? _b : bgClassMap.default;
67
67
  // The default alert sits on secondary.main, whose label is secondary.contrast; the status backgrounds take text.primary
68
68
  var textClasses = bgClasses === bgClassMap.default ? 'text-secondary-contrast' : 'text-fg-primary';
69
- var alertContent = (<div
69
+ var alertContent = (<div id={id}
70
70
  // Errors interrupt screen readers; everything else is announced politely
71
71
  role={type === 'error' ? 'alert' : 'status'} onMouseEnter={function () { return setIsPaused(true); }} onMouseLeave={function () { return setIsPaused(false); }} onFocus={function () { return setIsPaused(true); }} onBlur={function () { return setIsPaused(false); }} className={"flex ".concat(secondMessage ? 'items-start' : 'items-center', " justify-between w-full p-2 rounded-control transition-[opacity,transform] ").concat(isVisible ? motionClasses.enter : motionClasses.exit, " motion-reduce:transition-none ").concat(bgClasses, " ").concat(isVisible ? 'opacity-100 translate-y-0' : variant === 'toast' ? 'opacity-0 -translate-y-[calc(100%+1rem)]' : 'opacity-0', " ").concat(variant === 'toast' ? 'max-w-md pointer-events-auto' : '')}>
72
72
  <div className={"flex items-start gap-2 ".concat(textClasses)}>
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ interface AppShellProps {
3
+ /**
4
+ * The app's places, a `Navigation`. A column from md up; in a Drawer below md, and only one of the two is mounted.
5
+ * Keep a Modal's open state inside the sidebar's own components.
6
+ */
7
+ sidebar: React.ReactNode;
8
+ /** The page, in `<main>` */
9
+ children: React.ReactNode;
10
+ /** A `SidePane`: beside main from lg up, in place of main below lg. Below lg the skip link goes to the pane. */
11
+ pane?: React.ReactNode;
12
+ /** Names the page in the top bar below md */
13
+ title: string;
14
+ /** Below md: whether the sidebar's Drawer is open */
15
+ navOpen: boolean;
16
+ /**
17
+ * Called with `true` from the Menu IconButton, `false` on Close, Escape, the scrim, a choice in the menu and on widening past md.
18
+ * A choice in a portaled menu inside the sidebar (an account menu) does not close the phone menu; close it in that item's onClick.
19
+ */
20
+ onNavOpenChange: (open: boolean) => void;
21
+ /** The Menu IconButton's name, and the Drawer's. Default 'Menu'. */
22
+ menuLabel?: string;
23
+ /** Hides the sidebar column from md up, for a person who wants room. The phone menu still has it. */
24
+ sidebarHidden?: boolean;
25
+ /** The skip link's text. Default 'Skip to content'. */
26
+ skipLabel?: string;
27
+ /**
28
+ * Gives the person the control to hide the sidebar, from md up only (the phone menu has no such control).
29
+ * With it, AppShell renders a hide IconButton at the top of the column and, while `sidebarHidden`, a show
30
+ * IconButton in a slim rail at the start; focus moves to the other control after a press. Keep the
31
+ * keyboard shortcut (`useHotkey('b', …)`) in the app, and have it call this too.
32
+ */
33
+ onSidebarHiddenChange?: (hidden: boolean) => void;
34
+ /** The hide IconButton's name. Default 'Hide sidebar'. */
35
+ hideLabel?: string;
36
+ /** The show IconButton's name. Default 'Show sidebar'. */
37
+ showLabel?: string;
38
+ }
39
+ /**
40
+ * An app's frame: a skip link, the sidebar beside main from md up, and below md a top bar whose
41
+ * Menu IconButton opens the same sidebar in a start Drawer.
42
+ */
43
+ export default function AppShell({ sidebar, children, pane, title, navOpen, onNavOpenChange, menuLabel, sidebarHidden, skipLabel, onSidebarHiddenChange, hideLabel, showLabel, }: AppShellProps): React.JSX.Element;
44
+ export { AppShell };
@@ -0,0 +1,121 @@
1
+ 'use client';
2
+ import React, { useEffect, useId, useRef } from 'react';
3
+ import { Menu, PanelLeftClose, PanelLeftOpen } from 'lucide-react';
4
+ import Drawer from './drawer';
5
+ import IconButton from './iconButton';
6
+ import Tooltip from './tooltip';
7
+ import TitleBar from './titleBar';
8
+ import { focusRing } from './sharedStyles';
9
+ // Tailwind's md breakpoint: the sidebar is a column from here up
10
+ var WIDE = '(min-width: 768px)';
11
+ /**
12
+ * An app's frame: a skip link, the sidebar beside main from md up, and below md a top bar whose
13
+ * Menu IconButton opens the same sidebar in a start Drawer.
14
+ */
15
+ export default function AppShell(_a) {
16
+ var sidebar = _a.sidebar, children = _a.children, pane = _a.pane, title = _a.title, navOpen = _a.navOpen, onNavOpenChange = _a.onNavOpenChange, _b = _a.menuLabel, menuLabel = _b === void 0 ? 'Menu' : _b, _c = _a.sidebarHidden, sidebarHidden = _c === void 0 ? false : _c, _d = _a.skipLabel, skipLabel = _d === void 0 ? 'Skip to content' : _d, onSidebarHiddenChange = _a.onSidebarHiddenChange, _e = _a.hideLabel, hideLabel = _e === void 0 ? 'Hide sidebar' : _e, _f = _a.showLabel, showLabel = _f === void 0 ? 'Show sidebar' : _f;
17
+ var mainId = useId();
18
+ var paneId = useId();
19
+ var drawerId = useId();
20
+ var onNavOpenChangeRef = useRef(onNavOpenChange);
21
+ onNavOpenChangeRef.current = onNavOpenChange;
22
+ var columnRef = useRef(null);
23
+ var mainRef = useRef(null);
24
+ // Set when widening closes the Drawer while focus was in it: the Menu IconButton it would go back to is hidden from md up
25
+ var refocusAfterWiden = useRef(false);
26
+ var hideRef = useRef(null);
27
+ var showRef = useRef(null);
28
+ // Set by a press on the hide or show control: the other control takes focus once it is on screen
29
+ var focusAfterToggle = useRef(null);
30
+ useEffect(function () {
31
+ var _a;
32
+ var which = focusAfterToggle.current;
33
+ if (!which)
34
+ return;
35
+ focusAfterToggle.current = null;
36
+ (_a = (which === 'hide' ? hideRef : showRef).current) === null || _a === void 0 ? void 0 : _a.focus();
37
+ }, [sidebarHidden]);
38
+ // The Drawer is for a phone: widening past md closes it, so the page is never left locked under it
39
+ useEffect(function () {
40
+ if (!navOpen)
41
+ return;
42
+ var wide = window.matchMedia(WIDE);
43
+ var closeIfWide = function () {
44
+ var _a;
45
+ if (!wide.matches)
46
+ return;
47
+ refocusAfterWiden.current = !!((_a = document.getElementById(drawerId)) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement));
48
+ onNavOpenChangeRef.current(false);
49
+ };
50
+ closeIfWide();
51
+ wide.addEventListener('change', closeIfWide);
52
+ return function () { return wide.removeEventListener('change', closeIfWide); };
53
+ }, [navOpen]); // eslint-disable-line react-hooks/exhaustive-deps
54
+ // After the close commits (the Drawer's cleanup has already sent focus to the hidden Menu IconButton),
55
+ // focus the current item in the column that is now on screen, or else main.
56
+ useEffect(function () {
57
+ var _a, _b, _c;
58
+ if (navOpen || !refocusAfterWiden.current)
59
+ return;
60
+ refocusAfterWiden.current = false;
61
+ (_c = ((_b = (_a = columnRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('[aria-current]')) !== null && _b !== void 0 ? _b : mainRef.current)) === null || _c === void 0 ? void 0 : _c.focus();
62
+ }, [navOpen]);
63
+ // A choice in the menu (a link or a menu item in the sidebar itself) closes it. A Button that opens
64
+ // its own menu (aria-haspopup) does not, and neither does an item in a Popover, which is not in the panel.
65
+ var closeOnChoice = function (e) {
66
+ var _a, _b;
67
+ var choice = (_b = (_a = e.target).closest) === null || _b === void 0 ? void 0 : _b.call(_a, 'a[href], [role="menuitem"]');
68
+ if (choice && e.currentTarget.contains(choice) && !choice.hasAttribute('aria-haspopup'))
69
+ onNavOpenChange(false);
70
+ };
71
+ var skipLink = function (target, shown) { return (<a href={"#".concat(target)} className={"sr-only focus:not-sr-only focus:fixed focus:left-2 focus:top-2 focus:z-[var(--os-z-tooltip)] focus:rounded-control focus:bg-background-elevated focus:px-3 focus:py-2 focus:text-body2 focus:text-fg-primary focus:shadow-overlay ".concat(focusRing).concat(shown)}>
72
+ {skipLabel}
73
+ </a>); };
74
+ return (<div className="min-h-[100dvh] bg-background-default md:flex">
75
+ {/* With a pane, below lg the pane takes main's place, so the skip link goes to the pane there */}
76
+ {skipLink(mainId, pane ? ' hidden lg:block' : '')}
77
+ {pane && skipLink(paneId, ' lg:hidden')}
78
+ {/* Menu sits beside the TitleBar, not in its back slot: TitleBar puts Back on its own line below md */}
79
+ <div className="sticky top-0 z-10 flex items-center gap-2 border-b border-misc-divider bg-background-default py-2 pl-2 pr-4 md:hidden">
80
+ <IconButton color="iconOnly" state="enabled" size="medium" icon={Menu} ariaLabel={menuLabel} aria-expanded={navOpen} aria-controls={drawerId} onClick={function () { return onNavOpenChange(true); }}/>
81
+ <div className="min-w-0 flex-1">
82
+ <TitleBar title={title} level={2}/>
83
+ </div>
84
+ </div>
85
+ {/* Not while the phone menu is open, so the sidebar is mounted once. navOpen is true only below md. */}
86
+ {onSidebarHiddenChange && sidebarHidden && (<div className="hidden shrink-0 p-2 md:block">
87
+ <Tooltip title={showLabel}>
88
+ <IconButton ref={showRef} color="iconOnly" state="enabled" size="medium" icon={PanelLeftOpen} ariaLabel={showLabel} onClick={function () {
89
+ focusAfterToggle.current = 'hide';
90
+ onSidebarHiddenChange(false);
91
+ }}/>
92
+ </Tooltip>
93
+ </div>)}
94
+ {!sidebarHidden && !navOpen && (<div ref={columnRef} className="hidden md:flex md:sticky md:top-0 md:h-[100dvh] w-[16rem] shrink-0 flex-col overflow-y-auto [&>*]:flex-1">
95
+ {onSidebarHiddenChange ? (<>
96
+ <div className="!flex-none flex justify-end px-2 pt-2">
97
+ <Tooltip title={hideLabel}>
98
+ <IconButton ref={hideRef} color="iconOnly" state="enabled" size="medium" icon={PanelLeftClose} ariaLabel={hideLabel} onClick={function () {
99
+ focusAfterToggle.current = 'show';
100
+ onSidebarHiddenChange(true);
101
+ }}/>
102
+ </Tooltip>
103
+ </div>
104
+ {sidebar}
105
+ </>) : (sidebar)}
106
+ </div>)}
107
+ <main ref={mainRef} id={mainId} tabIndex={-1} className={"min-w-0 flex-1 p-xlarge outline-none md:p-xxlarge ".concat(pane ? 'hidden lg:block' : '')}>
108
+ {children}
109
+ </main>
110
+ {pane && (<div id={paneId} tabIndex={-1} className="flex min-w-0 flex-1 outline-none lg:sticky lg:top-0 lg:h-[100dvh] lg:flex-none">
111
+ {pane}
112
+ </div>)}
113
+ <Drawer id={drawerId} isOpen={navOpen} onClose={function () { return onNavOpenChange(false); }} aria-label={menuLabel} side="start" size="small">
114
+ {/* The panel already has its own background and padding: a Navigation drops its column's edge, fill and padding here */}
115
+ <div onClick={closeOnChoice} className="[&>nav]:border-r-0 [&>nav]:bg-transparent [&>nav]:p-0">
116
+ {sidebar}
117
+ </div>
118
+ </Drawer>
119
+ </div>);
120
+ }
121
+ export { AppShell };
@@ -105,11 +105,14 @@ var Button = forwardRef(function Button(_a, ref) {
105
105
  </div>
106
106
  </div>
107
107
  {actionIcon && (<span onClick={function (e) {
108
+ // With no handler of its own, the icon is part of the button and the click goes through
109
+ if (!onClickActionIcon)
110
+ return;
108
111
  // Don't also trigger the button's own click, or follow the link
109
112
  e.stopPropagation();
110
- if (isLink && onClickActionIcon)
113
+ if (isLink)
111
114
  e.preventDefault();
112
- onClickActionIcon === null || onClickActionIcon === void 0 ? void 0 : onClickActionIcon();
115
+ onClickActionIcon();
113
116
  }} className="cursor-pointer">
114
117
  <IconSlot icon={actionIcon} className={"".concat(sizeIcon, " flex-shrink-0")}/>
115
118
  </span>)}
@@ -5,6 +5,10 @@ interface CheckboxProps {
5
5
  checked?: boolean;
6
6
  onChange?: (checked: boolean) => void;
7
7
  disabled?: boolean;
8
+ /** On the `<input>`, so a `FormField` label can point at it */
9
+ id?: string;
10
+ /** Id of the element that describes the checkbox, e.g. help or error text */
11
+ 'aria-describedby'?: string;
8
12
  }
9
- export default function Checkbox({ label, secondLabel, checked, onChange, disabled }: CheckboxProps): React.JSX.Element;
13
+ export default function Checkbox({ label, secondLabel, checked, onChange, disabled, id, 'aria-describedby': ariaDescribedBy, }: CheckboxProps): React.JSX.Element;
10
14
  export {};
@@ -2,7 +2,7 @@
2
2
  import React, { useEffect, useState } from 'react';
3
3
  import { popTransition, stateTransition } from './sharedStyles';
4
4
  export default function Checkbox(_a) {
5
- var label = _a.label, secondLabel = _a.secondLabel, _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange, _c = _a.disabled, disabled = _c === void 0 ? false : _c;
5
+ var label = _a.label, secondLabel = _a.secondLabel, _b = _a.checked, checked = _b === void 0 ? false : _b, onChange = _a.onChange, _c = _a.disabled, disabled = _c === void 0 ? false : _c, id = _a.id, ariaDescribedBy = _a["aria-describedby"];
6
6
  var _d = useState(checked), isChecked = _d[0], setIsChecked = _d[1];
7
7
  // Follow the parent when it changes `checked` (e.g. resetting a form)
8
8
  useEffect(function () {
@@ -16,7 +16,7 @@ export default function Checkbox(_a) {
16
16
  };
17
17
  return (<label className={"group relative flex items-start ".concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer')}>
18
18
  {/* Native input keeps keyboard focus, Space to toggle and screen-reader semantics */}
19
- <input type="checkbox" className="peer sr-only" checked={isChecked} disabled={disabled} onChange={handleChange}/>
19
+ <input type="checkbox" id={id} aria-describedby={ariaDescribedBy} className="peer sr-only" checked={isChecked} disabled={disabled} onChange={handleChange}/>
20
20
  <span className={"relative flex flex-shrink-0 items-center justify-center w-6 h-6 rounded-full ".concat(stateTransition, "\n peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-0 peer-focus-visible:outline-fg-primary\n ").concat(disabled ? '' : 'group-hover:bg-action-selected')}>
21
21
  {/* Checkbox */}
22
22
  <span className={"relative w-4 h-4 border-2 rounded ".concat(stateTransition, " ").concat(disabled
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ interface CopyFieldProps {
3
+ id: string;
4
+ label: string;
5
+ value: string;
6
+ /** The button's words. Defaults to "Copy". */
7
+ copyLabel?: string;
8
+ /** The button's words for 2 seconds after the text is on the clipboard. Defaults to "Copied". */
9
+ copiedLabel?: string;
10
+ /** A monospace font, for keys and addresses */
11
+ mono?: boolean;
12
+ /** `once` adds the line "Copy it now. You will not see it again." under the field, for a secret shown a single time */
13
+ reveal?: 'once';
14
+ }
15
+ /**
16
+ * A read-only field with a button at its right that copies its text. "Copied" shows only after the
17
+ * browser accepted the text; when it refuses or has no clipboard, a line says to copy by hand.
18
+ */
19
+ export default function CopyField({ id, label, value, copyLabel, copiedLabel, mono, reveal, }: CopyFieldProps): React.JSX.Element;
20
+ export { CopyField };
@@ -0,0 +1,99 @@
1
+ 'use client';
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ import React, { useEffect, useRef, useState } from 'react';
39
+ import { copyText } from '../internal/copyField';
40
+ import Button from './button';
41
+ import TextField from './textField';
42
+ /**
43
+ * A read-only field with a button at its right that copies its text. "Copied" shows only after the
44
+ * browser accepted the text; when it refuses or has no clipboard, a line says to copy by hand.
45
+ */
46
+ export default function CopyField(_a) {
47
+ var _this = this;
48
+ var id = _a.id, label = _a.label, value = _a.value, _b = _a.copyLabel, copyLabel = _b === void 0 ? 'Copy' : _b, _c = _a.copiedLabel, copiedLabel = _c === void 0 ? 'Copied' : _c, _d = _a.mono, mono = _d === void 0 ? false : _d, reveal = _a.reveal;
49
+ var _e = useState(false), copied = _e[0], setCopied = _e[1];
50
+ var _f = useState(false), blocked = _f[0], setBlocked = _f[1];
51
+ var timer = useRef(undefined);
52
+ var mounted = useRef(false);
53
+ useEffect(function () {
54
+ mounted.current = true;
55
+ return function () {
56
+ mounted.current = false;
57
+ clearTimeout(timer.current);
58
+ };
59
+ }, []);
60
+ var handleCopy = function () { return __awaiter(_this, void 0, void 0, function () {
61
+ var ok;
62
+ return __generator(this, function (_a) {
63
+ switch (_a.label) {
64
+ case 0: return [4 /*yield*/, copyText(typeof navigator === 'undefined' ? undefined : navigator.clipboard, value)];
65
+ case 1:
66
+ ok = _a.sent();
67
+ if (!mounted.current)
68
+ return [2 /*return*/];
69
+ clearTimeout(timer.current);
70
+ setBlocked(!ok);
71
+ setCopied(ok);
72
+ if (ok)
73
+ timer.current = setTimeout(function () { return setCopied(false); }, 2000);
74
+ return [2 /*return*/];
75
+ }
76
+ });
77
+ }); };
78
+ var revealId = "".concat(id, "-reveal");
79
+ var blockedId = "".concat(id, "-blocked");
80
+ var describedBy = [reveal ? revealId : '', blocked ? blockedId : ''].filter(Boolean).join(' ') || undefined;
81
+ return (<div className="flex flex-col w-full">
82
+ <div className={"flex items-end gap-2".concat(mono ? ' [&_input]:font-mono' : '')}>
83
+ <TextField id={id} label={label} value={value} readOnly onChange={function () { }} onFocus={function (e) { return e.target.select(); }} aria-describedby={describedBy}/>
84
+ <div className="flex-shrink-0">
85
+ <Button size="medium" type="secondary" state="enabled" label={copied ? copiedLabel : copyLabel} aria-label={"".concat(copied ? copiedLabel : copyLabel, " ").concat(label)} onClickButton={handleCopy}/>
86
+ </div>
87
+ </div>
88
+ {reveal && (<p id={revealId} className="mt-1 text-fg-secondary text-body2">
89
+ Copy it now. You will not see it again.
90
+ </p>)}
91
+ {blocked && (<p id={blockedId} role="alert" className="mt-1 text-error-text text-body2">
92
+ Copying is blocked here. Select the text and copy it.
93
+ </p>)}
94
+ <span role="status" className="sr-only">
95
+ {copied ? copiedLabel : ''}
96
+ </span>
97
+ </div>);
98
+ }
99
+ export { CopyField };
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ interface DrawerProps {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ /** The visible heading; it names the dialog */
6
+ title?: string;
7
+ /** Names the dialog when there is no visible title */
8
+ 'aria-label'?: string;
9
+ /** 'start' (default) for navigation; 'end' for a short task, a bottom sheet below md */
10
+ side?: 'start' | 'end';
11
+ /** 20rem, 24rem (default) or 32rem, never wider than 85vw */
12
+ size?: 'small' | 'medium' | 'large';
13
+ /** Buttons in the header, between the title and Close */
14
+ actions?: React.ReactNode;
15
+ children: React.ReactNode;
16
+ /** As in Modal: 'first' focuses the first focusable element in the panel, 'body' the first in the children */
17
+ initialFocus?: 'first' | 'body';
18
+ /** The Close button's name */
19
+ closeLabel?: string;
20
+ /** The panel's id, for an opener's `aria-controls` */
21
+ id?: string;
22
+ /** `'md'`: a Drawer for a phone. It closes (calls `onClose`) when the window is, or becomes, at least md wide, so the page is never left locked under it. */
23
+ closeFrom?: 'md';
24
+ }
25
+ /**
26
+ * A panel that slides in over a scrim. Focus moves in on open and back to the opener on close; Tab
27
+ * stays inside. Escape and a scrim click close it while it is the top overlay, so a Modal opened from
28
+ * inside it closes first.
29
+ */
30
+ export default function Drawer({ isOpen, onClose, title, 'aria-label': ariaLabel, side, size, actions, children, initialFocus, closeLabel, id, closeFrom, }: DrawerProps): React.JSX.Element | null;
31
+ export { Drawer };
@@ -0,0 +1,121 @@
1
+ 'use client';
2
+ import React, { useEffect, useId, useRef } from 'react';
3
+ import { X } from 'lucide-react';
4
+ import IconButton from './iconButton';
5
+ import { useOverlayTransition } from './useOverlayTransition';
6
+ import { initialFocusCandidates } from '../internal/modal';
7
+ import { PICKABLE, claimEvent, isTopOverlay, lockScroll, popOverlay, pushOverlay, trapTab, unlockScroll } from '../internal/overlayStack';
8
+ // Class strings are written out whole so the app's Tailwind finds them
9
+ var widths = {
10
+ start: { small: 'w-[20rem]', medium: 'w-[24rem]', large: 'w-[32rem]' },
11
+ end: { small: 'md:w-[20rem]', medium: 'md:w-[24rem]', large: 'md:w-[32rem]' },
12
+ };
13
+ // A start Drawer is a full-height panel on the left at every width. An end Drawer is a bottom sheet
14
+ // below md, padded above a phone's home indicator, and a full-height panel on the right from md.
15
+ var placement = {
16
+ start: 'top-0 bottom-0 left-0 max-w-[85vw]',
17
+ end: 'bottom-0 left-0 right-0 max-h-[90dvh] rounded-t-container pb-[env(safe-area-inset-bottom)] md:pb-0 md:top-0 md:left-auto md:max-h-none md:max-w-[85vw] md:rounded-none',
18
+ };
19
+ // Hidden off its side. Open it has no transform at all, so a Modal inside the panel is fixed to the
20
+ // window and not to the panel.
21
+ var hidden = {
22
+ start: '[transform:translateX(-100%)]',
23
+ end: '[transform:translateY(100%)] md:[transform:translateX(100%)]',
24
+ };
25
+ /**
26
+ * A panel that slides in over a scrim. Focus moves in on open and back to the opener on close; Tab
27
+ * stays inside. Escape and a scrim click close it while it is the top overlay, so a Modal opened from
28
+ * inside it closes first.
29
+ */
30
+ export default function Drawer(_a) {
31
+ var isOpen = _a.isOpen, onClose = _a.onClose, title = _a.title, ariaLabel = _a["aria-label"], _b = _a.side, side = _b === void 0 ? 'start' : _b, _c = _a.size, size = _c === void 0 ? 'medium' : _c, actions = _a.actions, children = _a.children, _d = _a.initialFocus, initialFocus = _d === void 0 ? 'first' : _d, _e = _a.closeLabel, closeLabel = _e === void 0 ? 'Close' : _e, id = _a.id, closeFrom = _a.closeFrom;
32
+ var panelRef = useRef(null);
33
+ var bodyRef = useRef(null);
34
+ var titleId = useId();
35
+ var _f = useOverlayTransition(isOpen), mounted = _f.mounted, visible = _f.visible;
36
+ // Keep onClose in a ref so a new function each render doesn't re-run the focus effect
37
+ var onCloseRef = useRef(onClose);
38
+ onCloseRef.current = onClose;
39
+ // Tailwind's md breakpoint
40
+ useEffect(function () {
41
+ if (!isOpen || !closeFrom)
42
+ return;
43
+ var wide = window.matchMedia('(min-width: 768px)');
44
+ var closeIfWide = function () {
45
+ if (wide.matches)
46
+ onCloseRef.current();
47
+ };
48
+ closeIfWide();
49
+ wide.addEventListener('change', closeIfWide);
50
+ return function () { return wide.removeEventListener('change', closeIfWide); };
51
+ }, [isOpen, closeFrom]);
52
+ useEffect(function () {
53
+ var _a, _b, _c;
54
+ if (!isOpen || !mounted)
55
+ return;
56
+ var previouslyFocused = document.activeElement;
57
+ var panel = panelRef.current;
58
+ var candidates = initialFocusCandidates(Array.from((_a = panel === null || panel === void 0 ? void 0 : panel.querySelectorAll(PICKABLE)) !== null && _a !== void 0 ? _a : []), Array.from((_c = (_b = bodyRef.current) === null || _b === void 0 ? void 0 : _b.querySelectorAll(PICKABLE)) !== null && _c !== void 0 ? _c : []), initialFocus);
59
+ for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
60
+ var candidate = candidates_1[_i];
61
+ candidate.focus();
62
+ if (panel === null || panel === void 0 ? void 0 : panel.contains(document.activeElement))
63
+ break;
64
+ }
65
+ if (panel && !panel.contains(document.activeElement))
66
+ panel.focus();
67
+ pushOverlay(titleId, panel);
68
+ lockScroll();
69
+ var handleKeyDown = function (e) {
70
+ var _a;
71
+ if (!isTopOverlay(titleId))
72
+ return;
73
+ if (e.key === 'Escape') {
74
+ if (claimEvent(e))
75
+ onCloseRef.current();
76
+ return;
77
+ }
78
+ if (e.key !== 'Tab' || !panel)
79
+ return;
80
+ // Focus can fall to the page body, when a Modal in the panel gives it back to a menu item
81
+ // that is gone. Tab from there would leave the panel: start again at its first control.
82
+ if (document.activeElement === document.body) {
83
+ e.preventDefault();
84
+ (_a = panel.querySelector(PICKABLE)) === null || _a === void 0 ? void 0 : _a.focus();
85
+ return;
86
+ }
87
+ trapTab(panel, e);
88
+ };
89
+ window.addEventListener('keydown', handleKeyDown);
90
+ return function () {
91
+ var _a;
92
+ window.removeEventListener('keydown', handleKeyDown);
93
+ popOverlay(titleId);
94
+ unlockScroll();
95
+ (_a = previouslyFocused === null || previouslyFocused === void 0 ? void 0 : previouslyFocused.focus) === null || _a === void 0 ? void 0 : _a.call(previouslyFocused);
96
+ };
97
+ }, [isOpen, mounted]); // eslint-disable-line react-hooks/exhaustive-deps
98
+ if (!mounted)
99
+ return null;
100
+ var handleScrimClick = function () {
101
+ if (isTopOverlay(titleId))
102
+ onClose();
103
+ };
104
+ // dark-only edge: a ring only in dark mode, so it keeps a dark: variant (it follows whatever dark variant the app's preset/@theme defines, class-only or OS-aware)
105
+ return (<div className="fixed inset-0 z-[var(--os-z-overlay)]">
106
+ <div aria-hidden="true" onClick={handleScrimClick} className={"absolute inset-0 bg-misc-scrim/40 transition-opacity duration-[var(--os-duration-fast)] ease-out motion-reduce:transition-none ".concat(visible ? 'opacity-100' : 'opacity-0')}/>
107
+ <div ref={panelRef} id={id} role="dialog" aria-modal="true" aria-labelledby={title ? titleId : undefined} aria-label={title ? undefined : ariaLabel} tabIndex={-1} className={"absolute flex flex-col bg-background-elevated shadow-overlay dark:ring-1 dark:ring-misc-divider outline-none\n ".concat(placement[side], " ").concat(widths[side][size], "\n transition-[transform] duration-[var(--os-duration-fast)] ease-emphasized motion-reduce:transition-none\n ").concat(visible ? '[transform:none]' : hidden[side])}>
108
+ <div className="flex shrink-0 items-center gap-2 border-b border-misc-divider py-2 pl-4 pr-2">
109
+ {title ? (<h2 id={titleId} className="min-w-0 flex-1 text-h5 text-fg-primary">
110
+ {title}
111
+ </h2>) : (<div className="flex-1"/>)}
112
+ {actions && <div className="flex items-center gap-2">{actions}</div>}
113
+ <IconButton color="iconOnly" state="enabled" size="medium" icon={X} ariaLabel={closeLabel} onClick={onClose}/>
114
+ </div>
115
+ <div ref={bodyRef} className="min-h-0 flex-1 overflow-y-auto px-4 py-4 text-body1 text-fg-primary" style={{ scrollbarWidth: 'thin' }}>
116
+ {children}
117
+ </div>
118
+ </div>
119
+ </div>);
120
+ }
121
+ export { Drawer };
@@ -0,0 +1,34 @@
1
+ import React, { type ReactNode } from 'react';
2
+ /** What a FormField hands to its control */
3
+ export interface FormFieldControlProps {
4
+ id: string;
5
+ /** The help text's id, or the error text's id while there is an error. Absent when neither is shown. */
6
+ 'aria-describedby'?: string;
7
+ /** `true` while there is an error. Absent otherwise. */
8
+ 'aria-invalid'?: boolean;
9
+ }
10
+ interface FormFieldProps {
11
+ /** The control's id. The label points at it. */
12
+ id: string;
13
+ label: string;
14
+ /** A line under the control. The error replaces it while `error` is set. */
15
+ help?: string;
16
+ /** Shown under the control in place of the help text, and marks the control invalid */
17
+ error?: string;
18
+ /** Adds a required mark to the label that screen readers read as "required" */
19
+ required?: boolean;
20
+ /**
21
+ * A function that returns the control, e.g.
22
+ * `{(f) => <TextField id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} … />}`.
23
+ * A render prop, not a cloned child: the ids reach the control through props you can see, so
24
+ * nothing needs a `className`, a spread or a wrapper, and it works with any ODS control that
25
+ * takes `id` and `aria-describedby` (TextField, Textarea, Select, RadioGroup, Checkbox). Only
26
+ * TextField and Textarea take `aria-invalid`.
27
+ * The `<label for>` only names an input, textarea or button. Give a Select or RadioGroup the same
28
+ * text as its `aria-label`.
29
+ */
30
+ children: (field: FormFieldControlProps) => ReactNode;
31
+ }
32
+ /** A label, a control and its help or error text, tied together for screen readers */
33
+ export default function FormField({ id, label, help, error, required, children }: FormFieldProps): React.JSX.Element;
34
+ export { FormField };
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ /** A label, a control and its help or error text, tied together for screen readers */
3
+ export default function FormField(_a) {
4
+ var id = _a.id, label = _a.label, help = _a.help, error = _a.error, _b = _a.required, required = _b === void 0 ? false : _b, children = _a.children;
5
+ var helpId = "".concat(id, "-help");
6
+ var errorId = "".concat(id, "-error");
7
+ var describedBy = error ? errorId : help ? helpId : undefined;
8
+ return (<div className="flex flex-col w-full">
9
+ <label htmlFor={id} className="mb-1 text-body2 text-fg-secondary">
10
+ {label}
11
+ {required && (<>
12
+ <span aria-hidden="true" className="text-error-text ml-0.5">*</span>
13
+ <span className="sr-only"> required</span>
14
+ </>)}
15
+ </label>
16
+ {children({
17
+ id: id,
18
+ 'aria-describedby': describedBy,
19
+ 'aria-invalid': error ? true : undefined,
20
+ })}
21
+ {error ? (<p id={errorId} className="mt-1 text-error-text text-body2">
22
+ {error}
23
+ </p>) : (help && (<p id={helpId} className="mt-1 text-fg-secondary text-body2">
24
+ {help}
25
+ </p>))}
26
+ </div>);
27
+ }
28
+ export { FormField };
@@ -5,8 +5,12 @@ interface HeadingProps {
5
5
  level?: 1 | 2 | 3 | 4;
6
6
  /** How large it is set. */
7
7
  size?: 'h4' | 'h5' | 'h6' | 'subtitle1';
8
+ /** `danger` gives the heading the error text color, for a danger zone. */
9
+ color?: 'default' | 'danger';
8
10
  id?: string;
9
11
  className?: string;
12
+ /** -1 lets a page move focus to the heading (a pane's title on open) without putting it in the tab order. */
13
+ tabIndex?: number;
10
14
  }
11
- export default function Heading({ children, level, size, id, className }: HeadingProps): React.JSX.Element;
15
+ export default function Heading({ children, level, size, color, id, className, tabIndex }: HeadingProps): React.JSX.Element;
12
16
  export {};
@@ -6,9 +6,9 @@ var sizes = {
6
6
  subtitle1: 'text-subtitle1',
7
7
  };
8
8
  export default function Heading(_a) {
9
- var children = _a.children, _b = _a.level, level = _b === void 0 ? 3 : _b, _c = _a.size, size = _c === void 0 ? 'h6' : _c, id = _a.id, _d = _a.className, className = _d === void 0 ? '' : _d;
9
+ var children = _a.children, _b = _a.level, level = _b === void 0 ? 3 : _b, _c = _a.size, size = _c === void 0 ? 'h6' : _c, _d = _a.color, color = _d === void 0 ? 'default' : _d, id = _a.id, _e = _a.className, className = _e === void 0 ? '' : _e, tabIndex = _a.tabIndex;
10
10
  var Tag = "h".concat(level);
11
- return (<Tag id={id} className={"".concat(sizes[size], " text-fg-primary ").concat(className)}>
11
+ return (<Tag id={id} tabIndex={tabIndex} className={"".concat(sizes[size], " ").concat(color === 'danger' ? 'text-error-text' : 'text-fg-primary', " ").concat(className)}>
12
12
  {children}
13
13
  </Tag>);
14
14
  }
@@ -5,7 +5,12 @@ interface LinkProps {
5
5
  color?: 'info' | 'error' | 'warning' | 'success';
6
6
  size?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subtitle1' | 'subtitle2' | 'body1' | 'body2' | 'caption';
7
7
  openInNewTab?: boolean;
8
+ /**
9
+ * When the link opens a new tab, add a small external icon and the hidden words '(opens in a new tab)',
10
+ * so a screen reader hears it too. Default false.
11
+ */
12
+ announceNewTab?: boolean;
8
13
  className?: string;
9
14
  }
10
- export default function Link({ href, children, color, size, openInNewTab, className, }: LinkProps): React.JSX.Element;
15
+ export default function Link({ href, children, color, size, openInNewTab, announceNewTab, className, }: LinkProps): React.JSX.Element;
11
16
  export {};