oneslash-design-system 2.23.1 → 2.25.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.
- package/README.md +1 -1
- package/dist/DESIGN.md +20 -5
- package/dist/cases/activity-timeline/activity.d.ts +1 -0
- package/dist/cases/activity-timeline/activity.jsx +43 -0
- package/dist/cases/activity-timeline/versions.d.ts +1 -0
- package/dist/cases/activity-timeline/versions.jsx +130 -0
- package/dist/cases/activity-timeline.md +315 -0
- package/dist/cases/agent-plan-proposal.md +1 -0
- package/dist/cases/ask-page/answered.d.ts +1 -0
- package/dist/cases/ask-page/answered.jsx +248 -0
- package/dist/cases/ask-page/first-visit.d.ts +1 -0
- package/dist/cases/ask-page/first-visit.jsx +118 -0
- package/dist/cases/ask-page.md +551 -0
- package/dist/cases/billing-page/self-serve.jsx +4 -4
- package/dist/cases/billing-page/trial.d.ts +1 -0
- package/dist/cases/billing-page/trial.jsx +115 -0
- package/dist/cases/billing-page.md +166 -5
- package/dist/cases/chart/bars.d.ts +1 -0
- package/dist/cases/chart/bars.jsx +83 -0
- package/dist/cases/chart/lines.d.ts +1 -0
- package/dist/cases/chart/lines.jsx +71 -0
- package/dist/cases/chart.md +258 -0
- package/dist/cases/collapsible-search/popover.jsx +1 -1
- package/dist/cases/collapsible-search.md +2 -2
- package/dist/cases/comment-thread/card.d.ts +1 -0
- package/dist/cases/comment-thread/card.jsx +141 -0
- package/dist/cases/comment-thread/thread.d.ts +1 -0
- package/dist/cases/comment-thread/thread.jsx +87 -0
- package/dist/cases/comment-thread.md +349 -0
- package/dist/cases/cookie-choice/banner.d.ts +1 -0
- package/dist/cases/cookie-choice/banner.jsx +82 -0
- package/dist/cases/cookie-choice/settings.d.ts +1 -0
- package/dist/cases/cookie-choice/settings.jsx +75 -0
- package/dist/cases/cookie-choice.md +234 -0
- package/dist/cases/dashboard/numbers-first.jsx +63 -2
- package/dist/cases/dashboard/work-first.jsx +1 -1
- package/dist/cases/dashboard.md +77 -5
- package/dist/cases/data-table-page/all-rows.jsx +1 -1
- package/dist/cases/data-table-page/paged.jsx +1 -1
- package/dist/cases/data-table-page.md +2 -2
- package/dist/cases/invoice-list/table.jsx +21 -9
- package/dist/cases/invoice-list.md +27 -12
- package/dist/cases/leaderboard/ranked.d.ts +1 -0
- package/dist/cases/leaderboard/ranked.jsx +44 -0
- package/dist/cases/leaderboard/table.d.ts +1 -0
- package/dist/cases/leaderboard/table.jsx +87 -0
- package/dist/cases/leaderboard.md +177 -0
- package/dist/cases/message-reactions/picker.jsx +1 -1
- package/dist/cases/message-reactions.md +2 -2
- package/dist/cases/message-row.md +2 -1
- package/dist/cases/newsletter-signup/inline.d.ts +1 -0
- package/dist/cases/newsletter-signup/inline.jsx +72 -0
- package/dist/cases/newsletter-signup/section.d.ts +1 -0
- package/dist/cases/newsletter-signup/section.jsx +72 -0
- package/dist/cases/newsletter-signup.md +234 -0
- package/dist/cases/number-format.md +9 -3
- package/dist/cases/onboarding/checklist.d.ts +1 -0
- package/dist/cases/onboarding/checklist.jsx +92 -0
- package/dist/cases/onboarding/steps.d.ts +3 -0
- package/dist/cases/onboarding/steps.jsx +177 -0
- package/dist/cases/onboarding.md +368 -0
- package/dist/cases/people-row/stack.jsx +1 -1
- package/dist/cases/people-row.md +2 -2
- package/dist/cases/plan-comparison/table.d.ts +1 -0
- package/dist/cases/plan-comparison/table.jsx +47 -0
- package/dist/cases/plan-comparison.md +94 -0
- package/dist/cases/plan-picker.md +1 -0
- package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
- package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
- package/dist/cases/plan-sign-off/team.d.ts +1 -0
- package/dist/cases/plan-sign-off/team.jsx +213 -0
- package/dist/cases/plan-sign-off.md +541 -0
- package/dist/cases/pricing-section.md +1 -1
- package/dist/cases/site-footer/columns.jsx +2 -1
- package/dist/cases/site-footer.md +3 -1
- package/dist/cases/stat-row/tiles.jsx +2 -1
- package/dist/cases/stat-row.md +5 -2
- package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
- package/dist/cases/task-header/agent-sets-status.jsx +164 -0
- package/dist/cases/task-header/people-change-status.d.ts +1 -0
- package/dist/cases/task-header/people-change-status.jsx +175 -0
- package/dist/cases/task-header.md +576 -0
- package/dist/cases.json +883 -30
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +5 -5
- package/dist/components/barChart.d.ts +35 -0
- package/dist/components/barChart.jsx +92 -0
- package/dist/components/dateField.jsx +1 -1
- package/dist/components/formatNumber.d.ts +10 -2
- package/dist/components/formatNumber.js +44 -9
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +5 -3
- package/dist/components/layout.d.ts +4 -2
- package/dist/components/layout.jsx +13 -2
- package/dist/components/lineChart.d.ts +39 -0
- package/dist/components/lineChart.jsx +128 -0
- package/dist/components/markdown.d.ts +24 -0
- package/dist/components/markdown.jsx +81 -0
- package/dist/components/pageShell.d.ts +3 -3
- package/dist/components/pageShell.jsx +6 -5
- package/dist/components/popover.d.ts +5 -1
- package/dist/components/popover.jsx +3 -2
- package/dist/components/progress.jsx +1 -1
- package/dist/components/select.jsx +5 -2
- package/dist/components/statTile.d.ts +1 -1
- package/dist/components/statTile.jsx +7 -2
- package/dist/components/tableCell.d.ts +4 -3
- package/dist/components/tableCell.jsx +2 -2
- package/dist/components/timeline.d.ts +32 -0
- package/dist/components/timeline.jsx +54 -0
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +9 -4
- package/dist/components/toaster.jsx +81 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/chart.d.ts +39 -0
- package/dist/internal/chart.js +110 -0
- package/dist/internal/chartFrame.d.ts +29 -0
- package/dist/internal/chartFrame.jsx +57 -0
- package/dist/internal/markdown.d.ts +40 -0
- package/dist/internal/markdown.js +577 -0
- package/dist/internal/toaster.d.ts +2 -0
- package/dist/internal/toaster.js +8 -0
- package/dist/native-mapping.json +28 -4
- package/dist/stories/BarChart.stories.d.ts +10 -0
- package/dist/stories/BarChart.stories.jsx +104 -0
- package/dist/stories/Cases.generated.stories.d.ts +22 -0
- package/dist/stories/Cases.generated.stories.jsx +44 -0
- package/dist/stories/Heading.stories.d.ts +1 -0
- package/dist/stories/Heading.stories.jsx +17 -0
- package/dist/stories/LineChart.stories.d.ts +9 -0
- package/dist/stories/LineChart.stories.jsx +34 -0
- package/dist/stories/Markdown.stories.d.ts +9 -0
- package/dist/stories/Markdown.stories.jsx +66 -0
- package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
- package/dist/stories/Onboarding.probe.stories.jsx +12 -0
- package/dist/stories/Popover.stories.d.ts +2 -0
- package/dist/stories/Popover.stories.jsx +33 -0
- package/dist/stories/StatTile.stories.d.ts +4 -0
- package/dist/stories/StatTile.stories.jsx +47 -2
- package/dist/stories/Timeline.stories.d.ts +8 -0
- package/dist/stories/Timeline.stories.jsx +49 -0
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +13 -0
- package/dist/stories/Toaster.stories.d.ts +4 -0
- package/dist/stories/Toaster.stories.jsx +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,164 @@
|
|
|
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 TitleBar from '../../components/titleBar';
|
|
7
|
+
import Tag from '../../components/tag';
|
|
8
|
+
import AvatarStack from '../../components/avatarStack';
|
|
9
|
+
import Button from '../../components/button';
|
|
10
|
+
import IconButton from '../../components/iconButton';
|
|
11
|
+
import Tooltip from '../../components/tooltip';
|
|
12
|
+
import Popover from '../../components/popover';
|
|
13
|
+
import Menu from '../../components/menu';
|
|
14
|
+
import MenuItem from '../../components/menuItem';
|
|
15
|
+
import Line from '../../components/line';
|
|
16
|
+
import List from '../../components/list';
|
|
17
|
+
import Modal from '../../components/modal';
|
|
18
|
+
import Timeline from '../../components/timeline';
|
|
19
|
+
import Paragraph from '../../components/paragraph';
|
|
20
|
+
import Toaster, { toast, dismissToast } from '../../components/toaster';
|
|
21
|
+
import { Stack } from '../../components/layout';
|
|
22
|
+
var task = 'Launch checklist';
|
|
23
|
+
// The person who started the task comes first, here and in every list of these people.
|
|
24
|
+
var people = [
|
|
25
|
+
{ name: 'Ben Carter', role: 'Admin' },
|
|
26
|
+
{ name: 'Dana Lee', role: 'Member' },
|
|
27
|
+
{ name: 'Omar Reyes', role: 'Member' },
|
|
28
|
+
{ name: 'Mia Park', role: 'Member' },
|
|
29
|
+
{ name: 'Leo Grant', role: 'Guest' },
|
|
30
|
+
{ name: 'Ana Silva', role: 'Guest' },
|
|
31
|
+
];
|
|
32
|
+
var history = [
|
|
33
|
+
{ id: 'h3', title: 'Dana Lee approved the plan', when: 'Nov 16, 2026, 2:52 PM', dateTime: '2026-11-16T14:52', actor: { name: 'Dana Lee' } },
|
|
34
|
+
{ id: 'h2', title: 'Acme Agent wrote the plan', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', actor: { name: 'Acme Agent', agent: true } },
|
|
35
|
+
{ id: 'h1', title: 'Ben Carter created the task', when: 'Nov 15, 2026, 4:02 PM', dateTime: '2026-11-15T16:02', actor: { name: 'Ben Carter' } },
|
|
36
|
+
];
|
|
37
|
+
// The places. A real app lets each link go to its page.
|
|
38
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
39
|
+
<MenuItem size="small" label="Tasks" iconName="ListChecks" href="/tasks" isSelected aria-current="page" onClick={function (event) { return event.preventDefault(); }}/>
|
|
40
|
+
</Navigation>);
|
|
41
|
+
export default function TaskHeaderAgentSetsStatus() {
|
|
42
|
+
var _a = useState(false), navOpen = _a[0], setNavOpen = _a[1];
|
|
43
|
+
var _b = useState(null), peopleAnchor = _b[0], setPeopleAnchor = _b[1];
|
|
44
|
+
// Which More button opened the menu: on a phone the menu also holds History. It stays set while the menu fades out.
|
|
45
|
+
var _c = useState('wide'), moreFrom = _c[0], setMoreFrom = _c[1];
|
|
46
|
+
var _d = useState(null), moreAnchor = _d[0], setMoreAnchor = _d[1];
|
|
47
|
+
var _e = useState(false), moreOpen = _e[0], setMoreOpen = _e[1];
|
|
48
|
+
// One pane at a time. Opening another replaces it.
|
|
49
|
+
var _f = useState(null), pane = _f[0], setPane = _f[1];
|
|
50
|
+
var _g = useState(false), confirming = _g[0], setConfirming = _g[1];
|
|
51
|
+
var _h = useState(false), deleting = _h[0], setDeleting = _h[1];
|
|
52
|
+
var paneRef = useRef(null);
|
|
53
|
+
var moreButtons = useRef({ wide: null, phone: null });
|
|
54
|
+
var timer = useRef();
|
|
55
|
+
var toastIds = useRef([]);
|
|
56
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
57
|
+
var focusNext = useRef();
|
|
58
|
+
// On unmount it stops the request and closes every toast it opened.
|
|
59
|
+
useEffect(function () { return function () {
|
|
60
|
+
clearTimeout(timer.current);
|
|
61
|
+
toastIds.current.forEach(function (id) { return dismissToast(id); });
|
|
62
|
+
toastIds.current = [];
|
|
63
|
+
}; }, []);
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
var move = focusNext.current;
|
|
66
|
+
focusNext.current = undefined;
|
|
67
|
+
move === null || move === void 0 ? void 0 : move();
|
|
68
|
+
});
|
|
69
|
+
// Pressed again while its pane is open, the button brings the pane forward instead of opening a second one.
|
|
70
|
+
function togglePane(id) {
|
|
71
|
+
var _a;
|
|
72
|
+
if (pane === id)
|
|
73
|
+
(_a = paneRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
74
|
+
else
|
|
75
|
+
setPane(id);
|
|
76
|
+
}
|
|
77
|
+
function openMore(from, el) {
|
|
78
|
+
if (moreOpen && moreFrom === from) {
|
|
79
|
+
setMoreOpen(false);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setMoreFrom(from);
|
|
83
|
+
setMoreAnchor(el);
|
|
84
|
+
setMoreOpen(true);
|
|
85
|
+
}
|
|
86
|
+
// Every item closes the menu. The Popover gives focus back to More.
|
|
87
|
+
function choose(action) {
|
|
88
|
+
setMoreOpen(false);
|
|
89
|
+
action();
|
|
90
|
+
}
|
|
91
|
+
// The Modal opens while the menu fades, so it cannot take focus back from the menu item: 'Cancel' sends it to More.
|
|
92
|
+
function keepTask() {
|
|
93
|
+
if (deleting)
|
|
94
|
+
return;
|
|
95
|
+
setConfirming(false);
|
|
96
|
+
focusNext.current = function () { var _a; return (_a = moreButtons.current[moreFrom]) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
|
|
97
|
+
}
|
|
98
|
+
function confirmDelete() {
|
|
99
|
+
if (deleting)
|
|
100
|
+
return;
|
|
101
|
+
setDeleting(true);
|
|
102
|
+
// Stands in for the request to the server. A real app then goes back to the task list.
|
|
103
|
+
timer.current = setTimeout(function () {
|
|
104
|
+
setDeleting(false);
|
|
105
|
+
setConfirming(false);
|
|
106
|
+
toastIds.current.push(toast({ type: 'success', message: "".concat(task, " deleted.") }));
|
|
107
|
+
}, 1200);
|
|
108
|
+
}
|
|
109
|
+
var paneButton = function (id) { return (<Tooltip title={id === 'plan' ? 'Plan' : 'History'}>
|
|
110
|
+
<IconButton color="iconOnly" state={pane === id ? 'selected' : 'enabled'} size="medium" iconName={id === 'plan' ? 'FileText' : 'History'} ariaLabel={id === 'plan' ? "Show the plan for ".concat(task) : "Show the history of ".concat(task)} aria-expanded={pane === id} onClick={function () { return togglePane(id); }}/>
|
|
111
|
+
</Tooltip>); };
|
|
112
|
+
var more = function (from) { return (<Tooltip title="More">
|
|
113
|
+
<IconButton ref={function (el) { moreButtons.current[from] = el; }} color="iconOnly" state={moreOpen && moreFrom === from ? 'selected' : 'enabled'} size="medium" iconName="Ellipsis" ariaLabel={"More actions for ".concat(task)} aria-haspopup="menu" aria-expanded={moreOpen && moreFrom === from} onClick={function (e) { return openMore(from, e.currentTarget); }}/>
|
|
114
|
+
</Tooltip>); };
|
|
115
|
+
return (<AppShell title="Tasks" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} pane={pane && (<SidePane key={pane} ref={paneRef} title={pane === 'plan' ? 'Plan' : 'History'} onClose={function () { return setPane(null); }}>
|
|
116
|
+
{pane === 'plan' ? (<Stack gap="medium">
|
|
117
|
+
<Paragraph measure="none">Ship the new home page on Nov 20, 2026. Omar Reyes writes the copy and Mia Park checks the screens.</Paragraph>
|
|
118
|
+
<Paragraph tone="secondary" size="body2" measure="none">Written by Acme Agent, Nov 16, 2026, 2:40 PM</Paragraph>
|
|
119
|
+
</Stack>) : (<Timeline id="task-header-agent-history" aria-label="History" items={history}/>)}
|
|
120
|
+
</SidePane>)}>
|
|
121
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
122
|
+
<Toaster />
|
|
123
|
+
<Stack gap="large">
|
|
124
|
+
<TitleBar title={task} meta={<>
|
|
125
|
+
{/* Acme Agent and the checks set the state. People read it here and do not change it. */}
|
|
126
|
+
<Tag variant="dot" size="small" label="In progress"/>
|
|
127
|
+
<AvatarStack people={people} aria-label={"Show the ".concat(people.length, " people on ").concat(task)} aria-haspopup="dialog" aria-expanded={peopleAnchor !== null} onClick={function (event) { return setPeopleAnchor(peopleAnchor ? null : event.currentTarget); }}/>
|
|
128
|
+
Due Nov 20, 2026
|
|
129
|
+
</>} actions={<>
|
|
130
|
+
{paneButton('plan')}
|
|
131
|
+
{paneButton('history')}
|
|
132
|
+
{more('wide')}
|
|
133
|
+
</>} phoneActions={<>
|
|
134
|
+
{paneButton('plan')}
|
|
135
|
+
{more('phone')}
|
|
136
|
+
</>}/>
|
|
137
|
+
<Paragraph tone="secondary" measure="none">Acme Agent sets the status as the work moves. It is updating the home page, and Omar Reyes is writing the copy.</Paragraph>
|
|
138
|
+
</Stack>
|
|
139
|
+
<Popover id="task-header-agent-people" open={peopleAnchor !== null} anchorEl={peopleAnchor} onClose={function () { return setPeopleAnchor(null); }} returnFocus aria-label={"People on ".concat(task)}>
|
|
140
|
+
<List items={people.map(function (p) { return "".concat(p.name, ", ").concat(p.role); })}/>
|
|
141
|
+
</Popover>
|
|
142
|
+
<Popover id="task-header-agent-more" open={moreOpen} anchorEl={moreAnchor} onClose={function () { return setMoreOpen(false); }} returnFocus>
|
|
143
|
+
<Menu navigable aria-label={"Actions for ".concat(task)} width={200}>
|
|
144
|
+
{moreFrom === 'phone' && (<>
|
|
145
|
+
<MenuItem size="small" iconName="History" label="History" onClick={function () { return choose(function () { return togglePane('history'); }); }}/>
|
|
146
|
+
<Line />
|
|
147
|
+
</>)}
|
|
148
|
+
{/* A real app opens the Rename Modal of the case 'Rename', and archives the task with a toast. */}
|
|
149
|
+
<MenuItem size="small" iconName="Pencil" label="Rename" onClick={function () { return choose(function () { }); }}/>
|
|
150
|
+
<MenuItem size="small" iconName="Archive" label="Archive" onClick={function () { return choose(function () { }); }}/>
|
|
151
|
+
<Line />
|
|
152
|
+
{/* Delete is last, and danger. */}
|
|
153
|
+
<MenuItem size="small" color="danger" iconName="Trash2" label="Delete Task" onClick={function () { return choose(function () { return setConfirming(true); }); }}/>
|
|
154
|
+
</Menu>
|
|
155
|
+
</Popover>
|
|
156
|
+
{/* The task is a page, not a row in a list, so the confirm is a small Modal, as the case 'Delete confirm' says. */}
|
|
157
|
+
<Modal isOpen={confirming} size="small" title="Delete Task" onClose={keepTask} actions={<>
|
|
158
|
+
<Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={keepTask}/>
|
|
159
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={confirmDelete}/>
|
|
160
|
+
</>}>
|
|
161
|
+
<Paragraph measure="none">This deletes '{task}', its plan and its history.</Paragraph>
|
|
162
|
+
</Modal>
|
|
163
|
+
</AppShell>);
|
|
164
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function TaskHeaderPeopleChangeStatus(): import("react").JSX.Element;
|
|
@@ -0,0 +1,175 @@
|
|
|
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 TitleBar from '../../components/titleBar';
|
|
7
|
+
import Tag from '../../components/tag';
|
|
8
|
+
import AvatarStack from '../../components/avatarStack';
|
|
9
|
+
import Button from '../../components/button';
|
|
10
|
+
import IconButton from '../../components/iconButton';
|
|
11
|
+
import Tooltip from '../../components/tooltip';
|
|
12
|
+
import Popover from '../../components/popover';
|
|
13
|
+
import Menu from '../../components/menu';
|
|
14
|
+
import MenuItem from '../../components/menuItem';
|
|
15
|
+
import Line from '../../components/line';
|
|
16
|
+
import List from '../../components/list';
|
|
17
|
+
import Modal from '../../components/modal';
|
|
18
|
+
import Timeline from '../../components/timeline';
|
|
19
|
+
import Paragraph from '../../components/paragraph';
|
|
20
|
+
import Toaster, { toast, dismissToast } from '../../components/toaster';
|
|
21
|
+
import { Stack } from '../../components/layout';
|
|
22
|
+
var task = 'Launch checklist';
|
|
23
|
+
// A Button and a menu item say the state in Title Case. The Tag says it in sentence case.
|
|
24
|
+
var statuses = [
|
|
25
|
+
{ id: 'to-do', label: 'To Do', tag: 'To do' },
|
|
26
|
+
{ id: 'in-progress', label: 'In Progress', tag: 'In progress' },
|
|
27
|
+
{ id: 'in-review', label: 'In Review', tag: 'In review' },
|
|
28
|
+
{ id: 'done', label: 'Done', tag: 'Done' },
|
|
29
|
+
];
|
|
30
|
+
// The person who started the task comes first, here and in every list of these people.
|
|
31
|
+
var people = [
|
|
32
|
+
{ name: 'Ben Carter', role: 'Admin' },
|
|
33
|
+
{ name: 'Dana Lee', role: 'Member' },
|
|
34
|
+
{ name: 'Omar Reyes', role: 'Member' },
|
|
35
|
+
{ name: 'Mia Park', role: 'Member' },
|
|
36
|
+
{ name: 'Leo Grant', role: 'Guest' },
|
|
37
|
+
{ name: 'Ana Silva', role: 'Guest' },
|
|
38
|
+
];
|
|
39
|
+
var history = [
|
|
40
|
+
{ id: 'h3', title: 'Dana Lee approved the plan', when: 'Nov 16, 2026, 2:52 PM', dateTime: '2026-11-16T14:52', actor: { name: 'Dana Lee' } },
|
|
41
|
+
{ id: 'h2', title: 'Acme Agent wrote the plan', when: 'Nov 16, 2026, 2:40 PM', dateTime: '2026-11-16T14:40', actor: { name: 'Acme Agent', agent: true } },
|
|
42
|
+
{ id: 'h1', title: 'Ben Carter created the task', when: 'Nov 15, 2026, 4:02 PM', dateTime: '2026-11-15T16:02', actor: { name: 'Ben Carter' } },
|
|
43
|
+
];
|
|
44
|
+
// The places. A real app lets each link go to its page.
|
|
45
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
46
|
+
<MenuItem size="small" label="Tasks" iconName="ListChecks" href="/tasks" isSelected aria-current="page" onClick={function (event) { return event.preventDefault(); }}/>
|
|
47
|
+
</Navigation>);
|
|
48
|
+
export default function TaskHeaderPeopleChangeStatus() {
|
|
49
|
+
var _a;
|
|
50
|
+
var _b = useState(false), navOpen = _b[0], setNavOpen = _b[1];
|
|
51
|
+
var _c = useState('in-progress'), status = _c[0], setStatus = _c[1];
|
|
52
|
+
var _d = useState(null), statusAnchor = _d[0], setStatusAnchor = _d[1];
|
|
53
|
+
var _e = useState(null), peopleAnchor = _e[0], setPeopleAnchor = _e[1];
|
|
54
|
+
var _f = useState(null), moreAnchor = _f[0], setMoreAnchor = _f[1];
|
|
55
|
+
var _g = useState(false), moreOpen = _g[0], setMoreOpen = _g[1];
|
|
56
|
+
// One pane at a time. Opening another replaces it.
|
|
57
|
+
var _h = useState(null), pane = _h[0], setPane = _h[1];
|
|
58
|
+
var _j = useState(false), confirming = _j[0], setConfirming = _j[1];
|
|
59
|
+
var _k = useState(false), deleting = _k[0], setDeleting = _k[1];
|
|
60
|
+
var paneRef = useRef(null);
|
|
61
|
+
var moreButton = useRef(null);
|
|
62
|
+
var timer = useRef();
|
|
63
|
+
var toastIds = useRef([]);
|
|
64
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
65
|
+
var focusNext = useRef();
|
|
66
|
+
// On unmount it stops the request and closes every toast it opened.
|
|
67
|
+
useEffect(function () { return function () {
|
|
68
|
+
clearTimeout(timer.current);
|
|
69
|
+
toastIds.current.forEach(function (id) { return dismissToast(id); });
|
|
70
|
+
toastIds.current = [];
|
|
71
|
+
}; }, []);
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
var move = focusNext.current;
|
|
74
|
+
focusNext.current = undefined;
|
|
75
|
+
move === null || move === void 0 ? void 0 : move();
|
|
76
|
+
});
|
|
77
|
+
var current = (_a = statuses.find(function (s) { return s.id === status; })) !== null && _a !== void 0 ? _a : statuses[0];
|
|
78
|
+
// The new state shows in the Tag and on the Button at once. The Popover gives focus back to the Button.
|
|
79
|
+
function chooseStatus(id) {
|
|
80
|
+
setStatusAnchor(null);
|
|
81
|
+
// A real app sends the new state to the server here.
|
|
82
|
+
setStatus(id);
|
|
83
|
+
}
|
|
84
|
+
// Pressed again while its pane is open, the button brings the pane forward instead of opening a second one.
|
|
85
|
+
function togglePane(id) {
|
|
86
|
+
var _a;
|
|
87
|
+
if (pane === id)
|
|
88
|
+
(_a = paneRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
89
|
+
else
|
|
90
|
+
setPane(id);
|
|
91
|
+
}
|
|
92
|
+
function openMore(el) {
|
|
93
|
+
setMoreAnchor(el);
|
|
94
|
+
setMoreOpen(function (o) { return !o; });
|
|
95
|
+
}
|
|
96
|
+
// Every item closes the menu. The Popover gives focus back to More.
|
|
97
|
+
function choose(action) {
|
|
98
|
+
setMoreOpen(false);
|
|
99
|
+
action();
|
|
100
|
+
}
|
|
101
|
+
// The Modal opens while the menu fades, so it cannot take focus back from the menu item: 'Cancel' sends it to More.
|
|
102
|
+
function keepTask() {
|
|
103
|
+
if (deleting)
|
|
104
|
+
return;
|
|
105
|
+
setConfirming(false);
|
|
106
|
+
focusNext.current = function () { var _a; return (_a = moreButton.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
|
|
107
|
+
}
|
|
108
|
+
function confirmDelete() {
|
|
109
|
+
if (deleting)
|
|
110
|
+
return;
|
|
111
|
+
setDeleting(true);
|
|
112
|
+
// Stands in for the request to the server. A real app then goes back to the task list.
|
|
113
|
+
timer.current = setTimeout(function () {
|
|
114
|
+
setDeleting(false);
|
|
115
|
+
setConfirming(false);
|
|
116
|
+
toastIds.current.push(toast({ type: 'success', message: "".concat(task, " deleted.") }));
|
|
117
|
+
}, 1200);
|
|
118
|
+
}
|
|
119
|
+
var statusButton = (<Button size="small" type="secondary" state="enabled" label={"Status: ".concat(current.label)} aria-haspopup="menu" aria-expanded={statusAnchor !== null} onClickButton={function (e) { return setStatusAnchor(statusAnchor ? null : e.currentTarget); }}/>);
|
|
120
|
+
var paneButton = function (id) { return (<Tooltip title={id === 'plan' ? 'Plan' : 'History'}>
|
|
121
|
+
<IconButton color="iconOnly" state={pane === id ? 'selected' : 'enabled'} size="medium" iconName={id === 'plan' ? 'FileText' : 'History'} ariaLabel={id === 'plan' ? "Show the plan for ".concat(task) : "Show the history of ".concat(task)} aria-expanded={pane === id} onClick={function () { return togglePane(id); }}/>
|
|
122
|
+
</Tooltip>); };
|
|
123
|
+
var more = (<Tooltip title="More">
|
|
124
|
+
<IconButton ref={moreButton} color="iconOnly" state={moreOpen ? 'selected' : 'enabled'} size="medium" iconName="Ellipsis" ariaLabel={"More actions for ".concat(task)} aria-haspopup="menu" aria-expanded={moreOpen} onClick={function (e) { return openMore(e.currentTarget); }}/>
|
|
125
|
+
</Tooltip>);
|
|
126
|
+
return (<AppShell title="Tasks" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} pane={pane && (<SidePane key={pane} ref={paneRef} title={pane === 'plan' ? 'Plan' : 'History'} onClose={function () { return setPane(null); }}>
|
|
127
|
+
{pane === 'plan' ? (<Stack gap="medium">
|
|
128
|
+
<Paragraph measure="none">Ship the new home page on Nov 20, 2026. Omar Reyes writes the copy and Mia Park checks the screens.</Paragraph>
|
|
129
|
+
<Paragraph tone="secondary" size="body2" measure="none">Written by Acme Agent, Nov 16, 2026, 2:40 PM</Paragraph>
|
|
130
|
+
</Stack>) : (<Timeline id="task-header-history" aria-label="History" items={history}/>)}
|
|
131
|
+
</SidePane>)}>
|
|
132
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
133
|
+
<Toaster />
|
|
134
|
+
<Stack gap="large">
|
|
135
|
+
<TitleBar title={task} meta={<>
|
|
136
|
+
<Tag variant="dot" size="small" label={current.tag}/>
|
|
137
|
+
<AvatarStack people={people} aria-label={"Show the ".concat(people.length, " people on ").concat(task)} aria-haspopup="dialog" aria-expanded={peopleAnchor !== null} onClick={function (event) { return setPeopleAnchor(peopleAnchor ? null : event.currentTarget); }}/>
|
|
138
|
+
Due Nov 20, 2026
|
|
139
|
+
</>}
|
|
140
|
+
// The status Button is too wide to sit beside the title on a phone, so below md the actions take their own line.
|
|
141
|
+
actions={<>
|
|
142
|
+
{statusButton}
|
|
143
|
+
{paneButton('plan')}
|
|
144
|
+
{paneButton('history')}
|
|
145
|
+
{more}
|
|
146
|
+
</>} actionsBelow/>
|
|
147
|
+
<Paragraph tone="secondary" measure="none">Acme Agent is updating the home page. Omar Reyes is writing the copy.</Paragraph>
|
|
148
|
+
</Stack>
|
|
149
|
+
<Popover id="task-header-status" open={statusAnchor !== null} anchorEl={statusAnchor} onClose={function () { return setStatusAnchor(null); }} returnFocus>
|
|
150
|
+
<Menu navigable aria-label="Task status" width={200}>
|
|
151
|
+
{statuses.map(function (s) { return (<MenuItem key={s.id} size="small" label={s.label} isSelected={s.id === status} onClick={function () { return chooseStatus(s.id); }}/>); })}
|
|
152
|
+
</Menu>
|
|
153
|
+
</Popover>
|
|
154
|
+
<Popover id="task-header-people" open={peopleAnchor !== null} anchorEl={peopleAnchor} onClose={function () { return setPeopleAnchor(null); }} returnFocus aria-label={"People on ".concat(task)}>
|
|
155
|
+
<List items={people.map(function (p) { return "".concat(p.name, ", ").concat(p.role); })}/>
|
|
156
|
+
</Popover>
|
|
157
|
+
<Popover id="task-header-more" open={moreOpen} anchorEl={moreAnchor} onClose={function () { return setMoreOpen(false); }} returnFocus>
|
|
158
|
+
<Menu navigable aria-label={"Actions for ".concat(task)} width={200}>
|
|
159
|
+
{/* A real app opens the Rename Modal of the case 'Rename', and archives the task with a toast. */}
|
|
160
|
+
<MenuItem size="small" iconName="Pencil" label="Rename" onClick={function () { return choose(function () { }); }}/>
|
|
161
|
+
<MenuItem size="small" iconName="Archive" label="Archive" onClick={function () { return choose(function () { }); }}/>
|
|
162
|
+
<Line />
|
|
163
|
+
{/* Delete is last, and danger. */}
|
|
164
|
+
<MenuItem size="small" color="danger" iconName="Trash2" label="Delete Task" onClick={function () { return choose(function () { return setConfirming(true); }); }}/>
|
|
165
|
+
</Menu>
|
|
166
|
+
</Popover>
|
|
167
|
+
{/* The task is a page, not a row in a list, so the confirm is a small Modal, as the case 'Delete confirm' says. */}
|
|
168
|
+
<Modal isOpen={confirming} size="small" title="Delete Task" onClose={keepTask} actions={<>
|
|
169
|
+
<Button size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={keepTask}/>
|
|
170
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Delete" loading={deleting} onClickButton={confirmDelete}/>
|
|
171
|
+
</>}>
|
|
172
|
+
<Paragraph measure="none">This deletes '{task}', its plan and its history.</Paragraph>
|
|
173
|
+
</Modal>
|
|
174
|
+
</AppShell>);
|
|
175
|
+
}
|