@jobber/components-native 0.54.0 → 0.54.1
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/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.54.
|
|
3
|
+
"version": "0.54.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"react-native-reanimated": "^2.17.0",
|
|
85
85
|
"react-native-safe-area-context": "^4.5.2"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "31514b7c10bf164c4fbda7c5ec8fdb9122f1dc88"
|
|
88
88
|
}
|
|
@@ -22,7 +22,7 @@ function InputTextInternal({ invalid, disabled, name, placeholder, assistiveText
|
|
|
22
22
|
const internalValue = controlledValue !== null && controlledValue !== void 0 ? controlledValue : (_a = field.value) === null || _a === void 0 ? void 0 : _a.toString();
|
|
23
23
|
const hasValue = internalValue !== "" && internalValue !== undefined;
|
|
24
24
|
const [focused, setFocused] = useState(false);
|
|
25
|
-
const { hasMiniLabel
|
|
25
|
+
const { hasMiniLabel } = useMiniLabel(internalValue);
|
|
26
26
|
const textInputRef = useTextInputRef({ ref, onClear: handleClear });
|
|
27
27
|
const showClear = useShowClear({
|
|
28
28
|
clearable,
|
|
@@ -91,7 +91,7 @@ function InputTextInternal({ invalid, disabled, name, placeholder, assistiveText
|
|
|
91
91
|
setFocused(false);
|
|
92
92
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur();
|
|
93
93
|
field.onBlur();
|
|
94
|
-
trimWhitespace(field,
|
|
94
|
+
trimWhitespace(inputTransform(field.value), updateFormAndState);
|
|
95
95
|
}, ref: (instance) => {
|
|
96
96
|
// RHF wants us to do it this way
|
|
97
97
|
// https://react-hook-form.com/faqs#Howtosharerefusage
|
|
@@ -105,10 +105,7 @@ function InputTextInternal({ invalid, disabled, name, placeholder, assistiveText
|
|
|
105
105
|
* https://github.com/facebook/react-native/issues/36521#issuecomment-1555421134
|
|
106
106
|
*/
|
|
107
107
|
const removedIOSCharValue = isIOS ? value.replace(/\uFFFC/g, "") : value;
|
|
108
|
-
|
|
109
|
-
setHasMiniLabel(Boolean(newValue));
|
|
110
|
-
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(newValue);
|
|
111
|
-
field.onChange(newValue);
|
|
108
|
+
updateFormAndState(removedIOSCharValue);
|
|
112
109
|
}
|
|
113
110
|
function handleClear() {
|
|
114
111
|
handleChangeText("");
|
|
@@ -119,18 +116,26 @@ function InputTextInternal({ invalid, disabled, name, placeholder, assistiveText
|
|
|
119
116
|
handleOnFocusNext();
|
|
120
117
|
}
|
|
121
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Updates both the form value and the onChangeText callback
|
|
121
|
+
* Ensuring that the tranform output function is called
|
|
122
|
+
* @param rawValue value to be sent to form state and onChangeText callback
|
|
123
|
+
*/
|
|
124
|
+
function updateFormAndState(rawValue) {
|
|
125
|
+
const newValue = outputTransform(rawValue);
|
|
126
|
+
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(newValue);
|
|
127
|
+
field.onChange(newValue);
|
|
128
|
+
}
|
|
122
129
|
}
|
|
123
|
-
function trimWhitespace(
|
|
124
|
-
if (!
|
|
130
|
+
function trimWhitespace(inputValue, onChangeText) {
|
|
131
|
+
if (!inputValue || !inputValue.trim) {
|
|
125
132
|
return;
|
|
126
133
|
}
|
|
127
|
-
const trimmedInput =
|
|
128
|
-
if (trimmedInput ===
|
|
129
|
-
// avoid re-renders
|
|
130
|
-
return;
|
|
134
|
+
const trimmedInput = inputValue.trim();
|
|
135
|
+
if (trimmedInput === inputValue) {
|
|
136
|
+
return; // no changes, avoid re-renders
|
|
131
137
|
}
|
|
132
|
-
onChangeText
|
|
133
|
-
field.onChange(trimmedInput);
|
|
138
|
+
onChangeText(trimmedInput);
|
|
134
139
|
}
|
|
135
140
|
function useTextInputRef({ ref, onClear }) {
|
|
136
141
|
const textInputRef = useRef(null);
|
|
@@ -146,5 +151,5 @@ function useMiniLabel(internalValue) {
|
|
|
146
151
|
useEffect(() => {
|
|
147
152
|
setHasMiniLabel(Boolean(internalValue));
|
|
148
153
|
}, [internalValue]);
|
|
149
|
-
return { hasMiniLabel
|
|
154
|
+
return { hasMiniLabel };
|
|
150
155
|
}
|