@momo-kits/foundation 0.168.1-rn862.1 → 0.169.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.
- package/Application/BottomSheet.hooks.ts +195 -0
- package/Application/BottomSheet.parts.tsx +147 -0
- package/Application/BottomSheet.styles.ts +43 -0
- package/Application/BottomSheet.tsx +76 -279
- package/Application/BottomTab/ActiveIndicator.tsx +90 -0
- package/Application/BottomTab/BottomTabBar.styles.ts +65 -0
- package/Application/BottomTab/BottomTabBar.tsx +229 -276
- package/Application/BottomTab/BottomTabInset.tsx +14 -0
- package/Application/BottomTab/CurvedContainer.tsx +153 -0
- package/Application/BottomTab/CustomBottomTabItem.tsx +132 -108
- package/Application/BottomTab/DuoBarCompression.tsx +4 -12
- package/Application/BottomTab/DuoRailTabBar.tsx +227 -0
- package/Application/BottomTab/DuoTabBar.styles.ts +81 -0
- package/Application/BottomTab/DuoTabBar.tsx +29 -495
- package/Application/BottomTab/TabBarIcon.tsx +160 -72
- package/Application/BottomTab/TabScreen.tsx +164 -0
- package/Application/BottomTab/index.tsx +84 -351
- package/Application/BottomTab/metrics.ts +164 -0
- package/Application/BottomTab/tabItems.ts +46 -0
- package/Application/BottomTab/usePressLift.ts +32 -0
- package/Application/Components/DuoGlassBackground.tsx +7 -9
- package/Application/Components/HeaderAnimated.tsx +1 -1
- package/Application/Components/HeaderBackground.tsx +1 -1
- package/Application/Components/HeaderExtendHeader.tsx +17 -11
- package/Application/Components/HeaderRight.styles.ts +144 -0
- package/Application/Components/HeaderRight.tsx +6 -528
- package/Application/Components/HeaderTitle.shared.ts +43 -0
- package/Application/Components/HeaderTitle.styles.ts +125 -0
- package/Application/Components/HeaderTitle.tsx +12 -576
- package/Application/Components/HeaderToolkitAction.tsx +208 -0
- package/Application/Components/NavigationButton.tsx +9 -6
- package/Application/Components/SearchHeader.tsx +1 -1
- package/Application/Components/SwipeBackHaptic.tsx +95 -0
- package/Application/Components/TitleJourney.tsx +110 -0
- package/Application/Components/TitleLocation.tsx +73 -0
- package/Application/Components/TitleUser.tsx +304 -0
- package/Application/Components/useToolkitActions.tsx +233 -0
- package/Application/ModalIconButton.tsx +66 -0
- package/Application/ModalScreen.tsx +39 -18
- package/Application/Navigation.ts +1 -1
- package/Application/NavigationContainer.tsx +7 -8
- package/Application/StackScreen.tracking.ts +158 -0
- package/Application/StackScreen.tsx +10 -137
- package/Application/WidgetContainer.tsx +10 -3
- package/Application/__tests__/modalLayout.test.ts +128 -0
- package/Application/hooks.ts +137 -0
- package/Application/index.ts +13 -1
- package/Application/modalLayout.ts +177 -0
- package/Application/navigationOptions.tsx +217 -0
- package/Application/types.header.ts +116 -0
- package/Application/types.tabs.ts +48 -0
- package/Application/types.theme.ts +87 -0
- package/Application/types.ts +12 -244
- package/Application/utils.ts +107 -0
- package/Badge/BadgeRibbon.tsx +3 -3
- package/Badge/styles.ts +2 -0
- package/Button/index.tsx +16 -136
- package/Button/styles.ts +1 -1
- package/Button/utils.ts +139 -0
- package/CheckBox/index.tsx +1 -6
- package/Divider/DashDivider.tsx +10 -11
- package/Divider/index.tsx +18 -8
- package/Image/index.tsx +1 -46
- package/Input/Input.tsx +7 -8
- package/Input/InputDropDown.tsx +3 -4
- package/Input/InputMoney.tsx +38 -164
- package/Input/InputMoneyView.tsx +187 -0
- package/Input/InputOTP.tsx +1 -1
- package/Input/InputPhoneNumber.tsx +5 -1
- package/Input/InputSearch.tsx +2 -108
- package/Input/InputTextArea.tsx +1 -5
- package/Input/SearchTextTyping.tsx +104 -0
- package/Input/common.tsx +4 -4
- package/Input/moneyUtils.ts +17 -0
- package/Input/styles.ts +26 -2
- package/Layout/FloatingButton.tsx +22 -21
- package/Layout/ReservedRegions.tsx +21 -4
- package/Layout/Screen.tsx +74 -670
- package/Layout/Section.tsx +1 -2
- package/Layout/index.ts +10 -4
- package/Layout/layoutMetrics.ts +58 -0
- package/Layout/layoutTypes.ts +86 -0
- package/Layout/screenContent.tsx +90 -0
- package/Layout/screenFooter.tsx +53 -0
- package/Layout/screenHeader.tsx +315 -0
- package/Layout/screenQuickReturn.tsx +67 -0
- package/Layout/screenScroll.ts +110 -0
- package/Layout/screenTypes.ts +134 -0
- package/Layout/styles.ts +2 -0
- package/Layout/utils.ts +10 -144
- package/Loader/DotLoader.tsx +7 -3
- package/Loader/ProgressBar.tsx +2 -6
- package/Loader/Spinner.tsx +7 -3
- package/Loader/styles.ts +4 -0
- package/Popup/PopupNotify.tsx +70 -64
- package/Popup/PopupPromotion.tsx +5 -4
- package/Popup/types.ts +7 -0
- package/Popup/utils.ts +46 -24
- package/Radio/index.tsx +2 -10
- package/Radio/styles.ts +6 -0
- package/Skeleton/index.tsx +1 -9
- package/Skeleton/styles.ts +1 -0
- package/Tag/index.tsx +3 -3
- package/Text/index.tsx +11 -2
- package/Title/index.tsx +2 -9
- package/Title/styles.ts +6 -0
- package/package.json +21 -22
- package/Application/device.ts +0 -29
- package/Application/utils.tsx +0 -497
package/Input/InputMoney.tsx
CHANGED
|
@@ -7,53 +7,14 @@ import React, {
|
|
|
7
7
|
useRef,
|
|
8
8
|
useState,
|
|
9
9
|
} from 'react';
|
|
10
|
-
import {
|
|
11
|
-
Platform,
|
|
12
|
-
Pressable,
|
|
13
|
-
Text,
|
|
14
|
-
TextInput,
|
|
15
|
-
TextInputFocusEvent,
|
|
16
|
-
TouchableOpacity,
|
|
17
|
-
View,
|
|
18
|
-
} from 'react-native';
|
|
10
|
+
import { Platform, TextInput, TextInputFocusEvent, View } from 'react-native';
|
|
19
11
|
import { useComponentId } from '../Application';
|
|
20
|
-
import {
|
|
21
|
-
|
|
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';
|
|
12
|
+
import { ComponentContext, MiniAppContext } from '../Context';
|
|
13
|
+
import { ErrorView } from './common';
|
|
34
14
|
import { InputMoneyProps } from './index';
|
|
15
|
+
import { InputMoneyView } from './InputMoneyView';
|
|
16
|
+
import { findEdit, moneyFormatter } from './moneyUtils';
|
|
35
17
|
import styles from './styles';
|
|
36
|
-
import SystemTextInput from './SystemTextInput';
|
|
37
|
-
|
|
38
|
-
const moneyFormatter = new Intl.NumberFormat('vi-VN');
|
|
39
|
-
|
|
40
|
-
// Finds the common prefix and suffix of `old` and `text`; `size` counts the
|
|
41
|
-
// characters removed plus inserted between them.
|
|
42
|
-
const findEdit = (old: string, text: string) => {
|
|
43
|
-
let start = 0;
|
|
44
|
-
while (start < text.length && old[start] === text[start]) {
|
|
45
|
-
start += 1;
|
|
46
|
-
}
|
|
47
|
-
let suffix = 0;
|
|
48
|
-
while (
|
|
49
|
-
suffix < Math.min(text.length, old.length) - start &&
|
|
50
|
-
old[old.length - 1 - suffix] === text[text.length - 1 - suffix]
|
|
51
|
-
) {
|
|
52
|
-
suffix += 1;
|
|
53
|
-
}
|
|
54
|
-
const size = old.length + text.length - 2 * (start + suffix);
|
|
55
|
-
return { old, start, suffix, size };
|
|
56
|
-
};
|
|
57
18
|
|
|
58
19
|
const InputMoney = forwardRef(
|
|
59
20
|
(
|
|
@@ -85,11 +46,7 @@ const InputMoney = forwardRef(
|
|
|
85
46
|
}: InputMoneyProps,
|
|
86
47
|
ref,
|
|
87
48
|
) => {
|
|
88
|
-
const { theme } = useContext(ApplicationContext);
|
|
89
49
|
const context = useContext<any>(MiniAppContext);
|
|
90
|
-
const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
|
|
91
|
-
const scaledFontSize = useScaleSize(20);
|
|
92
|
-
const inputFontFamily = exportFontFamily('bold');
|
|
93
50
|
const [focused, setFocused] = useState(false);
|
|
94
51
|
const [displayValue, setDisplayValue] = useState('');
|
|
95
52
|
const [numericValue, setNumericValue] = useState('');
|
|
@@ -129,11 +86,8 @@ const InputMoney = forwardRef(
|
|
|
129
86
|
setLastDisplayValue(displayValue);
|
|
130
87
|
}, [displayValue]);
|
|
131
88
|
|
|
132
|
-
// The selection only rides along with the render that reformats the text,
|
|
133
|
-
// then it is released so the user can move the caret freely.
|
|
134
89
|
useEffect(() => {
|
|
135
90
|
if (!caretSelection) return;
|
|
136
|
-
// A newer keystroke may already have queued its own selection; keep it.
|
|
137
91
|
setCaretSelection(current =>
|
|
138
92
|
current === caretSelection ? undefined : current,
|
|
139
93
|
);
|
|
@@ -143,9 +97,6 @@ const InputMoney = forwardRef(
|
|
|
143
97
|
const next = numeric ? moneyFormatter.format(Number(numeric)) : '';
|
|
144
98
|
setDisplayValue(next);
|
|
145
99
|
|
|
146
|
-
// Android moves the caret proportionally when the text is replaced, so
|
|
147
|
-
// it lands before the typed digit once a separator is added. Send the
|
|
148
|
-
// caret together with the text, keeping the same digits after it.
|
|
149
100
|
const digitsAfter = caretDigitsAfter.current;
|
|
150
101
|
caretDigitsAfter.current = undefined;
|
|
151
102
|
if (Platform.OS !== 'android' || digitsAfter === undefined) return;
|
|
@@ -187,9 +138,6 @@ const InputMoney = forwardRef(
|
|
|
187
138
|
return;
|
|
188
139
|
}
|
|
189
140
|
const digits = parseInputText(text);
|
|
190
|
-
// When typing outpaces JS (slow devices) native rejects the stale
|
|
191
|
-
// formatted text and keeps the raw one, so the edit may apply to either.
|
|
192
|
-
// Pick the one that differs from the new text by a single edit.
|
|
193
141
|
const raw = lastRawText.current;
|
|
194
142
|
lastRawText.current = text;
|
|
195
143
|
const formattedEdit = findEdit(lastDisplayValue, text);
|
|
@@ -199,7 +147,6 @@ const InputMoney = forwardRef(
|
|
|
199
147
|
caretDigitsAfter.current = parseInputText(
|
|
200
148
|
text.slice(text.length - suffix),
|
|
201
149
|
).length;
|
|
202
|
-
// Deleting a separator removes the digit before it.
|
|
203
150
|
if (text.length < old.length && digits === numericValue) {
|
|
204
151
|
const index = parseInputText(text.slice(0, start)).length - 1;
|
|
205
152
|
if (index >= 0) {
|
|
@@ -210,6 +157,11 @@ const InputMoney = forwardRef(
|
|
|
210
157
|
updateNumericValue(digits);
|
|
211
158
|
};
|
|
212
159
|
|
|
160
|
+
const focusAtEnd = () => {
|
|
161
|
+
inputRef.current?.focus();
|
|
162
|
+
inputRef.current?.setSelection(displayValue.length, displayValue.length);
|
|
163
|
+
};
|
|
164
|
+
|
|
213
165
|
const _onFocus = (e: TextInputFocusEvent) => {
|
|
214
166
|
setFocused(true);
|
|
215
167
|
onFocus?.(e);
|
|
@@ -241,111 +193,6 @@ const InputMoney = forwardRef(
|
|
|
241
193
|
};
|
|
242
194
|
});
|
|
243
195
|
|
|
244
|
-
const renderInputView = () => {
|
|
245
|
-
const disabledColor = theme.colors.text.disable;
|
|
246
|
-
let textColor = theme.colors.text.default;
|
|
247
|
-
let placeholderColor = theme.colors.text.hint;
|
|
248
|
-
let iconTintColor = trailingColor;
|
|
249
|
-
if (disabled) {
|
|
250
|
-
textColor = disabledColor;
|
|
251
|
-
placeholderColor = disabledColor;
|
|
252
|
-
iconTintColor = disabledColor;
|
|
253
|
-
}
|
|
254
|
-
const textStyle = {
|
|
255
|
-
fontSize: scaledFontSize,
|
|
256
|
-
fontFamily: inputFontFamily,
|
|
257
|
-
};
|
|
258
|
-
const placeholderHasCurrency = placeholder.endsWith(currency);
|
|
259
|
-
const inputPlaceholder = placeholderHasCurrency
|
|
260
|
-
? placeholder.slice(0, -currency.length)
|
|
261
|
-
: placeholder;
|
|
262
|
-
return (
|
|
263
|
-
<View
|
|
264
|
-
style={[
|
|
265
|
-
styles.inputWrapper,
|
|
266
|
-
{ backgroundColor: theme.colors.background.surface },
|
|
267
|
-
getSizeStyle(size, undefined, scaleHeight),
|
|
268
|
-
getBorderColor(theme, focused, errorMessage, disabled),
|
|
269
|
-
]}
|
|
270
|
-
>
|
|
271
|
-
<FloatingView
|
|
272
|
-
floatingValue={floatingValue}
|
|
273
|
-
floatingIconColor={floatingIconColor}
|
|
274
|
-
disabled={disabled}
|
|
275
|
-
required={required}
|
|
276
|
-
floatingIcon={floatingIcon}
|
|
277
|
-
onPress={onPressFloatingIcon}
|
|
278
|
-
componentId={componentId}
|
|
279
|
-
/>
|
|
280
|
-
<Pressable
|
|
281
|
-
style={[styles.inputView, styles.moneyInputView]}
|
|
282
|
-
onPress={() => inputRef.current?.focus()}
|
|
283
|
-
disabled={disabled}
|
|
284
|
-
>
|
|
285
|
-
<SystemTextInput
|
|
286
|
-
{...props}
|
|
287
|
-
accessibilityLabel={`${componentId}`}
|
|
288
|
-
textAlignVertical="center"
|
|
289
|
-
ref={inputRef}
|
|
290
|
-
accessibilityState={{
|
|
291
|
-
disabled: disabled,
|
|
292
|
-
...props.accessibilityState,
|
|
293
|
-
}}
|
|
294
|
-
// No width: the input sizes to its text natively, so the
|
|
295
|
-
// currency follows it without waiting for JS.
|
|
296
|
-
style={[textStyle, styles.moneyTextInput, { color: textColor }]}
|
|
297
|
-
allowFontScaling={false}
|
|
298
|
-
textBreakStrategy="highQuality"
|
|
299
|
-
value={displayValue}
|
|
300
|
-
selection={caretSelection ?? props.selection}
|
|
301
|
-
onChangeText={_onChangeText}
|
|
302
|
-
onFocus={_onFocus}
|
|
303
|
-
onBlur={_onBlur}
|
|
304
|
-
placeholder={inputPlaceholder}
|
|
305
|
-
selectionColor={theme.colors.primary}
|
|
306
|
-
placeholderTextColor={placeholderColor}
|
|
307
|
-
keyboardType={'numeric'}
|
|
308
|
-
maxLength={undefined}
|
|
309
|
-
/>
|
|
310
|
-
{displayValue || placeholderHasCurrency ? (
|
|
311
|
-
<Text
|
|
312
|
-
style={[
|
|
313
|
-
textStyle,
|
|
314
|
-
{ color: displayValue ? textColor : placeholderColor },
|
|
315
|
-
]}
|
|
316
|
-
allowFontScaling={false}
|
|
317
|
-
>
|
|
318
|
-
{currency}
|
|
319
|
-
</Text>
|
|
320
|
-
) : null}
|
|
321
|
-
</Pressable>
|
|
322
|
-
<View style={styles.iconView}>
|
|
323
|
-
{showClearIcon && focused && displayValue ? (
|
|
324
|
-
<TouchableOpacity
|
|
325
|
-
accessibilityLabel={`${componentId}|clear-icon-touch`}
|
|
326
|
-
style={styles.iconWrapper}
|
|
327
|
-
onPress={onClearText}
|
|
328
|
-
>
|
|
329
|
-
<Icon
|
|
330
|
-
source="24_navigation_close_circle_full"
|
|
331
|
-
size={16}
|
|
332
|
-
color={theme.colors.text.hint}
|
|
333
|
-
accessibilityLabel={`${componentId}|clear-icon`}
|
|
334
|
-
/>
|
|
335
|
-
</TouchableOpacity>
|
|
336
|
-
) : null}
|
|
337
|
-
<RenderTrailing
|
|
338
|
-
color={iconTintColor}
|
|
339
|
-
icon={trailing}
|
|
340
|
-
onPressIcon={onPressTrailing}
|
|
341
|
-
loading={loading}
|
|
342
|
-
componentId={componentId}
|
|
343
|
-
/>
|
|
344
|
-
</View>
|
|
345
|
-
</View>
|
|
346
|
-
);
|
|
347
|
-
};
|
|
348
|
-
|
|
349
196
|
let inputState = 'active';
|
|
350
197
|
if (displayValue) {
|
|
351
198
|
inputState = 'filled';
|
|
@@ -373,7 +220,34 @@ const InputMoney = forwardRef(
|
|
|
373
220
|
showBaseLineDebug && styles.debugBaseLine,
|
|
374
221
|
]}
|
|
375
222
|
>
|
|
376
|
-
|
|
223
|
+
<InputMoneyView
|
|
224
|
+
size={size}
|
|
225
|
+
errorMessage={errorMessage}
|
|
226
|
+
disabled={disabled}
|
|
227
|
+
trailingColor={trailingColor}
|
|
228
|
+
trailing={trailing}
|
|
229
|
+
onPressTrailing={onPressTrailing}
|
|
230
|
+
loading={loading}
|
|
231
|
+
floatingValue={floatingValue}
|
|
232
|
+
floatingIconColor={floatingIconColor}
|
|
233
|
+
required={required}
|
|
234
|
+
floatingIcon={floatingIcon}
|
|
235
|
+
onPressFloatingIcon={onPressFloatingIcon}
|
|
236
|
+
showClearIcon={showClearIcon}
|
|
237
|
+
placeholder={placeholder}
|
|
238
|
+
currency={currency}
|
|
239
|
+
focused={focused}
|
|
240
|
+
componentId={componentId}
|
|
241
|
+
displayValue={displayValue}
|
|
242
|
+
caretSelection={caretSelection}
|
|
243
|
+
inputRef={inputRef}
|
|
244
|
+
focusAtEnd={focusAtEnd}
|
|
245
|
+
onClearText={onClearText}
|
|
246
|
+
onChangeText={_onChangeText}
|
|
247
|
+
onFocus={_onFocus}
|
|
248
|
+
onBlur={_onBlur}
|
|
249
|
+
inputProps={props}
|
|
250
|
+
/>
|
|
377
251
|
<ErrorView
|
|
378
252
|
errorMessage={errorMessage}
|
|
379
253
|
errorSpacing={errorSpacing}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import React, { RefObject, useContext } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Pressable,
|
|
4
|
+
Text,
|
|
5
|
+
TextInput,
|
|
6
|
+
TextInputFocusEvent,
|
|
7
|
+
TextInputProps,
|
|
8
|
+
TouchableOpacity,
|
|
9
|
+
View,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { ApplicationContext } from '../Context';
|
|
12
|
+
import { Icon } from '../Icon';
|
|
13
|
+
import { useScaleSize, exportFontFamily } from '../Text';
|
|
14
|
+
import {
|
|
15
|
+
FloatingView,
|
|
16
|
+
getBorderColor,
|
|
17
|
+
getSizeStyle,
|
|
18
|
+
RenderTrailing,
|
|
19
|
+
} from './common';
|
|
20
|
+
import { InputMoneyProps } from './index';
|
|
21
|
+
import styles from './styles';
|
|
22
|
+
import SystemTextInput from './SystemTextInput';
|
|
23
|
+
|
|
24
|
+
type InputMoneyViewProps = Pick<
|
|
25
|
+
InputMoneyProps,
|
|
26
|
+
| 'size'
|
|
27
|
+
| 'errorMessage'
|
|
28
|
+
| 'disabled'
|
|
29
|
+
| 'trailingColor'
|
|
30
|
+
| 'trailing'
|
|
31
|
+
| 'onPressTrailing'
|
|
32
|
+
| 'loading'
|
|
33
|
+
| 'floatingValue'
|
|
34
|
+
| 'floatingIconColor'
|
|
35
|
+
| 'required'
|
|
36
|
+
| 'floatingIcon'
|
|
37
|
+
| 'onPressFloatingIcon'
|
|
38
|
+
| 'showClearIcon'
|
|
39
|
+
> & {
|
|
40
|
+
placeholder: string;
|
|
41
|
+
currency: string;
|
|
42
|
+
focused: boolean;
|
|
43
|
+
componentId: string;
|
|
44
|
+
displayValue: string;
|
|
45
|
+
caretSelection?: { start: number; end: number };
|
|
46
|
+
inputRef: RefObject<TextInput | null>;
|
|
47
|
+
focusAtEnd: () => void;
|
|
48
|
+
onClearText: () => void;
|
|
49
|
+
onChangeText: (text: string) => void;
|
|
50
|
+
onFocus: (e: TextInputFocusEvent) => void;
|
|
51
|
+
onBlur: (e: TextInputFocusEvent) => void;
|
|
52
|
+
inputProps: TextInputProps;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const InputMoneyView = ({
|
|
56
|
+
size,
|
|
57
|
+
errorMessage,
|
|
58
|
+
disabled,
|
|
59
|
+
trailingColor,
|
|
60
|
+
trailing,
|
|
61
|
+
onPressTrailing,
|
|
62
|
+
loading,
|
|
63
|
+
floatingValue,
|
|
64
|
+
floatingIconColor,
|
|
65
|
+
required,
|
|
66
|
+
floatingIcon,
|
|
67
|
+
onPressFloatingIcon,
|
|
68
|
+
showClearIcon,
|
|
69
|
+
placeholder,
|
|
70
|
+
currency,
|
|
71
|
+
focused,
|
|
72
|
+
componentId,
|
|
73
|
+
displayValue,
|
|
74
|
+
caretSelection,
|
|
75
|
+
inputRef,
|
|
76
|
+
focusAtEnd,
|
|
77
|
+
onClearText,
|
|
78
|
+
onChangeText,
|
|
79
|
+
onFocus,
|
|
80
|
+
onBlur,
|
|
81
|
+
inputProps: props,
|
|
82
|
+
}: InputMoneyViewProps) => {
|
|
83
|
+
const { theme } = useContext(ApplicationContext);
|
|
84
|
+
const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
|
|
85
|
+
const scaledFontSize = useScaleSize(20);
|
|
86
|
+
const inputFontFamily = exportFontFamily('bold');
|
|
87
|
+
const disabledColor = theme.colors.text.disable;
|
|
88
|
+
let textColor = theme.colors.text.default;
|
|
89
|
+
let placeholderColor = theme.colors.text.hint;
|
|
90
|
+
let iconTintColor = trailingColor;
|
|
91
|
+
if (disabled) {
|
|
92
|
+
textColor = disabledColor;
|
|
93
|
+
placeholderColor = disabledColor;
|
|
94
|
+
iconTintColor = disabledColor;
|
|
95
|
+
}
|
|
96
|
+
const textStyle = {
|
|
97
|
+
fontSize: scaledFontSize,
|
|
98
|
+
fontFamily: inputFontFamily,
|
|
99
|
+
};
|
|
100
|
+
const placeholderHasCurrency = placeholder.endsWith(currency);
|
|
101
|
+
const inputPlaceholder = placeholderHasCurrency
|
|
102
|
+
? placeholder.slice(0, -currency.length)
|
|
103
|
+
: placeholder;
|
|
104
|
+
return (
|
|
105
|
+
<View
|
|
106
|
+
style={[
|
|
107
|
+
styles.inputWrapper,
|
|
108
|
+
{ backgroundColor: theme.colors.background.surface },
|
|
109
|
+
getSizeStyle(size, undefined, scaleHeight),
|
|
110
|
+
getBorderColor(theme, focused, errorMessage, disabled),
|
|
111
|
+
]}
|
|
112
|
+
>
|
|
113
|
+
<FloatingView
|
|
114
|
+
floatingValue={floatingValue}
|
|
115
|
+
floatingIconColor={floatingIconColor}
|
|
116
|
+
disabled={disabled}
|
|
117
|
+
required={required}
|
|
118
|
+
floatingIcon={floatingIcon}
|
|
119
|
+
onPress={onPressFloatingIcon}
|
|
120
|
+
componentId={componentId}
|
|
121
|
+
/>
|
|
122
|
+
<Pressable
|
|
123
|
+
style={[styles.inputView, styles.moneyInputView]}
|
|
124
|
+
onPress={focusAtEnd}
|
|
125
|
+
disabled={disabled}
|
|
126
|
+
>
|
|
127
|
+
<SystemTextInput
|
|
128
|
+
{...props}
|
|
129
|
+
accessibilityLabel={`${componentId}`}
|
|
130
|
+
textAlignVertical="center"
|
|
131
|
+
ref={inputRef}
|
|
132
|
+
accessibilityState={{
|
|
133
|
+
disabled: disabled,
|
|
134
|
+
...props.accessibilityState,
|
|
135
|
+
}}
|
|
136
|
+
style={[textStyle, styles.moneyTextInput, { color: textColor }]}
|
|
137
|
+
allowFontScaling={false}
|
|
138
|
+
textBreakStrategy="highQuality"
|
|
139
|
+
value={displayValue}
|
|
140
|
+
selection={caretSelection ?? props.selection}
|
|
141
|
+
onChangeText={onChangeText}
|
|
142
|
+
onFocus={onFocus}
|
|
143
|
+
onBlur={onBlur}
|
|
144
|
+
placeholder={inputPlaceholder}
|
|
145
|
+
selectionColor={theme.colors.primary}
|
|
146
|
+
placeholderTextColor={placeholderColor}
|
|
147
|
+
keyboardType={'numeric'}
|
|
148
|
+
maxLength={undefined}
|
|
149
|
+
/>
|
|
150
|
+
{displayValue || placeholderHasCurrency ? (
|
|
151
|
+
<Text
|
|
152
|
+
style={[
|
|
153
|
+
textStyle,
|
|
154
|
+
{ color: displayValue ? textColor : placeholderColor },
|
|
155
|
+
]}
|
|
156
|
+
allowFontScaling={false}
|
|
157
|
+
>
|
|
158
|
+
{currency}
|
|
159
|
+
</Text>
|
|
160
|
+
) : null}
|
|
161
|
+
</Pressable>
|
|
162
|
+
<View style={styles.iconView}>
|
|
163
|
+
{showClearIcon && focused && displayValue ? (
|
|
164
|
+
<TouchableOpacity
|
|
165
|
+
accessibilityLabel={`${componentId}|clear-icon-touch`}
|
|
166
|
+
style={styles.iconWrapper}
|
|
167
|
+
onPress={onClearText}
|
|
168
|
+
>
|
|
169
|
+
<Icon
|
|
170
|
+
source="24_navigation_close_circle_full"
|
|
171
|
+
size={16}
|
|
172
|
+
color={theme.colors.text.hint}
|
|
173
|
+
accessibilityLabel={`${componentId}|clear-icon`}
|
|
174
|
+
/>
|
|
175
|
+
</TouchableOpacity>
|
|
176
|
+
) : null}
|
|
177
|
+
<RenderTrailing
|
|
178
|
+
color={iconTintColor}
|
|
179
|
+
icon={trailing}
|
|
180
|
+
onPressIcon={onPressTrailing}
|
|
181
|
+
loading={loading}
|
|
182
|
+
componentId={componentId}
|
|
183
|
+
/>
|
|
184
|
+
</View>
|
|
185
|
+
</View>
|
|
186
|
+
);
|
|
187
|
+
};
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -71,9 +71,9 @@ const OTPCaret: FC<CaretProps> = ({ index, length }) => {
|
|
|
71
71
|
<View style={[Styles.rowCenter, spacingStyle]}>
|
|
72
72
|
<Animated.View
|
|
73
73
|
style={[
|
|
74
|
+
styles.otpCursor,
|
|
74
75
|
{
|
|
75
76
|
height: useScaleSize(12),
|
|
76
|
-
width: 1,
|
|
77
77
|
backgroundColor: theme.colors.primary,
|
|
78
78
|
},
|
|
79
79
|
animatedStyle,
|
|
@@ -214,7 +214,11 @@ const InputPhoneNumber = forwardRef(
|
|
|
214
214
|
color: textColor,
|
|
215
215
|
},
|
|
216
216
|
inputTextStyles,
|
|
217
|
-
secure &&
|
|
217
|
+
secure &&
|
|
218
|
+
haveValue &&
|
|
219
|
+
(size === 'small'
|
|
220
|
+
? styles.secureTextSmall
|
|
221
|
+
: styles.secureTextLarge),
|
|
218
222
|
]}
|
|
219
223
|
defaultValue={defaultValue}
|
|
220
224
|
allowFontScaling={false}
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
1
|
import React, {
|
|
3
|
-
FC,
|
|
4
2
|
forwardRef,
|
|
5
3
|
ForwardRefRenderFunction,
|
|
6
4
|
useContext,
|
|
7
|
-
useEffect,
|
|
8
5
|
useImperativeHandle,
|
|
9
6
|
useRef,
|
|
10
7
|
useState,
|
|
@@ -24,109 +21,11 @@ import {
|
|
|
24
21
|
import { Icon } from '../Icon';
|
|
25
22
|
import { Text, useScaleSize, exportFontFamily } from '../Text';
|
|
26
23
|
import { InputRef, InputSearchProps } from './index';
|
|
24
|
+
import { TextTyping } from './SearchTextTyping';
|
|
27
25
|
import styles from './styles';
|
|
28
26
|
import { Styles } from '../Consts';
|
|
29
27
|
import SystemTextInput from './SystemTextInput';
|
|
30
28
|
|
|
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
|
-
};
|
|
129
|
-
|
|
130
29
|
const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
131
30
|
{
|
|
132
31
|
placeholder,
|
|
@@ -214,12 +113,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
|
|
|
214
113
|
if (typingData && typingData?.length > 0) {
|
|
215
114
|
return (
|
|
216
115
|
<TouchableOpacity
|
|
217
|
-
style={[
|
|
218
|
-
styles.searchInput,
|
|
219
|
-
{
|
|
220
|
-
justifyContent: 'center',
|
|
221
|
-
},
|
|
222
|
-
]}
|
|
116
|
+
style={[styles.searchInput, styles.searchInputTyping]}
|
|
223
117
|
onPress={onPress}
|
|
224
118
|
activeOpacity={onPress ? 0.6 : 1}
|
|
225
119
|
>
|
package/Input/InputTextArea.tsx
CHANGED
|
@@ -15,7 +15,6 @@ 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';
|
|
19
18
|
import { ErrorView, FloatingView, getBorderColor, MAX_LENGTH } from './common';
|
|
20
19
|
import { InputTextAreaProps } from './index';
|
|
21
20
|
import styles from './styles';
|
|
@@ -158,11 +157,8 @@ const InputTextArea = forwardRef(
|
|
|
158
157
|
textAlignVertical="top"
|
|
159
158
|
allowFontScaling={false}
|
|
160
159
|
style={[
|
|
160
|
+
styles.textAreaInput,
|
|
161
161
|
{
|
|
162
|
-
width: '100%',
|
|
163
|
-
flex: 1,
|
|
164
|
-
paddingRight: Spacing.XS,
|
|
165
|
-
paddingVertical: Spacing.XS,
|
|
166
162
|
fontSize: scaledFontSize,
|
|
167
163
|
fontFamily: inputFontFamily,
|
|
168
164
|
},
|