@momo-kits/foundation 0.169.19-beta.1 → 0.169.19-beta.2

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.
Files changed (44) hide show
  1. package/Application/BottomSheet.parts.tsx +4 -4
  2. package/Application/BottomSheet.tsx +18 -8
  3. package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
  4. package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
  5. package/Application/BottomTab/TabBarIcon.tsx +1 -1
  6. package/Application/Components/HeaderExtendHeader.tsx +2 -7
  7. package/Application/Components/HeaderLeft.tsx +5 -9
  8. package/Application/Components/HeaderRight.styles.ts +1 -5
  9. package/Application/Components/HeaderRight.tsx +21 -7
  10. package/Application/Components/SearchHeader.tsx +1 -5
  11. package/Application/Components/useHeaderRightWidth.ts +2 -2
  12. package/Application/ModalIconButton.tsx +15 -13
  13. package/Application/ModalScreen.tsx +6 -15
  14. package/Application/StackScreen.tsx +2 -6
  15. package/Application/TooltipPortal.tsx +3 -3
  16. package/Application/__tests__/headerLayout.test.ts +1 -2
  17. package/Application/headerLayout.ts +13 -10
  18. package/Application/hooks.ts +1 -1
  19. package/Application/modalLayout.ts +3 -43
  20. package/Application/navigationOptions.tsx +12 -5
  21. package/Button/index.tsx +2 -2
  22. package/Divider/DashDivider.tsx +2 -2
  23. package/Divider/index.tsx +3 -3
  24. package/FoundationList/index.tsx +1 -1
  25. package/Icon/types.ts +2 -1
  26. package/Image/index.tsx +7 -62
  27. package/Image/styles.ts +0 -2
  28. package/Image/types.ts +1 -9
  29. package/Input/ErrorView.tsx +1 -1
  30. package/Input/Input.tsx +2 -2
  31. package/Input/InputMoney.tsx +2 -7
  32. package/Input/InputMoneyView.tsx +16 -8
  33. package/Input/InputOTP.tsx +2 -2
  34. package/Input/InputPhoneNumber.tsx +40 -22
  35. package/Input/InputSearch.tsx +2 -2
  36. package/Input/InputTextArea.tsx +2 -2
  37. package/Input/SearchTextTyping.tsx +2 -2
  38. package/Input/SystemTextInput.tsx +1 -2
  39. package/Input/TextTyping.tsx +2 -7
  40. package/Input/index.tsx +1 -15
  41. package/Layout/screenHeader.tsx +20 -16
  42. package/Pagination/types.ts +2 -6
  43. package/package.json +26 -28
  44. package/Input/CountryCodeView.tsx +0 -109
@@ -8,7 +8,7 @@ import { isIPhoneDuo } from './utils';
8
8
  const POPUP_MAX_WIDTH = 450;
9
9
  const POPUP_MIN_WIDTH = 280;
10
10
  const POPUP_MAX_HEIGHT = 600;
11
- const SHEET_MAX_WIDTH = 600;
11
+ const SHEET_MAX_WIDTH = 653;
12
12
  const SHEET_MIN_WIDTH = 296;
13
13
  const SHEET_MIN_HEIGHT = 230;
14
14
  const FOLDABLE_MIN_WIDTH = 600;
@@ -46,12 +46,6 @@ export type ModalLayout = {
46
46
  maxHeight?: number;
47
47
  margin: number;
48
48
  radius: number;
49
- /**
50
- * Window x of the left edge of a `width` wide popup, `undefined` on phones.
51
- * Centered on the window, but a margin clear of the iPhone Duo control
52
- * column / system insets; half folded it is centered in the right half.
53
- */
54
- x?: number;
55
49
  };
56
50
 
57
51
  sheet: {
@@ -59,12 +53,6 @@ export type ModalLayout = {
59
53
  * `undefined` on phones, the sheet spans the window.
60
54
  */
61
55
  width?: number;
62
- /**
63
- * Window x of the sheet's left edge, `undefined` on phones. Centered on the
64
- * window, but kept a margin clear of the iPhone Duo control column / system
65
- * insets; half folded it is centered in the right half.
66
- */
67
- x?: number;
68
56
  maxHeight?: number;
69
57
  minHeight?: number;
70
58
  margin: number;
@@ -90,25 +78,6 @@ const clamp = (value: number, min: number, max: number) => {
90
78
  return Math.min(Math.max(value, min), max);
91
79
  };
92
80
 
93
- /**
94
- * Window x of a `boxWidth` wide overlay: centered on `center` (the window, so
95
- * an inset on one side does not push it off center) but `margin` inside the
96
- * placement; centered in the placement when it does not fit with the margins.
97
- */
98
- const overlayX = (
99
- center: number,
100
- placement: ModalRect,
101
- boxWidth: number,
102
- margin: number,
103
- ) => {
104
- const min = placement.x + margin;
105
- const max = placement.x + placement.width - margin - boxWidth;
106
- if (max < min) {
107
- return placement.x + (placement.width - boxWidth) / 2;
108
- }
109
- return clamp(center - boxWidth / 2, min, max);
110
- };
111
-
112
81
  /**
113
82
  * Modal geometry for a window, pure so it can be tested without a device.
114
83
  */
@@ -161,20 +130,12 @@ const getModalLayout = ({
161
130
  const sheetSpace = placement.width - sheetMargin * 2;
162
131
  const sheetMinWidth = Math.min(SHEET_MIN_WIDTH, sheetSpace);
163
132
  const sheetMaxHeight = height - insets.top - Spacing.M;
164
- const sheetWidth = clamp(sheetSpace, sheetMinWidth, SHEET_MAX_WIDTH);
165
- const popupWidth = clamp(popupSpace, popupMinWidth, POPUP_MAX_WIDTH);
166
- // the window center; half folded, the right half's
167
- let overlayCenter = width / 2;
168
- if (isHalfFolded) {
169
- overlayCenter = placement.x + placement.width / 2;
170
- }
171
133
 
172
134
  return {
173
135
  isFoldable,
174
136
  placement,
175
137
  popup: {
176
- width: popupWidth,
177
- x: overlayX(overlayCenter, placement, popupWidth, popupMargin),
138
+ width: clamp(popupSpace, popupMinWidth, POPUP_MAX_WIDTH),
178
139
  minWidth: popupMinWidth,
179
140
  maxWidth: POPUP_MAX_WIDTH,
180
141
  maxHeight: Math.min(POPUP_MAX_HEIGHT, placement.height - Spacing.XL * 2),
@@ -182,8 +143,7 @@ const getModalLayout = ({
182
143
  radius: Radius.XL,
183
144
  },
184
145
  sheet: {
185
- width: sheetWidth,
186
- x: overlayX(overlayCenter, placement, sheetWidth, sheetMargin),
146
+ width: clamp(sheetSpace, sheetMinWidth, SHEET_MAX_WIDTH),
187
147
  maxHeight: sheetMaxHeight,
188
148
  minHeight: Math.min(SHEET_MIN_HEIGHT, sheetMaxHeight),
189
149
  margin: sheetMargin,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Platform } from 'react-native';
2
+ import { Dimensions, Platform } from 'react-native';
3
3
  import {
4
4
  CardStyleInterpolators,
5
5
  type StackCardInterpolatedStyle,
@@ -13,7 +13,11 @@ import { HeaderBackground } from './Components/HeaderBackground';
13
13
  import { HeaderLeft } from './Components/HeaderLeft';
14
14
  import { HeaderRight } from './Components/HeaderRight';
15
15
  import { HeaderTitle, TitleCustom } from './Components/HeaderTitle';
16
- import { HeaderBarMetrics, TITLE_CONTAINER_RESET } from './headerLayout';
16
+ import {
17
+ getHeaderRowInset,
18
+ HeaderBarMetrics,
19
+ TITLE_CONTAINER_RESET,
20
+ } from './headerLayout';
17
21
  import type { HeaderTitleProps, NavigationOptions } from './types';
18
22
 
19
23
  const CARD_SHADOW_OPACITY = 0.3;
@@ -144,8 +148,9 @@ const exportHeaderTitle = (
144
148
  };
145
149
 
146
150
  /**
147
- * React Navigation options from screen params: design system header left,
148
- * title and right, and swipe back off for screens that own their back flow.
151
+ * React Navigation options from screen params: design system header left, title
152
+ * (`sidePadding` from the window edge with hidden back) and right, and swipe back
153
+ * off for screens that own their back flow.
149
154
  */
150
155
  const getOptions = (
151
156
  params: NavigationOptions,
@@ -167,9 +172,11 @@ const getOptions = (
167
172
  };
168
173
  if (params.hiddenBack) {
169
174
  headerLeft = null;
175
+ // options are static, so the window width is read once when they are built
176
+ const { width } = Dimensions.get('window');
170
177
  options.headerTitleContainerStyle = {
171
178
  ...TITLE_CONTAINER_RESET,
172
- left: HeaderBarMetrics.sidePadding,
179
+ left: getHeaderRowInset(width),
173
180
  };
174
181
  }
175
182
  options = {
package/Button/index.tsx CHANGED
@@ -192,10 +192,10 @@ const Button: FC<ButtonProps> = ({
192
192
 
193
193
  const sizeStyle = getSizeStyle();
194
194
  const typeStyle = getTypeStyle(type, theme, color);
195
- const containerStyle = StyleSheet.flatten([
195
+ const containerStyle: ViewStyle = StyleSheet.flatten([
196
196
  full && { width: '100%' },
197
197
  loading && { opacity: 0.75 },
198
- ]) as ViewStyle;
198
+ ]);
199
199
  const buttonStyle = StyleSheet.flatten([sizeStyle, typeStyle]);
200
200
 
201
201
  const animatedStyle = useAnimatedStyle(() => {
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
2
+ import { StyleSheet, View, ViewStyle } from 'react-native';
3
3
  import { ApplicationContext } from '../Context';
4
4
  import { Spacing } from '../Consts';
5
5
  import Svg, { Line } from 'react-native-svg';
@@ -8,7 +8,7 @@ export interface DashDividerProps {
8
8
  /**
9
9
  * Custom styles for dash divider
10
10
  */
11
- style?: StyleProp<ViewStyle>;
11
+ style?: ViewStyle;
12
12
  }
13
13
 
14
14
  /** 1px dashed horizontal line in the default border color. */
package/Divider/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
2
+ import { StyleSheet, View, ViewStyle } from 'react-native';
3
3
  import { ApplicationContext } from '../Context';
4
4
  import { Spacing } from '../Consts';
5
5
  import { DashDivider } from './DashDivider';
@@ -8,7 +8,7 @@ export interface DividerProps {
8
8
  /**
9
9
  * Custom styles for divider
10
10
  */
11
- style?: StyleProp<ViewStyle>;
11
+ style?: ViewStyle;
12
12
 
13
13
  /**
14
14
  * Enable margin vertical 4px
@@ -34,10 +34,10 @@ const Divider: React.FC<DividerProps> = ({
34
34
  return (
35
35
  <View
36
36
  style={[
37
+ style,
37
38
  styles.divider,
38
39
  useMargin ? styles.margin : styles.noMargin,
39
40
  { backgroundColor: theme.colors.border.default },
40
- style,
41
41
  ]}
42
42
  />
43
43
  );
@@ -10,7 +10,7 @@ type CombinedListProps<ItemT> = FlatListProps<ItemT> &
10
10
  * switch to it without type changes.
11
11
  */
12
12
  const FoundationList = <ItemT,>(props: CombinedListProps<ItemT>) => {
13
- return <FlashList {...(props as FlashListProps<ItemT>)} />;
13
+ return <FlashList {...props} />;
14
14
  };
15
15
 
16
16
  export { FoundationList };
package/Icon/types.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ImageStyle, StyleProp } from 'react-native';
1
+ import { ImageStyle } from 'react-native-fast-image';
2
+ import { StyleProp } from 'react-native';
2
3
 
3
4
  export type IconProps = {
4
5
  /**
package/Image/index.tsx CHANGED
@@ -1,11 +1,6 @@
1
1
  import React, { useContext, useRef, useState } from 'react';
2
- import {
3
- ImageBackground,
4
- ImageSourcePropType,
5
- StyleSheet,
6
- View,
7
- } from 'react-native';
8
- import FastImage, { FastImageProps } from 'react-native-fast-image';
2
+ import { StyleSheet, View } from 'react-native';
3
+ import FastImage from 'react-native-fast-image';
9
4
  import styles from './styles';
10
5
  import {
11
6
  ApplicationContext,
@@ -29,10 +24,6 @@ export const getImageName = (source: any): string => {
29
24
  return '';
30
25
  };
31
26
 
32
- const isDataUriSource = (source: any): boolean => {
33
- return typeof source?.uri === 'string' && source.uri.startsWith('data:');
34
- };
35
-
36
27
  /**
37
28
  * FastImage that shows a skeleton while loading (if `loading`) or inside a
38
29
  * loading `SkeletonProvider`, and a fail icon on error.
@@ -57,7 +48,6 @@ const Image: React.FC<ImageProps> = ({
57
48
  const [status, setStatus] = useState<Status>('success');
58
49
 
59
50
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
60
- const useFastImage = !isDataUriSource(source);
61
51
 
62
52
  const imageName = getImageName(source);
63
53
  let accessibilityLabel: any = `img|${imageName}`;
@@ -91,61 +81,16 @@ const Image: React.FC<ImageProps> = ({
91
81
  return children;
92
82
  };
93
83
 
94
- if (!useFastImage) {
95
- // RN <Image> throws when given children (skeleton / fail icon), so use
96
- // ImageBackground, which renders them on top of the image like FastImage.
97
- return (
98
- <ImageBackground
99
- {...(rest as any)}
100
- {...{
101
- accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel,
102
- }}
103
- source={source as ImageSourcePropType}
104
- style={[
105
- styles.dataUriContainer,
106
- styles.container,
107
- style,
108
- showBaseLineDebug && styles.debugBaseLine,
109
- ]}
110
- onLoadStart={() => {
111
- hasErrorRef.current = false;
112
- if (status !== 'loading' && loading) {
113
- setStatus('loading');
114
- }
115
- }}
116
- onLoad={() => {
117
- hasErrorRef.current = false;
118
- }}
119
- onLoadEnd={() => {
120
- let current: Status = 'success';
121
- if (hasErrorRef.current) {
122
- current = 'error';
123
- }
124
- setStatus(prevState =>
125
- prevState !== current ? current : prevState,
126
- );
127
- }}
128
- onError={() => {
129
- hasErrorRef.current = true;
130
- }}
131
- >
132
- {renderContent()}
133
- </ImageBackground>
134
- );
135
- }
136
-
137
84
  return (
138
85
  <FastImage
139
86
  {...rest}
140
87
  {...{ accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel }}
141
88
  source={source}
142
- style={
143
- [
144
- styles.container,
145
- style,
146
- showBaseLineDebug && styles.debugBaseLine,
147
- ] as FastImageProps['style']
148
- }
89
+ style={[
90
+ styles.container,
91
+ style,
92
+ showBaseLineDebug && styles.debugBaseLine,
93
+ ]}
149
94
  onProgress={event => {
150
95
  hasErrorRef.current = false;
151
96
  if (status !== 'loading' && loading) {
package/Image/styles.ts CHANGED
@@ -3,7 +3,5 @@ import { Colors } from '../Consts';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  container: {},
6
- // same clipping as FastImage's container, so borderRadius rounds the image
7
- dataUriContainer: { overflow: 'hidden' },
8
6
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
9
7
  });
package/Image/types.ts CHANGED
@@ -1,14 +1,6 @@
1
- import { ImageStyle, StyleProp } from 'react-native';
2
1
  import { FastImageProps } from 'react-native-fast-image';
3
2
 
4
- /**
5
- * `style` uses React Native's own `ImageStyle`: from RN 0.87 (Strict TS API)
6
- * react-native no longer exports `FlexStyle`/`ShadowStyleIOS`, which
7
- * react-native-fast-image's `ImageStyle` extends, so that type lost layout
8
- * props such as `width`, `margin*` or `position`.
9
- */
10
- export interface ImageProps extends Omit<FastImageProps, 'style'> {
11
- style?: StyleProp<ImageStyle>;
3
+ export interface ImageProps extends FastImageProps {
12
4
  loading?: boolean;
13
5
  accessibilityLabel?: any;
14
6
  params?: any;
@@ -45,7 +45,7 @@ const ErrorView: FC<ErrorViewProps> = ({
45
45
  color={messageColor}
46
46
  typography={'description_default_regular'}
47
47
  >
48
- {errorMessage || hintTextDefault}
48
+ {errorMessage ?? hintTextDefault}
49
49
  </Text>
50
50
  </View>
51
51
  );
package/Input/Input.tsx CHANGED
@@ -6,10 +6,10 @@ import React, {
6
6
  useState,
7
7
  } from 'react';
8
8
  import {
9
+ TextInput,
9
10
  TextInputFocusEvent,
10
11
  TouchableOpacity,
11
12
  View,
12
- type TextInputInstance,
13
13
  } from 'react-native';
14
14
  import { useComponentId } from '../Application';
15
15
  import { Icon } from '../Icon';
@@ -81,7 +81,7 @@ const Input = forwardRef(
81
81
  const [isFocused, setIsFocused] = useState(false);
82
82
  const [internalText, setInternalText] = useState(defaultValue || '');
83
83
  const hasValue = value !== undefined ? !!value : !!internalText;
84
- const inputRef = useRef<TextInputInstance | null>(null);
84
+ const inputRef = useRef<TextInput | null>(null);
85
85
  const componentName = 'Input';
86
86
 
87
87
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
@@ -7,12 +7,7 @@ import React, {
7
7
  useRef,
8
8
  useState,
9
9
  } from 'react';
10
- import {
11
- Platform,
12
- TextInputFocusEvent,
13
- View,
14
- type TextInputInstance,
15
- } from 'react-native';
10
+ import { Platform, TextInput, TextInputFocusEvent, View } from 'react-native';
16
11
  import { useComponentId } from '../Application';
17
12
  import { ComponentContext, MiniAppContext } from '../Context';
18
13
  import { ErrorView } from './ErrorView';
@@ -61,7 +56,7 @@ const InputMoney = forwardRef(
61
56
  const [displayValue, setDisplayValue] = useState('');
62
57
  const [numericValue, setNumericValue] = useState('');
63
58
  const [lastDisplayValue, setLastDisplayValue] = useState('');
64
- const inputRef = useRef<TextInputInstance>(null);
59
+ const inputRef = useRef<TextInput>(null);
65
60
  const caretDigitsAfter = useRef<number | undefined>(undefined);
66
61
  const lastRawText = useRef('');
67
62
  const [caretSelection, setCaretSelection] = useState<{
@@ -2,11 +2,11 @@ import React, { RefObject, useContext } from 'react';
2
2
  import {
3
3
  Pressable,
4
4
  Text,
5
+ TextInput,
5
6
  TextInputFocusEvent,
6
7
  TextInputProps,
7
8
  TouchableOpacity,
8
9
  View,
9
- type TextInputInstance,
10
10
  } from 'react-native';
11
11
  import { ApplicationContext } from '../Context';
12
12
  import { Icon } from '../Icon';
@@ -43,7 +43,7 @@ type InputMoneyViewProps = Pick<
43
43
  componentId: string;
44
44
  displayValue: string;
45
45
  caretSelection?: { start: number; end: number };
46
- inputRef: RefObject<TextInputInstance | null>;
46
+ inputRef: RefObject<TextInput | null>;
47
47
  focusAtEnd: () => void;
48
48
  onClearText: () => void;
49
49
  onChangeText: (text: string) => void;
@@ -53,8 +53,8 @@ type InputMoneyViewProps = Pick<
53
53
  };
54
54
 
55
55
  /**
56
- * Presentational body of InputMoney: bordered field, currency suffix (shown
57
- * once there is a value) and the clear/trailing icons.
56
+ * Presentational body of InputMoney: bordered field, currency suffix (kept
57
+ * after a placeholder that ends with it) and the clear/trailing icons.
58
58
  */
59
59
  export const InputMoneyView = ({
60
60
  size,
@@ -101,8 +101,13 @@ export const InputMoneyView = ({
101
101
  fontSize: scaledFontSize,
102
102
  fontFamily: inputFontFamily,
103
103
  };
104
- const hasValue = displayValue.length > 0;
104
+ const hasCurrencyInPlaceholder = placeholder.endsWith(currency);
105
+ const shouldShowCurrency = !!displayValue || hasCurrencyInPlaceholder;
105
106
  const shouldShowClearIcon = !!(showClearIcon && focused && displayValue);
107
+ let inputPlaceholder = placeholder;
108
+ if (hasCurrencyInPlaceholder) {
109
+ inputPlaceholder = placeholder.slice(0, -currency.length);
110
+ }
106
111
  return (
107
112
  <View
108
113
  style={[
@@ -143,15 +148,18 @@ export const InputMoneyView = ({
143
148
  onChangeText={onChangeText}
144
149
  onFocus={onFocus}
145
150
  onBlur={onBlur}
146
- placeholder={placeholder}
151
+ placeholder={inputPlaceholder}
147
152
  selectionColor={theme.colors.primary}
148
153
  placeholderTextColor={placeholderColor}
149
154
  keyboardType={'numeric'}
150
155
  maxLength={undefined}
151
156
  />
152
- {hasValue && (
157
+ {shouldShowCurrency && (
153
158
  <Text
154
- style={[textStyle, { color: textColor }]}
159
+ style={[
160
+ textStyle,
161
+ { color: displayValue ? textColor : placeholderColor },
162
+ ]}
155
163
  allowFontScaling={false}
156
164
  >
157
165
  {currency}
@@ -9,10 +9,10 @@ import React, {
9
9
  } from 'react';
10
10
  import {
11
11
  PixelRatio,
12
+ TextInput,
12
13
  TextInputFocusEvent,
13
14
  TouchableOpacity,
14
15
  View,
15
- type TextInputInstance,
16
16
  } from 'react-native';
17
17
  import Animated, {
18
18
  cancelAnimation,
@@ -116,7 +116,7 @@ const InputOTP = forwardRef(
116
116
  ) => {
117
117
  const [value, setValue] = useState('');
118
118
  const [isFocused, setIsFocused] = useState(false);
119
- const inputRef = useRef<TextInputInstance | null>(null);
119
+ const inputRef = useRef<TextInput | null>(null);
120
120
  const { theme } = useContext(ApplicationContext);
121
121
  const context = useContext<any>(MiniAppContext);
122
122
 
@@ -6,10 +6,11 @@ import React, {
6
6
  useState,
7
7
  } from 'react';
8
8
  import {
9
+ StyleSheet,
10
+ TextInput,
9
11
  TextInputFocusEvent,
10
12
  TouchableOpacity,
11
13
  View,
12
- type TextInputInstance,
13
14
  } from 'react-native';
14
15
  import { useComponentId } from '../Application';
15
16
  import {
@@ -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 { useScaleSize, exportFontFamily } from '../Text';
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 DEFAULT_COUNTRY_CODE = '+84';
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
- * Phone number input behind a country flag and dial code (Vietnam `+84` by
43
- * default), number pad by default, plus clear and trailing icons.
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,
@@ -79,7 +76,7 @@ const InputPhoneNumber = forwardRef(
79
76
  const [isFocused, setIsFocused] = useState(false);
80
77
  const [internalText, setInternalText] = useState(defaultValue || '');
81
78
  const hasValue = value !== undefined ? !!value : !!internalText;
82
- const inputRef = useRef<TextInputInstance | null>(null);
79
+ const inputRef = useRef<TextInput | null>(null);
83
80
  const componentName = 'InputPhoneNumber';
84
81
 
85
82
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
@@ -185,16 +182,29 @@ const InputPhoneNumber = forwardRef(
185
182
  ]}
186
183
  >
187
184
  <View style={styles.inputView}>
188
- <CountryCodeView
189
- countryCode={countryCode}
190
- countryFlag={countryFlag}
191
- typography={typography}
192
- textColor={textColor}
193
- dividerHeight={dividerHeight}
194
- componentId={componentId}
195
- isDisabled={disabled || !editable}
196
- onPress={onPressLeadingIcon}
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;
@@ -7,10 +7,10 @@ import React, {
7
7
  useState,
8
8
  } from 'react';
9
9
  import {
10
+ TextInput,
10
11
  TextInputFocusEvent,
11
12
  TouchableOpacity,
12
13
  View,
13
- type TextInputInstance,
14
14
  } from 'react-native';
15
15
  import { useComponentId } from '../Application';
16
16
  import { HeaderBarMetrics } from '../Application/headerLayout';
@@ -76,7 +76,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
76
76
  const [internalText, setInternalText] = useState(defaultValue || '');
77
77
  const currentValue = value !== undefined ? value : internalText;
78
78
  const hasValue = !!currentValue;
79
- const inputRef = useRef<TextInputInstance | null>(null);
79
+ const inputRef = useRef<TextInput | null>(null);
80
80
 
81
81
  const componentName = 'InputSearch';
82
82
 
@@ -7,10 +7,10 @@ import React, {
7
7
  useState,
8
8
  } from 'react';
9
9
  import {
10
+ TextInput,
10
11
  TextInputFocusEvent,
11
12
  TouchableOpacity,
12
13
  View,
13
- type TextInputInstance,
14
14
  } from 'react-native';
15
15
  import { setAutomationID, useComponentId } from '../Application';
16
16
  import { ApplicationContext, MiniAppContext } from '../Context';
@@ -70,7 +70,7 @@ const InputTextArea = forwardRef(
70
70
  const inputFontFamily = exportFontFamily('regular');
71
71
  const [isFocused, setIsFocused] = useState(false);
72
72
  const [inputValue, setInputValue] = useState(defaultValue ?? '');
73
- const inputRef = useRef<TextInputInstance | null>(null);
73
+ const inputRef = useRef<TextInput | null>(null);
74
74
 
75
75
  useEffect(() => {
76
76
  setInputValue(value ?? '');
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import React, { FC, useEffect, useRef } from 'react';
3
- import { TextInput, type TextInputInstance } from 'react-native';
3
+ import { TextInput } from 'react-native';
4
4
  import { useScaleSize, exportFontFamily } from '../Text';
5
5
  import styles from './styles';
6
6
 
@@ -13,7 +13,7 @@ export const TextTyping: FC<any> = ({
13
13
  timeDelayEnd = 2000,
14
14
  timeDelayNextChar = 20,
15
15
  }) => {
16
- const textRef = useRef<TextInputInstance>(null);
16
+ const textRef = useRef<TextInput>(null);
17
17
  const scaledFontSize = useScaleSize(12);
18
18
  const typingFontFamily = exportFontFamily('regular');
19
19
 
@@ -4,12 +4,11 @@ import {
4
4
  TextInput,
5
5
  TextInputProps,
6
6
  TouchableOpacity,
7
- type TextInputInstance,
8
7
  } from 'react-native';
9
8
  import { Styles } from '../Consts';
10
9
 
11
10
  interface SystemTextInputProps extends TextInputProps {
12
- ref?: React.RefObject<TextInputInstance | null>;
11
+ ref?: React.RefObject<TextInput | null>;
13
12
  }
14
13
 
15
14
  /**