@bloxwap/hig 0.8.1 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/chart/README.md +3 -4
- package/chart/dist/altimeter-burst.d.ts +2 -2
- package/chart/dist/altimeter-burst.js +8 -7
- package/chart/dist/altimeter-chart.d.ts +13 -3
- package/chart/dist/altimeter-chart.js +37 -12
- package/chart/dist/altimeter-core.d.ts +21 -0
- package/chart/dist/altimeter-core.js +13 -0
- package/chart/dist/altimeter-targets.d.ts +3 -2
- package/chart/dist/altimeter-targets.js +7 -7
- package/chart/dist/index.d.ts +2 -2
- package/chart/dist/outcome-chart.d.ts +4 -2
- package/chart/dist/outcome-chart.js +9 -6
- package/chart/dist/outcome-model.d.ts +14 -1
- package/chart/dist/outcome-model.js +12 -4
- package/contracts/README.md +1 -1
- package/contracts/dist/login.d.ts +34 -0
- package/contracts/dist/login.js +43 -0
- package/contracts/dist/messages.d.ts +1 -1
- package/feedback/README.md +1 -1
- package/native/README.md +1 -1
- package/native/dist/address-readout.d.ts +9 -0
- package/native/dist/address-readout.js +22 -0
- package/native/dist/animated-number.js +3 -1
- package/native/dist/blocks.d.ts +5 -2
- package/native/dist/blocks.js +5 -2
- package/native/dist/chart.d.ts +20 -0
- package/native/dist/chart.js +161 -0
- package/native/dist/claim-reward-block.d.ts +22 -0
- package/native/dist/claim-reward-block.js +16 -0
- package/native/dist/confirm-block.d.ts +1 -5
- package/native/dist/confirm-block.js +5 -16
- package/native/dist/data.d.ts +1 -1
- package/native/dist/data.js +3 -1
- package/native/dist/deposit-block.d.ts +19 -0
- package/native/dist/deposit-block.js +20 -0
- package/native/dist/gesture-sheet.js +1 -1
- package/native/dist/language-block.js +1 -1
- package/native/dist/login-block.d.ts +4 -0
- package/native/dist/login-block.js +22 -0
- package/native/dist/manage-position-block.d.ts +7 -0
- package/native/dist/manage-position-block.js +29 -28
- package/native/dist/modal-radius.d.ts +2 -0
- package/native/dist/modal-radius.js +2 -0
- package/native/dist/overlay.d.ts +6 -2
- package/native/dist/overlay.js +7 -5
- package/native/dist/positions-block.d.ts +28 -0
- package/native/dist/positions-block.js +15 -0
- package/native/dist/screen-header.d.ts +3 -1
- package/native/dist/screen-header.js +2 -2
- package/native/dist/status.js +3 -2
- package/native/dist/{swap-panel-block.d.ts → swap-block.d.ts} +10 -6
- package/native/dist/{swap-panel-block.js → swap-block.js} +5 -3
- package/native/dist/swap-sheet.d.ts +3 -3
- package/native/dist/swap-sheet.js +3 -3
- package/native/dist/token-action-block.d.ts +1 -1
- package/native/dist/token-action-block.js +2 -1
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +76 -21
- package/react/README.md +1 -1
- package/react/dist/blocks/address-readout.d.ts +9 -0
- package/react/dist/blocks/address-readout.js +16 -0
- package/react/dist/blocks/claim-reward-block.d.ts +22 -0
- package/react/dist/blocks/claim-reward-block.js +10 -0
- package/react/dist/blocks/confirm-block.d.ts +1 -5
- package/react/dist/blocks/confirm-block.js +3 -13
- package/react/dist/blocks/deposit-block.d.ts +19 -0
- package/react/dist/blocks/deposit-block.js +18 -0
- package/react/dist/blocks/login-block.d.ts +16 -0
- package/react/dist/blocks/login-block.js +29 -0
- package/react/dist/blocks/manage-position-block.d.ts +7 -0
- package/react/dist/blocks/manage-position-block.js +9 -4
- package/react/dist/blocks/positions-block.d.ts +28 -0
- package/react/dist/blocks/positions-block.js +14 -0
- package/react/dist/blocks/{swap-panel-block.d.ts → swap-block.d.ts} +10 -6
- package/react/dist/blocks/{swap-panel-block.js → swap-block.js} +5 -3
- package/react/dist/blocks/swap-sheet.d.ts +3 -3
- package/react/dist/blocks/swap-sheet.js +3 -3
- package/react/dist/blocks/token-action-block.d.ts +1 -1
- package/react/dist/blocks/token-action-block.js +2 -1
- package/react/dist/blocks.d.ts +5 -2
- package/react/dist/blocks.js +5 -2
- package/react/dist/gesture-sheet.js +6 -2
- package/react/dist/overlay.d.ts +1 -29
- package/react/dist/overlay.js +3 -31
- package/react/dist/popover.d.ts +30 -0
- package/react/dist/popover.js +34 -0
- package/react/dist/styles.css +186 -33
- package/tokens/README.md +1 -1
- package/tokens/assets/onramps/apple-pay.svg +33 -0
- package/tokens/assets/onramps/bank.svg +98 -0
- package/tokens/assets/onramps/blink.svg +37 -0
- package/tokens/assets/onramps/cashapp.svg +33 -0
- package/tokens/assets/onramps/crypto.svg +121 -0
- package/tokens/assets/onramps/exchange.svg +105 -0
- package/tokens/dist/deposit-icons.d.ts +1 -0
- package/tokens/dist/deposit-icons.js +28 -0
- package/native/dist/explainer-block.d.ts +0 -91
- package/native/dist/explainer-block.js +0 -34
- package/react/dist/blocks/explainer-block.d.ts +0 -80
- package/react/dist/blocks/explainer-block.js +0 -20
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** The address as the two rows the block draws: split at the middle, with `anchor` on the characters people compare, the first 4 (6 when it starts with `0x`) and the last 4. An address too short to have a middle is all anchor. */
|
|
3
|
+
export declare function confirmAddressRows(address: string): {
|
|
4
|
+
text: string;
|
|
5
|
+
anchor: boolean;
|
|
6
|
+
}[][];
|
|
7
|
+
export declare function AddressReadout({ address }: {
|
|
8
|
+
address: string;
|
|
9
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** The address as the two rows the block draws: split at the middle, with `anchor` on the characters people compare, the first 4 (6 when it starts with `0x`) and the last 4. An address too short to have a middle is all anchor. */
|
|
3
|
+
export function confirmAddressRows(address) {
|
|
4
|
+
const characters = Array.from(address), head = address.startsWith('0x') ? 6 : 4, tail = characters.length - 4, split = Math.ceil(characters.length / 2);
|
|
5
|
+
return [characters.slice(0, split), characters.slice(split)].map((row, rowIndex) => {
|
|
6
|
+
const parts = [];
|
|
7
|
+
row.forEach((character, index) => { const position = rowIndex * split + index, anchor = position < head || position >= tail, last = parts[parts.length - 1]; if (last && last.anchor === anchor)
|
|
8
|
+
last.text += character;
|
|
9
|
+
else
|
|
10
|
+
parts.push({ text: character, anchor }); });
|
|
11
|
+
return parts;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function AddressReadout({ address }) {
|
|
15
|
+
return _jsxs("span", { className: 'hig-confirm-address', dir: 'ltr', translate: 'no', children: [_jsx("span", { className: 'hig-sr-only', children: address }), _jsx("span", { "aria-hidden": 'true', children: confirmAddressRows(address).map((row, index) => _jsx("span", { children: row.map((part, offset) => _jsx("span", { "data-anchor": part.anchor || undefined, children: part.text }, offset)) }, index)) })] });
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ClaimRewardBlockProps {
|
|
3
|
+
amount: number;
|
|
4
|
+
symbol: string;
|
|
5
|
+
walletAddress: string;
|
|
6
|
+
chain: string;
|
|
7
|
+
details?: readonly {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}[];
|
|
11
|
+
labels: {
|
|
12
|
+
title: string;
|
|
13
|
+
claim: string;
|
|
14
|
+
cancel: string;
|
|
15
|
+
wallet: string;
|
|
16
|
+
chain: string;
|
|
17
|
+
};
|
|
18
|
+
/** Open the host's confirmation screen for this prize. */
|
|
19
|
+
onClaim: () => void;
|
|
20
|
+
onCancel: () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function ClaimRewardBlock({ amount, symbol, walletAddress, chain, details, labels, onClaim, onCancel }: ClaimRewardBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
4
|
+
import { Button } from '../button.js';
|
|
5
|
+
import { ScreenHeader } from './screen-header.js';
|
|
6
|
+
import { AddressReadout } from './address-readout.js';
|
|
7
|
+
export function ClaimRewardBlock({ amount, symbol, walletAddress, chain, details, labels, onClaim, onCancel }) {
|
|
8
|
+
const disabled = !Number.isFinite(amount) || amount <= 0 || !walletAddress.trim() || !chain.trim();
|
|
9
|
+
return _jsxs("section", { className: "hig-confirm", children: [_jsx(ScreenHeader, { title: labels.title }), _jsxs("p", { className: "hig-confirm-amount", children: [_jsx(AnimatedNumberReadout, { value: amount, options: { maximumFractionDigits: 6 } }), " ", _jsx("span", { className: "hig-confirm-symbol", children: symbol })] }), _jsxs("dl", { className: "hig-confirm-details", children: [details?.map(detail => _jsxs("div", { children: [_jsx("dt", { children: detail.label }), _jsx("dd", { children: detail.value })] }, detail.label)), _jsxs("div", { style: { flexWrap: 'wrap' }, children: [_jsx("dt", { children: labels.wallet }), _jsx("dd", { style: { marginInlineStart: 'auto' }, children: _jsx(AddressReadout, { address: walletAddress }) })] }), _jsxs("div", { children: [_jsx("dt", { children: labels.chain }), _jsx("dd", { children: chain })] })] }), _jsxs("div", { className: "hig-confirm-actions", children: [_jsx(Button, { intent: "secondary", onClick: onCancel, children: labels.cancel }), _jsx(Button, { disabled: disabled, onClick: onClaim, children: labels.claim })] })] });
|
|
10
|
+
}
|
|
@@ -82,10 +82,6 @@ export interface ConfirmBlockProps extends Omit<React.HTMLAttributes<HTMLElement
|
|
|
82
82
|
/** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
83
83
|
headingId?: string;
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
export declare function confirmAddressRows(address: string): {
|
|
87
|
-
text: string;
|
|
88
|
-
anchor: boolean;
|
|
89
|
-
}[][];
|
|
85
|
+
export { confirmAddressRows } from './address-readout.js';
|
|
90
86
|
/** The last look before a send: the amount as the headline, where it goes and on which network, a warning that it cannot be taken back, then Cancel and Confirm side by side. Without an amount, address or network it confirms anything else, such as signing out or deleting an account: the header, `children`, then the actions. */
|
|
91
87
|
export declare function ConfirmBlock({ amount, symbol, amountOptions, amountLabel, address, network, details, oneLineDetails, children, points, confirmIntent, tertiaryAction, title, warningTitle, warning, notice, onConfirm, confirmLabel, busy, confirmDisabled, cancelWhileBusy, backWhileBusy, onCancel, cancelLabel, cancelDisabled, confirmTestID, cancelTestID, onBack, backProps, headerAction, stickyHeader, headingId, className, ...rest }: ConfirmBlockProps): React.JSX.Element;
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AddressReadout } from './address-readout.js';
|
|
3
4
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
4
5
|
import { useHIG } from '../provider.js';
|
|
5
6
|
import { Button } from '../button.js';
|
|
6
7
|
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
7
8
|
import { ScreenHeader } from './screen-header.js';
|
|
9
|
+
export { confirmAddressRows } from './address-readout.js';
|
|
8
10
|
const amountFormat = { maximumFractionDigits: 6 };
|
|
9
|
-
/** The address as the two rows the block draws: split at the middle, with `anchor` on the characters people compare, the first 4 (6 when it starts with `0x`) and the last 4. An address too short to have a middle is all anchor. */
|
|
10
|
-
export function confirmAddressRows(address) {
|
|
11
|
-
const characters = Array.from(address), head = address.startsWith('0x') ? 6 : 4, tail = characters.length - 4, split = Math.ceil(characters.length / 2);
|
|
12
|
-
return [characters.slice(0, split), characters.slice(split)].map((row, rowIndex) => {
|
|
13
|
-
const parts = [];
|
|
14
|
-
row.forEach((character, index) => { const position = rowIndex * split + index, anchor = position < head || position >= tail, last = parts[parts.length - 1]; if (last && last.anchor === anchor)
|
|
15
|
-
last.text += character;
|
|
16
|
-
else
|
|
17
|
-
parts.push({ text: character, anchor }); });
|
|
18
|
-
return parts;
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
11
|
/** The last look before a send: the amount as the headline, where it goes and on which network, a warning that it cannot be taken back, then Cancel and Confirm side by side. Without an amount, address or network it confirms anything else, such as signing out or deleting an account: the header, `children`, then the actions. */
|
|
22
12
|
export function ConfirmBlock({ amount, symbol, amountOptions = amountFormat, amountLabel, address, network, details, oneLineDetails, children, points, confirmIntent = 'primary', tertiaryAction, title, warningTitle, warning, notice, onConfirm, confirmLabel, busy, confirmDisabled, cancelWhileBusy, backWhileBusy, onCancel, cancelLabel, cancelDisabled, confirmTestID, cancelTestID, onBack, backProps, headerAction, stickyHeader, headingId, className, ...rest }) {
|
|
23
13
|
const { messages } = useHIG();
|
|
@@ -27,5 +17,5 @@ export function ConfirmBlock({ amount, symbol, amountOptions = amountFormat, amo
|
|
|
27
17
|
const heading = title ?? messages.confirmSend ?? en.confirmSend;
|
|
28
18
|
const body = warning === undefined ? (address !== undefined ? (messages.sendWarning ?? en.sendWarning)(symbol ?? '', network ?? '') : null) : warning;
|
|
29
19
|
const hasLines = address !== undefined || network !== undefined || !!details?.length;
|
|
30
|
-
return _jsxs("section", { ...rest, className: `hig-confirm${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: heading, onBack: onBack, backDisabled: backHeld, backProps: backProps, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), amount !== undefined && _jsxs("p", { className: 'hig-confirm-amount', children: [_jsx(AnimatedNumberReadout, { value: amount, options: amountOptions, label: amountLabel }), symbol ? _jsxs(_Fragment, { children: [" ", _jsx("span", { className: 'hig-confirm-symbol', children: symbol })] }) : null] }), hasLines && _jsxs("dl", { className: 'hig-confirm-details', "data-one-line": oneLineDetails || undefined, children: [address !== undefined && _jsxs("div", { children: [_jsx("dt", { children: messages.sendTo ?? en.sendTo }), _jsx("dd", { children:
|
|
20
|
+
return _jsxs("section", { ...rest, className: `hig-confirm${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: heading, onBack: onBack, backDisabled: backHeld, backProps: backProps, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), amount !== undefined && _jsxs("p", { className: 'hig-confirm-amount', children: [_jsx(AnimatedNumberReadout, { value: amount, options: amountOptions, label: amountLabel }), symbol ? _jsxs(_Fragment, { children: [" ", _jsx("span", { className: 'hig-confirm-symbol', children: symbol })] }) : null] }), hasLines && _jsxs("dl", { className: 'hig-confirm-details', "data-one-line": oneLineDetails || undefined, children: [address !== undefined && _jsxs("div", { children: [_jsx("dt", { children: messages.sendTo ?? en.sendTo }), _jsx("dd", { children: _jsx(AddressReadout, { address: address }) })] }), network !== undefined && _jsxs("div", { children: [_jsx("dt", { children: messages.sendNetwork ?? en.sendNetwork }), _jsx("dd", { children: network })] }), details?.map(detail => _jsxs("div", { children: [_jsx("dt", { children: detail.label }), _jsx("dd", { children: detail.valueLabel ? _jsxs(_Fragment, { children: [_jsx("span", { className: 'hig-sr-only', children: detail.valueLabel }), _jsx("span", { "aria-hidden": 'true', children: detail.value })] }) : detail.value })] }, detail.label))] }), (children != null && children !== false || !!points?.length) && _jsxs("div", { className: 'hig-confirm-body', children: [children, points?.length ? _jsx("ul", { className: 'hig-confirm-points', children: points.map((point, index) => _jsx("li", { children: point }, index)) }) : null] }), body != null && body !== false && _jsxs("div", { className: 'hig-confirm-warning', role: 'note', children: [_jsx("strong", { children: warningTitle ?? messages.sendWarningTitle ?? en.sendWarningTitle }), _jsx("p", { children: body })] }), notice, _jsxs("div", { className: 'hig-confirm-actions', children: [onCancel && _jsx(Button, { intent: 'secondary', disabled: held || cancelDisabled, "data-testid": cancelTestID, onClick: onCancel, children: cancelLabel ?? messages.cancel ?? en.cancel }), _jsx(Button, { intent: confirmIntent, busy: busy, disabled: confirmDisabled, "data-testid": confirmTestID, onClick: onConfirm, children: confirmLabel ?? messages.confirmSend ?? en.confirmSend })] }), tertiaryAction && _jsx(Button, { className: 'hig-confirm-tertiary', "data-tone": tertiaryAction.tone, "data-testid": tertiaryAction.testID, intent: 'ghost', fullWidth: true, disabled: held || tertiaryAction.disabled, onClick: tertiaryAction.onSelect, children: tertiaryAction.label })] });
|
|
31
21
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface DepositMethod {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
/** Optional artwork for a custom method or a replacement for its built-in icon. */
|
|
7
|
+
icon?: React.ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface DepositBlockProps {
|
|
11
|
+
title?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
methods: readonly DepositMethod[];
|
|
14
|
+
onSelect: (method: DepositMethod) => void;
|
|
15
|
+
onBack?: () => void;
|
|
16
|
+
headerAction?: React.ReactNode;
|
|
17
|
+
headingId?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function DepositBlock({ title, description, methods, onSelect, onBack, headerAction, headingId }: DepositBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { QrCode } from '@bloxwap/icons/react/qr-code';
|
|
4
|
+
import { deposit } from '@bloxwap/hig/contracts/messages';
|
|
5
|
+
import { useHIG } from '../provider.js';
|
|
6
|
+
import { ListGroup, ListRow } from '../list-group.js';
|
|
7
|
+
import { ScreenHeader } from './screen-header.js';
|
|
8
|
+
const builtInMethods = new Set(['apple-pay', 'cash-app', 'exchange', 'crypto', 'bank', 'blink']);
|
|
9
|
+
export function DepositBlock({ title, description, methods, onSelect, onBack, headerAction, headingId }) {
|
|
10
|
+
const { messages } = useHIG();
|
|
11
|
+
const qr = methods.find(method => method.id === 'qr');
|
|
12
|
+
const orderedMethods = qr ? [qr, ...methods.filter(method => method.id !== 'qr')] : methods;
|
|
13
|
+
return _jsxs("section", { className: "hig-deposit-block", children: [_jsx(ScreenHeader, { title: title ?? messages.deposit ?? deposit, onBack: onBack, action: headerAction, headingId: headingId }), description && _jsx("p", { className: "hig-settings-description", children: description }), _jsx(ListGroup, { children: orderedMethods.map(method => {
|
|
14
|
+
const leading = method.icon ?? (method.id === 'qr' ? _jsx("span", { "aria-hidden": "true", className: "hig-deposit-qr", children: _jsx(QrCode, { size: 24 }) }) : builtInMethods.has(method.id) &&
|
|
15
|
+
_jsx("span", { "aria-hidden": "true", className: "hig-deposit-icon", "data-method": method.id }));
|
|
16
|
+
return _jsx(ListRow, { leading: leading, label: method.label, description: method.description, disabled: method.disabled, onSelect: () => onSelect(method) }, method.id);
|
|
17
|
+
}) })] });
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type LoginBlockProps as SocialLoginProps, type LoginProvider } from '@bloxwap/hig/contracts/login';
|
|
3
|
+
export type { LoginProvider } from '@bloxwap/hig/contracts/login';
|
|
4
|
+
type WebLoginProvider = LoginProvider | 'email' | 'wallet';
|
|
5
|
+
declare const moreLabels: {
|
|
6
|
+
moreOptions: string;
|
|
7
|
+
email: string;
|
|
8
|
+
wallet: string;
|
|
9
|
+
};
|
|
10
|
+
export interface LoginBlockProps extends Omit<SocialLoginProps, 'lastUsed' | 'labels'> {
|
|
11
|
+
lastUsed?: WebLoginProvider | null;
|
|
12
|
+
labels?: SocialLoginProps['labels'] & Partial<typeof moreLabels>;
|
|
13
|
+
/** Enables the web disclosure and handles its two authentication methods. */
|
|
14
|
+
onMoreLogin?: (provider: 'email' | 'wallet') => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function LoginBlock({ onLogin, onMoreLogin, onClose, lastUsed, disabled, analyticsEnabled, onAnalyticsChange, labels, termsUrl, privacyUrl }: LoginBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useState } from 'react';
|
|
4
|
+
import { ChevronDown } from '@bloxwap/icons/react/chevron-down';
|
|
5
|
+
import { Mail } from '@bloxwap/icons/react/mail';
|
|
6
|
+
import { Wallet } from '@bloxwap/icons/react/wallet';
|
|
7
|
+
import { HeaderClose, ScreenHeader } from './screen-header.js';
|
|
8
|
+
import { Info } from '@bloxwap/icons/react/info';
|
|
9
|
+
import { Button, IconButton } from '../button.js';
|
|
10
|
+
import { Switch } from '../selection.js';
|
|
11
|
+
import { Popover } from '../popover.js';
|
|
12
|
+
import { Badge } from '../status.js';
|
|
13
|
+
import { loginArtwork, loginCopy, loginTermsUrl, loginPrivacyUrl } from '@bloxwap/hig/contracts/login';
|
|
14
|
+
const socialProviders = ['google', 'apple', 'twitter'];
|
|
15
|
+
const additionalProviders = ['email', 'wallet'];
|
|
16
|
+
const moreLabels = { moreOptions: 'More options', email: 'Continue with Email', wallet: 'Connect a wallet' };
|
|
17
|
+
export function LoginBlock({ onLogin, onMoreLogin, onClose, lastUsed, disabled, analyticsEnabled, onAnalyticsChange, labels, termsUrl = loginTermsUrl, privacyUrl = loginPrivacyUrl }) {
|
|
18
|
+
const copy = { ...loginCopy, ...moreLabels, ...labels };
|
|
19
|
+
const [expanded, setExpanded] = useState(lastUsed === 'email' || lastUsed === 'wallet');
|
|
20
|
+
const optionsId = useId();
|
|
21
|
+
const primary = lastUsed ?? 'google';
|
|
22
|
+
function providerButton(provider) {
|
|
23
|
+
const extra = provider === 'email' || provider === 'wallet';
|
|
24
|
+
const icon = provider === 'email' ? _jsx(Mail, { size: 20 }) : provider === 'wallet' ? _jsx(Wallet, { size: 20 }) :
|
|
25
|
+
_jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", children: loginArtwork[provider].map(path => _jsx("path", { d: path.d, fill: path.fill ?? 'currentColor' }, path.d)) });
|
|
26
|
+
return _jsxs(Button, { className: "hig-login-provider", fullWidth: true, disabled: disabled, intent: primary === provider ? 'primary' : 'secondary', onClick: () => extra ? onMoreLogin?.(provider) : onLogin(provider), children: [_jsxs("span", { className: "hig-login-provider-label", children: [_jsx("span", { "aria-hidden": "true", children: icon }), copy[provider]] }), lastUsed === provider && _jsx(Badge, { children: copy.lastUsed })] }, provider);
|
|
27
|
+
}
|
|
28
|
+
return _jsxs("section", { className: "hig-login-block", children: [_jsx(ScreenHeader, { title: copy.title, action: _jsx(HeaderClose, { label: copy.close, onClose: onClose }) }), _jsxs("div", { className: "hig-login-providers", children: [socialProviders.map(providerButton), onMoreLogin && _jsxs(_Fragment, { children: [_jsxs(Button, { intent: "ghost", "aria-expanded": expanded, "aria-controls": optionsId, onClick: () => setExpanded(!expanded), children: [copy.moreOptions, _jsx(ChevronDown, { size: 16, "aria-hidden": "true", style: { transform: expanded ? 'rotate(180deg)' : undefined } })] }), _jsx("div", { id: optionsId, hidden: !expanded, className: "hig-login-extra", children: additionalProviders.map(providerButton) })] })] }), _jsxs("div", { className: "hig-login-analytics", children: [_jsx("span", { children: copy.analytics }), _jsx(Popover, { label: copy.analyticsInfo, closeLabel: copy.close, trigger: _jsx(IconButton, { label: copy.analyticsInfo, intent: "ghost", children: _jsx(Info, { size: 18 }) }), children: _jsx("p", { children: copy.description }) }), _jsx(Switch, { hideLabel: true, label: copy.analytics, checked: analyticsEnabled, onCheckedChange: onAnalyticsChange })] }), _jsxs("footer", { children: [_jsx("a", { href: termsUrl, children: copy.terms }), _jsx("a", { href: privacyUrl, children: copy.privacy })] })] });
|
|
29
|
+
}
|
|
@@ -93,3 +93,10 @@ export declare function positionCorridor({ side, entry, mark, liquidation }: {
|
|
|
93
93
|
};
|
|
94
94
|
/** 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. */
|
|
95
95
|
export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, stickyHeader, className, ...rest }: ManagePositionBlockProps): React.JSX.Element;
|
|
96
|
+
export declare function PositionSummaryRow({ position, side, labels, pnlOptions, disclosure }: {
|
|
97
|
+
position: ManagePositionBlockSummary;
|
|
98
|
+
side: 'long' | 'short';
|
|
99
|
+
labels: Pick<ManagePositionBlockLabels, 'long' | 'short'>;
|
|
100
|
+
pnlOptions?: Intl.NumberFormatOptions;
|
|
101
|
+
disclosure?: boolean;
|
|
102
|
+
}): React.JSX.Element;
|
|
@@ -10,6 +10,7 @@ import { BarMark } from '../bar-mark.js';
|
|
|
10
10
|
import { BarPnl } from '../bar-pnl.js';
|
|
11
11
|
import { ListGroup, ListRow } from '../list-group.js';
|
|
12
12
|
import { ScreenHeader } from './screen-header.js';
|
|
13
|
+
import { ChevronRight } from '@bloxwap/icons/react/chevron-right';
|
|
13
14
|
import { SwapNumber } from './swap/shared.js';
|
|
14
15
|
const usd = { style: 'currency', currency: 'USD' }, known = (value) => value != null && Number.isFinite(value);
|
|
15
16
|
/** 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. */
|
|
@@ -35,13 +36,17 @@ export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidati
|
|
|
35
36
|
const locale = useNumberLocale();
|
|
36
37
|
const present = usePresentNumber();
|
|
37
38
|
const corridor = positionCorridor({ side, entry, mark, liquidation });
|
|
39
|
+
return _jsxs("section", { ...rest, className: `hig-manage-position-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), _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, present(usd)), tone: 'info' }, { id: 'notional', label: labels.notional, value: known(notional) ? Math.max(notional - margin, 0) : 0, detail: known(notional) ? formatNumber(notional, locale, present(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, value: action.value == null ? undefined : _jsx("span", { className: 'hig-manage-action-value', "data-tone": action.tone, children: typeof action.value === 'string' ? action.value : _jsx(AnimatedNumberReadout, { ...figureProps(action.value) }) }) }, action.id)) }), position && _jsx(PositionSummaryRow, { position: position, labels: labels, side: side, pnlOptions: pnlOptions })] });
|
|
40
|
+
}
|
|
41
|
+
export function PositionSummaryRow({ position, side, labels, pnlOptions, disclosure = false }) {
|
|
42
|
+
const locale = useNumberLocale();
|
|
38
43
|
const pnlTone = !known(position?.pnl) || position.pnl === 0 ? undefined : position.pnl > 0 ? 'up' : 'down';
|
|
39
44
|
const pnlFormat = { ...usd, signDisplay: 'exceptZero', maximumFractionDigits: 4, ...pnlOptions };
|
|
40
|
-
const content = (position, ids) => _jsxs(_Fragment, { children: [_jsx(PositionArt, { position: position }), _jsxs("span", { id: ids?.identity, className: 'hig-asset-row-identity', children: [position.badge ? _jsxs("span", { className: 'hig-position-name', children: [_jsx("strong", { children: position.name }), _jsx(Badge, { className: 'hig-position-badge', children: position.badge })] }) : _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", { id: ids?.amounts, className: 'hig-asset-row-amounts', children: [_jsx("strong", { "data-tone": pnlTone, children: _jsx(AnimatedNumberReadout, { value: position.pnl, options: pnlFormat }) }), _jsx("span", { children: _jsx(AnimatedNumberReadout, { value: position.pnlPercent, options: { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' } }) })] })] });
|
|
41
|
-
return
|
|
45
|
+
const content = (position, ids) => _jsxs(_Fragment, { children: [_jsx(PositionArt, { position: position }), _jsxs("span", { id: ids?.identity, className: 'hig-asset-row-identity', children: [position.badge ? _jsxs("span", { className: 'hig-position-name', children: [_jsx("strong", { children: position.name }), _jsx(Badge, { className: 'hig-position-badge', children: position.badge })] }) : _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", { id: ids?.amounts, className: 'hig-asset-row-amounts', children: [_jsx("strong", { "data-tone": pnlTone, children: _jsx(AnimatedNumberReadout, { value: position.pnl, options: pnlFormat }) }), _jsx("span", { children: _jsx(AnimatedNumberReadout, { value: position.pnlPercent, options: { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' } }) })] }), disclosure && position.onSelect && _jsx(ChevronRight, { size: 18, "aria-hidden": true })] });
|
|
46
|
+
return position.onSelect ? _jsx(PositionButton, { position: position, content: content, disclosure: disclosure }) : _jsxs(_Fragment, { children: [_jsx("div", { className: 'hig-asset-row hig-position-row', children: content(position) }), position.caption && _jsx("p", { className: 'hig-position-caption', children: position.caption })] });
|
|
42
47
|
}
|
|
43
48
|
/** The position row as a button: named by the host's label followed by what it shows, so the figures are part of the name, and described by the caption. Without a label it is named by what it shows alone. Its own component, so the ids it needs exist only when it is drawn. */
|
|
44
|
-
function PositionButton({ position, content }) {
|
|
49
|
+
function PositionButton({ position, content, disclosure }) {
|
|
45
50
|
const name = useId(), identity = useId(), amounts = useId(), about = useId();
|
|
46
|
-
return _jsxs(_Fragment, { children: [_jsxs("button", { type: 'button', className: 'hig-asset-row hig-position-row', "aria-labelledby": position.label ? `${name} ${identity} ${amounts}` : undefined, "aria-describedby": position.caption ? about : undefined, onClick: position.onSelect, children: [position.label && _jsxs("span", { id: name, className: 'hig-sr-only', children: [position.label, ","] }), content(position, { identity, amounts }), _jsx(PressDecoration, { kind: 'row' })] }), position.caption && _jsx("p", { id: about, className: 'hig-position-caption', children: position.caption })] });
|
|
51
|
+
return _jsxs(_Fragment, { children: [_jsxs("button", { type: 'button', className: 'hig-asset-row hig-position-row', style: disclosure ? { borderRadius: 0, padding: 16 } : undefined, "aria-labelledby": position.label ? `${name} ${identity} ${amounts}` : undefined, "aria-describedby": position.caption ? about : undefined, onClick: position.onSelect, children: [position.label && _jsxs("span", { id: name, className: 'hig-sr-only', children: [position.label, ","] }), content(position, { identity, amounts }), _jsx(PressDecoration, { kind: 'row' })] }), position.caption && _jsx("p", { id: about, className: 'hig-position-caption', children: position.caption })] });
|
|
47
52
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ManagePositionBlockSummary } from './manage-position-block.js';
|
|
3
|
+
export interface OpenPosition extends Omit<ManagePositionBlockSummary, 'onSelect'> {
|
|
4
|
+
id: string;
|
|
5
|
+
side: 'long' | 'short';
|
|
6
|
+
}
|
|
7
|
+
export interface PositionsBlockProps {
|
|
8
|
+
labels: {
|
|
9
|
+
title: string;
|
|
10
|
+
all: string;
|
|
11
|
+
wins: string;
|
|
12
|
+
losses: string;
|
|
13
|
+
long: string;
|
|
14
|
+
short: string;
|
|
15
|
+
empty: string;
|
|
16
|
+
closeAll: (count: number) => string;
|
|
17
|
+
};
|
|
18
|
+
positions: readonly OpenPosition[];
|
|
19
|
+
onSelect: (position: OpenPosition) => void;
|
|
20
|
+
/** Acts on every open position, including rows hidden by the filter. */
|
|
21
|
+
onCloseAll: () => void;
|
|
22
|
+
closing?: boolean;
|
|
23
|
+
pnlOptions?: Intl.NumberFormatOptions;
|
|
24
|
+
onBack?: () => void;
|
|
25
|
+
headerAction?: React.ReactNode;
|
|
26
|
+
headingId?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function PositionsBlock({ labels, positions, onSelect, onCloseAll, closing, pnlOptions, onBack, headerAction, headingId }: PositionsBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { PositionSummaryRow } from './manage-position-block.js';
|
|
5
|
+
import { ScreenHeader } from './screen-header.js';
|
|
6
|
+
import { ListGroup } from '../list-group.js';
|
|
7
|
+
import { Button } from '../button.js';
|
|
8
|
+
import { SegmentedControl } from '../selection.js';
|
|
9
|
+
export function PositionsBlock({ labels, positions, onSelect, onCloseAll, closing, pnlOptions, onBack, headerAction, headingId }) {
|
|
10
|
+
const [filter, setFilter] = useState('all');
|
|
11
|
+
const options = [{ value: 'all', label: labels.all }, { value: 'wins', label: labels.wins }, { value: 'losses', label: labels.losses }];
|
|
12
|
+
const visible = positions.filter(p => filter === 'all' || (p.pnl != null && Number.isFinite(p.pnl) && (filter === 'wins' ? p.pnl > 0 : p.pnl < 0)));
|
|
13
|
+
return _jsxs("section", { className: 'hig-stack', style: { gap: 16 }, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, headingId: headingId }), _jsx(SegmentedControl, { label: labels.title, hideLabel: true, value: filter, onValueChange: setFilter, options: options }), visible.length > 0 ? _jsx(ListGroup, { children: visible.map(position => _jsx(PositionSummaryRow, { position: { ...position, onSelect: () => onSelect(position) }, side: position.side, labels: labels, pnlOptions: pnlOptions, disclosure: true }, position.id)) }) : _jsx("p", { className: 'hig-position-note', children: labels.empty }), _jsx(Button, { fullWidth: true, intent: 'secondary', disabled: !positions.length, busy: closing, onClick: onCloseAll, children: labels.closeAll(positions.length) })] });
|
|
14
|
+
}
|
|
@@ -40,7 +40,7 @@ export interface SwapReceive {
|
|
|
40
40
|
qr?: React.ReactNode; /** Host clipboard adapter. When set, the whole view copies the address. */
|
|
41
41
|
onCopy?: () => Promise<void> | void;
|
|
42
42
|
}
|
|
43
|
-
export interface
|
|
43
|
+
export interface SwapBlockProps {
|
|
44
44
|
/** Catalog for the To side, and for the From side unless `fromTokens` is given. */
|
|
45
45
|
tokens: readonly SwapToken[];
|
|
46
46
|
/** Assets offered on the From side, typically the connected wallet's holdings. */
|
|
@@ -149,8 +149,12 @@ export interface SwapPanelBlockProps {
|
|
|
149
149
|
* or token units, token pickers, settings, and one action that names itself from the chosen pair.
|
|
150
150
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
151
151
|
*/
|
|
152
|
-
export declare function
|
|
153
|
-
/** @deprecated Renamed `
|
|
154
|
-
export declare const SwapPanel: typeof
|
|
155
|
-
/** @deprecated Renamed `
|
|
156
|
-
export type SwapPanelProps =
|
|
152
|
+
export declare function SwapBlock({ 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, submittingLabel, onReset, destination, details, note, noteTone, title, onBack, headingId, controls, actionIcon, lockFrom, lockTo, actionLabel, actionDisabled, actionStatus, actionIntent, limitToBalance, banner, footer, oneWay: oneWayProp, denominationSwitch, keypad, shortcuts, captureKeyboard, active, view: viewProp, onViewChange, settings, className, style }: SwapBlockProps): React.JSX.Element;
|
|
153
|
+
/** @deprecated Renamed `SwapBlock`. The old name and the `blocks/swap-panel` and `recipes/swap-panel` import paths keep working until the next major release. */
|
|
154
|
+
export declare const SwapPanel: typeof SwapBlock;
|
|
155
|
+
/** @deprecated Renamed `SwapBlockProps`. */
|
|
156
|
+
export type SwapPanelProps = SwapBlockProps;
|
|
157
|
+
/** @deprecated Use SwapBlock. */
|
|
158
|
+
export declare const SwapPanelBlock: typeof SwapBlock;
|
|
159
|
+
/** @deprecated Use SwapBlockProps. */
|
|
160
|
+
export type SwapPanelBlockProps = SwapBlockProps;
|
|
@@ -30,7 +30,7 @@ const amountKey = (event) => event.metaKey || event.ctrlKey || event.altKey ? nu
|
|
|
30
30
|
* or token units, token pickers, settings, and one action that names itself from the chosen pair.
|
|
31
31
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
32
32
|
*/
|
|
33
|
-
export function
|
|
33
|
+
export function SwapBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom = null, defaultTo = null, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage = 0.005, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting = false, submittingLabel, onReset, destination, details, note, noteTone = 'muted', title, onBack, headingId, controls = true, actionIcon, lockFrom = false, lockTo = false, actionLabel, actionDisabled = false, actionStatus, actionIntent = 'primary', limitToBalance = false, banner, footer, oneWay: oneWayProp = false, denominationSwitch = true, keypad = 'auto', shortcuts = true, captureKeyboard = false, active = true, view: viewProp, onViewChange, settings, className, style }) {
|
|
34
34
|
const { messages } = useHIG();
|
|
35
35
|
const locale = useNumberLocale();
|
|
36
36
|
const [from, setFrom] = useControllable(fromProp, defaultFrom, onFromChange);
|
|
@@ -209,5 +209,7 @@ export function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains,
|
|
|
209
209
|
event.stopPropagation();
|
|
210
210
|
} }, "data-view": view, "data-receiving": showReceive || undefined, onKeyDown: onKeyDown, onPaste: onPaste, children: [_jsx("div", { className: 'hig-swap-view', "data-direction": direction, children: body }, view), _jsx("p", { className: 'hig-sr-only', role: 'status', children: copied })] });
|
|
211
211
|
}
|
|
212
|
-
/** @deprecated Renamed `
|
|
213
|
-
export const SwapPanel =
|
|
212
|
+
/** @deprecated Renamed `SwapBlock`. The old name and the `blocks/swap-panel` and `recipes/swap-panel` import paths keep working until the next major release. */
|
|
213
|
+
export const SwapPanel = SwapBlock;
|
|
214
|
+
/** @deprecated Use SwapBlock. */
|
|
215
|
+
export const SwapPanelBlock = SwapBlock;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type
|
|
3
|
-
export interface SwapSheetProps extends
|
|
2
|
+
import { type SwapBlockProps } from './swap-block.js';
|
|
3
|
+
export interface SwapSheetProps extends SwapBlockProps {
|
|
4
4
|
open: boolean;
|
|
5
5
|
onOpenChange: (open: boolean) => void;
|
|
6
6
|
/** Accessible name of the sheet; not drawn. */
|
|
@@ -9,7 +9,7 @@ export interface SwapSheetProps extends SwapPanelBlockProps {
|
|
|
9
9
|
trigger?: React.ReactNode;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* SwapBlock presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
|
|
13
13
|
* each view. Escape and Back pop a pushed view first; from the cards, Escape, the scrim and a downward drag close the sheet.
|
|
14
14
|
* Lives in its own entry so the blocks aggregate stays free of the optional Vaul peer.
|
|
15
15
|
*/
|
|
@@ -3,10 +3,10 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { useControllable } from '../provider.js';
|
|
5
5
|
import { GestureSheet } from '../gesture-sheet.js';
|
|
6
|
-
import {
|
|
6
|
+
import { SwapBlock } from './swap-block.js';
|
|
7
7
|
import { parentView } from './swap/shared.js';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* SwapBlock presented in a gesture sheet (Vaul). Token pickers and settings push inside the same sheet, which resizes to
|
|
10
10
|
* each view. Escape and Back pop a pushed view first; from the cards, Escape, the scrim and a downward drag close the sheet.
|
|
11
11
|
* Lives in its own entry so the blocks aggregate stays free of the optional Vaul peer.
|
|
12
12
|
*/
|
|
@@ -18,5 +18,5 @@ export function SwapSheet({ open, onOpenChange, title, trigger, view: viewProp,
|
|
|
18
18
|
return _jsx(GestureSheet, { open: open, onOpenChange: onOpenChange, title: title, titleHidden: true, trigger: trigger, closeButton: null, contentMode: 'custom', enableDynamicSizing: true, contentProps: { className: 'hig-swap-sheet', onEscapeKeyDown: event => { if (view !== 'main') {
|
|
19
19
|
event.preventDefault();
|
|
20
20
|
show(parentView(view));
|
|
21
|
-
} } }, children: _jsx(
|
|
21
|
+
} } }, children: _jsx(SwapBlock, { ...panel, view: view, onViewChange: show }) });
|
|
22
22
|
}
|
|
@@ -40,7 +40,7 @@ export interface TokenActionBlockProps extends Omit<React.HTMLAttributes<HTMLEle
|
|
|
40
40
|
stickyHeader?: boolean;
|
|
41
41
|
/** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
42
42
|
headingId?: string;
|
|
43
|
-
/** A line under the actions, for example why some are missing. `noteTone` tints it as in `
|
|
43
|
+
/** A line under the actions, for example why some are missing. `noteTone` tints it as in `SwapBlock`. */
|
|
44
44
|
note?: React.ReactNode;
|
|
45
45
|
noteTone?: 'muted' | 'warning' | 'negative';
|
|
46
46
|
}
|
|
@@ -16,6 +16,7 @@ export function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unit
|
|
|
16
16
|
const locale = useNumberLocale();
|
|
17
17
|
const total = value !== undefined ? value : (assets ?? []).reduce((sum, asset) => sum + (held(asset.value) ? asset.value : 0), 0);
|
|
18
18
|
// With no dollar value the units are the headline, as an AccountBlock row headlines them.
|
|
19
|
+
const showChains = chains !== undefined && chains.length > 1;
|
|
19
20
|
const headline = units !== undefined && value == null ? _jsx(AnimatedNumberReadout, { value: units, options: unitsOptions, suffix: unitsSuffix }, 'units') : _jsx(AnimatedNumberReadout, { value: total, options: usd }, 'value');
|
|
20
|
-
return _jsxs("section", { ...rest, className: `hig-token-card${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: symbol, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), (assets ||
|
|
21
|
+
return _jsxs("section", { ...rest, className: `hig-token-card${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: symbol, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), (assets || showChains) && _jsxs("div", { className: 'hig-token-bars', children: [assets && _jsx(BarMark, { surface: false, title: name ?? symbol, description: headline, elements: assets }), showChains && _jsx(BarMark, { surface: false, title: chainsTitle ?? messages.swapChains ?? en.swapChains, description: formatNumber(chains.filter(chain => held(chain.value)).length, locale), elements: chains })] }), actions.length > 0 && _jsx("div", { className: 'hig-token-actions', children: actions.map(action => _jsx(Button, { fullWidth: true, intent: action.intent ?? 'secondary', disabled: action.disabled, onClick: action.onSelect, children: tokenActionLabel(action, messages) }, action.id)) }), note != null && note !== false && _jsx("p", { className: 'hig-swap-note hig-token-note', "data-tone": noteTone, role: 'note', children: note })] });
|
|
21
22
|
}
|
package/react/dist/blocks.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { TradeEntry } from './blocks/trade-entry.js';
|
|
|
4
4
|
export { InstallCommand } from './blocks/install-command.js';
|
|
5
5
|
export { MarketingHero } from './blocks/marketing-hero.js';
|
|
6
6
|
export { AccountBlock, AssetBalanceRow, accountRows, accountSectionRows, accountSectionTotal, assetValue, type AccountBlockProps, type AccountAsset, type AccountSection, type AccountOrder, type AccountRowsOptions, type AssetArtwork, type AssetBalanceRowProps } from './blocks/account-block.js';
|
|
7
|
+
export { LoginBlock, type LoginBlockProps, type LoginProvider } from './blocks/login-block.js';
|
|
8
|
+
export { DepositBlock, type DepositBlockProps, type DepositMethod } from './blocks/deposit-block.js';
|
|
7
9
|
export { LanguageBlock, filterLanguages, type LanguageBlockProps, type LanguageOption } from './blocks/language-block.js';
|
|
8
10
|
export { TokenActionBlock, tokenActionLabel, type TokenActionBlockProps, type TokenAction, type TokenActionId } from './blocks/token-action-block.js';
|
|
9
11
|
export { ManagePositionBlock, positionCorridor, type ManagePositionBlockProps, type ManagePositionBlockLabels, type ManagePositionBlockAction, type ManagePositionBlockSummary, type ManagePositionBlockFigure, type ManagePositionIcon } from './blocks/manage-position-block.js';
|
|
@@ -18,7 +20,8 @@ export { NotificationsBlock, type NotificationsBlockProps, type NotificationsIte
|
|
|
18
20
|
export { TradeHistoryListBlock, tradeHistorySide, type TradeHistoryListBlockProps, type TradeHistoryListLabels, type TradeHistoryItem } from './blocks/trade-history-list-block.js';
|
|
19
21
|
export { TradeHistoryDetailBlock, type TradeHistoryDetailBlockProps, type TradeHistoryDetailLabels, type TradeHistoryDetail, type TradeHistoryAction } from './blocks/trade-history-detail-block.js';
|
|
20
22
|
export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker, type FromPickerBlockProps, type ToPickerBlockProps, type FromPickerProps, type ToPickerProps, type PickerListProps, type PickerInputProps, type PickerRowProps } from './blocks/pickers.js';
|
|
21
|
-
export { SwapPanelBlock, SwapPanel, swapAction, type SwapPanelBlockProps, type SwapPanelProps, type SwapToken, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapReceive, type SwapDestination, type SwapDetail } from './blocks/swap-
|
|
23
|
+
export { SwapBlock, SwapPanelBlock, SwapPanel, swapAction, type SwapBlockProps, type SwapPanelBlockProps, type SwapPanelProps, type SwapToken, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapReceive, type SwapDestination, type SwapDetail } from './blocks/swap-block.js';
|
|
22
24
|
export { ConfirmBlock, type ConfirmBlockProps, type ConfirmDetail, type ConfirmTertiaryAction } from './blocks/confirm-block.js';
|
|
23
25
|
export { PresetPickerBlock, type PresetPickerBlockProps, type PresetPickerCustom } from './blocks/preset-picker-block.js';
|
|
24
|
-
export {
|
|
26
|
+
export { PositionsBlock, type PositionsBlockProps, type OpenPosition } from './blocks/positions-block.js';
|
|
27
|
+
export { ClaimRewardBlock, type ClaimRewardBlockProps } from './blocks/claim-reward-block.js';
|
package/react/dist/blocks.js
CHANGED
|
@@ -5,6 +5,8 @@ export { TradeEntry } from './blocks/trade-entry.js';
|
|
|
5
5
|
export { InstallCommand } from './blocks/install-command.js';
|
|
6
6
|
export { MarketingHero } from './blocks/marketing-hero.js';
|
|
7
7
|
export { AccountBlock, AssetBalanceRow, accountRows, accountSectionRows, accountSectionTotal, assetValue } from './blocks/account-block.js';
|
|
8
|
+
export { LoginBlock } from './blocks/login-block.js';
|
|
9
|
+
export { DepositBlock } from './blocks/deposit-block.js';
|
|
8
10
|
export { LanguageBlock, filterLanguages } from './blocks/language-block.js';
|
|
9
11
|
export { TokenActionBlock, tokenActionLabel } from './blocks/token-action-block.js';
|
|
10
12
|
export { ManagePositionBlock, positionCorridor } from './blocks/manage-position-block.js';
|
|
@@ -19,7 +21,8 @@ export { NotificationsBlock } from './blocks/notifications-block.js';
|
|
|
19
21
|
export { TradeHistoryListBlock, tradeHistorySide } from './blocks/trade-history-list-block.js';
|
|
20
22
|
export { TradeHistoryDetailBlock } from './blocks/trade-history-detail-block.js';
|
|
21
23
|
export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker } from './blocks/pickers.js';
|
|
22
|
-
export { SwapPanelBlock, SwapPanel, swapAction } from './blocks/swap-
|
|
24
|
+
export { SwapBlock, SwapPanelBlock, SwapPanel, swapAction } from './blocks/swap-block.js';
|
|
23
25
|
export { ConfirmBlock } from './blocks/confirm-block.js';
|
|
24
26
|
export { PresetPickerBlock } from './blocks/preset-picker-block.js';
|
|
25
|
-
export {
|
|
27
|
+
export { PositionsBlock } from './blocks/positions-block.js';
|
|
28
|
+
export { ClaimRewardBlock } from './blocks/claim-reward-block.js';
|
|
@@ -124,9 +124,13 @@ export function GestureSheet({ open, onOpenChange, title, description, trigger,
|
|
|
124
124
|
}
|
|
125
125
|
onOpenChange(next);
|
|
126
126
|
};
|
|
127
|
-
const
|
|
127
|
+
const detent = handle && _jsx(Drawer.Handle, { ...grip, ref: handleRef, className: ['hig-gesture-handle', handleClass].filter(Boolean).join(' ') });
|
|
128
|
+
const pinned = !!detent && contentMode === 'default' && (backend.direction ?? 'bottom') === 'bottom';
|
|
129
|
+
const body = _jsxs(_Fragment, { children: [pinned
|
|
130
|
+
? _jsx("div", { className: 'hig-detent-bar', children: detent })
|
|
131
|
+
: detent, _jsx(Drawer.Title, { className: titleHidden || labelledBy ? 'hig-sr-only' : undefined, "aria-hidden": labelledBy ? true : undefined, children: title }), description && _jsx(Drawer.Description, { className: descriptionHidden ? 'hig-sr-only' : undefined, children: description }), children, closeButton !== null && _jsx(Drawer.Close, { asChild: true, children: closeButton ?? _jsx(Button, { intent: 'secondary', suppressFeedback: true, children: closeLabel ?? messages.close ?? en.close }) })] });
|
|
128
132
|
return _jsxs(Drawer.Root, { ...backend, open: open, onOpenChange: requestOpen, modal: true, onAnimationEnd: next => { if (next === currentOpen.current)
|
|
129
|
-
onAnimationEnd?.(next); }, children: [trigger && _jsx(Drawer.Trigger, { asChild: true, children: trigger }), _jsxs(Drawer.Portal, { children: [_jsx(Drawer.Overlay, { ...overlay, ref: backdrop, className: ['hig-backdrop', 'hig-gesture-backdrop', overlayClass].filter(Boolean).join(' '), "data-hig-motion": reducedMotion ? 'reduced' : 'full' }), _jsx(Drawer.Content, { ...content, ...(!description ? { 'aria-describedby': undefined } : {}), ...(labelledBy ? { 'aria-labelledby': labelledBy } : {}), ref: setPanel, className: ['hig-gesture-sheet', className].filter(Boolean).join(' '), role: 'dialog', dir: direction, lang: locale, style: { ...themeStyle, ...style, ...(dynamic && maxDynamicContentSize !== undefined && { maxHeight: maxDynamicContentSize }) }, onPointerDownCapture: event => { const restorePanel = snapshotStyles(panel.current, MOTION_PROPERTIES), restoreOverlay = snapshotStyles(backdrop.current, ['opacity', 'transition']), restoreBackground = backend.shouldScaleBackground ? snapshotStyles(document.querySelector('[data-vaul-drawer-wrapper]'), BACKGROUND_PROPERTIES) : () => { }; motion.current = () => { restorePanel(); restoreOverlay(); restoreBackground(); }; onPointerDownCapture?.(event); }, onInteractOutside: event => { if (event.detail.originalEvent.type === 'focusin')
|
|
133
|
+
onAnimationEnd?.(next); }, children: [trigger && _jsx(Drawer.Trigger, { asChild: true, children: trigger }), _jsxs(Drawer.Portal, { children: [_jsx(Drawer.Overlay, { ...overlay, ref: backdrop, className: ['hig-backdrop', 'hig-gesture-backdrop', overlayClass].filter(Boolean).join(' '), "data-hig-motion": reducedMotion ? 'reduced' : 'full' }), _jsx(Drawer.Content, { ...content, ...(!description ? { 'aria-describedby': undefined } : {}), ...(labelledBy ? { 'aria-labelledby': labelledBy } : {}), ref: setPanel, className: ['hig-gesture-sheet', pinned && 'hig-pin', className].filter(Boolean).join(' '), role: 'dialog', dir: direction, lang: locale, style: { ...themeStyle, ...style, ...(dynamic && maxDynamicContentSize !== undefined && { maxHeight: maxDynamicContentSize }) }, onPointerDownCapture: event => { const restorePanel = snapshotStyles(panel.current, MOTION_PROPERTIES), restoreOverlay = snapshotStyles(backdrop.current, ['opacity', 'transition']), restoreBackground = backend.shouldScaleBackground ? snapshotStyles(document.querySelector('[data-vaul-drawer-wrapper]'), BACKGROUND_PROPERTIES) : () => { }; motion.current = () => { restorePanel(); restoreOverlay(); restoreBackground(); }; onPointerDownCapture?.(event); }, onInteractOutside: event => { if (event.detail.originalEvent.type === 'focusin')
|
|
130
134
|
onFocusOutside?.(event); onInteractOutside?.(event); }, "data-hig-content-mode": contentMode, "data-hig-motion": reducedMotion ? 'reduced' : 'full', "data-hig-dynamic": dynamic ? 'true' : undefined, children: dynamic ? _jsx("div", { ref: setAnatomy, className: 'hig-gesture-dynamic', "data-hig-content-mode": contentMode, children: body }) : body })] })] });
|
|
131
135
|
}
|
|
132
136
|
// One curve for the height and both views, measured from Vaul's Dynamic Drawer: no spring and no overshoot, a short ease in and a long ease out. The old view leaves in 270ms and the new one arrives in 220ms.
|
package/react/dist/overlay.d.ts
CHANGED
|
@@ -8,35 +8,7 @@ export declare function Menu({ label, items }: {
|
|
|
8
8
|
onSelect: (event: Event) => void;
|
|
9
9
|
}[];
|
|
10
10
|
}): React.JSX.Element;
|
|
11
|
-
export
|
|
12
|
-
/** Text of the built-in trigger, a secondary Button. With `trigger`, it names the popover instead (`aria-label` on its content). */
|
|
13
|
-
label: string;
|
|
14
|
-
children?: React.ReactNode;
|
|
15
|
-
/** Close button text and accessible name; defaults to HIGProvider `messages.close`. */
|
|
16
|
-
closeLabel?: string;
|
|
17
|
-
/** Leaves out the Close button, for a popover that holds only information or that the host closes itself. Escape and a press outside still close it. */
|
|
18
|
-
hideClose?: boolean;
|
|
19
|
-
/** Controls whether the popover is open. Omit it, with `defaultOpen`, to let the popover keep its own state. */
|
|
20
|
-
open?: boolean;
|
|
21
|
-
defaultOpen?: boolean;
|
|
22
|
-
/** Called with the next state when the trigger, Close, Escape, a press outside or (with `openOnHover`) the pointer opens or closes it. */
|
|
23
|
-
onOpenChange?: (open: boolean) => void;
|
|
24
|
-
/** The host's own trigger in place of the built-in Button: one element that accepts a ref and spreads its props onto a focusable element, such as a HIG `Button`, `IconButton` or a `<button>`. */
|
|
25
|
-
trigger?: React.ReactElement;
|
|
26
|
-
/** Also opens while a mouse pointer rests on the trigger, and closes shortly after it leaves both the trigger and the popover. Touch and pen keep press to open; keyboard focus is not moved by a hover. */
|
|
27
|
-
openOnHover?: boolean;
|
|
28
|
-
/** `data-testid` of the popover's content. */
|
|
29
|
-
testID?: string;
|
|
30
|
-
/** Tints the popover's surface from a token role: a 12% wash over its fill, a 40% stroke and a soft glow in the role's colour, such as `warning` for a gold badge's explanation. `data-tone` on the content. Without it the surface is neutral. */
|
|
31
|
-
tone?: PopoverTone;
|
|
32
|
-
/** Classes added to the popover's content after `hig-popover`, for a host surface treatment the tones do not cover. */
|
|
33
|
-
className?: string;
|
|
34
|
-
/** Inline style for the popover's content, after the theme's variables, so it can set `--hig-popover-tone` or a host border, background or shadow. */
|
|
35
|
-
style?: React.CSSProperties;
|
|
36
|
-
}
|
|
37
|
-
/** A token role that tints a `Popover`'s surface. */
|
|
38
|
-
export type PopoverTone = 'info' | 'positive' | 'warning' | 'negative';
|
|
39
|
-
export declare function Popover({ label, children, closeLabel, hideClose, open, defaultOpen, onOpenChange, trigger, openOnHover, testID, tone, className, style }: PopoverProps): React.JSX.Element;
|
|
11
|
+
export { Popover, type PopoverProps, type PopoverTone } from './popover.js';
|
|
40
12
|
export declare function Tooltip({ content, children }: React.PropsWithChildren<{
|
|
41
13
|
content: string;
|
|
42
14
|
}>): React.JSX.Element;
|