@bloxwap/hig 0.7.0 → 0.8.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 +2 -2
- package/chart/README.md +13 -2
- package/chart/dist/altimeter-burst.d.ts +4 -0
- package/chart/dist/altimeter-burst.js +43 -0
- package/chart/dist/altimeter-chart.d.ts +52 -0
- package/chart/dist/altimeter-chart.js +275 -0
- package/chart/dist/altimeter-model.d.ts +43 -0
- package/chart/dist/altimeter-model.js +148 -0
- package/chart/dist/altimeter-targets.d.ts +33 -0
- package/chart/dist/altimeter-targets.js +88 -0
- package/chart/dist/bitcoin-price.d.ts +8 -0
- package/chart/dist/bitcoin-price.js +41 -0
- package/chart/dist/champions-league.d.ts +19 -0
- package/chart/dist/champions-league.js +104 -0
- package/chart/dist/index.d.ts +6 -0
- package/chart/dist/index.js +5 -0
- package/chart/dist/outcome-chart.d.ts +37 -0
- package/chart/dist/outcome-chart.js +212 -0
- package/chart/dist/outcome-model.d.ts +43 -0
- package/chart/dist/outcome-model.js +71 -0
- package/chart/dist/plus-grid.d.ts +6 -0
- package/chart/dist/plus-grid.js +29 -0
- package/contracts/README.md +1 -1
- package/contracts/dist/avatar.d.ts +68 -0
- package/contracts/dist/avatar.js +93 -0
- package/contracts/dist/confetti.d.ts +174 -0
- package/contracts/dist/confetti.js +138 -0
- package/contracts/dist/decimal.d.ts +7 -0
- package/contracts/dist/decimal.js +35 -0
- package/contracts/dist/index.d.ts +29 -2
- package/contracts/dist/index.js +123 -4
- package/contracts/dist/invariants.d.ts +17 -0
- package/contracts/dist/invariants.js +24 -0
- package/contracts/dist/messages.d.ts +56 -2
- package/contracts/dist/messages.js +20 -2
- package/contracts/dist/number-flow.d.ts +90 -0
- package/contracts/dist/number-flow.js +150 -0
- package/contracts/dist/qr.d.ts +151 -0
- package/contracts/dist/qr.js +581 -0
- package/contracts/dist/toast.d.ts +168 -0
- package/contracts/dist/toast.js +171 -0
- package/feedback/README.md +1 -1
- package/feedback/dist/contract.js +1 -1
- package/feedback/dist/react.js +2 -4
- package/native/README.md +6 -1
- package/native/dist/account-block.d.ts +10 -1
- package/native/dist/account-block.js +17 -7
- package/native/dist/animated-number-model.d.ts +41 -1
- package/native/dist/animated-number-model.js +201 -23
- package/native/dist/animated-number.d.ts +39 -1
- package/native/dist/animated-number.js +161 -16
- package/native/dist/announce.d.ts +2 -0
- package/native/dist/announce.js +10 -0
- package/native/dist/asset-balance-row.d.ts +3 -1
- package/native/dist/asset-balance-row.js +15 -4
- package/native/dist/assets-block.d.ts +115 -0
- package/native/dist/assets-block.js +87 -0
- package/native/dist/async-result.d.ts +2 -0
- package/native/dist/async-result.js +11 -0
- package/native/dist/avatar-frame.d.ts +29 -0
- package/native/dist/avatar-frame.js +56 -0
- package/native/dist/avatar.d.ts +21 -0
- package/native/dist/avatar.js +31 -0
- package/native/dist/bar-mark.d.ts +2 -0
- package/native/dist/bar-mark.js +4 -2
- package/native/dist/bar-pnl.js +2 -1
- package/native/dist/blocks.d.ts +6 -1
- package/native/dist/blocks.js +5 -0
- package/native/dist/brand.js +2 -1
- package/native/dist/button.d.ts +7 -2
- package/native/dist/button.js +13 -3
- package/native/dist/checkbox.js +2 -1
- package/native/dist/confetti.d.ts +33 -0
- package/native/dist/confetti.js +143 -0
- package/native/dist/confirm-block.d.ts +98 -0
- package/native/dist/confirm-block.js +48 -0
- package/native/dist/data.js +2 -0
- package/native/dist/explainer-block.d.ts +91 -0
- package/native/dist/explainer-block.js +34 -0
- package/native/dist/field.d.ts +5 -1
- package/native/dist/field.js +27 -6
- package/native/dist/gesture-sheet-model.d.ts +50 -0
- package/native/dist/gesture-sheet-model.js +105 -0
- package/native/dist/gesture-sheet-next.d.ts +82 -0
- package/native/dist/gesture-sheet-next.js +315 -0
- package/native/dist/gesture-sheet.d.ts +5 -1
- package/native/dist/gesture-sheet.js +13 -6
- package/native/dist/icons.d.ts +9 -6
- package/native/dist/icons.js +25 -24
- package/native/dist/language-block.d.ts +10 -1
- package/native/dist/language-block.js +11 -4
- package/native/dist/list-group.d.ts +3 -1
- package/native/dist/list-group.js +26 -13
- package/native/dist/manage-position-block.d.ts +8 -1
- package/native/dist/manage-position-block.js +7 -2
- package/native/dist/market-row.js +19 -8
- package/native/dist/navigation.js +5 -3
- package/native/dist/number-format.d.ts +6 -0
- package/native/dist/number-format.js +9 -0
- package/native/dist/pickers.d.ts +8 -0
- package/native/dist/pickers.js +3 -3
- package/native/dist/position-block.d.ts +5 -5
- package/native/dist/preset-group.d.ts +31 -0
- package/native/dist/preset-group.js +39 -0
- package/native/dist/preset-picker-block.d.ts +107 -0
- package/native/dist/preset-picker-block.js +43 -0
- package/native/dist/profile-block.d.ts +10 -1
- package/native/dist/profile-block.js +8 -3
- package/native/dist/provider.d.ts +5 -2
- package/native/dist/provider.js +27 -5
- package/native/dist/qr-code.d.ts +33 -0
- package/native/dist/qr-code.js +29 -0
- package/native/dist/radio-group.d.ts +19 -7
- package/native/dist/radio-group.js +39 -10
- package/native/dist/reward-block.d.ts +10 -7
- package/native/dist/reward-block.js +9 -4
- package/native/dist/screen-header.d.ts +13 -3
- package/native/dist/screen-header.js +12 -4
- package/native/dist/select.js +4 -2
- package/native/dist/selection.d.ts +2 -1
- package/native/dist/selection.js +1 -0
- package/native/dist/setting-switch.d.ts +1 -1
- package/native/dist/setting-switch.js +7 -3
- package/native/dist/slider.js +5 -1
- package/native/dist/sound-haptics-block.js +1 -1
- package/native/dist/status.d.ts +41 -9
- package/native/dist/status.js +34 -17
- package/native/dist/sticky-header.js +9 -1
- package/native/dist/swap-amount-card.d.ts +57 -0
- package/native/dist/swap-amount-card.js +31 -0
- package/native/dist/swap-panel-block.d.ts +9 -3
- package/native/dist/swap-panel-block.js +59 -33
- package/native/dist/swap-parts.d.ts +3 -10
- package/native/dist/swap-parts.js +22 -24
- package/native/dist/swap-shared.d.ts +2 -2
- package/native/dist/swap-shared.js +10 -6
- package/native/dist/swap-views.js +1 -1
- package/native/dist/target-block.d.ts +7 -1
- package/native/dist/target-block.js +13 -6
- package/native/dist/toast.d.ts +47 -0
- package/native/dist/toast.js +386 -0
- package/native/dist/token-action-block.d.ts +10 -1
- package/native/dist/token-action-block.js +9 -4
- package/native/dist/trade-history-list-block.js +7 -4
- package/native/dist/wallet-address-core.js +6 -3
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +111 -2
- package/react/README.md +3 -1
- package/react/dist/animated-number-flow.d.ts +72 -0
- package/react/dist/animated-number-flow.js +316 -0
- package/react/dist/animated-number-model.d.ts +18 -0
- package/react/dist/animated-number-model.js +75 -5
- package/react/dist/animated-number.d.ts +45 -1
- package/react/dist/animated-number.js +137 -6
- package/react/dist/asset-balance-row.d.ts +3 -1
- package/react/dist/asset-balance-row.js +10 -4
- package/react/dist/async-result.d.ts +2 -0
- package/react/dist/async-result.js +11 -0
- package/react/dist/avatar.d.ts +25 -0
- package/react/dist/avatar.js +50 -0
- package/react/dist/blocks/account-block.d.ts +5 -1
- package/react/dist/blocks/account-block.js +11 -6
- package/react/dist/blocks/assets-block.d.ts +106 -0
- package/react/dist/blocks/assets-block.js +135 -0
- package/react/dist/blocks/confirm-block.d.ts +91 -0
- package/react/dist/blocks/confirm-block.js +31 -0
- package/react/dist/blocks/explainer-block.d.ts +80 -0
- package/react/dist/blocks/explainer-block.js +20 -0
- package/react/dist/blocks/install-command.js +3 -1
- package/react/dist/blocks/language-block.d.ts +5 -1
- package/react/dist/blocks/language-block.js +4 -3
- package/react/dist/blocks/manage-position-block.d.ts +3 -1
- package/react/dist/blocks/manage-position-block.js +2 -2
- package/react/dist/blocks/market-row.js +8 -3
- package/react/dist/blocks/notifications-block.d.ts +3 -1
- package/react/dist/blocks/notifications-block.js +2 -2
- package/react/dist/blocks/pickers.d.ts +9 -0
- package/react/dist/blocks/pickers.js +4 -2
- package/react/dist/blocks/position-block.d.ts +3 -3
- package/react/dist/blocks/preset-picker-block.d.ts +85 -0
- package/react/dist/blocks/preset-picker-block.js +19 -0
- package/react/dist/blocks/profile-block.d.ts +5 -1
- package/react/dist/blocks/profile-block.js +12 -13
- package/react/dist/blocks/reward-block.d.ts +13 -8
- package/react/dist/blocks/reward-block.js +7 -4
- package/react/dist/blocks/screen-header.d.ts +10 -2
- package/react/dist/blocks/screen-header.js +7 -4
- package/react/dist/blocks/setting-switch.js +6 -3
- package/react/dist/blocks/signals-block.d.ts +3 -1
- package/react/dist/blocks/signals-block.js +4 -3
- package/react/dist/blocks/sound-haptics-block.d.ts +3 -1
- package/react/dist/blocks/sound-haptics-block.js +2 -2
- package/react/dist/blocks/sticky-header.d.ts +14 -4
- package/react/dist/blocks/sticky-header.js +68 -8
- package/react/dist/blocks/swap/settings.js +2 -1
- package/react/dist/blocks/swap/shared.d.ts +22 -22
- package/react/dist/blocks/swap/shared.js +30 -28
- package/react/dist/blocks/swap-panel-block.d.ts +10 -3
- package/react/dist/blocks/swap-panel-block.js +71 -36
- package/react/dist/blocks/target-block.d.ts +7 -1
- package/react/dist/blocks/target-block.js +10 -4
- package/react/dist/blocks/token-action-block.d.ts +5 -1
- package/react/dist/blocks/token-action-block.js +2 -2
- package/react/dist/blocks/trade-history-detail-block.d.ts +3 -1
- package/react/dist/blocks/trade-history-detail-block.js +2 -2
- package/react/dist/blocks/trade-history-list-block.d.ts +3 -1
- package/react/dist/blocks/trade-history-list-block.js +7 -4
- package/react/dist/blocks.d.ts +5 -1
- package/react/dist/blocks.js +4 -0
- package/react/dist/brand.js +2 -1
- package/react/dist/button.d.ts +9 -3
- package/react/dist/button.js +8 -3
- package/react/dist/confetti.d.ts +27 -0
- package/react/dist/confetti.js +240 -0
- package/react/dist/data.js +8 -1
- package/react/dist/field.d.ts +6 -1
- package/react/dist/field.js +18 -9
- package/react/dist/gesture-sheet.d.ts +15 -1
- package/react/dist/gesture-sheet.js +53 -8
- package/react/dist/list-group.js +11 -7
- package/react/dist/navigation.js +11 -3
- package/react/dist/overlay.d.ts +28 -3
- package/react/dist/overlay.js +29 -3
- package/react/dist/preset-group.d.ts +30 -0
- package/react/dist/preset-group.js +13 -0
- package/react/dist/provider.d.ts +2 -2
- package/react/dist/provider.js +23 -6
- package/react/dist/qr-code.d.ts +32 -0
- package/react/dist/qr-code.js +28 -0
- package/react/dist/select.js +10 -3
- package/react/dist/selection.d.ts +13 -5
- package/react/dist/selection.js +13 -8
- package/react/dist/slider.js +5 -1
- package/react/dist/status.d.ts +14 -10
- package/react/dist/status.js +17 -9
- package/react/dist/styles.css +238 -163
- package/react/dist/toast.d.ts +19 -12
- package/react/dist/toast.js +29 -7
- package/react/dist/wallet-address-core.d.ts +8 -4
- package/react/dist/wallet-address-core.js +10 -5
- package/tokens/README.md +2 -2
- package/tokens/dist/index.d.ts +16 -0
- package/tokens/dist/index.js +16 -0
- package/tokens/dist/manifest.json +8 -0
- package/tokens/dist/tokens.css +6 -0
|
@@ -9,12 +9,49 @@ function scroller(node) {
|
|
|
9
9
|
}
|
|
10
10
|
return null;
|
|
11
11
|
}
|
|
12
|
+
/** The custom properties the stylesheet reads for the pinned inset and the fill above it. */
|
|
13
|
+
const insetProperty = '--hig-sticky-inset', coverProperty = '--hig-sticky-cover';
|
|
14
|
+
const length = (value) => `${value}px`;
|
|
15
|
+
const px = (value) => { const number = parseFloat(value ?? ''); return Number.isFinite(number) ? number : 0; };
|
|
16
|
+
/** True when something that takes space in the flow comes before `node`; hidden and out-of-flow siblings do not count. */
|
|
17
|
+
function follows(node) {
|
|
18
|
+
for (let sibling = node.previousElementSibling; sibling; sibling = sibling.previousElementSibling) {
|
|
19
|
+
const style = getComputedStyle(sibling);
|
|
20
|
+
if (style.display === 'none' || style.position === 'absolute' || style.position === 'fixed')
|
|
21
|
+
continue;
|
|
22
|
+
if (sibling.getBoundingClientRect().height > 0)
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* How far the header rests below the edge it sticks to: the scroller's content edge (browsers stick inside the scroller's own
|
|
29
|
+
* padding) or the viewport. When the header leads every box between it and the scroller, that distance is the top margins,
|
|
30
|
+
* borders and padding of those boxes, such as a pane's padding; sticking at it keeps the header where it rests. A header that
|
|
31
|
+
* follows other content returns `null`: it scrolls up to the edge before it pins, as before.
|
|
32
|
+
*/
|
|
33
|
+
export function stickyRestingInset(header, root) {
|
|
34
|
+
let inset = px(getComputedStyle(header).marginTop);
|
|
35
|
+
for (let node = header, parent = header.parentElement; parent && parent !== root; node = parent, parent = parent.parentElement) {
|
|
36
|
+
if (follows(node))
|
|
37
|
+
return null;
|
|
38
|
+
const style = getComputedStyle(parent);
|
|
39
|
+
inset += px(style.borderTopWidth) + px(style.paddingTop);
|
|
40
|
+
if (parent === document.documentElement)
|
|
41
|
+
break;
|
|
42
|
+
inset += px(style.marginTop);
|
|
43
|
+
}
|
|
44
|
+
return inset;
|
|
45
|
+
}
|
|
12
46
|
/**
|
|
13
47
|
* Marks a pinned header `data-scrolled` once content has scrolled under it, so its fill appears only then and it stays
|
|
14
|
-
* transparent at rest
|
|
15
|
-
* the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
48
|
+
* transparent at rest, and pins it where it rests so it does not move when it starts to stick, whatever padding sits between
|
|
49
|
+
* it and the scroller. The header's parent is the content: the header is scrolled once the parent has moved up past the point
|
|
50
|
+
* where the header pins (or the scroller is the parent and has moved). The pinned inset is `--hig-sticky-inset`, and
|
|
51
|
+
* `--hig-sticky-cover` is how far above the header the fill reaches to the scroller's edge, so content does not show through
|
|
52
|
+
* the gap; `data-sticky-inset` marks a header with such a gap. Where the browser supports scroll-driven animations the
|
|
53
|
+
* stylesheet fades the fill in on the same rule for a header that pins at the scroller's very edge; this keeps every other
|
|
54
|
+
* browser, a header with a gap and reduced motion in step with it.
|
|
18
55
|
*/
|
|
19
56
|
export function useStickyHeader(header, enabled) {
|
|
20
57
|
useEffect(() => {
|
|
@@ -30,14 +67,37 @@ export function useStickyHeader(header, enabled) {
|
|
|
30
67
|
// stylesheet leaves the scroll-driven fill off (data-sticky-own) and this script alone marks the moment.
|
|
31
68
|
const own = root === content;
|
|
32
69
|
element.toggleAttribute('data-sticky-own', own);
|
|
70
|
+
let inset = 0, leading = false;
|
|
71
|
+
const measure = () => {
|
|
72
|
+
const resting = stickyRestingInset(element, root);
|
|
73
|
+
leading = resting !== null;
|
|
74
|
+
inset = Math.max(0, resting ?? 0);
|
|
75
|
+
const pad = root ? px(getComputedStyle(root).paddingTop) : 0;
|
|
76
|
+
// Any gap above the pinned header (its own inset or the scroller's padding) hands the fill to the script, which marks the
|
|
77
|
+
// moment it pins; a scroll-driven fill would wait for the parent to reach the scroller's outer edge.
|
|
78
|
+
element.toggleAttribute('data-sticky-inset', inset + pad > 0.5);
|
|
79
|
+
element.style.setProperty(insetProperty, length(inset));
|
|
80
|
+
element.style.setProperty(coverProperty, length(inset + pad));
|
|
81
|
+
};
|
|
33
82
|
const update = () => {
|
|
34
|
-
|
|
83
|
+
let scrolled;
|
|
84
|
+
if (own)
|
|
85
|
+
scrolled = content.scrollTop > 0;
|
|
86
|
+
else if (leading) {
|
|
87
|
+
// The line the header pins to, and where the header would sit without sticking: the parent's content edge.
|
|
88
|
+
const edge = root ? root.getBoundingClientRect().top + root.clientTop + px(getComputedStyle(root).paddingTop) : 0;
|
|
89
|
+
const parent = getComputedStyle(content), natural = content.getBoundingClientRect().top + px(parent.borderTopWidth) + px(parent.paddingTop) + px(getComputedStyle(element).marginTop);
|
|
90
|
+
scrolled = natural < edge + inset - 0.5;
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
scrolled = content.getBoundingClientRect().top < (root ? root.getBoundingClientRect().top : 0) - 0.5;
|
|
35
94
|
if (element.hasAttribute('data-scrolled') !== scrolled)
|
|
36
95
|
element.toggleAttribute('data-scrolled', scrolled);
|
|
37
96
|
};
|
|
38
|
-
update();
|
|
97
|
+
const resize = () => { measure(); update(); };
|
|
98
|
+
resize();
|
|
39
99
|
target.addEventListener('scroll', update, { passive: true });
|
|
40
|
-
window.addEventListener('resize',
|
|
41
|
-
return () => { target.removeEventListener('scroll', update); window.removeEventListener('resize',
|
|
100
|
+
window.addEventListener('resize', resize, { passive: true });
|
|
101
|
+
return () => { target.removeEventListener('scroll', update); window.removeEventListener('resize', resize); element.removeAttribute('data-scrolled'); element.removeAttribute('data-sticky-own'); element.removeAttribute('data-sticky-inset'); element.style.removeProperty(insetProperty); element.style.removeProperty(coverProperty); };
|
|
42
102
|
}, [header, enabled]);
|
|
43
103
|
}
|
|
@@ -18,6 +18,7 @@ export function SwapSettings({ view, onViewChange, onBack, denomination, onDenom
|
|
|
18
18
|
const preset = slippagePresets.find(value => Math.abs(value - slippage) < 1e-9);
|
|
19
19
|
const row = (label, value, target) => _jsxs("button", { type: 'button', className: 'hig-swap-setting', onClick: () => onViewChange(target), children: [_jsx("span", { children: label }), _jsxs("span", { className: 'hig-swap-setting-value', children: [value, _jsx(SwapIcon, { name: 'chevron', size: 16 })] }), _jsx(PressDecoration, { kind: 'row' })] });
|
|
20
20
|
const slippageRow = row(messages.swapSlippageTitle ?? en.swapSlippageTitle, _jsx(SwapNumber, { ...percentNumber(slippage) }), 'slippage'), feesRow = row(messages.swapFees ?? en.swapFees, feeText, 'fees');
|
|
21
|
-
return _jsxs("div", { className: 'hig-swap-settings-view', role: 'group', "aria-label": title, children: [_jsx(SwapViewHeader, { title: title, titleRef: heading, backLabel: messages.back ?? en.back, onBack: onBack }), view === 'settings' && _jsxs("div", { className: 'hig-swap-settings', children: [onDenominationChange && _jsx(SegmentedControl, { label: (messages.swapDenomination ?? en.swapDenomination), options: [{ value: 'usd', label: (messages.swapDollars ?? en.swapDollars) }, { value: 'token', label: (messages.swapUnits ?? en.swapUnits) }], value: denomination, onValueChange: value => onDenominationChange(value) }), onSlippageChange && slippageRow, feesRow, children] }), view === 'slippage' && onSlippageChange && _jsxs("div", { className: 'hig-swap-settings hig-swap-presets', children: [_jsx(SegmentedControl, { label: (messages.swapSlippageTitle ?? en.swapSlippageTitle), options: slippagePresets.map(value => ({ value: String(value), label: formatPercent(value) })), value: preset === undefined ? '' : String(preset), onValueChange: value => { setCustom(null); onSlippageChange(Number(value)); } }), _jsx(Field, { label: (messages.swapSlippageCustom ?? en.swapSlippageCustom), children: _jsx(Input, { inputMode: 'decimal', value: custom ?? String(Number((slippage * 100).toFixed(4))), onChange: event => { const raw = event.target.value
|
|
21
|
+
return _jsxs("div", { className: 'hig-swap-settings-view', role: 'group', "aria-label": title, children: [_jsx(SwapViewHeader, { title: title, titleRef: heading, backLabel: messages.back ?? en.back, onBack: () => { setCustom(null); onBack(); } }), view === 'settings' && _jsxs("div", { className: 'hig-swap-settings', children: [onDenominationChange && _jsx(SegmentedControl, { label: (messages.swapDenomination ?? en.swapDenomination), options: [{ value: 'usd', label: (messages.swapDollars ?? en.swapDollars) }, { value: 'token', label: (messages.swapUnits ?? en.swapUnits) }], value: denomination, onValueChange: value => onDenominationChange(value) }), onSlippageChange && slippageRow, feesRow, children] }), view === 'slippage' && onSlippageChange && _jsxs("div", { className: 'hig-swap-settings hig-swap-presets', children: [_jsx(SegmentedControl, { label: (messages.swapSlippageTitle ?? en.swapSlippageTitle), options: slippagePresets.map(value => ({ value: String(value), label: formatPercent(value) })), value: preset === undefined ? '' : String(preset), onValueChange: value => { setCustom(null); onSlippageChange(Number(value)); } }), _jsx(Field, { label: (messages.swapSlippageCustom ?? en.swapSlippageCustom), children: _jsx(Input, { inputMode: 'decimal', onBlur: () => setCustom(null), value: custom ?? String(Number((slippage * 100).toFixed(4))), onChange: event => { const raw = event.target.value; const percent = Number(raw); if (!/^\d*\.?\d*$/.test(raw) || !Number.isFinite(percent) || percent > 50)
|
|
22
|
+
return; setCustom(raw); if (raw !== '' && raw !== '.')
|
|
22
23
|
onSlippageChange(percent / 100); } }) })] }), view === 'fees' && _jsxs("dl", { className: 'hig-swap-fees', children: [fees?.map(item => _jsxs("div", { children: [_jsx("dt", { children: item.label }), _jsx("dd", { children: _jsx(SwapNumber, { ...usdNumber(item.usd) }) })] }, item.label)), _jsxs("div", { className: 'hig-swap-fees-total', children: [_jsx("dt", { children: (messages.swapFeeTotal ?? en.swapFeeTotal) }), _jsx("dd", { className: 'hig-number', children: feeText })] })] })] });
|
|
23
24
|
}
|
|
@@ -12,7 +12,7 @@ export interface SwapToken {
|
|
|
12
12
|
/** Artwork: an image URL, or the host's own element (an inline SVG, say), which fills the disc. A missing token icon falls back to the symbol's first letters. */
|
|
13
13
|
icon?: SwapArtwork;
|
|
14
14
|
chainIcon?: SwapArtwork;
|
|
15
|
-
/** Most decimal places a token amount may be typed with, for example 6 for USDC.
|
|
15
|
+
/** Most decimal places a token amount may be typed with, for example 6 for USDC. Up to 100 when omitted; explicit precision must be an integer from 0 to 100. Dollars always stop at two. */
|
|
16
16
|
decimals?: number;
|
|
17
17
|
/** Holdings in token units, when the host knows them. Enables Max, Test and the balance check. */
|
|
18
18
|
balance?: number | null;
|
|
@@ -46,7 +46,7 @@ export declare const trimNumber: (value: number, digits?: number) => string;
|
|
|
46
46
|
/** Keeps digits and one decimal point, and strips leading zeros; never returns an empty string. */
|
|
47
47
|
export declare function sanitizeAmount(raw: string): string;
|
|
48
48
|
/** Token units shown in the active denomination. Dollars floor to the cent so Max never resolves to more than the balance. */
|
|
49
|
-
export declare function unitsToEntry(units: number, mode: SwapDenomination, price: number): string;
|
|
49
|
+
export declare function unitsToEntry(units: number | string, mode: SwapDenomination, price: number): string;
|
|
50
50
|
/** Applies one keypad or keyboard key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals, token units at `decimals` when given. */
|
|
51
51
|
export declare function applyAmountKey(current: string, key: string, mode: SwapDenomination, decimals?: number): string;
|
|
52
52
|
/** Case-insensitive substring or in-order subsequence match. */
|
|
@@ -89,27 +89,27 @@ export declare function testAmount(token: SwapToken): number;
|
|
|
89
89
|
export declare const shortAddress: (address: string) => string;
|
|
90
90
|
/** A stable two-stop gradient for a wallet address, so the same wallet always looks the same. */
|
|
91
91
|
export declare function addressGradient(address: string): string;
|
|
92
|
-
declare const
|
|
93
|
-
flip:
|
|
94
|
-
down:
|
|
95
|
-
reset:
|
|
96
|
-
menu:
|
|
97
|
-
close:
|
|
98
|
-
back:
|
|
99
|
-
chevron:
|
|
100
|
-
expand:
|
|
101
|
-
delete:
|
|
102
|
-
sliders:
|
|
103
|
-
flask:
|
|
104
|
-
scan:
|
|
105
|
-
flame:
|
|
106
|
-
logout:
|
|
107
|
-
wallet:
|
|
108
|
-
info:
|
|
109
|
-
lock:
|
|
92
|
+
declare const symbols: {
|
|
93
|
+
flip: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
94
|
+
down: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
95
|
+
reset: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
96
|
+
menu: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
97
|
+
close: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
98
|
+
back: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
99
|
+
chevron: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
100
|
+
expand: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
101
|
+
delete: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
102
|
+
sliders: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
103
|
+
flask: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
104
|
+
scan: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
105
|
+
flame: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
106
|
+
logout: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
107
|
+
wallet: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
108
|
+
info: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
109
|
+
lock: import("@bloxwap/icons/react/create-icon").IconComponent;
|
|
110
110
|
};
|
|
111
|
-
export type SwapIconName = keyof typeof
|
|
112
|
-
/**
|
|
111
|
+
export type SwapIconName = keyof typeof symbols;
|
|
112
|
+
/** Shared outline symbol; the containing control carries its accessible name. */
|
|
113
113
|
export declare function SwapIcon({ name, size }: {
|
|
114
114
|
name: SwapIconName;
|
|
115
115
|
size?: number;
|
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ArrowDown } from '@bloxwap/icons/react/arrow-down';
|
|
4
|
+
import { ArrowUpDown } from '@bloxwap/icons/react/arrow-up-down';
|
|
5
|
+
import { ChevronDown } from '@bloxwap/icons/react/chevron-down';
|
|
6
|
+
import { ChevronLeft } from '@bloxwap/icons/react/chevron-left';
|
|
7
|
+
import { ChevronRight } from '@bloxwap/icons/react/chevron-right';
|
|
8
|
+
import { Delete } from '@bloxwap/icons/react/delete';
|
|
9
|
+
import { Flame } from '@bloxwap/icons/react/flame';
|
|
10
|
+
import { FlaskConical } from '@bloxwap/icons/react/flask-conical';
|
|
11
|
+
import { Info } from '@bloxwap/icons/react/info';
|
|
12
|
+
import { Lock } from '@bloxwap/icons/react/lock';
|
|
13
|
+
import { LogOut } from '@bloxwap/icons/react/log-out';
|
|
14
|
+
import { Menu } from '@bloxwap/icons/react/menu';
|
|
15
|
+
import { RotateCcw } from '@bloxwap/icons/react/rotate-ccw';
|
|
16
|
+
import { ScanLine } from '@bloxwap/icons/react/scan-line';
|
|
17
|
+
import { SlidersHorizontal } from '@bloxwap/icons/react/sliders-horizontal';
|
|
18
|
+
import { Wallet } from '@bloxwap/icons/react/wallet';
|
|
19
|
+
import { X } from '@bloxwap/icons/react/x';
|
|
20
|
+
import { decimal, decimalMultiply, decimalDivide } from '@bloxwap/hig/contracts';
|
|
3
21
|
import { AnimatedNumberReadout } from '../../animated-number.js';
|
|
4
22
|
import { PressDecoration } from '../../provider.js';
|
|
5
23
|
import { figureProps } from '../../figure.js';
|
|
6
24
|
/** Artwork in a disc: the URL as an image, the host's element inside a clipped wrapper. */
|
|
7
25
|
export const swapArt = (icon, className, lazy) => typeof icon === 'string' ? _jsx("img", { className: className, src: icon, alt: '', loading: lazy ? 'lazy' : undefined }) : _jsx("span", { className: `hig-swap-art${className ? ` ${className}` : ''}`, "aria-hidden": 'true', children: icon });
|
|
8
26
|
export function swapAction(from, to) {
|
|
9
|
-
if (!from || !to
|
|
27
|
+
if (!from || !to)
|
|
10
28
|
return 'send';
|
|
11
|
-
|
|
29
|
+
if (String(from.chainId) !== String(to.chainId))
|
|
30
|
+
return 'bridge';
|
|
31
|
+
return from.id === to.id ? 'send' : 'swap';
|
|
12
32
|
}
|
|
13
33
|
/** A clean numeric string: no trailing zeros, at most `digits` decimals. */
|
|
14
34
|
export const trimNumber = (value, digits = 8) => String(Number((Number.isFinite(value) ? value : 0).toFixed(digits)));
|
|
@@ -24,8 +44,8 @@ export function sanitizeAmount(raw) {
|
|
|
24
44
|
/** Token units shown in the active denomination. Dollars floor to the cent so Max never resolves to more than the balance. */
|
|
25
45
|
export function unitsToEntry(units, mode, price) {
|
|
26
46
|
if (mode === 'token')
|
|
27
|
-
return
|
|
28
|
-
return price > 0 ?
|
|
47
|
+
return decimal(units);
|
|
48
|
+
return price > 0 ? decimalMultiply(units, price, 2) : '0';
|
|
29
49
|
}
|
|
30
50
|
/** Applies one keypad or keyboard key (`0`–`9`, `.`, `back`) to an amount string. Dollars stop at two decimals, token units at `decimals` when given. */
|
|
31
51
|
export function applyAmountKey(current, key, mode, decimals) {
|
|
@@ -70,9 +90,10 @@ export const formatPercent = (fraction) => `${Number((fraction * 100).toFixed(4)
|
|
|
70
90
|
/** A small trial amount: 1% of holdings, capped at about one dollar's worth. */
|
|
71
91
|
export function testAmount(token) {
|
|
72
92
|
const balance = token.balance ?? 0, price = token.price ?? 0;
|
|
73
|
-
if (!(balance > 0))
|
|
93
|
+
if (!(balance > 0) || !Number.isFinite(balance))
|
|
74
94
|
return 0;
|
|
75
|
-
|
|
95
|
+
const fraction = decimalDivide(balance, 100, token.decimals ?? 18);
|
|
96
|
+
return Number(decimal(price > 0 ? Math.min(Number(fraction), Number(decimalDivide(1, price, token.decimals ?? 18))) : fraction, token.decimals ?? 18));
|
|
76
97
|
}
|
|
77
98
|
export const shortAddress = (address) => address.length <= 12 ? address : `${address.slice(0, 6)}…${address.slice(-4)}`;
|
|
78
99
|
/** A stable two-stop gradient for a wallet address, so the same wallet always looks the same. */
|
|
@@ -82,28 +103,9 @@ export function addressGradient(address) {
|
|
|
82
103
|
hash = (hash * 31 + character.charCodeAt(0)) >>> 0;
|
|
83
104
|
return `linear-gradient(135deg,hsl(${hash % 360} 80% 62%),hsl(${(hash >>> 8) % 360} 75% 42%))`;
|
|
84
105
|
}
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
down: _jsx("path", { d: 'M10 3.5v13m0 0-4.5-4.5M10 16.5l4.5-4.5' }),
|
|
89
|
-
reset: _jsx("path", { d: 'M4 10a6 6 0 1 0 2-4.5M4 4v3h3' }),
|
|
90
|
-
menu: _jsx("path", { d: 'M4 6h12M4 10h12M4 14h12' }),
|
|
91
|
-
close: _jsx("path", { d: 'm5.5 5.5 9 9m0-9-9 9' }),
|
|
92
|
-
back: _jsx("path", { d: 'm12 4.5-5.5 5.5 5.5 5.5' }),
|
|
93
|
-
chevron: _jsx("path", { d: 'm7.5 4.5 5.5 5.5-5.5 5.5' }),
|
|
94
|
-
expand: _jsx("path", { d: 'm5 7.5 5 5 5-5' }),
|
|
95
|
-
delete: _jsx("path", { d: 'M7.5 4.5h8a1.5 1.5 0 0 1 1.5 1.5v8a1.5 1.5 0 0 1-1.5 1.5h-8L2.5 10ZM10 8l4 4m0-4-4 4' }),
|
|
96
|
-
sliders: _jsx("path", { d: 'M4 6h6m4 0h2M4 14h2m4 0h6M12 4v4M8 12v4' }),
|
|
97
|
-
flask: _jsx("path", { d: 'M8 3.5h4M8.75 3.5v4.75L4.5 15.5a1 1 0 0 0 .9 1.5h9.2a1 1 0 0 0 .9-1.5l-4.25-7.25V3.5M6.5 12.5h7' }),
|
|
98
|
-
scan: _jsx("path", { d: 'M4 7V5a1 1 0 0 1 1-1h2M13 4h2a1 1 0 0 1 1 1v2M16 13v2a1 1 0 0 1-1 1h-2M7 16H5a1 1 0 0 1-1-1v-2M4 10h12' }),
|
|
99
|
-
flame: _jsx("path", { d: 'M10 17a5 5 0 0 0 5-5c0-3-2.5-4.5-3-8-2 1-3.5 3-3.5 5.5C7.5 8.5 7 7.5 7 7c-1.5 1.5-2 3-2 5a5 5 0 0 0 5 5Z' }),
|
|
100
|
-
logout: _jsx("path", { d: 'M8 4H5.5A1.5 1.5 0 0 0 4 5.5v9A1.5 1.5 0 0 0 5.5 16H8M12.5 6.5 16 10l-3.5 3.5M16 10H8' }),
|
|
101
|
-
wallet: _jsx("path", { d: 'M3.5 6.5A1.5 1.5 0 0 1 5 5h9.5A1.5 1.5 0 0 1 16 6.5v.75M3.5 6.5v7A1.5 1.5 0 0 0 5 15h10.5a1 1 0 0 0 1-1V8.25a1 1 0 0 0-1-1H5a1.5 1.5 0 0 1-1.5-.75M13.25 11.25v.01' }),
|
|
102
|
-
info: _jsx("path", { d: 'M10 17a7 7 0 1 0 0-14 7 7 0 0 0 0 14ZM10 9.5v4M10 6.5v.01' }),
|
|
103
|
-
lock: _jsx("path", { d: 'M5.5 9h9a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1v-5a1 1 0 0 1 1-1ZM7 9V6.5a3 3 0 0 1 6 0V9' }),
|
|
104
|
-
};
|
|
105
|
-
/** Outline symbol on a 20 unit grid; decorative, so the control that holds it carries the name. */
|
|
106
|
-
export function SwapIcon({ name, size = 20 }) { return _jsx("svg", { className: 'hig-swap-icon', "aria-hidden": 'true', focusable: 'false', width: size, height: size, viewBox: '0 0 20 20', ...stroke, children: paths[name] }); }
|
|
106
|
+
const symbols = { flip: ArrowUpDown, down: ArrowDown, reset: RotateCcw, menu: Menu, close: X, back: ChevronLeft, chevron: ChevronRight, expand: ChevronDown, delete: Delete, sliders: SlidersHorizontal, flask: FlaskConical, scan: ScanLine, flame: Flame, logout: LogOut, wallet: Wallet, info: Info, lock: Lock };
|
|
107
|
+
/** Shared outline symbol; the containing control carries its accessible name. */
|
|
108
|
+
export function SwapIcon({ name, size = 20 }) { const Symbol = symbols[name]; return _jsx(Symbol, { className: 'hig-swap-icon', size: size }); }
|
|
107
109
|
const chainBadge = 'hig-swap-chain-badge';
|
|
108
110
|
/** Token artwork with its chain badge. */
|
|
109
111
|
export function TokenIcon({ token, size = 44 }) {
|
|
@@ -85,7 +85,10 @@ export interface SwapPanelBlockProps {
|
|
|
85
85
|
onReceivingChange?: (receiving: boolean) => void;
|
|
86
86
|
/** The host validates, quotes and executes. HIG never submits a transaction. */
|
|
87
87
|
onSubmit: (action: SwapAction) => void;
|
|
88
|
+
/** The host's submit is in flight: the action shows a spinner and ignores presses, the keypad, typed keys, Max and Test leave the amount as it is, and the action keeps its ready name (or `submittingLabel`, or a held action's `actionStatus`) even when the host has cleared the amount meanwhile, never “Enter an amount” or the balance check. */
|
|
88
89
|
submitting?: boolean;
|
|
90
|
+
/** What the action says while `submitting`, in place of its ready name: Burning…. Host text. */
|
|
91
|
+
submittingLabel?: string;
|
|
89
92
|
/** Called after the panel clears its entry and both tokens (through `onFromChange(null)` / `onToChange(null)`), so the host can drop its quote. */
|
|
90
93
|
onReset?: () => void;
|
|
91
94
|
/** `false` fixes both amounts to `denomination` (dollars by default): the conversion capsule under each amount and the denomination setting are not shown. For hosts that only have one of the two, for example no token price. */
|
|
@@ -97,9 +100,11 @@ export interface SwapPanelBlockProps {
|
|
|
97
100
|
/** A line under the cards: a limit, a delay, a warning. `noteTone` tints it. */
|
|
98
101
|
note?: React.ReactNode;
|
|
99
102
|
noteTone?: 'muted' | 'warning' | 'negative';
|
|
100
|
-
/** Heading above the cards, for a panel that is its own screen or sheet (“Withdraw from Papertrade”). `onBack` adds
|
|
103
|
+
/** Heading above the cards, for a panel that is its own screen or sheet (“Withdraw from Papertrade”), drawn as the shared `ScreenHeader` (the title centred in a 44px row) like every other block. `onBack` adds Back on its leading edge. */
|
|
101
104
|
title?: string;
|
|
102
105
|
onBack?: () => void;
|
|
106
|
+
/** With `title`: `id` of the heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
107
|
+
headingId?: string;
|
|
103
108
|
/** `false` leaves the action button on its own, full width: no settings and no reset button. */
|
|
104
109
|
controls?: boolean;
|
|
105
110
|
/** Decoration before the action text. */
|
|
@@ -111,7 +116,7 @@ export interface SwapPanelBlockProps {
|
|
|
111
116
|
actionLabel?: string;
|
|
112
117
|
/** Holds the action for a reason only the host knows: below a minimum, no quote yet, a closed market. The panel's own checks (a token, an amount, the balance) still apply first. */
|
|
113
118
|
actionDisabled?: boolean;
|
|
114
|
-
/** What the held action says, for example “Below minimum
|
|
119
|
+
/** What the held action says, for example “Below minimum” or, while `submitting`, “Signing…” (a `submittingLabel` wins over it). Without it the action keeps its ready name. */
|
|
115
120
|
actionStatus?: string;
|
|
116
121
|
/** `destructive` for an action that cannot be undone, such as a burn. */
|
|
117
122
|
actionIntent?: 'primary' | 'destructive';
|
|
@@ -129,6 +134,8 @@ export interface SwapPanelBlockProps {
|
|
|
129
134
|
shortcuts?: boolean;
|
|
130
135
|
/** Digits typed anywhere on the page (outside a text field) drive the amount, not only inside the panel. */
|
|
131
136
|
captureKeyboard?: boolean;
|
|
137
|
+
/** Disable global shortcuts and amount capture while a retained screen is inactive. */
|
|
138
|
+
active?: boolean;
|
|
132
139
|
/** The view on show. The panel pushes its token pickers and settings as views inside its own bounds; `main` is the cards. Uncontrolled when omitted. */
|
|
133
140
|
view?: SwapView;
|
|
134
141
|
onViewChange?: (view: SwapView) => void;
|
|
@@ -142,7 +149,7 @@ export interface SwapPanelBlockProps {
|
|
|
142
149
|
* or token units, token pickers, settings, and one action that names itself from the chosen pair.
|
|
143
150
|
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
144
151
|
*/
|
|
145
|
-
export declare function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom, defaultTo, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting, onReset, destination, details, note, noteTone, title, onBack, controls, actionIcon, lockFrom, lockTo, actionLabel, actionDisabled, actionStatus, actionIntent, limitToBalance, banner, footer, oneWay: oneWayProp, denominationSwitch, keypad, shortcuts, captureKeyboard, view: viewProp, onViewChange, settings, className, style }: SwapPanelBlockProps): React.JSX.Element;
|
|
152
|
+
export declare function SwapPanelBlock({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom, defaultTo, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting, submittingLabel, onReset, destination, details, note, noteTone, title, onBack, headingId, controls, actionIcon, lockFrom, lockTo, actionLabel, actionDisabled, actionStatus, actionIntent, limitToBalance, banner, footer, oneWay: oneWayProp, denominationSwitch, keypad, shortcuts, captureKeyboard, active, view: viewProp, onViewChange, settings, className, style }: SwapPanelBlockProps): React.JSX.Element;
|
|
146
153
|
/** @deprecated Renamed `SwapPanelBlock`. The old name and the `blocks/swap-panel` and `recipes/swap-panel` import paths keep working until the next major release. */
|
|
147
154
|
export declare const SwapPanel: typeof SwapPanelBlock;
|
|
148
155
|
/** @deprecated Renamed `SwapPanelBlockProps`. */
|