@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
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Eye } from '@bloxwap/icons/react/eye';
|
|
4
|
+
import { TrendingDown } from '@bloxwap/icons/react/trending-down';
|
|
5
|
+
import { TrendingUp } from '@bloxwap/icons/react/trending-up';
|
|
6
|
+
import { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import { formatCountdown } from '@bloxwap/hig/contracts';
|
|
8
|
+
import { PressDecoration, useHIG, useMessages } from '../provider.js';
|
|
9
|
+
import { SearchInput } from '../field.js';
|
|
10
|
+
import { Filter, SegmentedControl } from '../selection.js';
|
|
11
|
+
import { Badge } from '../status.js';
|
|
12
|
+
import { Button } from '../button.js';
|
|
13
|
+
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
14
|
+
import { ScreenHeader, HeaderClose } from './screen-header.js';
|
|
15
|
+
const fold = (text) => text.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase();
|
|
16
|
+
/** The markets a view, category and query leave, grouped by category in the host's order. Empty sections are dropped. */
|
|
17
|
+
export function filterAssets(assets, categories, { view = 'all', category = '', query = '' } = {}) {
|
|
18
|
+
const needle = fold(query.trim());
|
|
19
|
+
const keep = (asset) => (view === 'all' || (view === 'positions' ? !!asset.position : asset.signal != null)) && (needle === '' || fold(`${asset.name} ${asset.symbol} ${asset.keywords ?? ''}`).includes(needle));
|
|
20
|
+
return categories.filter(entry => category === '' || entry.id === category).map(entry => ({ category: entry, assets: assets.filter(asset => asset.category === entry.id && keep(asset)) })).filter(section => section.assets.length > 0);
|
|
21
|
+
}
|
|
22
|
+
const signalIcons = {
|
|
23
|
+
watch: _jsx(Eye, { size: 20 }),
|
|
24
|
+
up: _jsx(TrendingUp, { size: 20 }),
|
|
25
|
+
down: _jsx(TrendingDown, { size: 20 }),
|
|
26
|
+
};
|
|
27
|
+
/** Controlled when `value` is set, otherwise local. No feedback: the filter and segmented control emit their own, and typing emits none. */
|
|
28
|
+
function useHostState(value, initial, onChange) {
|
|
29
|
+
const [local, setLocal] = useState(initial);
|
|
30
|
+
const current = value === undefined ? local : value;
|
|
31
|
+
return [current, next => { if (Object.is(next, current))
|
|
32
|
+
return; if (value === undefined)
|
|
33
|
+
setLocal(next); onChange?.(next); }];
|
|
34
|
+
}
|
|
35
|
+
/** The host clock, ticking each second while one of `openings` is still ahead and not `paused`; paused keeps the last reading (or takes one) and judges "ahead" against it, so a host re-render after an opening passes keeps the frozen text. `null` until mounted, so server HTML never carries a clock that hydration would contradict. */
|
|
36
|
+
function useNow(openings, paused, clock) {
|
|
37
|
+
const [now, setNow] = useState(null);
|
|
38
|
+
const read = useRef(clock);
|
|
39
|
+
read.current = clock;
|
|
40
|
+
const reading = paused && now != null ? now : openings.length ? clock() : 0;
|
|
41
|
+
const active = openings.some(at => at > reading);
|
|
42
|
+
useEffect(() => { if (!active) {
|
|
43
|
+
setNow(null);
|
|
44
|
+
return;
|
|
45
|
+
} if (paused) {
|
|
46
|
+
setNow(last => last ?? read.current());
|
|
47
|
+
return;
|
|
48
|
+
} setNow(read.current()); const tick = setInterval(() => setNow(read.current()), 1000); return () => clearInterval(tick); }, [active, paused]);
|
|
49
|
+
return active ? now : null;
|
|
50
|
+
}
|
|
51
|
+
const opensAtTime = (category) => category.opensAt == null ? null : +category.opensAt;
|
|
52
|
+
/**
|
|
53
|
+
* Choose a market as one screen: a header, a search field, category capsules, the All / Positions / Trend views, then the
|
|
54
|
+
* markets in sections by category, each with its icon, name, symbol and detail, and its signal disc. The host owns the data.
|
|
55
|
+
*/
|
|
56
|
+
export function AssetsBlock({ title, onClose, assets, categories, onSelect, selectedId = null, view, defaultView = 'all', onViewChange, category, defaultCategory = '', onCategoryChange, query, defaultQuery = '', onQueryChange, categoryFilter, loading, stickyHeader, headingId, clearable, paused = false, now: clock = Date.now, emptyAction, autoFocusSearch, enterChoosesFirst, className, ...rest }) {
|
|
57
|
+
const t = useMessages();
|
|
58
|
+
const { locale } = useHIG();
|
|
59
|
+
const id = useId();
|
|
60
|
+
const [currentView, setView] = useHostState(view, defaultView, onViewChange);
|
|
61
|
+
const [currentCategory, setCategory] = useHostState(category, defaultCategory, onCategoryChange);
|
|
62
|
+
const [currentQuery, setQuery] = useHostState(query, defaultQuery, onQueryChange);
|
|
63
|
+
const sections = useMemo(() => filterAssets(assets, categories, { view: currentView, category: currentCategory, query: currentQuery }), [assets, categories, currentView, currentCategory, currentQuery]);
|
|
64
|
+
// The clock runs only while a section on screen has an opening still ahead.
|
|
65
|
+
const now = useNow(sections.flatMap(section => { const at = opensAtTime(section.category); return at == null ? [] : [at]; }), paused, clock);
|
|
66
|
+
const rows = useMemo(() => sections.flatMap(section => section.assets), [sections]);
|
|
67
|
+
// The cursor follows an asset, not a position, so a live update that reorders or drops rows never moves it onto another market.
|
|
68
|
+
const [activeId, setActiveId] = useState(null);
|
|
69
|
+
const active = activeId == null ? -1 : rows.findIndex(asset => asset.id === activeId);
|
|
70
|
+
const field = useRef(null), list = useRef(null);
|
|
71
|
+
useEffect(() => { if (autoFocusSearch && window.matchMedia?.('(pointer: fine)').matches)
|
|
72
|
+
field.current?.focus(); }, []);
|
|
73
|
+
useEffect(() => { setActiveId(null); }, [currentQuery, currentCategory, currentView]);
|
|
74
|
+
useEffect(() => { if (active >= 0)
|
|
75
|
+
list.current?.querySelector('[data-active]')?.scrollIntoView?.({ block: 'nearest' }); }, [active]);
|
|
76
|
+
// From the search field the arrow keys move through the enabled rows and Enter chooses one: the one the arrows reached, or, if they have not moved, the only row (or with `enterChoosesFirst` and a query, the first enabled one).
|
|
77
|
+
const step = (from, by) => { for (let index = from + by; index >= 0 && index < rows.length; index += by)
|
|
78
|
+
if (!rows[index].disabled)
|
|
79
|
+
return index; return from; };
|
|
80
|
+
const onKeyDown = (event) => {
|
|
81
|
+
if (event.nativeEvent.isComposing || event.keyCode === 229)
|
|
82
|
+
return; // An IME commit is not a choice.
|
|
83
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
const next = step(active, event.key === 'ArrowDown' ? 1 : -1);
|
|
86
|
+
setActiveId(rows[next]?.id ?? null);
|
|
87
|
+
}
|
|
88
|
+
else if (event.key === 'Enter') {
|
|
89
|
+
const choice = activeId != null ? rows[active] : enterChoosesFirst && currentQuery.trim() !== '' ? rows.find(asset => !asset.disabled) : rows.length === 1 ? rows[0] : undefined;
|
|
90
|
+
if (choice && !choice.disabled) {
|
|
91
|
+
event.preventDefault();
|
|
92
|
+
onSelect(choice);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
// With a row focused (by Tab or a click) the arrow keys move focus to the next or previous enabled row; Up from the first returns to the search field. Focus is then the cursor, so the field's highlight steps aside.
|
|
97
|
+
const onListKeyDown = (event) => {
|
|
98
|
+
if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp')
|
|
99
|
+
return;
|
|
100
|
+
const current = event.target.closest?.('.hig-assets-row');
|
|
101
|
+
if (!current || !list.current)
|
|
102
|
+
return;
|
|
103
|
+
const buttons = [...list.current.querySelectorAll('.hig-assets-row:not(:disabled)')];
|
|
104
|
+
const index = buttons.indexOf(current);
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
setActiveId(null);
|
|
107
|
+
if (event.key === 'ArrowUp' && index <= 0) {
|
|
108
|
+
field.current?.focus();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
buttons[event.key === 'ArrowDown' ? Math.min(buttons.length - 1, index + 1) : index - 1]?.focus();
|
|
112
|
+
};
|
|
113
|
+
const heading = title ?? t.assets;
|
|
114
|
+
const signalName = { watch: t.signalWatch, up: t.signalUp, down: t.signalDown };
|
|
115
|
+
const empty = loading ? `${t.loading}…` : currentQuery.trim() !== '' ? t.noResults : currentView === 'positions' ? t.noPositions : currentView === 'trend' ? t.noTrend : t.noItems;
|
|
116
|
+
const secondLine = (asset) => asset.detail ? `${asset.symbol} · ${asset.detail}` : asset.symbol;
|
|
117
|
+
const rowName = (asset) => [asset.name, secondLine(asset), asset.trailingLabel, asset.signal ? signalName[asset.signal] : null].filter(Boolean).join(', ');
|
|
118
|
+
const row = (asset, index) => {
|
|
119
|
+
const second = secondLine(asset);
|
|
120
|
+
const signal = asset.signal === undefined ? null : _jsx("span", { className: 'hig-assets-signal', "data-signal": asset.signal ?? undefined, children: asset.signal ? signalIcons[asset.signal] : null });
|
|
121
|
+
const name = rowName(asset);
|
|
122
|
+
return _jsx("li", { children: _jsxs("button", { type: 'button', className: 'hig-assets-row', "data-asset-id": asset.id, "data-active": index === active || undefined, "aria-label": name, "aria-current": asset.id === selectedId || undefined, disabled: asset.disabled, onClick: () => onSelect(asset), children: [_jsx("span", { className: 'hig-assets-icon', "aria-hidden": 'true', children: typeof asset.icon === 'string' ? _jsx("img", { src: asset.icon, alt: '' }) : asset.icon ?? asset.symbol.slice(0, 4) }), _jsxs("span", { className: 'hig-assets-text', "aria-hidden": 'true', children: [_jsx("strong", { children: asset.name }), _jsx("span", { children: second })] }), asset.trailing != null && asset.trailing !== false ? _jsx("span", { className: 'hig-assets-trailing', "aria-hidden": 'true', children: asset.trailing }) : null, signal, _jsx(PressDecoration, { kind: 'row', disabled: !!asset.disabled })] }) }, asset.id);
|
|
123
|
+
};
|
|
124
|
+
const showFilter = (categoryFilter ?? true) && categories.length > 1;
|
|
125
|
+
const sectionHeader = (entry) => {
|
|
126
|
+
const at = opensAtTime(entry);
|
|
127
|
+
const remaining = now != null && at != null && at > now ? at - now : null, countdown = remaining != null ? formatCountdown(remaining, locale) : null;
|
|
128
|
+
const badge = countdown ? { visible: `${t.opensIn} ${countdown.visible}`, spoken: `${t.opensIn} ${countdown.spoken}`, tone: 'neutral' } : entry.status ? { visible: entry.status.label, spoken: entry.status.label, tone: entry.status.tone ?? 'positive' } : null;
|
|
129
|
+
return _jsxs("div", { className: 'hig-assets-section-header', children: [_jsx("h3", { id: `${id}-${entry.id}`, "aria-label": badge ? `${entry.label}, ${badge.spoken}` : undefined, children: entry.label }), badge && _jsx(Badge, { "aria-hidden": 'true', className: 'hig-assets-status', "data-countdown": countdown ? '' : undefined, tone: badge.tone, children: countdown && remaining != null ? _jsx(AnimatedNumberReadout, { value: Math.ceil(remaining / 1000), formattedValue: countdown.visible, animateFormatted: true, duration: paused ? 0 : undefined, prefix: `${t.opensIn} ` }) : badge.visible })] });
|
|
130
|
+
};
|
|
131
|
+
return _jsxs("section", { ...rest, className: `hig-assets-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: heading, headingId: headingId, stickyHeader: stickyHeader, action: onClose ? _jsx(HeaderClose, { onClose: onClose, label: t.close }) : undefined }), _jsx(SearchInput, { ref: field, "aria-label": t.searchMarkets, placeholder: `${t.searchMarkets}…`, value: currentQuery, onChange: event => setQuery(event.target.value), onKeyDown: onKeyDown, onClear: clearable ? () => setQuery('') : undefined, enterKeyHint: 'search', autoComplete: 'off', autoCapitalize: 'none', autoCorrect: 'off', spellCheck: false }), showFilter && _jsx(Filter, { label: t.marketCategories, options: [{ value: '', label: t.assetsAll }, ...categories.map(entry => ({ value: entry.id, label: entry.label }))], value: currentCategory, onValueChange: setCategory }), _jsx(SegmentedControl, { hideLabel: true, label: t.assetsView, options: [{ value: 'all', label: t.assetsAll }, { value: 'positions', label: t.assetsPositions }, { value: 'trend', label: t.assetsTrend }], value: currentView, onValueChange: next => setView(next) }), _jsx("span", { className: 'hig-sr-only hig-assets-cursor', "aria-live": 'polite', "aria-atomic": 'true', children: rows[active] ? rowName(rows[active]) : '' }), _jsxs("div", { ref: list, className: 'hig-assets-list', "aria-busy": loading || undefined, onKeyDown: onListKeyDown, children: [sections.length === 0 && _jsx("p", { className: 'hig-assets-empty', role: 'status', children: empty }), sections.length === 0 && !loading && emptyAction && _jsx(Button, { intent: 'secondary', "data-testid": emptyAction.testID, onClick: emptyAction.onPress, children: emptyAction.label }), sections.map(section => {
|
|
132
|
+
const first = rows.indexOf(section.assets[0]);
|
|
133
|
+
return _jsxs("section", { className: 'hig-assets-section', "aria-labelledby": `${id}-${section.category.id}`, children: [sectionHeader(section.category), _jsx("ul", { children: section.assets.map((asset, offset) => row(asset, first + offset)) })] }, section.category.id);
|
|
134
|
+
})] })] });
|
|
135
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ScreenHeaderControlProps } from './screen-header.js';
|
|
3
|
+
/** One more line under Network, such as a fee: host text on both edges. */
|
|
4
|
+
export interface ConfirmDetail {
|
|
5
|
+
label: string;
|
|
6
|
+
value: React.ReactNode;
|
|
7
|
+
/** What a `value` that is not text reads as. */
|
|
8
|
+
valueLabel?: string;
|
|
9
|
+
}
|
|
10
|
+
/** A full-width action under Cancel and Confirm, such as “Delete anyway”: a ghost button, in the negative colour with `tone='destructive'`. */
|
|
11
|
+
export interface ConfirmTertiaryAction {
|
|
12
|
+
label: string;
|
|
13
|
+
onSelect: () => void;
|
|
14
|
+
tone?: 'destructive';
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** The button's `data-testid`. */
|
|
17
|
+
testID?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ConfirmBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
20
|
+
/** The amount being sent, in token units. `null` reads as unknown. Leave it out, with `symbol`, `address` and `network`, for a confirmation that is not a send, such as signing out: the block then draws only the header, `children`, the notice and the actions. */
|
|
21
|
+
amount?: number | null;
|
|
22
|
+
/** The token's ticker, after the amount: HYPE. */
|
|
23
|
+
symbol?: string;
|
|
24
|
+
/** Format of the amount. Defaults to at most six fraction digits. */
|
|
25
|
+
amountOptions?: Intl.NumberFormatOptions;
|
|
26
|
+
/** What the amount is read as before the figure, such as “Amount” (“Amount: 2.5”, then the ticker). Without it the figure is read alone. */
|
|
27
|
+
amountLabel?: string;
|
|
28
|
+
/** The destination address, shown in full beside “To”, always as two rows, with the first 4 characters (6 with a `0x` prefix) and the last 4 emphasised and the rest muted. */
|
|
29
|
+
address?: string;
|
|
30
|
+
/** The network the send moves on: HyperEVM. */
|
|
31
|
+
network?: string;
|
|
32
|
+
/** What is being confirmed, drawn as given under the header (and under the amount and lines of a send): usually a muted `Text`, a `List` of consequences, an `Alert` or a `ListGroup`. */
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
/** A bulleted list under `children`, in the muted colour, such as what deleting an account loses. */
|
|
35
|
+
points?: readonly React.ReactNode[];
|
|
36
|
+
/** The confirming action's intent: `primary` (the default), `destructive`, for an action that deletes or ends something, or `warning`, the warning role's fill, for an action that goes ahead despite a caution, such as confirming past a `warning`. */
|
|
37
|
+
confirmIntent?: 'primary' | 'destructive' | 'warning';
|
|
38
|
+
/** A full-width action under Cancel and Confirm, such as “Delete anyway”. Unavailable while `busy`, unless `cancelWhileBusy` is set. */
|
|
39
|
+
tertiaryAction?: ConfirmTertiaryAction;
|
|
40
|
+
/** More lines under Network, such as a fee. */
|
|
41
|
+
details?: readonly ConfirmDetail[];
|
|
42
|
+
/** Draws the Network line and each of `details` on one line: the label keeps its width and the value truncates with an ellipsis instead of wrapping. A value that is not text should be inline content, such as a span, for the ellipsis to show. The address keeps its two rows. Off by default. */
|
|
43
|
+
oneLineDetails?: boolean;
|
|
44
|
+
/** Heading. Defaults to the built-in “Confirm Send”. */
|
|
45
|
+
title?: string;
|
|
46
|
+
/** Heading of the warning. Defaults to the built-in “Double-check the address.” */
|
|
47
|
+
warningTitle?: string;
|
|
48
|
+
/** Body of the warning. Defaults to the built-in sentence naming the token and network when `address` is given, and to none otherwise; `null` or `false` draws no warning. */
|
|
49
|
+
warning?: React.ReactNode;
|
|
50
|
+
/** A notice between the warning and the actions, drawn as given, such as an error `Alert` when a fee cannot be read or the send failed. Nothing by default. */
|
|
51
|
+
notice?: React.ReactNode;
|
|
52
|
+
/** Called when the user confirms. The host signs and sends. */
|
|
53
|
+
onConfirm: () => void;
|
|
54
|
+
/** Text of the confirming action. Defaults to the built-in “Confirm Send”. */
|
|
55
|
+
confirmLabel?: string;
|
|
56
|
+
/** The send is in progress: the confirming action shows a spinner and ignores presses, and Back, Cancel and the tertiary action are unavailable. */
|
|
57
|
+
busy?: boolean;
|
|
58
|
+
/** Draws the confirming action unavailable, for example while a quote refreshes. */
|
|
59
|
+
confirmDisabled?: boolean;
|
|
60
|
+
/** Keeps Back, Cancel and the tertiary action available while `busy`, for a wait the user may walk away from, such as a wallet signature the host can abandon. Off by default. */
|
|
61
|
+
cancelWhileBusy?: boolean;
|
|
62
|
+
/** Keeps only Back available while `busy`: the user may leave the pane while the action finishes, but Cancel and the tertiary action stay held, since they cannot stop it. Off by default; `cancelWhileBusy` frees Back as well. */
|
|
63
|
+
backWhileBusy?: boolean;
|
|
64
|
+
/** Shows Cancel on the leading side of the confirming action, the two sharing the row equally. Without it the confirming action takes the full width. */
|
|
65
|
+
onCancel?: () => void;
|
|
66
|
+
/** Text of Cancel. Defaults to the built-in “Cancel”. */
|
|
67
|
+
cancelLabel?: string;
|
|
68
|
+
/** Draws Cancel unavailable without `busy`, for example while the host's own work runs and the confirming action is a step that does not show a spinner. */
|
|
69
|
+
cancelDisabled?: boolean;
|
|
70
|
+
/** The confirming action's `data-testid`. */
|
|
71
|
+
confirmTestID?: string;
|
|
72
|
+
/** Cancel's `data-testid`. */
|
|
73
|
+
cancelTestID?: string;
|
|
74
|
+
/** Shows Back on the leading edge of the header. */
|
|
75
|
+
onBack?: () => void;
|
|
76
|
+
/** Attributes for the header's Back `<button>`, such as a `data-testid`, as `ScreenHeader` takes them. */
|
|
77
|
+
backProps?: ScreenHeaderControlProps;
|
|
78
|
+
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
79
|
+
headerAction?: React.ReactNode;
|
|
80
|
+
/** Pins the header to the top of the nearest scroller: transparent at rest, filled once content scrolls under it, and still when it starts to stick. See Pinned headers. */
|
|
81
|
+
stickyHeader?: boolean;
|
|
82
|
+
/** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
83
|
+
headingId?: string;
|
|
84
|
+
}
|
|
85
|
+
/** The address as the two rows the block draws: split at the middle, with `anchor` on the characters people compare, the first 4 (6 when it starts with `0x`) and the last 4. An address too short to have a middle is all anchor. */
|
|
86
|
+
export declare function confirmAddressRows(address: string): {
|
|
87
|
+
text: string;
|
|
88
|
+
anchor: boolean;
|
|
89
|
+
}[][];
|
|
90
|
+
/** The last look before a send: the amount as the headline, where it goes and on which network, a warning that it cannot be taken back, then Cancel and Confirm side by side. Without an amount, address or network it confirms anything else, such as signing out or deleting an account: the header, `children`, then the actions. */
|
|
91
|
+
export declare function ConfirmBlock({ amount, symbol, amountOptions, amountLabel, address, network, details, oneLineDetails, children, points, confirmIntent, tertiaryAction, title, warningTitle, warning, notice, onConfirm, confirmLabel, busy, confirmDisabled, cancelWhileBusy, backWhileBusy, onCancel, cancelLabel, cancelDisabled, confirmTestID, cancelTestID, onBack, backProps, headerAction, stickyHeader, headingId, className, ...rest }: ConfirmBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
4
|
+
import { useHIG } from '../provider.js';
|
|
5
|
+
import { Button } from '../button.js';
|
|
6
|
+
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
7
|
+
import { ScreenHeader } from './screen-header.js';
|
|
8
|
+
const amountFormat = { maximumFractionDigits: 6 };
|
|
9
|
+
/** The address as the two rows the block draws: split at the middle, with `anchor` on the characters people compare, the first 4 (6 when it starts with `0x`) and the last 4. An address too short to have a middle is all anchor. */
|
|
10
|
+
export function confirmAddressRows(address) {
|
|
11
|
+
const characters = Array.from(address), head = address.startsWith('0x') ? 6 : 4, tail = characters.length - 4, split = Math.ceil(characters.length / 2);
|
|
12
|
+
return [characters.slice(0, split), characters.slice(split)].map((row, rowIndex) => {
|
|
13
|
+
const parts = [];
|
|
14
|
+
row.forEach((character, index) => { const position = rowIndex * split + index, anchor = position < head || position >= tail, last = parts[parts.length - 1]; if (last && last.anchor === anchor)
|
|
15
|
+
last.text += character;
|
|
16
|
+
else
|
|
17
|
+
parts.push({ text: character, anchor }); });
|
|
18
|
+
return parts;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/** The last look before a send: the amount as the headline, where it goes and on which network, a warning that it cannot be taken back, then Cancel and Confirm side by side. Without an amount, address or network it confirms anything else, such as signing out or deleting an account: the header, `children`, then the actions. */
|
|
22
|
+
export function ConfirmBlock({ amount, symbol, amountOptions = amountFormat, amountLabel, address, network, details, oneLineDetails, children, points, confirmIntent = 'primary', tertiaryAction, title, warningTitle, warning, notice, onConfirm, confirmLabel, busy, confirmDisabled, cancelWhileBusy, backWhileBusy, onCancel, cancelLabel, cancelDisabled, confirmTestID, cancelTestID, onBack, backProps, headerAction, stickyHeader, headingId, className, ...rest }) {
|
|
23
|
+
const { messages } = useHIG();
|
|
24
|
+
// What busy holds besides the confirming action: Back, Cancel and the tertiary action, unless the host lets them leave the wait (Back alone with backWhileBusy).
|
|
25
|
+
const held = !!busy && !cancelWhileBusy;
|
|
26
|
+
const backHeld = held && !backWhileBusy;
|
|
27
|
+
const heading = title ?? messages.confirmSend ?? en.confirmSend;
|
|
28
|
+
const body = warning === undefined ? (address !== undefined ? (messages.sendWarning ?? en.sendWarning)(symbol ?? '', network ?? '') : null) : warning;
|
|
29
|
+
const hasLines = address !== undefined || network !== undefined || !!details?.length;
|
|
30
|
+
return _jsxs("section", { ...rest, className: `hig-confirm${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: heading, onBack: onBack, backDisabled: backHeld, backProps: backProps, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), amount !== undefined && _jsxs("p", { className: 'hig-confirm-amount', children: [_jsx(AnimatedNumberReadout, { value: amount, options: amountOptions, label: amountLabel }), symbol ? _jsxs(_Fragment, { children: [" ", _jsx("span", { className: 'hig-confirm-symbol', children: symbol })] }) : null] }), hasLines && _jsxs("dl", { className: 'hig-confirm-details', "data-one-line": oneLineDetails || undefined, children: [address !== undefined && _jsxs("div", { children: [_jsx("dt", { children: messages.sendTo ?? en.sendTo }), _jsx("dd", { children: _jsxs("span", { className: 'hig-confirm-address', dir: 'ltr', translate: 'no', children: [_jsx("span", { className: 'hig-sr-only', children: address }), _jsx("span", { "aria-hidden": 'true', children: confirmAddressRows(address).map((row, index) => _jsx("span", { children: row.map((part, offset) => _jsx("span", { "data-anchor": part.anchor || undefined, children: part.text }, offset)) }, index)) })] }) })] }), network !== undefined && _jsxs("div", { children: [_jsx("dt", { children: messages.sendNetwork ?? en.sendNetwork }), _jsx("dd", { children: network })] }), details?.map(detail => _jsxs("div", { children: [_jsx("dt", { children: detail.label }), _jsx("dd", { children: detail.valueLabel ? _jsxs(_Fragment, { children: [_jsx("span", { className: 'hig-sr-only', children: detail.valueLabel }), _jsx("span", { "aria-hidden": 'true', children: detail.value })] }) : detail.value })] }, detail.label))] }), (children != null && children !== false || !!points?.length) && _jsxs("div", { className: 'hig-confirm-body', children: [children, points?.length ? _jsx("ul", { className: 'hig-confirm-points', children: points.map((point, index) => _jsx("li", { children: point }, index)) }) : null] }), body != null && body !== false && _jsxs("div", { className: 'hig-confirm-warning', role: 'note', children: [_jsx("strong", { children: warningTitle ?? messages.sendWarningTitle ?? en.sendWarningTitle }), _jsx("p", { children: body })] }), notice, _jsxs("div", { className: 'hig-confirm-actions', children: [onCancel && _jsx(Button, { intent: 'secondary', disabled: held || cancelDisabled, "data-testid": cancelTestID, onClick: onCancel, children: cancelLabel ?? messages.cancel ?? en.cancel }), _jsx(Button, { intent: confirmIntent, busy: busy, disabled: confirmDisabled, "data-testid": confirmTestID, onClick: onConfirm, children: confirmLabel ?? messages.confirmSend ?? en.confirmSend })] }), tertiaryAction && _jsx(Button, { className: 'hig-confirm-tertiary', "data-tone": tertiaryAction.tone, "data-testid": tertiaryAction.testID, intent: 'ghost', fullWidth: true, disabled: held || tertiaryAction.disabled, onClick: tertiaryAction.onSelect, children: tertiaryAction.label })] });
|
|
31
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ScreenHeaderControlProps } from './screen-header.js';
|
|
3
|
+
/** The colour of a section: its tint, its icon disc and its heading. */
|
|
4
|
+
export type ExplainerTone = 'up' | 'down' | 'positive' | 'negative' | 'warning';
|
|
5
|
+
/** One titled part of the explanation. Every field is optional, so a section can be a heading and a sentence, an icon row, or host media with a caption. */
|
|
6
|
+
export interface ExplainerSection {
|
|
7
|
+
/** Stable key, also used in native test IDs. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** The section's heading: Up. */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Muted text after the heading on the same line, such as what the heading means: → Momentum is rising. */
|
|
12
|
+
meaning?: string;
|
|
13
|
+
/** A glyph on the leading edge in a disc, drawn in `currentColor` (the tone's colour). Decorative: hidden from assistive technology. */
|
|
14
|
+
icon?: React.ReactNode;
|
|
15
|
+
/** Tints the section, its disc and its heading. Without it the section sits on the neutral fill. */
|
|
16
|
+
tone?: ExplainerTone;
|
|
17
|
+
/** Host content under the heading and before the body, centred, such as an example card and its caption. */
|
|
18
|
+
media?: React.ReactNode;
|
|
19
|
+
/** The section's text, muted. */
|
|
20
|
+
body?: React.ReactNode;
|
|
21
|
+
/** A small note at the end of the section, such as what the signal does not promise. */
|
|
22
|
+
caveat?: React.ReactNode;
|
|
23
|
+
/** The section's `data-testid`. */
|
|
24
|
+
testID?: string;
|
|
25
|
+
}
|
|
26
|
+
/** One action at the foot of the block. */
|
|
27
|
+
export interface ExplainerAction {
|
|
28
|
+
label: string;
|
|
29
|
+
onSelect: () => void;
|
|
30
|
+
/** Defaults to `primary` for `primaryAction` and `secondary` for `secondaryAction`. */
|
|
31
|
+
intent?: 'primary' | 'secondary' | 'destructive' | 'ghost';
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
busy?: boolean;
|
|
34
|
+
/** The button's `data-testid`. */
|
|
35
|
+
testID?: string;
|
|
36
|
+
/** A glyph after the label, such as an arrow for an action that opens something outside the app. Decorative: hidden from assistive technology, so the label alone names the button. */
|
|
37
|
+
icon?: React.ReactNode;
|
|
38
|
+
}
|
|
39
|
+
export interface ExplainerBlockProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
40
|
+
/** Heading of the header. Leave it out inside a host dialog or sheet that draws its own title. */
|
|
41
|
+
title?: string;
|
|
42
|
+
/** A kicker above the title in small muted capitals: Builder fee. With `title` it is centred in the header over the heading; without one it is the block's first line. Host text. */
|
|
43
|
+
eyebrow?: string;
|
|
44
|
+
/** Short host text in a badge beside the title, as `ScreenHeader` `badge` (needs `title`): Demo. */
|
|
45
|
+
badge?: string;
|
|
46
|
+
/** A large figure or host media centred under the header and before the lead, such as a 68px “4% off” or a donut. Drawn as given; the host sets its size and colour, and hides decorative media from assistive technology. */
|
|
47
|
+
hero?: React.ReactNode;
|
|
48
|
+
/** A lead paragraph under the header, muted. */
|
|
49
|
+
description?: React.ReactNode;
|
|
50
|
+
/** The titled sections, in order. */
|
|
51
|
+
sections?: readonly ExplainerSection[];
|
|
52
|
+
/** Numbered steps after the sections, such as how to finish a task. */
|
|
53
|
+
steps?: readonly React.ReactNode[];
|
|
54
|
+
/** A small note after the sections and steps, such as what the whole explanation does not promise. */
|
|
55
|
+
caveat?: React.ReactNode;
|
|
56
|
+
/** Host content after the sections, steps and closing note and before the actions, such as a field, a link or a share card. Drawn as given. */
|
|
57
|
+
children?: React.ReactNode;
|
|
58
|
+
/** The main action: Got it, Copy link. */
|
|
59
|
+
primaryAction?: ExplainerAction;
|
|
60
|
+
/** A second action on the leading side of the main one, the two sharing the row equally: Not now. */
|
|
61
|
+
secondaryAction?: ExplainerAction;
|
|
62
|
+
/** Keeps the provider's feedback off the actions, for a host that plays its own cue. */
|
|
63
|
+
suppressFeedback?: boolean;
|
|
64
|
+
/** Shows Back on the leading edge of the header (needs `title`). */
|
|
65
|
+
onBack?: () => void;
|
|
66
|
+
/** Attributes for the header's Back `<button>`. */
|
|
67
|
+
backProps?: ScreenHeaderControlProps;
|
|
68
|
+
/** A control on the trailing edge of the header, such as a Close `IconButton`. */
|
|
69
|
+
headerAction?: React.ReactNode;
|
|
70
|
+
/** `id` of the header's heading, so a dialog or sheet can name itself with `aria-labelledby`. */
|
|
71
|
+
headingId?: string;
|
|
72
|
+
/** Pins the header to the top of the nearest scroller. See Pinned headers. */
|
|
73
|
+
stickyHeader?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* How something works, or how to finish a task: an optional header, a lead paragraph, titled sections (each with an optional icon and
|
|
77
|
+
* tone, a heading, media, a body and a caveat), numbered steps, a closing note, then one or two actions. Draws the “How Swing works” and
|
|
78
|
+
* “How Trend works” sheets and short task dialogs such as inviting a friend.
|
|
79
|
+
*/
|
|
80
|
+
export declare function ExplainerBlock({ title, eyebrow, badge, hero, description, sections, steps, caveat, children, primaryAction, secondaryAction, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, className, ...rest }: ExplainerBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from 'react';
|
|
4
|
+
import { Button } from '../button.js';
|
|
5
|
+
import { ScreenHeader } from './screen-header.js';
|
|
6
|
+
/** The actions' default intents. */
|
|
7
|
+
const primaryIntent = 'primary', secondaryIntent = 'secondary';
|
|
8
|
+
/**
|
|
9
|
+
* How something works, or how to finish a task: an optional header, a lead paragraph, titled sections (each with an optional icon and
|
|
10
|
+
* tone, a heading, media, a body and a caveat), numbered steps, a closing note, then one or two actions. Draws the “How Swing works” and
|
|
11
|
+
* “How Trend works” sheets and short task dialogs such as inviting a friend.
|
|
12
|
+
*/
|
|
13
|
+
export function ExplainerBlock({ title, eyebrow, badge, hero, description, sections = [], steps = [], caveat, children, primaryAction, secondaryAction, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, className, ...rest }) {
|
|
14
|
+
const id = useId();
|
|
15
|
+
const action = (entry, fallback) => _jsxs(Button, { intent: entry.intent ?? fallback, disabled: entry.disabled, busy: entry.busy, suppressFeedback: suppressFeedback, "data-testid": entry.testID, onClick: entry.onSelect, children: [entry.label, entry.icon != null && entry.icon !== false ? _jsx("span", { className: 'hig-explainer-action-icon', "aria-hidden": 'true', children: entry.icon }) : null] });
|
|
16
|
+
return _jsxs("section", { ...rest, className: `hig-explainer${className ? ` ${className}` : ''}`, children: [title !== undefined ? _jsx(ScreenHeader, { title: title, eyebrow: eyebrow, badge: badge, onBack: onBack, backProps: backProps, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }) : eyebrow ? _jsx("p", { className: 'hig-explainer-eyebrow', children: eyebrow }) : null, hero != null && hero !== false && _jsx("div", { className: 'hig-explainer-hero', children: hero }), description != null && description !== false && _jsx("p", { className: 'hig-explainer-text', children: description }), sections.length > 0 && _jsx("div", { className: 'hig-explainer-sections', children: sections.map(section => {
|
|
17
|
+
const heading = section.title !== undefined ? `${id}-${section.id}` : undefined;
|
|
18
|
+
return _jsxs("div", { className: 'hig-explainer-section', "data-tone": section.tone, "data-testid": section.testID, children: [section.icon != null && _jsx("span", { className: 'hig-explainer-icon', "aria-hidden": 'true', children: section.icon }), _jsxs("div", { children: [section.title !== undefined && _jsxs("h3", { id: heading, children: [section.title, section.meaning ? _jsxs(_Fragment, { children: [" ", _jsx("span", { children: section.meaning })] }) : null] }), section.media != null && _jsx("div", { className: 'hig-explainer-media', children: section.media }), section.body != null && section.body !== false && _jsx("div", { className: 'hig-explainer-text', children: section.body }), section.caveat != null && section.caveat !== false && _jsx("p", { className: 'hig-explainer-text', "data-caveat": '', children: section.caveat })] })] }, section.id);
|
|
19
|
+
}) }), steps.length > 0 && _jsx("ol", { className: 'hig-explainer-steps hig-explainer-text', children: steps.map((step, index) => _jsx("li", { children: step }, index)) }), caveat != null && caveat !== false && _jsx("p", { className: 'hig-explainer-text', "data-caveat": '', children: caveat }), children, (primaryAction || secondaryAction) && _jsxs("div", { className: 'hig-confirm-actions', children: [secondaryAction && action(secondaryAction, secondaryIntent), primaryAction && action(primaryAction, primaryIntent)] })] });
|
|
20
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useAsyncResult } from '../async-result.js';
|
|
3
4
|
import { useState } from 'react';
|
|
4
5
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
6
|
import { useHIG } from '../provider.js';
|
|
@@ -10,6 +11,7 @@ import { notify } from '../notify.js';
|
|
|
10
11
|
export function InstallCommand({ command, onCopy }) {
|
|
11
12
|
const { messages } = useHIG();
|
|
12
13
|
const [status, setStatus] = useState({ text: '', toasted: false });
|
|
14
|
+
const beginCopy = useAsyncResult(command);
|
|
13
15
|
const report = (text, severity) => setStatus({ text, toasted: notify(text, { severity, id: 'hig-install-command', dismissName: (messages.dismissNotice ?? en.dismissNotice)(text, messages.dismiss ?? en.dismiss) }) });
|
|
14
|
-
return _jsxs(Surface, { children: [_jsx("pre", { className: 'hig-code', tabIndex: 0, children: _jsx("code", { children: command }) }), _jsx(Button, { intent: 'secondary', onClick: () => { Promise.resolve().then(onCopy).then(() => report(messages.copied ?? en.copied, 'success')).catch(() => report(messages.copyFailed ?? en.copyFailed, 'error')); }, children: messages.copyInstallCommand ?? en.copyInstallCommand }), _jsx("p", { role: 'status', className: status.toasted ? 'hig-sr-only' : undefined, children: status.text })] });
|
|
16
|
+
return _jsxs(Surface, { children: [_jsx("pre", { className: 'hig-code', tabIndex: 0, children: _jsx("code", { children: command }) }), _jsx(Button, { intent: 'secondary', onClick: () => { const current = beginCopy(); Promise.resolve().then(onCopy).then(() => current() && report(messages.copied ?? en.copied, 'success')).catch(() => current() && report(messages.copyFailed ?? en.copyFailed, 'error')); }, children: messages.copyInstallCommand ?? en.copyInstallCommand }), _jsx("p", { role: 'status', className: status.toasted ? 'hig-sr-only' : undefined, children: status.text })] });
|
|
15
17
|
}
|
|
@@ -17,6 +17,10 @@ export interface LanguageBlockProps extends Omit<React.HTMLAttributes<HTMLElemen
|
|
|
17
17
|
onBack?: () => void;
|
|
18
18
|
/** A control on the trailing edge of the header, usually an `IconButton` that closes the sheet. */
|
|
19
19
|
headerAction?: React.ReactNode;
|
|
20
|
+
/** Pins the header to the top of the nearest scroller: transparent at rest, filled once content scrolls under it, and still when it starts to stick. See Pinned headers. */
|
|
21
|
+
stickyHeader?: boolean;
|
|
22
|
+
/** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
23
|
+
headingId?: string;
|
|
20
24
|
languages: readonly LanguageOption[];
|
|
21
25
|
/** `code` of the language in use. */
|
|
22
26
|
value?: string | null;
|
|
@@ -33,4 +37,4 @@ export interface LanguageBlockProps extends Omit<React.HTMLAttributes<HTMLElemen
|
|
|
33
37
|
/** The languages whose name, description or code contains the query, ignoring case and accents. An empty query keeps every language, in the host's order. */
|
|
34
38
|
export declare function filterLanguages(languages: readonly LanguageOption[], query: string): LanguageOption[];
|
|
35
39
|
/** Choose the app's language: a header, a search field, then each language as a row with its flag, its own name over the reader's name for it, and a check on the one in use. */
|
|
36
|
-
export declare function LanguageBlock({ title, onBack, headerAction, languages, value, onSelect, search, autoFocus, disabled, description, className, ...rest }: LanguageBlockProps): React.JSX.Element;
|
|
40
|
+
export declare function LanguageBlock({ title, onBack, headerAction, languages, value, onSelect, search, autoFocus, disabled, description, stickyHeader, headingId, className, ...rest }: LanguageBlockProps): React.JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Check } from '@bloxwap/icons/react/check';
|
|
3
4
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
5
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
6
|
import { PressDecoration, useHIG } from '../provider.js';
|
|
@@ -11,9 +12,9 @@ export function filterLanguages(languages, query) {
|
|
|
11
12
|
const needle = fold(query.trim());
|
|
12
13
|
return needle === '' ? [...languages] : languages.filter(language => fold(`${language.name} ${language.description ?? ''} ${language.code}`).includes(needle));
|
|
13
14
|
}
|
|
14
|
-
const check = _jsx(
|
|
15
|
+
const check = _jsx(Check, { size: 20, className: 'hig-language-check' });
|
|
15
16
|
/** Choose the app's language: a header, a search field, then each language as a row with its flag, its own name over the reader's name for it, and a check on the one in use. */
|
|
16
|
-
export function LanguageBlock({ title, onBack, headerAction, languages, value = null, onSelect, search = true, autoFocus, disabled, description, className, ...rest }) {
|
|
17
|
+
export function LanguageBlock({ title, onBack, headerAction, languages, value = null, onSelect, search = true, autoFocus, disabled, description, stickyHeader, headingId, className, ...rest }) {
|
|
17
18
|
const { messages } = useHIG();
|
|
18
19
|
const heading = title ?? messages.language ?? en.language;
|
|
19
20
|
const [query, setQuery] = useState('');
|
|
@@ -45,7 +46,7 @@ export function LanguageBlock({ title, onBack, headerAction, languages, value =
|
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
48
|
const label = messages.searchLanguages ?? en.searchLanguages;
|
|
48
|
-
return _jsxs("section", { ...rest, className: `hig-language-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: heading, onBack: onBack, action: headerAction }), description && _jsx("p", { className: 'hig-settings-description', children: description }), search && _jsx(SearchInput, { ref: field, "aria-label": label, placeholder: label, value: query, onChange: event => setQuery(event.target.value), onKeyDown: onKeyDown, enterKeyHint: 'search', autoComplete: 'off', autoCapitalize: 'none', autoCorrect: 'off', spellCheck: false }), rows.length === 0 && _jsx("p", { className: 'hig-swap-empty', role: 'status', children: messages.noResults ?? en.noResults }), rows.length > 0 && _jsx("div", { ref: list, className: 'hig-language-list', role: 'radiogroup', "aria-label": heading, "aria-disabled": disabled || undefined, children: rows.map((language, index) => {
|
|
49
|
+
return _jsxs("section", { ...rest, className: `hig-language-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: heading, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), description && _jsx("p", { className: 'hig-settings-description', children: description }), search && _jsx(SearchInput, { ref: field, "aria-label": label, placeholder: label, value: query, onChange: event => setQuery(event.target.value), onKeyDown: onKeyDown, enterKeyHint: 'search', autoComplete: 'off', autoCapitalize: 'none', autoCorrect: 'off', spellCheck: false }), rows.length === 0 && _jsx("p", { className: 'hig-swap-empty', role: 'status', children: messages.noResults ?? en.noResults }), rows.length > 0 && _jsx("div", { ref: list, className: 'hig-language-list', role: 'radiogroup', "aria-label": heading, "aria-disabled": disabled || undefined, children: rows.map((language, index) => {
|
|
49
50
|
const selected = language.code === value;
|
|
50
51
|
return _jsxs("button", { type: 'button', role: 'radio', "aria-checked": selected, lang: language.code, className: 'hig-language-row', "data-active": index === active || undefined, disabled: disabled, onClick: () => onSelect(language), children: [_jsx("span", { className: 'hig-language-flag', "aria-hidden": 'true', children: typeof language.flag === 'string' ? _jsx("img", { src: language.flag, alt: '' }) : language.flag ?? language.code.slice(0, 2).toUpperCase() }), _jsxs("span", { className: 'hig-language-text', children: [_jsx("strong", { children: language.name }), language.description && _jsx("span", { lang: '', children: language.description })] }), selected && check, _jsx(PressDecoration, { kind: 'row', disabled: !!disabled })] }, language.code);
|
|
51
52
|
}) })] });
|
|
@@ -74,6 +74,8 @@ export interface ManagePositionBlockProps extends Omit<React.HTMLAttributes<HTML
|
|
|
74
74
|
onBack?: () => void;
|
|
75
75
|
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
76
76
|
headerAction?: React.ReactNode;
|
|
77
|
+
/** Pins the header to the top of the nearest scroller: transparent at rest, filled once content scrolls under it, and still when it starts to stick. See Pinned headers. */
|
|
78
|
+
stickyHeader?: boolean;
|
|
77
79
|
/** `id` of the heading, so a dialog or sheet can name itself with `aria-labelledby`. */
|
|
78
80
|
headingId?: string;
|
|
79
81
|
}
|
|
@@ -90,4 +92,4 @@ export declare function positionCorridor({ side, entry, mark, liquidation }: {
|
|
|
90
92
|
share: number | null;
|
|
91
93
|
};
|
|
92
94
|
/** Manage one open position: margin against notional (with the share left before liquidation) as a `BarMark` and the liquidation, mark and entry prices as a `BarPnl`, both drawn without a card because they are read-only, the host's actions as one `ListGroup` of rows, and the position itself underneath. */
|
|
93
|
-
export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, className, ...rest }: ManagePositionBlockProps): React.JSX.Element;
|
|
95
|
+
export declare function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, stickyHeader, className, ...rest }: ManagePositionBlockProps): React.JSX.Element;
|
|
@@ -31,14 +31,14 @@ function PositionArt({ position }) {
|
|
|
31
31
|
return _jsx("span", { className: 'hig-asset-row-icon', "aria-hidden": 'true', children: art });
|
|
32
32
|
}
|
|
33
33
|
/** Manage one open position: margin against notional (with the share left before liquidation) as a `BarMark` and the liquidation, mark and entry prices as a `BarPnl`, both drawn without a card because they are read-only, the host's actions as one `ListGroup` of rows, and the position itself underneath. */
|
|
34
|
-
export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, className, ...rest }) {
|
|
34
|
+
export function ManagePositionBlock({ labels, mode, side, entry, mark, liquidation, margin, notional, priceOptions, actions, position, pnlOptions, onBack, headerAction, headingId, stickyHeader, className, ...rest }) {
|
|
35
35
|
const locale = useNumberLocale();
|
|
36
36
|
const present = usePresentNumber();
|
|
37
37
|
const corridor = positionCorridor({ side, entry, mark, liquidation });
|
|
38
38
|
const pnlTone = !known(position?.pnl) || position.pnl === 0 ? undefined : position.pnl > 0 ? 'up' : 'down';
|
|
39
39
|
const pnlFormat = { ...usd, signDisplay: 'exceptZero', maximumFractionDigits: 4, ...pnlOptions };
|
|
40
40
|
const content = (position, ids) => _jsxs(_Fragment, { children: [_jsx(PositionArt, { position: position }), _jsxs("span", { id: ids?.identity, className: 'hig-asset-row-identity', children: [position.badge ? _jsxs("span", { className: 'hig-position-name', children: [_jsx("strong", { children: position.name }), _jsx(Badge, { className: 'hig-position-badge', children: position.badge })] }) : _jsx("strong", { children: position.name }), _jsxs("span", { children: [_jsx("span", { className: 'hig-position-side', "data-side": side, "aria-hidden": 'true', children: side === 'long' ? '↑' : '↓' }), _jsx("span", { className: 'hig-sr-only', children: side === 'long' ? labels.long : labels.short }), position.leverage != null && _jsxs("span", { className: 'hig-position-side hig-position-leverage', "data-side": side, children: [" ", formatNumber(position.leverage, locale), "\u00D7"] }), known(position.size) && _jsxs(_Fragment, { children: [" \u00B7 ", _jsx(AnimatedNumberReadout, { value: position.size, options: { maximumFractionDigits: 6 } })] })] })] }), _jsxs("span", { id: ids?.amounts, className: 'hig-asset-row-amounts', children: [_jsx("strong", { "data-tone": pnlTone, children: _jsx(AnimatedNumberReadout, { value: position.pnl, options: pnlFormat }) }), _jsx("span", { children: _jsx(AnimatedNumberReadout, { value: position.pnlPercent, options: { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' } }) })] })] });
|
|
41
|
-
return _jsxs("section", { ...rest, className: `hig-manage-position-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, headingId: headingId }), _jsxs("div", { className: 'hig-token-bars', children: [_jsx(BarMark, { surface: false, title: mode ?? labels.margin, description: corridor.share === null ? labels.toLiquidation('—') : _jsx(SwapNumber, { template: labels.toLiquidation, value: Number((corridor.share * 100).toFixed(1)), suffix: '%', options: { maximumFractionDigits: 1 } }), elements: [{ id: 'margin', label: labels.margin, value: margin, detail: formatNumber(margin, locale, present(usd)), tone: 'info' }, { id: 'notional', label: labels.notional, value: known(notional) ? Math.max(notional - margin, 0) : 0, detail: known(notional) ? formatNumber(notional, locale, present(usd)) : '—', tone: 'positive' }] }), _jsx(BarPnl, { surface: false, compact: true, side: side, entry: entry, mark: mark, liquidation: liquidation, labels: { liquidation: labels.liquidation, mark: labels.mark, entry: labels.entry }, priceOptions: priceOptions })] }), actions.length > 0 && _jsx(ListGroup, { className: 'hig-manage-actions', children: actions.map(action => _jsx(ListRow, { label: action.label, disabled: action.disabled, onSelect: action.onSelect, value: action.value == null ? undefined : _jsx("span", { className: 'hig-manage-action-value', "data-tone": action.tone, children: typeof action.value === 'string' ? action.value : _jsx(AnimatedNumberReadout, { ...figureProps(action.value) }) }) }, action.id)) }), position && (position.onSelect ? _jsx(PositionButton, { position: position, content: content }) : _jsx("div", { className: 'hig-asset-row hig-position-row', children: content(position) })), position?.caption && !position.onSelect && _jsx("p", { className: 'hig-position-caption', children: position.caption })] });
|
|
41
|
+
return _jsxs("section", { ...rest, className: `hig-manage-position-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: labels.title, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), _jsxs("div", { className: 'hig-token-bars', children: [_jsx(BarMark, { surface: false, title: mode ?? labels.margin, description: corridor.share === null ? labels.toLiquidation('—') : _jsx(SwapNumber, { template: labels.toLiquidation, value: Number((corridor.share * 100).toFixed(1)), suffix: '%', options: { maximumFractionDigits: 1 } }), elements: [{ id: 'margin', label: labels.margin, value: margin, detail: formatNumber(margin, locale, present(usd)), tone: 'info' }, { id: 'notional', label: labels.notional, value: known(notional) ? Math.max(notional - margin, 0) : 0, detail: known(notional) ? formatNumber(notional, locale, present(usd)) : '—', tone: 'positive' }] }), _jsx(BarPnl, { surface: false, compact: true, side: side, entry: entry, mark: mark, liquidation: liquidation, labels: { liquidation: labels.liquidation, mark: labels.mark, entry: labels.entry }, priceOptions: priceOptions })] }), actions.length > 0 && _jsx(ListGroup, { className: 'hig-manage-actions', children: actions.map(action => _jsx(ListRow, { label: action.label, disabled: action.disabled, onSelect: action.onSelect, value: action.value == null ? undefined : _jsx("span", { className: 'hig-manage-action-value', "data-tone": action.tone, children: typeof action.value === 'string' ? action.value : _jsx(AnimatedNumberReadout, { ...figureProps(action.value) }) }) }, action.id)) }), position && (position.onSelect ? _jsx(PositionButton, { position: position, content: content }) : _jsx("div", { className: 'hig-asset-row hig-position-row', children: content(position) })), position?.caption && !position.onSelect && _jsx("p", { className: 'hig-position-caption', children: position.caption })] });
|
|
42
42
|
}
|
|
43
43
|
/** The position row as a button: named by the host's label followed by what it shows, so the figures are part of the name, and described by the caption. Without a label it is named by what it shows alone. Its own component, so the ids it needs exist only when it is drawn. */
|
|
44
44
|
function PositionButton({ position, content }) {
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Check } from '@bloxwap/icons/react/check';
|
|
3
4
|
import { forwardRef } from 'react';
|
|
4
5
|
import { Button } from '../button.js';
|
|
5
6
|
import { Usd, Percent } from '../data.js';
|
|
6
|
-
const check = _jsx(
|
|
7
|
+
const check = _jsx(Check, { size: 20, className: 'hig-market-check' });
|
|
7
8
|
/** A market as one row: its name (a button, or the host's identity in presentation mode), price and change. Other attributes, pointer handlers and the ref reach the row's root. */
|
|
8
9
|
export const MarketRow = forwardRef(function MarketRow({ symbol, name, price, change, onSelect, priceOptions, changeOptions, mode = 'action', identity, icon, favorite, volume, detail, trailing, selected, disabled, active, className, style, ...rest }, ref) {
|
|
9
|
-
|
|
10
|
+
// The name sits in its own span so an action row can truncate it on one line instead of wrapping.
|
|
11
|
+
const title = detail === undefined ? _jsxs("span", { className: 'hig-market-label', children: [name, " (", symbol, ")"] }) : _jsxs("span", { className: 'hig-market-text', children: [_jsxs("span", { className: 'hig-market-label', children: [name, " (", symbol, ")"] }), _jsx("span", { className: 'hig-market-detail', children: detail })] });
|
|
10
12
|
const current = selected ? 'true' : undefined;
|
|
11
13
|
const content = _jsxs(_Fragment, { children: [favorite !== undefined && _jsx("span", { className: 'hig-market-favorite', children: favorite }), icon !== undefined && _jsx("span", { className: 'hig-market-icon', children: icon }), mode === 'presentation' ? _jsx("span", { className: 'hig-market-name', children: identity === undefined ? title : identity }) : _jsx(Button, { intent: 'ghost', onClick: onSelect, disabled: disabled, "aria-current": current, children: title })] });
|
|
12
14
|
const hasTrailing = trailing !== undefined && trailing !== null && trailing !== false;
|
|
13
15
|
// The default three or four columns keep their grid; any other set of cells flows into as many columns as it has.
|
|
14
16
|
const flow = price === undefined || change === undefined || hasTrailing || !!selected || undefined;
|
|
15
|
-
|
|
17
|
+
// Presentation mode places each figure in its own grid column. An action row groups them so that, when the row is too narrow for
|
|
18
|
+
// everything, whole figures drop from the end (volume, then change, then price) instead of the name collapsing or cells overlapping.
|
|
19
|
+
const figures = price === undefined && change === undefined && volume === undefined ? null : _jsxs(_Fragment, { children: [price !== undefined && _jsx("span", { className: 'hig-market-price', children: _jsx(Usd, { value: price, options: priceOptions }) }), change !== undefined && _jsx("span", { className: 'hig-market-change', children: _jsx(Percent, { value: change, options: changeOptions }) }), volume !== undefined && _jsx("span", { className: 'hig-market-volume', children: volume })] });
|
|
20
|
+
return _jsxs("div", { ref: ref, ...rest, className: `hig-row hig-market-row${className ? ` ${className}` : ''}`, style: style, "data-mode": mode, "data-has-volume": volume !== undefined || undefined, "data-flow": flow, "data-selected": selected || undefined, "data-active": active || undefined, "data-disabled": disabled || undefined, "aria-current": mode === 'presentation' ? current : undefined, "aria-disabled": mode === 'presentation' && disabled ? true : undefined, children: [_jsx("div", { className: 'hig-market-identity', children: content }), mode === 'action' && figures !== null ? _jsx("span", { className: 'hig-market-figures', children: figures }) : figures, hasTrailing && _jsx("span", { className: 'hig-market-trailing', children: trailing }), selected && check] });
|
|
16
21
|
});
|
|
@@ -39,8 +39,10 @@ export interface NotificationsBlockProps extends Omit<React.HTMLAttributes<HTMLE
|
|
|
39
39
|
onBack?: () => void;
|
|
40
40
|
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
41
41
|
headerAction?: React.ReactNode;
|
|
42
|
+
/** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
43
|
+
headingId?: string;
|
|
42
44
|
/** Pins the header to the top of the nearest scrolling container, transparent at rest and filled with `--hig-sticky-header-background` once content scrolls under it. */
|
|
43
45
|
stickyHeader?: boolean;
|
|
44
46
|
}
|
|
45
47
|
/** The notifications the viewer receives: each kind is a card with a switch and a line of explanation, and a failure to turn one on reads under its card. */
|
|
46
|
-
export declare function NotificationsBlock({ title, description, items, groups, onBack, headerAction, stickyHeader, className, ...rest }: NotificationsBlockProps): React.JSX.Element;
|
|
48
|
+
export declare function NotificationsBlock({ title, description, items, groups, onBack, headerAction, stickyHeader, headingId, className, ...rest }: NotificationsBlockProps): React.JSX.Element;
|
|
@@ -12,6 +12,6 @@ function Group({ group }) {
|
|
|
12
12
|
return _jsxs("section", { className: 'hig-notifications-group', "aria-labelledby": group.title ? id : undefined, children: [group.title && _jsx("div", { className: 'hig-signals-group-header', children: _jsx("h3", { id: id, children: group.title }) }), group.items.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: group.items.map(item => _jsx(Item, { item: item }, item.id)) })] });
|
|
13
13
|
}
|
|
14
14
|
/** The notifications the viewer receives: each kind is a card with a switch and a line of explanation, and a failure to turn one on reads under its card. */
|
|
15
|
-
export function NotificationsBlock({ title, description, items = [], groups, onBack, headerAction, stickyHeader, className, ...rest }) {
|
|
16
|
-
return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, stickyHeader: stickyHeader }), description && _jsx("p", { className: 'hig-settings-description', children: description }), items.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: items.map(item => _jsx(Item, { item: item }, item.id)) }), groups?.map(group => _jsx(Group, { group: group }, group.id))] });
|
|
15
|
+
export function NotificationsBlock({ title, description, items = [], groups, onBack, headerAction, stickyHeader, headingId, className, ...rest }) {
|
|
16
|
+
return _jsxs("section", { ...rest, className: `hig-settings-block${className ? ` ${className}` : ''}`, children: [_jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), description && _jsx("p", { className: 'hig-settings-description', children: description }), items.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: items.map(item => _jsx(Item, { item: item }, item.id)) }), groups?.map(group => _jsx(Group, { group: group }, group.id))] });
|
|
17
17
|
}
|
|
@@ -31,11 +31,20 @@ export interface PickerListProps {
|
|
|
31
31
|
searchRef?: React.Ref<HTMLInputElement>;
|
|
32
32
|
/** Attributes for the search input, such as `name`, `autoComplete`, `data-1p-ignore` or `onFocus`/`onBlur`. The value and its change handler stay HIG's; a host `onKeyDown` runs before the list's arrow keys. */
|
|
33
33
|
searchInputProps?: PickerInputProps;
|
|
34
|
+
/** Host attributes for each token's row, such as `{'data-testid': \`token-${token.id}\`}`. HIG keeps the row's type, class, state, click and pointer handlers. */
|
|
35
|
+
tokenRowProps?: (token: SwapToken) => PickerRowProps;
|
|
34
36
|
}
|
|
35
37
|
/** Host attributes for a picker's input: anything an `<input>` takes, including `data-*`, except the value and its change handler. */
|
|
36
38
|
export type PickerInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'type' | 'children'> & {
|
|
37
39
|
[attribute: `data-${string}`]: string | number | boolean | undefined;
|
|
38
40
|
};
|
|
41
|
+
/** Host attributes for one token row (a `<button>`): `data-*`, `id`, `title` or ARIA descriptions. The row's own type, class, selected state and handlers stay HIG's. */
|
|
42
|
+
export type PickerRowProps = {
|
|
43
|
+
id?: string;
|
|
44
|
+
title?: string;
|
|
45
|
+
'aria-describedby'?: string;
|
|
46
|
+
[attribute: `data-${string}`]: string | number | boolean | undefined;
|
|
47
|
+
};
|
|
39
48
|
export interface FromPickerBlockProps extends PickerListProps {
|
|
40
49
|
/** The connected wallet. Omit for a list with no wallet row at all. */
|
|
41
50
|
wallet?: SwapWallet;
|