oneslash-design-system 2.28.0 → 2.29.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 (237) 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 +49 -0
  28. package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
  29. package/dist/cases/agent-permissions/per-tool.jsx +178 -0
  30. package/dist/cases/agent-permissions.md +314 -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/list.jsx +30 -3
  47. package/dist/cases/api-keys.md +37 -3
  48. package/dist/cases/app-shell.md +2 -0
  49. package/dist/cases/artifact-card.md +2 -0
  50. package/dist/cases/ask-page.md +2 -0
  51. package/dist/cases/auth-gate-loading.md +2 -0
  52. package/dist/cases/billing-page.md +2 -0
  53. package/dist/cases/blog-index.md +2 -0
  54. package/dist/cases/breadcrumb.md +2 -0
  55. package/dist/cases/breakdown-list.md +2 -0
  56. package/dist/cases/bulk-actions/list.d.ts +1 -0
  57. package/dist/cases/bulk-actions/list.jsx +209 -0
  58. package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
  59. package/dist/cases/bulk-actions/paged-table.jsx +246 -0
  60. package/dist/cases/bulk-actions.md +559 -0
  61. package/dist/cases/changelog.md +2 -0
  62. package/dist/cases/chart.md +2 -0
  63. package/dist/cases/check-your-email.md +2 -0
  64. package/dist/cases/code-sample.md +2 -0
  65. package/dist/cases/collapsible-search.md +2 -0
  66. package/dist/cases/comment-thread.md +2 -0
  67. package/dist/cases/comparison-page/table.d.ts +1 -0
  68. package/dist/cases/comparison-page/table.jsx +97 -0
  69. package/dist/cases/comparison-page.md +156 -0
  70. package/dist/cases/composer-limit.md +2 -0
  71. package/dist/cases/confirm-destructive-action.md +2 -0
  72. package/dist/cases/confirm-dialogs.md +2 -0
  73. package/dist/cases/connection-status/card.d.ts +1 -0
  74. package/dist/cases/connection-status/card.jsx +97 -0
  75. package/dist/cases/connection-status/row.d.ts +1 -0
  76. package/dist/cases/connection-status/row.jsx +120 -0
  77. package/dist/cases/connection-status.md +330 -0
  78. package/dist/cases/contact-page.md +2 -0
  79. package/dist/cases/conversation-starters.md +2 -0
  80. package/dist/cases/cookie-choice.md +2 -0
  81. package/dist/cases/create-modal.md +2 -0
  82. package/dist/cases/danger-zone.md +2 -0
  83. package/dist/cases/dashboard.md +2 -0
  84. package/dist/cases/data-table-page.md +2 -0
  85. package/dist/cases/date-field.md +2 -0
  86. package/dist/cases/device-login.md +2 -0
  87. package/dist/cases/docs-component-page.md +2 -0
  88. package/dist/cases/email-confirmed.md +2 -0
  89. package/dist/cases/empty-list.md +2 -0
  90. package/dist/cases/empty-lists.md +2 -0
  91. package/dist/cases/empty-not-set-up.md +2 -0
  92. package/dist/cases/empty-search.md +2 -0
  93. package/dist/cases/error-page.md +2 -0
  94. package/dist/cases/faq.md +2 -0
  95. package/dist/cases/feature-grid.md +2 -0
  96. package/dist/cases/feedback-form.md +2 -0
  97. package/dist/cases/file-upload.md +2 -0
  98. package/dist/cases/filter-menu.md +2 -0
  99. package/dist/cases/forgot-password.md +2 -0
  100. package/dist/cases/form-errors.md +2 -0
  101. package/dist/cases/image-viewer.md +2 -0
  102. package/dist/cases/import-checklist.md +2 -0
  103. package/dist/cases/inline-form-feedback.md +2 -0
  104. package/dist/cases/integrations-list/nested.jsx +1 -1
  105. package/dist/cases/integrations-list/rows.jsx +1 -1
  106. package/dist/cases/integrations-list.md +6 -4
  107. package/dist/cases/invite-member.md +2 -0
  108. package/dist/cases/invoice-list.md +2 -0
  109. package/dist/cases/landing-hero.md +2 -0
  110. package/dist/cases/leaderboard.md +2 -0
  111. package/dist/cases/legal-page.md +2 -0
  112. package/dist/cases/load-failure.md +2 -0
  113. package/dist/cases/log-out-confirm.md +2 -0
  114. package/dist/cases/login-page.md +2 -0
  115. package/dist/cases/long-form-page.md +2 -0
  116. package/dist/cases/master-detail.md +2 -0
  117. package/dist/cases/members-list/rows.jsx +37 -6
  118. package/dist/cases/members-list/table.jsx +37 -6
  119. package/dist/cases/members-list.md +83 -12
  120. package/dist/cases/mention-list.md +2 -0
  121. package/dist/cases/message-actions.md +2 -0
  122. package/dist/cases/message-attachments.md +2 -0
  123. package/dist/cases/message-composer/with-tools.jsx +17 -7
  124. package/dist/cases/message-composer.md +28 -11
  125. package/dist/cases/message-edit.md +2 -0
  126. package/dist/cases/message-reactions.md +2 -0
  127. package/dist/cases/message-row.md +2 -0
  128. package/dist/cases/message-send-failure/needs-a-person.d.ts +1 -0
  129. package/dist/cases/message-send-failure/needs-a-person.jsx +116 -0
  130. package/dist/cases/message-send-failure/retrying.d.ts +1 -0
  131. package/dist/cases/message-send-failure/retrying.jsx +116 -0
  132. package/dist/cases/message-send-failure.md +308 -0
  133. package/dist/cases/mobile-menu.md +2 -0
  134. package/dist/cases/newsletter-signup.md +2 -0
  135. package/dist/cases/no-access/page.d.ts +1 -0
  136. package/dist/cases/no-access/page.jsx +37 -0
  137. package/dist/cases/no-access/read-only.d.ts +1 -0
  138. package/dist/cases/no-access/read-only.jsx +33 -0
  139. package/dist/cases/no-access.md +147 -0
  140. package/dist/cases/not-found-page.md +2 -0
  141. package/dist/cases/notification-menu.md +2 -0
  142. package/dist/cases/number-format.md +2 -0
  143. package/dist/cases/oauth-consent.md +2 -0
  144. package/dist/cases/on-off-settings.md +2 -0
  145. package/dist/cases/on-this-page.md +2 -0
  146. package/dist/cases/onboarding.md +2 -0
  147. package/dist/cases/one-main-action.md +2 -0
  148. package/dist/cases/overflow-menu.md +2 -0
  149. package/dist/cases/page-end.md +2 -0
  150. package/dist/cases/page-header.md +2 -0
  151. package/dist/cases/paged-card.md +2 -0
  152. package/dist/cases/password-gate.md +2 -0
  153. package/dist/cases/payment-method.md +2 -0
  154. package/dist/cases/people-row.md +2 -0
  155. package/dist/cases/phone-navigation.md +2 -0
  156. package/dist/cases/plan-change-confirm.md +2 -0
  157. package/dist/cases/plan-comparison.md +3 -1
  158. package/dist/cases/plan-picker.md +4 -1
  159. package/dist/cases/plan-sign-off.md +2 -0
  160. package/dist/cases/pricing-section.md +5 -1
  161. package/dist/cases/product-cards.md +2 -0
  162. package/dist/cases/product-demo/scripted.d.ts +3 -0
  163. package/dist/cases/product-demo/scripted.jsx +95 -0
  164. package/dist/cases/product-demo/still.d.ts +1 -0
  165. package/dist/cases/product-demo/still.jsx +20 -0
  166. package/dist/cases/product-demo.md +221 -0
  167. package/dist/cases/profile-form.md +2 -0
  168. package/dist/cases/quick-switcher.md +2 -0
  169. package/dist/cases/range-switch.md +2 -0
  170. package/dist/cases/rename.md +2 -0
  171. package/dist/cases/reply-feedback.md +2 -0
  172. package/dist/cases/reply-sources.md +2 -0
  173. package/dist/cases/route-loading.md +2 -0
  174. package/dist/cases/scope-picker.md +2 -0
  175. package/dist/cases/section-index.md +2 -0
  176. package/dist/cases/session-expired/in-place.d.ts +1 -0
  177. package/dist/cases/session-expired/in-place.jsx +63 -0
  178. package/dist/cases/session-expired/redirect.d.ts +1 -0
  179. package/dist/cases/session-expired/redirect.jsx +62 -0
  180. package/dist/cases/session-expired.md +204 -0
  181. package/dist/cases/set-new-password.md +2 -0
  182. package/dist/cases/settings-page.md +2 -0
  183. package/dist/cases/settings-save.md +2 -0
  184. package/dist/cases/side-pane.md +2 -0
  185. package/dist/cases/sidebar-nav.md +2 -0
  186. package/dist/cases/sign-up-page.md +3 -0
  187. package/dist/cases/signup-from-site/plain.d.ts +1 -0
  188. package/dist/cases/signup-from-site/plain.jsx +125 -0
  189. package/dist/cases/signup-from-site/with-plan.d.ts +4 -0
  190. package/dist/cases/signup-from-site/with-plan.jsx +151 -0
  191. package/dist/cases/signup-from-site.md +351 -0
  192. package/dist/cases/site-footer.md +2 -0
  193. package/dist/cases/site-header/links.d.ts +3 -1
  194. package/dist/cases/site-header/links.jsx +6 -2
  195. package/dist/cases/site-header.md +11 -3
  196. package/dist/cases/site-matches-app.md +32 -0
  197. package/dist/cases/site-search.md +2 -0
  198. package/dist/cases/slash-command-list.md +2 -0
  199. package/dist/cases/stat-row.md +2 -0
  200. package/dist/cases/status-label.md +3 -1
  201. package/dist/cases/success-feedback.md +2 -0
  202. package/dist/cases/tabbed-panels.md +2 -0
  203. package/dist/cases/tag-filter.md +2 -0
  204. package/dist/cases/task-header.md +2 -0
  205. package/dist/cases/theme-switcher.md +2 -0
  206. package/dist/cases/type-to-confirm.md +2 -0
  207. package/dist/cases/typing-and-status.md +2 -0
  208. package/dist/cases/unsaved-changes-guard.md +2 -0
  209. package/dist/cases/upgrade-prompt.md +2 -0
  210. package/dist/cases/usage-meters.md +2 -0
  211. package/dist/cases.json +1494 -42
  212. package/dist/components/checkBox.d.ts +5 -1
  213. package/dist/components/checkBox.jsx +23 -9
  214. package/dist/components/diff.d.ts +29 -0
  215. package/dist/components/diff.jsx +35 -0
  216. package/dist/index.d.ts +1 -0
  217. package/dist/index.js +1 -0
  218. package/dist/internal/diff.d.ts +17 -0
  219. package/dist/internal/diff.js +44 -0
  220. package/dist/native-mapping.json +9 -2
  221. package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
  222. package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
  223. package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
  224. package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
  225. package/dist/stories/Cases.generated.stories.d.ts +24 -0
  226. package/dist/stories/Cases.generated.stories.jsx +48 -0
  227. package/dist/stories/Checkbox.stories.d.ts +2 -0
  228. package/dist/stories/Checkbox.stories.jsx +18 -0
  229. package/dist/stories/Diff.stories.d.ts +9 -0
  230. package/dist/stories/Diff.stories.jsx +40 -0
  231. package/dist/stories/ProductDemo.probe.stories.d.ts +6 -0
  232. package/dist/stories/ProductDemo.probe.stories.jsx +12 -0
  233. package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
  234. package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
  235. package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
  236. package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
  237. package/package.json +1 -1
@@ -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;
@@ -0,0 +1,151 @@
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 Link from '../../components/link';
15
+ import Line from '../../components/line';
16
+ import BrandIcon from '../../components/brandIcon';
17
+ import { formatMoney } from '../../components/formatNumber';
18
+ import { Center, Stack } from '../../components/layout';
19
+ // The product's mark. A real app passes its own file.
20
+ 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";
21
+ // A real app passes the router from its framework, such as Next's useRouter().
22
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
23
+ // The paid plans, with the names and prices of the case 'Plan picker'. A real app reads them from the same place.
24
+ // Free needs no line: it is what the plain sign-up gives.
25
+ var paidPlans = {
26
+ pro: { name: 'Pro', price: 8 },
27
+ business: { name: 'Business', price: 16 },
28
+ };
29
+ var trialDays = 14;
30
+ // A small check: some text, an @, then some text.
31
+ function looksLikeEmail(value) {
32
+ return /^[^@\s]+@[^@\s]+$/.test(value);
33
+ }
34
+ // `plan` is read from the address, such as '/sign-up?plan=pro'. A plan the app does not know shows the plain sign-up.
35
+ // `failOnce` is for tests only: the first request fails, so the plan can be seen to stay.
36
+ export default function SignupFromSiteWithPlan(_a) {
37
+ var _b = _a === void 0 ? {} : _a, _c = _b.plan, plan = _c === void 0 ? 'pro' : _c, _d = _b.failOnce, failOnce = _d === void 0 ? false : _d;
38
+ var picked = Object.prototype.hasOwnProperty.call(paidPlans, plan) ? paidPlans[plan] : undefined;
39
+ var _e = useState('Dana Lee'), name = _e[0], setName = _e[1];
40
+ var _f = useState('dana@acme.example'), email = _f[0], setEmail = _f[1];
41
+ var _g = useState(''), password = _g[0], setPassword = _g[1];
42
+ var _h = useState(''), error = _h[0], setError = _h[1];
43
+ var _j = useState(''), nameError = _j[0], setNameError = _j[1];
44
+ var _k = useState(''), emailError = _k[0], setEmailError = _k[1];
45
+ var _l = useState(''), passwordError = _l[0], setPasswordError = _l[1];
46
+ var _m = useState(false), loading = _m[0], setLoading = _m[1];
47
+ // The address the link went to. Set once the account request ends, which shows the check-your-email view.
48
+ var _o = useState(''), sentTo = _o[0], setSentTo = _o[1];
49
+ var _p = useState(false), resending = _p[0], setResending = _p[1];
50
+ var _q = useState(false), resent = _q[0], setResent = _q[1];
51
+ var timer = useRef();
52
+ var failNext = useRef(failOnce);
53
+ // Stops the request if the example goes away before it ends.
54
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
55
+ // 'Sent' shows for 2 seconds, then the Button reads 'Send Again'.
56
+ useEffect(function () {
57
+ if (!resent)
58
+ return;
59
+ var timer = setTimeout(function () { return setResent(false); }, 2000);
60
+ return function () { return clearTimeout(timer); };
61
+ }, [resent]);
62
+ function handleSubmit() {
63
+ if (loading)
64
+ return;
65
+ setError('');
66
+ setNameError('');
67
+ setEmailError('');
68
+ setPasswordError('');
69
+ if (!name.trim()) {
70
+ setNameError('Enter your name.');
71
+ return;
72
+ }
73
+ if (!email.trim()) {
74
+ setEmailError('Enter your email.');
75
+ return;
76
+ }
77
+ if (!looksLikeEmail(email.trim())) {
78
+ setEmailError('Enter an email address, like name@example.com.');
79
+ return;
80
+ }
81
+ if (password.length < 8) {
82
+ setPasswordError('Use at least 8 characters.');
83
+ return;
84
+ }
85
+ setLoading(true);
86
+ var address = email.trim();
87
+ // Stands in for the request to the server. It sends the plan with the account, so the app starts the trial on it.
88
+ timer.current = setTimeout(function () {
89
+ setLoading(false);
90
+ if (failNext.current) {
91
+ failNext.current = false;
92
+ // The plan line, the plan and the fields stay as they were.
93
+ setError('Your account was not created. Try again.');
94
+ return;
95
+ }
96
+ // Every address goes on to the same view, so the page never says whether it has an account.
97
+ // The Button stays loading until the view changes.
98
+ setSentTo(address);
99
+ }, 1200);
100
+ }
101
+ function handleSendAgain() {
102
+ // One click sends one email: clicks while it sends or reads 'Sent' do nothing.
103
+ if (resending || resent)
104
+ return;
105
+ setResending(true);
106
+ // Stands in for the request to the server.
107
+ // A failed request shows an inline error Alert above the Buttons, such as 'The email was not sent. Try again.'
108
+ timer.current = setTimeout(function () {
109
+ setResending(false);
110
+ setResent(true);
111
+ }, 1200);
112
+ }
113
+ // The first page after sign-up says the plan again, so the person sees it was kept.
114
+ if (sentTo) {
115
+ return (<Center fill>
116
+ <Icon icon={Mail} size="large" color="secondary"/>
117
+ <Stack gap="medium">
118
+ <Heading level={1} size="h5">Check your email</Heading>
119
+ <Paragraph tone="secondary" measure="none">We sent a link to {sentTo}. Open it to continue.</Paragraph>
120
+ {picked && <Paragraph tone="secondary" measure="none">{"Your plan is ".concat(picked.name, ". The ").concat(trialDays, "-day trial starts when you open the link.")}</Paragraph>}
121
+ </Stack>
122
+ <Stack gap="large">
123
+ <Button size="medium" type="secondary" state="enabled" label={resent ? 'Sent' : 'Send Again'} loading={resending} onClickButton={handleSendAgain}/>
124
+ <Button size="medium" type="textOnly" state="enabled" label="Back to Login" onClickButton={function () { return router.push('/login'); }}/>
125
+ </Stack>
126
+ </Center>);
127
+ }
128
+ return (<Center fill>
129
+ <Image src={productMark} alt="Acme" width={40} height={40}/>
130
+ <TabsContainer fill>
131
+ {/* Log In keeps the plan too, for a visitor who already has an account. */}
132
+ <Tab label="Log In" isSelected={false} href={picked ? "/login?plan=".concat(plan) : '/login'} router={router} onClickTab={function () { }}/>
133
+ <Tab label="Sign Up" isSelected onClickTab={function () { }}/>
134
+ </TabsContainer>
135
+ {picked && (
136
+ // No card here: the person pays after the trial, once the account exists.
137
+ <Stack gap="small">
138
+ <Alert type="info" variant="inline" message={"You picked ".concat(picked.name, ", ").concat(formatMoney(picked.price), " per member per month. You pay after a ").concat(trialDays, "-day trial.")} autoDismiss={false}/>
139
+ <Link href="/#pricing" size="body2">Change Plan</Link>
140
+ </Stack>)}
141
+ <Form aria-label="Sign up" onSubmit={handleSubmit}>
142
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
143
+ <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(''); }}/>
144
+ <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(''); }}/>
145
+ <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(''); }}/>
146
+ <Button size="medium" type="primary" state="enabled" label="Sign Up" htmlType="submit" loading={loading}/>
147
+ </Form>
148
+ <Line label="or"/>
149
+ <Button size="medium" type="secondary" state="enabled" label="Continue with Google" decoIcon={<BrandIcon name="google"/>}/>
150
+ </Center>);
151
+ }