@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.
Files changed (153) hide show
  1. package/Application/BottomSheet.tsx +398 -86
  2. package/Application/BottomTab/BottomTabBar.tsx +275 -215
  3. package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
  4. package/Application/BottomTab/DuoBarCompression.tsx +28 -14
  5. package/Application/BottomTab/DuoTabBar.tsx +540 -32
  6. package/Application/BottomTab/TabBarIcon.tsx +72 -146
  7. package/Application/BottomTab/index.tsx +353 -89
  8. package/Application/BottomTab/useLiquidSelection.ts +374 -0
  9. package/Application/Components/BackgroundImageView.tsx +0 -4
  10. package/Application/Components/DuoGlassBackground.tsx +5 -7
  11. package/Application/Components/HeaderAnimated.tsx +13 -41
  12. package/Application/Components/HeaderBackground.tsx +3 -20
  13. package/Application/Components/HeaderExtendHeader.tsx +46 -66
  14. package/Application/Components/HeaderLeft.tsx +18 -5
  15. package/Application/Components/HeaderRight.tsx +529 -8
  16. package/Application/Components/HeaderTitle.tsx +579 -16
  17. package/Application/Components/NavigationButton.tsx +11 -18
  18. package/Application/Components/SearchHeader.tsx +18 -38
  19. package/Application/Localize.ts +0 -7
  20. package/Application/ModalScreen.tsx +18 -41
  21. package/Application/Navigation.ts +17 -15
  22. package/Application/NavigationContainer.tsx +21 -23
  23. package/Application/Navigator.ts +48 -20
  24. package/Application/ScaleSizeProvider.tsx +6 -13
  25. package/Application/StackScreen.tsx +172 -27
  26. package/Application/TooltipPortal.tsx +5 -12
  27. package/Application/WidgetContainer.tsx +7 -20
  28. package/Application/device.ts +52 -0
  29. package/Application/index.ts +1 -23
  30. package/Application/types.ts +242 -17
  31. package/Application/utils.tsx +493 -0
  32. package/Badge/Badge.tsx +0 -5
  33. package/Badge/BadgeDot.tsx +0 -1
  34. package/Badge/BadgeDotAnimation.tsx +7 -15
  35. package/Badge/BadgeRibbon.tsx +39 -47
  36. package/Badge/Shape.tsx +0 -2
  37. package/Badge/styles.ts +0 -2
  38. package/Badge/types.ts +2 -2
  39. package/Button/index.tsx +152 -21
  40. package/Button/styles.ts +1 -1
  41. package/CheckBox/index.tsx +6 -5
  42. package/Consts/theme.ts +10 -10
  43. package/Context/index.ts +1 -5
  44. package/Divider/DashDivider.tsx +11 -11
  45. package/Divider/index.tsx +7 -21
  46. package/FoundationList/index.tsx +0 -4
  47. package/Icon/index.tsx +6 -6
  48. package/Icon/types.ts +1 -1
  49. package/IconButton/index.tsx +12 -4
  50. package/Image/index.tsx +7 -9
  51. package/Input/Input.tsx +12 -10
  52. package/Input/InputDropDown.tsx +13 -10
  53. package/Input/InputMoney.tsx +152 -45
  54. package/Input/InputOTP.tsx +34 -36
  55. package/Input/InputPhoneNumber.tsx +5 -8
  56. package/Input/InputSearch.tsx +111 -19
  57. package/Input/InputTextArea.tsx +5 -5
  58. package/Input/SystemTextInput.tsx +2 -7
  59. package/Input/TextTyping.tsx +0 -4
  60. package/Input/common.tsx +17 -31
  61. package/Input/index.tsx +21 -24
  62. package/Input/styles.ts +5 -25
  63. package/Input/utils.ts +12 -14
  64. package/Layout/Card.tsx +4 -7
  65. package/Layout/FloatingButton.tsx +21 -26
  66. package/Layout/Item.tsx +2 -6
  67. package/Layout/ItemList.tsx +7 -9
  68. package/Layout/ItemSectionList.tsx +1 -2
  69. package/Layout/ReservedRegions.tsx +17 -34
  70. package/Layout/Screen.tsx +696 -122
  71. package/Layout/Section.tsx +7 -9
  72. package/Layout/TrackingScope.tsx +0 -1
  73. package/Layout/index.ts +4 -10
  74. package/Layout/styles.ts +0 -2
  75. package/Layout/types.ts +4 -2
  76. package/Layout/utils.ts +181 -40
  77. package/Loader/DotLoader.tsx +3 -11
  78. package/Loader/Loader.tsx +0 -4
  79. package/Loader/ProgressBar.tsx +6 -3
  80. package/Loader/Spinner.tsx +3 -11
  81. package/Loader/styles.ts +0 -4
  82. package/Loader/utils.ts +7 -11
  83. package/Pagination/Dot.tsx +0 -4
  84. package/Pagination/PaginationDot.tsx +0 -1
  85. package/Pagination/PaginationNumber.tsx +3 -5
  86. package/Pagination/PaginationScroll.tsx +0 -5
  87. package/Pagination/PaginationWhiteDot.tsx +0 -1
  88. package/Pagination/index.tsx +0 -4
  89. package/Pagination/types.ts +2 -2
  90. package/Popup/PopupNotify.tsx +102 -94
  91. package/Popup/PopupPromotion.tsx +11 -9
  92. package/Popup/types.ts +4 -11
  93. package/Popup/utils.ts +18 -50
  94. package/Radio/index.tsx +10 -6
  95. package/Radio/styles.ts +0 -6
  96. package/Skeleton/index.tsx +9 -9
  97. package/Skeleton/styles.ts +0 -1
  98. package/Switch/index.tsx +0 -1
  99. package/Tag/index.tsx +4 -8
  100. package/Tag/types.ts +3 -3
  101. package/Text/index.tsx +5 -25
  102. package/Text/styles.ts +1 -1
  103. package/Text/types.ts +6 -1
  104. package/Text/utils.ts +4 -20
  105. package/Title/index.tsx +40 -42
  106. package/Title/styles.ts +0 -6
  107. package/ViewBoundary/index.tsx +2 -4
  108. package/index.ts +6 -0
  109. package/package.json +1 -2
  110. package/Application/BottomSheet.hooks.ts +0 -195
  111. package/Application/BottomSheet.parts.tsx +0 -157
  112. package/Application/BottomSheet.styles.ts +0 -43
  113. package/Application/BottomTab/ActiveIndicator.tsx +0 -91
  114. package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
  115. package/Application/BottomTab/BottomTabInset.tsx +0 -18
  116. package/Application/BottomTab/CurvedContainer.tsx +0 -155
  117. package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
  118. package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
  119. package/Application/BottomTab/TabScreen.tsx +0 -160
  120. package/Application/BottomTab/metrics.ts +0 -164
  121. package/Application/BottomTab/tabItems.ts +0 -46
  122. package/Application/BottomTab/usePressLift.ts +0 -32
  123. package/Application/Components/HeaderRight.styles.ts +0 -146
  124. package/Application/Components/HeaderTitle.shared.ts +0 -44
  125. package/Application/Components/HeaderTitle.styles.ts +0 -125
  126. package/Application/Components/HeaderToolkitAction.tsx +0 -180
  127. package/Application/Components/SwipeBackHaptic.tsx +0 -95
  128. package/Application/Components/TitleJourney.tsx +0 -110
  129. package/Application/Components/TitleLocation.tsx +0 -73
  130. package/Application/Components/TitleUser.tsx +0 -304
  131. package/Application/Components/useToolkitActions.tsx +0 -218
  132. package/Application/ModalIconButton.tsx +0 -66
  133. package/Application/StackScreen.tracking.ts +0 -143
  134. package/Application/headerLayout.ts +0 -158
  135. package/Application/hooks.ts +0 -137
  136. package/Application/modalLayout.ts +0 -176
  137. package/Application/navigationOptions.tsx +0 -212
  138. package/Application/types.header.ts +0 -121
  139. package/Application/types.tabs.ts +0 -48
  140. package/Application/types.theme.ts +0 -87
  141. package/Application/utils.ts +0 -107
  142. package/Button/utils.ts +0 -133
  143. package/Input/InputMoneyView.tsx +0 -194
  144. package/Input/SearchTextTyping.tsx +0 -108
  145. package/Input/moneyUtils.ts +0 -23
  146. package/Layout/layoutMetrics.ts +0 -58
  147. package/Layout/layoutTypes.ts +0 -86
  148. package/Layout/screenContent.tsx +0 -92
  149. package/Layout/screenFooter.tsx +0 -63
  150. package/Layout/screenHeader.tsx +0 -321
  151. package/Layout/screenQuickReturn.tsx +0 -64
  152. package/Layout/screenScroll.ts +0 -107
  153. package/Layout/screenTypes.ts +0 -143
@@ -7,20 +7,52 @@ import React, {
7
7
  useRef,
8
8
  useState,
9
9
  } from 'react';
10
- import { Platform, TextInput, TextInputFocusEvent, View } from 'react-native';
10
+ import {
11
+ Platform,
12
+ Pressable,
13
+ Text,
14
+ TextInput,
15
+ TextInputFocusEvent,
16
+ TouchableOpacity,
17
+ View,
18
+ } from 'react-native';
11
19
  import { useComponentId } from '../Application';
12
- import { ComponentContext, MiniAppContext } from '../Context';
13
- import { ErrorView } from './common';
20
+ import {
21
+ ApplicationContext,
22
+ ComponentContext,
23
+ MiniAppContext,
24
+ } from '../Context';
25
+ import { Icon } from '../Icon';
26
+ import { useScaleSize, exportFontFamily } from '../Text';
27
+ import {
28
+ ErrorView,
29
+ FloatingView,
30
+ getBorderColor,
31
+ getSizeStyle,
32
+ RenderTrailing,
33
+ } from './common';
14
34
  import { InputMoneyProps } from './index';
15
- import { InputMoneyView } from './InputMoneyView';
16
- import { findEdit, moneyFormatter } from './moneyUtils';
17
35
  import styles from './styles';
36
+ import SystemTextInput from './SystemTextInput';
37
+
38
+ const moneyFormatter = new Intl.NumberFormat('vi-VN');
39
+
40
+ const findEdit = (old: string, text: string) => {
41
+ let start = 0;
42
+ while (start < text.length && old[start] === text[start]) {
43
+ start += 1;
44
+ }
45
+ let suffix = 0;
46
+ while (
47
+ suffix < Math.min(text.length, old.length) - start &&
48
+ old[old.length - 1 - suffix] === text[text.length - 1 - suffix]
49
+ ) {
50
+ suffix += 1;
51
+ }
52
+ const size = old.length + text.length - 2 * (start + suffix);
53
+ return { old, start, suffix, size };
54
+ };
18
55
 
19
- /**
20
- * Money input: keeps digits only, shows them grouped with a currency suffix and
21
- * reports raw digits to `onChangeText`. On Android it restores the caret by the
22
- * count of digits after it, since regrouping shifts positions.
23
- */
24
56
  const InputMoney = forwardRef(
25
57
  (
26
58
  {
@@ -51,7 +83,11 @@ const InputMoney = forwardRef(
51
83
  }: InputMoneyProps,
52
84
  ref,
53
85
  ) => {
86
+ const { theme } = useContext(ApplicationContext);
54
87
  const context = useContext<any>(MiniAppContext);
88
+ const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
89
+ const scaledFontSize = useScaleSize(20);
90
+ const inputFontFamily = exportFontFamily('bold');
55
91
  const [focused, setFocused] = useState(false);
56
92
  const [displayValue, setDisplayValue] = useState('');
57
93
  const [numericValue, setNumericValue] = useState('');
@@ -93,9 +129,9 @@ const InputMoney = forwardRef(
93
129
 
94
130
  useEffect(() => {
95
131
  if (!caretSelection) return;
96
- setCaretSelection(current => {
97
- return current === caretSelection ? undefined : current;
98
- });
132
+ setCaretSelection(current =>
133
+ current === caretSelection ? undefined : current,
134
+ );
99
135
  }, [caretSelection]);
100
136
 
101
137
  const updateDisplayValue = (numeric: string) => {
@@ -147,10 +183,11 @@ const InputMoney = forwardRef(
147
183
  lastRawText.current = text;
148
184
  const formattedEdit = findEdit(lastDisplayValue, text);
149
185
  const rawEdit = findEdit(raw, text);
150
- const isRawEditSmaller = !!raw && rawEdit.size < formattedEdit.size;
151
- const { old, start, suffix } = isRawEditSmaller ? rawEdit : formattedEdit;
152
- const textAfterEdit = text.slice(text.length - suffix);
153
- caretDigitsAfter.current = parseInputText(textAfterEdit).length;
186
+ const { old, start, suffix } =
187
+ raw && rawEdit.size < formattedEdit.size ? rawEdit : formattedEdit;
188
+ caretDigitsAfter.current = parseInputText(
189
+ text.slice(text.length - suffix),
190
+ ).length;
154
191
  if (text.length < old.length && digits === numericValue) {
155
192
  const index = parseInputText(text.slice(0, start)).length - 1;
156
193
  if (index >= 0) {
@@ -197,6 +234,103 @@ const InputMoney = forwardRef(
197
234
  };
198
235
  });
199
236
 
237
+ const renderInputView = () => {
238
+ const disabledColor = theme.colors.text.disable;
239
+ let textColor = theme.colors.text.default;
240
+ let placeholderColor = theme.colors.text.hint;
241
+ let iconTintColor = trailingColor;
242
+ if (disabled) {
243
+ textColor = disabledColor;
244
+ placeholderColor = disabledColor;
245
+ iconTintColor = disabledColor;
246
+ }
247
+ const textStyle = {
248
+ fontSize: scaledFontSize,
249
+ fontFamily: inputFontFamily,
250
+ };
251
+ const hasValue = displayValue.length > 0;
252
+ return (
253
+ <View
254
+ style={[
255
+ styles.inputWrapper,
256
+ { backgroundColor: theme.colors.background.surface },
257
+ getSizeStyle(size, undefined, scaleHeight),
258
+ getBorderColor(theme, focused, errorMessage, disabled),
259
+ ]}
260
+ >
261
+ <FloatingView
262
+ floatingValue={floatingValue}
263
+ floatingIconColor={floatingIconColor}
264
+ disabled={disabled}
265
+ required={required}
266
+ floatingIcon={floatingIcon}
267
+ onPress={onPressFloatingIcon}
268
+ componentId={componentId}
269
+ />
270
+ <Pressable
271
+ style={[styles.inputView, styles.moneyInputView]}
272
+ onPress={focusAtEnd}
273
+ disabled={disabled}
274
+ >
275
+ <SystemTextInput
276
+ {...props}
277
+ accessibilityLabel={`${componentId}`}
278
+ textAlignVertical="center"
279
+ ref={inputRef}
280
+ accessibilityState={{
281
+ disabled: disabled,
282
+ ...props.accessibilityState,
283
+ }}
284
+ style={[textStyle, styles.moneyTextInput, { color: textColor }]}
285
+ allowFontScaling={false}
286
+ textBreakStrategy="highQuality"
287
+ value={displayValue}
288
+ selection={caretSelection ?? props.selection}
289
+ onChangeText={_onChangeText}
290
+ onFocus={_onFocus}
291
+ onBlur={_onBlur}
292
+ placeholder={placeholder}
293
+ selectionColor={theme.colors.primary}
294
+ placeholderTextColor={placeholderColor}
295
+ keyboardType={'numeric'}
296
+ maxLength={undefined}
297
+ />
298
+ {hasValue ? (
299
+ <Text
300
+ style={[textStyle, { color: textColor }]}
301
+ allowFontScaling={false}
302
+ >
303
+ {currency}
304
+ </Text>
305
+ ) : null}
306
+ </Pressable>
307
+ <View style={styles.iconView}>
308
+ {showClearIcon && focused && displayValue ? (
309
+ <TouchableOpacity
310
+ accessibilityLabel={`${componentId}|clear-icon-touch`}
311
+ style={styles.iconWrapper}
312
+ onPress={onClearText}
313
+ >
314
+ <Icon
315
+ source="24_navigation_close_circle_full"
316
+ size={16}
317
+ color={theme.colors.text.hint}
318
+ accessibilityLabel={`${componentId}|clear-icon`}
319
+ />
320
+ </TouchableOpacity>
321
+ ) : null}
322
+ <RenderTrailing
323
+ color={iconTintColor}
324
+ icon={trailing}
325
+ onPressIcon={onPressTrailing}
326
+ loading={loading}
327
+ componentId={componentId}
328
+ />
329
+ </View>
330
+ </View>
331
+ );
332
+ };
333
+
200
334
  let inputState = 'active';
201
335
  if (displayValue) {
202
336
  inputState = 'filled';
@@ -224,34 +358,7 @@ const InputMoney = forwardRef(
224
358
  showBaseLineDebug && styles.debugBaseLine,
225
359
  ]}
226
360
  >
227
- <InputMoneyView
228
- size={size}
229
- errorMessage={errorMessage}
230
- disabled={disabled}
231
- trailingColor={trailingColor}
232
- trailing={trailing}
233
- onPressTrailing={onPressTrailing}
234
- loading={loading}
235
- floatingValue={floatingValue}
236
- floatingIconColor={floatingIconColor}
237
- required={required}
238
- floatingIcon={floatingIcon}
239
- onPressFloatingIcon={onPressFloatingIcon}
240
- showClearIcon={showClearIcon}
241
- placeholder={placeholder}
242
- currency={currency}
243
- focused={focused}
244
- componentId={componentId}
245
- displayValue={displayValue}
246
- caretSelection={caretSelection}
247
- inputRef={inputRef}
248
- focusAtEnd={focusAtEnd}
249
- onClearText={onClearText}
250
- onChangeText={_onChangeText}
251
- onFocus={_onFocus}
252
- onBlur={_onBlur}
253
- inputProps={props}
254
- />
361
+ {renderInputView()}
255
362
  <ErrorView
256
363
  errorMessage={errorMessage}
257
364
  errorSpacing={errorSpacing}
@@ -38,7 +38,6 @@ import {
38
38
  MiniAppContext,
39
39
  } from '../Context';
40
40
 
41
- /** Blinking caret shown in the OTP slot being typed. */
42
41
  const OTPCaret: FC<CaretProps> = ({ index, length }) => {
43
42
  const DURATION = 300;
44
43
  const { theme } = useContext(ApplicationContext);
@@ -61,7 +60,9 @@ const OTPCaret: FC<CaretProps> = ({ index, length }) => {
61
60
  };
62
61
  }, [opacity]);
63
62
 
64
- const animatedStyle = useAnimatedStyle(() => ({ opacity: opacity.value }));
63
+ const animatedStyle = useAnimatedStyle(() => ({
64
+ opacity: opacity.value,
65
+ }));
65
66
 
66
67
  const hasNextInput = !isNaN(Number(length)) && index !== Number(length) - 1;
67
68
  const spacingStyle = hasNextInput && { marginRight: Spacing.L };
@@ -70,9 +71,9 @@ const OTPCaret: FC<CaretProps> = ({ index, length }) => {
70
71
  <View style={[Styles.rowCenter, spacingStyle]}>
71
72
  <Animated.View
72
73
  style={[
73
- styles.otpCursor,
74
74
  {
75
75
  height: useScaleSize(12),
76
+ width: 1,
76
77
  backgroundColor: theme.colors.primary,
77
78
  },
78
79
  animatedStyle,
@@ -85,10 +86,6 @@ const OTPCaret: FC<CaretProps> = ({ index, length }) => {
85
86
  );
86
87
  };
87
88
 
88
- /**
89
- * OTP input: a hidden TextInput drives `length` slots (or a free-length row
90
- * when `length` is unset) with a blinking caret; accepts at most 10 chars.
91
- */
92
89
  const InputOTP = forwardRef(
93
90
  (
94
91
  {
@@ -124,16 +121,14 @@ const InputOTP = forwardRef(
124
121
  props.accessibilityLabel,
125
122
  );
126
123
 
127
- useImperativeHandle(ref, () => {
128
- return {
129
- onChangeText: (text: string) => {
130
- _onChangeText(text);
131
- },
132
- focus: () => inputRef.current?.focus(),
133
- blur: () => inputRef.current?.blur(),
134
- setText: (text: string) => _onChangeText(text),
135
- };
136
- });
124
+ useImperativeHandle(ref, () => ({
125
+ onChangeText: (text: string) => {
126
+ _onChangeText(text);
127
+ },
128
+ focus: () => inputRef.current?.focus(),
129
+ blur: () => inputRef.current?.blur(),
130
+ setText: (text: string) => _onChangeText(text),
131
+ }));
137
132
 
138
133
  const onFocusInput = (e: TextInputFocusEvent) => {
139
134
  setFocused(true);
@@ -147,10 +142,13 @@ const InputOTP = forwardRef(
147
142
 
148
143
  const _onChangeText = (text: string) => {
149
144
  if (text.length > MAX_LENGTH) return;
150
- const isNumeric = !isNaN(Number(text));
151
- if (dataType === 'number' && !isNumeric) return;
152
- const isFull = value.length >= Number(length);
153
- if (isNumeric && isFull && text.length >= value.length) return;
145
+ if (dataType === 'number' && isNaN(Number(text))) return;
146
+ if (
147
+ !isNaN(Number(text)) &&
148
+ value.length >= Number(length) &&
149
+ text.length >= value.length
150
+ )
151
+ return;
154
152
 
155
153
  setValue(text);
156
154
  onChangeText?.(text);
@@ -166,21 +164,21 @@ const InputOTP = forwardRef(
166
164
  const TextInputs: React.ReactNode[] = [];
167
165
  const textColors = theme.colors.text;
168
166
  for (let i = 0; i < inputLength; i++) {
169
- let slot: React.ReactNode;
170
- if (focused && value.length === i) {
171
- slot = <OTPCaret index={i} length={inputLength} />;
172
- } else {
173
- slot = (
174
- <Text
175
- style={i !== inputLength - 1 && { marginRight: Spacing.L }}
176
- color={value[i] ? textColors.default : textColors.hint}
177
- typography={value[i] ? 'header_m_bold' : 'body_default_regular'}
178
- >
179
- {value[i] || '-'}
180
- </Text>
181
- );
182
- }
183
- TextInputs.push(<View key={`otp-input-${i}`}>{slot}</View>);
167
+ TextInputs.push(
168
+ <View key={`otp-input-${i}`}>
169
+ {focused && value.length === i ? (
170
+ <OTPCaret index={i} length={inputLength} />
171
+ ) : (
172
+ <Text
173
+ style={i !== inputLength - 1 && { marginRight: Spacing.L }}
174
+ color={value[i] ? textColors.default : textColors.hint}
175
+ typography={value[i] ? 'header_m_bold' : 'body_default_regular'}
176
+ >
177
+ {value[i] || '-'}
178
+ </Text>
179
+ )}
180
+ </View>,
181
+ );
184
182
  }
185
183
  return TextInputs;
186
184
  };
@@ -34,8 +34,7 @@ import { Image } from '../Image';
34
34
  import { Typography } from '../Text/types';
35
35
 
36
36
  /**
37
- * Vietnamese phone number input with a fixed flag and `+84` prefix, number pad
38
- * by default, plus clear and trailing icons.
37
+ * Input default component
39
38
  */
40
39
  const InputPhoneNumber = forwardRef(
41
40
  (
@@ -147,6 +146,9 @@ const InputPhoneNumber = forwardRef(
147
146
  typography = 'header_m_bold';
148
147
  }
149
148
 
149
+ /**
150
+ * Render input view
151
+ */
150
152
  const renderInputView = () => {
151
153
  const disabledColor = theme.colors.text.disable;
152
154
  const secure = secureTextEntry;
@@ -154,11 +156,6 @@ const InputPhoneNumber = forwardRef(
154
156
  let placeholderColor = theme.colors.text.hint;
155
157
  let iconTintColor = trailingColor ?? theme.colors.text.default;
156
158
  const borderWidth = focused ? 1.5 : 1;
157
- let secureTextStyle = styles.secureTextLarge;
158
-
159
- if (size === 'small') {
160
- secureTextStyle = styles.secureTextSmall;
161
- }
162
159
 
163
160
  if (disabled) {
164
161
  textColor = disabledColor;
@@ -217,7 +214,7 @@ const InputPhoneNumber = forwardRef(
217
214
  color: textColor,
218
215
  },
219
216
  inputTextStyles,
220
- secure && haveValue && secureTextStyle,
217
+ secure && haveValue && { fontSize: size === 'small' ? 18 : 22 },
221
218
  ]}
222
219
  defaultValue={defaultValue}
223
220
  allowFontScaling={false}
@@ -1,7 +1,10 @@
1
+ /* eslint-disable react-hooks/exhaustive-deps */
1
2
  import React, {
3
+ FC,
2
4
  forwardRef,
3
5
  ForwardRefRenderFunction,
4
6
  useContext,
7
+ useEffect,
5
8
  useImperativeHandle,
6
9
  useRef,
7
10
  useState,
@@ -13,7 +16,6 @@ import {
13
16
  View,
14
17
  } from 'react-native';
15
18
  import { useComponentId } from '../Application';
16
- import { HeaderBarMetrics } from '../Application/headerLayout';
17
19
  import {
18
20
  ApplicationContext,
19
21
  ComponentContext,
@@ -22,17 +24,109 @@ import {
22
24
  import { Icon } from '../Icon';
23
25
  import { Text, useScaleSize, exportFontFamily } from '../Text';
24
26
  import { InputRef, InputSearchProps } from './index';
25
- import { TextTyping } from './SearchTextTyping';
26
27
  import styles from './styles';
27
28
  import { Styles } from '../Consts';
28
29
  import SystemTextInput from './SystemTextInput';
29
30
 
30
- const SEARCH_ICON_SIZE = 24;
31
+ const TextTyping: FC<any> = ({
32
+ data = [],
33
+ timeDelayEnd = 2000,
34
+ timeDelayNextChar = 20,
35
+ }) => {
36
+ const textRef = useRef<TextInput>(null);
37
+ const scaledFontSize = useScaleSize(12);
38
+ const typingFontFamily = exportFontFamily('regular');
39
+
40
+ const currentIndex = useRef<number>(0);
41
+ const currentCharIndex = useRef<number>(0);
42
+ const currentText = useRef('');
43
+
44
+ useEffect(() => {
45
+ setTimeout(() => {
46
+ playAnimation();
47
+ }, 1000);
48
+ }, []);
49
+
50
+ const playAnimation = () => {
51
+ const handleResetList = () => {
52
+ currentIndex.current = 0;
53
+ handleAnimation();
54
+ };
55
+
56
+ const handleAnimation = () => {
57
+ const listChar = data?.[currentIndex.current]?.split('') || [];
58
+ listChar.length !== 0 && showChar(listChar?.[currentCharIndex.current]);
59
+ };
60
+
61
+ if (currentIndex.current >= data?.length) {
62
+ handleResetList();
63
+ } else {
64
+ handleAnimation();
65
+ }
66
+ };
67
+
68
+ const showChar = (char?: string) => {
69
+ const handleResetString = () => {
70
+ setTimeout(() => {
71
+ reset();
72
+ }, timeDelayEnd);
73
+ };
74
+
75
+ const handleShowChar = () => {
76
+ setTimeout(() => {
77
+ textRef.current?.setNativeProps?.({
78
+ text: currentText.current + char,
79
+ });
80
+ currentText.current += char;
81
+ currentCharIndex.current++;
82
+ playAnimation();
83
+ }, timeDelayNextChar);
84
+ };
85
+
86
+ const textLength = data?.[currentIndex.current]?.length || 0;
87
+ if (currentCharIndex.current >= textLength) {
88
+ handleResetString();
89
+ } else {
90
+ handleShowChar();
91
+ }
92
+ };
93
+
94
+ const reset = () => {
95
+ const handleNextString = () => {
96
+ currentIndex.current++;
97
+ playAnimation();
98
+ };
99
+
100
+ const handleReset = () => {
101
+ setTimeout(() => {
102
+ textRef.current?.setNativeProps?.({
103
+ text: currentText.current.slice(0, -1),
104
+ });
105
+ currentText.current = currentText.current.slice(0, -1);
106
+ currentCharIndex.current--;
107
+ reset();
108
+ }, timeDelayNextChar);
109
+ };
110
+
111
+ currentCharIndex.current <= 0 ? handleNextString() : handleReset();
112
+ };
113
+
114
+ return (
115
+ <TextInput
116
+ style={[
117
+ styles.inputStyle,
118
+ { fontSize: scaledFontSize, fontFamily: typingFontFamily },
119
+ ]}
120
+ ref={textRef}
121
+ editable={false}
122
+ autoCorrect={false}
123
+ pointerEvents={'none'}
124
+ numberOfLines={1}
125
+ allowFontScaling={false}
126
+ />
127
+ );
128
+ };
31
129
 
32
- /**
33
- * Search field with search icon, clear icon, optional trailing icon and a
34
- * cancel button; with `typingData` it shows an animated placeholder instead.
35
- */
36
130
  const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
37
131
  {
38
132
  placeholder,
@@ -52,7 +146,6 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
52
146
  backgroundColor,
53
147
  onPress,
54
148
  typingData,
55
- size = 'default',
56
149
  ...props
57
150
  },
58
151
  ref,
@@ -63,13 +156,6 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
63
156
  const searchFontFamily = exportFontFamily('regular');
64
157
 
65
158
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
66
- const isHeaderSize = size === 'header';
67
- const inputHeightStyle = isHeaderSize && {
68
- height: HeaderBarMetrics.searchHeight,
69
- };
70
- const searchIconSize = isHeaderSize
71
- ? HeaderBarMetrics.iconSize
72
- : SEARCH_ICON_SIZE;
73
159
 
74
160
  const [focused, setFocused] = useState(false);
75
161
  const [internalText, setInternalText] = useState(defaultValue || '');
@@ -121,14 +207,18 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
121
207
  };
122
208
  });
123
209
 
210
+ /**
211
+ * Render the input view
212
+ */
124
213
  const renderInputView = () => {
125
214
  if (typingData && typingData?.length > 0) {
126
215
  return (
127
216
  <TouchableOpacity
128
217
  style={[
129
218
  styles.searchInput,
130
- styles.searchInputTyping,
131
- inputHeightStyle,
219
+ {
220
+ justifyContent: 'center',
221
+ },
132
222
  ]}
133
223
  onPress={onPress}
134
224
  activeOpacity={onPress ? 0.6 : 1}
@@ -147,7 +237,6 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
147
237
  ref={inputRef}
148
238
  style={[
149
239
  styles.searchInput,
150
- inputHeightStyle,
151
240
  {
152
241
  fontSize: scaledFontSize,
153
242
  color: theme.colors.text.default,
@@ -166,6 +255,9 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
166
255
  );
167
256
  };
168
257
 
258
+ /**
259
+ * Render trailing icon or text
260
+ */
169
261
  const renderTrailing = () => {
170
262
  return (
171
263
  <View style={Styles.row}>
@@ -241,7 +333,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
241
333
  >
242
334
  <Icon
243
335
  source={'navigation_search'}
244
- size={searchIconSize}
336
+ size={24}
245
337
  color={theme.colors.text.hint}
246
338
  />
247
339
  {renderInputView()}
@@ -15,16 +15,13 @@ import {
15
15
  import { ApplicationContext, MiniAppContext } from '../Context';
16
16
  import { Icon } from '../Icon';
17
17
  import { Text, useScaleSize, exportFontFamily } from '../Text';
18
+ import { Spacing } from '../Consts';
18
19
  import { ErrorView, FloatingView, getBorderColor, MAX_LENGTH } from './common';
19
20
  import { InputTextAreaProps } from './index';
20
21
  import styles from './styles';
21
22
  import SystemTextInput from './SystemTextInput';
22
23
  import { setAutomationID, useComponentId } from '../Application';
23
24
 
24
- /**
25
- * Multiline input with floating label, clear icon and a `length/maxLength`
26
- * counter; the ref exposes clear, focus, blur and setText.
27
- */
28
25
  const InputTextArea = forwardRef(
29
26
  (
30
27
  {
@@ -161,8 +158,11 @@ const InputTextArea = forwardRef(
161
158
  textAlignVertical="top"
162
159
  allowFontScaling={false}
163
160
  style={[
164
- styles.textAreaInput,
165
161
  {
162
+ width: '100%',
163
+ flex: 1,
164
+ paddingRight: Spacing.XS,
165
+ paddingVertical: Spacing.XS,
166
166
  fontSize: scaledFontSize,
167
167
  fontFamily: inputFontFamily,
168
168
  },
@@ -11,16 +11,11 @@ interface SystemTextInputProps extends TextInputProps {
11
11
  ref?: React.RefObject<TextInput | null>;
12
12
  }
13
13
 
14
- /**
15
- * TextInput that still fires onPressIn/onPressOut when not editable on
16
- * Android, by moving them to a wrapping touchable.
17
- */
18
14
  const SystemTextInput: FC<SystemTextInputProps> = props => {
19
15
  const { editable, onPressIn, onPressOut, ref } = props;
20
16
 
21
- const isAndroidReadOnly = Platform.OS === 'android' && !editable;
22
- const hasPressHandler = !!(onPressIn || onPressOut);
23
- const needsAndroidWrapper = isAndroidReadOnly && hasPressHandler;
17
+ const needsAndroidWrapper =
18
+ Platform.OS === 'android' && !editable && (onPressIn || onPressOut);
24
19
 
25
20
  const noPressHandlers = { onPressIn: undefined, onPressOut: undefined };
26
21
  const inputProps: TextInputProps = {
@@ -11,10 +11,6 @@ export interface TextTypingProps {
11
11
  inputStyle?: TextStyle;
12
12
  }
13
13
 
14
- /**
15
- * Typing placeholder: types each string of `data` char by char, then erases
16
- * it, looping forever. Writes via setNativeProps to avoid re-renders.
17
- */
18
14
  const TextTyping: FC<TextTypingProps> = ({
19
15
  data = [],
20
16
  timeDelayEnd = 2000,