@bloxwap/hig 0.9.0 → 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/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/blocks.d.ts +2 -1
- package/native/dist/blocks.js +2 -1
- 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/deposit-block.js +5 -2
- package/native/dist/gesture-sheet.js +1 -1
- package/native/dist/language-block.js +1 -1
- 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-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +32 -12
- 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.js +5 -2
- package/react/dist/blocks/login-block.d.ts +15 -3
- package/react/dist/blocks/login-block.js +22 -7
- 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.d.ts +2 -1
- package/react/dist/blocks.js +2 -1
- package/react/dist/gesture-sheet.js +6 -2
- package/react/dist/styles.css +170 -37
- package/tokens/README.md +1 -1
- 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
|
@@ -18,7 +18,7 @@ export function HeaderClose({ onClose, label, testID, closeProps }) {
|
|
|
18
18
|
* edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
|
|
19
19
|
* it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
|
|
20
20
|
*/
|
|
21
|
-
export function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, eyebrow, hideTitle, description, stickyHeader, scrolled, stickyHeaderBackground, inset, style }) {
|
|
21
|
+
export function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, eyebrow, hideTitle, description, stickyHeader, scrolled, stickyHeaderBackground, inset, style, sideWidth = 44 }) {
|
|
22
22
|
const colors = useColors(), t = useMessages(), { direction } = useHIG();
|
|
23
23
|
const id = (part) => testID === undefined ? undefined : `${testID}-${part}`;
|
|
24
24
|
// Clear white stays in the accessibility tree where opacity 0 might not; the title keeps its line so the header keeps its height.
|
|
@@ -29,7 +29,7 @@ export function ScreenHeader({ title, onBack, backDisabled, backProps, action, t
|
|
|
29
29
|
// Beside the sides the title fills the middle; under an eyebrow it sits in a column at its own height.
|
|
30
30
|
const grow = eyebrow ? null : { flex: 1 };
|
|
31
31
|
const titleNode = badge ? _jsxs(View, { ref: titleRef, nativeID: headingId, accessible: true, accessibilityRole: 'header', accessibilityLabel: `${title}, ${badge}`, accessibilityHint: description, style: { ...grow, flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: 8, minWidth: 0 }, children: [_jsx(Text, { testID: id('title'), accessible: false, numberOfLines: 1, style: { ...heading, flexShrink: 1 }, children: title }), hideTitle ? null : _jsx(View, { testID: id('badge'), style: { flexShrink: 0 }, children: _jsx(Badge, { children: _jsx(Text, { style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.text }, children: badge }) }) })] }) : _jsx(Text, { ref: titleRef, testID: id('title'), nativeID: headingId, accessibilityRole: 'header', accessibilityHint: description, numberOfLines: 1, style: { ...grow, ...heading }, children: title });
|
|
32
|
-
const row = _jsxs(View, { testID: id('header'), style: [{ flexDirection: 'row', alignItems: 'center', minHeight: height }, pad ? { paddingTop: pad, paddingHorizontal: pad } : undefined, fill, stickyHeader ? undefined : style], children: [_jsx(View, { style: { minWidth:
|
|
32
|
+
const row = _jsxs(View, { testID: id('header'), style: [{ flexDirection: 'row', alignItems: 'center', minHeight: height }, pad ? { paddingTop: pad, paddingHorizontal: pad } : undefined, fill, stickyHeader ? undefined : style], children: [_jsx(View, { style: { minWidth: sideWidth, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { ...backProps, intent: 'ghost', label: t.back, disabled: backDisabled, suppressFeedback: true, testID: id('back'), onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: backDisabled ? colors.faint : colors.text }) }) }) : null }), eyebrow ? _jsxs(View, { style: { flex: 1, minWidth: 0, gap: 2 }, children: [_jsx(Text, { testID: id('eyebrow'), numberOfLines: 1, style: { textAlign: 'center', fontSize: 12, lineHeight: 16, letterSpacing: 1.5, textTransform: 'uppercase', color: colors.muted }, children: eyebrow }), titleNode] }) : titleNode, _jsx(View, { style: { minWidth: sideWidth, alignItems: 'flex-end' }, children: action })] });
|
|
33
33
|
// A pinned header is the host scroller's sticky child: React Native moves its `style` prop onto the slot's own wrapper and passes flex:1 in its
|
|
34
34
|
// place, which in that column measures the child at its minimum height alone (0 plus padding). So the outer view carries only what may move
|
|
35
35
|
// (the host's style) and a minimum height of the whole row, and the row, the inset and the fill sit on the inner view, pinned or not.
|
package/native/dist/status.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { progressValue } from '@bloxwap/hig/contracts';
|
|
3
3
|
import React, { useEffect, useRef, useState } from 'react';
|
|
4
|
-
import { tokens } from '@bloxwap/hig/tokens';
|
|
4
|
+
import { tokens, nativeMetrics } from '@bloxwap/hig/tokens';
|
|
5
|
+
import { capsuleRadius } from './modal-radius.js';
|
|
5
6
|
import { CloseIcon, EmptyIcon, SeverityIcon } from './icons.js';
|
|
6
7
|
import { notificationDelta } from '@bloxwap/hig/contracts/announcements';
|
|
7
8
|
import { AvatarFrame, sameFrame } from './avatar-frame.js';
|
|
@@ -33,7 +34,7 @@ export function Alert({ title, children: body, severity = 'info', tone, action,
|
|
|
33
34
|
previous.current = key;
|
|
34
35
|
if (Platform.OS === 'ios')
|
|
35
36
|
speak(message, severity);
|
|
36
|
-
} }); return _jsxs(Surface, { style: { gap: 12, backgroundColor: tint(accent, colors.surface, neutral ? 0.06 : 0.1) }, accessibilityLiveRegion: announce && Platform.OS !== 'ios' ? (severity === 'error' ? 'assertive' : 'polite') : 'none', children: [_jsx(Heading, { style: { color: accent }, children: title }), children, action] }); }
|
|
37
|
+
} }); return _jsxs(Surface, { style: { gap: 12, borderRadius: nativeMetrics.space.xl + capsuleRadius, backgroundColor: tint(accent, colors.surface, neutral ? 0.06 : 0.1) }, accessibilityLiveRegion: announce && Platform.OS !== 'ios' ? (severity === 'error' ? 'assertive' : 'polite') : 'none', children: [_jsx(Heading, { style: { color: accent }, children: title }), children, action] }); }
|
|
37
38
|
export const Callout = Alert;
|
|
38
39
|
/** Loops a 0→1 value while `active`; rests at 0 otherwise (reduced motion, or nothing to show). */
|
|
39
40
|
function useLoop(active, duration, easing = Easing.linear) { const value = useRef(new Animated.Value(0)).current; useEffect(() => { if (!active) {
|
package/native-fonts/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/native-fonts
|
|
2
2
|
|
|
3
|
-
Version 0.9.
|
|
3
|
+
Version 0.9.1, an entry of `@bloxwap/hig`. Static Bloxwap Sans/Mono (and Korean/Simplified Chinese Sans) TTF faces for React Native and Expo hosts, derived reproducibly from pinned `@bloxwap/font` 0.1.4 by `npm run generate:fonts`.
|
|
4
4
|
|
|
5
5
|
Web hosts never import this entry: load fonts through `@bloxwap/font` and use `@bloxwap/hig/tokens/css`. Open Graph card renderers (Satori, `next/og`) use the much smaller `@bloxwap/hig/og-fonts` entry instead (#99).
|
|
6
6
|
|
package/og-fonts/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/og-fonts
|
|
2
2
|
|
|
3
|
-
Version 0.9.
|
|
3
|
+
Version 0.9.1, an entry of `@bloxwap/hig`. Five static Latin Bloxwap Sans/Mono TTF faces for Open Graph card renderers: Satori, `next/og` `ImageResponse` and `@vercel/og`. Satori reads TTF/OTF but not WOFF2, and `@bloxwap/font` ships only WOFF2.
|
|
4
4
|
|
|
5
5
|
| Face | File | Weight |
|
|
6
6
|
| --- | --- | --- |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloxwap/hig",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Bloxwap Human Interface Guidelines: tokens, contracts, React and React Native components, chart adapter, feedback and fonts in one package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -418,16 +418,6 @@
|
|
|
418
418
|
"import": "./native/dist/preset-picker-block.js",
|
|
419
419
|
"default": "./native/dist/preset-picker-block.js"
|
|
420
420
|
},
|
|
421
|
-
"./react/blocks/explainer-block": {
|
|
422
|
-
"types": "./react/dist/blocks/explainer-block.d.ts",
|
|
423
|
-
"import": "./react/dist/blocks/explainer-block.js",
|
|
424
|
-
"default": "./react/dist/blocks/explainer-block.js"
|
|
425
|
-
},
|
|
426
|
-
"./native/explainer-block": {
|
|
427
|
-
"types": "./native/dist/explainer-block.d.ts",
|
|
428
|
-
"import": "./native/dist/explainer-block.js",
|
|
429
|
-
"default": "./native/dist/explainer-block.js"
|
|
430
|
-
},
|
|
431
421
|
"./react/confetti": {
|
|
432
422
|
"types": "./react/dist/confetti.d.ts",
|
|
433
423
|
"import": "./react/dist/confetti.js",
|
|
@@ -713,7 +703,37 @@
|
|
|
713
703
|
"import": "./native/dist/toast.js",
|
|
714
704
|
"default": "./native/dist/toast.js"
|
|
715
705
|
},
|
|
716
|
-
"./package.json": "./package.json"
|
|
706
|
+
"./package.json": "./package.json",
|
|
707
|
+
"./native/chart": {
|
|
708
|
+
"types": "./native/dist/chart.d.ts",
|
|
709
|
+
"import": "./native/dist/chart.js",
|
|
710
|
+
"default": "./native/dist/chart.js"
|
|
711
|
+
},
|
|
712
|
+
"./chart/altimeter-core": {
|
|
713
|
+
"types": "./chart/dist/altimeter-core.d.ts",
|
|
714
|
+
"import": "./chart/dist/altimeter-core.js",
|
|
715
|
+
"default": "./chart/dist/altimeter-core.js"
|
|
716
|
+
},
|
|
717
|
+
"./native/positions-block": {
|
|
718
|
+
"types": "./native/dist/positions-block.d.ts",
|
|
719
|
+
"import": "./native/dist/positions-block.js",
|
|
720
|
+
"default": "./native/dist/positions-block.js"
|
|
721
|
+
},
|
|
722
|
+
"./react/blocks/positions-block": {
|
|
723
|
+
"types": "./react/dist/blocks/positions-block.d.ts",
|
|
724
|
+
"import": "./react/dist/blocks/positions-block.js",
|
|
725
|
+
"default": "./react/dist/blocks/positions-block.js"
|
|
726
|
+
},
|
|
727
|
+
"./react/blocks/claim-reward-block": {
|
|
728
|
+
"types": "./react/dist/blocks/claim-reward-block.d.ts",
|
|
729
|
+
"import": "./react/dist/blocks/claim-reward-block.js",
|
|
730
|
+
"default": "./react/dist/blocks/claim-reward-block.js"
|
|
731
|
+
},
|
|
732
|
+
"./native/claim-reward-block": {
|
|
733
|
+
"types": "./native/dist/claim-reward-block.d.ts",
|
|
734
|
+
"import": "./native/dist/claim-reward-block.js",
|
|
735
|
+
"default": "./native/dist/claim-reward-block.js"
|
|
736
|
+
}
|
|
717
737
|
},
|
|
718
738
|
"files": [
|
|
719
739
|
"README.md",
|
package/react/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/react
|
|
2
2
|
|
|
3
|
-
Version 0.9.
|
|
3
|
+
Version 0.9.1, an entry of `@bloxwap/hig`. Import individual entries; see docs/components for platform and accessibility contracts.
|
|
4
4
|
|
|
5
5
|
UI symbols come from `@bloxwap/icons` (install `@bloxwap/icons@^0.1.0`). The web entry renders inline SVG and imports individual icon modules.
|
|
6
6
|
|
|
@@ -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
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { QrCode } from '@bloxwap/icons/react/qr-code';
|
|
3
4
|
import { deposit } from '@bloxwap/hig/contracts/messages';
|
|
4
5
|
import { useHIG } from '../provider.js';
|
|
5
6
|
import { ListGroup, ListRow } from '../list-group.js';
|
|
@@ -7,8 +8,10 @@ import { ScreenHeader } from './screen-header.js';
|
|
|
7
8
|
const builtInMethods = new Set(['apple-pay', 'cash-app', 'exchange', 'crypto', 'bank', 'blink']);
|
|
8
9
|
export function DepositBlock({ title, description, methods, onSelect, onBack, headerAction, headingId }) {
|
|
9
10
|
const { messages } = useHIG();
|
|
10
|
-
|
|
11
|
-
|
|
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) &&
|
|
12
15
|
_jsx("span", { "aria-hidden": "true", className: "hig-deposit-icon", "data-method": method.id }));
|
|
13
16
|
return _jsx(ListRow, { leading: leading, label: method.label, description: method.description, disabled: method.disabled, onSelect: () => onSelect(method) }, method.id);
|
|
14
17
|
}) })] });
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { type LoginBlockProps } from '@bloxwap/hig/contracts/login';
|
|
3
|
-
export type {
|
|
4
|
-
|
|
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;
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { 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';
|
|
3
7
|
import { HeaderClose, ScreenHeader } from './screen-header.js';
|
|
4
8
|
import { Info } from '@bloxwap/icons/react/info';
|
|
5
|
-
import { IconButton } from '../button.js';
|
|
9
|
+
import { Button, IconButton } from '../button.js';
|
|
6
10
|
import { Switch } from '../selection.js';
|
|
7
11
|
import { Popover } from '../popover.js';
|
|
8
|
-
import { ListRow } from '../list-group.js';
|
|
9
12
|
import { Badge } from '../status.js';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 })] })] });
|
|
14
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
|
+
}
|
package/react/dist/blocks.d.ts
CHANGED
|
@@ -23,4 +23,5 @@ export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker, type FromPickerBl
|
|
|
23
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';
|
|
24
24
|
export { ConfirmBlock, type ConfirmBlockProps, type ConfirmDetail, type ConfirmTertiaryAction } from './blocks/confirm-block.js';
|
|
25
25
|
export { PresetPickerBlock, type PresetPickerBlockProps, type PresetPickerCustom } from './blocks/preset-picker-block.js';
|
|
26
|
-
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
|
@@ -24,4 +24,5 @@ export { FromPickerBlock, ToPickerBlock, FromPicker, ToPicker } from './blocks/p
|
|
|
24
24
|
export { SwapBlock, SwapPanelBlock, SwapPanel, swapAction } from './blocks/swap-block.js';
|
|
25
25
|
export { ConfirmBlock } from './blocks/confirm-block.js';
|
|
26
26
|
export { PresetPickerBlock } from './blocks/preset-picker-block.js';
|
|
27
|
-
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.
|