@jobber/components-native 0.48.3 → 0.48.4-st-spike-w.11
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 +3 -3
- package/dist/src/Form/Form.js +11 -2
- package/dist/src/Form/hooks/useInternalForm.js +1 -0
- package/dist/src/InputCurrency/InputCurrency.js +17 -17
- package/dist/src/InputEmail/InputEmail.js +1 -0
- package/dist/src/InputNumber/InputNumber.js +1 -0
- package/dist/src/hooks/useFormController.js +5 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/InputCurrency/InputCurrency.d.ts +3 -3
- package/package.json +3 -3
- package/src/Form/Form.tsx +12 -4
- package/src/Form/hooks/useInternalForm.ts +2 -1
- package/src/InputCurrency/InputCurrency.tsx +41 -38
- package/src/InputEmail/InputEmail.tsx +2 -1
- package/src/InputNumber/InputNumber.tsx +10 -1
- package/src/hooks/useFormController.ts +7 -3
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.4-st-spike-w.11+8da4c7c3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"autolinker": "^4.0.0",
|
|
44
44
|
"deepmerge": "^4.2.2",
|
|
45
45
|
"lodash": "^4.17.21",
|
|
46
|
-
"react-hook-form": "^7.30.0",
|
|
47
46
|
"react-intl": "^6.4.2",
|
|
48
47
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
49
48
|
"react-native-modalize": "^2.0.13",
|
|
@@ -74,6 +73,7 @@
|
|
|
74
73
|
"date-fns": "^2.0.0",
|
|
75
74
|
"date-fns-tz": "*",
|
|
76
75
|
"react": "^18",
|
|
76
|
+
"react-hook-form": "^7.43.7",
|
|
77
77
|
"react-intl": "^6.4.2",
|
|
78
78
|
"react-native": ">=0.69.2",
|
|
79
79
|
"react-native-gesture-handler": ">=2.10.0",
|
|
@@ -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": "8da4c7c38a6ec9bfa99b0a2ec9fd297ebad3abe9"
|
|
88
88
|
}
|
package/dist/src/Form/Form.js
CHANGED
|
@@ -105,7 +105,9 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
105
105
|
React.createElement(React.Fragment, null,
|
|
106
106
|
(isSubmitting || isSecondaryActionLoading) && React.createElement(FormMask, null),
|
|
107
107
|
React.createElement(FormCache, { localCacheKey: localCacheKey, localCacheExclude: localCacheExclude, setLocalCache: setLocalCache }),
|
|
108
|
-
React.createElement(FormBody, { keyboardHeight: calculateSaveButtonOffset(),
|
|
108
|
+
React.createElement(FormBody, { keyboardHeight: calculateSaveButtonOffset(),
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
+
submit: handleSubmit(internalSubmit), isFormSubmitting: isSubmitting, saveButtonLabel: saveButtonLabel, shouldRenderActionBar: saveButtonPosition === "sticky", renderStickySection: renderStickySection, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, setSaveButtonHeight: setSaveButtonHeight, saveButtonOffset: saveButtonOffset },
|
|
109
111
|
React.createElement(KeyboardAwareScrollView, Object.assign({ enableResetScrollToCoords: false, enableAutomaticScroll: true, keyboardOpeningTime: Platform.OS === "ios" ? tokens["timing-slowest"] : 0, keyboardShouldPersistTaps: "handled", ref: scrollViewRef }, keyboardProps, { extraHeight: headerHeight, contentContainerStyle: !keyboardHeight && styles.scrollContentContainer }),
|
|
110
112
|
React.createElement(View, { onLayout: ({ nativeEvent }) => {
|
|
111
113
|
setFormContentHeight(nativeEvent.layout.height);
|
|
@@ -116,7 +118,13 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
116
118
|
React.createElement(View, { style: styles.formChildContainer },
|
|
117
119
|
React.createElement(React.Fragment, null,
|
|
118
120
|
React.createElement(View, { style: styles.formContent }, children),
|
|
119
|
-
saveButtonPosition === "inline" && (React.createElement(View, { style: styles.fixedSaveButton }, renderStickySection ? (renderStickySection(
|
|
121
|
+
saveButtonPosition === "inline" && (React.createElement(View, { style: styles.fixedSaveButton }, renderStickySection ? (renderStickySection(
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
123
|
+
handleSubmit(internalSubmit), saveButtonLabel, isSubmitting)) : (React.createElement(FormSaveButton
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
|
+
, {
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
127
|
+
primaryAction: handleSubmit(internalSubmit), label: saveButtonLabel, loading: isSubmitting, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, onOpenBottomSheet: () => setIsBottomSheetOpen(true), onCloseBottomSheet: () => setIsBottomSheetOpen(false) })))),
|
|
120
128
|
renderFooter))),
|
|
121
129
|
React.createElement(View, { style: styles.safeArea, ref: bottomViewRef })))),
|
|
122
130
|
React.createElement(FormMessage, null)));
|
|
@@ -175,6 +183,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
|
|
|
175
183
|
}
|
|
176
184
|
function handleRetry() {
|
|
177
185
|
clearFormErrors();
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
178
187
|
return handleSubmit(internalSubmit)();
|
|
179
188
|
}
|
|
180
189
|
function calculateSaveButtonOffset() {
|
|
@@ -7,6 +7,7 @@ export function useInternalForm({ mode, reValidateMode, initialValues, formRef,
|
|
|
7
7
|
const formMethods = useForm({
|
|
8
8
|
mode,
|
|
9
9
|
reValidateMode,
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
11
|
defaultValues: initialValues,
|
|
11
12
|
shouldFocusError: false,
|
|
12
13
|
});
|
|
@@ -73,21 +73,21 @@ export function InputCurrency(props) {
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
const { t } = useAtlantisI18n();
|
|
76
|
-
return (React.createElement(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
return (React.createElement(InputText, Object.assign({}, props, { prefix: showCurrencySymbol ? { label: currencySymbol } : undefined, keyboard: getKeyboard(props), value: ((_a = props.value) === null || _a === void 0 ? void 0 : _a.toString()) || displayValue, defaultValue: (_b = props.defaultValue) === null || _b === void 0 ? void 0 : _b.toString(), onChangeText: handleChange, transform: {
|
|
77
|
+
output: val => {
|
|
78
|
+
return val === null || val === void 0 ? void 0 : val.split(floatSeparators.group).join("").replace(floatSeparators.decimal, ".");
|
|
79
|
+
},
|
|
80
|
+
}, validations: Object.assign({ pattern: {
|
|
81
|
+
value: NUMBER_VALIDATION_REGEX,
|
|
82
|
+
message: t("errors.notANumber"),
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
+
} }, props.validations), onBlur: () => {
|
|
85
|
+
var _a;
|
|
86
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
87
|
+
if (field.value === 0 ||
|
|
88
|
+
field.value === "" ||
|
|
89
|
+
field.value === undefined) {
|
|
90
|
+
setDisplayValue("0");
|
|
91
|
+
}
|
|
92
|
+
} })));
|
|
93
93
|
}
|
|
@@ -5,5 +5,6 @@ function InputEmailInternal(props, ref) {
|
|
|
5
5
|
return (React.createElement(InputText, Object.assign({}, props, { ref: ref, autoCapitalize: "none", autoCorrect: false, keyboard: "email-address", validations: Object.assign({ pattern: {
|
|
6
6
|
value: /[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/,
|
|
7
7
|
message: "Enter a valid email address (email@example.com)",
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
9
|
} }, props.validations) })));
|
|
9
10
|
}
|
|
@@ -30,6 +30,7 @@ function InputNumberInternal(props, ref) {
|
|
|
30
30
|
}, ref: ref, value: (_c = props.value) === null || _c === void 0 ? void 0 : _c.toString(), defaultValue: (_d = props.defaultValue) === null || _d === void 0 ? void 0 : _d.toString(), onChangeText: handleChange, validations: Object.assign({ pattern: {
|
|
31
31
|
value: NUMBER_VALIDATION_REGEX,
|
|
32
32
|
message: t("errors.notANumber"),
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
34
|
} }, props.validations) })));
|
|
34
35
|
}
|
|
35
36
|
function hasPeriodAtEnd(value) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { v1 } from "react-native-uuid";
|
|
2
2
|
import { useController, useForm, useFormContext, } from "react-hook-form";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
+
// eslint-disable-next-line max-statements
|
|
4
5
|
export function useFormController({ name, value, validations, }) {
|
|
5
|
-
var _a
|
|
6
|
+
var _a;
|
|
6
7
|
const fieldName = useControlName(name);
|
|
7
8
|
const form = useForm({
|
|
8
9
|
mode: "onTouched",
|
|
@@ -24,12 +25,13 @@ export function useFormController({ name, value, validations, }) {
|
|
|
24
25
|
let error;
|
|
25
26
|
if (fieldIdentifiers.length === 3) {
|
|
26
27
|
const [section, item, identifier] = fieldIdentifiers;
|
|
27
|
-
|
|
28
|
+
const err = (_a = errors[section]) === null || _a === void 0 ? void 0 : _a[item];
|
|
29
|
+
error = err === null || err === void 0 ? void 0 : err[identifier];
|
|
28
30
|
}
|
|
29
31
|
else {
|
|
30
32
|
error = errors[fieldName];
|
|
31
33
|
}
|
|
32
|
-
return { error, field };
|
|
34
|
+
return { error: error, field };
|
|
33
35
|
}
|
|
34
36
|
function useControlName(name) {
|
|
35
37
|
const [identifier] = useState(v1());
|