@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,6 +9,8 @@ import { Filter } from '../selection.js';
|
|
|
9
9
|
import { SwapIcon, SwapNumber, TokenIcon, usdNumber, addressGradient, chainsOf, fuzzyMatch, shortAddress } from './swap/shared.js';
|
|
10
10
|
/** A row shows a known balance above zero, or a zero one when the host asks for it. */
|
|
11
11
|
const showBalance = (token, zero) => token.balance != null && Number.isFinite(token.balance) && (token.balance > 0 || (!!zero && token.balance === 0));
|
|
12
|
+
/** The host's row attributes HIG accepts: `data-*` (except the row's own state), `id`, `title` and `aria-describedby`. */
|
|
13
|
+
const rowAttributes = (props) => Object.fromEntries(Object.entries(props ?? {}).filter(([key]) => (key.startsWith('data-') && key !== 'data-active' && key !== 'data-selected') || key === 'id' || key === 'title' || key === 'aria-describedby'));
|
|
12
14
|
/** One callback ref that sets each given ref. */
|
|
13
15
|
function useMergedRef(...refs) {
|
|
14
16
|
const latest = useRef(refs);
|
|
@@ -20,7 +22,7 @@ function useMergedRef(...refs) {
|
|
|
20
22
|
ref.current = node;
|
|
21
23
|
} }, []);
|
|
22
24
|
}
|
|
23
|
-
function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected = null, onSelect, loading, autoFocus, search: searchable = true, zeroBalances, searchLabel, searchRef, searchInputProps, label }) {
|
|
25
|
+
function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected = null, onSelect, loading, autoFocus, search: searchable = true, zeroBalances, searchLabel, searchRef, searchInputProps, tokenRowProps, label }) {
|
|
24
26
|
const { messages } = useHIG();
|
|
25
27
|
const id = useId();
|
|
26
28
|
const [query, setQuery] = useState('');
|
|
@@ -64,7 +66,7 @@ function TokenList({ tokens, chains, chainFilter = true, hotTokenIds, selected =
|
|
|
64
66
|
const filters = [{ value: '', label: messages.swapAllChains ?? en.swapAllChains }, ...options.map(chain => ({ value: String(chain.chainId), label: chain.name, icon: chain.icon }))];
|
|
65
67
|
const row = (token, index) => {
|
|
66
68
|
const isSelected = selected?.id === token.id;
|
|
67
|
-
return _jsx("div", { role: 'listitem', children: _jsxs("button", { type: 'button', className: 'hig-swap-row', "data-active": index === active, "data-selected": isSelected || undefined, onClick: () => onSelect(token), onPointerMove: () => setActive(index), children: [_jsx(TokenIcon, { token: token }), _jsxs("span", { className: 'hig-swap-row-text', children: [_jsx("strong", { children: token.name }), _jsxs("span", { children: [token.detail ?? token.chain, isSelected ? ' · ' + (messages.swapSelected ?? en.swapSelected) : ''] })] }), showBalance(token, zeroBalances) && _jsxs("span", { className: 'hig-swap-row-balance', children: [_jsx("strong", { children: _jsx(SwapNumber, { value: token.balance, options: { maximumFractionDigits: 6 }, suffix: token.unitsSuffix }) }), (token.price ?? 0) > 0 && _jsx(SwapNumber, { ...usdNumber((token.balance ?? 0) * (token.price ?? 0)) })] }), _jsx(PressDecoration, { kind: 'row' })] }) }, token.id);
|
|
69
|
+
return _jsx("div", { role: 'listitem', children: _jsxs("button", { ...rowAttributes(tokenRowProps?.(token)), type: 'button', className: 'hig-swap-row', "data-active": index === active, "data-selected": isSelected || undefined, "aria-current": isSelected || undefined, onClick: () => onSelect(token), onPointerMove: () => setActive(index), children: [_jsx(TokenIcon, { token: token }), _jsxs("span", { className: 'hig-swap-row-text', children: [_jsx("strong", { children: token.name }), _jsxs("span", { children: [token.detail ?? token.chain, isSelected ? ' · ' + (messages.swapSelected ?? en.swapSelected) : ''] })] }), showBalance(token, zeroBalances) && _jsxs("span", { className: 'hig-swap-row-balance', children: [_jsx("strong", { children: _jsx(SwapNumber, { value: token.balance, options: { maximumFractionDigits: 6 }, suffix: token.unitsSuffix }) }), (token.price ?? 0) > 0 && _jsx(SwapNumber, { ...usdNumber((token.balance ?? 0) * (token.price ?? 0)) })] }), _jsx(PressDecoration, { kind: 'row' })] }) }, token.id);
|
|
68
70
|
};
|
|
69
71
|
const searchName = messages.swapSearchTokens ?? en.swapSearchTokens;
|
|
70
72
|
const field = _jsx(SearchInput, { ref: searchInput, "aria-label": searchLabel ? undefined : searchName, placeholder: searchName, enterKeyHint: 'search', autoComplete: 'off', autoCapitalize: 'none', autoCorrect: 'off', spellCheck: false, ...searchInputProps, value: query, onChange: event => setQuery(event.target.value), onKeyDown: event => { searchInputProps?.onKeyDown?.(event); if (!event.defaultPrevented)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type Figure } from '../figure.js';
|
|
3
|
-
import { type ScreenHeaderControlProps } from './screen-header.js';
|
|
3
|
+
import { type HeaderCloseProps, type ScreenHeaderControlProps } from './screen-header.js';
|
|
4
4
|
/** A number the host supplies as a number so it updates place by place: `{value:0.53,options:{style:'currency',currency:'USD'}}`, or Leverage as `{value:40,suffix:'×'}`. `null` reads as unknown. `formattedValue` is the host's own text for it, still moving place by place. */
|
|
5
5
|
export type PositionBlockFigure = Figure;
|
|
6
6
|
/** One line of the summary: Notional, Fee, Liquidation. `value` is host text (`2% of profit`) or a live figure. `tone` colours the value; the default is the text colour. */
|
|
@@ -65,8 +65,8 @@ export interface PositionBlockProps extends Omit<React.HTMLAttributes<HTMLElemen
|
|
|
65
65
|
stickyHeader?: boolean;
|
|
66
66
|
/** Attributes for the header's Back `<button>`. */
|
|
67
67
|
backProps?: ScreenHeaderControlProps;
|
|
68
|
-
/** Attributes for the header's Close `<button
|
|
69
|
-
closeProps?:
|
|
68
|
+
/** Attributes for the header's Close `<button>`; `disabled` draws Close unavailable. */
|
|
69
|
+
closeProps?: HeaderCloseProps;
|
|
70
70
|
}
|
|
71
71
|
/** The position being opened or edited: a summary of what it costs and where it ends, an optional paper trading switch, and its settings as grouped rows that open the host's own views. */
|
|
72
72
|
export declare function PositionBlock({ title, details, note, paperTrade, groups, onClose, onBack, headerAction, headingId, stickyHeader, backProps, closeProps, className, ...rest }: PositionBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type PresetOption } from '../preset-group.js';
|
|
3
|
+
import { type ScreenHeaderControlProps } from './screen-header.js';
|
|
4
|
+
/** The row that opens the host's own entry of a value no quick choice holds, such as a keypad. */
|
|
5
|
+
export interface PresetPickerCustom {
|
|
6
|
+
/** The row's text: Custom amount. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Called on a press; the host opens its own entry. */
|
|
9
|
+
onSelect: () => void;
|
|
10
|
+
/** The value the host's entry set, as host text: `$75`. It is drawn on the trailing edge and the row reads as selected. */
|
|
11
|
+
value?: string;
|
|
12
|
+
/** Whether the row reads as selected. Defaults to whether `value` is given. */
|
|
13
|
+
selected?: boolean;
|
|
14
|
+
/** The row's accessible name, in place of its text: Edit custom size, current $75. */
|
|
15
|
+
accessibilityLabel?: string;
|
|
16
|
+
/** The row's `data-testid`. */
|
|
17
|
+
testID?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PresetPickerBlockProps<T extends string | number = number> extends Omit<React.HTMLAttributes<HTMLElement>, 'title'> {
|
|
20
|
+
/** Heading of the header. Leave it out for a pane whose host draws its own header: the block then starts at the headline figure. */
|
|
21
|
+
title?: string;
|
|
22
|
+
/** The headline figure, the value being chosen. `null` reads as unknown. */
|
|
23
|
+
value: number | null;
|
|
24
|
+
/** Format of the headline figure, such as `{style:'currency',currency:'USD',maximumFractionDigits:0}`. */
|
|
25
|
+
valueOptions?: Intl.NumberFormatOptions;
|
|
26
|
+
/** Text drawn before the figure, such as a sign the format does not draw. */
|
|
27
|
+
valuePrefix?: string;
|
|
28
|
+
/** Text drawn after the figure, such as `×` for leverage. */
|
|
29
|
+
valueSuffix?: string;
|
|
30
|
+
/** What the figure is read as before its value: Size. */
|
|
31
|
+
valueLabel?: string;
|
|
32
|
+
/** The host's own text for the figure, in place of formatting `value` with `valueOptions`, for a host with its own number table: `$1,250.50`. Drawn static unless `animateFormatted`; `value` still decides known or unknown and the direction of a move. As `AnimatedNumberReadout` `formattedValue`. */
|
|
33
|
+
formattedValue?: string;
|
|
34
|
+
/** With `formattedValue`, rolls each of its digits in place, counted from the end, as `AnimatedNumberReadout` `animateFormatted`. */
|
|
35
|
+
animateFormatted?: boolean;
|
|
36
|
+
/** The quick choices as chips, in order: `{value, label, disabled?, testID?}`. Labels are host text: `$25`, `Max`, `40×`. */
|
|
37
|
+
presets: readonly PresetOption<T>[];
|
|
38
|
+
/** The chip shown selected; `null` selects none, such as for a custom value. */
|
|
39
|
+
selected: T | null;
|
|
40
|
+
/** Called with the chip taken. A press on the selected chip, or on a dimmed one, does nothing. */
|
|
41
|
+
onPresetChange: (value: T) => void;
|
|
42
|
+
/** Accessible name of the chips' group, not drawn: Size. Defaults to `title`. */
|
|
43
|
+
presetsLabel?: string;
|
|
44
|
+
/** Chips per row. Defaults to every chip in one row. */
|
|
45
|
+
columns?: number;
|
|
46
|
+
/** The row that opens the host's own entry, drawn above the chips. */
|
|
47
|
+
custom?: PresetPickerCustom;
|
|
48
|
+
/** Fill of the selected chip, the selected custom row and the confirming action: `primary` (the default) or `destructive`. */
|
|
49
|
+
intent?: 'primary' | 'destructive';
|
|
50
|
+
/** Drawn as given between the chips and the actions, such as a muted note. */
|
|
51
|
+
children?: React.ReactNode;
|
|
52
|
+
/** Called on the confirming action. */
|
|
53
|
+
onSubmit: () => void;
|
|
54
|
+
/** Text of the confirming action: Set Size. */
|
|
55
|
+
submitLabel: string;
|
|
56
|
+
submitDisabled?: boolean;
|
|
57
|
+
/** The confirming action shows a spinner and ignores presses. */
|
|
58
|
+
busy?: boolean;
|
|
59
|
+
/** Shows Cancel on the leading side of the confirming action, the two sharing the row equally. */
|
|
60
|
+
onCancel?: () => void;
|
|
61
|
+
/** Text of Cancel. Defaults to the built-in “Cancel”. */
|
|
62
|
+
cancelLabel?: string;
|
|
63
|
+
/** The confirming action's `data-testid`. */
|
|
64
|
+
submitTestID?: string;
|
|
65
|
+
/** Cancel's `data-testid`. */
|
|
66
|
+
cancelTestID?: string;
|
|
67
|
+
/** Keeps the provider's feedback off the chips and both actions, for a host that plays its own cue. */
|
|
68
|
+
suppressFeedback?: boolean;
|
|
69
|
+
/** Shows Back on the leading edge of the header (needs `title`). */
|
|
70
|
+
onBack?: () => void;
|
|
71
|
+
/** Attributes for the header's Back `<button>`. */
|
|
72
|
+
backProps?: ScreenHeaderControlProps;
|
|
73
|
+
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
74
|
+
headerAction?: React.ReactNode;
|
|
75
|
+
/** `id` of the header's heading, so a dialog or sheet can name itself with `aria-labelledby`. */
|
|
76
|
+
headingId?: string;
|
|
77
|
+
/** Pins the header to the top of the nearest scroller. See Pinned headers. */
|
|
78
|
+
stickyHeader?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Choose one value from quick choices: an optional header, the value as the headline figure, an optional row that opens the host's own
|
|
82
|
+
* entry, the choices as chips, then Cancel and the confirming action. Draws a trade sheet's Size and Leverage panes. It reuses
|
|
83
|
+
* TargetBlock's parts (the headline, the Custom row, PresetGroup and the actions row) without its price card and unit control.
|
|
84
|
+
*/
|
|
85
|
+
export declare function PresetPickerBlock<T extends string | number = number>({ title, value, valueOptions, valuePrefix, valueSuffix, valueLabel, formattedValue, animateFormatted, presets, selected, onPresetChange, presetsLabel, columns, custom, intent, children, onSubmit, submitLabel, submitDisabled, busy, onCancel, cancelLabel, submitTestID, cancelTestID, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, className, ...rest }: PresetPickerBlockProps<T>): React.JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
4
|
+
import { PressDecoration, useHIG } from '../provider.js';
|
|
5
|
+
import { Button } from '../button.js';
|
|
6
|
+
import { PresetGroup } from '../preset-group.js';
|
|
7
|
+
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
8
|
+
import { ScreenHeader } from './screen-header.js';
|
|
9
|
+
import { SwapIcon } from './swap/shared.js';
|
|
10
|
+
/**
|
|
11
|
+
* Choose one value from quick choices: an optional header, the value as the headline figure, an optional row that opens the host's own
|
|
12
|
+
* entry, the choices as chips, then Cancel and the confirming action. Draws a trade sheet's Size and Leverage panes. It reuses
|
|
13
|
+
* TargetBlock's parts (the headline, the Custom row, PresetGroup and the actions row) without its price card and unit control.
|
|
14
|
+
*/
|
|
15
|
+
export function PresetPickerBlock({ title, value, valueOptions, valuePrefix, valueSuffix, valueLabel, formattedValue, animateFormatted, presets, selected, onPresetChange, presetsLabel, columns, custom, intent = 'primary', children, onSubmit, submitLabel, submitDisabled, busy, onCancel, cancelLabel, submitTestID, cancelTestID, suppressFeedback, onBack, backProps, headerAction, headingId, stickyHeader, className, ...rest }) {
|
|
16
|
+
const { messages } = useHIG();
|
|
17
|
+
const customSelected = custom ? (custom.selected ?? custom.value !== undefined) : false;
|
|
18
|
+
return _jsxs("section", { ...rest, className: `hig-preset-picker${className ? ` ${className}` : ''}`, "data-intent": intent === 'destructive' ? intent : undefined, children: [title !== undefined && _jsx(ScreenHeader, { title: title, onBack: onBack, backProps: backProps, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), _jsx("p", { className: 'hig-target-amount', children: _jsx(AnimatedNumberReadout, { value: value, options: valueOptions, formattedValue: formattedValue, animateFormatted: animateFormatted, prefix: valuePrefix, suffix: valueSuffix, label: valueLabel }) }), custom && _jsxs("button", { type: 'button', className: 'hig-swap-setting', "aria-pressed": customSelected, "aria-label": custom.accessibilityLabel, "data-testid": custom.testID, onClick: custom.onSelect, children: [_jsx("span", { children: custom.label }), custom.value !== undefined ? _jsxs("span", { className: 'hig-swap-setting-value', children: [custom.value, _jsx(SwapIcon, { name: 'chevron', size: 16 })] }) : _jsx(SwapIcon, { name: 'chevron', size: 16 }), _jsx(PressDecoration, { kind: 'row' })] }), presets.length > 0 && _jsx(PresetGroup, { label: presetsLabel ?? title, options: presets, value: selected, onValueChange: onPresetChange, columns: columns, selectedIntent: intent, suppressFeedback: suppressFeedback }), children, _jsxs("div", { className: 'hig-target-actions', children: [onCancel && _jsx(Button, { fullWidth: true, intent: 'secondary', suppressFeedback: suppressFeedback, "data-testid": cancelTestID, onClick: onCancel, children: cancelLabel ?? messages.cancel ?? en.cancel }), _jsx(Button, { fullWidth: true, intent: intent, disabled: submitDisabled, busy: busy, suppressFeedback: suppressFeedback, "data-testid": submitTestID, onClick: onSubmit, children: submitLabel })] })] });
|
|
19
|
+
}
|
|
@@ -66,6 +66,10 @@ export interface ProfileBlockProps extends Omit<React.HTMLAttributes<HTMLElement
|
|
|
66
66
|
sections: readonly ProfileSection[];
|
|
67
67
|
/** Host content under the sections, such as legal links. */
|
|
68
68
|
footer?: React.ReactNode;
|
|
69
|
+
/** Pins the top bar (address and Close) to the top of the nearest scroller, transparent at rest and filled once content scrolls under it, without moving when it starts to stick. See Pinned headers. */
|
|
70
|
+
stickyHeader?: boolean;
|
|
71
|
+
/** `id` of the name heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
72
|
+
headingId?: string;
|
|
69
73
|
}
|
|
70
74
|
/** A person's profile as one screen: who they are (avatar, status, name), then grouped rows that open their accounts, history, rewards and settings. */
|
|
71
|
-
export declare function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, className, ...rest }: ProfileBlockProps): React.JSX.Element;
|
|
75
|
+
export declare function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, stickyHeader, headingId, className, ...rest }: ProfileBlockProps): React.JSX.Element;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { PenLine } from '@bloxwap/icons/react/pen-line';
|
|
3
4
|
import React, { useRef } from 'react';
|
|
4
5
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
-
import { PressDecoration,
|
|
6
|
+
import { PressDecoration, useHIG } from '../provider.js';
|
|
7
|
+
import { useStickyHeader } from './sticky-header.js';
|
|
6
8
|
import { Button, IconButton } from '../button.js';
|
|
7
9
|
import { ListGroup, ListRow } from '../list-group.js';
|
|
8
10
|
import { AnimatedNumberReadout } from '../animated-number.js';
|
|
9
11
|
import { figureProps } from '../figure.js';
|
|
10
12
|
import { qrIcon } from './screen-header.js';
|
|
11
13
|
import { SwapIcon, addressGradient } from './swap/shared.js';
|
|
12
|
-
const editIcon = _jsx(
|
|
14
|
+
const editIcon = _jsx(PenLine, { size: 20 });
|
|
13
15
|
/** True for a `ProfileFigure`: a plain object with a `value`, not an element, array or other node. */
|
|
14
16
|
const isProfileFigure = (value) => value != null && typeof value === 'object' && !React.isValidElement(value) && !Array.isArray(value) && !(Symbol.iterator in value) && 'value' in value;
|
|
15
17
|
function rowValue(row) {
|
|
@@ -21,21 +23,18 @@ function rowValue(row) {
|
|
|
21
23
|
return tone ? _jsx("span", { className: 'hig-profile-value', "data-tone": tone, children: value }) : value;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
|
-
* A switch row whose whole row is the target
|
|
25
|
-
*
|
|
26
|
-
*
|
|
26
|
+
* A switch row whose whole row is the target: `ListRow`'s switch row. A press anywhere outside the switch toggles it, the switch
|
|
27
|
+
* input stays the one named control, named by the visible label (so the name is read once), and the host's press decoration
|
|
28
|
+
* covers the whole row.
|
|
27
29
|
*/
|
|
28
30
|
function ProfileSwitchRow({ row }) {
|
|
29
|
-
|
|
30
|
-
const input = useRef(null);
|
|
31
|
-
const toggle = (event) => { if (row.disabled || event.target.closest('.hig-switch'))
|
|
32
|
-
return; input.current?.click(); };
|
|
33
|
-
const value = rowValue(row);
|
|
34
|
-
return _jsxs("div", { className: 'hig-list-row', "aria-disabled": row.disabled || undefined, onClick: toggle, children: [row.leading != null && _jsx("span", { className: 'hig-list-row-leading', "aria-hidden": 'true', children: row.leading }), _jsx("span", { className: 'hig-list-row-label', children: row.label }), value != null && _jsx("span", { className: 'hig-list-row-value', children: value }), _jsx("span", { className: 'hig-list-row-trailing', children: _jsxs("label", { className: 'hig-choice hig-switch', children: [_jsx("input", { ref: input, role: 'switch', type: 'checkbox', checked: !!checked, disabled: row.disabled, onChange: event => set(event.target.checked) }), _jsx("span", { children: row.label })] }) }), _jsx(PressDecoration, { kind: 'switch', disabled: !!row.disabled, input: input })] });
|
|
31
|
+
return _jsx(ListRow, { label: row.label, leading: row.leading, value: rowValue(row), disabled: row.disabled, checked: !!row.checked, onCheckedChange: row.onCheckedChange });
|
|
35
32
|
}
|
|
36
33
|
/** A person's profile as one screen: who they are (avatar, status, name), then grouped rows that open their accounts, history, rewards and settings. */
|
|
37
|
-
export function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, className, ...rest }) {
|
|
34
|
+
export function ProfileBlock({ name, nameAccessory, address, avatar, onAvatarPress, avatarLabel, status, onEditName, onShowAddress, onClose, action, sections, footer, stickyHeader, headingId, className, ...rest }) {
|
|
38
35
|
const { messages } = useHIG();
|
|
36
|
+
const bar = useRef(null);
|
|
37
|
+
useStickyHeader(bar, !!stickyHeader);
|
|
39
38
|
const artwork = typeof avatar === 'string' ? _jsx("img", { src: avatar, alt: '' }) : avatar ?? (address ? null : name?.slice(0, 2));
|
|
40
|
-
return _jsxs("section", { ...rest, className: `hig-profile-block${className ? ` ${className}` : ''}`, children: [_jsxs("div", { className: 'hig-profile-bar', children: [_jsx("span", { children: onShowAddress && _jsx(IconButton, { intent: 'ghost', label: messages.showAddress ?? en.showAddress, onClick: onShowAddress, children: qrIcon }) }), _jsx("span", { children: onClose && _jsx(IconButton, { intent: 'ghost', label: messages.close ?? en.close, onClick: onClose, children: _jsx(SwapIcon, { name: 'close' }) }) })] }), _jsxs("div", { className: 'hig-profile-identity', children: [_jsxs("span", { className: 'hig-profile-avatar', style: avatar == null && address ? { background: addressGradient(address) } : undefined, children: [onAvatarPress ? _jsxs("button", { type: 'button', className: 'hig-profile-artwork', "aria-label": avatarLabel ?? name ?? messages.changeProfilePicture ?? en.changeProfilePicture, onClick: onAvatarPress, children: [artwork, _jsx(PressDecoration, { kind: 'icon-button' })] }) : _jsx("span", { className: 'hig-profile-artwork', "aria-hidden": 'true', children: artwork }), status && _jsx("span", { className: 'hig-profile-status', "data-tone": status.tone ?? 'warning', children: _jsx("span", { className: 'hig-sr-only', children: status.label }) })] }), name != null && _jsxs("div", { className: 'hig-profile-name', children: [_jsx("h2", { children: name }), nameAccessory != null && _jsx("span", { className: 'hig-profile-name-accessory', children: nameAccessory }), onEditName && _jsx(IconButton, { intent: 'ghost', label: messages.editName ?? en.editName, onClick: onEditName, children: editIcon })] }), action && _jsx(Button, { className: 'hig-profile-action', fullWidth: true, intent: action.intent ?? 'primary', disabled: action.disabled, onClick: action.onSelect, children: action.label })] }), sections.filter(section => section.rows.length > 0).map(section => _jsx(ListGroup, { title: section.title, children: section.rows.map(row => row.onCheckedChange ? _jsx(ProfileSwitchRow, { row: row }, row.id) : _jsx(ListRow, { label: row.label, leading: row.leading, value: rowValue(row), disabled: row.disabled, onSelect: row.onSelect, trailing: row.trailing }, row.id)) }, section.id)), footer != null && _jsx("div", { className: 'hig-profile-footer', children: footer })] });
|
|
39
|
+
return _jsxs("section", { ...rest, className: `hig-profile-block${className ? ` ${className}` : ''}`, children: [_jsxs("div", { ref: bar, className: 'hig-profile-bar', "data-sticky": stickyHeader || undefined, children: [_jsx("span", { children: onShowAddress && _jsx(IconButton, { intent: 'ghost', label: messages.showAddress ?? en.showAddress, onClick: onShowAddress, children: qrIcon }) }), _jsx("span", { children: onClose && _jsx(IconButton, { intent: 'ghost', label: messages.close ?? en.close, onClick: onClose, children: _jsx(SwapIcon, { name: 'close' }) }) })] }), _jsxs("div", { className: 'hig-profile-identity', children: [_jsxs("span", { className: 'hig-profile-avatar', style: avatar == null && address ? { background: addressGradient(address) } : undefined, children: [onAvatarPress ? _jsxs("button", { type: 'button', className: 'hig-profile-artwork', "aria-label": avatarLabel ?? name ?? messages.changeProfilePicture ?? en.changeProfilePicture, onClick: onAvatarPress, children: [artwork, _jsx(PressDecoration, { kind: 'icon-button' })] }) : _jsx("span", { className: 'hig-profile-artwork', "aria-hidden": 'true', children: artwork }), status && _jsx("span", { className: 'hig-profile-status', "data-tone": status.tone ?? 'warning', children: _jsx("span", { className: 'hig-sr-only', children: status.label }) })] }), name != null && _jsxs("div", { className: 'hig-profile-name', children: [_jsx("h2", { id: headingId, children: name }), nameAccessory != null && _jsx("span", { className: 'hig-profile-name-accessory', children: nameAccessory }), onEditName && _jsx(IconButton, { intent: 'ghost', label: messages.editName ?? en.editName, onClick: onEditName, children: editIcon })] }), action && _jsx(Button, { className: 'hig-profile-action', fullWidth: true, intent: action.intent ?? 'primary', disabled: action.disabled, onClick: action.onSelect, children: action.label })] }), sections.filter(section => section.rows.length > 0).map(section => _jsx(ListGroup, { title: section.title, children: section.rows.map(row => row.onCheckedChange ? _jsx(ProfileSwitchRow, { row: row }, row.id) : _jsx(ListRow, { label: row.label, leading: row.leading, value: rowValue(row), disabled: row.disabled, onSelect: row.onSelect, trailing: row.trailing }, row.id)) }, section.id)), footer != null && _jsx("div", { className: 'hig-profile-footer', children: footer })] });
|
|
41
40
|
}
|
|
@@ -19,14 +19,16 @@ export interface RewardPromo {
|
|
|
19
19
|
eyebrow: string;
|
|
20
20
|
/** A text link with a chevron on the trailing edge of the eyebrow: Rules. */
|
|
21
21
|
rules?: RewardLink;
|
|
22
|
-
/** The headline figure: the pool so far, or the top prize. `null` reads as unknown. */
|
|
23
|
-
amount
|
|
24
|
-
/**
|
|
22
|
+
/** The headline figure: the pool so far, or the top prize. A number updates place by place, formatted with `amountOptions`; `null` reads as unknown; a string is host text drawn as given in the same style, such as `$500` already formatted. Leave it out (with no `figure`) for a promotion with no figure. */
|
|
23
|
+
amount?: number | null | string;
|
|
24
|
+
/** Host content drawn in the headline figure's place and type, in place of `amount`, such as the host's own live figure. */
|
|
25
|
+
figure?: React.ReactNode;
|
|
26
|
+
/** Format of a number `amount` and of `goal`. Defaults to whole US dollars. */
|
|
25
27
|
amountOptions?: Intl.NumberFormatOptions;
|
|
26
|
-
/** The amount the pool is filling towards. Draws the progress bar under the caption. */
|
|
28
|
+
/** The amount the pool is filling towards. Draws the progress bar under the caption (full only against a number `amount`). */
|
|
27
29
|
goal?: number;
|
|
28
|
-
/** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given: top prize. */
|
|
29
|
-
caption?:
|
|
30
|
+
/** The line under the figure. A function receives the formatted goal: `goal => 'of ' + goal + ' prize pool'`. A string is drawn as given: top prize. Any other node is drawn as given, such as a live countdown. */
|
|
31
|
+
caption?: React.ReactNode | ((goal: string) => React.ReactNode);
|
|
30
32
|
/** The lead of the explaining sentence, in the text colour: Top 100 traders split the pool. Host text, or host elements for an accented word. */
|
|
31
33
|
headline?: React.ReactNode;
|
|
32
34
|
/** Continues the sentence after the headline in the muted colour: Funded by builder fees on every trade. */
|
|
@@ -85,7 +87,8 @@ export interface RewardBlockProps extends Omit<React.HTMLAttributes<HTMLElement>
|
|
|
85
87
|
listTitle?: string;
|
|
86
88
|
/** The column heading over the scores: Entries. */
|
|
87
89
|
scoreTitle?: string;
|
|
88
|
-
|
|
90
|
+
/** The standings, in order. Leave them out for a promotion-only pane: no list is drawn. */
|
|
91
|
+
entries?: readonly RewardEntry[];
|
|
89
92
|
/** Format of every score. Defaults to a whole number. An entry's own `scoreOptions` wins. */
|
|
90
93
|
scoreOptions?: Intl.NumberFormatOptions;
|
|
91
94
|
/** Accessible name of the verified mark. The mark is decorative without it. */
|
|
@@ -109,6 +112,8 @@ export interface RewardBlockProps extends Omit<React.HTMLAttributes<HTMLElement>
|
|
|
109
112
|
onBack?: () => void;
|
|
110
113
|
/** A control on the trailing edge of the header, usually an `IconButton` that shares. */
|
|
111
114
|
headerAction?: React.ReactNode;
|
|
115
|
+
/** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
116
|
+
headingId?: string;
|
|
112
117
|
/** Keeps the header pinned to the top of the scrolling container. It is transparent at rest and fills with `--hig-sticky-header-background` (`--hig-background` by default) once the standings scroll under it; inside a sheet remap it, for example `--hig-sticky-header-background: var(--hig-overlay)`. */
|
|
113
118
|
stickyHeader?: boolean;
|
|
114
119
|
/** Set false to leave the header out, when the host pins its own `ScreenHeader` above the block. */
|
|
@@ -117,4 +122,4 @@ export interface RewardBlockProps extends Omit<React.HTMLAttributes<HTMLElement>
|
|
|
117
122
|
/** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
|
|
118
123
|
export declare function rewardProgress(amount: number | null | undefined, goal: number | null | undefined): number | null;
|
|
119
124
|
/** A competition as a screen: an optional promotion (a prize pool filling towards its goal, or a draw with its top prize), an optional choice of standings, the viewer's own standing pinned on a tinted row, and the ranked list. */
|
|
120
|
-
export declare function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, header, className, ...rest }: RewardBlockProps): React.JSX.Element;
|
|
125
|
+
export declare function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries, scoreOptions, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, headingId, header, className, ...rest }: RewardBlockProps): React.JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CircleCheck } from '@bloxwap/icons/react/circle-check';
|
|
3
4
|
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
4
5
|
import { PressDecoration, usePresentNumber, useNumberLocale } from '../provider.js';
|
|
5
6
|
import { figureProps } from '../figure.js';
|
|
@@ -9,12 +10,13 @@ import { AnimatedNumberReadout } from '../animated-number.js';
|
|
|
9
10
|
import { ScreenHeader } from './screen-header.js';
|
|
10
11
|
import { SwapIcon, SwapNumber } from './swap/shared.js';
|
|
11
12
|
const wholeDollars = { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }, whole = { maximumFractionDigits: 0 };
|
|
13
|
+
const noEntries = [];
|
|
12
14
|
const skeletons = [0, 1, 2, 3, 4];
|
|
13
15
|
/** The share of the goal reached, from 0 to 1. Unknown amounts and goals that are not above zero give `null`. */
|
|
14
16
|
export function rewardProgress(amount, goal) {
|
|
15
17
|
return amount == null || goal == null || !Number.isFinite(amount) || !Number.isFinite(goal) || !(goal > 0) ? null : Math.min(1, Math.max(0, amount / goal));
|
|
16
18
|
}
|
|
17
|
-
const verifiedGlyph =
|
|
19
|
+
const verifiedGlyph = _jsx(CircleCheck, { size: 16, className: 'hig-reward-verified-mark' });
|
|
18
20
|
function Standing({ entry, scoreOptions, verifiedLabel, verifiedMark, verifiedMarkInteractive, as: Tag = 'li' }) {
|
|
19
21
|
const detail = entry.detail;
|
|
20
22
|
return _jsxs(Tag, { className: 'hig-reward-row', "data-you": entry.you || undefined, children: [_jsx("span", { className: 'hig-reward-rank hig-number', children: entry.rank }), _jsx("span", { className: 'hig-reward-avatar', "aria-hidden": 'true', children: typeof entry.avatar === 'string' ? _jsx("img", { src: entry.avatar, alt: '' }) : entry.avatar ?? entry.name.slice(0, 2) }), _jsxs("span", { className: 'hig-reward-identity', children: [_jsxs("strong", { className: 'hig-number', children: [entry.name, entry.verified && (verifiedMark != null && verifiedMarkInteractive ? _jsxs("span", { className: 'hig-reward-verified', children: [verifiedLabel && _jsx("span", { className: 'hig-sr-only', children: verifiedLabel }), verifiedMark] }) : _jsx("span", { className: 'hig-reward-verified', role: verifiedLabel ? 'img' : undefined, "aria-label": verifiedLabel, children: verifiedMark ?? verifiedGlyph }))] }), detail != null && detail !== '' && _jsx("span", { className: 'hig-number', children: typeof detail === 'string' ? detail : _jsx(SwapNumber, { ...figureProps(detail) }) })] }), _jsx("span", { className: 'hig-reward-score', children: _jsx(AnimatedNumberReadout, { value: entry.score, options: entry.scoreOptions ?? scoreOptions }) })] });
|
|
@@ -24,11 +26,12 @@ function Onward({ link, className, children }) {
|
|
|
24
26
|
: _jsxs("button", { type: 'button', className: className, onClick: link.onSelect, children: [children, _jsx(PressDecoration, { kind: 'row' })] });
|
|
25
27
|
}
|
|
26
28
|
/** A competition as a screen: an optional promotion (a prize pool filling towards its goal, or a draw with its top prize), an optional choice of standings, the viewer's own standing pinned on a tinted row, and the ranked list. */
|
|
27
|
-
export function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries, scoreOptions = whole, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, header = true, className, ...rest }) {
|
|
29
|
+
export function RewardBlock({ title, promo, tabs, you, youLabel, status, listTitle, scoreTitle, entries = noEntries, scoreOptions = whole, verifiedLabel, verifiedMark, verifiedMarkInteractive, loading, loadingLabel, pagination, footnote, onBack, headerAction, stickyHeader, headingId, header = true, className, ...rest }) {
|
|
28
30
|
const locale = useNumberLocale();
|
|
29
31
|
const present = usePresentNumber();
|
|
30
|
-
const money = promo?.amountOptions ?? wholeDollars, share = promo ? rewardProgress(
|
|
32
|
+
const amount = promo?.amount, money = promo?.amountOptions ?? wholeDollars, share = promo ? rewardProgress(typeof amount === 'string' ? null : amount, promo.goal) : null;
|
|
31
33
|
const caption = typeof promo?.caption === 'function' ? promo.goal !== undefined ? promo.caption(formatNumber(promo.goal, locale, present(money))) : undefined : promo?.caption;
|
|
34
|
+
const figure = promo?.figure != null && promo.figure !== false ? promo.figure : amount === undefined ? null : typeof amount === 'string' ? amount : _jsx(AnimatedNumberReadout, { value: amount, options: money });
|
|
32
35
|
const pinned = you && _jsx(Standing, { as: 'div', entry: { ...you, you: true }, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive });
|
|
33
|
-
return _jsxs("section", { ...rest, className: `hig-reward-block${className ? ` ${className}` : ''}`, children: [header && _jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, stickyHeader: stickyHeader }), promo && _jsxs("section", { className: 'hig-surface hig-reward-promo', children: [_jsxs("div", { className: 'hig-reward-promo-top', children: [_jsx("span", { className: 'hig-reward-eyebrow hig-number', children: promo.eyebrow }), promo.rules && _jsxs(Onward, { link: promo.rules, className: 'hig-reward-rules', children: [promo.rules.label, _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), _jsx("
|
|
36
|
+
return _jsxs("section", { ...rest, className: `hig-reward-block${className ? ` ${className}` : ''}`, children: [header && _jsx(ScreenHeader, { title: title, onBack: onBack, action: headerAction, headingId: headingId, stickyHeader: stickyHeader }), promo && _jsxs("section", { className: 'hig-surface hig-reward-promo', children: [_jsxs("div", { className: 'hig-reward-promo-top', children: [_jsx("span", { className: 'hig-reward-eyebrow hig-number', children: promo.eyebrow }), promo.rules && _jsxs(Onward, { link: promo.rules, className: 'hig-reward-rules', children: [promo.rules.label, _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), figure != null && (promo.figure != null && promo.figure !== false ? _jsx("div", { className: 'hig-reward-amount', children: figure }) : _jsx("p", { className: 'hig-reward-amount', children: figure })), caption != null && caption !== false && caption !== '' && (typeof caption === 'string' || typeof caption === 'number' ? _jsx("p", { className: 'hig-reward-caption hig-number', children: caption }) : _jsx("div", { className: 'hig-reward-caption hig-number', children: caption })), promo.goal !== undefined && _jsx("div", { className: 'hig-reward-track', "aria-hidden": 'true', children: _jsx("span", { style: { width: `${(share ?? 0) * 100}%` } }) }), (promo.headline || promo.description) && _jsxs("p", { className: 'hig-reward-summary', children: [promo.headline && _jsx("strong", { children: promo.headline }), promo.headline && promo.description ? ' ' : null, promo.description] }), promo.action && _jsxs(Onward, { link: promo.action, className: 'hig-reward-action', children: [_jsx("span", { children: promo.action.label }), _jsx(SwapIcon, { name: 'chevron', size: 16 })] })] }), tabs && _jsx(SegmentedControl, { label: tabs.label, options: tabs.options, value: tabs.value, onValueChange: tabs.onValueChange }), pinned && (youLabel ? _jsx("div", { className: 'hig-reward-you', role: 'group', "aria-label": youLabel, children: pinned }) : _jsx("div", { className: 'hig-reward-you', children: pinned })), status && _jsx("p", { className: 'hig-reward-status', role: 'status', children: status }), loading ? _jsxs(_Fragment, { children: [loadingLabel && _jsx("p", { className: 'hig-sr-only', role: 'status', children: loadingLabel }), _jsx("div", { className: 'hig-reward-list', "aria-busy": 'true', children: skeletons.map(index => _jsx("div", { className: 'hig-skeleton hig-reward-skeleton', "aria-hidden": 'true' }, index)) })] }) : (entries.length > 0 || listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-list', children: [(listTitle || scoreTitle) && _jsxs("div", { className: 'hig-reward-columns hig-number', children: [_jsx("span", { children: listTitle }), _jsx("span", { children: scoreTitle })] }), entries.length > 0 && _jsx("ol", { className: 'hig-reward-rows', children: entries.map(entry => _jsx(Standing, { entry: entry, scoreOptions: scoreOptions, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive }, entry.id)) })] }), pagination && _jsxs("div", { className: 'hig-reward-pagination', children: [pagination.previous ? _jsx(Button, { intent: 'secondary', disabled: pagination.previous.disabled, onClick: pagination.previous.onSelect, children: pagination.previous.label }) : _jsx("span", {}), pagination.label ? _jsx("span", { className: 'hig-reward-page hig-number', "aria-live": 'polite', children: pagination.label }) : _jsx("span", {}), pagination.next ? _jsx(Button, { intent: 'secondary', disabled: pagination.next.disabled, onClick: pagination.next.onSelect, children: pagination.next.label }) : _jsx("span", {})] }), footnote && _jsx("p", { className: 'hig-reward-footnote', children: footnote })] });
|
|
34
37
|
}
|
|
@@ -16,18 +16,26 @@ export interface ScreenHeaderProps {
|
|
|
16
16
|
headingId?: string;
|
|
17
17
|
/** Short host text in a badge beside the title, read as part of the heading after a pause: Demo. */
|
|
18
18
|
badge?: string;
|
|
19
|
+
/** A kicker over the title, centred in small muted capitals: Builder fee. Host text, read before the heading as its own line. The header grows to fit it. */
|
|
20
|
+
eyebrow?: string;
|
|
19
21
|
/** Hides the title visually while it stays the accessible heading, for a host that draws its own visible title and must not have it read twice. The header keeps its height and its two sides. */
|
|
20
22
|
hideTitle?: boolean;
|
|
23
|
+
/** Host text that describes the pane, never drawn and read after the heading: a visually hidden paragraph that follows it, `id` `<headingId>-description` when `headingId` is set, so a dialog can point `aria-describedby` at it. */
|
|
24
|
+
description?: string;
|
|
21
25
|
/** Pins the header to the top of the nearest scrolling container. It is transparent at rest and takes its fill (`--hig-sticky-header-background`) only once content has scrolled under it. */
|
|
22
26
|
stickyHeader?: boolean;
|
|
23
27
|
}
|
|
28
|
+
/** Attributes for a header Close `<button>`: those of `ScreenHeaderControlProps`, plus `disabled`, which draws Close unavailable (dimmed, `disabled`, not pressable), for example while the pane's action is being signed. */
|
|
29
|
+
export type HeaderCloseProps = ScreenHeaderControlProps & {
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
};
|
|
24
32
|
/** The block header's Close control, shared by the blocks that draw one. */
|
|
25
33
|
export declare function HeaderClose({ onClose, label, closeProps }: {
|
|
26
34
|
onClose: () => void;
|
|
27
35
|
label: string;
|
|
28
|
-
closeProps?:
|
|
36
|
+
closeProps?: HeaderCloseProps;
|
|
29
37
|
}): React.JSX.Element;
|
|
30
38
|
/** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. Every block draws it; import it from `@bloxwap/hig/react/blocks/screen-header` for a host pane that has no block. */
|
|
31
|
-
export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, headingId, badge, hideTitle, stickyHeader }: ScreenHeaderProps): React.JSX.Element;
|
|
39
|
+
export declare function ScreenHeader({ title, onBack, backDisabled, backProps, action, headingId, badge, eyebrow, hideTitle, description, stickyHeader }: ScreenHeaderProps): React.JSX.Element;
|
|
32
40
|
/** The QR glyph of a control that shows an address. */
|
|
33
41
|
export declare const qrIcon: React.JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { QrCode } from '@bloxwap/icons/react/qr-code';
|
|
3
4
|
import { useRef } from 'react';
|
|
4
5
|
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
6
|
import { PressDecoration, useHIG } from '../provider.js';
|
|
@@ -7,14 +8,16 @@ import { SwapIcon } from './swap/shared.js';
|
|
|
7
8
|
import { useStickyHeader } from './sticky-header.js';
|
|
8
9
|
/** The block header's Close control, shared by the blocks that draw one. */
|
|
9
10
|
export function HeaderClose({ onClose, label, closeProps }) {
|
|
10
|
-
|
|
11
|
+
const off = !!closeProps?.disabled;
|
|
12
|
+
return _jsxs("button", { ...closeProps, type: 'button', className: 'hig-swap-back', "aria-label": label, disabled: off || undefined, onClick: onClose, children: [_jsx(SwapIcon, { name: 'close' }), _jsx(PressDecoration, { kind: 'back', disabled: off })] });
|
|
11
13
|
}
|
|
12
14
|
/** Header of a card that is its own screen: Back on the leading edge, the title centred, and an optional control on the trailing edge. The title stays centred with either, both or neither. Every block draws it; import it from `@bloxwap/hig/react/blocks/screen-header` for a host pane that has no block. */
|
|
13
|
-
export function ScreenHeader({ title, onBack, backDisabled, backProps, action, headingId, badge, hideTitle, stickyHeader }) {
|
|
15
|
+
export function ScreenHeader({ title, onBack, backDisabled, backProps, action, headingId, badge, eyebrow, hideTitle, description, stickyHeader }) {
|
|
14
16
|
const { messages } = useHIG();
|
|
15
17
|
const header = useRef(null);
|
|
16
18
|
useStickyHeader(header, !!stickyHeader);
|
|
17
|
-
|
|
19
|
+
const heading = _jsx("h2", { id: headingId, className: `hig-screen-title${hideTitle ? ' hig-sr-only' : ''}`, children: badge ? _jsxs(_Fragment, { children: [title, _jsx("span", { className: 'hig-sr-only', children: "," }), " ", _jsx("span", { className: 'hig-badge hig-screen-badge', children: badge })] }) : title });
|
|
20
|
+
return _jsxs("div", { ref: header, className: 'hig-screen-header', "data-sticky": stickyHeader || undefined, children: [_jsx("span", { className: 'hig-screen-header-side', children: onBack && _jsxs("button", { ...backProps, type: 'button', className: 'hig-swap-back', "aria-label": messages.back ?? en.back, disabled: backDisabled || undefined, onClick: onBack, children: [_jsx(SwapIcon, { name: 'back' }), _jsx(PressDecoration, { kind: 'back', disabled: !!backDisabled })] }) }), eyebrow ? _jsxs("div", { className: 'hig-screen-heading', children: [_jsx("p", { className: 'hig-screen-eyebrow', children: eyebrow }), heading] }) : heading, description ? _jsx("p", { id: headingId ? `${headingId}-description` : undefined, className: 'hig-sr-only', children: description }) : null, _jsx("span", { className: 'hig-screen-header-side', children: action })] });
|
|
18
21
|
}
|
|
19
22
|
/** The QR glyph of a control that shows an address. */
|
|
20
|
-
export const qrIcon =
|
|
23
|
+
export const qrIcon = _jsx(QrCode, { size: 20 });
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useId, useRef } from 'react';
|
|
4
4
|
import { PressDecoration } from '../provider.js';
|
|
5
5
|
/** One setting as a switch: the label over an optional description on the leading edge, the track on the trailing edge. The whole row is the `label.hig-choice` hit target, at least `--hig-control` tall, and toggles it; the label names the switch and the description describes it. */
|
|
6
6
|
export function SettingSwitch({ label, description, checked, onCheckedChange, disabled, locked, labelAccessory, labelAccessoryLabel }) {
|
|
7
|
-
const id = useId(), name = `${id}-label`, about = `${id}-description`;
|
|
7
|
+
const id = useId(), name = `${id}-label`, about = `${id}-description`, spoken = `${id}-name`, extra = `${id}-accessory`;
|
|
8
8
|
const input = useRef(null);
|
|
9
|
+
const accessory = labelAccessory != null && labelAccessory !== false, worded = accessory && !!labelAccessoryLabel;
|
|
9
10
|
// The comma is read, not drawn, so the name pauses between the label and the accessory instead of running them together.
|
|
10
|
-
|
|
11
|
+
// The label and its comma are one hidden text node: a visually hidden comma beside the label is laid out apart, and Chromium and WebKit read a space before it (`Swing notifications , Genesis`).
|
|
12
|
+
// With host words that node is the whole name; otherwise the name is that node then the accessory's own content, which the name computation joins with one space (`Feed, New`).
|
|
13
|
+
return _jsxs("label", { className: 'hig-choice hig-setting-switch', "data-disabled": disabled || undefined, "data-locked": locked || undefined, children: [_jsxs("span", { className: 'hig-setting-switch-text', children: [_jsxs("span", { id: name, children: [label, accessory && _jsx("span", { id: worded ? undefined : extra, className: 'hig-setting-switch-accessory', "aria-hidden": worded || undefined, children: labelAccessory })] }), accessory && _jsx("span", { id: spoken, hidden: true, children: worded ? `${label}, ${labelAccessoryLabel}` : `${label},` }), description && _jsx("span", { id: about, className: 'hig-setting-switch-description', children: description })] }), _jsx("span", { className: 'hig-switch', children: _jsx("input", { ref: input, type: 'checkbox', role: 'switch', "aria-labelledby": !accessory ? name : worded ? spoken : `${spoken} ${extra}`, "aria-describedby": description ? about : undefined, "aria-disabled": locked || undefined, checked: locked ? true : checked, disabled: disabled, onChange: event => { if (!locked)
|
|
11
14
|
onCheckedChange(event.target.checked); } }) }), _jsx(PressDecoration, { kind: 'switch', disabled: !!disabled || !!locked, input: input })] });
|
|
12
15
|
}
|
|
@@ -47,8 +47,10 @@ export interface SignalsBlockProps extends Omit<React.HTMLAttributes<HTMLElement
|
|
|
47
47
|
onBack?: () => void;
|
|
48
48
|
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
49
49
|
headerAction?: React.ReactNode;
|
|
50
|
+
/** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
51
|
+
headingId?: string;
|
|
50
52
|
/** 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. */
|
|
51
53
|
stickyHeader?: boolean;
|
|
52
54
|
}
|
|
53
55
|
/** The signals the viewer receives, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
|
|
54
|
-
export declare function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, className, ...rest }: SignalsBlockProps): React.JSX.Element;
|
|
56
|
+
export declare function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, headingId, className, ...rest }: SignalsBlockProps): React.JSX.Element;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { CircleCheck } from '@bloxwap/icons/react/circle-check';
|
|
3
4
|
import { useId } from 'react';
|
|
4
5
|
import { ScreenHeader } from './screen-header.js';
|
|
5
6
|
import { SettingSwitch } from './setting-switch.js';
|
|
6
7
|
import { SwapPill } from './swap/shared.js';
|
|
7
|
-
const verifiedGlyph =
|
|
8
|
+
const verifiedGlyph = _jsx(CircleCheck, { size: 16 });
|
|
8
9
|
function Group({ group, verifiedLabel, verifiedMark, verifiedMarkInteractive }) {
|
|
9
10
|
const id = useId();
|
|
10
11
|
return _jsxs("section", { className: 'hig-signals-group', "aria-labelledby": id, children: [_jsxs("div", { className: 'hig-signals-group-header', children: [_jsxs("h3", { id: id, children: [group.title, group.verified && (verifiedMark != null && verifiedMarkInteractive ? _jsxs("span", { className: 'hig-reward-verified', children: [verifiedLabel && _jsx("span", { className: 'hig-sr-only', children: verifiedLabel }), verifiedMark] }) : _jsx("span", { className: 'hig-reward-verified', role: verifiedLabel ? 'img' : undefined, "aria-label": verifiedLabel, children: verifiedMark ?? verifiedGlyph }))] }), group.help && _jsx(SwapPill, { ref: group.help.ref, onClick: group.help.onSelect, children: group.help.label })] }), group.items.length > 0 && _jsx("div", { className: 'hig-setting-list', children: group.items.map(item => _jsxs("div", { className: 'hig-setting-card', children: [_jsx(SettingSwitch, { label: item.label, description: item.description, checked: item.checked, disabled: item.disabled, locked: item.locked, labelAccessory: item.labelAccessory, labelAccessoryLabel: item.labelAccessoryLabel, onCheckedChange: item.onCheckedChange }), (item.hint || item.error) && _jsxs("div", { className: 'hig-setting-notes', children: [item.hint && _jsx("p", { role: 'status', className: 'hig-setting-hint', children: item.hint }), item.error && _jsx("p", { role: 'alert', className: 'hig-setting-error', children: item.error })] })] }, item.id)) })] });
|
|
11
12
|
}
|
|
12
13
|
/** The signals the viewer receives, in groups: each group has a heading with an optional verified mark and a small help pill, and its signals as switches with a line of explanation, sharing one rounded container. */
|
|
13
|
-
export function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, className, ...rest }) {
|
|
14
|
-
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 }), groups.map(group => _jsx(Group, { group: group, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive }, group.id))] });
|
|
14
|
+
export function SignalsBlock({ title, description, groups, verifiedLabel, verifiedMark, verifiedMarkInteractive, onBack, headerAction, stickyHeader, headingId, className, ...rest }) {
|
|
15
|
+
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 }), groups.map(group => _jsx(Group, { group: group, verifiedLabel: verifiedLabel, verifiedMark: verifiedMark, verifiedMarkInteractive: verifiedMarkInteractive }, group.id))] });
|
|
15
16
|
}
|
|
@@ -50,10 +50,12 @@ export interface SoundHapticsBlockProps extends Omit<React.HTMLAttributes<HTMLEl
|
|
|
50
50
|
onBack?: () => void;
|
|
51
51
|
/** A control on the trailing edge of the header, usually an `IconButton`. */
|
|
52
52
|
headerAction?: React.ReactNode;
|
|
53
|
+
/** `id` of the header's heading, so a host dialog or sheet can name itself with `aria-labelledby`. */
|
|
54
|
+
headingId?: string;
|
|
53
55
|
/** 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. */
|
|
54
56
|
stickyHeader?: boolean;
|
|
55
57
|
}
|
|
56
58
|
/** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
|
|
57
59
|
export declare const soundLevel: (level: number | null | undefined) => number;
|
|
58
60
|
/** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a choice of devices, a live input meter and its volume as fixed steps. */
|
|
59
|
-
export declare function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, className, ...rest }: SoundHapticsBlockProps): React.JSX.Element;
|
|
61
|
+
export declare function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, headingId, className, ...rest }: SoundHapticsBlockProps): React.JSX.Element;
|
|
@@ -10,9 +10,9 @@ const steps = [0.25, 0.5, 0.75, 1], percent = { style: 'percent', maximumFractio
|
|
|
10
10
|
/** The share of the meter filled, from 0 to 1. Unknown and out-of-range levels are clamped. */
|
|
11
11
|
export const soundLevel = (level) => level == null || !Number.isFinite(level) ? 0 : Math.min(1, Math.max(0, level));
|
|
12
12
|
/** The settings for what the app plays and feels like: each channel is a card with a switch, and a channel that is on can show the device it uses, a choice of devices, a live input meter and its volume as fixed steps. */
|
|
13
|
-
export function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, className, ...rest }) {
|
|
13
|
+
export function SoundHapticsBlock({ title, description, sections, onBack, headerAction, stickyHeader, headingId, className, ...rest }) {
|
|
14
14
|
const locale = useNumberLocale();
|
|
15
|
-
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 }), sections.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: sections.map(section => {
|
|
15
|
+
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 }), sections.length > 0 && _jsx("div", { className: 'hig-setting-cards', children: sections.map(section => {
|
|
16
16
|
const { source, choices, level, levelLabel, volume, action } = section, on = section.checked;
|
|
17
17
|
const showVolume = !!volume && (on || section.volumeWhenOff === 'disabled'), volumeOff = !!section.disabled || !on;
|
|
18
18
|
const open = (on && (!!source || !!choices || level !== undefined)) || showVolume || !!action;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { type RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* How far the header rests below the edge it sticks to: the scroller's content edge (browsers stick inside the scroller's own
|
|
4
|
+
* padding) or the viewport. When the header leads every box between it and the scroller, that distance is the top margins,
|
|
5
|
+
* borders and padding of those boxes, such as a pane's padding; sticking at it keeps the header where it rests. A header that
|
|
6
|
+
* follows other content returns `null`: it scrolls up to the edge before it pins, as before.
|
|
7
|
+
*/
|
|
8
|
+
export declare function stickyRestingInset(header: HTMLElement, root: HTMLElement | null): number | null;
|
|
2
9
|
/**
|
|
3
10
|
* Marks a pinned header `data-scrolled` once content has scrolled under it, so its fill appears only then and it stays
|
|
4
|
-
* transparent at rest
|
|
5
|
-
* the
|
|
6
|
-
*
|
|
7
|
-
*
|
|
11
|
+
* transparent at rest, and pins it where it rests so it does not move when it starts to stick, whatever padding sits between
|
|
12
|
+
* it and the scroller. The header's parent is the content: the header is scrolled once the parent has moved up past the point
|
|
13
|
+
* where the header pins (or the scroller is the parent and has moved). The pinned inset is `--hig-sticky-inset`, and
|
|
14
|
+
* `--hig-sticky-cover` is how far above the header the fill reaches to the scroller's edge, so content does not show through
|
|
15
|
+
* the gap; `data-sticky-inset` marks a header with such a gap. Where the browser supports scroll-driven animations the
|
|
16
|
+
* stylesheet fades the fill in on the same rule for a header that pins at the scroller's very edge; this keeps every other
|
|
17
|
+
* browser, a header with a gap and reduced motion in step with it.
|
|
8
18
|
*/
|
|
9
19
|
export declare function useStickyHeader(header: RefObject<HTMLElement | null>, enabled: boolean): void;
|