@jztack/ui-native 0.0.0-stage → 0.2.0

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.
Files changed (100) hide show
  1. package/README.md +128 -2
  2. package/dist/Alert.d.ts +20 -0
  3. package/dist/Alert.js +14 -0
  4. package/dist/AppBar.d.ts +21 -0
  5. package/dist/AppBar.js +16 -0
  6. package/dist/Avatar.d.ts +21 -0
  7. package/dist/Avatar.js +23 -0
  8. package/dist/Badge.d.ts +15 -0
  9. package/dist/Badge.js +27 -0
  10. package/dist/BottomTabBar.d.ts +26 -0
  11. package/dist/BottomTabBar.js +39 -0
  12. package/dist/Button.d.ts +21 -0
  13. package/dist/Button.js +63 -0
  14. package/dist/Card.d.ts +37 -0
  15. package/dist/Card.js +41 -0
  16. package/dist/Checkbox.d.ts +11 -0
  17. package/dist/Checkbox.js +11 -0
  18. package/dist/ConfirmActionModal.d.ts +27 -0
  19. package/dist/ConfirmActionModal.js +43 -0
  20. package/dist/DeleteButton.d.ts +20 -0
  21. package/dist/DeleteButton.js +41 -0
  22. package/dist/Dialog.d.ts +10 -0
  23. package/dist/Dialog.js +10 -0
  24. package/dist/DropdownMenu.d.ts +25 -0
  25. package/dist/DropdownMenu.js +57 -0
  26. package/dist/EmptyState.d.ts +13 -0
  27. package/dist/EmptyState.js +10 -0
  28. package/dist/ErrorBoundary.d.ts +33 -0
  29. package/dist/ErrorBoundary.js +37 -0
  30. package/dist/Field.d.ts +24 -0
  31. package/dist/Field.js +20 -0
  32. package/dist/FormFields.d.ts +37 -0
  33. package/dist/FormFields.js +24 -0
  34. package/dist/FormPanel.d.ts +20 -0
  35. package/dist/FormPanel.js +14 -0
  36. package/dist/Input.d.ts +30 -0
  37. package/dist/Input.js +52 -0
  38. package/dist/OptionList.d.ts +25 -0
  39. package/dist/OptionList.js +15 -0
  40. package/dist/PageHeader.d.ts +13 -0
  41. package/dist/PageHeader.js +10 -0
  42. package/dist/Primitives.d.ts +636 -0
  43. package/dist/Primitives.js +5 -0
  44. package/dist/Progress.d.ts +8 -0
  45. package/dist/Progress.js +42 -0
  46. package/dist/RadioGroup.d.ts +15 -0
  47. package/dist/RadioGroup.js +11 -0
  48. package/dist/ScrollOverflowContainer.d.ts +14 -0
  49. package/dist/ScrollOverflowContainer.js +83 -0
  50. package/dist/SegmentedControl.d.ts +19 -0
  51. package/dist/SegmentedControl.js +15 -0
  52. package/dist/Select.d.ts +9 -0
  53. package/dist/Select.js +27 -0
  54. package/dist/Select.web.d.ts +10 -0
  55. package/dist/Select.web.js +41 -0
  56. package/dist/SelectTypes.d.ts +17 -0
  57. package/dist/SelectTypes.js +1 -0
  58. package/dist/Separator.d.ts +6 -0
  59. package/dist/Separator.js +9 -0
  60. package/dist/Sheet.d.ts +31 -0
  61. package/dist/Sheet.js +43 -0
  62. package/dist/Skeleton.d.ts +11 -0
  63. package/dist/Skeleton.js +30 -0
  64. package/dist/StartupScreen.d.ts +9 -0
  65. package/dist/StartupScreen.js +9 -0
  66. package/dist/StateViews.d.ts +13 -0
  67. package/dist/StateViews.js +14 -0
  68. package/dist/Switch.d.ts +13 -0
  69. package/dist/Switch.js +42 -0
  70. package/dist/Table.d.ts +22 -0
  71. package/dist/Table.js +17 -0
  72. package/dist/TextField.d.ts +22 -0
  73. package/dist/TextField.js +116 -0
  74. package/dist/Toast.d.ts +34 -0
  75. package/dist/Toast.js +92 -0
  76. package/dist/ToastHost.d.ts +6 -0
  77. package/dist/ToastHost.js +4 -0
  78. package/dist/ToastHost.web.d.ts +7 -0
  79. package/dist/ToastHost.web.js +11 -0
  80. package/dist/Toggle.d.ts +16 -0
  81. package/dist/Toggle.js +7 -0
  82. package/dist/ToggleGroup.d.ts +27 -0
  83. package/dist/ToggleGroup.js +27 -0
  84. package/dist/haptics.d.ts +45 -0
  85. package/dist/haptics.js +96 -0
  86. package/dist/index.d.ts +41 -0
  87. package/dist/index.js +46 -0
  88. package/dist/shadows.d.ts +28 -0
  89. package/dist/shadows.js +19 -0
  90. package/dist/theme.d.ts +23 -0
  91. package/dist/theme.js +19 -0
  92. package/dist/useDismissOnEscape.d.ts +7 -0
  93. package/dist/useDismissOnEscape.js +10 -0
  94. package/dist/useDismissOnEscape.web.d.ts +2 -0
  95. package/dist/useDismissOnEscape.web.js +14 -0
  96. package/dist/useResponsive.d.ts +28 -0
  97. package/dist/useResponsive.js +23 -0
  98. package/dist/useTextFieldCurrency.d.ts +9 -0
  99. package/dist/useTextFieldCurrency.js +45 -0
  100. package/package.json +52 -3
package/README.md CHANGED
@@ -1,3 +1,129 @@
1
- # Temporary Holding Version
1
+ # @jztack/ui-native
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The TWJS twin of `@jztack/ui`: the same component names, variants, and prop
4
+ specs wherever the platform allows, implemented on `@shopify/restyle` for
5
+ React Native (and react-native-web), consuming `@jztack/tokens`' restyle
6
+ emitter for every color, spacing, radius, breakpoint, and type role.
7
+
8
+ It is the rebuild of TWJS's `@burma-inventory/ui-components`. The full
9
+ mapping (which web primitives have twins, which TWJS components were
10
+ absorbed or retired, and the adaptation rules R1–R11) lives in
11
+ [`DESIGN.md`](./DESIGN.md); the decisions behind it are in
12
+ `../../docs/decisions.md`.
13
+
14
+ ## Consumer wiring (mobile-web)
15
+
16
+ Peer dependencies the consumer installs alongside this package:
17
+ `react` (19.3.1), `react-native` (0.88.0), `@shopify/restyle` (^2.4.5),
18
+ `lucide-react-native` (^1.14.0), and `expo-haptics` (~58.0.8 — the haptics
19
+ engine's backend; the range tracks Expo SDK 58, per the `expo` package's
20
+ bundledNativeModules map).
21
+
22
+ Install as a workspace dependency, then provide the theme at the app root
23
+ exactly as TWJS does today — the only change is where the theme comes from:
24
+
25
+ ```tsx
26
+ import { ThemeProvider } from '@shopify/restyle';
27
+ import { theme, darkTheme, getThemeForLocale } from '@jztack/ui-native';
28
+
29
+ export function AppRoot() {
30
+ const colorScheme = useColorScheme();
31
+ const language = useLanguage(); // the app's own i18n state
32
+ const base = colorScheme === 'dark' ? darkTheme : theme;
33
+ // Locale layers compose type metrics only (Burmese line heights/sizes);
34
+ // unknown locales return the theme unchanged.
35
+ const active = getThemeForLocale(base, language);
36
+ return <ThemeProvider theme={active}>{/* app */}</ThemeProvider>;
37
+ }
38
+ ```
39
+
40
+ - `theme` / `darkTheme` are built with restyle's `createTheme` over
41
+ `createThemeData('twjs', 'light' | 'dark')` from `@jztack/tokens`, plus
42
+ TWJS's `layout.minTableWidth` extra. Do not fork the values — token
43
+ changes ship from `@jztack/tokens`.
44
+ - Breakpoints for imperative checks come from the same contract:
45
+ `useResponsive()` / `BREAKPOINTS` (single-sourced from tokens; the
46
+ hand-synced duplicate TWJS used to keep is gone).
47
+
48
+ ### Haptics (fleet-wide standard)
49
+
50
+ Haptics are opt-in per app and inert until configured:
51
+
52
+ ```ts
53
+ import { configureHaptics } from '@jztack/ui-native';
54
+
55
+ configureHaptics({ enabled: () => settings.hapticsEnabled });
56
+ ```
57
+
58
+ The API (`configureHaptics` / `triggerHaptic`, the pattern union, the
59
+ default pattern table, the 40ms throttle) is identical to `@jztack/ui`'s.
60
+ The engine is `expo-haptics` (peer dependency; Justin's decision, Dec 4,
61
+ 2026): patterns map by name to its semantic calls — `selection` →
62
+ `selectionAsync()`, `light`/`medium`/`heavy` → `impactAsync(Light |
63
+ Medium | Heavy)`, `success`/`warning`/`error` →
64
+ `notificationAsync(Success | Warning | Error)`. The one exception is a
65
+ pattern an app overrode via `patterns` with a raw duration/sequence,
66
+ which the semantic API cannot express — those are honored through RN
67
+ `Vibration` with the resolved value, the engine's only Vibration path.
68
+
69
+ ## What's inside
70
+
71
+ - **Twins of the web primitives/Tier-2** with native counterparts: Button,
72
+ Badge, Alert, Avatar(+Group), Card family, Checkbox, RadioGroup, Toggle,
73
+ ToggleGroup (absorbs ChipGroup), Switch, Progress, Separator,
74
+ Input/Textarea/Label, Skeleton, Sheet, Dialog, Select, DropdownMenu,
75
+ Table, Field + form fields/panel/actions, DeleteButton,
76
+ ConfirmActionModal, EmptyState, PageHeader/SectionHeading, ErrorBoundary,
77
+ LoadingRows/ErrorState, StartupScreen, AppBar, BottomTabBar,
78
+ ToastProvider/useToast.
79
+ - **Native-only extras** the design keeps: SegmentedControl,
80
+ ScrollOverflowContainer, and TextField with its currency mechanism
81
+ (`useCurrencyConversion`, `registerExchangeRateResolver` — including the
82
+ deliberate offline fallback rates USD 4200 / THB 115 MMK, ported verbatim
83
+ from TWJS).
84
+ - **Platform splits**: `Select.web.tsx` renders a real DOM `<select>` on
85
+ web; `ToastHost.web.tsx` portals toasts to `document.body`;
86
+ `useDismissOnEscape.web.ts` wires the Escape key. Metro/webpack platform
87
+ resolution picks these up automatically.
88
+ - **Internal substrates are not exported**: `OptionList` (backs Select and
89
+ the phone DropdownMenu), `SheetBase` (backs Sheet and Dialog),
90
+ `ToastHost`.
91
+
92
+ Standards baked in: 48px default touch targets and 16px form controls
93
+ (dense sizes — Button `sm` 36px / `xs` 28px — exist only as documented
94
+ escape hatches); the destructive-action standard is two-step inline
95
+ (`DeleteButton`) for row-level deletes and `ConfirmActionModal` for
96
+ high-impact actions; copy always arrives via props (no baked-in strings —
97
+ apps pass their i18n-resolved text).
98
+
99
+ ## Legacy-alias retirement (tokens DESIGN §3, this package's DESIGN §5.2)
100
+
101
+ The tokens restyle emitter currently emits TWJS's legacy color keys
102
+ (`brand`, `mainBackground`, `primaryButton`, …) alongside the canonical
103
+ contract keys so un-migrated app code keeps working. The twin's own sources
104
+ use canonical keys only (enforced by `src/noLegacyKeys.spec.ts`).
105
+
106
+ | Phase | What happens | Gate |
107
+ | -------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
108
+ | 0 — twin ships | Aliases emitted by tokens; twin components canonical-only | Twin source grep: zero legacy keys (spec-enforced) |
109
+ | 1 — adoption | Codemod rewrites mobile-web's legacy keys → canonical, key-for-key, in the same per-directory pass as the import/prop renames | Per-directory test suites green |
110
+ | 2 — removal | Tokens stops emitting aliases in the first co-versioned release after adoption completes | Repo-wide grep in TWJS: zero legacy-key references; removal ships as a noted breaking change |
111
+
112
+ Measured adoption surface (Dec 4, 2026): 656 `colors.*` + 462 restyle-prop
113
+ legacy references across 147 mobile-web files.
114
+
115
+ ## Development
116
+
117
+ ```sh
118
+ npx -y pnpm@10 install # from the monorepo root
119
+ npm run typecheck
120
+ npm test # native (RN preset) + web (jsdom) projects
121
+ npm run test:coverage # thresholds set at the achieved level
122
+ npm run build # dist/ with .d.ts
123
+ ```
124
+
125
+ Tests follow TWJS's spec-per-component pattern (render + variant→theme-key
126
+ assertions + behaviour + a11y state). Note that
127
+ `@testing-library/react-native` v14's `render`/`fireEvent`/`renderHook`
128
+ are async — specs `await` them. Coverage thresholds (root `jest.config.cjs`)
129
+ are set at the achieved level and only move up.
@@ -0,0 +1,20 @@
1
+ import type React from 'react';
2
+ import type { StyleProp, ViewStyle } from 'react-native';
3
+ export type AlertTone = 'default' | 'success' | 'warning' | 'danger' | 'info';
4
+ export interface AlertProps {
5
+ tone?: AlertTone;
6
+ title?: string;
7
+ description?: string;
8
+ /** Inline action node (e.g. a Button) rendered under the text. */
9
+ action?: React.ReactNode;
10
+ icon?: React.ReactNode;
11
+ children?: React.ReactNode;
12
+ style?: StyleProp<ViewStyle>;
13
+ testID?: string;
14
+ }
15
+ /**
16
+ * Banner alert (DESIGN §2.1 #1): the web compound collapses to a single
17
+ * component with title/description/action slots. RN's `Alert.alert()`
18
+ * system dialog is a different concept and is not used.
19
+ */
20
+ export declare function Alert({ tone, title, description, action, icon, children, style, testID, }: AlertProps): React.JSX.Element;
package/dist/Alert.js ADDED
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from './Primitives';
3
+ /**
4
+ * Banner alert (DESIGN §2.1 #1): the web compound collapses to a single
5
+ * component with title/description/action slots. RN's `Alert.alert()`
6
+ * system dialog is a different concept and is not used.
7
+ */
8
+ export function Alert({ tone = 'default', title, description, action, icon, children, style, testID, }) {
9
+ const isStatus = tone !== 'default';
10
+ const bg = isStatus ? `${tone}-bg` : 'card';
11
+ const titleColor = isStatus ? `${tone}-foreground` : 'foreground';
12
+ const bodyColor = isStatus ? `${tone}-foreground` : 'foreground-secondary';
13
+ return (_jsxs(Box, { borderRadius: "xl", borderWidth: 1, borderColor: isStatus ? 'transparent' : 'border', bg: bg, p: "m", style: style, testID: testID, accessibilityLiveRegion: tone === 'danger' ? 'assertive' : 'polite', children: [_jsxs(Box, { flexDirection: "row", alignItems: "flex-start", children: [icon ? _jsx(Box, { mr: "s", children: icon }) : null, _jsxs(Box, { flex: 1, children: [title ? (_jsx(Text, { variant: "bodyStrong", color: titleColor, children: title })) : null, description ? (_jsx(Text, { variant: "body", color: bodyColor, mt: title ? 'xxs' : 'none', children: description })) : null, children] })] }), action ? _jsx(Box, { mt: "s", children: action }) : null] }));
14
+ }
@@ -0,0 +1,21 @@
1
+ import type React from 'react';
2
+ /** Layer constants for the shell chrome (moved from mobile-web's NavBar,
3
+ * DESIGN §6.1): menus render above the bar, below nothing else. */
4
+ export declare const MENU_BACKDROP_LAYER = 1000;
5
+ export declare const APP_BAR_LAYER = 10000;
6
+ export interface AppBarProps {
7
+ /** Logo/title block (NavBarBrand's slot). */
8
+ brand: React.ReactNode;
9
+ /** Right-hand cluster (toggles, sync slot, menus). */
10
+ actions?: React.ReactNode;
11
+ /** Optional second row (desktop nav row). */
12
+ children?: React.ReactNode;
13
+ testID?: string;
14
+ }
15
+ /**
16
+ * AppBar (DESIGN §6.1): the NavBar *frame* — sticky top bar on
17
+ * `background` with the bottom hairline. Everything NavBar *does* (sync
18
+ * wiring, theme toggle, domain dropdowns) stays in the app and arrives
19
+ * through the slots.
20
+ */
21
+ export declare function AppBar({ brand, actions, children, testID }: AppBarProps): React.JSX.Element;
package/dist/AppBar.js ADDED
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { StyleSheet } from 'react-native';
3
+ import { Box } from './Primitives';
4
+ /** Layer constants for the shell chrome (moved from mobile-web's NavBar,
5
+ * DESIGN §6.1): menus render above the bar, below nothing else. */
6
+ export const MENU_BACKDROP_LAYER = 1000;
7
+ export const APP_BAR_LAYER = 10000;
8
+ /**
9
+ * AppBar (DESIGN §6.1): the NavBar *frame* — sticky top bar on
10
+ * `background` with the bottom hairline. Everything NavBar *does* (sync
11
+ * wiring, theme toggle, domain dropdowns) stays in the app and arrives
12
+ * through the slots.
13
+ */
14
+ export function AppBar({ brand, actions, children, testID }) {
15
+ return (_jsxs(Box, { bg: "background", borderBottomWidth: StyleSheet.hairlineWidth, borderColor: "border", style: { zIndex: APP_BAR_LAYER }, testID: testID, children: [_jsxs(Box, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", px: "m", minHeight: 56, children: [_jsx(Box, { flexShrink: 1, children: brand }), actions ? (_jsx(Box, { flexDirection: "row", alignItems: "center", style: { gap: 8 }, children: actions })) : null] }), children] }));
16
+ }
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { type ImageSourcePropType, type StyleProp, type ViewStyle } from 'react-native';
3
+ export interface AvatarProps {
4
+ source?: ImageSourcePropType;
5
+ /** Used for the initials fallback (shown while loading and on error). */
6
+ name?: string;
7
+ size?: number;
8
+ style?: StyleProp<ViewStyle>;
9
+ testID?: string;
10
+ }
11
+ export declare function Avatar({ source, name, size, style, testID }: AvatarProps): React.JSX.Element;
12
+ export interface AvatarGroupProps {
13
+ /** How many avatars to show before the +N count bubble. Default 3. */
14
+ max?: number;
15
+ size?: number;
16
+ children: React.ReactNode;
17
+ style?: StyleProp<ViewStyle>;
18
+ testID?: string;
19
+ }
20
+ /** Overlapping avatar row; overflow collapses into a count bubble (a Badge). */
21
+ export declare function AvatarGroup({ max, size, children, style, testID }: AvatarGroupProps): React.JSX.Element;
package/dist/Avatar.js ADDED
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useState } from 'react';
3
+ import { Image } from 'react-native';
4
+ import { Badge } from './Badge';
5
+ import { Box, Text } from './Primitives';
6
+ function initialsOf(name) {
7
+ if (!name)
8
+ return '';
9
+ const parts = name.trim().split(/\s+/).slice(0, 2);
10
+ return parts.map((p) => p.charAt(0).toUpperCase()).join('');
11
+ }
12
+ export function Avatar({ source, name, size = 40, style, testID }) {
13
+ const [failed, setFailed] = useState(false);
14
+ const showImage = source !== undefined && !failed;
15
+ return (_jsx(Box, { width: size, height: size, borderRadius: "full", bg: "muted", alignItems: "center", justifyContent: "center", overflow: "hidden", style: style, testID: testID, children: showImage ? (_jsx(Image, { source: source, onError: () => setFailed(true), style: { width: size, height: size }, accessibilityLabel: name, testID: testID ? `${testID}-image` : undefined })) : (_jsx(Text, { variant: "bodySecondary", fontWeight: "700", color: "muted-foreground", children: initialsOf(name) })) }));
16
+ }
17
+ /** Overlapping avatar row; overflow collapses into a count bubble (a Badge). */
18
+ export function AvatarGroup({ max = 3, size = 40, children, style, testID }) {
19
+ const items = React.Children.toArray(children);
20
+ const visible = items.slice(0, max);
21
+ const overflow = items.length - visible.length;
22
+ return (_jsxs(Box, { flexDirection: "row", alignItems: "center", style: style, testID: testID, children: [visible.map((child, index) => (_jsx(Box, { style: index === 0 ? undefined : { marginLeft: -size / 4 }, children: child }, index))), overflow > 0 ? (_jsx(Box, { style: { marginLeft: -size / 4 }, children: _jsx(Badge, { tone: "neutral", appearance: "solid", children: `+${overflow}` }) })) : null] }));
23
+ }
@@ -0,0 +1,15 @@
1
+ import type React from 'react';
2
+ import type { StyleProp, ViewStyle } from 'react-native';
3
+ export type BadgeTone = 'neutral' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
4
+ export type BadgeAppearance = 'subtle' | 'solid' | 'outline';
5
+ export interface BadgeProps {
6
+ tone?: BadgeTone;
7
+ appearance?: BadgeAppearance;
8
+ /** Optional leading icon node (aria-hidden by construction — a badge's
9
+ * label text is mandatory, tone is never the only signal). */
10
+ icon?: React.ReactNode;
11
+ children: string;
12
+ style?: StyleProp<ViewStyle>;
13
+ testID?: string;
14
+ }
15
+ export declare function Badge({ tone, appearance, icon, children, style, testID, }: BadgeProps): React.JSX.Element;
package/dist/Badge.js ADDED
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from './Primitives';
3
+ function resolveColors(tone, appearance) {
4
+ if (appearance === 'solid') {
5
+ if (tone === 'neutral')
6
+ return { bg: 'muted', text: 'muted-foreground', border: 'transparent' };
7
+ if (tone === 'primary')
8
+ return { bg: 'primary', text: 'primary-foreground', border: 'transparent' };
9
+ // Status solid: the triple's main value as bg, emitter's white as text.
10
+ return { bg: tone, text: 'pureWhite', border: 'transparent' };
11
+ }
12
+ if (appearance === 'outline') {
13
+ const border = tone === 'neutral' ? 'border' : tone === 'primary' ? 'primary' : tone;
14
+ const text = tone === 'neutral' ? 'foreground' : tone === 'primary' ? 'primary' : tone;
15
+ return { bg: 'transparent', text, border };
16
+ }
17
+ // subtle
18
+ if (tone === 'neutral')
19
+ return { bg: 'muted', text: 'muted-foreground', border: 'transparent' };
20
+ if (tone === 'primary')
21
+ return { bg: 'accent-bg', text: 'accent', border: 'accent-border' };
22
+ return { bg: `${tone}-bg`, text: tone, border: 'transparent' };
23
+ }
24
+ export function Badge({ tone = 'neutral', appearance = 'subtle', icon, children, style, testID, }) {
25
+ const colors = resolveColors(tone, appearance);
26
+ return (_jsxs(Box, { flexDirection: "row", alignItems: "center", alignSelf: "flex-start", borderRadius: "full", borderWidth: appearance === 'outline' ? 1 : 0, borderColor: colors.border, bg: colors.bg, px: "sm", py: "xxs", style: style, testID: testID, children: [icon ? (_jsx(Box, { mr: "xxs", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: icon })) : null, _jsx(Text, { variant: "badge", color: colors.text, children: children })] }));
27
+ }
@@ -0,0 +1,26 @@
1
+ import type React from 'react';
2
+ export interface ShellTabItem {
3
+ key: string;
4
+ /** Resolved string (the app's i18n, R9). */
5
+ label: string;
6
+ icon: (state: {
7
+ focused: boolean;
8
+ }) => React.ReactNode;
9
+ badge?: number | string;
10
+ }
11
+ export interface BottomTabBarProps {
12
+ items: ShellTabItem[];
13
+ activeKey: string;
14
+ onSelect: (key: string) => void;
15
+ /** Host safe-area bottom inset; padding never drops below spacing.s. */
16
+ bottomInset?: number;
17
+ testID?: string;
18
+ }
19
+ /**
20
+ * BottomTabBar (DESIGN §6.1): mobile-web's tab bar generalized off its app
21
+ * couplings (ScreenId / ROLE_SCREENS / useAuth / SCREEN_ICONS /
22
+ * useTranslation all stay in the app, which maps its navigation config
23
+ * into items). Each item is ≥48px, flex-1, icon + label; pressed scale
24
+ * 0.96; selected state via accessibilityState + tab role.
25
+ */
26
+ export declare function BottomTabBar({ items, activeKey, onSelect, bottomInset, testID, }: BottomTabBarProps): React.JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTheme } from '@shopify/restyle';
3
+ import { Platform, Pressable, StyleSheet } from 'react-native';
4
+ import { Box, Text } from './Primitives';
5
+ const PRESSED_TAB_SCALE = 0.96;
6
+ /**
7
+ * BottomTabBar (DESIGN §6.1): mobile-web's tab bar generalized off its app
8
+ * couplings (ScreenId / ROLE_SCREENS / useAuth / SCREEN_ICONS /
9
+ * useTranslation all stay in the app, which maps its navigation config
10
+ * into items). Each item is ≥48px, flex-1, icon + label; pressed scale
11
+ * 0.96; selected state via accessibilityState + tab role.
12
+ */
13
+ export function BottomTabBar({ items, activeKey, onSelect, bottomInset = 0, testID = 'bottom-tab-bar', }) {
14
+ const theme = useTheme();
15
+ const { spacing } = theme;
16
+ const shadowY = -spacing.xs;
17
+ const shadowRadius = spacing.s;
18
+ const boxShadow = `${spacing.none}px ${shadowY}px ${shadowRadius}px rgba(0,0,0,0.05)`;
19
+ return (_jsx(Box, { accessibilityRole: "tablist", flexDirection: "row", bg: "card", borderTopWidth: StyleSheet.hairlineWidth, borderColor: "border", pt: "xs", style: [
20
+ { paddingBottom: Math.max(bottomInset, spacing.s) },
21
+ Platform.OS === 'web'
22
+ ? { boxShadow }
23
+ : {
24
+ shadowColor: '#000',
25
+ shadowOffset: { width: 0, height: shadowY },
26
+ shadowOpacity: 0.05,
27
+ shadowRadius,
28
+ },
29
+ ], testID: testID, children: items.map((item) => {
30
+ const selected = item.key === activeKey;
31
+ const color = selected ? 'primary' : 'foreground-secondary';
32
+ return (_jsxs(Pressable, { onPress: () => onSelect(item.key), accessibilityRole: "tab", accessibilityState: { selected }, testID: `${testID}-${item.key}`, style: ({ pressed }) => ({
33
+ alignItems: 'center',
34
+ flex: 1,
35
+ minHeight: 48,
36
+ transform: [{ scale: pressed ? PRESSED_TAB_SCALE : 1 }],
37
+ }), children: [_jsxs(Box, { px: "s", py: "xs", borderRadius: "xl", bg: selected ? 'accent-bg' : 'transparent', position: "relative", children: [item.icon({ focused: selected }), item.badge !== undefined ? (_jsx(Box, { position: "absolute", top: -4, right: -8, minWidth: 18, height: 18, borderRadius: "full", bg: "destructive", alignItems: "center", justifyContent: "center", px: "xxs", children: _jsx(Text, { variant: "badge", color: "destructive-foreground", style: { fontSize: 10, lineHeight: 12 }, children: String(item.badge) }) })) : null] }), _jsx(Text, { variant: "caption", fontWeight: "700", numberOfLines: 1, textAlign: "center", mt: "xs", color: color, children: item.label })] }, item.key));
38
+ }) }));
39
+ }
@@ -0,0 +1,21 @@
1
+ import type React from 'react';
2
+ import { type PressableProps, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { type HapticPattern } from './haptics';
4
+ export type ButtonVariant = 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive' | 'link';
5
+ export type ButtonSize = 'default' | 'lg' | 'sm' | 'xs' | 'icon';
6
+ export interface ButtonProps extends Omit<PressableProps, 'children' | 'style'> {
7
+ variant?: ButtonVariant;
8
+ /** `sm` (36px) / `xs` (28px) are dense-only escape hatches (decisions log,
9
+ * Dec 4, 2026) — never the default, never for primary touch actions. */
10
+ size?: ButtonSize;
11
+ isLoading?: boolean;
12
+ icon?: React.ReactNode;
13
+ iconPosition?: 'left' | 'right';
14
+ /** Opt-in haptics (DESIGN §2.3): `true` fires the variant's default
15
+ * pattern, a string fires that pattern. Inert until the app calls
16
+ * `configureHaptics`. */
17
+ haptic?: boolean | HapticPattern;
18
+ children?: React.ReactNode;
19
+ style?: StyleProp<ViewStyle>;
20
+ }
21
+ export declare function Button({ variant, size, isLoading, disabled, icon, iconPosition, haptic, children, onPress, style, ...rest }: ButtonProps): React.JSX.Element;
package/dist/Button.js ADDED
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTheme } from '@shopify/restyle';
3
+ import { ActivityIndicator, Pressable, } from 'react-native';
4
+ import { BUTTON_VARIANT_PATTERNS, triggerHaptic } from './haptics';
5
+ import { Box, Text } from './Primitives';
6
+ const VARIANT_STYLES = {
7
+ default: {
8
+ bg: 'primary',
9
+ textColor: 'primary-foreground',
10
+ borderWidth: 0,
11
+ borderColor: 'transparent',
12
+ },
13
+ secondary: {
14
+ bg: 'secondary',
15
+ textColor: 'secondary-foreground',
16
+ borderWidth: 0,
17
+ borderColor: 'transparent',
18
+ },
19
+ outline: { bg: 'transparent', textColor: 'foreground', borderWidth: 1, borderColor: 'border' },
20
+ ghost: { bg: 'transparent', textColor: 'primary', borderWidth: 0, borderColor: 'transparent' },
21
+ destructive: {
22
+ bg: 'destructive',
23
+ textColor: 'destructive-foreground',
24
+ borderWidth: 0,
25
+ borderColor: 'transparent',
26
+ },
27
+ link: { bg: 'transparent', textColor: 'primary', borderWidth: 0, borderColor: 'transparent' },
28
+ };
29
+ const SIZE_MIN_HEIGHT = {
30
+ default: 48,
31
+ lg: 52,
32
+ sm: 36,
33
+ xs: 28,
34
+ icon: 48,
35
+ };
36
+ const SIZE_PADDING_X = {
37
+ default: 'm',
38
+ lg: 'l',
39
+ sm: 's',
40
+ xs: 's',
41
+ icon: 'none',
42
+ };
43
+ const SIZE_PADDING_Y = {
44
+ default: 's',
45
+ lg: 's',
46
+ sm: 'xs',
47
+ xs: 'none',
48
+ icon: 'none',
49
+ };
50
+ export function Button({ variant = 'default', size = 'default', isLoading = false, disabled, icon, iconPosition = 'left', haptic = false, children, onPress, style, ...rest }) {
51
+ const theme = useTheme();
52
+ const v = VARIANT_STYLES[variant];
53
+ const isDisabled = disabled || isLoading;
54
+ const isLink = variant === 'link';
55
+ const textVariant = size === 'sm' || size === 'xs' ? 'bodySecondary' : 'button';
56
+ const handlePress = (event) => {
57
+ if (haptic) {
58
+ triggerHaptic(haptic === true ? (BUTTON_VARIANT_PATTERNS[variant] ?? 'light') : haptic);
59
+ }
60
+ onPress?.(event);
61
+ };
62
+ return (_jsx(Pressable, { disabled: isDisabled, onPress: handlePress, accessibilityRole: "button", accessibilityState: { disabled: !!isDisabled, busy: isLoading }, style: ({ pressed }) => [{ opacity: pressed && !isDisabled ? 0.8 : 1 }, style], ...rest, children: _jsxs(Box, { flexDirection: "row", justifyContent: "center", alignItems: "center", borderRadius: "lg", bg: v.bg, borderWidth: v.borderWidth, borderColor: v.borderColor, px: isLink ? 'none' : SIZE_PADDING_X[size], py: isLink ? 'none' : SIZE_PADDING_Y[size], minHeight: isLink ? undefined : SIZE_MIN_HEIGHT[size], minWidth: size === 'icon' ? 48 : undefined, opacity: isDisabled ? 0.5 : 1, children: [isLoading ? (_jsx(Box, { mr: children ? 'xs' : 'none', children: _jsx(ActivityIndicator, { testID: "button-loading-indicator", color: theme.colors[v.textColor], size: "small" }) })) : null, icon && iconPosition === 'left' ? _jsx(Box, { mr: children ? 'xs' : 'none', children: icon }) : null, typeof children === 'string' ? (_jsx(Text, { variant: textVariant, color: v.textColor, children: children })) : (children), icon && iconPosition === 'right' ? _jsx(Box, { ml: children ? 'xs' : 'none', children: icon }) : null] }) }));
63
+ }
package/dist/Card.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import { type BoxProps } from '@shopify/restyle';
2
+ import type React from 'react';
3
+ import type { StyleProp, ViewStyle } from 'react-native';
4
+ import type { Theme } from './theme';
5
+ export type CardVariant = 'raised' | 'glass' | 'flat';
6
+ export type CardSize = 'default' | 'sm';
7
+ export interface CardProps extends BoxProps<Theme> {
8
+ variant?: CardVariant;
9
+ size?: CardSize;
10
+ elevation?: number;
11
+ /** Wraps children in a ScrollOverflowContainer (retained TWJS behaviour). */
12
+ scrollable?: boolean;
13
+ children?: React.ReactNode;
14
+ style?: StyleProp<ViewStyle>;
15
+ testID?: string;
16
+ }
17
+ type CardSectionProps = BoxProps<Theme> & {
18
+ children?: React.ReactNode;
19
+ };
20
+ /**
21
+ * Card (DESIGN §2.1 #5). `raised` is the light-theme default (decisions
22
+ * log, Dec 4, 2026); `glass` is translucency without backdrop blur on
23
+ * native (open question Q6) and the dark-theme identity; `flat` is the
24
+ * border-only dense/nested form.
25
+ */
26
+ export declare function Card({ children, variant, size, elevation, scrollable, style, ...rest }: CardProps): React.JSX.Element;
27
+ export declare function CardHeader({ children, ...rest }: CardSectionProps): React.JSX.Element;
28
+ export declare function CardTitle({ children }: {
29
+ children: React.ReactNode;
30
+ }): React.JSX.Element;
31
+ export declare function CardDescription({ children }: {
32
+ children: React.ReactNode;
33
+ }): React.JSX.Element;
34
+ export declare function CardContent({ children, ...rest }: CardSectionProps): React.JSX.Element;
35
+ export declare function CardFooter({ children, ...rest }: CardSectionProps): React.JSX.Element;
36
+ export declare function CardAction({ children, ...rest }: CardSectionProps): React.JSX.Element;
37
+ export {};
package/dist/Card.js ADDED
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useTheme } from '@shopify/restyle';
3
+ import { Box, Text } from './Primitives';
4
+ import { ScrollOverflowContainer } from './ScrollOverflowContainer';
5
+ import { getShadowStyle } from './shadows';
6
+ function hexWithAlpha(hex, alphaHex) {
7
+ return /^#[0-9a-fA-F]{6}$/.test(hex) ? `${hex}${alphaHex}` : undefined;
8
+ }
9
+ /**
10
+ * Card (DESIGN §2.1 #5). `raised` is the light-theme default (decisions
11
+ * log, Dec 4, 2026); `glass` is translucency without backdrop blur on
12
+ * native (open question Q6) and the dark-theme identity; `flat` is the
13
+ * border-only dense/nested form.
14
+ */
15
+ export function Card({ children, variant = 'raised', size = 'default', elevation = 1, scrollable = false, style, ...rest }) {
16
+ const theme = useTheme();
17
+ const glassBg = variant === 'glass' ? hexWithAlpha(theme.colors.card ?? '', '99') : undefined;
18
+ return (_jsx(Box, { bg: variant === 'glass' ? undefined : 'card', borderRadius: "xl", p: size === 'sm' ? 'sm' : 'm', borderWidth: variant === 'raised' ? 0 : 1, borderColor: "border", elevation: variant === 'raised' ? elevation : undefined, style: [
19
+ variant === 'raised' ? getShadowStyle('card') : undefined,
20
+ glassBg ? { backgroundColor: glassBg } : undefined,
21
+ style,
22
+ ], ...rest, children: scrollable ? (_jsx(ScrollOverflowContainer, { style: { flex: 1 }, children: children })) : (children) }));
23
+ }
24
+ export function CardHeader({ children, ...rest }) {
25
+ return (_jsx(Box, { mb: "s", ...rest, children: children }));
26
+ }
27
+ export function CardTitle({ children }) {
28
+ return _jsx(Text, { variant: "title", children: children });
29
+ }
30
+ export function CardDescription({ children }) {
31
+ return (_jsx(Text, { variant: "bodySecondary", mt: "xxs", children: children }));
32
+ }
33
+ export function CardContent({ children, ...rest }) {
34
+ return _jsx(Box, { ...rest, children: children });
35
+ }
36
+ export function CardFooter({ children, ...rest }) {
37
+ return (_jsx(Box, { flexDirection: "row", alignItems: "center", mt: "s", ...rest, children: children }));
38
+ }
39
+ export function CardAction({ children, ...rest }) {
40
+ return (_jsx(Box, { alignSelf: "flex-end", ...rest, children: children }));
41
+ }
@@ -0,0 +1,11 @@
1
+ import { type StyleProp, type ViewStyle } from 'react-native';
2
+ export interface CheckboxProps {
3
+ checked: boolean;
4
+ onCheckedChange?: (checked: boolean) => void;
5
+ disabled?: boolean;
6
+ style?: StyleProp<ViewStyle>;
7
+ testID?: string;
8
+ }
9
+ /** `checked` / `onCheckedChange` names kept from Radix (DESIGN §2.1 #6).
10
+ * The 48px hit area is the CheckboxField row's job, as on web. */
11
+ export declare function Checkbox({ checked, onCheckedChange, disabled, style, testID }: CheckboxProps): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useTheme } from '@shopify/restyle';
3
+ import { Check } from 'lucide-react-native';
4
+ import { Pressable } from 'react-native';
5
+ import { Box } from './Primitives';
6
+ /** `checked` / `onCheckedChange` names kept from Radix (DESIGN §2.1 #6).
7
+ * The 48px hit area is the CheckboxField row's job, as on web. */
8
+ export function Checkbox({ checked, onCheckedChange, disabled, style, testID }) {
9
+ const theme = useTheme();
10
+ return (_jsx(Pressable, { onPress: () => onCheckedChange?.(!checked), disabled: disabled, accessibilityRole: "checkbox", accessibilityState: { checked, disabled: !!disabled }, testID: testID, style: style, children: _jsx(Box, { width: 24, height: 24, borderRadius: "sm", borderWidth: 2, borderColor: checked ? 'primary' : 'border', bg: checked ? 'primary' : 'transparent', alignItems: "center", justifyContent: "center", opacity: disabled ? 0.5 : 1, children: checked ? (_jsx(Check, { size: 16, color: theme.colors['primary-foreground'], strokeWidth: 3 })) : null }) }));
11
+ }
@@ -0,0 +1,27 @@
1
+ import type React from 'react';
2
+ export interface ConfirmActionModalProps {
3
+ isOpen: boolean;
4
+ onClose: () => void;
5
+ title: string;
6
+ description: string;
7
+ confirmLabel: string;
8
+ cancelLabel: string;
9
+ /** Shown with a spinner on the confirm button while pending. */
10
+ busyLabel?: string;
11
+ onConfirm: () => undefined | Promise<unknown>;
12
+ /** Destructive Button variant + danger tone. */
13
+ isDestructive?: boolean;
14
+ isConfirmDisabled?: boolean;
15
+ /** External busy state. */
16
+ isLoading?: boolean;
17
+ /** Detail block between title and description (e.g. an amount). */
18
+ children?: React.ReactNode;
19
+ }
20
+ /**
21
+ * ConfirmActionModal (DESIGN §2.2): the web prop spec carried over nearly
22
+ * whole, built on twin Dialog. The web's `descriptionInTooltip` /
23
+ * `moreInfoLabel` mode is dropped — there is no Tooltip on native.
24
+ * Behaviours kept from the source: async pending state, double-submit
25
+ * guard, content snapshot while open, no destructive auto-focus.
26
+ */
27
+ export declare function ConfirmActionModal(props: ConfirmActionModalProps): React.JSX.Element | null;
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { Button } from './Button';
4
+ import { Dialog } from './Dialog';
5
+ import { Box } from './Primitives';
6
+ /**
7
+ * ConfirmActionModal (DESIGN §2.2): the web prop spec carried over nearly
8
+ * whole, built on twin Dialog. The web's `descriptionInTooltip` /
9
+ * `moreInfoLabel` mode is dropped — there is no Tooltip on native.
10
+ * Behaviours kept from the source: async pending state, double-submit
11
+ * guard, content snapshot while open, no destructive auto-focus.
12
+ */
13
+ export function ConfirmActionModal(props) {
14
+ const { isOpen, onClose, onConfirm, isLoading } = props;
15
+ const [pending, setPending] = useState(false);
16
+ const snapshot = useRef(props);
17
+ useEffect(() => {
18
+ if (isOpen)
19
+ snapshot.current = props;
20
+ });
21
+ const content = isOpen ? props : snapshot.current;
22
+ const busy = pending || !!isLoading;
23
+ const handleConfirm = async () => {
24
+ if (busy || content.isConfirmDisabled)
25
+ return;
26
+ setPending(true);
27
+ try {
28
+ await onConfirm();
29
+ onClose();
30
+ }
31
+ catch {
32
+ // Stay open and re-enable — the caller surfaces the error.
33
+ }
34
+ finally {
35
+ setPending(false);
36
+ }
37
+ };
38
+ if (!isOpen && snapshot.current === props) {
39
+ // Never opened: render nothing (no snapshot to preserve yet).
40
+ return null;
41
+ }
42
+ return (_jsx(Dialog, { open: isOpen, onOpenChange: (next) => (next ? undefined : onClose()), title: content.title, description: content.description, showCloseButton: false, testID: "confirm-action-modal", footer: _jsxs(Box, { flexDirection: "row", style: { gap: 12 }, children: [_jsx(Box, { flex: 1, children: _jsx(Button, { variant: "secondary", onPress: onClose, disabled: busy, children: content.cancelLabel }) }), _jsx(Box, { flex: 1, children: _jsx(Button, { variant: content.isDestructive ? 'destructive' : 'default', onPress: handleConfirm, isLoading: busy, disabled: busy || content.isConfirmDisabled, children: busy && content.busyLabel ? content.busyLabel : content.confirmLabel }) })] }), children: content.children }));
43
+ }