oneslash-design-system 2.28.1 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +31 -1
  3. package/dist/cases/about-page.md +2 -0
  4. package/dist/cases/accept-invite.md +2 -0
  5. package/dist/cases/account-menu.md +2 -0
  6. package/dist/cases/activity-timeline.md +2 -0
  7. package/dist/cases/admin-inbox.md +2 -0
  8. package/dist/cases/agent-asks-before-risky-action.md +3 -1
  9. package/dist/cases/agent-cancels-when-unanswered.md +2 -0
  10. package/dist/cases/agent-changes-review/all-at-once.d.ts +1 -0
  11. package/dist/cases/agent-changes-review/all-at-once.jsx +238 -0
  12. package/dist/cases/agent-changes-review/per-change.d.ts +1 -0
  13. package/dist/cases/agent-changes-review/per-change.jsx +203 -0
  14. package/dist/cases/agent-changes-review.md +585 -0
  15. package/dist/cases/agent-handoff/to-agent.d.ts +1 -0
  16. package/dist/cases/agent-handoff/to-agent.jsx +53 -0
  17. package/dist/cases/agent-handoff/to-person.d.ts +1 -0
  18. package/dist/cases/agent-handoff/to-person.jsx +84 -0
  19. package/dist/cases/agent-handoff.md +231 -0
  20. package/dist/cases/agent-memory/list.d.ts +1 -0
  21. package/dist/cases/agent-memory/list.jsx +256 -0
  22. package/dist/cases/agent-memory.md +354 -0
  23. package/dist/cases/agent-options.md +2 -0
  24. package/dist/cases/agent-pending-reply/steps.jsx +70 -21
  25. package/dist/cases/agent-pending-reply.md +74 -27
  26. package/dist/cases/agent-permissions/levels.d.ts +3 -0
  27. package/dist/cases/agent-permissions/levels.jsx +49 -0
  28. package/dist/cases/agent-permissions/per-tool.d.ts +3 -0
  29. package/dist/cases/agent-permissions/per-tool.jsx +178 -0
  30. package/dist/cases/agent-permissions.md +314 -0
  31. package/dist/cases/agent-plan-proposal/changes.jsx +18 -11
  32. package/dist/cases/agent-plan-proposal/steps.jsx +11 -4
  33. package/dist/cases/agent-plan-proposal.md +36 -21
  34. package/dist/cases/agent-question.md +2 -0
  35. package/dist/cases/agent-refuses-clearly.md +2 -0
  36. package/dist/cases/agent-run-failure/limit-reached.d.ts +1 -0
  37. package/dist/cases/agent-run-failure/limit-reached.jsx +172 -0
  38. package/dist/cases/agent-run-failure/step-failed.d.ts +3 -0
  39. package/dist/cases/agent-run-failure/step-failed.jsx +187 -0
  40. package/dist/cases/agent-run-failure.md +500 -0
  41. package/dist/cases/agent-says-what-it-is.md +2 -0
  42. package/dist/cases/agent-says-where-it-stopped.md +27 -0
  43. package/dist/cases/agent-settings.md +2 -0
  44. package/dist/cases/agent-shows-progress.md +2 -0
  45. package/dist/cases/agent-shows-sources.md +2 -0
  46. package/dist/cases/api-keys.md +2 -0
  47. package/dist/cases/app-shell.md +2 -0
  48. package/dist/cases/artifact-card.md +2 -0
  49. package/dist/cases/ask-page.md +2 -0
  50. package/dist/cases/auth-gate-loading.md +2 -0
  51. package/dist/cases/billing-page.md +2 -0
  52. package/dist/cases/blog-index.md +2 -0
  53. package/dist/cases/breadcrumb.md +2 -0
  54. package/dist/cases/breakdown-list.md +2 -0
  55. package/dist/cases/bulk-actions/list.d.ts +1 -0
  56. package/dist/cases/bulk-actions/list.jsx +209 -0
  57. package/dist/cases/bulk-actions/paged-table.d.ts +1 -0
  58. package/dist/cases/bulk-actions/paged-table.jsx +246 -0
  59. package/dist/cases/bulk-actions.md +559 -0
  60. package/dist/cases/changelog.md +2 -0
  61. package/dist/cases/chart.md +2 -0
  62. package/dist/cases/check-your-email.md +2 -0
  63. package/dist/cases/code-sample.md +2 -0
  64. package/dist/cases/collapsible-search.md +2 -0
  65. package/dist/cases/comment-thread.md +2 -0
  66. package/dist/cases/comparison-page/table.d.ts +1 -0
  67. package/dist/cases/comparison-page/table.jsx +97 -0
  68. package/dist/cases/comparison-page.md +156 -0
  69. package/dist/cases/composer-limit.md +2 -0
  70. package/dist/cases/confirm-destructive-action.md +2 -0
  71. package/dist/cases/confirm-dialogs.md +2 -0
  72. package/dist/cases/connection-status/card.d.ts +1 -0
  73. package/dist/cases/connection-status/card.jsx +97 -0
  74. package/dist/cases/connection-status/row.d.ts +1 -0
  75. package/dist/cases/connection-status/row.jsx +120 -0
  76. package/dist/cases/connection-status.md +330 -0
  77. package/dist/cases/contact-page.md +2 -0
  78. package/dist/cases/conversation-starters.md +2 -0
  79. package/dist/cases/cookie-choice.md +2 -0
  80. package/dist/cases/create-modal.md +2 -0
  81. package/dist/cases/danger-zone.md +2 -0
  82. package/dist/cases/dashboard.md +2 -0
  83. package/dist/cases/data-table-page.md +2 -0
  84. package/dist/cases/date-field.md +2 -0
  85. package/dist/cases/device-login.md +2 -0
  86. package/dist/cases/docs-component-page.md +2 -0
  87. package/dist/cases/email-confirmed.md +2 -0
  88. package/dist/cases/empty-list.md +2 -0
  89. package/dist/cases/empty-lists.md +2 -0
  90. package/dist/cases/empty-not-set-up.md +2 -0
  91. package/dist/cases/empty-search.md +2 -0
  92. package/dist/cases/error-page.md +2 -0
  93. package/dist/cases/faq.md +2 -0
  94. package/dist/cases/feature-grid.md +2 -0
  95. package/dist/cases/feedback-form.md +2 -0
  96. package/dist/cases/file-upload.md +2 -0
  97. package/dist/cases/filter-menu.md +2 -0
  98. package/dist/cases/forgot-password.md +2 -0
  99. package/dist/cases/form-errors.md +2 -0
  100. package/dist/cases/image-viewer.md +2 -0
  101. package/dist/cases/import-checklist.md +2 -0
  102. package/dist/cases/inline-form-feedback.md +2 -0
  103. package/dist/cases/integrations-list/nested.jsx +1 -1
  104. package/dist/cases/integrations-list/rows.jsx +1 -1
  105. package/dist/cases/integrations-list.md +6 -4
  106. package/dist/cases/invite-member.md +2 -0
  107. package/dist/cases/invoice-list.md +2 -0
  108. package/dist/cases/landing-hero.md +2 -0
  109. package/dist/cases/leaderboard.md +2 -0
  110. package/dist/cases/legal-page.md +2 -0
  111. package/dist/cases/load-failure.md +2 -0
  112. package/dist/cases/log-out-confirm.md +2 -0
  113. package/dist/cases/login-page.md +2 -0
  114. package/dist/cases/long-form-page.md +2 -0
  115. package/dist/cases/master-detail.md +2 -0
  116. package/dist/cases/members-list.md +2 -0
  117. package/dist/cases/mention-list.md +2 -0
  118. package/dist/cases/message-actions.md +2 -0
  119. package/dist/cases/message-attachments.md +2 -0
  120. package/dist/cases/message-composer/with-tools.jsx +17 -7
  121. package/dist/cases/message-composer.md +28 -11
  122. package/dist/cases/message-edit.md +2 -0
  123. package/dist/cases/message-reactions.md +2 -0
  124. package/dist/cases/message-row.md +2 -0
  125. package/dist/cases/message-send-failure/needs-a-person.d.ts +1 -0
  126. package/dist/cases/message-send-failure/needs-a-person.jsx +116 -0
  127. package/dist/cases/message-send-failure/retrying.d.ts +1 -0
  128. package/dist/cases/message-send-failure/retrying.jsx +116 -0
  129. package/dist/cases/message-send-failure.md +308 -0
  130. package/dist/cases/mobile-menu.md +2 -0
  131. package/dist/cases/newsletter-signup.md +2 -0
  132. package/dist/cases/no-access/page.d.ts +1 -0
  133. package/dist/cases/no-access/page.jsx +37 -0
  134. package/dist/cases/no-access/read-only.d.ts +1 -0
  135. package/dist/cases/no-access/read-only.jsx +33 -0
  136. package/dist/cases/no-access.md +147 -0
  137. package/dist/cases/not-found-page.md +2 -0
  138. package/dist/cases/notification-menu.md +2 -0
  139. package/dist/cases/number-format.md +2 -0
  140. package/dist/cases/oauth-consent.md +2 -0
  141. package/dist/cases/on-off-settings.md +2 -0
  142. package/dist/cases/on-this-page.md +2 -0
  143. package/dist/cases/onboarding.md +2 -0
  144. package/dist/cases/one-main-action.md +2 -0
  145. package/dist/cases/overflow-menu.md +2 -0
  146. package/dist/cases/page-end.md +2 -0
  147. package/dist/cases/page-header.md +2 -0
  148. package/dist/cases/paged-card.md +2 -0
  149. package/dist/cases/password-gate.md +2 -0
  150. package/dist/cases/payment-method.md +2 -0
  151. package/dist/cases/people-row.md +2 -0
  152. package/dist/cases/phone-navigation.md +2 -0
  153. package/dist/cases/plan-change-confirm.md +2 -0
  154. package/dist/cases/plan-comparison.md +3 -1
  155. package/dist/cases/plan-picker.md +4 -1
  156. package/dist/cases/plan-sign-off.md +2 -0
  157. package/dist/cases/pricing-section.md +5 -1
  158. package/dist/cases/product-cards.md +2 -0
  159. package/dist/cases/product-demo/scripted.d.ts +3 -0
  160. package/dist/cases/product-demo/scripted.jsx +95 -0
  161. package/dist/cases/product-demo/still.d.ts +1 -0
  162. package/dist/cases/product-demo/still.jsx +20 -0
  163. package/dist/cases/product-demo.md +221 -0
  164. package/dist/cases/profile-form.md +2 -0
  165. package/dist/cases/quick-switcher.md +2 -0
  166. package/dist/cases/range-switch.md +2 -0
  167. package/dist/cases/rename.md +2 -0
  168. package/dist/cases/reply-feedback.md +2 -0
  169. package/dist/cases/reply-sources.md +2 -0
  170. package/dist/cases/route-loading.md +2 -0
  171. package/dist/cases/scope-picker.md +2 -0
  172. package/dist/cases/section-index.md +2 -0
  173. package/dist/cases/session-expired/in-place.d.ts +1 -0
  174. package/dist/cases/session-expired/in-place.jsx +63 -0
  175. package/dist/cases/session-expired/redirect.d.ts +1 -0
  176. package/dist/cases/session-expired/redirect.jsx +62 -0
  177. package/dist/cases/session-expired.md +204 -0
  178. package/dist/cases/set-new-password.md +2 -0
  179. package/dist/cases/settings-page.md +2 -0
  180. package/dist/cases/settings-save.md +2 -0
  181. package/dist/cases/side-pane.md +2 -0
  182. package/dist/cases/sidebar-nav.md +2 -0
  183. package/dist/cases/sign-up-page.md +3 -0
  184. package/dist/cases/signup-from-site/plain.d.ts +1 -0
  185. package/dist/cases/signup-from-site/plain.jsx +125 -0
  186. package/dist/cases/signup-from-site/with-plan.d.ts +4 -0
  187. package/dist/cases/signup-from-site/with-plan.jsx +151 -0
  188. package/dist/cases/signup-from-site.md +351 -0
  189. package/dist/cases/site-footer.md +2 -0
  190. package/dist/cases/site-header/links.d.ts +3 -1
  191. package/dist/cases/site-header/links.jsx +6 -2
  192. package/dist/cases/site-header.md +11 -3
  193. package/dist/cases/site-matches-app.md +32 -0
  194. package/dist/cases/site-search.md +2 -0
  195. package/dist/cases/slash-command-list.md +2 -0
  196. package/dist/cases/stat-row.md +2 -0
  197. package/dist/cases/status-label.md +3 -1
  198. package/dist/cases/success-feedback.md +2 -0
  199. package/dist/cases/tabbed-panels.md +2 -0
  200. package/dist/cases/tag-filter.md +2 -0
  201. package/dist/cases/task-header.md +2 -0
  202. package/dist/cases/theme-switcher.md +2 -0
  203. package/dist/cases/type-to-confirm.md +2 -0
  204. package/dist/cases/typing-and-status.md +2 -0
  205. package/dist/cases/unsaved-changes-guard.md +2 -0
  206. package/dist/cases/upgrade-prompt.md +2 -0
  207. package/dist/cases/usage-meters.md +2 -0
  208. package/dist/cases.json +1489 -39
  209. package/dist/components/checkBox.d.ts +5 -1
  210. package/dist/components/checkBox.jsx +23 -9
  211. package/dist/components/diff.d.ts +29 -0
  212. package/dist/components/diff.jsx +35 -0
  213. package/dist/index.d.ts +1 -0
  214. package/dist/index.js +1 -0
  215. package/dist/internal/diff.d.ts +17 -0
  216. package/dist/internal/diff.js +44 -0
  217. package/dist/native-mapping.json +9 -2
  218. package/dist/stories/AgentPermissions.probe.stories.d.ts +7 -0
  219. package/dist/stories/AgentPermissions.probe.stories.jsx +18 -0
  220. package/dist/stories/AgentRunFailure.probe.stories.d.ts +6 -0
  221. package/dist/stories/AgentRunFailure.probe.stories.jsx +12 -0
  222. package/dist/stories/Cases.generated.stories.d.ts +24 -0
  223. package/dist/stories/Cases.generated.stories.jsx +48 -0
  224. package/dist/stories/Checkbox.stories.d.ts +2 -0
  225. package/dist/stories/Checkbox.stories.jsx +18 -0
  226. package/dist/stories/Diff.stories.d.ts +9 -0
  227. package/dist/stories/Diff.stories.jsx +40 -0
  228. package/dist/stories/ProductDemo.probe.stories.d.ts +6 -0
  229. package/dist/stories/ProductDemo.probe.stories.jsx +12 -0
  230. package/dist/stories/SignupFromSite.probe.stories.d.ts +7 -0
  231. package/dist/stories/SignupFromSite.probe.stories.jsx +17 -0
  232. package/dist/stories/SiteHeader.probe.stories.d.ts +6 -0
  233. package/dist/stories/SiteHeader.probe.stories.jsx +13 -0
  234. package/package.json +1 -1
@@ -0,0 +1,559 @@
1
+ # Bulk actions
2
+
3
+ A person picks several rows of a list or a table and does one thing to all of them at once.
4
+
5
+ For: an app
6
+
7
+ ## Do
8
+
9
+ - Give each row a `Checkbox` named for its row: 'Select Write the launch email'.
10
+ - Put a header `Checkbox` above the rows, named for what it picks: 'Select all tasks'. Set `indeterminate` when some rows are picked, and `checked` when all are.
11
+ - Pick every row with the header Checkbox when some are picked, and none when all are.
12
+ - Replace the toolbar with a bar while any row is picked. It says the count, '3 selected', then up to two Buttons, a More menu and a tertiary 'Clear Selection'.
13
+ - Give the count `role="status"` and keep it on the page, so a screen reader hears each new count once.
14
+ - Name the More menu for the rows it acts on: 'More actions for 3 tasks'. Follow the case 'More menu'.
15
+ - Follow the case 'Data table page' for a table over many pages. The header Checkbox picks the rows of the page shown.
16
+ - Offer 'Select All 240' as a text Button in the bar of a paged table, until every row is picked. Focus then goes to 'Clear Selection'.
17
+ - Keep the picked rows when the person changes page, sorts or comes back.
18
+ - Confirm a delete in a small Modal, as the case 'Delete confirm' does, titled with the count: 'Delete 3 Invoices'.
19
+ - Move focus to the header Checkbox after 'Clear Selection' and after a delete, because the bar and its Buttons are gone.
20
+ - Stay on the same page after a delete if it still has rows, or go to the last page that does.
21
+ - Show the case 'Empty list' in the table's place when a delete leaves no rows. Focus goes to its Button.
22
+ - Say what happened in a toast that counts: '3 invoices deleted.'
23
+
24
+ ## Don't
25
+
26
+ - Do not make Cmd-click or Shift-click the only way to pick rows. A Checkbox works for a keyboard, a screen reader and touch.
27
+ - Do not make dragging the only way to act on picked rows. Give each action a Button or a menu item.
28
+ - Do not drop the picked rows when the page changes.
29
+ - Do not say 'Select All' with no count on a paged table. Say how many it picks.
30
+ - Do not show the bar and the toolbar at once.
31
+
32
+ ## Option: Ticks on one page
33
+
34
+ Use when: A list whose rows all fit on one page, such as the tasks of a project.
35
+
36
+ Uses: `Button`, `Center`, `Checkbox`, `Cluster`, `EmptyBox`, `Heading`, `IconButton`, `Menu`, `MenuItem`, `Modal`, `Paragraph`, `Popover`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`, `Toaster`, `Tooltip`, `dismissToast`, `toast`
37
+
38
+ ```tsx
39
+ 'use client';
40
+ import { useEffect, useRef, useState } from 'react';
41
+ import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
42
+ import Heading from 'oneslash-design-system/components/heading';
43
+ import Paragraph from 'oneslash-design-system/components/paragraph';
44
+ import Checkbox from 'oneslash-design-system/components/checkBox';
45
+ import Button from 'oneslash-design-system/components/button';
46
+ import IconButton from 'oneslash-design-system/components/iconButton';
47
+ import Tooltip from 'oneslash-design-system/components/tooltip';
48
+ import Popover from 'oneslash-design-system/components/popover';
49
+ import Menu from 'oneslash-design-system/components/menu';
50
+ import MenuItem from 'oneslash-design-system/components/menuItem';
51
+ import Modal from 'oneslash-design-system/components/modal';
52
+ import Tag from 'oneslash-design-system/components/tag';
53
+ import EmptyBox from 'oneslash-design-system/components/emptyBox';
54
+ import TableContainer from 'oneslash-design-system/components/tableContainer';
55
+ import TableHeader from 'oneslash-design-system/components/tableHeader';
56
+ import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
57
+ import TableRow from 'oneslash-design-system/components/tableRow';
58
+ import TableCell from 'oneslash-design-system/components/tableCell';
59
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
60
+
61
+ type Task = { id: string; title: string; assignee: string | null; done: boolean };
62
+
63
+ // A real app reads this from the session.
64
+ const me = 'Dana Lee';
65
+
66
+ // A real app reads these from the server. They all fit on one page.
67
+ const firstTasks: Task[] = [
68
+ { id: 't1', title: 'Write the launch email', assignee: 'Ben Carter', done: false },
69
+ { id: 't2', title: 'Update the pricing page', assignee: 'Dana Lee', done: false },
70
+ { id: 't3', title: 'Check the plan table on a phone', assignee: 'Omar Reyes', done: false },
71
+ { id: 't4', title: 'Send the press kit', assignee: 'Mia Park', done: true },
72
+ { id: 't5', title: 'Book the launch call', assignee: null, done: false },
73
+ { id: 't6', title: 'Review the help article', assignee: 'Ben Carter', done: false },
74
+ { id: 't7', title: 'Record the demo video', assignee: 'Omar Reyes', done: false },
75
+ { id: 't8', title: 'Translate the FAQ', assignee: null, done: false },
76
+ ];
77
+
78
+ const plural = (n: number) => `${n} ${n === 1 ? 'task' : 'tasks'}`;
79
+
80
+ // Names up to three tasks, then counts the rest: 'A', 'B' and 2 more tasks.
81
+ function nameTasks(list: Task[]) {
82
+ const names = list.slice(0, 3).map((t) => `'${t.title}'`);
83
+ const rest = list.length - names.length;
84
+ if (rest > 0) return `${names.join(', ')} and ${rest} more ${rest === 1 ? 'task' : 'tasks'}`;
85
+ if (names.length <= 1) return names[0] ?? '';
86
+ return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;
87
+ }
88
+
89
+ export default function BulkActionsList() {
90
+ const [tasks, setTasks] = useState(firstTasks);
91
+ // Opens with three tasks picked, so the bar shows.
92
+ const [picked, setPicked] = useState<string[]>(['t1', 't3', 't5']);
93
+ const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
94
+ const [menuOpen, setMenuOpen] = useState(false);
95
+ // The tasks the confirm names. They stay set while the Modal fades out.
96
+ const [toDelete, setToDelete] = useState<Task[]>([]);
97
+ const [confirming, setConfirming] = useState(false);
98
+ const [deleting, setDeleting] = useState(false);
99
+ const timer = useRef<ReturnType<typeof setTimeout>>();
100
+ const toastIds = useRef<string[]>([]);
101
+ // Holds the header Checkbox. Checkbox takes no ref, so focus goes to the box inside this line.
102
+ const headerBox = useRef<HTMLParagraphElement>(null);
103
+ // With no task left there is no header Checkbox, so focus goes to Add Task.
104
+ const addTask = useRef<HTMLButtonElement | HTMLAnchorElement | null>(null);
105
+ // Where focus goes after the next render, once the element it goes to is on screen.
106
+ const focusNext = useRef<() => void>();
107
+
108
+ // On unmount it stops the request and closes every toast it opened.
109
+ useEffect(() => () => {
110
+ clearTimeout(timer.current);
111
+ toastIds.current.forEach((id) => dismissToast(id));
112
+ toastIds.current = [];
113
+ }, []);
114
+
115
+ useEffect(() => {
116
+ const move = focusNext.current;
117
+ focusNext.current = undefined;
118
+ move?.();
119
+ });
120
+
121
+ const headerCheckbox = () => headerBox.current?.querySelector('input') ?? addTask.current;
122
+ const pickedTasks = tasks.filter((t) => picked.includes(t.id));
123
+ const count = pickedTasks.length;
124
+ const all = tasks.length > 0 && count === tasks.length;
125
+
126
+ function toggle(id: string, on: boolean) {
127
+ setPicked((list) => (on ? [...list, id] : list.filter((x) => x !== id)));
128
+ }
129
+
130
+ // Mixed or empty: pick every task. All picked: pick none.
131
+ function toggleAll(on: boolean) {
132
+ setPicked(on ? tasks.map((t) => t.id) : []);
133
+ }
134
+
135
+ // The bar and its Buttons go, so focus goes to the header Checkbox.
136
+ function clearSelection() {
137
+ setPicked([]);
138
+ focusNext.current = () => headerCheckbox()?.focus();
139
+ }
140
+
141
+ function update(change: (t: Task) => Task, message: string) {
142
+ setTasks((list) => list.map((t) => (picked.includes(t.id) ? change(t) : t)));
143
+ toastIds.current.push(toast({ type: 'success', message }));
144
+ }
145
+
146
+ function choose(action: () => void) {
147
+ setMenuOpen(false);
148
+ action();
149
+ }
150
+
151
+ // Escape, a click outside and Cancel all close it, except while the request runs.
152
+ function closeConfirm() {
153
+ if (deleting) return;
154
+ setConfirming(false);
155
+ }
156
+
157
+ function deletePicked() {
158
+ if (deleting) return;
159
+ const ids = toDelete.map((t) => t.id);
160
+ setDeleting(true);
161
+ // Stands in for the request to the server.
162
+ timer.current = setTimeout(() => {
163
+ setDeleting(false);
164
+ setTasks((list) => list.filter((t) => !ids.includes(t.id)));
165
+ setPicked([]);
166
+ setConfirming(false);
167
+ toastIds.current.push(toast({ type: 'success', message: `${plural(ids.length)} deleted.` }));
168
+ }, 1200);
169
+ }
170
+
171
+ return (
172
+ <Center width="page">
173
+ {/* A real app mounts one Toaster near its root. */}
174
+ <Toaster />
175
+ <Stack gap="large">
176
+ <Heading level={1} size="h5">Launch tasks</Heading>
177
+ {/* The toolbar. While any task is picked, the bar takes its place. */}
178
+ <Cluster justify="between">
179
+ {/* On the page from the start, so each new count is heard once. */}
180
+ <Paragraph id="bulk-actions-list-count" role="status" size="body2" measure="none">
181
+ {count > 0 ? `${count} selected` : plural(tasks.length)}
182
+ </Paragraph>
183
+ {count > 0 ? (
184
+ <Cluster gap="small">
185
+ <Button size="small" type="secondary" state="enabled" label="Mark Done" onClickButton={() => update((t) => ({ ...t, done: true }), `${plural(count)} marked done.`)} />
186
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete" onClickButton={() => { setToDelete(pickedTasks); setConfirming(true); }} />
187
+ <Tooltip title="More">
188
+ <IconButton
189
+ color="iconOnly"
190
+ state={menuOpen ? 'selected' : 'enabled'}
191
+ size="small"
192
+ iconName="Ellipsis"
193
+ ariaLabel={`More actions for ${plural(count)}`}
194
+ aria-haspopup="menu"
195
+ aria-expanded={menuOpen}
196
+ onClick={(e: { currentTarget: HTMLElement }) => {
197
+ setMenuAnchor(e.currentTarget);
198
+ setMenuOpen((o) => !o);
199
+ }}
200
+ />
201
+ </Tooltip>
202
+ <Button size="small" type="tertiary" state="enabled" label="Clear Selection" onClickButton={clearSelection} />
203
+ </Cluster>
204
+ ) : (
205
+ <Button ref={addTask} size="small" type="secondary" state="enabled" label="Add Task" decoIcon="Plus" onClickButton={() => console.info('Open the new task form')} />
206
+ )}
207
+ </Cluster>
208
+
209
+ {tasks.length === 0 ? (
210
+ <EmptyBox size="large" text="No tasks" secondText="Tasks you add to this project appear here." />
211
+ ) : (
212
+ <TableContainer aria-label="Launch tasks" minWidth="520px">
213
+ <TableHeader>
214
+ <TableRow>
215
+ <TableHeaderCell width="48px">
216
+ <Paragraph ref={headerBox} measure="none">
217
+ <Checkbox aria-label="Select all tasks" checked={all} indeterminate={count > 0 && !all} onChange={toggleAll} />
218
+ </Paragraph>
219
+ </TableHeaderCell>
220
+ <TableHeaderCell>Task</TableHeaderCell>
221
+ <TableHeaderCell width="140px">Assignee</TableHeaderCell>
222
+ <TableHeaderCell width="80px">Status</TableHeaderCell>
223
+ </TableRow>
224
+ </TableHeader>
225
+ {tasks.map((t) => (
226
+ <TableRow key={t.id}>
227
+ <TableCell width="48px">
228
+ <Checkbox aria-label={`Select ${t.title}`} checked={picked.includes(t.id)} onChange={(on) => toggle(t.id, on)} />
229
+ </TableCell>
230
+ <TableCell>{t.title}</TableCell>
231
+ <TableCell width="140px">{t.assignee ?? 'No one'}</TableCell>
232
+ <TableCell width="80px">
233
+ <Tag variant="textOnly" size="small" label={t.done ? 'Done' : 'Open'} />
234
+ </TableCell>
235
+ </TableRow>
236
+ ))}
237
+ </TableContainer>
238
+ )}
239
+ </Stack>
240
+
241
+ <Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>
242
+ <Menu navigable aria-label={`Actions for ${plural(count)}`} width={200}>
243
+ <MenuItem size="small" iconName="UserCheck" label="Assign to Me" onClick={() => choose(() => update((t) => ({ ...t, assignee: me }), `${plural(count)} assigned to you.`))} />
244
+ <MenuItem size="small" iconName="UserX" label="Unassign" onClick={() => choose(() => update((t) => ({ ...t, assignee: null }), `${plural(count)} unassigned.`))} />
245
+ </Menu>
246
+ </Popover>
247
+
248
+ {/* After a delete the bar is gone, so the Modal gives focus to the header Checkbox. Cancel gives it back to Delete. */}
249
+ <Modal
250
+ isOpen={confirming}
251
+ size="small"
252
+ title={`Delete ${toDelete.length} ${toDelete.length === 1 ? 'Task' : 'Tasks'}`}
253
+ onClose={closeConfirm}
254
+ returnFocus={headerCheckbox}
255
+ actions={
256
+ <>
257
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={closeConfirm} />
258
+ <Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={deletePicked} />
259
+ </>
260
+ }
261
+ >
262
+ <Paragraph measure="none">{`This deletes ${nameTasks(toDelete)}.`}</Paragraph>
263
+ <Paragraph tone="secondary" size="body2" measure="none">Their comments and files go too.</Paragraph>
264
+ </Modal>
265
+ </Center>
266
+ );
267
+ }
268
+ ```
269
+
270
+ ## Option: Ticks across pages
271
+
272
+ Use when: A table over many pages, where the person may want every row, not only the ones they see.
273
+
274
+ Uses: `Button`, `Center`, `Checkbox`, `Cluster`, `EmptyBox`, `IconButton`, `Menu`, `MenuItem`, `Modal`, `Pagination`, `Paragraph`, `Popover`, `Stack`, `Surface`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`, `TitleBar`, `Toaster`, `Tooltip`, `dismissToast`, `formatCount`, `formatMoney`, `toast`
275
+
276
+ ```tsx
277
+ 'use client';
278
+ import { useEffect, useRef, useState } from 'react';
279
+ import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
280
+ import TitleBar from 'oneslash-design-system/components/titleBar';
281
+ import Paragraph from 'oneslash-design-system/components/paragraph';
282
+ import Checkbox from 'oneslash-design-system/components/checkBox';
283
+ import Button from 'oneslash-design-system/components/button';
284
+ import IconButton from 'oneslash-design-system/components/iconButton';
285
+ import Tooltip from 'oneslash-design-system/components/tooltip';
286
+ import Popover from 'oneslash-design-system/components/popover';
287
+ import Menu from 'oneslash-design-system/components/menu';
288
+ import MenuItem from 'oneslash-design-system/components/menuItem';
289
+ import Modal from 'oneslash-design-system/components/modal';
290
+ import Tag from 'oneslash-design-system/components/tag';
291
+ import Surface from 'oneslash-design-system/components/surface';
292
+ import EmptyBox from 'oneslash-design-system/components/emptyBox';
293
+ import Pagination from 'oneslash-design-system/components/pagination';
294
+ import TableContainer from 'oneslash-design-system/components/tableContainer';
295
+ import TableHeader from 'oneslash-design-system/components/tableHeader';
296
+ import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
297
+ import TableRow from 'oneslash-design-system/components/tableRow';
298
+ import TableCell from 'oneslash-design-system/components/tableCell';
299
+ import { formatCount, formatMoney } from 'oneslash-design-system/components/formatNumber';
300
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
301
+
302
+ type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
303
+ type Status = 'Paid' | 'Past due';
304
+ type Invoice = { id: string; number: string; customer: string; date: string; cents: number; status: Status };
305
+
306
+ const customers = ['Willow Bakery', 'Harbor Studio', 'Lumen Labs', 'Pine and Co', 'Cedar Works', 'Bright Dental', 'Maple Design', 'Atlas Freight'];
307
+ const monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
308
+
309
+ // A real app asks the server for one page. This makes the 240 invoices the server would hold, newest first.
310
+ const firstInvoices: Invoice[] = Array.from({ length: 240 }, (_, i) => {
311
+ const day = new Date(Date.UTC(2026, 10, 16 - i));
312
+ return {
313
+ id: `inv-${i}`,
314
+ number: `INV-${1290 - i}`,
315
+ customer: customers[(i * 5 + 1) % customers.length],
316
+ date: `${monthNames[day.getUTCMonth()]} ${day.getUTCDate()}, ${day.getUTCFullYear()}`,
317
+ cents: 2400 + ((i * 5303) % 40000),
318
+ status: i % 11 === 4 ? 'Past due' : 'Paid',
319
+ };
320
+ });
321
+
322
+ const PAGE_SIZE = 25;
323
+ const plural = (n: number) => `${formatCount(n)} ${n === 1 ? 'invoice' : 'invoices'}`;
324
+
325
+ // Names up to three invoices, then counts the rest: INV-1290, INV-1289 and 23 more.
326
+ function nameInvoices(list: Invoice[]) {
327
+ const names = list.slice(0, 3).map((inv) => inv.number);
328
+ const rest = list.length - names.length;
329
+ if (rest > 0) return `${plural(list.length)}: ${names.join(', ')} and ${formatCount(rest)} more`;
330
+ if (names.length <= 1) return names[0] ?? '';
331
+ return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;
332
+ }
333
+
334
+ export default function BulkActionsPagedTable() {
335
+ const [invoices, setInvoices] = useState(firstInvoices);
336
+ const [page, setPage] = useState(1);
337
+ // The picked invoices by id, on any page. Opens with three picked, so the bar shows.
338
+ const [picked, setPicked] = useState<string[]>(['inv-0', 'inv-1', 'inv-3']);
339
+ const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
340
+ const [menuOpen, setMenuOpen] = useState(false);
341
+ // The invoices the confirm names. They stay set while the Modal fades out.
342
+ const [toDelete, setToDelete] = useState<Invoice[]>([]);
343
+ const [confirming, setConfirming] = useState(false);
344
+ const [deleting, setDeleting] = useState(false);
345
+ const timer = useRef<ReturnType<typeof setTimeout>>();
346
+ const toastIds = useRef<string[]>([]);
347
+ const clearButton = useRef<Focusable>(null);
348
+ // With no invoice left there is no header Checkbox, so focus goes to the empty state's Button.
349
+ const createButton = useRef<Focusable>(null);
350
+ // Holds the header Checkbox. Checkbox takes no ref, so focus goes to the box inside this line.
351
+ const headerBox = useRef<HTMLParagraphElement>(null);
352
+ // Where focus goes after the next render, once the element it goes to is on screen.
353
+ const focusNext = useRef<() => void>();
354
+
355
+ // On unmount it stops the request and closes every toast it opened.
356
+ useEffect(() => () => {
357
+ clearTimeout(timer.current);
358
+ toastIds.current.forEach((id) => dismissToast(id));
359
+ toastIds.current = [];
360
+ }, []);
361
+
362
+ useEffect(() => {
363
+ const move = focusNext.current;
364
+ focusNext.current = undefined;
365
+ move?.();
366
+ });
367
+
368
+ const headerCheckbox = () => headerBox.current?.querySelector('input') ?? createButton.current;
369
+ const pageCount = Math.ceil(invoices.length / PAGE_SIZE);
370
+ const rows = invoices.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
371
+ const pickedInvoices = invoices.filter((inv) => picked.includes(inv.id));
372
+ const count = pickedInvoices.length;
373
+ const everyRow = count > 0 && count === invoices.length;
374
+ // The header Checkbox speaks for the page shown.
375
+ const onPage = rows.filter((inv) => picked.includes(inv.id)).length;
376
+ const wholePage = rows.length > 0 && onPage === rows.length;
377
+
378
+ function toggle(id: string, on: boolean) {
379
+ setPicked((list) => (on ? [...list, id] : list.filter((x) => x !== id)));
380
+ }
381
+
382
+ // Mixed or empty: pick every row on this page. All picked: unpick them. Rows on other pages stay as they are.
383
+ function togglePage(on: boolean) {
384
+ const ids = rows.map((inv) => inv.id);
385
+ setPicked((list) => (on ? [...list.filter((x) => !ids.includes(x)), ...ids] : list.filter((x) => !ids.includes(x))));
386
+ }
387
+
388
+ // 'Select All 240' goes away once every row is picked, so focus goes to 'Clear Selection'.
389
+ function pickEveryRow() {
390
+ setPicked(invoices.map((inv) => inv.id));
391
+ focusNext.current = () => clearButton.current?.focus();
392
+ }
393
+
394
+ // The bar and its Buttons go, so focus goes to the header Checkbox.
395
+ function clearSelection() {
396
+ setPicked([]);
397
+ focusNext.current = () => headerCheckbox()?.focus();
398
+ }
399
+
400
+ function choose(action: () => void) {
401
+ setMenuOpen(false);
402
+ action();
403
+ }
404
+
405
+ function markPaid() {
406
+ setInvoices((list) => list.map((inv) => (picked.includes(inv.id) ? { ...inv, status: 'Paid' } : inv)));
407
+ toastIds.current.push(toast({ type: 'success', message: `${plural(count)} marked as paid.` }));
408
+ }
409
+
410
+ // Escape, a click outside and Cancel all close it, except while the request runs.
411
+ function closeConfirm() {
412
+ if (deleting) return;
413
+ setConfirming(false);
414
+ }
415
+
416
+ function deletePicked() {
417
+ if (deleting) return;
418
+ const ids = toDelete.map((inv) => inv.id);
419
+ setDeleting(true);
420
+ // Stands in for the request to the server.
421
+ timer.current = setTimeout(() => {
422
+ setDeleting(false);
423
+ const left = invoices.filter((inv) => !ids.includes(inv.id));
424
+ setInvoices(left);
425
+ // Fewer pages may be left: stay on this page if it still exists, or go to the last one.
426
+ setPage((p) => Math.min(p, Math.max(1, Math.ceil(left.length / PAGE_SIZE))));
427
+ setPicked([]);
428
+ setConfirming(false);
429
+ toastIds.current.push(toast({ type: 'success', message: `${plural(ids.length)} deleted.` }));
430
+ }, 1200);
431
+ }
432
+
433
+ return (
434
+ <Center width="page">
435
+ {/* A real app mounts one Toaster near its root. */}
436
+ <Toaster />
437
+ <Stack gap="large">
438
+ {/* The case 'Data table page' adds search, a filter and sorting here. */}
439
+ <Stack gap="small">
440
+ <TitleBar title="Invoices" id="bulk-actions-paged-table-top" />
441
+ <Paragraph tone="secondary" size="body2" measure="none">{plural(invoices.length)}</Paragraph>
442
+ </Stack>
443
+
444
+ {/* The toolbar. While any invoice is picked, the bar takes its place. */}
445
+ <Cluster justify="between">
446
+ <Cluster gap="small">
447
+ {/* On the page from the start, so each new count is heard once. */}
448
+ <Paragraph id="bulk-actions-paged-table-count" role="status" size="body2" measure="none">
449
+ {count > 0 ? `${formatCount(count)} selected` : ''}
450
+ </Paragraph>
451
+ {count > 0 && !everyRow && (
452
+ <Button size="small" type="textOnly" state="enabled" label={`Select All ${formatCount(invoices.length)}`} onClickButton={pickEveryRow} />
453
+ )}
454
+ </Cluster>
455
+ {count > 0 ? (
456
+ <Cluster gap="small">
457
+ <Button size="small" type="secondary" state="enabled" label="Export" onClickButton={() => toastIds.current.push(toast({ type: 'success', message: `Export of ${plural(count)} sent to dana@acme.example.` }))} />
458
+ <Button size="small" type="secondary" color="danger" state="enabled" label="Delete" onClickButton={() => { setToDelete(pickedInvoices); setConfirming(true); }} />
459
+ <Tooltip title="More">
460
+ <IconButton
461
+ color="iconOnly"
462
+ state={menuOpen ? 'selected' : 'enabled'}
463
+ size="small"
464
+ iconName="Ellipsis"
465
+ ariaLabel={`More actions for ${plural(count)}`}
466
+ aria-haspopup="menu"
467
+ aria-expanded={menuOpen}
468
+ onClick={(e: { currentTarget: HTMLElement }) => {
469
+ setMenuAnchor(e.currentTarget);
470
+ setMenuOpen((o) => !o);
471
+ }}
472
+ />
473
+ </Tooltip>
474
+ <Button ref={clearButton} size="small" type="tertiary" state="enabled" label="Clear Selection" onClickButton={clearSelection} />
475
+ </Cluster>
476
+ ) : invoices.length === 0 ? null : (
477
+ <Button size="small" type="secondary" state="enabled" label="Export All" onClickButton={() => toastIds.current.push(toast({ type: 'success', message: `Export of ${plural(invoices.length)} sent to dana@acme.example.` }))} />
478
+ )}
479
+ </Cluster>
480
+
481
+ {invoices.length === 0 ? (
482
+ // The case 'Empty list' takes the table's place.
483
+ <Surface minHeight="tall" align="center">
484
+ <EmptyBox
485
+ size="large"
486
+ text="No invoices yet"
487
+ secondText="Your next invoice appears here after the next payment."
488
+ action={<Button ref={createButton} size="medium" type="primary" state="enabled" label="Create Invoice" onClickButton={() => console.info('Open the new invoice form')} />}
489
+ />
490
+ </Surface>
491
+ ) : (
492
+ <TableContainer aria-label="Invoices" minWidth="640px">
493
+ <TableHeader>
494
+ <TableRow>
495
+ <TableHeaderCell width="48px">
496
+ <Paragraph ref={headerBox} measure="none">
497
+ <Checkbox aria-label="Select all invoices on this page" checked={wholePage} indeterminate={onPage > 0 && !wholePage} onChange={togglePage} />
498
+ </Paragraph>
499
+ </TableHeaderCell>
500
+ <TableHeaderCell width="110px">Invoice</TableHeaderCell>
501
+ <TableHeaderCell>Customer</TableHeaderCell>
502
+ <TableHeaderCell width="130px">Date</TableHeaderCell>
503
+ <TableHeaderCell width="120px" align="right">Amount</TableHeaderCell>
504
+ <TableHeaderCell width="100px">Status</TableHeaderCell>
505
+ </TableRow>
506
+ </TableHeader>
507
+ {rows.map((inv) => (
508
+ <TableRow key={inv.id}>
509
+ <TableCell width="48px">
510
+ <Checkbox aria-label={`Select ${inv.number}`} checked={picked.includes(inv.id)} onChange={(on) => toggle(inv.id, on)} />
511
+ </TableCell>
512
+ <TableCell width="110px">{inv.number}</TableCell>
513
+ <TableCell>{inv.customer}</TableCell>
514
+ <TableCell width="130px">{inv.date}</TableCell>
515
+ <TableCell width="120px" align="right">{formatMoney(inv.cents / 100)}</TableCell>
516
+ <TableCell width="100px">
517
+ {inv.status === 'Past due' ? <Tag variant="dot" size="small" color="error" label={inv.status} /> : <Tag variant="textOnly" size="small" label={inv.status} />}
518
+ </TableCell>
519
+ </TableRow>
520
+ ))}
521
+ </TableContainer>
522
+ )}
523
+
524
+ {/* Changing page keeps the picked invoices. A real app also passes `getHref`, so each page has an address. */}
525
+ <Pagination aria-label="Invoice pages" page={page} pageCount={pageCount} onPageChange={setPage} scrollTargetId="bulk-actions-paged-table-top" />
526
+ </Stack>
527
+
528
+ <Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>
529
+ <Menu navigable aria-label={`Actions for ${plural(count)}`} width={200}>
530
+ <MenuItem size="small" iconName="Mail" label="Send Receipts" onClick={() => choose(() => toastIds.current.push(toast({ type: 'success', message: `Receipts for ${plural(count)} sent.` })))} />
531
+ <MenuItem size="small" iconName="Check" label="Mark as Paid" onClick={() => choose(markPaid)} />
532
+ </Menu>
533
+ </Popover>
534
+
535
+ {/* After a delete the bar is gone, so the Modal gives focus to the header Checkbox. Cancel gives it back to Delete. */}
536
+ <Modal
537
+ isOpen={confirming}
538
+ size="small"
539
+ title={`Delete ${formatCount(toDelete.length)} ${toDelete.length === 1 ? 'Invoice' : 'Invoices'}`}
540
+ onClose={closeConfirm}
541
+ returnFocus={headerCheckbox}
542
+ actions={
543
+ <>
544
+ <Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={closeConfirm} />
545
+ <Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={deletePicked} />
546
+ </>
547
+ }
548
+ >
549
+ <Paragraph measure="none">{`This deletes ${nameInvoices(toDelete)}.`}</Paragraph>
550
+ <Paragraph tone="secondary" size="body2" measure="none">Payments made on them stay in Payments.</Paragraph>
551
+ </Modal>
552
+ </Center>
553
+ );
554
+ }
555
+ ```
556
+
557
+ ## Native
558
+
559
+ On Apple put the list in edit mode with `EditButton`, bind a `Set` of ids to the `List` selection, and show the actions in a bottom toolbar. On Android show a contextual top bar with the count and the actions while any row is picked.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A visitor or a customer wants to know what changed in the product lately, and may be sent to one change from a message.
4
4
 
5
+ For: a marketing site
6
+
5
7
  ## Do
6
8
 
7
9
  - Use `PageHeader` with `level={1}`: the title 'Changelog' is the one level 1 heading, with a `lede` that says the order.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A dashboard shows how a count moved over its range, day by day or week by week.
4
4
 
5
+ For: an app
6
+
5
7
  ## Do
6
8
 
7
9
  - Follow the rule 'A number shows its unit and never shows 0 for unknown'. The axis shows a number from 10,000 up in its short form, and the readout and the table show it exact.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A person signed up, and the product sent a link to confirm their email.
4
4
 
5
+ For: an app
6
+
5
7
  ## Do
6
8
 
7
9
  - Name the page 'Check your email' in a `Heading` with `level={1}`, with a `Mail` icon above it.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A page shows code that a person reads, or copies to run.
4
4
 
5
+ For: a marketing site
6
+
5
7
  ## Do
6
8
 
7
9
  - Use `CodeBlock` for `block`, with a `label` that names what the code is, such as 'ask.ts' or 'Set up the client'. The label names the block, its scroll region and its Copy Button.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A person filters a list by a word, and the list should keep its room when they are not typing.
4
4
 
5
+ For: an app
6
+
5
7
  ## Do
6
8
 
7
9
  - Use an `IconButton` with `iconName="Search"` beside the list's heading, and open a `<Popover returnFocus aria-label="Search">` with a search `TextField` from it.
@@ -2,6 +2,8 @@
2
2
 
3
3
  A person reads comments left on a piece of work, opens one, and reads and answers its thread.
4
4
 
5
+ For: an app
6
+
5
7
  ## Do
6
8
 
7
9
  - Follow the cases 'Message row' and 'Message composer'.
@@ -0,0 +1 @@
1
+ export default function ComparisonPageTable(): import("react").JSX.Element;