@bloxwap/hig 0.6.0 → 0.7.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 (167) hide show
  1. package/chart/README.md +1 -1
  2. package/contracts/README.md +1 -1
  3. package/contracts/dist/index.d.ts +16 -0
  4. package/contracts/dist/index.js +22 -0
  5. package/contracts/dist/messages.d.ts +6 -0
  6. package/contracts/dist/messages.js +3 -1
  7. package/feedback/README.md +1 -1
  8. package/native/README.md +1 -1
  9. package/native/dist/account-block.d.ts +53 -7
  10. package/native/dist/account-block.js +42 -9
  11. package/native/dist/animated-number-model.d.ts +7 -1
  12. package/native/dist/animated-number-model.js +50 -1
  13. package/native/dist/animated-number.d.ts +3 -1
  14. package/native/dist/animated-number.js +8 -5
  15. package/native/dist/asset-balance-row.d.ts +17 -1
  16. package/native/dist/asset-balance-row.js +13 -8
  17. package/native/dist/bar-mark.d.ts +14 -2
  18. package/native/dist/bar-mark.js +19 -5
  19. package/native/dist/bar-pnl.js +5 -4
  20. package/native/dist/blocks.d.ts +8 -14
  21. package/native/dist/blocks.js +5 -6
  22. package/native/dist/button.js +3 -1
  23. package/native/dist/data.d.ts +1 -1
  24. package/native/dist/data.js +6 -4
  25. package/native/dist/field.d.ts +14 -4
  26. package/native/dist/field.js +33 -7
  27. package/native/dist/figure.d.ts +23 -0
  28. package/native/dist/figure.js +10 -0
  29. package/native/dist/language-block.d.ts +5 -1
  30. package/native/dist/language-block.js +3 -3
  31. package/native/dist/list-group.d.ts +42 -8
  32. package/native/dist/list-group.js +71 -13
  33. package/native/dist/manage-position-block.d.ts +28 -2
  34. package/native/dist/manage-position-block.js +36 -11
  35. package/native/dist/market-row.d.ts +46 -0
  36. package/native/dist/market-row.js +30 -0
  37. package/native/dist/notifications-block.d.ts +30 -2
  38. package/native/dist/notifications-block.js +16 -8
  39. package/native/dist/pickers.d.ts +24 -2
  40. package/native/dist/pickers.js +16 -8
  41. package/native/dist/position-block.d.ts +66 -10
  42. package/native/dist/position-block.js +45 -11
  43. package/native/dist/profile-block.d.ts +29 -5
  44. package/native/dist/profile-block.js +25 -5
  45. package/native/dist/provider.d.ts +9 -3
  46. package/native/dist/provider.js +7 -3
  47. package/native/dist/radio-group.d.ts +9 -3
  48. package/native/dist/radio-group.js +4 -5
  49. package/native/dist/recipes.d.ts +6 -0
  50. package/native/dist/recipes.js +6 -0
  51. package/native/dist/reward-block.d.ts +45 -6
  52. package/native/dist/reward-block.js +30 -12
  53. package/native/dist/screen-header.d.ts +49 -0
  54. package/native/dist/screen-header.js +29 -0
  55. package/native/dist/selection.d.ts +2 -2
  56. package/native/dist/setting-header.d.ts +2 -8
  57. package/native/dist/setting-header.js +2 -11
  58. package/native/dist/setting-switch.d.ts +14 -1
  59. package/native/dist/setting-switch.js +5 -2
  60. package/native/dist/signals-block.d.ts +26 -2
  61. package/native/dist/signals-block.js +14 -4
  62. package/native/dist/sound-haptics-block.d.ts +29 -2
  63. package/native/dist/sound-haptics-block.js +18 -7
  64. package/native/dist/status.d.ts +6 -5
  65. package/native/dist/status.js +5 -5
  66. package/native/dist/sticky-header.d.ts +28 -0
  67. package/native/dist/sticky-header.js +21 -0
  68. package/native/dist/surface.d.ts +3 -1
  69. package/native/dist/surface.js +2 -1
  70. package/native/dist/swap-panel-block.d.ts +2 -1
  71. package/native/dist/swap-panel-block.js +9 -6
  72. package/native/dist/swap-parts.d.ts +5 -3
  73. package/native/dist/swap-parts.js +2 -2
  74. package/native/dist/swap-shared.d.ts +6 -0
  75. package/native/dist/swap-views.js +5 -3
  76. package/native/dist/switch-row.d.ts +3 -2
  77. package/native/dist/switch-row.js +5 -3
  78. package/native/dist/switch.d.ts +4 -2
  79. package/native/dist/switch.js +3 -3
  80. package/native/dist/target-block.d.ts +33 -6
  81. package/native/dist/target-block.js +19 -6
  82. package/native/dist/token-action-block.d.ts +17 -9
  83. package/native/dist/token-action-block.js +14 -6
  84. package/native/dist/trade-history-detail-block.d.ts +26 -1
  85. package/native/dist/trade-history-detail-block.js +17 -9
  86. package/native/dist/trade-history-list-block.d.ts +71 -5
  87. package/native/dist/trade-history-list-block.js +50 -15
  88. package/native/dist/wallet-address-core.d.ts +25 -0
  89. package/native/dist/wallet-address-core.js +31 -0
  90. package/native/dist/wallet-address.d.ts +6 -10
  91. package/native/dist/wallet-address.js +16 -20
  92. package/native-fonts/README.md +1 -1
  93. package/og-fonts/README.md +1 -1
  94. package/package.json +21 -1
  95. package/react/README.md +1 -1
  96. package/react/dist/animated-number-model.d.ts +6 -0
  97. package/react/dist/animated-number-model.js +33 -0
  98. package/react/dist/animated-number.d.ts +5 -1
  99. package/react/dist/animated-number.js +12 -8
  100. package/react/dist/asset-balance-row.d.ts +17 -1
  101. package/react/dist/asset-balance-row.js +11 -3
  102. package/react/dist/bar-mark.d.ts +5 -2
  103. package/react/dist/bar-mark.js +5 -3
  104. package/react/dist/blocks/account-block.d.ts +53 -7
  105. package/react/dist/blocks/account-block.js +45 -10
  106. package/react/dist/blocks/language-block.d.ts +5 -1
  107. package/react/dist/blocks/language-block.js +6 -5
  108. package/react/dist/blocks/manage-position-block.d.ts +28 -2
  109. package/react/dist/blocks/manage-position-block.js +23 -4
  110. package/react/dist/blocks/market-row.d.ts +20 -9
  111. package/react/dist/blocks/market-row.js +12 -4
  112. package/react/dist/blocks/notifications-block.d.ts +25 -2
  113. package/react/dist/blocks/notifications-block.js +11 -2
  114. package/react/dist/blocks/pickers.d.ts +21 -1
  115. package/react/dist/blocks/pickers.js +30 -10
  116. package/react/dist/blocks/position-block.d.ts +34 -11
  117. package/react/dist/blocks/position-block.js +16 -5
  118. package/react/dist/blocks/profile-block.d.ts +29 -6
  119. package/react/dist/blocks/profile-block.js +31 -5
  120. package/react/dist/blocks/reward-block.d.ts +53 -14
  121. package/react/dist/blocks/reward-block.js +20 -10
  122. package/react/dist/blocks/screen-header.d.ts +26 -2
  123. package/react/dist/blocks/screen-header.js +13 -5
  124. package/react/dist/blocks/setting-switch.d.ts +14 -1
  125. package/react/dist/blocks/setting-switch.js +8 -4
  126. package/react/dist/blocks/signals-block.d.ts +21 -2
  127. package/react/dist/blocks/signals-block.js +5 -5
  128. package/react/dist/blocks/sound-haptics-block.d.ts +25 -3
  129. package/react/dist/blocks/sound-haptics-block.js +11 -7
  130. package/react/dist/blocks/sticky-header.d.ts +9 -0
  131. package/react/dist/blocks/sticky-header.js +43 -0
  132. package/react/dist/blocks/swap/amount-card.js +2 -1
  133. package/react/dist/blocks/swap/settings.js +2 -2
  134. package/react/dist/blocks/swap/shared.d.ts +7 -1
  135. package/react/dist/blocks/swap/shared.js +6 -4
  136. package/react/dist/blocks/swap-panel-block.d.ts +2 -0
  137. package/react/dist/blocks/swap-panel-block.js +6 -6
  138. package/react/dist/blocks/target-block.d.ts +28 -6
  139. package/react/dist/blocks/target-block.js +17 -9
  140. package/react/dist/blocks/token-action-block.d.ts +17 -8
  141. package/react/dist/blocks/token-action-block.js +9 -6
  142. package/react/dist/blocks/trade-history-detail-block.d.ts +21 -1
  143. package/react/dist/blocks/trade-history-detail-block.js +5 -4
  144. package/react/dist/blocks/trade-history-list-block.d.ts +29 -5
  145. package/react/dist/blocks/trade-history-list-block.js +15 -8
  146. package/react/dist/blocks.d.ts +8 -8
  147. package/react/dist/blocks.js +2 -2
  148. package/react/dist/button.js +6 -4
  149. package/react/dist/data.js +3 -3
  150. package/react/dist/field.d.ts +14 -4
  151. package/react/dist/field.js +19 -6
  152. package/react/dist/figure.d.ts +23 -0
  153. package/react/dist/figure.js +12 -0
  154. package/react/dist/list-group.d.ts +41 -8
  155. package/react/dist/list-group.js +44 -12
  156. package/react/dist/provider.d.ts +40 -3
  157. package/react/dist/provider.js +63 -6
  158. package/react/dist/selection.d.ts +8 -2
  159. package/react/dist/selection.js +11 -6
  160. package/react/dist/styles.css +164 -9
  161. package/react/dist/surface.d.ts +5 -1
  162. package/react/dist/surface.js +1 -1
  163. package/react/dist/wallet-address-core.d.ts +23 -0
  164. package/react/dist/wallet-address-core.js +24 -0
  165. package/react/dist/wallet-address.d.ts +6 -12
  166. package/react/dist/wallet-address.js +5 -16
  167. package/tokens/README.md +1 -1
@@ -1,24 +1,34 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { formatNumber } from '@bloxwap/hig/contracts';
4
- import { useHIG } from '../provider.js';
4
+ import { PressDecoration, usePresentNumber, useNumberLocale } from '../provider.js';
5
+ import { figureProps } from '../figure.js';
5
6
  import { SegmentedControl } from '../selection.js';
7
+ import { Button } from '../button.js';
6
8
  import { AnimatedNumberReadout } from '../animated-number.js';
7
9
  import { ScreenHeader } from './screen-header.js';
8
- import { SwapIcon } from './swap/shared.js';
10
+ import { SwapIcon, SwapNumber } from './swap/shared.js';
9
11
  const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }, whole = { maximumFractionDigits: 0 };
12
+ const skeletons = [0, 1, 2, 3, 4];
10
13
  /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
11
14
  export function rewardProgress(amount, goal) {
12
15
  return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
13
16
  }
14
- const verifiedMark = _jsxs("svg", { className: 'hig-reward-verified-mark', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '16', height: '16', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: [_jsx("circle", { cx: '10', cy: '10', r: '7.5' }), _jsx("path", { d: 'm6.75 10.25 2.25 2.25 4.25-4.75' })] });
15
- function Standing({ entry, scoreOptions, verifiedLabel, as: Tag = 'li' }) {
16
- return _jsxs(Tag, { className: 'hig-reward-row', "data-you": entry.you || undefined, children: [_jsx("span", { className: 'hig-reward-rank hig-number', children: entry.rank }), _jsx("span", { className: 'hig-reward-avatar', "aria-hidden": 'true', children: typeof entry.avatar === 'string' ? _jsx("img", { src: entry.avatar, alt: '' }) : entry.avatar ?? entry.name.slice(0, 2) }), _jsxs("span", { className: 'hig-reward-identity', children: [_jsxs("strong", { className: 'hig-number', children: [entry.name, entry.verified && _jsx("span", { className: 'hig-reward-verified', role: verifiedLabel ? 'img' : undefined, "aria-label": verifiedLabel, children: verifiedMark })] }), entry.detail && _jsx("span", { className: 'hig-number', children: entry.detail })] }), _jsx("span", { className: 'hig-reward-score', children: _jsx(AnimatedNumberReadout, { value: entry.score, options: scoreOptions }) })] });
17
+ const verifiedGlyph = _jsxs("svg", { className: 'hig-reward-verified-mark', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '16', height: '16', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: [_jsx("circle", { cx: '10', cy: '10', r: '7.5' }), _jsx("path", { d: 'm6.75 10.25 2.25 2.25 4.25-4.75' })] });
18
+ function Standing({ entry, scoreOptions, verifiedLabel, verifiedMark, verifiedMarkInteractive, as: Tag = 'li' }) {
19
+ const detail = entry.detail;
20
+ return _jsxs(Tag, { className: 'hig-reward-row', "data-you": entry.you || undefined, children: [_jsx("span", { className: 'hig-reward-rank hig-number', children: entry.rank }), _jsx("span", { className: 'hig-reward-avatar', "aria-hidden": 'true', children: typeof entry.avatar === 'string' ? _jsx("img", { src: entry.avatar, alt: '' }) : entry.avatar ?? entry.name.slice(0, 2) }), _jsxs("span", { className: 'hig-reward-identity', children: [_jsxs("strong", { className: 'hig-number', children: [entry.name, entry.verified && (verifiedMark != null && verifiedMarkInteractive ? _jsxs("span", { className: 'hig-reward-verified', children: [verifiedLabel && _jsx("span", { className: 'hig-sr-only', children: verifiedLabel }), verifiedMark] }) : _jsx("span", { className: 'hig-reward-verified', role: verifiedLabel ? 'img' : undefined, "aria-label": verifiedLabel, children: verifiedMark ?? verifiedGlyph }))] }), detail != null && detail !== '' && _jsx("span", { className: 'hig-number', children: typeof detail === 'string' ? detail : _jsx(SwapNumber, { ...figureProps(detail) }) })] }), _jsx("span", { className: 'hig-reward-score', children: _jsx(AnimatedNumberReadout, { value: entry.score, options: entry.scoreOptions ?? scoreOptions }) })] });
21
+ }
22
+ function Onward({ link, className, children }) {
23
+ return link.href !== undefined ? _jsxs("a", { className: className, href: link.href, target: link.target, rel: link.target === '_blank' ? 'noopener noreferrer' : undefined, onClick: link.onSelect, children: [children, _jsx(PressDecoration, { kind: 'row' })] })
24
+ : _jsxs("button", { type: 'button', className: className, onClick: link.onSelect, children: [children, _jsx(PressDecoration, { kind: 'row' })] });
17
25
  }
18
26
  /** A competition as a screen: an optional promotion (a prize pool filling towards its goal, or a draw with its top prize), an optional choice of standings, the viewer's own standing pinned on a tinted row, and the ranked list. */
19
- export function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions = whole, verifiedLabel, footnote, onBack, headerAction, className, ...rest }) {
20
- const { locale } = useHIG();
27
+ export function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries, scoreOptions = whole, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, header = true, className, ...rest }) {
28
+ const locale = useNumberLocale();
29
+ const present = usePresentNumber();
21
30
  const money = promo?.amountOptions ?? wholeDollars, share = promo ? rewardProgress(promo.amount, promo.goal) : null;
22
- const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, money)) : undefined : promo?.caption;
23
- return _jsxs("section", { ...rest, className: `hig-reward-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction }), promo && _jsxs("section", { className: 'hig-surface hig-reward-promo', children: [_jsxs("div", { className: 'hig-reward-promo-top', children: [_jsx("span", { className: 'hig-reward-eyebrow hig-number', children: promo.eyebrow }), promo.rules && _jsxs("button", { type: 'button', className: 'hig-reward-rules', onClick: promo.rules.onSelect, children: [promo.rules.label, _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), _jsx("p", { className: 'hig-reward-amount', children: _jsx(AnimatedNumberReadout, { value: promo.amount, options: money }) }), caption && _jsx("p", { className: 'hig-reward-caption hig-number', children: caption }), promo.goal !== undefined && _jsx("div", { className: 'hig-reward-track', "aria-hidden": 'true', children: _jsx("span", { style: { width: `${(share ?? 0) * 100}%` } }) }), (promo.headline || promo.description) && _jsxs("p", { className: 'hig-reward-summary', children: [promo.headline && _jsx("strong", { children: promo.headline }), promo.headline && promo.description ? ' ' : null, promo.description] }), promo.action && _jsxs("button", { type: 'button', className: 'hig-reward-action', onClick: promo.action.onSelect, children: [_jsx("span", { children: promo.action.label }), _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), tabs && _jsx(SegmentedControl, { label: tabs.label, options: tabs.options, value: tabs.value, onValueChange: tabs.onValueChange }), you && _jsx("div", { className: 'hig-reward-you', children: _jsx(Standing, { as: 'div', entry: { ...you, you: true }, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel }) }), (entries.length > 0 || listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-list', children: [(listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-columns hig-number', children: [_jsx("span", { children: listTitle }), _jsx("span", { children: scoreTitle })] }), entries.length > 0 && _jsx("ol", { className: 'hig-reward-rows', children: entries.map(entry => _jsx(Standing, { entry: entry, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel }, entry.id)) })] }), footnote && _jsx("p", { className: 'hig-reward-footnote', children: footnote })] });
31
+ const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, present(money))) : undefined : promo?.caption;
32
+ const pinned = you && _jsx(Standing, { as: 'div', entry: { ...you, you: true }, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive });
33
+ return _jsxs("section", { ...rest, className: `hig-reward-block${className ? ` ${className}` : ''}`, children: [header && _jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, stickyHeader: stickyHeader }), promo && _jsxs("section", { className: 'hig-surface hig-reward-promo', children: [_jsxs("div", { className: 'hig-reward-promo-top', children: [_jsx("span", { className: 'hig-reward-eyebrow hig-number', children: promo.eyebrow }), promo.rules && _jsxs(Onward, { link: promo.rules, className: 'hig-reward-rules', children: [promo.rules.label, _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), _jsx("p", { className: 'hig-reward-amount', children: _jsx(AnimatedNumberReadout, { value: promo.amount, options: money }) }), caption && _jsx("p", { className: 'hig-reward-caption hig-number', children: caption }), promo.goal !== undefined && _jsx("div", { className: 'hig-reward-track', "aria-hidden": 'true', children: _jsx("span", { style: { width: `${(share ?? 0) * 100}%` } }) }), (promo.headline || promo.description) && _jsxs("p", { className: 'hig-reward-summary', children: [promo.headline && _jsx("strong", { children: promo.headline }), promo.headline && promo.description ? ' ' : null, promo.description] }), promo.action && _jsxs(Onward, { link: promo.action, className: 'hig-reward-action', children: [_jsx("span", { children: promo.action.label }), _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), tabs && _jsx(SegmentedControl, { label: tabs.label, options: tabs.options, value: tabs.value, onValueChange: tabs.onValueChange }), pinned && (youLabel ? _jsx("div", { className: 'hig-reward-you', role: 'group', "aria-label": youLabel, children: pinned }) : _jsx("div", { className: 'hig-reward-you', children: pinned })), status && _jsx("p", { className: 'hig-reward-status', role: 'status', children: status }), loading ? _jsxs(_Fragment, { children: [loadingLabel && _jsx("p", { className: 'hig-sr-only', role: 'status', children: loadingLabel }), _jsx("div", { className: 'hig-reward-list', "aria-busy": 'true', children: skeletons.map(index => _jsx("div", { className: 'hig-skeleton hig-reward-skeleton', "aria-hidden": 'true' }, index)) })] }) : (entries.length > 0 || listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-list', children: [(listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-columns hig-number', children: [_jsx("span", { children: listTitle }), _jsx("span", { children: scoreTitle })] }), entries.length > 0 && _jsx("ol", { className: 'hig-reward-rows', children: entries.map(entry => _jsx(Standing, { entry: entry, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive }, entry.id)) })] }), pagination && _jsxs("div", { className: 'hig-reward-pagination', children: [pagination.previous ? _jsx(Button, { intent: 'secondary', disabled: pagination.previous.disabled, onClick: pagination.previous.onSelect, children: pagination.previous.label }) : _jsx("span", {}), pagination.label ? _jsx("span", { className: 'hig-reward-page hig-number', "aria-live": 'polite', children: pagination.label }) : _jsx("span", {}), pagination.next ? _jsx(Button, { intent: 'secondary', disabled: pagination.next.disabled, onClick: pagination.next.onSelect, children: pagination.next.label }) : _jsx("span", {})] }), footnote && _jsx("p", { className: 'hig-reward-footnote', children: footnote })] });
24
34
  }
@@ -1,9 +1,33 @@
1
1
  import React from 'react';
2
- /** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. */
3
- export declare function ScreenHeader({ title, onBack, action }: {
2
+ /** Attributes passed through to a header control's `<button>`, such as a data attribute or a pointer handler. HIG keeps its own type, class, name and click. */
3
+ export type ScreenHeaderControlProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'type' | 'className' | 'onClick' | 'aria-label' | 'children' | 'disabled'>;
4
+ export interface ScreenHeaderProps {
5
+ /** The heading, centred. Host text. */
4
6
  title: string;
7
+ /** Shows Back on the leading edge. */
5
8
  onBack?: () => void;
9
+ /** Draws Back unavailable: dimmed, `disabled` and not pressable, for example while a close is being signed. */
10
+ backDisabled?: boolean;
11
+ /** Attributes for the Back `<button>`. */
12
+ backProps?: ScreenHeaderControlProps;
13
+ /** A control on the trailing edge, usually an `IconButton`. */
6
14
  action?: React.ReactNode;
15
+ /** `id` of the heading, so a dialog or sheet can name itself with `aria-labelledby` instead of repeating the title. */
16
+ headingId?: string;
17
+ /** Short host text in a badge beside the title, read as part of the heading after a pause: Demo. */
18
+ badge?: string;
19
+ /** Hides the title visually while it stays the accessible heading, for a host that draws its own visible title and must not have it read twice. The header keeps its height and its two sides. */
20
+ hideTitle?: boolean;
21
+ /** Pins the header to the top of the nearest scrolling container. It is transparent at rest and takes its fill (`--hig-sticky-header-background`) only once content has scrolled under it. */
22
+ stickyHeader?: boolean;
23
+ }
24
+ /** The block header's Close control, shared by the blocks that draw one. */
25
+ export declare function HeaderClose({ onClose, label, closeProps }: {
26
+ onClose: () => void;
27
+ label: string;
28
+ closeProps?: ScreenHeaderControlProps;
7
29
  }): React.JSX.Element;
30
+ /** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. Every block draws it; import it from `@bloxwap/hig/react/blocks/screen-header` for a host pane that has no block. */
31
+ export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, headingId, badge, hideTitle, stickyHeader }: ScreenHeaderProps): React.JSX.Element;
8
32
  /** The QR glyph of a control that shows an address. */
9
33
  export declare const qrIcon: React.JSX.Element;
@@ -1,12 +1,20 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from 'react';
3
4
  import * as en from '@bloxwap/hig/contracts/messages';
4
- import { useHIG } from '../provider.js';
5
+ import { PressDecoration, useHIG } from '../provider.js';
5
6
  import { SwapIcon } from './swap/shared.js';
6
- /** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. */
7
- export function ScreenHeader({ title, onBack, action }) {
7
+ import { useStickyHeader } from './sticky-header.js';
8
+ /** The block header's Close control, shared by the blocks that draw one. */
9
+ export function HeaderClose({ onClose, label, closeProps }) {
10
+ return _jsxs("button", { ...closeProps, type: 'button', className: 'hig-swap-back', "aria-label": label, onClick: onClose, children: [_jsx(SwapIcon, { name: 'close' }), _jsx(PressDecoration, { kind: 'back' })] });
11
+ }
12
+ /** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. Every block draws it; import it from `@bloxwap/hig/react/blocks/screen-header` for a host pane that has no block. */
13
+ export function ScreenHeader({ title, onBack, backDisabled, backProps, action, headingId, badge, hideTitle, stickyHeader }) {
8
14
  const { messages } = useHIG();
9
- return _jsxs("div", { className: 'hig-screen-header', children: [_jsx("span", { className: 'hig-screen-header-side', children: onBack && _jsx("button", { type: 'button', className: 'hig-swap-back', "aria-label": messages.back ?? en.back, onClick: onBack, children: _jsx(SwapIcon, { name: 'back' }) }) }), _jsx("h2", { className: 'hig-screen-title', children: title }), _jsx("span", { className: 'hig-screen-header-side', children: action })] });
15
+ const header = useRef(null);
16
+ useStickyHeader(header, !!stickyHeader);
17
+ return _jsxs("div", { ref: header, className: 'hig-screen-header', "data-sticky": stickyHeader || undefined, children: [_jsx("span", { className: 'hig-screen-header-side', children: onBack && _jsxs("button", { ...backProps, type: 'button', className: 'hig-swap-back', "aria-label": messages.back ?? en.back, disabled: backDisabled || undefined, onClick: onBack, children: [_jsx(SwapIcon, { name: 'back' }), _jsx(PressDecoration, { kind: 'back', disabled: !!backDisabled })] }) }), _jsx("h2", { id: headingId, className: `hig-screen-title${hideTitle ? ' hig-sr-only' : ''}`, children: badge ? _jsxs(_Fragment, { children: [title, _jsx("span", { className: 'hig-sr-only', children: "," }), " ", _jsx("span", { className: 'hig-badge hig-screen-badge', children: badge })] }) : title }), _jsx("span", { className: 'hig-screen-header-side', children: action })] });
10
18
  }
11
19
  /** The QR glyph of a control that shows an address. */
12
20
  export const qrIcon = _jsxs("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '20', height: '20', fill: 'none', stroke: 'currentColor', strokeWidth: '1.6', strokeLinejoin: 'round', children: [_jsx("rect", { x: '3', y: '3', width: '5.5', height: '5.5', rx: '1' }), _jsx("rect", { x: '11.5', y: '3', width: '5.5', height: '5.5', rx: '1' }), _jsx("rect", { x: '3', y: '11.5', width: '5.5', height: '5.5', rx: '1' }), _jsx("path", { d: 'M11.5 11.5h2v2h-2zM15 15h2v2h-2z', fill: 'currentColor', stroke: 'none' })] });
@@ -1,10 +1,23 @@
1
1
  import React from 'react';
2
+ /** A secondary button under a setting, such as Open Settings. `feedback: false` keeps the provider's press feedback off this one button, for a host that plays its own cue for it; by default it plays like any `Button`. */
3
+ export interface SettingAction {
4
+ label: string;
5
+ onSelect: () => void;
6
+ disabled?: boolean;
7
+ feedback?: boolean;
8
+ }
2
9
  export interface SettingSwitchProps {
3
10
  label: string;
4
11
  description?: string;
5
12
  checked: boolean;
6
13
  onCheckedChange: (checked: boolean) => void;
7
14
  disabled?: boolean;
15
+ /** Always on and not changeable: the switch shows on at full strength and is read as unavailable. Presses do nothing. */
16
+ locked?: boolean;
17
+ /** Host content after the label, such as a badge. It is part of the switch's name, read after the label and a pause, so give artwork a text alternative or hide it. */
18
+ labelAccessory?: React.ReactNode;
19
+ /** Host words for the `labelAccessory`, read after the label and a pause in place of the accessory's own content, which is then hidden from assistive technology: `Feed, New`. Same prop on native. */
20
+ labelAccessoryLabel?: string;
8
21
  }
9
22
  /** One setting as a switch: the label over an optional description on the leading edge, the track on the trailing edge. The whole row is the `label.hig-choice` hit target, at least `--hig-control` tall, and toggles it; the label names the switch and the description describes it. */
10
- export declare function SettingSwitch({ label, description, checked, onCheckedChange, disabled }: SettingSwitchProps): React.JSX.Element;
23
+ export declare function SettingSwitch({ label, description, checked, onCheckedChange, disabled, locked, labelAccessory, labelAccessoryLabel }: SettingSwitchProps): React.JSX.Element;
@@ -1,8 +1,12 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useId } from 'react';
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useRef } from 'react';
4
+ import { PressDecoration } from '../provider.js';
4
5
  /** One setting as a switch: the label over an optional description on the leading edge, the track on the trailing edge. The whole row is the `label.hig-choice` hit target, at least `--hig-control` tall, and toggles it; the label names the switch and the description describes it. */
5
- export function SettingSwitch({ label, description, checked, onCheckedChange, disabled }) {
6
+ export function SettingSwitch({ label, description, checked, onCheckedChange, disabled, locked, labelAccessory, labelAccessoryLabel }) {
6
7
  const id = useId(), name = `${id}-label`, about = `${id}-description`;
7
- return _jsxs("label", { className: 'hig-choice hig-setting-switch', "data-disabled": disabled || undefined, children: [_jsxs("span", { className: 'hig-setting-switch-text', children: [_jsx("span", { id: name, children: label }), description && _jsx("span", { id: about, className: 'hig-setting-switch-description', children: description })] }), _jsx("span", { className: 'hig-switch', children: _jsx("input", { type: 'checkbox', role: 'switch', "aria-labelledby": name, "aria-describedby": description ? about : undefined, checked: checked, disabled: disabled, onChange: event => onCheckedChange(event.target.checked) }) })] });
8
+ const input = useRef(null);
9
+ // The comma is read, not drawn, so the name pauses between the label and the accessory instead of running them together.
10
+ return _jsxs("label", { className: 'hig-choice hig-setting-switch', "data-disabled": disabled || undefined, "data-locked": locked || undefined, children: [_jsxs("span", { className: 'hig-setting-switch-text', children: [_jsxs("span", { id: name, children: [label, labelAccessory != null && labelAccessory !== false && _jsxs(_Fragment, { children: [_jsx("span", { className: 'hig-sr-only', children: labelAccessoryLabel ? `, ${labelAccessoryLabel}` : ', ' }), _jsx("span", { className: 'hig-setting-switch-accessory', "aria-hidden": labelAccessoryLabel ? true : undefined, children: labelAccessory })] })] }), description && _jsx("span", { id: about, className: 'hig-setting-switch-description', children: description })] }), _jsx("span", { className: 'hig-switch', children: _jsx("input", { ref: input, type: 'checkbox', role: 'switch', "aria-labelledby": name, "aria-describedby": description ? about : undefined, "aria-disabled": locked || undefined, checked: locked ? true : checked, disabled: disabled, onChange: event => { if (!locked)
11
+ onCheckedChange(event.target.checked); } }) }), _jsx(PressDecoration, { kind: 'switch', disabled: !!disabled || !!locked, input: input })] });
8
12
  }
@@ -7,6 +7,16 @@ export interface SignalsItem {
7
7
  checked: boolean;
8
8
  onCheckedChange: (checked: boolean) => void;
9
9
  disabled?: boolean;
10
+ /** Always on and not changeable: shown on at full strength and read as unavailable. */
11
+ locked?: boolean;
12
+ /** Host content after the label, such as a badge. It is part of the switch's name. */
13
+ labelAccessory?: React.ReactNode;
14
+ /** Host words for the `labelAccessory`, read after the label and a pause in place of its content: `Feed, New`. */
15
+ labelAccessoryLabel?: string;
16
+ /** A neutral line under the switch, announced when it changes: Needs this browser's permission. */
17
+ hint?: string;
18
+ /** A failure under the switch, in the negative role and announced. */
19
+ error?: string;
10
20
  }
11
21
  /** A family of signals under one heading: Trend, Swing. Every word is host text. */
12
22
  export interface SignalsGroup {
@@ -14,22 +24,31 @@ export interface SignalsGroup {
14
24
  title: string;
15
25
  /** Shows the verified mark after the title. */
16
26
  verified?: boolean;
17
- /** A small pill on the trailing edge of the heading: How it works. The host opens its own explanation. */
27
+ /** A small pill on the trailing edge of the heading: How it works. The host opens its own explanation. `ref` reaches the pill, so the host can return focus to it when the explanation closes. */
18
28
  help?: {
19
29
  label: string;
20
30
  onSelect: () => void;
31
+ ref?: React.Ref<HTMLButtonElement>;
21
32
  };
22
33
  items: readonly SignalsItem[];
23
34
  }
24
35
  export interface SignalsBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
25
36
  /** Heading: Signals. */
26
37
  title: string;
38
+ /** A muted line under the header that explains the screen. */
39
+ description?: string;
27
40
  groups: readonly SignalsGroup[];
28
41
  /** Accessible name of the verified mark. The mark is decorative without it. */
29
42
  verifiedLabel?: string;
43
+ /** Host artwork in place of the built-in verified mark, drawn inside the mark's image role. */
44
+ verifiedMark?: React.ReactNode;
45
+ /** The `verifiedMark` is a control, such as a badge with a popover: it stays in the accessibility tree outside the image role, and `verifiedLabel` is read before it. */
46
+ verifiedMarkInteractive?: boolean;
30
47
  onBack?: () => void;
31
48
  /** A control on the trailing edge of the header, usually an `IconButton`. */
32
49
  headerAction?: React.ReactNode;
50
+ /** Pins the header to the top of the nearest scrolling container, transparent at rest and filled with `--hig-sticky-header-background` once content scrolls under it. */
51
+ stickyHeader?: boolean;
33
52
  }
34
53
  /** The signals the viewer receives, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
35
- export declare function SignalsBlock({ title, groups, verifiedLabel, onBack, headerAction, className, ...rest }: SignalsBlockProps): React.JSX.Element;
54
+ export declare function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, className, ...rest }: SignalsBlockProps): React.JSX.Element;
@@ -4,12 +4,12 @@ import { useId } from 'react';
4
4
  import { ScreenHeader } from './screen-header.js';
5
5
  import { SettingSwitch } from './setting-switch.js';
6
6
  import { SwapPill } from './swap/shared.js';
7
- const verifiedMark = _jsxs("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '16', height: '16', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: [_jsx("circle", { cx: '10', cy: '10', r: '7.5' }), _jsx("path", { d: 'm6.75 10.25 2.25 2.25 4.25-4.75' })] });
8
- function Group({ group, verifiedLabel }) {
7
+ const verifiedGlyph = _jsxs("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '16', height: '16', fill: 'none', stroke: 'currentColor', strokeWidth: '1.8', strokeLinecap: 'round', strokeLinejoin: 'round', children: [_jsx("circle", { cx: '10', cy: '10', r: '7.5' }), _jsx("path", { d: 'm6.75 10.25 2.25 2.25 4.25-4.75' })] });
8
+ function Group({ group, verifiedLabel, verifiedMark, verifiedMarkInteractive }) {
9
9
  const id = useId();
10
- return _jsxs("section", { className: 'hig-signals-group', "aria-labelledby": id, children: [_jsxs("div", { className: 'hig-signals-group-header', children: [_jsxs("h3", { id: id, children: [group.title, group.verified && _jsx("span", { className: 'hig-reward-verified', role: verifiedLabel ? 'img' : undefined, "aria-label": verifiedLabel, children: verifiedMark })] }), group.help && _jsx(SwapPill, { onClick: group.help.onSelect, children: group.help.label })] }), group.items.length > 0 && _jsx("div", { className: 'hig-setting-list', children: group.items.map(item => _jsx("div", { className: 'hig-setting-card', children: _jsx(SettingSwitch, { label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, onCheckedChange: item.onCheckedChange }) }, item.id)) })] });
10
+ return _jsxs("section", { className: 'hig-signals-group', "aria-labelledby": id, children: [_jsxs("div", { className: 'hig-signals-group-header', children: [_jsxs("h3", { id: id, children: [group.title, group.verified && (verifiedMark != null && verifiedMarkInteractive ? _jsxs("span", { className: 'hig-reward-verified', children: [verifiedLabel && _jsx("span", { className: 'hig-sr-only', children: verifiedLabel }), verifiedMark] }) : _jsx("span", { className: 'hig-reward-verified', role: verifiedLabel ? 'img' : undefined, "aria-label": verifiedLabel, children: verifiedMark ?? verifiedGlyph }))] }), group.help && _jsx(SwapPill, { ref: group.help.ref, onClick: group.help.onSelect, children: group.help.label })] }), group.items.length > 0 && _jsx("div", { className: 'hig-setting-list', children: group.items.map(item => _jsxs("div", { className: 'hig-setting-card', children: [_jsx(SettingSwitch, { label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, locked: item.locked, labelAccessory: item.labelAccessory, labelAccessoryLabel: item.labelAccessoryLabel, onCheckedChange: item.onCheckedChange }), (item.hint || item.error) && _jsxs("div", { className: 'hig-setting-notes', children: [item.hint && _jsx("p", { role: 'status', className: 'hig-setting-hint', children: item.hint }), item.error && _jsx("p", { role: 'alert', className: 'hig-setting-error', children: item.error })] })] }, item.id)) })] });
11
11
  }
12
12
  /** The signals the viewer receives, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
13
- export function SignalsBlock({ title, groups, verifiedLabel, onBack, headerAction, className, ...rest }) {
14
- return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction }), groups.map(group => _jsx(Group, { group: group, verifiedLabel: verifiedLabel }, group.id))] });
13
+ export function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, className, ...rest }) {
14
+ return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, stickyHeader: stickyHeader }), description && _jsx("p", { className: 'hig-settings-description', children: description }), groups.map(group => _jsx(Group, { group: group, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive }, group.id))] });
15
15
  }
@@ -1,4 +1,7 @@
1
1
  import React from 'react';
2
+ import { type Choice } from '../selection.js';
3
+ import { type SettingAction } from './setting-switch.js';
4
+ export type { SettingAction } from './setting-switch.js';
2
5
  /** A volume as a few fixed steps. `value` and `options` are fractions: 0.25 reads 25%. */
3
6
  export interface SoundVolume {
4
7
  /** Names the steps and is drawn above them: Volume. */
@@ -8,6 +11,13 @@ export interface SoundVolume {
8
11
  value: number;
9
12
  onValueChange: (value: number) => void;
10
13
  }
14
+ /** A choice of device under the source, such as which microphone to use. `label` names the group and is drawn above it. */
15
+ export interface SoundChoices {
16
+ label: string;
17
+ options: readonly Choice[];
18
+ value: string;
19
+ onValueChange: (value: string) => void;
20
+ }
11
21
  /** One feedback channel: sound effects, the microphone, haptics, the flash. Every word is host text. */
12
22
  export interface SoundSection {
13
23
  id: string;
@@ -18,20 +28,32 @@ export interface SoundSection {
18
28
  disabled?: boolean;
19
29
  /** The device in use, under the switch: iPhone Microphone. */
20
30
  source?: string;
31
+ /** A choice between devices, as radios under the source: Automatic, iPhone Microphone, AirPods. Shown while the channel is on. */
32
+ choices?: SoundChoices;
21
33
  /** A live input level from 0 to 1, drawn as a meter. `null` draws an empty meter. */
22
34
  level?: number | null;
35
+ /** Names the meter for assistive technology, which then reads the level as a percentage. Without it the meter is decorative. */
36
+ levelLabel?: string;
23
37
  volume?: SoundVolume;
38
+ /** What the volume does while the channel is off: `hidden` (the default) leaves it out, `disabled` keeps it in place and unavailable. */
39
+ volumeWhenOff?: 'hidden' | 'disabled';
40
+ /** A secondary action at the foot of the card, shown whether the channel is on or off: Open Settings. */
41
+ action?: SettingAction;
24
42
  }
25
43
  export interface SoundHapticsBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
26
44
  /** Heading: Sound & Haptics. */
27
45
  title: string;
28
- /** One card each, in order. A section's source, meter and volume show only while it is on. */
46
+ /** A muted line under the header that explains the screen. */
47
+ description?: string;
48
+ /** One card each, in order. A section's source, choices and meter show only while it is on; its volume too unless `volumeWhenOff` is `disabled`. */
29
49
  sections: readonly SoundSection[];
30
50
  onBack?: () => void;
31
51
  /** A control on the trailing edge of the header, usually an `IconButton`. */
32
52
  headerAction?: React.ReactNode;
53
+ /** Pins the header to the top of the nearest scrolling container, transparent at rest and filled with `--hig-sticky-header-background` once content scrolls under it. */
54
+ stickyHeader?: boolean;
33
55
  }
34
56
  /** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
35
57
  export declare const soundLevel: (level: number | null | undefined) => number;
36
- /** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a live input meter and its volume as fixed steps. */
37
- export declare function SoundHapticsBlock({ title, sections, onBack, headerAction, className, ...rest }: SoundHapticsBlockProps): React.JSX.Element;
58
+ /** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a choice of devices, a live input meter and its volume as fixed steps. */
59
+ export declare function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, className, ...rest }: SoundHapticsBlockProps): React.JSX.Element;
@@ -1,18 +1,22 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { formatNumber } from '@bloxwap/hig/contracts';
4
- import { useHIG } from '../provider.js';
4
+ import { useNumberLocale } from '../provider.js';
5
5
  import { Button } from '../button.js';
6
+ import { RadioGroup } from '../selection.js';
6
7
  import { ScreenHeader } from './screen-header.js';
7
8
  import { SettingSwitch } from './setting-switch.js';
8
9
  const steps = [0.25, 0.5, 0.75, 1], percent = { style: 'percent', maximumFractionDigits: 0 };
9
10
  /** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
10
11
  export const soundLevel = (level) => level == null || !Number.isFinite(level) ? 0 : Math.min(1, Math.max(0, level));
11
- /** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a live input meter and its volume as fixed steps. */
12
- export function SoundHapticsBlock({ title, sections, onBack, headerAction, className, ...rest }) {
13
- const { locale } = useHIG();
14
- return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction }), sections.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: sections.map(section => {
15
- const { source, level, volume } = section, open = section.checked && (!!source || level !== undefined || !!volume);
16
- return _jsxs("div", { className: 'hig-setting-card', children: [_jsx(SettingSwitch, { label: section.label, description: section.description, checked: section.checked, disabled: section.disabled, onCheckedChange: section.onCheckedChange }), open && _jsxs("div", { className: 'hig-setting-body', children: [source && _jsx("span", { className: 'hig-setting-caption', children: source }), level !== undefined && _jsx("div", { className: 'hig-setting-meter', "aria-hidden": 'true', children: _jsx("span", { style: { width: `${soundLevel(level) * 100}%` } }) }), volume && _jsxs("div", { className: 'hig-setting-volume', role: 'group', "aria-label": volume.label, children: [_jsx("span", { className: 'hig-setting-caption', "aria-hidden": 'true', children: volume.label }), _jsx("div", { className: 'hig-setting-steps', children: (volume.options ?? steps).map(option => _jsx(Button, { fullWidth: true, intent: option === volume.value ? 'primary' : 'secondary', "aria-pressed": option === volume.value, disabled: section.disabled, onClick: () => volume.onValueChange(option), children: formatNumber(option, locale, percent) }, option)) })] })] })] }, section.id);
12
+ /** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a choice of devices, a live input meter and its volume as fixed steps. */
13
+ export function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, className, ...rest }) {
14
+ const locale = useNumberLocale();
15
+ return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, stickyHeader: stickyHeader }), description && _jsx("p", { className: 'hig-settings-description', children: description }), sections.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: sections.map(section => {
16
+ const { source, choices, level, levelLabel, volume, action } = section, on = section.checked;
17
+ const showVolume = !!volume && (on || section.volumeWhenOff === 'disabled'), volumeOff = !!section.disabled || !on;
18
+ const open = (on && (!!source || !!choices || level !== undefined)) || showVolume || !!action;
19
+ return _jsxs("div", { className: 'hig-setting-card', children: [_jsx(SettingSwitch, { label: section.label, description: section.description, checked: section.checked, disabled: section.disabled, onCheckedChange: section.onCheckedChange }), open && _jsxs("div", { className: 'hig-setting-body', children: [on && source && _jsx("span", { className: 'hig-setting-caption', children: source }), on && choices && _jsx("div", { className: 'hig-setting-choices', children: _jsx(RadioGroup, { label: choices.label, options: choices.options, value: choices.value, disabled: section.disabled, onValueChange: choices.onValueChange }) }), on && level !== undefined && (levelLabel ? _jsx("div", { className: 'hig-setting-meter', role: 'meter', "aria-label": levelLabel, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round(soundLevel(level) * 100), "aria-valuetext": formatNumber(soundLevel(level), locale, percent), children: _jsx("span", { style: { width: `${soundLevel(level) * 100}%` } }) })
20
+ : _jsx("div", { className: 'hig-setting-meter', "aria-hidden": 'true', children: _jsx("span", { style: { width: `${soundLevel(level) * 100}%` } }) })), showVolume && volume && _jsxs("div", { className: 'hig-setting-volume', role: 'group', "aria-label": volume.label, children: [_jsx("span", { className: 'hig-setting-caption', "aria-hidden": 'true', children: volume.label }), _jsx("div", { className: 'hig-setting-steps', children: (volume.options ?? steps).map(option => _jsx(Button, { fullWidth: true, intent: option === volume.value ? 'primary' : 'secondary', "aria-pressed": option === volume.value, disabled: on ? section.disabled : volumeOff, onClick: () => volume.onValueChange(option), children: formatNumber(option, locale, percent) }, option)) })] }), action && _jsx(Button, { className: 'hig-setting-action', intent: 'secondary', fullWidth: true, disabled: action.disabled, suppressFeedback: action.feedback === false, onClick: action.onSelect, children: action.label })] })] }, section.id);
17
21
  }) })] });
18
22
  }
@@ -0,0 +1,9 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * Marks a pinned header `data-scrolled` once content has scrolled under it, so its fill appears only then and it stays
4
+ * transparent at rest. The header's parent is the content: the header is scrolled once the parent's top edge has passed
5
+ * the top of the nearest scroller (or the scroller is the parent and has moved). Where the browser supports scroll-driven
6
+ * animations the stylesheet already fades the fill in on the same rule; this keeps every other browser, and reduced
7
+ * motion, in step with it.
8
+ */
9
+ export declare function useStickyHeader(header: RefObject<HTMLElement | null>, enabled: boolean): void;
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { useEffect } from 'react';
3
+ const scrolls = /(auto|scroll|overlay)/;
4
+ /** The nearest ancestor of `node` (itself included) that scrolls vertically, or `null` for the document. */
5
+ function scroller(node) {
6
+ for (let current = node; current && current !== document.body && current !== document.documentElement; current = current.parentElement) {
7
+ if (scrolls.test(getComputedStyle(current).overflowY))
8
+ return current;
9
+ }
10
+ return null;
11
+ }
12
+ /**
13
+ * Marks a pinned header `data-scrolled` once content has scrolled under it, so its fill appears only then and it stays
14
+ * transparent at rest. The header's parent is the content: the header is scrolled once the parent's top edge has passed
15
+ * the top of the nearest scroller (or the scroller is the parent and has moved). Where the browser supports scroll-driven
16
+ * animations the stylesheet already fades the fill in on the same rule; this keeps every other browser, and reduced
17
+ * motion, in step with it.
18
+ */
19
+ export function useStickyHeader(header, enabled) {
20
+ useEffect(() => {
21
+ const element = header.current;
22
+ if (!enabled || !element)
23
+ return;
24
+ const content = element.parentElement;
25
+ if (!content)
26
+ return;
27
+ const root = scroller(content);
28
+ const target = root ?? window;
29
+ // When the parent is the scroller itself a view timeline on it tracks an outer scroller, never its own scrolling, so the
30
+ // stylesheet leaves the scroll-driven fill off (data-sticky-own) and this script alone marks the moment.
31
+ const own = root === content;
32
+ element.toggleAttribute('data-sticky-own', own);
33
+ const update = () => {
34
+ const scrolled = own ? content.scrollTop > 0 : content.getBoundingClientRect().top < (root ? root.getBoundingClientRect().top : 0) - 0.5;
35
+ if (element.hasAttribute('data-scrolled') !== scrolled)
36
+ element.toggleAttribute('data-scrolled', scrolled);
37
+ };
38
+ update();
39
+ target.addEventListener('scroll', update, { passive: true });
40
+ window.addEventListener('resize', update, { passive: true });
41
+ return () => { target.removeEventListener('scroll', update); window.removeEventListener('resize', update); element.removeAttribute('data-scrolled'); element.removeAttribute('data-sticky-own'); };
42
+ }, [header, enabled]);
43
+ }
@@ -1,7 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { AnimatedNumberReadout } from '../../animated-number.js';
4
+ import { PressDecoration } from '../../provider.js';
4
5
  /** The swap panel's From card on its own: the asset with its actions and balance in the slot, the entered amount under it. The host owns the entry, the keypad and what the amount means. */
5
6
  export function SwapAmountCard({ name, symbol, icon, chainIcon, context, actions, meta, value, amountLabel, prefix = '', suffix = '', fractionDigits = 0, trailingDot = false, maximumFractionDigits = 8, conversion, onSelect, selectLabel, className, style }) {
6
- return _jsxs("div", { className: `hig-swap-card${className ? ` ${className}` : ''}`, style: style, "data-side": 'from', children: [_jsxs("div", { className: 'hig-swap-slot', children: [onSelect && _jsx("button", { type: 'button', className: 'hig-swap-hit', "aria-label": selectLabel, onClick: onSelect }), _jsx("div", { className: 'hig-swap-slot-content', children: _jsxs("div", { className: 'hig-swap-selected', children: [_jsxs("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: [chainIcon && _jsx("img", { src: chainIcon, alt: '' }), typeof icon === 'string' ? _jsx("img", { src: icon, alt: '' }) : icon ?? _jsx("span", { className: 'hig-swap-initials', children: symbol.slice(0, 3) })] }), _jsxs("span", { className: 'hig-swap-identity', children: [context != null && _jsx("span", { children: context }), _jsx("strong", { children: name })] }), (actions != null || meta != null) && _jsxs("span", { className: 'hig-swap-meta', children: [actions != null && _jsx("span", { className: 'hig-swap-pills', children: actions }), meta != null && _jsx("span", { className: 'hig-number', children: meta })] })] }) })] }), _jsx("div", { className: 'hig-swap-amount-area', children: _jsxs("div", { className: 'hig-swap-amount-content', children: [_jsx("div", { className: 'hig-swap-amount', role: 'textbox', tabIndex: 0, "aria-readonly": 'true', "aria-label": amountLabel, children: _jsx(AnimatedNumberReadout, { value: value, prefix: prefix, suffix: (trailingDot ? '.' : '') + suffix, options: { minimumFractionDigits: Math.min(fractionDigits, maximumFractionDigits), maximumFractionDigits, useGrouping: false } }) }), conversion] }) })] });
7
+ return _jsxs("div", { className: `hig-swap-card${className ? ` ${className}` : ''}`, style: style, "data-side": 'from', children: [_jsxs("div", { className: 'hig-swap-slot', children: [onSelect && _jsx("button", { type: 'button', className: 'hig-swap-hit', "aria-label": selectLabel, onClick: onSelect, children: _jsx(PressDecoration, { kind: 'row' }) }), _jsx("div", { className: 'hig-swap-slot-content', children: _jsxs("div", { className: 'hig-swap-selected', children: [_jsxs("span", { className: 'hig-swap-stack', "aria-hidden": 'true', children: [chainIcon && _jsx("img", { src: chainIcon, alt: '' }), typeof icon === 'string' ? _jsx("img", { src: icon, alt: '' }) : icon ?? _jsx("span", { className: 'hig-swap-initials', children: symbol.slice(0, 3) })] }), _jsxs("span", { className: 'hig-swap-identity', children: [context != null && _jsx("span", { children: context }), _jsx("strong", { children: name })] }), (actions != null || meta != null) && _jsxs("span", { className: 'hig-swap-meta', children: [actions != null && _jsx("span", { className: 'hig-swap-pills', children: actions }), meta != null && _jsx("span", { className: 'hig-number', children: meta })] })] }) })] }), _jsx("div", { className: 'hig-swap-amount-area', children: _jsxs("div", { className: 'hig-swap-amount-content', children: [_jsx("div", { className: 'hig-swap-amount', role: 'textbox', tabIndex: 0, "aria-readonly": 'true', "aria-label": amountLabel, children: _jsx(AnimatedNumberReadout, { value: value, prefix: prefix, suffix: (trailingDot ? '.' : '') + suffix, options: { minimumFractionDigits: Math.min(fractionDigits, maximumFractionDigits), maximumFractionDigits, useGrouping: false } }) }), conversion] }) })] });
7
8
  }
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useRef, useState } from 'react';
4
4
  import * as en from '@bloxwap/hig/contracts/messages';
5
- import { useHIG } from '../../provider.js';
5
+ import { PressDecoration, useHIG } from '../../provider.js';
6
6
  import { Field, Input } from '../../field.js';
7
7
  import { SegmentedControl } from '../../selection.js';
8
8
  import { SwapIcon, SwapNumber, SwapViewHeader, formatPercent, percentNumber, usdNumber } from './shared.js';
@@ -16,7 +16,7 @@ export function SwapSettings({ view, onViewChange, onBack, denomination, onDenom
16
16
  const title = view === 'slippage' ? (messages.swapSlippageTitle ?? en.swapSlippageTitle) : view === 'fees' ? (messages.swapFees ?? en.swapFees) : (messages.swapSettings ?? en.swapSettings);
17
17
  const feeText = quoteLoading ? '…' : fee != null ? _jsx(SwapNumber, { ...usdNumber(fee) }) : '—';
18
18
  const preset = slippagePresets.find(value => Math.abs(value - slippage) < 1e-9);
19
- const row = (label, value, target) => _jsxs("button", { type: 'button', className: 'hig-swap-setting', onClick: () => onViewChange(target), children: [_jsx("span", { children: label }), _jsxs("span", { className: 'hig-swap-setting-value', children: [value, _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] });
19
+ const row = (label, value, target) => _jsxs("button", { type: 'button', className: 'hig-swap-setting', onClick: () => onViewChange(target), children: [_jsx("span", { children: label }), _jsxs("span", { className: 'hig-swap-setting-value', children: [value, _jsx(SwapIcon, { name: 'chevron', size: 16 })] }), _jsx(PressDecoration, { kind: 'row' })] });
20
20
  const slippageRow = row(messages.swapSlippageTitle ?? en.swapSlippageTitle, _jsx(SwapNumber, { ...percentNumber(slippage) }), 'slippage'), feesRow = row(messages.swapFees ?? en.swapFees, feeText, 'fees');
21
21
  return _jsxs("div", { className: 'hig-swap-settings-view', role: 'group', "aria-label": title, children: [_jsx(SwapViewHeader, { title: title, titleRef: heading, backLabel: messages.back ?? en.back, onBack: onBack }), view === 'settings' && _jsxs("div", { className: 'hig-swap-settings', children: [onDenominationChange && _jsx(SegmentedControl, { label: (messages.swapDenomination ?? en.swapDenomination), options: [{ value: 'usd', label: (messages.swapDollars ?? en.swapDollars) }, { value: 'token', label: (messages.swapUnits ?? en.swapUnits) }], value: denomination, onValueChange: value => onDenominationChange(value) }), onSlippageChange && slippageRow, feesRow, children] }), view === 'slippage' && onSlippageChange && _jsxs("div", { className: 'hig-swap-settings hig-swap-presets', children: [_jsx(SegmentedControl, { label: (messages.swapSlippageTitle ?? en.swapSlippageTitle), options: slippagePresets.map(value => ({ value: String(value), label: formatPercent(value) })), value: preset === undefined ? '' : String(preset), onValueChange: value => { setCustom(null); onSlippageChange(Number(value)); } }), _jsx(Field, { label: (messages.swapSlippageCustom ?? en.swapSlippageCustom), children: _jsx(Input, { inputMode: 'decimal', value: custom ?? String(Number((slippage * 100).toFixed(4))), onChange: event => { const raw = event.target.value.replace(/[^0-9.]/g, ''); setCustom(raw); const percent = Number.parseFloat(raw); if (Number.isFinite(percent) && percent >= 0 && percent <= 50)
22
22
  onSlippageChange(percent / 100); } }) })] }), view === 'fees' && _jsxs("dl", { className: 'hig-swap-fees', children: [fees?.map(item => _jsxs("div", { children: [_jsx("dt", { children: item.label }), _jsx("dd", { children: _jsx(SwapNumber, { ...usdNumber(item.usd) }) })] }, item.label)), _jsxs("div", { className: 'hig-swap-fees-total', children: [_jsx("dt", { children: (messages.swapFeeTotal ?? en.swapFeeTotal) }), _jsx("dd", { className: 'hig-number', children: feeText })] })] })] });
@@ -23,6 +23,10 @@ export interface SwapToken {
23
23
  caption?: string | SwapFigure;
24
24
  /** Extra text matched by the picker search, such as the contract address. */
25
25
  keywords?: string;
26
+ /** Picker rows: host text after the balance figure, such as ` HYPE`. */
27
+ unitsSuffix?: string;
28
+ /** Picker rows: the second line under the name in place of the chain, for a list that is not about chains. The search still matches the chain. */
29
+ detail?: string;
26
30
  }
27
31
  /** An image URL, or an element the host draws. */
28
32
  export type SwapArtwork = string | React.ReactElement;
@@ -57,6 +61,8 @@ export interface SwapFigure {
57
61
  options?: Intl.NumberFormatOptions;
58
62
  prefix?: string;
59
63
  suffix?: string;
64
+ /** Host-formatted text for `value`, drawn and read in place of Intl's and still moving place by place. Never parsed back. */
65
+ formattedValue?: string;
60
66
  }
61
67
  /** Host text that is either a fixed string or a live figure. */
62
68
  export declare const swapFigure: (text: string | SwapFigure) => string | React.JSX.Element;
@@ -114,7 +120,7 @@ export declare function TokenIcon({ token, size }: {
114
120
  size?: number;
115
121
  }): React.JSX.Element;
116
122
  /** Small capsule action that sits on a card: Max, Test, the slippage setting and the denomination switch. */
117
- export declare function SwapPill({ children, ...props }: React.ButtonHTMLAttributes<HTMLButtonElement>): React.JSX.Element;
123
+ export declare function SwapPill({ children, ...props }: React.ComponentPropsWithRef<'button'>): React.JSX.Element;
118
124
  /** Numeric keypad. Emits `0`–`9`, `.` or `back`. */
119
125
  export declare function SwapKeypad({ onKey, label, deleteLabel }: {
120
126
  onKey: (key: string) => void;
@@ -1,6 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { AnimatedNumberReadout } from '../../animated-number.js';
4
+ import { PressDecoration } from '../../provider.js';
5
+ import { figureProps } from '../../figure.js';
4
6
  /** Artwork in a disc: the URL as an image, the host's element inside a clipped wrapper. */
5
7
  export const swapArt = (icon, className, lazy) => typeof icon === 'string' ? _jsx("img", { className: className, src: icon, alt: '', loading: lazy ? 'lazy' : undefined }) : _jsx("span", { className: `hig-swap-art${className ? ` ${className}` : ''}`, "aria-hidden": 'true', children: icon });
6
8
  export function swapAction(from, to) {
@@ -59,7 +61,7 @@ export function SwapNumber({ template, ...number }) {
59
61
  return _jsxs("span", { children: [before, _jsx(AnimatedNumberReadout, { ...number }), after] });
60
62
  }
61
63
  /** Host text that is either a fixed string or a live figure. */
62
- export const swapFigure = (text) => typeof text === 'string' ? text : _jsx(SwapNumber, { value: text.value, options: text.options, prefix: text.prefix, suffix: text.suffix });
64
+ export const swapFigure = (text) => typeof text === 'string' ? text : _jsx(SwapNumber, { ...figureProps(text) });
63
65
  /** `SwapNumber` props for a dollar amount and for a slippage fraction (0.005 reads `0.5%`). */
64
66
  export const usdNumber = (value) => ({ value, options: { style: 'currency', currency: 'USD' } });
65
67
  export const percentNumber = (fraction) => ({ value: Number((fraction * 100).toFixed(4)), suffix: '%', options: { maximumFractionDigits: 4, useGrouping: false } });
@@ -108,11 +110,11 @@ export function TokenIcon({ token, size = 44 }) {
108
110
  return _jsxs("span", { className: 'hig-swap-token-icon', style: { width: size, height: size }, children: [token.icon ? swapArt(token.icon, undefined, true) : _jsx("span", { "aria-hidden": 'true', children: token.symbol.slice(0, 3) }), token.chainIcon && swapArt(token.chainIcon, chainBadge, true)] });
109
111
  }
110
112
  /** Small capsule action that sits on a card: Max, Test, the slippage setting and the denomination switch. */
111
- export function SwapPill({ children, ...props }) { return _jsx("button", { type: 'button', ...props, className: 'hig-swap-pill', children: children }); }
113
+ export function SwapPill({ children, ...props }) { return _jsxs("button", { type: 'button', ...props, className: 'hig-swap-pill', children: [children, _jsx(PressDecoration, { kind: 'button', disabled: !!props.disabled })] }); }
112
114
  const keys = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '0', 'back'];
113
115
  /** Numeric keypad. Emits `0`–`9`, `.` or `back`. */
114
116
  export function SwapKeypad({ onKey, label, deleteLabel }) {
115
- return _jsx("div", { className: 'hig-swap-keypad', role: 'group', "aria-label": label, children: keys.map(key => _jsx("button", { type: 'button', className: 'hig-swap-key', "aria-label": key === 'back' ? deleteLabel : undefined, onClick: () => onKey(key), children: key === 'back' ? _jsx(SwapIcon, { name: 'delete', size: 24 }) : key }, key)) });
117
+ return _jsx("div", { className: 'hig-swap-keypad', role: 'group', "aria-label": label, children: keys.map(key => _jsxs("button", { type: 'button', className: 'hig-swap-key', "aria-label": key === 'back' ? deleteLabel : undefined, onClick: () => onKey(key), children: [key === 'back' ? _jsx(SwapIcon, { name: 'delete', size: 24 }) : key, _jsx(PressDecoration, { kind: 'button' })] }, key)) });
116
118
  }
117
119
  /** Chains present in a token list, in first-seen order. */
118
120
  export function chainsOf(tokens) { const seen = new Map(); for (const token of tokens)
@@ -122,5 +124,5 @@ export function chainsOf(tokens) { const seen = new Map(); for (const token of t
122
124
  export const parentView = (view) => view === 'slippage' || view === 'fees' ? 'settings' : 'main';
123
125
  /** Header of a pushed view: Back on the leading edge, then the title, which takes focus when the view arrives. */
124
126
  export function SwapViewHeader({ title, titleRef, backLabel, onBack }) {
125
- return _jsxs("div", { className: 'hig-swap-view-header', children: [_jsx("button", { type: 'button', className: 'hig-swap-back', "aria-label": backLabel, onClick: onBack, children: _jsx(SwapIcon, { name: 'back' }) }), _jsx("h2", { ref: titleRef, tabIndex: -1, className: 'hig-swap-view-title', children: title })] });
127
+ return _jsxs("div", { className: 'hig-swap-view-header', children: [_jsxs("button", { type: 'button', className: 'hig-swap-back', "aria-label": backLabel, onClick: onBack, children: [_jsx(SwapIcon, { name: 'back' }), _jsx(PressDecoration, { kind: 'back' })] }), _jsx("h2", { ref: titleRef, tabIndex: -1, className: 'hig-swap-view-title', children: title })] });
126
128
  }
@@ -31,6 +31,8 @@ export interface SwapDetail {
31
31
  options?: Intl.NumberFormatOptions;
32
32
  prefix?: string;
33
33
  suffix?: string;
34
+ /** With a number `value`: host-formatted text drawn and read in place of Intl's, still moving place by place. */
35
+ formattedValue?: string;
34
36
  }
35
37
  /** The receive view: the host's address and its rendered QR code. HIG ships no QR encoder. */
36
38
  export interface SwapReceive {