oneslash-design-system 2.19.0 → 2.21.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 (264) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +62 -5
  3. package/dist/cases/about-page/profile.d.ts +1 -0
  4. package/dist/cases/about-page/profile.jsx +64 -0
  5. package/dist/cases/about-page.md +114 -0
  6. package/dist/cases/admin-inbox/list.d.ts +1 -0
  7. package/dist/cases/admin-inbox/list.jsx +104 -0
  8. package/dist/cases/admin-inbox/split.d.ts +1 -0
  9. package/dist/cases/admin-inbox/split.jsx +68 -0
  10. package/dist/cases/admin-inbox.md +254 -0
  11. package/dist/cases/api-keys.md +1 -1
  12. package/dist/cases/billing-page/billed-elsewhere.d.ts +1 -0
  13. package/dist/cases/billing-page/billed-elsewhere.jsx +28 -0
  14. package/dist/cases/billing-page/self-serve.d.ts +1 -0
  15. package/dist/cases/billing-page/self-serve.jsx +134 -0
  16. package/dist/cases/billing-page.md +247 -0
  17. package/dist/cases/blog-index/cards.d.ts +1 -0
  18. package/dist/cases/blog-index/cards.jsx +45 -0
  19. package/dist/cases/blog-index/list.d.ts +1 -0
  20. package/dist/cases/blog-index/list.jsx +46 -0
  21. package/dist/cases/blog-index.md +160 -0
  22. package/dist/cases/breakdown-list/bars.d.ts +1 -0
  23. package/dist/cases/breakdown-list/bars.jsx +47 -0
  24. package/dist/cases/breakdown-list/table.d.ts +1 -0
  25. package/dist/cases/breakdown-list/table.jsx +69 -0
  26. package/dist/cases/breakdown-list.md +158 -0
  27. package/dist/cases/changelog/by-month.d.ts +1 -0
  28. package/dist/cases/changelog/by-month.jsx +70 -0
  29. package/dist/cases/changelog/one-page.d.ts +1 -0
  30. package/dist/cases/changelog/one-page.jsx +70 -0
  31. package/dist/cases/changelog.md +200 -0
  32. package/dist/cases/code-sample/block.d.ts +1 -0
  33. package/dist/cases/code-sample/block.jsx +19 -0
  34. package/dist/cases/code-sample/command.d.ts +1 -0
  35. package/dist/cases/code-sample/command.jsx +17 -0
  36. package/dist/cases/code-sample.md +96 -0
  37. package/dist/cases/composer-limit/notice-with-action.jsx +3 -3
  38. package/dist/cases/composer-limit/notice.jsx +3 -3
  39. package/dist/cases/composer-limit.md +8 -8
  40. package/dist/cases/contact-page/form.d.ts +1 -0
  41. package/dist/cases/contact-page/form.jsx +83 -0
  42. package/dist/cases/contact-page/links.d.ts +1 -0
  43. package/dist/cases/contact-page/links.jsx +19 -0
  44. package/dist/cases/contact-page.md +142 -0
  45. package/dist/cases/dashboard/numbers-first.d.ts +1 -0
  46. package/dist/cases/dashboard/numbers-first.jsx +165 -0
  47. package/dist/cases/dashboard/work-first.d.ts +1 -0
  48. package/dist/cases/dashboard/work-first.jsx +165 -0
  49. package/dist/cases/dashboard.md +507 -0
  50. package/dist/cases/data-table-page/all-rows.d.ts +1 -0
  51. package/dist/cases/data-table-page/all-rows.jsx +226 -0
  52. package/dist/cases/data-table-page/paged.d.ts +1 -0
  53. package/dist/cases/data-table-page/paged.jsx +284 -0
  54. package/dist/cases/data-table-page.md +771 -0
  55. package/dist/cases/docs-component-page/reference.d.ts +1 -0
  56. package/dist/cases/docs-component-page/reference.jsx +93 -0
  57. package/dist/cases/docs-component-page.md +144 -0
  58. package/dist/cases/faq/accordion.d.ts +1 -0
  59. package/dist/cases/faq/accordion.jsx +25 -0
  60. package/dist/cases/faq/open-list.d.ts +1 -0
  61. package/dist/cases/faq/open-list.jsx +27 -0
  62. package/dist/cases/faq.md +110 -0
  63. package/dist/cases/feature-grid/cards.d.ts +1 -0
  64. package/dist/cases/feature-grid/cards.jsx +33 -0
  65. package/dist/cases/feature-grid/rows.d.ts +1 -0
  66. package/dist/cases/feature-grid/rows.jsx +30 -0
  67. package/dist/cases/feature-grid.md +132 -0
  68. package/dist/cases/image-viewer/gallery.d.ts +1 -0
  69. package/dist/cases/image-viewer/gallery.jsx +32 -0
  70. package/dist/cases/image-viewer/single.d.ts +1 -0
  71. package/dist/cases/image-viewer/single.jsx +25 -0
  72. package/dist/cases/image-viewer.md +123 -0
  73. package/dist/cases/invoice-list/table.d.ts +1 -0
  74. package/dist/cases/invoice-list/table.jsx +64 -0
  75. package/dist/cases/invoice-list/with-upcoming.d.ts +1 -0
  76. package/dist/cases/invoice-list/with-upcoming.jsx +75 -0
  77. package/dist/cases/invoice-list.md +237 -0
  78. package/dist/cases/landing-hero/centered.d.ts +1 -0
  79. package/dist/cases/landing-hero/centered.jsx +22 -0
  80. package/dist/cases/landing-hero/split.d.ts +1 -0
  81. package/dist/cases/landing-hero/split.jsx +30 -0
  82. package/dist/cases/landing-hero.md +114 -0
  83. package/dist/cases/legal-page/sections.d.ts +1 -0
  84. package/dist/cases/legal-page/sections.jsx +61 -0
  85. package/dist/cases/legal-page.md +96 -0
  86. package/dist/cases/load-failure/inline.jsx +2 -2
  87. package/dist/cases/load-failure.md +2 -2
  88. package/dist/cases/long-form-page/article.d.ts +1 -0
  89. package/dist/cases/long-form-page/article.jsx +58 -0
  90. package/dist/cases/long-form-page/with-contents.d.ts +1 -0
  91. package/dist/cases/long-form-page/with-contents.jsx +41 -0
  92. package/dist/cases/long-form-page.md +170 -0
  93. package/dist/cases/members-list/rows.jsx +2 -1
  94. package/dist/cases/members-list/table.jsx +8 -9
  95. package/dist/cases/members-list.md +12 -13
  96. package/dist/cases/message-actions/hover-toolbar.jsx +11 -8
  97. package/dist/cases/message-actions/menu.jsx +10 -7
  98. package/dist/cases/message-actions.md +19 -13
  99. package/dist/cases/message-attachments/in-composer.jsx +2 -2
  100. package/dist/cases/message-attachments/in-message.jsx +16 -11
  101. package/dist/cases/message-attachments.md +29 -17
  102. package/dist/cases/number-format.md +36 -0
  103. package/dist/cases/one-main-action.md +33 -0
  104. package/dist/cases/overflow-menu/in-a-header.jsx +9 -6
  105. package/dist/cases/overflow-menu/on-a-row.jsx +9 -6
  106. package/dist/cases/overflow-menu.md +16 -10
  107. package/dist/cases/page-end/cta-band.d.ts +1 -0
  108. package/dist/cases/page-end/cta-band.jsx +24 -0
  109. package/dist/cases/page-end/next-link.d.ts +1 -0
  110. package/dist/cases/page-end/next-link.jsx +18 -0
  111. package/dist/cases/page-end.md +88 -0
  112. package/dist/cases/paged-card/pager.d.ts +1 -0
  113. package/dist/cases/paged-card/pager.jsx +41 -0
  114. package/dist/cases/paged-card/see-all.d.ts +1 -0
  115. package/dist/cases/paged-card/see-all.jsx +34 -0
  116. package/dist/cases/paged-card.md +147 -0
  117. package/dist/cases/password-gate/inline.d.ts +1 -0
  118. package/dist/cases/password-gate/inline.jsx +94 -0
  119. package/dist/cases/password-gate/modal.d.ts +1 -0
  120. package/dist/cases/password-gate/modal.jsx +81 -0
  121. package/dist/cases/password-gate/page.d.ts +1 -0
  122. package/dist/cases/password-gate/page.jsx +82 -0
  123. package/dist/cases/password-gate.md +351 -0
  124. package/dist/cases/payment-method/none.d.ts +1 -0
  125. package/dist/cases/payment-method/none.jsx +17 -0
  126. package/dist/cases/payment-method/on-file.d.ts +1 -0
  127. package/dist/cases/payment-method/on-file.jsx +92 -0
  128. package/dist/cases/payment-method.md +182 -0
  129. package/dist/cases/plan-change-confirm/blocked.d.ts +1 -0
  130. package/dist/cases/plan-change-confirm/blocked.jsx +48 -0
  131. package/dist/cases/plan-change-confirm/downgrade.d.ts +1 -0
  132. package/dist/cases/plan-change-confirm/downgrade.jsx +52 -0
  133. package/dist/cases/plan-change-confirm/upgrade.d.ts +1 -0
  134. package/dist/cases/plan-change-confirm/upgrade.jsx +51 -0
  135. package/dist/cases/plan-change-confirm.md +261 -0
  136. package/dist/cases/plan-picker/cards.d.ts +1 -0
  137. package/dist/cases/plan-picker/cards.jsx +97 -0
  138. package/dist/cases/plan-picker/list.d.ts +1 -0
  139. package/dist/cases/plan-picker/list.jsx +103 -0
  140. package/dist/cases/plan-picker.md +297 -0
  141. package/dist/cases/pricing-section/cards.d.ts +1 -0
  142. package/dist/cases/pricing-section/cards.jsx +40 -0
  143. package/dist/cases/pricing-section.md +85 -0
  144. package/dist/cases/product-cards/grid.d.ts +1 -0
  145. package/dist/cases/product-cards/grid.jsx +20 -0
  146. package/dist/cases/product-cards.md +71 -0
  147. package/dist/cases/range-switch/segmented.jsx +11 -7
  148. package/dist/cases/range-switch.md +16 -11
  149. package/dist/cases/reply-feedback/thumbs.jsx +11 -8
  150. package/dist/cases/reply-feedback/with-reason.jsx +11 -8
  151. package/dist/cases/reply-feedback.md +20 -14
  152. package/dist/cases/section-index/cards.d.ts +1 -0
  153. package/dist/cases/section-index/cards.jsx +25 -0
  154. package/dist/cases/section-index/list.d.ts +1 -0
  155. package/dist/cases/section-index/list.jsx +56 -0
  156. package/dist/cases/section-index.md +140 -0
  157. package/dist/cases/settings-page/top-tabs.jsx +4 -3
  158. package/dist/cases/settings-page.md +5 -4
  159. package/dist/cases/site-header.md +1 -1
  160. package/dist/cases/site-search/dialog.d.ts +1 -0
  161. package/dist/cases/site-search/dialog.jsx +131 -0
  162. package/dist/cases/site-search.md +176 -0
  163. package/dist/cases/stat-row/featured.d.ts +1 -0
  164. package/dist/cases/stat-row/featured.jsx +17 -0
  165. package/dist/cases/stat-row/tiles.d.ts +1 -0
  166. package/dist/cases/stat-row/tiles.jsx +34 -0
  167. package/dist/cases/stat-row.md +104 -0
  168. package/dist/cases/status-label/dot.d.ts +1 -0
  169. package/dist/cases/status-label/dot.jsx +39 -0
  170. package/dist/cases/status-label/text.d.ts +1 -0
  171. package/dist/cases/status-label/text.jsx +44 -0
  172. package/dist/cases/status-label.md +143 -0
  173. package/dist/cases/tabbed-panels/tabs.d.ts +1 -0
  174. package/dist/cases/tabbed-panels/tabs.jsx +40 -0
  175. package/dist/cases/tabbed-panels.md +81 -0
  176. package/dist/cases/upgrade-prompt/inline.jsx +4 -2
  177. package/dist/cases/upgrade-prompt/modal.jsx +2 -1
  178. package/dist/cases/upgrade-prompt.md +10 -6
  179. package/dist/cases/usage-meters/by-person.d.ts +1 -0
  180. package/dist/cases/usage-meters/by-person.jsx +72 -0
  181. package/dist/cases/usage-meters/meters.d.ts +1 -0
  182. package/dist/cases/usage-meters/meters.jsx +49 -0
  183. package/dist/cases/usage-meters/with-cap.d.ts +1 -0
  184. package/dist/cases/usage-meters/with-cap.jsx +73 -0
  185. package/dist/cases/usage-meters.md +303 -0
  186. package/dist/cases.json +2178 -97
  187. package/dist/components/accordion.d.ts +31 -0
  188. package/dist/components/accordion.jsx +103 -0
  189. package/dist/components/button.d.ts +1 -1
  190. package/dist/components/button.jsx +11 -5
  191. package/dist/components/codeBlock.d.ts +26 -0
  192. package/dist/components/codeBlock.jsx +101 -0
  193. package/dist/components/formatNumber.d.ts +25 -0
  194. package/dist/components/formatNumber.js +125 -0
  195. package/dist/components/iconButton.jsx +12 -7
  196. package/dist/components/lightbox.d.ts +31 -0
  197. package/dist/components/lightbox.jsx +161 -0
  198. package/dist/components/linkCard.d.ts +10 -1
  199. package/dist/components/linkCard.jsx +32 -6
  200. package/dist/components/modal.d.ts +10 -2
  201. package/dist/components/modal.jsx +17 -12
  202. package/dist/components/pageHeader.jsx +1 -1
  203. package/dist/components/pagination.d.ts +28 -0
  204. package/dist/components/pagination.jsx +89 -0
  205. package/dist/components/progress.d.ts +33 -0
  206. package/dist/components/progress.jsx +50 -0
  207. package/dist/components/searchDialog.d.ts +44 -0
  208. package/dist/components/searchDialog.jsx +152 -0
  209. package/dist/components/skeleton.d.ts +21 -0
  210. package/dist/components/skeleton.jsx +41 -0
  211. package/dist/components/statTile.d.ts +32 -0
  212. package/dist/components/statTile.jsx +61 -0
  213. package/dist/components/tab.d.ts +5 -1
  214. package/dist/components/tab.jsx +2 -2
  215. package/dist/components/tabPanel.d.ts +16 -0
  216. package/dist/components/tabPanel.jsx +12 -0
  217. package/dist/components/tableContainer.d.ts +5 -1
  218. package/dist/components/tableContainer.jsx +9 -1
  219. package/dist/components/tableHeaderCell.d.ts +3 -1
  220. package/dist/components/tableHeaderCell.jsx +2 -2
  221. package/dist/components/tabsContainer.d.ts +5 -1
  222. package/dist/components/tabsContainer.jsx +2 -2
  223. package/dist/components/titleBar.d.ts +3 -1
  224. package/dist/components/titleBar.jsx +4 -3
  225. package/dist/index.d.ts +10 -0
  226. package/dist/index.js +10 -0
  227. package/dist/internal/accordion.d.ts +4 -0
  228. package/dist/internal/accordion.js +53 -0
  229. package/dist/internal/combobox.d.ts +20 -0
  230. package/dist/internal/combobox.js +28 -0
  231. package/dist/internal/highlight.d.ts +5 -0
  232. package/dist/internal/highlight.js +18 -0
  233. package/dist/native-mapping.json +57 -3
  234. package/dist/stories/Accordion.stories.d.ts +11 -0
  235. package/dist/stories/Accordion.stories.jsx +93 -0
  236. package/dist/stories/Button.stories.d.ts +1 -0
  237. package/dist/stories/Button.stories.jsx +19 -1
  238. package/dist/stories/Cases.generated.stories.d.ts +60 -0
  239. package/dist/stories/Cases.generated.stories.jsx +120 -0
  240. package/dist/stories/CodeBlock.stories.d.ts +12 -0
  241. package/dist/stories/CodeBlock.stories.jsx +65 -0
  242. package/dist/stories/Lightbox.stories.d.ts +8 -0
  243. package/dist/stories/Lightbox.stories.jsx +40 -0
  244. package/dist/stories/LinkCard.stories.d.ts +6 -0
  245. package/dist/stories/LinkCard.stories.jsx +17 -0
  246. package/dist/stories/PageHeader.stories.d.ts +2 -0
  247. package/dist/stories/PageHeader.stories.jsx +13 -0
  248. package/dist/stories/Pagination.stories.d.ts +9 -0
  249. package/dist/stories/Pagination.stories.jsx +75 -0
  250. package/dist/stories/Progress.stories.d.ts +9 -0
  251. package/dist/stories/Progress.stories.jsx +43 -0
  252. package/dist/stories/SearchDialog.stories.d.ts +17 -0
  253. package/dist/stories/SearchDialog.stories.jsx +111 -0
  254. package/dist/stories/Skeleton.stories.d.ts +7 -0
  255. package/dist/stories/Skeleton.stories.jsx +27 -0
  256. package/dist/stories/StatTile.stories.d.ts +10 -0
  257. package/dist/stories/StatTile.stories.jsx +55 -0
  258. package/dist/stories/TabPanel.stories.d.ts +7 -0
  259. package/dist/stories/TabPanel.stories.jsx +31 -0
  260. package/dist/stories/Table.stories.d.ts +1 -0
  261. package/dist/stories/Table.stories.jsx +49 -1
  262. package/dist/stories/TitleBar.stories.d.ts +1 -0
  263. package/dist/stories/TitleBar.stories.jsx +7 -0
  264. package/package.json +5 -1
@@ -0,0 +1,161 @@
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 React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
14
+ import { ChevronLeft, ChevronRight, ImageOff, X } from 'lucide-react';
15
+ import Modal from './modal';
16
+ import IconButton from './iconButton';
17
+ import Icon from './icon';
18
+ import Image from './image';
19
+ import Figure from './figure';
20
+ import { formatCount } from './formatNumber';
21
+ import { focusRing } from './sharedStyles';
22
+ // useLayoutEffect warns during server rendering on React 18
23
+ var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
24
+ // A horizontal move this long on touch steps to the next or previous image
25
+ var SWIPE_PX = 40;
26
+ // The image in its frame, or the words that stand in for it when it fails. Mounted per image (keyed by src), so its
27
+ // layout effect attaches the error listener before the browser can report a failure.
28
+ function Frame(_a) {
29
+ var image = _a.image, broken = _a.broken, onBroken = _a.onBroken, onSwipe = _a.onSwipe;
30
+ var ref = useRef(null);
31
+ var start = useRef(null);
32
+ var onBrokenRef = useRef(onBroken);
33
+ onBrokenRef.current = onBroken;
34
+ useIsomorphicLayoutEffect(function () {
35
+ var _a;
36
+ var img = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.querySelector('img');
37
+ if (!img)
38
+ return;
39
+ var fail = function () { return onBrokenRef.current(); };
40
+ img.addEventListener('error', fail);
41
+ return function () { return img.removeEventListener('error', fail); };
42
+ }, []);
43
+ return (<div ref={ref} className="relative min-h-0 flex-1 touch-pan-y touch-pinch-zoom [&_img]:absolute [&_img]:inset-0 [&_img]:h-full [&_img]:w-full" onPointerDown={function (e) {
44
+ start.current = e.pointerType === 'touch' ? { x: e.clientX, y: e.clientY } : null;
45
+ }} onPointerUp={function (e) {
46
+ var s = start.current;
47
+ start.current = null;
48
+ if (!s)
49
+ return;
50
+ var dx = e.clientX - s.x;
51
+ if (Math.abs(dx) < SWIPE_PX || Math.abs(dx) <= Math.abs(e.clientY - s.y))
52
+ return;
53
+ onSwipe(dx < 0 ? 'next' : 'prev');
54
+ }} onPointerCancel={function () {
55
+ start.current = null;
56
+ }}>
57
+ {broken ? (<div className="absolute inset-0 flex flex-col items-center justify-center gap-small rounded-control bg-background-panel p-large text-center">
58
+ <Icon icon={ImageOff} size="medium" color="disabled"/>
59
+ <p className="text-body1 text-fg-primary">This image could not be loaded.</p>
60
+ <p className="text-body2 text-fg-secondary">{image.alt}</p>
61
+ </div>) : (<Image src={image.src} alt={image.alt} fit="contain"/>)}
62
+ </div>);
63
+ }
64
+ /**
65
+ * Images in a full-size Modal: the image fits the viewport, its caption under it, and '2 of 5' after the title.
66
+ * 'Previous image' and 'Next image', ArrowLeft and ArrowRight, and a 40px swipe on touch step one image and stop at
67
+ * the ends; the Button at an end is disabled and focus moves to the other one, as Pagination does. Escape, the
68
+ * backdrop and Close close it, and the Modal gives focus back to what opened it. Images only: no video.
69
+ */
70
+ export default function Lightbox(_a) {
71
+ var images = _a.images, index = _a.index, onIndexChange = _a.onIndexChange, isOpen = _a.isOpen, onClose = _a.onClose, _b = _a["aria-label"], ariaLabel = _b === void 0 ? 'Image viewer' : _b;
72
+ var count = images.length;
73
+ var at = Math.min(Math.max(index, 0), Math.max(count - 1, 0));
74
+ var image = images[at];
75
+ var many = count >= 2;
76
+ var atFirst = at <= 0;
77
+ var atLast = at >= count - 1;
78
+ var viewRef = useRef(null);
79
+ var prevRef = useRef(null);
80
+ var nextRef = useRef(null);
81
+ var pending = useRef(null);
82
+ var onChange = useRef(onIndexChange);
83
+ onChange.current = onIndexChange;
84
+ var _c = useState({}), broken = _c[0], setBroken = _c[1];
85
+ var go = function (to, from) {
86
+ if (to < 0 || to > count - 1 || to === at)
87
+ return;
88
+ if (to === 0 || to === count - 1)
89
+ pending.current = { to: to, focus: from === 'prev' ? 'next' : 'prev' };
90
+ onChange.current(to);
91
+ };
92
+ var goRef = useRef(go);
93
+ goRef.current = go;
94
+ // Focus must not drop to the page when the Button it was on turns disabled at an end
95
+ useEffect(function () {
96
+ var _a, _b;
97
+ var p = pending.current;
98
+ if (!p || p.to !== at)
99
+ return;
100
+ pending.current = null;
101
+ var dialog = (_a = viewRef.current) === null || _a === void 0 ? void 0 : _a.closest('[role="dialog"]');
102
+ var disabled = p.focus === 'prev' ? nextRef.current : prevRef.current;
103
+ var active = document.activeElement;
104
+ if (active && active !== document.body && active !== disabled && (dialog === null || dialog === void 0 ? void 0 : dialog.contains(active)))
105
+ return;
106
+ (_b = (p.focus === 'prev' ? prevRef : nextRef).current) === null || _b === void 0 ? void 0 : _b.focus();
107
+ }, [at]);
108
+ // ArrowLeft and ArrowRight step while focus is in this viewer, wherever it is in the dialog
109
+ useEffect(function () {
110
+ if (!isOpen || !many)
111
+ return;
112
+ var onKey = function (e) {
113
+ var _a;
114
+ if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey)
115
+ return;
116
+ if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight')
117
+ return;
118
+ var dialog = (_a = viewRef.current) === null || _a === void 0 ? void 0 : _a.closest('[role="dialog"]');
119
+ if (!dialog || !(e.target instanceof Node) || !dialog.contains(e.target))
120
+ return;
121
+ e.preventDefault();
122
+ if (e.key === 'ArrowLeft')
123
+ goRef.current(at - 1, 'prev');
124
+ else
125
+ goRef.current(at + 1, 'next');
126
+ };
127
+ document.addEventListener('keydown', onKey);
128
+ return function () { return document.removeEventListener('keydown', onKey); };
129
+ }, [isOpen, many, at]);
130
+ if (!image)
131
+ return null;
132
+ var title = image.caption || image.alt;
133
+ var of = many ? "".concat(formatCount(at + 1), " of ").concat(formatCount(count)) : undefined;
134
+ return (<Modal isOpen={isOpen} onClose={onClose} size="fill" title={title} secondTitle={of} aria-label={ariaLabel} actions={<IconButton color="iconOnly" size="medium" state="enabled" icon={X} ariaLabel="Close" onClick={onClose}/>}>
135
+ <div ref={viewRef} className="flex h-full min-h-0 flex-col gap-medium">
136
+ <figure className="flex min-h-0 flex-1 flex-col gap-medium">
137
+ <Frame key={image.src} image={image} broken={!!broken[image.src]} onBroken={function () { return setBroken(function (b) {
138
+ var _a;
139
+ return (__assign(__assign({}, b), (_a = {}, _a[image.src] = true, _a)));
140
+ }); }} onSwipe={function (direction) { return (direction === 'next' ? go(at + 1, 'next') : go(at - 1, 'prev')); }}/>
141
+ {image.caption && <figcaption aria-hidden="true" className="text-body2 text-fg-secondary">{image.caption}</figcaption>}
142
+ </figure>
143
+ {many && (<div className="flex shrink-0 items-center justify-between gap-medium">
144
+ <IconButton ref={prevRef} color="tertiary" size="large" state={atFirst ? 'disabled' : 'enabled'} icon={ChevronLeft} ariaLabel="Previous image" onClick={function () { return go(at - 1, 'prev'); }}/>
145
+ {/* The count is in the title; say it when it changes, as the title is not read again */}
146
+ <span className="sr-only" aria-live="polite" aria-atomic="true">{image.caption ? "".concat(image.caption, ". ").concat(image.alt, ", ").concat(of) : "".concat(image.alt, ", ").concat(of)}</span>
147
+ <IconButton ref={nextRef} color="tertiary" size="large" state={atLast ? 'disabled' : 'enabled'} icon={ChevronRight} ariaLabel="Next image" onClick={function () { return go(at + 1, 'next'); }}/>
148
+ </div>)}
149
+ </div>
150
+ </Modal>);
151
+ }
152
+ /** A thumbnail that opens the Lightbox: a button named 'Open image: <alt>' around a cropped Figure. */
153
+ export function LightboxThumbnail(_a) {
154
+ var image = _a.image, onOpen = _a.onOpen;
155
+ return (<button type="button" aria-label={"Open image: ".concat(image.alt)} onClick={onOpen} className={"block w-full cursor-zoom-in rounded-container transition-opacity hover:opacity-90 motion-reduce:transition-none ".concat(focusRing)}>
156
+ <Figure crop={4 / 3}>
157
+ <Image src={image.src} alt=""/>
158
+ </Figure>
159
+ </button>);
160
+ }
161
+ export { Lightbox };
@@ -4,7 +4,16 @@ interface LinkCardProps {
4
4
  title: string;
5
5
  /** A small line under the title, in the mono face. */
6
6
  caption?: string;
7
+ /** A body2 line under the title that says what is there. */
8
+ description?: string;
9
+ /** An image on top of the card, cropped to 16:9. Its alt text joins the link's name: use "" when the title says it all. */
10
+ image?: {
11
+ src: string;
12
+ alt: string;
13
+ };
14
+ /** Opens the link in a new tab (`target="_blank"`, `rel="noopener noreferrer"`) and says so to a screen reader. */
15
+ external?: boolean;
7
16
  className?: string;
8
17
  }
9
- export default function LinkCard({ href, title, caption, className }: LinkCardProps): React.JSX.Element;
18
+ export default function LinkCard({ href, title, caption, description, image, external, className }: LinkCardProps): React.JSX.Element;
10
19
  export {};
@@ -2,15 +2,41 @@
2
2
  import React from 'react';
3
3
  import NextLink from 'next/link';
4
4
  import Icon from './icon';
5
+ import Figure from './figure';
6
+ import Image from './image';
5
7
  import { focusRing } from './sharedStyles';
6
8
  // A link set as a card: the title, a caption, and an arrow that moves off the corner.
7
9
  export default function LinkCard(_a) {
8
- var href = _a.href, title = _a.title, caption = _a.caption, _b = _a.className, className = _b === void 0 ? '' : _b;
9
- return (<NextLink href={href} className={"group flex items-center justify-between gap-xxlarge rounded-container bg-background-panel p-large transition-colors hover:bg-background-accent200 motion-reduce:transition-none ".concat(focusRing, " ").concat(className)}>
10
- <span className="flex flex-col gap-small">
11
- <span className="text-subtitle1 text-fg-primary">{title}</span>
12
- {caption && <span className="font-mono text-caption text-fg-secondary">{caption}</span>}
10
+ var href = _a.href, title = _a.title, caption = _a.caption, description = _a.description, image = _a.image, _b = _a.external, external = _b === void 0 ? false : _b, _c = _a.className, className = _c === void 0 ? '' : _c;
11
+ var text = (<span className="flex flex-col gap-small">
12
+ <span className="text-subtitle1 text-fg-primary">
13
+ {title}
14
+ {external && <span className="sr-only">, opens in a new tab</span>}
13
15
  </span>
14
- <Icon name="ArrowUpRight" size="small" color="secondary" className="shrink-0 transition-transform group-hover:-translate-y-0.5 group-hover:translate-x-0.5 motion-reduce:transition-none"/>
16
+ {description && <span className="text-body2 text-fg-secondary">{description}</span>}
17
+ {caption && <span className="font-mono text-caption text-fg-secondary">{caption}</span>}
18
+ </span>);
19
+ var arrow = (<Icon name="ArrowUpRight" size="small" color="secondary" className="shrink-0 transition-transform group-hover:-translate-y-0.5 group-hover:translate-x-0.5 motion-reduce:transition-none"/>);
20
+ var look = "rounded-container bg-background-panel p-large transition-colors hover:bg-background-accent200 motion-reduce:transition-none ".concat(focusRing, " ").concat(className);
21
+ var content = image ? (<>
22
+ <Figure crop={16 / 9} radius="control">
23
+ <Image src={image.src} alt={image.alt}/>
24
+ </Figure>
25
+ <span className="flex items-center justify-between gap-xxlarge">
26
+ {text}
27
+ {arrow}
28
+ </span>
29
+ </>) : (<>
30
+ {text}
31
+ {arrow}
32
+ </>);
33
+ var classes = image ? "group flex flex-col gap-medium ".concat(look) : "group flex items-center justify-between gap-xxlarge ".concat(look);
34
+ if (external) {
35
+ return (<a href={href} target="_blank" rel="noopener noreferrer" className={classes}>
36
+ {content}
37
+ </a>);
38
+ }
39
+ return (<NextLink href={href} className={classes}>
40
+ {content}
15
41
  </NextLink>);
16
42
  }
@@ -6,8 +6,16 @@ interface ModalProps {
6
6
  children: React.ReactNode;
7
7
  onClose: () => void;
8
8
  actions?: React.ReactNode;
9
- size?: 'small' | 'medium' | 'large';
9
+ /** `fill` is the viewport less 16px on a phone and 32px from md, for a Lightbox. */
10
+ size?: 'small' | 'medium' | 'large' | 'fill';
10
11
  initialFocus?: 'first' | 'body';
12
+ /**
13
+ * Names the dialog when it has no title (a search dialog), or in place of a title that changes as the
14
+ * dialog is used (a Lightbox, whose title is the image shown). Wins over the title for the name.
15
+ */
16
+ 'aria-label'?: string;
17
+ /** `top` sits the panel at the top below sm, so a phone keyboard does not cover a field in it. Centered from sm up. Default 'center'. */
18
+ placement?: 'center' | 'top';
11
19
  }
12
- export default function Modal({ isOpen, title, secondTitle, children, onClose, actions, size, initialFocus, }: ModalProps): React.JSX.Element | null;
20
+ export default function Modal({ isOpen, title, secondTitle, children, onClose, actions, size, initialFocus, 'aria-label': ariaLabel, placement, }: ModalProps): React.JSX.Element | null;
13
21
  export {};
@@ -5,11 +5,11 @@ import { useOverlayTransition } from './useOverlayTransition';
5
5
  import { initialFocusCandidates } from '../internal/modal';
6
6
  import { PICKABLE, claimEvent, isTopOverlay, lockScroll, popOverlay, pushOverlay, trapTab, unlockScroll } from '../internal/overlayStack';
7
7
  export default function Modal(_a) {
8
- var isOpen = _a.isOpen, title = _a.title, secondTitle = _a.secondTitle, children = _a.children, onClose = _a.onClose, actions = _a.actions, _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.initialFocus, initialFocus = _c === void 0 ? 'first' : _c;
8
+ var isOpen = _a.isOpen, title = _a.title, secondTitle = _a.secondTitle, children = _a.children, onClose = _a.onClose, actions = _a.actions, _b = _a.size, size = _b === void 0 ? 'medium' : _b, _c = _a.initialFocus, initialFocus = _c === void 0 ? 'first' : _c, ariaLabel = _a["aria-label"], _d = _a.placement, placement = _d === void 0 ? 'center' : _d;
9
9
  var panelRef = useRef(null);
10
10
  var bodyRef = useRef(null);
11
11
  var titleId = useId();
12
- var _d = useOverlayTransition(isOpen), mounted = _d.mounted, visible = _d.visible;
12
+ var _e = useOverlayTransition(isOpen), mounted = _e.mounted, visible = _e.visible;
13
13
  // Keep onClose in a ref so a new function each render doesn't re-run the focus effect
14
14
  var onCloseRef = useRef(onClose);
15
15
  onCloseRef.current = onClose;
@@ -62,7 +62,14 @@ export default function Modal(_a) {
62
62
  medium: { width: 'w-[600px]', maxWidth: '600px' },
63
63
  large: { width: 'w-[1024px]', maxWidth: '1024px' },
64
64
  };
65
- var _e = sizeConfig[size], modalWidth = _e.width, maxWidth = _e.maxWidth;
65
+ var fill = size === 'fill';
66
+ var _f = fill
67
+ ? { width: 'w-[calc(100vw-16px)] h-[calc(100dvh-16px)] md:w-[calc(100vw-32px)] md:h-[calc(100dvh-32px)]', maxWidth: undefined }
68
+ : sizeConfig[size], modalWidth = _f.width, maxWidth = _f.maxWidth;
69
+ var panelStyle = fill
70
+ ? { overflow: 'hidden' }
71
+ : { maxWidth: maxWidth, width: 'calc(100vw - 64px)', maxHeight: '90vh', overflow: 'hidden' };
72
+ var align = placement === 'top' ? 'items-start pt-2 sm:items-center sm:pt-0' : 'items-center';
66
73
  // close modal by clicking elsewhere
67
74
  var handleOverlayClick = function (e) {
68
75
  if (e.target === e.currentTarget) {
@@ -72,14 +79,12 @@ export default function Modal(_a) {
72
79
  if (!mounted)
73
80
  return null;
74
81
  // dark-only edge: a ring only in dark mode, so it keeps a dark: variant (it follows whatever dark variant the app's preset/@theme defines, class-only or OS-aware)
75
- return (<div className={"fixed bg-misc-scrim/40 flex items-center justify-center z-[var(--os-z-overlay)]\n transition-opacity duration-[var(--os-duration-fast)] ease-out motion-reduce:transition-none ".concat(visible ? 'opacity-100' : 'opacity-0')} style={{ top: 0, left: 0, right: 0, bottom: 0 }} onClick={handleOverlayClick}>
76
- <div ref={panelRef} role="dialog" aria-modal="true" aria-labelledby={title ? titleId : undefined} tabIndex={-1} className={"bg-background-elevated dark:ring-1 dark:ring-misc-divider rounded-control ".concat(modalWidth, " flex flex-col outline-none\n ").concat(overlayTransition, " ").concat(visible ? overlayVisible : overlayHidden)} style={{
77
- maxWidth: maxWidth,
78
- width: 'calc(100vw - 64px)',
79
- maxHeight: '90vh',
80
- overflow: 'hidden',
81
- }}>
82
- {(title || actions) && (<div className="px-6 py-3 border-b border-misc-divider flex justify-between items-start" style={{ flexShrink: 0 }}>
82
+ return (<div className={"fixed bg-misc-scrim/40 flex ".concat(align, " justify-center z-[var(--os-z-overlay)]\n transition-opacity duration-[var(--os-duration-fast)] ease-out motion-reduce:transition-none ").concat(visible ? 'opacity-100' : 'opacity-0')} style={{ top: 0, left: 0, right: 0, bottom: 0 }} onClick={handleOverlayClick}>
83
+ <div ref={panelRef} role="dialog" aria-modal="true" aria-label={ariaLabel} aria-labelledby={title && !ariaLabel ? titleId : undefined} tabIndex={-1} className={"bg-background-elevated dark:ring-1 dark:ring-misc-divider rounded-control ".concat(modalWidth, " flex flex-col outline-none\n ").concat(overlayTransition, " ").concat(visible ? overlayVisible : overlayHidden)} style={panelStyle}>
84
+ {(title || actions) && (
85
+ // Below sm the header wraps and the actions take their own line, end-aligned, so a long action is never cut off.
86
+ // Each phone class is undone from sm up.
87
+ <div className="px-6 py-3 border-b border-misc-divider flex justify-between items-start flex-wrap gap-y-2 sm:flex-nowrap sm:gap-y-0" style={{ flexShrink: 0 }}>
83
88
  {title && (<div className="flex flex-col">
84
89
  <h2 id={titleId} className="text-h5 text-fg-primary">
85
90
  {title}
@@ -88,7 +93,7 @@ export default function Modal(_a) {
88
93
  {secondTitle}
89
94
  </span>)}
90
95
  </div>)}
91
- {actions && (<div className="flex space-x-2">
96
+ {actions && (<div className="flex space-x-2 basis-full justify-end sm:basis-auto sm:justify-start">
92
97
  {actions}
93
98
  </div>)}
94
99
  </div>)}
@@ -16,7 +16,7 @@ export default function PageHeader(_a) {
16
16
  {eyebrow && (<Paragraph tone="secondary" size="body2" measure="none">
17
17
  {eyebrow}
18
18
  </Paragraph>)}
19
- <Tag className={"".concat(sizes[level], " text-fg-primary")}>{title}</Tag>
19
+ <Tag className={"".concat(sizes[level], " break-words text-fg-primary")}>{title}</Tag>
20
20
  {lede && (<Paragraph tone="secondary" measure="lede">
21
21
  {lede}
22
22
  </Paragraph>)}
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ interface PaginationProps {
3
+ /** The page being shown, counted from 1. */
4
+ page: number;
5
+ /** How many pages there are. With 1 or fewer, nothing renders. */
6
+ pageCount: number;
7
+ /** Called with the page asked for. Also called with the last page when `page` is past `pageCount` (a filter left fewer pages). */
8
+ onPageChange?: (page: number) => void;
9
+ /** Names the navigation. Defaults to 'Pages'. */
10
+ 'aria-label'?: string;
11
+ /** `default` is 'Previous', 'Page 3 of 12' and 'Next'. `compact` is two small arrows and '2 of 5', for a card. */
12
+ variant?: 'default' | 'compact';
13
+ /** Makes Previous and Next links to the address of that page, with `rel="prev"` and `rel="next"`. `onPageChange` is still called. */
14
+ getHref?: (page: number) => string;
15
+ /**
16
+ * The id of the element (the table) to scroll to the top of the view after a press of Previous or Next. Instant under
17
+ * reduced motion. Focus stays on Next so a keyboard user keeps paging, and the live region announces the page.
18
+ * A page set from outside (a filter reset) does not scroll.
19
+ */
20
+ scrollTargetId?: string;
21
+ }
22
+ /**
23
+ * Previous and Next with the page named in words. There are no numbered buttons: they do not fit a phone or 500 pages.
24
+ * The page text is a polite live region. When the press that reaches the first or last page leaves focus on a
25
+ * disabled button, focus moves to the other one.
26
+ */
27
+ export default function Pagination({ page, pageCount, onPageChange, 'aria-label': ariaLabel, variant, getHref, scrollTargetId, }: PaginationProps): React.JSX.Element | null;
28
+ export {};
@@ -0,0 +1,89 @@
1
+ 'use client';
2
+ import React, { useEffect, useRef } from 'react';
3
+ import Button from './button';
4
+ import IconButton from './iconButton';
5
+ import { formatCount } from './formatNumber';
6
+ /**
7
+ * Previous and Next with the page named in words. There are no numbered buttons: they do not fit a phone or 500 pages.
8
+ * The page text is a polite live region. When the press that reaches the first or last page leaves focus on a
9
+ * disabled button, focus moves to the other one.
10
+ */
11
+ export default function Pagination(_a) {
12
+ var page = _a.page, pageCount = _a.pageCount, onPageChange = _a.onPageChange, _b = _a["aria-label"], ariaLabel = _b === void 0 ? 'Pages' : _b, _c = _a.variant, variant = _c === void 0 ? 'default' : _c, getHref = _a.getHref, scrollTargetId = _a.scrollTargetId;
13
+ var navRef = useRef(null);
14
+ var prevRef = useRef(null);
15
+ var nextRef = useRef(null);
16
+ var pending = useRef(null);
17
+ var onChange = useRef(onPageChange);
18
+ onChange.current = onPageChange;
19
+ var lastPage = useRef(page);
20
+ // The page a press of Previous or Next asked for, so only reaching it scrolls: a parent resetting the page, the clamp and the first render do not
21
+ var pressed = useRef(null);
22
+ var last = Math.max(1, pageCount);
23
+ var shown = Math.max(1, Math.min(page, last));
24
+ // A filter that leaves fewer pages than the one being shown
25
+ useEffect(function () {
26
+ var _a;
27
+ if (page > pageCount)
28
+ (_a = onChange.current) === null || _a === void 0 ? void 0 : _a.call(onChange, last);
29
+ }, [page, pageCount, last]);
30
+ // Focus must not drop to the page when the Button it was on turns disabled
31
+ useEffect(function () {
32
+ var _a, _b;
33
+ var p = pending.current;
34
+ if (!p || p.to !== shown)
35
+ return;
36
+ pending.current = null;
37
+ var active = document.activeElement;
38
+ if (active && active !== document.body && !((_a = navRef.current) === null || _a === void 0 ? void 0 : _a.contains(active)))
39
+ return;
40
+ (_b = (p.focus === 'prev' ? prevRef : nextRef).current) === null || _b === void 0 ? void 0 : _b.focus();
41
+ }, [shown]);
42
+ useEffect(function () {
43
+ var _a;
44
+ if (lastPage.current === shown)
45
+ return;
46
+ lastPage.current = shown;
47
+ var byPress = pressed.current === shown;
48
+ pressed.current = null;
49
+ if (!scrollTargetId || !byPress)
50
+ return;
51
+ var reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
52
+ (_a = document.getElementById(scrollTargetId)) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: 'start', behavior: reduced ? 'instant' : 'smooth' });
53
+ }, [shown, scrollTargetId]);
54
+ if (pageCount <= 1)
55
+ return null;
56
+ var atFirst = shown <= 1;
57
+ var atLast = shown >= last;
58
+ var go = function (to, from) {
59
+ var _a;
60
+ if (to < 1 || to > last || to === shown)
61
+ return;
62
+ if (to === 1 || to === last)
63
+ pending.current = { to: to, focus: from === 'prev' ? 'next' : 'prev' };
64
+ pressed.current = to;
65
+ (_a = onChange.current) === null || _a === void 0 ? void 0 : _a.call(onChange, to);
66
+ };
67
+ var prevHref = getHref && !atFirst ? getHref(shown - 1) : undefined;
68
+ var nextHref = getHref && !atLast ? getHref(shown + 1) : undefined;
69
+ // `rel` is not a Button prop; it lands on the anchor with the rest
70
+ var prevRel = prevHref ? { rel: 'prev' } : {};
71
+ var nextRel = nextHref ? { rel: 'next' } : {};
72
+ var of = "".concat(formatCount(shown), " of ").concat(formatCount(pageCount));
73
+ var text = variant === 'compact' ? of : "Page ".concat(of);
74
+ var live = (<span aria-live="polite" aria-atomic="true" className={"tabular-nums text-fg-secondary ".concat(variant === 'compact' ? 'text-caption' : 'text-body2')}>
75
+ {text}
76
+ </span>);
77
+ if (variant === 'compact') {
78
+ return (<nav ref={navRef} aria-label={ariaLabel} className="flex items-center gap-1">
79
+ <IconButton ref={prevRef} color="iconOnly" size="tiny" state={atFirst ? 'disabled' : 'enabled'} iconName="ChevronLeft" ariaLabel="Previous page" href={prevHref} onClick={function () { return go(shown - 1, 'prev'); }} {...prevRel}/>
80
+ {live}
81
+ <IconButton ref={nextRef} color="iconOnly" size="tiny" state={atLast ? 'disabled' : 'enabled'} iconName="ChevronRight" ariaLabel="Next page" href={nextHref} onClick={function () { return go(shown + 1, 'next'); }} {...nextRel}/>
82
+ </nav>);
83
+ }
84
+ return (<nav ref={navRef} aria-label={ariaLabel} className="flex items-center justify-between gap-2">
85
+ <Button ref={prevRef} size="small" type="tertiary" state={atFirst ? 'disabled' : 'enabled'} label="Previous" decoIcon="ChevronLeft" aria-label="Previous page" href={prevHref} onClickButton={function () { return go(shown - 1, 'prev'); }} {...prevRel}/>
86
+ {live}
87
+ <Button ref={nextRef} size="small" type="tertiary" state={atLast ? 'disabled' : 'enabled'} label="Next" actionIcon="ChevronRight" aria-label="Next page" href={nextHref} onClickButton={function () { return go(shown + 1, 'next'); }} {...nextRel}/>
88
+ </nav>);
89
+ }
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ interface ProgressProps {
3
+ /** What is measured, e.g. "Responses". Always the meter's name, even with `hideLabel`. */
4
+ label: string;
5
+ /** The amount used. */
6
+ value: number;
7
+ /** The limit. `null` means there is no limit: the label and the text show, with no bar and no `meter` role. */
8
+ max: number | null;
9
+ /** The words for the amount, in place of '<value> of <max> <unit>'. */
10
+ valueText?: string;
11
+ /** What is counted, e.g. "responses". Goes after the numbers in the default text. */
12
+ unit?: string;
13
+ /**
14
+ * `limit` (default) is how much of a limit is used: the bar turns to a warning near it and to an error at it.
15
+ * `share` is one part of a total (`max` is the total): always the main color, no status words, and the text is
16
+ * '42%, 1,240 responses'. A share is not a limit.
17
+ */
18
+ kind?: 'limit' | 'share';
19
+ /** The share of `max` where the bar turns to a warning. Defaults to 0.8. */
20
+ warnAt?: number;
21
+ /** Keeps the name for a screen reader and hides the row of words, for a bar in a table cell. */
22
+ hideLabel?: boolean;
23
+ /** Bar thickness: 4px or 6px. */
24
+ size?: 'small' | 'medium';
25
+ id?: string;
26
+ 'aria-describedby'?: string;
27
+ }
28
+ /**
29
+ * A meter: how much of a limit is used. It is not a task progress bar and not a spinner. The bar turns to a
30
+ * warning near the limit and to an error at it, and says so in words, never by color alone.
31
+ */
32
+ export default function Progress({ label, value, max, valueText, unit, kind, warnAt, hideLabel, size, id, 'aria-describedby': describedBy, }: ProgressProps): React.JSX.Element;
33
+ export {};
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+ import React, { useId } from 'react';
3
+ import { formatCount, formatPercent } from './formatNumber';
4
+ /**
5
+ * A meter: how much of a limit is used. It is not a task progress bar and not a spinner. The bar turns to a
6
+ * warning near the limit and to an error at it, and says so in words, never by color alone.
7
+ */
8
+ export default function Progress(_a) {
9
+ var label = _a.label, value = _a.value, max = _a.max, valueText = _a.valueText, unit = _a.unit, _b = _a.kind, kind = _b === void 0 ? 'limit' : _b, _c = _a.warnAt, warnAt = _c === void 0 ? 0.8 : _c, _d = _a.hideLabel, hideLabel = _d === void 0 ? false : _d, _e = _a.size, size = _e === void 0 ? 'medium' : _e, id = _a.id, describedBy = _a["aria-describedby"];
10
+ var autoId = useId();
11
+ var labelId = "".concat(id !== null && id !== void 0 ? id : autoId, "-label");
12
+ var withUnit = function (text) { return (unit ? "".concat(text, " ").concat(unit) : text); };
13
+ var rowClasses = "flex items-baseline justify-between gap-2 text-body2".concat(hideLabel ? ' sr-only' : '');
14
+ if (max === null) {
15
+ var text_1 = valueText !== null && valueText !== void 0 ? valueText : "".concat(withUnit(formatCount(value)), ", no limit");
16
+ return (
17
+ // No meter here, so there is nothing for aria-describedby to describe: it is ignored
18
+ <div id={id} className="w-full">
19
+ <div className={rowClasses}>
20
+ <span className="text-fg-primary">{label}</span>
21
+ <span className="text-fg-secondary">{text_1}</span>
22
+ </div>
23
+ </div>);
24
+ }
25
+ var fraction = max > 0 ? value / max : value > 0 ? 1 : 0;
26
+ var now = Math.min(max, Math.max(0, value));
27
+ var status = kind === 'share' ? 'primary' : fraction >= 1 ? 'error' : fraction >= warnAt ? 'warning' : 'primary';
28
+ var share = kind === 'share';
29
+ var text = valueText !== null && valueText !== void 0 ? valueText : (share ? withUnit("".concat(formatPercent(max > 0 ? value / max : 0), ", ").concat(formatCount(value))) : withUnit("".concat(formatCount(value), " of ").concat(formatCount(max))));
30
+ var suffix = share ? '' : status === 'error' ? (value > max ? ', over the limit' : ', at the limit') : status === 'warning' ? ', almost at the limit' : '';
31
+ var statusWords = { error: 'Limit reached', warning: 'Almost at the limit', primary: '' }[status];
32
+ var bar = { error: 'bg-error-main', warning: 'bg-warning-main', primary: 'bg-accent-main' }[status];
33
+ var wordColor = { error: 'text-error-text', warning: 'text-warning-text', primary: '' }[status];
34
+ var percent = Math.min(100, Math.max(0, fraction * 100));
35
+ return (
36
+ // The wrapper is the meter: a meter's children are presentational, so a reader that supports the role says the
37
+ // name and value text once, and one that does not reads the visible words
38
+ <div id={id} role="meter" aria-labelledby={labelId} aria-valuemin={0} aria-valuenow={now} aria-valuemax={max} aria-valuetext={"".concat(text).concat(suffix)} aria-describedby={describedBy} className="w-full">
39
+ <div className={rowClasses}>
40
+ <span id={labelId} className="text-fg-primary">{label}</span>
41
+ <span className="text-fg-secondary">
42
+ {text}
43
+ {statusWords && <span className={"ml-1 ".concat(wordColor)}>{statusWords}</span>}
44
+ </span>
45
+ </div>
46
+ <div className={"".concat(hideLabel ? '' : 'mt-1 ', "w-full overflow-hidden rounded-full bg-fg-primary/10 ").concat(size === 'small' ? 'h-1' : 'h-[6px]')}>
47
+ <div className={"h-full rounded-full ".concat(bar, " transition-[width] duration-[var(--os-duration-fast)] ease-out motion-reduce:transition-none")} style={{ width: "".concat(percent, "%") }}/>
48
+ </div>
49
+ </div>);
50
+ }
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ export interface SearchResult {
3
+ id: string;
4
+ title: string;
5
+ /** A line of the text around the match. The query's words are marked in it, as in the title. */
6
+ excerpt?: string;
7
+ /** Where it is, such as the workspace or the section. */
8
+ secondLabel?: string;
9
+ href: string;
10
+ /** A Lucide icon name for the kind of thing it is. */
11
+ iconName?: string;
12
+ }
13
+ export interface SearchGroup {
14
+ /** Names the group, such as 'Docs' or 'Tasks'. */
15
+ label: string;
16
+ items: SearchResult[];
17
+ }
18
+ interface SearchDialogProps {
19
+ isOpen: boolean;
20
+ onClose: () => void;
21
+ query: string;
22
+ onQueryChange: (query: string) => void;
23
+ /** The results for `query`. While `status` is 'loading', the last results stay on screen. */
24
+ groups: SearchGroup[];
25
+ /**
26
+ * 'idle' before anything is typed, 'loading' while the caller fetches, 'done' with the results, 'error' when the
27
+ * fetch failed. The caller drops a reply for an older query, so `groups` always answer the current `query`.
28
+ */
29
+ status: 'idle' | 'loading' | 'done' | 'error';
30
+ /** Called by 'Try Again' after a failure. */
31
+ onRetry?: () => void;
32
+ /** Shown before anything is typed, at most 6, most recent first. */
33
+ recent?: SearchResult[];
34
+ /** Names the dialog and the field. Defaults to 'Search'. */
35
+ 'aria-label'?: string;
36
+ placeholder?: string;
37
+ }
38
+ /**
39
+ * Site search in a Modal: the field first, then the results in groups. Focus stays in the field; the arrows move the
40
+ * highlight, Enter follows the highlighted link, and Escape closes. One polite status says the count, 'Searching'
41
+ * after 300 ms of waiting, that nothing matched, or that search failed. The caller fetches and passes the results.
42
+ */
43
+ export default function SearchDialog({ isOpen, onClose, query, onQueryChange, groups, status, onRetry, recent, 'aria-label': ariaLabel, placeholder, }: SearchDialogProps): React.JSX.Element;
44
+ export { SearchDialog };