@campxdev/react-native-blueprint 0.1.14 → 0.1.16
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/global.css +672 -0
- package/lib/module/assets/Loading Animation.json +1 -0
- package/lib/module/assets/Success-Tick.json +1 -0
- package/lib/module/assets/lotties/index.js +3 -1
- package/lib/module/assets/lotties/index.js.map +1 -1
- package/lib/module/components/DataDisplay/Accordion/Accordion.js +1 -0
- package/lib/module/components/DataDisplay/Accordion/Accordion.js.map +1 -1
- package/lib/module/components/DataDisplay/AccordionItem/AccordionItem.js +1 -0
- package/lib/module/components/DataDisplay/AccordionItem/AccordionItem.js.map +1 -1
- package/lib/module/components/DataDisplay/Badge/Badge.figma.js +1 -0
- package/lib/module/components/DataDisplay/Badge/Badge.figma.js.map +1 -1
- package/lib/module/components/DataDisplay/Badge/Badge.js +1 -0
- package/lib/module/components/DataDisplay/Badge/Badge.js.map +1 -1
- package/lib/module/components/DataDisplay/Banner/Banner.figma.js +25 -0
- package/lib/module/components/DataDisplay/Banner/Banner.figma.js.map +1 -0
- package/lib/module/components/DataDisplay/Banner/Banner.js +101 -0
- package/lib/module/components/DataDisplay/Banner/Banner.js.map +1 -0
- package/lib/module/components/DataDisplay/BannerRow/BannerRow.js +1 -0
- package/lib/module/components/DataDisplay/BannerRow/BannerRow.js.map +1 -1
- package/lib/module/components/DataDisplay/CalendarItem/CalendarItem.js +1 -0
- package/lib/module/components/DataDisplay/CalendarItem/CalendarItem.js.map +1 -1
- package/lib/module/components/DataDisplay/Card/Card.js +1 -0
- package/lib/module/components/DataDisplay/Card/Card.js.map +1 -1
- package/lib/module/components/DataDisplay/Chips/Chips.js +1 -0
- package/lib/module/components/DataDisplay/Chips/Chips.js.map +1 -1
- package/lib/module/components/DataDisplay/ChipsRow/ChipsRow.js +1 -0
- package/lib/module/components/DataDisplay/ChipsRow/ChipsRow.js.map +1 -1
- package/lib/module/components/DataDisplay/DataListItem/DataListItem.js +1 -0
- package/lib/module/components/DataDisplay/DataListItem/DataListItem.js.map +1 -1
- package/lib/module/components/DataDisplay/Datalist/Datalist.js +1 -0
- package/lib/module/components/DataDisplay/Datalist/Datalist.js.map +1 -1
- package/lib/module/components/DataDisplay/Greeting/Greeting.figma.js +15 -0
- package/lib/module/components/DataDisplay/Greeting/Greeting.figma.js.map +1 -0
- package/lib/module/components/DataDisplay/Greeting/Greeting.js +121 -0
- package/lib/module/components/DataDisplay/Greeting/Greeting.js.map +1 -0
- package/lib/module/components/DataDisplay/MonthCalendar/MonthCalendar.figma.js +5 -7
- package/lib/module/components/DataDisplay/MonthCalendar/MonthCalendar.figma.js.map +1 -1
- package/lib/module/components/DataDisplay/Separator/Separator.js +1 -0
- package/lib/module/components/DataDisplay/Separator/Separator.js.map +1 -1
- package/lib/module/components/DataDisplay/Skeleton/Skeleton.js +1 -0
- package/lib/module/components/DataDisplay/Skeleton/Skeleton.js.map +1 -1
- package/lib/module/components/DataDisplay/Tooltip/Tooltip.figma.js +1 -0
- package/lib/module/components/DataDisplay/Tooltip/Tooltip.figma.js.map +1 -1
- package/lib/module/components/DataDisplay/Tooltip/Tooltip.js +1 -0
- package/lib/module/components/DataDisplay/Tooltip/Tooltip.js.map +1 -1
- package/lib/module/components/Feedback/InfoBar/InfoBar.figma.js +32 -0
- package/lib/module/components/Feedback/InfoBar/InfoBar.figma.js.map +1 -0
- package/lib/module/components/Feedback/InfoBar/InfoBar.js +107 -0
- package/lib/module/components/Feedback/InfoBar/InfoBar.js.map +1 -0
- package/lib/module/components/Feedback/ProgressCircular/Progress-circular.js +1 -0
- package/lib/module/components/Feedback/ProgressCircular/Progress-circular.js.map +1 -1
- package/lib/module/components/Feedback/ProgressLinear/Progress-linear.js +1 -0
- package/lib/module/components/Feedback/ProgressLinear/Progress-linear.js.map +1 -1
- package/lib/module/components/Input/Button/Button.js +99 -43
- package/lib/module/components/Input/Button/Button.js.map +1 -1
- package/lib/module/components/Input/Checkbox/Checkbox.js +1 -0
- package/lib/module/components/Input/Checkbox/Checkbox.js.map +1 -1
- package/lib/module/components/Input/RadioGroup/Radio-Group.figma.js +3 -3
- package/lib/module/components/Input/RadioGroup/Radio-Group.figma.js.map +1 -1
- package/lib/module/components/Input/RadioGroup/Radio-Group.js +1 -0
- package/lib/module/components/Input/RadioGroup/Radio-Group.js.map +1 -1
- package/lib/module/components/Input/Select/Select.js +1 -0
- package/lib/module/components/Input/Select/Select.js.map +1 -1
- package/lib/module/components/Input/TextField/Textfield.figma.js +4 -2
- package/lib/module/components/Input/TextField/Textfield.figma.js.map +1 -1
- package/lib/module/components/Input/TextField/Textfield.js +219 -43
- package/lib/module/components/Input/TextField/Textfield.js.map +1 -1
- package/lib/module/components/Input/Toggle/Toggle.figma.js +32 -0
- package/lib/module/components/Input/Toggle/Toggle.figma.js.map +1 -0
- package/lib/module/components/Input/Toggle/Toggle.js +52 -23
- package/lib/module/components/Input/Toggle/Toggle.js.map +1 -1
- package/lib/module/components/Input/ToggleGroup/Toggle-Group.js +1 -0
- package/lib/module/components/Input/ToggleGroup/Toggle-Group.js.map +1 -1
- package/lib/module/components/Input/switch/Switch.figma.js +1 -0
- package/lib/module/components/Input/switch/Switch.figma.js.map +1 -1
- package/lib/module/components/Input/switch/Switch.js +1 -0
- package/lib/module/components/Input/switch/Switch.js.map +1 -1
- package/lib/module/components/Layout/Tabs/Tabs.figma.js +1 -0
- package/lib/module/components/Layout/Tabs/Tabs.figma.js.map +1 -1
- package/lib/module/components/Layout/Tabs/Tabs.js +1 -0
- package/lib/module/components/Layout/Tabs/Tabs.js.map +1 -1
- package/lib/module/components/Navigation/Appbar/AppBar.figma.js +1 -0
- package/lib/module/components/Navigation/Appbar/AppBar.figma.js.map +1 -1
- package/lib/module/components/Navigation/FloatingAction/Floating-Action.js +1 -0
- package/lib/module/components/Navigation/FloatingAction/Floating-Action.js.map +1 -1
- package/lib/module/components/Navigation/Popover/Popover.figma.js +1 -0
- package/lib/module/components/Navigation/Popover/Popover.figma.js.map +1 -1
- package/lib/module/components/Navigation/Popover/Popover.js +1 -0
- package/lib/module/components/Navigation/Popover/Popover.js.map +1 -1
- package/lib/module/components/ui/Custom-Card.js +1 -0
- package/lib/module/components/ui/Custom-Card.js.map +1 -1
- package/lib/module/components/ui/Dropdown-Menu.js +1 -0
- package/lib/module/components/ui/Dropdown-Menu.js.map +1 -1
- package/lib/module/components/ui/Hover-Card.js +1 -0
- package/lib/module/components/ui/Hover-Card.js.map +1 -1
- package/lib/module/components/ui/Icon.js +1 -0
- package/lib/module/components/ui/Icon.js.map +1 -1
- package/lib/module/components/ui/Input.js +1 -0
- package/lib/module/components/ui/Input.js.map +1 -1
- package/lib/module/components/ui/Menubar.js +1 -0
- package/lib/module/components/ui/Menubar.js.map +1 -1
- package/lib/module/components/ui/Slider.js +1 -0
- package/lib/module/components/ui/Slider.js.map +1 -1
- package/lib/module/components/ui/Table.js +1 -0
- package/lib/module/components/ui/Table.js.map +1 -1
- package/lib/module/components/ui/Toast.js +1 -0
- package/lib/module/components/ui/Toast.js.map +1 -1
- package/lib/module/components/ui/index.js +4 -1
- package/lib/module/components/ui/index.js.map +1 -1
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/patterns/pattern-components/AlertDialogPattern/AlertDialogPattern.js +1 -0
- package/lib/module/patterns/pattern-components/AlertDialogPattern/AlertDialogPattern.js.map +1 -1
- package/lib/module/patterns/pattern-components/AlertPattern/AlertPattern.js +1 -0
- package/lib/module/patterns/pattern-components/AlertPattern/AlertPattern.js.map +1 -1
- package/lib/module/patterns/pattern-components/BottomSheetPattern/index.js +4 -0
- package/lib/module/patterns/pattern-components/BottomSheetPattern/index.js.map +1 -0
- package/lib/module/patterns/pattern-components/CalendarPattern/CalendarPattern.figma.js +1 -0
- package/lib/module/patterns/pattern-components/CalendarPattern/CalendarPattern.figma.js.map +1 -1
- package/lib/module/patterns/pattern-components/CalendarPattern/CalendarPattern.js +1 -0
- package/lib/module/patterns/pattern-components/CalendarPattern/CalendarPattern.js.map +1 -1
- package/lib/module/patterns/pattern-components/CalendarPattern/index.js +4 -0
- package/lib/module/patterns/pattern-components/CalendarPattern/index.js.map +1 -0
- package/lib/module/patterns/pattern-components/DashboardPattern/index.js +4 -0
- package/lib/module/patterns/pattern-components/DashboardPattern/index.js.map +1 -0
- package/lib/module/patterns/pattern-components/EmptyState/EmptyState.js +1 -0
- package/lib/module/patterns/pattern-components/EmptyState/EmptyState.js.map +1 -1
- package/lib/module/patterns/pattern-components/EntityPatternGuided/EntityPatternGuided.js +1 -0
- package/lib/module/patterns/pattern-components/EntityPatternGuided/EntityPatternGuided.js.map +1 -1
- package/lib/module/patterns/pattern-components/EntityPatternGuided/index.js +4 -0
- package/lib/module/patterns/pattern-components/EntityPatternGuided/index.js.map +1 -0
- package/lib/module/patterns/pattern-components/EntityPatternOverview/EntityPatternOverview.js +1 -0
- package/lib/module/patterns/pattern-components/EntityPatternOverview/EntityPatternOverview.js.map +1 -1
- package/lib/module/patterns/pattern-components/EntityPatternStructured/EntityPatternStructured.js +1 -0
- package/lib/module/patterns/pattern-components/EntityPatternStructured/EntityPatternStructured.js.map +1 -1
- package/lib/module/patterns/pattern-components/FormPattern/FormPattern.js +1 -0
- package/lib/module/patterns/pattern-components/FormPattern/FormPattern.js.map +1 -1
- package/lib/module/patterns/pattern-components/SuccessPattern/SuccessPattern.figma.js +38 -0
- package/lib/module/patterns/pattern-components/SuccessPattern/SuccessPattern.figma.js.map +1 -0
- package/lib/module/patterns/pattern-components/SuccessPattern/SuccessPattern.js +91 -0
- package/lib/module/patterns/pattern-components/SuccessPattern/SuccessPattern.js.map +1 -0
- package/lib/module/patterns/pattern-components/SuccessPattern/index.js +4 -0
- package/lib/module/patterns/pattern-components/SuccessPattern/index.js.map +1 -0
- package/lib/module/patterns/pattern-components/index.js +5 -3
- package/lib/module/patterns/pattern-components/index.js.map +1 -1
- package/package.json +4 -3
- package/src/assets/Loading Animation.json +1 -0
- package/src/assets/Success-Tick.json +1 -0
- package/src/assets/lotties/index.ts +2 -0
- package/src/components/DataDisplay/Accordion/Accordion.tsx +1 -0
- package/src/components/DataDisplay/AccordionItem/AccordionItem.tsx +1 -0
- package/src/components/DataDisplay/Badge/Badge.figma.tsx +1 -0
- package/src/components/DataDisplay/Badge/Badge.tsx +1 -0
- package/src/components/DataDisplay/Banner/Banner.figma.tsx +26 -0
- package/src/components/DataDisplay/Banner/Banner.tsx +108 -0
- package/src/components/DataDisplay/BannerRow/BannerRow.tsx +1 -0
- package/src/components/DataDisplay/CalendarItem/CalendarItem.tsx +1 -0
- package/src/components/DataDisplay/Card/Card.tsx +1 -0
- package/src/components/DataDisplay/Chips/Chips.tsx +1 -0
- package/src/components/DataDisplay/ChipsRow/ChipsRow.tsx +1 -0
- package/src/components/DataDisplay/DataListItem/DataListItem.tsx +1 -0
- package/src/components/DataDisplay/Datalist/Datalist.tsx +1 -0
- package/src/components/DataDisplay/Greeting/Greeting.figma.tsx +12 -0
- package/src/components/DataDisplay/Greeting/Greeting.tsx +154 -0
- package/src/components/DataDisplay/MonthCalendar/MonthCalendar.figma.tsx +7 -11
- package/src/components/DataDisplay/Separator/Separator.tsx +1 -0
- package/src/components/DataDisplay/Skeleton/Skeleton.tsx +1 -0
- package/src/components/DataDisplay/Tooltip/Tooltip.figma.tsx +1 -0
- package/src/components/DataDisplay/Tooltip/Tooltip.tsx +1 -0
- package/src/components/Feedback/InfoBar/InfoBar.figma.tsx +31 -0
- package/src/components/Feedback/InfoBar/InfoBar.tsx +127 -0
- package/src/components/Feedback/ProgressCircular/Progress-circular.tsx +1 -0
- package/src/components/Feedback/ProgressLinear/Progress-linear.tsx +1 -0
- package/src/components/Input/Button/Button.tsx +110 -43
- package/src/components/Input/Checkbox/Checkbox.tsx +1 -0
- package/src/components/Input/RadioGroup/Radio-Group.figma.tsx +3 -3
- package/src/components/Input/RadioGroup/Radio-Group.tsx +1 -0
- package/src/components/Input/Select/Select.tsx +1 -0
- package/src/components/Input/TextField/Textfield.figma.tsx +2 -0
- package/src/components/Input/TextField/Textfield.tsx +280 -48
- package/src/components/Input/Toggle/Toggle.figma.tsx +37 -0
- package/src/components/Input/Toggle/Toggle.tsx +49 -22
- package/src/components/Input/ToggleGroup/Toggle-Group.tsx +1 -0
- package/src/components/Input/switch/Switch.figma.tsx +1 -0
- package/src/components/Input/switch/Switch.tsx +1 -0
- package/src/components/Layout/Tabs/Tabs.figma.tsx +1 -0
- package/src/components/Layout/Tabs/Tabs.tsx +1 -0
- package/src/components/Navigation/Appbar/AppBar.figma.tsx +1 -0
- package/src/components/Navigation/FloatingAction/Floating-Action.tsx +1 -0
- package/src/components/Navigation/Popover/Popover.figma.tsx +1 -0
- package/src/components/Navigation/Popover/Popover.tsx +1 -0
- package/src/components/ui/Custom-Card.tsx +1 -0
- package/src/components/ui/Dropdown-Menu.tsx +1 -0
- package/src/components/ui/Hover-Card.tsx +1 -0
- package/src/components/ui/Icon.tsx +1 -0
- package/src/components/ui/Input.tsx +1 -0
- package/src/components/ui/Menubar.tsx +1 -0
- package/src/components/ui/Slider.tsx +1 -0
- package/src/components/ui/Table.tsx +1 -0
- package/src/components/ui/Toast.tsx +1 -0
- package/src/components/ui/index.ts +5 -1
- package/src/index.tsx +3 -0
- package/src/patterns/pattern-components/AlertDialogPattern/AlertDialogPattern.tsx +1 -0
- package/src/patterns/pattern-components/AlertPattern/AlertPattern.tsx +1 -0
- package/src/patterns/pattern-components/BottomSheetPattern/index.ts +1 -0
- package/src/patterns/pattern-components/CalendarPattern/CalendarPattern.figma.tsx +1 -0
- package/src/patterns/pattern-components/CalendarPattern/CalendarPattern.tsx +1 -0
- package/src/patterns/pattern-components/CalendarPattern/index.ts +1 -0
- package/src/patterns/pattern-components/DashboardPattern/index.ts +1 -0
- package/src/patterns/pattern-components/EmptyState/EmptyState.tsx +1 -0
- package/src/patterns/pattern-components/EntityPatternGuided/EntityPatternGuided.tsx +1 -0
- package/src/patterns/pattern-components/EntityPatternGuided/index.ts +1 -0
- package/src/patterns/pattern-components/EntityPatternOverview/EntityPatternOverview.tsx +1 -0
- package/src/patterns/pattern-components/EntityPatternStructured/EntityPatternStructured.tsx +1 -0
- package/src/patterns/pattern-components/FormPattern/FormPattern.tsx +1 -0
- package/src/patterns/pattern-components/SuccessPattern/SuccessPattern.figma.tsx +38 -0
- package/src/patterns/pattern-components/SuccessPattern/SuccessPattern.tsx +119 -0
- package/src/patterns/pattern-components/SuccessPattern/index.ts +2 -0
- package/src/patterns/pattern-components/index.ts +3 -1
- package/lib/module/components/ui/Greeting-Card.js +0 -392
- package/lib/module/components/ui/Greeting-Card.js.map +0 -1
- package/src/components/ui/Greeting-Card.tsx +0 -471
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import {
|
|
3
4
|
Pressable,
|
|
4
5
|
View,
|
|
5
6
|
Text as RNText,
|
|
7
|
+
type GestureResponderEvent,
|
|
6
8
|
type StyleProp,
|
|
7
9
|
type ViewStyle,
|
|
8
10
|
type PressableProps,
|
|
9
11
|
} from 'react-native';
|
|
10
12
|
import { cssInterop } from 'nativewind';
|
|
13
|
+
import { SquircleView } from 'react-native-figma-squircle';
|
|
11
14
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
12
15
|
|
|
13
16
|
import { cn } from '../../../lib/utils';
|
|
17
|
+
import { useThemeColors } from '../../../lib/theme';
|
|
14
18
|
|
|
15
19
|
// NativeWind interop (className -> style)
|
|
16
20
|
cssInterop(Pressable, { className: 'style' });
|
|
@@ -30,19 +34,66 @@ export const ButtonVariants = {
|
|
|
30
34
|
* ✅ No inline styles (satisfies react-native/no-inline-styles)
|
|
31
35
|
*/
|
|
32
36
|
function DummyIcon({ testID }: { testID?: string }) {
|
|
33
|
-
return <View testID={testID} className="w-4 h-4 rounded bg-
|
|
37
|
+
return <View testID={testID} className="w-4 h-4 rounded bg-text-inverse" />;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Returns squircle fill & stroke colors per variant from THEME tokens
|
|
42
|
+
*/
|
|
43
|
+
function useVariantSquircleParams(variant: string) {
|
|
44
|
+
const colors = useThemeColors();
|
|
45
|
+
|
|
46
|
+
const map: Record<
|
|
47
|
+
string,
|
|
48
|
+
{ fillColor: string; strokeColor: string; strokeWidth: number }
|
|
49
|
+
> = {
|
|
50
|
+
default: {
|
|
51
|
+
fillColor: colors.brandPrimary,
|
|
52
|
+
strokeColor: 'transparent',
|
|
53
|
+
strokeWidth: 0,
|
|
54
|
+
},
|
|
55
|
+
secondary: {
|
|
56
|
+
fillColor: colors.brandSecondary,
|
|
57
|
+
strokeColor: colors.brandPrimary,
|
|
58
|
+
strokeWidth: 1,
|
|
59
|
+
},
|
|
60
|
+
outline: {
|
|
61
|
+
fillColor: 'transparent',
|
|
62
|
+
strokeColor: colors.border,
|
|
63
|
+
strokeWidth: 1,
|
|
64
|
+
},
|
|
65
|
+
ghost: {
|
|
66
|
+
fillColor: 'transparent',
|
|
67
|
+
strokeColor: 'transparent',
|
|
68
|
+
strokeWidth: 0,
|
|
69
|
+
},
|
|
70
|
+
destructive: {
|
|
71
|
+
fillColor: colors.destructive,
|
|
72
|
+
strokeColor: 'transparent',
|
|
73
|
+
strokeWidth: 0,
|
|
74
|
+
},
|
|
75
|
+
link: {
|
|
76
|
+
fillColor: 'transparent',
|
|
77
|
+
strokeColor: 'transparent',
|
|
78
|
+
strokeWidth: 0,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return map[variant] ?? map.default;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const CORNER_RADIUS = 8; // radius-lg
|
|
86
|
+
const CORNER_SMOOTHING = 1; // maximum smoothing
|
|
87
|
+
|
|
88
|
+
const buttonVariants = cva('flex-row items-center justify-center', {
|
|
37
89
|
variants: {
|
|
38
90
|
variant: {
|
|
39
|
-
default: '
|
|
40
|
-
secondary:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
link: 'bg-transparent',
|
|
91
|
+
default: 'gap-2 active:opacity-90',
|
|
92
|
+
secondary: 'active:opacity-90',
|
|
93
|
+
outline: 'active:opacity-90',
|
|
94
|
+
ghost: 'active:opacity-90',
|
|
95
|
+
destructive: 'active:opacity-90',
|
|
96
|
+
link: '',
|
|
46
97
|
},
|
|
47
98
|
size: {
|
|
48
99
|
// ✅ Figma-like sizing
|
|
@@ -77,7 +128,7 @@ const buttonVariants = cva('flex-row items-center justify-center rounded-md', {
|
|
|
77
128
|
const buttonTextVariants = cva('font-semibold', {
|
|
78
129
|
variants: {
|
|
79
130
|
variant: {
|
|
80
|
-
default: 'text-
|
|
131
|
+
default: 'text-text-inverse',
|
|
81
132
|
secondary: 'text-foreground',
|
|
82
133
|
outline: 'text-foreground',
|
|
83
134
|
ghost: 'text-foreground',
|
|
@@ -177,44 +228,60 @@ export function Button(props: ButtonProps) {
|
|
|
177
228
|
// spacing only when icons exist
|
|
178
229
|
const hasIcons = Boolean(showLeftIcon || showRightIcon);
|
|
179
230
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
231
|
+
const squircleParams = useVariantSquircleParams(v);
|
|
232
|
+
|
|
233
|
+
const handlePress = React.useCallback(
|
|
234
|
+
(e: GestureResponderEvent) => {
|
|
235
|
+
if (d) return;
|
|
236
|
+
onPress?.(e);
|
|
237
|
+
},
|
|
238
|
+
[d, onPress]
|
|
239
|
+
);
|
|
240
|
+
|
|
183
241
|
return (
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
style={style}
|
|
199
|
-
{...rest}
|
|
200
|
-
>
|
|
201
|
-
{showLeftIcon ? <DummyIcon testID="button-left-icon" /> : null}
|
|
202
|
-
|
|
203
|
-
{!isIconOnly ? (
|
|
204
|
-
<RNText
|
|
205
|
-
testID="button-label"
|
|
242
|
+
<View style={style}>
|
|
243
|
+
<SquircleView
|
|
244
|
+
squircleParams={{
|
|
245
|
+
cornerRadius: CORNER_RADIUS,
|
|
246
|
+
cornerSmoothing: CORNER_SMOOTHING,
|
|
247
|
+
...squircleParams,
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
<Pressable
|
|
251
|
+
testID={testID ?? 'button'}
|
|
252
|
+
accessibilityRole="button"
|
|
253
|
+
accessibilityState={{ disabled: d }}
|
|
254
|
+
disabled={d}
|
|
255
|
+
onPress={handlePress}
|
|
206
256
|
className={cn(
|
|
207
|
-
|
|
257
|
+
buttonVariants({
|
|
258
|
+
variant: v,
|
|
259
|
+
size: s,
|
|
260
|
+
disabled: d,
|
|
261
|
+
hasIcons,
|
|
262
|
+
})
|
|
208
263
|
)}
|
|
209
|
-
|
|
210
|
-
ellipsizeMode="tail"
|
|
264
|
+
{...rest}
|
|
211
265
|
>
|
|
212
|
-
{
|
|
213
|
-
|
|
214
|
-
|
|
266
|
+
{showLeftIcon ? <DummyIcon testID="button-left-icon" /> : null}
|
|
267
|
+
|
|
268
|
+
{!isIconOnly ? (
|
|
269
|
+
<RNText
|
|
270
|
+
testID="button-label"
|
|
271
|
+
className={cn(
|
|
272
|
+
buttonTextVariants({ variant: v, size: s, disabled: d })
|
|
273
|
+
)}
|
|
274
|
+
numberOfLines={1}
|
|
275
|
+
ellipsizeMode="tail"
|
|
276
|
+
>
|
|
277
|
+
{children}
|
|
278
|
+
</RNText>
|
|
279
|
+
) : null}
|
|
215
280
|
|
|
216
|
-
|
|
217
|
-
|
|
281
|
+
{showRightIcon ? <DummyIcon testID="button-right-icon" /> : null}
|
|
282
|
+
</Pressable>
|
|
283
|
+
</SquircleView>
|
|
284
|
+
</View>
|
|
218
285
|
);
|
|
219
286
|
}
|
|
220
287
|
|
|
@@ -17,14 +17,14 @@ figma.connect(RadioGroup, FIGMA_URL, {
|
|
|
17
17
|
}),
|
|
18
18
|
|
|
19
19
|
state: figma.enum('state', {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
Unchecked: 'unchecked',
|
|
21
|
+
Checked: 'checked',
|
|
22
22
|
}),
|
|
23
23
|
},
|
|
24
24
|
|
|
25
25
|
example: ({ size, disabled, state }) => (
|
|
26
26
|
<RadioGroup
|
|
27
|
-
value={state === '
|
|
27
|
+
value={state === 'checked' ? 'one' : ''}
|
|
28
28
|
size={size}
|
|
29
29
|
disabled={disabled}
|
|
30
30
|
onValueChange={() => {}}
|
|
@@ -13,6 +13,7 @@ figma.connect(TextField, FIGMA_URL, {
|
|
|
13
13
|
success: 'success',
|
|
14
14
|
error: 'error',
|
|
15
15
|
disabled: 'disabled',
|
|
16
|
+
loading: 'loading',
|
|
16
17
|
}),
|
|
17
18
|
|
|
18
19
|
// Content
|
|
@@ -27,6 +28,7 @@ figma.connect(TextField, FIGMA_URL, {
|
|
|
27
28
|
search: 'search',
|
|
28
29
|
ai: 'ai',
|
|
29
30
|
composer: 'composer',
|
|
31
|
+
code: 'code',
|
|
30
32
|
}),
|
|
31
33
|
|
|
32
34
|
// Visibility
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
/// <reference types="nativewind/types" />
|
|
2
|
+
// @ts-nocheck
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import * as Slot from '@rn-primitives/slot';
|
|
4
5
|
import type { SlottableViewProps, ViewRef } from '@rn-primitives/types';
|
|
5
6
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
7
|
import { cssInterop } from 'nativewind';
|
|
7
|
-
import { View, TextInput } from 'react-native';
|
|
8
|
+
import { View, TextInput, Pressable } from 'react-native';
|
|
8
9
|
import type { LucideIcon } from 'lucide-react-native';
|
|
10
|
+
import LottieView from 'lottie-react-native';
|
|
11
|
+
import { SquircleView } from 'react-native-figma-squircle';
|
|
9
12
|
|
|
10
13
|
import { cn } from '../../../lib/utils';
|
|
11
14
|
import { TextClassContext, Text } from '../Text/Text';
|
|
15
|
+
import { Lotties } from '../../../assets/lotties';
|
|
16
|
+
import { useThemeColors } from '../../../lib/theme';
|
|
12
17
|
|
|
13
18
|
// NativeWind interop (className -> style)
|
|
14
19
|
cssInterop(View, { className: 'style' });
|
|
@@ -23,17 +28,62 @@ const StyledTextInput = TextInput as any;
|
|
|
23
28
|
* Variants
|
|
24
29
|
* -------------------------------------------------------------------------- */
|
|
25
30
|
|
|
31
|
+
const CORNER_RADIUS = 8;
|
|
32
|
+
const CORNER_SMOOTHING = 1;
|
|
33
|
+
|
|
34
|
+
function useStateSquircleParams(state: string) {
|
|
35
|
+
const colors = useThemeColors();
|
|
36
|
+
|
|
37
|
+
const map: Record<
|
|
38
|
+
string,
|
|
39
|
+
{ fillColor: string; strokeColor: string; strokeWidth: number }
|
|
40
|
+
> = {
|
|
41
|
+
default: {
|
|
42
|
+
fillColor: colors.surfaceDefault,
|
|
43
|
+
strokeColor: colors.border,
|
|
44
|
+
strokeWidth: 1,
|
|
45
|
+
},
|
|
46
|
+
focused: {
|
|
47
|
+
fillColor: colors.surfaceDefault,
|
|
48
|
+
strokeColor: colors.brandPrimary,
|
|
49
|
+
strokeWidth: 1,
|
|
50
|
+
},
|
|
51
|
+
success: {
|
|
52
|
+
fillColor: colors.surfaceDefault,
|
|
53
|
+
strokeColor: colors.success,
|
|
54
|
+
strokeWidth: 1,
|
|
55
|
+
},
|
|
56
|
+
error: {
|
|
57
|
+
fillColor: colors.surfaceDefault,
|
|
58
|
+
strokeColor: colors.destructive,
|
|
59
|
+
strokeWidth: 1,
|
|
60
|
+
},
|
|
61
|
+
disabled: {
|
|
62
|
+
fillColor: colors.surfaceSubtle,
|
|
63
|
+
strokeColor: colors.border,
|
|
64
|
+
strokeWidth: 1,
|
|
65
|
+
},
|
|
66
|
+
loading: {
|
|
67
|
+
fillColor: colors.surfaceDefault,
|
|
68
|
+
strokeColor: colors.border,
|
|
69
|
+
strokeWidth: 1,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return map[state] ?? map.default;
|
|
74
|
+
}
|
|
75
|
+
|
|
26
76
|
const textFieldVariants = cva(
|
|
27
|
-
'flex-row items-center
|
|
77
|
+
'flex-row items-center justify-between self-stretch bg-transparent min-h-[54px] px-3',
|
|
28
78
|
{
|
|
29
79
|
variants: {
|
|
30
80
|
state: {
|
|
31
|
-
default: '
|
|
32
|
-
focused: '
|
|
33
|
-
success: '
|
|
34
|
-
error: '
|
|
35
|
-
disabled:
|
|
36
|
-
|
|
81
|
+
default: '',
|
|
82
|
+
focused: '',
|
|
83
|
+
success: '',
|
|
84
|
+
error: '',
|
|
85
|
+
disabled: 'opacity-60',
|
|
86
|
+
loading: '',
|
|
37
87
|
},
|
|
38
88
|
},
|
|
39
89
|
defaultVariants: {
|
|
@@ -42,7 +92,7 @@ const textFieldVariants = cva(
|
|
|
42
92
|
}
|
|
43
93
|
);
|
|
44
94
|
|
|
45
|
-
const fieldTextVariants = cva('text-
|
|
95
|
+
const fieldTextVariants = cva('text-xs font-medium', {
|
|
46
96
|
variants: {
|
|
47
97
|
state: {
|
|
48
98
|
default: 'text-text-primary',
|
|
@@ -50,6 +100,7 @@ const fieldTextVariants = cva('text-sm', {
|
|
|
50
100
|
success: 'text-highlight-success-green',
|
|
51
101
|
error: 'text-highlight-alert-red',
|
|
52
102
|
disabled: 'text-text-muted',
|
|
103
|
+
loading: 'text-text-secondary',
|
|
53
104
|
},
|
|
54
105
|
},
|
|
55
106
|
defaultVariants: {
|
|
@@ -57,7 +108,7 @@ const fieldTextVariants = cva('text-sm', {
|
|
|
57
108
|
},
|
|
58
109
|
});
|
|
59
110
|
|
|
60
|
-
const nativeTextFieldVariants = cva('flex-1 text-
|
|
111
|
+
const nativeTextFieldVariants = cva('flex-1 text-sm font-medium', {
|
|
61
112
|
variants: {
|
|
62
113
|
state: {
|
|
63
114
|
default: 'text-text-primary',
|
|
@@ -65,6 +116,7 @@ const nativeTextFieldVariants = cva('flex-1 text-base', {
|
|
|
65
116
|
success: 'text-text-primary',
|
|
66
117
|
error: 'text-text-primary',
|
|
67
118
|
disabled: 'text-text-muted',
|
|
119
|
+
loading: 'text-text-secondary',
|
|
68
120
|
},
|
|
69
121
|
content: {
|
|
70
122
|
placeholder: 'placeholder:text-text-muted',
|
|
@@ -85,6 +137,7 @@ const iconVariants = cva('', {
|
|
|
85
137
|
success: 'text-highlight-success-green',
|
|
86
138
|
error: 'text-highlight-alert-red',
|
|
87
139
|
disabled: 'text-text-muted',
|
|
140
|
+
loading: 'text-text-primary',
|
|
88
141
|
},
|
|
89
142
|
},
|
|
90
143
|
defaultVariants: {
|
|
@@ -107,10 +160,10 @@ type TextFieldProps = Omit<SlottableViewProps, 'className'> &
|
|
|
107
160
|
asChild?: boolean;
|
|
108
161
|
|
|
109
162
|
leftIcon?: LucideIcon;
|
|
110
|
-
rightIcon?: LucideIcon;
|
|
163
|
+
rightIcon?: LucideIcon | React.ReactNode;
|
|
111
164
|
|
|
112
165
|
// Type (custom, not from CVA)
|
|
113
|
-
type?: 'text' | 'search' | 'ai' | 'composer';
|
|
166
|
+
type?: 'text' | 'search' | 'ai' | 'composer' | 'code';
|
|
114
167
|
|
|
115
168
|
// Visibility
|
|
116
169
|
showLabel?: boolean;
|
|
@@ -160,6 +213,7 @@ const TextField = React.forwardRef<ViewRef, TextFieldProps>(
|
|
|
160
213
|
) => {
|
|
161
214
|
const Component = asChild ? Slot.View : View;
|
|
162
215
|
const isDisabled = state === 'disabled';
|
|
216
|
+
const squircleParams = useStateSquircleParams(state ?? 'default');
|
|
163
217
|
|
|
164
218
|
const valueLike =
|
|
165
219
|
inputProps?.value ??
|
|
@@ -180,7 +234,9 @@ const TextField = React.forwardRef<ViewRef, TextFieldProps>(
|
|
|
180
234
|
? errorMessage || 'This field has an error'
|
|
181
235
|
: state === 'success'
|
|
182
236
|
? successMessage || 'This field is valid'
|
|
183
|
-
:
|
|
237
|
+
: state === 'loading'
|
|
238
|
+
? 'Loading...'
|
|
239
|
+
: helpText || 'Helper text';
|
|
184
240
|
|
|
185
241
|
const getPlaceholder = () => {
|
|
186
242
|
if (resolvedContent !== 'placeholder') {
|
|
@@ -194,12 +250,157 @@ const TextField = React.forwardRef<ViewRef, TextFieldProps>(
|
|
|
194
250
|
return 'Ask AI';
|
|
195
251
|
case 'composer':
|
|
196
252
|
return 'Type here';
|
|
253
|
+
case 'code':
|
|
254
|
+
return 'Paste your code here';
|
|
197
255
|
case 'text':
|
|
198
256
|
default:
|
|
199
257
|
return inputProps?.placeholder ?? 'Placeholder text';
|
|
200
258
|
}
|
|
201
259
|
};
|
|
202
260
|
|
|
261
|
+
// Handle code type (OTP-style boxes)
|
|
262
|
+
const hiddenInputRef = React.useRef<TextInput>(null);
|
|
263
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
264
|
+
const [selection, setSelection] = React.useState({
|
|
265
|
+
start: (inputProps?.value as string)?.length || 0,
|
|
266
|
+
end: (inputProps?.value as string)?.length || 0,
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
const codeLength = 6;
|
|
270
|
+
const codeValue = (inputProps?.value as string) || '';
|
|
271
|
+
|
|
272
|
+
const handlePress = React.useCallback((index: number) => {
|
|
273
|
+
setIsFocused(true);
|
|
274
|
+
setSelection({ start: index, end: index });
|
|
275
|
+
// Focus on next frame to avoid navigation context issues
|
|
276
|
+
setTimeout(() => {
|
|
277
|
+
hiddenInputRef.current?.focus();
|
|
278
|
+
}, 0);
|
|
279
|
+
}, []);
|
|
280
|
+
|
|
281
|
+
const handleChangeText = React.useCallback(
|
|
282
|
+
(text: string) => {
|
|
283
|
+
// Only keep numbers
|
|
284
|
+
const numericText = text.replace(/[^0-9]/g, '');
|
|
285
|
+
|
|
286
|
+
// Update the value through inputProps.onChangeText if available
|
|
287
|
+
if (inputProps?.onChangeText) {
|
|
288
|
+
inputProps.onChangeText(numericText);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Auto-focus to next box when digit is entered
|
|
292
|
+
if (
|
|
293
|
+
numericText.length < codeLength &&
|
|
294
|
+
selection.start < codeLength - 1
|
|
295
|
+
) {
|
|
296
|
+
setSelection({
|
|
297
|
+
start: selection.start + 1,
|
|
298
|
+
end: selection.start + 1,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
[selection.start, codeLength, inputProps]
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
const handleKeyPress = React.useCallback(
|
|
306
|
+
(e: any) => {
|
|
307
|
+
// Handle backspace to go to previous box
|
|
308
|
+
if (
|
|
309
|
+
e.nativeEvent.key === 'Backspace' &&
|
|
310
|
+
selection.start > 0 &&
|
|
311
|
+
codeValue.length === selection.start
|
|
312
|
+
) {
|
|
313
|
+
setSelection({
|
|
314
|
+
start: selection.start - 1,
|
|
315
|
+
end: selection.start - 1,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
[selection.start, codeValue.length]
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
if (type === 'code') {
|
|
323
|
+
const codeBoxes = Array.from({ length: codeLength }).map(
|
|
324
|
+
(_, i) => codeValue[i] || ''
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
return (
|
|
328
|
+
<TextClassContext.Provider value={fieldTextVariants({ state })}>
|
|
329
|
+
<StyledView className="gap-2">
|
|
330
|
+
{showLabel && (
|
|
331
|
+
<StyledView>
|
|
332
|
+
<Text>{label || 'Label'}</Text>
|
|
333
|
+
</StyledView>
|
|
334
|
+
)}
|
|
335
|
+
|
|
336
|
+
<StyledView className="flex-row gap-2 justify-between">
|
|
337
|
+
{codeBoxes.map((char, index) => {
|
|
338
|
+
const isActive = selection.start === index && isFocused;
|
|
339
|
+
|
|
340
|
+
return (
|
|
341
|
+
<Pressable
|
|
342
|
+
key={index}
|
|
343
|
+
onPress={() => handlePress(index)}
|
|
344
|
+
className="flex-1"
|
|
345
|
+
>
|
|
346
|
+
<StyledView
|
|
347
|
+
className={cn(
|
|
348
|
+
'items-center justify-center border rounded-md px-3 py-4',
|
|
349
|
+
isActive
|
|
350
|
+
? 'border-brand-primary ring-1 ring-brand-primary'
|
|
351
|
+
: state === 'error'
|
|
352
|
+
? 'border-highlight-alert-red'
|
|
353
|
+
: 'border-border-default',
|
|
354
|
+
'bg-surface-default'
|
|
355
|
+
)}
|
|
356
|
+
>
|
|
357
|
+
<Text
|
|
358
|
+
className={cn(
|
|
359
|
+
'text-sm font-medium',
|
|
360
|
+
state === 'error'
|
|
361
|
+
? 'text-highlight-alert-red'
|
|
362
|
+
: 'text-text-primary'
|
|
363
|
+
)}
|
|
364
|
+
>
|
|
365
|
+
{char || ''}
|
|
366
|
+
</Text>
|
|
367
|
+
</StyledView>
|
|
368
|
+
</Pressable>
|
|
369
|
+
);
|
|
370
|
+
})}
|
|
371
|
+
</StyledView>
|
|
372
|
+
|
|
373
|
+
{/* Hidden input for actual text input */}
|
|
374
|
+
<StyledTextInput
|
|
375
|
+
{...inputProps}
|
|
376
|
+
ref={hiddenInputRef}
|
|
377
|
+
maxLength={codeLength}
|
|
378
|
+
editable={!isDisabled}
|
|
379
|
+
keyboardType="number-pad"
|
|
380
|
+
textContentType="oneTimeCode"
|
|
381
|
+
value={codeValue}
|
|
382
|
+
onChangeText={handleChangeText}
|
|
383
|
+
onKeyPress={handleKeyPress}
|
|
384
|
+
selection={selection}
|
|
385
|
+
onSelectionChange={(e: any) =>
|
|
386
|
+
setSelection(e.nativeEvent.selection)
|
|
387
|
+
}
|
|
388
|
+
onFocus={() => setIsFocused(true)}
|
|
389
|
+
onBlur={() => setIsFocused(false)}
|
|
390
|
+
multiline={false}
|
|
391
|
+
className="absolute opacity-0 w-0 h-0"
|
|
392
|
+
/>
|
|
393
|
+
|
|
394
|
+
{showHelpText && (
|
|
395
|
+
<StyledView>
|
|
396
|
+
<Text>{message}</Text>
|
|
397
|
+
</StyledView>
|
|
398
|
+
)}
|
|
399
|
+
</StyledView>
|
|
400
|
+
</TextClassContext.Provider>
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
|
|
203
404
|
return (
|
|
204
405
|
<TextClassContext.Provider value={fieldTextVariants({ state })}>
|
|
205
406
|
<StyledView className="gap-1">
|
|
@@ -209,42 +410,73 @@ const TextField = React.forwardRef<ViewRef, TextFieldProps>(
|
|
|
209
410
|
</StyledView>
|
|
210
411
|
)}
|
|
211
412
|
|
|
212
|
-
<
|
|
213
|
-
|
|
214
|
-
{
|
|
215
|
-
className={cn(textFieldVariants({ state }))}
|
|
413
|
+
<View
|
|
414
|
+
key={`squircle-${state}`}
|
|
415
|
+
style={{ overflow: 'hidden', borderRadius: CORNER_RADIUS }}
|
|
216
416
|
>
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
417
|
+
<SquircleView
|
|
418
|
+
squircleParams={{
|
|
419
|
+
cornerRadius: CORNER_RADIUS,
|
|
420
|
+
cornerSmoothing: CORNER_SMOOTHING,
|
|
421
|
+
...squircleParams,
|
|
422
|
+
}}
|
|
423
|
+
>
|
|
424
|
+
<Component
|
|
425
|
+
ref={ref as any}
|
|
426
|
+
{...containerProps}
|
|
427
|
+
className={cn(textFieldVariants({ state }))}
|
|
428
|
+
>
|
|
429
|
+
{showLeftIcon && LeftIcon && (
|
|
430
|
+
<LeftIcon
|
|
431
|
+
size={16}
|
|
432
|
+
className={cn('mr-2 mt-1', iconVariants({ state }))}
|
|
433
|
+
/>
|
|
434
|
+
)}
|
|
435
|
+
|
|
436
|
+
<StyledTextInput
|
|
437
|
+
{...inputProps}
|
|
438
|
+
multiline={type === 'composer' || inputProps?.multiline}
|
|
439
|
+
editable={!isDisabled}
|
|
440
|
+
placeholder={getPlaceholder()}
|
|
441
|
+
className={cn(
|
|
442
|
+
nativeTextFieldVariants({
|
|
443
|
+
state,
|
|
444
|
+
content: resolvedContent,
|
|
445
|
+
}),
|
|
446
|
+
isDisabled && 'opacity-100'
|
|
447
|
+
)}
|
|
448
|
+
style={[
|
|
449
|
+
{
|
|
450
|
+
textAlignVertical: 'top',
|
|
451
|
+
},
|
|
452
|
+
inputProps?.style,
|
|
453
|
+
]}
|
|
454
|
+
/>
|
|
455
|
+
|
|
456
|
+
{state === 'loading' ? (
|
|
457
|
+
<LottieView
|
|
458
|
+
source={Lotties.loading}
|
|
459
|
+
autoPlay
|
|
460
|
+
loop
|
|
461
|
+
style={{ width: 48, height: 48, marginLeft: 8 }}
|
|
462
|
+
/>
|
|
463
|
+
) : showRightIcon &&
|
|
464
|
+
RightIcon &&
|
|
465
|
+
typeof RightIcon !== 'undefined' ? (
|
|
466
|
+
typeof RightIcon === 'function' ? (
|
|
467
|
+
<RightIcon
|
|
468
|
+
size={16}
|
|
469
|
+
className={cn('ml-2 mt-1', iconVariants({ state }))}
|
|
470
|
+
/>
|
|
471
|
+
) : React.isValidElement(RightIcon) ? (
|
|
472
|
+
<StyledView className={cn('ml-2 mt-1')}>
|
|
473
|
+
{RightIcon}
|
|
474
|
+
</StyledView>
|
|
475
|
+
) : null
|
|
476
|
+
) : null}
|
|
477
|
+
</Component>
|
|
478
|
+
</SquircleView>
|
|
479
|
+
</View>
|
|
248
480
|
|
|
249
481
|
{showHelpText && (
|
|
250
482
|
<StyledView>
|