oneslash-design-system 2.23.1 → 2.24.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 (78) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +13 -2
  3. package/dist/cases/activity-timeline/activity.d.ts +1 -0
  4. package/dist/cases/activity-timeline/activity.jsx +43 -0
  5. package/dist/cases/activity-timeline/versions.d.ts +1 -0
  6. package/dist/cases/activity-timeline/versions.jsx +130 -0
  7. package/dist/cases/activity-timeline.md +315 -0
  8. package/dist/cases/agent-plan-proposal.md +1 -0
  9. package/dist/cases/ask-page/answered.d.ts +1 -0
  10. package/dist/cases/ask-page/answered.jsx +240 -0
  11. package/dist/cases/ask-page/first-visit.d.ts +1 -0
  12. package/dist/cases/ask-page/first-visit.jsx +118 -0
  13. package/dist/cases/ask-page.md +542 -0
  14. package/dist/cases/chart/bars.d.ts +1 -0
  15. package/dist/cases/chart/bars.jsx +83 -0
  16. package/dist/cases/chart/lines.d.ts +1 -0
  17. package/dist/cases/chart/lines.jsx +71 -0
  18. package/dist/cases/chart.md +258 -0
  19. package/dist/cases/comment-thread/card.d.ts +1 -0
  20. package/dist/cases/comment-thread/card.jsx +141 -0
  21. package/dist/cases/comment-thread/thread.d.ts +1 -0
  22. package/dist/cases/comment-thread/thread.jsx +87 -0
  23. package/dist/cases/comment-thread.md +349 -0
  24. package/dist/cases/dashboard/numbers-first.jsx +62 -1
  25. package/dist/cases/dashboard.md +75 -3
  26. package/dist/cases/leaderboard/ranked.d.ts +1 -0
  27. package/dist/cases/leaderboard/ranked.jsx +44 -0
  28. package/dist/cases/leaderboard/table.d.ts +1 -0
  29. package/dist/cases/leaderboard/table.jsx +87 -0
  30. package/dist/cases/leaderboard.md +177 -0
  31. package/dist/cases/number-format.md +4 -2
  32. package/dist/cases/onboarding/checklist.d.ts +1 -0
  33. package/dist/cases/onboarding/checklist.jsx +92 -0
  34. package/dist/cases/onboarding/steps.d.ts +3 -0
  35. package/dist/cases/onboarding/steps.jsx +177 -0
  36. package/dist/cases/onboarding.md +368 -0
  37. package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
  38. package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
  39. package/dist/cases/plan-sign-off/team.d.ts +1 -0
  40. package/dist/cases/plan-sign-off/team.jsx +213 -0
  41. package/dist/cases/plan-sign-off.md +541 -0
  42. package/dist/cases/stat-row.md +1 -1
  43. package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
  44. package/dist/cases/task-header/agent-sets-status.jsx +164 -0
  45. package/dist/cases/task-header/people-change-status.d.ts +1 -0
  46. package/dist/cases/task-header/people-change-status.jsx +175 -0
  47. package/dist/cases/task-header.md +576 -0
  48. package/dist/cases.json +645 -7
  49. package/dist/components/barChart.d.ts +35 -0
  50. package/dist/components/barChart.jsx +90 -0
  51. package/dist/components/heading.d.ts +2 -2
  52. package/dist/components/heading.jsx +5 -3
  53. package/dist/components/lineChart.d.ts +39 -0
  54. package/dist/components/lineChart.jsx +128 -0
  55. package/dist/components/timeline.d.ts +32 -0
  56. package/dist/components/timeline.jsx +54 -0
  57. package/dist/components/titleBar.d.ts +3 -1
  58. package/dist/components/titleBar.jsx +9 -4
  59. package/dist/internal/chart.d.ts +39 -0
  60. package/dist/internal/chart.js +110 -0
  61. package/dist/internal/chartFrame.d.ts +29 -0
  62. package/dist/internal/chartFrame.jsx +57 -0
  63. package/dist/native-mapping.json +19 -1
  64. package/dist/stories/BarChart.stories.d.ts +10 -0
  65. package/dist/stories/BarChart.stories.jsx +104 -0
  66. package/dist/stories/Cases.generated.stories.d.ts +16 -0
  67. package/dist/stories/Cases.generated.stories.jsx +32 -0
  68. package/dist/stories/Heading.stories.d.ts +1 -0
  69. package/dist/stories/Heading.stories.jsx +17 -0
  70. package/dist/stories/LineChart.stories.d.ts +9 -0
  71. package/dist/stories/LineChart.stories.jsx +34 -0
  72. package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
  73. package/dist/stories/Onboarding.probe.stories.jsx +12 -0
  74. package/dist/stories/Timeline.stories.d.ts +8 -0
  75. package/dist/stories/Timeline.stories.jsx +49 -0
  76. package/dist/stories/TitleBar.stories.d.ts +1 -0
  77. package/dist/stories/TitleBar.stories.jsx +13 -0
  78. package/package.json +1 -1
@@ -0,0 +1,368 @@
1
+ # First-run setup
2
+
3
+ A person has just signed up, and the app needs a few things from them before it works or before it is fully set up.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A form error shows next to the problem'.
8
+ - Ask only for what the app cannot work without. Everything else goes in the checklist or in Settings.
9
+ - Say the count of steps up front, in words above the heading: 'Step 2 of 3'.
10
+ - Center each step in `<Center width="form">`, and title it with a `Heading level={1}` that names the step: 'Name your workspace'.
11
+ - Give the heading a `ref` and `tabIndex={-1}`, and move focus to it on every step change, so a screen reader hears where the person is.
12
+ - Put each step in its own `Form`. 'Continue' is the primary Button and submits it. Give the last step 'Go to Workspace'.
13
+ - Give every step after the first a tertiary 'Back'. Keep what the person typed in state, so Back shows it again.
14
+ - Save each step when the person continues. A person who leaves comes back to the first step not done, with what they entered.
15
+ - Make Back and Continue again change what was saved, never make it twice: the same workspace name goes on at once, and only new addresses are invited.
16
+ - Give an optional step a tertiary 'Skip for Now'. It sends nothing and goes on at once. The last step says what was sent, counting invites sent before Back.
17
+ - Make the pressed Button `loading` while the request runs, and keep the step, its fields and its label on screen.
18
+ - Keep the step and what was typed when a request fails. Show an inline error `Alert` at the top of the form, above the fields and the Buttons.
19
+ - Show a field's error on submit, under the field: 'Enter a name for your workspace.'
20
+ - Show what can wait as a `SettingsSection` on the home page: a `Progress kind="share"` with `valueText` such as '2 of 4 done', then a `StepList` of done and waiting steps.
21
+ - Link each waiting step to the place where it is done, such as 'Connect Calendar'.
22
+ - Say 'Acme is set up.' in an inline success `Alert` once every step is done, and offer a tertiary 'Hide Checklist'. Move focus to the page's heading when it hides.
23
+
24
+ ## Don't
25
+
26
+ - Do not show progress as a bar of colored segments with no words.
27
+ - Do not disable Continue until a field is filled. Show the error on submit.
28
+ - Do not swap the step for a spinner while a request runs.
29
+ - Do not make a tour of the interface a step. Show help where the person needs it.
30
+ - Do not lose what the person typed when they go Back or a request fails.
31
+ - Do not make a second workspace or send an invite twice when the person goes Back and on again.
32
+ - Do not put a step the app can work without before the app. Put it in the checklist.
33
+
34
+ ## Option: Steps before the app
35
+
36
+ Use when: Two to four steps a new person must pass before the app works, such as naming a workspace.
37
+
38
+ Uses: `Alert`, `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Paragraph`, `Stack`, `TextField`
39
+
40
+ ```tsx
41
+ 'use client';
42
+ import { useEffect, useRef, useState } from 'react';
43
+ import Heading from 'oneslash-design-system/components/heading';
44
+ import Paragraph from 'oneslash-design-system/components/paragraph';
45
+ import Form from 'oneslash-design-system/components/form';
46
+ import TextField from 'oneslash-design-system/components/textField';
47
+ import Alert from 'oneslash-design-system/components/alert';
48
+ import Button from 'oneslash-design-system/components/button';
49
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
50
+
51
+ const titles = ['Name your workspace', 'Invite your team', 'You are set'];
52
+
53
+ // A small check: some text, an @, then some text.
54
+ function looksLikeEmail(value: string) {
55
+ return /^[^@\s]+@[^@\s]+$/.test(value);
56
+ }
57
+
58
+ function addresses(text: string) {
59
+ return text.split(',').map((a) => a.trim()).filter(Boolean);
60
+ }
61
+
62
+ // `failOn` makes the workspace request fail once, so a test can see the error. A real app leaves it out.
63
+ // A real app saves each step on Continue. A person who leaves comes back to the first step not done,
64
+ // with what they entered, and the steps before it show what was saved.
65
+ export default function OnboardingSteps({ failOn }: { failOn?: 'workspace' } = {}) {
66
+ const [step, setStep] = useState(0);
67
+ // What the person typed stays in state, so Back shows it again.
68
+ const [name, setName] = useState('');
69
+ const [emails, setEmails] = useState('');
70
+ const [nameError, setNameError] = useState('');
71
+ const [emailError, setEmailError] = useState('');
72
+ const [error, setError] = useState('');
73
+ const [loading, setLoading] = useState(false);
74
+ // What was saved: the workspace's name once it exists, and the addresses already invited.
75
+ // Back and Continue again never make the workspace twice or send an invite twice.
76
+ const [created, setCreated] = useState<string | null>(null);
77
+ const [sent, setSent] = useState<string[]>([]);
78
+ const heading = useRef<HTMLHeadingElement>(null);
79
+ const failed = useRef(false);
80
+ const timer = useRef<ReturnType<typeof setTimeout>>();
81
+ // Set on a step change; run after the next render, once the new heading is on screen.
82
+ const focusNext = useRef<() => void>();
83
+
84
+ // Stops the request if the example goes away before it ends.
85
+ useEffect(() => () => clearTimeout(timer.current), []);
86
+
87
+ useEffect(() => {
88
+ const move = focusNext.current;
89
+ focusNext.current = undefined;
90
+ move?.();
91
+ });
92
+
93
+ // Each step change moves focus to the step's heading, so a screen reader reads where the person is.
94
+ // The first step keeps focus where the page put it.
95
+ function go(next: number) {
96
+ setError('');
97
+ setNameError('');
98
+ setEmailError('');
99
+ setStep(next);
100
+ focusNext.current = () => heading.current?.focus({ preventScroll: true });
101
+ }
102
+
103
+ function back() {
104
+ if (loading) return;
105
+ go(step - 1);
106
+ }
107
+
108
+ function createWorkspace() {
109
+ if (loading) return;
110
+ setError('');
111
+ setNameError('');
112
+ const wanted = name.trim();
113
+ if (!wanted) {
114
+ setNameError('Enter a name for your workspace.');
115
+ return;
116
+ }
117
+ // Already saved with this name: go on with no request.
118
+ if (wanted === created) {
119
+ go(1);
120
+ return;
121
+ }
122
+ setLoading(true);
123
+ // Stands in for the request to the server: it creates the workspace, or renames it when it exists.
124
+ // The step and its Buttons stay while it runs.
125
+ timer.current = setTimeout(() => {
126
+ setLoading(false);
127
+ if (failOn === 'workspace' && !failed.current) {
128
+ failed.current = true;
129
+ setError(created === null ? 'The workspace was not created. Try again.' : 'The workspace was not renamed. Try again.');
130
+ return;
131
+ }
132
+ setCreated(wanted);
133
+ go(1);
134
+ }, 1200);
135
+ }
136
+
137
+ function sendInvites() {
138
+ if (loading) return;
139
+ setError('');
140
+ setEmailError('');
141
+ const list = addresses(emails);
142
+ if (list.length === 0 && sent.length === 0) {
143
+ setEmailError('Enter an email address, or choose Skip for Now.');
144
+ return;
145
+ }
146
+ const wrong = list.find((a) => !looksLikeEmail(a));
147
+ if (wrong) {
148
+ setEmailError(`Check ${wrong}. Enter an address like name@example.com.`);
149
+ return;
150
+ }
151
+ // Only addresses not yet invited are sent. With none, the step goes on at once.
152
+ const fresh = list.filter((a) => !sent.includes(a));
153
+ if (fresh.length === 0) {
154
+ go(2);
155
+ return;
156
+ }
157
+ setLoading(true);
158
+ // Stands in for the request to the server. A failed request shows an inline error Alert, as on the first step.
159
+ timer.current = setTimeout(() => {
160
+ setLoading(false);
161
+ setSent((s) => [...s, ...fresh]);
162
+ go(2);
163
+ }, 1200);
164
+ }
165
+
166
+ // Skip sends nothing and goes on at once. Invites already sent stay sent.
167
+ function skip() {
168
+ if (loading) return;
169
+ go(2);
170
+ }
171
+
172
+ const workspace = created ?? name.trim();
173
+
174
+ return (
175
+ <Center width="form">
176
+ <Stack gap="small">
177
+ {/* The count of steps is said up front, in words. */}
178
+ <Paragraph size="body2" tone="secondary" measure="none">{`Step ${step + 1} of ${titles.length}`}</Paragraph>
179
+ <Heading ref={heading} tabIndex={-1} level={1} size="h5">{titles[step]}</Heading>
180
+ </Stack>
181
+
182
+ {step === 0 && (
183
+ <Form aria-label={titles[0]} onSubmit={createWorkspace}>
184
+ {/* A failed request keeps the step and what was typed, and says so above the fields and the Buttons. */}
185
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
186
+ <TextField
187
+ id="onboarding-steps-workspace"
188
+ label="Workspace name"
189
+ value={name}
190
+ disabled={loading}
191
+ error={Boolean(nameError)}
192
+ errorText={nameError}
193
+ helperText="Your team works here. You can change the name later."
194
+ onChange={(e) => { setName(e.target.value); setNameError(''); }}
195
+ />
196
+ <Cluster gap="small">
197
+ <Button size="medium" type="primary" state="enabled" label="Continue" htmlType="submit" loading={loading} />
198
+ </Cluster>
199
+ </Form>
200
+ )}
201
+
202
+ {step === 1 && (
203
+ <Form aria-label={titles[1]} onSubmit={sendInvites}>
204
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={() => setError('')} />}
205
+ <Paragraph measure="none">{`Invite the people you work with to ${workspace}. You can skip this and invite them later.`}</Paragraph>
206
+ <TextField
207
+ id="onboarding-steps-emails"
208
+ label="Email addresses"
209
+ type="email"
210
+ value={emails}
211
+ disabled={loading}
212
+ error={Boolean(emailError)}
213
+ errorText={emailError}
214
+ helperText="Separate addresses with commas."
215
+ onChange={(e) => { setEmails(e.target.value); setEmailError(''); }}
216
+ />
217
+ <Cluster gap="small" justify="between">
218
+ <Button size="medium" type="tertiary" state="enabled" label="Back" decoIcon="ChevronLeft" onClickButton={back} />
219
+ <Cluster gap="small">
220
+ <Button size="medium" type="tertiary" state="enabled" label="Skip for Now" onClickButton={skip} />
221
+ <Button size="medium" type="primary" state="enabled" label="Continue" htmlType="submit" loading={loading} />
222
+ </Cluster>
223
+ </Cluster>
224
+ </Form>
225
+ )}
226
+
227
+ {step === 2 && (
228
+ <Stack gap="large">
229
+ <Paragraph measure="none">
230
+ {sent.length === 0
231
+ ? `${workspace} is ready. No invites were sent. You can invite your team later in Settings, under Members.`
232
+ : `${workspace} is ready. Invites went to ${sent.length} ${sent.length === 1 ? 'person' : 'people'}.`}
233
+ </Paragraph>
234
+ <Cluster gap="small" justify="between">
235
+ <Button size="medium" type="tertiary" state="enabled" label="Back" decoIcon="ChevronLeft" onClickButton={back} />
236
+ {/* A real app goes to the new workspace. */}
237
+ <Button size="medium" type="primary" state="enabled" label="Go to Workspace" href="/workspace" />
238
+ </Cluster>
239
+ </Stack>
240
+ )}
241
+ </Center>
242
+ );
243
+ }
244
+ ```
245
+
246
+ ## Option: Checklist on the home page
247
+
248
+ Use when: Things to set up that can wait, shown on the home page until they are done.
249
+
250
+ Uses: `Alert`, `Button`, `Center`, `Cluster`, `Heading`, `Paragraph`, `Progress`, `SettingsSection`, `Stack`, `StepList`, `Toaster`, `dismissToast`, `toast`
251
+
252
+ ```tsx
253
+ 'use client';
254
+ import { useEffect, useRef, useState } from 'react';
255
+ import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
256
+ import Heading from 'oneslash-design-system/components/heading';
257
+ import Paragraph from 'oneslash-design-system/components/paragraph';
258
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
259
+ import StepList from 'oneslash-design-system/components/stepList';
260
+ import Progress from 'oneslash-design-system/components/progress';
261
+ import Alert from 'oneslash-design-system/components/alert';
262
+ import Button from 'oneslash-design-system/components/button';
263
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
264
+
265
+ type Task = { id: string; label: string; detail: string; action: string; href: string; done: boolean };
266
+
267
+ // Things to set up that can wait. The app works without them. A real app reads them from the server.
268
+ const first: Task[] = [
269
+ { id: 'workspace', label: 'Name your workspace', detail: 'Done Nov 14, 2026', action: 'Rename Workspace', href: '/settings/workspace', done: true },
270
+ { id: 'invite', label: 'Invite your team', detail: 'Done Nov 14, 2026', action: 'Invite People', href: '/settings/members', done: true },
271
+ { id: 'calendar', label: 'Connect a calendar', detail: 'In Settings, under Integrations', action: 'Connect Calendar', href: '/settings/integrations', done: false },
272
+ { id: 'project', label: 'Create your first project', detail: 'On the Projects page', action: 'Create Project', href: '/projects/new', done: false },
273
+ ];
274
+
275
+ type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
276
+
277
+ export default function OnboardingChecklist() {
278
+ const [tasks, setTasks] = useState(first);
279
+ const [hidden, setHidden] = useState(false);
280
+ const page = useRef<HTMLHeadingElement>(null);
281
+ const hideButton = useRef<Focusable>(null);
282
+ const firstAction = useRef<Focusable>(null);
283
+ const toastIds = useRef<string[]>([]);
284
+ // Where focus goes after the next render, once the element it goes to is on screen.
285
+ const focusNext = useRef<() => void>();
286
+
287
+ // On unmount it closes every toast it opened.
288
+ useEffect(() => () => {
289
+ toastIds.current.forEach((id) => dismissToast(id));
290
+ toastIds.current = [];
291
+ }, []);
292
+
293
+ useEffect(() => {
294
+ const move = focusNext.current;
295
+ focusNext.current = undefined;
296
+ move?.();
297
+ });
298
+
299
+ const done = tasks.filter((t) => t.done).length;
300
+ const waiting = tasks.filter((t) => !t.done);
301
+ const allDone = waiting.length === 0;
302
+
303
+ // A real app lets the link go to its page, and the step is done when the person comes back.
304
+ // The example marks it done here, so the end of the checklist shows.
305
+ function finish(event: { preventDefault: () => void }, id: string) {
306
+ event.preventDefault();
307
+ const next = tasks.map((t) => (t.id === id ? { ...t, done: true, detail: 'Done Nov 16, 2026' } : t));
308
+ setTasks(next);
309
+ // The pressed link goes away. Focus goes to the next link, or to 'Hide Checklist' after the last one.
310
+ focusNext.current = next.every((t) => t.done)
311
+ ? () => hideButton.current?.focus({ preventScroll: true })
312
+ : () => firstAction.current?.focus({ preventScroll: true });
313
+ }
314
+
315
+ // The checklist leaves the home page for good. Its Button goes with it, so focus goes to the page's heading.
316
+ function hide() {
317
+ setHidden(true);
318
+ toastIds.current.push(toast({ type: 'success', message: 'Setup checklist hidden.' }));
319
+ focusNext.current = () => page.current?.focus({ preventScroll: true });
320
+ }
321
+
322
+ return (
323
+ <Center width="page">
324
+ <Stack gap="xlarge">
325
+ <Heading ref={page} tabIndex={-1} level={1} size="h5">Home</Heading>
326
+ {!hidden && (
327
+ <SettingsSection title="Set up Acme" description="The app works without these. Finish them when you are ready." id="onboarding-checklist-setup">
328
+ <Stack gap="large">
329
+ <Progress kind="share" label="Set up" value={done} max={tasks.length} valueText={`${done} of ${tasks.length} done`} />
330
+ <StepList aria-label="Setup steps" steps={tasks.map((t) => ({ label: t.label, detail: t.detail, status: t.done ? 'done' : 'waiting' }))} />
331
+ {allDone ? (
332
+ <Stack gap="medium" align="start">
333
+ {/* An inline Alert is a polite status, so a screen reader hears it. */}
334
+ <Alert variant="inline" type="success" autoDismiss={false} message="Acme is set up." />
335
+ <Button ref={hideButton} size="small" type="tertiary" state="enabled" label="Hide Checklist" onClickButton={hide} />
336
+ </Stack>
337
+ ) : (
338
+ // Each waiting step links to the place where it is done.
339
+ <Cluster gap="small">
340
+ {waiting.map((t, i) => (
341
+ <Button
342
+ key={t.id}
343
+ ref={i === 0 ? firstAction : undefined}
344
+ size="small"
345
+ type="secondary"
346
+ state="enabled"
347
+ label={t.action}
348
+ href={t.href}
349
+ onClickButton={(event: { preventDefault: () => void }) => finish(event, t.id)}
350
+ />
351
+ ))}
352
+ </Cluster>
353
+ )}
354
+ </Stack>
355
+ </SettingsSection>
356
+ )}
357
+ <Paragraph tone="secondary" measure="none">Your projects and comments show here.</Paragraph>
358
+ </Stack>
359
+ {/* A real app mounts one Toaster near its root. */}
360
+ <Toaster />
361
+ </Center>
362
+ );
363
+ }
364
+ ```
365
+
366
+ ## Native
367
+
368
+ On Apple show the steps as a `NavigationStack` that pushes one `Form` per step, with Back in the navigation bar and Continue in a bottom bar, and post a screen-changed accessibility notification on each step. On Android use one screen per step with a `TopAppBar` back arrow, and the checklist as a card on the home screen.
@@ -0,0 +1 @@
1
+ export default function PlanSignOffOneApprover(): import("react").JSX.Element;
@@ -0,0 +1,129 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import AppShell from '../../components/appShell';
4
+ import SidePane from '../../components/sidePane';
5
+ import Navigation from '../../components/navigation';
6
+ import MenuItem from '../../components/menuItem';
7
+ import TitleBar from '../../components/titleBar';
8
+ import IconButton from '../../components/iconButton';
9
+ import Tooltip from '../../components/tooltip';
10
+ import Heading from '../../components/heading';
11
+ import Paragraph from '../../components/paragraph';
12
+ import List from '../../components/list';
13
+ import Line from '../../components/line';
14
+ import Button from '../../components/button';
15
+ import Textarea from '../../components/textarea';
16
+ import Alert from '../../components/alert';
17
+ import { Cluster, Stack } from '../../components/layout';
18
+ var task = 'Launch checklist';
19
+ // The plan Acme Agent wrote, as headed sections.
20
+ var steps = [
21
+ 'Acme Agent updates the home page and its tests.',
22
+ 'Omar Reyes writes the new copy.',
23
+ 'Mia Park checks the screens on a phone.',
24
+ 'Ben Carter merges the pull request.',
25
+ ];
26
+ // The places. A real app lets each link go to its page.
27
+ var sidebar = (<Navigation aria-label="Main">
28
+ <MenuItem size="small" label="Tasks" iconName="ListChecks" href="/tasks" isSelected aria-current="page" onClick={function (event) { return event.preventDefault(); }}/>
29
+ </Navigation>);
30
+ export default function PlanSignOffOneApprover() {
31
+ var _a = useState(false), navOpen = _a[0], setNavOpen = _a[1];
32
+ // The person opened the plan from the task header. The example starts with the pane open.
33
+ var _b = useState(true), open = _b[0], setOpen = _b[1];
34
+ var _c = useState('open'), status = _c[0], setStatus = _c[1];
35
+ var _d = useState(null), pending = _d[0], setPending = _d[1];
36
+ var _e = useState(''), draft = _e[0], setDraft = _e[1];
37
+ var pane = useRef(null);
38
+ var requestButton = useRef(null);
39
+ var timer = useRef();
40
+ // Where focus goes after the next render, once the element it goes to is on screen.
41
+ var focusNext = useRef();
42
+ // On unmount it stops the request.
43
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
44
+ useEffect(function () {
45
+ var move = focusNext.current;
46
+ focusNext.current = undefined;
47
+ move === null || move === void 0 ? void 0 : move();
48
+ });
49
+ // Acme Agent starts only after 'Approve'. 'Cancel' marks the plan Cancelled, and the agent does nothing.
50
+ // Either way the Buttons go, and nothing takes their place, so focus goes to the pane's title.
51
+ function decide(action) {
52
+ if (pending || status !== 'open')
53
+ return;
54
+ setPending(action);
55
+ // Stands in for the request to the server.
56
+ timer.current = setTimeout(function () {
57
+ setPending(null);
58
+ setStatus(action === 'cancel' ? 'cancelled' : 'approved');
59
+ focusNext.current = function () { var _a; return (_a = pane.current) === null || _a === void 0 ? void 0 : _a.focus(); };
60
+ }, 1200);
61
+ }
62
+ function startRequest() {
63
+ if (pending)
64
+ return;
65
+ setDraft('');
66
+ setStatus('requesting');
67
+ }
68
+ // 'Discard' leaves the field and keeps the plan waiting. Focus goes back to 'Request Changes'.
69
+ function discard() {
70
+ setStatus('open');
71
+ focusNext.current = function () { var _a; return (_a = requestButton.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
72
+ }
73
+ var empty = draft.trim() === '';
74
+ // 'Send' gives the agent what should change. The Buttons go, and the agent rewrites the plan.
75
+ function send() {
76
+ if (pending || empty)
77
+ return;
78
+ setPending('send');
79
+ // Stands in for the request to the server.
80
+ timer.current = setTimeout(function () {
81
+ setPending(null);
82
+ setStatus('redoing');
83
+ focusNext.current = function () { var _a; return (_a = pane.current) === null || _a === void 0 ? void 0 : _a.focus(); };
84
+ }, 1200);
85
+ }
86
+ return (<AppShell title="Tasks" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} pane={open && (<SidePane ref={pane} title="Plan" onClose={function () { return setOpen(false); }}>
87
+ <Stack gap="large">
88
+ <Stack gap="small">
89
+ <Heading level={3} size="subtitle1">Goal</Heading>
90
+ <Paragraph measure="none">Ship the new home page on Nov 20, 2026, with the sign-up form above the pricing table.</Paragraph>
91
+ </Stack>
92
+ <Stack gap="small">
93
+ <Heading level={3} size="subtitle1">Steps</Heading>
94
+ <List marker="number" items={steps}/>
95
+ </Stack>
96
+ <Stack gap="small">
97
+ <Heading level={3} size="subtitle1">Out of scope</Heading>
98
+ <Paragraph measure="none">The pricing page stays as it is.</Paragraph>
99
+ </Stack>
100
+ <Paragraph size="caption" tone="secondary" measure="none">Written by Acme Agent, Nov 16, 2026, 2:40 PM</Paragraph>
101
+ <Line />
102
+ {/* The approval comes last, after the whole plan. */}
103
+ <Stack gap="medium">
104
+ <Heading level={3} size="subtitle1">Approval</Heading>
105
+ {status === 'approved' ? (
106
+ // An inline Alert is a polite status, so a screen reader hears it.
107
+ <Alert variant="inline" type="success" autoDismiss={false} message="Approved by Dana Lee, Nov 16, 2026, 2:52 PM. Acme Agent starts the work."/>) : status === 'cancelled' ? (<Alert variant="inline" type="info" autoDismiss={false} message="Cancelled. Nothing was changed."/>) : status === 'redoing' ? (<Alert variant="inline" type="info" autoDismiss={false} message="Acme Agent is rewriting the plan. The new plan shows here when it is ready."/>) : (<Paragraph measure="none">Acme Agent starts once Dana Lee approves this plan.</Paragraph>)}
108
+ {status === 'requesting' && (<Textarea id="plan-sign-off-change-request" label="What should change?" value={draft} onChange={function (e) { return setDraft(e.target.value); }} onSubmit={send} autoFocus disabled={pending === 'send'}/>)}
109
+ {status === 'open' && (<Cluster gap="small">
110
+ <Button size="small" type="tertiary" state={pending === 'approve' ? 'disabled' : 'enabled'} label="Cancel" loading={pending === 'cancel'} onClickButton={function () { return decide('cancel'); }}/>
111
+ <Button ref={requestButton} size="small" type="secondary" state={pending ? 'disabled' : 'enabled'} label="Request Changes" onClickButton={startRequest}/>
112
+ {/* The product writes this label, never the agent. */}
113
+ <Button size="small" type="primary" state={pending === 'cancel' ? 'disabled' : 'enabled'} label="Approve" loading={pending === 'approve'} onClickButton={function () { return decide('approve'); }}/>
114
+ </Cluster>)}
115
+ {status === 'requesting' && (<Cluster gap="small">
116
+ <Button size="small" type="tertiary" state={pending === 'send' ? 'disabled' : 'enabled'} label="Discard" onClickButton={discard}/>
117
+ <Button size="small" type="primary" state={empty ? 'disabled' : 'enabled'} label="Send" loading={pending === 'send'} onClickButton={send}/>
118
+ </Cluster>)}
119
+ </Stack>
120
+ </Stack>
121
+ </SidePane>)}>
122
+ <Stack gap="large">
123
+ <TitleBar title={task} actions={<Tooltip title="Plan">
124
+ <IconButton color="iconOnly" state={open ? 'selected' : 'enabled'} size="medium" iconName="FileText" ariaLabel={"Show the plan for ".concat(task)} aria-expanded={open} onClick={function () { var _a; return (open ? (_a = pane.current) === null || _a === void 0 ? void 0 : _a.focus() : setOpen(true)); }}/>
125
+ </Tooltip>}/>
126
+ <Paragraph tone="secondary" measure="none">Acme Agent wrote a plan for this task. It waits for Dana Lee to approve it.</Paragraph>
127
+ </Stack>
128
+ </AppShell>);
129
+ }
@@ -0,0 +1 @@
1
+ export default function PlanSignOffTeam(): import("react").JSX.Element;