@momo-kits/foundation 0.168.1-beta.39 → 0.168.1-beta.40
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/Application/BottomSheet.tsx +398 -86
- package/Application/BottomTab/BottomTabBar.tsx +275 -215
- package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
- package/Application/BottomTab/DuoBarCompression.tsx +28 -14
- package/Application/BottomTab/DuoTabBar.tsx +540 -32
- package/Application/BottomTab/TabBarIcon.tsx +72 -146
- package/Application/BottomTab/index.tsx +353 -89
- package/Application/BottomTab/useLiquidSelection.ts +374 -0
- package/Application/Components/BackgroundImageView.tsx +0 -4
- package/Application/Components/DuoGlassBackground.tsx +5 -7
- package/Application/Components/HeaderAnimated.tsx +13 -41
- package/Application/Components/HeaderBackground.tsx +3 -20
- package/Application/Components/HeaderExtendHeader.tsx +46 -66
- package/Application/Components/HeaderLeft.tsx +18 -5
- package/Application/Components/HeaderRight.tsx +529 -8
- package/Application/Components/HeaderTitle.tsx +579 -16
- package/Application/Components/NavigationButton.tsx +11 -18
- package/Application/Components/SearchHeader.tsx +18 -38
- package/Application/Localize.ts +0 -7
- package/Application/ModalScreen.tsx +18 -41
- package/Application/Navigation.ts +17 -15
- package/Application/NavigationContainer.tsx +21 -23
- package/Application/Navigator.ts +48 -20
- package/Application/ScaleSizeProvider.tsx +6 -13
- package/Application/StackScreen.tsx +172 -27
- package/Application/TooltipPortal.tsx +5 -12
- package/Application/WidgetContainer.tsx +7 -20
- package/Application/device.ts +52 -0
- package/Application/index.ts +1 -23
- package/Application/types.ts +242 -17
- package/Application/utils.tsx +493 -0
- package/Badge/Badge.tsx +0 -5
- package/Badge/BadgeDot.tsx +0 -1
- package/Badge/BadgeDotAnimation.tsx +7 -15
- package/Badge/BadgeRibbon.tsx +39 -47
- package/Badge/Shape.tsx +0 -2
- package/Badge/styles.ts +0 -2
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +152 -21
- package/Button/styles.ts +1 -1
- package/CheckBox/index.tsx +6 -5
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +1 -5
- package/Divider/DashDivider.tsx +11 -11
- package/Divider/index.tsx +7 -21
- package/FoundationList/index.tsx +0 -4
- package/Icon/index.tsx +6 -6
- package/Icon/types.ts +1 -1
- package/IconButton/index.tsx +12 -4
- package/Image/index.tsx +7 -9
- package/Input/Input.tsx +12 -10
- package/Input/InputDropDown.tsx +13 -10
- package/Input/InputMoney.tsx +152 -45
- package/Input/InputOTP.tsx +34 -36
- package/Input/InputPhoneNumber.tsx +5 -8
- package/Input/InputSearch.tsx +111 -19
- package/Input/InputTextArea.tsx +5 -5
- package/Input/SystemTextInput.tsx +2 -7
- package/Input/TextTyping.tsx +0 -4
- package/Input/common.tsx +17 -31
- package/Input/index.tsx +21 -24
- package/Input/styles.ts +5 -25
- package/Input/utils.ts +12 -14
- package/Layout/Card.tsx +4 -7
- package/Layout/FloatingButton.tsx +21 -26
- package/Layout/Item.tsx +2 -6
- package/Layout/ItemList.tsx +7 -9
- package/Layout/ItemSectionList.tsx +1 -2
- package/Layout/ReservedRegions.tsx +17 -34
- package/Layout/Screen.tsx +696 -122
- package/Layout/Section.tsx +7 -9
- package/Layout/TrackingScope.tsx +0 -1
- package/Layout/index.ts +4 -10
- package/Layout/styles.ts +0 -2
- package/Layout/types.ts +4 -2
- package/Layout/utils.ts +181 -40
- package/Loader/DotLoader.tsx +3 -11
- package/Loader/Loader.tsx +0 -4
- package/Loader/ProgressBar.tsx +6 -3
- package/Loader/Spinner.tsx +3 -11
- package/Loader/styles.ts +0 -4
- package/Loader/utils.ts +7 -11
- package/Pagination/Dot.tsx +0 -4
- package/Pagination/PaginationDot.tsx +0 -1
- package/Pagination/PaginationNumber.tsx +3 -5
- package/Pagination/PaginationScroll.tsx +0 -5
- package/Pagination/PaginationWhiteDot.tsx +0 -1
- package/Pagination/index.tsx +0 -4
- package/Pagination/types.ts +2 -2
- package/Popup/PopupNotify.tsx +102 -94
- package/Popup/PopupPromotion.tsx +11 -9
- package/Popup/types.ts +4 -11
- package/Popup/utils.ts +18 -50
- package/Radio/index.tsx +10 -6
- package/Radio/styles.ts +0 -6
- package/Skeleton/index.tsx +9 -9
- package/Skeleton/styles.ts +0 -1
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +4 -8
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +5 -25
- package/Text/styles.ts +1 -1
- package/Text/types.ts +6 -1
- package/Text/utils.ts +4 -20
- package/Title/index.tsx +40 -42
- package/Title/styles.ts +0 -6
- package/ViewBoundary/index.tsx +2 -4
- package/index.ts +6 -0
- package/package.json +1 -2
- package/Application/BottomSheet.hooks.ts +0 -195
- package/Application/BottomSheet.parts.tsx +0 -157
- package/Application/BottomSheet.styles.ts +0 -43
- package/Application/BottomTab/ActiveIndicator.tsx +0 -91
- package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
- package/Application/BottomTab/BottomTabInset.tsx +0 -18
- package/Application/BottomTab/CurvedContainer.tsx +0 -155
- package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
- package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
- package/Application/BottomTab/TabScreen.tsx +0 -160
- package/Application/BottomTab/metrics.ts +0 -164
- package/Application/BottomTab/tabItems.ts +0 -46
- package/Application/BottomTab/usePressLift.ts +0 -32
- package/Application/Components/HeaderRight.styles.ts +0 -146
- package/Application/Components/HeaderTitle.shared.ts +0 -44
- package/Application/Components/HeaderTitle.styles.ts +0 -125
- package/Application/Components/HeaderToolkitAction.tsx +0 -180
- package/Application/Components/SwipeBackHaptic.tsx +0 -95
- package/Application/Components/TitleJourney.tsx +0 -110
- package/Application/Components/TitleLocation.tsx +0 -73
- package/Application/Components/TitleUser.tsx +0 -304
- package/Application/Components/useToolkitActions.tsx +0 -218
- package/Application/ModalIconButton.tsx +0 -66
- package/Application/StackScreen.tracking.ts +0 -143
- package/Application/headerLayout.ts +0 -158
- package/Application/hooks.ts +0 -137
- package/Application/modalLayout.ts +0 -176
- package/Application/navigationOptions.tsx +0 -212
- package/Application/types.header.ts +0 -121
- package/Application/types.tabs.ts +0 -48
- package/Application/types.theme.ts +0 -87
- package/Application/utils.ts +0 -107
- package/Button/utils.ts +0 -133
- package/Input/InputMoneyView.tsx +0 -194
- package/Input/SearchTextTyping.tsx +0 -108
- package/Input/moneyUtils.ts +0 -23
- package/Layout/layoutMetrics.ts +0 -58
- package/Layout/layoutTypes.ts +0 -86
- package/Layout/screenContent.tsx +0 -92
- package/Layout/screenFooter.tsx +0 -63
- package/Layout/screenHeader.tsx +0 -321
- package/Layout/screenQuickReturn.tsx +0 -64
- package/Layout/screenScroll.ts +0 -107
- package/Layout/screenTypes.ts +0 -143
package/Input/common.tsx
CHANGED
|
@@ -35,7 +35,6 @@ type TrailingProps = {
|
|
|
35
35
|
|
|
36
36
|
export const MAX_LENGTH = 300;
|
|
37
37
|
|
|
38
|
-
/** Border color by state; priority is disabled > error > focused > default. */
|
|
39
38
|
export const getBorderColor = (
|
|
40
39
|
theme: Theme,
|
|
41
40
|
focused: boolean,
|
|
@@ -59,10 +58,6 @@ export const getBorderColor = (
|
|
|
59
58
|
return { borderColor };
|
|
60
59
|
};
|
|
61
60
|
|
|
62
|
-
/**
|
|
63
|
-
* Container style for `size`; multiline uses `height` as minHeight so the
|
|
64
|
-
* field can grow with its content.
|
|
65
|
-
*/
|
|
66
61
|
export const getSizeStyle = (
|
|
67
62
|
size?: 'small' | 'large',
|
|
68
63
|
multiline: boolean = false,
|
|
@@ -73,14 +68,13 @@ export const getSizeStyle = (
|
|
|
73
68
|
scaleStyle = { height };
|
|
74
69
|
}
|
|
75
70
|
|
|
76
|
-
if (multiline)
|
|
71
|
+
if (multiline)
|
|
77
72
|
return [
|
|
78
73
|
styles.multilineContainer,
|
|
79
74
|
{
|
|
80
75
|
minHeight: height,
|
|
81
76
|
},
|
|
82
77
|
];
|
|
83
|
-
}
|
|
84
78
|
|
|
85
79
|
if (size === 'small') {
|
|
86
80
|
return [styles.smallContainer, scaleStyle];
|
|
@@ -88,10 +82,6 @@ export const getSizeStyle = (
|
|
|
88
82
|
return [styles.container, scaleStyle];
|
|
89
83
|
};
|
|
90
84
|
|
|
91
|
-
/**
|
|
92
|
-
* Error or hint row under an input (error wins); with neither, `errorSpacing`
|
|
93
|
-
* keeps an empty row so the layout doesn't jump when an error appears.
|
|
94
|
-
*/
|
|
95
85
|
export const ErrorView: FC<{
|
|
96
86
|
errorMessage?: string;
|
|
97
87
|
errorSpacing?: boolean;
|
|
@@ -105,34 +95,34 @@ export const ErrorView: FC<{
|
|
|
105
95
|
const scaledIconSize = useScaleSize(16);
|
|
106
96
|
|
|
107
97
|
if (errorMessage || hintText) {
|
|
108
|
-
const messageColor = errorMessage ? errorColor : hintColor;
|
|
109
|
-
const messageType = errorMessage ? 'error' : 'hint';
|
|
110
98
|
return (
|
|
111
99
|
<View style={styles.errorView}>
|
|
112
100
|
<View style={styles.errorIcon}>
|
|
113
|
-
<Icon
|
|
101
|
+
<Icon
|
|
102
|
+
color={errorMessage ? errorColor : hintColor}
|
|
103
|
+
source="ic_error"
|
|
104
|
+
size={scaledIconSize}
|
|
105
|
+
/>
|
|
114
106
|
</View>
|
|
115
107
|
<Text
|
|
116
|
-
accessibilityLabel={`${componentId}|${
|
|
108
|
+
accessibilityLabel={`${componentId}|${
|
|
109
|
+
errorMessage ? 'error' : 'hint'
|
|
110
|
+
}-text`}
|
|
117
111
|
style={Styles.flex}
|
|
118
|
-
color={
|
|
112
|
+
color={errorMessage ? errorColor : hintColor}
|
|
119
113
|
typography={'description_default_regular'}
|
|
120
114
|
>
|
|
121
|
-
{errorMessage
|
|
115
|
+
{errorMessage || hintTextDefault}
|
|
122
116
|
</Text>
|
|
123
117
|
</View>
|
|
124
118
|
);
|
|
125
119
|
}
|
|
126
120
|
if (errorSpacing) {
|
|
127
|
-
return <View style={[styles.errorView,
|
|
121
|
+
return <View style={[styles.errorView, { height: 18 }]} />;
|
|
128
122
|
}
|
|
129
123
|
return <View />;
|
|
130
124
|
};
|
|
131
125
|
|
|
132
|
-
/**
|
|
133
|
-
* Floating label on the input's top border with a required `*` and an
|
|
134
|
-
* optional pressable icon; renders nothing without `floatingValue`.
|
|
135
|
-
*/
|
|
136
126
|
export const FloatingView: FC<FloatingViewProps> = ({
|
|
137
127
|
floatingValue,
|
|
138
128
|
floatingIconColor,
|
|
@@ -157,9 +147,9 @@ export const FloatingView: FC<FloatingViewProps> = ({
|
|
|
157
147
|
<View
|
|
158
148
|
style={[
|
|
159
149
|
styles.floatingView,
|
|
160
|
-
styles.floatingViewLayer,
|
|
161
150
|
{
|
|
162
151
|
backgroundColor: theme.colors.background.surface,
|
|
152
|
+
zIndex: 10,
|
|
163
153
|
top: -scaledTop,
|
|
164
154
|
},
|
|
165
155
|
style,
|
|
@@ -201,10 +191,6 @@ export const FloatingView: FC<FloatingViewProps> = ({
|
|
|
201
191
|
return null;
|
|
202
192
|
};
|
|
203
193
|
|
|
204
|
-
/**
|
|
205
|
-
* Trailing slot: spinner while `loading`, an icon when `icon` is a known icon
|
|
206
|
-
* name or URL, otherwise `icon` as a text action (first 15 chars).
|
|
207
|
-
*/
|
|
208
194
|
export const RenderTrailing: FC<TrailingProps> = ({
|
|
209
195
|
loading,
|
|
210
196
|
color,
|
|
@@ -218,16 +204,16 @@ export const RenderTrailing: FC<TrailingProps> = ({
|
|
|
218
204
|
}
|
|
219
205
|
|
|
220
206
|
if (icon) {
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
const renderIconTouchable = (
|
|
207
|
+
const isIcon =
|
|
208
|
+
(IconSources as any)?.[icon as string]?.uri || icon?.includes('http');
|
|
209
|
+
const renderIconTouchable = (icon: ReactNode) => {
|
|
224
210
|
return (
|
|
225
211
|
<TouchableOpacity
|
|
226
212
|
accessibilityLabel={`${componentId}|trailing-touch`}
|
|
227
213
|
onPress={onPressIcon}
|
|
228
214
|
style={styles.icon}
|
|
229
215
|
>
|
|
230
|
-
{
|
|
216
|
+
{icon}
|
|
231
217
|
</TouchableOpacity>
|
|
232
218
|
);
|
|
233
219
|
};
|
package/Input/index.tsx
CHANGED
|
@@ -36,7 +36,7 @@ export interface InputProps extends TextInputProps {
|
|
|
36
36
|
errorMessage?: string;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
* Optional.
|
|
39
|
+
* Optional. Represents the name or key of the icon to be displayed in the Input component.
|
|
40
40
|
*/
|
|
41
41
|
trailing?: string;
|
|
42
42
|
|
|
@@ -69,18 +69,19 @@ export interface InputProps extends TextInputProps {
|
|
|
69
69
|
required?: boolean;
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
* Optional. If `true`,
|
|
72
|
+
* Optional. If `true`,
|
|
73
|
+
* include spacing when Input not have error message.
|
|
73
74
|
* Defaults to `false` if not provided.
|
|
74
75
|
*/
|
|
75
76
|
errorSpacing?: boolean;
|
|
76
77
|
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
+
* If true, the icon of input will use be show indicator loading.
|
|
79
80
|
*/
|
|
80
81
|
loading?: boolean;
|
|
81
82
|
|
|
82
83
|
/**
|
|
83
|
-
*
|
|
84
|
+
* Optional. Represents the leading icon in the Input component.
|
|
84
85
|
*/
|
|
85
86
|
leadingIcon?: string;
|
|
86
87
|
|
|
@@ -110,13 +111,12 @@ export interface InputProps extends TextInputProps {
|
|
|
110
111
|
hintText?: string;
|
|
111
112
|
|
|
112
113
|
/**
|
|
113
|
-
* Optional.
|
|
114
|
+
* Optional. Represents the style of the Input component.
|
|
114
115
|
*/
|
|
115
116
|
onPressFloatingIcon?: () => void;
|
|
116
117
|
|
|
117
118
|
/**
|
|
118
|
-
* Optional.
|
|
119
|
-
* Defaults to `true` if not provided.
|
|
119
|
+
* Optional. Represents the style of the Input component.
|
|
120
120
|
*/
|
|
121
121
|
showClearIcon?: boolean;
|
|
122
122
|
}
|
|
@@ -137,12 +137,12 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
* Optional. If `true`, the text on the search button will be displayed.
|
|
140
|
-
* Defaults to `
|
|
140
|
+
* Defaults to `false` if not provided.
|
|
141
141
|
*/
|
|
142
142
|
showButtonText?: boolean;
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* Optional.
|
|
145
|
+
* Optional. Represents the value for the floating title in the InputSearch component.
|
|
146
146
|
*/
|
|
147
147
|
onPressButtonText?: () => void;
|
|
148
148
|
|
|
@@ -180,7 +180,7 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
180
180
|
onPressTrailing?: () => void;
|
|
181
181
|
|
|
182
182
|
/**
|
|
183
|
-
* Optional.
|
|
183
|
+
* Optional. If `true`, the user won't be able to interact with the Input component.
|
|
184
184
|
*/
|
|
185
185
|
backgroundColor?: string;
|
|
186
186
|
|
|
@@ -195,13 +195,8 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
195
195
|
typingData?: string[];
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
|
-
* Optional.
|
|
199
|
-
*
|
|
200
|
-
*/
|
|
201
|
-
size?: 'default' | 'header';
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Optional. Called when the field is pressed while showing `typingData`.
|
|
198
|
+
* Optional. Represents the callback function to be called when the search button is pressed.
|
|
199
|
+
* @param e
|
|
205
200
|
*/
|
|
206
201
|
onPress?: (e: GestureResponderEvent) => void;
|
|
207
202
|
}
|
|
@@ -264,7 +259,7 @@ export interface InputDropDownProps extends TouchableOpacityProps {
|
|
|
264
259
|
placeholder?: string;
|
|
265
260
|
|
|
266
261
|
/**
|
|
267
|
-
* Optional.
|
|
262
|
+
* Optional. Represents the data for the dropdown.
|
|
268
263
|
*/
|
|
269
264
|
multiline?: boolean;
|
|
270
265
|
|
|
@@ -308,18 +303,19 @@ export interface InputDropDownProps extends TouchableOpacityProps {
|
|
|
308
303
|
required?: boolean;
|
|
309
304
|
|
|
310
305
|
/**
|
|
311
|
-
* Optional. If `true`,
|
|
306
|
+
* Optional. If `true`,
|
|
307
|
+
* include spacing when Input not have error message.
|
|
312
308
|
* Defaults to `false` if not provided.
|
|
313
309
|
*/
|
|
314
310
|
errorSpacing?: boolean;
|
|
315
311
|
|
|
316
312
|
/**
|
|
317
|
-
*
|
|
313
|
+
* If true, the icon of input will use be show indicator loading.
|
|
318
314
|
*/
|
|
319
315
|
loading?: boolean;
|
|
320
316
|
|
|
321
317
|
/**
|
|
322
|
-
*
|
|
318
|
+
* Optional. Represents the leading icon in the Input component.
|
|
323
319
|
*/
|
|
324
320
|
leadingIcon?: string;
|
|
325
321
|
|
|
@@ -344,14 +340,15 @@ export interface InputDropDownProps extends TouchableOpacityProps {
|
|
|
344
340
|
hintText?: string;
|
|
345
341
|
|
|
346
342
|
/**
|
|
347
|
-
* Optional.
|
|
343
|
+
* Optional. Represents the style of the Input component.
|
|
348
344
|
*/
|
|
349
345
|
onPressFloatingIcon?: () => void;
|
|
350
346
|
}
|
|
351
347
|
|
|
352
348
|
export interface InputPhoneNumberProps extends InputProps {
|
|
353
349
|
/**
|
|
354
|
-
* Optional.
|
|
350
|
+
* Optional. Represents the country code to be displayed in the InputPhoneNumber component.
|
|
351
|
+
* It should be in the format of a string, e.g., "+1" for the United States.
|
|
355
352
|
*/
|
|
356
353
|
countryCode?: string;
|
|
357
354
|
}
|
|
@@ -373,4 +370,4 @@ export {
|
|
|
373
370
|
InputPhoneNumber,
|
|
374
371
|
};
|
|
375
372
|
|
|
376
|
-
export {
|
|
373
|
+
export {checkValidPhoneNumber};
|
package/Input/styles.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Platform, StyleSheet } from 'react-native';
|
|
|
2
2
|
import { Colors, Radius, Spacing } from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
|
+
//input style
|
|
5
6
|
input: {
|
|
6
7
|
flex: 1,
|
|
7
8
|
paddingLeft: Spacing.M,
|
|
@@ -64,6 +65,7 @@ export default StyleSheet.create({
|
|
|
64
65
|
marginTop: Spacing.S,
|
|
65
66
|
},
|
|
66
67
|
|
|
68
|
+
//text area style
|
|
67
69
|
textAreaView: {
|
|
68
70
|
flex: 1,
|
|
69
71
|
},
|
|
@@ -92,6 +94,7 @@ export default StyleSheet.create({
|
|
|
92
94
|
marginBottom: Spacing.XS,
|
|
93
95
|
},
|
|
94
96
|
|
|
97
|
+
//searchInput
|
|
95
98
|
searchInputWrapper: {
|
|
96
99
|
flexDirection: 'row',
|
|
97
100
|
borderRadius: Radius.XL,
|
|
@@ -133,6 +136,7 @@ export default StyleSheet.create({
|
|
|
133
136
|
ios: 36,
|
|
134
137
|
}),
|
|
135
138
|
},
|
|
139
|
+
//OTP
|
|
136
140
|
otpWrapper: {
|
|
137
141
|
width: '100%',
|
|
138
142
|
marginTop: Spacing.M,
|
|
@@ -179,6 +183,7 @@ export default StyleSheet.create({
|
|
|
179
183
|
opacity: 0.02,
|
|
180
184
|
letterSpacing: Spacing.XXL,
|
|
181
185
|
},
|
|
186
|
+
//DropDown
|
|
182
187
|
inputDropDownWrapper: {
|
|
183
188
|
flexDirection: 'row',
|
|
184
189
|
marginTop: Spacing.S,
|
|
@@ -222,29 +227,4 @@ export default StyleSheet.create({
|
|
|
222
227
|
paddingRight: Spacing.XXS,
|
|
223
228
|
paddingVertical: 0,
|
|
224
229
|
},
|
|
225
|
-
inputField: {
|
|
226
|
-
flex: 1,
|
|
227
|
-
paddingLeft: Spacing.M,
|
|
228
|
-
height: '100%',
|
|
229
|
-
},
|
|
230
|
-
secureTextSmall: { fontSize: 18 },
|
|
231
|
-
secureTextLarge: { fontSize: 22 },
|
|
232
|
-
iconViewDropDownMultiline: {
|
|
233
|
-
alignItems: 'flex-start',
|
|
234
|
-
paddingTop: Spacing.M,
|
|
235
|
-
},
|
|
236
|
-
iconViewDropDownSingle: {
|
|
237
|
-
alignItems: 'center',
|
|
238
|
-
paddingTop: 0,
|
|
239
|
-
},
|
|
240
|
-
otpCursor: { width: 1 },
|
|
241
|
-
searchInputTyping: { justifyContent: 'center' },
|
|
242
|
-
textAreaInput: {
|
|
243
|
-
width: '100%',
|
|
244
|
-
flex: 1,
|
|
245
|
-
paddingRight: Spacing.XS,
|
|
246
|
-
paddingVertical: Spacing.XS,
|
|
247
|
-
},
|
|
248
|
-
errorSpacing: { height: 18 },
|
|
249
|
-
floatingViewLayer: { zIndex: 10 },
|
|
250
230
|
});
|
package/Input/utils.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Localize } from '../Application';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Formats a number Vietnamese-style (`.` thousands, `,` decimals) with
|
|
5
|
-
* `currency` appended; 0, NaN or a falsy value gives `0<currency>`.
|
|
6
|
-
*/
|
|
7
3
|
const formatNumberToMoney = (number: number, currency = '') => {
|
|
8
4
|
if (!number || isNaN(number) || Number(number) === 0) {
|
|
9
5
|
return `0${currency}`;
|
|
@@ -45,10 +41,6 @@ const formatNumberToMoney = (number: number, currency = '') => {
|
|
|
45
41
|
return isNegative ? `-${result}${currency}` : `${result}${currency}`;
|
|
46
42
|
};
|
|
47
43
|
|
|
48
|
-
/**
|
|
49
|
-
* Parses a formatted money string back to a number by stripping
|
|
50
|
-
* `currencyUnit`, separators, `đ` and spaces; unparsable text gives 0.
|
|
51
|
-
*/
|
|
52
44
|
const formatMoneyToNumber = (money: string, currencyUnit: string) => {
|
|
53
45
|
if (money && money.length > 0) {
|
|
54
46
|
const moneyString = money
|
|
@@ -67,20 +59,26 @@ const formatMoneyToNumber = (money: string, currencyUnit: string) => {
|
|
|
67
59
|
return Number(money);
|
|
68
60
|
};
|
|
69
61
|
|
|
62
|
+
// --- PHONE VALIDATION ---
|
|
70
63
|
function formatPhoneNumber(phone: string): string {
|
|
71
64
|
return phone.replace(/\D/g, '');
|
|
72
65
|
}
|
|
73
66
|
|
|
74
|
-
/**
|
|
75
|
-
* Keeps the digits of `phone` (prepending the `0` a 9-char local number lacks)
|
|
76
|
-
* and returns a localized error when empty or not 10-11 digits.
|
|
77
|
-
*/
|
|
78
67
|
function checkValidPhoneNumber(phone: string): {
|
|
79
68
|
phoneFormatted: string;
|
|
80
69
|
error?: string;
|
|
81
70
|
} {
|
|
82
|
-
|
|
83
|
-
|
|
71
|
+
let phoneNumber = phone;
|
|
72
|
+
|
|
73
|
+
// if not starting with 0 and has 9 digits => prepend 0
|
|
74
|
+
if (
|
|
75
|
+
phoneNumber.length > 0 &&
|
|
76
|
+
phoneNumber[0] !== '0' &&
|
|
77
|
+
/^\d$/.test(phoneNumber[0]) &&
|
|
78
|
+
phoneNumber.length === 9
|
|
79
|
+
) {
|
|
80
|
+
phoneNumber = '0' + phoneNumber;
|
|
81
|
+
}
|
|
84
82
|
|
|
85
83
|
const phoneFormatted = formatPhoneNumber(phoneNumber);
|
|
86
84
|
const localize = new Localize({ vi: {}, en: {} });
|
package/Layout/Card.tsx
CHANGED
|
@@ -20,10 +20,6 @@ export interface CardProps extends ViewProps {
|
|
|
20
20
|
useShadow?: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* Surface card across the content width minus 12pt margins, with its own grid for child
|
|
25
|
-
* Items; optional background image and light shadow.
|
|
26
|
-
*/
|
|
27
23
|
const Card: React.FC<CardProps> = ({
|
|
28
24
|
children,
|
|
29
25
|
style,
|
|
@@ -38,9 +34,10 @@ const Card: React.FC<CardProps> = ({
|
|
|
38
34
|
const gutterSize = 8;
|
|
39
35
|
const margin = 12;
|
|
40
36
|
const widthSection = contentWidth - margin * 2;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
let sizePerSpan =
|
|
38
|
+
(widthSection - margin * 2 - gutterSize * (numberOfColumns - 1)) /
|
|
39
|
+
numberOfColumns -
|
|
40
|
+
1 / numberOfColumns;
|
|
44
41
|
|
|
45
42
|
const gridContext: GridContextProps = {
|
|
46
43
|
numberOfColumns,
|
|
@@ -13,11 +13,12 @@ import Animated, {
|
|
|
13
13
|
} from 'react-native-reanimated';
|
|
14
14
|
import { scheduleOnRN } from 'react-native-worklets';
|
|
15
15
|
import { ApplicationContext } from '../Context';
|
|
16
|
-
import { Colors } from '../Consts';
|
|
17
16
|
import { Icon } from '../Icon';
|
|
18
17
|
import { useScaleSize, exportFontFamily } from '../Text';
|
|
19
|
-
import {
|
|
20
|
-
|
|
18
|
+
import {
|
|
19
|
+
AnimatedCompatValue,
|
|
20
|
+
useNormalizedSharedValue,
|
|
21
|
+
} from '../Application/utils';
|
|
21
22
|
|
|
22
23
|
export interface FloatingButtonProps {
|
|
23
24
|
label?: string;
|
|
@@ -31,10 +32,6 @@ export interface FloatingButtonProps {
|
|
|
31
32
|
renderComponent?: () => React.ReactNode;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
/**
|
|
35
|
-
* Floating action button above the screen bottom. With a label and a scroll value it
|
|
36
|
-
* shrinks to its icon while scrolling down and expands again on scroll up.
|
|
37
|
-
*/
|
|
38
35
|
export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
39
36
|
renderComponent,
|
|
40
37
|
label = '',
|
|
@@ -121,9 +118,11 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
121
118
|
onLayout={handleLayout}
|
|
122
119
|
style={[
|
|
123
120
|
styles.container,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
121
|
+
{
|
|
122
|
+
right: position === 'right' ? 12 : undefined,
|
|
123
|
+
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
124
|
+
bottom,
|
|
125
|
+
},
|
|
127
126
|
]}
|
|
128
127
|
>
|
|
129
128
|
{renderComponent()}
|
|
@@ -136,14 +135,20 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
136
135
|
onLayout={handleLayout}
|
|
137
136
|
style={[
|
|
138
137
|
styles.container,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
{
|
|
139
|
+
right: position === 'right' ? 12 : undefined,
|
|
140
|
+
alignSelf: position === 'center' ? 'center' : 'flex-end',
|
|
141
|
+
height: size === 'small' ? 36 : 48,
|
|
142
|
+
backgroundColor: theme.colors.primary,
|
|
143
|
+
bottom,
|
|
144
|
+
},
|
|
143
145
|
containerStyle,
|
|
144
146
|
]}
|
|
145
147
|
>
|
|
146
|
-
<TouchableOpacity
|
|
148
|
+
<TouchableOpacity
|
|
149
|
+
style={{ flexDirection: 'row', alignItems: 'center' }}
|
|
150
|
+
onPress={onPress}
|
|
151
|
+
>
|
|
147
152
|
<Icon
|
|
148
153
|
source={icon}
|
|
149
154
|
size={size === 'small' ? 12 : 24}
|
|
@@ -154,10 +159,10 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
|
|
|
154
159
|
allowFontScaling={false}
|
|
155
160
|
style={[
|
|
156
161
|
styles.label,
|
|
157
|
-
styles.labelText,
|
|
158
162
|
{
|
|
159
163
|
fontSize: scaledFontSize,
|
|
160
164
|
lineHeight: scaledLineHeight,
|
|
165
|
+
color: 'white',
|
|
161
166
|
fontFamily: labelFontFamily,
|
|
162
167
|
},
|
|
163
168
|
labelStyle,
|
|
@@ -186,14 +191,4 @@ const styles = StyleSheet.create({
|
|
|
186
191
|
label: {
|
|
187
192
|
marginLeft: 8,
|
|
188
193
|
},
|
|
189
|
-
alignRight: { right: 12 },
|
|
190
|
-
alignCenter: { alignSelf: 'center' },
|
|
191
|
-
alignEnd: { alignSelf: 'flex-end' },
|
|
192
|
-
small: { height: 36 },
|
|
193
|
-
large: { height: 48 },
|
|
194
|
-
content: {
|
|
195
|
-
flexDirection: 'row',
|
|
196
|
-
alignItems: 'center',
|
|
197
|
-
},
|
|
198
|
-
labelText: { color: Colors.black_01 },
|
|
199
194
|
});
|
package/Layout/Item.tsx
CHANGED
|
@@ -7,20 +7,16 @@ import { SpanNumber } from './types';
|
|
|
7
7
|
|
|
8
8
|
export interface ItemProps extends ViewProps {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Represents the width of the Card component in terms of span numbers (1-12).
|
|
11
11
|
*/
|
|
12
12
|
widthSpan?: SpanNumber;
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Optional.
|
|
15
|
+
* Optional. Represents the height of the Card component in terms of span numbers (1-12).
|
|
16
16
|
*/
|
|
17
17
|
heightSpan?: SpanNumber;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Grid cell sized from the enclosing GridContext; outlined when the mini app turns on
|
|
22
|
-
* the baseline debug feature.
|
|
23
|
-
*/
|
|
24
20
|
const Item: React.FC<ItemProps> = ({
|
|
25
21
|
widthSpan,
|
|
26
22
|
heightSpan,
|
package/Layout/ItemList.tsx
CHANGED
|
@@ -7,16 +7,12 @@ import { SpanNumber } from './types';
|
|
|
7
7
|
|
|
8
8
|
export interface ItemListProps extends FlatListProps<any> {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Represents the width of the Card component in terms of span numbers (1-12).
|
|
11
11
|
*/
|
|
12
12
|
widthSpan?: SpanNumber;
|
|
13
13
|
data: any[];
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
/**
|
|
17
|
-
* FlatList on the grid: `widthSpan` sets how many items share a row, and every item but
|
|
18
|
-
* the first of a row gets the gutter on its left.
|
|
19
|
-
*/
|
|
20
16
|
const ItemList = forwardRef(
|
|
21
17
|
(
|
|
22
18
|
{
|
|
@@ -34,9 +30,6 @@ const ItemList = forwardRef(
|
|
|
34
30
|
const indexBegin = props?.data?.map(
|
|
35
31
|
(_i: any, index: number) => index * numColumns,
|
|
36
32
|
);
|
|
37
|
-
const defaultKeyExtractor = (item: any, index: number) => {
|
|
38
|
-
return (item?.id ?? item?.key ?? index).toString();
|
|
39
|
-
};
|
|
40
33
|
const _renderItem = (item: any) => {
|
|
41
34
|
if (indexBegin?.includes(item?.index)) {
|
|
42
35
|
return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
|
|
@@ -53,7 +46,12 @@ const ItemList = forwardRef(
|
|
|
53
46
|
ref={ref as React.RefObject<FlatList>}
|
|
54
47
|
{...props}
|
|
55
48
|
key={`ItemList-${numColumns}`}
|
|
56
|
-
keyExtractor={
|
|
49
|
+
keyExtractor={
|
|
50
|
+
// prefer caller's keyExtractor; fallback to common id/key/index
|
|
51
|
+
(props as any)?.keyExtractor ??
|
|
52
|
+
((item: any, index: number) =>
|
|
53
|
+
(item?.id ?? item?.key ?? index).toString())
|
|
54
|
+
}
|
|
57
55
|
numColumns={numColumns}
|
|
58
56
|
renderItem={_renderItem}
|
|
59
57
|
horizontal={false}
|
|
@@ -7,12 +7,11 @@ import { SpanNumber } from './types';
|
|
|
7
7
|
|
|
8
8
|
export interface ItemSectionListProps extends SectionListProps<any> {
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Represents the width of the Card component in terms of span numbers (1-12).
|
|
11
11
|
*/
|
|
12
12
|
widthSpan?: SpanNumber;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
/** SectionList whose items sit on the grid, `widthSpan` columns wide, a gutter apart. */
|
|
16
15
|
const ItemSectionList: FC<ItemSectionListProps> = ({
|
|
17
16
|
renderItem,
|
|
18
17
|
widthSpan,
|