@bloxwap/hig 0.5.1 → 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.
- package/README.md +1 -1
- package/chart/README.md +1 -1
- package/contracts/README.md +1 -1
- package/contracts/dist/messages.d.ts +31 -4
- package/contracts/dist/messages.js +11 -2
- package/feedback/README.md +1 -1
- package/native/README.md +1 -1
- package/native/dist/account-block.d.ts +46 -0
- package/native/dist/account-block.js +28 -0
- package/native/dist/asset-balance-row.d.ts +20 -0
- package/native/dist/asset-balance-row.js +21 -0
- package/native/dist/bar-mark.d.ts +45 -0
- package/native/dist/bar-mark.js +34 -0
- package/native/dist/bar-pnl.d.ts +50 -0
- package/native/dist/bar-pnl.js +59 -0
- package/native/dist/blocks.d.ts +44 -0
- package/native/dist/{recipes.js → blocks.js} +20 -9
- package/native/dist/field.d.ts +0 -1
- package/native/dist/field.js +0 -1
- package/native/dist/icons.d.ts +8 -0
- package/native/dist/icons.js +4 -0
- package/native/dist/language-block.d.ts +31 -0
- package/native/dist/language-block.js +30 -0
- package/native/dist/list-group.d.ts +26 -0
- package/native/dist/list-group.js +27 -0
- package/native/dist/manage-position-block.d.ts +69 -0
- package/native/dist/manage-position-block.js +57 -0
- package/native/dist/notifications-block.d.ts +25 -0
- package/native/dist/notifications-block.js +14 -0
- package/native/dist/pickers.d.ts +13 -5
- package/native/dist/pickers.js +10 -6
- package/native/dist/position-block.d.ts +51 -0
- package/native/dist/position-block.js +21 -0
- package/native/dist/profile-block.d.ts +42 -0
- package/native/dist/profile-block.js +28 -0
- package/native/dist/reward-block.d.ts +83 -0
- package/native/dist/reward-block.js +35 -0
- package/native/dist/setting-header.d.ts +8 -0
- package/native/dist/setting-header.js +11 -0
- package/native/dist/setting-switch.d.ts +18 -0
- package/native/dist/setting-switch.js +17 -0
- package/native/dist/signals-block.d.ts +37 -0
- package/native/dist/signals-block.js +16 -0
- package/native/dist/sound-haptics-block.d.ts +39 -0
- package/native/dist/sound-haptics-block.js +21 -0
- package/native/dist/{swap-panel.d.ts → swap-panel-block.d.ts} +28 -9
- package/native/dist/{swap-panel.js → swap-panel-block.js} +24 -14
- package/native/dist/swap-parts.d.ts +14 -3
- package/native/dist/swap-parts.js +16 -1
- package/native/dist/swap-shared.d.ts +18 -6
- package/native/dist/swap-shared.js +3 -2
- package/native/dist/swap-sheet.d.ts +4 -4
- package/native/dist/swap-sheet.js +4 -4
- package/native/dist/swap-views.d.ts +1 -1
- package/native/dist/swap-views.js +11 -8
- package/native/dist/target-block.d.ts +83 -0
- package/native/dist/target-block.js +61 -0
- package/native/dist/token-action-block.d.ts +39 -0
- package/native/dist/token-action-block.js +20 -0
- package/native/dist/trade-history-detail-block.d.ts +59 -0
- package/native/dist/trade-history-detail-block.js +38 -0
- package/native/dist/trade-history-list-block.d.ts +44 -0
- package/native/dist/trade-history-list-block.js +29 -0
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +246 -41
- package/react/README.md +1 -1
- package/react/dist/asset-balance-row.d.ts +19 -0
- package/react/dist/asset-balance-row.js +10 -0
- package/react/dist/bar-mark.d.ts +35 -0
- package/react/dist/bar-mark.js +21 -0
- package/react/dist/bar-pnl.d.ts +49 -0
- package/react/dist/bar-pnl.js +45 -0
- package/react/dist/blocks/account-block.d.ts +46 -0
- package/react/dist/blocks/account-block.js +27 -0
- package/react/dist/blocks/language-block.d.ts +32 -0
- package/react/dist/blocks/language-block.js +51 -0
- package/react/dist/blocks/manage-position-block.d.ts +67 -0
- package/react/dist/blocks/manage-position-block.js +28 -0
- package/react/dist/blocks/notifications-block.d.ts +23 -0
- package/react/dist/blocks/notifications-block.js +8 -0
- package/react/dist/{recipes → blocks}/pickers.d.ts +12 -4
- package/react/dist/{recipes → blocks}/pickers.js +9 -6
- package/react/dist/blocks/position-block.d.ts +49 -0
- package/react/dist/blocks/position-block.js +14 -0
- package/react/dist/blocks/profile-block.d.ts +48 -0
- package/react/dist/blocks/profile-block.js +15 -0
- package/react/dist/blocks/reward-block.d.ts +81 -0
- package/react/dist/blocks/reward-block.js +24 -0
- package/react/dist/blocks/screen-header.d.ts +9 -0
- package/react/dist/blocks/screen-header.js +12 -0
- package/react/dist/blocks/setting-switch.d.ts +10 -0
- package/react/dist/blocks/setting-switch.js +8 -0
- package/react/dist/blocks/signals-block.d.ts +35 -0
- package/react/dist/blocks/signals-block.js +15 -0
- package/react/dist/blocks/sound-haptics-block.d.ts +37 -0
- package/react/dist/blocks/sound-haptics-block.js +18 -0
- package/react/dist/{recipes → blocks}/swap/picker.d.ts +1 -1
- package/react/dist/{recipes → blocks}/swap/picker.js +4 -4
- package/react/dist/{recipes → blocks}/swap/settings.js +5 -7
- package/react/dist/{recipes → blocks}/swap/shared.d.ts +44 -6
- package/react/dist/{recipes → blocks}/swap/shared.js +25 -5
- package/react/dist/{recipes/swap-panel.d.ts → blocks/swap-panel-block.d.ts} +29 -9
- package/react/dist/{recipes/swap-panel.js → blocks/swap-panel-block.js} +22 -14
- package/react/dist/{recipes → blocks}/swap-sheet.d.ts +4 -4
- package/react/dist/{recipes → blocks}/swap-sheet.js +4 -4
- package/react/dist/blocks/target-block.d.ts +81 -0
- package/react/dist/blocks/target-block.js +65 -0
- package/react/dist/blocks/token-action-block.d.ts +37 -0
- package/react/dist/blocks/token-action-block.js +18 -0
- package/react/dist/{recipes → blocks}/trade-entry.js +2 -2
- package/react/dist/blocks/trade-history-detail-block.d.ts +58 -0
- package/react/dist/blocks/trade-history-detail-block.js +16 -0
- package/react/dist/blocks/trade-history-list-block.d.ts +43 -0
- package/react/dist/blocks/trade-history-list-block.js +21 -0
- package/react/dist/blocks.d.ts +20 -0
- package/react/dist/blocks.js +21 -0
- package/react/dist/field.d.ts +0 -2
- package/react/dist/field.js +0 -2
- package/react/dist/list-group.d.ts +26 -0
- package/react/dist/list-group.js +20 -0
- package/react/dist/styles.css +275 -8
- package/tokens/README.md +1 -1
- package/native/dist/recipes.d.ts +0 -45
- package/react/dist/recipes/activity-list.d.ts +0 -8
- package/react/dist/recipes/activity-list.js +0 -6
- package/react/dist/recipes/balance-card.d.ts +0 -6
- package/react/dist/recipes/balance-card.js +0 -5
- package/react/dist/recipes/code-window.d.ts +0 -4
- package/react/dist/recipes/code-window.js +0 -4
- package/react/dist/recipes.d.ts +0 -10
- package/react/dist/recipes.js +0 -11
- /package/react/dist/{recipes → blocks}/install-command.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/install-command.js +0 -0
- /package/react/dist/{recipes → blocks}/market-row.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/market-row.js +0 -0
- /package/react/dist/{recipes → blocks}/marketing-hero.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/marketing-hero.js +0 -0
- /package/react/dist/{recipes → blocks}/swap/amount-card.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/swap/amount-card.js +0 -0
- /package/react/dist/{recipes → blocks}/swap/settings.d.ts +0 -0
- /package/react/dist/{recipes → blocks}/trade-entry.d.ts +0 -0
|
@@ -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;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { ScreenHeader } from './screen-header.js';
|
|
5
|
+
import { SettingSwitch } from './setting-switch.js';
|
|
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 }) {
|
|
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)) })] });
|
|
11
|
+
}
|
|
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))] });
|
|
15
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** A volume as a few fixed steps. `value` and `options` are fractions: 0.25 reads 25%. */
|
|
3
|
+
export interface SoundVolume {
|
|
4
|
+
/** Names the steps and is drawn above them: Volume. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Defaults to 25%, 50%, 75% and 100%. */
|
|
7
|
+
options?: readonly number[];
|
|
8
|
+
value: number;
|
|
9
|
+
onValueChange: (value: number) => void;
|
|
10
|
+
}
|
|
11
|
+
/** One feedback channel: sound effects, the microphone, haptics, the flash. Every word is host text. */
|
|
12
|
+
export interface SoundSection {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
checked: boolean;
|
|
17
|
+
onCheckedChange: (checked: boolean) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** The device in use, under the switch: iPhone Microphone. */
|
|
20
|
+
source?: string;
|
|
21
|
+
/** A live input level from 0 to 1, drawn as a meter. `null` draws an empty meter. */
|
|
22
|
+
level?: number | null;
|
|
23
|
+
volume?: SoundVolume;
|
|
24
|
+
}
|
|
25
|
+
export interface SoundHapticsBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
26
|
+
/** Heading: Sound & Haptics. */
|
|
27
|
+
title: string;
|
|
28
|
+
/** One card each, in order. A section's source, meter and volume show only while it is on. */
|
|
29
|
+
sections: readonly SoundSection[];
|
|
30
|
+
onBack?: () => void;
|
|
31
|
+
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
32
|
+
headerAction?: React.ReactNode;
|
|
33
|
+
}
|
|
34
|
+
/** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
|
|
35
|
+
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;
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { Button } from '../button.js';
|
|
6
|
+
import { ScreenHeader } from './screen-header.js';
|
|
7
|
+
import { SettingSwitch } from './setting-switch.js';
|
|
8
|
+
const steps = [0.25, 0.5, 0.75, 1], percent = { style: 'percent', maximumFractionDigits: 0 };
|
|
9
|
+
/** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
|
|
10
|
+
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);
|
|
17
|
+
}) })] });
|
|
18
|
+
}
|
|
@@ -22,5 +22,5 @@ export interface SwapPickerProps {
|
|
|
22
22
|
onRecipientChange?: (address: string) => void;
|
|
23
23
|
onScanRecipient?: () => void;
|
|
24
24
|
}
|
|
25
|
-
/** The panel's pushed picker view: a header with Back above the From or To picker
|
|
25
|
+
/** The panel's pushed picker view: a header with Back above the From or To picker block. */
|
|
26
26
|
export declare function SwapPicker({ side, onBack, selected, onSelect, wallet, onConnect, onDisconnect, receiving, onReceivingChange, recipient, onRecipientChange, onScanRecipient, ...list }: SwapPickerProps): React.JSX.Element;
|
|
@@ -3,9 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
4
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
5
|
import { useHIG } from '../../provider.js';
|
|
6
|
-
import {
|
|
6
|
+
import { FromPickerBlock, ToPickerBlock } from '../pickers.js';
|
|
7
7
|
import { SwapViewHeader, shortAddress } from './shared.js';
|
|
8
|
-
/** The panel's pushed picker view: a header with Back above the From or To picker
|
|
8
|
+
/** The panel's pushed picker view: a header with Back above the From or To picker block. */
|
|
9
9
|
export function SwapPicker({ side, onBack, selected, onSelect, wallet, onConnect, onDisconnect, receiving, onReceivingChange, recipient, onRecipientChange, onScanRecipient, ...list }) {
|
|
10
10
|
const { messages } = useHIG();
|
|
11
11
|
const title = side === 'from' ? messages.swapFrom ?? en.swapFrom : messages.swapTo ?? en.swapTo;
|
|
@@ -15,6 +15,6 @@ export function SwapPicker({ side, onBack, selected, onSelect, wallet, onConnect
|
|
|
15
15
|
heading.current?.focus(); }, []);
|
|
16
16
|
const choose = (token) => { onSelect(token); onBack(); };
|
|
17
17
|
return _jsxs("div", { className: 'hig-swap-picker', children: [_jsx(SwapViewHeader, { title: title, titleRef: heading, backLabel: messages.back ?? en.back, onBack: onBack }), side === 'from'
|
|
18
|
-
? _jsx(
|
|
19
|
-
: _jsx(
|
|
18
|
+
? _jsx(FromPickerBlock, { ...list, autoFocus: true, selected: selected, onSelect: choose, wallet: wallet ?? { connected: false }, onConnect: onConnect, onDisconnect: onDisconnect, generateAddress: !!receiving, onGenerateAddressChange: onReceivingChange })
|
|
19
|
+
: _jsx(ToPickerBlock, { ...list, autoFocus: true, selected: selected, onSelect: choose, address: recipient, onAddressChange: onRecipientChange, addressPlaceholder: wallet?.address ? shortAddress(wallet.address) : undefined, onScan: onScanRecipient })] });
|
|
20
20
|
}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
|
-
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
5
4
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
6
5
|
import { useHIG } from '../../provider.js';
|
|
7
6
|
import { Field, Input } from '../../field.js';
|
|
8
7
|
import { SegmentedControl } from '../../selection.js';
|
|
9
|
-
import { SwapIcon, SwapViewHeader, formatPercent } from './shared.js';
|
|
8
|
+
import { SwapIcon, SwapNumber, SwapViewHeader, formatPercent, percentNumber, usdNumber } from './shared.js';
|
|
10
9
|
export const slippagePresets = [0.001, 0.005, 0.01];
|
|
11
10
|
/** The panel's settings as pushed views: the list, then slippage and the fee breakdown one level deeper. */
|
|
12
11
|
export function SwapSettings({ view, onViewChange, onBack, denomination, onDenominationChange, slippage, onSlippageChange, fee, fees, quoteLoading, children }) {
|
|
13
|
-
const { messages
|
|
12
|
+
const { messages } = useHIG();
|
|
14
13
|
const heading = useRef(null);
|
|
15
14
|
useEffect(() => { heading.current?.focus(); }, [view]);
|
|
16
|
-
const usd = (value) => formatNumber(value, locale, { style: 'currency', currency: 'USD' });
|
|
17
15
|
const [custom, setCustom] = useState(null);
|
|
18
16
|
const title = view === 'slippage' ? (messages.swapSlippageTitle ?? en.swapSlippageTitle) : view === 'fees' ? (messages.swapFees ?? en.swapFees) : (messages.swapSettings ?? en.swapSettings);
|
|
19
|
-
const feeText = quoteLoading ? '…' : fee != null ?
|
|
17
|
+
const feeText = quoteLoading ? '…' : fee != null ? _jsx(SwapNumber, { ...usdNumber(fee) }) : '—';
|
|
20
18
|
const preset = slippagePresets.find(value => Math.abs(value - slippage) < 1e-9);
|
|
21
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 })] })] });
|
|
22
|
-
const slippageRow = row(messages.swapSlippageTitle ?? en.swapSlippageTitle,
|
|
20
|
+
const slippageRow = row(messages.swapSlippageTitle ?? en.swapSlippageTitle, _jsx(SwapNumber, { ...percentNumber(slippage) }), 'slippage'), feesRow = row(messages.swapFees ?? en.swapFees, feeText, 'fees');
|
|
23
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)
|
|
24
|
-
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", {
|
|
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 })] })] })] });
|
|
25
23
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type AnimatedNumberProps } from '../../animated-number.js';
|
|
2
3
|
/** An asset on one chain. The host supplies every value; HIG formats and lays it out. */
|
|
3
4
|
export interface SwapToken {
|
|
4
5
|
/** Unique per asset and chain, for example `${chainId}-${address}`. */
|
|
@@ -8,18 +9,25 @@ export interface SwapToken {
|
|
|
8
9
|
/** Chain display name and identity. Two tokens on the same `chainId` swap; different chains bridge. */
|
|
9
10
|
chain: string;
|
|
10
11
|
chainId: string | number;
|
|
11
|
-
/**
|
|
12
|
-
icon?:
|
|
13
|
-
chainIcon?:
|
|
12
|
+
/** Artwork: an image URL, or the host's own element (an inline SVG, say), which fills the disc. A missing token icon falls back to the symbol's first letters. */
|
|
13
|
+
icon?: SwapArtwork;
|
|
14
|
+
chainIcon?: SwapArtwork;
|
|
15
|
+
/** Most decimal places a token amount may be typed with, for example 6 for USDC. Unlimited when omitted. Dollars always stop at two. */
|
|
16
|
+
decimals?: number;
|
|
14
17
|
/** Holdings in token units, when the host knows them. Enables Max, Test and the balance check. */
|
|
15
18
|
balance?: number | null;
|
|
16
19
|
/** USD per unit, when the host knows it. Enables the dollar and unit conversion. */
|
|
17
20
|
price?: number | null;
|
|
18
21
|
/** Presents the side as an account rather than a token: this line (for example `$22.72 available`) sits under the name, the artwork is a single disc, and only Max is offered. */
|
|
19
|
-
|
|
22
|
+
/** Pass a `SwapFigure` when the amount in it can change while the card is shown, so it updates place by place. */
|
|
23
|
+
caption?: string | SwapFigure;
|
|
20
24
|
/** Extra text matched by the picker search, such as the contract address. */
|
|
21
25
|
keywords?: string;
|
|
22
26
|
}
|
|
27
|
+
/** An image URL, or an element the host draws. */
|
|
28
|
+
export type SwapArtwork = string | React.ReactElement;
|
|
29
|
+
/** Artwork in a disc: the URL as an image, the host's element inside a clipped wrapper. */
|
|
30
|
+
export declare const swapArt: (icon: SwapArtwork, className?: string, lazy?: boolean) => React.JSX.Element;
|
|
23
31
|
export interface SwapChain {
|
|
24
32
|
chainId: string | number;
|
|
25
33
|
name: string;
|
|
@@ -35,10 +43,39 @@ export declare const trimNumber: (value: number, digits?: number) => string;
|
|
|
35
43
|
export declare function sanitizeAmount(raw: string): string;
|
|
36
44
|
/** Token units shown in the active denomination. Dollars floor to the cent so Max never resolves to more than the balance. */
|
|
37
45
|
export declare function unitsToEntry(units: number, mode: SwapDenomination, price: number): string;
|
|
38
|
-
/** Applies one keypad or keyboard key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals. */
|
|
39
|
-
export declare function applyAmountKey(current: string, key: string, mode: SwapDenomination): string;
|
|
46
|
+
/** Applies one keypad or keyboard key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals, token units at `decimals` when given. */
|
|
47
|
+
export declare function applyAmountKey(current: string, key: string, mode: SwapDenomination, decimals?: number): string;
|
|
40
48
|
/** Case-insensitive substring or in-order subsequence match. */
|
|
41
49
|
export declare function fuzzyMatch(query: string, text: string): boolean;
|
|
50
|
+
/** A number in the swap card that can change while it is on screen. It always updates place by place (never by swapping the text), and `template` keeps it inside its localized sentence: `template={messages.swapFee}` renders "Fee " around the moving amount. */
|
|
51
|
+
export declare function SwapNumber({ template, ...number }: AnimatedNumberProps & {
|
|
52
|
+
template?: (value: string) => string;
|
|
53
|
+
}): React.JSX.Element;
|
|
54
|
+
/** A figure the host supplies as a number so it can update place by place: `{value:234.68,options:{style:'currency',currency:'USD'},suffix:' available'}`. */
|
|
55
|
+
export interface SwapFigure {
|
|
56
|
+
value: number;
|
|
57
|
+
options?: Intl.NumberFormatOptions;
|
|
58
|
+
prefix?: string;
|
|
59
|
+
suffix?: string;
|
|
60
|
+
}
|
|
61
|
+
/** Host text that is either a fixed string or a live figure. */
|
|
62
|
+
export declare const swapFigure: (text: string | SwapFigure) => string | React.JSX.Element;
|
|
63
|
+
/** `SwapNumber` props for a dollar amount and for a slippage fraction (0.005 reads `0.5%`). */
|
|
64
|
+
export declare const usdNumber: (value: number | null | undefined) => {
|
|
65
|
+
readonly value: number | null | undefined;
|
|
66
|
+
readonly options: {
|
|
67
|
+
readonly style: 'currency';
|
|
68
|
+
readonly currency: 'USD';
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export declare const percentNumber: (fraction: number) => {
|
|
72
|
+
readonly value: number;
|
|
73
|
+
readonly suffix: '%';
|
|
74
|
+
readonly options: {
|
|
75
|
+
readonly maximumFractionDigits: 4;
|
|
76
|
+
readonly useGrouping: false;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
42
79
|
/** A slippage fraction as a percent string: 0.005 is `0.5%`. */
|
|
43
80
|
export declare const formatPercent: (fraction: number) => string;
|
|
44
81
|
/** A small trial amount: 1% of holdings, capped at about one dollar's worth. */
|
|
@@ -62,6 +99,7 @@ declare const paths: {
|
|
|
62
99
|
flame: React.JSX.Element;
|
|
63
100
|
logout: React.JSX.Element;
|
|
64
101
|
wallet: React.JSX.Element;
|
|
102
|
+
info: React.JSX.Element;
|
|
65
103
|
lock: React.JSX.Element;
|
|
66
104
|
};
|
|
67
105
|
export type SwapIconName = keyof typeof paths;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AnimatedNumberReadout } from '../../animated-number.js';
|
|
4
|
+
/** Artwork in a disc: the URL as an image, the host's element inside a clipped wrapper. */
|
|
5
|
+
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 });
|
|
3
6
|
export function swapAction(from, to) {
|
|
4
7
|
if (!from || !to || from.symbol === to.symbol)
|
|
5
8
|
return 'send';
|
|
@@ -22,8 +25,8 @@ export function unitsToEntry(units, mode, price) {
|
|
|
22
25
|
return trimNumber(units);
|
|
23
26
|
return price > 0 ? String(Math.floor(units * price * 100) / 100) : '0';
|
|
24
27
|
}
|
|
25
|
-
/** Applies one keypad or keyboard key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals. */
|
|
26
|
-
export function applyAmountKey(current, key, mode) {
|
|
28
|
+
/** Applies one keypad or keyboard key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals, token units at `decimals` when given. */
|
|
29
|
+
export function applyAmountKey(current, key, mode, decimals) {
|
|
27
30
|
if (key === 'back')
|
|
28
31
|
return current.length <= 1 ? '0' : current.slice(0, -1);
|
|
29
32
|
if (key === '.')
|
|
@@ -32,7 +35,8 @@ export function applyAmountKey(current, key, mode) {
|
|
|
32
35
|
return current;
|
|
33
36
|
const next = sanitizeAmount(current === '0' ? key : current + key);
|
|
34
37
|
const dot = next.indexOf('.');
|
|
35
|
-
|
|
38
|
+
const limit = mode === 'usd' ? 2 : decimals;
|
|
39
|
+
return limit !== undefined && dot !== -1 && next.length - dot - 1 > limit ? current : next;
|
|
36
40
|
}
|
|
37
41
|
/** Case-insensitive substring or in-order subsequence match. */
|
|
38
42
|
export function fuzzyMatch(query, text) {
|
|
@@ -45,6 +49,20 @@ export function fuzzyMatch(query, text) {
|
|
|
45
49
|
matched++;
|
|
46
50
|
return matched === needle.length;
|
|
47
51
|
}
|
|
52
|
+
const numberMark = '\uE000';
|
|
53
|
+
/** A number in the swap card that can change while it is on screen. It always updates place by place (never by swapping the text), and `template` keeps it inside its localized sentence: `template={messages.swapFee}` renders "Fee " around the moving amount. */
|
|
54
|
+
export function SwapNumber({ template, ...number }) {
|
|
55
|
+
if (!template)
|
|
56
|
+
return _jsx(AnimatedNumberReadout, { ...number });
|
|
57
|
+
const [before, after = ''] = template(numberMark).split(numberMark);
|
|
58
|
+
// One element, so a flex parent spaces the sentence as a single item.
|
|
59
|
+
return _jsxs("span", { children: [before, _jsx(AnimatedNumberReadout, { ...number }), after] });
|
|
60
|
+
}
|
|
61
|
+
/** 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 });
|
|
63
|
+
/** `SwapNumber` props for a dollar amount and for a slippage fraction (0.005 reads `0.5%`). */
|
|
64
|
+
export const usdNumber = (value) => ({ value, options: { style: 'currency', currency: 'USD' } });
|
|
65
|
+
export const percentNumber = (fraction) => ({ value: Number((fraction * 100).toFixed(4)), suffix: '%', options: { maximumFractionDigits: 4, useGrouping: false } });
|
|
48
66
|
/** A slippage fraction as a percent string: 0.005 is `0.5%`. */
|
|
49
67
|
export const formatPercent = (fraction) => `${Number((fraction * 100).toFixed(4))}%`;
|
|
50
68
|
/** A small trial amount: 1% of holdings, capped at about one dollar's worth. */
|
|
@@ -79,13 +97,15 @@ const paths = {
|
|
|
79
97
|
flame: _jsx("path", { d: 'M10 17a5 5 0 0 0 5-5c0-3-2.5-4.5-3-8-2 1-3.5 3-3.5 5.5C7.5 8.5 7 7.5 7 7c-1.5 1.5-2 3-2 5a5 5 0 0 0 5 5Z' }),
|
|
80
98
|
logout: _jsx("path", { d: 'M8 4H5.5A1.5 1.5 0 0 0 4 5.5v9A1.5 1.5 0 0 0 5.5 16H8M12.5 6.5 16 10l-3.5 3.5M16 10H8' }),
|
|
81
99
|
wallet: _jsx("path", { d: 'M3.5 6.5A1.5 1.5 0 0 1 5 5h9.5A1.5 1.5 0 0 1 16 6.5v.75M3.5 6.5v7A1.5 1.5 0 0 0 5 15h10.5a1 1 0 0 0 1-1V8.25a1 1 0 0 0-1-1H5a1.5 1.5 0 0 1-1.5-.75M13.25 11.25v.01' }),
|
|
100
|
+
info: _jsx("path", { d: 'M10 17a7 7 0 1 0 0-14 7 7 0 0 0 0 14ZM10 9.5v4M10 6.5v.01' }),
|
|
82
101
|
lock: _jsx("path", { d: 'M5.5 9h9a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1ZM7 9V6.5a3 3 0 0 1 6 0V9' }),
|
|
83
102
|
};
|
|
84
103
|
/** Outline symbol on a 20 unit grid; decorative, so the control that holds it carries the name. */
|
|
85
104
|
export function SwapIcon({ name, size = 20 }) { return _jsx("svg", { className: 'hig-swap-icon', "aria-hidden": 'true', focusable: 'false', width: size, height: size, viewBox: '0 0 20 20', ...stroke, children: paths[name] }); }
|
|
105
|
+
const chainBadge = 'hig-swap-chain-badge';
|
|
86
106
|
/** Token artwork with its chain badge. */
|
|
87
107
|
export function TokenIcon({ token, size = 44 }) {
|
|
88
|
-
return _jsxs("span", { className: 'hig-swap-token-icon', style: { width: size, height: size }, children: [token.icon ?
|
|
108
|
+
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)] });
|
|
89
109
|
}
|
|
90
110
|
/** Small capsule action that sits on a card: Max, Test, the slippage setting and the denomination switch. */
|
|
91
111
|
export function SwapPill({ children, ...props }) { return _jsx("button", { type: 'button', ...props, className: 'hig-swap-pill', children: children }); }
|
|
@@ -97,7 +117,7 @@ export function SwapKeypad({ onKey, label, deleteLabel }) {
|
|
|
97
117
|
/** Chains present in a token list, in first-seen order. */
|
|
98
118
|
export function chainsOf(tokens) { const seen = new Map(); for (const token of tokens)
|
|
99
119
|
if (!seen.has(token.chainId))
|
|
100
|
-
seen.set(token.chainId, { chainId: token.chainId, name: token.chain, icon: token.chainIcon }); return [...seen.values()]; }
|
|
120
|
+
seen.set(token.chainId, { chainId: token.chainId, name: token.chain, icon: typeof token.chainIcon === 'string' ? token.chainIcon : undefined }); return [...seen.values()]; }
|
|
101
121
|
/** Where Back leads from a pushed view. */
|
|
102
122
|
export const parentView = (view) => view === 'slippage' || view === 'fees' ? 'settings' : 'main';
|
|
103
123
|
/** Header of a pushed view: Back on the leading edge, then the title, which takes focus when the view arrives. */
|
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type SwapWallet } from './swap/picker.js';
|
|
3
3
|
import { type SwapFee } from './swap/settings.js';
|
|
4
|
-
import { type SwapAction, type SwapChain, type SwapDenomination, type SwapToken, type SwapView } from './swap/shared.js';
|
|
5
|
-
export { swapAction, type SwapAction, type SwapChain, type SwapDenomination, type SwapToken, type SwapView } from './swap/shared.js';
|
|
4
|
+
import { type SwapFigure, type SwapAction, type SwapArtwork, type SwapChain, type SwapDenomination, type SwapToken, type SwapView } from './swap/shared.js';
|
|
5
|
+
export { swapAction, type SwapAction, type SwapArtwork, type SwapChain, type SwapDenomination, type SwapToken, type SwapView } from './swap/shared.js';
|
|
6
6
|
export type { SwapWallet } from './swap/picker.js';
|
|
7
7
|
export type { SwapFee } from './swap/settings.js';
|
|
8
8
|
export { SwapAmountCard, type SwapAmountCardProps } from './swap/amount-card.js';
|
|
9
|
-
export { SwapPill, SwapKeypad } from './swap/shared.js';
|
|
9
|
+
export { SwapPill, SwapKeypad, SwapNumber, type SwapFigure } from './swap/shared.js';
|
|
10
10
|
/** A fixed place the assets go, in place of a token the user picks: a wallet, a staking pool, a trading account. Shown as a compact To card with no amount. */
|
|
11
11
|
export interface SwapDestination {
|
|
12
12
|
title: string;
|
|
13
13
|
/** One muted line above the title, such as the chain or a rate. */
|
|
14
14
|
subtitle?: string;
|
|
15
|
-
/**
|
|
16
|
-
icon?:
|
|
15
|
+
/** An image URL or the host's own element. Without one, `address` draws the wallet's colour disc. */
|
|
16
|
+
icon?: SwapArtwork;
|
|
17
17
|
/** A wallet address; shown shortened under the subtitle. */
|
|
18
18
|
address?: string;
|
|
19
19
|
/** Muted trailing text, such as an arrival time or a rate. */
|
|
20
|
-
detail?: string;
|
|
20
|
+
detail?: string | SwapFigure;
|
|
21
21
|
/** Makes the card a button with a trailing chevron, for example to change the recipient. */
|
|
22
22
|
onPress?: () => void;
|
|
23
23
|
/** Still to be chosen: the card shows `title` / `subtitle` as a placeholder and the action stays disabled, asking for a destination. */
|
|
24
24
|
pending?: boolean;
|
|
25
25
|
}
|
|
26
26
|
/** One label and value row of the details card. */
|
|
27
|
+
/** One label and value row. A number `value` is formatted with `options` (plus `prefix` and `suffix`) and updates place by place; pass numbers for anything that can change while the card is shown. A string is drawn as given. */
|
|
27
28
|
export interface SwapDetail {
|
|
28
29
|
label: string;
|
|
29
|
-
value: string;
|
|
30
|
+
value: string | number;
|
|
31
|
+
options?: Intl.NumberFormatOptions;
|
|
32
|
+
prefix?: string;
|
|
33
|
+
suffix?: string;
|
|
30
34
|
}
|
|
31
35
|
/** The receive view: the host's address and its rendered QR code. HIG ships no QR encoder. */
|
|
32
36
|
export interface SwapReceive {
|
|
@@ -34,7 +38,7 @@ export interface SwapReceive {
|
|
|
34
38
|
qr?: React.ReactNode; /** Host clipboard adapter. When set, the whole view copies the address. */
|
|
35
39
|
onCopy?: () => Promise<void> | void;
|
|
36
40
|
}
|
|
37
|
-
export interface
|
|
41
|
+
export interface SwapPanelBlockProps {
|
|
38
42
|
/** Catalog for the To side, and for the From side unless `fromTokens` is given. */
|
|
39
43
|
tokens: readonly SwapToken[];
|
|
40
44
|
/** Assets offered on the From side, typically the connected wallet's holdings. */
|
|
@@ -103,6 +107,18 @@ export interface SwapPanelProps {
|
|
|
103
107
|
lockTo?: boolean;
|
|
104
108
|
/** Names the action when it is ready, in place of Send, Swap or Bridge: for example Stake, Deposit or Withdraw. The host supplies the translated text. */
|
|
105
109
|
actionLabel?: string;
|
|
110
|
+
/** Holds the action for a reason only the host knows: below a minimum, no quote yet, a closed market. The panel's own checks (a token, an amount, the balance) still apply first. */
|
|
111
|
+
actionDisabled?: boolean;
|
|
112
|
+
/** What the held action says, for example “Below minimum”. Without it the action keeps its ready name. */
|
|
113
|
+
actionStatus?: string;
|
|
114
|
+
/** `destructive` for an action that cannot be undone, such as a burn. */
|
|
115
|
+
actionIntent?: 'primary' | 'destructive';
|
|
116
|
+
/** Refuses a key that would take the amount past the From balance, so the entry never reads more than the user holds. */
|
|
117
|
+
limitToBalance?: boolean;
|
|
118
|
+
/** Host content above the From card, such as a pending transfer. */
|
|
119
|
+
banner?: React.ReactNode;
|
|
120
|
+
/** Host content under the action, such as recent activity. */
|
|
121
|
+
footer?: React.ReactNode;
|
|
106
122
|
/** One direction only, top to bottom: the control between the cards becomes a down arrow instead of the flip button, and the pair cannot be exchanged. */
|
|
107
123
|
oneWay?: boolean;
|
|
108
124
|
/** `auto` shows the keypad for a coarse pointer (touch), where there is no hardware keyboard. */
|
|
@@ -124,4 +140,8 @@ export interface SwapPanelProps {
|
|
|
124
140
|
* or token units, token pickers, settings, and one action that names itself from the chosen pair.
|
|
125
141
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
126
142
|
*/
|
|
127
|
-
export declare function
|
|
143
|
+
export declare function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom, defaultTo, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting, onReset, destination, details, note, noteTone, title, onBack, controls, actionIcon, lockFrom, lockTo, actionLabel, actionDisabled, actionStatus, actionIntent, limitToBalance, banner, footer, oneWay: oneWayProp, denominationSwitch, keypad, shortcuts, captureKeyboard, view: viewProp, onViewChange, settings, className, style }: SwapPanelBlockProps): React.JSX.Element;
|
|
144
|
+
/** @deprecated Renamed `SwapPanelBlock`. The old name and the `blocks/swap-panel` and `recipes/swap-panel` import paths keep working until the next major release. */
|
|
145
|
+
export declare const SwapPanel: typeof SwapPanelBlock;
|
|
146
|
+
/** @deprecated Renamed `SwapPanelBlockProps`. */
|
|
147
|
+
export type SwapPanelProps = SwapPanelBlockProps;
|