@bloxwap/hig 0.7.0 → 0.8.1

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 (246) hide show
  1. package/README.md +2 -2
  2. package/chart/README.md +13 -2
  3. package/chart/dist/altimeter-burst.d.ts +4 -0
  4. package/chart/dist/altimeter-burst.js +43 -0
  5. package/chart/dist/altimeter-chart.d.ts +52 -0
  6. package/chart/dist/altimeter-chart.js +275 -0
  7. package/chart/dist/altimeter-model.d.ts +43 -0
  8. package/chart/dist/altimeter-model.js +148 -0
  9. package/chart/dist/altimeter-targets.d.ts +33 -0
  10. package/chart/dist/altimeter-targets.js +88 -0
  11. package/chart/dist/bitcoin-price.d.ts +8 -0
  12. package/chart/dist/bitcoin-price.js +41 -0
  13. package/chart/dist/champions-league.d.ts +19 -0
  14. package/chart/dist/champions-league.js +104 -0
  15. package/chart/dist/index.d.ts +6 -0
  16. package/chart/dist/index.js +5 -0
  17. package/chart/dist/outcome-chart.d.ts +37 -0
  18. package/chart/dist/outcome-chart.js +212 -0
  19. package/chart/dist/outcome-model.d.ts +43 -0
  20. package/chart/dist/outcome-model.js +71 -0
  21. package/chart/dist/plus-grid.d.ts +6 -0
  22. package/chart/dist/plus-grid.js +29 -0
  23. package/contracts/README.md +1 -1
  24. package/contracts/dist/avatar.d.ts +68 -0
  25. package/contracts/dist/avatar.js +93 -0
  26. package/contracts/dist/confetti.d.ts +174 -0
  27. package/contracts/dist/confetti.js +138 -0
  28. package/contracts/dist/decimal.d.ts +7 -0
  29. package/contracts/dist/decimal.js +35 -0
  30. package/contracts/dist/index.d.ts +29 -2
  31. package/contracts/dist/index.js +123 -4
  32. package/contracts/dist/invariants.d.ts +17 -0
  33. package/contracts/dist/invariants.js +24 -0
  34. package/contracts/dist/messages.d.ts +56 -2
  35. package/contracts/dist/messages.js +20 -2
  36. package/contracts/dist/number-flow.d.ts +90 -0
  37. package/contracts/dist/number-flow.js +150 -0
  38. package/contracts/dist/qr.d.ts +151 -0
  39. package/contracts/dist/qr.js +581 -0
  40. package/contracts/dist/toast.d.ts +168 -0
  41. package/contracts/dist/toast.js +171 -0
  42. package/feedback/README.md +1 -1
  43. package/feedback/dist/contract.js +1 -1
  44. package/feedback/dist/react.js +2 -4
  45. package/native/README.md +6 -1
  46. package/native/dist/account-block.d.ts +10 -1
  47. package/native/dist/account-block.js +17 -7
  48. package/native/dist/animated-number-model.d.ts +41 -1
  49. package/native/dist/animated-number-model.js +201 -23
  50. package/native/dist/animated-number.d.ts +39 -1
  51. package/native/dist/animated-number.js +161 -16
  52. package/native/dist/announce.d.ts +2 -0
  53. package/native/dist/announce.js +10 -0
  54. package/native/dist/asset-balance-row.d.ts +3 -1
  55. package/native/dist/asset-balance-row.js +15 -4
  56. package/native/dist/assets-block.d.ts +115 -0
  57. package/native/dist/assets-block.js +87 -0
  58. package/native/dist/async-result.d.ts +2 -0
  59. package/native/dist/async-result.js +11 -0
  60. package/native/dist/avatar-frame.d.ts +29 -0
  61. package/native/dist/avatar-frame.js +56 -0
  62. package/native/dist/avatar.d.ts +21 -0
  63. package/native/dist/avatar.js +31 -0
  64. package/native/dist/bar-mark.d.ts +2 -0
  65. package/native/dist/bar-mark.js +4 -2
  66. package/native/dist/bar-pnl.js +2 -1
  67. package/native/dist/blocks.d.ts +6 -1
  68. package/native/dist/blocks.js +5 -0
  69. package/native/dist/brand.js +2 -1
  70. package/native/dist/button.d.ts +7 -2
  71. package/native/dist/button.js +13 -3
  72. package/native/dist/checkbox.js +2 -1
  73. package/native/dist/confetti.d.ts +33 -0
  74. package/native/dist/confetti.js +143 -0
  75. package/native/dist/confirm-block.d.ts +98 -0
  76. package/native/dist/confirm-block.js +48 -0
  77. package/native/dist/data.js +2 -0
  78. package/native/dist/explainer-block.d.ts +91 -0
  79. package/native/dist/explainer-block.js +34 -0
  80. package/native/dist/field.d.ts +5 -1
  81. package/native/dist/field.js +27 -6
  82. package/native/dist/gesture-sheet-model.d.ts +50 -0
  83. package/native/dist/gesture-sheet-model.js +105 -0
  84. package/native/dist/gesture-sheet-next.d.ts +82 -0
  85. package/native/dist/gesture-sheet-next.js +315 -0
  86. package/native/dist/gesture-sheet.d.ts +5 -1
  87. package/native/dist/gesture-sheet.js +13 -6
  88. package/native/dist/icons.d.ts +9 -6
  89. package/native/dist/icons.js +25 -24
  90. package/native/dist/language-block.d.ts +10 -1
  91. package/native/dist/language-block.js +11 -4
  92. package/native/dist/list-group.d.ts +3 -1
  93. package/native/dist/list-group.js +26 -13
  94. package/native/dist/manage-position-block.d.ts +8 -1
  95. package/native/dist/manage-position-block.js +7 -2
  96. package/native/dist/market-row.js +19 -8
  97. package/native/dist/navigation.js +5 -3
  98. package/native/dist/number-format.d.ts +6 -0
  99. package/native/dist/number-format.js +9 -0
  100. package/native/dist/pickers.d.ts +8 -0
  101. package/native/dist/pickers.js +3 -3
  102. package/native/dist/position-block.d.ts +5 -5
  103. package/native/dist/preset-group.d.ts +31 -0
  104. package/native/dist/preset-group.js +39 -0
  105. package/native/dist/preset-picker-block.d.ts +107 -0
  106. package/native/dist/preset-picker-block.js +43 -0
  107. package/native/dist/profile-block.d.ts +10 -1
  108. package/native/dist/profile-block.js +8 -3
  109. package/native/dist/provider.d.ts +5 -2
  110. package/native/dist/provider.js +27 -5
  111. package/native/dist/qr-code.d.ts +33 -0
  112. package/native/dist/qr-code.js +29 -0
  113. package/native/dist/radio-group.d.ts +19 -7
  114. package/native/dist/radio-group.js +39 -10
  115. package/native/dist/reward-block.d.ts +10 -7
  116. package/native/dist/reward-block.js +9 -4
  117. package/native/dist/screen-header.d.ts +13 -3
  118. package/native/dist/screen-header.js +12 -4
  119. package/native/dist/select.js +4 -2
  120. package/native/dist/selection.d.ts +2 -1
  121. package/native/dist/selection.js +1 -0
  122. package/native/dist/setting-switch.d.ts +1 -1
  123. package/native/dist/setting-switch.js +7 -3
  124. package/native/dist/slider.js +5 -1
  125. package/native/dist/sound-haptics-block.js +1 -1
  126. package/native/dist/status.d.ts +41 -9
  127. package/native/dist/status.js +34 -17
  128. package/native/dist/sticky-header.js +9 -1
  129. package/native/dist/swap-amount-card.d.ts +57 -0
  130. package/native/dist/swap-amount-card.js +31 -0
  131. package/native/dist/swap-panel-block.d.ts +9 -3
  132. package/native/dist/swap-panel-block.js +59 -33
  133. package/native/dist/swap-parts.d.ts +3 -10
  134. package/native/dist/swap-parts.js +22 -24
  135. package/native/dist/swap-shared.d.ts +2 -2
  136. package/native/dist/swap-shared.js +10 -6
  137. package/native/dist/swap-views.js +1 -1
  138. package/native/dist/target-block.d.ts +7 -1
  139. package/native/dist/target-block.js +13 -6
  140. package/native/dist/toast.d.ts +47 -0
  141. package/native/dist/toast.js +386 -0
  142. package/native/dist/token-action-block.d.ts +10 -1
  143. package/native/dist/token-action-block.js +9 -4
  144. package/native/dist/trade-history-list-block.js +7 -4
  145. package/native/dist/wallet-address-core.js +6 -3
  146. package/native-fonts/README.md +1 -1
  147. package/og-fonts/README.md +1 -1
  148. package/package.json +111 -2
  149. package/react/README.md +3 -1
  150. package/react/dist/animated-number-flow.d.ts +72 -0
  151. package/react/dist/animated-number-flow.js +316 -0
  152. package/react/dist/animated-number-model.d.ts +18 -0
  153. package/react/dist/animated-number-model.js +75 -5
  154. package/react/dist/animated-number.d.ts +45 -1
  155. package/react/dist/animated-number.js +137 -6
  156. package/react/dist/asset-balance-row.d.ts +3 -1
  157. package/react/dist/asset-balance-row.js +10 -4
  158. package/react/dist/async-result.d.ts +2 -0
  159. package/react/dist/async-result.js +11 -0
  160. package/react/dist/avatar.d.ts +25 -0
  161. package/react/dist/avatar.js +50 -0
  162. package/react/dist/blocks/account-block.d.ts +5 -1
  163. package/react/dist/blocks/account-block.js +11 -6
  164. package/react/dist/blocks/assets-block.d.ts +106 -0
  165. package/react/dist/blocks/assets-block.js +135 -0
  166. package/react/dist/blocks/confirm-block.d.ts +91 -0
  167. package/react/dist/blocks/confirm-block.js +31 -0
  168. package/react/dist/blocks/explainer-block.d.ts +80 -0
  169. package/react/dist/blocks/explainer-block.js +20 -0
  170. package/react/dist/blocks/install-command.js +3 -1
  171. package/react/dist/blocks/language-block.d.ts +5 -1
  172. package/react/dist/blocks/language-block.js +4 -3
  173. package/react/dist/blocks/manage-position-block.d.ts +3 -1
  174. package/react/dist/blocks/manage-position-block.js +2 -2
  175. package/react/dist/blocks/market-row.js +8 -3
  176. package/react/dist/blocks/notifications-block.d.ts +3 -1
  177. package/react/dist/blocks/notifications-block.js +2 -2
  178. package/react/dist/blocks/pickers.d.ts +9 -0
  179. package/react/dist/blocks/pickers.js +4 -2
  180. package/react/dist/blocks/position-block.d.ts +3 -3
  181. package/react/dist/blocks/preset-picker-block.d.ts +85 -0
  182. package/react/dist/blocks/preset-picker-block.js +19 -0
  183. package/react/dist/blocks/profile-block.d.ts +5 -1
  184. package/react/dist/blocks/profile-block.js +12 -13
  185. package/react/dist/blocks/reward-block.d.ts +13 -8
  186. package/react/dist/blocks/reward-block.js +7 -4
  187. package/react/dist/blocks/screen-header.d.ts +10 -2
  188. package/react/dist/blocks/screen-header.js +7 -4
  189. package/react/dist/blocks/setting-switch.js +6 -3
  190. package/react/dist/blocks/signals-block.d.ts +3 -1
  191. package/react/dist/blocks/signals-block.js +4 -3
  192. package/react/dist/blocks/sound-haptics-block.d.ts +3 -1
  193. package/react/dist/blocks/sound-haptics-block.js +2 -2
  194. package/react/dist/blocks/sticky-header.d.ts +14 -4
  195. package/react/dist/blocks/sticky-header.js +68 -8
  196. package/react/dist/blocks/swap/settings.js +2 -1
  197. package/react/dist/blocks/swap/shared.d.ts +22 -22
  198. package/react/dist/blocks/swap/shared.js +30 -28
  199. package/react/dist/blocks/swap-panel-block.d.ts +10 -3
  200. package/react/dist/blocks/swap-panel-block.js +71 -36
  201. package/react/dist/blocks/target-block.d.ts +7 -1
  202. package/react/dist/blocks/target-block.js +10 -4
  203. package/react/dist/blocks/token-action-block.d.ts +5 -1
  204. package/react/dist/blocks/token-action-block.js +2 -2
  205. package/react/dist/blocks/trade-history-detail-block.d.ts +3 -1
  206. package/react/dist/blocks/trade-history-detail-block.js +2 -2
  207. package/react/dist/blocks/trade-history-list-block.d.ts +3 -1
  208. package/react/dist/blocks/trade-history-list-block.js +7 -4
  209. package/react/dist/blocks.d.ts +5 -1
  210. package/react/dist/blocks.js +4 -0
  211. package/react/dist/brand.js +2 -1
  212. package/react/dist/button.d.ts +9 -3
  213. package/react/dist/button.js +8 -3
  214. package/react/dist/confetti.d.ts +27 -0
  215. package/react/dist/confetti.js +240 -0
  216. package/react/dist/data.js +8 -1
  217. package/react/dist/field.d.ts +6 -1
  218. package/react/dist/field.js +18 -9
  219. package/react/dist/gesture-sheet.d.ts +15 -1
  220. package/react/dist/gesture-sheet.js +53 -8
  221. package/react/dist/list-group.js +11 -7
  222. package/react/dist/navigation.js +11 -3
  223. package/react/dist/overlay.d.ts +28 -3
  224. package/react/dist/overlay.js +29 -3
  225. package/react/dist/preset-group.d.ts +30 -0
  226. package/react/dist/preset-group.js +13 -0
  227. package/react/dist/provider.d.ts +2 -2
  228. package/react/dist/provider.js +23 -6
  229. package/react/dist/qr-code.d.ts +32 -0
  230. package/react/dist/qr-code.js +28 -0
  231. package/react/dist/select.js +10 -3
  232. package/react/dist/selection.d.ts +13 -5
  233. package/react/dist/selection.js +13 -8
  234. package/react/dist/slider.js +5 -1
  235. package/react/dist/status.d.ts +14 -10
  236. package/react/dist/status.js +17 -9
  237. package/react/dist/styles.css +238 -163
  238. package/react/dist/toast.d.ts +19 -12
  239. package/react/dist/toast.js +29 -7
  240. package/react/dist/wallet-address-core.d.ts +8 -4
  241. package/react/dist/wallet-address-core.js +10 -5
  242. package/tokens/README.md +2 -2
  243. package/tokens/dist/index.d.ts +16 -0
  244. package/tokens/dist/index.js +16 -0
  245. package/tokens/dist/manifest.json +8 -0
  246. package/tokens/dist/tokens.css +6 -0
@@ -1,5 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ChevronDown } from '@bloxwap/icons/react/chevron-down';
4
+ import { assertUniqueKeys, paginationValue } from '@bloxwap/hig/contracts';
3
5
  import { useEffect, useId, useLayoutEffect, useRef } from 'react';
4
6
  import { formatNumber } from '@bloxwap/hig/contracts';
5
7
  import * as en from '@bloxwap/hig/contracts/messages';
@@ -34,7 +36,12 @@ else if (!stop && panel.hasAttribute('tabindex'))
34
36
  export function Tabs({ label, items, value, defaultValue, onValueChange }) {
35
37
  const { direction } = useHIG();
36
38
  const id = useId();
37
- const [current, set] = useControllable(value, defaultValue ?? items.find(item => !item.disabled)?.value ?? '', onValueChange);
39
+ const [stored, set] = useControllable(value, defaultValue ?? items.find(item => !item.disabled)?.value ?? '', onValueChange);
40
+ assertUniqueKeys(items, item => item.value, 'Tabs');
41
+ const controlled = useRef(value !== undefined).current;
42
+ const current = items.some(item => item.value === stored && !item.disabled) ? stored : controlled ? '' : items.find(item => !item.disabled)?.value ?? '';
43
+ useEffect(() => { if (!controlled && stored !== current)
44
+ set(current); }, [controlled, stored, current]);
38
45
  const enabled = items.filter(item => !item.disabled);
39
46
  const tabStop = (enabled.find(item => item.value === current) ?? enabled[0])?.value;
40
47
  // APG: a panel is a tab stop only when its first content is not focusable; otherwise that control is the single stop after the tab list.
@@ -62,8 +69,9 @@ export function Tabs({ label, items, value, defaultValue, onValueChange }) {
62
69
  document.getElementById(`${id}-tab-${enabled[next].value}`)?.focus();
63
70
  } }, children: items.map(item => _jsx("button", { type: 'button', className: 'hig-button hig-tab', role: 'tab', id: `${id}-tab-${item.value}`, "aria-controls": `${id}-panel-${item.value}`, "aria-selected": current === item.value, tabIndex: tabStop === item.value ? 0 : -1, disabled: item.disabled, onClick: () => set(item.value), children: item.label }, item.value)) }), items.map(item => _jsx("div", { ref: current === item.value ? panel : undefined, hidden: current !== item.value, className: 'hig-tab-panel', role: 'tabpanel', id: `${id}-panel-${item.value}`, "aria-labelledby": `${id}-tab-${item.value}`, tabIndex: 0, children: item.content }, item.value))] });
64
71
  }
65
- export function Accordion({ title, children, open, onOpenChange }) { return _jsxs("details", { open: open, className: 'hig-surface hig-accordion', onToggle: e => onOpenChange?.(e.currentTarget.open), children: [_jsxs("summary", { className: 'hig-accordion-summary', children: [_jsx("span", { children: title }), _jsx("svg", { className: 'hig-accordion-chevron', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', children: _jsx("path", { d: 'm5 7.5 5 5 5-5' }) })] }), children] }); }
72
+ export function Accordion({ title, children, open, onOpenChange }) { const [current, set] = useControllable(open, false, onOpenChange, 'disclosure'); return _jsxs("details", { open: current, className: 'hig-surface hig-accordion', onToggle: e => { if (e.currentTarget.open !== current)
73
+ e.currentTarget.open = current; }, children: [_jsxs("summary", { className: 'hig-accordion-summary', onClick: e => { e.preventDefault(); set(!current); }, children: [_jsx("span", { children: title }), _jsx(ChevronDown, { size: 20, className: 'hig-accordion-chevron' })] }), children] }); }
66
74
  export function Breadcrumb({ items }) { const { messages } = useHIG(); return _jsx("nav", { "aria-label": messages.breadcrumb ?? en.breadcrumb, children: _jsx("ol", { role: 'list', className: 'hig-inline hig-breadcrumb', children: items.map((item, i) => _jsxs("li", { children: [i > 0 && _jsx("span", { "aria-hidden": 'true', className: 'hig-breadcrumb-separator', children: "/" }), item.href ? _jsx(Link, { href: item.href, "aria-current": i === items.length - 1 ? 'page' : undefined, children: item.label }) : _jsx("span", { "aria-current": i === items.length - 1 ? 'page' : undefined, children: item.label })] }, i)) }) }); }
67
75
  export function Navigation({ label, items }) { return _jsx("nav", { "aria-label": label, className: 'hig-stack hig-navigation', children: items.map(item => _jsx(Link, { href: item.href, "aria-current": item.active ? 'page' : undefined, children: item.label }, item.href)) }); }
68
- export function Pagination({ page, total, onPageChange }) { const { locale, messages } = useHIG(); return _jsxs("nav", { "aria-label": messages.pagination ?? en.pagination, className: 'hig-inline hig-pagination', children: [_jsx(Button, { intent: 'secondary', disabled: page <= 1, onClick: () => onPageChange(page - 1), children: messages.previous ?? en.previous }), _jsx("span", { children: (messages.pageOf ?? en.pageOf)(formatNumber(page, locale), formatNumber(total, locale)) }), _jsx(Button, { intent: 'secondary', disabled: page >= total, onClick: () => onPageChange(page + 1), children: messages.next ?? en.next })] }); }
76
+ export function Pagination({ page, total, onPageChange }) { ({ page, total } = paginationValue(page, total)); const { locale, messages } = useHIG(); return _jsxs("nav", { "aria-label": messages.pagination ?? en.pagination, className: 'hig-inline hig-pagination', children: [_jsx(Button, { intent: 'secondary', disabled: page <= 1, onClick: () => onPageChange(page - 1), children: messages.previous ?? en.previous }), _jsx("span", { children: (messages.pageOf ?? en.pageOf)(formatNumber(page, locale), formatNumber(total, locale)) }), _jsx(Button, { intent: 'secondary', disabled: page >= total, onClick: () => onPageChange(page + 1), children: messages.next ?? en.next })] }); }
69
77
  export function Search({ query, onQueryChange, results, loading, error }) { const { messages } = useHIG(); return _jsxs("section", { children: [_jsx(Field, { label: messages.search ?? en.search, children: _jsx(SearchInput, { value: query, onChange: e => onQueryChange(e.target.value) }) }), loading ? _jsx("p", { role: 'status', children: messages.searching ?? en.searching }) : error ? _jsx("p", { role: 'alert', children: error }) : results.length ? _jsx("ul", { children: results.map(r => _jsx("li", { children: _jsx(Button, { intent: 'ghost', onClick: r.onSelect, children: r.label }) }, r.id)) }) : _jsx("p", { role: 'status', children: messages.noResults ?? en.noResults })] }); }
@@ -8,10 +8,35 @@ export declare function Menu({ label, items }: {
8
8
  onSelect: (event: Event) => void;
9
9
  }[];
10
10
  }): React.JSX.Element;
11
- export declare function Popover({ label, children, closeLabel }: React.PropsWithChildren<{
12
- label: string; /** Close button text and accessible name; defaults to HIGProvider `messages.close`. */
11
+ export interface PopoverProps {
12
+ /** Text of the built-in trigger, a secondary Button. With `trigger`, it names the popover instead (`aria-label` on its content). */
13
+ label: string;
14
+ children?: React.ReactNode;
15
+ /** Close button text and accessible name; defaults to HIGProvider `messages.close`. */
13
16
  closeLabel?: string;
14
- }>): React.JSX.Element;
17
+ /** Leaves out the Close button, for a popover that holds only information or that the host closes itself. Escape and a press outside still close it. */
18
+ hideClose?: boolean;
19
+ /** Controls whether the popover is open. Omit it, with `defaultOpen`, to let the popover keep its own state. */
20
+ open?: boolean;
21
+ defaultOpen?: boolean;
22
+ /** Called with the next state when the trigger, Close, Escape, a press outside or (with `openOnHover`) the pointer opens or closes it. */
23
+ onOpenChange?: (open: boolean) => void;
24
+ /** The host's own trigger in place of the built-in Button: one element that accepts a ref and spreads its props onto a focusable element, such as a HIG `Button`, `IconButton` or a `<button>`. */
25
+ trigger?: React.ReactElement;
26
+ /** Also opens while a mouse pointer rests on the trigger, and closes shortly after it leaves both the trigger and the popover. Touch and pen keep press to open; keyboard focus is not moved by a hover. */
27
+ openOnHover?: boolean;
28
+ /** `data-testid` of the popover's content. */
29
+ testID?: string;
30
+ /** Tints the popover's surface from a token role: a 12% wash over its fill, a 40% stroke and a soft glow in the role's colour, such as `warning` for a gold badge's explanation. `data-tone` on the content. Without it the surface is neutral. */
31
+ tone?: PopoverTone;
32
+ /** Classes added to the popover's content after `hig-popover`, for a host surface treatment the tones do not cover. */
33
+ className?: string;
34
+ /** Inline style for the popover's content, after the theme's variables, so it can set `--hig-popover-tone` or a host border, background or shadow. */
35
+ style?: React.CSSProperties;
36
+ }
37
+ /** A token role that tints a `Popover`'s surface. */
38
+ export type PopoverTone = 'info' | 'positive' | 'warning' | 'negative';
39
+ export declare function Popover({ label, children, closeLabel, hideClose, open, defaultOpen, onOpenChange, trigger, openOnHover, testID, tone, className, style }: PopoverProps): React.JSX.Element;
15
40
  export declare function Tooltip({ content, children }: React.PropsWithChildren<{
16
41
  content: string;
17
42
  }>): React.JSX.Element;
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useId, useRef } from 'react';
3
+ import { useEffect, useId, useRef } from 'react';
4
4
  import * as en from '@bloxwap/hig/contracts/messages';
5
- import { useHIG, useThemeStyle } from './provider.js';
5
+ import { useControllable, useHIG, useThemeStyle } from './provider.js';
6
6
  import * as Drop from '@radix-ui/react-dropdown-menu';
7
7
  import * as Pop from '@radix-ui/react-popover';
8
8
  import * as Tip from '@radix-ui/react-tooltip';
@@ -14,5 +14,31 @@ export function Menu({ label, items }) { const { feedback, direction, locale, de
14
14
  feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent: 'selection', origin: origin.current });
15
15
  }
16
16
  catch { /* Optional feedback cannot alter the action. */ } }, children: item.label }, i)) }) })] }); }
17
- export function Popover({ label, children, closeLabel }) { const { messages, direction, locale, density } = useHIG(); const themeStyle = useThemeStyle(); return _jsxs(Pop.Root, { children: [_jsx(Pop.Trigger, { asChild: true, children: _jsx(Button, { intent: 'secondary', suppressFeedback: true, children: label }) }), _jsx(Pop.Portal, { children: _jsxs(Pop.Content, { className: 'hig-popover', sideOffset: 6, collisionPadding: 16, style: themeStyle, dir: direction, lang: locale, "data-hig-density": density, children: [children, _jsx(Pop.Close, { asChild: true, children: _jsx(Button, { intent: 'ghost', suppressFeedback: true, children: closeLabel ?? messages.close ?? en.close }) })] }) })] }); }
17
+ /** How long the pointer may be off the trigger and the popover before a hover-opened popover closes, so it can cross the gap between them. */
18
+ const hoverCloseDelay = 150;
19
+ export function Popover({ label, children, closeLabel, hideClose, open, defaultOpen = false, onOpenChange, trigger, openOnHover, testID, tone, className, style }) {
20
+ const { messages, direction, locale, density } = useHIG();
21
+ const themeStyle = useThemeStyle();
22
+ const [current, set] = useControllable(open, defaultOpen, onOpenChange, null);
23
+ const timer = useRef(undefined), hovered = useRef(false), pinned = useRef(false);
24
+ useEffect(() => () => clearTimeout(timer.current), []);
25
+ // Hover handlers only for a mouse: a touch's pointerenter comes just before its click, which toggles. A hover opens without moving focus into the popover.
26
+ const hover = openOnHover ? {
27
+ onPointerEnter: (event) => { if (event.pointerType !== 'mouse')
28
+ return; clearTimeout(timer.current); if (!current) {
29
+ hovered.current = true;
30
+ set(true);
31
+ } },
32
+ onPointerLeave: (event) => { if (event.pointerType !== 'mouse' || pinned.current)
33
+ return; clearTimeout(timer.current); timer.current = setTimeout(() => set(false), hoverCloseDelay); },
34
+ } : undefined;
35
+ // A click on the trigger of a hover-opened popover pins it open instead of toggling it shut: the pointer always hovers before it clicks.
36
+ const pin = openOnHover ? { onClick: (event) => { if (!hovered.current)
37
+ return; event.preventDefault(); clearTimeout(timer.current); hovered.current = false; pinned.current = true; } } : undefined;
38
+ return _jsxs(Pop.Root, { open: current, onOpenChange: next => { clearTimeout(timer.current); if (!next) {
39
+ hovered.current = false;
40
+ pinned.current = false;
41
+ } set(next); }, children: [_jsx(Pop.Trigger, { asChild: true, ...hover, ...pin, children: trigger ?? _jsx(Button, { intent: 'secondary', suppressFeedback: true, children: label }) }), _jsx(Pop.Portal, { children: _jsxs(Pop.Content, { ...hover, className: `hig-popover${className ? ` ${className}` : ''}`, "data-tone": tone, sideOffset: 6, collisionPadding: 16, style: style ? { ...themeStyle, ...style } : themeStyle, dir: direction, lang: locale, "data-hig-density": density, "aria-label": trigger ? label : undefined, "data-testid": testID, onOpenAutoFocus: event => { if (hovered.current)
42
+ event.preventDefault(); }, children: [children, hideClose ? null : _jsx(Pop.Close, { asChild: true, children: _jsx(Button, { intent: 'ghost', suppressFeedback: true, children: closeLabel ?? messages.close ?? en.close }) })] }) })] });
43
+ }
18
44
  export function Tooltip({ content, children }) { const { direction, locale, density } = useHIG(); const themeStyle = useThemeStyle(); return _jsx(Tip.Provider, { children: _jsxs(Tip.Root, { children: [_jsx(Tip.Trigger, { asChild: true, children: children }), _jsx(Tip.Portal, { children: _jsx(Tip.Content, { className: 'hig-popover hig-tooltip', sideOffset: 6, collisionPadding: 16, style: themeStyle, dir: direction, lang: locale, "data-hig-density": density, children: content }) })] }) }); }
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ /** One quick choice. `testID` becomes the chip's `data-testid`. */
3
+ export interface PresetOption<T extends string | number = string> {
4
+ value: T;
5
+ label: string;
6
+ disabled?: boolean;
7
+ testID?: string;
8
+ }
9
+ export interface PresetGroupProps<T extends string | number = string> {
10
+ /** Accessible name of the group; not drawn, so a heading or row above it names it on screen. */
11
+ label?: string;
12
+ options: readonly PresetOption<T>[];
13
+ /** The selected choice; `null` selects none. Omit it, with `defaultValue`, to let the group keep its own selection. */
14
+ value?: T | null;
15
+ defaultValue?: T | null;
16
+ /** Called with the choice taken. A press on the selected chip, or on a dimmed one, does nothing. */
17
+ onValueChange?: (value: T) => void;
18
+ /** Chips per row. Defaults to every option in one row; with fewer columns the chips wrap onto equal-width rows. */
19
+ columns?: number;
20
+ /** Fill of the selected chip. Defaults to `primary`; TargetBlock passes `destructive` for a stop loss. */
21
+ selectedIntent?: 'primary' | 'destructive' | 'up' | 'down';
22
+ disabled?: boolean;
23
+ /** Keeps the provider's `selection` feedback off this group, for a host that plays its own cue. By default a new choice plays it like a SegmentedControl. */
24
+ suppressFeedback?: boolean;
25
+ className?: string;
26
+ /** The group's `data-testid`. */
27
+ testID?: string;
28
+ }
29
+ /** A set of quick choices as chips in an equal-width grid, such as order sizes or leverage steps. Single choice, or none; each chip is a toggle button that reads pressed when selected, at least 44px tall, in the interface face. TargetBlock draws its presets with it. */
30
+ export declare function PresetGroup<T extends string | number = string>({ label, options, value, defaultValue, onValueChange, columns, selectedIntent, disabled, suppressFeedback, className, testID }: PresetGroupProps<T>): React.JSX.Element;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { assertUniqueKeys } from '@bloxwap/hig/contracts';
4
+ import { useControllable } from './provider.js';
5
+ import { Button } from './button.js';
6
+ /** A set of quick choices as chips in an equal-width grid, such as order sizes or leverage steps. Single choice, or none; each chip is a toggle button that reads pressed when selected, at least 44px tall, in the interface face. TargetBlock draws its presets with it. */
7
+ export function PresetGroup({ label, options, value, defaultValue = null, onValueChange, columns, selectedIntent = 'primary', disabled, suppressFeedback, className, testID }) {
8
+ assertUniqueKeys(options, option => option.value, 'Choices');
9
+ const [current, set] = useControllable(value, defaultValue, onValueChange, suppressFeedback ? null : 'selection');
10
+ const count = Math.max(1, Math.floor(columns ?? options.length) || 1);
11
+ return _jsx("div", { role: 'group', "aria-label": label, "aria-disabled": disabled || undefined, className: `hig-preset-group${className ? ` ${className}` : ''}`, "data-testid": testID, style: { '--hig-preset-columns': count }, children: options.map(option => { const selected = current !== null && Object.is(current, option.value), blocked = !!disabled || !!option.disabled; return _jsx(Button, { "data-testid": option.testID, fullWidth: true, intent: selected ? selectedIntent : 'secondary', "aria-pressed": selected, disabled: blocked, suppressFeedback: true, onClick: () => { if (!blocked && !selected)
12
+ set(option.value); }, children: option.label }, String(option.value)); }) });
13
+ }
@@ -58,5 +58,5 @@ export declare function useThemeStyle(): React.CSSProperties | undefined;
58
58
  export declare function useColors(): Readonly<Record<keyof typeof nativeSrgb, string>>;
59
59
  /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
60
60
  export declare function useMessages(): HIGMessages;
61
- /** Controlled values never silently switch to internal state. */
62
- export declare function useControllable<T>(value: T | undefined, initial: T, onChange?: (value: T) => void, intent?: FeedbackIntent): [T, (next: T) => void];
61
+ /** Controlled values never silently switch to internal state. `intent: null` commits without provider feedback. */
62
+ export declare function useControllable<T>(value: T | undefined, initial: T, onChange?: (value: T) => void, intent?: FeedbackIntent | null): [T, (next: T) => void];
@@ -6,8 +6,13 @@ import { defaultMessages, resolveMessages } from '@bloxwap/hig/contracts/message
6
6
  import { nativeSrgb, resolvePrimaryColor } from '@bloxwap/hig/tokens';
7
7
  const Context = createContext({ ...defaultEnvironment, messages: {} });
8
8
  const marketColor = (value) => typeof value === 'string' && value !== '' ? value : undefined;
9
- export function HIGProvider({ children, density = 'comfortable', locale = 'en-US', direction = 'ltr', reducedMotion, onAccepted, feedback, primaryColor, messages, pressDecoration, numberFormat, marketColors }) {
9
+ export function HIGProvider({ children, density, locale, direction, reducedMotion, onAccepted, feedback, primaryColor, messages, pressDecoration, numberFormat, marketColors }) {
10
10
  const parent = useContext(Context);
11
+ density ??= parent.density;
12
+ locale ??= parent.locale;
13
+ direction ??= parent.direction;
14
+ onAccepted ??= parent.onAccepted;
15
+ feedback ??= parent.feedback;
11
16
  const inherited = parent.messages;
12
17
  const resolved = useMemo(() => resolveMessages(inherited, messages), [inherited, messages]);
13
18
  const market = marketColors ?? parent.marketColors;
@@ -20,7 +25,11 @@ export function HIGProvider({ children, density = 'comfortable', locale = 'en-US
20
25
  const [osReduced, setOSReduced] = useState(false);
21
26
  useEffect(() => { const query = window.matchMedia?.('(prefers-reduced-motion: reduce)'); if (!query)
22
27
  return; const update = () => setOSReduced(query.matches); update(); query.addEventListener('change', update); return () => query.removeEventListener('change', update); }, []);
23
- return _jsx(Context.Provider, { value: { density, locale, direction, reducedMotion: reducedMotion ?? osReduced, onAccepted, feedback, primaryColor: accent, messages: resolved, pressDecoration: decorate, numberFormat: numberFormat ?? parent.numberFormat, marketColors: inheritedMarket, drawPress }, children: _jsx("div", { style: theme, "data-hig-density": density, "data-hig-motion": reducedMotion ?? osReduced ? 'reduced' : 'full', dir: direction, lang: locale, children: children }) });
28
+ const reduced = reducedMotion ?? (parent.provided ? parent.reducedMotion : osReduced), format = numberFormat ?? parent.numberFormat;
29
+ // One context value for as long as nothing in it changes. A provider that renders again (a host state change above it) then
30
+ // re-renders no component that reads the context: measured over 500 generated avatars, 25,000 face renders per 50 provider renders became none.
31
+ const value = useMemo(() => ({ provided: true, density, locale, direction, reducedMotion: reduced, onAccepted, feedback, primaryColor: accent, messages: resolved, pressDecoration: decorate, numberFormat: format, marketColors: inheritedMarket, drawPress }), [density, locale, direction, reduced, onAccepted, feedback, accent, resolved, decorate, format, inheritedMarket, drawPress]);
32
+ return _jsx(Context.Provider, { value: value, children: _jsx("div", { style: theme, "data-hig-density": density, "data-hig-motion": reduced ? 'reduced' : 'full', dir: direction, lang: locale, children: children }) });
24
33
  }
25
34
  export const useHIG = () => useContext(Context);
26
35
  /** Number options with the nearest provider's `numberFormat` merged under them; only currency formats change. */
@@ -86,22 +95,30 @@ export function useThemeStyle() { const { primaryColor, marketColors } = useHIG(
86
95
  export function useColors() { const { primaryColor } = useHIG(); return useMemo(() => primaryColor === undefined ? nativeSrgb : { ...nativeSrgb, ...resolvePrimaryColor(primaryColor) }, [primaryColor]); }
87
96
  /** Complete built-in copy for the nearest HIGProvider: host translations over the English defaults. */
88
97
  export function useMessages() { const overrides = useContext(Context).messages; return useMemo(() => resolveMessages({ ...defaultMessages }, overrides), [overrides]); }
89
- /** Controlled values never silently switch to internal state. */
98
+ /** Controlled values never silently switch to internal state. `intent: null` commits without provider feedback. */
90
99
  export function useControllable(value, initial, onChange, intent = 'selection') {
91
100
  const [internal, setInternal] = useState(initial);
92
- const current = value === undefined ? internal : value;
101
+ const controlled = useRef(value !== undefined).current, last = useRef(initial), warned = useRef(false);
102
+ if (controlled && value !== undefined)
103
+ last.current = value;
104
+ const current = controlled ? last.current : internal;
105
+ useEffect(() => { if ((value !== undefined) !== controlled && !warned.current) {
106
+ warned.current = true;
107
+ if (process.env.NODE_ENV !== 'production')
108
+ console.warn('HIG controlled state cannot change ownership after mount. Remount to reset it.');
109
+ } }, [controlled, value]);
93
110
  const { feedback } = useHIG();
94
111
  const id = useId();
95
112
  const sequence = useRef(0);
96
113
  const pending = useRef(null);
97
114
  useEffect(() => { const request = pending.current; if (!request)
98
- return; pending.current = null; if (Object.is(current, request.value)) {
115
+ return; pending.current = null; if (intent && Object.is(current, request.value)) {
99
116
  try {
100
117
  feedback?.emit({ id: `${id}/${++sequence.current}`, source: id, intent, origin: 'programmatic' });
101
118
  }
102
119
  catch { /* Effects remain optional. */ }
103
120
  } });
104
121
  return [current, (next) => { if (Object.is(current, next))
105
- return; pending.current = { value: next }; if (value === undefined)
122
+ return; pending.current = { value: next }; if (!controlled)
106
123
  setInternal(next); onChange?.(next); }];
107
124
  }
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { type QRErrorCorrection } from '@bloxwap/hig/contracts/qr';
3
+ export type { QRErrorCorrection } from '@bloxwap/hig/contracts/qr';
4
+ export interface QRCodeProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children' | 'color'> {
5
+ /** The text to encode: an address, a payment URI, a link. Digits pack tightest, then upper-case alphanumerics, then UTF-8. A value too long for a QR code draws an empty square. */
6
+ value: string;
7
+ /** Edge of the square in CSS pixels, quiet zone included; default 196. It sets `--hig-qr-code-size`, the element's width, so host CSS may resize the element: the drawing and the arena's box scale with it. */
8
+ size?: number;
9
+ /** Drawn over the centre, which is cleared of modules: an image URL, or a node such as a token mark laid out in the arena's box. */
10
+ arena?: React.ReactNode;
11
+ /** Error correction level. Defaults to `high` with an arena, which covers part of the code, and `medium` without. With an arena, `low` and `medium` are raised to `quartile` so the code still reads. */
12
+ errorCorrection?: QRErrorCorrection;
13
+ /** Colour of the modules. Defaults to the text role, `var(--hig-text)`. */
14
+ color?: string;
15
+ /** Colour of the tile behind the code. Defaults to the background role, `var(--hig-background)`; `'none'` draws no tile, for a code that sits on the host's own surface. */
16
+ background?: string;
17
+ /** Clear modules kept on every side, inside `size`; default 4, the margin scanners expect. Pass 0 only where the host keeps that margin itself. */
18
+ quietZone?: number;
19
+ /** Accessible name. Defaults to the built-in “QR code”. */
20
+ label?: string;
21
+ /** Hides the code from assistive technology, for a host that names it on an element of its own. */
22
+ decorative?: boolean;
23
+ }
24
+ /**
25
+ * A QR code in the Cuer style: round modules, rounded finder patterns and an optional arena in the centre. HIG encodes the
26
+ * value itself, so no package is needed, and the whole code is one path in one inline SVG. The value is encoded once per
27
+ * `value`, `errorCorrection` and arena; `size`, the colours and the quiet zone only change attributes.
28
+ *
29
+ * The arena is an HTML box over the SVG, not a `foreignObject` inside it: WebKit paints positioned, transformed or
30
+ * translucent content of a `foreignObject` at the SVG's corner, where it would cover a finder pattern.
31
+ */
32
+ export declare function QRCode({ value, size, arena, errorCorrection, color, background, quietZone, label, decorative, className, style, ...rest }: QRCodeProps): React.JSX.Element;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useMemo } from 'react';
4
+ import * as en from '@bloxwap/hig/contracts/messages';
5
+ import { QR_QUIET_ZONE, qrCodeGeometry, qrFrame } from '@bloxwap/hig/contracts/qr';
6
+ import { useHIG } from './provider.js';
7
+ const drawn = (node) => node != null && node !== false && node !== true && node !== '';
8
+ const percent = (fraction) => `${Math.round(fraction * 1e6) / 1e4}%`;
9
+ /**
10
+ * A QR code in the Cuer style: round modules, rounded finder patterns and an optional arena in the centre. HIG encodes the
11
+ * value itself, so no package is needed, and the whole code is one path in one inline SVG. The value is encoded once per
12
+ * `value`, `errorCorrection` and arena; `size`, the colours and the quiet zone only change attributes.
13
+ *
14
+ * The arena is an HTML box over the SVG, not a `foreignObject` inside it: WebKit paints positioned, transformed or
15
+ * translucent content of a `foreignObject` at the SVG's corner, where it would cover a finder pattern.
16
+ */
17
+ export function QRCode({ value, size = 196, arena, errorCorrection, color, background, quietZone = QR_QUIET_ZONE, label, decorative = false, className, style, ...rest }) {
18
+ const { messages } = useHIG();
19
+ const withArena = drawn(arena);
20
+ const geometry = useMemo(() => qrCodeGeometry(value, { errorCorrection, arena: withArena }), [value, errorCorrection, withArena]);
21
+ const frame = useMemo(() => geometry ? qrFrame(geometry, size, quietZone) : null, [geometry, size, quietZone]);
22
+ const tile = background === 'none' || background === 'transparent' ? null : background ?? 'var(--hig-background,transparent)';
23
+ const named = !decorative && geometry !== null;
24
+ const box = frame?.arena;
25
+ // Percentages of the square, so the box stays over the cleared modules when host CSS resizes the code. Physical `left`: a right-to-left page does not mirror a QR code.
26
+ const boxStyle = box ? { left: percent(box.inset), top: percent(box.inset), width: percent(box.extent), height: percent(box.extent), borderRadius: percent(box.radius / box.size) } : undefined;
27
+ return _jsxs("span", { ...rest, className: `hig-qr-code${className ? ` ${className}` : ''}`, style: { '--hig-qr-code-size': `${size}px`, ...style }, role: named ? 'img' : undefined, "aria-label": named ? label ?? messages.qrCode ?? en.qrCode : undefined, "aria-hidden": named ? undefined : true, "data-empty": geometry ? undefined : '', children: [_jsxs("svg", { "aria-hidden": 'true', focusable: 'false', width: size, height: size, viewBox: frame?.viewBox, children: [tile && frame && _jsx("rect", { x: -frame.quietZone, y: -frame.quietZone, width: frame.span, height: frame.span, rx: frame.tileRadius, style: { fill: tile } }), geometry && _jsx("path", { d: geometry.path, style: { fill: color ?? 'var(--hig-text,currentColor)' } })] }), box && _jsx("span", { className: 'hig-qr-code-arena', style: boxStyle, children: typeof arena === 'string' ? _jsx("img", { className: 'hig-qr-code-image', src: arena, alt: '', draggable: false }) : arena })] });
28
+ }
@@ -1,9 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Check } from '@bloxwap/icons/react/check';
4
+ import { ChevronDown } from '@bloxwap/icons/react/chevron-down';
5
+ import { assertUniqueKeys } from '@bloxwap/hig/contracts';
3
6
  import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
4
7
  import { useControllable, useHIG } from './provider.js';
5
8
  /** A select-only combobox. DOM focus stays on the trigger while its active option is announced. */
6
9
  export function Select({ label, options, value, defaultValue, disabled, onValueChange }) {
10
+ assertUniqueKeys(options, option => option.value, 'Select');
11
+ const controlled = useRef(value !== undefined).current;
7
12
  const id = useId();
8
13
  const { direction, locale } = useHIG();
9
14
  const [current, setCurrent] = useControllable(value, defaultValue ?? options.find(option => !option.disabled)?.value ?? '', onValueChange);
@@ -13,7 +18,9 @@ export function Select({ label, options, value, defaultValue, disabled, onValueC
13
18
  const list = useRef(null);
14
19
  const search = useRef({ text: '', time: 0 });
15
20
  const match = options.findIndex(option => option.value === current);
16
- const selected = match >= 0 ? match : options.findIndex(option => !option.disabled);
21
+ const selected = match >= 0 && !options[match].disabled ? match : controlled ? -1 : options.findIndex(option => !option.disabled);
22
+ useEffect(() => { if (!controlled && selected >= 0 && current !== options[selected].value)
23
+ setCurrent(options[selected].value); }, [controlled, current, selected, options]);
17
24
  const expanded = open && !disabled && options.length > 0;
18
25
  const activeOption = active >= 0 && !options[active]?.disabled ? options[active] : undefined;
19
26
  const optionId = (index) => `${id}-option-${index}`;
@@ -169,6 +176,6 @@ export function Select({ label, options, value, defaultValue, disabled, onValueC
169
176
  else if (option.offsetTop + option.offsetHeight > popup.scrollTop + popup.clientHeight)
170
177
  popup.scrollTop = option.offsetTop + option.offsetHeight - popup.clientHeight;
171
178
  }, [expanded, active, activeOption, id]);
172
- return _jsxs("div", { className: 'hig-field', children: [_jsx("label", { id: `${id}-label`, htmlFor: id, children: label }), _jsxs("div", { className: 'hig-select', children: [_jsxs("button", { ref: trigger, id: id, type: 'button', role: 'combobox', className: 'hig-input hig-select-trigger', disabled: disabled, "aria-labelledby": `${id}-label`, "aria-haspopup": 'listbox', "aria-expanded": expanded, "aria-controls": expanded ? `${id}-list` : undefined, "aria-activedescendant": expanded && activeOption ? optionId(active) : undefined, onClick: () => expanded ? setOpen(false) : show(), onKeyDown: onKeyDown, onBlur: () => setOpen(false), children: [_jsx("span", { className: 'hig-select-value', children: options[selected]?.label ?? '' }), _jsx("svg", { className: 'hig-select-chevron', "aria-hidden": 'true', viewBox: '0 0 20 20', children: _jsx("path", { d: 'm5 7.5 5 5 5-5' }) })] }), expanded && _jsx("div", { ref: list, id: `${id}-list`, className: 'hig-select-list', role: 'listbox', "aria-labelledby": `${id}-label`, popover: 'manual', onPointerDown: event => event.preventDefault(), children: options.map((option, index) => _jsxs("div", { id: optionId(index), role: 'option', className: 'hig-select-option', "aria-selected": index === selected, "aria-disabled": option.disabled || undefined, "data-active": index === active || undefined, onPointerMove: () => { if (!option.disabled)
173
- setActive(index); }, onClick: () => choose(index), children: [_jsx("span", { children: option.label }), _jsx("svg", { className: 'hig-select-check', "aria-hidden": 'true', viewBox: '0 0 20 20', children: _jsx("path", { d: 'm4 10 4 4 8-8' }) })] }, option.value)) })] })] });
179
+ return _jsxs("div", { className: 'hig-field', children: [_jsx("label", { id: `${id}-label`, htmlFor: id, children: label }), _jsxs("div", { className: 'hig-select', children: [_jsxs("button", { ref: trigger, id: id, type: 'button', role: 'combobox', className: 'hig-input hig-select-trigger', disabled: disabled, "aria-labelledby": `${id}-label`, "aria-haspopup": 'listbox', "aria-expanded": expanded, "aria-controls": expanded ? `${id}-list` : undefined, "aria-activedescendant": expanded && activeOption ? optionId(active) : undefined, onClick: () => expanded ? setOpen(false) : show(), onKeyDown: onKeyDown, onBlur: () => setOpen(false), children: [_jsx("span", { className: 'hig-select-value', children: options[selected]?.label ?? '' }), _jsx(ChevronDown, { size: 20, className: 'hig-select-chevron' })] }), expanded && _jsx("div", { ref: list, id: `${id}-list`, className: 'hig-select-list', role: 'listbox', "aria-labelledby": `${id}-label`, popover: 'manual', onPointerDown: event => event.preventDefault(), children: options.map((option, index) => _jsxs("div", { id: optionId(index), role: 'option', className: 'hig-select-option', "aria-selected": index === selected, "aria-disabled": option.disabled || undefined, "data-active": index === active || undefined, onPointerMove: () => { if (!option.disabled)
180
+ setActive(index); }, onClick: () => choose(index), children: [_jsx("span", { children: option.label }), _jsx(Check, { size: 20, className: 'hig-select-check' })] }, option.value)) })] })] });
174
181
  }
@@ -24,11 +24,17 @@ export interface ChoicesProps {
24
24
  disabled?: boolean;
25
25
  onValueChange?: (value: string) => void;
26
26
  }
27
- export interface SegmentedControlProps extends ChoicesProps {
28
- hideLabel?: boolean;
27
+ /** One segment. `testID` becomes the `data-testid` of the segment's radio, in place of `<group testID>-<value>`. */
28
+ export interface SegmentedControlOption extends Choice {
29
+ testID?: string;
30
+ }
31
+ export interface SegmentedControlProps extends Omit<ChoicesProps, 'options'> {
32
+ options: readonly SegmentedControlOption[]; /** Keeps `label` as the group's accessible name but does not draw it, for a control whose heading or row already names it. */
33
+ hideLabel?: boolean; /** The group's `data-testid`; each segment's radio then takes `<testID>-<value>` unless the option sets its own `testID`, as on native. Omitted, only options with a `testID` set one. */
34
+ testID?: string;
29
35
  }
30
36
  export declare function RadioGroup({ label, options, value, defaultValue, disabled, onValueChange }: ChoicesProps): React.JSX.Element;
31
- export declare function SegmentedControl({ label, options, value, defaultValue, disabled, hideLabel, onValueChange }: SegmentedControlProps): React.JSX.Element;
37
+ export declare function SegmentedControl({ label, options, value, defaultValue, disabled, hideLabel, testID, onValueChange }: SegmentedControlProps): React.JSX.Element;
32
38
  export interface FilterOption extends Choice {
33
39
  icon?: string;
34
40
  }
@@ -38,9 +44,11 @@ export interface FilterProps {
38
44
  value?: string;
39
45
  defaultValue?: string;
40
46
  disabled?: boolean;
41
- onValueChange?: (value: string) => void;
47
+ onValueChange?: (value: string) => void; /** Pixels the row scrolls out past its container on each side (`--hig-filter-bleed`), so the capsules are cut by the container's edge, while the first and last capsule rest this far in: pass the container's side padding. Default 0, or what an ancestor sets in `--hig-filter-bleed`. */
48
+ bleed?: number;
42
49
  }
43
50
  /** One row of filter capsules that scrolls sideways. Single choice with radio semantics; the chosen capsule inverts and a check draws into its circle. */
44
- export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange }: FilterProps): React.JSX.Element;
51
+ export declare function Filter({ label, options, value, defaultValue, disabled, onValueChange, bleed }: FilterProps): React.JSX.Element;
45
52
  export { Select } from './select.js';
46
53
  export { Slider } from './slider.js';
54
+ export { PresetGroup, type PresetGroupProps, type PresetOption } from './preset-group.js';
@@ -1,28 +1,33 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Check } from '@bloxwap/icons/react/check';
4
+ import { assertUniqueKeys } from '@bloxwap/hig/contracts';
3
5
  import { useId, useRef } from 'react';
4
6
  import { PressDecoration, useControllable } from './provider.js';
5
7
  export function Checkbox({ label, checked, defaultChecked = false, disabled, onCheckedChange }) { const [value, set] = useControllable(checked, defaultChecked, onCheckedChange); return _jsxs("label", { className: 'hig-choice', children: [_jsx("input", { type: 'checkbox', checked: value, disabled: disabled, onChange: e => set(e.target.checked) }), _jsx("span", { children: label })] }); }
6
8
  export function Switch({ label, checked, defaultChecked = false, disabled, hideLabel, onCheckedChange }) { const [value, set] = useControllable(checked, defaultChecked, onCheckedChange); const input = useRef(null); return _jsxs("label", { className: 'hig-choice hig-switch', children: [_jsx("input", { ref: input, role: 'switch', type: 'checkbox', checked: value, disabled: disabled, onChange: e => set(e.target.checked) }), _jsx("span", { className: hideLabel ? 'hig-sr-only' : undefined, children: label }), _jsx(PressDecoration, { kind: 'switch', disabled: !!disabled, input: input })] }); }
7
9
  /** One segment: a label around its radio, with the provider's press decoration aimed at that radio. */
8
- function Segment({ name, option, checked, blocked, onSelect }) {
10
+ function Segment({ name, option, checked, blocked, testID, onSelect }) {
9
11
  const input = useRef(null);
10
- return _jsxs("label", { className: 'hig-segment', children: [_jsx("input", { ref: input, type: 'radio', name: name, value: option.value, checked: checked, disabled: option.disabled, onChange: () => { if (!blocked)
12
+ return _jsxs("label", { className: 'hig-segment', children: [_jsx("input", { ref: input, type: 'radio', name: name, value: option.value, checked: checked, disabled: option.disabled, "data-testid": testID, onChange: () => { if (!blocked)
11
13
  onSelect(); } }), _jsx("span", { children: option.label }), _jsx(PressDecoration, { kind: 'segment', disabled: blocked, input: input })] });
12
14
  }
13
- export function RadioGroup({ label, options, value, defaultValue = '', disabled, onValueChange }) { const name = useId(); const [current, set] = useControllable(value, defaultValue, onValueChange); return _jsxs("fieldset", { className: 'hig-group', disabled: disabled, children: [_jsx("legend", { children: label }), options.map(o => _jsxs("label", { className: 'hig-choice', children: [_jsx("input", { type: 'radio', name: name, value: o.value, checked: current === o.value, disabled: o.disabled, onChange: () => set(o.value) }), _jsx("span", { children: o.label })] }, o.value))] }); }
14
- export function SegmentedControl({ label, options, value, defaultValue = '', disabled, hideLabel, onValueChange }) {
15
+ export function RadioGroup({ label, options, value, defaultValue = '', disabled, onValueChange }) { assertUniqueKeys(options, option => option.value, 'Choices'); const name = useId(); const [current, set] = useControllable(value, defaultValue, onValueChange); return _jsxs("fieldset", { className: 'hig-group', disabled: disabled, children: [_jsx("legend", { children: label }), options.map(o => _jsxs("label", { className: 'hig-choice', children: [_jsx("input", { type: 'radio', name: name, value: o.value, checked: current === o.value, disabled: o.disabled, onChange: () => set(o.value) }), _jsx("span", { children: o.label })] }, o.value))] }); }
16
+ export function SegmentedControl({ label, options, value, defaultValue = '', disabled, hideLabel, testID, onValueChange }) {
17
+ assertUniqueKeys(options, option => option.value, 'Choices');
15
18
  const name = useId();
16
19
  const [current, set] = useControllable(value, defaultValue, onValueChange);
17
20
  const selected = options.findIndex(option => option.value === current);
18
- return _jsxs("fieldset", { className: 'hig-group hig-segmented-control', disabled: disabled, children: [_jsx("legend", { className: hideLabel ? 'hig-sr-only' : undefined, children: label }), _jsxs("div", { className: 'hig-segments', style: { '--hig-segment-count': Math.max(1, options.length), '--hig-segment-index': selected }, children: [selected >= 0 && _jsx("span", { className: 'hig-segment-indicator', "aria-hidden": 'true', "data-disabled": disabled || options[selected].disabled || undefined }), options.map(o => _jsx(Segment, { name: name, option: o, checked: current === o.value, blocked: !!disabled || !!o.disabled, onSelect: () => set(o.value) }, o.value))] })] });
21
+ return _jsxs("fieldset", { className: 'hig-group hig-segmented-control', disabled: disabled, "data-testid": testID, children: [_jsx("legend", { className: hideLabel ? 'hig-sr-only' : undefined, children: label }), _jsxs("div", { className: 'hig-segments', style: { '--hig-segment-count': Math.max(1, options.length), '--hig-segment-index': selected }, children: [selected >= 0 && _jsx("span", { className: 'hig-segment-indicator', "aria-hidden": 'true', "data-disabled": disabled || options[selected].disabled || undefined }), options.map(o => _jsx(Segment, { name: name, option: o, checked: current === o.value, blocked: !!disabled || !!o.disabled, testID: o.testID ?? (testID === undefined ? undefined : `${testID}-${o.value}`), onSelect: () => set(o.value) }, o.value))] })] });
19
22
  }
20
23
  /** One row of filter capsules that scrolls sideways. Single choice with radio semantics; the chosen capsule inverts and a check draws into its circle. */
21
- export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange }) {
24
+ export function Filter({ label, options, value, defaultValue = '', disabled, onValueChange, bleed }) {
25
+ assertUniqueKeys(options, option => option.value, 'Choices');
22
26
  const name = useId();
23
27
  const [current, set] = useControllable(value, defaultValue, onValueChange);
24
- return _jsx("div", { className: 'hig-filter', role: 'radiogroup', "aria-label": label, "aria-disabled": disabled || undefined, children: options.map(o => _jsxs("label", { className: 'hig-filter-chip', children: [_jsx("input", { type: 'radio', name: name, value: o.value, checked: current === o.value, disabled: disabled || o.disabled, onChange: () => { if (!disabled && !o.disabled)
25
- set(o.value); } }), _jsxs("span", { className: 'hig-filter-mark', "aria-hidden": 'true', children: [o.icon && _jsx("img", { src: o.icon, alt: '', loading: 'lazy' }), _jsx("svg", { viewBox: '0 0 16 16', focusable: 'false', children: _jsx("path", { pathLength: '1', d: 'm3.75 8.5 2.75 2.75 5.75-6.25' }) })] }), _jsx("span", { children: o.label })] }, o.value)) });
28
+ return _jsx("div", { className: 'hig-filter', role: 'radiogroup', "aria-label": label, "aria-disabled": disabled || undefined, style: bleed == null ? undefined : { '--hig-filter-bleed': `${bleed}px` }, children: options.map(o => _jsxs("label", { className: 'hig-filter-chip', children: [_jsx("input", { type: 'radio', name: name, value: o.value, checked: current === o.value, disabled: disabled || o.disabled, onChange: () => { if (!disabled && !o.disabled)
29
+ set(o.value); } }), _jsxs("span", { className: 'hig-filter-mark', "aria-hidden": 'true', children: [o.icon && _jsx("img", { src: o.icon, alt: '', loading: 'lazy' }), _jsx(Check, { size: 16 })] }), _jsx("span", { children: o.label })] }, o.value)) });
26
30
  }
27
31
  export { Select } from './select.js';
28
32
  export { Slider } from './slider.js';
33
+ export { PresetGroup } from './preset-group.js';
@@ -1,10 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { numericRange } from '@bloxwap/hig/contracts';
3
4
  import { useId } from 'react';
4
5
  import { useControllable } from './provider.js';
5
6
  export function Slider({ label, value, defaultValue = 0, min = 0, max = 100, step = 1, disabled, onValueChange }) {
6
7
  const id = useId();
7
- const [current, set] = useControllable(value, defaultValue, onValueChange);
8
+ const range = numericRange(min, max, step);
9
+ const [stored, commit] = useControllable(value, defaultValue, onValueChange);
10
+ const current = range.clamp(stored);
11
+ const set = (next) => commit(range.clamp(next));
8
12
  const fill = max > min ? Math.min(100, Math.max(0, (current - min) / (max - min) * 100)) : 0;
9
13
  return _jsxs("div", { className: 'hig-field hig-slider', children: [_jsxs("label", { htmlFor: id, children: [label, ": ", current] }), _jsx("input", { id: id, className: 'hig-range', style: { '--hig-range-fill': `${fill}%` }, type: 'range', min: min, max: max, step: step, disabled: disabled, value: current, onChange: e => set(e.target.valueAsNumber) })] });
10
14
  }
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  export type BadgeTone = 'neutral' | 'positive' | 'negative' | 'warning' | 'info';
3
3
  export interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
4
- tone?: BadgeTone;
4
+ tone?: BadgeTone; /** A 6px status dot in the label colour on the leading edge, hidden from assistive technology. */
5
+ dot?: boolean;
5
6
  }
6
7
  /** A quiet status label. The host owns announcements and may supply typography or an accessible name. */
7
8
  export declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
@@ -21,9 +22,10 @@ export interface Notice {
21
22
  severity: 'info' | 'success' | 'warning' | 'error';
22
23
  action?: React.ReactNode;
23
24
  }
24
- /** One notice as a single capsule row: severity symbol on the leading edge, message, optional action, close on the trailing edge. Shared by `Toast` and the Sonner-backed `toast()`; it announces nothing itself. */
25
- export declare function ToastNotice({ message, severity, action, dismissName, onDismiss }: {
26
- message: React.ReactNode;
25
+ /** One notice as a single capsule row: severity symbol on the leading edge, message with an optional description under it, optional action, close on the trailing edge. Shared by `Toast` and the Sonner-backed `toast()`; it announces nothing itself. */
26
+ export declare function ToastNotice({ message, description, severity, action, dismissName, onDismiss }: {
27
+ message: React.ReactNode; /** A second line under the message, in regular weight. With one the capsule keeps a fixed corner radius, not a full pill. */
28
+ description?: React.ReactNode;
27
29
  severity?: Notice['severity'];
28
30
  action?: React.ReactNode; /** Accessible name of the close button. */
29
31
  dismissName: string;
@@ -40,9 +42,13 @@ export declare function Progress({ label, value, max }: {
40
42
  value?: number;
41
43
  max?: number;
42
44
  }): React.JSX.Element;
43
- export declare function Spinner({ label }: {
45
+ export interface SpinnerProps {
46
+ /** What is loading; defaults to HIGProvider `messages.loading`. */
44
47
  label?: string;
45
- }): React.JSX.Element;
48
+ /** Draws the ring alone, for a tight spot such as a row or a button-sized slot: the label is not drawn but stays the status's accessible text. */
49
+ hideLabel?: boolean;
50
+ }
51
+ export declare function Spinner({ label, hideLabel }: SpinnerProps): React.JSX.Element;
46
52
  export declare function Skeleton({ label }: {
47
53
  label?: string;
48
54
  }): React.JSX.Element;
@@ -53,10 +59,8 @@ export declare function EmptyState({ title, description, action, illustration }:
53
59
  action?: React.ReactNode;
54
60
  illustration?: React.ReactNode;
55
61
  }): React.JSX.Element;
56
- export declare function Avatar({ name, src }: {
57
- name: string;
58
- src?: string;
59
- }): React.JSX.Element;
62
+ /** `Avatar` is its own entry, `@bloxwap/hig/react/avatar`; this entry keeps exporting it for the imports that predate that one. */
63
+ export { Avatar, type AvatarProps } from './avatar.js';
60
64
  export declare function StatusIndicator({ label, state }: {
61
65
  label: string;
62
66
  state: 'online' | 'offline' | 'stale';
@@ -1,17 +1,24 @@
1
1
  "use client";
2
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { CircleCheck } from '@bloxwap/icons/react/circle-check';
4
+ import { CircleX } from '@bloxwap/icons/react/circle-x';
5
+ import { Inbox } from '@bloxwap/icons/react/inbox';
6
+ import { Info } from '@bloxwap/icons/react/info';
7
+ import { TriangleAlert } from '@bloxwap/icons/react/triangle-alert';
8
+ import { X } from '@bloxwap/icons/react/x';
9
+ import { progressValue } from '@bloxwap/hig/contracts';
3
10
  import React, { useEffect, useRef, useState } from 'react';
4
11
  import { notificationDelta } from '@bloxwap/hig/contracts/announcements';
5
12
  import * as en from '@bloxwap/hig/contracts/messages';
6
13
  import { useHIG } from './provider.js';
7
14
  /** A quiet status label. The host owns announcements and may supply typography or an accessible name. */
8
- export const Badge = React.forwardRef(function Badge({ children, tone = 'neutral', className, ...props }, ref) { const accent = ['positive', 'negative', 'warning', 'info'].includes(tone) ? tone : undefined; return _jsx("span", { ...props, ref: ref, className: ['hig-badge', className].filter(Boolean).join(' '), "data-tone": accent, children: children }); });
15
+ export const Badge = React.forwardRef(function Badge({ children, tone = 'neutral', dot, className, ...props }, ref) { const accent = ['positive', 'negative', 'warning', 'info'].includes(tone) ? tone : undefined; return _jsxs("span", { ...props, ref: ref, className: ['hig-badge', className].filter(Boolean).join(' '), "data-tone": accent, children: [dot && _jsx("span", { className: 'hig-badge-dot', "aria-hidden": 'true' }), children] }); });
9
16
  /** Severity tints the fill 10% and colours the title from a token role (info/note → info, success/tip → positive, warning → warning, error → negative; default → 6% of text), with no stroke or glow. The title may be any inline node, such as text with a code span. */
10
17
  export function Alert({ title, children, severity = 'info', action, announce = true }) { return _jsxs("section", { className: 'hig-surface hig-alert', "data-severity": severity, role: announce ? (severity === 'error' ? 'alert' : 'status') : undefined, children: [_jsx("strong", { children: title }), children, action != null && _jsx("div", { className: 'hig-alert-actions', children: action })] }); }
11
18
  export const Callout = Alert;
12
- const noticeSymbol = { info: _jsxs(_Fragment, { children: [_jsx("circle", { cx: '10', cy: '10', r: '7.25' }), _jsx("path", { d: 'M10 9.25v4.25M10 6.5v.01' })] }), success: _jsxs(_Fragment, { children: [_jsx("circle", { cx: '10', cy: '10', r: '7.25' }), _jsx("path", { d: 'm6.75 10.25 2.25 2.25 4.25-4.5' })] }), warning: _jsxs(_Fragment, { children: [_jsx("path", { d: 'M10 3.5 17.25 16H2.75Z' }), _jsx("path", { d: 'M10 8.5v3.25M10 14v.01' })] }), error: _jsxs(_Fragment, { children: [_jsx("circle", { cx: '10', cy: '10', r: '7.25' }), _jsx("path", { d: 'm7.5 7.5 5 5m0-5-5 5' })] }) };
13
- /** One notice as a single capsule row: severity symbol on the leading edge, message, optional action, close on the trailing edge. Shared by `Toast` and the Sonner-backed `toast()`; it announces nothing itself. */
14
- export function ToastNotice({ message, severity = 'info', action, dismissName, onDismiss }) { return _jsxs("div", { className: 'hig-toast-item', "data-severity": severity, children: [_jsx("svg", { className: 'hig-toast-icon', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', children: noticeSymbol[severity] ?? noticeSymbol.info }), _jsx("span", { className: 'hig-toast-message', children: message }), action, _jsx("button", { type: 'button', className: 'hig-toast-close', "aria-label": dismissName, onClick: onDismiss, children: _jsx("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', children: _jsx("path", { d: 'm5.5 5.5 9 9m0-9-9 9' }) }) })] }); }
19
+ const noticeSymbol = { info: Info, success: CircleCheck, warning: TriangleAlert, error: CircleX };
20
+ /** One notice as a single capsule row: severity symbol on the leading edge, message with an optional description under it, optional action, close on the trailing edge. Shared by `Toast` and the Sonner-backed `toast()`; it announces nothing itself. */
21
+ export function ToastNotice({ message, description, severity = 'info', action, dismissName, onDismiss }) { const Symbol = noticeSymbol[severity] ?? Info; const described = description != null && description !== false && description !== ''; return _jsxs("div", { className: 'hig-toast-item', "data-severity": severity, "data-described": described ? '' : undefined, children: [_jsx(Symbol, { size: 20, className: 'hig-toast-icon' }), _jsxs("span", { className: 'hig-toast-message', children: [message, described && _jsx("span", { className: 'hig-toast-description', children: description })] }), action, _jsx("button", { type: 'button', className: 'hig-toast-close', "aria-label": dismissName, onClick: onDismiss, children: _jsx(X, { size: 20 }) })] }); }
15
22
  /** Persistent until dismissed; host deduplicates ids, critical messages remain inline. */
16
23
  export function Toast({ notices, onDismiss, dismissLabel }) {
17
24
  const { messages } = useHIG();
@@ -37,11 +44,12 @@ export function Toast({ notices, onDismiss, dismissLabel }) {
37
44
  clearTimeout(timer.current); }, []);
38
45
  return _jsxs("aside", { className: 'hig-toast', "aria-label": messages.notifications ?? en.notifications, children: [unique.map(n => _jsx(ToastNotice, { message: n.message, severity: n.severity, action: n.action, dismissName: (messages.dismissNotice ?? en.dismissNotice)(n.message, dismiss), onDismiss: () => onDismiss(n.id) }, n.id)), _jsx("span", { className: 'hig-sr-only', role: announcement.severity === 'error' ? 'alert' : 'status', "aria-atomic": 'true', children: announcement.message })] });
39
46
  }
40
- export function Progress({ label, value, max = 100 }) { return _jsxs("label", { className: 'hig-progress', children: [label, _jsx("progress", { "aria-label": label, value: value, max: max })] }); }
41
- export function Spinner({ label }) { const { messages } = useHIG(); return _jsxs("span", { className: 'hig-spinner', role: 'status', children: [_jsx("span", { className: 'hig-spinner-indicator', "aria-hidden": 'true' }), label ?? messages.loading ?? en.loading, "\u2026"] }); }
47
+ export function Progress({ label, value, max = 100 }) { ({ value, max } = progressValue(value, max)); return _jsxs("label", { className: 'hig-progress', children: [label, _jsx("progress", { "aria-label": label, value: value, max: max })] }); }
48
+ export function Spinner({ label, hideLabel }) { const { messages } = useHIG(); const text = `${label ?? messages.loading ?? en.loading}…`; return _jsxs("span", { className: 'hig-spinner', role: 'status', children: [_jsx("span", { className: 'hig-spinner-indicator', "aria-hidden": 'true' }), hideLabel ? _jsx("span", { className: 'hig-sr-only', children: text }) : text] }); }
42
49
  export function Skeleton({ label }) { const { messages } = useHIG(); return _jsx("div", { className: 'hig-skeleton', "aria-label": label ?? messages.loadingContent ?? en.loadingContent, role: 'status' }); }
43
- const emptySymbol = _jsxs("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 32 32', children: [_jsx("path", { d: 'M5 18.5 8.6 8.9A2 2 0 0 1 10.5 7.5h11a2 2 0 0 1 1.9 1.4L27 18.5v4a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2Z' }), _jsx("path", { d: 'M5 18.5h6.5a4.5 4.5 0 0 0 9 0H27' })] });
50
+ const emptySymbol = _jsx(Inbox, { size: 48 });
44
51
  /** Centred stack: symbol, title, optional description, optional action. Decorative `illustration` replaces the default symbol (same prop as native); `null` omits it. */
45
52
  export function EmptyState({ title, description, action, illustration }) { return _jsxs("section", { className: 'hig-surface hig-empty-state', children: [illustration !== null && _jsx("span", { className: 'hig-empty-state-icon', "aria-hidden": 'true', children: illustration ?? emptySymbol }), _jsx("h3", { children: title }), description && _jsx("p", { children: description }), action] }); }
46
- export function Avatar({ name, src }) { return src ? _jsx("img", { className: 'hig-avatar', alt: name, src: src }) : _jsx("span", { className: 'hig-avatar', role: 'img', "aria-label": name, children: name.slice(0, 2) }); }
53
+ /** `Avatar` is its own entry, `@bloxwap/hig/react/avatar`; this entry keeps exporting it for the imports that predate that one. */
54
+ export { Avatar } from './avatar.js';
47
55
  export function StatusIndicator({ label, state }) { const { messages } = useHIG(); const text = { online: messages.statusOnline ?? en.statusOnline, offline: messages.statusOffline ?? en.statusOffline, stale: messages.statusStale ?? en.statusStale }[state] ?? state; return _jsxs("span", { className: 'hig-status-indicator', "data-state": state, children: [label, ": ", text] }); }