@grupalia/rn-ui-kit 0.17.0 → 0.19.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/README.md +27 -0
- package/lib/commonjs/UIKitProvider.js +41 -0
- package/lib/commonjs/UIKitProvider.js.map +1 -0
- package/lib/commonjs/assets/illustrations/warning.svg +1 -0
- package/lib/commonjs/components/AppView.js +64 -0
- package/lib/commonjs/components/AppView.js.map +1 -0
- package/lib/commonjs/components/BaseDatesScrollView.js +13 -7
- package/lib/commonjs/components/BaseDatesScrollView.js.map +1 -1
- package/lib/commonjs/components/BaseErrorBox.js +92 -0
- package/lib/commonjs/components/BaseErrorBox.js.map +1 -0
- package/lib/commonjs/components/BaseErrorScreen.js +41 -0
- package/lib/commonjs/components/BaseErrorScreen.js.map +1 -0
- package/lib/commonjs/components/BaseStickyFooter.js +19 -0
- package/lib/commonjs/components/BaseStickyFooter.js.map +1 -0
- package/lib/commonjs/components/DateSelector.js +10 -5
- package/lib/commonjs/components/DateSelector.js.map +1 -1
- package/lib/commonjs/components/DateTimeSelector.js +89 -48
- package/lib/commonjs/components/DateTimeSelector.js.map +1 -1
- package/lib/commonjs/components/NetworkBanner.js +73 -0
- package/lib/commonjs/components/NetworkBanner.js.map +1 -0
- package/lib/commonjs/components/index.js +21 -0
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/svgs/Warning.js +15 -0
- package/lib/commonjs/components/svgs/Warning.js.map +1 -0
- package/lib/commonjs/hooks/index.js +22 -13
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/useInternetConnectionStatus.js +24 -14
- package/lib/commonjs/hooks/useInternetConnectionStatus.js.map +1 -1
- package/lib/commonjs/hooks/useTimezonedDate.js +73 -0
- package/lib/commonjs/hooks/useTimezonedDate.js.map +1 -0
- package/lib/commonjs/index.js +36 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/test-setup.js +11 -0
- package/lib/commonjs/test-setup.js.map +1 -0
- package/lib/commonjs/utils/filters.js +52 -0
- package/lib/commonjs/utils/filters.js.map +1 -0
- package/lib/commonjs/utils/index.js +11 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/module/UIKitProvider.js +34 -0
- package/lib/module/UIKitProvider.js.map +1 -0
- package/lib/module/assets/illustrations/warning.svg +1 -0
- package/lib/module/components/AppView.js +59 -0
- package/lib/module/components/AppView.js.map +1 -0
- package/lib/module/components/BaseDatesScrollView.js +15 -9
- package/lib/module/components/BaseDatesScrollView.js.map +1 -1
- package/lib/module/components/BaseErrorBox.js +87 -0
- package/lib/module/components/BaseErrorBox.js.map +1 -0
- package/lib/module/components/BaseErrorScreen.js +36 -0
- package/lib/module/components/BaseErrorScreen.js.map +1 -0
- package/lib/module/components/BaseStickyFooter.js +15 -0
- package/lib/module/components/BaseStickyFooter.js.map +1 -0
- package/lib/module/components/DateSelector.js +11 -6
- package/lib/module/components/DateSelector.js.map +1 -1
- package/lib/module/components/DateTimeSelector.js +90 -48
- package/lib/module/components/DateTimeSelector.js.map +1 -1
- package/lib/module/components/NetworkBanner.js +67 -0
- package/lib/module/components/NetworkBanner.js.map +1 -0
- package/lib/module/components/index.js +3 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/svgs/Warning.js +10 -0
- package/lib/module/components/svgs/Warning.js.map +1 -0
- package/lib/module/hooks/index.js +2 -1
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useInternetConnectionStatus.js +23 -13
- package/lib/module/hooks/useInternetConnectionStatus.js.map +1 -1
- package/lib/module/hooks/useTimezonedDate.js +70 -0
- package/lib/module/hooks/useTimezonedDate.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/test-setup.js +10 -0
- package/lib/module/test-setup.js.map +1 -0
- package/lib/module/utils/filters.js +48 -0
- package/lib/module/utils/filters.js.map +1 -0
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/commonjs/UIKitProvider.d.ts +15 -0
- package/lib/typescript/commonjs/UIKitProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/__tests__/smoke.test.d.ts +2 -0
- package/lib/typescript/commonjs/__tests__/smoke.test.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/AppView.d.ts +19 -0
- package/lib/typescript/commonjs/components/AppView.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/BaseDatesScrollView.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/BaseErrorBox.d.ts +14 -0
- package/lib/typescript/commonjs/components/BaseErrorBox.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/BaseErrorScreen.d.ts +13 -0
- package/lib/typescript/commonjs/components/BaseErrorScreen.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/BaseStickyFooter.d.ts +11 -0
- package/lib/typescript/commonjs/components/BaseStickyFooter.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/DateSelector.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/DateTimeSelector.d.ts +10 -4
- package/lib/typescript/commonjs/components/DateTimeSelector.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/FormikDateTimeSelector.d.ts +1 -1
- package/lib/typescript/commonjs/components/FormikDateTimeSelectorBottomSheet.d.ts +1 -1
- package/lib/typescript/commonjs/components/NetworkBanner.d.ts +10 -0
- package/lib/typescript/commonjs/components/NetworkBanner.d.ts.map +1 -0
- package/lib/typescript/commonjs/components/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/components/svgs/Warning.d.ts +6 -0
- package/lib/typescript/commonjs/components/svgs/Warning.d.ts.map +1 -0
- package/lib/typescript/commonjs/hooks/index.d.ts +2 -1
- package/lib/typescript/commonjs/hooks/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/useInternetConnectionStatus.d.ts +4 -4
- package/lib/typescript/commonjs/hooks/useInternetConnectionStatus.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/useTimezonedDate.d.ts +59 -0
- package/lib/typescript/commonjs/hooks/useTimezonedDate.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +3 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/test-setup.d.ts +2 -0
- package/lib/typescript/commonjs/test-setup.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/filters.d.ts +4 -0
- package/lib/typescript/commonjs/utils/filters.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/index.d.ts +1 -0
- package/lib/typescript/commonjs/utils/index.d.ts.map +1 -1
- package/lib/typescript/module/UIKitProvider.d.ts +15 -0
- package/lib/typescript/module/UIKitProvider.d.ts.map +1 -0
- package/lib/typescript/module/__tests__/smoke.test.d.ts +2 -0
- package/lib/typescript/module/__tests__/smoke.test.d.ts.map +1 -0
- package/lib/typescript/module/components/AppView.d.ts +19 -0
- package/lib/typescript/module/components/AppView.d.ts.map +1 -0
- package/lib/typescript/module/components/BaseDatesScrollView.d.ts.map +1 -1
- package/lib/typescript/module/components/BaseErrorBox.d.ts +14 -0
- package/lib/typescript/module/components/BaseErrorBox.d.ts.map +1 -0
- package/lib/typescript/module/components/BaseErrorScreen.d.ts +13 -0
- package/lib/typescript/module/components/BaseErrorScreen.d.ts.map +1 -0
- package/lib/typescript/module/components/BaseStickyFooter.d.ts +11 -0
- package/lib/typescript/module/components/BaseStickyFooter.d.ts.map +1 -0
- package/lib/typescript/module/components/DateSelector.d.ts.map +1 -1
- package/lib/typescript/module/components/DateTimeSelector.d.ts +10 -4
- package/lib/typescript/module/components/DateTimeSelector.d.ts.map +1 -1
- package/lib/typescript/module/components/FormikDateTimeSelector.d.ts +1 -1
- package/lib/typescript/module/components/FormikDateTimeSelectorBottomSheet.d.ts +1 -1
- package/lib/typescript/module/components/NetworkBanner.d.ts +10 -0
- package/lib/typescript/module/components/NetworkBanner.d.ts.map +1 -0
- package/lib/typescript/module/components/index.d.ts +3 -0
- package/lib/typescript/module/components/index.d.ts.map +1 -1
- package/lib/typescript/module/components/svgs/Warning.d.ts +6 -0
- package/lib/typescript/module/components/svgs/Warning.d.ts.map +1 -0
- package/lib/typescript/module/hooks/index.d.ts +2 -1
- package/lib/typescript/module/hooks/index.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useInternetConnectionStatus.d.ts +4 -4
- package/lib/typescript/module/hooks/useInternetConnectionStatus.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useTimezonedDate.d.ts +59 -0
- package/lib/typescript/module/hooks/useTimezonedDate.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +3 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/test-setup.d.ts +2 -0
- package/lib/typescript/module/test-setup.d.ts.map +1 -0
- package/lib/typescript/module/utils/filters.d.ts +4 -0
- package/lib/typescript/module/utils/filters.d.ts.map +1 -0
- package/lib/typescript/module/utils/index.d.ts +1 -0
- package/lib/typescript/module/utils/index.d.ts.map +1 -1
- package/package.json +19 -9
- package/src/components/BaseAlert.tsx +0 -181
- package/src/components/BaseBadge.tsx +0 -192
- package/src/components/BaseBottomSheetModal.tsx +0 -50
- package/src/components/BaseButton.tsx +0 -317
- package/src/components/BaseConfirmationModal.tsx +0 -66
- package/src/components/BaseDateInput.tsx +0 -153
- package/src/components/BaseDatesScrollView.tsx +0 -123
- package/src/components/BaseHorizontalTabs.tsx +0 -225
- package/src/components/BaseIcon.tsx +0 -41
- package/src/components/BaseIconBox.tsx +0 -75
- package/src/components/BaseRadioGroup.tsx +0 -75
- package/src/components/BaseSelect.tsx +0 -170
- package/src/components/BaseSelectionItem.tsx +0 -85
- package/src/components/BaseSpinner.tsx +0 -21
- package/src/components/BaseStackedList.tsx +0 -146
- package/src/components/BaseSwitch.tsx +0 -48
- package/src/components/BaseText.tsx +0 -34
- package/src/components/CameraImageInput.tsx +0 -610
- package/src/components/CameraWrapperModal.tsx +0 -309
- package/src/components/DateSelector.tsx +0 -91
- package/src/components/DateTimeSelector.tsx +0 -267
- package/src/components/FormikCameraImageInput.tsx +0 -39
- package/src/components/FormikDateInput.tsx +0 -53
- package/src/components/FormikDateSelector.tsx +0 -36
- package/src/components/FormikDateTimeSelector.tsx +0 -49
- package/src/components/FormikDateTimeSelectorBottomSheet.tsx +0 -129
- package/src/components/FormikRadioGroup.tsx +0 -35
- package/src/components/FormikSelect.tsx +0 -49
- package/src/components/ImagePickerBottomSheet.tsx +0 -109
- package/src/components/PhotoPickerModal.tsx +0 -116
- package/src/components/PressableOpacity.tsx +0 -88
- package/src/components/Toasts.tsx +0 -200
- package/src/components/index.ts +0 -30
- package/src/components/svgs/Camera.tsx +0 -14
- package/src/hooks/index.ts +0 -3
- package/src/hooks/useBreakpoints.ts +0 -20
- package/src/hooks/useInternetConnectionStatus.ts +0 -221
- package/src/hooks/useIsAboveBreakpoint.ts +0 -8
- package/src/utils/clabe.ts +0 -31
- package/src/utils/date.ts +0 -1
- package/src/utils/fileDirectoryUtils.ts +0 -12
- package/src/utils/fonts.ts +0 -118
- package/src/utils/index.ts +0 -3
- package/src/utils/mx-banks.json +0 -492
- package/src/utils/mx-banks.ts +0 -9
- package/src/utils/timeConstants.ts +0 -19
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { styled } from 'nativewind';
|
|
3
|
-
import { ViewProps } from 'react-native';
|
|
4
|
-
|
|
5
|
-
import { View } from '../hoc-components';
|
|
6
|
-
import BaseIcon from './BaseIcon';
|
|
7
|
-
import BaseText from './BaseText';
|
|
8
|
-
import { HeroIcon } from '../types/heroicons';
|
|
9
|
-
|
|
10
|
-
export type BadgeVariant =
|
|
11
|
-
'gray' |
|
|
12
|
-
'brand' |
|
|
13
|
-
'error' |
|
|
14
|
-
'warning' |
|
|
15
|
-
'success' |
|
|
16
|
-
'blue_gray' |
|
|
17
|
-
'blue_light' |
|
|
18
|
-
'blue' |
|
|
19
|
-
'indigo' |
|
|
20
|
-
'purple' |
|
|
21
|
-
'pink' |
|
|
22
|
-
'orange';
|
|
23
|
-
|
|
24
|
-
export type BadgeSize = 'sm' | 'md' | 'lg';
|
|
25
|
-
|
|
26
|
-
interface BaseBadgeProps extends ViewProps {
|
|
27
|
-
variant?: BadgeVariant;
|
|
28
|
-
size?: BadgeSize;
|
|
29
|
-
text: string;
|
|
30
|
-
transparent?: boolean;
|
|
31
|
-
squared?: boolean;
|
|
32
|
-
leftIcon?: HeroIcon | null;
|
|
33
|
-
rightIcon?: HeroIcon | null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function BaseBadge({
|
|
37
|
-
variant = 'gray',
|
|
38
|
-
size = 'md',
|
|
39
|
-
text,
|
|
40
|
-
transparent = false,
|
|
41
|
-
squared = false,
|
|
42
|
-
leftIcon = null,
|
|
43
|
-
rightIcon = null,
|
|
44
|
-
...props
|
|
45
|
-
}: BaseBadgeProps) {
|
|
46
|
-
const variantStyles = {
|
|
47
|
-
gray: {
|
|
48
|
-
bg: 'bg-utility-gray-50',
|
|
49
|
-
text: 'text-utility-gray-700',
|
|
50
|
-
border: 'border-utility-gray-200',
|
|
51
|
-
},
|
|
52
|
-
brand: {
|
|
53
|
-
bg: 'bg-utility-brand-50',
|
|
54
|
-
text: 'text-utility-brand-700',
|
|
55
|
-
border: 'border-utility-brand-200',
|
|
56
|
-
},
|
|
57
|
-
error: {
|
|
58
|
-
bg: 'bg-utility-error-50',
|
|
59
|
-
text: 'text-utility-error-700',
|
|
60
|
-
border: 'border-utility-error-200',
|
|
61
|
-
},
|
|
62
|
-
warning: {
|
|
63
|
-
bg: 'bg-utility-warning-50',
|
|
64
|
-
text: 'text-utility-warning-700',
|
|
65
|
-
border: 'border-utility-warning-200',
|
|
66
|
-
},
|
|
67
|
-
success: {
|
|
68
|
-
bg: 'bg-utility-success-50',
|
|
69
|
-
text: 'text-utility-success-700',
|
|
70
|
-
border: 'border-utility-success-200',
|
|
71
|
-
},
|
|
72
|
-
blue_gray: {
|
|
73
|
-
bg: 'bg-utility-gray_blue-50',
|
|
74
|
-
text: 'text-utility-gray_blue-700',
|
|
75
|
-
border: 'border-utility-gray_blue-200',
|
|
76
|
-
},
|
|
77
|
-
blue_light: {
|
|
78
|
-
bg: 'bg-utility-blue_light-50',
|
|
79
|
-
text: 'text-utility-blue_light-700',
|
|
80
|
-
border: 'border-utility-blue_light-200',
|
|
81
|
-
},
|
|
82
|
-
blue: {
|
|
83
|
-
bg: 'bg-utility-blue-50',
|
|
84
|
-
text: 'text-utility-blue-700',
|
|
85
|
-
border: 'border-utility-blue-200',
|
|
86
|
-
},
|
|
87
|
-
indigo: {
|
|
88
|
-
bg: 'bg-utility-indigo-50',
|
|
89
|
-
text: 'text-utility-indigo-700',
|
|
90
|
-
border: 'border-utility-indigo-200',
|
|
91
|
-
},
|
|
92
|
-
purple: {
|
|
93
|
-
bg: 'bg-utility-purple-50',
|
|
94
|
-
text: 'text-utility-purple-700',
|
|
95
|
-
border: 'border-utility-purple-200',
|
|
96
|
-
},
|
|
97
|
-
pink: {
|
|
98
|
-
bg: 'bg-utility-pink-50',
|
|
99
|
-
text: 'text-utility-pink-700',
|
|
100
|
-
border: 'border-utility-pink-200',
|
|
101
|
-
},
|
|
102
|
-
orange: {
|
|
103
|
-
bg: 'bg-utility-orange-50',
|
|
104
|
-
text: 'text-utility-orange-700',
|
|
105
|
-
border: 'border-utility-orange-200',
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const sizeStyles = {
|
|
110
|
-
sm: {
|
|
111
|
-
container: 'px-1.5 py-0.5',
|
|
112
|
-
text: 'text-xs',
|
|
113
|
-
},
|
|
114
|
-
md: {
|
|
115
|
-
container: 'px-2.5 py-0.5',
|
|
116
|
-
text: 'text-sm',
|
|
117
|
-
},
|
|
118
|
-
lg: {
|
|
119
|
-
container: 'px-3 py-1',
|
|
120
|
-
text: 'text-base',
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const iconSizes = {
|
|
125
|
-
sm: 12,
|
|
126
|
-
md: 14,
|
|
127
|
-
lg: 16,
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const containerStyles = clsx(
|
|
131
|
-
'flex-row items-center justify-center border',
|
|
132
|
-
squared ? 'rounded-md' : 'rounded-full',
|
|
133
|
-
transparent ? 'bg-transparent' : variantStyles[variant].bg,
|
|
134
|
-
transparent ? 'border-primary' : variantStyles[variant].border,
|
|
135
|
-
sizeStyles[size].container,
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
const textStyles = clsx(
|
|
139
|
-
'font-medium',
|
|
140
|
-
variantStyles[variant].text,
|
|
141
|
-
sizeStyles[size].text,
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
const iconSpacingStyles = {
|
|
145
|
-
left: 'mr-1.5',
|
|
146
|
-
right: 'ml-1.5',
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const iconColors = {
|
|
150
|
-
gray: 'utility-gray-500',
|
|
151
|
-
brand: 'utility-brand-500',
|
|
152
|
-
error: 'utility-error-500',
|
|
153
|
-
warning: 'utility-warning-500',
|
|
154
|
-
success: 'utility-success-500',
|
|
155
|
-
blue_gray: 'utility-gray_blue-500',
|
|
156
|
-
blue_light: 'utility-blue_light-500',
|
|
157
|
-
blue: 'utility-blue-500',
|
|
158
|
-
indigo: 'utility-indigo-500',
|
|
159
|
-
purple: 'utility-purple-500',
|
|
160
|
-
pink: 'utility-pink-500',
|
|
161
|
-
orange: 'utility-orange-500',
|
|
162
|
-
} as const;
|
|
163
|
-
|
|
164
|
-
return (
|
|
165
|
-
<View
|
|
166
|
-
className={containerStyles}
|
|
167
|
-
{...props}
|
|
168
|
-
>
|
|
169
|
-
{leftIcon && (
|
|
170
|
-
<View className={iconSpacingStyles.left}>
|
|
171
|
-
<BaseIcon
|
|
172
|
-
icon={leftIcon}
|
|
173
|
-
size={iconSizes[size]}
|
|
174
|
-
color={iconColors[variant]}
|
|
175
|
-
/>
|
|
176
|
-
</View>
|
|
177
|
-
)}
|
|
178
|
-
<BaseText className={textStyles}>{text}</BaseText>
|
|
179
|
-
{rightIcon && (
|
|
180
|
-
<View className={iconSpacingStyles.right}>
|
|
181
|
-
<BaseIcon
|
|
182
|
-
icon={rightIcon}
|
|
183
|
-
size={iconSizes[size]}
|
|
184
|
-
color={iconColors[variant]}
|
|
185
|
-
/>
|
|
186
|
-
</View>
|
|
187
|
-
)}
|
|
188
|
-
</View>
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export default styled(BaseBadge);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BottomSheetModal,
|
|
3
|
-
BottomSheetBackdrop,
|
|
4
|
-
BottomSheetBackdropProps,
|
|
5
|
-
BottomSheetModalProps,
|
|
6
|
-
BottomSheetView,
|
|
7
|
-
} from '@gorhom/bottom-sheet';
|
|
8
|
-
import { forwardRef, ReactNode } from 'react';
|
|
9
|
-
import { StyleSheet } from 'react-native';
|
|
10
|
-
|
|
11
|
-
function BackdropComponent(props: BottomSheetBackdropProps) {
|
|
12
|
-
return (
|
|
13
|
-
<BottomSheetBackdrop
|
|
14
|
-
{...props}
|
|
15
|
-
opacity={0.5}
|
|
16
|
-
enableTouchThrough={false}
|
|
17
|
-
appearsOnIndex={0}
|
|
18
|
-
disappearsOnIndex={-1}
|
|
19
|
-
style={[{ backgroundColor: 'rgba(0, 0, 0, 1)' }, StyleSheet.absoluteFillObject]}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface BaseBottomSheetModalProps extends BottomSheetModalProps {
|
|
25
|
-
children: ReactNode;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const BaseBottomSheetModal = forwardRef<
|
|
29
|
-
BottomSheetModal,
|
|
30
|
-
BaseBottomSheetModalProps
|
|
31
|
-
>(({ children, ...props }, ref) => (
|
|
32
|
-
<BottomSheetModal
|
|
33
|
-
ref={ref}
|
|
34
|
-
backdropComponent={BackdropComponent}
|
|
35
|
-
style={{
|
|
36
|
-
shadowColor: 'black',
|
|
37
|
-
shadowOffset: { width: 0, height: 10 },
|
|
38
|
-
shadowOpacity: 0.53,
|
|
39
|
-
shadowRadius: 13.97,
|
|
40
|
-
elevation: 21,
|
|
41
|
-
}}
|
|
42
|
-
{...props}
|
|
43
|
-
>
|
|
44
|
-
<BottomSheetView>
|
|
45
|
-
{children}
|
|
46
|
-
</BottomSheetView>
|
|
47
|
-
</BottomSheetModal>
|
|
48
|
-
));
|
|
49
|
-
|
|
50
|
-
export default BaseBottomSheetModal;
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import { styled } from 'nativewind';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { GestureResponderEvent } from 'react-native';
|
|
5
|
-
|
|
6
|
-
import { View, ActivityIndicator } from '../hoc-components';
|
|
7
|
-
import BaseIcon from './BaseIcon';
|
|
8
|
-
import BaseText from './BaseText';
|
|
9
|
-
import PressableOpacity from './PressableOpacity';
|
|
10
|
-
import { Color as ForegroundColor } from '../styles/foreground-colors';
|
|
11
|
-
import { HeroIcon } from '../types/heroicons';
|
|
12
|
-
|
|
13
|
-
interface ButtonProps extends React.ComponentProps<typeof PressableOpacity> {
|
|
14
|
-
variant?: 'primary' | 'secondary' | 'tertiary' | 'link-color' | 'link-gray';
|
|
15
|
-
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
16
|
-
text?: string;
|
|
17
|
-
loading?: boolean;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
destructive?: boolean;
|
|
20
|
-
leftIcon?: HeroIcon | null;
|
|
21
|
-
rightIcon?: HeroIcon | null;
|
|
22
|
-
countdownSecs?: number;
|
|
23
|
-
debounceSecs?: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function BaseButton({
|
|
27
|
-
variant = 'primary',
|
|
28
|
-
size = 'md',
|
|
29
|
-
text = '',
|
|
30
|
-
loading = false,
|
|
31
|
-
disabled = false,
|
|
32
|
-
destructive = false,
|
|
33
|
-
leftIcon = null,
|
|
34
|
-
rightIcon = null,
|
|
35
|
-
hitSlop = 6,
|
|
36
|
-
countdownSecs = 0,
|
|
37
|
-
debounceSecs = 0,
|
|
38
|
-
onPress,
|
|
39
|
-
...props
|
|
40
|
-
}: ButtonProps) {
|
|
41
|
-
const [timer, setTimer] = React.useState(countdownSecs);
|
|
42
|
-
const [timerUsed, setTimerUsed] = React.useState(false);
|
|
43
|
-
const [debounce, setDebounce] = React.useState<number>(0);
|
|
44
|
-
const [isDisabled, setIsDisabled] = React.useState(disabled || countdownSecs > 0);
|
|
45
|
-
|
|
46
|
-
React.useEffect(() => {
|
|
47
|
-
let intervalId: NodeJS.Timeout;
|
|
48
|
-
if (countdownSecs > 0 && !timerUsed) {
|
|
49
|
-
setIsDisabled(true);
|
|
50
|
-
setTimer(countdownSecs);
|
|
51
|
-
intervalId = setInterval(() => {
|
|
52
|
-
setTimer((prevTimer: number) => {
|
|
53
|
-
if (prevTimer <= 1) {
|
|
54
|
-
clearInterval(intervalId);
|
|
55
|
-
setIsDisabled(Boolean(disabled));
|
|
56
|
-
setTimerUsed(true);
|
|
57
|
-
return 0;
|
|
58
|
-
}
|
|
59
|
-
return prevTimer - 1;
|
|
60
|
-
});
|
|
61
|
-
}, 1000);
|
|
62
|
-
} else {
|
|
63
|
-
setIsDisabled(Boolean(disabled));
|
|
64
|
-
}
|
|
65
|
-
return () => {
|
|
66
|
-
if (intervalId) clearInterval(intervalId);
|
|
67
|
-
};
|
|
68
|
-
}, [countdownSecs, disabled, timerUsed]);
|
|
69
|
-
|
|
70
|
-
React.useEffect(() => {
|
|
71
|
-
let timeout: NodeJS.Timeout | undefined;
|
|
72
|
-
|
|
73
|
-
if (debounce > 0) {
|
|
74
|
-
setIsDisabled(true);
|
|
75
|
-
timeout = setTimeout(() => {
|
|
76
|
-
setDebounce((prev: number) => {
|
|
77
|
-
if (prev <= 1) {
|
|
78
|
-
setIsDisabled(false);
|
|
79
|
-
return 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return prev - 1;
|
|
83
|
-
});
|
|
84
|
-
}, 1000);
|
|
85
|
-
}
|
|
86
|
-
return () => {
|
|
87
|
-
if (timeout) clearTimeout(timeout);
|
|
88
|
-
};
|
|
89
|
-
}, [debounce, disabled]);
|
|
90
|
-
|
|
91
|
-
function handleOnPress(e: GestureResponderEvent) {
|
|
92
|
-
onPress?.(e);
|
|
93
|
-
if (debounceSecs) {
|
|
94
|
-
setDebounce(debounceSecs);
|
|
95
|
-
setIsDisabled(true);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const sizeClasses = {
|
|
100
|
-
xs: 'rounded-md h-8 px-4',
|
|
101
|
-
sm: 'rounded-md h-9 px-4',
|
|
102
|
-
md: 'rounded-lg h-10 px-5',
|
|
103
|
-
lg: 'rounded-lg h-11 px-5',
|
|
104
|
-
xl: 'rounded-lg h-12 px-6',
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const iconOnlyClasses = {
|
|
108
|
-
xs: 'rounded-md h-8 w-8',
|
|
109
|
-
sm: 'rounded-md h-9 w-9',
|
|
110
|
-
md: 'rounded-lg h-10 w-10',
|
|
111
|
-
lg: 'rounded-lg h-11 w-11',
|
|
112
|
-
xl: 'rounded-lg h-12 w-12',
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const containerClasses = {
|
|
116
|
-
primary: {
|
|
117
|
-
default: destructive ? 'bg-error-solid' : 'bg-brand-solid',
|
|
118
|
-
disabled: 'bg-disabled border border-disabled_subtle',
|
|
119
|
-
loading: destructive ? 'bg-error-solid' : 'bg-brand-solid_hover',
|
|
120
|
-
},
|
|
121
|
-
secondary: {
|
|
122
|
-
default: destructive ? 'bg-primary border border-error_subtle' : 'bg-primary border border-primary',
|
|
123
|
-
disabled: 'bg-primary border border-disabled_subtle',
|
|
124
|
-
loading: destructive ? 'bg-error-primary border border-error_subtle' : 'bg-primary_hover border border-primary',
|
|
125
|
-
},
|
|
126
|
-
tertiary: {
|
|
127
|
-
default: 'bg-transparent',
|
|
128
|
-
disabled: 'bg-transparent',
|
|
129
|
-
loading: destructive ? 'bg-error-primary' : 'bg-primary_hover',
|
|
130
|
-
},
|
|
131
|
-
'link-color': {
|
|
132
|
-
default: 'bg-transparent',
|
|
133
|
-
disabled: 'bg-transparent',
|
|
134
|
-
loading: 'bg-transparent',
|
|
135
|
-
},
|
|
136
|
-
'link-gray': {
|
|
137
|
-
default: 'bg-transparent',
|
|
138
|
-
disabled: 'bg-transparent',
|
|
139
|
-
loading: 'bg-transparent',
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const textColorClasses = {
|
|
144
|
-
primary: {
|
|
145
|
-
default: 'text-white',
|
|
146
|
-
disabled: 'text-disabled',
|
|
147
|
-
loading: 'text-white',
|
|
148
|
-
},
|
|
149
|
-
secondary: {
|
|
150
|
-
default: destructive ? 'text-error' : 'text-secondary',
|
|
151
|
-
disabled: 'text-disabled',
|
|
152
|
-
loading: destructive ? 'text-error-primary' : 'text-secondary',
|
|
153
|
-
},
|
|
154
|
-
tertiary: {
|
|
155
|
-
default: destructive ? 'text-error' : 'text-tertiary',
|
|
156
|
-
disabled: 'text-disabled',
|
|
157
|
-
loading: destructive ? 'text-error-primary' : 'text-tertiary',
|
|
158
|
-
},
|
|
159
|
-
'link-color': {
|
|
160
|
-
default: destructive ? 'text-error' : 'text-brand-tertiary',
|
|
161
|
-
disabled: 'text-disabled',
|
|
162
|
-
loading: destructive ? 'text-error' : 'text-brand-tertiary',
|
|
163
|
-
},
|
|
164
|
-
'link-gray': {
|
|
165
|
-
default: destructive ? 'text-error' : 'text-tertiary',
|
|
166
|
-
disabled: 'text-disabled',
|
|
167
|
-
loading: destructive ? 'text-error' : 'text-tertiary',
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const textSizeClasses = {
|
|
172
|
-
xs: 'text-xs',
|
|
173
|
-
sm: 'text-sm',
|
|
174
|
-
md: 'text-sm',
|
|
175
|
-
lg: 'text-sm',
|
|
176
|
-
xl: 'text-base',
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
let buttonState: 'default' | 'disabled' | 'loading' = 'default';
|
|
180
|
-
if (loading) {
|
|
181
|
-
buttonState = 'loading';
|
|
182
|
-
} else if (isDisabled) {
|
|
183
|
-
buttonState = 'disabled';
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const isIconOnly = !text && (leftIcon || rightIcon);
|
|
187
|
-
|
|
188
|
-
const buttonStyles = clsx(
|
|
189
|
-
'flex flex-row items-center justify-center',
|
|
190
|
-
isIconOnly ? iconOnlyClasses[size] : sizeClasses[size],
|
|
191
|
-
containerClasses[variant][buttonState],
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
const textStyles = clsx(
|
|
195
|
-
'font-medium',
|
|
196
|
-
textSizeClasses[size],
|
|
197
|
-
textColorClasses[variant][buttonState],
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
const iconColors = {
|
|
201
|
-
primary: {
|
|
202
|
-
default: 'fg-white',
|
|
203
|
-
disabled: 'fg-disabled',
|
|
204
|
-
loading: 'fg-white',
|
|
205
|
-
},
|
|
206
|
-
secondary: {
|
|
207
|
-
default: 'fg-secondary',
|
|
208
|
-
disabled: 'fg-disabled',
|
|
209
|
-
loading: 'fg-secondary',
|
|
210
|
-
},
|
|
211
|
-
tertiary: {
|
|
212
|
-
default: 'fg-tertiary',
|
|
213
|
-
disabled: 'fg-disabled',
|
|
214
|
-
loading: 'fg-tertiary',
|
|
215
|
-
},
|
|
216
|
-
'link-color': {
|
|
217
|
-
default: 'fg-brand-primary',
|
|
218
|
-
disabled: 'fg-disabled',
|
|
219
|
-
loading: 'fg-brand-primary',
|
|
220
|
-
},
|
|
221
|
-
'link-gray': {
|
|
222
|
-
default: 'fg-secondary',
|
|
223
|
-
disabled: 'fg-disabled',
|
|
224
|
-
loading: 'fg-secondary',
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
const spinnerColorMap = {
|
|
229
|
-
primary: {
|
|
230
|
-
default: '#fff',
|
|
231
|
-
disabled: '#9AA4B2', // text-disabled color
|
|
232
|
-
loading: '#fff',
|
|
233
|
-
},
|
|
234
|
-
secondary: {
|
|
235
|
-
default: destructive ? '#F04438' : '#667085',
|
|
236
|
-
disabled: '#9AA4B2', // text-disabled color
|
|
237
|
-
loading: destructive ? '#F04438' : '#667085',
|
|
238
|
-
},
|
|
239
|
-
tertiary: {
|
|
240
|
-
default: destructive ? '#F04438' : '#667085',
|
|
241
|
-
disabled: '#9AA4B2', // text-disabled color
|
|
242
|
-
loading: destructive ? '#F04438' : '#667085',
|
|
243
|
-
},
|
|
244
|
-
'link-color': {
|
|
245
|
-
default: destructive ? '#F04438' : '#7F56D9',
|
|
246
|
-
disabled: '#9AA4B2', // text-disabled color
|
|
247
|
-
loading: destructive ? '#F04438' : '#7F56D9',
|
|
248
|
-
},
|
|
249
|
-
'link-gray': {
|
|
250
|
-
default: destructive ? '#F04438' : '#667085',
|
|
251
|
-
disabled: '#9AA4B2', // text-disabled color
|
|
252
|
-
loading: destructive ? '#F04438' : '#667085',
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
|
|
256
|
-
let spinnerColor = '#fff';
|
|
257
|
-
if (buttonState === 'disabled') {
|
|
258
|
-
spinnerColor = spinnerColorMap[variant].disabled;
|
|
259
|
-
} else if (buttonState === 'loading') {
|
|
260
|
-
spinnerColor = spinnerColorMap[variant].loading;
|
|
261
|
-
} else {
|
|
262
|
-
spinnerColor = spinnerColorMap[variant].default;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return (
|
|
266
|
-
<PressableOpacity
|
|
267
|
-
disabled={isDisabled || loading}
|
|
268
|
-
className={buttonStyles}
|
|
269
|
-
hitSlop={hitSlop}
|
|
270
|
-
onPress={(e) => handleOnPress(e)}
|
|
271
|
-
{...props}
|
|
272
|
-
>
|
|
273
|
-
<View className={clsx('flex flex-row items-center justify-center', loading && 'opacity-0')}>
|
|
274
|
-
{leftIcon && (
|
|
275
|
-
<BaseIcon
|
|
276
|
-
icon={leftIcon}
|
|
277
|
-
size={20}
|
|
278
|
-
color={iconColors[variant][buttonState] as ForegroundColor}
|
|
279
|
-
className={isIconOnly ? '' : 'mr-1.5'}
|
|
280
|
-
/>
|
|
281
|
-
)}
|
|
282
|
-
{text && (
|
|
283
|
-
<BaseText className={textStyles}>
|
|
284
|
-
{text}
|
|
285
|
-
{timer > 0 ? ` (${timer})` : ''}
|
|
286
|
-
{debounce > 0 ? ` (${debounce})` : ''}
|
|
287
|
-
</BaseText>
|
|
288
|
-
)}
|
|
289
|
-
{rightIcon && (
|
|
290
|
-
<BaseIcon
|
|
291
|
-
icon={rightIcon}
|
|
292
|
-
size={20}
|
|
293
|
-
color={iconColors[variant][buttonState] as ForegroundColor}
|
|
294
|
-
className={isIconOnly ? '' : 'ml-1.5'}
|
|
295
|
-
/>
|
|
296
|
-
)}
|
|
297
|
-
</View>
|
|
298
|
-
{loading && (
|
|
299
|
-
<ActivityIndicator
|
|
300
|
-
size="small"
|
|
301
|
-
color={spinnerColor}
|
|
302
|
-
style={{
|
|
303
|
-
position: 'absolute',
|
|
304
|
-
top: 0,
|
|
305
|
-
left: 0,
|
|
306
|
-
right: 0,
|
|
307
|
-
bottom: 0,
|
|
308
|
-
justifyContent: 'center',
|
|
309
|
-
alignItems: 'center',
|
|
310
|
-
}}
|
|
311
|
-
/>
|
|
312
|
-
)}
|
|
313
|
-
</PressableOpacity>
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export default styled(BaseButton);
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { styled } from 'nativewind';
|
|
2
|
-
|
|
3
|
-
import { View, Modal } from '../hoc-components';
|
|
4
|
-
import BaseButton from './BaseButton';
|
|
5
|
-
import BaseText from './BaseText';
|
|
6
|
-
|
|
7
|
-
interface Props extends React.ComponentProps<typeof Modal> {
|
|
8
|
-
visible: boolean;
|
|
9
|
-
title: string;
|
|
10
|
-
body: string | React.ReactNode;
|
|
11
|
-
confirmText?: string;
|
|
12
|
-
cancelText?: string;
|
|
13
|
-
onConfirm: () => void;
|
|
14
|
-
onCancel: () => void;
|
|
15
|
-
countdownSecs?: number;
|
|
16
|
-
loading?: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function BaseConfirmationModal({
|
|
20
|
-
visible,
|
|
21
|
-
title,
|
|
22
|
-
body,
|
|
23
|
-
confirmText = 'Aceptar',
|
|
24
|
-
cancelText = 'Cancelar',
|
|
25
|
-
onConfirm,
|
|
26
|
-
onCancel,
|
|
27
|
-
countdownSecs = 0,
|
|
28
|
-
loading = false,
|
|
29
|
-
...props
|
|
30
|
-
}: Props) {
|
|
31
|
-
return (
|
|
32
|
-
<Modal
|
|
33
|
-
animationType="fade"
|
|
34
|
-
transparent
|
|
35
|
-
visible={visible}
|
|
36
|
-
onRequestClose={() => onCancel()}
|
|
37
|
-
{...props}
|
|
38
|
-
>
|
|
39
|
-
<View className="flex-1 items-center justify-center bg-overlay">
|
|
40
|
-
<View className="m-4 flex flex-col space-y-4 rounded-lg bg-primary p-8">
|
|
41
|
-
<BaseText className="mb-4 text-lg font-semibold">
|
|
42
|
-
{title}
|
|
43
|
-
</BaseText>
|
|
44
|
-
{typeof body === 'string' ? (
|
|
45
|
-
<BaseText className="text-base">
|
|
46
|
-
{body}
|
|
47
|
-
</BaseText>
|
|
48
|
-
) : body}
|
|
49
|
-
<BaseButton
|
|
50
|
-
text={confirmText}
|
|
51
|
-
onPress={onConfirm}
|
|
52
|
-
loading={loading}
|
|
53
|
-
countdownSecs={countdownSecs}
|
|
54
|
-
/>
|
|
55
|
-
<BaseButton
|
|
56
|
-
variant="secondary"
|
|
57
|
-
text={cancelText}
|
|
58
|
-
onPress={onCancel}
|
|
59
|
-
/>
|
|
60
|
-
</View>
|
|
61
|
-
</View>
|
|
62
|
-
</Modal>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export default styled(BaseConfirmationModal);
|