oneslash-design-system 2.15.0 → 2.16.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 (195) hide show
  1. package/README.md +6 -1
  2. package/dist/DESIGN.md +75 -71
  3. package/dist/cases/accept-invite/signed-in.d.ts +1 -0
  4. package/dist/cases/accept-invite/signed-in.jsx +57 -0
  5. package/dist/cases/accept-invite/signed-out.d.ts +1 -0
  6. package/dist/cases/accept-invite/signed-out.jsx +33 -0
  7. package/dist/cases/accept-invite.md +161 -0
  8. package/dist/cases/agent-asks-before-risky-action.md +1 -1
  9. package/dist/cases/agent-cancels-when-unanswered.md +1 -1
  10. package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
  11. package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
  12. package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
  13. package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
  14. package/dist/cases/auth-gate-loading.md +70 -0
  15. package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
  16. package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
  17. package/dist/cases/check-your-email/page.d.ts +1 -0
  18. package/dist/cases/check-your-email/page.jsx +49 -0
  19. package/dist/cases/check-your-email.md +184 -0
  20. package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
  21. package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
  22. package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
  23. package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
  24. package/dist/cases/confirm-destructive-action.md +211 -0
  25. package/dist/cases/confirm-dialogs.md +36 -0
  26. package/dist/cases/create-modal/quick.d.ts +1 -0
  27. package/dist/cases/create-modal/quick.jsx +80 -0
  28. package/dist/cases/create-modal/with-settings.d.ts +1 -0
  29. package/dist/cases/create-modal/with-settings.jsx +99 -0
  30. package/dist/cases/create-modal.md +244 -0
  31. package/dist/cases/device-login/popup.d.ts +1 -0
  32. package/dist/cases/device-login/popup.jsx +14 -0
  33. package/dist/cases/device-login/provider-first.d.ts +1 -0
  34. package/dist/cases/device-login/provider-first.jsx +98 -0
  35. package/dist/cases/device-login.md +171 -0
  36. package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
  37. package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
  38. package/dist/cases/email-confirmed/page.d.ts +1 -0
  39. package/dist/cases/email-confirmed/page.jsx +21 -0
  40. package/dist/cases/email-confirmed.md +151 -0
  41. package/dist/cases/empty-list/region.d.ts +1 -0
  42. package/dist/cases/empty-list/region.jsx +13 -0
  43. package/dist/cases/empty-list/section.d.ts +1 -0
  44. package/dist/cases/empty-list/section.jsx +17 -0
  45. package/dist/cases/empty-list.md +77 -0
  46. package/dist/cases/empty-lists.md +35 -0
  47. package/dist/cases/empty-not-set-up/action.d.ts +1 -0
  48. package/dist/cases/empty-not-set-up/action.jsx +16 -0
  49. package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
  50. package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
  51. package/dist/cases/empty-not-set-up.md +88 -0
  52. package/dist/cases/empty-search/clear-search.d.ts +1 -0
  53. package/dist/cases/empty-search/clear-search.jsx +29 -0
  54. package/dist/cases/empty-search.md +77 -0
  55. package/dist/cases/error-page/full-page.d.ts +1 -0
  56. package/dist/cases/error-page/full-page.jsx +19 -0
  57. package/dist/cases/error-page/in-shell.d.ts +1 -0
  58. package/dist/cases/error-page/in-shell.jsx +39 -0
  59. package/dist/cases/error-page.md +107 -0
  60. package/dist/cases/feedback-form/modal.d.ts +1 -0
  61. package/dist/cases/feedback-form/modal.jsx +89 -0
  62. package/dist/cases/feedback-form.md +139 -0
  63. package/dist/cases/forgot-password/in-place.d.ts +1 -0
  64. package/dist/cases/forgot-password/in-place.jsx +155 -0
  65. package/dist/cases/forgot-password/own-page.d.ts +1 -0
  66. package/dist/cases/forgot-password/own-page.jsx +99 -0
  67. package/dist/cases/forgot-password.md +328 -0
  68. package/dist/cases/form-errors.md +32 -0
  69. package/dist/cases/import-checklist/modal.d.ts +1 -0
  70. package/dist/cases/import-checklist/modal.jsx +125 -0
  71. package/dist/cases/import-checklist.md +188 -0
  72. package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
  73. package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
  74. package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
  75. package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
  76. package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
  77. package/dist/cases/inline-form-feedback/toast.jsx +66 -0
  78. package/dist/cases/inline-form-feedback.md +237 -0
  79. package/dist/cases/invite-member/by-email.d.ts +1 -0
  80. package/dist/cases/invite-member/by-email.jsx +98 -0
  81. package/dist/cases/invite-member/by-link.d.ts +1 -0
  82. package/dist/cases/invite-member/by-link.jsx +122 -0
  83. package/dist/cases/invite-member.md +321 -0
  84. package/dist/cases/load-failure/inline.d.ts +1 -0
  85. package/dist/cases/load-failure/inline.jsx +52 -0
  86. package/dist/cases/load-failure/region.d.ts +1 -0
  87. package/dist/cases/load-failure/region.jsx +34 -0
  88. package/dist/cases/load-failure.md +155 -0
  89. package/dist/cases/log-out-confirm/modal.d.ts +1 -0
  90. package/dist/cases/log-out-confirm/modal.jsx +57 -0
  91. package/dist/cases/log-out-confirm.md +106 -0
  92. package/dist/cases/login-page/centered.jsx +10 -7
  93. package/dist/cases/login-page/email-only.jsx +11 -8
  94. package/dist/cases/login-page/provider-first.jsx +12 -9
  95. package/dist/cases/login-page/split.jsx +11 -8
  96. package/dist/cases/login-page.md +58 -41
  97. package/dist/cases/not-found-page/full-page.d.ts +1 -0
  98. package/dist/cases/not-found-page/full-page.jsx +16 -0
  99. package/dist/cases/not-found-page/in-shell.d.ts +1 -0
  100. package/dist/cases/not-found-page/in-shell.jsx +36 -0
  101. package/dist/cases/not-found-page.md +98 -0
  102. package/dist/cases/oauth-consent/simple.d.ts +1 -0
  103. package/dist/cases/oauth-consent/simple.jsx +73 -0
  104. package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
  105. package/dist/cases/oauth-consent/with-scope.jsx +89 -0
  106. package/dist/cases/oauth-consent.md +233 -0
  107. package/dist/cases/rename/inline.d.ts +1 -0
  108. package/dist/cases/rename/inline.jsx +58 -0
  109. package/dist/cases/rename/modal.d.ts +1 -0
  110. package/dist/cases/rename/modal.jsx +70 -0
  111. package/dist/cases/rename.md +205 -0
  112. package/dist/cases/route-loading/full-screen.d.ts +1 -0
  113. package/dist/cases/route-loading/full-screen.jsx +8 -0
  114. package/dist/cases/route-loading/region.d.ts +1 -0
  115. package/dist/cases/route-loading/region.jsx +26 -0
  116. package/dist/cases/route-loading.md +84 -0
  117. package/dist/cases/set-new-password/form.d.ts +1 -0
  118. package/dist/cases/set-new-password/form.jsx +130 -0
  119. package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
  120. package/dist/cases/set-new-password/invalid-link.jsx +50 -0
  121. package/dist/cases/set-new-password.md +247 -0
  122. package/dist/cases/sign-up-page/centered.d.ts +1 -0
  123. package/dist/cases/sign-up-page/centered.jsx +124 -0
  124. package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
  125. package/dist/cases/sign-up-page/provider-first.jsx +124 -0
  126. package/dist/cases/sign-up-page/split.d.ts +1 -0
  127. package/dist/cases/sign-up-page/split.jsx +134 -0
  128. package/dist/cases/sign-up-page.md +478 -0
  129. package/dist/cases/success-feedback.md +35 -0
  130. package/dist/cases/type-to-confirm/inline.d.ts +1 -0
  131. package/dist/cases/type-to-confirm/inline.jsx +69 -0
  132. package/dist/cases/type-to-confirm/modal.d.ts +1 -0
  133. package/dist/cases/type-to-confirm/modal.jsx +73 -0
  134. package/dist/cases/type-to-confirm.md +222 -0
  135. package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
  136. package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
  137. package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
  138. package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
  139. package/dist/cases/unsaved-changes-guard.md +239 -0
  140. package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
  141. package/dist/cases/upgrade-prompt/inline.jsx +52 -0
  142. package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
  143. package/dist/cases/upgrade-prompt/modal.jsx +43 -0
  144. package/dist/cases/upgrade-prompt.md +174 -0
  145. package/dist/cases.json +1856 -39
  146. package/dist/components/alert.d.ts +3 -1
  147. package/dist/components/alert.jsx +6 -4
  148. package/dist/components/emptyBox.d.ts +6 -1
  149. package/dist/components/emptyBox.jsx +4 -2
  150. package/dist/components/heading.d.ts +2 -2
  151. package/dist/components/loadingScreen.d.ts +5 -1
  152. package/dist/components/loadingScreen.jsx +4 -2
  153. package/dist/components/modal.d.ts +2 -1
  154. package/dist/components/modal.jsx +20 -8
  155. package/dist/components/radioGroup.d.ts +2 -1
  156. package/dist/components/radioGroup.jsx +2 -2
  157. package/dist/components/select.d.ts +2 -1
  158. package/dist/components/select.jsx +4 -2
  159. package/dist/components/tab.jsx +3 -2
  160. package/dist/components/tabsContainer.d.ts +4 -1
  161. package/dist/components/tabsContainer.jsx +7 -3
  162. package/dist/components/textField.d.ts +5 -1
  163. package/dist/components/textField.jsx +7 -3
  164. package/dist/components/toaster.d.ts +12 -0
  165. package/dist/components/toaster.jsx +103 -0
  166. package/dist/internal/alert.d.ts +4 -0
  167. package/dist/internal/alert.js +6 -0
  168. package/dist/internal/modal.d.ts +2 -0
  169. package/dist/internal/modal.js +21 -0
  170. package/dist/internal/toaster.d.ts +19 -0
  171. package/dist/internal/toaster.js +50 -0
  172. package/dist/native-mapping.json +6 -0
  173. package/dist/stories/Alert.stories.d.ts +1 -0
  174. package/dist/stories/Alert.stories.jsx +16 -0
  175. package/dist/stories/Cases.generated.stories.d.ts +52 -0
  176. package/dist/stories/Cases.generated.stories.jsx +104 -0
  177. package/dist/stories/EmptyBox.stories.d.ts +2 -0
  178. package/dist/stories/EmptyBox.stories.jsx +16 -0
  179. package/dist/stories/Heading.stories.d.ts +6 -0
  180. package/dist/stories/Heading.stories.jsx +10 -0
  181. package/dist/stories/LoadingScreen.stories.d.ts +1 -0
  182. package/dist/stories/LoadingScreen.stories.jsx +8 -0
  183. package/dist/stories/Modal.stories.d.ts +2 -0
  184. package/dist/stories/Modal.stories.jsx +36 -0
  185. package/dist/stories/RadioGroup.stories.d.ts +1 -0
  186. package/dist/stories/RadioGroup.stories.jsx +14 -0
  187. package/dist/stories/Select.stories.d.ts +1 -0
  188. package/dist/stories/Select.stories.jsx +14 -0
  189. package/dist/stories/TabsContainer.stories.d.ts +1 -0
  190. package/dist/stories/TabsContainer.stories.jsx +12 -0
  191. package/dist/stories/TextField.stories.d.ts +2 -0
  192. package/dist/stories/TextField.stories.jsx +22 -0
  193. package/dist/stories/Toaster.stories.d.ts +6 -0
  194. package/dist/stories/Toaster.stories.jsx +29 -0
  195. package/package.json +1 -1
@@ -7,6 +7,8 @@ interface AlertProps {
7
7
  onClose?: () => void;
8
8
  showCloseButton?: boolean;
9
9
  variant?: 'toast' | 'inline';
10
+ /** 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
+ autoDismiss?: boolean;
10
12
  }
11
- export default function Alert({ open, type, message, secondMessage, onClose, showCloseButton, variant, }: AlertProps): React.JSX.Element | null;
13
+ export default function Alert({ open, type, message, secondMessage, onClose, showCloseButton, variant, autoDismiss, }: AlertProps): React.JSX.Element | null;
12
14
  export {};
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import React, { useEffect, useRef, useState } from 'react';
3
3
  import IconButton from './iconButton';
4
+ import { shouldAutoDismiss } from '../internal/alert';
4
5
  var bgClassMap = {
5
6
  error: 'bg-error-alertBg',
6
7
  warning: 'bg-warning-alertBg',
@@ -17,7 +18,7 @@ var motionClasses = {
17
18
  };
18
19
  export default function Alert(_a) {
19
20
  var _b;
20
- 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;
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
22
  var _f = useState(false), isVisible = _f[0], setIsVisible = _f[1];
22
23
  var _g = useState(false), shouldRender = _g[0], setShouldRender = _g[1];
23
24
  // Auto-dismiss pauses while the toast is hovered or focused
@@ -40,9 +41,10 @@ export default function Alert(_a) {
40
41
  return function () { return clearTimeout(hideTimer_1); };
41
42
  }
42
43
  }, [open, showCloseButton, shouldRender]);
43
- // Only auto-dismiss if there's no close button
44
+ // Auto-dismiss unless autoDismiss says otherwise; by default only an alert with no close button
45
+ var autoDismissOn = shouldAutoDismiss({ autoDismiss: autoDismiss, showCloseButton: showCloseButton });
44
46
  useEffect(function () {
45
- if (!open || !shouldRender || showCloseButton || isPaused)
47
+ if (!open || !shouldRender || !autoDismissOn || isPaused)
46
48
  return;
47
49
  var startedAt = Date.now();
48
50
  var dismissTimer = setTimeout(function () { return handleClose(); }, remainingMs.current);
@@ -50,7 +52,7 @@ export default function Alert(_a) {
50
52
  clearTimeout(dismissTimer);
51
53
  remainingMs.current -= Date.now() - startedAt;
52
54
  };
53
- }, [open, shouldRender, showCloseButton, isPaused]); // eslint-disable-line react-hooks/exhaustive-deps
55
+ }, [open, shouldRender, autoDismissOn, isPaused]); // eslint-disable-line react-hooks/exhaustive-deps
54
56
  var handleClose = function () {
55
57
  setIsVisible(false);
56
58
  // Wait for animation to complete before unmounting
@@ -1,8 +1,13 @@
1
1
  import React from 'react';
2
+ import { type IconSource } from './iconSlot';
2
3
  interface EmptyBoxProps {
3
4
  text: string;
4
5
  secondText?: string;
5
6
  size: "small" | "large";
7
+ /** Shown under the text, centered, for the one thing to do next. Wrap more than one Button yourself. */
8
+ action?: React.ReactNode;
9
+ /** Replaces the default icon: a Lucide name, an icon component or an element */
10
+ icon?: IconSource;
6
11
  }
7
- export default function EmptyBox({ text, secondText, size, }: EmptyBoxProps): React.JSX.Element;
12
+ export default function EmptyBox({ text, secondText, size, action, icon, }: EmptyBoxProps): React.JSX.Element;
8
13
  export {};
@@ -1,15 +1,16 @@
1
1
  'use client';
2
2
  import React from 'react';
3
3
  import { AlertCircle } from 'lucide-react';
4
+ import IconSlot from './iconSlot';
4
5
  export default function EmptyBox(_a) {
5
- var text = _a.text, secondText = _a.secondText, size = _a.size;
6
+ var text = _a.text, secondText = _a.secondText, size = _a.size, action = _a.action, icon = _a.icon;
6
7
  // The icon can be faint; the text needs readable contrast
7
8
  var iconColor = 'text-fg-disabled';
8
9
  var textColor = 'text-fg-secondary';
9
10
  var height = size === 'small' ? 'py-6' : 'h-full';
10
11
  var iconSize = 'size-6';
11
12
  return (<div className={"flex flex-col space-y-2 justify-center items-center w-full ".concat(height)}>
12
- <AlertCircle className={"".concat(iconSize, " ").concat(iconColor)} strokeWidth={2} aria-hidden/>
13
+ {icon ? (<IconSlot icon={icon} className={"".concat(iconSize, " ").concat(iconColor)}/>) : (<AlertCircle className={"".concat(iconSize, " ").concat(iconColor)} strokeWidth={2} aria-hidden/>)}
13
14
  <div className="flex flex-col text-center">
14
15
  <p className={"text-body1 ".concat(textColor)}>
15
16
  {text}
@@ -18,5 +19,6 @@ export default function EmptyBox(_a) {
18
19
  {secondText}
19
20
  </p>)}
20
21
  </div>
22
+ {action}
21
23
  </div>);
22
24
  }
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  interface HeadingProps {
3
3
  children: React.ReactNode;
4
- /** The element: h2 to h4. Pick the one that fits the page's outline, not the size. */
5
- level?: 2 | 3 | 4;
4
+ /** The element: h1 to h4. Pick the one that fits the page's outline, not the size. */
5
+ level?: 1 | 2 | 3 | 4;
6
6
  /** How large it is set. */
7
7
  size?: 'h4' | 'h5' | 'h6' | 'subtitle1';
8
8
  id?: string;
@@ -2,6 +2,10 @@ import React from 'react';
2
2
  interface LoadingSmallProps {
3
3
  size?: 'large' | 'medium' | 'small' | 'tiny';
4
4
  }
5
- export default function LoadingScreen(): React.JSX.Element;
5
+ interface LoadingScreenProps {
6
+ /** One line of text centered under the spinner. It is also the status element's accessible name, in place of "Loading". */
7
+ label?: string;
8
+ }
9
+ export default function LoadingScreen({ label }?: LoadingScreenProps): React.JSX.Element;
6
10
  export declare function LoadingSmall({ size }: LoadingSmallProps): React.JSX.Element;
7
11
  export {};
@@ -1,8 +1,10 @@
1
1
  'use client';
2
2
  import React from 'react';
3
- export default function LoadingScreen() {
4
- return (<div role="status" aria-label="Loading" className="flex justify-center items-center h-full w-full min-h-[200px]">
3
+ export default function LoadingScreen(_a) {
4
+ var _b = _a === void 0 ? {} : _a, label = _b.label;
5
+ return (<div role="status" aria-label={label !== null && label !== void 0 ? label : 'Loading'} className={"flex ".concat(label ? 'flex-col ' : '', "justify-center items-center ").concat(label ? 'gap-1 ' : '', "h-full w-full min-h-[200px]")}>
5
6
  <div className="w-12 h-12 rounded-full border-4 border-current border-t-transparent text-fg-primary animate-spin"></div>
7
+ {label && <p className="text-body2 text-fg-secondary text-center">{label}</p>}
6
8
  </div>);
7
9
  }
8
10
  ;
@@ -7,6 +7,7 @@ interface ModalProps {
7
7
  onClose: () => void;
8
8
  actions?: React.ReactNode;
9
9
  size?: 'small' | 'medium' | 'large';
10
+ initialFocus?: 'first' | 'body';
10
11
  }
11
- export default function Modal({ isOpen, title, secondTitle, children, onClose, actions, size, }: ModalProps): React.JSX.Element | null;
12
+ export default function Modal({ isOpen, title, secondTitle, children, onClose, actions, size, initialFocus, }: ModalProps): React.JSX.Element | null;
12
13
  export {};
@@ -2,26 +2,38 @@
2
2
  import React, { useEffect, useId, useRef } from 'react';
3
3
  import { overlayHidden, overlayTransition, overlayVisible } from './sharedStyles';
4
4
  import { useOverlayTransition } from './useOverlayTransition';
5
+ import { initialFocusCandidates } from '../internal/modal';
5
6
  var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
7
+ // For the first focus and the Tab trap: the same, minus a hidden input, which matches but cannot take focus
8
+ var PICKABLE = FOCUSABLE.replace('input:not([disabled])', 'input:not([disabled]):not([type="hidden"])');
6
9
  export default function Modal(_a) {
7
- var isOpen = _a.isOpen, title = _a.title, secondTitle = _a.secondTitle, children = _a.children, onClose = _a.onClose, actions = _a.actions, _b = _a.size, size = _b === void 0 ? 'medium' : _b;
10
+ var isOpen = _a.isOpen, title = _a.title, secondTitle = _a.secondTitle, children = _a.children, onClose = _a.onClose, actions = _a.actions, _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.initialFocus, initialFocus = _c === void 0 ? 'first' : _c;
8
11
  var panelRef = useRef(null);
12
+ var bodyRef = useRef(null);
9
13
  var titleId = useId();
10
- var _c = useOverlayTransition(isOpen), mounted = _c.mounted, visible = _c.visible;
14
+ var _d = useOverlayTransition(isOpen), mounted = _d.mounted, visible = _d.visible;
11
15
  // Keep onClose in a ref so a new function each render doesn't re-run the focus effect
12
16
  var onCloseRef = useRef(onClose);
13
17
  onCloseRef.current = onClose;
14
18
  // Move focus into the panel, trap Tab inside it, close on Escape,
15
19
  // lock page scroll, and give focus back to the trigger on close
16
20
  useEffect(function () {
17
- var _a;
21
+ var _a, _b, _c;
18
22
  // Wait for the panel to mount before moving focus into it
19
23
  if (!isOpen || !mounted)
20
24
  return;
21
25
  var previouslyFocused = document.activeElement;
22
26
  var panel = panelRef.current;
23
- var firstFocusable = panel === null || panel === void 0 ? void 0 : panel.querySelector(FOCUSABLE);
24
- (_a = (firstFocusable !== null && firstFocusable !== void 0 ? firstFocusable : panel)) === null || _a === void 0 ? void 0 : _a.focus();
27
+ 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);
28
+ // An element that is hidden or display:none ignores focus(); try the next one
29
+ for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
30
+ var candidate = candidates_1[_i];
31
+ candidate.focus();
32
+ if (panel === null || panel === void 0 ? void 0 : panel.contains(document.activeElement))
33
+ break;
34
+ }
35
+ if (panel && !panel.contains(document.activeElement))
36
+ panel.focus();
25
37
  var previousOverflow = document.body.style.overflow;
26
38
  document.body.style.overflow = 'hidden';
27
39
  var handleKeyDown = function (e) {
@@ -31,7 +43,7 @@ export default function Modal(_a) {
31
43
  }
32
44
  if (e.key !== 'Tab' || !panel)
33
45
  return;
34
- var focusable = Array.from(panel.querySelectorAll(FOCUSABLE));
46
+ var focusable = Array.from(panel.querySelectorAll(PICKABLE));
35
47
  if (focusable.length === 0) {
36
48
  e.preventDefault();
37
49
  return;
@@ -61,7 +73,7 @@ export default function Modal(_a) {
61
73
  medium: { width: 'w-[600px]', maxWidth: '600px' },
62
74
  large: { width: 'w-[1024px]', maxWidth: '1024px' },
63
75
  };
64
- var _d = sizeConfig[size], modalWidth = _d.width, maxWidth = _d.maxWidth;
76
+ var _e = sizeConfig[size], modalWidth = _e.width, maxWidth = _e.maxWidth;
65
77
  // close modal by clicking elsewhere
66
78
  var handleOverlayClick = function (e) {
67
79
  if (e.target === e.currentTarget) {
@@ -92,7 +104,7 @@ export default function Modal(_a) {
92
104
  </div>)}
93
105
  </div>)}
94
106
 
95
- <div className="text-body1 space-y-4 text-fg-primary p-6" style={{
107
+ <div ref={bodyRef} className="text-body1 space-y-4 text-fg-primary p-6" style={{
96
108
  overflowY: 'auto',
97
109
  flexGrow: 1,
98
110
  minHeight: 0,
@@ -9,6 +9,7 @@ interface RadioGroupProps {
9
9
  selectedValue: string;
10
10
  onChange: (value: string) => void;
11
11
  direction?: 'horizontal' | 'vertical';
12
+ 'aria-label'?: string;
12
13
  }
13
- export default function RadioGroup({ options, selectedValue, onChange, direction, }: RadioGroupProps): React.JSX.Element;
14
+ export default function RadioGroup({ options, selectedValue, onChange, direction, 'aria-label': ariaLabel, }: RadioGroupProps): React.JSX.Element;
14
15
  export {};
@@ -2,10 +2,10 @@
2
2
  import React, { useId } from 'react';
3
3
  import { popTransition, stateTransition } from './sharedStyles';
4
4
  export default function RadioGroup(_a) {
5
- var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b;
5
+ var options = _a.options, selectedValue = _a.selectedValue, onChange = _a.onChange, _b = _a.direction, direction = _b === void 0 ? 'vertical' : _b, ariaLabel = _a["aria-label"];
6
6
  // One shared name gives native arrow-key movement between the options
7
7
  var groupName = useId();
8
- return (<div role="radiogroup" className={"flex ".concat(direction === 'horizontal' ? 'gap-4' : 'flex-col gap-2')}>
8
+ return (<div role="radiogroup" aria-label={ariaLabel} className={"flex ".concat(direction === 'horizontal' ? 'gap-4' : 'flex-col gap-2')}>
9
9
  {options.map(function (option) {
10
10
  var isSelected = selectedValue === option.value;
11
11
  return (<label key={option.value} className="group relative flex items-start cursor-pointer">
@@ -14,6 +14,7 @@ interface SelectProps {
14
14
  width?: number | string;
15
15
  multiple?: boolean;
16
16
  className?: string;
17
+ 'aria-label'?: string;
17
18
  }
18
- export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, }: SelectProps): React.JSX.Element;
19
+ export default function Select({ value, options, onChange, disabled, placeholder, decoIconName, width, multiple, className, 'aria-label': ariaLabel, }: SelectProps): React.JSX.Element;
19
20
  export { Select };
@@ -42,7 +42,7 @@ var popperOptions = {
42
42
  };
43
43
  export default function Select(_a) {
44
44
  var _b, _c;
45
- var value = _a.value, options = _a.options, onChange = _a.onChange, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? 'Label' : _e, decoIconName = _a.decoIconName, width = _a.width, _f = _a.multiple, multiple = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? '' : _g;
45
+ var value = _a.value, options = _a.options, onChange = _a.onChange, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.placeholder, placeholder = _e === void 0 ? 'Label' : _e, decoIconName = _a.decoIconName, width = _a.width, _f = _a.multiple, multiple = _f === void 0 ? false : _f, _g = _a.className, className = _g === void 0 ? '' : _g, ariaLabel = _a["aria-label"];
46
46
  var _h = useState(false), isOpen = _h[0], setIsOpen = _h[1];
47
47
  // Option highlighted by the keyboard; focus itself stays on the trigger
48
48
  var _j = useState(-1), activeIndex = _j[0], setActiveIndex = _j[1];
@@ -153,6 +153,8 @@ export default function Select(_a) {
153
153
  break;
154
154
  case 'Escape':
155
155
  e.preventDefault();
156
+ // Close only the list: keep this Escape from reaching a Modal's window listener
157
+ e.stopPropagation();
156
158
  closeMenu();
157
159
  break;
158
160
  case 'Tab':
@@ -208,7 +210,7 @@ export default function Select(_a) {
208
210
  };
209
211
  return (<div className={"relative ".concat(className)} style={{ width: width || '100%' }}>
210
212
  {/* Select Button */}
211
- <div ref={setTrigger} role="combobox" aria-haspopup="listbox" aria-expanded={isOpen} aria-controls={listboxId} aria-activedescendant={isOpen && activeIndex >= 0 ? optionId(activeIndex) : undefined} aria-disabled={disabled || undefined} className={"\n rounded-control\n ".concat(getStateStyles(), "\n ").concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer', "\n ").concat(stateTransition, "\n ").concat(focusRing, "\n ")} onClick={handleToggle} tabIndex={disabled ? -1 : 0} onKeyDown={handleKeyDown}>
213
+ <div ref={setTrigger} role="combobox" aria-label={ariaLabel} aria-haspopup="listbox" aria-expanded={isOpen} aria-controls={listboxId} aria-activedescendant={isOpen && activeIndex >= 0 ? optionId(activeIndex) : undefined} aria-disabled={disabled || undefined} className={"\n rounded-control\n ".concat(getStateStyles(), "\n ").concat(disabled ? 'cursor-not-allowed' : 'cursor-pointer', "\n ").concat(stateTransition, "\n ").concat(focusRing, "\n ")} onClick={handleToggle} tabIndex={disabled ? -1 : 0} onKeyDown={handleKeyDown}>
212
214
  {/* Inner Content Container; 7px vertical padding makes the control 40px like Button and TextField */}
213
215
  <div className={"flex items-center justify-between px-2 py-[7px] ".concat(getTextColor())}>
214
216
  {/* Content Container */}
@@ -1,11 +1,12 @@
1
1
  'use client';
2
2
  import React, { useContext } from 'react';
3
3
  import IconSlot from './iconSlot';
4
- import { TabsContainerContext } from './tabsContainer';
4
+ import { TabsContainerContext, TabsFillContext } from './tabsContainer';
5
5
  import { focusRing, pressFeedbackAny, stateTransition } from './sharedStyles';
6
6
  export default function Tab(_a) {
7
7
  var label = _a.label, secondLabel = _a.secondLabel, href = _a.href, isSelected = _a.isSelected, onClickTab = _a.onClickTab, onClickActionIcon = _a.onClickActionIcon, decoIcon = _a.decoIcon, actionIcon = _a.actionIcon, router = _a.router, _b = _a.size, size = _b === void 0 ? 'medium' : _b;
8
8
  var inContainer = useContext(TabsContainerContext);
9
+ var fill = useContext(TabsFillContext);
9
10
  var handleClick = function () {
10
11
  onClickTab();
11
12
  if (href && router) {
@@ -28,7 +29,7 @@ export default function Tab(_a) {
28
29
  e.preventDefault();
29
30
  handleClick();
30
31
  }
31
- }} className={"\n relative flex items-center space-x-1 rounded-control cursor-pointer justify-start ".concat(stateTransition, " ").concat(pressFeedbackAny, " ").concat(focusRing, "\n ").concat(sizeClasses.tab, "\n ").concat(isSelected
32
+ }} className={"\n relative flex items-center space-x-1 rounded-control cursor-pointer ".concat(fill ? 'flex-1 justify-center' : 'justify-start', " ").concat(stateTransition, " ").concat(pressFeedbackAny, " ").concat(focusRing, "\n ").concat(sizeClasses.tab, "\n ").concat(isSelected
32
33
  ? selectedClasses
33
34
  : 'text-fg-primary hover:bg-background-accent200', "\n ")} onClick={handleClick}>
34
35
  <IconSlot icon={decoIcon} className={sizeClasses.icon}/>
@@ -1,7 +1,10 @@
1
1
  import React from 'react';
2
2
  interface TabsContainerProps {
3
3
  children: React.ReactNode;
4
+ /** The container is as wide as its parent and every tab takes an equal share, label centered. */
5
+ fill?: boolean;
4
6
  }
5
7
  export declare const TabsContainerContext: React.Context<boolean>;
6
- export default function TabsContainer({ children, }: TabsContainerProps): React.JSX.Element;
8
+ export declare const TabsFillContext: React.Context<boolean>;
9
+ export default function TabsContainer({ children, fill, }: TabsContainerProps): React.JSX.Element;
7
10
  export {};
@@ -4,12 +4,14 @@ import React, { createContext, useEffect, useLayoutEffect, useRef, useState } fr
4
4
  var useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
5
5
  // Lets a Tab know a container draws its selected background (the sliding pill)
6
6
  export var TabsContainerContext = createContext(false);
7
+ // Lets a Tab know every tab in the container takes an equal share of the width
8
+ export var TabsFillContext = createContext(false);
7
9
  export default function TabsContainer(_a) {
8
- var children = _a.children;
10
+ var children = _a.children, _b = _a.fill, fill = _b === void 0 ? false : _b;
9
11
  var tabCount = React.Children.count(children);
10
12
  var containerRef = useRef(null);
11
13
  var selectedRef = useRef(null);
12
- var _b = useState(null), indicator = _b[0], setIndicator = _b[1];
14
+ var _c = useState(null), indicator = _c[0], setIndicator = _c[1];
13
15
  useIsomorphicLayoutEffect(function () {
14
16
  var _a;
15
17
  var container = containerRef.current;
@@ -61,6 +63,7 @@ export default function TabsContainer(_a) {
61
63
  };
62
64
  }, [children]);
63
65
  return (<TabsContainerContext.Provider value={true}>
66
+ <TabsFillContext.Provider value={fill}>
64
67
  <div ref={containerRef} role="tablist" onKeyDown={function (e) {
65
68
  var _a, _b;
66
69
  // Arrow keys move focus to the next tab and select it
@@ -79,7 +82,7 @@ export default function TabsContainer(_a) {
79
82
  e.preventDefault();
80
83
  tabs[next].focus();
81
84
  tabs[next].click();
82
- }} className={"\n relative flex gap-0.5 p-1 rounded-container overflow-x-auto\n ".concat(tabCount > 0 ? 'bg-background-accent100' : 'bg-transparent', "\n ")} style={{
85
+ }} className={"\n relative flex gap-0.5 p-1 rounded-container overflow-x-auto".concat(fill ? ' w-full' : '', "\n ").concat(tabCount > 0 ? 'bg-background-accent100' : 'bg-transparent', "\n ")} style={{
83
86
  scrollbarWidth: 'none',
84
87
  msOverflowStyle: 'none',
85
88
  }}>
@@ -92,5 +95,6 @@ export default function TabsContainer(_a) {
92
95
  }}/>)}
93
96
  {children}
94
97
  </div>
98
+ </TabsFillContext.Provider>
95
99
  </TabsContainerContext.Provider>);
96
100
  }
@@ -13,9 +13,13 @@ interface TextFieldProps {
13
13
  multiline?: boolean;
14
14
  maxRows?: number;
15
15
  disabled?: boolean;
16
+ /** Passed to the `<input>` or `<textarea>`: the text can be focused and selected but not changed. Keeps the normal colors, unlike `disabled`. `required` has no effect on a read-only field. */
17
+ readOnly?: boolean;
16
18
  error?: boolean;
17
19
  /** Message shown under the field when `error` is true */
18
20
  errorText?: string;
21
+ /** A caption under the field. Tied to the field with `aria-describedby`. While `error` is true the error text replaces it, so the error text should restate the rule. */
22
+ helperText?: string;
19
23
  required?: boolean;
20
24
  size?: 'large' | 'medium' | 'small' | 'tiny';
21
25
  placeholder?: string;
@@ -30,5 +34,5 @@ interface TextFieldProps {
30
34
  /** Passed to the `<input>` or `<textarea>`. Left to the browser's default when not set. */
31
35
  spellCheck?: boolean;
32
36
  }
33
- export default function TextField({ id, label, value, type, onChange, onBlur, onFocus, onKeyDown, onSubmit, autoFocus, multiline, maxRows, disabled, error, errorText, required, size, placeholder, name, autoComplete, tabIndex, maxLength, minLength, spellCheck, }: TextFieldProps): React.JSX.Element;
37
+ export default function TextField({ id, label, value, type, onChange, onBlur, onFocus, onKeyDown, onSubmit, autoFocus, multiline, maxRows, disabled, readOnly, error, errorText, helperText, required, size, placeholder, name, autoComplete, tabIndex, maxLength, minLength, spellCheck, }: TextFieldProps): React.JSX.Element;
34
38
  export {};
@@ -2,7 +2,7 @@
2
2
  import React from 'react';
3
3
  import { stateTransition } from './sharedStyles';
4
4
  export default function TextField(_a) {
5
- var id = _a.id, label = _a.label, value = _a.value, _b = _a.type, type = _b === void 0 ? 'text' : _b, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onSubmit = _a.onSubmit, _c = _a.autoFocus, autoFocus = _c === void 0 ? false : _c, _d = _a.multiline, multiline = _d === void 0 ? false : _d, _e = _a.maxRows, maxRows = _e === void 0 ? 6 : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.error, error = _g === void 0 ? false : _g, _h = _a.errorText, errorText = _h === void 0 ? 'This field is required' : _h, _j = _a.required, required = _j === void 0 ? false : _j, _k = _a.size, size = _k === void 0 ? 'medium' : _k, placeholder = _a.placeholder, name = _a.name, _l = _a.autoComplete, autoComplete = _l === void 0 ? 'off' : _l, tabIndex = _a.tabIndex, maxLength = _a.maxLength, minLength = _a.minLength, spellCheck = _a.spellCheck;
5
+ var id = _a.id, label = _a.label, value = _a.value, _b = _a.type, type = _b === void 0 ? 'text' : _b, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, onKeyDown = _a.onKeyDown, onSubmit = _a.onSubmit, _c = _a.autoFocus, autoFocus = _c === void 0 ? false : _c, _d = _a.multiline, multiline = _d === void 0 ? false : _d, _e = _a.maxRows, maxRows = _e === void 0 ? 6 : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.readOnly, readOnly = _g === void 0 ? false : _g, _h = _a.error, error = _h === void 0 ? false : _h, _j = _a.errorText, errorText = _j === void 0 ? 'This field is required' : _j, helperText = _a.helperText, _k = _a.required, required = _k === void 0 ? false : _k, _l = _a.size, size = _l === void 0 ? 'medium' : _l, placeholder = _a.placeholder, name = _a.name, _m = _a.autoComplete, autoComplete = _m === void 0 ? 'off' : _m, tabIndex = _a.tabIndex, maxLength = _a.maxLength, minLength = _a.minLength, spellCheck = _a.spellCheck;
6
6
  var handleKeyDown = function (e) {
7
7
  // Ctrl+Enter or Cmd+Enter to submit
8
8
  if ((e.ctrlKey || e.metaKey) && e.key === 'Enter' && onSubmit) {
@@ -35,6 +35,7 @@ export default function TextField(_a) {
35
35
  return "border-fg-disabled\n hover:border-fg-secondary\n focus:outline focus:outline-1 focus:outline-offset-2 focus:outline-fg-primary";
36
36
  };
37
37
  var errorId = "".concat(id, "-error");
38
+ var helperId = "".concat(id, "-helper");
38
39
  // Get inputMode for mobile keyboard optimization
39
40
  var getInputMode = function () {
40
41
  switch (type) {
@@ -55,17 +56,20 @@ export default function TextField(_a) {
55
56
  var containerClasses = "\n ".concat(colorClasses, "\n ").concat(baseClasses, "\n ").concat(sizeClasses, "\n ").concat(getBorderColor(), "\n ");
56
57
  var errorProps = {
57
58
  'aria-invalid': error || undefined,
58
- 'aria-describedby': error ? errorId : undefined,
59
+ 'aria-describedby': error ? errorId : helperText ? helperId : undefined,
59
60
  };
60
61
  return (<div className="flex flex-col w-full">
61
62
  {label && (<label htmlFor={id} className="mb-1 text-body2 text-fg-secondary">
62
63
  {label}{required && <span className="text-error-text ml-0.5">*</span>}
63
64
  </label>)}
64
65
  <div className="relative">
65
- {multiline ? (<textarea id={id} rows={maxRows} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>) : (<input id={id} type={type} inputMode={getInputMode()} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>)}
66
+ {multiline ? (<textarea id={id} rows={maxRows} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} readOnly={readOnly} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>) : (<input id={id} type={type} inputMode={getInputMode()} className={containerClasses} value={value} onChange={onChange} placeholder={placeholder} onFocus={onFocus} onBlur={onBlur} onKeyDown={handleKeyDown} autoFocus={autoFocus} disabled={disabled} readOnly={readOnly} required={required} name={name} autoComplete={autoComplete} tabIndex={tabIndex} maxLength={maxLength} minLength={minLength} spellCheck={spellCheck} {...errorProps}/>)}
66
67
  </div>
67
68
  {error && (<p id={errorId} className="mt-1 text-error-text text-body2">
68
69
  {errorText}
69
70
  </p>)}
71
+ {!error && helperText && (<p id={helperId} className="mt-1 text-fg-secondary text-body2">
72
+ {helperText}
73
+ </p>)}
70
74
  </div>);
71
75
  }
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export type ToastInput = {
3
+ type?: 'success' | 'warning' | 'error' | 'info' | 'default';
4
+ message: string;
5
+ secondMessage?: string;
6
+ /** Milliseconds before the toast closes itself; `null` keeps it until closed. Default 5000, and `null` for errors. A value that is not finite or is above 2^31-1 (what `setTimeout` can hold) counts as `null`. */
7
+ duration?: number | null;
8
+ };
9
+ /** Shows a toast and returns its id. Call it from client code (event handlers and effects), not from a Server Component or a server action. */
10
+ export declare function toast(input: string | ToastInput): string;
11
+ export declare function dismissToast(id: string): void;
12
+ export default function Toaster(): React.JSX.Element | null;
@@ -0,0 +1,103 @@
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 React, { useEffect, useReducer, useRef, useState, useSyncExternalStore } from 'react';
23
+ import Alert from './alert';
24
+ import { addToast, removeToast, visibleToasts, pauseReducer, isPaused } from '../internal/toaster';
25
+ // Matches Alert's exit transition
26
+ var EXIT_MS = 150;
27
+ var store = { toasts: [], mounts: [] };
28
+ var serverStore = { toasts: [], mounts: [] };
29
+ var listeners = new Set();
30
+ var nextId = 0;
31
+ var setStore = function (next) {
32
+ store = next;
33
+ listeners.forEach(function (l) { return l(); });
34
+ };
35
+ var subscribe = function (listener) {
36
+ listeners.add(listener);
37
+ return function () { return listeners.delete(listener); };
38
+ };
39
+ /** Shows a toast and returns its id. Call it from client code (event handlers and effects), not from a Server Component or a server action. */
40
+ export function toast(input) {
41
+ var id = "toast-".concat(++nextId);
42
+ // During a server render there is no Toaster to show it, and the store would outlive the request
43
+ if (typeof window === 'undefined')
44
+ return id;
45
+ setStore(__assign(__assign({}, store), { toasts: addToast(store.toasts, input, id) }));
46
+ return id;
47
+ }
48
+ export function dismissToast(id) {
49
+ var toasts = removeToast(store.toasts, id);
50
+ if (toasts !== store.toasts)
51
+ setStore(__assign(__assign({}, store), { toasts: toasts }));
52
+ }
53
+ function Toast(_a) {
54
+ var item = _a.item;
55
+ var _b = useState(true), open = _b[0], setOpen = _b[1];
56
+ var _c = useReducer(pauseReducer, { hovered: false, focused: false }), pause = _c[0], dispatch = _c[1];
57
+ var paused = isPaused(pause);
58
+ var remainingMs = useRef(item.duration);
59
+ useEffect(function () {
60
+ if (!open || paused || remainingMs.current === null)
61
+ return;
62
+ var startedAt = Date.now();
63
+ var timer = setTimeout(function () { return setOpen(false); }, remainingMs.current);
64
+ return function () {
65
+ clearTimeout(timer);
66
+ if (remainingMs.current !== null)
67
+ remainingMs.current -= Date.now() - startedAt;
68
+ };
69
+ }, [open, paused]);
70
+ // Let the alert fade out, then take the toast out of the store
71
+ useEffect(function () {
72
+ if (open)
73
+ return;
74
+ var timer = setTimeout(function () { return dismissToast(item.id); }, EXIT_MS);
75
+ return function () { return clearTimeout(timer); };
76
+ }, [open, item.id]);
77
+ return (<div className="pointer-events-auto" onMouseEnter={function () { return dispatch('pointerEnter'); }} onMouseLeave={function () { return dispatch('pointerLeave'); }} onFocus={function () { return dispatch('focus'); }}
78
+ // Focus moving to another element inside the same toast has not left it
79
+ onBlur={function (e) { if (!e.currentTarget.contains(e.relatedTarget))
80
+ dispatch('blur'); }}>
81
+ <Alert variant="inline" showCloseButton autoDismiss={false} open={open} type={item.type} message={item.message} secondMessage={item.secondMessage} onClose={function () { return dismissToast(item.id); }}/>
82
+ </div>);
83
+ }
84
+ // Mount once near the app root. A second Toaster renders nothing.
85
+ export default function Toaster() {
86
+ var _a = useSyncExternalStore(subscribe, function () { return store; }, function () { return serverStore; }), toasts = _a.toasts, mounts = _a.mounts;
87
+ var me = useState(function () { return Symbol('Toaster'); })[0];
88
+ useEffect(function () {
89
+ setStore(__assign(__assign({}, store), { mounts: __spreadArray(__spreadArray([], store.mounts, true), [me], false) }));
90
+ return function () { return setStore(__assign(__assign({}, store), { mounts: store.mounts.filter(function (m) { return m !== me; }) })); };
91
+ }, [me]);
92
+ if (mounts[0] !== me)
93
+ return null;
94
+ var shown = visibleToasts(toasts);
95
+ if (shown.length === 0)
96
+ return null;
97
+ // Above modals; the column lets clicks through beside and between the toasts
98
+ return (<div className="fixed top-4 inset-x-0 z-[var(--os-z-tooltip)] flex justify-center px-4 pointer-events-none">
99
+ <div className="flex flex-col gap-2 w-full max-w-md">
100
+ {shown.map(function (item) { return <Toast key={item.id} item={item}/>; })}
101
+ </div>
102
+ </div>);
103
+ }
@@ -0,0 +1,4 @@
1
+ export declare function shouldAutoDismiss({ autoDismiss, showCloseButton }: {
2
+ autoDismiss?: boolean;
3
+ showCloseButton?: boolean;
4
+ }): boolean;
@@ -0,0 +1,6 @@
1
+ // Alert's pure helper, kept out of the public API (index.ts and the package exports do not reach internal/)
2
+ // Whether the alert starts its own dismiss timer
3
+ export function shouldAutoDismiss(_a) {
4
+ var autoDismiss = _a.autoDismiss, showCloseButton = _a.showCloseButton;
5
+ return autoDismiss !== null && autoDismiss !== void 0 ? autoDismiss : !showCloseButton;
6
+ }
@@ -0,0 +1,2 @@
1
+ export declare function initialFocusCandidates<T>(panelFocusables: T[], bodyFocusables: T[], initialFocus?: 'first' | 'body'): T[];
2
+ export declare function pickInitialFocus<T>(panelFocusables: T[], bodyFocusables: T[], initialFocus?: 'first' | 'body'): T | undefined;
@@ -0,0 +1,21 @@
1
+ // Modal's pure helpers, kept out of the public API (index.ts and the package exports do not reach internal/)
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ // Elements to try for the first focus, best first. 'body' puts the body's elements ahead of the
12
+ // panel's, so it falls back to 'first' when the body has none or none of them takes focus.
13
+ export function initialFocusCandidates(panelFocusables, bodyFocusables, initialFocus) {
14
+ if (initialFocus === void 0) { initialFocus = 'first'; }
15
+ return initialFocus === 'body' ? __spreadArray(__spreadArray([], bodyFocusables, true), panelFocusables, true) : panelFocusables;
16
+ }
17
+ // Which element gets focus when the panel opens
18
+ export function pickInitialFocus(panelFocusables, bodyFocusables, initialFocus) {
19
+ if (initialFocus === void 0) { initialFocus = 'first'; }
20
+ return initialFocusCandidates(panelFocusables, bodyFocusables, initialFocus)[0];
21
+ }
@@ -0,0 +1,19 @@
1
+ import type { ToastInput } from '../components/toaster';
2
+ export type ToastItem = {
3
+ id: string;
4
+ type: NonNullable<ToastInput['type']>;
5
+ message: string;
6
+ secondMessage?: string;
7
+ duration: number | null;
8
+ };
9
+ export declare function addToast(state: ToastItem[], input: string | ToastInput, id: string): ToastItem[];
10
+ export declare function removeToast(state: ToastItem[], id: string): ToastItem[];
11
+ export declare function visibleToasts(state: ToastItem[]): ToastItem[];
12
+ type PauseState = {
13
+ hovered: boolean;
14
+ focused: boolean;
15
+ };
16
+ type PauseEvent = 'pointerEnter' | 'pointerLeave' | 'focus' | 'blur';
17
+ export declare function pauseReducer(state: PauseState, event: PauseEvent): PauseState;
18
+ export declare const isPaused: ({ hovered, focused }: PauseState) => boolean;
19
+ export {};