oneslash-design-system 2.14.2 → 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 (232) hide show
  1. package/README.md +15 -0
  2. package/dist/DESIGN.md +138 -1
  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 +29 -0
  9. package/dist/cases/agent-cancels-when-unanswered.md +27 -0
  10. package/dist/cases/agent-refuses-clearly.md +31 -0
  11. package/dist/cases/agent-says-what-it-is.md +29 -0
  12. package/dist/cases/agent-shows-progress.md +30 -0
  13. package/dist/cases/agent-shows-sources.md +26 -0
  14. package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
  15. package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
  16. package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
  17. package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
  18. package/dist/cases/auth-gate-loading.md +70 -0
  19. package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
  20. package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
  21. package/dist/cases/check-your-email/page.d.ts +1 -0
  22. package/dist/cases/check-your-email/page.jsx +49 -0
  23. package/dist/cases/check-your-email.md +184 -0
  24. package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
  25. package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
  26. package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
  27. package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
  28. package/dist/cases/confirm-destructive-action.md +211 -0
  29. package/dist/cases/confirm-dialogs.md +36 -0
  30. package/dist/cases/create-modal/quick.d.ts +1 -0
  31. package/dist/cases/create-modal/quick.jsx +80 -0
  32. package/dist/cases/create-modal/with-settings.d.ts +1 -0
  33. package/dist/cases/create-modal/with-settings.jsx +99 -0
  34. package/dist/cases/create-modal.md +244 -0
  35. package/dist/cases/device-login/popup.d.ts +1 -0
  36. package/dist/cases/device-login/popup.jsx +14 -0
  37. package/dist/cases/device-login/provider-first.d.ts +1 -0
  38. package/dist/cases/device-login/provider-first.jsx +98 -0
  39. package/dist/cases/device-login.md +171 -0
  40. package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
  41. package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
  42. package/dist/cases/email-confirmed/page.d.ts +1 -0
  43. package/dist/cases/email-confirmed/page.jsx +21 -0
  44. package/dist/cases/email-confirmed.md +151 -0
  45. package/dist/cases/empty-list/region.d.ts +1 -0
  46. package/dist/cases/empty-list/region.jsx +13 -0
  47. package/dist/cases/empty-list/section.d.ts +1 -0
  48. package/dist/cases/empty-list/section.jsx +17 -0
  49. package/dist/cases/empty-list.md +77 -0
  50. package/dist/cases/empty-lists.md +35 -0
  51. package/dist/cases/empty-not-set-up/action.d.ts +1 -0
  52. package/dist/cases/empty-not-set-up/action.jsx +16 -0
  53. package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
  54. package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
  55. package/dist/cases/empty-not-set-up.md +88 -0
  56. package/dist/cases/empty-search/clear-search.d.ts +1 -0
  57. package/dist/cases/empty-search/clear-search.jsx +29 -0
  58. package/dist/cases/empty-search.md +77 -0
  59. package/dist/cases/error-page/full-page.d.ts +1 -0
  60. package/dist/cases/error-page/full-page.jsx +19 -0
  61. package/dist/cases/error-page/in-shell.d.ts +1 -0
  62. package/dist/cases/error-page/in-shell.jsx +39 -0
  63. package/dist/cases/error-page.md +107 -0
  64. package/dist/cases/feedback-form/modal.d.ts +1 -0
  65. package/dist/cases/feedback-form/modal.jsx +89 -0
  66. package/dist/cases/feedback-form.md +139 -0
  67. package/dist/cases/forgot-password/in-place.d.ts +1 -0
  68. package/dist/cases/forgot-password/in-place.jsx +155 -0
  69. package/dist/cases/forgot-password/own-page.d.ts +1 -0
  70. package/dist/cases/forgot-password/own-page.jsx +99 -0
  71. package/dist/cases/forgot-password.md +328 -0
  72. package/dist/cases/form-errors.md +32 -0
  73. package/dist/cases/import-checklist/modal.d.ts +1 -0
  74. package/dist/cases/import-checklist/modal.jsx +125 -0
  75. package/dist/cases/import-checklist.md +188 -0
  76. package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
  77. package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
  78. package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
  79. package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
  80. package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
  81. package/dist/cases/inline-form-feedback/toast.jsx +66 -0
  82. package/dist/cases/inline-form-feedback.md +237 -0
  83. package/dist/cases/invite-member/by-email.d.ts +1 -0
  84. package/dist/cases/invite-member/by-email.jsx +98 -0
  85. package/dist/cases/invite-member/by-link.d.ts +1 -0
  86. package/dist/cases/invite-member/by-link.jsx +122 -0
  87. package/dist/cases/invite-member.md +321 -0
  88. package/dist/cases/load-failure/inline.d.ts +1 -0
  89. package/dist/cases/load-failure/inline.jsx +52 -0
  90. package/dist/cases/load-failure/region.d.ts +1 -0
  91. package/dist/cases/load-failure/region.jsx +34 -0
  92. package/dist/cases/load-failure.md +155 -0
  93. package/dist/cases/log-out-confirm/modal.d.ts +1 -0
  94. package/dist/cases/log-out-confirm/modal.jsx +57 -0
  95. package/dist/cases/log-out-confirm.md +106 -0
  96. package/dist/cases/login-page/centered.d.ts +1 -0
  97. package/dist/cases/login-page/centered.jsx +72 -0
  98. package/dist/cases/login-page/email-only.d.ts +1 -0
  99. package/dist/cases/login-page/email-only.jsx +59 -0
  100. package/dist/cases/login-page/provider-first.d.ts +1 -0
  101. package/dist/cases/login-page/provider-first.jsx +66 -0
  102. package/dist/cases/login-page/split.d.ts +1 -0
  103. package/dist/cases/login-page/split.jsx +79 -0
  104. package/dist/cases/login-page.md +373 -0
  105. package/dist/cases/not-found-page/full-page.d.ts +1 -0
  106. package/dist/cases/not-found-page/full-page.jsx +16 -0
  107. package/dist/cases/not-found-page/in-shell.d.ts +1 -0
  108. package/dist/cases/not-found-page/in-shell.jsx +36 -0
  109. package/dist/cases/not-found-page.md +98 -0
  110. package/dist/cases/oauth-consent/simple.d.ts +1 -0
  111. package/dist/cases/oauth-consent/simple.jsx +73 -0
  112. package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
  113. package/dist/cases/oauth-consent/with-scope.jsx +89 -0
  114. package/dist/cases/oauth-consent.md +233 -0
  115. package/dist/cases/rename/inline.d.ts +1 -0
  116. package/dist/cases/rename/inline.jsx +58 -0
  117. package/dist/cases/rename/modal.d.ts +1 -0
  118. package/dist/cases/rename/modal.jsx +70 -0
  119. package/dist/cases/rename.md +205 -0
  120. package/dist/cases/route-loading/full-screen.d.ts +1 -0
  121. package/dist/cases/route-loading/full-screen.jsx +8 -0
  122. package/dist/cases/route-loading/region.d.ts +1 -0
  123. package/dist/cases/route-loading/region.jsx +26 -0
  124. package/dist/cases/route-loading.md +84 -0
  125. package/dist/cases/set-new-password/form.d.ts +1 -0
  126. package/dist/cases/set-new-password/form.jsx +130 -0
  127. package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
  128. package/dist/cases/set-new-password/invalid-link.jsx +50 -0
  129. package/dist/cases/set-new-password.md +247 -0
  130. package/dist/cases/sign-up-page/centered.d.ts +1 -0
  131. package/dist/cases/sign-up-page/centered.jsx +124 -0
  132. package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
  133. package/dist/cases/sign-up-page/provider-first.jsx +124 -0
  134. package/dist/cases/sign-up-page/split.d.ts +1 -0
  135. package/dist/cases/sign-up-page/split.jsx +134 -0
  136. package/dist/cases/sign-up-page.md +478 -0
  137. package/dist/cases/success-feedback.md +35 -0
  138. package/dist/cases/type-to-confirm/inline.d.ts +1 -0
  139. package/dist/cases/type-to-confirm/inline.jsx +69 -0
  140. package/dist/cases/type-to-confirm/modal.d.ts +1 -0
  141. package/dist/cases/type-to-confirm/modal.jsx +73 -0
  142. package/dist/cases/type-to-confirm.md +222 -0
  143. package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
  144. package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
  145. package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
  146. package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
  147. package/dist/cases/unsaved-changes-guard.md +239 -0
  148. package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
  149. package/dist/cases/upgrade-prompt/inline.jsx +52 -0
  150. package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
  151. package/dist/cases/upgrade-prompt/modal.jsx +43 -0
  152. package/dist/cases/upgrade-prompt.md +174 -0
  153. package/dist/cases.json +2073 -0
  154. package/dist/components/alert.d.ts +3 -1
  155. package/dist/components/alert.jsx +6 -4
  156. package/dist/components/brandIcon.d.ts +12 -0
  157. package/dist/components/brandIcon.jsx +24 -0
  158. package/dist/components/emptyBox.d.ts +6 -1
  159. package/dist/components/emptyBox.jsx +4 -2
  160. package/dist/components/form.d.ts +11 -0
  161. package/dist/components/form.jsx +22 -0
  162. package/dist/components/heading.d.ts +2 -2
  163. package/dist/components/image.d.ts +14 -0
  164. package/dist/components/image.jsx +6 -0
  165. package/dist/components/layout.d.ts +18 -1
  166. package/dist/components/layout.jsx +16 -0
  167. package/dist/components/line.d.ts +3 -1
  168. package/dist/components/line.jsx +8 -1
  169. package/dist/components/loadingScreen.d.ts +5 -1
  170. package/dist/components/loadingScreen.jsx +4 -2
  171. package/dist/components/modal.d.ts +2 -1
  172. package/dist/components/modal.jsx +20 -8
  173. package/dist/components/radioGroup.d.ts +2 -1
  174. package/dist/components/radioGroup.jsx +2 -2
  175. package/dist/components/select.d.ts +2 -1
  176. package/dist/components/select.jsx +4 -2
  177. package/dist/components/tab.jsx +3 -2
  178. package/dist/components/tabsContainer.d.ts +4 -1
  179. package/dist/components/tabsContainer.jsx +11 -5
  180. package/dist/components/textField.d.ts +5 -1
  181. package/dist/components/textField.jsx +7 -3
  182. package/dist/components/toaster.d.ts +12 -0
  183. package/dist/components/toaster.jsx +103 -0
  184. package/dist/components/tooltip.jsx +3 -1
  185. package/dist/designTokens.d.ts +1 -0
  186. package/dist/designTokens.js +1 -0
  187. package/dist/internal/alert.d.ts +4 -0
  188. package/dist/internal/alert.js +6 -0
  189. package/dist/internal/modal.d.ts +2 -0
  190. package/dist/internal/modal.js +21 -0
  191. package/dist/internal/toaster.d.ts +19 -0
  192. package/dist/internal/toaster.js +50 -0
  193. package/dist/native-mapping.json +23 -1
  194. package/dist/stories/Alert.stories.d.ts +1 -0
  195. package/dist/stories/Alert.stories.jsx +16 -0
  196. package/dist/stories/BrandIcon.stories.d.ts +9 -0
  197. package/dist/stories/BrandIcon.stories.jsx +19 -0
  198. package/dist/stories/Cases.generated.stories.d.ts +60 -0
  199. package/dist/stories/Cases.generated.stories.jsx +116 -0
  200. package/dist/stories/EmptyBox.stories.d.ts +2 -0
  201. package/dist/stories/EmptyBox.stories.jsx +16 -0
  202. package/dist/stories/Form.stories.d.ts +6 -0
  203. package/dist/stories/Form.stories.jsx +26 -0
  204. package/dist/stories/Heading.stories.d.ts +6 -0
  205. package/dist/stories/Heading.stories.jsx +10 -0
  206. package/dist/stories/Image.stories.d.ts +7 -0
  207. package/dist/stories/Image.stories.jsx +18 -0
  208. package/dist/stories/Line.stories.d.ts +1 -0
  209. package/dist/stories/Line.stories.jsx +12 -0
  210. package/dist/stories/LoadingScreen.stories.d.ts +1 -0
  211. package/dist/stories/LoadingScreen.stories.jsx +8 -0
  212. package/dist/stories/Modal.stories.d.ts +2 -0
  213. package/dist/stories/Modal.stories.jsx +36 -0
  214. package/dist/stories/PageComponents.stories.d.ts +2 -0
  215. package/dist/stories/PageComponents.stories.jsx +15 -1
  216. package/dist/stories/RadioGroup.stories.d.ts +1 -0
  217. package/dist/stories/RadioGroup.stories.jsx +14 -0
  218. package/dist/stories/Select.stories.d.ts +1 -0
  219. package/dist/stories/Select.stories.jsx +14 -0
  220. package/dist/stories/TabsContainer.stories.d.ts +1 -0
  221. package/dist/stories/TabsContainer.stories.jsx +12 -0
  222. package/dist/stories/TextField.stories.d.ts +2 -0
  223. package/dist/stories/TextField.stories.jsx +22 -0
  224. package/dist/stories/Toaster.stories.d.ts +6 -0
  225. package/dist/stories/Toaster.stories.jsx +29 -0
  226. package/dist/tailwind-preset-auto.js +2 -1
  227. package/dist/tailwind-preset.js +2 -1
  228. package/dist/theme-auto.css +1 -0
  229. package/dist/theme.css +1 -0
  230. package/dist/tokens.css +1 -0
  231. package/dist/tokens.json +7 -0
  232. package/package.json +4 -2
@@ -0,0 +1,188 @@
1
+ # Import checklist
2
+
3
+ A person picks which items to bring in from another place, such as pages from a wiki.
4
+
5
+ **Not built yet:** Scindo's Notion import labels its Buttons 'Select all' and 'Import', changes the action to 'Importing… 1/2' while it runs, and shows bare text when nothing matches.
6
+
7
+ ## Do
8
+
9
+ - Put a search field at the top, then a count line, then the list of `Checkbox`es.
10
+ - Write the count line as plain words: '3 of 8 pages selected.' While a search is on, add how many match: '3 of 8 pages selected. 2 match "launch".'
11
+ - Offer 'Select All' and 'Clear' as tertiary Buttons. Both act on the items shown, and while a search is on their labels say so: 'Select Shown' and 'Clear Shown'.
12
+ - Focus the search field when the Modal opens, with `initialFocus="body"`, and again after 'Clear Search'.
13
+ - Count the selection in the action: 'Import 3 Pages'. Keep it `state="disabled"` while nothing is selected.
14
+ - Keep the selection when a search hides items. Items that are filtered out stay selected.
15
+ - Show `EmptyBox size="small"` with the words searched for and a 'Clear Search' Button when nothing matches.
16
+ - Show `EmptyBox size="small"` when there is nothing left to import.
17
+ - Show `loading` on the action while it imports, and keep the list on screen with the Checkboxes disabled.
18
+ - Close the Modal when it works and show the new items where they live.
19
+
20
+ ## Don't
21
+
22
+ - Do not use a master Checkbox for Select All. Checkbox has no state for some selected.
23
+ - Do not label the action 'Import' without the count, or change it while it runs, such as to 'Importing… 1/2'.
24
+ - Do not clear the selection when the person searches.
25
+ - Do not show a bare line of text when the list is empty or nothing matches.
26
+
27
+ ## Example: Pick in a Modal
28
+
29
+ Uses: `Button`, `Center`, `Checkbox`, `Cluster`, `EmptyBox`, `Heading`, `List`, `Modal`, `Paragraph`, `Stack`, `Surface`, `TextField`
30
+
31
+ ```tsx
32
+ 'use client';
33
+ import { useEffect, useRef, useState } from 'react';
34
+ import Modal from 'oneslash-design-system/components/modal';
35
+ import Surface from 'oneslash-design-system/components/surface';
36
+ import Heading from 'oneslash-design-system/components/heading';
37
+ import Paragraph from 'oneslash-design-system/components/paragraph';
38
+ import List from 'oneslash-design-system/components/list';
39
+ import TextField from 'oneslash-design-system/components/textField';
40
+ import Checkbox from 'oneslash-design-system/components/checkBox';
41
+ import EmptyBox from 'oneslash-design-system/components/emptyBox';
42
+ import Button from 'oneslash-design-system/components/button';
43
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
44
+
45
+ // Pages in the other place. A real app loads them when the Modal opens.
46
+ const wikiPages = [
47
+ { id: 'p1', title: 'Launch checklist', edited: 'Edited 2 days ago' },
48
+ { id: 'p2', title: 'Launch email draft', edited: 'Edited 3 days ago' },
49
+ { id: 'p3', title: 'Brand voice', edited: 'Edited last week' },
50
+ { id: 'p4', title: 'Pricing notes', edited: 'Edited last week' },
51
+ { id: 'p5', title: 'Hiring plan', edited: 'Edited 2 weeks ago' },
52
+ { id: 'p6', title: 'Office move', edited: 'Edited last month' },
53
+ { id: 'p7', title: 'Onboarding guide', edited: 'Edited last month' },
54
+ { id: 'p8', title: 'Team rituals', edited: 'Edited 2 months ago' },
55
+ ];
56
+
57
+ const plural = (n: number) => (n === 1 ? 'Page' : 'Pages');
58
+
59
+ export default function ImportChecklistModal() {
60
+ const [docs, setDocs] = useState(['Q3 plan', 'Meeting notes']);
61
+ const [imported, setImported] = useState<string[]>([]);
62
+ // Opens on the Modal with three pages picked, as if the person just chose Import Pages.
63
+ const [open, setOpen] = useState(true);
64
+ const [query, setQuery] = useState('');
65
+ const [selected, setSelected] = useState<string[]>(['p1', 'p2', 'p4']);
66
+ const [importing, setImporting] = useState(false);
67
+ // Bumped by 'Clear Search'. It remounts the search field with `autoFocus`, so focus goes
68
+ // back to the field instead of being lost with the Button that the list replaces.
69
+ const [searchKey, setSearchKey] = useState(0);
70
+ const timer = useRef<ReturnType<typeof setTimeout>>();
71
+
72
+ // Stops the request if the example goes away before it ends.
73
+ useEffect(() => () => clearTimeout(timer.current), []);
74
+
75
+ const available = wikiPages.filter((p) => !imported.includes(p.id));
76
+ const words = query.trim();
77
+ const shown = available.filter((p) => p.title.toLowerCase().includes(words.toLowerCase()));
78
+ const shownIds = shown.map((p) => p.id);
79
+ const count = selected.length;
80
+ // While a search is on, the labels say that they act only on the pages shown.
81
+ const searching = words !== '';
82
+
83
+ function toggle(id: string, checked: boolean) {
84
+ setSelected((list) => (checked ? [...list, id] : list.filter((x) => x !== id)));
85
+ }
86
+
87
+ // Both act on the pages shown. Pages the search hides keep their selection.
88
+ function selectShown() {
89
+ setSelected((list) => [...list, ...shownIds.filter((id) => !list.includes(id))]);
90
+ }
91
+ function clearShown() {
92
+ setSelected((list) => list.filter((id) => !shownIds.includes(id)));
93
+ }
94
+
95
+ function clearSearch() {
96
+ setQuery('');
97
+ setSearchKey((k) => k + 1);
98
+ }
99
+
100
+ function handleOpen() {
101
+ setQuery('');
102
+ setSelected([]);
103
+ setOpen(true);
104
+ }
105
+
106
+ // Escape, a click outside and Cancel all close it, except while the request runs.
107
+ function handleClose() {
108
+ if (importing) return;
109
+ setOpen(false);
110
+ }
111
+
112
+ function handleImport() {
113
+ if (importing || count === 0) return;
114
+ setImporting(true);
115
+ // Stands in for the request to the server.
116
+ timer.current = setTimeout(() => {
117
+ setImporting(false);
118
+ setDocs((list) => [...wikiPages.filter((p) => selected.includes(p.id)).map((p) => p.title), ...list]);
119
+ setImported((list) => [...list, ...selected]);
120
+ setSelected([]);
121
+ setOpen(false);
122
+ }, 1200);
123
+ }
124
+
125
+ return (
126
+ <Center width="page">
127
+ <Stack gap="large">
128
+ <Cluster>
129
+ <Heading level={1} size="h5">Docs</Heading>
130
+ <Button size="small" type="secondary" state="enabled" label="Import Pages" decoIcon="Download" onClickButton={handleOpen} />
131
+ </Cluster>
132
+ {/* The imported pages show at the top of the list, so no toast is needed. */}
133
+ <Surface padding="large">
134
+ <List items={docs} size="body1" />
135
+ </Surface>
136
+ </Stack>
137
+ <Modal
138
+ isOpen={open}
139
+ size="medium"
140
+ initialFocus="body"
141
+ title="Import Pages"
142
+ secondTitle="From the Acme wiki"
143
+ onClose={handleClose}
144
+ actions={
145
+ <>
146
+ <Button size="small" type="tertiary" state={importing ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
147
+ <Button size="small" type="primary" state={count === 0 ? 'disabled' : 'enabled'} label={count === 0 ? 'Import Pages' : `Import ${count} ${plural(count)}`} loading={importing} onClickButton={handleImport} />
148
+ </>
149
+ }
150
+ >
151
+ {available.length === 0 ? (
152
+ <EmptyBox size="small" icon="FileCheck" text="No pages left to import" secondText="Every page in the Acme wiki is already in Docs." />
153
+ ) : (
154
+ <>
155
+ <TextField key={searchKey} autoFocus={searchKey > 0} id="import-checklist-search" label="Search pages" type="search" value={query} disabled={importing} onChange={(e) => setQuery(e.target.value)} />
156
+ <Stack gap="small">
157
+ <Paragraph tone="secondary" size="body2" measure="none">
158
+ {count} of {available.length} pages selected.{words && ` ${shown.length} match "${words}".`}
159
+ </Paragraph>
160
+ <Cluster gap="small">
161
+ <Button size="small" type="tertiary" state={importing || shown.length === 0 ? 'disabled' : 'enabled'} label={searching ? 'Select Shown' : 'Select All'} onClickButton={selectShown} />
162
+ <Button size="small" type="tertiary" state={importing || shown.length === 0 ? 'disabled' : 'enabled'} label={searching ? 'Clear Shown' : 'Clear'} onClickButton={clearShown} />
163
+ </Cluster>
164
+ </Stack>
165
+ {shown.length > 0 ? (
166
+ <Stack gap="medium">
167
+ {shown.map((p) => (
168
+ <Checkbox key={p.id} label={p.title} secondLabel={p.edited} checked={selected.includes(p.id)} disabled={importing} onChange={(checked) => toggle(p.id, checked)} />
169
+ ))}
170
+ </Stack>
171
+ ) : (
172
+ <EmptyBox
173
+ size="small"
174
+ icon="Search"
175
+ text={`No pages match "${words}"`}
176
+ secondText="Check the spelling, or search for fewer words."
177
+ action={<Button size="small" type="secondary" state="enabled" label="Clear Search" onClickButton={clearSearch} />}
178
+ />
179
+ )}
180
+ </>
181
+ )}
182
+ </Modal>
183
+ </Center>
184
+ );
185
+ }
186
+ ```
187
+
188
+ Seen in: Scindo.
@@ -0,0 +1 @@
1
+ export default function InlineFormFeedbackButtonLabel(): import("react").JSX.Element;
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Surface from '../../components/surface';
4
+ import Heading from '../../components/heading';
5
+ import Form from '../../components/form';
6
+ import TextField from '../../components/textField';
7
+ import Button from '../../components/button';
8
+ import { Center, Cluster, Stack } from '../../components/layout';
9
+ export default function InlineFormFeedbackButtonLabel() {
10
+ var _a = useState('Dana Reyes'), name = _a[0], setName = _a[1];
11
+ var _b = useState(''), nameError = _b[0], setNameError = _b[1];
12
+ var _c = useState(false), loading = _c[0], setLoading = _c[1];
13
+ // Starts saved, so the example opens on the state it shows.
14
+ var _d = useState(true), saved = _d[0], setSaved = _d[1];
15
+ var timer = useRef();
16
+ // Stops the request if the example goes away before it ends.
17
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
18
+ // 'Saved' shows for 2 seconds, or until the person edits again, then the Button reads 'Save'.
19
+ useEffect(function () {
20
+ if (!saved)
21
+ return;
22
+ var timer = setTimeout(function () { return setSaved(false); }, 2000);
23
+ return function () { return clearTimeout(timer); };
24
+ }, [saved]);
25
+ function handleSubmit() {
26
+ if (loading)
27
+ return;
28
+ setNameError('');
29
+ setSaved(false);
30
+ if (!name.trim()) {
31
+ setNameError('Enter the name people see on your comments.');
32
+ return;
33
+ }
34
+ setLoading(true);
35
+ // Stands in for the request to the server.
36
+ timer.current = setTimeout(function () {
37
+ setLoading(false);
38
+ setSaved(true);
39
+ }, 1200);
40
+ }
41
+ return (<Center>
42
+ <Surface padding="large">
43
+ <Stack gap="large">
44
+ <Heading level={2} size="h6">Profile</Heading>
45
+ <Form aria-label="Profile" onSubmit={handleSubmit}>
46
+ <TextField id="inline-form-feedback-name" label="Display name" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} onChange={function (e) { setName(e.target.value); setNameError(''); setSaved(false); }}/>
47
+ <Cluster>
48
+ <Button size="medium" type="primary" state="enabled" label={saved ? 'Saved' : 'Save'} htmlType="submit" loading={loading}/>
49
+ </Cluster>
50
+ </Form>
51
+ </Stack>
52
+ </Surface>
53
+ </Center>);
54
+ }
@@ -0,0 +1 @@
1
+ export default function InlineFormFeedbackInlineAlert(): import("react").JSX.Element;
@@ -0,0 +1,49 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Surface from '../../components/surface';
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 { Center, Cluster, Stack } from '../../components/layout';
10
+ export default function InlineFormFeedbackInlineAlert() {
11
+ var _a = useState('Dana Reyes'), name = _a[0], setName = _a[1];
12
+ var _b = useState(''), nameError = _b[0], setNameError = _b[1];
13
+ // Starts failed, so the example opens on the state it shows.
14
+ var _c = useState('Your profile was not saved. Try again.'), error = _c[0], setError = _c[1];
15
+ var _d = useState(false), loading = _d[0], setLoading = _d[1];
16
+ var timer = useRef();
17
+ // Stops the request if the example goes away before it ends.
18
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
19
+ function handleSubmit() {
20
+ if (loading)
21
+ return;
22
+ setError('');
23
+ setNameError('');
24
+ if (!name.trim()) {
25
+ setNameError('Enter the name people see on your comments.');
26
+ return;
27
+ }
28
+ setLoading(true);
29
+ // Stands in for the request to the server.
30
+ timer.current = setTimeout(function () {
31
+ setLoading(false);
32
+ setError('Your profile was not saved. Try again.');
33
+ }, 1200);
34
+ }
35
+ return (<Center>
36
+ <Surface padding="large">
37
+ <Stack gap="large">
38
+ <Heading level={2} size="h6">Profile</Heading>
39
+ <Form aria-label="Profile" onSubmit={handleSubmit}>
40
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
41
+ <TextField id="inline-form-feedback-alert-name" label="Display name" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} onChange={function (e) { setName(e.target.value); setNameError(''); }}/>
42
+ <Cluster>
43
+ <Button size="medium" type="primary" state="enabled" label="Save" htmlType="submit" loading={loading}/>
44
+ </Cluster>
45
+ </Form>
46
+ </Stack>
47
+ </Surface>
48
+ </Center>);
49
+ }
@@ -0,0 +1 @@
1
+ export default function InlineFormFeedbackToast(): import("react").JSX.Element;
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
4
+ import Surface from '../../components/surface';
5
+ import Heading from '../../components/heading';
6
+ import Form from '../../components/form';
7
+ import TextField from '../../components/textField';
8
+ import Button from '../../components/button';
9
+ import { Center, Cluster, Stack } from '../../components/layout';
10
+ // A small check: some text, an @, then some text.
11
+ function looksLikeEmail(value) {
12
+ return /^[^@\s]+@[^@\s]+$/.test(value);
13
+ }
14
+ export default function InlineFormFeedbackToast() {
15
+ var _a = useState(''), email = _a[0], setEmail = _a[1];
16
+ var _b = useState(''), emailError = _b[0], setEmailError = _b[1];
17
+ var _c = useState(false), loading = _c[0], setLoading = _c[1];
18
+ var timer = useRef();
19
+ var toastIds = useRef([]);
20
+ // Opens on the toast the example shows, as if an invite was just sent.
21
+ // On unmount it stops the request and closes every toast it opened.
22
+ useEffect(function () {
23
+ toastIds.current.push(toast({ type: 'success', message: 'Invite sent to dana@example.com.' }));
24
+ return function () {
25
+ clearTimeout(timer.current);
26
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
27
+ toastIds.current = [];
28
+ };
29
+ }, []);
30
+ function handleSubmit() {
31
+ if (loading)
32
+ return;
33
+ setEmailError('');
34
+ var address = email.trim();
35
+ if (!address) {
36
+ setEmailError('Enter an email address.');
37
+ return;
38
+ }
39
+ if (!looksLikeEmail(address)) {
40
+ setEmailError('Enter an email address, like name@example.com.');
41
+ return;
42
+ }
43
+ setLoading(true);
44
+ // Stands in for the request to the server.
45
+ timer.current = setTimeout(function () {
46
+ setLoading(false);
47
+ setEmail('');
48
+ toastIds.current.push(toast({ type: 'success', message: "Invite sent to ".concat(address, ".") }));
49
+ }, 1200);
50
+ }
51
+ return (<Center fill>
52
+ {/* A real app mounts one Toaster near its root. */}
53
+ <Toaster />
54
+ <Surface padding="large">
55
+ <Stack gap="large">
56
+ <Heading level={2} size="h6">Invite people</Heading>
57
+ <Form aria-label="Invite people" onSubmit={handleSubmit}>
58
+ <TextField id="inline-form-feedback-email" label="Email" type="email" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
59
+ <Cluster>
60
+ <Button size="medium" type="primary" state="enabled" label="Invite" htmlType="submit" loading={loading}/>
61
+ </Cluster>
62
+ </Form>
63
+ </Stack>
64
+ </Surface>
65
+ </Center>);
66
+ }
@@ -0,0 +1,237 @@
1
+ # Form feedback
2
+
3
+ A person submits a small form, such as a settings field, and the request ends. The three options are the three outcomes of one save: it worked in place, it failed, or the result is elsewhere.
4
+
5
+ **Not built yet:** Scindo on the web labels its save Buttons 'Saving...' while they save. Its profile settings show nothing when a save fails. Its instructions settings show the error's own message in an inline Alert with no close button.
6
+
7
+ ## Do
8
+
9
+ - Show `loading` on the submit Button while the request runs, and keep its label.
10
+ - Show 'Saved' on the Button for 2 seconds when the form saves in place, or until the person edits again.
11
+ - Show a failed request above the fields in `<Alert type="error" variant="inline" showCloseButton>`, and keep what the person typed.
12
+ - Call `toast({ type: 'success', message })` when the result is somewhere else.
13
+
14
+ ## Don't
15
+
16
+ - Do not change the Button's label while it is loading, such as to 'Saving…'.
17
+ - Do not show a toast for a change the person can already see.
18
+ - Do not let a failed save pass with no message.
19
+ - Do not say 'successfully'.
20
+
21
+ ## Option: Saved on the Button
22
+
23
+ Use when: It worked in place: the change shows where it is.
24
+
25
+ Uses: `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Stack`, `Surface`, `TextField`
26
+
27
+ ```tsx
28
+ 'use client';
29
+ import { useEffect, useRef, useState } from 'react';
30
+ import Surface from 'oneslash-design-system/components/surface';
31
+ import Heading from 'oneslash-design-system/components/heading';
32
+ import Form from 'oneslash-design-system/components/form';
33
+ import TextField from 'oneslash-design-system/components/textField';
34
+ import Button from 'oneslash-design-system/components/button';
35
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
36
+
37
+ export default function InlineFormFeedbackButtonLabel() {
38
+ const [name, setName] = useState('Dana Reyes');
39
+ const [nameError, setNameError] = useState('');
40
+ const [loading, setLoading] = useState(false);
41
+ // Starts saved, so the example opens on the state it shows.
42
+ const [saved, setSaved] = useState(true);
43
+ const timer = useRef<ReturnType<typeof setTimeout>>();
44
+
45
+ // Stops the request if the example goes away before it ends.
46
+ useEffect(() => () => clearTimeout(timer.current), []);
47
+
48
+ // 'Saved' shows for 2 seconds, or until the person edits again, then the Button reads 'Save'.
49
+ useEffect(() => {
50
+ if (!saved) return;
51
+ const timer = setTimeout(() => setSaved(false), 2000);
52
+ return () => clearTimeout(timer);
53
+ }, [saved]);
54
+
55
+ function handleSubmit() {
56
+ if (loading) return;
57
+ setNameError('');
58
+ setSaved(false);
59
+ if (!name.trim()) {
60
+ setNameError('Enter the name people see on your comments.');
61
+ return;
62
+ }
63
+ setLoading(true);
64
+ // Stands in for the request to the server.
65
+ timer.current = setTimeout(() => {
66
+ setLoading(false);
67
+ setSaved(true);
68
+ }, 1200);
69
+ }
70
+
71
+ return (
72
+ <Center>
73
+ <Surface padding="large">
74
+ <Stack gap="large">
75
+ <Heading level={2} size="h6">Profile</Heading>
76
+ <Form aria-label="Profile" onSubmit={handleSubmit}>
77
+ <TextField id="inline-form-feedback-name" label="Display name" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} onChange={(e) => { setName(e.target.value); setNameError(''); setSaved(false); }} />
78
+ <Cluster>
79
+ <Button size="medium" type="primary" state="enabled" label={saved ? 'Saved' : 'Save'} htmlType="submit" loading={loading} />
80
+ </Cluster>
81
+ </Form>
82
+ </Stack>
83
+ </Surface>
84
+ </Center>
85
+ );
86
+ }
87
+ ```
88
+
89
+ ## Option: Inline error Alert
90
+
91
+ Use when: It failed: the request did not go through.
92
+
93
+ Uses: `Alert`, `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Stack`, `Surface`, `TextField`
94
+
95
+ ```tsx
96
+ 'use client';
97
+ import { useEffect, useRef, useState } from 'react';
98
+ import Surface from 'oneslash-design-system/components/surface';
99
+ import Heading from 'oneslash-design-system/components/heading';
100
+ import Form from 'oneslash-design-system/components/form';
101
+ import Alert from 'oneslash-design-system/components/alert';
102
+ import TextField from 'oneslash-design-system/components/textField';
103
+ import Button from 'oneslash-design-system/components/button';
104
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
105
+
106
+ export default function InlineFormFeedbackInlineAlert() {
107
+ const [name, setName] = useState('Dana Reyes');
108
+ const [nameError, setNameError] = useState('');
109
+ // Starts failed, so the example opens on the state it shows.
110
+ const [error, setError] = useState('Your profile was not saved. Try again.');
111
+ const [loading, setLoading] = useState(false);
112
+ const timer = useRef<ReturnType<typeof setTimeout>>();
113
+
114
+ // Stops the request if the example goes away before it ends.
115
+ useEffect(() => () => clearTimeout(timer.current), []);
116
+
117
+ function handleSubmit() {
118
+ if (loading) return;
119
+ setError('');
120
+ setNameError('');
121
+ if (!name.trim()) {
122
+ setNameError('Enter the name people see on your comments.');
123
+ return;
124
+ }
125
+ setLoading(true);
126
+ // Stands in for the request to the server.
127
+ timer.current = setTimeout(() => {
128
+ setLoading(false);
129
+ setError('Your profile was not saved. Try again.');
130
+ }, 1200);
131
+ }
132
+
133
+ return (
134
+ <Center>
135
+ <Surface padding="large">
136
+ <Stack gap="large">
137
+ <Heading level={2} size="h6">Profile</Heading>
138
+ <Form aria-label="Profile" onSubmit={handleSubmit}>
139
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
140
+ <TextField id="inline-form-feedback-alert-name" label="Display name" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} onChange={(e) => { setName(e.target.value); setNameError(''); }} />
141
+ <Cluster>
142
+ <Button size="medium" type="primary" state="enabled" label="Save" htmlType="submit" loading={loading} />
143
+ </Cluster>
144
+ </Form>
145
+ </Stack>
146
+ </Surface>
147
+ </Center>
148
+ );
149
+ }
150
+ ```
151
+
152
+ ## Option: Toast
153
+
154
+ Use when: The result is elsewhere, such as an invite that was sent.
155
+
156
+ Uses: `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Stack`, `Surface`, `TextField`, `Toaster`, `dismissToast`, `toast`
157
+
158
+ ```tsx
159
+ 'use client';
160
+ import { useEffect, useRef, useState } from 'react';
161
+ import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
162
+ import Surface from 'oneslash-design-system/components/surface';
163
+ import Heading from 'oneslash-design-system/components/heading';
164
+ import Form from 'oneslash-design-system/components/form';
165
+ import TextField from 'oneslash-design-system/components/textField';
166
+ import Button from 'oneslash-design-system/components/button';
167
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
168
+
169
+ // A small check: some text, an @, then some text.
170
+ function looksLikeEmail(value: string) {
171
+ return /^[^@\s]+@[^@\s]+$/.test(value);
172
+ }
173
+
174
+ export default function InlineFormFeedbackToast() {
175
+ const [email, setEmail] = useState('');
176
+ const [emailError, setEmailError] = useState('');
177
+ const [loading, setLoading] = useState(false);
178
+ const timer = useRef<ReturnType<typeof setTimeout>>();
179
+ const toastIds = useRef<string[]>([]);
180
+
181
+ // Opens on the toast the example shows, as if an invite was just sent.
182
+ // On unmount it stops the request and closes every toast it opened.
183
+ useEffect(() => {
184
+ toastIds.current.push(toast({ type: 'success', message: 'Invite sent to dana@example.com.' }));
185
+ return () => {
186
+ clearTimeout(timer.current);
187
+ toastIds.current.forEach((id) => dismissToast(id));
188
+ toastIds.current = [];
189
+ };
190
+ }, []);
191
+
192
+ function handleSubmit() {
193
+ if (loading) return;
194
+ setEmailError('');
195
+ const address = email.trim();
196
+ if (!address) {
197
+ setEmailError('Enter an email address.');
198
+ return;
199
+ }
200
+ if (!looksLikeEmail(address)) {
201
+ setEmailError('Enter an email address, like name@example.com.');
202
+ return;
203
+ }
204
+ setLoading(true);
205
+ // Stands in for the request to the server.
206
+ timer.current = setTimeout(() => {
207
+ setLoading(false);
208
+ setEmail('');
209
+ toastIds.current.push(toast({ type: 'success', message: `Invite sent to ${address}.` }));
210
+ }, 1200);
211
+ }
212
+
213
+ return (
214
+ <Center fill>
215
+ {/* A real app mounts one Toaster near its root. */}
216
+ <Toaster />
217
+ <Surface padding="large">
218
+ <Stack gap="large">
219
+ <Heading level={2} size="h6">Invite people</Heading>
220
+ <Form aria-label="Invite people" onSubmit={handleSubmit}>
221
+ <TextField id="inline-form-feedback-email" label="Email" type="email" value={email} disabled={loading} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
222
+ <Cluster>
223
+ <Button size="medium" type="primary" state="enabled" label="Invite" htmlType="submit" loading={loading} />
224
+ </Cluster>
225
+ </Form>
226
+ </Stack>
227
+ </Surface>
228
+ </Center>
229
+ );
230
+ }
231
+ ```
232
+
233
+ ## Native
234
+
235
+ On Apple there is no toast. Show the result in place.
236
+
237
+ Seen in: Scindo.
@@ -0,0 +1 @@
1
+ export default function InviteMemberByEmail(): import("react").JSX.Element;