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,252 @@
1
+ # Mention list
2
+
3
+ A person types @ in the message box to name someone, or the agent.
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 name is highlighted. It shows no 'Agent' tag on the agent's row.
6
+
7
+ ## Do
8
+
9
+ - Open the list when the person types @ at the start of the text or after a space. A bare @ opens it, and each letter after it narrows it.
10
+ - Show at most 8 names. 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 person's avatar and name. A person with no picture shows their initial, and the avatar is not read aloud, since the name is.
13
+ - Put the agent first, with its icon avatar and an 'Agent' tag, as the rule 'An agent says what it is' says.
14
+ - Keep focus in the message box while the list is open, so the person keeps typing.
15
+ - Move the highlight with the arrow keys. Enter or Tab picks the highlighted name, and Escape closes the list.
16
+ - Leave Enter and the arrow keys to an input method while it is still composing, such as for Korean or Japanese.
17
+ - Close the list when the caret moves out of the name being typed, and when focus leaves the message box.
18
+ - Check the word at the caret again on Enter or Tab, and pick only if a name still matches. Shift+Tab picks nothing.
19
+ - Put the name in at the caret with a space after it, and put the caret after the space.
20
+ - Close the list when no name matches.
21
+ - Leave out the person who is typing.
22
+
23
+ ## Don't
24
+
25
+ - Do not move focus into the list. The person keeps typing in the field.
26
+ - Do not send the message on the Enter that picks a name.
27
+ - Do not show an empty list.
28
+ - Do not open the list for an @ inside a word, such as in an email address.
29
+ - Do not show the agent with a photo or an initial.
30
+
31
+ ## Example: List in the composer
32
+
33
+ Uses: `Center`, `Composer`, `Heading`, `Menu`, `MenuItem`, `Message`, `Paragraph`, `Stack`, `TimeStamp`, `UserImage`
34
+
35
+ ```tsx
36
+ 'use client';
37
+ import { useEffect, useRef, useState, type KeyboardEvent, type SyntheticEvent } from 'react';
38
+ import { Bot } from 'lucide-react';
39
+ import Message from 'oneslash-design-system/components/message';
40
+ import UserImage from 'oneslash-design-system/components/userImage';
41
+ import TimeStamp from 'oneslash-design-system/components/timeStamp';
42
+ import Heading from 'oneslash-design-system/components/heading';
43
+ import Paragraph from 'oneslash-design-system/components/paragraph';
44
+ import Composer from 'oneslash-design-system/components/composer';
45
+ import Menu from 'oneslash-design-system/components/menu';
46
+ import MenuItem from 'oneslash-design-system/components/menuItem';
47
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
48
+
49
+ // A real app reads these from the session and the workspace.
50
+ const me = 'Dana Lee';
51
+ type Member = { id: string; name: string; agent?: boolean };
52
+ // The agent comes first.
53
+ const members: Member[] = [
54
+ { id: 'acme-agent', name: 'Acme Agent', agent: true },
55
+ { id: 'ben-carter', name: 'Ben Carter' },
56
+ { id: 'dana-lee', name: 'Dana Lee' },
57
+ { id: 'omar-reyes', name: 'Omar Reyes' },
58
+ ];
59
+
60
+ const listId = 'mention-list-suggestions';
61
+ // The list shows at most this many names; typing more letters narrows it.
62
+ const MAX_MATCHES = 8;
63
+ const optionId = (m: Member) => `mention-list-option-${m.id}`;
64
+
65
+ type Row = { id: string; from: string; at: Date; text: string };
66
+
67
+ const firstThread: Row[] = [
68
+ { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The pricing page is live.' },
69
+ { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Who checks the links before we announce it?' },
70
+ ];
71
+
72
+ // Opens with the person part-way through a mention, so the list shows.
73
+ const firstText = 'Can you check the links, @';
74
+
75
+ // The word after the @ that ends the text before the caret, or null when there is none. The @ starts
76
+ // the text or follows a space, so an email address such as dana@example.com opens nothing.
77
+ function mentionQuery(before: string) {
78
+ const match = before.match(/(?:^|\s)@(\w*)$/);
79
+ return match ? match[1] : null;
80
+ }
81
+
82
+ // The query for where the caret is now.
83
+ function queryAtCaret(field: HTMLTextAreaElement) {
84
+ return mentionQuery(field.value.slice(0, field.selectionStart ?? field.value.length));
85
+ }
86
+
87
+ // Names with a word that starts with what was typed, at most 8. The person typing is left out.
88
+ function matches(query: string) {
89
+ const q = query.toLowerCase();
90
+ return members.filter((m) => m.name !== me && m.name.toLowerCase().split(' ').some((w) => w.startsWith(q))).slice(0, MAX_MATCHES);
91
+ }
92
+
93
+ export default function MentionListInComposer() {
94
+ const [thread, setThread] = useState(firstThread);
95
+ const [text, setText] = useState(firstText);
96
+ const [query, setQuery] = useState<string | null>(mentionQuery(firstText));
97
+ const [active, setActive] = useState(0);
98
+ // Where the caret goes after a pick; the effect below puts it there once the new text is in the field.
99
+ const [caret, setCaret] = useState<number | null>(null);
100
+ const field = useRef<HTMLTextAreaElement>(null);
101
+
102
+ const results = query === null ? [] : matches(query);
103
+ // No match: the list closes.
104
+ const open = results.length > 0;
105
+
106
+ // The field opens with the caret at the end, after the @.
107
+ useEffect(() => {
108
+ const end = field.current?.value.length ?? 0;
109
+ field.current?.setSelectionRange(end, end);
110
+ }, []);
111
+
112
+ useEffect(() => {
113
+ if (caret === null || !field.current) return;
114
+ field.current.focus();
115
+ field.current.setSelectionRange(caret, caret);
116
+ setCaret(null);
117
+ }, [caret]);
118
+
119
+ function change(value: string) {
120
+ setText(value);
121
+ const at = field.current?.selectionStart ?? value.length;
122
+ setQuery(mentionQuery(value.slice(0, at)));
123
+ setActive(0);
124
+ }
125
+
126
+ // The caret moved (an arrow key, a click, Home or End): the list follows the word at the caret, and
127
+ // closes when the caret leaves it.
128
+ function caretMoved(e: SyntheticEvent<HTMLTextAreaElement>) {
129
+ const next = queryAtCaret(e.currentTarget);
130
+ if (next === query) return;
131
+ setQuery(next);
132
+ setActive(0);
133
+ }
134
+
135
+ // Puts '@Name ' in place of the @ and the word typed so far, and the caret after the space.
136
+ function pick(m: Member) {
137
+ const at = field.current?.selectionStart ?? text.length;
138
+ const before = text.slice(0, at);
139
+ const start = before.lastIndexOf('@');
140
+ if (start < 0) return;
141
+ const inserted = `@${m.name} `;
142
+ setText(before.slice(0, start) + inserted + text.slice(at));
143
+ setQuery(null);
144
+ setCaret(start + inserted.length);
145
+ }
146
+
147
+ // While the list is open it takes the arrows, Enter, Tab and Escape, so Enter picks instead of sending.
148
+ function keyDown(e: KeyboardEvent<HTMLTextAreaElement>) {
149
+ // An input method (Korean, Japanese, Chinese) uses Enter and the arrows while it composes: leave them to it.
150
+ if (e.nativeEvent.isComposing || e.keyCode === 229) return;
151
+ if (!open) return;
152
+ if (e.key === 'ArrowDown') {
153
+ e.preventDefault();
154
+ setActive((i) => Math.min(i + 1, results.length - 1));
155
+ } else if (e.key === 'ArrowUp') {
156
+ e.preventDefault();
157
+ setActive((i) => Math.max(i - 1, 0));
158
+ } else if (e.key === 'Enter' || (e.key === 'Tab' && !e.shiftKey)) {
159
+ // Check the word at the caret again before taking the key. If nothing matches now, the list
160
+ // closes and the key does what it always does: Enter sends, Tab moves on. Shift+Tab is never a pick.
161
+ const now = queryAtCaret(e.currentTarget);
162
+ const found = now === null ? [] : matches(now);
163
+ if (found.length === 0) {
164
+ setQuery(null);
165
+ return;
166
+ }
167
+ e.preventDefault();
168
+ pick(found[now === query ? Math.min(active, found.length - 1) : 0]);
169
+ } else if (e.key === 'Escape') {
170
+ e.preventDefault();
171
+ e.stopPropagation();
172
+ setQuery(null);
173
+ }
174
+ }
175
+
176
+ function send() {
177
+ // A real app sends the message to the server here and shows it at once.
178
+ setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);
179
+ setText('');
180
+ setQuery(null);
181
+ }
182
+
183
+ return (
184
+ <Center width="page">
185
+ <Stack gap="large">
186
+ <Heading level={1} size="h5">Launch plan</Heading>
187
+ {/* A real app gives the list that holds the rows role="log". */}
188
+ <Stack gap="small">
189
+ {thread.map((m) => (
190
+ <Message
191
+ key={m.id}
192
+ aria-label={m.from}
193
+ avatar={<UserImage userHandle={m.from} decorative />}
194
+ name={m.from}
195
+ meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
196
+ >
197
+ <Paragraph measure="none">{m.text}</Paragraph>
198
+ </Message>
199
+ ))}
200
+ </Stack>
201
+ <Composer
202
+ ref={field}
203
+ id="mention-list-message"
204
+ aria-label="Message"
205
+ placeholder="Message the team"
206
+ value={text}
207
+ onChange={change}
208
+ onSubmit={send}
209
+ onKeyDown={keyDown}
210
+ onSelect={caretMoved}
211
+ // A press on a row keeps focus in the field, so this runs only when focus leaves for good.
212
+ onBlur={() => setQuery(null)}
213
+ // Focus stays in the field; the field points at the list and at the highlighted row.
214
+ role="combobox"
215
+ aria-autocomplete="list"
216
+ aria-expanded={open}
217
+ aria-controls={open ? listId : undefined}
218
+ aria-activedescendant={open ? optionId(results[active]) : undefined}
219
+ above={
220
+ open ? (
221
+ <Menu role="listbox" id={listId} aria-label="People and agents" width={280}>
222
+ {results.map((m, i) => (
223
+ <MenuItem
224
+ key={m.id}
225
+ id={optionId(m)}
226
+ role="option"
227
+ tabIndex={-1}
228
+ isActive={i === active}
229
+ aria-selected={i === active}
230
+ size="small"
231
+ // A person may have no picture, so the avatar goes in icon: UserImage shows the initial.
232
+ icon={m.agent ? <UserImage userHandle={m.name} icon={Bot} size={20} decorative /> : <UserImage userHandle={m.name} size={20} decorative />}
233
+ label={m.name}
234
+ tag={m.agent ? { label: 'Agent' } : undefined}
235
+ onClick={() => pick(m)}
236
+ />
237
+ ))}
238
+ </Menu>
239
+ ) : undefined
240
+ }
241
+ />
242
+ </Stack>
243
+ </Center>
244
+ );
245
+ }
246
+ ```
247
+
248
+ ## Native
249
+
250
+ On Apple the list shows above the field, the agent with a sparkles icon and people with a person icon. A name is picked with a click or a tap.
251
+
252
+ Seen in: Scindo.
@@ -0,0 +1 @@
1
+ export default function MessageActionsHoverToolbar(): import("react").JSX.Element;
@@ -0,0 +1,229 @@
1
+ 'use client';
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ import { useEffect, useRef, useState } from 'react';
23
+ import { Bot } from 'lucide-react';
24
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
25
+ import Message from '../../components/message';
26
+ import UserImage from '../../components/userImage';
27
+ import Tag from '../../components/tag';
28
+ import TimeStamp from '../../components/timeStamp';
29
+ import Heading from '../../components/heading';
30
+ import Paragraph from '../../components/paragraph';
31
+ import Composer from '../../components/composer';
32
+ import Button from '../../components/button';
33
+ import IconButton from '../../components/iconButton';
34
+ import Tooltip from '../../components/tooltip';
35
+ import { Center, Cluster, Stack } from '../../components/layout';
36
+ // A real app reads this from the session.
37
+ var me = 'Dana Lee';
38
+ var firstThread = [
39
+ { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The press kit is in the shared folder.' },
40
+ { id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'I checked the press kit. Two images have no alt text.' },
41
+ { id: 'm3', from: me, at: new Date('2025-01-15T11:44:00Z'), text: 'Thanks. I will add the alt text today.' },
42
+ ];
43
+ export default function MessageActionsHoverToolbar() {
44
+ var _a = useState(firstThread), thread = _a[0], setThread = _a[1];
45
+ var _b = useState(''), text = _b[0], setText = _b[1];
46
+ var _c = useState(null), copiedId = _c[0], setCopiedId = _c[1];
47
+ var _d = useState(null), editingId = _d[0], setEditingId = _d[1];
48
+ var _e = useState(''), draft = _e[0], setDraft = _e[1];
49
+ var _f = useState(false), saving = _f[0], setSaving = _f[1];
50
+ // The row whose footer asks to confirm the delete. One row at a time.
51
+ var _g = useState(null), confirmingId = _g[0], setConfirmingId = _g[1];
52
+ var _h = useState(false), deleting = _h[0], setDeleting = _h[1];
53
+ var copyTimer = useRef();
54
+ // One timer per request, so a save and a delete never clear each other's.
55
+ var saveTimer = useRef();
56
+ var deleteTimer = useRef();
57
+ var toastIds = useRef([]);
58
+ var field = useRef(null);
59
+ var box = useRef(null);
60
+ var cancelDelete = useRef(null);
61
+ // Each row's buttons by row id, so focus can move to one when the thing that had it is gone.
62
+ var reactButtons = useRef({});
63
+ var editButtons = useRef({});
64
+ var deleteButtons = useRef({});
65
+ // Where focus goes after the next render, once the element it goes to is on screen.
66
+ var focusNext = useRef();
67
+ // The clipboard answers later; by then the example may be gone.
68
+ var mounted = useRef(true);
69
+ // On unmount it stops the timers and closes every toast it opened.
70
+ useEffect(function () { return function () {
71
+ mounted.current = false;
72
+ clearTimeout(copyTimer.current);
73
+ clearTimeout(saveTimer.current);
74
+ clearTimeout(deleteTimer.current);
75
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
76
+ toastIds.current = [];
77
+ }; }, []);
78
+ useEffect(function () {
79
+ var move = focusNext.current;
80
+ focusNext.current = undefined;
81
+ move === null || move === void 0 ? void 0 : move();
82
+ });
83
+ var editingRow = thread.find(function (m) { return m.id === editingId; });
84
+ var canSave = !!editingRow && draft.trim() !== '' && draft.trim() !== editingRow.text;
85
+ // A real app opens its reaction picker here; this one adds or removes a thumbs-up.
86
+ function react(id) {
87
+ setThread(function (rows) { return rows.map(function (m) { return (m.id === id ? __assign(__assign({}, m), { reacted: !m.reacted }) : m); }); });
88
+ }
89
+ function copy(m) {
90
+ var _a;
91
+ (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(m.text).then(function () {
92
+ if (!mounted.current)
93
+ return;
94
+ setCopiedId(m.id);
95
+ clearTimeout(copyTimer.current);
96
+ copyTimer.current = setTimeout(function () { return setCopiedId(null); }, 2000);
97
+ }, function () { });
98
+ }
99
+ // The field takes focus, with the caret after the text.
100
+ function startEditing(m) {
101
+ setDraft(m.text);
102
+ setEditingId(m.id);
103
+ focusNext.current = function () {
104
+ var _a, _b, _c, _d;
105
+ var end = (_b = (_a = field.current) === null || _a === void 0 ? void 0 : _a.value.length) !== null && _b !== void 0 ? _b : 0;
106
+ (_c = field.current) === null || _c === void 0 ? void 0 : _c.focus();
107
+ (_d = field.current) === null || _d === void 0 ? void 0 : _d.setSelectionRange(end, end);
108
+ };
109
+ }
110
+ // The field that had focus is gone, so focus goes to the row's Edit button.
111
+ function stopEditing(id) {
112
+ setEditingId(null);
113
+ focusNext.current = function () { var _a; return (_a = editButtons.current[id]) === null || _a === void 0 ? void 0 : _a.focus(); };
114
+ }
115
+ function cancelEditing() {
116
+ if (saving || !editingId)
117
+ return;
118
+ stopEditing(editingId);
119
+ }
120
+ function save() {
121
+ if (saving || !canSave || !editingId)
122
+ return;
123
+ var id = editingId;
124
+ var value = draft.trim();
125
+ setSaving(true);
126
+ // Stands in for the request to the server.
127
+ saveTimer.current = setTimeout(function () {
128
+ setSaving(false);
129
+ setThread(function (rows) { return rows.map(function (m) { return (m.id === id ? __assign(__assign({}, m), { text: value, edited: true }) : m); }); });
130
+ stopEditing(id);
131
+ }, 1200);
132
+ }
133
+ // The confirm opens in the row's footer, with focus on 'Cancel'.
134
+ function askToDelete(id) {
135
+ setConfirmingId(id);
136
+ focusNext.current = function () { var _a; return (_a = cancelDelete.current) === null || _a === void 0 ? void 0 : _a.focus(); };
137
+ }
138
+ // 'Cancel' goes away with the confirm, so focus goes back to the row's Delete button.
139
+ function keepMessage() {
140
+ if (deleting || !confirmingId)
141
+ return;
142
+ var id = confirmingId;
143
+ setConfirmingId(null);
144
+ focusNext.current = function () { var _a; return (_a = deleteButtons.current[id]) === null || _a === void 0 ? void 0 : _a.focus(); };
145
+ }
146
+ function confirmDelete() {
147
+ if (deleting || !confirmingId)
148
+ return;
149
+ var id = confirmingId;
150
+ var next = thread[thread.findIndex(function (m) { return m.id === id; }) + 1];
151
+ setDeleting(true);
152
+ // Stands in for the request to the server.
153
+ deleteTimer.current = setTimeout(function () {
154
+ setDeleting(false);
155
+ setConfirmingId(null);
156
+ setThread(function (rows) { return rows.filter(function (m) { return m.id !== id; }); });
157
+ toastIds.current.push(toast({ type: 'success', message: 'Message deleted.' }));
158
+ // The row is gone: focus goes to the next row's first action, or to the message box when none follows.
159
+ // If the next row's button is not on screen, focus goes to the message box.
160
+ focusNext.current = function () { var _a, _b; return (_b = ((_a = (next ? reactButtons.current[next.id] : null)) !== null && _a !== void 0 ? _a : box.current)) === null || _b === void 0 ? void 0 : _b.focus(); };
161
+ }, 1200);
162
+ }
163
+ function send() {
164
+ // A real app sends the message to the server here and shows it at once.
165
+ setThread(function (rows) { return __spreadArray(__spreadArray([], rows, true), [{ id: "m".concat(rows.length + 1), from: me, at: new Date(), text: text.trim() }], false); });
166
+ setText('');
167
+ }
168
+ return (<Center width="page">
169
+ {/* A real app mounts one Toaster near its root. */}
170
+ <Toaster />
171
+ <Stack gap="large">
172
+ <Heading level={1} size="h5">Launch plan</Heading>
173
+ {/* A real app gives the list that holds the rows role="log". */}
174
+ <Stack gap="small">
175
+ {thread.map(function (m) {
176
+ var own = m.from === me;
177
+ var editing = m.id === editingId;
178
+ var confirming = m.id === confirmingId;
179
+ return (<Message key={m.id} aria-label={m.agent ? "".concat(m.from, ", agent") : m.from} avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative/> : <UserImage userHandle={m.from} decorative/>} name={m.from} meta={<>
180
+ {m.agent && <Tag variant="contained" size="small" label="Agent"/>}
181
+ <TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>
182
+ {m.agent && <Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>}
183
+ {m.edited && <Paragraph size="caption" tone="secondary" measure="none">(edited)</Paragraph>}
184
+ </>} footer={m.reacted || confirming ? (<Stack gap="small">
185
+ {m.reacted && <Tag variant="contained" size="small" state="selected" label="👍 1" aria-label="Thumbs up, 1 reaction"/>}
186
+ {confirming && (
187
+ // The confirm is in the row, as the case 'Delete confirm' says for a row in a dense list.
188
+ <Stack gap="small">
189
+ <Paragraph size="body2" measure="none">Delete this message?</Paragraph>
190
+ <Cluster gap="small">
191
+ <Button ref={cancelDelete} size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" aria-label="Cancel deleting your message" onClickButton={keepMessage}/>
192
+ <Button size="small" type="primary" color="danger" state="enabled" label="Delete" aria-label="Delete this message" loading={deleting} onClickButton={confirmDelete}/>
193
+ </Cluster>
194
+ </Stack>)}
195
+ </Stack>) : undefined}
196
+ // Shown while the pointer is on the row or focus is in it, and always on a touch screen.
197
+ actions={editing || confirming ? undefined : (<>
198
+ <Tooltip title="Add reaction">
199
+ <IconButton ref={function (el) { reactButtons.current[m.id] = el; }} color="iconOnly" state="enabled" size="small" iconName="SmilePlus" ariaLabel={"Add reaction to message from ".concat(m.from)} onClick={function () { return react(m.id); }}/>
200
+ </Tooltip>
201
+ <Tooltip title={copiedId === m.id ? 'Copied' : 'Copy'}>
202
+ <IconButton color="iconOnly" state="enabled" size="small" iconName={copiedId === m.id ? 'Check' : 'Copy'} ariaLabel={copiedId === m.id ? 'Copied' : "Copy message from ".concat(m.from)} onClick={function () { return copy(m); }}/>
203
+ </Tooltip>
204
+ {own && (<Tooltip title="Edit">
205
+ <IconButton ref={function (el) { editButtons.current[m.id] = el; }} color="iconOnly" state="enabled" size="small" iconName="Pencil" ariaLabel="Edit your message" onClick={function () { return startEditing(m); }}/>
206
+ </Tooltip>)}
207
+ {own && (<Tooltip title="Delete">
208
+ <IconButton ref={function (el) { deleteButtons.current[m.id] = el; }} color="iconOnly" state="enabled" size="small" iconName="Trash2" ariaLabel="Delete your message" onClick={function () { return askToDelete(m.id); }}/>
209
+ </Tooltip>)}
210
+ </>)}>
211
+ {editing ? (
212
+ // Edit works as the case 'Message edit' says.
213
+ <Composer ref={field} id="message-actions-hover-edit" aria-label="Edit message" value={draft} onChange={setDraft} onSubmit={save} canSubmit={canSave} disabled={saving} onKeyDown={function (e) {
214
+ if (e.key === 'Escape') {
215
+ e.preventDefault();
216
+ e.stopPropagation();
217
+ cancelEditing();
218
+ }
219
+ }} actions={<Cluster gap="small">
220
+ <Button size="small" type="tertiary" state={saving ? 'disabled' : 'enabled'} label="Cancel" onClickButton={cancelEditing}/>
221
+ <Button size="small" type="primary" state={canSave ? 'enabled' : 'disabled'} label="Save" loading={saving} onClickButton={save}/>
222
+ </Cluster>}/>) : (<Paragraph measure="none">{m.text}</Paragraph>)}
223
+ </Message>);
224
+ })}
225
+ </Stack>
226
+ <Composer ref={box} id="message-actions-hover-message" aria-label="Message" placeholder="Message the team" value={text} onChange={setText} onSubmit={send}/>
227
+ </Stack>
228
+ </Center>);
229
+ }
@@ -0,0 +1 @@
1
+ export default function MessageActionsMenu(): import("react").JSX.Element;