@retray-dev/ui-kit 1.8.0 → 2.5.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.
- package/COMPONENTS.md +150 -43
- package/dist/index.d.mts +80 -44
- package/dist/index.d.ts +80 -44
- package/dist/index.js +627 -457
- package/dist/index.mjs +626 -457
- package/package.json +8 -2
- package/src/components/Accordion/Accordion.tsx +4 -6
- package/src/components/Alert/Alert.tsx +3 -3
- package/src/components/AlertBanner/AlertBanner.tsx +85 -0
- package/src/components/{Alert → AlertBanner}/index.ts +2 -2
- package/src/components/Avatar/Avatar.tsx +1 -0
- package/src/components/Badge/Badge.tsx +45 -9
- package/src/components/Button/Button.tsx +5 -5
- package/src/components/Card/Card.tsx +90 -18
- package/src/components/Checkbox/Checkbox.tsx +4 -4
- package/src/components/Chip/Chip.tsx +36 -5
- package/src/components/CurrencyInput/CurrencyInput.tsx +9 -1
- package/src/components/EmptyState/EmptyState.tsx +2 -1
- package/src/components/Input/Input.tsx +107 -26
- package/src/components/ListItem/ListItem.tsx +157 -21
- package/src/components/MonthPicker/MonthPicker.tsx +3 -6
- package/src/components/RadioGroup/RadioGroup.tsx +2 -2
- package/src/components/Select/Select.tsx +200 -132
- package/src/components/Slider/Slider.tsx +64 -100
- package/src/components/Switch/Switch.tsx +22 -20
- package/src/components/Textarea/Textarea.tsx +16 -7
- package/src/components/Toast/Toast.tsx +23 -18
- package/src/components/Toggle/Toggle.tsx +36 -49
- package/src/index.ts +3 -2
- package/src/theme/ThemeProvider.tsx +11 -8
- package/src/theme/colors.ts +19 -18
- package/src/theme/types.ts +2 -0
- package/src/components/CurrencyInputLarge/CurrencyInputLarge.tsx +0 -66
- package/src/components/CurrencyInputLarge/index.ts +0 -1
package/COMPONENTS.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @retray-dev/ui-kit — Component Reference (
|
|
1
|
+
# @retray-dev/ui-kit — Component Reference (v2.1.0)
|
|
2
2
|
|
|
3
3
|
This file is the AI reference for this package. It is shipped inside the npm package so consuming projects can import it into their `CLAUDE.md` with:
|
|
4
4
|
|
|
@@ -74,7 +74,7 @@ function MyComponent() {
|
|
|
74
74
|
|
|
75
75
|
## Theme Tokens
|
|
76
76
|
|
|
77
|
-
All 20 tokens are available via `useTheme().colors
|
|
77
|
+
All 20 tokens are available via `useTheme().colors` and are applied exactly as provided — there is no automatic color derivation or forced contrast applied by the library. Consumers may pass partial overrides for `light` and/or `dark` and the values are used as-is.
|
|
78
78
|
|
|
79
79
|
The `ThemeColors` type (and `Theme`, `ColorScheme`) are exported directly from the package:
|
|
80
80
|
```ts
|
|
@@ -85,23 +85,23 @@ import type { ThemeColors } from '@retray-dev/ui-kit'
|
|
|
85
85
|
|-------|-------|------|---------------|
|
|
86
86
|
| `background` | `#ffffff` | `#171717` | Screen / page background |
|
|
87
87
|
| `foreground` | `#171717` | `#fafafa` | Primary text color |
|
|
88
|
-
| `card` | `#ffffff` | `#
|
|
88
|
+
| `card` | `#ffffff` | `#222222` | Card / surface background |
|
|
89
89
|
| `cardForeground` | `#171717` | `#fafafa` | Text on cards |
|
|
90
90
|
| `primary` | `#1a1a1a` | `#fafafa` | Primary action (buttons, selected states) |
|
|
91
|
-
| `primaryForeground` | `#
|
|
92
|
-
| `secondary` | `#
|
|
93
|
-
| `secondaryForeground` | `#
|
|
94
|
-
| `muted` | `#
|
|
95
|
-
| `mutedForeground` | `#
|
|
96
|
-
| `accent` | `#
|
|
97
|
-
| `accentForeground` | `#
|
|
91
|
+
| `primaryForeground` | `#ffffff` | `#1a1a1a` | Text/icon on primary background |
|
|
92
|
+
| `secondary` | `#f1f1f1` | `#323232` | Secondary surfaces |
|
|
93
|
+
| `secondaryForeground` | `#171717` | `#fafafa` | Text on secondary |
|
|
94
|
+
| `muted` | `#f1f1f1` | `#323232` | Muted backgrounds, skeleton fills, track fills |
|
|
95
|
+
| `mutedForeground` | `#a2a2a2` | `#888888` | Placeholder text, helper text, captions |
|
|
96
|
+
| `accent` | `#e4e4e4` | `#323232` | Hover / pressed state fills |
|
|
97
|
+
| `accentForeground` | `#171717` | `#fafafa` | Text on accent |
|
|
98
98
|
| `destructive` | `#ef4444` | `#dc2626` | Error / danger / delete actions |
|
|
99
|
-
| `destructiveForeground` | `#
|
|
99
|
+
| `destructiveForeground` | `#1a1a1a` | `#1a1a1a` | Text on destructive |
|
|
100
100
|
| `border` | `#e5e5e5` | `#2a2a2a` | Borders and dividers |
|
|
101
101
|
| `input` | `#e5e5e5` | `#2a2a2a` | Input field border color |
|
|
102
|
-
| `ring` | `#
|
|
102
|
+
| `ring` | `#1a1a1a` | `#fafafa` | Optional focus ring token (components may use `primary` by default) |
|
|
103
103
|
| `success` | `#16a34a` | `#22c55e` | Success state (Toast success variant) |
|
|
104
|
-
| `successForeground` | `#
|
|
104
|
+
| `successForeground` | `#1a1a1a` | `#1a1a1a` | Text on success background |
|
|
105
105
|
|
|
106
106
|
---
|
|
107
107
|
|
|
@@ -121,12 +121,12 @@ import type { ThemeColors } from '@retray-dev/ui-kit'
|
|
|
121
121
|
| color | `string` | — | Override the color. Defaults to `foreground`, except `caption` which uses `mutedForeground` |
|
|
122
122
|
|
|
123
123
|
**Sizes:**
|
|
124
|
-
- `h1`:
|
|
125
|
-
- `h2`:
|
|
126
|
-
- `h3`:
|
|
127
|
-
- `body`:
|
|
128
|
-
- `label`:
|
|
129
|
-
- `caption`:
|
|
124
|
+
- `h1`: 40px / 700 weight / lineHeight 52
|
|
125
|
+
- `h2`: 28px / 700 weight / lineHeight 36
|
|
126
|
+
- `h3`: 22px / 600 weight / lineHeight 30
|
|
127
|
+
- `body`: 17px / 400 weight / lineHeight 26
|
|
128
|
+
- `label`: 15px / 500 weight / lineHeight 22
|
|
129
|
+
- `caption`: 13px / 400 weight / lineHeight 20 / `mutedForeground` color by default
|
|
130
130
|
|
|
131
131
|
**Example:**
|
|
132
132
|
```tsx
|
|
@@ -151,7 +151,7 @@ import type { ThemeColors } from '@retray-dev/ui-kit'
|
|
|
151
151
|
| size | `'sm' \| 'md' \| 'lg'` | `'md'` | — |
|
|
152
152
|
| loading | `boolean` | `false` | Replaces label with a spinner and forces disabled state |
|
|
153
153
|
| fullWidth | `boolean` | `false` | Stretches to container width (`alignSelf: 'stretch'`) |
|
|
154
|
-
| disabled | `boolean` | — | Reduces opacity to 0.
|
|
154
|
+
| disabled | `boolean` | — | Reduces opacity to 0.5 |
|
|
155
155
|
| icon | `React.ReactNode` | — | Icon rendered alongside the label |
|
|
156
156
|
| iconPosition | `'left' \| 'right'` | `'left'` | Side the icon appears on |
|
|
157
157
|
|
|
@@ -186,14 +186,19 @@ import type { ThemeColors } from '@retray-dev/ui-kit'
|
|
|
186
186
|
| label | `string` | — | Label above the input |
|
|
187
187
|
| error | `string` | — | Shows error text below; turns border red (`destructive` token) |
|
|
188
188
|
| hint | `string` | — | Helper text below (hidden when `error` is set) |
|
|
189
|
+
| prefix | `string \| ReactNode` | — | Content rendered before the input field (e.g., `"$"` or an icon) |
|
|
190
|
+
| suffix | `string \| ReactNode` | — | Content rendered after the input field (e.g., `"kg"` or a button) |
|
|
191
|
+
| type | `'text' \| 'password'` | `'text'` | When `'password'`, shows a visibility toggle button in the suffix slot |
|
|
189
192
|
|
|
190
193
|
**Border colors:** `destructive` when `error` is set, `ring` when focused, `border` otherwise.
|
|
191
194
|
|
|
192
195
|
**Example:**
|
|
193
196
|
```tsx
|
|
194
197
|
<Input label="Email" placeholder="you@example.com" keyboardType="email-address" />
|
|
195
|
-
<Input label="Password"
|
|
198
|
+
<Input label="Password" type="password" error="Incorrect password" />
|
|
196
199
|
<Input label="Username" hint="Must be at least 4 characters" />
|
|
200
|
+
<Input label="Amount" prefix="$" placeholder="0.00" keyboardType="numeric" />
|
|
201
|
+
<Input label="Weight" suffix="kg" placeholder="0" />
|
|
197
202
|
```
|
|
198
203
|
|
|
199
204
|
---
|
|
@@ -210,6 +215,7 @@ import type { ThemeColors } from '@retray-dev/ui-kit'
|
|
|
210
215
|
| onChangeValue | `(raw: number) => void` | — | Called with the parsed number (no separators, no prefix) |
|
|
211
216
|
| prefix | `string` | `'$'` | Symbol prepended to the formatted value |
|
|
212
217
|
| thousandsSeparator | `'.' \| ','` | `'.'` | Character used to separate groups of three digits |
|
|
218
|
+
| size | `'default' \| 'large'` | `'default'` | `'large'` uses 36px font size (previously `CurrencyInputLarge`) |
|
|
213
219
|
| label | `string` | — | Label above the input |
|
|
214
220
|
| error | `string` | — | Error text below; turns border red |
|
|
215
221
|
| hint | `string` | — | Helper text below (hidden when `error` is set) |
|
|
@@ -270,16 +276,20 @@ const [amount, setAmount] = useState(0)
|
|
|
270
276
|
|
|
271
277
|
| Prop | Type | Default | Notes |
|
|
272
278
|
|------|------|---------|-------|
|
|
273
|
-
| label | `string` |
|
|
279
|
+
| label | `string` | — | Badge text — can be omitted if using `children` |
|
|
280
|
+
| children | `ReactNode` | — | Alternative to `label` for custom content |
|
|
274
281
|
| variant | `'default' \| 'secondary' \| 'destructive' \| 'outline'` | `'default'` | — |
|
|
282
|
+
| size | `'sm' \| 'md' \| 'lg'` | `'md'` | Controls padding and font size |
|
|
283
|
+
| icon | `ReactNode` | — | Icon rendered before the label/children |
|
|
275
284
|
| style | `ViewStyle` | — | — |
|
|
276
285
|
|
|
277
286
|
**Example:**
|
|
278
287
|
```tsx
|
|
279
288
|
<Badge label="New" />
|
|
280
289
|
<Badge label="Error" variant="destructive" />
|
|
281
|
-
<Badge label="Draft" variant="secondary" />
|
|
290
|
+
<Badge label="Draft" variant="secondary" size="sm" />
|
|
282
291
|
<Badge label="Beta" variant="outline" />
|
|
292
|
+
<Badge icon={<CheckIcon size={12} />} size="sm">Verified</Badge>
|
|
283
293
|
```
|
|
284
294
|
|
|
285
295
|
---
|
|
@@ -458,11 +468,20 @@ const [amount, setAmount] = useState(0)
|
|
|
458
468
|
**Import:** `import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@retray-dev/ui-kit'`
|
|
459
469
|
**When to use:** Grouped content with a surface background, border, and shadow.
|
|
460
470
|
|
|
461
|
-
|
|
471
|
+
**`Card` Props:**
|
|
472
|
+
|
|
473
|
+
| Prop | Type | Default | Notes |
|
|
474
|
+
|------|------|---------|-------|
|
|
475
|
+
| variant | `'elevated' \| 'outlined' \| 'filled'` | `'elevated'` | `elevated`: shadow + border; `outlined`: border only; `filled`: background fill, no border |
|
|
476
|
+
| onPress | `() => void` | — | Makes the card pressable with scale animation + haptics |
|
|
477
|
+
| children | `ReactNode` | — | — |
|
|
478
|
+
| style | `ViewStyle` | — | — |
|
|
479
|
+
|
|
480
|
+
All sub-components (`CardHeader`, `CardTitle`, `CardDescription`, `CardContent`, `CardFooter`) accept a `style` prop for overrides.
|
|
462
481
|
|
|
463
482
|
**Example:**
|
|
464
483
|
```tsx
|
|
465
|
-
<Card>
|
|
484
|
+
<Card variant="elevated">
|
|
466
485
|
<CardHeader>
|
|
467
486
|
<CardTitle>Account</CardTitle>
|
|
468
487
|
<CardDescription>Manage your profile settings</CardDescription>
|
|
@@ -474,6 +493,13 @@ All sub-components accept a `style` prop for overrides.
|
|
|
474
493
|
<Button label="Save" fullWidth />
|
|
475
494
|
</CardFooter>
|
|
476
495
|
</Card>
|
|
496
|
+
|
|
497
|
+
// Pressable card
|
|
498
|
+
<Card variant="outlined" onPress={() => navigate('detail')}>
|
|
499
|
+
<CardContent>
|
|
500
|
+
<Text>Tap me</Text>
|
|
501
|
+
</CardContent>
|
|
502
|
+
</Card>
|
|
477
503
|
```
|
|
478
504
|
|
|
479
505
|
**Notes:**
|
|
@@ -481,6 +507,7 @@ All sub-components accept a `style` prop for overrides.
|
|
|
481
507
|
- `CardFooter` has `paddingTop: 0` so it connects naturally to `CardContent`
|
|
482
508
|
- `CardTitle`: 18px / 600 weight, `cardForeground` color
|
|
483
509
|
- `CardDescription`: 14px, `mutedForeground` color
|
|
510
|
+
- Press animation scales to 0.98 via `Animated.spring` when `onPress` is provided
|
|
484
511
|
|
|
485
512
|
---
|
|
486
513
|
|
|
@@ -638,7 +665,7 @@ const [accepted, setAccepted] = useState(false)
|
|
|
638
665
|
### Select
|
|
639
666
|
|
|
640
667
|
**Import:** `import { Select } from '@retray-dev/ui-kit'`
|
|
641
|
-
**When to use:** Dropdown picker.
|
|
668
|
+
**When to use:** Dropdown picker. Uses the native system picker UI on each platform — wheel modal on iOS (confirm with "Done"), spinner dialog on Android, native `<select>` on web (full keyboard support). Requires `@react-native-picker/picker` installed in the consuming app.
|
|
642
669
|
|
|
643
670
|
| Prop | Type | Default | Notes |
|
|
644
671
|
|------|------|---------|-------|
|
|
@@ -678,13 +705,27 @@ const [accepted, setAccepted] = useState(false)
|
|
|
678
705
|
| onValueChange | `(value: number) => void` | — | Fires while dragging |
|
|
679
706
|
| onSlidingComplete | `(value: number) => void` | — | Fires on finger release |
|
|
680
707
|
| disabled | `boolean` | — | — |
|
|
708
|
+
| label | `string` | — | Label text displayed above the slider |
|
|
709
|
+
| showValue | `boolean` | `false` | When `true`, displays the current value at the top right |
|
|
710
|
+
| formatValue | `(value: number) => string` | — | Custom formatter for the displayed value |
|
|
711
|
+
| accessibilityLabel | `string` | — | Accessibility label for screen readers |
|
|
681
712
|
| style | `ViewStyle` | — | — |
|
|
682
713
|
|
|
683
|
-
**
|
|
714
|
+
**Notes:** Uses `@react-native-community/slider` natively — theming applied via `minimumTrackTintColor` (primary), `maximumTrackTintColor` (muted), `thumbTintColor` (primary). Requires `@react-native-community/slider` installed in the consuming app.
|
|
684
715
|
|
|
685
716
|
**Example:**
|
|
686
717
|
```tsx
|
|
687
718
|
<Slider value={volume} minimumValue={0} maximumValue={100} step={1} onValueChange={setVolume} />
|
|
719
|
+
<Slider
|
|
720
|
+
label="Volume"
|
|
721
|
+
showValue
|
|
722
|
+
value={volume}
|
|
723
|
+
minimumValue={0}
|
|
724
|
+
maximumValue={100}
|
|
725
|
+
step={5}
|
|
726
|
+
formatValue={(v) => `${v}%`}
|
|
727
|
+
onValueChange={setVolume}
|
|
728
|
+
/>
|
|
688
729
|
```
|
|
689
730
|
|
|
690
731
|
---
|
|
@@ -849,6 +890,7 @@ function MyComponent() {
|
|
|
849
890
|
**Notes:**
|
|
850
891
|
- Max 3 toasts shown simultaneously (oldest is removed when a 4th arrives)
|
|
851
892
|
- Toasts appear at the top of the screen, below the status bar (dynamic safe area inset)
|
|
893
|
+
- **On web:** constrained to 400px wide and centered (`alignSelf: 'center'`) — not full-width
|
|
852
894
|
- Entrance: `withTiming(120ms, Easing.out(Easing.exp))` slide-down + opacity fade — fast, sharp feel
|
|
853
895
|
- Exit: `withTiming(200ms)` slide-up + opacity fade
|
|
854
896
|
- Swipe left or right to dismiss early (threshold: 80px or 800 pt/s velocity)
|
|
@@ -858,32 +900,81 @@ function MyComponent() {
|
|
|
858
900
|
### ListItem
|
|
859
901
|
|
|
860
902
|
**Import:** `import { ListItem } from '@retray-dev/ui-kit'`
|
|
861
|
-
**When to use:** Rows in a list or menu. Composes icon,
|
|
903
|
+
**When to use:** Rows in a list, feed, or menu. Composes a left slot (avatar, icon, image), title/subtitle/caption text block, and a right slot (price, badge, chevron, switch, etc.) in a standard horizontal layout. Supports both plain and card visual variants.
|
|
862
904
|
|
|
863
905
|
| Prop | Type | Default | Notes |
|
|
864
906
|
|------|------|---------|-------|
|
|
865
|
-
| title | `string` | required | Primary
|
|
866
|
-
| subtitle | `string` | — | Secondary
|
|
867
|
-
|
|
|
868
|
-
|
|
|
869
|
-
|
|
|
907
|
+
| title | `string` | required | Primary text (17px / 500 weight) |
|
|
908
|
+
| subtitle | `string` | — | Secondary line below the title (14px / 400 weight) |
|
|
909
|
+
| caption | `string` | — | Tertiary / caption line below the subtitle (12px / 400 weight, 70% opacity) |
|
|
910
|
+
| leftRender | `ReactNode` | — | Arbitrary content in a fixed 44×44pt left slot (avatar, icon, image, etc.) |
|
|
911
|
+
| rightRender | `string \| ReactNode` | — | Content on the right edge. Strings are styled as muted text (15px); pass ReactNode for Badges, prices, switches, etc. |
|
|
912
|
+
| variant | `'plain' \| 'card'` | `'plain'` | `plain`: no background, sits inside a parent surface. `card`: standalone surface with background, border, and shadow |
|
|
913
|
+
| showChevron | `boolean` | `false` | Shows a `›` chevron on the far right. Ignored when `rightRender` is set |
|
|
914
|
+
| showSeparator | `boolean` | `false` | Renders a hairline separator at the bottom. Useful when stacking multiple plain items in a list |
|
|
915
|
+
| onPress | `() => void` | — | Makes the row pressable (scale spring + haptics). No animation or haptics when omitted |
|
|
870
916
|
| disabled | `boolean` | — | Reduces opacity to 0.45 |
|
|
871
|
-
| style | `ViewStyle` | — |
|
|
917
|
+
| style | `ViewStyle` | — | Style applied to the outer container |
|
|
918
|
+
| titleStyle | `TextStyle` | — | Style override for the title text |
|
|
919
|
+
| subtitleStyle | `TextStyle` | — | Style override for the subtitle text |
|
|
920
|
+
| captionStyle | `TextStyle` | — | Style override for the caption text |
|
|
921
|
+
| icon | `ReactNode` | — | **Deprecated** — use `leftRender` |
|
|
922
|
+
| trailing | `string \| ReactNode` | — | **Deprecated** — use `rightRender` |
|
|
923
|
+
|
|
924
|
+
**Animation:** Scale springs to 0.97 on press-in, back to 1.0 on press-out (only when `onPress` is provided).
|
|
872
925
|
|
|
873
926
|
**Example:**
|
|
874
927
|
```tsx
|
|
928
|
+
// Simple row with chevron
|
|
875
929
|
<ListItem
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
onPress={() => navigate('detail')}
|
|
930
|
+
title="Profile"
|
|
931
|
+
subtitle="Manage your account"
|
|
932
|
+
showChevron
|
|
933
|
+
onPress={() => navigate('profile')}
|
|
881
934
|
/>
|
|
882
935
|
|
|
883
|
-
//
|
|
884
|
-
<ListItem
|
|
936
|
+
// Rich row: avatar + title/subtitle/caption + price + badge
|
|
937
|
+
<ListItem
|
|
938
|
+
leftRender={<Avatar src={item.avatar} fallback={item.initials} size="md" />}
|
|
939
|
+
title={item.name}
|
|
940
|
+
subtitle={item.date}
|
|
941
|
+
caption={item.category}
|
|
942
|
+
rightRender={
|
|
943
|
+
<View style={{ alignItems: 'flex-end', gap: 4 }}>
|
|
944
|
+
<Text variant="label">${item.amount}</Text>
|
|
945
|
+
<Badge label={item.status} variant="secondary" size="sm" />
|
|
946
|
+
</View>
|
|
947
|
+
}
|
|
948
|
+
onPress={() => navigate('detail', { id: item.id })}
|
|
949
|
+
/>
|
|
950
|
+
|
|
951
|
+
// Card variant (standalone surface)
|
|
952
|
+
<ListItem
|
|
953
|
+
variant="card"
|
|
954
|
+
leftRender={<Ionicons name="wallet-outline" size={20} />}
|
|
955
|
+
title="Balance"
|
|
956
|
+
subtitle="Available funds"
|
|
957
|
+
rightRender="$12.500"
|
|
958
|
+
/>
|
|
959
|
+
|
|
960
|
+
// List with separators
|
|
961
|
+
{transactions.map((t, i) => (
|
|
962
|
+
<ListItem
|
|
963
|
+
key={t.id}
|
|
964
|
+
title={t.name}
|
|
965
|
+
subtitle={t.date}
|
|
966
|
+
rightRender={t.amount}
|
|
967
|
+
showSeparator={i < transactions.length - 1}
|
|
968
|
+
onPress={() => navigate('detail', { id: t.id })}
|
|
969
|
+
/>
|
|
970
|
+
))}
|
|
885
971
|
```
|
|
886
972
|
|
|
973
|
+
**Notes:**
|
|
974
|
+
- `leftRender` renders inside a fixed 44×44pt container (centered) — no need to wrap in a sized View
|
|
975
|
+
- `rightRender` container has `maxWidth: 160` and aligns content to the right edge
|
|
976
|
+
- The separator inset aligns to the text block: `marginLeft: 16 + 44 + 12` when `leftRender` is set, `marginLeft: 16` otherwise
|
|
977
|
+
|
|
887
978
|
---
|
|
888
979
|
|
|
889
980
|
### Chip / ChipGroup
|
|
@@ -905,14 +996,16 @@ function MyComponent() {
|
|
|
905
996
|
| Prop | Type | Default | Notes |
|
|
906
997
|
|------|------|---------|-------|
|
|
907
998
|
| options | `ChipOption[]` | required | Each: `{ label: string, value: string \| number }` |
|
|
908
|
-
| value | `string \| number` | — | Currently selected value |
|
|
909
|
-
| onValueChange | `(value: string \| number) => void` | — | — |
|
|
999
|
+
| value | `string \| number \| (string \| number)[]` | — | Currently selected value (single mode) or array of selected values (multi mode) |
|
|
1000
|
+
| onValueChange | `(value: string \| number \| (string \| number)[]) => void` | — | — |
|
|
1001
|
+
| multiSelect | `boolean` | `false` | When `true`, allows multiple chips to be selected simultaneously |
|
|
910
1002
|
| style | `ViewStyle` | — | Applied to the wrapping row |
|
|
911
1003
|
|
|
912
1004
|
**Animation:** Background, text, and border colors animate via `Animated.timing` (150ms) between unselected (`secondary`/`border`/`foreground`) and selected (`primary`/`primary`/`primaryForeground`) states.
|
|
913
1005
|
|
|
914
1006
|
**Example:**
|
|
915
1007
|
```tsx
|
|
1008
|
+
// Single select
|
|
916
1009
|
const [pct, setPct] = useState(50)
|
|
917
1010
|
|
|
918
1011
|
<ChipGroup
|
|
@@ -924,6 +1017,20 @@ const [pct, setPct] = useState(50)
|
|
|
924
1017
|
value={pct}
|
|
925
1018
|
onValueChange={setPct}
|
|
926
1019
|
/>
|
|
1020
|
+
|
|
1021
|
+
// Multi select
|
|
1022
|
+
const [categories, setCategories] = useState<number[]>([1, 3])
|
|
1023
|
+
|
|
1024
|
+
<ChipGroup
|
|
1025
|
+
multiSelect
|
|
1026
|
+
options={[
|
|
1027
|
+
{ label: 'Food', value: 1 },
|
|
1028
|
+
{ label: 'Transport', value: 2 },
|
|
1029
|
+
{ label: 'Entertainment', value: 3 },
|
|
1030
|
+
]}
|
|
1031
|
+
value={categories}
|
|
1032
|
+
onValueChange={setCategories}
|
|
1033
|
+
/>
|
|
927
1034
|
```
|
|
928
1035
|
|
|
929
1036
|
---
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TouchableOpacityProps, TextProps as TextProps$1, TextInputProps,
|
|
2
|
+
import { TouchableOpacityProps, TextProps as TextProps$1, TextInputProps, TextStyle, ViewStyle, ActivityIndicatorProps } from 'react-native';
|
|
3
3
|
export { BottomSheetModalProvider } from '@gorhom/bottom-sheet';
|
|
4
4
|
|
|
5
5
|
type ThemeColors = {
|
|
@@ -36,11 +36,10 @@ type ThemeContextValue = {
|
|
|
36
36
|
interface ThemeProviderProps {
|
|
37
37
|
children: React.ReactNode;
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* dark: { primary: '#818cf8', primaryForeground: '#fff' } }
|
|
39
|
+
* Optional full-palette overrides per scheme. Supply a partial or full `ThemeColors` object
|
|
40
|
+
* for `light` and/or `dark` to override the defaults.
|
|
41
|
+
* @example
|
|
42
|
+
* { light: { primary: '#6366f1', card: '#fff' }, dark: { primary: '#818cf8' } }
|
|
44
43
|
*/
|
|
45
44
|
theme?: Theme;
|
|
46
45
|
/**
|
|
@@ -94,21 +93,42 @@ interface InputProps extends TextInputProps {
|
|
|
94
93
|
error?: string;
|
|
95
94
|
/** Helper text shown below the input when there is no error. */
|
|
96
95
|
hint?: string;
|
|
97
|
-
/**
|
|
96
|
+
/** Text or component rendered before the input text. */
|
|
97
|
+
prefix?: React.ReactNode;
|
|
98
|
+
/** Text or component rendered after the input text. */
|
|
99
|
+
suffix?: React.ReactNode;
|
|
100
|
+
/** Style applied to prefix text if prefix is a string. */
|
|
101
|
+
prefixStyle?: TextStyle;
|
|
102
|
+
/** Style applied to suffix text if suffix is a string. */
|
|
103
|
+
suffixStyle?: TextStyle;
|
|
104
|
+
/** Input type. When set to \`'password'\`, shows a toggle button to reveal/hide text. */
|
|
105
|
+
type?: 'text' | 'password';
|
|
106
|
+
/** Style for the outer container \`View\`. Use \`style\` (from \`TextInputProps\`) to style the \`TextInput\` itself. */
|
|
98
107
|
containerStyle?: ViewStyle;
|
|
99
108
|
}
|
|
100
|
-
declare function Input({ label, error, hint, containerStyle, style, onFocus, onBlur, ...props }: InputProps): React.JSX.Element;
|
|
109
|
+
declare function Input({ label, error, hint, prefix, suffix, prefixStyle, suffixStyle, type, containerStyle, style, onFocus, onBlur, secureTextEntry, ...props }: InputProps): React.JSX.Element;
|
|
101
110
|
|
|
102
111
|
type BadgeVariant = 'default' | 'secondary' | 'destructive' | 'outline';
|
|
112
|
+
type BadgeSize = 'sm' | 'md' | 'lg';
|
|
103
113
|
interface BadgeProps {
|
|
104
|
-
label
|
|
114
|
+
label?: string;
|
|
115
|
+
/** Alternative to \`label\` — allows JSX children. */
|
|
116
|
+
children?: React.ReactNode;
|
|
105
117
|
variant?: BadgeVariant;
|
|
118
|
+
size?: BadgeSize;
|
|
119
|
+
/** Icon rendered before the label/children. */
|
|
120
|
+
icon?: React.ReactNode;
|
|
106
121
|
style?: ViewStyle;
|
|
107
122
|
}
|
|
108
|
-
declare function Badge({ label, variant, style }: BadgeProps): React.JSX.Element;
|
|
123
|
+
declare function Badge({ label, children, variant, size, icon, style }: BadgeProps): React.JSX.Element;
|
|
109
124
|
|
|
125
|
+
type CardVariant = 'elevated' | 'outlined' | 'filled';
|
|
110
126
|
interface CardProps {
|
|
111
127
|
children: React.ReactNode;
|
|
128
|
+
/** Visual style variant. `'elevated'` (default) has shadow, `'outlined'` has border only, `'filled'` uses accent background. */
|
|
129
|
+
variant?: CardVariant;
|
|
130
|
+
/** Makes the card tappable. Adds press animation and haptic feedback. */
|
|
131
|
+
onPress?: () => void;
|
|
112
132
|
style?: ViewStyle;
|
|
113
133
|
}
|
|
114
134
|
interface CardHeaderProps {
|
|
@@ -131,7 +151,7 @@ interface CardFooterProps {
|
|
|
131
151
|
children: React.ReactNode;
|
|
132
152
|
style?: ViewStyle;
|
|
133
153
|
}
|
|
134
|
-
declare function Card({ children, style }: CardProps): React.JSX.Element;
|
|
154
|
+
declare function Card({ children, variant, onPress, style }: CardProps): React.JSX.Element;
|
|
135
155
|
declare function CardHeader({ children, style }: CardHeaderProps): React.JSX.Element;
|
|
136
156
|
declare function CardTitle({ children, style }: CardTitleProps): React.JSX.Element;
|
|
137
157
|
declare function CardDescription({ children, style }: CardDescriptionProps): React.JSX.Element;
|
|
@@ -303,20 +323,20 @@ interface AccordionProps {
|
|
|
303
323
|
declare function Accordion({ items, type, defaultValue, style }: AccordionProps): React.JSX.Element;
|
|
304
324
|
|
|
305
325
|
interface SliderProps {
|
|
306
|
-
/** Current value. Controlled when provided; falls back to internal state otherwise. */
|
|
307
326
|
value?: number;
|
|
308
327
|
minimumValue?: number;
|
|
309
328
|
maximumValue?: number;
|
|
310
|
-
/** Snap interval. `0` (default) means continuous (no snapping). */
|
|
311
329
|
step?: number;
|
|
312
|
-
/** Called on every move while dragging. */
|
|
313
330
|
onValueChange?: (value: number) => void;
|
|
314
|
-
/** Called once when the user releases the thumb. */
|
|
315
331
|
onSlidingComplete?: (value: number) => void;
|
|
332
|
+
label?: string;
|
|
333
|
+
showValue?: boolean;
|
|
334
|
+
formatValue?: (value: number) => string;
|
|
335
|
+
accessibilityLabel?: string;
|
|
316
336
|
disabled?: boolean;
|
|
317
337
|
style?: ViewStyle;
|
|
318
338
|
}
|
|
319
|
-
declare function Slider({ value, minimumValue, maximumValue, step, onValueChange, onSlidingComplete, disabled, style, }: SliderProps): React.JSX.Element;
|
|
339
|
+
declare function Slider({ value, minimumValue, maximumValue, step, onValueChange, onSlidingComplete, label, showValue, formatValue, accessibilityLabel, disabled, style, }: SliderProps): React.JSX.Element;
|
|
320
340
|
|
|
321
341
|
interface SheetProps {
|
|
322
342
|
open: boolean;
|
|
@@ -343,10 +363,8 @@ interface SelectProps {
|
|
|
343
363
|
options: SelectOption[];
|
|
344
364
|
value?: string;
|
|
345
365
|
onValueChange?: (value: string) => void;
|
|
346
|
-
/** Text shown when no option is selected. Defaults to `'Select an option'`. */
|
|
347
366
|
placeholder?: string;
|
|
348
367
|
label?: string;
|
|
349
|
-
/** Red helper text; also changes trigger border to `destructive` color. */
|
|
350
368
|
error?: string;
|
|
351
369
|
disabled?: boolean;
|
|
352
370
|
style?: ViewStyle;
|
|
@@ -387,6 +405,8 @@ interface CurrencyInputProps {
|
|
|
387
405
|
prefix?: string;
|
|
388
406
|
/** Character used to separate groups of three digits. Defaults to `'.'`. */
|
|
389
407
|
thousandsSeparator?: '.' | ',';
|
|
408
|
+
/** Font size variant. `'large'` renders at 36pt, `'default'` at 17pt. */
|
|
409
|
+
size?: 'default' | 'large';
|
|
390
410
|
label?: string;
|
|
391
411
|
/** Red helper text; also changes input border to destructive color. */
|
|
392
412
|
error?: string;
|
|
@@ -394,8 +414,9 @@ interface CurrencyInputProps {
|
|
|
394
414
|
placeholder?: string;
|
|
395
415
|
editable?: boolean;
|
|
396
416
|
containerStyle?: ViewStyle;
|
|
417
|
+
style?: TextStyle;
|
|
397
418
|
}
|
|
398
|
-
declare function CurrencyInput({ value, onChangeText, onChangeValue, prefix, thousandsSeparator, label, error, hint, placeholder, editable, containerStyle, }: CurrencyInputProps): React.JSX.Element;
|
|
419
|
+
declare function CurrencyInput({ value, onChangeText, onChangeValue, prefix, thousandsSeparator, size, label, error, hint, placeholder, editable, containerStyle, style, }: CurrencyInputProps): React.JSX.Element;
|
|
399
420
|
|
|
400
421
|
interface CurrencyDisplayProps {
|
|
401
422
|
value: number | string;
|
|
@@ -409,35 +430,48 @@ interface CurrencyDisplayProps {
|
|
|
409
430
|
}
|
|
410
431
|
declare function CurrencyDisplay({ value, prefix, showDecimals, textColor, style }: CurrencyDisplayProps): React.JSX.Element;
|
|
411
432
|
|
|
412
|
-
|
|
413
|
-
value?: string;
|
|
414
|
-
onChangeText?: (formatted: string) => void;
|
|
415
|
-
/** Called with the parsed numeric value (no separators, no prefix). */
|
|
416
|
-
onChangeValue?: (raw: number) => void;
|
|
417
|
-
/** Symbol prepended to the formatted value. Defaults to `'$'`. */
|
|
418
|
-
prefix?: string;
|
|
419
|
-
/** Character used to separate groups of three digits. Defaults to `'.'`. */
|
|
420
|
-
thousandsSeparator?: '.' | ',';
|
|
421
|
-
label?: string;
|
|
422
|
-
/** Red helper text; also changes input border to destructive color. */
|
|
423
|
-
error?: string;
|
|
424
|
-
hint?: string;
|
|
425
|
-
placeholder?: string;
|
|
426
|
-
editable?: boolean;
|
|
427
|
-
containerStyle?: ViewStyle;
|
|
428
|
-
}
|
|
429
|
-
declare function CurrencyInputLarge({ value, onChangeText, onChangeValue, prefix, thousandsSeparator, label, error, hint, placeholder, editable, containerStyle, }: CurrencyInputLargeProps): React.JSX.Element;
|
|
430
|
-
|
|
433
|
+
type ListItemVariant = 'plain' | 'card';
|
|
431
434
|
interface ListItemProps {
|
|
435
|
+
/**
|
|
436
|
+
* Arbitrary content rendered on the left (avatar, icon, image, etc.).
|
|
437
|
+
* Rendered inside a 44×44 aligned container.
|
|
438
|
+
*/
|
|
439
|
+
leftRender?: React.ReactNode;
|
|
440
|
+
/**
|
|
441
|
+
* Arbitrary content rendered on the right (badge, price, chevron, switch, etc.).
|
|
442
|
+
* Replaces the old `trailing` prop (still accepted as an alias).
|
|
443
|
+
*/
|
|
444
|
+
rightRender?: React.ReactNode | string;
|
|
445
|
+
/** @deprecated Use `rightRender` instead. */
|
|
446
|
+
trailing?: React.ReactNode | string;
|
|
447
|
+
/** @deprecated Use `leftRender` instead. */
|
|
432
448
|
icon?: React.ReactNode;
|
|
433
449
|
title: string;
|
|
450
|
+
/** Secondary line below the title. */
|
|
434
451
|
subtitle?: string;
|
|
435
|
-
|
|
452
|
+
/** Tertiary / caption line below the subtitle. */
|
|
453
|
+
caption?: string;
|
|
454
|
+
/**
|
|
455
|
+
* - `plain` (default): no background, no border — designed to sit inside a parent surface (Card, list wrapper, etc.)
|
|
456
|
+
* - `card`: standalone surface with background, border and shadow.
|
|
457
|
+
*/
|
|
458
|
+
variant?: ListItemVariant;
|
|
459
|
+
/** Show a right-pointing chevron on the far right. Ignored when `rightRender` / `trailing` is set. */
|
|
460
|
+
showChevron?: boolean;
|
|
461
|
+
/** Visual separator line at the bottom of the item. Useful when rendering multiple plain items in a list. */
|
|
462
|
+
showSeparator?: boolean;
|
|
436
463
|
onPress?: () => void;
|
|
437
464
|
disabled?: boolean;
|
|
465
|
+
/** Style applied to the outer container. */
|
|
438
466
|
style?: ViewStyle;
|
|
467
|
+
/** Style applied to the title Text. */
|
|
468
|
+
titleStyle?: TextStyle;
|
|
469
|
+
/** Style applied to the subtitle Text. */
|
|
470
|
+
subtitleStyle?: TextStyle;
|
|
471
|
+
/** Style applied to the caption Text. */
|
|
472
|
+
captionStyle?: TextStyle;
|
|
439
473
|
}
|
|
440
|
-
declare function ListItem({ icon, title, subtitle,
|
|
474
|
+
declare function ListItem({ leftRender, rightRender, trailing, icon, title, subtitle, caption, variant, showChevron, showSeparator, onPress, disabled, style, titleStyle, subtitleStyle, captionStyle, }: ListItemProps): React.JSX.Element;
|
|
441
475
|
|
|
442
476
|
interface ChipProps {
|
|
443
477
|
label: string;
|
|
@@ -451,12 +485,14 @@ interface ChipOption {
|
|
|
451
485
|
}
|
|
452
486
|
interface ChipGroupProps {
|
|
453
487
|
options: ChipOption[];
|
|
454
|
-
value?: string | number;
|
|
455
|
-
onValueChange?: (value: string | number) => void;
|
|
488
|
+
value?: string | number | (string | number)[];
|
|
489
|
+
onValueChange?: (value: string | number | (string | number)[]) => void;
|
|
490
|
+
/** When true, allows selecting multiple chips. `value` and `onValueChange` will use arrays. */
|
|
491
|
+
multiSelect?: boolean;
|
|
456
492
|
style?: ViewStyle;
|
|
457
493
|
}
|
|
458
494
|
declare function Chip({ label, selected, onPress, style }: ChipProps): React.JSX.Element;
|
|
459
|
-
declare function ChipGroup({ options, value, onValueChange, style }: ChipGroupProps): React.JSX.Element;
|
|
495
|
+
declare function ChipGroup({ options, value, onValueChange, multiSelect, style }: ChipGroupProps): React.JSX.Element;
|
|
460
496
|
|
|
461
497
|
interface ConfirmDialogProps {
|
|
462
498
|
visible: boolean;
|
|
@@ -489,4 +525,4 @@ interface MonthPickerProps {
|
|
|
489
525
|
}
|
|
490
526
|
declare function MonthPicker({ value, onChange, style }: MonthPickerProps): React.JSX.Element;
|
|
491
527
|
|
|
492
|
-
export { Accordion, type AccordionItem, type AccordionProps, AlertBanner, type AlertBannerProps, type AlertBannerVariant, Avatar, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeVariant, Button, type ButtonProps, type ButtonSize, type ButtonVariant, Card, CardContent, type CardContentProps, CardDescription, type CardDescriptionProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, type CardTitleProps, Checkbox, type CheckboxProps, Chip, ChipGroup, type ChipGroupProps, type ChipOption, type ChipProps, type ColorScheme, ConfirmDialog, type ConfirmDialogProps, CurrencyDisplay, type CurrencyDisplayProps, CurrencyInput,
|
|
528
|
+
export { Accordion, type AccordionItem, type AccordionProps, AlertBanner, type AlertBannerProps, type AlertBannerVariant, Avatar, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeVariant, Button, type ButtonProps, type ButtonSize, type ButtonVariant, Card, CardContent, type CardContentProps, CardDescription, type CardDescriptionProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, type CardTitleProps, Checkbox, type CheckboxProps, Chip, ChipGroup, type ChipGroupProps, type ChipOption, type ChipProps, type ColorScheme, ConfirmDialog, type ConfirmDialogProps, CurrencyDisplay, type CurrencyDisplayProps, CurrencyInput, CurrencyInput as CurrencyInputLarge, type CurrencyInputProps, EmptyState, type EmptyStateProps, Input, type InputProps, LabelValue, type LabelValueProps, ListItem, type ListItemProps, MonthPicker, type MonthPickerProps, type MonthPickerValue, Progress, type ProgressProps, RadioGroup, type RadioGroupProps, type RadioOption, Select, type SelectOption, type SelectProps, Separator, type SeparatorProps, Sheet, type SheetProps, Skeleton, type SkeletonProps, Slider, type SliderProps, Spinner, type SpinnerProps, type SpinnerSize, Switch, type SwitchProps, type TabItem, Tabs, TabsContent, type TabsContentProps, type TabsProps, Text, type TextProps, type TextVariant, Textarea, type TextareaProps, type Theme, type ThemeColors, ThemeProvider, type ThemeProviderProps, type ToastItem, ToastProvider, type ToastProviderProps, type ToastVariant, Toggle, type ToggleProps, type ToggleSize, type ToggleVariant, defaultDark, defaultLight, useTheme, useToast };
|