@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
|
@@ -38,39 +38,40 @@ function Sentence({ template, text, value, options, suffix, testID }) {
|
|
|
38
38
|
return _jsx(Text, { testID: testID, style: { ...words, flexShrink: 1 }, children: reading });
|
|
39
39
|
return _jsxs(View, { accessible: true, accessibilityLabel: reading, testID: testID, style: { direction, flexDirection: 'row', alignItems: 'center', flexShrink: 1 }, children: [parts[0] ? _jsx(Text, { accessible: false, style: words, children: parts[0] }) : null, _jsx(AnimatedNumberReadout, { value: value, options: options, suffix: suffix, tone: 'muted', style: type }), parts[1] ? _jsx(Text, { accessible: false, style: words, children: parts[1] }) : null] });
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
41
|
+
export function PositionSummaryRow({ position, side, labels, pnlOptions, disclosure = false }) {
|
|
42
|
+
const colors = useColors(), fills = useFills(), { direction } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
|
|
43
|
+
const long = side === 'long';
|
|
44
44
|
// The artwork that failed to draw (its URL, or the position for a host element); it then shows the fallback or the initials until the artwork changes.
|
|
45
45
|
const [broken, setBroken] = useState(null);
|
|
46
46
|
const pnlUsd = pnlOptions ? { ...pnlUsdDefault, ...pnlOptions } : pnlUsdDefault;
|
|
47
47
|
const read = (value, options) => known(value) ? formatNumberReadout(value, locale, present(options)).text : unknown;
|
|
48
|
-
const
|
|
48
|
+
const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
|
|
49
|
+
const { name, icon, iconFallback, symbol, leverage, size, pnl, pnlPercent, badge, caption, onSelect } = position;
|
|
50
|
+
const initials = _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: symbol ?? name.slice(0, 3) });
|
|
51
|
+
const key = typeof icon === 'string' ? icon : `${symbol ?? ''}|${name}`, failed = broken === key, fail = () => setBroken(key);
|
|
52
|
+
const art = failed ? _jsx(View, { testID: 'manage-position-initials', style: shape, children: iconFallback ?? initials })
|
|
53
|
+
: typeof icon === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: icon }, onError: fail, style: shape })
|
|
54
|
+
: _jsx(View, { style: shape, children: typeof icon === 'function' ? icon(fail) : icon ?? initials });
|
|
55
|
+
const gearing = known(leverage) ? formatNumberReadout(leverage, locale, units).text + times : null, held = size !== undefined ? read(size, units) : null;
|
|
56
|
+
const label = [name, long ? labels.long : labels.short, gearing, held, pnl !== undefined ? read(pnl, pnlUsd) : null, pnlPercent !== undefined ? read(pnlPercent, pnlShare) : null].filter(Boolean).join(', ');
|
|
57
|
+
const meta = { fontSize: 14, lineHeight: 20 };
|
|
58
|
+
const title = _jsx(Text, { numberOfLines: 1, style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text, ...(badge ? { flexShrink: 1 } : null) }, children: name });
|
|
59
|
+
const surface = (pressed) => ({ flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: pressed ? fills.raised : fills.well, marginTop: disclosure ? 0 : 16, ...(disclosure ? { paddingVertical: 16, paddingStart: 16, borderRadius: 0 } : {}) });
|
|
60
|
+
const parts = _jsxs(_Fragment, { children: [_jsx(View, { ...hidden, children: art }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [badge ? _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 8, minWidth: 0 }, children: [title, _jsx(View, { testID: 'manage-position-badge', style: { flexShrink: 0, borderRadius: 9999, paddingHorizontal: 8, backgroundColor: fills.raised }, children: _jsx(Text, { numberOfLines: 1, style: { fontSize: 12, lineHeight: 18, fontWeight: '500', color: colors.muted }, children: badge }) })] }) : title, _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { testID: 'manage-position-side', style: { ...meta, fontWeight: '600', color: long ? colors.up : colors.down }, children: long ? up : down }), gearing ? _jsx(Text, { testID: 'manage-position-leverage', style: { ...meta, fontWeight: '600', color: long ? colors.up : colors.down }, children: gearing }) : null, gearing && held ? _jsx(Text, { style: { ...meta, color: colors.muted }, children: dot.trim() }) : null, size !== undefined ? _jsx(AnimatedNumberReadout, { value: size, options: units, tone: 'muted', testID: 'manage-position-size', style: meta }) : null] })] }), _jsxs(View, { ...hidden, style: { alignItems: 'flex-end', justifyContent: 'center' }, children: [pnl !== undefined ? _jsx(AnimatedNumberReadout, { value: pnl, options: pnlUsd, tone: known(pnl) && pnl > 0 ? 'up' : known(pnl) && pnl < 0 ? 'down' : 'text', testID: 'manage-position-pnl', style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) : null, pnlPercent !== undefined ? _jsx(AnimatedNumberReadout, { value: pnlPercent, options: pnlShare, tone: 'muted', testID: 'manage-position-pnl-percent', style: meta }) : null] }), disclosure && onSelect && _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '90deg' : '-90deg' }] }, children: _jsx(ChevronIcon, { color: colors.muted }) })] });
|
|
61
|
+
const note = caption ? _jsx(Text, { testID: 'manage-position-caption', style: { marginTop: 8, paddingHorizontal: 16, color: colors.muted, fontSize: 13, lineHeight: 20 }, children: caption }) : null;
|
|
62
|
+
if (onSelect) {
|
|
63
|
+
// A pressable row is named by the host's label and then what it shows, so the figures are read even with hints off; the caption is its hint.
|
|
64
|
+
return _jsxs(_Fragment, { children: [_jsx(Pressable, { testID: 'manage-position-row', accessibilityRole: 'button', accessibilityLabel: position.label ? `${position.label}, ${label}` : label, accessibilityHint: caption, onPress: onSelect, style: ({ pressed }) => surface(pressed), children: parts }), note] });
|
|
65
|
+
}
|
|
66
|
+
return _jsxs(_Fragment, { children: [_jsx(View, { testID: 'manage-position-row', accessible: true, accessibilityLabel: label, style: surface(false), children: parts }), note] });
|
|
67
|
+
}
|
|
68
|
+
/** One open position as a screen: margin and notional under the share left before liquidation, then the liquidation, mark and entry prices as a `BarPnl`, what can be done, and the position itself. Both bars are drawn without a card, because nothing in them can be pressed. */
|
|
69
|
+
export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, stickyHeader, stickyHeaderBackground, scrollComponent, testID }) {
|
|
70
|
+
const colors = useColors(), t = useMessages(), { direction } = useHIG(), locale = useNumberLocale(), present = usePresentNumber();
|
|
71
|
+
const read = (value, options) => known(value) ? formatNumberReadout(value, locale, present(options)).text : unknown;
|
|
72
|
+
const corridor = positionCorridor({ side, entry, mark, liquidation });
|
|
49
73
|
const marginBar = [{ id: 'margin', label: labels.margin, value: margin, detail: read(margin, usd), tone: 'info' }, { id: 'notional', label: labels.notional, value: known(notional) ? Math.max(notional - margin, 0) : 0, detail: read(notional, usd), tone: 'positive' }];
|
|
50
74
|
const left = corridor.share === null ? null : corridor.share * 100;
|
|
51
|
-
const shape = { width: avatar, height: avatar, borderRadius: avatar / 2, backgroundColor: fills.raised, alignItems: 'center', justifyContent: 'center', overflow: 'hidden' };
|
|
52
|
-
const row = () => {
|
|
53
|
-
if (!position)
|
|
54
|
-
return null;
|
|
55
|
-
const { name, icon, iconFallback, symbol, leverage, size, pnl, pnlPercent, badge, caption, onSelect } = position;
|
|
56
|
-
const initials = _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1, style: { fontSize: 12, lineHeight: 16, fontWeight: '600', color: colors.muted }, children: symbol ?? name.slice(0, 3) });
|
|
57
|
-
const key = typeof icon === 'string' ? icon : `${symbol ?? ''}|${name}`, failed = broken === key, fail = () => setBroken(key);
|
|
58
|
-
const art = failed ? _jsx(View, { testID: 'manage-position-initials', style: shape, children: iconFallback ?? initials })
|
|
59
|
-
: typeof icon === 'string' ? _jsx(Image, { accessible: false, accessibilityIgnoresInvertColors: true, source: { uri: icon }, onError: fail, style: shape })
|
|
60
|
-
: _jsx(View, { style: shape, children: typeof icon === 'function' ? icon(fail) : icon ?? initials });
|
|
61
|
-
const gearing = known(leverage) ? formatNumberReadout(leverage, locale, units).text + times : null, held = size !== undefined ? read(size, units) : null;
|
|
62
|
-
const label = [name, long ? labels.long : labels.short, gearing, held, pnl !== undefined ? read(pnl, pnlUsd) : null, pnlPercent !== undefined ? read(pnlPercent, pnlShare) : null].filter(Boolean).join(', ');
|
|
63
|
-
const meta = { fontSize: 14, lineHeight: 20 };
|
|
64
|
-
const title = _jsx(Text, { numberOfLines: 1, style: { fontSize: 16, lineHeight: 24, fontWeight: '600', color: colors.text, ...(badge ? { flexShrink: 1 } : null) }, children: name });
|
|
65
|
-
const surface = (pressed) => ({ flexDirection: 'row', alignItems: 'center', gap: 12, minHeight: 56, paddingVertical: 8, paddingStart: 8, paddingEnd: 16, borderRadius: 28, backgroundColor: pressed ? fills.raised : fills.well, marginTop: 16 });
|
|
66
|
-
const parts = _jsxs(_Fragment, { children: [_jsx(View, { ...hidden, children: art }), _jsxs(View, { ...hidden, style: { flex: 1, flexShrink: 1, minWidth: 0 }, children: [badge ? _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 8, minWidth: 0 }, children: [title, _jsx(View, { testID: 'manage-position-badge', style: { flexShrink: 0, borderRadius: 9999, paddingHorizontal: 8, backgroundColor: fills.raised }, children: _jsx(Text, { numberOfLines: 1, style: { fontSize: 12, lineHeight: 18, fontWeight: '500', color: colors.muted }, children: badge }) })] }) : title, _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: 4 }, children: [_jsx(Text, { testID: 'manage-position-side', style: { ...meta, fontWeight: '600', color: long ? colors.up : colors.down }, children: long ? up : down }), gearing ? _jsx(Text, { testID: 'manage-position-leverage', style: { ...meta, fontWeight: '600', color: long ? colors.up : colors.down }, children: gearing }) : null, gearing && held ? _jsx(Text, { style: { ...meta, color: colors.muted }, children: dot.trim() }) : null, size !== undefined ? _jsx(AnimatedNumberReadout, { value: size, options: units, tone: 'muted', testID: 'manage-position-size', style: meta }) : null] })] }), _jsxs(View, { ...hidden, style: { alignItems: 'flex-end', justifyContent: 'center' }, children: [pnl !== undefined ? _jsx(AnimatedNumberReadout, { value: pnl, options: pnlUsd, tone: known(pnl) && pnl > 0 ? 'up' : known(pnl) && pnl < 0 ? 'down' : 'text', testID: 'manage-position-pnl', style: { fontSize: 16, lineHeight: 24, fontWeight: '600' } }) : null, pnlPercent !== undefined ? _jsx(AnimatedNumberReadout, { value: pnlPercent, options: pnlShare, tone: 'muted', testID: 'manage-position-pnl-percent', style: meta }) : null] })] });
|
|
67
|
-
const note = caption ? _jsx(Text, { testID: 'manage-position-caption', style: { marginTop: 8, paddingHorizontal: 16, color: colors.muted, fontSize: 13, lineHeight: 20 }, children: caption }) : null;
|
|
68
|
-
if (onSelect) {
|
|
69
|
-
// A pressable row is named by the host's label and then what it shows, so the figures are read even with hints off; the caption is its hint.
|
|
70
|
-
return _jsxs(_Fragment, { children: [_jsx(Pressable, { testID: 'manage-position-row', accessibilityRole: 'button', accessibilityLabel: position.label ? `${position.label}, ${label}` : label, accessibilityHint: caption, onPress: onSelect, style: ({ pressed }) => surface(pressed), children: parts }), note] });
|
|
71
|
-
}
|
|
72
|
-
return _jsxs(_Fragment, { children: [_jsx(View, { testID: 'manage-position-row', accessible: true, accessibilityLabel: label, style: surface(false), children: parts }), note] });
|
|
73
|
-
};
|
|
74
75
|
const actionValue = (action) => {
|
|
75
76
|
const figure = action.value;
|
|
76
77
|
if (figure == null)
|
|
@@ -80,7 +81,7 @@ export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidati
|
|
|
80
81
|
return { value: _jsx(AnimatedNumberReadout, { ...figureProps(figure), tone: action.tone ?? 'muted', testID: `manage-action-${action.id}-value`, style: { fontSize: 16, lineHeight: 24 } }), valueLabel: figureReading(figure, locale, present(figure.options)) };
|
|
81
82
|
};
|
|
82
83
|
const header = _jsxs(View, { testID: 'manage-header', style: { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'manage-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'manage-title', nativeID: headingId, accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: labels.title }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction })] });
|
|
83
|
-
const body = _jsxs(_Fragment, { children: [_jsxs(View, { style: { gap: 20, marginTop: 16, paddingHorizontal: 4 }, children: [_jsx(BarMark, { testID: 'manage-margin', surface: false, title: mode ?? labels.margin, elements: marginBar, description: _jsx(Sentence, { testID: 'manage-to-liquidation', template: labels.toLiquidation, text: left === null ? unknown : formatNumberReadout(left, locale, tenth).text + percent, value: left, options: tenth, suffix: percent }) }), _jsx(BarPnl, { testID: 'manage-liquidation', 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(View, { testID: 'manage-actions', style: { marginTop: 16 }, children: _jsx(ListGroup, { children: actions.map(action => _jsx(ListRow, { testID: `manage-action-${action.id}`, label: action.label, disabled: action.disabled, onSelect: action.onSelect, ...actionValue(action) }, action.id)) }) }) : null,
|
|
84
|
+
const body = _jsxs(_Fragment, { children: [_jsxs(View, { style: { gap: 20, marginTop: 16, paddingHorizontal: 4 }, children: [_jsx(BarMark, { testID: 'manage-margin', surface: false, title: mode ?? labels.margin, elements: marginBar, description: _jsx(Sentence, { testID: 'manage-to-liquidation', template: labels.toLiquidation, text: left === null ? unknown : formatNumberReadout(left, locale, tenth).text + percent, value: left, options: tenth, suffix: percent }) }), _jsx(BarPnl, { testID: 'manage-liquidation', 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(View, { testID: 'manage-actions', style: { marginTop: 16 }, children: _jsx(ListGroup, { children: actions.map(action => _jsx(ListRow, { testID: `manage-action-${action.id}`, label: action.label, disabled: action.disabled, onSelect: action.onSelect, ...actionValue(action) }, action.id)) }) }) : null, position && _jsx(PositionSummaryRow, { position: position, side: side, labels: labels, pnlOptions: pnlOptions })] });
|
|
84
85
|
if (stickyHeader)
|
|
85
86
|
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'manage-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
|
|
86
87
|
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
|
package/native/dist/overlay.d.ts
CHANGED
|
@@ -13,14 +13,18 @@ export interface DialogProps {
|
|
|
13
13
|
/** Custom content owns its visible heading, actions, padding and scrolling. The native Modal remains HIG-owned. */ contentMode?: 'default' | 'custom';
|
|
14
14
|
/** Accessible caller heading used when custom content renders the title. Otherwise HIG keeps a visually hidden title. */ titleRef?: React.RefObject<React.ComponentRef<typeof View> | React.ComponentRef<typeof RNText> | React.ComponentRef<typeof TextInput> | null>;
|
|
15
15
|
/** Custom-mode stage inside the Modal, for example GestureHandlerRootView on Android. */ stageComponent?: React.ComponentType<ViewProps>;
|
|
16
|
-
stageStyle?: StyleProp<ViewStyle>;
|
|
16
|
+
/** Layout inside the modal safe area, or on the custom stage. */ stageStyle?: StyleProp<ViewStyle>;
|
|
17
17
|
stageTestID?: string;
|
|
18
18
|
/** Custom-mode backdrop, including the host's dismissal policy and decoration. */ backdrop?: React.ReactNode;
|
|
19
|
+
/** Align the standard modal surface with its inset 44dp capsule controls. Defaults to true. */
|
|
20
|
+
concentric?: boolean;
|
|
21
|
+
/** Accent label above the standard title, with a matching radial glow across the panel. */ accentEyebrow?: string;
|
|
22
|
+
/** Size and placement of the standard scrollable dialog inside the safe area. */ frameStyle?: StyleProp<ViewStyle>;
|
|
19
23
|
/** Custom-mode surface layout; no implicit padding or scroll view is added. */ contentStyle?: StyleProp<ViewStyle>;
|
|
20
24
|
/** Identifies the actual modal content surface in either mode. */ testID?: string;
|
|
21
25
|
/** Native Modal animation. Reduced motion always selects `none`; the default stays `none`. */ animationType?: ModalProps['animationType'];
|
|
22
26
|
}
|
|
23
|
-
export declare function Dialog({ open, onOpenChange, title, description, children, initialFocusRef, returnFocusRef, closeLabel, contentMode, titleRef, stageComponent: Stage, stageStyle, stageTestID, backdrop, contentStyle, testID, animationType }: DialogProps): React.JSX.Element;
|
|
27
|
+
export declare function Dialog({ open, onOpenChange, title, description, children, initialFocusRef, returnFocusRef, closeLabel, contentMode, concentric, accentEyebrow, titleRef, stageComponent: Stage, stageStyle, stageTestID, backdrop, contentStyle, frameStyle, testID, animationType }: DialogProps): React.JSX.Element;
|
|
24
28
|
export declare const Sheet: typeof Dialog;
|
|
25
29
|
export declare const AlertDialog: typeof Dialog;
|
|
26
30
|
export declare function Menu({ label, items, closeLabel }: {
|
package/native/dist/overlay.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { withAlpha } from '@bloxwap/hig/tokens';
|
|
2
3
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
3
4
|
import { Raised, useColors, useHIG } from './provider.js';
|
|
4
5
|
import React, { useEffect, useRef, useId, useCallback } from 'react';
|
|
@@ -6,15 +7,17 @@ import { Modal, KeyboardAvoidingView, Platform, ScrollView, AccessibilityInfo, f
|
|
|
6
7
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
|
7
8
|
import { Heading, Text, Stack } from './surface.js';
|
|
8
9
|
import { Button } from './button.js';
|
|
9
|
-
|
|
10
|
+
import { capsuleRadius } from './modal-radius.js';
|
|
11
|
+
/** The panel has no stroke: it uses the overlay fill, darker than a card, lifted by a soft shadow. Native focus requests remain best effort; host supplies a live trigger ref for restoration. */
|
|
10
12
|
/** Android TalkBack ignores the TYPE_VIEW_FOCUSED event behind setAccessibilityFocus in RN 0.81 Fabric (emulator: focus fell back to the first screen element); a hover-enter event moves its focus. */
|
|
11
13
|
function focusNative(target) { if (Platform.OS === 'web' || !target)
|
|
12
14
|
return; const handle = findNodeHandle(target); if (handle == null)
|
|
13
15
|
return; AccessibilityInfo.setAccessibilityFocus(handle); if (Platform.OS === 'android')
|
|
14
16
|
AccessibilityInfo.sendAccessibilityEvent(target, 'viewHoverEnter'); }
|
|
17
|
+
const dialogPadding = 24;
|
|
15
18
|
/** React Native's iOS Modal defaults to portrait only; opening an overlay must not rotate a landscape host. */
|
|
16
19
|
const overlayOrientations = ['portrait', 'portrait-upside-down', 'landscape', 'landscape-left', 'landscape-right'];
|
|
17
|
-
export function Dialog({ open, onOpenChange, title, description, children, initialFocusRef, returnFocusRef, closeLabel, contentMode = 'default', titleRef, stageComponent: Stage = View, stageStyle, stageTestID, backdrop, contentStyle, testID, animationType = 'none' }) {
|
|
20
|
+
export function Dialog({ open, onOpenChange, title, description, children, initialFocusRef, returnFocusRef, closeLabel, contentMode = 'default', concentric = true, accentEyebrow, titleRef, stageComponent: Stage = View, stageStyle, stageTestID, backdrop, contentStyle, frameStyle, testID, animationType = 'none' }) {
|
|
18
21
|
const { messages, reducedMotion, direction } = useHIG();
|
|
19
22
|
const colors = useColors();
|
|
20
23
|
const heading = useRef(null);
|
|
@@ -49,9 +52,8 @@ export function Dialog({ open, onOpenChange, title, description, children, initi
|
|
|
49
52
|
}, [open, resolvedAnimation, restoreFocus]);
|
|
50
53
|
useEffect(() => () => { if (frame.current !== undefined)
|
|
51
54
|
cancelAnimationFrame(frame.current); returnPending.current = false; }, []);
|
|
52
|
-
|
|
53
|
-
focusNative(initialFocusRef?.current ?? (contentMode === 'custom' ? titleRef?.current : null) ?? heading.current); }, onDismiss: restoreFocus, onRequestClose: () => onOpenChange(false), accessibilityViewIsModal: true, children: contentMode === 'custom' ? _jsxs(Stage, { style: [{ flex: 1, backgroundColor: '#000b', justifyContent: 'center', direction }, stageStyle], testID: stageTestID, children: [backdrop, _jsxs(View, { accessible: false, accessibilityLabel: title, accessibilityViewIsModal: true, onAccessibilityEscape: () => onOpenChange(false), collapsable: false, style: [{ direction }, contentStyle], testID: testID, children: [!titleRef && _jsx(Heading, { ref: heading, accessible: true, accessibilityLabel: title, style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden' }, children: title }), _jsx(Raised, { children: children })] })] }) : _jsx(SafeAreaView, { style: { flex: 1, backgroundColor: '#000b', justifyContent: 'center' }, children: _jsx(KeyboardAvoidingView, { behavior: Platform.OS === 'ios' ? 'padding' : 'height', style: { maxHeight: '90%' }, children: _jsx(ScrollView, { testID: testID, keyboardShouldPersistTaps: 'handled', contentContainerStyle: { padding:
|
|
54
|
-
return modal;
|
|
55
|
+
return _jsx(Modal, { visible: open, transparent: true, animationType: resolvedAnimation, supportedOrientations: overlayOrientations, onShow: () => { if (latest.current.open)
|
|
56
|
+
focusNative(initialFocusRef?.current ?? (contentMode === 'custom' ? titleRef?.current : null) ?? heading.current); }, onDismiss: restoreFocus, onRequestClose: () => onOpenChange(false), accessibilityViewIsModal: true, children: contentMode === 'custom' ? _jsxs(Stage, { style: [{ flex: 1, backgroundColor: '#000b', justifyContent: 'center', direction, paddingHorizontal: 8 }, stageStyle], testID: stageTestID, children: [backdrop, _jsxs(View, { accessible: false, accessibilityLabel: title, accessibilityViewIsModal: true, onAccessibilityEscape: () => onOpenChange(false), collapsable: false, style: [{ direction }, contentStyle], testID: testID, children: [!titleRef && _jsx(Heading, { ref: heading, accessible: true, accessibilityLabel: title, style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden' }, children: title }), _jsx(Raised, { children: children })] })] }) : _jsx(SafeAreaView, { style: [{ flex: 1, backgroundColor: '#000b', justifyContent: 'center', paddingHorizontal: 8 }, stageStyle], children: _jsx(KeyboardAvoidingView, { behavior: Platform.OS === 'ios' ? 'padding' : 'height', style: [{ maxHeight: '90%' }, frameStyle], children: _jsx(ScrollView, { testID: testID, keyboardShouldPersistTaps: 'handled', contentContainerStyle: { padding: dialogPadding, backgroundColor: colors.overlay, experimental_backgroundImage: accentEyebrow ? `radial-gradient(140% 80% at 50% -10%, ${withAlpha(colors.action, 0.14)}, transparent 60%)` : undefined, borderRadius: concentric ? dialogPadding + capsuleRadius : 14, boxShadow: '0 16px 48px #0008' }, children: _jsx(Raised, { children: _jsxs(Stack, { children: [accentEyebrow && _jsx(Text, { style: { color: colors.action, fontSize: 11, lineHeight: 16, fontWeight: "800", letterSpacing: 1.1, textTransform: "uppercase" }, children: accentEyebrow }), _jsx(Heading, { ref: heading, children: title }), description !== undefined && _jsx(Text, { children: description }), children, _jsx(Button, { intent: 'secondary', suppressFeedback: true, style: { marginTop: 4 }, onPress: () => onOpenChange(false), children: closeLabel ?? messages.close ?? en.close })] }) }) }) }) }) });
|
|
55
57
|
}
|
|
56
58
|
export const Sheet = Dialog;
|
|
57
59
|
export const AlertDialog = Dialog;
|
|
@@ -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,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { Text } from './surface.js';
|
|
5
|
+
import { PositionSummaryRow } from './manage-position-block.js';
|
|
6
|
+
import { ScreenHeader } from './screen-header.js';
|
|
7
|
+
import { ListGroup } from './list-group.js';
|
|
8
|
+
import { Button } from './button.js';
|
|
9
|
+
import { SegmentedControl } from './radio-group.js';
|
|
10
|
+
export function PositionsBlock({ labels, positions, onSelect, onCloseAll, closing, pnlOptions, onBack, headerAction, headingId }) {
|
|
11
|
+
const [filter, setFilter] = useState('all');
|
|
12
|
+
const options = [{ value: 'all', label: labels.all }, { value: 'wins', label: labels.wins }, { value: 'losses', label: labels.losses }];
|
|
13
|
+
const visible = positions.filter(p => filter === 'all' || (p.pnl != null && Number.isFinite(p.pnl) && (filter === 'wins' ? p.pnl > 0 : p.pnl < 0)));
|
|
14
|
+
return _jsxs(View, { 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(Text, { tone: 'muted', children: labels.empty }), _jsx(Button, { fullWidth: true, intent: 'secondary', disabled: !positions.length, busy: closing, onPress: onCloseAll, children: labels.closeAll(positions.length) })] });
|
|
15
|
+
}
|
|
@@ -37,6 +37,8 @@ export interface ScreenHeaderProps {
|
|
|
37
37
|
stickyHeaderBackground?: string;
|
|
38
38
|
/** With `stickyHeader`: space kept inside the fill above the row and to each side of it, such as the blocks' 16, so the inset fills with the header once content scrolls under it. Pass the inset here, not as `style` padding: React Native moves a sticky child's `style` onto its own wrapper, outside the fill. */
|
|
39
39
|
inset?: number;
|
|
40
|
+
/** Equal leading and trailing space when a header has multiple actions. */
|
|
41
|
+
sideWidth?: number;
|
|
40
42
|
/** Style of the header's container. With `stickyHeader` it sits outside the fill (React Native moves it onto the sticky slot's wrapper once pinned); put an inset in `inset`. */
|
|
41
43
|
style?: StyleProp<ViewStyle>;
|
|
42
44
|
}
|
|
@@ -56,4 +58,4 @@ export declare function HeaderClose({ onClose, label, testID, closeProps }: {
|
|
|
56
58
|
* edge. The settings blocks (Notifications, Signals, Sound & Haptics) draw it; the other native blocks draw a header that matches
|
|
57
59
|
* it. Import it from `@bloxwap/hig/native/screen-header` for a host pane that has no block.
|
|
58
60
|
*/
|
|
59
|
-
export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, eyebrow, hideTitle, description, stickyHeader, scrolled, stickyHeaderBackground, inset, style }: ScreenHeaderProps): React.JSX.Element;
|
|
61
|
+
export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, testID, headingId, titleRef, badge, eyebrow, hideTitle, description, stickyHeader, scrolled, stickyHeaderBackground, inset, style, sideWidth }: ScreenHeaderProps): React.JSX.Element;
|
|
@@ -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) {
|
|
@@ -36,7 +36,7 @@ export interface SwapReceive {
|
|
|
36
36
|
qr?: React.ReactNode; /** Host clipboard adapter. When set, the whole view copies the address. */
|
|
37
37
|
onCopy?: () => Promise<void> | void;
|
|
38
38
|
}
|
|
39
|
-
export interface
|
|
39
|
+
export interface SwapBlockProps {
|
|
40
40
|
/** Catalog for the To side, and for the From side unless `fromTokens` is given. */
|
|
41
41
|
tokens: readonly SwapToken[];
|
|
42
42
|
/** Assets offered on the From side, typically the connected wallet's holdings. */
|
|
@@ -144,8 +144,12 @@ export interface SwapPanelBlockProps {
|
|
|
144
144
|
* or token units through the keypad, token pickers, settings, and one action that names itself from the chosen pair.
|
|
145
145
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
146
146
|
*/
|
|
147
|
-
export declare function
|
|
148
|
-
/** @deprecated Renamed `
|
|
149
|
-
export declare const SwapPanel: typeof
|
|
150
|
-
/** @deprecated Renamed `
|
|
151
|
-
export type SwapPanelProps =
|
|
147
|
+
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, keypad, destination, details, note, noteTone, title, onBack, headingId, controls, actionIcon, lockFrom, lockTo, actionLabel, actionDisabled, actionStatus, actionIntent, limitToBalance, banner, footer, oneWay: oneWayProp, denominationSwitch, settings, view: viewProp, onViewChange, style }: SwapBlockProps): React.JSX.Element;
|
|
148
|
+
/** @deprecated Renamed `SwapBlock`. The old name keeps working until the next major release. */
|
|
149
|
+
export declare const SwapPanel: typeof SwapBlock;
|
|
150
|
+
/** @deprecated Renamed `SwapBlockProps`. */
|
|
151
|
+
export type SwapPanelProps = SwapBlockProps;
|
|
152
|
+
/** @deprecated Use SwapBlock. */
|
|
153
|
+
export declare const SwapPanelBlock: typeof SwapBlock;
|
|
154
|
+
/** @deprecated Use SwapBlockProps. */
|
|
155
|
+
export type SwapPanelBlockProps = SwapBlockProps;
|
|
@@ -25,7 +25,7 @@ export { SwapAmountCard, SwapPill } from './swap-amount-card.js';
|
|
|
25
25
|
* or token units through the keypad, token pickers, settings, and one action that names itself from the chosen pair.
|
|
26
26
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
27
27
|
*/
|
|
28
|
-
export function
|
|
28
|
+
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, keypad = 'auto', 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, settings, view: viewProp, onViewChange, style }) {
|
|
29
29
|
const env = useHIG();
|
|
30
30
|
const { direction } = env;
|
|
31
31
|
const locale = useNumberLocale();
|
|
@@ -212,5 +212,7 @@ function SwapStage({ view, animateHeight, children }) {
|
|
|
212
212
|
const fitted = sizing && sized;
|
|
213
213
|
return _jsx(Animated.View, { testID: 'swap-stage', style: fitted ? { height, overflow: 'hidden' } : undefined, children: _jsx(Animated.View, { onLayout: onLayout, style: [fitted ? { position: 'absolute', left: 0, right: 0, top: 0 } : null, { opacity: slide, transform: [{ translateX: slide.interpolate({ inputRange: [0, 1], outputRange: [travel.current * 48, 0] }) }] }], children: children }) });
|
|
214
214
|
}
|
|
215
|
-
/** @deprecated Renamed `
|
|
216
|
-
export const SwapPanel =
|
|
215
|
+
/** @deprecated Renamed `SwapBlock`. The old name keeps working until the next major release. */
|
|
216
|
+
export const SwapPanel = SwapBlock;
|
|
217
|
+
/** @deprecated Use SwapBlock. */
|
|
218
|
+
export const SwapPanelBlock = SwapBlock;
|
|
@@ -1,13 +1,13 @@
|
|
|
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. */
|
|
7
7
|
title: string;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* SwapBlock presented in the gesture sheet. Pickers and settings push inside the same sheet, which resizes to the view
|
|
11
11
|
* on show. A back press or a dismiss gesture pops a pushed view first and closes the sheet only from the main form;
|
|
12
12
|
* closing always returns to the main form. Needs the optional gesture-sheet backend, which `blocks` does not load.
|
|
13
13
|
*/
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { BottomSheetFlatList } from '@gorhom/bottom-sheet';
|
|
4
4
|
import { GestureSheet } from './gesture-sheet.js';
|
|
5
|
-
import { SwapHostContext,
|
|
5
|
+
import { SwapHostContext, SwapBlock, swapParentView } from './swap-block.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* SwapBlock presented in the gesture sheet. Pickers and settings push inside the same sheet, which resizes to the view
|
|
8
8
|
* on show. A back press or a dismiss gesture pops a pushed view first and closes the sheet only from the main form;
|
|
9
9
|
* closing always returns to the main form. Needs the optional gesture-sheet backend, which `blocks` does not load.
|
|
10
10
|
*/
|
|
@@ -22,5 +22,5 @@ export function SwapSheet({ open, onOpenChange, title, view: viewProp, onViewCha
|
|
|
22
22
|
return false; show(swapParentView(view)); return true; };
|
|
23
23
|
return _jsx(GestureSheet, { open: open, onOpenChange: next => { if (!next && leave())
|
|
24
24
|
return; onOpenChange(next); }, title: title, contentMode: 'custom', enableDynamicSizing: true, keyboardBehavior: 'interactive', onHardwareBackPress: () => { if (!leave())
|
|
25
|
-
onOpenChange(false); return true; }, children: _jsx(SwapHostContext.Provider, { value: host, children: _jsx(
|
|
25
|
+
onOpenChange(false); return true; }, children: _jsx(SwapHostContext.Provider, { value: host, children: _jsx(SwapBlock, { ...panel, view: view, onViewChange: show, style: [{ paddingHorizontal: 12, paddingBottom: 16 }, style] }) }) });
|
|
26
26
|
}
|
|
@@ -38,7 +38,7 @@ export interface TokenActionBlockProps {
|
|
|
38
38
|
onBack?: () => void;
|
|
39
39
|
/** A control on the trailing edge of the header, usually an IconButton. */
|
|
40
40
|
headerAction?: React.ReactNode;
|
|
41
|
-
/** A line under the actions, for example why some are missing. `noteTone` tints it as in
|
|
41
|
+
/** A line under the actions, for example why some are missing. `noteTone` tints it as in SwapBlock. */
|
|
42
42
|
note?: React.ReactNode;
|
|
43
43
|
noteTone?: 'muted' | 'warning' | 'negative';
|
|
44
44
|
/** Keeps the header pinned while the rest scrolls: the block becomes its own scroll view with the header as its sticky first child, transparent at rest and filled once content scrolls under it. Place it in a bounded container, such as a sheet body. */
|
|
@@ -23,10 +23,11 @@ export function TokenActionBlock({ symbol, name, value, units, unitsSuffix, unit
|
|
|
23
23
|
const colors = useColors(), t = useMessages(), { direction } = useHIG(), locale = useNumberLocale();
|
|
24
24
|
const total = value !== undefined ? value : (assets ?? []).reduce((sum, asset) => sum + (held(asset.value) ? asset.value : 0), 0);
|
|
25
25
|
// With no dollar value the units are the headline, as an AccountBlock row headlines them.
|
|
26
|
+
const showChains = chains !== undefined && chains.length > 1;
|
|
26
27
|
const headline = units !== undefined && value == null ? _jsx(AnimatedNumberReadout, { value: units, options: unitsOptions, suffix: unitsSuffix, tone: 'muted', testID: 'token-units', style: { fontSize: 14, lineHeight: 21 } }, 'units') : _jsx(AnimatedNumberReadout, { value: total, options: usd, tone: 'muted', testID: 'token-value', style: { fontSize: 14, lineHeight: 21 } }, 'value');
|
|
27
28
|
const tone = noteTone === 'warning' ? colors.warning : noteTone === 'negative' ? colors.negative : null;
|
|
28
29
|
const header = _jsxs(View, { testID: 'token-header', style: { flexDirection: 'row', alignItems: 'center', minHeight: 44 }, children: [_jsx(View, { style: { minWidth: 44, alignItems: 'flex-start' }, children: onBack ? _jsx(IconButton, { intent: 'ghost', label: t.back, suppressFeedback: true, testID: 'token-back', onPress: onBack, children: _jsx(View, { style: { transform: [{ rotate: direction === 'rtl' ? '-90deg' : '90deg' }] }, children: _jsx(ChevronIcon, { color: colors.text }) }) }) : null }), _jsx(Text, { testID: 'token-title', nativeID: headingId, accessibilityRole: 'header', numberOfLines: 1, style: { flex: 1, textAlign: 'center', fontSize: 17, lineHeight: 24, fontWeight: '600', color: colors.text }, children: symbol }), _jsx(View, { style: { minWidth: 44, alignItems: 'flex-end' }, children: headerAction })] });
|
|
29
|
-
const body = _jsxs(_Fragment, { children: [assets ||
|
|
30
|
+
const body = _jsxs(_Fragment, { children: [assets || showChains ? _jsx(BarMarkFigureContext.Provider, { value: animatedFigure, children: _jsxs(View, { testID: 'token-bars', style: { gap: 20, marginTop: 16, paddingHorizontal: 4 }, children: [assets ? _jsx(BarMark, { testID: 'token-assets', surface: false, title: name ?? symbol, elements: assets, description: headline }) : null, showChains ? _jsx(BarMark, { testID: 'token-chains', surface: false, title: chainsTitle ?? t.swapChains, elements: chains, description: formatNumber(chains.filter(chain => held(chain.value)).length, locale) }) : null] }) }) : null, actions.length > 0 ? _jsx(View, { testID: 'token-actions', style: { gap: 8, marginTop: 16 }, children: actions.map(action => _jsx(Button, { testID: `token-action-${action.id}`, fullWidth: true, intent: action.intent ?? 'secondary', disabled: action.disabled, onPress: action.onSelect, children: tokenActionLabel(action, t) }, action.id)) }) : null, note != null && note !== false ? _jsx(View, { testID: 'token-note', style: [{ marginTop: actions.length > 0 ? 8 : 16 }, tone ? { paddingVertical: 12, paddingHorizontal: 16, borderRadius: 16, backgroundColor: withAlpha(tone, 0.1) } : { paddingHorizontal: 4 }], children: _jsx(Text, { style: { fontSize: 14, lineHeight: 21, color: tone ?? colors.muted }, children: note }) }) : null] });
|
|
30
31
|
if (stickyHeader)
|
|
31
32
|
return _jsx(StickyHeaderLayout, { testID: testID, headerTestID: 'token-sticky-header', header: header, background: stickyHeaderBackground, scrollComponent: scrollComponent, children: body });
|
|
32
33
|
return _jsxs(View, { testID: testID, style: { padding: 16 }, children: [header, body] });
|
package/native-fonts/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/native-fonts
|
|
2
2
|
|
|
3
|
-
Version 0.
|
|
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.
|
|
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.
|
|
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",
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
"import": "./tokens/dist/index.js",
|
|
11
11
|
"default": "./tokens/dist/index.js"
|
|
12
12
|
},
|
|
13
|
+
"./tokens/deposit-icons": {
|
|
14
|
+
"types": "./tokens/dist/deposit-icons.d.ts",
|
|
15
|
+
"import": "./tokens/dist/deposit-icons.js",
|
|
16
|
+
"default": "./tokens/dist/deposit-icons.js"
|
|
17
|
+
},
|
|
13
18
|
"./tokens/brand": {
|
|
14
19
|
"types": "./tokens/dist/brand.d.ts",
|
|
15
20
|
"import": "./tokens/dist/brand.js",
|
|
@@ -41,6 +46,11 @@
|
|
|
41
46
|
"import": "./contracts/dist/number-flow.js",
|
|
42
47
|
"default": "./contracts/dist/number-flow.js"
|
|
43
48
|
},
|
|
49
|
+
"./contracts/login": {
|
|
50
|
+
"types": "./contracts/dist/login.d.ts",
|
|
51
|
+
"import": "./contracts/dist/login.js",
|
|
52
|
+
"default": "./contracts/dist/login.js"
|
|
53
|
+
},
|
|
44
54
|
"./contracts/messages": {
|
|
45
55
|
"types": "./contracts/dist/messages.d.ts",
|
|
46
56
|
"import": "./contracts/dist/messages.js",
|
|
@@ -215,20 +225,25 @@
|
|
|
215
225
|
"import": "./react/dist/blocks/trade-entry.js",
|
|
216
226
|
"default": "./react/dist/blocks/trade-entry.js"
|
|
217
227
|
},
|
|
228
|
+
"./react/blocks/swap-block": {
|
|
229
|
+
"types": "./react/dist/blocks/swap-block.d.ts",
|
|
230
|
+
"import": "./react/dist/blocks/swap-block.js",
|
|
231
|
+
"default": "./react/dist/blocks/swap-block.js"
|
|
232
|
+
},
|
|
218
233
|
"./react/blocks/swap-panel-block": {
|
|
219
|
-
"types": "./react/dist/blocks/swap-
|
|
220
|
-
"import": "./react/dist/blocks/swap-
|
|
221
|
-
"default": "./react/dist/blocks/swap-
|
|
234
|
+
"types": "./react/dist/blocks/swap-block.d.ts",
|
|
235
|
+
"import": "./react/dist/blocks/swap-block.js",
|
|
236
|
+
"default": "./react/dist/blocks/swap-block.js"
|
|
222
237
|
},
|
|
223
238
|
"./react/blocks/swap-panel": {
|
|
224
|
-
"types": "./react/dist/blocks/swap-
|
|
225
|
-
"import": "./react/dist/blocks/swap-
|
|
226
|
-
"default": "./react/dist/blocks/swap-
|
|
239
|
+
"types": "./react/dist/blocks/swap-block.d.ts",
|
|
240
|
+
"import": "./react/dist/blocks/swap-block.js",
|
|
241
|
+
"default": "./react/dist/blocks/swap-block.js"
|
|
227
242
|
},
|
|
228
243
|
"./react/recipes/swap-panel": {
|
|
229
|
-
"types": "./react/dist/blocks/swap-
|
|
230
|
-
"import": "./react/dist/blocks/swap-
|
|
231
|
-
"default": "./react/dist/blocks/swap-
|
|
244
|
+
"types": "./react/dist/blocks/swap-block.d.ts",
|
|
245
|
+
"import": "./react/dist/blocks/swap-block.js",
|
|
246
|
+
"default": "./react/dist/blocks/swap-block.js"
|
|
232
247
|
},
|
|
233
248
|
"./react/blocks/pickers": {
|
|
234
249
|
"types": "./react/dist/blocks/pickers.d.ts",
|
|
@@ -318,6 +333,16 @@
|
|
|
318
333
|
"import": "./react/dist/blocks/token-action-block.js",
|
|
319
334
|
"default": "./react/dist/blocks/token-action-block.js"
|
|
320
335
|
},
|
|
336
|
+
"./react/blocks/login-block": {
|
|
337
|
+
"types": "./react/dist/blocks/login-block.d.ts",
|
|
338
|
+
"import": "./react/dist/blocks/login-block.js",
|
|
339
|
+
"default": "./react/dist/blocks/login-block.js"
|
|
340
|
+
},
|
|
341
|
+
"./react/blocks/deposit-block": {
|
|
342
|
+
"types": "./react/dist/blocks/deposit-block.d.ts",
|
|
343
|
+
"import": "./react/dist/blocks/deposit-block.js",
|
|
344
|
+
"default": "./react/dist/blocks/deposit-block.js"
|
|
345
|
+
},
|
|
321
346
|
"./react/blocks/language-block": {
|
|
322
347
|
"types": "./react/dist/blocks/language-block.d.ts",
|
|
323
348
|
"import": "./react/dist/blocks/language-block.js",
|
|
@@ -393,16 +418,6 @@
|
|
|
393
418
|
"import": "./native/dist/preset-picker-block.js",
|
|
394
419
|
"default": "./native/dist/preset-picker-block.js"
|
|
395
420
|
},
|
|
396
|
-
"./react/blocks/explainer-block": {
|
|
397
|
-
"types": "./react/dist/blocks/explainer-block.d.ts",
|
|
398
|
-
"import": "./react/dist/blocks/explainer-block.js",
|
|
399
|
-
"default": "./react/dist/blocks/explainer-block.js"
|
|
400
|
-
},
|
|
401
|
-
"./native/explainer-block": {
|
|
402
|
-
"types": "./native/dist/explainer-block.d.ts",
|
|
403
|
-
"import": "./native/dist/explainer-block.js",
|
|
404
|
-
"default": "./native/dist/explainer-block.js"
|
|
405
|
-
},
|
|
406
421
|
"./react/confetti": {
|
|
407
422
|
"types": "./react/dist/confetti.d.ts",
|
|
408
423
|
"import": "./react/dist/confetti.js",
|
|
@@ -473,6 +488,16 @@
|
|
|
473
488
|
"import": "./native/dist/token-action-block.js",
|
|
474
489
|
"default": "./native/dist/token-action-block.js"
|
|
475
490
|
},
|
|
491
|
+
"./native/login-block": {
|
|
492
|
+
"types": "./native/dist/login-block.d.ts",
|
|
493
|
+
"import": "./native/dist/login-block.js",
|
|
494
|
+
"default": "./native/dist/login-block.js"
|
|
495
|
+
},
|
|
496
|
+
"./native/deposit-block": {
|
|
497
|
+
"types": "./native/dist/deposit-block.d.ts",
|
|
498
|
+
"import": "./native/dist/deposit-block.js",
|
|
499
|
+
"default": "./native/dist/deposit-block.js"
|
|
500
|
+
},
|
|
476
501
|
"./native/language-block": {
|
|
477
502
|
"types": "./native/dist/language-block.d.ts",
|
|
478
503
|
"import": "./native/dist/language-block.js",
|
|
@@ -678,7 +703,37 @@
|
|
|
678
703
|
"import": "./native/dist/toast.js",
|
|
679
704
|
"default": "./native/dist/toast.js"
|
|
680
705
|
},
|
|
681
|
-
"./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
|
+
}
|
|
682
737
|
},
|
|
683
738
|
"files": [
|
|
684
739
|
"README.md",
|
package/react/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/react
|
|
2
2
|
|
|
3
|
-
Version 0.
|
|
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
|
|