oneslash-design-system 2.28.1 → 2.30.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 (248) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +31 -1
  3. package/dist/cases/about-page.md +2 -0
  4. package/dist/cases/accept-invite.md +2 -0
  5. package/dist/cases/account-menu.md +2 -0
  6. package/dist/cases/activity-timeline.md +2 -0
  7. package/dist/cases/admin-inbox.md +2 -0
  8. package/dist/cases/agent-asks-before-risky-action.md +3 -1
  9. package/dist/cases/agent-cancels-when-unanswered.md +2 -0
  10. package/dist/cases/agent-changes-review/all-at-once.d.ts +1 -0
  11. package/dist/cases/agent-changes-review/all-at-once.jsx +238 -0
  12. package/dist/cases/agent-changes-review/per-change.d.ts +1 -0
  13. package/dist/cases/agent-changes-review/per-change.jsx +203 -0
  14. package/dist/cases/agent-changes-review.md +585 -0
  15. package/dist/cases/agent-handoff/to-agent.d.ts +1 -0
  16. package/dist/cases/agent-handoff/to-agent.jsx +53 -0
  17. package/dist/cases/agent-handoff/to-person.d.ts +1 -0
  18. package/dist/cases/agent-handoff/to-person.jsx +84 -0
  19. package/dist/cases/agent-handoff.md +231 -0
  20. package/dist/cases/agent-memory/list.d.ts +1 -0
  21. package/dist/cases/agent-memory/list.jsx +256 -0
  22. package/dist/cases/agent-memory.md +354 -0
  23. package/dist/cases/agent-options.md +2 -0
  24. package/dist/cases/agent-pending-reply/steps.jsx +70 -21
  25. package/dist/cases/agent-pending-reply.md +74 -27
  26. package/dist/cases/agent-permissions/levels.d.ts +3 -0
  27. package/dist/cases/agent-permissions/levels.jsx +51 -0
  28. package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
  29. package/dist/cases/agent-permissions/per-tool.jsx +180 -0
  30. package/dist/cases/agent-permissions.md +319 -0
  31. package/dist/cases/agent-plan-proposal/changes.jsx +18 -11
  32. package/dist/cases/agent-plan-proposal/steps.jsx +11 -4
  33. package/dist/cases/agent-plan-proposal.md +36 -21
  34. package/dist/cases/agent-question.md +2 -0
  35. package/dist/cases/agent-refuses-clearly.md +2 -0
  36. package/dist/cases/agent-run-failure/limit-reached.d.ts +1 -0
  37. package/dist/cases/agent-run-failure/limit-reached.jsx +172 -0
  38. package/dist/cases/agent-run-failure/step-failed.d.ts +3 -0
  39. package/dist/cases/agent-run-failure/step-failed.jsx +187 -0
  40. package/dist/cases/agent-run-failure.md +500 -0
  41. package/dist/cases/agent-says-what-it-is.md +2 -0
  42. package/dist/cases/agent-says-where-it-stopped.md +27 -0
  43. package/dist/cases/agent-settings.md +2 -0
  44. package/dist/cases/agent-shows-progress.md +2 -0
  45. package/dist/cases/agent-shows-sources.md +2 -0
  46. package/dist/cases/api-keys.md +2 -0
  47. package/dist/cases/app-shell.md +2 -0
  48. package/dist/cases/artifact-card.md +2 -0
  49. package/dist/cases/ask-page.md +2 -0
  50. package/dist/cases/auth-gate-loading.md +2 -0
  51. package/dist/cases/billing-page.md +2 -0
  52. package/dist/cases/blog-index.md +2 -0
  53. package/dist/cases/breadcrumb.md +2 -0
  54. package/dist/cases/breakdown-list.md +2 -0
  55. package/dist/cases/bulk-actions/list.d.ts +1 -0
  56. package/dist/cases/bulk-actions/list.jsx +206 -0
  57. package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
  58. package/dist/cases/bulk-actions/paged-table.jsx +243 -0
  59. package/dist/cases/bulk-actions.md +553 -0
  60. package/dist/cases/changelog.md +2 -0
  61. package/dist/cases/chart.md +2 -0
  62. package/dist/cases/check-your-email.md +2 -0
  63. package/dist/cases/code-sample.md +2 -0
  64. package/dist/cases/collapsible-search.md +2 -0
  65. package/dist/cases/comment-thread.md +2 -0
  66. package/dist/cases/comparison-page/table.d.ts +1 -0
  67. package/dist/cases/comparison-page/table.jsx +97 -0
  68. package/dist/cases/comparison-page.md +156 -0
  69. package/dist/cases/composer-limit.md +2 -0
  70. package/dist/cases/confirm-destructive-action.md +2 -0
  71. package/dist/cases/confirm-dialogs.md +2 -0
  72. package/dist/cases/connection-status/card.d.ts +1 -0
  73. package/dist/cases/connection-status/card.jsx +97 -0
  74. package/dist/cases/connection-status/row.d.ts +1 -0
  75. package/dist/cases/connection-status/row.jsx +120 -0
  76. package/dist/cases/connection-status.md +330 -0
  77. package/dist/cases/contact-page.md +2 -0
  78. package/dist/cases/conversation-starters.md +2 -0
  79. package/dist/cases/cookie-choice.md +2 -0
  80. package/dist/cases/create-modal.md +2 -0
  81. package/dist/cases/danger-zone.md +2 -0
  82. package/dist/cases/dashboard.md +2 -0
  83. package/dist/cases/data-table-page.md +2 -0
  84. package/dist/cases/date-field.md +2 -0
  85. package/dist/cases/device-login.md +2 -0
  86. package/dist/cases/docs-component-page.md +2 -0
  87. package/dist/cases/email-confirmed.md +2 -0
  88. package/dist/cases/empty-list.md +2 -0
  89. package/dist/cases/empty-lists.md +2 -0
  90. package/dist/cases/empty-not-set-up.md +2 -0
  91. package/dist/cases/empty-search.md +2 -0
  92. package/dist/cases/error-page.md +2 -0
  93. package/dist/cases/faq.md +2 -0
  94. package/dist/cases/feature-grid.md +2 -0
  95. package/dist/cases/feedback-form.md +2 -0
  96. package/dist/cases/file-upload.md +2 -0
  97. package/dist/cases/filter-menu.md +2 -0
  98. package/dist/cases/forgot-password.md +2 -0
  99. package/dist/cases/form-errors.md +2 -0
  100. package/dist/cases/image-viewer.md +2 -0
  101. package/dist/cases/import-checklist.md +2 -0
  102. package/dist/cases/inline-form-feedback.md +2 -0
  103. package/dist/cases/integrations-list/nested.jsx +1 -1
  104. package/dist/cases/integrations-list/rows.jsx +1 -1
  105. package/dist/cases/integrations-list.md +6 -4
  106. package/dist/cases/invite-member.md +2 -0
  107. package/dist/cases/invoice-list.md +2 -0
  108. package/dist/cases/landing-hero.md +2 -0
  109. package/dist/cases/leaderboard.md +2 -0
  110. package/dist/cases/legal-page.md +2 -0
  111. package/dist/cases/load-failure.md +2 -0
  112. package/dist/cases/log-out-confirm.md +2 -0
  113. package/dist/cases/login-page.md +2 -0
  114. package/dist/cases/long-form-page.md +2 -0
  115. package/dist/cases/master-detail.md +2 -0
  116. package/dist/cases/members-list.md +2 -0
  117. package/dist/cases/mention-list.md +2 -0
  118. package/dist/cases/message-actions.md +2 -0
  119. package/dist/cases/message-attachments.md +2 -0
  120. package/dist/cases/message-composer/with-tools.jsx +17 -7
  121. package/dist/cases/message-composer.md +28 -11
  122. package/dist/cases/message-edit.md +2 -0
  123. package/dist/cases/message-reactions.md +2 -0
  124. package/dist/cases/message-row.md +2 -0
  125. package/dist/cases/message-send-failure/needs-a-person.d.ts +1 -0
  126. package/dist/cases/message-send-failure/needs-a-person.jsx +116 -0
  127. package/dist/cases/message-send-failure/retrying.d.ts +1 -0
  128. package/dist/cases/message-send-failure/retrying.jsx +116 -0
  129. package/dist/cases/message-send-failure.md +308 -0
  130. package/dist/cases/mobile-menu.md +2 -0
  131. package/dist/cases/newsletter-signup.md +2 -0
  132. package/dist/cases/no-access/page.d.ts +1 -0
  133. package/dist/cases/no-access/page.jsx +37 -0
  134. package/dist/cases/no-access/read-only.d.ts +1 -0
  135. package/dist/cases/no-access/read-only.jsx +33 -0
  136. package/dist/cases/no-access.md +147 -0
  137. package/dist/cases/not-found-page.md +2 -0
  138. package/dist/cases/notification-menu.md +2 -0
  139. package/dist/cases/number-format.md +2 -0
  140. package/dist/cases/oauth-consent.md +2 -0
  141. package/dist/cases/on-off-settings.md +2 -0
  142. package/dist/cases/on-this-page.md +2 -0
  143. package/dist/cases/onboarding.md +2 -0
  144. package/dist/cases/one-main-action.md +2 -0
  145. package/dist/cases/overflow-menu.md +2 -0
  146. package/dist/cases/page-end.md +2 -0
  147. package/dist/cases/page-header.md +2 -0
  148. package/dist/cases/paged-card.md +2 -0
  149. package/dist/cases/password-gate.md +2 -0
  150. package/dist/cases/payment-method.md +2 -0
  151. package/dist/cases/people-row.md +2 -0
  152. package/dist/cases/phone-navigation.md +2 -0
  153. package/dist/cases/plan-change-confirm.md +2 -0
  154. package/dist/cases/plan-comparison.md +3 -1
  155. package/dist/cases/plan-picker.md +4 -1
  156. package/dist/cases/plan-sign-off.md +2 -0
  157. package/dist/cases/pricing-section.md +5 -1
  158. package/dist/cases/product-cards.md +2 -0
  159. package/dist/cases/product-demo/scripted.d.ts +1 -0
  160. package/dist/cases/product-demo/scripted.jsx +99 -0
  161. package/dist/cases/product-demo/still.d.ts +1 -0
  162. package/dist/cases/product-demo/still.jsx +20 -0
  163. package/dist/cases/product-demo.md +226 -0
  164. package/dist/cases/profile-form.md +2 -0
  165. package/dist/cases/quick-switcher.md +2 -0
  166. package/dist/cases/range-switch.md +2 -0
  167. package/dist/cases/rename.md +2 -0
  168. package/dist/cases/reply-feedback.md +2 -0
  169. package/dist/cases/reply-sources.md +2 -0
  170. package/dist/cases/route-loading.md +2 -0
  171. package/dist/cases/scope-picker.md +2 -0
  172. package/dist/cases/section-index.md +2 -0
  173. package/dist/cases/session-expired/in-place.d.ts +1 -0
  174. package/dist/cases/session-expired/in-place.jsx +63 -0
  175. package/dist/cases/session-expired/redirect.d.ts +1 -0
  176. package/dist/cases/session-expired/redirect.jsx +62 -0
  177. package/dist/cases/session-expired.md +204 -0
  178. package/dist/cases/set-new-password.md +2 -0
  179. package/dist/cases/settings-page.md +2 -0
  180. package/dist/cases/settings-save.md +2 -0
  181. package/dist/cases/side-pane.md +2 -0
  182. package/dist/cases/sidebar-nav.md +2 -0
  183. package/dist/cases/sign-up-page.md +3 -0
  184. package/dist/cases/signup-from-site/plain.d.ts +1 -0
  185. package/dist/cases/signup-from-site/plain.jsx +125 -0
  186. package/dist/cases/signup-from-site/with-plan.d.ts +4 -0
  187. package/dist/cases/signup-from-site/with-plan.jsx +151 -0
  188. package/dist/cases/signup-from-site.md +351 -0
  189. package/dist/cases/site-footer.md +2 -0
  190. package/dist/cases/site-header/links.d.ts +3 -1
  191. package/dist/cases/site-header/links.jsx +6 -2
  192. package/dist/cases/site-header.md +11 -3
  193. package/dist/cases/site-matches-app.md +32 -0
  194. package/dist/cases/site-search.md +2 -0
  195. package/dist/cases/slash-command-list.md +2 -0
  196. package/dist/cases/stat-row.md +2 -0
  197. package/dist/cases/status-label.md +3 -1
  198. package/dist/cases/success-feedback.md +2 -0
  199. package/dist/cases/tabbed-panels.md +2 -0
  200. package/dist/cases/tag-filter.md +2 -0
  201. package/dist/cases/task-header.md +2 -0
  202. package/dist/cases/theme-switcher.md +2 -0
  203. package/dist/cases/type-to-confirm.md +2 -0
  204. package/dist/cases/typing-and-status.md +2 -0
  205. package/dist/cases/unsaved-changes-guard.md +2 -0
  206. package/dist/cases/upgrade-prompt.md +2 -0
  207. package/dist/cases/usage-meters.md +2 -0
  208. package/dist/cases.json +1492 -39
  209. package/dist/components/checkBox.d.ts +7 -2
  210. package/dist/components/checkBox.jsx +39 -14
  211. package/dist/components/diff.d.ts +32 -0
  212. package/dist/components/diff.jsx +42 -0
  213. package/dist/components/segmentedControl.d.ts +3 -1
  214. package/dist/components/segmentedControl.jsx +8 -6
  215. package/dist/components/slidingIndicator.d.ts +5 -2
  216. package/dist/components/slidingIndicator.jsx +9 -3
  217. package/dist/components/tableContainer.d.ts +1 -1
  218. package/dist/components/tableContainer.jsx +2 -2
  219. package/dist/components/timeStamp.d.ts +3 -1
  220. package/dist/components/timeStamp.jsx +4 -2
  221. package/dist/components/useReducedMotion.d.ts +6 -0
  222. package/dist/components/useReducedMotion.js +19 -0
  223. package/dist/index.d.ts +2 -0
  224. package/dist/index.js +2 -0
  225. package/dist/internal/diff.d.ts +17 -0
  226. package/dist/internal/diff.js +44 -0
  227. package/dist/native-mapping.json +9 -2
  228. package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
  229. package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
  230. package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
  231. package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
  232. package/dist/stories/Cases.generated.stories.d.ts +24 -0
  233. package/dist/stories/Cases.generated.stories.jsx +48 -0
  234. package/dist/stories/Checkbox.stories.d.ts +3 -0
  235. package/dist/stories/Checkbox.stories.jsx +38 -0
  236. package/dist/stories/Diff.stories.d.ts +10 -0
  237. package/dist/stories/Diff.stories.jsx +45 -0
  238. package/dist/stories/SegmentedControl.stories.d.ts +1 -0
  239. package/dist/stories/SegmentedControl.stories.jsx +6 -0
  240. package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
  241. package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
  242. package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
  243. package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
  244. package/dist/stories/Table.stories.d.ts +1 -0
  245. package/dist/stories/Table.stories.jsx +25 -0
  246. package/dist/stories/TimeStamp.stories.d.ts +1 -0
  247. package/dist/stories/TimeStamp.stories.jsx +13 -0
  248. package/package.json +5 -1
@@ -0,0 +1,63 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import TitleBar from '../../components/titleBar';
4
+ import Paragraph from '../../components/paragraph';
5
+ import TextField from '../../components/textField';
6
+ import Button from '../../components/button';
7
+ import Modal from '../../components/modal';
8
+ import { Center, Cluster, Stack } from '../../components/layout';
9
+ // A real app reads this from the session that ended.
10
+ var email = 'dana@acme.example';
11
+ export default function SessionExpiredInPlace() {
12
+ // Dana was typing a note when her login ended. The note stays on the page behind the Modal.
13
+ var _a = useState('Thanks for the order. The second box ships on Nov 20, 2026, and the invoice covers both.'), note = _a[0], setNote = _a[1];
14
+ // Opens on the Modal, as if the login just ended.
15
+ var _b = useState(true), loggedOut = _b[0], setLoggedOut = _b[1];
16
+ var _c = useState(''), password = _c[0], setPassword = _c[1];
17
+ var _d = useState(''), passwordError = _d[0], setPasswordError = _d[1];
18
+ var _e = useState(false), loading = _e[0], setLoading = _e[1];
19
+ var timer = useRef();
20
+ // Stops the request if the example goes away before it ends.
21
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
22
+ function logIn() {
23
+ if (loading)
24
+ return;
25
+ if (!password) {
26
+ setPasswordError('Enter your password.');
27
+ return;
28
+ }
29
+ setPasswordError('');
30
+ setLoading(true);
31
+ // Stands in for the request to the server.
32
+ timer.current = setTimeout(function () {
33
+ setLoading(false);
34
+ setPassword('');
35
+ // The Modal gives focus back to the field the person was typing in.
36
+ setLoggedOut(false);
37
+ }, 1200);
38
+ }
39
+ return (<Center width="page">
40
+ <Stack gap="large">
41
+ <TitleBar title="INV-1291"/>
42
+ <Stack gap="medium">
43
+ {/* The field had focus when the login ended. A real app does not move it. */}
44
+ <TextField id="session-expired-note" label="Note to the customer" multiline maxRows={6} autoFocus value={note} onChange={function (e) { return setNote(e.target.value); }}/>
45
+ <Cluster>
46
+ <Button size="medium" type="primary" state="enabled" label="Save Note" onClickButton={function () { return console.info('Save the note'); }}/>
47
+ </Cluster>
48
+ </Stack>
49
+ </Stack>
50
+ {/* The page cannot save until the person logs in, so Escape and a click outside do not close it. */}
51
+ <Modal isOpen={loggedOut} size="small" title="Log In Again" initialFocus="body" onClose={function () { }} actions={<Button size="small" type="primary" state="enabled" label="Log In" loading={loading} onClickButton={logIn}/>}>
52
+ <Paragraph measure="none">{"Log in as ".concat(email, " to keep working. Your note stays on this page.")}</Paragraph>
53
+ <TextField id="session-expired-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }} onKeyDown={function (e) {
54
+ if (e.key === 'Enter') {
55
+ e.preventDefault();
56
+ logIn();
57
+ }
58
+ }}/>
59
+ {/* A new tab, so the note stays on this page. */}
60
+ <Button size="small" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" href="/forgot-password" openInNewTab/>
61
+ </Modal>
62
+ </Center>);
63
+ }
@@ -0,0 +1 @@
1
+ export default function SessionExpiredRedirect(): import("react").JSX.Element;
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Image from '../../components/image';
4
+ import Heading from '../../components/heading';
5
+ import Form from '../../components/form';
6
+ import Alert from '../../components/alert';
7
+ import TextField from '../../components/textField';
8
+ import Button from '../../components/button';
9
+ import Line from '../../components/line';
10
+ import BrandIcon from '../../components/brandIcon';
11
+ import { Center } from '../../components/layout';
12
+ // The product's mark. A real app passes its own file.
13
+ var productMark = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
14
+ // A real app passes the router from its framework, such as Next's useRouter().
15
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
16
+ // The app sent the person here from '/invoices' with '/login?next=%2Finvoices'. A real app reads it from the address,
17
+ // and goes back only to a page of its own.
18
+ var next = { path: '/invoices', name: 'Invoices' };
19
+ export default function SessionExpiredRedirect() {
20
+ // The email the person used last, so they only type the password.
21
+ var _a = useState('dana@acme.example'), email = _a[0], setEmail = _a[1];
22
+ var _b = useState(''), password = _b[0], setPassword = _b[1];
23
+ var _c = useState(''), emailError = _c[0], setEmailError = _c[1];
24
+ var _d = useState(''), passwordError = _d[0], setPasswordError = _d[1];
25
+ var _e = useState(false), loading = _e[0], setLoading = _e[1];
26
+ var timer = useRef();
27
+ // Stops the request if the example goes away before it ends.
28
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
29
+ function handleSubmit() {
30
+ if (loading)
31
+ return;
32
+ setEmailError('');
33
+ setPasswordError('');
34
+ if (!email.trim()) {
35
+ setEmailError('Enter your email.');
36
+ return;
37
+ }
38
+ if (!password) {
39
+ setPasswordError('Enter your password.');
40
+ return;
41
+ }
42
+ setLoading(true);
43
+ // Stands in for the request to the server. After it, the person goes back to the page they were on.
44
+ timer.current = setTimeout(function () {
45
+ setLoading(false);
46
+ router.push(next.path);
47
+ }, 1200);
48
+ }
49
+ return (<Center fill>
50
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
51
+ <Heading level={1} size="h5">Log in to Acme</Heading>
52
+ <Form aria-label="Log in" onSubmit={handleSubmit}>
53
+ <Alert type="info" variant="inline" message={"You were logged out. Log in to go back to ".concat(next.name, ".")} autoDismiss={false}/>
54
+ <TextField id="session-expired-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
55
+ <TextField id="session-expired-login-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
56
+ <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading}/>
57
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?"/>
58
+ </Form>
59
+ <Line label="or"/>
60
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
61
+ </Center>);
62
+ }
@@ -0,0 +1,204 @@
1
+ # Session that ended
2
+
3
+ A person is using the app when their login ends, such as after a long break or a password change somewhere else.
4
+
5
+ For: an app
6
+
7
+ ## Do
8
+
9
+ - Follow the case 'Login page' for the fields, the errors and the loading Button.
10
+ - Open a small `Modal` titled 'Log In Again' over the page when the person has unsaved work, so the work stays where it is.
11
+ - Say whose login ended and that the work is safe: 'Log in as dana@acme.example to keep working. Your note stays on this page.'
12
+ - Ask only for the password in the Modal, or show the provider's Button, such as 'Continue with Google', for a person who logs in that way.
13
+ - Show 'Log In' as `loading` while it runs, and keep its label.
14
+ - Return focus to where it was when the Modal closes, such as the field with the typed text.
15
+ - Open the login page with an info `Alert` when nothing would be lost: 'You were logged out. Log in to go back to Invoices.'
16
+ - Keep the page the person was on in the address, and go back to it after they log in.
17
+ - Fill in the email the person used, so they only type the password.
18
+
19
+ ## Don't
20
+
21
+ - Do not send the person to the login page without a word, and drop what they typed.
22
+ - Do not close the Modal on Escape or a click outside. The page cannot save until the person logs in.
23
+ - Do not land on the home page after the login when the person came from another page.
24
+ - Do not say 'Session expired' or 'Token invalid'. Say they were logged out and what to do.
25
+
26
+ ## Option: Log in over the page
27
+
28
+ Use when: The person has unsaved work on the page, such as text they typed.
29
+
30
+ Uses: `Button`, `Center`, `Cluster`, `Modal`, `Paragraph`, `Stack`, `TextField`, `TitleBar`
31
+
32
+ ```tsx
33
+ 'use client';
34
+ import { useEffect, useRef, useState } from 'react';
35
+ import TitleBar from 'oneslash-design-system/components/titleBar';
36
+ import Paragraph from 'oneslash-design-system/components/paragraph';
37
+ import TextField from 'oneslash-design-system/components/textField';
38
+ import Button from 'oneslash-design-system/components/button';
39
+ import Modal from 'oneslash-design-system/components/modal';
40
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
41
+
42
+ // A real app reads this from the session that ended.
43
+ const email = 'dana@acme.example';
44
+
45
+ export default function SessionExpiredInPlace() {
46
+ // Dana was typing a note when her login ended. The note stays on the page behind the Modal.
47
+ const [note, setNote] = useState('Thanks for the order. The second box ships on Nov 20, 2026, and the invoice covers both.');
48
+ // Opens on the Modal, as if the login just ended.
49
+ const [loggedOut, setLoggedOut] = useState(true);
50
+ const [password, setPassword] = useState('');
51
+ const [passwordError, setPasswordError] = useState('');
52
+ const [loading, setLoading] = useState(false);
53
+ const timer = useRef<ReturnType<typeof setTimeout>>();
54
+
55
+ // Stops the request if the example goes away before it ends.
56
+ useEffect(() => () => clearTimeout(timer.current), []);
57
+
58
+ function logIn() {
59
+ if (loading) return;
60
+ if (!password) {
61
+ setPasswordError('Enter your password.');
62
+ return;
63
+ }
64
+ setPasswordError('');
65
+ setLoading(true);
66
+ // Stands in for the request to the server.
67
+ timer.current = setTimeout(() => {
68
+ setLoading(false);
69
+ setPassword('');
70
+ // The Modal gives focus back to the field the person was typing in.
71
+ setLoggedOut(false);
72
+ }, 1200);
73
+ }
74
+
75
+ return (
76
+ <Center width="page">
77
+ <Stack gap="large">
78
+ <TitleBar title="INV-1291" />
79
+ <Stack gap="medium">
80
+ {/* The field had focus when the login ended. A real app does not move it. */}
81
+ <TextField id="session-expired-note" label="Note to the customer" multiline maxRows={6} autoFocus value={note} onChange={(e) => setNote(e.target.value)} />
82
+ <Cluster>
83
+ <Button size="medium" type="primary" state="enabled" label="Save Note" onClickButton={() => console.info('Save the note')} />
84
+ </Cluster>
85
+ </Stack>
86
+ </Stack>
87
+ {/* The page cannot save until the person logs in, so Escape and a click outside do not close it. */}
88
+ <Modal
89
+ isOpen={loggedOut}
90
+ size="small"
91
+ title="Log In Again"
92
+ initialFocus="body"
93
+ onClose={() => {}}
94
+ actions={<Button size="small" type="primary" state="enabled" label="Log In" loading={loading} onClickButton={logIn} />}
95
+ >
96
+ <Paragraph measure="none">{`Log in as ${email} to keep working. Your note stays on this page.`}</Paragraph>
97
+ <TextField
98
+ id="session-expired-password"
99
+ label="Password"
100
+ type="password"
101
+ autoComplete="current-password"
102
+ value={password}
103
+ disabled={loading}
104
+ error={Boolean(passwordError)}
105
+ errorText={passwordError}
106
+ onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }}
107
+ onKeyDown={(e) => {
108
+ if (e.key === 'Enter') {
109
+ e.preventDefault();
110
+ logIn();
111
+ }
112
+ }}
113
+ />
114
+ {/* A new tab, so the note stays on this page. */}
115
+ <Button size="small" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" href="/forgot-password" openInNewTab />
116
+ </Modal>
117
+ </Center>
118
+ );
119
+ }
120
+ ```
121
+
122
+ ## Option: Log in, then go back
123
+
124
+ Use when: Nothing on the page would be lost, so the login page can take its place.
125
+
126
+ Uses: `Alert`, `BrandIcon`, `Button`, `Center`, `Form`, `Heading`, `Image`, `Line`, `TextField`
127
+
128
+ ```tsx
129
+ 'use client';
130
+ import { useEffect, useRef, useState } from 'react';
131
+ import Image from 'oneslash-design-system/components/image';
132
+ import Heading from 'oneslash-design-system/components/heading';
133
+ import Form from 'oneslash-design-system/components/form';
134
+ import Alert from 'oneslash-design-system/components/alert';
135
+ import TextField from 'oneslash-design-system/components/textField';
136
+ import Button from 'oneslash-design-system/components/button';
137
+ import Line from 'oneslash-design-system/components/line';
138
+ import BrandIcon from 'oneslash-design-system/components/brandIcon';
139
+ import { Center } from 'oneslash-design-system/components/layout';
140
+
141
+ // The product's mark. A real app passes its own file.
142
+ const productMark =
143
+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
144
+
145
+ // A real app passes the router from its framework, such as Next's useRouter().
146
+ const router = { push: (url: string) => console.info(`Go to ${url}`) };
147
+
148
+ // The app sent the person here from '/invoices' with '/login?next=%2Finvoices'. A real app reads it from the address,
149
+ // and goes back only to a page of its own.
150
+ const next = { path: '/invoices', name: 'Invoices' };
151
+
152
+ export default function SessionExpiredRedirect() {
153
+ // The email the person used last, so they only type the password.
154
+ const [email, setEmail] = useState('dana@acme.example');
155
+ const [password, setPassword] = useState('');
156
+ const [emailError, setEmailError] = useState('');
157
+ const [passwordError, setPasswordError] = useState('');
158
+ const [loading, setLoading] = useState(false);
159
+ const timer = useRef<ReturnType<typeof setTimeout>>();
160
+
161
+ // Stops the request if the example goes away before it ends.
162
+ useEffect(() => () => clearTimeout(timer.current), []);
163
+
164
+ function handleSubmit() {
165
+ if (loading) return;
166
+ setEmailError('');
167
+ setPasswordError('');
168
+ if (!email.trim()) {
169
+ setEmailError('Enter your email.');
170
+ return;
171
+ }
172
+ if (!password) {
173
+ setPasswordError('Enter your password.');
174
+ return;
175
+ }
176
+ setLoading(true);
177
+ // Stands in for the request to the server. After it, the person goes back to the page they were on.
178
+ timer.current = setTimeout(() => {
179
+ setLoading(false);
180
+ router.push(next.path);
181
+ }, 1200);
182
+ }
183
+
184
+ return (
185
+ <Center fill>
186
+ <Image src={productMark} alt="Acme" width={40} height={40} />
187
+ <Heading level={1} size="h5">Log in to Acme</Heading>
188
+ <Form aria-label="Log in" onSubmit={handleSubmit}>
189
+ <Alert type="info" variant="inline" message={`You were logged out. Log in to go back to ${next.name}.`} autoDismiss={false} />
190
+ <TextField id="session-expired-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
191
+ <TextField id="session-expired-login-password" label="Password" type="password" autoComplete="current-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} onChange={(e) => { setPassword(e.target.value); setPasswordError(''); }} />
192
+ <Button size="medium" type="primary" state="enabled" label="Log In" htmlType="submit" loading={loading} />
193
+ <Button size="medium" type="textOnly" state={loading ? 'disabled' : 'enabled'} label="Forgot Password?" />
194
+ </Form>
195
+ <Line label="or" />
196
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google" />} />
197
+ </Center>
198
+ );
199
+ }
200
+ ```
201
+
202
+ ## Native
203
+
204
+ On Apple show the login as a sheet over the screen with the password field, so the screen behind keeps its state; use `ASWebAuthenticationSession` for a provider. On Android show a dialog with the password field, and keep the screen's state in its `ViewModel`.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A person opened the link to reset their password and now chooses a new one.
4
4
 
5
+ For: an app
6
+
5
7
  ## Do
6
8
 
7
9
  - Name the page 'Set new password' in a `Heading` with `level={1}`, and name the account it is for.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A person opens the settings of the product and looks for one area, such as Profile or Billing.
4
4
 
5
+ For: an app
6
+
5
7
  ## Do
6
8
 
7
9
  - Title the page 'Settings' with a level 1 `Heading`.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A person changes a setting.
4
4
 
5
+ For: a marketing site, an app
6
+
5
7
  ## Answer
6
8
 
7
9
  A control that stands alone saves as soon as it changes: a `Switch`, a choice in a `RadioGroup` or a `Select`, or a picture the person chooses. It shows nothing on success, because the control already shows the new value. While the request runs it is busy: a `Switch` takes `busy`, and a `RadioGroup` or `Select` is disabled. If the save fails, the control goes back to its old value and says why next to itself: in a Switch's `error`, in the error line of its `FormField`, or in an inline error `Alert` under a control with no visible label, such as a role in a row. A group of fields that belong together, such as a name, a profile, instructions or a budget, has one Save Button for the whole group. The Button is `loading` while it saves, keeps its label, then reads 'Saved' for 2 seconds. It is disabled while nothing has changed. A group that fails to save follows the rule 'A form error shows next to the problem'. Leaving with unsaved changes follows the case 'Unsaved changes'. Never mix both in one group: a Switch beside a Save Button leaves the person unsure which one is saved. Never show a toast for a setting saved in place. The one exception is a setting chosen from a menu: the menu closes, so a failed save shows in a toast and the control goes back to its old value. A person who cannot change a setting sees it read-only, with one line that says who can change it.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A person opens more about the page, such as its members, its history or a document, without leaving the page.
4
4
 
5
+ For: an app
6
+
5
7
  ## Do
6
8
 
7
9
  - Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail': on a phone a pane takes the whole content area.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A person looks down the sidebar for a place, and for what has something new in it.
4
4
 
5
+ For: an app
6
+
5
7
  ## Do
6
8
 
7
9
  - Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A person who has no account yet opens the product and wants one.
4
4
 
5
+ For: an app
6
+
5
7
  ## Do
6
8
 
7
9
  - Ask only for what the account needs: name, email and password.
@@ -15,6 +17,7 @@ A person who has no account yet opens the product and wants one.
15
17
  - Keep the submit Button loading until the check-your-email view shows.
16
18
  - Name the provider on its button: 'Continue with Google'.
17
19
  - Link or tab to login for people who already have an account.
20
+ - Follow the case 'Sign-up from the site' when the visitor chose a plan first.
18
21
 
19
22
  ## Don't
20
23
 
@@ -0,0 +1 @@
1
+ export default function SignupFromSitePlain(): import("react").JSX.Element;
@@ -0,0 +1,125 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { Mail } from 'lucide-react';
4
+ import Image from '../../components/image';
5
+ import TabsContainer from '../../components/tabsContainer';
6
+ import Tab from '../../components/tab';
7
+ import Form from '../../components/form';
8
+ import Alert from '../../components/alert';
9
+ import TextField from '../../components/textField';
10
+ import Paragraph from '../../components/paragraph';
11
+ import Heading from '../../components/heading';
12
+ import Icon from '../../components/icon';
13
+ import Button from '../../components/button';
14
+ import Line from '../../components/line';
15
+ import BrandIcon from '../../components/brandIcon';
16
+ import { Center, Stack } from '../../components/layout';
17
+ // The product's mark. A real app passes its own file.
18
+ var productMark = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
19
+ // A real app passes the router from its framework, such as Next's useRouter().
20
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
21
+ // A small check: some text, an @, then some text.
22
+ function looksLikeEmail(value) {
23
+ return /^[^@\s]+@[^@\s]+$/.test(value);
24
+ }
25
+ // The visitor pressed 'Sign Up' on the site, which links to '/sign-up', so the page opens on the Sign Up tab.
26
+ export default function SignupFromSitePlain() {
27
+ var _a = useState('Dana Lee'), name = _a[0], setName = _a[1];
28
+ var _b = useState('dana@acme.example'), email = _b[0], setEmail = _b[1];
29
+ var _c = useState(''), password = _c[0], setPassword = _c[1];
30
+ var _d = useState(''), error = _d[0], setError = _d[1];
31
+ var _e = useState(''), nameError = _e[0], setNameError = _e[1];
32
+ var _f = useState(''), emailError = _f[0], setEmailError = _f[1];
33
+ var _g = useState(''), passwordError = _g[0], setPasswordError = _g[1];
34
+ var _h = useState(false), loading = _h[0], setLoading = _h[1];
35
+ // The address the link went to. Set once the account request ends, which shows the check-your-email view.
36
+ var _j = useState(''), sentTo = _j[0], setSentTo = _j[1];
37
+ var _k = useState(false), resending = _k[0], setResending = _k[1];
38
+ var _l = useState(false), resent = _l[0], setResent = _l[1];
39
+ var timer = useRef();
40
+ // Stops the request if the example goes away before it ends.
41
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
42
+ // 'Sent' shows for 2 seconds, then the Button reads 'Send Again'.
43
+ useEffect(function () {
44
+ if (!resent)
45
+ return;
46
+ var timer = setTimeout(function () { return setResent(false); }, 2000);
47
+ return function () { return clearTimeout(timer); };
48
+ }, [resent]);
49
+ function handleSubmit() {
50
+ if (loading)
51
+ return;
52
+ setError('');
53
+ setNameError('');
54
+ setEmailError('');
55
+ setPasswordError('');
56
+ if (!name.trim()) {
57
+ setNameError('Enter your name.');
58
+ return;
59
+ }
60
+ if (!email.trim()) {
61
+ setEmailError('Enter your email.');
62
+ return;
63
+ }
64
+ if (!looksLikeEmail(email.trim())) {
65
+ setEmailError('Enter an email address, like name@example.com.');
66
+ return;
67
+ }
68
+ if (password.length < 8) {
69
+ setPasswordError('Use at least 8 characters.');
70
+ return;
71
+ }
72
+ setLoading(true);
73
+ var address = email.trim();
74
+ // Stands in for the request to the server.
75
+ // A failed request calls setError with one sentence instead, such as 'Your account was not created. Try again.'
76
+ timer.current = setTimeout(function () {
77
+ // Every address goes on to the same view, so the page never says whether it has an account.
78
+ // The Button stays loading until the view changes.
79
+ setLoading(false);
80
+ setSentTo(address);
81
+ }, 1200);
82
+ }
83
+ function handleSendAgain() {
84
+ // One click sends one email: clicks while it sends or reads 'Sent' do nothing.
85
+ if (resending || resent)
86
+ return;
87
+ setResending(true);
88
+ // Stands in for the request to the server.
89
+ // A failed request shows an inline error Alert above the Buttons, such as 'The email was not sent. Try again.'
90
+ timer.current = setTimeout(function () {
91
+ setResending(false);
92
+ setResent(true);
93
+ }, 1200);
94
+ }
95
+ // The same view as the 'Check your email' case, in place of the form.
96
+ if (sentTo) {
97
+ return (<Center fill>
98
+ <Icon icon={Mail} size="large" color="secondary"/>
99
+ <Stack gap="medium">
100
+ <Heading level={1} size="h5">Check your email</Heading>
101
+ <Paragraph tone="secondary" measure="none">We sent a link to {sentTo}. Open it to continue.</Paragraph>
102
+ </Stack>
103
+ <Stack gap="large">
104
+ <Button size="medium" type="secondary" state="enabled" label={resent ? 'Sent' : 'Send Again'} loading={resending} onClickButton={handleSendAgain}/>
105
+ <Button size="medium" type="textOnly" state="enabled" label="Back to Login" onClickButton={function () { return router.push('/login'); }}/>
106
+ </Stack>
107
+ </Center>);
108
+ }
109
+ return (<Center fill>
110
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
111
+ <TabsContainer fill>
112
+ <Tab label="Log In" isSelected={false} href="/login" router={router} onClickTab={function () { }}/>
113
+ <Tab label="Sign Up" isSelected onClickTab={function () { }}/>
114
+ </TabsContainer>
115
+ <Form aria-label="Sign up" onSubmit={handleSubmit}>
116
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
117
+ <TextField id="signup-from-site-name" label="Name" autoComplete="name" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} onChange={function (e) { setName(e.target.value); setNameError(''); }}/>
118
+ <TextField id="signup-from-site-email" label="Email" type="email" autoComplete="username" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
119
+ <TextField id="signup-from-site-password" label="Password" type="password" autoComplete="new-password" value={password} disabled={loading} error={Boolean(passwordError)} errorText={passwordError} helperText="Use at least 8 characters." onChange={function (e) { setPassword(e.target.value); setPasswordError(''); }}/>
120
+ <Button size="medium" type="primary" state="enabled" label="Sign Up" htmlType="submit" loading={loading}/>
121
+ </Form>
122
+ <Line label="or"/>
123
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
124
+ </Center>);
125
+ }
@@ -0,0 +1,4 @@
1
+ export default function SignupFromSiteWithPlan({ plan, failOnce }?: {
2
+ plan?: string;
3
+ failOnce?: boolean;
4
+ }): import("react").JSX.Element;