oneslash-design-system 2.23.0 → 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 (81) 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/popover.jsx +7 -2
  56. package/dist/components/timeline.d.ts +32 -0
  57. package/dist/components/timeline.jsx +54 -0
  58. package/dist/components/titleBar.d.ts +3 -1
  59. package/dist/components/titleBar.jsx +9 -4
  60. package/dist/internal/chart.d.ts +39 -0
  61. package/dist/internal/chart.js +110 -0
  62. package/dist/internal/chartFrame.d.ts +29 -0
  63. package/dist/internal/chartFrame.jsx +57 -0
  64. package/dist/native-mapping.json +19 -1
  65. package/dist/stories/BarChart.stories.d.ts +10 -0
  66. package/dist/stories/BarChart.stories.jsx +104 -0
  67. package/dist/stories/Cases.generated.stories.d.ts +16 -0
  68. package/dist/stories/Cases.generated.stories.jsx +32 -0
  69. package/dist/stories/Heading.stories.d.ts +1 -0
  70. package/dist/stories/Heading.stories.jsx +17 -0
  71. package/dist/stories/LineChart.stories.d.ts +9 -0
  72. package/dist/stories/LineChart.stories.jsx +34 -0
  73. package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
  74. package/dist/stories/Onboarding.probe.stories.jsx +12 -0
  75. package/dist/stories/Popover.stories.d.ts +1 -0
  76. package/dist/stories/Popover.stories.jsx +17 -0
  77. package/dist/stories/Timeline.stories.d.ts +8 -0
  78. package/dist/stories/Timeline.stories.jsx +49 -0
  79. package/dist/stories/TitleBar.stories.d.ts +1 -0
  80. package/dist/stories/TitleBar.stories.jsx +13 -0
  81. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ export default function LeaderboardTable(): import("react").JSX.Element;
@@ -0,0 +1,87 @@
1
+ 'use client';
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
+ if (ar || !(i in from)) {
16
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
+ ar[i] = from[i];
18
+ }
19
+ }
20
+ return to.concat(ar || Array.prototype.slice.call(from));
21
+ };
22
+ import { useState } from 'react';
23
+ import Heading from '../../components/heading';
24
+ import SettingsSection from '../../components/settingsSection';
25
+ import UserImage from '../../components/userImage';
26
+ import Paragraph from '../../components/paragraph';
27
+ import Pagination from '../../components/pagination';
28
+ import TableContainer from '../../components/tableContainer';
29
+ import TableHeader from '../../components/tableHeader';
30
+ import TableHeaderCell from '../../components/tableHeaderCell';
31
+ import TableRow from '../../components/tableRow';
32
+ import TableCell from '../../components/tableCell';
33
+ import { formatChange, formatCount } from '../../components/formatNumber';
34
+ import { Center, Cluster, Stack } from '../../components/layout';
35
+ // A real app counts these on the server. `previous` is last week's count of comments.
36
+ var people = [
37
+ { name: 'Ben Carter', comments: 42, replies: 31, previous: 0 },
38
+ { name: 'Omar Reyes', comments: 58, replies: 44, previous: 52 },
39
+ { name: 'Ana Silva', comments: 9, replies: 15, previous: 12 },
40
+ { name: 'Mia Park', comments: 42, replies: 18, previous: 40 },
41
+ { name: 'Leo Grant', comments: 21, replies: 9, previous: 14 },
42
+ { name: 'Dana Lee', comments: 30, replies: 27, previous: 30 },
43
+ ];
44
+ // Sorted by comments, largest first. People with the same count share a rank, and the next rank skips: 1, 2, 2, 4.
45
+ var sorted = __spreadArray([], people, true).sort(function (a, b) { return b.comments - a.comments || a.name.localeCompare(b.name); });
46
+ var ranked = sorted.map(function (p) { return (__assign(__assign({}, p), { rank: sorted.findIndex(function (q) { return q.comments === p.comments; }) + 1 })); });
47
+ var PAGE_SIZE = 25;
48
+ export default function LeaderboardTable() {
49
+ var _a = useState(1), page = _a[0], setPage = _a[1];
50
+ var pageCount = Math.ceil(ranked.length / PAGE_SIZE);
51
+ var rows = ranked.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
52
+ return (<Center width="page">
53
+ <Stack gap="xlarge">
54
+ <Heading level={1} size="h5">People</Heading>
55
+ <SettingsSection title="Comments by person this week" description="Everyone who commented from Nov 10 to Nov 16, 2026, by comments" id="leaderboard-table-people">
56
+ <Stack gap="large">
57
+ {/* A named table sits in a region that scrolls sideways by itself, so the page never does. */}
58
+ <TableContainer aria-label="Comments by person this week" minWidth="640px">
59
+ <TableHeader>
60
+ <TableRow>
61
+ <TableHeaderCell align="right" width="64px">Rank</TableHeaderCell>
62
+ <TableHeaderCell>Person</TableHeaderCell>
63
+ <TableHeaderCell align="right" width="110px" sort="descending">Comments</TableHeaderCell>
64
+ <TableHeaderCell align="right" width="90px">Replies</TableHeaderCell>
65
+ <TableHeaderCell align="right" width="200px">Change</TableHeaderCell>
66
+ </TableRow>
67
+ </TableHeader>
68
+ {rows.map(function (p) { return (<TableRow key={p.name}>
69
+ <TableCell align="right" width="64px">{String(p.rank)}</TableCell>
70
+ <TableCell>
71
+ <Cluster gap="small">
72
+ <UserImage userHandle={p.name} decorative size={24}/>
73
+ <Paragraph size="body2" measure="none">{p.name}</Paragraph>
74
+ </Cluster>
75
+ </TableCell>
76
+ <TableCell align="right" width="110px">{formatCount(p.comments)}</TableCell>
77
+ <TableCell align="right" width="90px">{formatCount(p.replies)}</TableCell>
78
+ <TableCell align="right" width="200px">{formatChange(p.comments, p.previous, 'week').text}</TableCell>
79
+ </TableRow>); })}
80
+ </TableContainer>
81
+ {/* Past 25 people the table pages. With one page, Pagination draws nothing. */}
82
+ <Pagination page={page} pageCount={pageCount} onPageChange={setPage} aria-label="Pages of people" scrollTargetId="leaderboard-table-people"/>
83
+ </Stack>
84
+ </SettingsSection>
85
+ </Stack>
86
+ </Center>);
87
+ }
@@ -0,0 +1,177 @@
1
+ # Leaderboard
2
+
3
+ A dashboard shows who did the most of something over its range, such as who left the most comments this week.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A number shows its unit and never shows 0 for unknown'.
8
+ - Say what is counted and over which range, in the title and the description: 'Most active this week', 'Comments each person left from Nov 10 to Nov 16, 2026'.
9
+ - Show the top five in a `SettingsSection` as a `List marker="number"`, so the list's numbers are the ranks.
10
+ - Make each row a `Cluster justify="between"`: the face as `UserImage decorative size={24}` and the name, then the count with its unit, '42 comments', and the change beside it. On a phone they wrap under the name.
11
+ - Write the change in words with `formatChange`: 'Up 12% from last week', 'New this week'.
12
+ - List people with the same count in the top five by name. The table shows the shared rank.
13
+ - Show the person viewing their own row under the list, with their rank, when they are not in the top five.
14
+ - End the list with a `Link` 'See All People' to the table of everyone.
15
+ - Show everyone in a table, as the case 'Breakdown of a total' says: Rank, Person, Comments, Replies and Change. Mark the sorted column with `sort`, and right-align the numbers. Leave out the Total row: a ranking is read by person.
16
+ - Give people with the same count the same rank in the table, and skip the next: '2', '2', '4'.
17
+ - Page the table with `Pagination` past 25 people.
18
+ - Leave out the person viewing only when the heading says so, such as 'Most active this week, besides you'.
19
+
20
+ ## Don't
21
+
22
+ - Do not give the top people medals, crowns or their own colors.
23
+ - Do not show the change as an arrow alone, or as a percent with no period.
24
+ - Do not draw a bar against the top person. The rank and the number say it, and a bar with no total reads like a share.
25
+ - Do not show a count with no unit.
26
+
27
+ ## Option: Ranked list
28
+
29
+ Use when: The top five or so people, read in order on a dashboard.
30
+
31
+ Uses: `Center`, `Cluster`, `Heading`, `Link`, `List`, `Paragraph`, `SettingsSection`, `Stack`, `UserImage`, `formatChange`, `formatCount`
32
+
33
+ ```tsx
34
+ 'use client';
35
+ import Heading from 'oneslash-design-system/components/heading';
36
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
37
+ import List from 'oneslash-design-system/components/list';
38
+ import UserImage from 'oneslash-design-system/components/userImage';
39
+ import Paragraph from 'oneslash-design-system/components/paragraph';
40
+ import Link from 'oneslash-design-system/components/link';
41
+ import { formatChange, formatCount } from 'oneslash-design-system/components/formatNumber';
42
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
43
+
44
+ // A real app counts these on the server, largest first. `previous` is last week's count.
45
+ // The table example has a tie for second; this list has none, since its numbers are the ranks.
46
+ const people = [
47
+ { name: 'Omar Reyes', comments: 58, previous: 52 },
48
+ { name: 'Ben Carter', comments: 42, previous: 0 },
49
+ { name: 'Mia Park', comments: 37, previous: 41 },
50
+ { name: 'Dana Lee', comments: 30, previous: 30 },
51
+ { name: 'Leo Grant', comments: 21, previous: 14 },
52
+ { name: 'Ana Silva', comments: 9, previous: 12 },
53
+ ];
54
+
55
+ const top = people.slice(0, 5);
56
+
57
+ export default function LeaderboardRanked() {
58
+ return (
59
+ <Center width="page">
60
+ <Stack gap="xlarge">
61
+ <Heading level={1} size="h5">Dashboard</Heading>
62
+ <SettingsSection title="Most active this week" description="Comments each person left from Nov 10 to Nov 16, 2026" id="leaderboard-ranked-people">
63
+ <Stack gap="large">
64
+ {/* The list's numbers are the ranks. The count and the change say the rest, so there are no bars. */}
65
+ <List
66
+ marker="number"
67
+ items={top.map((p) => (
68
+ <Cluster key={p.name} justify="between" gap="small">
69
+ <Cluster gap="small">
70
+ <UserImage userHandle={p.name} decorative size={24} />
71
+ <Paragraph measure="none">{p.name}</Paragraph>
72
+ </Cluster>
73
+ <Cluster gap="small">
74
+ <Paragraph measure="none">{`${formatCount(p.comments)} ${p.comments === 1 ? 'comment' : 'comments'}`}</Paragraph>
75
+ <Paragraph size="body2" tone="secondary" measure="none">{formatChange(p.comments, p.previous, 'week').text}</Paragraph>
76
+ </Cluster>
77
+ </Cluster>
78
+ ))}
79
+ />
80
+ {/* A real app goes to the table of everyone. */}
81
+ <Link href="/people" size="body2">See All People</Link>
82
+ </Stack>
83
+ </SettingsSection>
84
+ </Stack>
85
+ </Center>
86
+ );
87
+ }
88
+ ```
89
+
90
+ ## Option: Table of everyone
91
+
92
+ Use when: Everyone, sorted and compared on more than one number.
93
+
94
+ Uses: `Center`, `Cluster`, `Heading`, `Pagination`, `Paragraph`, `SettingsSection`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `UserImage`, `formatChange`, `formatCount`
95
+
96
+ ```tsx
97
+ 'use client';
98
+ import { useState } from 'react';
99
+ import Heading from 'oneslash-design-system/components/heading';
100
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
101
+ import UserImage from 'oneslash-design-system/components/userImage';
102
+ import Paragraph from 'oneslash-design-system/components/paragraph';
103
+ import Pagination from 'oneslash-design-system/components/pagination';
104
+ import TableContainer from 'oneslash-design-system/components/tableContainer';
105
+ import TableHeader from 'oneslash-design-system/components/tableHeader';
106
+ import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
107
+ import TableRow from 'oneslash-design-system/components/tableRow';
108
+ import TableCell from 'oneslash-design-system/components/tableCell';
109
+ import { formatChange, formatCount } from 'oneslash-design-system/components/formatNumber';
110
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
111
+
112
+ // A real app counts these on the server. `previous` is last week's count of comments.
113
+ const people = [
114
+ { name: 'Ben Carter', comments: 42, replies: 31, previous: 0 },
115
+ { name: 'Omar Reyes', comments: 58, replies: 44, previous: 52 },
116
+ { name: 'Ana Silva', comments: 9, replies: 15, previous: 12 },
117
+ { name: 'Mia Park', comments: 42, replies: 18, previous: 40 },
118
+ { name: 'Leo Grant', comments: 21, replies: 9, previous: 14 },
119
+ { name: 'Dana Lee', comments: 30, replies: 27, previous: 30 },
120
+ ];
121
+
122
+ // Sorted by comments, largest first. People with the same count share a rank, and the next rank skips: 1, 2, 2, 4.
123
+ const sorted = [...people].sort((a, b) => b.comments - a.comments || a.name.localeCompare(b.name));
124
+ const ranked = sorted.map((p) => ({ ...p, rank: sorted.findIndex((q) => q.comments === p.comments) + 1 }));
125
+
126
+ const PAGE_SIZE = 25;
127
+
128
+ export default function LeaderboardTable() {
129
+ const [page, setPage] = useState(1);
130
+ const pageCount = Math.ceil(ranked.length / PAGE_SIZE);
131
+ const rows = ranked.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
132
+
133
+ return (
134
+ <Center width="page">
135
+ <Stack gap="xlarge">
136
+ <Heading level={1} size="h5">People</Heading>
137
+ <SettingsSection title="Comments by person this week" description="Everyone who commented from Nov 10 to Nov 16, 2026, by comments" id="leaderboard-table-people">
138
+ <Stack gap="large">
139
+ {/* A named table sits in a region that scrolls sideways by itself, so the page never does. */}
140
+ <TableContainer aria-label="Comments by person this week" minWidth="640px">
141
+ <TableHeader>
142
+ <TableRow>
143
+ <TableHeaderCell align="right" width="64px">Rank</TableHeaderCell>
144
+ <TableHeaderCell>Person</TableHeaderCell>
145
+ <TableHeaderCell align="right" width="110px" sort="descending">Comments</TableHeaderCell>
146
+ <TableHeaderCell align="right" width="90px">Replies</TableHeaderCell>
147
+ <TableHeaderCell align="right" width="200px">Change</TableHeaderCell>
148
+ </TableRow>
149
+ </TableHeader>
150
+ {rows.map((p) => (
151
+ <TableRow key={p.name}>
152
+ <TableCell align="right" width="64px">{String(p.rank)}</TableCell>
153
+ <TableCell>
154
+ <Cluster gap="small">
155
+ <UserImage userHandle={p.name} decorative size={24} />
156
+ <Paragraph size="body2" measure="none">{p.name}</Paragraph>
157
+ </Cluster>
158
+ </TableCell>
159
+ <TableCell align="right" width="110px">{formatCount(p.comments)}</TableCell>
160
+ <TableCell align="right" width="90px">{formatCount(p.replies)}</TableCell>
161
+ <TableCell align="right" width="200px">{formatChange(p.comments, p.previous, 'week').text}</TableCell>
162
+ </TableRow>
163
+ ))}
164
+ </TableContainer>
165
+ {/* Past 25 people the table pages. With one page, Pagination draws nothing. */}
166
+ <Pagination page={page} pageCount={pageCount} onPageChange={setPage} aria-label="Pages of people" scrollTargetId="leaderboard-table-people" />
167
+ </Stack>
168
+ </SettingsSection>
169
+ </Stack>
170
+ </Center>
171
+ );
172
+ }
173
+ ```
174
+
175
+ ## Native
176
+
177
+ On Apple use a `List` of rows with the rank, a face, the name and the count with `monospacedDigit()`, and a `Table` for everyone on a Mac or iPad. On Android use a `LazyColumn` of rows, and a table screen for everyone.
@@ -4,7 +4,7 @@ A page shows counts, money, sizes, shares or changes.
4
4
 
5
5
  ## Answer
6
6
 
7
- Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. Money has its symbol and two decimals: '$1,240.00'. A cost under a cent reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. It has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.
7
+ Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. On a chart's axis, a number from 10,000 up shows its short form too: '12.4K'. The chart's readout and its table show the exact number. Money has its symbol and two decimals: '$1,240.00'. A cost under a cent reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. It has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.
8
8
 
9
9
  ## Why
10
10
 
@@ -14,6 +14,7 @@ One page that rounds a cost to four decimals and another that rounds it to two m
14
14
 
15
15
  - Show a count whole and grouped: '1,240'. In a tile, show a count or an amount from 10,000 up in its short form: '12.4K', '$12.4K'.
16
16
  - Show the exact number in a table, right-aligned.
17
+ - Show a number from 10,000 up on a chart's axis in its short form too: '12.4K'. Show the exact number in the chart's readout and its table.
17
18
  - Show money with its symbol and two decimals, and a cost under a cent as '< $0.01'.
18
19
  - Show a time as '340 ms', '1.2 s' or '2 h 24 min'. Show a share as a whole percent, and a small one as '< 1%'. Show a size in base 1024: '52 MB', '1.2 GB'.
19
20
  - Put the unit in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'.
@@ -29,8 +30,9 @@ One page that rounds a cost to four decimals and another that rounds it to two m
29
30
  - Do not round a cost to four decimals in one place and two in another.
30
31
  - Do not color a change green or red. More is not good or bad by itself.
31
32
  - Do not show the compact form ('12.4K') in a table, or give a screen reader only the compact form.
33
+ - Do not show only the short form in a chart. Its readout and table are exact.
32
34
  - Do not show 100% for a share that is not the whole.
33
35
 
34
36
  ## Native
35
37
 
36
- On Apple use `FormatStyle` for numbers, money and percents, and `ByteCountFormatStyle` with the `.memory` style for sizes, which is base 1024. On Android use `NumberFormat`.
38
+ On Apple use `FormatStyle` for numbers, money and percents, and `ByteCountFormatStyle` with the `.memory` style for sizes, which is base 1024. On Android use `NumberFormat`. On a chart's axis use `.notation(.compactName)` on Apple and `CompactDecimalFormat` on Android.
@@ -0,0 +1 @@
1
+ export default function OnboardingChecklist(): import("react").JSX.Element;
@@ -0,0 +1,92 @@
1
+ 'use client';
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ import { useEffect, useRef, useState } from 'react';
14
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
15
+ import Heading from '../../components/heading';
16
+ import Paragraph from '../../components/paragraph';
17
+ import SettingsSection from '../../components/settingsSection';
18
+ import StepList from '../../components/stepList';
19
+ import Progress from '../../components/progress';
20
+ import Alert from '../../components/alert';
21
+ import Button from '../../components/button';
22
+ import { Center, Cluster, Stack } from '../../components/layout';
23
+ // Things to set up that can wait. The app works without them. A real app reads them from the server.
24
+ var first = [
25
+ { id: 'workspace', label: 'Name your workspace', detail: 'Done Nov 14, 2026', action: 'Rename Workspace', href: '/settings/workspace', done: true },
26
+ { id: 'invite', label: 'Invite your team', detail: 'Done Nov 14, 2026', action: 'Invite People', href: '/settings/members', done: true },
27
+ { id: 'calendar', label: 'Connect a calendar', detail: 'In Settings, under Integrations', action: 'Connect Calendar', href: '/settings/integrations', done: false },
28
+ { id: 'project', label: 'Create your first project', detail: 'On the Projects page', action: 'Create Project', href: '/projects/new', done: false },
29
+ ];
30
+ export default function OnboardingChecklist() {
31
+ var _a = useState(first), tasks = _a[0], setTasks = _a[1];
32
+ var _b = useState(false), hidden = _b[0], setHidden = _b[1];
33
+ var page = useRef(null);
34
+ var hideButton = useRef(null);
35
+ var firstAction = useRef(null);
36
+ var toastIds = useRef([]);
37
+ // Where focus goes after the next render, once the element it goes to is on screen.
38
+ var focusNext = useRef();
39
+ // On unmount it closes every toast it opened.
40
+ useEffect(function () { return function () {
41
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
42
+ toastIds.current = [];
43
+ }; }, []);
44
+ useEffect(function () {
45
+ var move = focusNext.current;
46
+ focusNext.current = undefined;
47
+ move === null || move === void 0 ? void 0 : move();
48
+ });
49
+ var done = tasks.filter(function (t) { return t.done; }).length;
50
+ var waiting = tasks.filter(function (t) { return !t.done; });
51
+ var allDone = waiting.length === 0;
52
+ // A real app lets the link go to its page, and the step is done when the person comes back.
53
+ // The example marks it done here, so the end of the checklist shows.
54
+ function finish(event, id) {
55
+ event.preventDefault();
56
+ var next = tasks.map(function (t) { return (t.id === id ? __assign(__assign({}, t), { done: true, detail: 'Done Nov 16, 2026' }) : t); });
57
+ setTasks(next);
58
+ // The pressed link goes away. Focus goes to the next link, or to 'Hide Checklist' after the last one.
59
+ focusNext.current = next.every(function (t) { return t.done; })
60
+ ? function () { var _a; return (_a = hideButton.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); }
61
+ : function () { var _a; return (_a = firstAction.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
62
+ }
63
+ // The checklist leaves the home page for good. Its Button goes with it, so focus goes to the page's heading.
64
+ function hide() {
65
+ setHidden(true);
66
+ toastIds.current.push(toast({ type: 'success', message: 'Setup checklist hidden.' }));
67
+ focusNext.current = function () { var _a; return (_a = page.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
68
+ }
69
+ return (<Center width="page">
70
+ <Stack gap="xlarge">
71
+ <Heading ref={page} tabIndex={-1} level={1} size="h5">Home</Heading>
72
+ {!hidden && (<SettingsSection title="Set up Acme" description="The app works without these. Finish them when you are ready." id="onboarding-checklist-setup">
73
+ <Stack gap="large">
74
+ <Progress kind="share" label="Set up" value={done} max={tasks.length} valueText={"".concat(done, " of ").concat(tasks.length, " done")}/>
75
+ <StepList aria-label="Setup steps" steps={tasks.map(function (t) { return ({ label: t.label, detail: t.detail, status: t.done ? 'done' : 'waiting' }); })}/>
76
+ {allDone ? (<Stack gap="medium" align="start">
77
+ {/* An inline Alert is a polite status, so a screen reader hears it. */}
78
+ <Alert variant="inline" type="success" autoDismiss={false} message="Acme is set up."/>
79
+ <Button ref={hideButton} size="small" type="tertiary" state="enabled" label="Hide Checklist" onClickButton={hide}/>
80
+ </Stack>) : (
81
+ // Each waiting step links to the place where it is done.
82
+ <Cluster gap="small">
83
+ {waiting.map(function (t, i) { return (<Button key={t.id} ref={i === 0 ? firstAction : undefined} size="small" type="secondary" state="enabled" label={t.action} href={t.href} onClickButton={function (event) { return finish(event, t.id); }}/>); })}
84
+ </Cluster>)}
85
+ </Stack>
86
+ </SettingsSection>)}
87
+ <Paragraph tone="secondary" measure="none">Your projects and comments show here.</Paragraph>
88
+ </Stack>
89
+ {/* A real app mounts one Toaster near its root. */}
90
+ <Toaster />
91
+ </Center>);
92
+ }
@@ -0,0 +1,3 @@
1
+ export default function OnboardingSteps({ failOn }?: {
2
+ failOn?: 'workspace';
3
+ }): import("react").JSX.Element;
@@ -0,0 +1,177 @@
1
+ 'use client';
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ import { useEffect, useRef, useState } from 'react';
12
+ import Heading from '../../components/heading';
13
+ import Paragraph from '../../components/paragraph';
14
+ import Form from '../../components/form';
15
+ import TextField from '../../components/textField';
16
+ import Alert from '../../components/alert';
17
+ import Button from '../../components/button';
18
+ import { Center, Cluster, Stack } from '../../components/layout';
19
+ var titles = ['Name your workspace', 'Invite your team', 'You are set'];
20
+ // A small check: some text, an @, then some text.
21
+ function looksLikeEmail(value) {
22
+ return /^[^@\s]+@[^@\s]+$/.test(value);
23
+ }
24
+ function addresses(text) {
25
+ return text.split(',').map(function (a) { return a.trim(); }).filter(Boolean);
26
+ }
27
+ // `failOn` makes the workspace request fail once, so a test can see the error. A real app leaves it out.
28
+ // A real app saves each step on Continue. A person who leaves comes back to the first step not done,
29
+ // with what they entered, and the steps before it show what was saved.
30
+ export default function OnboardingSteps(_a) {
31
+ var _b = _a === void 0 ? {} : _a, failOn = _b.failOn;
32
+ var _c = useState(0), step = _c[0], setStep = _c[1];
33
+ // What the person typed stays in state, so Back shows it again.
34
+ var _d = useState(''), name = _d[0], setName = _d[1];
35
+ var _e = useState(''), emails = _e[0], setEmails = _e[1];
36
+ var _f = useState(''), nameError = _f[0], setNameError = _f[1];
37
+ var _g = useState(''), emailError = _g[0], setEmailError = _g[1];
38
+ var _h = useState(''), error = _h[0], setError = _h[1];
39
+ var _j = useState(false), loading = _j[0], setLoading = _j[1];
40
+ // What was saved: the workspace's name once it exists, and the addresses already invited.
41
+ // Back and Continue again never make the workspace twice or send an invite twice.
42
+ var _k = useState(null), created = _k[0], setCreated = _k[1];
43
+ var _l = useState([]), sent = _l[0], setSent = _l[1];
44
+ var heading = useRef(null);
45
+ var failed = useRef(false);
46
+ var timer = useRef();
47
+ // Set on a step change; run after the next render, once the new heading is on screen.
48
+ var focusNext = useRef();
49
+ // Stops the request if the example goes away before it ends.
50
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
51
+ useEffect(function () {
52
+ var move = focusNext.current;
53
+ focusNext.current = undefined;
54
+ move === null || move === void 0 ? void 0 : move();
55
+ });
56
+ // Each step change moves focus to the step's heading, so a screen reader reads where the person is.
57
+ // The first step keeps focus where the page put it.
58
+ function go(next) {
59
+ setError('');
60
+ setNameError('');
61
+ setEmailError('');
62
+ setStep(next);
63
+ focusNext.current = function () { var _a; return (_a = heading.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
64
+ }
65
+ function back() {
66
+ if (loading)
67
+ return;
68
+ go(step - 1);
69
+ }
70
+ function createWorkspace() {
71
+ if (loading)
72
+ return;
73
+ setError('');
74
+ setNameError('');
75
+ var wanted = name.trim();
76
+ if (!wanted) {
77
+ setNameError('Enter a name for your workspace.');
78
+ return;
79
+ }
80
+ // Already saved with this name: go on with no request.
81
+ if (wanted === created) {
82
+ go(1);
83
+ return;
84
+ }
85
+ setLoading(true);
86
+ // Stands in for the request to the server: it creates the workspace, or renames it when it exists.
87
+ // The step and its Buttons stay while it runs.
88
+ timer.current = setTimeout(function () {
89
+ setLoading(false);
90
+ if (failOn === 'workspace' && !failed.current) {
91
+ failed.current = true;
92
+ setError(created === null ? 'The workspace was not created. Try again.' : 'The workspace was not renamed. Try again.');
93
+ return;
94
+ }
95
+ setCreated(wanted);
96
+ go(1);
97
+ }, 1200);
98
+ }
99
+ function sendInvites() {
100
+ if (loading)
101
+ return;
102
+ setError('');
103
+ setEmailError('');
104
+ var list = addresses(emails);
105
+ if (list.length === 0 && sent.length === 0) {
106
+ setEmailError('Enter an email address, or choose Skip for Now.');
107
+ return;
108
+ }
109
+ var wrong = list.find(function (a) { return !looksLikeEmail(a); });
110
+ if (wrong) {
111
+ setEmailError("Check ".concat(wrong, ". Enter an address like name@example.com."));
112
+ return;
113
+ }
114
+ // Only addresses not yet invited are sent. With none, the step goes on at once.
115
+ var fresh = list.filter(function (a) { return !sent.includes(a); });
116
+ if (fresh.length === 0) {
117
+ go(2);
118
+ return;
119
+ }
120
+ setLoading(true);
121
+ // Stands in for the request to the server. A failed request shows an inline error Alert, as on the first step.
122
+ timer.current = setTimeout(function () {
123
+ setLoading(false);
124
+ setSent(function (s) { return __spreadArray(__spreadArray([], s, true), fresh, true); });
125
+ go(2);
126
+ }, 1200);
127
+ }
128
+ // Skip sends nothing and goes on at once. Invites already sent stay sent.
129
+ function skip() {
130
+ if (loading)
131
+ return;
132
+ go(2);
133
+ }
134
+ var workspace = created !== null && created !== void 0 ? created : name.trim();
135
+ return (<Center width="form">
136
+ <Stack gap="small">
137
+ {/* The count of steps is said up front, in words. */}
138
+ <Paragraph size="body2" tone="secondary" measure="none">{"Step ".concat(step + 1, " of ").concat(titles.length)}</Paragraph>
139
+ <Heading ref={heading} tabIndex={-1} level={1} size="h5">{titles[step]}</Heading>
140
+ </Stack>
141
+
142
+ {step === 0 && (<Form aria-label={titles[0]} onSubmit={createWorkspace}>
143
+ {/* A failed request keeps the step and what was typed, and says so above the fields and the Buttons. */}
144
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
145
+ <TextField id="onboarding-steps-workspace" label="Workspace name" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} helperText="Your team works here. You can change the name later." onChange={function (e) { setName(e.target.value); setNameError(''); }}/>
146
+ <Cluster gap="small">
147
+ <Button size="medium" type="primary" state="enabled" label="Continue" htmlType="submit" loading={loading}/>
148
+ </Cluster>
149
+ </Form>)}
150
+
151
+ {step === 1 && (<Form aria-label={titles[1]} onSubmit={sendInvites}>
152
+ {error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
153
+ <Paragraph measure="none">{"Invite the people you work with to ".concat(workspace, ". You can skip this and invite them later.")}</Paragraph>
154
+ <TextField id="onboarding-steps-emails" label="Email addresses" type="email" value={emails} disabled={loading} error={Boolean(emailError)} errorText={emailError} helperText="Separate addresses with commas." onChange={function (e) { setEmails(e.target.value); setEmailError(''); }}/>
155
+ <Cluster gap="small" justify="between">
156
+ <Button size="medium" type="tertiary" state="enabled" label="Back" decoIcon="ChevronLeft" onClickButton={back}/>
157
+ <Cluster gap="small">
158
+ <Button size="medium" type="tertiary" state="enabled" label="Skip for Now" onClickButton={skip}/>
159
+ <Button size="medium" type="primary" state="enabled" label="Continue" htmlType="submit" loading={loading}/>
160
+ </Cluster>
161
+ </Cluster>
162
+ </Form>)}
163
+
164
+ {step === 2 && (<Stack gap="large">
165
+ <Paragraph measure="none">
166
+ {sent.length === 0
167
+ ? "".concat(workspace, " is ready. No invites were sent. You can invite your team later in Settings, under Members.")
168
+ : "".concat(workspace, " is ready. Invites went to ").concat(sent.length, " ").concat(sent.length === 1 ? 'person' : 'people', ".")}
169
+ </Paragraph>
170
+ <Cluster gap="small" justify="between">
171
+ <Button size="medium" type="tertiary" state="enabled" label="Back" decoIcon="ChevronLeft" onClickButton={back}/>
172
+ {/* A real app goes to the new workspace. */}
173
+ <Button size="medium" type="primary" state="enabled" label="Go to Workspace" href="/workspace"/>
174
+ </Cluster>
175
+ </Stack>)}
176
+ </Center>);
177
+ }