@artsy/palette-mobile 13.2.18 → 13.2.20
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.
|
@@ -22,7 +22,7 @@ export interface InputProps extends Omit<TextInputProps, "placeholder" | "onChan
|
|
|
22
22
|
onHintPress?: () => void;
|
|
23
23
|
onSelectTap?: () => void;
|
|
24
24
|
optional?: boolean;
|
|
25
|
-
onChangeText?: (text: string, unmaskedText
|
|
25
|
+
onChangeText?: (text: string, unmaskedText?: string) => void;
|
|
26
26
|
/**
|
|
27
27
|
* The placeholder can be an array of string, specifically for android, because of a bug.
|
|
28
28
|
* On ios, the longest string will always be picked, as ios can add ellipsis.
|
|
@@ -64,7 +64,7 @@ exports.Input = (0, react_1.forwardRef)(({ addClearListener = false, defaultValu
|
|
|
64
64
|
const [focused, setIsFocused] = (0, react_1.useState)(false);
|
|
65
65
|
const [delayedFocused, setDelayedFocused] = (0, react_1.useState)(false);
|
|
66
66
|
const [value, setValue] = (0, react_1.useState)((0, maskValue_1.maskValue)({
|
|
67
|
-
currentValue: propValue ?? defaultValue
|
|
67
|
+
currentValue: propValue ?? defaultValue,
|
|
68
68
|
mask: mask,
|
|
69
69
|
}));
|
|
70
70
|
const [showPassword, setShowPassword] = (0, react_1.useState)(!secureTextEntry);
|
|
@@ -121,9 +121,15 @@ exports.Input = (0, react_1.forwardRef)(({ addClearListener = false, defaultValu
|
|
|
121
121
|
};
|
|
122
122
|
}, [focused, delayedFocused]);
|
|
123
123
|
const handleChangeText = (0, react_1.useCallback)((text) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
if (mask) {
|
|
125
|
+
const newText = (0, maskValue_1.maskValue)({ currentValue: text, mask: mask, previousValue: value }) || "";
|
|
126
|
+
setValue(newText);
|
|
127
|
+
onChangeText?.(newText, (0, maskValue_1.unmaskText)(text));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
setValue(text);
|
|
131
|
+
onChangeText?.(text);
|
|
132
|
+
}
|
|
127
133
|
}, [onChangeText, value, mask]);
|
|
128
134
|
const handleClear = (0, react_1.useCallback)(() => {
|
|
129
135
|
react_native_1.LayoutAnimation.configureNext({ ...react_native_1.LayoutAnimation.Presets.easeInEaseOut, duration: 200 });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const maskValue: ({ currentValue, mask, previousValue, }: {
|
|
2
|
-
currentValue: string;
|
|
2
|
+
currentValue: string | undefined;
|
|
3
3
|
mask: string | string[] | undefined;
|
|
4
4
|
previousValue?: string | undefined;
|
|
5
|
-
}) => string;
|
|
5
|
+
}) => string | undefined;
|
|
6
6
|
export declare const unmaskText: (mask: string) => string;
|