@momo-kits/foundation 0.169.16-beta.16 → 0.169.16-beta.18
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/Input/InputMoneyView.tsx +6 -14
- package/Input/InputPhoneNumber.tsx +38 -20
- package/Input/index.tsx +1 -14
- package/package.json +1 -1
- package/Input/CountryCodeView.tsx +0 -93
package/Input/InputMoneyView.tsx
CHANGED
|
@@ -53,8 +53,8 @@ type InputMoneyViewProps = Pick<
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* Presentational body of InputMoney: bordered field, currency suffix (
|
|
57
|
-
*
|
|
56
|
+
* Presentational body of InputMoney: bordered field, currency suffix (shown
|
|
57
|
+
* once there is a value) and the clear/trailing icons.
|
|
58
58
|
*/
|
|
59
59
|
export const InputMoneyView = ({
|
|
60
60
|
size,
|
|
@@ -101,13 +101,8 @@ export const InputMoneyView = ({
|
|
|
101
101
|
fontSize: scaledFontSize,
|
|
102
102
|
fontFamily: inputFontFamily,
|
|
103
103
|
};
|
|
104
|
-
const
|
|
105
|
-
const shouldShowCurrency = !!displayValue || hasCurrencyInPlaceholder;
|
|
104
|
+
const hasValue = displayValue.length > 0;
|
|
106
105
|
const shouldShowClearIcon = !!(showClearIcon && focused && displayValue);
|
|
107
|
-
let inputPlaceholder = placeholder;
|
|
108
|
-
if (hasCurrencyInPlaceholder) {
|
|
109
|
-
inputPlaceholder = placeholder.slice(0, -currency.length);
|
|
110
|
-
}
|
|
111
106
|
return (
|
|
112
107
|
<View
|
|
113
108
|
style={[
|
|
@@ -148,18 +143,15 @@ export const InputMoneyView = ({
|
|
|
148
143
|
onChangeText={onChangeText}
|
|
149
144
|
onFocus={onFocus}
|
|
150
145
|
onBlur={onBlur}
|
|
151
|
-
placeholder={
|
|
146
|
+
placeholder={placeholder}
|
|
152
147
|
selectionColor={theme.colors.primary}
|
|
153
148
|
placeholderTextColor={placeholderColor}
|
|
154
149
|
keyboardType={'numeric'}
|
|
155
150
|
maxLength={undefined}
|
|
156
151
|
/>
|
|
157
|
-
{
|
|
152
|
+
{hasValue && (
|
|
158
153
|
<Text
|
|
159
|
-
style={[
|
|
160
|
-
textStyle,
|
|
161
|
-
{ color: displayValue ? textColor : placeholderColor },
|
|
162
|
-
]}
|
|
154
|
+
style={[textStyle, { color: textColor }]}
|
|
163
155
|
allowFontScaling={false}
|
|
164
156
|
>
|
|
165
157
|
{currency}
|
|
@@ -6,6 +6,7 @@ import React, {
|
|
|
6
6
|
useState,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import {
|
|
9
|
+
StyleSheet,
|
|
9
10
|
TextInput,
|
|
10
11
|
TextInputFocusEvent,
|
|
11
12
|
TouchableOpacity,
|
|
@@ -17,11 +18,12 @@ import {
|
|
|
17
18
|
ComponentContext,
|
|
18
19
|
MiniAppContext,
|
|
19
20
|
} from '../Context';
|
|
21
|
+
import { Colors, Spacing, Styles } from '../Consts';
|
|
20
22
|
import { Icon } from '../Icon';
|
|
21
|
-
import {
|
|
23
|
+
import { Image } from '../Image';
|
|
24
|
+
import { useScaleSize, Text, exportFontFamily } from '../Text';
|
|
22
25
|
import { Typography } from '../Text/types';
|
|
23
26
|
import { CLEAR_ICON_SIZE } from './constants';
|
|
24
|
-
import { CountryCodeView } from './CountryCodeView';
|
|
25
27
|
import { ErrorView } from './ErrorView';
|
|
26
28
|
import { InputPhoneNumberProps } from './index';
|
|
27
29
|
import { RenderTrailing } from './RenderTrailing';
|
|
@@ -34,13 +36,11 @@ const LARGE_FONT_SIZE = 18;
|
|
|
34
36
|
const SMALL_DIVIDER_HEIGHT = 24;
|
|
35
37
|
const LARGE_DIVIDER_HEIGHT = 32;
|
|
36
38
|
const FOCUSED_BORDER_WIDTH = 1.5;
|
|
37
|
-
const
|
|
38
|
-
const DEFAULT_COUNTRY_FLAG =
|
|
39
|
-
'https://static.momocdn.net/app/img/icon/ic-qrcode-package/ic_vn_flag.png';
|
|
39
|
+
const FLAG_SIZE = 24;
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Vietnamese phone number input with a fixed flag and `+84` prefix, number pad
|
|
43
|
+
* by default, plus clear and trailing icons.
|
|
44
44
|
*/
|
|
45
45
|
const InputPhoneNumber = forwardRef(
|
|
46
46
|
(
|
|
@@ -66,9 +66,6 @@ const InputPhoneNumber = forwardRef(
|
|
|
66
66
|
editable = true,
|
|
67
67
|
showClearIcon = true,
|
|
68
68
|
defaultValue,
|
|
69
|
-
countryCode = DEFAULT_COUNTRY_CODE,
|
|
70
|
-
countryFlag = DEFAULT_COUNTRY_FLAG,
|
|
71
|
-
onPressLeadingIcon,
|
|
72
69
|
...props
|
|
73
70
|
}: InputPhoneNumberProps,
|
|
74
71
|
ref,
|
|
@@ -185,16 +182,29 @@ const InputPhoneNumber = forwardRef(
|
|
|
185
182
|
]}
|
|
186
183
|
>
|
|
187
184
|
<View style={styles.inputView}>
|
|
188
|
-
<
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
185
|
+
<View style={[styles.leadingIconContainer, Styles.row]}>
|
|
186
|
+
<Image
|
|
187
|
+
source={{
|
|
188
|
+
uri: 'https://static.momocdn.net/app/img/icon/ic-qrcode-package/ic_vn_flag.png',
|
|
189
|
+
}}
|
|
190
|
+
style={innerStyle.iconFlag}
|
|
191
|
+
resizeMode="contain"
|
|
192
|
+
accessibilityLabel={`${componentId}|leading-icon`}
|
|
193
|
+
/>
|
|
194
|
+
<View style={{ width: Spacing.XS }} />
|
|
195
|
+
<Text typography={typography} color={textColor}>
|
|
196
|
+
{'+84'}
|
|
197
|
+
</Text>
|
|
198
|
+
<View
|
|
199
|
+
style={[
|
|
200
|
+
styles.phoneNumberDivider,
|
|
201
|
+
{
|
|
202
|
+
height: dividerHeight,
|
|
203
|
+
backgroundColor: Colors.black_04,
|
|
204
|
+
},
|
|
205
|
+
]}
|
|
206
|
+
/>
|
|
207
|
+
</View>
|
|
198
208
|
<SystemTextInput
|
|
199
209
|
{...props}
|
|
200
210
|
accessibilityLabel={`${componentId}`}
|
|
@@ -292,4 +302,12 @@ const InputPhoneNumber = forwardRef(
|
|
|
292
302
|
},
|
|
293
303
|
);
|
|
294
304
|
|
|
305
|
+
const innerStyle = StyleSheet.create({
|
|
306
|
+
iconFlag: {
|
|
307
|
+
width: FLAG_SIZE,
|
|
308
|
+
height: FLAG_SIZE,
|
|
309
|
+
marginHorizontal: Spacing.XXS,
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
|
|
295
313
|
export default InputPhoneNumber;
|
package/Input/index.tsx
CHANGED
|
@@ -351,22 +351,9 @@ export interface InputDropDownProps extends TouchableOpacityProps {
|
|
|
351
351
|
|
|
352
352
|
export interface InputPhoneNumberProps extends InputProps {
|
|
353
353
|
/**
|
|
354
|
-
* Optional.
|
|
355
|
-
* Defaults to `+84` if not provided.
|
|
354
|
+
* Optional. Currently unused: the displayed prefix is always `+84`.
|
|
356
355
|
*/
|
|
357
356
|
countryCode?: string;
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Optional. URL of the flag image shown before the dial code.
|
|
361
|
-
* Defaults to the Vietnam flag if not provided.
|
|
362
|
-
*/
|
|
363
|
-
countryFlag?: string;
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Optional. Called when the flag or dial code is pressed (e.g. to pick a country),
|
|
367
|
-
* which then reads as a button. Ignored while `disabled` or `editable={false}`.
|
|
368
|
-
*/
|
|
369
|
-
onPressLeadingIcon?: () => void;
|
|
370
357
|
}
|
|
371
358
|
|
|
372
359
|
export type InputRef = {
|
package/package.json
CHANGED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import { Colors, Spacing, Styles } from '../Consts';
|
|
4
|
-
import { Image } from '../Image';
|
|
5
|
-
import { Text } from '../Text';
|
|
6
|
-
import { Typography } from '../Text/types';
|
|
7
|
-
import styles from './styles';
|
|
8
|
-
|
|
9
|
-
const FLAG_SIZE = 24;
|
|
10
|
-
|
|
11
|
-
type CountryCodeViewProps = {
|
|
12
|
-
countryCode: string;
|
|
13
|
-
countryFlag: string;
|
|
14
|
-
typography: Typography;
|
|
15
|
-
textColor: string;
|
|
16
|
-
dividerHeight: number;
|
|
17
|
-
componentId: string;
|
|
18
|
-
isDisabled: boolean;
|
|
19
|
-
onPress?: () => void;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Flag, dial code and divider ahead of a phone number. Only becomes a button
|
|
24
|
-
* when `onPress` is given, so the default render stays a plain view.
|
|
25
|
-
*/
|
|
26
|
-
const CountryCodeView: React.FC<CountryCodeViewProps> = ({
|
|
27
|
-
countryCode,
|
|
28
|
-
countryFlag,
|
|
29
|
-
typography,
|
|
30
|
-
textColor,
|
|
31
|
-
dividerHeight,
|
|
32
|
-
componentId,
|
|
33
|
-
isDisabled,
|
|
34
|
-
onPress,
|
|
35
|
-
}) => {
|
|
36
|
-
const content = (
|
|
37
|
-
<>
|
|
38
|
-
<Image
|
|
39
|
-
source={{ uri: countryFlag }}
|
|
40
|
-
style={innerStyle.iconFlag}
|
|
41
|
-
resizeMode="contain"
|
|
42
|
-
accessibilityLabel={`${componentId}|leading-icon`}
|
|
43
|
-
/>
|
|
44
|
-
<View style={{ width: Spacing.XS }} />
|
|
45
|
-
<Text typography={typography} color={textColor}>
|
|
46
|
-
{countryCode}
|
|
47
|
-
</Text>
|
|
48
|
-
</>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
const renderContent = () => {
|
|
52
|
-
if (!onPress) {
|
|
53
|
-
return content;
|
|
54
|
-
}
|
|
55
|
-
return (
|
|
56
|
-
<TouchableOpacity
|
|
57
|
-
style={Styles.row}
|
|
58
|
-
onPress={onPress}
|
|
59
|
-
disabled={isDisabled}
|
|
60
|
-
accessibilityRole="button"
|
|
61
|
-
accessibilityLabel={`${componentId}|leading-icon-touch|${countryCode}`}
|
|
62
|
-
accessibilityState={{ disabled: isDisabled }}
|
|
63
|
-
>
|
|
64
|
-
{content}
|
|
65
|
-
</TouchableOpacity>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<View style={[styles.leadingIconContainer, Styles.row]}>
|
|
71
|
-
{renderContent()}
|
|
72
|
-
<View
|
|
73
|
-
style={[
|
|
74
|
-
styles.phoneNumberDivider,
|
|
75
|
-
{
|
|
76
|
-
height: dividerHeight,
|
|
77
|
-
backgroundColor: Colors.black_04,
|
|
78
|
-
},
|
|
79
|
-
]}
|
|
80
|
-
/>
|
|
81
|
-
</View>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const innerStyle = StyleSheet.create({
|
|
86
|
-
iconFlag: {
|
|
87
|
-
width: FLAG_SIZE,
|
|
88
|
-
height: FLAG_SIZE,
|
|
89
|
-
marginHorizontal: Spacing.XXS,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
export { CountryCodeView };
|