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.
Files changed (147) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +20 -5
  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 +248 -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 +551 -0
  14. package/dist/cases/billing-page/self-serve.jsx +4 -4
  15. package/dist/cases/billing-page/trial.d.ts +1 -0
  16. package/dist/cases/billing-page/trial.jsx +115 -0
  17. package/dist/cases/billing-page.md +166 -5
  18. package/dist/cases/chart/bars.d.ts +1 -0
  19. package/dist/cases/chart/bars.jsx +83 -0
  20. package/dist/cases/chart/lines.d.ts +1 -0
  21. package/dist/cases/chart/lines.jsx +71 -0
  22. package/dist/cases/chart.md +258 -0
  23. package/dist/cases/collapsible-search/popover.jsx +1 -1
  24. package/dist/cases/collapsible-search.md +2 -2
  25. package/dist/cases/comment-thread/card.d.ts +1 -0
  26. package/dist/cases/comment-thread/card.jsx +141 -0
  27. package/dist/cases/comment-thread/thread.d.ts +1 -0
  28. package/dist/cases/comment-thread/thread.jsx +87 -0
  29. package/dist/cases/comment-thread.md +349 -0
  30. package/dist/cases/cookie-choice/banner.d.ts +1 -0
  31. package/dist/cases/cookie-choice/banner.jsx +82 -0
  32. package/dist/cases/cookie-choice/settings.d.ts +1 -0
  33. package/dist/cases/cookie-choice/settings.jsx +75 -0
  34. package/dist/cases/cookie-choice.md +234 -0
  35. package/dist/cases/dashboard/numbers-first.jsx +63 -2
  36. package/dist/cases/dashboard/work-first.jsx +1 -1
  37. package/dist/cases/dashboard.md +77 -5
  38. package/dist/cases/data-table-page/all-rows.jsx +1 -1
  39. package/dist/cases/data-table-page/paged.jsx +1 -1
  40. package/dist/cases/data-table-page.md +2 -2
  41. package/dist/cases/invoice-list/table.jsx +21 -9
  42. package/dist/cases/invoice-list.md +27 -12
  43. package/dist/cases/leaderboard/ranked.d.ts +1 -0
  44. package/dist/cases/leaderboard/ranked.jsx +44 -0
  45. package/dist/cases/leaderboard/table.d.ts +1 -0
  46. package/dist/cases/leaderboard/table.jsx +87 -0
  47. package/dist/cases/leaderboard.md +177 -0
  48. package/dist/cases/message-reactions/picker.jsx +1 -1
  49. package/dist/cases/message-reactions.md +2 -2
  50. package/dist/cases/message-row.md +2 -1
  51. package/dist/cases/newsletter-signup/inline.d.ts +1 -0
  52. package/dist/cases/newsletter-signup/inline.jsx +72 -0
  53. package/dist/cases/newsletter-signup/section.d.ts +1 -0
  54. package/dist/cases/newsletter-signup/section.jsx +72 -0
  55. package/dist/cases/newsletter-signup.md +234 -0
  56. package/dist/cases/number-format.md +9 -3
  57. package/dist/cases/onboarding/checklist.d.ts +1 -0
  58. package/dist/cases/onboarding/checklist.jsx +92 -0
  59. package/dist/cases/onboarding/steps.d.ts +3 -0
  60. package/dist/cases/onboarding/steps.jsx +177 -0
  61. package/dist/cases/onboarding.md +368 -0
  62. package/dist/cases/people-row/stack.jsx +1 -1
  63. package/dist/cases/people-row.md +2 -2
  64. package/dist/cases/plan-comparison/table.d.ts +1 -0
  65. package/dist/cases/plan-comparison/table.jsx +47 -0
  66. package/dist/cases/plan-comparison.md +94 -0
  67. package/dist/cases/plan-picker.md +1 -0
  68. package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
  69. package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
  70. package/dist/cases/plan-sign-off/team.d.ts +1 -0
  71. package/dist/cases/plan-sign-off/team.jsx +213 -0
  72. package/dist/cases/plan-sign-off.md +541 -0
  73. package/dist/cases/pricing-section.md +1 -1
  74. package/dist/cases/site-footer/columns.jsx +2 -1
  75. package/dist/cases/site-footer.md +3 -1
  76. package/dist/cases/stat-row/tiles.jsx +2 -1
  77. package/dist/cases/stat-row.md +5 -2
  78. package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
  79. package/dist/cases/task-header/agent-sets-status.jsx +164 -0
  80. package/dist/cases/task-header/people-change-status.d.ts +1 -0
  81. package/dist/cases/task-header/people-change-status.jsx +175 -0
  82. package/dist/cases/task-header.md +576 -0
  83. package/dist/cases.json +883 -30
  84. package/dist/components/alert.d.ts +3 -1
  85. package/dist/components/alert.jsx +5 -5
  86. package/dist/components/barChart.d.ts +35 -0
  87. package/dist/components/barChart.jsx +92 -0
  88. package/dist/components/dateField.jsx +1 -1
  89. package/dist/components/formatNumber.d.ts +10 -2
  90. package/dist/components/formatNumber.js +44 -9
  91. package/dist/components/heading.d.ts +2 -2
  92. package/dist/components/heading.jsx +5 -3
  93. package/dist/components/layout.d.ts +4 -2
  94. package/dist/components/layout.jsx +13 -2
  95. package/dist/components/lineChart.d.ts +39 -0
  96. package/dist/components/lineChart.jsx +128 -0
  97. package/dist/components/markdown.d.ts +24 -0
  98. package/dist/components/markdown.jsx +81 -0
  99. package/dist/components/pageShell.d.ts +3 -3
  100. package/dist/components/pageShell.jsx +6 -5
  101. package/dist/components/popover.d.ts +5 -1
  102. package/dist/components/popover.jsx +3 -2
  103. package/dist/components/progress.jsx +1 -1
  104. package/dist/components/select.jsx +5 -2
  105. package/dist/components/statTile.d.ts +1 -1
  106. package/dist/components/statTile.jsx +7 -2
  107. package/dist/components/tableCell.d.ts +4 -3
  108. package/dist/components/tableCell.jsx +2 -2
  109. package/dist/components/timeline.d.ts +32 -0
  110. package/dist/components/timeline.jsx +54 -0
  111. package/dist/components/titleBar.d.ts +3 -1
  112. package/dist/components/titleBar.jsx +9 -4
  113. package/dist/components/toaster.jsx +81 -11
  114. package/dist/index.d.ts +1 -0
  115. package/dist/index.js +1 -0
  116. package/dist/internal/chart.d.ts +39 -0
  117. package/dist/internal/chart.js +110 -0
  118. package/dist/internal/chartFrame.d.ts +29 -0
  119. package/dist/internal/chartFrame.jsx +57 -0
  120. package/dist/internal/markdown.d.ts +40 -0
  121. package/dist/internal/markdown.js +577 -0
  122. package/dist/internal/toaster.d.ts +2 -0
  123. package/dist/internal/toaster.js +8 -0
  124. package/dist/native-mapping.json +28 -4
  125. package/dist/stories/BarChart.stories.d.ts +10 -0
  126. package/dist/stories/BarChart.stories.jsx +104 -0
  127. package/dist/stories/Cases.generated.stories.d.ts +22 -0
  128. package/dist/stories/Cases.generated.stories.jsx +44 -0
  129. package/dist/stories/Heading.stories.d.ts +1 -0
  130. package/dist/stories/Heading.stories.jsx +17 -0
  131. package/dist/stories/LineChart.stories.d.ts +9 -0
  132. package/dist/stories/LineChart.stories.jsx +34 -0
  133. package/dist/stories/Markdown.stories.d.ts +9 -0
  134. package/dist/stories/Markdown.stories.jsx +66 -0
  135. package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
  136. package/dist/stories/Onboarding.probe.stories.jsx +12 -0
  137. package/dist/stories/Popover.stories.d.ts +2 -0
  138. package/dist/stories/Popover.stories.jsx +33 -0
  139. package/dist/stories/StatTile.stories.d.ts +4 -0
  140. package/dist/stories/StatTile.stories.jsx +47 -2
  141. package/dist/stories/Timeline.stories.d.ts +8 -0
  142. package/dist/stories/Timeline.stories.jsx +49 -0
  143. package/dist/stories/TitleBar.stories.d.ts +1 -0
  144. package/dist/stories/TitleBar.stories.jsx +13 -0
  145. package/dist/stories/Toaster.stories.d.ts +4 -0
  146. package/dist/stories/Toaster.stories.jsx +30 -0
  147. package/package.json +1 -1
@@ -25,9 +25,9 @@ var isAdmin = true;
25
25
  // A real app reads this from the server: set when the last payment failed.
26
26
  var failedPayment = { fixBy: 'Nov 30, 2026' };
27
27
  var invoices = [
28
- { id: 'inv-0', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
29
- { id: 'inv-1', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
30
- { id: 'inv-2', date: 'Sep 1, 2026', amount: 24, status: 'Paid' },
28
+ { id: 'inv-0', kind: 'charge', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
29
+ { id: 'ref-1', kind: 'refund', date: 'Oct 16, 2026', amount: -12, status: 'Issued' },
30
+ { id: 'inv-1', kind: 'charge', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
31
31
  ];
32
32
  export default function BillingPageSelfServe() {
33
33
  var _a = useState(false), canceling = _a[0], setCanceling = _a[1];
@@ -108,7 +108,7 @@ export default function BillingPageSelfServe() {
108
108
  <TableCell><Tag variant="textOnly" size="small" label={inv.status}/></TableCell>
109
109
  <TableCell width="130px">
110
110
  {/* A real app links to the file on its own server. */}
111
- <Button size="small" type="tertiary" state="enabled" label="Download" aria-label={"Download invoice for ".concat(inv.date, ", opens in a new tab")} actionIcon="ExternalLink" href={"https://acme.example/invoices/".concat(inv.id, ".pdf")} openInNewTab/>
111
+ <Button size="small" type="tertiary" state="enabled" label="Download" aria-label={"Download ".concat(inv.kind === 'refund' ? 'refund' : 'invoice', " for ").concat(inv.date, ", opens in a new tab")} actionIcon="ExternalLink" href={"https://acme.example/invoices/".concat(inv.id, ".pdf")} openInNewTab/>
112
112
  </TableCell>
113
113
  </TableRow>); })}
114
114
  </TableContainer>
@@ -0,0 +1 @@
1
+ export default function BillingPageTrial(): import("react").JSX.Element;
@@ -0,0 +1,115 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Modal from '../../components/modal';
4
+ import Surface from '../../components/surface';
5
+ import Heading from '../../components/heading';
6
+ import Paragraph from '../../components/paragraph';
7
+ import Progress from '../../components/progress';
8
+ import Tag from '../../components/tag';
9
+ import Button from '../../components/button';
10
+ import EmptyBox from '../../components/emptyBox';
11
+ import SettingsSection from '../../components/settingsSection';
12
+ import TitleBar from '../../components/titleBar';
13
+ import { formatMoney } from '../../components/formatNumber';
14
+ import { Center, Cluster, Stack } from '../../components/layout';
15
+ // A real app passes the router from its framework, such as Next's useRouter().
16
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
17
+ // A real app reads these from the server. The price and the members match the case 'Plan picker'.
18
+ var members = 3;
19
+ var pricePerMember = 8;
20
+ var trialEnds = 'Dec 1, 2026';
21
+ // A real app reads this from the server: null when no card is on file.
22
+ var card = 'Visa ending in 4821';
23
+ export default function BillingPageTrial() {
24
+ var _a = useState(true), trial = _a[0], setTrial = _a[1];
25
+ var _b = useState(false), confirmOpen = _b[0], setConfirmOpen = _b[1];
26
+ var _c = useState(false), busy = _c[0], setBusy = _c[1];
27
+ var timer = useRef();
28
+ var planHeading = useRef(null);
29
+ // Where focus goes after the next render, once the element it goes to is on screen.
30
+ var focusNext = useRef();
31
+ // Stops the request if the example goes away before it ends.
32
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
33
+ useEffect(function () {
34
+ var move = focusNext.current;
35
+ focusNext.current = undefined;
36
+ move === null || move === void 0 ? void 0 : move();
37
+ });
38
+ // Escape, a click outside and Cancel all close it, except while the request runs.
39
+ function handleClose() {
40
+ if (busy)
41
+ return;
42
+ setConfirmOpen(false);
43
+ }
44
+ // Stands in for the request to the server. End Trial is gone after it, so focus goes to the plan, which now reads Free.
45
+ function endTrial() {
46
+ if (busy)
47
+ return;
48
+ setBusy(true);
49
+ timer.current = setTimeout(function () {
50
+ setBusy(false);
51
+ setConfirmOpen(false);
52
+ setTrial(false);
53
+ focusNext.current = function () { var _a; return (_a = planHeading.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
54
+ }, 1200);
55
+ }
56
+ return (<Center width="page">
57
+ <Stack gap="xlarge">
58
+ <TitleBar title="Billing"/>
59
+ <SettingsSection id="billing-page-trial-plan" title="Plan" description="What Acme pays for.">
60
+ {trial ? (<Stack gap="small">
61
+ <Cluster gap="small">
62
+ <Heading ref={planHeading} tabIndex={-1} level={3} size="h6">Pro</Heading>
63
+ <Tag variant="dot" size="small" label="Trial"/>
64
+ </Cluster>
65
+ <Paragraph size="body2" measure="none">{"Acme is on a free trial of Pro until ".concat(trialEnds, ".")}</Paragraph>
66
+ {/* The day it ends, the amount then, and how it is counted. */}
67
+ <Paragraph size="body2" measure="none">
68
+ {"Then Acme pays ".concat(formatMoney(members * pricePerMember), " each month: ").concat(members, " members at ").concat(formatMoney(pricePerMember), " per member per month.")}
69
+ </Paragraph>
70
+ {card && (<Paragraph tone="secondary" size="body2" measure="none">{"Your card is charged ".concat(formatMoney(members * pricePerMember), " on ").concat(trialEnds, ".")}</Paragraph>)}
71
+ </Stack>) : (<Stack gap="small">
72
+ <Heading ref={planHeading} tabIndex={-1} level={3} size="h6">Free</Heading>
73
+ <Paragraph size="body2" measure="none">{"".concat(formatMoney(0), " per month")}</Paragraph>
74
+ <Paragraph tone="secondary" size="body2" measure="none">The trial ended. Nothing was charged.</Paragraph>
75
+ </Stack>)}
76
+ <Cluster gap="small">
77
+ {!trial ? (<Button size="small" type="secondary" state="enabled" label="Change Plan" onClickButton={function () { return router.push('/settings/billing/plans'); }}/>) : card ? (<Button size="small" type="tertiary" state="enabled" label="End Trial" onClickButton={function () { return setConfirmOpen(true); }}/>) : (
78
+ // A real app hands off to its payment provider's own page here. The page never takes card details.
79
+ <Button size="small" type="primary" state="enabled" label="Add Payment Method" aria-label="Add payment method, opens in a new tab" actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab/>)}
80
+ </Cluster>
81
+ </SettingsSection>
82
+ <SettingsSection id="billing-page-trial-usage" title="Usage" description="This month.">
83
+ <Stack gap="medium">
84
+ <Progress label="AI agent responses" value={312} max={1000} unit="responses"/>
85
+ <Paragraph tone="secondary" size="body2" measure="none">Resets on Dec 1.</Paragraph>
86
+ <Progress label="Members" value={members} max={null} unit="members"/>
87
+ </Stack>
88
+ </SettingsSection>
89
+ <SettingsSection id="billing-page-trial-payment" title="Payment method" description="Pays for Acme's plan.">
90
+ {card ? (<Surface padding="small">
91
+ <Cluster justify="between" gap="medium">
92
+ <Stack gap="small">
93
+ <Paragraph measure="none">{card}</Paragraph>
94
+ <Paragraph tone="secondary" size="body2" measure="none">Expires 08/28</Paragraph>
95
+ </Stack>
96
+ {/* A real app hands off to its payment provider's own page here. */}
97
+ <Button size="small" type="tertiary" state="enabled" label="Update" aria-label={"Update ".concat(card, ", opens in a new tab")} actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab/>
98
+ </Cluster>
99
+ </Surface>) : (<Paragraph measure="none">No payment method.</Paragraph>)}
100
+ </SettingsSection>
101
+ <SettingsSection id="billing-page-trial-invoices" title="Invoices" description="The last three.">
102
+ {/* A trial has paid nothing yet. The line says when the first invoice arrives. */}
103
+ <EmptyBox size="small" text="No invoices yet" secondText="Your first invoice appears here after your first payment."/>
104
+ </SettingsSection>
105
+ </Stack>
106
+ <Modal isOpen={confirmOpen} size="small" title="End Trial" onClose={handleClose} actions={<>
107
+ {/* 'Cancel' comes first, as in every confirm. */}
108
+ <Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
109
+ <Button size="small" type="primary" state="enabled" label="End Trial" loading={busy} onClickButton={endTrial}/>
110
+ </>}>
111
+ <Paragraph measure="none">Acme moves to Free now. Nothing is charged.</Paragraph>
112
+ <Paragraph tone="secondary" size="body2" measure="none">Its members and messages stay.</Paragraph>
113
+ </Modal>
114
+ </Center>);
115
+ }
@@ -17,6 +17,10 @@ A workspace pays for a plan. One page says what it pays for, what it has used, h
17
17
  - Say who pays and where for a plan billed elsewhere: 'Ben Carter pays for this plan through an app store.' Say who can change it.
18
18
  - Leave out every control, price, card and invoice on a plan billed elsewhere.
19
19
  - Show a status as the case 'Status in a row' says: 'Past due' and 'Canceling' as dots, 'Paid' as text.
20
+ - Say the day a trial ends and the amount charged then, with how it is counted.
21
+ - Show a trial as a grey dot `Tag` 'Trial' by the plan name, as the case 'Status in a row' says. Then say 'Acme is on a free trial of Pro until Dec 1, 2026.' and 'Then Acme pays $24.00 each month: 3 members at $8.00 per member per month.'
22
+ - Offer a primary 'Add Payment Method' when a trial has no card. With a card, say 'Your card is charged $24.00 on Dec 1, 2026.' and offer a tertiary 'End Trial'.
23
+ - Confirm 'End Trial' in a small `Modal` titled 'End Trial': 'Acme moves to Free now. Nothing is charged.' 'Cancel' comes first, as the rule 'A confirm says exactly what will happen' says.
20
24
 
21
25
  ## Don't
22
26
 
@@ -24,9 +28,10 @@ A workspace pays for a plan. One page says what it pays for, what it has used, h
24
28
  - Do not show Change Plan, Update or End Plan to someone who cannot use them. Show the text and the line that says who can.
25
29
  - Do not leave a failed payment without the date it must be fixed by.
26
30
  - Do not end the plan on the first click. Ask in a Modal first.
27
- - Do not name the action 'Cancel Plan'. It would sit beside 'Cancel' in the confirm.
31
+ - Do not name the action 'Cancel Plan' or 'Cancel Trial'. It would sit beside 'Cancel' in the confirm.
28
32
  - Do not show a plan billed elsewhere with a 'Change Plan' Button that does nothing. Say where to change it.
29
33
  - Do not write 'Canceled' for a plan that is still on. Say 'Canceling' and when it ends.
34
+ - Do not say 'Your trial ends soon' with no date or no amount.
30
35
 
31
36
  ## Option: An admin pays here
32
37
 
@@ -66,9 +71,9 @@ const isAdmin = true;
66
71
  const failedPayment: { fixBy: string } | null = { fixBy: 'Nov 30, 2026' };
67
72
 
68
73
  const invoices = [
69
- { id: 'inv-0', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
70
- { id: 'inv-1', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
71
- { id: 'inv-2', date: 'Sep 1, 2026', amount: 24, status: 'Paid' },
74
+ { id: 'inv-0', kind: 'charge', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
75
+ { id: 'ref-1', kind: 'refund', date: 'Oct 16, 2026', amount: -12, status: 'Issued' },
76
+ { id: 'inv-1', kind: 'charge', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
72
77
  ];
73
78
 
74
79
  export default function BillingPageSelfServe() {
@@ -165,7 +170,7 @@ export default function BillingPageSelfServe() {
165
170
  <TableCell><Tag variant="textOnly" size="small" label={inv.status} /></TableCell>
166
171
  <TableCell width="130px">
167
172
  {/* A real app links to the file on its own server. */}
168
- <Button size="small" type="tertiary" state="enabled" label="Download" aria-label={`Download invoice for ${inv.date}, opens in a new tab`} actionIcon="ExternalLink" href={`https://acme.example/invoices/${inv.id}.pdf`} openInNewTab />
173
+ <Button size="small" type="tertiary" state="enabled" label="Download" aria-label={`Download ${inv.kind === 'refund' ? 'refund' : 'invoice'} for ${inv.date}, opens in a new tab`} actionIcon="ExternalLink" href={`https://acme.example/invoices/${inv.id}.pdf`} openInNewTab />
169
174
  </TableCell>
170
175
  </TableRow>
171
176
  ))}
@@ -242,6 +247,162 @@ export default function BillingPageBilledElsewhere() {
242
247
  }
243
248
  ```
244
249
 
250
+ ## Option: A free trial
251
+
252
+ Use when: The workspace is in a free trial of a paid plan.
253
+
254
+ Uses: `Button`, `Center`, `Cluster`, `EmptyBox`, `Heading`, `Modal`, `Paragraph`, `Progress`, `SettingsSection`, `Stack`, `Surface`, `Tag`, `TitleBar`, `formatMoney`
255
+
256
+ ```tsx
257
+ 'use client';
258
+ import { useEffect, useRef, useState } from 'react';
259
+ import Modal from 'oneslash-design-system/components/modal';
260
+ import Surface from 'oneslash-design-system/components/surface';
261
+ import Heading from 'oneslash-design-system/components/heading';
262
+ import Paragraph from 'oneslash-design-system/components/paragraph';
263
+ import Progress from 'oneslash-design-system/components/progress';
264
+ import Tag from 'oneslash-design-system/components/tag';
265
+ import Button from 'oneslash-design-system/components/button';
266
+ import EmptyBox from 'oneslash-design-system/components/emptyBox';
267
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
268
+ import TitleBar from 'oneslash-design-system/components/titleBar';
269
+ import { formatMoney } from 'oneslash-design-system/components/formatNumber';
270
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
271
+
272
+ // A real app passes the router from its framework, such as Next's useRouter().
273
+ const router = { push: (url: string) => console.info(`Go to ${url}`) };
274
+
275
+ // A real app reads these from the server. The price and the members match the case 'Plan picker'.
276
+ const members = 3;
277
+ const pricePerMember = 8;
278
+ const trialEnds = 'Dec 1, 2026';
279
+
280
+ // A real app reads this from the server: null when no card is on file.
281
+ const card: string | null = 'Visa ending in 4821';
282
+
283
+ export default function BillingPageTrial() {
284
+ const [trial, setTrial] = useState(true);
285
+ const [confirmOpen, setConfirmOpen] = useState(false);
286
+ const [busy, setBusy] = useState(false);
287
+ const timer = useRef<ReturnType<typeof setTimeout>>();
288
+ const planHeading = useRef<HTMLHeadingElement>(null);
289
+ // Where focus goes after the next render, once the element it goes to is on screen.
290
+ const focusNext = useRef<() => void>();
291
+
292
+ // Stops the request if the example goes away before it ends.
293
+ useEffect(() => () => clearTimeout(timer.current), []);
294
+
295
+ useEffect(() => {
296
+ const move = focusNext.current;
297
+ focusNext.current = undefined;
298
+ move?.();
299
+ });
300
+
301
+ // Escape, a click outside and Cancel all close it, except while the request runs.
302
+ function handleClose() {
303
+ if (busy) return;
304
+ setConfirmOpen(false);
305
+ }
306
+
307
+ // Stands in for the request to the server. End Trial is gone after it, so focus goes to the plan, which now reads Free.
308
+ function endTrial() {
309
+ if (busy) return;
310
+ setBusy(true);
311
+ timer.current = setTimeout(() => {
312
+ setBusy(false);
313
+ setConfirmOpen(false);
314
+ setTrial(false);
315
+ focusNext.current = () => planHeading.current?.focus({ preventScroll: true });
316
+ }, 1200);
317
+ }
318
+
319
+ return (
320
+ <Center width="page">
321
+ <Stack gap="xlarge">
322
+ <TitleBar title="Billing" />
323
+ <SettingsSection id="billing-page-trial-plan" title="Plan" description="What Acme pays for.">
324
+ {trial ? (
325
+ <Stack gap="small">
326
+ <Cluster gap="small">
327
+ <Heading ref={planHeading} tabIndex={-1} level={3} size="h6">Pro</Heading>
328
+ <Tag variant="dot" size="small" label="Trial" />
329
+ </Cluster>
330
+ <Paragraph size="body2" measure="none">{`Acme is on a free trial of Pro until ${trialEnds}.`}</Paragraph>
331
+ {/* The day it ends, the amount then, and how it is counted. */}
332
+ <Paragraph size="body2" measure="none">
333
+ {`Then Acme pays ${formatMoney(members * pricePerMember)} each month: ${members} members at ${formatMoney(pricePerMember)} per member per month.`}
334
+ </Paragraph>
335
+ {card && (
336
+ <Paragraph tone="secondary" size="body2" measure="none">{`Your card is charged ${formatMoney(members * pricePerMember)} on ${trialEnds}.`}</Paragraph>
337
+ )}
338
+ </Stack>
339
+ ) : (
340
+ <Stack gap="small">
341
+ <Heading ref={planHeading} tabIndex={-1} level={3} size="h6">Free</Heading>
342
+ <Paragraph size="body2" measure="none">{`${formatMoney(0)} per month`}</Paragraph>
343
+ <Paragraph tone="secondary" size="body2" measure="none">The trial ended. Nothing was charged.</Paragraph>
344
+ </Stack>
345
+ )}
346
+ <Cluster gap="small">
347
+ {!trial ? (
348
+ <Button size="small" type="secondary" state="enabled" label="Change Plan" onClickButton={() => router.push('/settings/billing/plans')} />
349
+ ) : card ? (
350
+ <Button size="small" type="tertiary" state="enabled" label="End Trial" onClickButton={() => setConfirmOpen(true)} />
351
+ ) : (
352
+ // A real app hands off to its payment provider's own page here. The page never takes card details.
353
+ <Button size="small" type="primary" state="enabled" label="Add Payment Method" aria-label="Add payment method, opens in a new tab" actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab />
354
+ )}
355
+ </Cluster>
356
+ </SettingsSection>
357
+ <SettingsSection id="billing-page-trial-usage" title="Usage" description="This month.">
358
+ <Stack gap="medium">
359
+ <Progress label="AI agent responses" value={312} max={1000} unit="responses" />
360
+ <Paragraph tone="secondary" size="body2" measure="none">Resets on Dec 1.</Paragraph>
361
+ <Progress label="Members" value={members} max={null} unit="members" />
362
+ </Stack>
363
+ </SettingsSection>
364
+ <SettingsSection id="billing-page-trial-payment" title="Payment method" description="Pays for Acme's plan.">
365
+ {card ? (
366
+ <Surface padding="small">
367
+ <Cluster justify="between" gap="medium">
368
+ <Stack gap="small">
369
+ <Paragraph measure="none">{card}</Paragraph>
370
+ <Paragraph tone="secondary" size="body2" measure="none">Expires 08/28</Paragraph>
371
+ </Stack>
372
+ {/* A real app hands off to its payment provider's own page here. */}
373
+ <Button size="small" type="tertiary" state="enabled" label="Update" aria-label={`Update ${card}, opens in a new tab`} actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab />
374
+ </Cluster>
375
+ </Surface>
376
+ ) : (
377
+ <Paragraph measure="none">No payment method.</Paragraph>
378
+ )}
379
+ </SettingsSection>
380
+ <SettingsSection id="billing-page-trial-invoices" title="Invoices" description="The last three.">
381
+ {/* A trial has paid nothing yet. The line says when the first invoice arrives. */}
382
+ <EmptyBox size="small" text="No invoices yet" secondText="Your first invoice appears here after your first payment." />
383
+ </SettingsSection>
384
+ </Stack>
385
+ <Modal
386
+ isOpen={confirmOpen}
387
+ size="small"
388
+ title="End Trial"
389
+ onClose={handleClose}
390
+ actions={
391
+ <>
392
+ {/* 'Cancel' comes first, as in every confirm. */}
393
+ <Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
394
+ <Button size="small" type="primary" state="enabled" label="End Trial" loading={busy} onClickButton={endTrial} />
395
+ </>
396
+ }
397
+ >
398
+ <Paragraph measure="none">Acme moves to Free now. Nothing is charged.</Paragraph>
399
+ <Paragraph tone="secondary" size="body2" measure="none">Its members and messages stay.</Paragraph>
400
+ </Modal>
401
+ </Center>
402
+ );
403
+ }
404
+ ```
405
+
245
406
  ## Native
246
407
 
247
408
  On Apple a plan bought in the app is managed in the system subscription sheet. Show who pays and open that sheet from one Button, never a card form.
@@ -0,0 +1 @@
1
+ export default function ChartBars(): import("react").JSX.Element;
@@ -0,0 +1,83 @@
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 TitleBar from '../../components/titleBar';
13
+ import SegmentedControl from '../../components/segmentedControl';
14
+ import SettingsSection from '../../components/settingsSection';
15
+ import BarChart from '../../components/barChart';
16
+ import { formatCount } from '../../components/formatNumber';
17
+ import { Center, Stack } from '../../components/layout';
18
+ var ranges = [
19
+ { value: 'week', label: 'Week' },
20
+ { value: 'month', label: 'Month' },
21
+ { value: 'quarter', label: 'Quarter' },
22
+ ];
23
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
24
+ // 'Nov 14' for the day `back` days before Nov 16, 2026. Written from UTC, so the server and the browser agree.
25
+ function day(back) {
26
+ var d = new Date(Date.UTC(2026, 10, 16 - back));
27
+ return "".concat(months[d.getUTCMonth()], " ").concat(d.getUTCDate());
28
+ }
29
+ // A real app counts these on the server. The last seven days are the week.
30
+ var week = [40, 46, 38, 52, 58, 61, 72];
31
+ var month = __spreadArray(__spreadArray([], Array.from({ length: 23 }, function (_, i) { return 28 + Math.round(i * 0.8) + ((i * 7) % 5) * 3; }), true), week, true);
32
+ // The quarter is counted by week: 13 weeks, the last from Nov 10 to Nov 16.
33
+ var quarter = [236, 251, 228, 262, 270, 249, 281, 290, 276, 302, 311, 334, 367];
34
+ var data = {
35
+ week: week.map(function (value, i) { return ({ label: day(6 - i), value: value }); }),
36
+ month: month.map(function (value, i) { return ({ label: day(29 - i), value: value }); }),
37
+ quarter: quarter.map(function (value, i) { return ({ label: day(6 + (12 - i) * 7), value: value }); }),
38
+ };
39
+ var noun = { week: 'this week', month: 'this month', quarter: 'this quarter' };
40
+ // The summary says what changed, written from the same data the chart draws. A day with no data (null)
41
+ // is left out, never read as 0: the summary runs from the first day with data to the last.
42
+ function summary(points, range) {
43
+ var known = points.filter(function (p) { return p.value !== null; });
44
+ if (known.length === 0)
45
+ return "No comments were counted ".concat(noun[range], ".");
46
+ var first = known[0];
47
+ var last = known[known.length - 1];
48
+ var when = function (p) { return (range === 'quarter' ? "in the week of ".concat(p.label) : "on ".concat(p.label)); };
49
+ if (known.length === 1)
50
+ return "Comments were counted only ".concat(when(first), ": ").concat(formatCount(first.value), ".");
51
+ var move = last.value > first.value ? 'rose' : last.value < first.value ? 'fell' : 'stayed';
52
+ return move === 'stayed'
53
+ ? "Comments stayed at ".concat(formatCount(first.value), " from ").concat(first.label, " to ").concat(last.label, ".")
54
+ : "Comments ".concat(move, " from ").concat(formatCount(first.value), " ").concat(when(first), " to ").concat(formatCount(last.value), " ").concat(when(last), ".");
55
+ }
56
+ export default function ChartBars() {
57
+ var _a = useState('week'), range = _a[0], setRange = _a[1];
58
+ // The numbers load again when the range changes.
59
+ var _b = useState(false), loading = _b[0], setLoading = _b[1];
60
+ var timer = useRef();
61
+ // Stops the request if the example goes away before it ends.
62
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
63
+ function changeRange(next) {
64
+ clearTimeout(timer.current);
65
+ setRange(next);
66
+ setLoading(true);
67
+ // Stands in for the request to the server.
68
+ timer.current = setTimeout(function () { return setLoading(false); }, 600);
69
+ }
70
+ var points = data[range];
71
+ // The total adds the days with data, and says so when a day has none.
72
+ var total = points.reduce(function (sum, p) { var _a; return sum + ((_a = p.value) !== null && _a !== void 0 ? _a : 0); }, 0);
73
+ var gap = points.some(function (p) { return p.value === null; });
74
+ return (<Center width="page">
75
+ <Stack gap="xlarge">
76
+ {/* The dashboard's one range drives the chart too. Below md the switch takes its own line under the title. */}
77
+ <TitleBar title="Dashboard" actionsBelow actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange}/>}/>
78
+ <SettingsSection title={"Comments ".concat(noun[range])} description={"".concat(formatCount(total), " comments ").concat(gap ? 'on the days with data ' : '', "from ").concat(points[0].label, " to Nov 16, 2026")} id="chart-bars-comments">
79
+ <BarChart id="chart-bars-per-day" title={range === 'quarter' ? 'Comments per week' : 'Comments per day'} summary={summary(points, range)} data={points} unit="comments" labelHeader={range === 'quarter' ? 'Week of' : 'Date'} loading={loading} emptyText={"No comments ".concat(noun[range])}/>
80
+ </SettingsSection>
81
+ </Stack>
82
+ </Center>);
83
+ }
@@ -0,0 +1 @@
1
+ export default function ChartLines(): import("react").JSX.Element;
@@ -0,0 +1,71 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import TitleBar from '../../components/titleBar';
4
+ import SegmentedControl from '../../components/segmentedControl';
5
+ import SettingsSection from '../../components/settingsSection';
6
+ import LineChart from '../../components/lineChart';
7
+ import { formatCount } from '../../components/formatNumber';
8
+ import { Center, Stack } from '../../components/layout';
9
+ var ranges = [
10
+ { value: 'week', label: 'Week' },
11
+ { value: 'month', label: 'Month' },
12
+ { value: 'quarter', label: 'Quarter' },
13
+ ];
14
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
15
+ // 'Nov 14' for the day `back` days before Nov 16, 2026. Written from UTC, so the server and the browser agree.
16
+ function day(back) {
17
+ var d = new Date(Date.UTC(2026, 10, 16 - back));
18
+ return "".concat(months[d.getUTCMonth()], " ").concat(d.getUTCDate());
19
+ }
20
+ // A real app counts these on the server. Both lines count threads, so they share one unit and one scale.
21
+ var openedMonth = Array.from({ length: 30 }, function (_, i) { return 18 + Math.round(i * 0.9) + ((i * 5) % 7); });
22
+ var doneMonth = Array.from({ length: 30 }, function (_, i) { return 12 + Math.round(i * 0.8) + ((i * 3) % 5); });
23
+ var data = {
24
+ week: { labels: Array.from({ length: 7 }, function (_, i) { return day(6 - i); }), opened: openedMonth.slice(23), done: doneMonth.slice(23) },
25
+ month: { labels: Array.from({ length: 30 }, function (_, i) { return day(29 - i); }), opened: openedMonth, done: doneMonth },
26
+ // The quarter is counted by week: 13 weeks, the last from Nov 10 to Nov 16.
27
+ quarter: {
28
+ labels: Array.from({ length: 13 }, function (_, i) { return day(6 + (12 - i) * 7); }),
29
+ opened: [150, 162, 158, 171, 166, 180, 177, 189, 196, 204, 199, 221, 238],
30
+ done: [131, 140, 149, 152, 160, 158, 169, 171, 180, 186, 192, 201, 214],
31
+ },
32
+ };
33
+ var noun = { week: 'this week', month: 'this month', quarter: 'this quarter' };
34
+ // The summary says what changed, written from the same data the chart draws.
35
+ function summary(_a, range) {
36
+ var labels = _a.labels, opened = _a.opened, done = _a.done;
37
+ var when = function (i) { return (range === 'quarter' ? "in the week of ".concat(labels[i]) : "on ".concat(labels[i])); };
38
+ var last = labels.length - 1;
39
+ var move = function (list) { return (list[last] > list[0] ? 'rose' : list[last] < list[0] ? 'fell' : 'stayed'); };
40
+ return "Threads opened ".concat(move(opened), " from ").concat(formatCount(opened[0]), " ").concat(when(0), " to ").concat(formatCount(opened[last]), " ").concat(when(last), ", and threads done ").concat(move(done), " from ").concat(formatCount(done[0]), " to ").concat(formatCount(done[last]), ".");
41
+ }
42
+ export default function ChartLines() {
43
+ // A trend needs more than a few points, so this chart opens on the month.
44
+ var _a = useState('month'), range = _a[0], setRange = _a[1];
45
+ // The numbers load again when the range changes.
46
+ var _b = useState(false), loading = _b[0], setLoading = _b[1];
47
+ var timer = useRef();
48
+ // Stops the request if the example goes away before it ends.
49
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
50
+ function changeRange(next) {
51
+ clearTimeout(timer.current);
52
+ setRange(next);
53
+ setLoading(true);
54
+ // Stands in for the request to the server.
55
+ timer.current = setTimeout(function () { return setLoading(false); }, 600);
56
+ }
57
+ var counts = data[range];
58
+ return (<Center width="page">
59
+ <Stack gap="xlarge">
60
+ {/* The dashboard's one range drives the chart too. Below md the switch takes its own line under the title. */}
61
+ <TitleBar title="Dashboard" actionsBelow actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange}/>}/>
62
+ <SettingsSection title={"Threads ".concat(noun[range])} description={"Opened and marked done, ".concat(range === 'quarter' ? 'per week' : 'per day', ", from ").concat(counts.labels[0], " to Nov 16, 2026")} id="chart-lines-threads">
63
+ {/* Two series in one unit. A third would go in a chart of its own. */}
64
+ <LineChart id="chart-lines-opened-done" title={"Opened and done ".concat(noun[range])} summary={summary(counts, range)} labels={counts.labels} series={[
65
+ { name: 'opened', values: counts.opened },
66
+ { name: 'done', values: counts.done },
67
+ ]} unit="threads" labelHeader={range === 'quarter' ? 'Week of' : 'Date'} loading={loading} emptyText={"No threads opened or done ".concat(noun[range])}/>
68
+ </SettingsSection>
69
+ </Stack>
70
+ </Center>);
71
+ }