@bloxwap/hig 0.0.0-stage → 0.5.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/LICENSE +5 -0
- package/README.md +44 -2
- package/chart/README.md +23 -0
- package/chart/dist/index.d.ts +8 -0
- package/chart/dist/index.js +12 -0
- package/contracts/README.md +3 -0
- package/contracts/dist/announcements.d.ts +12 -0
- package/contracts/dist/announcements.js +8 -0
- package/contracts/dist/feedback.d.ts +40 -0
- package/contracts/dist/feedback.js +1 -0
- package/contracts/dist/index.d.ts +41 -0
- package/contracts/dist/index.js +52 -0
- package/contracts/dist/messages.d.ts +300 -0
- package/contracts/dist/messages.js +114 -0
- package/css.d.ts +2 -0
- package/feedback/README.md +7 -0
- package/feedback/assets/error.wav +0 -0
- package/feedback/assets/manifest.json +78 -0
- package/feedback/assets/success.wav +0 -0
- package/feedback/assets/tick.wav +0 -0
- package/feedback/assets/toggle.wav +0 -0
- package/feedback/dist/browser-haptic.d.ts +23 -0
- package/feedback/dist/browser-haptic.js +41 -0
- package/feedback/dist/contract.d.ts +40 -0
- package/feedback/dist/contract.js +59 -0
- package/feedback/dist/native.d.ts +28 -0
- package/feedback/dist/native.js +63 -0
- package/feedback/dist/preferences.d.ts +8 -0
- package/feedback/dist/preferences.js +24 -0
- package/feedback/dist/presets.d.ts +57 -0
- package/feedback/dist/presets.js +1 -0
- package/feedback/dist/react.d.ts +19 -0
- package/feedback/dist/react.js +23 -0
- package/feedback/dist/web-haptic.d.ts +6 -0
- package/feedback/dist/web-haptic.js +6 -0
- package/feedback/dist/web-sound.d.ts +5 -0
- package/feedback/dist/web-sound.js +32 -0
- package/feedback/dist/web.d.ts +3 -0
- package/feedback/dist/web.js +4 -0
- package/native/README.md +16 -0
- package/native/android/build.gradle +28 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableView.java +173 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGAdjustableViewManager.java +23 -0
- package/native/android/src/main/java/com/bloxwap/hig/HIGPackage.java +24 -0
- package/native/dist/animated-number-model.d.ts +24 -0
- package/native/dist/animated-number-model.js +110 -0
- package/native/dist/animated-number.d.ts +9 -0
- package/native/dist/animated-number.js +97 -0
- package/native/dist/brand.d.ts +7 -0
- package/native/dist/brand.js +7 -0
- package/native/dist/button.d.ts +30 -0
- package/native/dist/button.js +36 -0
- package/native/dist/checkbox.d.ts +3 -0
- package/native/dist/checkbox.js +11 -0
- package/native/dist/data.d.ts +57 -0
- package/native/dist/data.js +47 -0
- package/native/dist/field.d.ts +16 -0
- package/native/dist/field.js +26 -0
- package/native/dist/gesture-sheet.d.ts +73 -0
- package/native/dist/gesture-sheet.js +153 -0
- package/native/dist/icons.d.ts +21 -0
- package/native/dist/icons.js +20 -0
- package/native/dist/navigation.d.ts +48 -0
- package/native/dist/navigation.js +58 -0
- package/native/dist/overlay.d.ts +36 -0
- package/native/dist/overlay.js +65 -0
- package/native/dist/pickers.d.ts +54 -0
- package/native/dist/pickers.js +60 -0
- package/native/dist/provider.d.ts +62 -0
- package/native/dist/provider.js +67 -0
- package/native/dist/radio-group.d.ts +21 -0
- package/native/dist/radio-group.js +91 -0
- package/native/dist/recipes.d.ts +45 -0
- package/native/dist/recipes.js +32 -0
- package/native/dist/roles.d.ts +6 -0
- package/native/dist/roles.js +4 -0
- package/native/dist/select.d.ts +3 -0
- package/native/dist/select.js +9 -0
- package/native/dist/selection-types.d.ts +22 -0
- package/native/dist/selection-types.js +1 -0
- package/native/dist/selection.d.ts +8 -0
- package/native/dist/selection.js +7 -0
- package/native/dist/slider.d.ts +11 -0
- package/native/dist/slider.js +42 -0
- package/native/dist/status.d.ts +86 -0
- package/native/dist/status.js +112 -0
- package/native/dist/surface.d.ts +19 -0
- package/native/dist/surface.js +42 -0
- package/native/dist/swap-panel.d.ts +125 -0
- package/native/dist/swap-panel.js +177 -0
- package/native/dist/swap-parts.d.ts +86 -0
- package/native/dist/swap-parts.js +66 -0
- package/native/dist/swap-shared.d.ts +65 -0
- package/native/dist/swap-shared.js +76 -0
- package/native/dist/swap-sheet.d.ts +14 -0
- package/native/dist/swap-sheet.js +26 -0
- package/native/dist/swap-views.d.ts +41 -0
- package/native/dist/swap-views.js +37 -0
- package/native/dist/switch-row.d.ts +8 -0
- package/native/dist/switch-row.js +18 -0
- package/native/dist/switch.d.ts +10 -0
- package/native/dist/switch.js +30 -0
- package/native/dist/text-content.d.ts +5 -0
- package/native/dist/text-content.js +6 -0
- package/native/dist/wallet-address.d.ts +37 -0
- package/native/dist/wallet-address.js +50 -0
- package/native-fonts/README.md +17 -0
- package/native-fonts/dist/index.d.ts +164 -0
- package/native-fonts/dist/index.js +164 -0
- package/native-fonts/fonts/BloxwapMono-Bold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-ExtraBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapMono.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Black.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-ExtraBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSans.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansKR-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansKR.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansSC-SemiBold.ttf +0 -0
- package/native-fonts/fonts/BloxwapSansSC.ttf +0 -0
- package/native-fonts/fonts/OFL.txt +93 -0
- package/native-fonts/fonts/manifest.json +164 -0
- package/og-fonts/README.md +34 -0
- package/og-fonts/dist/index.d.ts +116 -0
- package/og-fonts/dist/index.js +102 -0
- package/og-fonts/dist/node.d.ts +11 -0
- package/og-fonts/dist/node.js +39 -0
- package/og-fonts/fonts/BloxwapMono-Medium.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Black.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Bold.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans-Medium.ttf +0 -0
- package/og-fonts/fonts/BloxwapSans.ttf +0 -0
- package/og-fonts/fonts/OFL.txt +93 -0
- package/og-fonts/fonts/manifest.json +65 -0
- package/package.json +476 -4
- package/react/README.md +30 -0
- package/react/dist/animated-number-model.d.ts +20 -0
- package/react/dist/animated-number-model.js +92 -0
- package/react/dist/animated-number.d.ts +8 -0
- package/react/dist/animated-number.js +72 -0
- package/react/dist/base.css +9 -0
- package/react/dist/brand.d.ts +7 -0
- package/react/dist/brand.js +5 -0
- package/react/dist/button.d.ts +14 -0
- package/react/dist/button.js +20 -0
- package/react/dist/data.d.ts +78 -0
- package/react/dist/data.js +36 -0
- package/react/dist/dialog.d.ts +29 -0
- package/react/dist/dialog.js +21 -0
- package/react/dist/field.d.ts +16 -0
- package/react/dist/field.js +20 -0
- package/react/dist/gesture-sheet.d.ts +41 -0
- package/react/dist/gesture-sheet.js +128 -0
- package/react/dist/navigation.d.ts +48 -0
- package/react/dist/navigation.js +69 -0
- package/react/dist/notify.d.ts +14 -0
- package/react/dist/notify.js +6 -0
- package/react/dist/overlay.d.ts +17 -0
- package/react/dist/overlay.js +18 -0
- package/react/dist/provider.d.ts +25 -0
- package/react/dist/provider.js +50 -0
- package/react/dist/recipes/activity-list.d.ts +8 -0
- package/react/dist/recipes/activity-list.js +6 -0
- package/react/dist/recipes/balance-card.d.ts +6 -0
- package/react/dist/recipes/balance-card.js +5 -0
- package/react/dist/recipes/code-window.d.ts +4 -0
- package/react/dist/recipes/code-window.js +4 -0
- package/react/dist/recipes/install-command.d.ts +6 -0
- package/react/dist/recipes/install-command.js +15 -0
- package/react/dist/recipes/market-row.d.ts +25 -0
- package/react/dist/recipes/market-row.js +8 -0
- package/react/dist/recipes/marketing-hero.d.ts +7 -0
- package/react/dist/recipes/marketing-hero.js +5 -0
- package/react/dist/recipes/pickers.d.ts +57 -0
- package/react/dist/recipes/pickers.js +78 -0
- package/react/dist/recipes/swap/amount-card.d.ts +40 -0
- package/react/dist/recipes/swap/amount-card.js +7 -0
- package/react/dist/recipes/swap/picker.d.ts +26 -0
- package/react/dist/recipes/swap/picker.js +20 -0
- package/react/dist/recipes/swap/settings.d.ts +24 -0
- package/react/dist/recipes/swap/settings.js +25 -0
- package/react/dist/recipes/swap/shared.d.ts +98 -0
- package/react/dist/recipes/swap/shared.js +106 -0
- package/react/dist/recipes/swap-panel.d.ts +127 -0
- package/react/dist/recipes/swap-panel.js +170 -0
- package/react/dist/recipes/swap-sheet.d.ts +16 -0
- package/react/dist/recipes/swap-sheet.js +22 -0
- package/react/dist/recipes/trade-entry.d.ts +11 -0
- package/react/dist/recipes/trade-entry.js +12 -0
- package/react/dist/recipes.d.ts +10 -0
- package/react/dist/recipes.js +11 -0
- package/react/dist/select.d.ts +4 -0
- package/react/dist/select.js +174 -0
- package/react/dist/selection.d.ts +40 -0
- package/react/dist/selection.js +23 -0
- package/react/dist/slider.d.ts +11 -0
- package/react/dist/slider.js +10 -0
- package/react/dist/status.d.ts +63 -0
- package/react/dist/status.js +47 -0
- package/react/dist/styles.css +542 -0
- package/react/dist/surface.d.ts +291 -0
- package/react/dist/surface.js +9 -0
- package/react/dist/toast.d.ts +17 -0
- package/react/dist/toast.js +21 -0
- package/react/dist/wallet-address.d.ts +23 -0
- package/react/dist/wallet-address.js +24 -0
- package/tokens/README.md +17 -0
- package/tokens/assets/bloxwap-icon.svg +1 -0
- package/tokens/dist/brand.d.ts +19 -0
- package/tokens/dist/brand.js +24 -0
- package/tokens/dist/index.d.ts +437 -0
- package/tokens/dist/index.js +514 -0
- package/tokens/dist/manifest.json +200 -0
- package/tokens/dist/theme.d.ts +11 -0
- package/tokens/dist/theme.js +22 -0
- package/tokens/dist/tokens.css +120 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Choice {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string; /** Optional translated name or supporting text, shown below the option label. */
|
|
4
|
+
description?: string; /** BCP-47 language of the label, for native pronunciation and shared-script punctuation. */
|
|
5
|
+
lang?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckedProps {
|
|
9
|
+
label: string;
|
|
10
|
+
checked?: boolean;
|
|
11
|
+
defaultChecked?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onCheckedChange?: (v: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface ChoicesProps {
|
|
16
|
+
label: string;
|
|
17
|
+
options: readonly Choice[];
|
|
18
|
+
value?: string;
|
|
19
|
+
defaultValue?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
onValueChange?: (v: string) => void;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { Choice, CheckedProps, ChoicesProps } from './selection-types.js';
|
|
2
|
+
export { Switch, SwitchRow, type SwitchRowProps } from './switch.js';
|
|
3
|
+
export { Checkbox } from './checkbox.js';
|
|
4
|
+
export { RadioGroup } from './radio-group.js';
|
|
5
|
+
export { Select } from './select.js';
|
|
6
|
+
export { Slider } from './slider.js';
|
|
7
|
+
export { SegmentedControl } from './radio-group.js';
|
|
8
|
+
export { Filter, type FilterOption, type FilterProps } from './radio-group.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Switch, SwitchRow } from './switch.js';
|
|
2
|
+
export { Checkbox } from './checkbox.js';
|
|
3
|
+
export { RadioGroup } from './radio-group.js';
|
|
4
|
+
export { Select } from './select.js';
|
|
5
|
+
export { Slider } from './slider.js';
|
|
6
|
+
export { SegmentedControl } from './radio-group.js';
|
|
7
|
+
export { Filter } from './radio-group.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function Slider({ label, value, defaultValue, min, max, step, disabled, onValueChange }: {
|
|
3
|
+
label: string;
|
|
4
|
+
value?: number;
|
|
5
|
+
defaultValue?: number;
|
|
6
|
+
min?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
step?: number;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
onValueChange?: (v: number) => void;
|
|
11
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View, Platform, UIManager, requireNativeComponent } from 'react-native';
|
|
3
|
+
import SliderBackend from '@react-native-community/slider';
|
|
4
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
5
|
+
import { useColors, useControllable, useFills, useHIG } from './provider.js';
|
|
6
|
+
import { Text } from './surface.js';
|
|
7
|
+
// RN maps accessibilityActions names to fixed or synthetic Android ids and drops action arguments, so a plain View
|
|
8
|
+
// cannot offer ACTION_SET_PROGRESS. The package's autolinked HIGAdjustableView (android/) adds it and reports
|
|
9
|
+
// {actionName:'setProgress',value}; without native linking (Expo Go, web, tests) the wrapper stays a plain View.
|
|
10
|
+
const AndroidAdjustable = Platform.OS === 'android' && UIManager.hasViewManagerConfig?.('HIGAdjustableView') ? requireNativeComponent('HIGAdjustableView') : null;
|
|
11
|
+
export function Slider({ label, value, defaultValue = 0, min = 0, max = 100, step = 1, disabled, onValueChange }) {
|
|
12
|
+
const [current, set] = useControllable(value, defaultValue, onValueChange);
|
|
13
|
+
const { messages } = useHIG();
|
|
14
|
+
const colors = useColors();
|
|
15
|
+
const fills = useFills();
|
|
16
|
+
// Explicit action labels (#87): RN 0.83 Android lists an unlabeled increment/decrement action with an empty label "".
|
|
17
|
+
const actions = [{ name: 'increment', label: messages.increase ?? en.increase }, { name: 'decrement', label: messages.decrease ?? en.decrease }];
|
|
18
|
+
// A plain 48dp adjustable View owns label/value/increment/decrement on iOS and Android and hides the backend:
|
|
19
|
+
// @react-native-community/slider 5 drops onAccessibilityAction and its iOS Fabric view ignores accessibilityIncrement
|
|
20
|
+
// (iOS Simulator AX actions 2004/2005 left the value unchanged), and its Android SeekBar node measured 18dp
|
|
21
|
+
// (emulator UiAutomation audit). Steps are 5% of the range, matching Android's native SeekBar increment.
|
|
22
|
+
const accessibilityStep = Math.max(step, Math.round((max - min) / 20 / step) * step);
|
|
23
|
+
const semantics = { accessibilityRole: 'adjustable', accessibilityState: { disabled: !!disabled }, accessibilityLabel: label, accessibilityValue: { min, max, now: current } };
|
|
24
|
+
const clamp = (next) => Math.min(max, Math.max(min, next));
|
|
25
|
+
const adjust = (event) => { if (disabled)
|
|
26
|
+
return; const { actionName, value: requested } = event.nativeEvent; if (actionName === 'setProgress') {
|
|
27
|
+
if (typeof requested === 'number' && Number.isFinite(requested))
|
|
28
|
+
set(clamp(min + Math.round((requested - min) / step) * step));
|
|
29
|
+
return;
|
|
30
|
+
} const direction = actionName === 'increment' ? 1 : actionName === 'decrement' ? -1 : 0; if (direction)
|
|
31
|
+
set(clamp(current + direction * accessibilityStep)); };
|
|
32
|
+
const webProps = Platform.OS === 'web' ? { 'aria-valuemin': min, 'aria-valuemax': max, 'aria-valuenow': current, 'aria-disabled': !!disabled, tabIndex: disabled ? -1 : 0, onKeyDown: (e) => { if (disabled)
|
|
33
|
+
return; const next = e.key === 'Home' ? min : e.key === 'End' ? max : e.key === 'ArrowRight' || e.key === 'ArrowUp' ? current + step : e.key === 'ArrowLeft' || e.key === 'ArrowDown' ? current - step : e.key === 'PageUp' ? current + step * 10 : e.key === 'PageDown' ? current - step * 10 : undefined; if (next !== undefined) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
set(Math.min(max, Math.max(min, next)));
|
|
36
|
+
} } } : {};
|
|
37
|
+
const wrap = Platform.OS !== 'web';
|
|
38
|
+
const Adjustable = AndroidAdjustable ?? View;
|
|
39
|
+
const backend = _jsx(SliderBackend, { ...webProps, ...(wrap ? { accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' } : semantics), minimumValue: min, maximumValue: max, step: step, value: current, disabled: disabled, onValueChange: next => { if (!disabled)
|
|
40
|
+
set(next); }, minimumTrackTintColor: colors.action, maximumTrackTintColor: fills.raised, thumbTintColor: colors.text, style: { minHeight: 48 } });
|
|
41
|
+
return _jsxs(View, { children: [_jsxs(Text, { children: [label, ": ", current] }), wrap ? _jsx(Adjustable, { accessible: true, ...semantics, accessibilityActions: actions, onAccessibilityAction: adjust, style: { minHeight: 48, justifyContent: 'center' }, children: backend }) : backend] });
|
|
42
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type DimensionValue, type ImageSourcePropType, type ViewProps, type TextProps } from 'react-native';
|
|
3
|
+
import { type AccentRole } from './roles.js';
|
|
4
|
+
export type { AccentRole } from './roles.js';
|
|
5
|
+
declare const severityRole: {
|
|
6
|
+
readonly info: 'info';
|
|
7
|
+
readonly note: 'info';
|
|
8
|
+
readonly success: 'positive';
|
|
9
|
+
readonly tip: 'positive';
|
|
10
|
+
readonly warning: 'warning';
|
|
11
|
+
readonly error: 'negative';
|
|
12
|
+
};
|
|
13
|
+
/** `note` and `tip` are documentation callout severities that reuse the info and positive token roles; `default` is the neutral variant (a faint `text` tint, title in `text`). */
|
|
14
|
+
export type AlertSeverity = keyof typeof severityRole | 'default';
|
|
15
|
+
/** Neutral chip in the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
|
|
16
|
+
export declare function Badge({ children }: React.PropsWithChildren): React.JSX.Element;
|
|
17
|
+
/** Severity tints the fill 10% and colours the title from a token role (info/note → info, success/tip → positive, warning, error → negative; default → 6% of `text`), with no stroke or glow; `tone` swaps in another approved token role, never a raw colour. A non-string title renders inside the Heading, so pass strings or inline Text; its visible text is announced. */
|
|
18
|
+
export declare function Alert({ title, children, severity, tone, action, announce }: React.PropsWithChildren<{
|
|
19
|
+
title: React.ReactNode;
|
|
20
|
+
severity?: AlertSeverity;
|
|
21
|
+
tone?: AccentRole;
|
|
22
|
+
action?: React.ReactNode;
|
|
23
|
+
announce?: boolean;
|
|
24
|
+
}>): React.JSX.Element;
|
|
25
|
+
export declare const Callout: typeof Alert;
|
|
26
|
+
export interface Notice {
|
|
27
|
+
id: string;
|
|
28
|
+
message: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
severity: 'info' | 'success' | 'warning' | 'error';
|
|
31
|
+
action?: React.ReactNode;
|
|
32
|
+
/** Defaults to true when Toast has an onDismiss handler. */
|
|
33
|
+
closable?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface ToastProps {
|
|
36
|
+
notices: readonly Notice[];
|
|
37
|
+
onDismiss?: (id: string) => void;
|
|
38
|
+
/** Dismiss wording inside the close control's accessible name; defaults to HIGProvider messages.dismiss. The control shows an x, not text. */
|
|
39
|
+
dismissLabel?: string;
|
|
40
|
+
/** Scroll viewport limit, in dp or a percentage of the parent. Defaults to 60% of the window height. */
|
|
41
|
+
maxHeight?: DimensionValue;
|
|
42
|
+
testID?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Each notice is one capsule row: severity symbol, message, optional action, then a close control. Compact, scrollable notices remain visible until their host removes them. */
|
|
45
|
+
export declare function Toast({ notices, onDismiss, dismissLabel, maxHeight, testID }: ToastProps): React.JSX.Element;
|
|
46
|
+
/** One transient notice: shown for about four seconds, replaced by the next one, dismissible, and cleared on unmount. Render it with `Toast`, which announces it. */
|
|
47
|
+
export declare function useTransientNotice(duration?: number): {
|
|
48
|
+
notice: Notice | null;
|
|
49
|
+
show: (message: string, severity?: Notice['severity']) => void;
|
|
50
|
+
dismiss: () => void;
|
|
51
|
+
};
|
|
52
|
+
export declare function Spinner({ label }: {
|
|
53
|
+
label?: string;
|
|
54
|
+
}): React.JSX.Element;
|
|
55
|
+
export declare function Progress({ label, value, max }: {
|
|
56
|
+
label: string;
|
|
57
|
+
value?: number;
|
|
58
|
+
max?: number;
|
|
59
|
+
}): React.JSX.Element;
|
|
60
|
+
/** Pulses while content is on its way; still with reduced motion. */
|
|
61
|
+
export declare function Skeleton({ label }: {
|
|
62
|
+
label?: string;
|
|
63
|
+
}): React.JSX.Element;
|
|
64
|
+
export interface EmptyStateProps extends Omit<ViewProps, 'children'> {
|
|
65
|
+
title: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
action?: React.ReactNode;
|
|
68
|
+
/** Decorative mark above the title, hidden from accessibility; the title and description supply its meaning. Omitted, a neutral outline icon shows; `null` shows none. */
|
|
69
|
+
illustration?: React.ReactNode;
|
|
70
|
+
titleStyle?: TextProps['style'];
|
|
71
|
+
descriptionStyle?: TextProps['style'];
|
|
72
|
+
/** Applies to both actual text nodes; omitted values retain the provider's scaling policy. */
|
|
73
|
+
maxFontSizeMultiplier?: number;
|
|
74
|
+
}
|
|
75
|
+
/** A strokeless card, centred: icon, title, optional description, then the action. */
|
|
76
|
+
export declare function EmptyState({ title, description, action, illustration, titleStyle, descriptionStyle, maxFontSizeMultiplier, ...props }: EmptyStateProps): React.JSX.Element;
|
|
77
|
+
/** Initials sit on the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
|
|
78
|
+
export declare function Avatar({ name, source }: {
|
|
79
|
+
name: string;
|
|
80
|
+
source?: ImageSourcePropType;
|
|
81
|
+
}): React.JSX.Element;
|
|
82
|
+
/** The dot carries the state colour. Online and stale emit a ring that grows and fades in that colour; offline and reduced motion stay still. */
|
|
83
|
+
export declare function StatusIndicator({ label, state }: {
|
|
84
|
+
label: string;
|
|
85
|
+
state: 'online' | 'offline' | 'stale';
|
|
86
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { tokens } from '@bloxwap/hig/tokens';
|
|
4
|
+
import { CloseIcon, EmptyIcon, SeverityIcon } from './icons.js';
|
|
5
|
+
import { notificationDelta } from '@bloxwap/hig/contracts/announcements';
|
|
6
|
+
import { ActivityIndicator, Animated, Easing, View, Image, ScrollView, useWindowDimensions, AccessibilityInfo, Platform } from 'react-native';
|
|
7
|
+
import { Text, Heading, Surface, Stack } from './surface.js';
|
|
8
|
+
import { formatNumber } from '@bloxwap/hig/contracts';
|
|
9
|
+
import { Button } from './button.js';
|
|
10
|
+
import * as en from '@bloxwap/hig/contracts/messages';
|
|
11
|
+
import { useColors, useFills, useHIG } from './provider.js';
|
|
12
|
+
import { blockText, plainText } from './text-content.js';
|
|
13
|
+
import { roleColor } from './roles.js';
|
|
14
|
+
const severityRole = { info: 'info', note: 'info', success: 'positive', tip: 'positive', warning: 'warning', error: 'negative' };
|
|
15
|
+
function speak(message, severity) { if (Platform.OS === 'web' || !message)
|
|
16
|
+
return; try {
|
|
17
|
+
if (Platform.OS === 'ios' && typeof AccessibilityInfo.announceForAccessibilityWithOptions === 'function')
|
|
18
|
+
AccessibilityInfo.announceForAccessibilityWithOptions(message, { queue: severity !== 'error' });
|
|
19
|
+
else
|
|
20
|
+
AccessibilityInfo.announceForAccessibility(message);
|
|
21
|
+
}
|
|
22
|
+
catch { /* The visible message and navigable text remain available. */ } }
|
|
23
|
+
/** Neutral chip in the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
|
|
24
|
+
export function Badge({ children }) { const fills = useFills(); return _jsx(Text, { style: { alignSelf: 'flex-start', maxWidth: '100%', backgroundColor: fills.well, overflow: 'hidden', borderRadius: 9999, paddingVertical: 4, paddingHorizontal: 10 }, children: children }); }
|
|
25
|
+
/** Opaque sRGB blend of `tone` into `base` (both `#rrggbb`): the native counterpart of CSS `color-mix`. */
|
|
26
|
+
const tint = (tone, base, amount) => '#' + [1, 3, 5].map(i => Math.round(parseInt(base.slice(i, i + 2), 16) * (1 - amount) + parseInt(tone.slice(i, i + 2), 16) * amount).toString(16).padStart(2, '0')).join('');
|
|
27
|
+
/** Severity tints the fill 10% and colours the title from a token role (info/note → info, success/tip → positive, warning, error → negative; default → 6% of `text`), with no stroke or glow; `tone` swaps in another approved token role, never a raw colour. A non-string title renders inside the Heading, so pass strings or inline Text; its visible text is announced. */
|
|
28
|
+
export function Alert({ title, children, severity = 'info', tone, action, announce = true }) { const colors = useColors(); const neutral = severity === 'default' && tone === undefined; const accent = neutral ? colors.text : roleColor(tone, severityRole[severity] ?? 'info', colors); const message = [plainText(title), blockText(children)].filter(Boolean).join('. '); const previous = useRef(''); useEffect(() => { const key = severity + message; if (announce && key !== previous.current) {
|
|
29
|
+
previous.current = key;
|
|
30
|
+
if (Platform.OS === 'ios')
|
|
31
|
+
speak(message, severity);
|
|
32
|
+
} }); return _jsxs(Surface, { style: { gap: 12, backgroundColor: tint(accent, colors.surface, neutral ? 0.06 : 0.1) }, accessibilityLiveRegion: announce && Platform.OS !== 'ios' ? (severity === 'error' ? 'assertive' : 'polite') : 'none', children: [_jsx(Heading, { style: { color: accent }, children: title }), children, action] }); }
|
|
33
|
+
export const Callout = Alert;
|
|
34
|
+
/** Loops a 0→1 value while `active`; rests at 0 otherwise (reduced motion, or nothing to show). */
|
|
35
|
+
function useLoop(active, duration, easing = Easing.linear) { const value = useRef(new Animated.Value(0)).current; useEffect(() => { if (!active) {
|
|
36
|
+
value.stopAnimation();
|
|
37
|
+
value.setValue(0);
|
|
38
|
+
return;
|
|
39
|
+
} const loop = Animated.loop(Animated.timing(value, { toValue: 1, duration, easing, useNativeDriver: Platform.OS !== 'web', isInteraction: false })); loop.start(); return () => loop.stop(); }, [active, duration, easing, value]); return value; }
|
|
40
|
+
/** Each notice is one capsule row: severity symbol, message, optional action, then a close control. Compact, scrollable notices remain visible until their host removes them. */
|
|
41
|
+
export function Toast({ notices, onDismiss, dismissLabel, maxHeight, testID }) {
|
|
42
|
+
const { messages, direction } = useHIG();
|
|
43
|
+
const colors = useColors();
|
|
44
|
+
const { height } = useWindowDimensions();
|
|
45
|
+
const dismiss = dismissLabel ?? messages.dismiss ?? en.dismiss;
|
|
46
|
+
const unique = [...new Map(notices.map(n => [n.id, n])).values()];
|
|
47
|
+
const spoken = unique.map(n => ({ ...n, message: [n.message, n.description].filter(Boolean).join('. ') }));
|
|
48
|
+
const previous = useRef(new Map()), [announcement, setAnnouncement] = useState('');
|
|
49
|
+
const timer = useRef(null);
|
|
50
|
+
const key = JSON.stringify(spoken.map(n => [n.id, n.message, n.severity]));
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const delta = notificationDelta(previous.current, spoken);
|
|
53
|
+
previous.current = delta.next;
|
|
54
|
+
if (!delta.message)
|
|
55
|
+
return;
|
|
56
|
+
if (Platform.OS !== 'web') {
|
|
57
|
+
speak(delta.message, delta.severity);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setAnnouncement('');
|
|
61
|
+
if (timer.current !== null)
|
|
62
|
+
clearTimeout(timer.current);
|
|
63
|
+
timer.current = setTimeout(() => { timer.current = null; if (previous.current.get(delta.id) === delta.next.get(delta.id))
|
|
64
|
+
setAnnouncement(delta.message); }, 25);
|
|
65
|
+
}, [key]);
|
|
66
|
+
useEffect(() => () => { if (timer.current !== null)
|
|
67
|
+
clearTimeout(timer.current); }, []);
|
|
68
|
+
return _jsxs(View, { testID: testID, style: { maxHeight: maxHeight ?? height * .6, flexShrink: 1 }, children: [_jsx(ScrollView, { style: { flexGrow: 0, flexShrink: 1 }, nestedScrollEnabled: true, keyboardShouldPersistTaps: 'handled', accessibilityLabel: messages.notifications ?? en.notifications, children: _jsx(Stack, { style: { gap: 8 }, children: unique.map(n => _jsxs(View, { accessibilityLiveRegion: 'none', style: { direction, flexDirection: 'row', alignItems: 'center', gap: 10, minHeight: 44, paddingVertical: 6, paddingHorizontal: 12, borderRadius: 22, backgroundColor: colors.nested, boxShadow: '0 4px 16px #0006' }, children: [_jsx(SeverityIcon, { kind: n.severity, color: colors[severityRole[n.severity]] }), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { style: { fontWeight: '600' }, children: n.message }), n.description ? _jsx(Text, { children: n.description }) : null] }), n.action, n.closable !== false && onDismiss ? _jsx(Button, { intent: 'ghost', contentMode: 'custom', suppressFeedback: true, accessibilityLabel: (messages.dismissNotice ?? en.dismissNotice)(n.message, dismiss), hitSlop: 8, onPress: () => onDismiss(n.id), style: { minHeight: 32, minWidth: 32, paddingHorizontal: 0, paddingVertical: 0, alignSelf: 'center' }, children: _jsx(CloseIcon, { color: colors.muted }) }) : null] }, n.id)) }) }), Platform.OS === 'web' && _jsx(Text, { accessibilityLiveRegion: 'polite', style: { position: 'absolute', width: 1, height: 1, overflow: 'hidden' }, children: announcement })] });
|
|
69
|
+
}
|
|
70
|
+
/** One transient notice: shown for about four seconds, replaced by the next one, dismissible, and cleared on unmount. Render it with `Toast`, which announces it. */
|
|
71
|
+
export function useTransientNotice(duration = 4000) {
|
|
72
|
+
const [notice, setNotice] = useState(null);
|
|
73
|
+
const sequence = useRef(0), timer = useRef(null), alive = useRef(true);
|
|
74
|
+
useEffect(() => { alive.current = true; return () => { alive.current = false; if (timer.current !== null)
|
|
75
|
+
clearTimeout(timer.current); }; }, []);
|
|
76
|
+
const stop = () => { if (timer.current !== null) {
|
|
77
|
+
clearTimeout(timer.current);
|
|
78
|
+
timer.current = null;
|
|
79
|
+
} };
|
|
80
|
+
return { notice, dismiss: () => { stop(); setNotice(null); }, show: (message, severity = 'success') => { if (!alive.current)
|
|
81
|
+
return; stop(); setNotice({ id: `notice-${++sequence.current}`, message, severity }); timer.current = setTimeout(() => { timer.current = null; setNotice(null); }, duration); } };
|
|
82
|
+
}
|
|
83
|
+
export function Spinner({ label }) { const { messages } = useHIG(); const colors = useColors(); const text = label ?? messages.loading ?? en.loading; return _jsxs(View, { accessible: true, accessibilityLabel: text, children: [_jsx(ActivityIndicator, { color: colors.action }), _jsx(Text, { children: text })] }); }
|
|
84
|
+
export function Progress({ label, value, max = 100 }) {
|
|
85
|
+
const { locale, messages, direction } = useHIG();
|
|
86
|
+
const colors = useColors();
|
|
87
|
+
const fills = useFills();
|
|
88
|
+
const fill = value === undefined ? 35 : Math.min(100, Math.max(0, Number.isFinite(value) && max > 0 ? value / max * 100 : 0));
|
|
89
|
+
return _jsxs(View, { style: { gap: 12, direction }, accessibilityRole: 'progressbar', accessibilityLabel: label, accessibilityValue: { min: 0, max, now: value, text: value === undefined ? messages.inProgress ?? en.inProgress : (messages.progressValue ?? en.progressValue)(formatNumber(value, locale), formatNumber(max, locale)) }, children: [_jsxs(Text, { children: [label, value === undefined ? '…' : ` ${value}/${max}`] }), _jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { height: 6, borderRadius: 9999, overflow: 'hidden', backgroundColor: fills.raised }, children: _jsx(View, { style: { width: `${fill}%`, height: '100%', alignSelf: value === undefined ? 'center' : 'flex-start', borderRadius: 9999, backgroundColor: colors.action } }) })] });
|
|
90
|
+
}
|
|
91
|
+
/** Pulses while content is on its way; still with reduced motion. */
|
|
92
|
+
export function Skeleton({ label }) { const { messages, reducedMotion } = useHIG(); const fills = useFills(); const pulse = useLoop(!reducedMotion, 1500); return _jsx(Animated.View, { accessible: true, accessibilityLabel: label ?? messages.loadingContent ?? en.loadingContent, style: { minHeight: 48, backgroundColor: fills.raised, borderRadius: 10, opacity: pulse.interpolate({ inputRange: [0, .5, 1], outputRange: [1, .5, 1] }) } }); }
|
|
93
|
+
/** A strokeless card, centred: icon, title, optional description, then the action. */
|
|
94
|
+
export function EmptyState({ title, description, action, illustration, titleStyle, descriptionStyle, maxFontSizeMultiplier, ...props }) {
|
|
95
|
+
const colors = useColors();
|
|
96
|
+
const mark = illustration !== undefined ? illustration : _jsx(EmptyIcon, { color: colors.muted });
|
|
97
|
+
return _jsxs(Surface, { ...props, style: [{ gap: 12, alignItems: 'center' }, props.style], children: [mark != null && _jsx(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', children: mark }), _jsx(Heading, { style: [{ textAlign: 'center' }, titleStyle], maxFontSizeMultiplier: maxFontSizeMultiplier, children: title }), description ? _jsx(Text, { style: [{ textAlign: 'center', color: colors.muted }, descriptionStyle], maxFontSizeMultiplier: maxFontSizeMultiplier, children: description }) : null, action] });
|
|
98
|
+
}
|
|
99
|
+
/** Initials sit on the dark well fill (one step lighter inside a Surface, Dialog or sheet). */
|
|
100
|
+
export function Avatar({ name, source }) { const fills = useFills(); return source ? _jsx(Image, { source: source, accessibilityLabel: name, style: { width: 40, height: 40, borderRadius: 20 } }) : _jsx(View, { accessible: true, accessibilityRole: 'image', accessibilityLabel: name, style: { width: 40, height: 40, borderRadius: 20, backgroundColor: fills.well, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { accessible: false, children: name.slice(0, 2) }) }); }
|
|
101
|
+
const statusRole = { online: 'positive', stale: 'warning', offline: 'muted' };
|
|
102
|
+
const ringEasing = Easing.out(Easing.quad);
|
|
103
|
+
/** The dot carries the state colour. Online and stale emit a ring that grows and fades in that colour; offline and reduced motion stay still. */
|
|
104
|
+
export function StatusIndicator({ label, state }) {
|
|
105
|
+
const { messages, reducedMotion, direction } = useHIG();
|
|
106
|
+
const colors = useColors();
|
|
107
|
+
const text = { online: messages.statusOnline ?? en.statusOnline, offline: messages.statusOffline ?? en.statusOffline, stale: messages.statusStale ?? en.statusStale }[state] ?? state;
|
|
108
|
+
const color = colors[statusRole[state] ?? 'muted'];
|
|
109
|
+
const live = !reducedMotion && (state === 'online' || state === 'stale');
|
|
110
|
+
const ring = useLoop(live, 1600, ringEasing);
|
|
111
|
+
return _jsxs(View, { style: { direction, flexDirection: 'row', alignItems: 'center', gap: tokens.space.sm }, children: [_jsxs(View, { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants', style: { width: 7, height: 7 }, children: [live && _jsx(Animated.View, { style: { position: 'absolute', width: 7, height: 7, borderRadius: 4, backgroundColor: color, opacity: ring.interpolate({ inputRange: [0, 1], outputRange: [.6, 0] }), transform: [{ scale: ring.interpolate({ inputRange: [0, 1], outputRange: [1, 3] }) }] } }), _jsx(View, { style: { width: 7, height: 7, borderRadius: 4, backgroundColor: color } })] }), _jsxs(Text, { style: { flexShrink: 1, minWidth: 0 }, children: [label, ": ", text] })] });
|
|
112
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text as RNText, type TextProps, type ViewProps } from 'react-native';
|
|
3
|
+
export type TextScript = 'latin' | 'ko' | 'zh';
|
|
4
|
+
/** Korean and Chinese companion faces are set at their own spacing (0em): Latin tracking spreads CJK glyphs apart. Hosts override per script through HIGProvider `letterSpacingByScript`. */
|
|
5
|
+
export declare const scriptLetterSpacing: Readonly<Record<Exclude<TextScript, 'latin'>, number>>;
|
|
6
|
+
/** Hangul selects the Korean companion; Han (which the KR face does not carry) the Chinese one; shared CJK punctuation follows the locale. */
|
|
7
|
+
export declare function detectScript(text: string, locale: string): TextScript;
|
|
8
|
+
export interface HIGTextProps extends TextProps {
|
|
9
|
+
script?: TextScript; /** Caps Dynamic Type / Android font scale for dense numeric readouts (2 = 200%). Defaults to HIGProvider `maxFontSizeMultiplier`; never disable scaling. */
|
|
10
|
+
maxFontSizeMultiplier?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const Text: React.ForwardRefExoticComponent<HIGTextProps & React.RefAttributes<React.ComponentRef<typeof RNText>>>;
|
|
13
|
+
export declare const Heading: React.ForwardRefExoticComponent<HIGTextProps & React.RefAttributes<React.ComponentRef<typeof RNText>>>;
|
|
14
|
+
export declare function Stack({ style, ...props }: ViewProps): React.JSX.Element;
|
|
15
|
+
export declare function Inline({ style, ...props }: ViewProps): React.JSX.Element;
|
|
16
|
+
/** A filled card with no stroke; its fill and the space around it separate it from the page. */
|
|
17
|
+
export declare function Surface({ style, children, ...props }: ViewProps): React.JSX.Element;
|
|
18
|
+
export declare const Card: typeof Surface;
|
|
19
|
+
export declare function Separator(): React.JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { Text as RNText, View, StyleSheet } from 'react-native';
|
|
4
|
+
import { nativeMetrics as tokens } from '@bloxwap/hig/tokens';
|
|
5
|
+
import { Raised, useColors, useFills, useHIG } from './provider.js';
|
|
6
|
+
import { plainText } from './text-content.js';
|
|
7
|
+
/** Korean and Chinese companion faces are set at their own spacing (0em): Latin tracking spreads CJK glyphs apart. Hosts override per script through HIGProvider `letterSpacingByScript`. */
|
|
8
|
+
export const scriptLetterSpacing = { ko: 0, zh: 0 };
|
|
9
|
+
const HANGUL = /[\u1100-\u11ff\u3130-\u318f\uac00-\ud7af]/u, HAN = /[\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]/u, CJK_PUNCTUATION = /[\u3000-\u303f\uff01-\uff60\uffe0-\uffe6]/u;
|
|
10
|
+
/** Hangul selects the Korean companion; Han (which the KR face does not carry) the Chinese one; shared CJK punctuation follows the locale. */
|
|
11
|
+
export function detectScript(text, locale) { if (HANGUL.test(text))
|
|
12
|
+
return 'ko'; if (HAN.test(text))
|
|
13
|
+
return 'zh'; if (CJK_PUNCTUATION.test(text))
|
|
14
|
+
return /^ko\b/i.test(locale) ? 'ko' : 'zh'; return 'latin'; }
|
|
15
|
+
/** Keep a script in its registered companion face even when that family ships fewer static weights. */
|
|
16
|
+
function scriptFont(families, weight) {
|
|
17
|
+
if (!families)
|
|
18
|
+
return undefined;
|
|
19
|
+
if (families[weight])
|
|
20
|
+
return families[weight];
|
|
21
|
+
const weights = Object.keys(families).map(Number).filter(value => Number.isFinite(value) && !!families[value]);
|
|
22
|
+
weights.sort((a, b) => Math.abs(a - Number(weight)) - Math.abs(b - Number(weight)) || a - b);
|
|
23
|
+
return weights.length ? families[weights[0]] : undefined;
|
|
24
|
+
}
|
|
25
|
+
export const Text = forwardRef(function Text({ style, script, maxFontSizeMultiplier, ...props }, ref) {
|
|
26
|
+
const env = useHIG();
|
|
27
|
+
const colors = useColors();
|
|
28
|
+
const resolved = StyleSheet.flatten(style);
|
|
29
|
+
const requested = resolved?.fontWeight ?? 400;
|
|
30
|
+
const weight = requested === 'normal' ? 400 : requested === 'bold' ? 700 : requested;
|
|
31
|
+
const resolvedScript = script ?? detectScript(plainText(props.children), props.accessibilityLanguage ?? env.locale);
|
|
32
|
+
const registered = resolved?.fontFamily ? undefined : scriptFont(env.fontFamiliesByScript?.[resolvedScript], weight) ?? env.fontFamilies?.[weight];
|
|
33
|
+
const tracking = resolvedScript === 'latin' ? undefined : { letterSpacing: (env.letterSpacingByScript?.[resolvedScript] ?? scriptLetterSpacing[resolvedScript]) * (resolved?.fontSize ?? 16) };
|
|
34
|
+
return _jsx(RNText, { ...props, ref: ref, maxFontSizeMultiplier: maxFontSizeMultiplier ?? env.maxFontSizeMultiplier, style: [{ color: colors.text, fontSize: 16, lineHeight: 24, fontFamily: env.fontFamily, writingDirection: env.direction }, style, registered ? { fontFamily: registered, fontWeight: 'normal' } : undefined, tracking] });
|
|
35
|
+
});
|
|
36
|
+
export const Heading = forwardRef(function Heading({ style, ...props }, ref) { return _jsx(Text, { ...props, ref: ref, accessibilityRole: 'header', style: [{ fontSize: 24, lineHeight: 30, fontWeight: '600' }, style] }); });
|
|
37
|
+
export function Stack({ style, ...props }) { const env = useHIG(); return _jsx(View, { ...props, style: [{ direction: env.direction, gap: tokens.space.md }, style] }); }
|
|
38
|
+
export function Inline({ style, ...props }) { const env = useHIG(); return _jsx(View, { ...props, style: [{ direction: env.direction, flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: tokens.space.md }, style] }); }
|
|
39
|
+
/** A filled card with no stroke; its fill and the space around it separate it from the page. */
|
|
40
|
+
export function Surface({ style, children, ...props }) { const env = useHIG(); const colors = useColors(); return _jsx(View, { ...props, style: [{ direction: env.direction, backgroundColor: colors.surface, borderRadius: tokens.radius.xl, padding: tokens.space.xl, minWidth: 0 }, style], children: _jsx(Raised, { children: children }) }); }
|
|
41
|
+
export const Card = Surface;
|
|
42
|
+
export function Separator() { const fills = useFills(); return _jsx(View, { accessibilityRole: 'none', style: { height: 2, borderRadius: 9999, backgroundColor: fills.raised } }); }
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { type SwapAction, type SwapChain, type SwapDenomination, type SwapFee, type SwapToken, type SwapView, type SwapWallet } from './swap-shared.js';
|
|
4
|
+
export { swapAction, swapParentView, type SwapAction, type SwapChain, type SwapDenomination, type SwapFee, type SwapToken, type SwapView, type SwapWallet } from './swap-shared.js';
|
|
5
|
+
/** What a host surface lends the panel. A sheet passes its backend's list, so list drags hand off to the sheet, and sizes itself, so the panel does not animate its own height. */
|
|
6
|
+
export { SwapHostContext } from './swap-parts.js';
|
|
7
|
+
/** A fixed place the assets go, in place of a token the user picks: a wallet, a staking pool, a trading account. Shown as a compact To card with no amount. */
|
|
8
|
+
export interface SwapDestination {
|
|
9
|
+
title: string;
|
|
10
|
+
/** One muted line under the title, such as the chain or a rate. */
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
/** Image URL. Without one, `address` draws the wallet's colour disc. */
|
|
13
|
+
icon?: string;
|
|
14
|
+
/** A wallet address; shown shortened under the subtitle. */
|
|
15
|
+
address?: string;
|
|
16
|
+
/** Muted trailing text, such as an arrival time or a rate. */
|
|
17
|
+
detail?: string;
|
|
18
|
+
/** Makes the card a button with a trailing chevron, for example to change the recipient. */
|
|
19
|
+
onPress?: () => void;
|
|
20
|
+
/** Still to be chosen: the card shows `title` / `subtitle` as a placeholder and the action stays disabled, asking for a destination. */
|
|
21
|
+
pending?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** One label and value row of the details card. */
|
|
24
|
+
export interface SwapDetail {
|
|
25
|
+
label: string;
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
/** The receive view: the host's address and its rendered QR code. HIG ships no QR encoder. */
|
|
29
|
+
export interface SwapReceive {
|
|
30
|
+
address: string;
|
|
31
|
+
qr?: React.ReactNode; /** Host clipboard adapter. When set, the whole view copies the address. */
|
|
32
|
+
onCopy?: () => Promise<void> | void;
|
|
33
|
+
}
|
|
34
|
+
export interface SwapPanelProps {
|
|
35
|
+
/** Catalog for the To side, and for the From side unless `fromTokens` is given. */
|
|
36
|
+
tokens: readonly SwapToken[];
|
|
37
|
+
/** Assets offered on the From side, typically the connected wallet's holdings. */
|
|
38
|
+
fromTokens?: readonly SwapToken[];
|
|
39
|
+
fromTokensLoading?: boolean;
|
|
40
|
+
/** Chain filter chips. Derived from the tokens, in first-seen order, when omitted. */
|
|
41
|
+
chains?: readonly SwapChain[];
|
|
42
|
+
/** Token ids for the picker's Hot section, in rank order. */
|
|
43
|
+
hotTokenIds?: readonly string[];
|
|
44
|
+
/** The chosen pair. Controlled when `from` / `to` is set (`null` is an empty side); otherwise the panel keeps it, seeded from the defaults. */
|
|
45
|
+
from?: SwapToken | null;
|
|
46
|
+
to?: SwapToken | null;
|
|
47
|
+
defaultFrom?: SwapToken | null;
|
|
48
|
+
defaultTo?: SwapToken | null;
|
|
49
|
+
onFromChange?: (token: SwapToken | null) => void;
|
|
50
|
+
onToChange?: (token: SwapToken | null) => void;
|
|
51
|
+
/** From amount in token units. Optional: set it to resync the entry, for example to `'0'` after a submit. */
|
|
52
|
+
amount?: string;
|
|
53
|
+
/** Reports the From amount in token units whenever the entry, denomination or price changes it. */
|
|
54
|
+
onAmountChange?: (units: string) => void;
|
|
55
|
+
/** To amount in token units from the host's quote. Until it arrives the panel shows a price estimate. */
|
|
56
|
+
received?: number | null;
|
|
57
|
+
/** Total fee in USD from the host's quote, and its breakdown for the settings sheet. */
|
|
58
|
+
fee?: number | null;
|
|
59
|
+
fees?: readonly SwapFee[];
|
|
60
|
+
quoteLoading?: boolean;
|
|
61
|
+
/** Slippage tolerance as a fraction (0.005 is 0.5%). Omit `onSlippageChange` to show it read-only. */
|
|
62
|
+
slippage?: number;
|
|
63
|
+
onSlippageChange?: (slippage: number) => void;
|
|
64
|
+
/** Default denomination of both amounts. Uncontrolled when omitted. */
|
|
65
|
+
denomination?: SwapDenomination;
|
|
66
|
+
onDenominationChange?: (denomination: SwapDenomination) => void;
|
|
67
|
+
wallet?: SwapWallet;
|
|
68
|
+
onConnect?: () => void;
|
|
69
|
+
onDisconnect?: () => void;
|
|
70
|
+
recipient?: string;
|
|
71
|
+
onRecipientChange?: (address: string) => void;
|
|
72
|
+
onScanRecipient?: () => void;
|
|
73
|
+
/** Enables the receive view, offered in the From picker before a wallet is connected. */
|
|
74
|
+
receive?: SwapReceive;
|
|
75
|
+
receiving?: boolean;
|
|
76
|
+
onReceivingChange?: (receiving: boolean) => void;
|
|
77
|
+
/** The host validates, quotes and executes. HIG never submits a transaction. */
|
|
78
|
+
onSubmit: (action: SwapAction) => void;
|
|
79
|
+
submitting?: boolean;
|
|
80
|
+
/** Called after the panel clears its entry and both tokens (through `onFromChange(null)` / `onToChange(null)`), so the host can drop its quote. */
|
|
81
|
+
onReset?: () => void;
|
|
82
|
+
/** On native there is no hardware keyboard to rely on, so `auto` shows the keypad; `never` hides it. */
|
|
83
|
+
/** `false` fixes both amounts to `denomination` (dollars by default): the conversion capsule under each amount and the denomination setting are not shown. For hosts that only have one of the two, for example no token price. */
|
|
84
|
+
denominationSwitch?: boolean;
|
|
85
|
+
/** A fixed destination in place of the To token. The To card becomes compact (no picker, no amount), the panel is one-way, and the action is ready once the From side is. `onSubmit` receives `'send'`. */
|
|
86
|
+
destination?: SwapDestination;
|
|
87
|
+
/** Label and value rows on the bottom card, such as a staked balance or a fee tier. With no To token and no destination they are the bottom card on their own, and the panel behaves as it does for a destination. */
|
|
88
|
+
details?: readonly SwapDetail[];
|
|
89
|
+
/** A line under the cards: a limit, a delay, a warning. `noteTone` tints it. */
|
|
90
|
+
note?: React.ReactNode;
|
|
91
|
+
noteTone?: 'muted' | 'warning' | 'negative';
|
|
92
|
+
/** Heading above the cards, for a panel that is its own screen or sheet. `onBack` adds a Back control before it. */
|
|
93
|
+
title?: string;
|
|
94
|
+
onBack?: () => void;
|
|
95
|
+
/** `false` leaves the action button on its own, full width: no settings and no reset button. */
|
|
96
|
+
controls?: boolean;
|
|
97
|
+
/** Decoration before the action text. */
|
|
98
|
+
actionIcon?: React.ReactNode;
|
|
99
|
+
/** Keep a side's token fixed: its card shows the token but does not open the picker. Use with `from` / `to` or their defaults. */
|
|
100
|
+
lockFrom?: boolean;
|
|
101
|
+
lockTo?: boolean;
|
|
102
|
+
/** Names the action when it is ready, in place of Send, Swap or Bridge: for example Stake, Deposit or Withdraw. The host supplies the translated text. */
|
|
103
|
+
actionLabel?: string;
|
|
104
|
+
/** One direction only, top to bottom: the control between the cards becomes a down arrow instead of the flip button, and the pair cannot be exchanged. */
|
|
105
|
+
oneWay?: boolean;
|
|
106
|
+
keypad?: 'auto' | 'always' | 'never';
|
|
107
|
+
/** Web only (⌘F / ⌘K picker shortcuts); accepted and ignored so one example serves both platforms. */
|
|
108
|
+
shortcuts?: boolean;
|
|
109
|
+
/** Web only (page-wide digit capture); accepted and ignored. */
|
|
110
|
+
captureKeyboard?: boolean;
|
|
111
|
+
/** Host rows for the settings view, such as language or theme. */
|
|
112
|
+
settings?: React.ReactNode;
|
|
113
|
+
/** The view on show. Pickers and settings push inside the panel's own bounds; Back pops. Uncontrolled when omitted. */
|
|
114
|
+
view?: SwapView;
|
|
115
|
+
onViewChange?: (view: SwapView) => void;
|
|
116
|
+
/** Web only; accepted and ignored. */
|
|
117
|
+
className?: string;
|
|
118
|
+
style?: StyleProp<ViewStyle>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Send, swap and bridge in one panel: a From card and a To card joined by a flip control, an amount entered in dollars
|
|
122
|
+
* or token units through the keypad, token pickers, settings, and one action that names itself from the chosen pair.
|
|
123
|
+
* Presentation only. The host owns tokens, balances, prices, the quote, the wallet and the transaction.
|
|
124
|
+
*/
|
|
125
|
+
export declare function SwapPanel({ tokens, fromTokens, fromTokensLoading, chains, hotTokenIds, from: fromProp, to: toProp, defaultFrom, defaultTo, onFromChange, onToChange, amount, onAmountChange, received, fee, fees, quoteLoading, slippage, onSlippageChange, denomination, onDenominationChange, wallet, onConnect, onDisconnect, recipient, onRecipientChange, onScanRecipient, receive, receiving, onReceivingChange, onSubmit, submitting, onReset, keypad, destination, details, note, noteTone, title, onBack, controls, actionIcon, lockFrom, lockTo, actionLabel, oneWay: oneWayProp, denominationSwitch, settings, view: viewProp, onViewChange, style }: SwapPanelProps): React.JSX.Element;
|