@flipova/foundation 2.2.1 → 2.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +157 -156
- package/components/ui/accordion/ANIMATION_CUSTOMIZATION.md +16 -7
- package/components/ui/accordion/AccordionAnimatedHeight.tsx +3 -15
- package/components/ui/accordion/AccordionAnimatedIcon.tsx +2 -9
- package/components/ui/accordion/AnimatedHeight.tsx +3 -15
- package/components/ui/accordion/AnimatedIcon.tsx +2 -9
- package/components/ui/accordion/MIGRATION_SUMMARY.md +22 -11
- package/components/ui/accordion/USAGE_EXAMPLE.tsx +10 -25
- package/components/ui/accordion/index.tsx +71 -139
- package/components/ui/actionsheet/index.tsx +63 -105
- package/components/ui/alert/index.tsx +20 -50
- package/components/ui/alert-dialog/index.tsx +23 -48
- package/components/ui/avatar/index.tsx +32 -68
- package/components/ui/badge/index.tsx +18 -49
- package/components/ui/bottomsheet/index.tsx +20 -52
- package/components/ui/box/index.tsx +4 -9
- package/components/ui/box/index.web.tsx +3 -9
- package/components/ui/button/index.tsx +73 -109
- package/components/ui/calendar/creator.tsx +69 -30
- package/components/ui/calendar/index.tsx +81 -159
- package/components/ui/calendar/styles.tsx +10 -10
- package/components/ui/card/index.tsx +8 -9
- package/components/ui/card/index.web.tsx +4 -10
- package/components/ui/center/index.tsx +6 -11
- package/components/ui/center/index.web.tsx +3 -9
- package/components/ui/checkbox/index.tsx +46 -107
- package/components/ui/date-time-picker/creator.tsx +14 -1
- package/components/ui/date-time-picker/index.tsx +107 -156
- package/components/ui/date-time-picker/index.web.tsx +11 -33
- package/components/ui/date-time-picker/styles.tsx +5 -5
- package/components/ui/divider/index.tsx +5 -6
- package/components/ui/drawer/index.tsx +108 -128
- package/components/ui/fab/index.tsx +25 -68
- package/components/ui/flat-list/index.tsx +11 -8
- package/components/ui/form-control/index.tsx +49 -90
- package/components/ui/gluestack-ui-provider/config.ts +69 -2
- package/components/ui/gluestack-ui-provider/index.tsx +32 -12
- package/components/ui/gluestack-ui-provider/index.web.tsx +43 -16
- package/components/ui/gluestack-ui-provider/script.ts +13 -8
- package/components/ui/gluestack-ui-provider/theme-context.ts +36 -1
- package/components/ui/gluestack-ui-provider/useGluestackColors.ts +11 -4
- package/components/ui/grid/index.tsx +128 -165
- package/components/ui/grid/index.web.tsx +17 -19
- package/components/ui/grid/styles.tsx +1 -3
- package/components/ui/heading/index.tsx +146 -169
- package/components/ui/heading/index.web.tsx +7 -28
- package/components/ui/heading/styles.tsx +5 -5
- package/components/ui/hstack/index.tsx +16 -15
- package/components/ui/hstack/index.web.tsx +17 -17
- package/components/ui/hstack/styles.tsx +5 -5
- package/components/ui/icon/index.tsx +95 -486
- package/components/ui/icon/index.web.tsx +79 -439
- package/components/ui/image/index.tsx +13 -18
- package/components/ui/image-viewer/index.tsx +149 -221
- package/components/ui/image-viewer/index.web.tsx +88 -113
- package/components/ui/input/index.tsx +20 -33
- package/components/ui/link/index.tsx +16 -22
- package/components/ui/liquid-glass/index.tsx +19 -25
- package/components/ui/menu/index.tsx +44 -66
- package/components/ui/modal/index.tsx +70 -91
- package/components/ui/popover/index.tsx +102 -121
- package/components/ui/portal/index.tsx +5 -6
- package/components/ui/pressable/index.tsx +5 -9
- package/components/ui/progress/index.tsx +4 -11
- package/components/ui/radio/index.tsx +47 -83
- package/components/ui/select/index.tsx +38 -59
- package/components/ui/select/select-actionsheet.tsx +61 -108
- package/components/ui/skeleton/index.tsx +22 -43
- package/components/ui/skeleton/index.web.tsx +63 -75
- package/components/ui/slider/index.tsx +36 -56
- package/components/ui/spinner/index.tsx +1 -10
- package/components/ui/switch/index.tsx +6 -13
- package/components/ui/table/index.tsx +39 -102
- package/components/ui/table/index.web.tsx +41 -79
- package/components/ui/tabs/TabsAnimatedIndicator.tsx +10 -38
- package/components/ui/tabs/creator.tsx +32 -24
- package/components/ui/tabs/index.tsx +253 -309
- package/components/ui/text/index.tsx +23 -37
- package/components/ui/text/index.web.tsx +33 -35
- package/components/ui/text/styles.tsx +5 -5
- package/components/ui/textarea/index.tsx +24 -38
- package/components/ui/toast/index.tsx +47 -52
- package/components/ui/tooltip/index.tsx +12 -28
- package/components/ui/vstack/index.tsx +17 -17
- package/components/ui/vstack/index.web.tsx +17 -17
- package/components/ui/vstack/styles.tsx +5 -5
- package/design/canonical.index.txt +15 -1
- package/design/manifest.xml +2 -0
- package/design/schema.xsd +11 -0
- package/design/themes.xml +175 -2
- package/design/tools/design.js +15 -12
- package/design/tools/npm.js +4 -3
- package/design/tools/sources/.generate/config.py +60 -2
- package/dist/{chunk-RPLDFHEZ.mjs → chunk-2R66P5X5.mjs} +1907 -3130
- package/dist/chunk-2R66P5X5.mjs.map +1 -0
- package/dist/{chunk-JVHJUIXV.js → chunk-LCTFQJZM.js} +1909 -3129
- package/dist/chunk-LCTFQJZM.js.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +303 -291
- package/dist/index.mjs +1 -1
- package/dist/ui/index.d.mts +44 -3
- package/dist/ui/index.d.ts +44 -3
- package/dist/ui/index.js +303 -291
- package/dist/ui/index.mjs +1 -1
- package/package.json +12 -7
- package/dist/chunk-JVHJUIXV.js.map +0 -1
- package/dist/chunk-RPLDFHEZ.mjs.map +0 -1
|
@@ -3,10 +3,7 @@ import React, { useMemo } from 'react';
|
|
|
3
3
|
import { Text, View } from 'react-native';
|
|
4
4
|
import { UIIcon } from '@gluestack-ui/core/icon/creator';
|
|
5
5
|
import { tva } from '@gluestack-ui/utils/nativewind-utils';
|
|
6
|
-
import {
|
|
7
|
-
withStyleContext,
|
|
8
|
-
useStyleContext,
|
|
9
|
-
} from '@gluestack-ui/utils/nativewind-utils';
|
|
6
|
+
import { withStyleContext, useStyleContext } from '@gluestack-ui/utils/nativewind-utils';
|
|
10
7
|
import { cssInterop } from 'nativewind';
|
|
11
8
|
import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
12
9
|
|
|
@@ -19,8 +16,7 @@ const badgeStyle = tva({
|
|
|
19
16
|
variant: {
|
|
20
17
|
default: 'bg-primary',
|
|
21
18
|
secondary: 'bg-secondary',
|
|
22
|
-
destructive:
|
|
23
|
-
'bg-destructive dark:bg-destructive/60',
|
|
19
|
+
destructive: 'bg-destructive dark:bg-destructive/60',
|
|
24
20
|
outline: 'border border-border dark:border-border/90 bg-transparent',
|
|
25
21
|
},
|
|
26
22
|
},
|
|
@@ -65,32 +61,21 @@ cssInterop(UIIcon, {
|
|
|
65
61
|
},
|
|
66
62
|
});
|
|
67
63
|
|
|
68
|
-
type IBadgeProps = React.ComponentPropsWithoutRef<typeof ContextView> &
|
|
69
|
-
|
|
70
|
-
function Badge({
|
|
71
|
-
children,
|
|
72
|
-
variant = 'default',
|
|
73
|
-
className,
|
|
74
|
-
...props
|
|
75
|
-
}: { className?: string } & IBadgeProps) {
|
|
64
|
+
type IBadgeProps = React.ComponentPropsWithoutRef<typeof ContextView> & VariantProps<typeof badgeStyle>;
|
|
65
|
+
function Badge({ children, variant = 'default', className, ...props }: { className?: string } & IBadgeProps) {
|
|
76
66
|
return (
|
|
77
|
-
<ContextView
|
|
78
|
-
className={badgeStyle({ variant, class: className })}
|
|
79
|
-
{...props}
|
|
80
|
-
context={{ variant }}
|
|
81
|
-
>
|
|
67
|
+
<ContextView className={badgeStyle({ variant, class: className })} {...props} context={{ variant }}>
|
|
82
68
|
{children}
|
|
83
69
|
</ContextView>
|
|
84
70
|
);
|
|
85
71
|
}
|
|
86
72
|
|
|
87
|
-
type IBadgeTextProps = React.ComponentPropsWithoutRef<typeof Text> &
|
|
88
|
-
VariantProps<typeof badgeTextStyle>;
|
|
73
|
+
type IBadgeTextProps = React.ComponentPropsWithoutRef<typeof Text> & VariantProps<typeof badgeTextStyle>;
|
|
89
74
|
|
|
90
|
-
const BadgeText = React.forwardRef<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
75
|
+
const BadgeText = React.forwardRef<React.ComponentRef<typeof Text>, IBadgeTextProps>(function BadgeText(
|
|
76
|
+
{ children, className, ...props },
|
|
77
|
+
ref,
|
|
78
|
+
) {
|
|
94
79
|
const { variant: parentVariant } = useStyleContext(SCOPE);
|
|
95
80
|
return (
|
|
96
81
|
<Text
|
|
@@ -115,32 +100,16 @@ type IBadgeIconProps = React.ComponentPropsWithoutRef<typeof UIIcon> &
|
|
|
115
100
|
width?: number;
|
|
116
101
|
};
|
|
117
102
|
|
|
118
|
-
const BadgeIcon = React.forwardRef<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
103
|
+
const BadgeIcon = React.forwardRef<React.ComponentRef<typeof Svg>, IBadgeIconProps>(function BadgeIcon(
|
|
104
|
+
{ className, size, ...props },
|
|
105
|
+
ref,
|
|
106
|
+
) {
|
|
122
107
|
const { variant: parentVariant } = useStyleContext(SCOPE);
|
|
123
108
|
|
|
124
109
|
if (typeof size === 'number') {
|
|
125
|
-
return (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
{...props}
|
|
129
|
-
className={badgeIconStyle({ class: className })}
|
|
130
|
-
size={size}
|
|
131
|
-
/>
|
|
132
|
-
);
|
|
133
|
-
} else if (
|
|
134
|
-
(props?.height !== undefined || props?.width !== undefined) &&
|
|
135
|
-
size === undefined
|
|
136
|
-
) {
|
|
137
|
-
return (
|
|
138
|
-
<UIIcon
|
|
139
|
-
ref={ref as any}
|
|
140
|
-
{...props}
|
|
141
|
-
className={badgeIconStyle({ class: className })}
|
|
142
|
-
/>
|
|
143
|
-
);
|
|
110
|
+
return <UIIcon ref={ref as any} {...props} className={badgeIconStyle({ class: className })} size={size} />;
|
|
111
|
+
} else if ((props?.height !== undefined || props?.width !== undefined) && size === undefined) {
|
|
112
|
+
return <UIIcon ref={ref as any} {...props} className={badgeIconStyle({ class: className })} />;
|
|
144
113
|
}
|
|
145
114
|
return (
|
|
146
115
|
<UIIcon
|
|
@@ -160,4 +129,4 @@ Badge.displayName = 'Badge';
|
|
|
160
129
|
BadgeText.displayName = 'BadgeText';
|
|
161
130
|
BadgeIcon.displayName = 'BadgeIcon';
|
|
162
131
|
|
|
163
|
-
export { Badge, BadgeIcon, BadgeText };
|
|
132
|
+
export { Badge, BadgeIcon, BadgeText };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { FocusScope } from '@gluestack-ui/utils/aria';
|
|
3
3
|
import { tva } from '@gluestack-ui/utils/nativewind-utils';
|
|
4
4
|
import GorhomBottomSheet, {
|
|
@@ -70,10 +70,10 @@ type BottomSheetContextValue = {
|
|
|
70
70
|
const BottomSheetContext = createContext<BottomSheetContextValue>({
|
|
71
71
|
visible: false,
|
|
72
72
|
bottomSheetRef: { current: null! },
|
|
73
|
-
handleClose: () => {
|
|
74
|
-
handleNaturalClose: () => {
|
|
75
|
-
handleOpen: () => {
|
|
76
|
-
snapToIndex: () => {
|
|
73
|
+
handleClose: () => {},
|
|
74
|
+
handleNaturalClose: () => {},
|
|
75
|
+
handleOpen: () => {},
|
|
76
|
+
snapToIndex: () => {},
|
|
77
77
|
currentIndex: -1,
|
|
78
78
|
});
|
|
79
79
|
|
|
@@ -107,7 +107,7 @@ export const BottomSheet = forwardRef<BottomSheetRef, IBottomSheetRootProps>(
|
|
|
107
107
|
setCurrentIndex(targetIndex);
|
|
108
108
|
onOpen?.();
|
|
109
109
|
},
|
|
110
|
-
[defaultSnapIndex, onOpen]
|
|
110
|
+
[defaultSnapIndex, onOpen],
|
|
111
111
|
);
|
|
112
112
|
|
|
113
113
|
// Triggers the close animation only — state updates happen via onChange chain
|
|
@@ -146,7 +146,7 @@ export const BottomSheet = forwardRef<BottomSheetRef, IBottomSheetRootProps>(
|
|
|
146
146
|
expand,
|
|
147
147
|
collapse,
|
|
148
148
|
}),
|
|
149
|
-
[handleOpen, handleClose, snapToIndex, expand, collapse]
|
|
149
|
+
[handleOpen, handleClose, snapToIndex, expand, collapse],
|
|
150
150
|
);
|
|
151
151
|
|
|
152
152
|
const contextValue = useMemo(
|
|
@@ -159,23 +159,16 @@ export const BottomSheet = forwardRef<BottomSheetRef, IBottomSheetRootProps>(
|
|
|
159
159
|
snapToIndex,
|
|
160
160
|
currentIndex,
|
|
161
161
|
}),
|
|
162
|
-
[visible, handleClose, handleNaturalClose, handleOpen, snapToIndex, currentIndex]
|
|
162
|
+
[visible, handleClose, handleNaturalClose, handleOpen, snapToIndex, currentIndex],
|
|
163
163
|
);
|
|
164
164
|
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
{children}
|
|
168
|
-
</BottomSheetContext.Provider>
|
|
169
|
-
);
|
|
170
|
-
}
|
|
165
|
+
return <BottomSheetContext.Provider value={contextValue}>{children}</BottomSheetContext.Provider>;
|
|
166
|
+
},
|
|
171
167
|
);
|
|
172
168
|
|
|
173
169
|
BottomSheet.displayName = 'BottomSheet';
|
|
174
170
|
|
|
175
|
-
type IBottomSheetPortalProps = Omit<
|
|
176
|
-
React.ComponentProps<typeof GorhomBottomSheet>,
|
|
177
|
-
'ref'
|
|
178
|
-
> & {
|
|
171
|
+
type IBottomSheetPortalProps = Omit<React.ComponentProps<typeof GorhomBottomSheet>, 'ref'> & {
|
|
179
172
|
snapPoints: (string | number)[];
|
|
180
173
|
className?: string;
|
|
181
174
|
backgroundClassName?: string;
|
|
@@ -209,7 +202,7 @@ export const BottomSheetPortal = ({
|
|
|
209
202
|
handleNaturalClose();
|
|
210
203
|
}
|
|
211
204
|
},
|
|
212
|
-
[handleNaturalClose, onChange]
|
|
205
|
+
[handleNaturalClose, onChange],
|
|
213
206
|
);
|
|
214
207
|
|
|
215
208
|
return (
|
|
@@ -284,9 +277,7 @@ export const BottomSheetBackdrop = ({
|
|
|
284
277
|
);
|
|
285
278
|
};
|
|
286
279
|
|
|
287
|
-
type IBottomSheetHandleProps = React.ComponentProps<
|
|
288
|
-
typeof GorhomBottomSheetHandle
|
|
289
|
-
> & {
|
|
280
|
+
type IBottomSheetHandleProps = React.ComponentProps<typeof GorhomBottomSheetHandle> & {
|
|
290
281
|
className?: string;
|
|
291
282
|
indicatorClassName?: string;
|
|
292
283
|
};
|
|
@@ -308,18 +299,12 @@ export const BottomSheetDragIndicator = ({
|
|
|
308
299
|
);
|
|
309
300
|
};
|
|
310
301
|
|
|
311
|
-
type IBottomSheetContentProps = React.ComponentProps<
|
|
312
|
-
typeof GorhomBottomSheetView
|
|
313
|
-
> & {
|
|
302
|
+
type IBottomSheetContentProps = React.ComponentProps<typeof GorhomBottomSheetView> & {
|
|
314
303
|
className?: string;
|
|
315
304
|
focusScope?: boolean;
|
|
316
305
|
};
|
|
317
306
|
|
|
318
|
-
export const BottomSheetContent = ({
|
|
319
|
-
className,
|
|
320
|
-
focusScope = true,
|
|
321
|
-
...props
|
|
322
|
-
}: IBottomSheetContentProps) => {
|
|
307
|
+
export const BottomSheetContent = ({ className, focusScope = true, ...props }: IBottomSheetContentProps) => {
|
|
323
308
|
const { handleClose, visible } = useContext(BottomSheetContext);
|
|
324
309
|
|
|
325
310
|
const keyDownHandlers = useMemo(() => {
|
|
@@ -357,18 +342,12 @@ export const BottomSheetContent = ({
|
|
|
357
342
|
);
|
|
358
343
|
};
|
|
359
344
|
|
|
360
|
-
type IBottomSheetFooterProps = React.ComponentProps<
|
|
361
|
-
typeof GorhomBottomSheetFooter
|
|
362
|
-
> & {
|
|
345
|
+
type IBottomSheetFooterProps = React.ComponentProps<typeof GorhomBottomSheetFooter> & {
|
|
363
346
|
className?: string;
|
|
364
347
|
children?: React.ReactNode;
|
|
365
348
|
};
|
|
366
349
|
|
|
367
|
-
export const BottomSheetFooter = ({
|
|
368
|
-
className,
|
|
369
|
-
children,
|
|
370
|
-
...props
|
|
371
|
-
}: IBottomSheetFooterProps) => {
|
|
350
|
+
export const BottomSheetFooter = ({ className, children, ...props }: IBottomSheetFooterProps) => {
|
|
372
351
|
return (
|
|
373
352
|
<GorhomBottomSheetFooter {...props}>
|
|
374
353
|
<View
|
|
@@ -386,12 +365,7 @@ type IBottomSheetItemProps = PressableProps & {
|
|
|
386
365
|
closeOnSelect?: boolean;
|
|
387
366
|
};
|
|
388
367
|
|
|
389
|
-
export const BottomSheetItem = ({
|
|
390
|
-
children,
|
|
391
|
-
className,
|
|
392
|
-
closeOnSelect = true,
|
|
393
|
-
...props
|
|
394
|
-
}: IBottomSheetItemProps) => {
|
|
368
|
+
export const BottomSheetItem = ({ children, className, closeOnSelect = true, ...props }: IBottomSheetItemProps) => {
|
|
395
369
|
const { handleClose } = useContext(BottomSheetContext);
|
|
396
370
|
|
|
397
371
|
return (
|
|
@@ -416,17 +390,11 @@ type IBottomSheetItemTextProps = TextProps & {
|
|
|
416
390
|
className?: string;
|
|
417
391
|
};
|
|
418
392
|
|
|
419
|
-
export const BottomSheetItemText = ({
|
|
420
|
-
className,
|
|
421
|
-
...props
|
|
422
|
-
}: IBottomSheetItemTextProps) => {
|
|
393
|
+
export const BottomSheetItemText = ({ className, ...props }: IBottomSheetItemTextProps) => {
|
|
423
394
|
return <Text {...props} className={bottomSheetItemTextStyle({ className })} />;
|
|
424
395
|
};
|
|
425
396
|
|
|
426
|
-
export const BottomSheetTextInput = ({
|
|
427
|
-
className,
|
|
428
|
-
...props
|
|
429
|
-
}: TextInputProps) => {
|
|
397
|
+
export const BottomSheetTextInput = ({ className, ...props }: TextInputProps) => {
|
|
430
398
|
return <GorhomBottomSheetInput {...props} className={bottomSheetTextInputStyle({ className })} />;
|
|
431
399
|
};
|
|
432
400
|
// Scrollable components with className support
|
|
@@ -4,16 +4,11 @@ import { View, ViewProps } from 'react-native';
|
|
|
4
4
|
import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
5
5
|
import { boxStyle } from './styles';
|
|
6
6
|
|
|
7
|
-
type IBoxProps = ViewProps &
|
|
8
|
-
VariantProps<typeof boxStyle> & { className?: string };
|
|
7
|
+
type IBoxProps = ViewProps & VariantProps<typeof boxStyle> & { className?: string };
|
|
9
8
|
|
|
10
|
-
const Box = React.forwardRef<React.ComponentRef<typeof View>, IBoxProps>(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<View ref={ref} {...props} className={boxStyle({ class: className })} />
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
);
|
|
9
|
+
const Box = React.forwardRef<React.ComponentRef<typeof View>, IBoxProps>(function Box({ className, ...props }, ref) {
|
|
10
|
+
return <View ref={ref} {...props} className={boxStyle({ class: className })} />;
|
|
11
|
+
});
|
|
17
12
|
|
|
18
13
|
Box.displayName = 'Box';
|
|
19
14
|
export { Box };
|
|
@@ -3,16 +3,10 @@ import { boxStyle } from './styles';
|
|
|
3
3
|
|
|
4
4
|
import type { VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
5
5
|
|
|
6
|
-
type IBoxProps = React.ComponentPropsWithoutRef<'div'> &
|
|
7
|
-
VariantProps<typeof boxStyle> & { className?: string };
|
|
6
|
+
type IBoxProps = React.ComponentPropsWithoutRef<'div'> & VariantProps<typeof boxStyle> & { className?: string };
|
|
8
7
|
|
|
9
|
-
const Box = React.forwardRef<HTMLDivElement, IBoxProps>(function Box(
|
|
10
|
-
{ className
|
|
11
|
-
ref
|
|
12
|
-
) {
|
|
13
|
-
return (
|
|
14
|
-
<div ref={ref} className={boxStyle({ class: className })} {...props} />
|
|
15
|
-
);
|
|
8
|
+
const Box = React.forwardRef<HTMLDivElement, IBoxProps>(function Box({ className, ...props }, ref) {
|
|
9
|
+
return <div ref={ref} className={boxStyle({ class: className })} {...props} />;
|
|
16
10
|
});
|
|
17
11
|
|
|
18
12
|
Box.displayName = 'Box';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { createButton } from '@gluestack-ui/core/button/creator';
|
|
4
|
-
import {
|
|
5
|
-
tva,
|
|
6
|
-
withStyleContext,
|
|
7
|
-
useStyleContext,
|
|
8
|
-
type VariantProps,
|
|
9
|
-
} from '@gluestack-ui/utils/nativewind-utils';
|
|
4
|
+
import { tva, withStyleContext, useStyleContext, type VariantProps } from '@gluestack-ui/utils/nativewind-utils';
|
|
10
5
|
import { cssInterop } from 'nativewind';
|
|
11
6
|
import { ActivityIndicator, Pressable, Text, View } from 'react-native';
|
|
12
7
|
import { UIIcon } from '@gluestack-ui/core/icon/creator';
|
|
@@ -35,15 +30,15 @@ const buttonStyle = tva({
|
|
|
35
30
|
base: 'rounded-md flex-row items-center justify-center data-[focus-visible=true]:web:outline-none data-[focus-visible=true]:web:ring-2 data-[disabled=true]:opacity-40 gap-2 h-fit',
|
|
36
31
|
variants: {
|
|
37
32
|
variant: {
|
|
38
|
-
default:
|
|
39
|
-
'bg-primary data-[hover=true]:bg-primary/90 data-[active=true]:bg-primary/90',
|
|
33
|
+
default: 'bg-primary data-[hover=true]:bg-primary/90 data-[active=true]:bg-primary/90',
|
|
40
34
|
destructive:
|
|
41
35
|
'bg-destructive data-[hover=true]:bg-destructive/90 data-[active=true]:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
|
|
42
36
|
outline:
|
|
43
37
|
'border border-border bg-background shadow-xs data-[hover=true]:bg-accent data-[active=true]:bg-accent dark:bg-input/[0.045] dark:border-border/90 dark:data-[hover=true]:bg-input/[0.075] dark:data-[active=true]:bg-input/[0.075]',
|
|
44
38
|
secondary:
|
|
45
39
|
'bg-secondary text-secondary-foreground data-[hover=true]:bg-secondary/80 data-[active=true]:bg-secondary/80',
|
|
46
|
-
ghost:
|
|
40
|
+
ghost:
|
|
41
|
+
'data-[hover=true]:bg-accent data-[active=true]:bg-accent dark:data-[hover=true]:bg-accent/50 dark:data-[active=true]:bg-accent/50',
|
|
47
42
|
link: 'text-primary underline-offset-4 data-[hover=true]:underline data-[active=true]:underline',
|
|
48
43
|
},
|
|
49
44
|
size: {
|
|
@@ -92,11 +87,9 @@ const buttonIconStyle = tva({
|
|
|
92
87
|
variant: {
|
|
93
88
|
default: 'text-primary-foreground',
|
|
94
89
|
destructive: 'text-white',
|
|
95
|
-
outline:
|
|
96
|
-
'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
90
|
+
outline: 'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
97
91
|
secondary: 'text-secondary-foreground',
|
|
98
|
-
ghost:
|
|
99
|
-
'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
92
|
+
ghost: 'text-foreground data-[hover=true]:text-accent-foreground data-[active=true]:text-accent-foreground',
|
|
100
93
|
link: 'text-primary',
|
|
101
94
|
},
|
|
102
95
|
size: {
|
|
@@ -111,11 +104,11 @@ const buttonGroupStyle = tva({
|
|
|
111
104
|
base: '',
|
|
112
105
|
variants: {
|
|
113
106
|
space: {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
xs: 'gap-1',
|
|
108
|
+
sm: 'gap-2',
|
|
109
|
+
md: 'gap-3',
|
|
110
|
+
lg: 'gap-4',
|
|
111
|
+
xl: 'gap-5',
|
|
119
112
|
'2xl': 'gap-6',
|
|
120
113
|
'3xl': 'gap-7',
|
|
121
114
|
'4xl': 'gap-8',
|
|
@@ -124,60 +117,61 @@ const buttonGroupStyle = tva({
|
|
|
124
117
|
true: 'gap-0',
|
|
125
118
|
},
|
|
126
119
|
flexDirection: {
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
row: 'flex-row',
|
|
121
|
+
column: 'flex-col',
|
|
129
122
|
'row-reverse': 'flex-row-reverse',
|
|
130
123
|
'column-reverse': 'flex-col-reverse',
|
|
131
124
|
},
|
|
132
125
|
},
|
|
133
126
|
});
|
|
134
|
-
type IButtonProps = Omit<
|
|
135
|
-
React.ComponentPropsWithoutRef<typeof UIButton>,
|
|
136
|
-
'context'
|
|
137
|
-
> &
|
|
127
|
+
type IButtonProps = Omit<React.ComponentPropsWithoutRef<typeof UIButton>, 'context'> &
|
|
138
128
|
VariantProps<typeof buttonStyle> & { className?: string };
|
|
139
|
-
const Button = React.forwardRef<
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
129
|
+
const Button = React.forwardRef<React.ElementRef<typeof UIButton>, IButtonProps>(
|
|
130
|
+
({ className, variant = 'default', size = 'default', ...props }, ref) => {
|
|
131
|
+
return (
|
|
132
|
+
<UIButton
|
|
133
|
+
ref={ref}
|
|
134
|
+
{...props}
|
|
135
|
+
className={buttonStyle({ variant, size, class: className })}
|
|
136
|
+
context={{ variant, size }}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
);
|
|
152
141
|
type IButtonTextProps = React.ComponentPropsWithoutRef<typeof UIButton.Text> &
|
|
153
142
|
VariantProps<typeof buttonTextStyle> & { className?: string };
|
|
154
|
-
const ButtonText = React.forwardRef<
|
|
155
|
-
|
|
156
|
-
|
|
143
|
+
const ButtonText = React.forwardRef<React.ElementRef<typeof UIButton.Text>, IButtonTextProps>(
|
|
144
|
+
({ className, size, ...props }, ref) => {
|
|
145
|
+
const { size: parentSize, variant: parentVariant } = useStyleContext(SCOPE);
|
|
146
|
+
return (
|
|
147
|
+
<UIButton.Text
|
|
148
|
+
ref={ref}
|
|
149
|
+
{...props}
|
|
150
|
+
className={buttonTextStyle({
|
|
151
|
+
parentVariants: {
|
|
152
|
+
size: parentSize,
|
|
153
|
+
variant: parentVariant,
|
|
154
|
+
},
|
|
155
|
+
size,
|
|
156
|
+
class: className,
|
|
157
|
+
})}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
const ButtonSpinner = React.forwardRef<
|
|
163
|
+
React.ElementRef<typeof UIButton.Spinner>,
|
|
164
|
+
React.ComponentPropsWithoutRef<typeof UIButton.Spinner>
|
|
157
165
|
>(({ className, size, ...props }, ref) => {
|
|
158
|
-
const { size: parentSize
|
|
166
|
+
const { size: parentSize } = useStyleContext(SCOPE);
|
|
159
167
|
return (
|
|
160
|
-
<UIButton.
|
|
168
|
+
<UIButton.Spinner
|
|
161
169
|
ref={ref}
|
|
162
170
|
{...props}
|
|
163
|
-
className={
|
|
164
|
-
parentVariants: {
|
|
165
|
-
size: parentSize,
|
|
166
|
-
variant: parentVariant,
|
|
167
|
-
},
|
|
168
|
-
size,
|
|
169
|
-
class: className,
|
|
170
|
-
})}
|
|
171
|
+
className={buttonSpinnerStyle({ parentVariants: { size: parentSize }, class: className, size: size as any })}
|
|
171
172
|
/>
|
|
172
173
|
);
|
|
173
174
|
});
|
|
174
|
-
const ButtonSpinner = React.forwardRef<
|
|
175
|
-
React.ElementRef<typeof UIButton.Spinner>,
|
|
176
|
-
React.ComponentPropsWithoutRef<typeof UIButton.Spinner>
|
|
177
|
-
>(({ className, size, ...props }, ref) => {
|
|
178
|
-
const { size: parentSize } = useStyleContext(SCOPE);
|
|
179
|
-
return <UIButton.Spinner ref={ref} {...props} className={buttonSpinnerStyle({ parentVariants: { size: parentSize }, class: className, size: size as any })} />;
|
|
180
|
-
});
|
|
181
175
|
type IButtonIcon = React.ComponentPropsWithoutRef<typeof UIButton.Icon> &
|
|
182
176
|
VariantProps<typeof buttonIconStyle> & {
|
|
183
177
|
className?: string | undefined;
|
|
@@ -185,63 +179,33 @@ type IButtonIcon = React.ComponentPropsWithoutRef<typeof UIButton.Icon> &
|
|
|
185
179
|
height?: number;
|
|
186
180
|
width?: number;
|
|
187
181
|
};
|
|
188
|
-
const ButtonIcon = React.forwardRef<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
182
|
+
const ButtonIcon = React.forwardRef<React.ElementRef<typeof UIButton.Icon>, IButtonIcon>(
|
|
183
|
+
({ className, size, ...props }, ref) => {
|
|
184
|
+
const { size: parentSize, variant: parentVariant } = useStyleContext(SCOPE);
|
|
185
|
+
if (typeof size === 'number') {
|
|
186
|
+
return <UIButton.Icon ref={ref} {...props} className={buttonIconStyle({ class: className })} size={size} />;
|
|
187
|
+
} else if ((props.height !== undefined || props.width !== undefined) && size === undefined) {
|
|
188
|
+
return <UIButton.Icon ref={ref} {...props} className={buttonIconStyle({ class: className })} />;
|
|
189
|
+
}
|
|
194
190
|
return (
|
|
195
191
|
<UIButton.Icon
|
|
196
|
-
ref={ref}
|
|
197
192
|
{...props}
|
|
198
|
-
className={buttonIconStyle({
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
<UIButton.Icon
|
|
193
|
+
className={buttonIconStyle({
|
|
194
|
+
parentVariants: {
|
|
195
|
+
size: parentSize,
|
|
196
|
+
variant: parentVariant,
|
|
197
|
+
},
|
|
198
|
+
size,
|
|
199
|
+
class: className,
|
|
200
|
+
})}
|
|
208
201
|
ref={ref}
|
|
209
|
-
{...props}
|
|
210
|
-
className={buttonIconStyle({ class: className })}
|
|
211
202
|
/>
|
|
212
203
|
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
parentVariants: {
|
|
219
|
-
size: parentSize,
|
|
220
|
-
variant: parentVariant,
|
|
221
|
-
},
|
|
222
|
-
size,
|
|
223
|
-
class: className,
|
|
224
|
-
})}
|
|
225
|
-
ref={ref}
|
|
226
|
-
/>
|
|
227
|
-
);
|
|
228
|
-
});
|
|
229
|
-
type IButtonGroupProps = React.ComponentPropsWithoutRef<typeof UIButton.Group> &
|
|
230
|
-
VariantProps<typeof buttonGroupStyle>;
|
|
231
|
-
const ButtonGroup = React.forwardRef<
|
|
232
|
-
React.ElementRef<typeof UIButton.Group>,
|
|
233
|
-
IButtonGroupProps
|
|
234
|
-
>(
|
|
235
|
-
(
|
|
236
|
-
{
|
|
237
|
-
className,
|
|
238
|
-
space = 'md',
|
|
239
|
-
isAttached = false,
|
|
240
|
-
flexDirection = 'column',
|
|
241
|
-
...props
|
|
242
|
-
},
|
|
243
|
-
ref
|
|
244
|
-
) => {
|
|
204
|
+
},
|
|
205
|
+
);
|
|
206
|
+
type IButtonGroupProps = React.ComponentPropsWithoutRef<typeof UIButton.Group> & VariantProps<typeof buttonGroupStyle>;
|
|
207
|
+
const ButtonGroup = React.forwardRef<React.ElementRef<typeof UIButton.Group>, IButtonGroupProps>(
|
|
208
|
+
({ className, space = 'md', isAttached = false, flexDirection = 'column', ...props }, ref) => {
|
|
245
209
|
return (
|
|
246
210
|
<UIButton.Group
|
|
247
211
|
className={buttonGroupStyle({
|
|
@@ -254,7 +218,7 @@ const ButtonGroup = React.forwardRef<
|
|
|
254
218
|
ref={ref}
|
|
255
219
|
/>
|
|
256
220
|
);
|
|
257
|
-
}
|
|
221
|
+
},
|
|
258
222
|
);
|
|
259
223
|
Button.displayName = 'Button';
|
|
260
224
|
ButtonText.displayName = 'ButtonText';
|