oneslash-design-system 2.15.0 → 2.17.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 (331) hide show
  1. package/README.md +6 -1
  2. package/dist/DESIGN.md +100 -73
  3. package/dist/cases/accept-invite/signed-in.d.ts +1 -0
  4. package/dist/cases/accept-invite/signed-in.jsx +57 -0
  5. package/dist/cases/accept-invite/signed-out.d.ts +1 -0
  6. package/dist/cases/accept-invite/signed-out.jsx +33 -0
  7. package/dist/cases/accept-invite.md +161 -0
  8. package/dist/cases/agent-asks-before-risky-action.md +1 -1
  9. package/dist/cases/agent-cancels-when-unanswered.md +1 -1
  10. package/dist/cases/agent-options/cards.d.ts +1 -0
  11. package/dist/cases/agent-options/cards.jsx +91 -0
  12. package/dist/cases/agent-options.md +168 -0
  13. package/dist/cases/agent-pending-reply/steps.d.ts +1 -0
  14. package/dist/cases/agent-pending-reply/steps.jsx +149 -0
  15. package/dist/cases/agent-pending-reply/streaming.d.ts +1 -0
  16. package/dist/cases/agent-pending-reply/streaming.jsx +146 -0
  17. package/dist/cases/agent-pending-reply.md +432 -0
  18. package/dist/cases/agent-plan-proposal/changes.d.ts +1 -0
  19. package/dist/cases/agent-plan-proposal/changes.jsx +224 -0
  20. package/dist/cases/agent-plan-proposal/steps.d.ts +1 -0
  21. package/dist/cases/agent-plan-proposal/steps.jsx +211 -0
  22. package/dist/cases/agent-plan-proposal.md +656 -0
  23. package/dist/cases/agent-question/choices.d.ts +1 -0
  24. package/dist/cases/agent-question/choices.jsx +132 -0
  25. package/dist/cases/agent-question/free-text.d.ts +1 -0
  26. package/dist/cases/agent-question/free-text.jsx +81 -0
  27. package/dist/cases/agent-question.md +338 -0
  28. package/dist/cases/agent-shows-sources.md +2 -2
  29. package/dist/cases/artifact-card/card.d.ts +1 -0
  30. package/dist/cases/artifact-card/card.jsx +45 -0
  31. package/dist/cases/artifact-card.md +103 -0
  32. package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
  33. package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
  34. package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
  35. package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
  36. package/dist/cases/auth-gate-loading.md +70 -0
  37. package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
  38. package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
  39. package/dist/cases/check-your-email/page.d.ts +1 -0
  40. package/dist/cases/check-your-email/page.jsx +49 -0
  41. package/dist/cases/check-your-email.md +184 -0
  42. package/dist/cases/composer-limit/notice-with-action.d.ts +1 -0
  43. package/dist/cases/composer-limit/notice-with-action.jsx +87 -0
  44. package/dist/cases/composer-limit/notice.d.ts +1 -0
  45. package/dist/cases/composer-limit/notice.jsx +84 -0
  46. package/dist/cases/composer-limit.md +286 -0
  47. package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
  48. package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
  49. package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
  50. package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
  51. package/dist/cases/confirm-destructive-action.md +211 -0
  52. package/dist/cases/confirm-dialogs.md +36 -0
  53. package/dist/cases/conversation-starters/chips.d.ts +1 -0
  54. package/dist/cases/conversation-starters/chips.jsx +69 -0
  55. package/dist/cases/conversation-starters/none.d.ts +1 -0
  56. package/dist/cases/conversation-starters/none.jsx +45 -0
  57. package/dist/cases/conversation-starters.md +208 -0
  58. package/dist/cases/create-modal/quick.d.ts +1 -0
  59. package/dist/cases/create-modal/quick.jsx +80 -0
  60. package/dist/cases/create-modal/with-settings.d.ts +1 -0
  61. package/dist/cases/create-modal/with-settings.jsx +99 -0
  62. package/dist/cases/create-modal.md +244 -0
  63. package/dist/cases/device-login/popup.d.ts +1 -0
  64. package/dist/cases/device-login/popup.jsx +14 -0
  65. package/dist/cases/device-login/provider-first.d.ts +1 -0
  66. package/dist/cases/device-login/provider-first.jsx +98 -0
  67. package/dist/cases/device-login.md +171 -0
  68. package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
  69. package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
  70. package/dist/cases/email-confirmed/page.d.ts +1 -0
  71. package/dist/cases/email-confirmed/page.jsx +21 -0
  72. package/dist/cases/email-confirmed.md +151 -0
  73. package/dist/cases/empty-list/region.d.ts +1 -0
  74. package/dist/cases/empty-list/region.jsx +13 -0
  75. package/dist/cases/empty-list/section.d.ts +1 -0
  76. package/dist/cases/empty-list/section.jsx +17 -0
  77. package/dist/cases/empty-list.md +77 -0
  78. package/dist/cases/empty-lists.md +35 -0
  79. package/dist/cases/empty-not-set-up/action.d.ts +1 -0
  80. package/dist/cases/empty-not-set-up/action.jsx +16 -0
  81. package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
  82. package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
  83. package/dist/cases/empty-not-set-up.md +88 -0
  84. package/dist/cases/empty-search/clear-search.d.ts +1 -0
  85. package/dist/cases/empty-search/clear-search.jsx +29 -0
  86. package/dist/cases/empty-search.md +77 -0
  87. package/dist/cases/error-page/full-page.d.ts +1 -0
  88. package/dist/cases/error-page/full-page.jsx +19 -0
  89. package/dist/cases/error-page/in-shell.d.ts +1 -0
  90. package/dist/cases/error-page/in-shell.jsx +39 -0
  91. package/dist/cases/error-page.md +107 -0
  92. package/dist/cases/feedback-form/modal.d.ts +1 -0
  93. package/dist/cases/feedback-form/modal.jsx +89 -0
  94. package/dist/cases/feedback-form.md +139 -0
  95. package/dist/cases/forgot-password/in-place.d.ts +1 -0
  96. package/dist/cases/forgot-password/in-place.jsx +155 -0
  97. package/dist/cases/forgot-password/own-page.d.ts +1 -0
  98. package/dist/cases/forgot-password/own-page.jsx +99 -0
  99. package/dist/cases/forgot-password.md +328 -0
  100. package/dist/cases/form-errors.md +32 -0
  101. package/dist/cases/import-checklist/modal.d.ts +1 -0
  102. package/dist/cases/import-checklist/modal.jsx +125 -0
  103. package/dist/cases/import-checklist.md +188 -0
  104. package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
  105. package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
  106. package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
  107. package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
  108. package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
  109. package/dist/cases/inline-form-feedback/toast.jsx +66 -0
  110. package/dist/cases/inline-form-feedback.md +237 -0
  111. package/dist/cases/invite-member/by-email.d.ts +1 -0
  112. package/dist/cases/invite-member/by-email.jsx +98 -0
  113. package/dist/cases/invite-member/by-link.d.ts +1 -0
  114. package/dist/cases/invite-member/by-link.jsx +122 -0
  115. package/dist/cases/invite-member.md +321 -0
  116. package/dist/cases/load-failure/inline.d.ts +1 -0
  117. package/dist/cases/load-failure/inline.jsx +52 -0
  118. package/dist/cases/load-failure/region.d.ts +1 -0
  119. package/dist/cases/load-failure/region.jsx +34 -0
  120. package/dist/cases/load-failure.md +155 -0
  121. package/dist/cases/log-out-confirm/modal.d.ts +1 -0
  122. package/dist/cases/log-out-confirm/modal.jsx +57 -0
  123. package/dist/cases/log-out-confirm.md +106 -0
  124. package/dist/cases/login-page/centered.jsx +10 -7
  125. package/dist/cases/login-page/email-only.jsx +11 -8
  126. package/dist/cases/login-page/provider-first.jsx +12 -9
  127. package/dist/cases/login-page/split.jsx +11 -8
  128. package/dist/cases/login-page.md +58 -41
  129. package/dist/cases/mention-list/in-composer.d.ts +1 -0
  130. package/dist/cases/mention-list/in-composer.jsx +169 -0
  131. package/dist/cases/mention-list.md +252 -0
  132. package/dist/cases/message-actions/hover-toolbar.d.ts +1 -0
  133. package/dist/cases/message-actions/hover-toolbar.jsx +229 -0
  134. package/dist/cases/message-actions/menu.d.ts +1 -0
  135. package/dist/cases/message-actions/menu.jsx +258 -0
  136. package/dist/cases/message-actions.md +651 -0
  137. package/dist/cases/message-attachments/in-composer.d.ts +1 -0
  138. package/dist/cases/message-attachments/in-composer.jsx +134 -0
  139. package/dist/cases/message-attachments/in-message.d.ts +1 -0
  140. package/dist/cases/message-attachments/in-message.jsx +46 -0
  141. package/dist/cases/message-attachments.md +310 -0
  142. package/dist/cases/message-composer/plain.d.ts +1 -0
  143. package/dist/cases/message-composer/plain.jsx +57 -0
  144. package/dist/cases/message-composer/with-tools.d.ts +1 -0
  145. package/dist/cases/message-composer/with-tools.jsx +182 -0
  146. package/dist/cases/message-composer.md +356 -0
  147. package/dist/cases/message-edit/in-place.d.ts +1 -0
  148. package/dist/cases/message-edit/in-place.jsx +99 -0
  149. package/dist/cases/message-edit.md +179 -0
  150. package/dist/cases/message-reactions/chips.d.ts +1 -0
  151. package/dist/cases/message-reactions/chips.jsx +118 -0
  152. package/dist/cases/message-reactions/quick-pick.d.ts +1 -0
  153. package/dist/cases/message-reactions/quick-pick.jsx +155 -0
  154. package/dist/cases/message-reactions.md +371 -0
  155. package/dist/cases/message-row/grouped.d.ts +1 -0
  156. package/dist/cases/message-row/grouped.jsx +56 -0
  157. package/dist/cases/message-row/person-and-agent.d.ts +1 -0
  158. package/dist/cases/message-row/person-and-agent.jsx +41 -0
  159. package/dist/cases/message-row.md +189 -0
  160. package/dist/cases/not-found-page/full-page.d.ts +1 -0
  161. package/dist/cases/not-found-page/full-page.jsx +16 -0
  162. package/dist/cases/not-found-page/in-shell.d.ts +1 -0
  163. package/dist/cases/not-found-page/in-shell.jsx +36 -0
  164. package/dist/cases/not-found-page.md +98 -0
  165. package/dist/cases/oauth-consent/simple.d.ts +1 -0
  166. package/dist/cases/oauth-consent/simple.jsx +73 -0
  167. package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
  168. package/dist/cases/oauth-consent/with-scope.jsx +89 -0
  169. package/dist/cases/oauth-consent.md +233 -0
  170. package/dist/cases/rename/inline.d.ts +1 -0
  171. package/dist/cases/rename/inline.jsx +58 -0
  172. package/dist/cases/rename/modal.d.ts +1 -0
  173. package/dist/cases/rename/modal.jsx +70 -0
  174. package/dist/cases/rename.md +205 -0
  175. package/dist/cases/reply-feedback/thumbs.d.ts +1 -0
  176. package/dist/cases/reply-feedback/thumbs.jsx +191 -0
  177. package/dist/cases/reply-feedback/with-reason.d.ts +1 -0
  178. package/dist/cases/reply-feedback/with-reason.jsx +221 -0
  179. package/dist/cases/reply-feedback.md +552 -0
  180. package/dist/cases/reply-sources/cards.d.ts +1 -0
  181. package/dist/cases/reply-sources/cards.jsx +83 -0
  182. package/dist/cases/reply-sources/tag-only.d.ts +1 -0
  183. package/dist/cases/reply-sources/tag-only.jsx +45 -0
  184. package/dist/cases/reply-sources.md +247 -0
  185. package/dist/cases/route-loading/full-screen.d.ts +1 -0
  186. package/dist/cases/route-loading/full-screen.jsx +8 -0
  187. package/dist/cases/route-loading/region.d.ts +1 -0
  188. package/dist/cases/route-loading/region.jsx +26 -0
  189. package/dist/cases/route-loading.md +84 -0
  190. package/dist/cases/set-new-password/form.d.ts +1 -0
  191. package/dist/cases/set-new-password/form.jsx +130 -0
  192. package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
  193. package/dist/cases/set-new-password/invalid-link.jsx +50 -0
  194. package/dist/cases/set-new-password.md +247 -0
  195. package/dist/cases/sign-up-page/centered.d.ts +1 -0
  196. package/dist/cases/sign-up-page/centered.jsx +124 -0
  197. package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
  198. package/dist/cases/sign-up-page/provider-first.jsx +124 -0
  199. package/dist/cases/sign-up-page/split.d.ts +1 -0
  200. package/dist/cases/sign-up-page/split.jsx +134 -0
  201. package/dist/cases/sign-up-page.md +478 -0
  202. package/dist/cases/slash-command-list/in-composer.d.ts +1 -0
  203. package/dist/cases/slash-command-list/in-composer.jsx +162 -0
  204. package/dist/cases/slash-command-list.md +247 -0
  205. package/dist/cases/success-feedback.md +35 -0
  206. package/dist/cases/type-to-confirm/inline.d.ts +1 -0
  207. package/dist/cases/type-to-confirm/inline.jsx +69 -0
  208. package/dist/cases/type-to-confirm/modal.d.ts +1 -0
  209. package/dist/cases/type-to-confirm/modal.jsx +73 -0
  210. package/dist/cases/type-to-confirm.md +222 -0
  211. package/dist/cases/typing-and-status/line.d.ts +1 -0
  212. package/dist/cases/typing-and-status/line.jsx +50 -0
  213. package/dist/cases/typing-and-status.md +96 -0
  214. package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
  215. package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
  216. package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
  217. package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
  218. package/dist/cases/unsaved-changes-guard.md +239 -0
  219. package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
  220. package/dist/cases/upgrade-prompt/inline.jsx +52 -0
  221. package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
  222. package/dist/cases/upgrade-prompt/modal.jsx +43 -0
  223. package/dist/cases/upgrade-prompt.md +174 -0
  224. package/dist/cases.json +3138 -59
  225. package/dist/components/alert.d.ts +3 -1
  226. package/dist/components/alert.jsx +6 -4
  227. package/dist/components/button.d.ts +3 -2
  228. package/dist/components/button.jsx +9 -7
  229. package/dist/components/composer.d.ts +74 -0
  230. package/dist/components/composer.jsx +122 -0
  231. package/dist/components/emptyBox.d.ts +6 -1
  232. package/dist/components/emptyBox.jsx +4 -2
  233. package/dist/components/fileChip.d.ts +33 -0
  234. package/dist/components/fileChip.jsx +61 -0
  235. package/dist/components/heading.d.ts +2 -2
  236. package/dist/components/iconButton.d.ts +3 -3
  237. package/dist/components/iconButton.jsx +9 -7
  238. package/dist/components/layout.d.ts +7 -1
  239. package/dist/components/layout.jsx +5 -2
  240. package/dist/components/loadingScreen.d.ts +5 -1
  241. package/dist/components/loadingScreen.jsx +4 -2
  242. package/dist/components/menu.d.ts +21 -0
  243. package/dist/components/menu.jsx +27 -3
  244. package/dist/components/menuItem.d.ts +9 -1
  245. package/dist/components/menuItem.jsx +5 -4
  246. package/dist/components/message.d.ts +28 -0
  247. package/dist/components/message.jsx +25 -0
  248. package/dist/components/modal.d.ts +2 -1
  249. package/dist/components/modal.jsx +20 -8
  250. package/dist/components/paragraph.d.ts +3 -1
  251. package/dist/components/paragraph.jsx +2 -2
  252. package/dist/components/popover.d.ts +7 -1
  253. package/dist/components/popover.jsx +35 -9
  254. package/dist/components/radioGroup.d.ts +9 -1
  255. package/dist/components/radioGroup.jsx +20 -9
  256. package/dist/components/select.d.ts +2 -1
  257. package/dist/components/select.jsx +4 -2
  258. package/dist/components/sourceCard.d.ts +23 -0
  259. package/dist/components/sourceCard.jsx +56 -0
  260. package/dist/components/stepList.d.ts +17 -0
  261. package/dist/components/stepList.jsx +79 -0
  262. package/dist/components/tab.jsx +3 -2
  263. package/dist/components/tabsContainer.d.ts +4 -1
  264. package/dist/components/tabsContainer.jsx +7 -3
  265. package/dist/components/tag.d.ts +9 -1
  266. package/dist/components/tag.jsx +6 -4
  267. package/dist/components/textField.d.ts +5 -1
  268. package/dist/components/textField.jsx +7 -3
  269. package/dist/components/textarea.jsx +3 -18
  270. package/dist/components/toaster.d.ts +12 -0
  271. package/dist/components/toaster.jsx +103 -0
  272. package/dist/components/userImage.d.ts +9 -1
  273. package/dist/components/userImage.jsx +10 -3
  274. package/dist/internal/alert.d.ts +4 -0
  275. package/dist/internal/alert.js +6 -0
  276. package/dist/internal/autoGrow.d.ts +11 -0
  277. package/dist/internal/autoGrow.js +28 -0
  278. package/dist/internal/composer.d.ts +16 -0
  279. package/dist/internal/composer.js +18 -0
  280. package/dist/internal/menu.d.ts +6 -0
  281. package/dist/internal/menu.js +31 -0
  282. package/dist/internal/modal.d.ts +2 -0
  283. package/dist/internal/modal.js +21 -0
  284. package/dist/internal/toaster.d.ts +19 -0
  285. package/dist/internal/toaster.js +50 -0
  286. package/dist/native-mapping.json +38 -1
  287. package/dist/stories/Alert.stories.d.ts +1 -0
  288. package/dist/stories/Alert.stories.jsx +16 -0
  289. package/dist/stories/Button.stories.d.ts +1 -0
  290. package/dist/stories/Button.stories.jsx +17 -1
  291. package/dist/stories/Cases.generated.stories.d.ts +82 -0
  292. package/dist/stories/Cases.generated.stories.jsx +164 -0
  293. package/dist/stories/Composer.stories.d.ts +23 -0
  294. package/dist/stories/Composer.stories.jsx +121 -0
  295. package/dist/stories/EmptyBox.stories.d.ts +2 -0
  296. package/dist/stories/EmptyBox.stories.jsx +16 -0
  297. package/dist/stories/FileChip.stories.d.ts +7 -0
  298. package/dist/stories/FileChip.stories.jsx +35 -0
  299. package/dist/stories/Heading.stories.d.ts +6 -0
  300. package/dist/stories/Heading.stories.jsx +10 -0
  301. package/dist/stories/IconButton.stories.d.ts +1 -0
  302. package/dist/stories/IconButton.stories.jsx +18 -1
  303. package/dist/stories/LoadingScreen.stories.d.ts +1 -0
  304. package/dist/stories/LoadingScreen.stories.jsx +8 -0
  305. package/dist/stories/Menu.stories.d.ts +4 -0
  306. package/dist/stories/Menu.stories.jsx +46 -1
  307. package/dist/stories/MenuItem.stories.d.ts +1 -0
  308. package/dist/stories/MenuItem.stories.jsx +8 -0
  309. package/dist/stories/Message.stories.d.ts +10 -0
  310. package/dist/stories/Message.stories.jsx +77 -0
  311. package/dist/stories/Modal.stories.d.ts +2 -0
  312. package/dist/stories/Modal.stories.jsx +36 -0
  313. package/dist/stories/PageComponents.stories.d.ts +1 -0
  314. package/dist/stories/PageComponents.stories.jsx +21 -0
  315. package/dist/stories/RadioGroup.stories.d.ts +3 -0
  316. package/dist/stories/RadioGroup.stories.jsx +54 -1
  317. package/dist/stories/Select.stories.d.ts +1 -0
  318. package/dist/stories/Select.stories.jsx +14 -0
  319. package/dist/stories/SourceCard.stories.d.ts +8 -0
  320. package/dist/stories/SourceCard.stories.jsx +33 -0
  321. package/dist/stories/StepList.stories.d.ts +8 -0
  322. package/dist/stories/StepList.stories.jsx +35 -0
  323. package/dist/stories/TabsContainer.stories.d.ts +1 -0
  324. package/dist/stories/TabsContainer.stories.jsx +12 -0
  325. package/dist/stories/TextField.stories.d.ts +2 -0
  326. package/dist/stories/TextField.stories.jsx +22 -0
  327. package/dist/stories/Toaster.stories.d.ts +6 -0
  328. package/dist/stories/Toaster.stories.jsx +29 -0
  329. package/dist/stories/UserImage.stories.d.ts +2 -0
  330. package/dist/stories/UserImage.stories.jsx +19 -0
  331. package/package.json +4 -3
@@ -0,0 +1,247 @@
1
+ # Command list
2
+
3
+ A person types / at the start of the message box to run a command.
4
+
5
+ **Not built yet:** Scindo on the web builds its list from buttons, so a screen reader in the field does not hear which command is highlighted. Both Scindo apps run a command with no argument as soon as it is picked.
6
+
7
+ ## Do
8
+
9
+ - Open the list when the text starts with /. A bare / opens it, each letter after it narrows it, and a space closes it.
10
+ - Show at most 8 commands. Typing more letters finds the rest.
11
+ - Build it as a combobox. The text area gets `role="combobox"`, `aria-expanded`, `aria-controls` and `aria-activedescendant`, and the list in `above` is a `Menu role="listbox"` of `MenuItem role="option"` rows with `isActive` and `aria-selected`.
12
+ - Show each command with one line on what it does, and the argument it takes, such as '[topic]'. A menu row has no code font yet, so the command is plain text.
13
+ - Keep focus in the message box while the list is open, so the person keeps typing.
14
+ - Use the same keys as the case 'Mention list': the arrows move, Enter or Tab picks, Escape closes.
15
+ - Leave Enter and the arrow keys to an input method while it is still composing, such as for Korean or Japanese.
16
+ - Close the list when the caret moves out of the command being typed, and when focus leaves the message box.
17
+ - Check the word at the caret again on Enter or Tab, and pick only if a command still matches. Shift+Tab picks nothing.
18
+ - Put the command and a space in place of the '/word' before the caret, and keep the text after it.
19
+ - Put the caret after that space, so the person can type the argument.
20
+ - Run the command when the person sends it. Every command works this way, even one that takes no argument.
21
+ - Close the list when no command matches.
22
+
23
+ ## Don't
24
+
25
+ - Do not move focus into the list. The person keeps typing in the field.
26
+ - Do not run a command on the Enter that picks it.
27
+ - Do not show an empty list.
28
+ - Do not open the list for a / in the middle of the text.
29
+
30
+ ## Example: List in the composer
31
+
32
+ Uses: `Center`, `Composer`, `Heading`, `Menu`, `MenuItem`, `Message`, `Paragraph`, `Stack`, `TimeStamp`, `UserImage`
33
+
34
+ ```tsx
35
+ 'use client';
36
+ import { useEffect, useRef, useState, type KeyboardEvent, type SyntheticEvent } from 'react';
37
+ import Message from 'oneslash-design-system/components/message';
38
+ import UserImage from 'oneslash-design-system/components/userImage';
39
+ import TimeStamp from 'oneslash-design-system/components/timeStamp';
40
+ import Heading from 'oneslash-design-system/components/heading';
41
+ import Paragraph from 'oneslash-design-system/components/paragraph';
42
+ import Composer from 'oneslash-design-system/components/composer';
43
+ import Menu from 'oneslash-design-system/components/menu';
44
+ import MenuItem from 'oneslash-design-system/components/menuItem';
45
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
46
+
47
+ // A real app reads this from the session.
48
+ const me = 'Dana Lee';
49
+
50
+ type Command = { name: string; does: string; argument?: string };
51
+ const commands: Command[] = [
52
+ { name: 'plan', does: 'Ask the agent for a plan before it acts' },
53
+ { name: 'summarize', does: 'Sum up this thread', argument: '[topic]' },
54
+ { name: 'remind', does: 'Set a reminder for this thread', argument: '[time]' },
55
+ { name: 'status', does: 'Show what the agent is working on' },
56
+ ];
57
+
58
+ const listId = 'slash-command-list-commands';
59
+ // The list shows at most this many commands; typing more letters narrows it.
60
+ const MAX_MATCHES = 8;
61
+ const optionId = (c: Command) => `slash-command-list-option-${c.name}`;
62
+
63
+ type Row = { id: string; from: string; at: Date; text: string; command?: boolean };
64
+
65
+ const firstThread: Row[] = [
66
+ { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The pricing page is live.' },
67
+ { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'I missed the morning. What did we decide?' },
68
+ ];
69
+
70
+ // Opens with a / typed, so the list shows every command.
71
+ const firstText = '/';
72
+
73
+ // The word after a / at the start of the text before the caret, or null once there is a space or no /.
74
+ function commandQuery(before: string) {
75
+ const match = before.match(/^\/(\S*)$/);
76
+ return match ? match[1] : null;
77
+ }
78
+
79
+ // The query for where the caret is now.
80
+ function queryAtCaret(field: HTMLTextAreaElement) {
81
+ return commandQuery(field.value.slice(0, field.selectionStart ?? field.value.length));
82
+ }
83
+
84
+ const matches = (query: string) => commands.filter((c) => c.name.startsWith(query.toLowerCase())).slice(0, MAX_MATCHES);
85
+
86
+ export default function SlashCommandListInComposer() {
87
+ const [thread, setThread] = useState(firstThread);
88
+ const [text, setText] = useState(firstText);
89
+ const [query, setQuery] = useState<string | null>(commandQuery(firstText));
90
+ const [active, setActive] = useState(0);
91
+ // Where the caret goes after a pick; the effect below puts it there once the new text is in the field.
92
+ const [caret, setCaret] = useState<number | null>(null);
93
+ const field = useRef<HTMLTextAreaElement>(null);
94
+
95
+ const results = query === null ? [] : matches(query);
96
+ // No match: the list closes.
97
+ const open = results.length > 0;
98
+
99
+ // The field opens with the caret at the end, after the /.
100
+ useEffect(() => {
101
+ const end = field.current?.value.length ?? 0;
102
+ field.current?.setSelectionRange(end, end);
103
+ }, []);
104
+
105
+ useEffect(() => {
106
+ if (caret === null || !field.current) return;
107
+ field.current.focus();
108
+ field.current.setSelectionRange(caret, caret);
109
+ setCaret(null);
110
+ }, [caret]);
111
+
112
+ function change(value: string) {
113
+ setText(value);
114
+ const at = field.current?.selectionStart ?? value.length;
115
+ setQuery(commandQuery(value.slice(0, at)));
116
+ setActive(0);
117
+ }
118
+
119
+ // The caret moved (an arrow key, a click, Home or End): the list follows the word at the caret, and
120
+ // closes when the caret leaves it.
121
+ function caretMoved(e: SyntheticEvent<HTMLTextAreaElement>) {
122
+ const next = queryAtCaret(e.currentTarget);
123
+ if (next === query) return;
124
+ setQuery(next);
125
+ setActive(0);
126
+ }
127
+
128
+ // Puts '/name ' in place of the '/word' before the caret and keeps the text after it. The caret goes
129
+ // after the space, so the person can type the argument. Nothing runs yet.
130
+ function pick(c: Command) {
131
+ const at = field.current?.selectionStart ?? text.length;
132
+ const insert = `/${c.name} `;
133
+ // One space between the command and what follows, not two.
134
+ const after = text.slice(at).replace(/^ /, '');
135
+ setText(insert + after);
136
+ setQuery(null);
137
+ setCaret(insert.length);
138
+ }
139
+
140
+ // While the list is open it takes the arrows, Enter, Tab and Escape, so Enter picks instead of sending.
141
+ function keyDown(e: KeyboardEvent<HTMLTextAreaElement>) {
142
+ // An input method (Korean, Japanese, Chinese) uses Enter and the arrows while it composes: leave them to it.
143
+ if (e.nativeEvent.isComposing || e.keyCode === 229) return;
144
+ if (!open) return;
145
+ if (e.key === 'ArrowDown') {
146
+ e.preventDefault();
147
+ setActive((i) => Math.min(i + 1, results.length - 1));
148
+ } else if (e.key === 'ArrowUp') {
149
+ e.preventDefault();
150
+ setActive((i) => Math.max(i - 1, 0));
151
+ } else if (e.key === 'Enter' || (e.key === 'Tab' && !e.shiftKey)) {
152
+ // Check the word at the caret again before taking the key. If nothing matches now, the list
153
+ // closes and the key does what it always does: Enter sends, Tab moves on. Shift+Tab is never a pick.
154
+ const now = queryAtCaret(e.currentTarget);
155
+ const found = now === null ? [] : matches(now);
156
+ if (found.length === 0) {
157
+ setQuery(null);
158
+ return;
159
+ }
160
+ e.preventDefault();
161
+ pick(found[now === query ? Math.min(active, found.length - 1) : 0]);
162
+ } else if (e.key === 'Escape') {
163
+ e.preventDefault();
164
+ e.stopPropagation();
165
+ setQuery(null);
166
+ }
167
+ }
168
+
169
+ // A real app runs the command here. This one shows it in the thread.
170
+ function send() {
171
+ const value = text.trim();
172
+ setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: value, command: value.startsWith('/') }]);
173
+ setText('');
174
+ setQuery(null);
175
+ }
176
+
177
+ return (
178
+ <Center width="page">
179
+ <Stack gap="large">
180
+ <Heading level={1} size="h5">Launch plan</Heading>
181
+ {/* A real app gives the list that holds the rows role="log". */}
182
+ <Stack gap="small">
183
+ {thread.map((m) => (
184
+ <Message
185
+ key={m.id}
186
+ aria-label={m.from}
187
+ avatar={<UserImage userHandle={m.from} decorative />}
188
+ name={m.from}
189
+ meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
190
+ >
191
+ <Paragraph measure="none" mono={m.command}>{m.text}</Paragraph>
192
+ </Message>
193
+ ))}
194
+ </Stack>
195
+ <Composer
196
+ ref={field}
197
+ id="slash-command-list-message"
198
+ aria-label="Message"
199
+ placeholder="Message the team, or type / for commands"
200
+ value={text}
201
+ onChange={change}
202
+ onSubmit={send}
203
+ onKeyDown={keyDown}
204
+ onSelect={caretMoved}
205
+ // A press on a row keeps focus in the field, so this runs only when focus leaves for good.
206
+ onBlur={() => setQuery(null)}
207
+ // Focus stays in the field; the field points at the list and at the highlighted row.
208
+ role="combobox"
209
+ aria-autocomplete="list"
210
+ aria-expanded={open}
211
+ aria-controls={open ? listId : undefined}
212
+ aria-activedescendant={open ? optionId(results[active]) : undefined}
213
+ above={
214
+ open ? (
215
+ <Menu role="listbox" id={listId} aria-label="Commands" width={400}>
216
+ {results.map((c, i) => (
217
+ <MenuItem
218
+ key={c.name}
219
+ id={optionId(c)}
220
+ role="option"
221
+ tabIndex={-1}
222
+ isActive={i === active}
223
+ aria-selected={i === active}
224
+ size="small"
225
+ iconName="SquareSlash"
226
+ // MenuItem has no mono label, so the command is plain text.
227
+ label={`/${c.name}`}
228
+ secondLabel={c.does}
229
+ tag={c.argument ? { label: c.argument, variant: 'textOnly' } : undefined}
230
+ onClick={() => pick(c)}
231
+ />
232
+ ))}
233
+ </Menu>
234
+ ) : undefined
235
+ }
236
+ />
237
+ </Stack>
238
+ </Center>
239
+ );
240
+ }
241
+ ```
242
+
243
+ ## Native
244
+
245
+ On Apple the list shows above the field with the command, what it does and, when it takes an argument, its usage. Escape closes the list on a Mac.
246
+
247
+ Seen in: Scindo.
@@ -0,0 +1,35 @@
1
+ # Success shows where the person is looking
2
+
3
+ Something the person did has worked.
4
+
5
+ ## Answer
6
+
7
+ The feedback depends on where the result shows. A Button that is `loading` keeps its label, and the spinner shows that it is working. Only success changes a label, and there are three success labels: 'Saved', 'Copied' and 'Sent', each for 2 seconds. When a form saves in place, its Button is `loading`, then reads 'Saved' for 2 seconds, then its own label again. There is no toast. Sometimes the result is somewhere else or gone. Something was deleted, sent, moved or duplicated somewhere else, or a long job has finished. Then call `toast({ type: 'success', message: '…' })` with one short sentence in the past tense, in sentence case. It closes after 5 seconds. When something is copied to the clipboard, a Button reads 'Copied' for 2 seconds, and an IconButton swaps its icon to `Check` for 2 seconds. When Copy is a menu item, the menu closes, so a toast says 'Message copied.' instead. When a Button sends an email again, it reads 'Sent' for 2 seconds. The message names the thing and does not say 'successfully'.
8
+
9
+ **Not built yet:** Scindo on the web has no toast. It shows success in five ways: a 'Saved' Button label, a green caption, an inline Alert, a thank-you that replaces a dialog and a 'Copied' label. The timed ones clear after 1.5, 2, 3 or 4 seconds. Commentify shows toasts through `Alert`, one at a time, and many of them say 'successfully'.
10
+
11
+ ## Why
12
+
13
+ Feedback belongs where the person is looking. A change they can see needs only a word on the Button, and a result they cannot see needs a short message that names it.
14
+
15
+ ## Do
16
+
17
+ - Show `loading` on the Button while a form saves, then 'Saved' for 2 seconds.
18
+ - Write a toast as one short sentence in the past tense that names the thing: 'Invite sent to Dana.'
19
+ - Show 'Copied' on a copy Button, or the `Check` icon on a copy IconButton, for 2 seconds.
20
+ - Show 'Sent' for 2 seconds on a Button that sends an email again, such as 'Send Again'.
21
+ - Mount one `Toaster` near the app root, and show every toast with `toast()`.
22
+
23
+ ## Don't
24
+
25
+ - Do not say 'successfully'.
26
+ - Do not change a Button's label while it is loading, such as to 'Saving…' or 'Deleting…'.
27
+ - Do not show a toast for a change the person can already see.
28
+ - Do not build a toast from `Alert`. Use `toast()`.
29
+ - Do not make the person close a success message.
30
+
31
+ ## Native
32
+
33
+ On Apple there is no toast. Show the result in place.
34
+
35
+ Seen in: Commentify, Scindo.
@@ -0,0 +1 @@
1
+ export default function TypeToConfirmInline(): import("react").JSX.Element;
@@ -0,0 +1,69 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Surface from '../../components/surface';
4
+ import Heading from '../../components/heading';
5
+ import Paragraph from '../../components/paragraph';
6
+ import TextField from '../../components/textField';
7
+ import Button from '../../components/button';
8
+ import { Center, Cluster, Stack } from '../../components/layout';
9
+ // An account has no name to type, so the person types a fixed word.
10
+ var word = 'DELETE';
11
+ export default function TypeToConfirmInline() {
12
+ // Opens with the field showing, as if the person just chose Delete Account.
13
+ var _a = useState(true), confirming = _a[0], setConfirming = _a[1];
14
+ var _b = useState(''), typed = _b[0], setTyped = _b[1];
15
+ var _c = useState(false), deleting = _c[0], setDeleting = _c[1];
16
+ var _d = useState(false), deleted = _d[0], setDeleted = _d[1];
17
+ var timer = useRef();
18
+ // Stops the request if the example goes away before it ends.
19
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
20
+ // An exact match, with case. Pasting the word is fine.
21
+ var matches = typed === word;
22
+ function handleCancel() {
23
+ setConfirming(false);
24
+ setTyped('');
25
+ }
26
+ function handleDelete() {
27
+ if (deleting || !matches)
28
+ return;
29
+ setDeleting(true);
30
+ // Stands in for the request to the server.
31
+ timer.current = setTimeout(function () {
32
+ setDeleting(false);
33
+ setDeleted(true);
34
+ }, 1200);
35
+ }
36
+ // The account is gone, so the page that showed it is gone too.
37
+ if (deleted) {
38
+ return (<Center fill>
39
+ <Heading level={1} size="h5">Your account is deleted</Heading>
40
+ <Paragraph tone="secondary" measure="none">We sent a note to ada@example.com to say so.</Paragraph>
41
+ </Center>);
42
+ }
43
+ return (<Center width="page">
44
+ <Stack gap="xlarge">
45
+ <Heading level={1} size="h5">Account settings</Heading>
46
+ <Surface padding="large">
47
+ <Stack gap="medium">
48
+ <Heading level={2} size="h6">Profile</Heading>
49
+ <Paragraph size="body2" measure="none">Ada Brooks, ada@example.com</Paragraph>
50
+ </Stack>
51
+ </Surface>
52
+ <Surface padding="large">
53
+ <Stack gap="medium">
54
+ <Heading level={2} size="h6">Delete account</Heading>
55
+ <Paragraph size="body2" measure="none">This deletes your account, your private documents and your settings. It cannot be undone. Projects you shared stay with your team.</Paragraph>
56
+ {confirming ? (<>
57
+ <TextField id="type-to-confirm-word" label={"Type ".concat(word, " to confirm")} value={typed} disabled={deleting} onChange={function (e) { return setTyped(e.target.value); }}/>
58
+ <Cluster gap="small">
59
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancel}/>
60
+ <Button size="small" type="primary" color="danger" state={matches ? 'enabled' : 'disabled'} label="Delete Account" loading={deleting} onClickButton={handleDelete}/>
61
+ </Cluster>
62
+ </>) : (<Cluster>
63
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete Account" onClickButton={function () { return setConfirming(true); }}/>
64
+ </Cluster>)}
65
+ </Stack>
66
+ </Surface>
67
+ </Stack>
68
+ </Center>);
69
+ }
@@ -0,0 +1 @@
1
+ export default function TypeToConfirmModal(): import("react").JSX.Element;
@@ -0,0 +1,73 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
4
+ import Modal from '../../components/modal';
5
+ import Surface from '../../components/surface';
6
+ import Heading from '../../components/heading';
7
+ import Paragraph from '../../components/paragraph';
8
+ import List from '../../components/list';
9
+ import TextField from '../../components/textField';
10
+ import Button from '../../components/button';
11
+ import { Center, Cluster, Stack } from '../../components/layout';
12
+ var workspace = 'Acme Design';
13
+ var otherWorkspaces = ['Acme Marketing', 'Acme Support'];
14
+ export default function TypeToConfirmModal() {
15
+ // Opens on the confirm, as if the person just chose Delete Workspace.
16
+ var _a = useState(true), open = _a[0], setOpen = _a[1];
17
+ var _b = useState(''), typed = _b[0], setTyped = _b[1];
18
+ var _c = useState(false), deleting = _c[0], setDeleting = _c[1];
19
+ var _d = useState(false), deleted = _d[0], setDeleted = _d[1];
20
+ var timer = useRef();
21
+ var toastIds = useRef([]);
22
+ // On unmount it stops the request and closes every toast it opened.
23
+ useEffect(function () { return function () {
24
+ clearTimeout(timer.current);
25
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
26
+ toastIds.current = [];
27
+ }; }, []);
28
+ // An exact match, with case. Pasting the name is fine.
29
+ var matches = typed === workspace;
30
+ // Escape, a click outside and Cancel all close it, except while the request runs.
31
+ function handleClose() {
32
+ if (deleting)
33
+ return;
34
+ setOpen(false);
35
+ setTyped('');
36
+ }
37
+ function handleDelete() {
38
+ if (deleting || !matches)
39
+ return;
40
+ setDeleting(true);
41
+ // Stands in for the request to the server.
42
+ timer.current = setTimeout(function () {
43
+ setDeleting(false);
44
+ setOpen(false);
45
+ setDeleted(true);
46
+ toastIds.current.push(toast({ type: 'success', message: "Workspace '".concat(workspace, "' deleted.") }));
47
+ }, 1200);
48
+ }
49
+ return (<Center width="page">
50
+ {/* A real app mounts one Toaster near its root. */}
51
+ <Toaster />
52
+ {deleted ? (<Stack gap="large">
53
+ <Heading level={2} size="h5">Workspaces</Heading>
54
+ <Surface padding="large">
55
+ <List items={otherWorkspaces} size="body1"/>
56
+ </Surface>
57
+ </Stack>) : (<Stack gap="medium">
58
+ <Heading level={2} size="h5">{workspace}</Heading>
59
+ <Paragraph tone="secondary" size="body2" measure="none">6 members and 14 channels.</Paragraph>
60
+ <Cluster>
61
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete Workspace" onClickButton={function () { return setOpen(true); }}/>
62
+ </Cluster>
63
+ </Stack>)}
64
+ <Modal isOpen={open} size="small" initialFocus="body" title="Delete Workspace" onClose={handleClose} actions={<>
65
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
66
+ <Button size="small" type="primary" color="danger" state={matches ? 'enabled' : 'disabled'} label="Delete" loading={deleting} onClickButton={handleDelete}/>
67
+ </>}>
68
+ <Paragraph measure="none">This deletes the workspace &apos;{workspace}&apos; with its 14 channels, tasks and messages. It cannot be undone.</Paragraph>
69
+ <Paragraph tone="secondary" size="body2" measure="none">Members keep their Acme accounts.</Paragraph>
70
+ <TextField id="type-to-confirm-name" label={"Type ".concat(workspace, " to confirm")} value={typed} disabled={deleting} onChange={function (e) { return setTyped(e.target.value); }}/>
71
+ </Modal>
72
+ </Center>);
73
+ }
@@ -0,0 +1,222 @@
1
+ # Type to confirm
2
+
3
+ A person asks to delete something large that cannot be brought back, such as a workspace or an account.
4
+
5
+ **Not built yet:** Commentify matches its phrase with any case and ignores spaces around it, and labels its Button 'Deleting…' while it runs. Scindo labels its Button 'Deleting...' on the web and on Apple. On the web its Delete Workspace Modal shows a failed request as a red caption written by hand.
6
+
7
+ ## Do
8
+
9
+ - Ask for typing only when the loss is permanent and large, such as a workspace with everything in it, or an account.
10
+ - Ask the person to type the thing's name when it has one, and a fixed word such as DELETE when it does not.
11
+ - Put the text to type in the field's label: 'Type Acme Design to confirm'.
12
+ - Keep the action Button `state="disabled"` until the typed text matches exactly.
13
+ - Match with case: 'acme design' does not match 'Acme Design'. Allow pasting the text.
14
+ - Say above the field what is deleted and what is kept.
15
+
16
+ ## Don't
17
+
18
+ - Do not ask for typing for an everyday delete. A plain confirm is enough.
19
+ - Do not block pasting into the field.
20
+ - Do not change the action's label while it is loading, such as to 'Deleting…'.
21
+ - Do not show a failed request as a red caption written by hand. Use an inline error Alert.
22
+
23
+ ## Option: Type the name in a Modal
24
+
25
+ Use when: The action starts from a menu or a row, away from a settings page.
26
+
27
+ Uses: `Button`, `Center`, `Cluster`, `Heading`, `List`, `Modal`, `Paragraph`, `Stack`, `Surface`, `TextField`, `Toaster`, `dismissToast`, `toast`
28
+
29
+ ```tsx
30
+ 'use client';
31
+ import { useEffect, useRef, useState } from 'react';
32
+ import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
33
+ import Modal from 'oneslash-design-system/components/modal';
34
+ import Surface from 'oneslash-design-system/components/surface';
35
+ import Heading from 'oneslash-design-system/components/heading';
36
+ import Paragraph from 'oneslash-design-system/components/paragraph';
37
+ import List from 'oneslash-design-system/components/list';
38
+ import TextField from 'oneslash-design-system/components/textField';
39
+ import Button from 'oneslash-design-system/components/button';
40
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
41
+
42
+ const workspace = 'Acme Design';
43
+ const otherWorkspaces = ['Acme Marketing', 'Acme Support'];
44
+
45
+ export default function TypeToConfirmModal() {
46
+ // Opens on the confirm, as if the person just chose Delete Workspace.
47
+ const [open, setOpen] = useState(true);
48
+ const [typed, setTyped] = useState('');
49
+ const [deleting, setDeleting] = useState(false);
50
+ const [deleted, setDeleted] = useState(false);
51
+ const timer = useRef<ReturnType<typeof setTimeout>>();
52
+ const toastIds = useRef<string[]>([]);
53
+
54
+ // On unmount it stops the request and closes every toast it opened.
55
+ useEffect(() => () => {
56
+ clearTimeout(timer.current);
57
+ toastIds.current.forEach((id) => dismissToast(id));
58
+ toastIds.current = [];
59
+ }, []);
60
+
61
+ // An exact match, with case. Pasting the name is fine.
62
+ const matches = typed === workspace;
63
+
64
+ // Escape, a click outside and Cancel all close it, except while the request runs.
65
+ function handleClose() {
66
+ if (deleting) return;
67
+ setOpen(false);
68
+ setTyped('');
69
+ }
70
+
71
+ function handleDelete() {
72
+ if (deleting || !matches) return;
73
+ setDeleting(true);
74
+ // Stands in for the request to the server.
75
+ timer.current = setTimeout(() => {
76
+ setDeleting(false);
77
+ setOpen(false);
78
+ setDeleted(true);
79
+ toastIds.current.push(toast({ type: 'success', message: `Workspace '${workspace}' deleted.` }));
80
+ }, 1200);
81
+ }
82
+
83
+ return (
84
+ <Center width="page">
85
+ {/* A real app mounts one Toaster near its root. */}
86
+ <Toaster />
87
+ {deleted ? (
88
+ <Stack gap="large">
89
+ <Heading level={2} size="h5">Workspaces</Heading>
90
+ <Surface padding="large">
91
+ <List items={otherWorkspaces} size="body1" />
92
+ </Surface>
93
+ </Stack>
94
+ ) : (
95
+ <Stack gap="medium">
96
+ <Heading level={2} size="h5">{workspace}</Heading>
97
+ <Paragraph tone="secondary" size="body2" measure="none">6 members and 14 channels.</Paragraph>
98
+ <Cluster>
99
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete Workspace" onClickButton={() => setOpen(true)} />
100
+ </Cluster>
101
+ </Stack>
102
+ )}
103
+ <Modal
104
+ isOpen={open}
105
+ size="small"
106
+ initialFocus="body"
107
+ title="Delete Workspace"
108
+ onClose={handleClose}
109
+ actions={
110
+ <>
111
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
112
+ <Button size="small" type="primary" color="danger" state={matches ? 'enabled' : 'disabled'} label="Delete" loading={deleting} onClickButton={handleDelete} />
113
+ </>
114
+ }
115
+ >
116
+ <Paragraph measure="none">This deletes the workspace &apos;{workspace}&apos; with its 14 channels, tasks and messages. It cannot be undone.</Paragraph>
117
+ <Paragraph tone="secondary" size="body2" measure="none">Members keep their Acme accounts.</Paragraph>
118
+ <TextField id="type-to-confirm-name" label={`Type ${workspace} to confirm`} value={typed} disabled={deleting} onChange={(e) => setTyped(e.target.value)} />
119
+ </Modal>
120
+ </Center>
121
+ );
122
+ }
123
+ ```
124
+
125
+ ## Option: Type a word in place
126
+
127
+ Use when: The action lives in a danger zone on a settings page.
128
+
129
+ Uses: `Button`, `Center`, `Cluster`, `Heading`, `Paragraph`, `Stack`, `Surface`, `TextField`
130
+
131
+ ```tsx
132
+ 'use client';
133
+ import { useEffect, useRef, useState } from 'react';
134
+ import Surface from 'oneslash-design-system/components/surface';
135
+ import Heading from 'oneslash-design-system/components/heading';
136
+ import Paragraph from 'oneslash-design-system/components/paragraph';
137
+ import TextField from 'oneslash-design-system/components/textField';
138
+ import Button from 'oneslash-design-system/components/button';
139
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
140
+
141
+ // An account has no name to type, so the person types a fixed word.
142
+ const word = 'DELETE';
143
+
144
+ export default function TypeToConfirmInline() {
145
+ // Opens with the field showing, as if the person just chose Delete Account.
146
+ const [confirming, setConfirming] = useState(true);
147
+ const [typed, setTyped] = useState('');
148
+ const [deleting, setDeleting] = useState(false);
149
+ const [deleted, setDeleted] = useState(false);
150
+ const timer = useRef<ReturnType<typeof setTimeout>>();
151
+
152
+ // Stops the request if the example goes away before it ends.
153
+ useEffect(() => () => clearTimeout(timer.current), []);
154
+
155
+ // An exact match, with case. Pasting the word is fine.
156
+ const matches = typed === word;
157
+
158
+ function handleCancel() {
159
+ setConfirming(false);
160
+ setTyped('');
161
+ }
162
+
163
+ function handleDelete() {
164
+ if (deleting || !matches) return;
165
+ setDeleting(true);
166
+ // Stands in for the request to the server.
167
+ timer.current = setTimeout(() => {
168
+ setDeleting(false);
169
+ setDeleted(true);
170
+ }, 1200);
171
+ }
172
+
173
+ // The account is gone, so the page that showed it is gone too.
174
+ if (deleted) {
175
+ return (
176
+ <Center fill>
177
+ <Heading level={1} size="h5">Your account is deleted</Heading>
178
+ <Paragraph tone="secondary" measure="none">We sent a note to ada@example.com to say so.</Paragraph>
179
+ </Center>
180
+ );
181
+ }
182
+
183
+ return (
184
+ <Center width="page">
185
+ <Stack gap="xlarge">
186
+ <Heading level={1} size="h5">Account settings</Heading>
187
+ <Surface padding="large">
188
+ <Stack gap="medium">
189
+ <Heading level={2} size="h6">Profile</Heading>
190
+ <Paragraph size="body2" measure="none">Ada Brooks, ada@example.com</Paragraph>
191
+ </Stack>
192
+ </Surface>
193
+ <Surface padding="large">
194
+ <Stack gap="medium">
195
+ <Heading level={2} size="h6">Delete account</Heading>
196
+ <Paragraph size="body2" measure="none">This deletes your account, your private documents and your settings. It cannot be undone. Projects you shared stay with your team.</Paragraph>
197
+ {confirming ? (
198
+ <>
199
+ <TextField id="type-to-confirm-word" label={`Type ${word} to confirm`} value={typed} disabled={deleting} onChange={(e) => setTyped(e.target.value)} />
200
+ <Cluster gap="small">
201
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancel} />
202
+ <Button size="small" type="primary" color="danger" state={matches ? 'enabled' : 'disabled'} label="Delete Account" loading={deleting} onClickButton={handleDelete} />
203
+ </Cluster>
204
+ </>
205
+ ) : (
206
+ <Cluster>
207
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete Account" onClickButton={() => setConfirming(true)} />
208
+ </Cluster>
209
+ )}
210
+ </Stack>
211
+ </Surface>
212
+ </Stack>
213
+ </Center>
214
+ );
215
+ }
216
+ ```
217
+
218
+ ## Native
219
+
220
+ On Apple use an `.alert` with a `TextField` in it. Put the action in the `.destructive` role and disable it until the text matches.
221
+
222
+ Seen in: Commentify, Scindo.
@@ -0,0 +1 @@
1
+ export default function TypingAndStatusLine(): import("react").JSX.Element;