@bloxwap/hig 0.5.2 → 0.6.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 (138) hide show
  1. package/README.md +1 -1
  2. package/chart/README.md +1 -1
  3. package/contracts/README.md +1 -1
  4. package/contracts/dist/messages.d.ts +31 -4
  5. package/contracts/dist/messages.js +11 -2
  6. package/feedback/README.md +1 -1
  7. package/native/README.md +1 -1
  8. package/native/dist/account-block.d.ts +46 -0
  9. package/native/dist/account-block.js +28 -0
  10. package/native/dist/asset-balance-row.d.ts +20 -0
  11. package/native/dist/asset-balance-row.js +21 -0
  12. package/native/dist/bar-mark.d.ts +45 -0
  13. package/native/dist/bar-mark.js +34 -0
  14. package/native/dist/bar-pnl.d.ts +50 -0
  15. package/native/dist/bar-pnl.js +59 -0
  16. package/native/dist/blocks.d.ts +44 -0
  17. package/native/dist/{recipes.js → blocks.js} +19 -9
  18. package/native/dist/field.d.ts +0 -1
  19. package/native/dist/field.js +0 -1
  20. package/native/dist/icons.d.ts +8 -0
  21. package/native/dist/icons.js +4 -0
  22. package/native/dist/language-block.d.ts +31 -0
  23. package/native/dist/language-block.js +30 -0
  24. package/native/dist/list-group.d.ts +26 -0
  25. package/native/dist/list-group.js +27 -0
  26. package/native/dist/manage-position-block.d.ts +69 -0
  27. package/native/dist/manage-position-block.js +57 -0
  28. package/native/dist/notifications-block.d.ts +25 -0
  29. package/native/dist/notifications-block.js +14 -0
  30. package/native/dist/pickers.d.ts +12 -4
  31. package/native/dist/pickers.js +6 -2
  32. package/native/dist/position-block.d.ts +51 -0
  33. package/native/dist/position-block.js +21 -0
  34. package/native/dist/profile-block.d.ts +42 -0
  35. package/native/dist/profile-block.js +28 -0
  36. package/native/dist/reward-block.d.ts +83 -0
  37. package/native/dist/reward-block.js +35 -0
  38. package/native/dist/setting-header.d.ts +8 -0
  39. package/native/dist/setting-header.js +11 -0
  40. package/native/dist/setting-switch.d.ts +18 -0
  41. package/native/dist/setting-switch.js +17 -0
  42. package/native/dist/signals-block.d.ts +37 -0
  43. package/native/dist/signals-block.js +16 -0
  44. package/native/dist/sound-haptics-block.d.ts +39 -0
  45. package/native/dist/sound-haptics-block.js +21 -0
  46. package/native/dist/{swap-panel.d.ts → swap-panel-block.d.ts} +6 -2
  47. package/native/dist/{swap-panel.js → swap-panel-block.js} +4 -2
  48. package/native/dist/swap-sheet.d.ts +4 -4
  49. package/native/dist/swap-sheet.js +4 -4
  50. package/native/dist/swap-views.d.ts +1 -1
  51. package/native/dist/swap-views.js +4 -4
  52. package/native/dist/target-block.d.ts +83 -0
  53. package/native/dist/target-block.js +61 -0
  54. package/native/dist/token-action-block.d.ts +39 -0
  55. package/native/dist/token-action-block.js +20 -0
  56. package/native/dist/trade-history-detail-block.d.ts +59 -0
  57. package/native/dist/trade-history-detail-block.js +38 -0
  58. package/native/dist/trade-history-list-block.d.ts +44 -0
  59. package/native/dist/trade-history-list-block.js +29 -0
  60. package/native-fonts/README.md +1 -1
  61. package/og-fonts/README.md +1 -1
  62. package/package.json +246 -41
  63. package/react/README.md +1 -1
  64. package/react/dist/asset-balance-row.d.ts +19 -0
  65. package/react/dist/asset-balance-row.js +10 -0
  66. package/react/dist/bar-mark.d.ts +35 -0
  67. package/react/dist/bar-mark.js +21 -0
  68. package/react/dist/bar-pnl.d.ts +49 -0
  69. package/react/dist/bar-pnl.js +45 -0
  70. package/react/dist/blocks/account-block.d.ts +46 -0
  71. package/react/dist/blocks/account-block.js +27 -0
  72. package/react/dist/blocks/language-block.d.ts +32 -0
  73. package/react/dist/blocks/language-block.js +51 -0
  74. package/react/dist/blocks/manage-position-block.d.ts +67 -0
  75. package/react/dist/blocks/manage-position-block.js +28 -0
  76. package/react/dist/blocks/notifications-block.d.ts +23 -0
  77. package/react/dist/blocks/notifications-block.js +8 -0
  78. package/react/dist/{recipes → blocks}/pickers.d.ts +12 -4
  79. package/react/dist/{recipes → blocks}/pickers.js +6 -2
  80. package/react/dist/blocks/position-block.d.ts +49 -0
  81. package/react/dist/blocks/position-block.js +14 -0
  82. package/react/dist/blocks/profile-block.d.ts +48 -0
  83. package/react/dist/blocks/profile-block.js +15 -0
  84. package/react/dist/blocks/reward-block.d.ts +81 -0
  85. package/react/dist/blocks/reward-block.js +24 -0
  86. package/react/dist/blocks/screen-header.d.ts +9 -0
  87. package/react/dist/blocks/screen-header.js +12 -0
  88. package/react/dist/blocks/setting-switch.d.ts +10 -0
  89. package/react/dist/blocks/setting-switch.js +8 -0
  90. package/react/dist/blocks/signals-block.d.ts +35 -0
  91. package/react/dist/blocks/signals-block.js +15 -0
  92. package/react/dist/blocks/sound-haptics-block.d.ts +37 -0
  93. package/react/dist/blocks/sound-haptics-block.js +18 -0
  94. package/react/dist/{recipes → blocks}/swap/picker.d.ts +1 -1
  95. package/react/dist/{recipes → blocks}/swap/picker.js +4 -4
  96. package/react/dist/{recipes → blocks}/swap/shared.d.ts +1 -0
  97. package/react/dist/{recipes → blocks}/swap/shared.js +1 -0
  98. package/react/dist/{recipes/swap-panel.d.ts → blocks/swap-panel-block.d.ts} +6 -2
  99. package/react/dist/{recipes/swap-panel.js → blocks/swap-panel-block.js} +3 -1
  100. package/react/dist/{recipes → blocks}/swap-sheet.d.ts +4 -4
  101. package/react/dist/{recipes → blocks}/swap-sheet.js +4 -4
  102. package/react/dist/blocks/target-block.d.ts +81 -0
  103. package/react/dist/blocks/target-block.js +65 -0
  104. package/react/dist/blocks/token-action-block.d.ts +37 -0
  105. package/react/dist/blocks/token-action-block.js +18 -0
  106. package/react/dist/{recipes → blocks}/trade-entry.js +2 -2
  107. package/react/dist/blocks/trade-history-detail-block.d.ts +58 -0
  108. package/react/dist/blocks/trade-history-detail-block.js +16 -0
  109. package/react/dist/blocks/trade-history-list-block.d.ts +43 -0
  110. package/react/dist/blocks/trade-history-list-block.js +21 -0
  111. package/react/dist/blocks.d.ts +20 -0
  112. package/react/dist/blocks.js +21 -0
  113. package/react/dist/field.d.ts +0 -2
  114. package/react/dist/field.js +0 -2
  115. package/react/dist/list-group.d.ts +26 -0
  116. package/react/dist/list-group.js +20 -0
  117. package/react/dist/styles.css +270 -5
  118. package/tokens/README.md +1 -1
  119. package/native/dist/recipes.d.ts +0 -46
  120. package/react/dist/recipes/activity-list.d.ts +0 -8
  121. package/react/dist/recipes/activity-list.js +0 -6
  122. package/react/dist/recipes/balance-card.d.ts +0 -6
  123. package/react/dist/recipes/balance-card.js +0 -5
  124. package/react/dist/recipes/code-window.d.ts +0 -4
  125. package/react/dist/recipes/code-window.js +0 -4
  126. package/react/dist/recipes.d.ts +0 -10
  127. package/react/dist/recipes.js +0 -11
  128. /package/react/dist/{recipes → blocks}/install-command.d.ts +0 -0
  129. /package/react/dist/{recipes → blocks}/install-command.js +0 -0
  130. /package/react/dist/{recipes → blocks}/market-row.d.ts +0 -0
  131. /package/react/dist/{recipes → blocks}/market-row.js +0 -0
  132. /package/react/dist/{recipes → blocks}/marketing-hero.d.ts +0 -0
  133. /package/react/dist/{recipes → blocks}/marketing-hero.js +0 -0
  134. /package/react/dist/{recipes → blocks}/swap/amount-card.d.ts +0 -0
  135. /package/react/dist/{recipes → blocks}/swap/amount-card.js +0 -0
  136. /package/react/dist/{recipes → blocks}/swap/settings.d.ts +0 -0
  137. /package/react/dist/{recipes → blocks}/swap/settings.js +0 -0
  138. /package/react/dist/{recipes → blocks}/trade-entry.d.ts +0 -0
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ /** One language the host offers. */
3
+ export interface LanguageOption {
4
+ /** Stable id the host switches on, usually a BCP 47 tag such as `pt-BR`. */
5
+ code: string;
6
+ /** The language in its own words: `Français`. */
7
+ name: string;
8
+ /** The language in the reader's words, shown under the name: `French`. Omit it where it would repeat the name. */
9
+ description?: string;
10
+ /** Round artwork, usually a flag: an image URL or a host element. Without it the row shows the first letters of the code. */
11
+ flag?: string | React.ReactElement;
12
+ }
13
+ export interface LanguageBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title' | 'onSelect'> {
14
+ /** Heading. Defaults to the built-in “Language”. */
15
+ title?: string;
16
+ /** Shows Back on the leading edge of the header. */
17
+ onBack?: () => void;
18
+ /** A control on the trailing edge of the header, usually an `IconButton` that closes the sheet. */
19
+ headerAction?: React.ReactNode;
20
+ languages: readonly LanguageOption[];
21
+ /** `code` of the language in use. */
22
+ value?: string | null;
23
+ onSelect: (language: LanguageOption) => void;
24
+ /** Set false to leave out the search field, for a short list. Default `true`. */
25
+ search?: boolean;
26
+ /** With a hardware pointer, focus the search field on mount so typing filters at once. */
27
+ autoFocus?: boolean;
28
+ }
29
+ /** The languages whose name, description or code contains the query, ignoring case and accents. An empty query keeps every language, in the host's order. */
30
+ export declare function filterLanguages(languages: readonly LanguageOption[], query: string): LanguageOption[];
31
+ /** Choose the app's language: a header, a search field, then each language as a row with its flag, its own name over the reader's name for it, and a check on the one in use. */
32
+ export declare function LanguageBlock({ title, onBack, headerAction, languages, value, onSelect, search, autoFocus, className, ...rest }: LanguageBlockProps): React.JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useMemo, useRef, useState } from 'react';
4
+ import * as en from '@bloxwap/hig/contracts/messages';
5
+ import { useHIG } from '../provider.js';
6
+ import { SearchInput } from '../field.js';
7
+ import { ScreenHeader } from './screen-header.js';
8
+ const fold = (text) => text.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase();
9
+ /** The languages whose name, description or code contains the query, ignoring case and accents. An empty query keeps every language, in the host's order. */
10
+ export function filterLanguages(languages, query) {
11
+ const needle = fold(query.trim());
12
+ return needle === '' ? [...languages] : languages.filter(language => fold(`${language.name} ${language.description ?? ''} ${language.code}`).includes(needle));
13
+ }
14
+ const check = _jsx("svg", { className: 'hig-language-check', "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '20', height: '20', fill: 'none', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', children: _jsx("path", { d: 'm4.5 10.5 3.5 3.5 7.5-8' }) });
15
+ /** Choose the app's language: a header, a search field, then each language as a row with its flag, its own name over the reader's name for it, and a check on the one in use. */
16
+ export function LanguageBlock({ title, onBack, headerAction, languages, value = null, onSelect, search = true, autoFocus, className, ...rest }) {
17
+ const { messages } = useHIG();
18
+ const heading = title ?? messages.language ?? en.language;
19
+ const [query, setQuery] = useState('');
20
+ const [active, setActive] = useState(-1);
21
+ const field = useRef(null), list = useRef(null);
22
+ useEffect(() => { if (autoFocus && window.matchMedia?.('(pointer: fine)').matches)
23
+ field.current?.focus(); }, []);
24
+ const rows = useMemo(() => filterLanguages(languages, query), [languages, query]);
25
+ useEffect(() => { setActive(-1); }, [query]);
26
+ useEffect(() => { if (active >= 0)
27
+ list.current?.querySelector('[data-active="true"]')?.scrollIntoView?.({ block: 'nearest' }); }, [active]);
28
+ // From the search field, the arrow keys move through the matches and Enter chooses one: the only match, or the one the arrows reached.
29
+ const onKeyDown = (event) => {
30
+ if (event.key === 'ArrowDown') {
31
+ event.preventDefault();
32
+ setActive(index => Math.min(index + 1, rows.length - 1));
33
+ }
34
+ else if (event.key === 'ArrowUp') {
35
+ event.preventDefault();
36
+ setActive(index => Math.max(index - 1, 0));
37
+ }
38
+ else if (event.key === 'Enter') {
39
+ const choice = rows[active] ?? (rows.length === 1 ? rows[0] : undefined);
40
+ if (choice) {
41
+ event.preventDefault();
42
+ onSelect(choice);
43
+ }
44
+ }
45
+ };
46
+ const label = messages.searchLanguages ?? en.searchLanguages;
47
+ return _jsxs("section", { ...rest, className: `hig-language-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: heading, onBack: onBack, action: headerAction }), search && _jsx(SearchInput, { ref: field, "aria-label": label, placeholder: label, value: query, onChange: event => setQuery(event.target.value), onKeyDown: onKeyDown, enterKeyHint: 'search', autoComplete: 'off', autoCapitalize: 'none', autoCorrect: 'off', spellCheck: false }), rows.length === 0 && _jsx("p", { className: 'hig-swap-empty', role: 'status', children: messages.noResults ?? en.noResults }), rows.length > 0 && _jsx("div", { ref: list, className: 'hig-language-list', role: 'radiogroup', "aria-label": heading, children: rows.map((language, index) => {
48
+ const selected = language.code === value;
49
+ return _jsxs("button", { type: 'button', role: 'radio', "aria-checked": selected, lang: language.code, className: 'hig-language-row', "data-active": index === active || undefined, onClick: () => onSelect(language), children: [_jsx("span", { className: 'hig-language-flag', "aria-hidden": 'true', children: typeof language.flag === 'string' ? _jsx("img", { src: language.flag, alt: '' }) : language.flag ?? language.code.slice(0, 2).toUpperCase() }), _jsxs("span", { className: 'hig-language-text', children: [_jsx("strong", { children: language.name }), language.description && _jsx("span", { lang: '', children: language.description })] }), selected && check] }, language.code);
50
+ }) })] });
51
+ }
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import type { AssetArtwork } from '../asset-balance-row.js';
3
+ /** The words of the block. They are trading terms, so the host supplies them in its own vocabulary and language; HIG ships none. */
4
+ export interface ManagePositionBlockLabels {
5
+ title: string;
6
+ margin: string;
7
+ notional: string;
8
+ liquidation: string;
9
+ /** `99.8% to liquidation`: receives the formatted percent. */
10
+ toLiquidation: (percent: string) => string;
11
+ mark: string;
12
+ entry: string;
13
+ /** Accessible words for the direction arrow. */
14
+ long: string;
15
+ short: string;
16
+ }
17
+ export interface ManagePositionBlockAction {
18
+ id: string;
19
+ label: string;
20
+ onSelect: () => void;
21
+ disabled?: boolean;
22
+ }
23
+ /** The position being managed, shown as the row under the actions. */
24
+ export interface ManagePositionBlockSummary {
25
+ name: string;
26
+ icon?: AssetArtwork;
27
+ /** 40 reads `40×`. */
28
+ leverage?: number;
29
+ /** Size in asset units. */
30
+ size?: number | null;
31
+ /** Profit and loss in dollars. */
32
+ pnl?: number | null;
33
+ /** Profit and loss as a fraction: -0.0025 reads -0.25%. */
34
+ pnlPercent?: number | null;
35
+ }
36
+ export interface ManagePositionBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
37
+ labels: ManagePositionBlockLabels;
38
+ /** Margin mode, the title of the first card: Demo, Cross, Isolated. Without it the title is the margin label. */
39
+ mode?: string;
40
+ side: 'long' | 'short';
41
+ entry: number;
42
+ mark?: number | null;
43
+ liquidation?: number | null;
44
+ margin: number;
45
+ notional: number;
46
+ /** Format of the three prices, such as another currency. They are drawn compact: no extra zeros. */
47
+ priceOptions?: Intl.NumberFormatOptions;
48
+ actions: readonly ManagePositionBlockAction[];
49
+ position?: ManagePositionBlockSummary;
50
+ onBack?: () => void;
51
+ /** A control on the trailing edge of the header, usually an `IconButton`. */
52
+ headerAction?: React.ReactNode;
53
+ }
54
+ /** Distance left before liquidation. `total` is the span from entry to liquidation, `buffer` what remains of it between the mark and liquidation (the whole span while in profit, nothing once past liquidation), `drawdown` the rest, and `share` the buffer as a fraction. Unknown prices, or a liquidation price on the wrong side of entry, give an empty corridor. */
55
+ export declare function positionCorridor({ side, entry, mark, liquidation }: {
56
+ side: 'long' | 'short';
57
+ entry: number;
58
+ mark?: number | null;
59
+ liquidation?: number | null;
60
+ }): {
61
+ total: number;
62
+ buffer: number;
63
+ drawdown: number;
64
+ share: number | null;
65
+ };
66
+ /** Manage one open position: margin against notional (with the share left before liquidation) as a `BarMark` and the liquidation, mark and entry prices as a `BarPnl`, both drawn without a card because they are read-only, the host's actions as one `ListGroup` of rows, and the position itself underneath. */
67
+ export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, onBack, headerAction, className, ...rest }: ManagePositionBlockProps): React.JSX.Element;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { formatNumber } from '@bloxwap/hig/contracts';
4
+ import { useHIG } from '../provider.js';
5
+ import { AnimatedNumberReadout } from '../animated-number.js';
6
+ import { BarMark } from '../bar-mark.js';
7
+ import { BarPnl } from '../bar-pnl.js';
8
+ import { ListGroup, ListRow } from '../list-group.js';
9
+ import { ScreenHeader } from './screen-header.js';
10
+ import { SwapNumber } from './swap/shared.js';
11
+ const usd = { style: 'currency', currency: 'USD' }, known = (value) => value != null && Number.isFinite(value);
12
+ /** Distance left before liquidation. `total` is the span from entry to liquidation, `buffer` what remains of it between the mark and liquidation (the whole span while in profit, nothing once past liquidation), `drawdown` the rest, and `share` the buffer as a fraction. Unknown prices, or a liquidation price on the wrong side of entry, give an empty corridor. */
13
+ export function positionCorridor({ side, entry, mark, liquidation }) {
14
+ if (!known(mark) || !known(liquidation))
15
+ return { total: 0, buffer: 0, drawdown: 0, share: null };
16
+ const span = side === 'long' ? entry - liquidation : liquidation - entry;
17
+ if (!(span > 0))
18
+ return { total: 0, buffer: 0, drawdown: 0, share: null };
19
+ const traveled = side === 'long' ? entry - mark : mark - entry, buffer = Math.max(0, Math.min(span, span - traveled));
20
+ return { total: span, buffer, drawdown: span - buffer, share: buffer / span };
21
+ }
22
+ /** Manage one open position: margin against notional (with the share left before liquidation) as a `BarMark` and the liquidation, mark and entry prices as a `BarPnl`, both drawn without a card because they are read-only, the host's actions as one `ListGroup` of rows, and the position itself underneath. */
23
+ export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, onBack, headerAction, className, ...rest }) {
24
+ const { locale } = useHIG();
25
+ const corridor = positionCorridor({ side, entry, mark, liquidation });
26
+ const pnlTone = !known(position?.pnl) || position.pnl === 0 ? undefined : position.pnl > 0 ? 'up' : 'down';
27
+ return _jsxs("section", { ...rest, className: `hig-manage-position-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction }), _jsxs("div", { className: 'hig-token-bars', children: [_jsx(BarMark, { surface: false, title: mode ?? labels.margin, description: corridor.share === null ? labels.toLiquidation('—') : _jsx(SwapNumber, { template: labels.toLiquidation, value: Number((corridor.share * 100).toFixed(1)), suffix: '%', options: { maximumFractionDigits: 1 } }), elements: [{ id: 'margin', label: labels.margin, value: margin, detail: formatNumber(margin, locale, usd), tone: 'info' }, { id: 'notional', label: labels.notional, value: known(notional) ? Math.max(notional - margin, 0) : 0, detail: known(notional) ? formatNumber(notional, locale, usd) : '—', tone: 'positive' }] }), _jsx(BarPnl, { surface: false, compact: true, side: side, entry: entry, mark: mark, liquidation: liquidation, labels: { liquidation: labels.liquidation, mark: labels.mark, entry: labels.entry }, priceOptions: priceOptions })] }), actions.length > 0 && _jsx(ListGroup, { className: 'hig-manage-actions', children: actions.map(action => _jsx(ListRow, { label: action.label, disabled: action.disabled, onSelect: action.onSelect }, action.id)) }), position && _jsxs("div", { className: 'hig-asset-row hig-position-row', children: [_jsx("span", { className: 'hig-asset-row-icon', "aria-hidden": 'true', children: typeof position.icon === 'string' ? _jsx("img", { src: position.icon, alt: '' }) : position.icon ?? position.name.slice(0, 3) }), _jsxs("span", { className: 'hig-asset-row-identity', children: [_jsx("strong", { children: position.name }), _jsxs("span", { children: [_jsx("span", { className: 'hig-position-side', "data-side": side, "aria-hidden": 'true', children: side === 'long' ? '↑' : '↓' }), _jsx("span", { className: 'hig-sr-only', children: side === 'long' ? labels.long : labels.short }), position.leverage != null && _jsxs("span", { className: 'hig-position-side hig-position-leverage', "data-side": side, children: [" ", formatNumber(position.leverage, locale), "\u00D7"] }), known(position.size) && _jsxs(_Fragment, { children: [" \u00B7 ", _jsx(AnimatedNumberReadout, { value: position.size, options: { maximumFractionDigits: 6 } })] })] })] }), _jsxs("span", { className: 'hig-asset-row-amounts', children: [_jsx("strong", { "data-tone": pnlTone, children: _jsx(AnimatedNumberReadout, { value: position.pnl, options: { ...usd, signDisplay: 'exceptZero', maximumFractionDigits: 4 } }) }), _jsx("span", { children: _jsx(AnimatedNumberReadout, { value: position.pnlPercent, options: { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' } }) })] })] })] });
28
+ }
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ /** One kind of notification. Every word is host text. */
3
+ export interface NotificationsItem {
4
+ id: string;
5
+ label: string;
6
+ description?: string;
7
+ checked: boolean;
8
+ onCheckedChange: (checked: boolean) => void;
9
+ disabled?: boolean;
10
+ /** Why turning it on failed, under the card: Push request timed out. It is announced when it appears. */
11
+ error?: string;
12
+ }
13
+ export interface NotificationsBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
14
+ /** Heading: Notifications. */
15
+ title: string;
16
+ /** One card each, in order. */
17
+ items: readonly NotificationsItem[];
18
+ onBack?: () => void;
19
+ /** A control on the trailing edge of the header, usually an `IconButton`. */
20
+ headerAction?: React.ReactNode;
21
+ }
22
+ /** The notifications the viewer receives: each kind is a card with a switch and a line of explanation, and a failure to turn one on reads under its card. */
23
+ export declare function NotificationsBlock({ title, items, onBack, headerAction, className, ...rest }: NotificationsBlockProps): React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { ScreenHeader } from './screen-header.js';
4
+ import { SettingSwitch } from './setting-switch.js';
5
+ /** The notifications the viewer receives: each kind is a card with a switch and a line of explanation, and a failure to turn one on reads under its card. */
6
+ export function NotificationsBlock({ title, items, onBack, headerAction, className, ...rest }) {
7
+ return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction }), items.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: items.map(item => _jsxs("div", { className: 'hig-notifications-item', children: [_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.error && _jsx("p", { role: 'alert', className: 'hig-setting-error', children: item.error })] }, item.id)) })] });
8
+ }
@@ -22,7 +22,7 @@ export interface PickerListProps {
22
22
  /** With a hardware pointer, focus the search field on mount so typing filters at once. */
23
23
  autoFocus?: boolean;
24
24
  }
25
- export interface FromPickerProps extends PickerListProps {
25
+ export interface FromPickerBlockProps extends PickerListProps {
26
26
  /** The connected wallet. Omit for a list with no wallet row at all. */
27
27
  wallet?: SwapWallet;
28
28
  /** Shows Connect wallet while no wallet is connected. */
@@ -39,8 +39,8 @@ export interface FromPickerProps extends PickerListProps {
39
39
  * the tokens it holds (or a whitelist). With no wallet it offers Connect wallet and a Generate address switch above the list.
40
40
  * The host owns the wallet, the token data and the generated address.
41
41
  */
42
- export declare function FromPicker({ wallet, onConnect, onDisconnect, generateAddress, onGenerateAddressChange, className, ...list }: FromPickerProps): React.JSX.Element;
43
- export interface ToPickerProps extends Partial<PickerListProps> {
42
+ export declare function FromPickerBlock({ wallet, onConnect, onDisconnect, generateAddress, onGenerateAddressChange, className, ...list }: FromPickerBlockProps): React.JSX.Element;
43
+ export interface ToPickerBlockProps extends Partial<PickerListProps> {
44
44
  /** The destination address field. Omit `onAddressChange` to hide it. */
45
45
  address?: string;
46
46
  onAddressChange?: (address: string) => void;
@@ -54,4 +54,12 @@ export interface ToPickerProps extends Partial<PickerListProps> {
54
54
  * Where the assets go. On its own it is a destination address field with a scan button. With `tokens` it adds the
55
55
  * searchable token list, with the chain filter or, with `chainFilter={false}`, without it.
56
56
  */
57
- export declare function ToPicker({ address, onAddressChange, addressPlaceholder, onScan, className, tokens, onSelect, ...list }: ToPickerProps): React.JSX.Element;
57
+ export declare function ToPickerBlock({ address, onAddressChange, addressPlaceholder, onScan, className, tokens, onSelect, ...list }: ToPickerBlockProps): React.JSX.Element;
58
+ /** @deprecated Renamed `FromPickerBlock`. The old name keeps working until the next major release. */
59
+ export declare const FromPicker: typeof FromPickerBlock;
60
+ /** @deprecated Renamed `FromPickerBlockProps`. */
61
+ export type FromPickerProps = FromPickerBlockProps;
62
+ /** @deprecated Renamed `ToPickerBlock`. The old name keeps working until the next major release. */
63
+ export declare const ToPicker: typeof ToPickerBlock;
64
+ /** @deprecated Renamed `ToPickerBlockProps`. */
65
+ export type ToPickerProps = ToPickerBlockProps;
@@ -58,7 +58,7 @@ function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected =
58
58
  * the tokens it holds (or a whitelist). With no wallet it offers Connect wallet and a Generate address switch above the list.
59
59
  * The host owns the wallet, the token data and the generated address.
60
60
  */
61
- export function FromPicker({ wallet, onConnect, onDisconnect, generateAddress = false, onGenerateAddressChange, className, ...list }) {
61
+ export function FromPickerBlock({ wallet, onConnect, onDisconnect, generateAddress = false, onGenerateAddressChange, className, ...list }) {
62
62
  const { messages } = useHIG();
63
63
  const id = useId();
64
64
  const label = messages.swapFrom ?? en.swapFrom;
@@ -70,8 +70,12 @@ export function FromPicker({ wallet, onConnect, onDisconnect, generateAddress =
70
70
  * Where the assets go. On its own it is a destination address field with a scan button. With `tokens` it adds the
71
71
  * searchable token list, with the chain filter or, with `chainFilter={false}`, without it.
72
72
  */
73
- export function ToPicker({ address, onAddressChange, addressPlaceholder, onScan, className, tokens, onSelect, ...list }) {
73
+ export function ToPickerBlock({ address, onAddressChange, addressPlaceholder, onScan, className, tokens, onSelect, ...list }) {
74
74
  const { messages } = useHIG();
75
75
  const label = messages.swapTo ?? en.swapTo;
76
76
  return _jsxs("div", { className: `hig-picker${className ? ` ${className}` : ''}`, role: 'group', "aria-label": label, children: [onAddressChange && _jsxs("div", { className: 'hig-swap-wallet', children: [_jsx(Input, { "aria-label": messages.swapRecipient ?? en.swapRecipient, placeholder: addressPlaceholder ?? messages.swapRecipient ?? en.swapRecipient, value: address ?? '', onChange: event => onAddressChange(event.target.value), autoComplete: 'off', autoCapitalize: 'none', autoCorrect: 'off', spellCheck: false }), onScan && _jsx(IconButton, { intent: 'secondary', label: messages.swapScan ?? en.swapScan, onClick: onScan, children: _jsx(SwapIcon, { name: 'scan' }) })] }), tokens && onSelect && _jsx(TokenList, { ...list, tokens: tokens, onSelect: onSelect, label: label })] });
77
77
  }
78
+ /** @deprecated Renamed `FromPickerBlock`. The old name keeps working until the next major release. */
79
+ export const FromPicker = FromPickerBlock;
80
+ /** @deprecated Renamed `ToPickerBlock`. The old name keeps working until the next major release. */
81
+ export const ToPicker = ToPickerBlock;
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ /** A number the host supplies as a number so it updates place by place: `{value:0.53,options:{style:'currency',currency:'USD'}}`. `null` reads as unknown. */
3
+ export interface PositionBlockFigure {
4
+ value: number | null;
5
+ options?: Intl.NumberFormatOptions;
6
+ prefix?: string;
7
+ suffix?: string;
8
+ }
9
+ /** One line of the summary: Notional, Fee, Liquidation. `value` is host text (`2% of profit`) or a live figure. `tone` colours the value; the default is the text colour. */
10
+ export interface PositionBlockDetail {
11
+ id?: string;
12
+ label: string;
13
+ value: string | PositionBlockFigure;
14
+ tone?: 'positive' | 'negative' | 'muted';
15
+ }
16
+ /** One setting of the position: Size, Leverage, Stop Loss. With `onSelect` the row opens the host's own view and shows a chevron. */
17
+ export interface PositionBlockRow {
18
+ id: string;
19
+ label: string;
20
+ value?: string;
21
+ onSelect?: () => void;
22
+ disabled?: boolean;
23
+ }
24
+ /** The paper trading switch. The host supplies its name, because HIG ships no trading terms. */
25
+ export interface PositionBlockFlag {
26
+ label: string;
27
+ checked: boolean;
28
+ onCheckedChange: (checked: boolean) => void;
29
+ disabled?: boolean;
30
+ }
31
+ export interface PositionBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
32
+ /** Heading: Position. */
33
+ title: string;
34
+ /** The summary under the header, in order. */
35
+ details: readonly PositionBlockDetail[];
36
+ /** One sentence under the summary, such as the minimum margin. */
37
+ note?: string;
38
+ /** Shows the paper trading switch as a row of its own above the settings. */
39
+ paperTrade?: PositionBlockFlag;
40
+ /** The settings, as groups of rows. Each group is one rounded container. */
41
+ groups: readonly (readonly PositionBlockRow[])[];
42
+ /** Shows Close on the trailing edge of the header. */
43
+ onClose?: () => void;
44
+ onBack?: () => void;
45
+ /** A control on the trailing edge of the header in place of Close. */
46
+ headerAction?: React.ReactNode;
47
+ }
48
+ /** The position being opened or edited: a summary of what it costs and where it ends, an optional paper trading switch, and its settings as grouped rows that open the host's own views. */
49
+ export declare function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, className, ...rest }: PositionBlockProps): React.JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as en from '@bloxwap/hig/contracts/messages';
4
+ import { useHIG } from '../provider.js';
5
+ import { Switch } from '../selection.js';
6
+ import { ListGroup, ListRow } from '../list-group.js';
7
+ import { AnimatedNumberReadout } from '../animated-number.js';
8
+ import { ScreenHeader } from './screen-header.js';
9
+ import { SwapIcon } from './swap/shared.js';
10
+ /** The position being opened or edited: a summary of what it costs and where it ends, an optional paper trading switch, and its settings as grouped rows that open the host's own views. */
11
+ export function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, className, ...rest }) {
12
+ const { messages } = useHIG();
13
+ return _jsxs("section", { ...rest, className: `hig-position-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction ?? (onClose && _jsx("button", { type: 'button', className: 'hig-swap-back', "aria-label": messages.close ?? en.close, onClick: onClose, children: _jsx(SwapIcon, { name: 'close' }) })) }), details.length > 0 && _jsx("dl", { className: 'hig-position-details', children: details.map((detail, index) => _jsxs("div", { "data-tone": detail.tone, children: [_jsx("dt", { children: detail.label }), _jsx("dd", { className: 'hig-number', children: typeof detail.value === 'string' ? detail.value : _jsx(AnimatedNumberReadout, { ...detail.value }) })] }, detail.id ?? index)) }), note && _jsx("p", { className: 'hig-position-note', children: note }), (paperTrade || groups.some(group => group.length > 0)) && _jsxs("div", { className: 'hig-position-groups', children: [paperTrade && _jsx(ListGroup, { className: 'hig-position-flag', children: _jsx(ListRow, { label: paperTrade.label, disabled: paperTrade.disabled, trailing: _jsx(Switch, { label: paperTrade.label, checked: paperTrade.checked, disabled: paperTrade.disabled, onCheckedChange: paperTrade.onCheckedChange }) }) }), groups.map((group, index) => group.length > 0 && _jsx(ListGroup, { children: group.map(row => _jsx(ListRow, { label: row.label, value: row.value, onSelect: row.onSelect, disabled: row.disabled }, row.id)) }, index))] })] });
14
+ }
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import type { AssetArtwork } from '../asset-balance-row.js';
3
+ /** One row of a profile section. With `onSelect` it opens something and shows a chevron; with `onCheckedChange` it is a switch. */
4
+ export interface ProfileRow {
5
+ id: string;
6
+ label: string;
7
+ /** Artwork before the label, such as an icon. */
8
+ leading?: React.ReactNode;
9
+ /** Short text on the trailing edge, such as a balance or `Off`. */
10
+ value?: React.ReactNode;
11
+ /** Anything richer on the trailing edge: icons or a `Badge`. */
12
+ trailing?: React.ReactNode;
13
+ onSelect?: () => void;
14
+ disabled?: boolean;
15
+ /** With `onCheckedChange`, the row is a switch: the track trails and the label names it. */
16
+ checked?: boolean;
17
+ onCheckedChange?: (checked: boolean) => void;
18
+ }
19
+ export interface ProfileSection {
20
+ id: string;
21
+ /** Heading above the group, such as Rewards or Settings. */
22
+ title?: string;
23
+ rows: readonly ProfileRow[];
24
+ }
25
+ /** The dot on the avatar: an account mode or state the host names, such as Demo. */
26
+ export interface ProfileStatus {
27
+ /** Read out for the dot. */
28
+ label: string;
29
+ tone?: 'positive' | 'warning' | 'negative' | 'info';
30
+ }
31
+ export interface ProfileBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
32
+ /** The name under the avatar: a display name or a shortened address. */
33
+ name: string;
34
+ /** Colours the avatar when there is no artwork. */
35
+ address?: string;
36
+ /** An image URL or an element the host draws. */
37
+ avatar?: AssetArtwork;
38
+ status?: ProfileStatus;
39
+ /** Shows the edit control after the name. */
40
+ onEditName?: () => void;
41
+ /** Shows the address control on the leading edge of the top bar. */
42
+ onShowAddress?: () => void;
43
+ /** Shows Close on the trailing edge of the top bar. */
44
+ onClose?: () => void;
45
+ sections: readonly ProfileSection[];
46
+ }
47
+ /** A person's profile as one screen: who they are (avatar, status, name), then grouped rows that open their accounts, history, rewards and settings. */
48
+ export declare function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, className, ...rest }: ProfileBlockProps): React.JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as en from '@bloxwap/hig/contracts/messages';
4
+ import { useHIG } from '../provider.js';
5
+ import { IconButton } from '../button.js';
6
+ import { Switch } from '../selection.js';
7
+ import { ListGroup, ListRow } from '../list-group.js';
8
+ import { qrIcon } from './screen-header.js';
9
+ import { SwapIcon, addressGradient } from './swap/shared.js';
10
+ const editIcon = _jsx("svg", { "aria-hidden": 'true', focusable: 'false', viewBox: '0 0 20 20', width: '20', height: '20', fill: 'none', stroke: 'currentColor', strokeWidth: '1.6', strokeLinecap: 'round', strokeLinejoin: 'round', children: _jsx("path", { d: 'M12.5 4.5 15.5 7.5 7.5 15.5H4.5V12.5ZM10.5 15.5H16' }) });
11
+ /** A person's profile as one screen: who they are (avatar, status, name), then grouped rows that open their accounts, history, rewards and settings. */
12
+ export function ProfileBlock({ name, address, avatar, status, onEditName, onShowAddress, onClose, sections, className, ...rest }) {
13
+ const { messages } = useHIG();
14
+ return _jsxs("section", { ...rest, className: `hig-profile-block${className ? ` ${className}` : ''}`, children: [_jsxs("div", { className: 'hig-profile-bar', children: [_jsx("span", { children: onShowAddress && _jsx(IconButton, { intent: 'ghost', label: messages.showAddress ?? en.showAddress, onClick: onShowAddress, children: qrIcon }) }), _jsx("span", { children: onClose && _jsx(IconButton, { intent: 'ghost', label: messages.close ?? en.close, onClick: onClose, children: _jsx(SwapIcon, { name: 'close' }) }) })] }), _jsxs("div", { className: 'hig-profile-identity', children: [_jsxs("span", { className: 'hig-profile-avatar', style: avatar == null && address ? { background: addressGradient(address) } : undefined, children: [_jsx("span", { className: 'hig-profile-artwork', "aria-hidden": 'true', children: typeof avatar === 'string' ? _jsx("img", { src: avatar, alt: '' }) : avatar ?? (address ? null : name.slice(0, 2)) }), status && _jsx("span", { className: 'hig-profile-status', "data-tone": status.tone ?? 'warning', children: _jsx("span", { className: 'hig-sr-only', children: status.label }) })] }), _jsxs("div", { className: 'hig-profile-name', children: [_jsx("h2", { children: name }), onEditName && _jsx(IconButton, { intent: 'ghost', label: messages.editName ?? en.editName, onClick: onEditName, children: editIcon })] })] }), sections.filter(section => section.rows.length > 0).map(section => _jsx(ListGroup, { title: section.title, children: section.rows.map(row => _jsx(ListRow, { label: row.label, leading: row.leading, value: row.value, disabled: row.disabled, onSelect: row.onCheckedChange ? undefined : row.onSelect, trailing: row.onCheckedChange ? _jsx(Switch, { label: row.label, checked: !!row.checked, disabled: row.disabled, onCheckedChange: row.onCheckedChange }) : row.trailing }, row.id)) }, section.id))] });
15
+ }
@@ -0,0 +1,81 @@
1
+ import React from 'react';
2
+ import type { AssetArtwork } from '../asset-balance-row.js';
3
+ /** The promotion above the standings: a prize pool filling towards a goal, or a draw with a top prize. Every word is host text. */
4
+ export interface RewardPromo {
5
+ /** The small capitals line: Season 01. */
6
+ eyebrow: string;
7
+ /** A text link with a chevron on the trailing edge of the eyebrow: Rules. */
8
+ rules?: {
9
+ label: string;
10
+ onSelect: () => void;
11
+ };
12
+ /** The headline figure: the pool so far, or the top prize. `null` reads as unknown. */
13
+ amount: number | null;
14
+ /** Format of `amount` and `goal`. Defaults to whole US dollars. */
15
+ amountOptions?: Intl.NumberFormatOptions;
16
+ /** The amount the pool is filling towards. Draws the progress bar under the caption. */
17
+ goal?: number;
18
+ /** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given: top prize. */
19
+ caption?: string | ((goal: string) => string);
20
+ /** The lead of the explaining sentence, in the text colour: Top 100 traders split the pool. */
21
+ headline?: string;
22
+ /** Continues the sentence after the headline in the muted colour: Funded by builder fees on every trade. */
23
+ description?: string;
24
+ /** A quiet row under a hairline at the foot of the card, with a chevron on its trailing edge: Draws and winners. The host opens its own destination. */
25
+ action?: {
26
+ label: string;
27
+ onSelect: () => void;
28
+ };
29
+ }
30
+ /** One trader in the standings. */
31
+ export interface RewardEntry {
32
+ id: string;
33
+ rank: number;
34
+ /** A short address, a handle, or the host's word for the viewer. */
35
+ name: string;
36
+ /** An image URL or a host element. Without one the first letters of the name are shown. */
37
+ avatar?: AssetArtwork;
38
+ /** Shows the verified mark after the name. */
39
+ verified?: boolean;
40
+ /** The line under the name: `$1,090,779 vol`. */
41
+ detail?: string;
42
+ /** Points or entries. `null` reads as unknown. */
43
+ score: number | null;
44
+ /** Marks the viewer's own row: the name and score take the action colour. */
45
+ you?: boolean;
46
+ }
47
+ export interface RewardBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
48
+ /** Heading: Leaderboard. */
49
+ title: string;
50
+ promo?: RewardPromo;
51
+ /** A choice between standings, such as Upcoming draw and Top winners. `label` names the control and is not drawn. */
52
+ tabs?: {
53
+ label: string;
54
+ options: readonly {
55
+ value: string;
56
+ label: string;
57
+ }[];
58
+ value: string;
59
+ onValueChange: (value: string) => void;
60
+ };
61
+ /** The viewer's own standing, pinned above the list on a tinted row. */
62
+ you?: RewardEntry;
63
+ /** The column heading over the names: Top 25 by volume. */
64
+ listTitle?: string;
65
+ /** The column heading over the scores: Entries. */
66
+ scoreTitle?: string;
67
+ entries: readonly RewardEntry[];
68
+ /** Format of every score. Defaults to a whole number. */
69
+ scoreOptions?: Intl.NumberFormatOptions;
70
+ /** Accessible name of the verified mark. The mark is decorative without it. */
71
+ verifiedLabel?: string;
72
+ /** A line under the list: Entries are provisional until audited. */
73
+ footnote?: string;
74
+ onBack?: () => void;
75
+ /** A control on the trailing edge of the header, usually an `IconButton` that shares. */
76
+ headerAction?: React.ReactNode;
77
+ }
78
+ /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
79
+ export declare function rewardProgress(amount: number | null | undefined, goal: number | null | undefined): number | null;
80
+ /** 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. */
81
+ export declare function RewardBlock({ title, promo, tabs, you, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, footnote, onBack, headerAction, className, ...rest }: RewardBlockProps): React.JSX.Element;
@@ -0,0 +1,24 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { formatNumber } from '@bloxwap/hig/contracts';
4
+ import { useHIG } from '../provider.js';
5
+ import { SegmentedControl } from '../selection.js';
6
+ import { AnimatedNumberReadout } from '../animated-number.js';
7
+ import { ScreenHeader } from './screen-header.js';
8
+ import { SwapIcon } from './swap/shared.js';
9
+ const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }, whole = { maximumFractionDigits: 0 };
10
+ /** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
11
+ export function rewardProgress(amount, goal) {
12
+ return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
13
+ }
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
+ }
18
+ /** 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();
21
+ 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 })] });
24
+ }
@@ -0,0 +1,9 @@
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 }: {
4
+ title: string;
5
+ onBack?: () => void;
6
+ action?: React.ReactNode;
7
+ }): React.JSX.Element;
8
+ /** The QR glyph of a control that shows an address. */
9
+ export declare const qrIcon: React.JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as en from '@bloxwap/hig/contracts/messages';
4
+ import { useHIG } from '../provider.js';
5
+ 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 }) {
8
+ 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 })] });
10
+ }
11
+ /** The QR glyph of a control that shows an address. */
12
+ 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' })] });
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export interface SettingSwitchProps {
3
+ label: string;
4
+ description?: string;
5
+ checked: boolean;
6
+ onCheckedChange: (checked: boolean) => void;
7
+ disabled?: boolean;
8
+ }
9
+ /** 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;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId } from 'react';
4
+ /** 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
+ 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
+ }
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ /** One signal the viewer can turn on. */
3
+ export interface SignalsItem {
4
+ id: string;
5
+ label: string;
6
+ description?: string;
7
+ checked: boolean;
8
+ onCheckedChange: (checked: boolean) => void;
9
+ disabled?: boolean;
10
+ }
11
+ /** A family of signals under one heading: Trend, Swing. Every word is host text. */
12
+ export interface SignalsGroup {
13
+ id: string;
14
+ title: string;
15
+ /** Shows the verified mark after the title. */
16
+ verified?: boolean;
17
+ /** A small pill on the trailing edge of the heading: How it works. The host opens its own explanation. */
18
+ help?: {
19
+ label: string;
20
+ onSelect: () => void;
21
+ };
22
+ items: readonly SignalsItem[];
23
+ }
24
+ export interface SignalsBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
25
+ /** Heading: Signals. */
26
+ title: string;
27
+ groups: readonly SignalsGroup[];
28
+ /** Accessible name of the verified mark. The mark is decorative without it. */
29
+ verifiedLabel?: string;
30
+ onBack?: () => void;
31
+ /** A control on the trailing edge of the header, usually an `IconButton`. */
32
+ headerAction?: React.ReactNode;
33
+ }
34
+ /** 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;