@jobber/components-native 0.48.4-st-spike-w.11 → 0.48.4

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.48.4-st-spike-w.11+8da4c7c3",
3
+ "version": "0.48.4",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -37,12 +37,13 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@jobber/design": "^0.47.0",
40
- "@jobber/hooks": "^2.7.0",
40
+ "@jobber/hooks": "^2.7.1",
41
41
  "@react-native-clipboard/clipboard": "^1.11.2",
42
42
  "@react-native-picker/picker": "^2.4.10",
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",
46
47
  "react-intl": "^6.4.2",
47
48
  "react-native-keyboard-aware-scroll-view": "^0.9.5",
48
49
  "react-native-modalize": "^2.0.13",
@@ -73,7 +74,6 @@
73
74
  "date-fns": "^2.0.0",
74
75
  "date-fns-tz": "*",
75
76
  "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": "8da4c7c38a6ec9bfa99b0a2ec9fd297ebad3abe9"
87
+ "gitHead": "b514c578d69d01182bb0b88080d1b39ea4f94235"
88
88
  }
@@ -105,9 +105,7 @@ 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(),
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 },
108
+ React.createElement(FormBody, { keyboardHeight: calculateSaveButtonOffset(), submit: handleSubmit(internalSubmit), isFormSubmitting: isSubmitting, saveButtonLabel: saveButtonLabel, shouldRenderActionBar: saveButtonPosition === "sticky", renderStickySection: renderStickySection, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, setSaveButtonHeight: setSaveButtonHeight, saveButtonOffset: saveButtonOffset },
111
109
  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 }),
112
110
  React.createElement(View, { onLayout: ({ nativeEvent }) => {
113
111
  setFormContentHeight(nativeEvent.layout.height);
@@ -118,13 +116,7 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
118
116
  React.createElement(View, { style: styles.formChildContainer },
119
117
  React.createElement(React.Fragment, null,
120
118
  React.createElement(View, { style: styles.formContent }, children),
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) })))),
119
+ saveButtonPosition === "inline" && (React.createElement(View, { style: styles.fixedSaveButton }, renderStickySection ? (renderStickySection(handleSubmit(internalSubmit), saveButtonLabel, isSubmitting)) : (React.createElement(FormSaveButton, { primaryAction: handleSubmit(internalSubmit), label: saveButtonLabel, loading: isSubmitting, secondaryActions: secondaryActions, setSecondaryActionLoading: setIsSecondaryActionLoading, onOpenBottomSheet: () => setIsBottomSheetOpen(true), onCloseBottomSheet: () => setIsBottomSheetOpen(false) })))),
128
120
  renderFooter))),
129
121
  React.createElement(View, { style: styles.safeArea, ref: bottomViewRef })))),
130
122
  React.createElement(FormMessage, null)));
@@ -183,7 +175,6 @@ function InternalForm({ children, onBeforeSubmit, onSubmit, onSubmitError, onSub
183
175
  }
184
176
  function handleRetry() {
185
177
  clearFormErrors();
186
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
187
178
  return handleSubmit(internalSubmit)();
188
179
  }
189
180
  function calculateSaveButtonOffset() {
@@ -7,7 +7,6 @@ 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
11
10
  defaultValues: initialValues,
12
11
  shouldFocusError: false,
13
12
  });
@@ -73,21 +73,21 @@ export function InputCurrency(props) {
73
73
  }
74
74
  };
75
75
  const { t } = useAtlantisI18n();
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
- } })));
76
+ return (React.createElement(React.Fragment, null,
77
+ 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: {
78
+ output: val => {
79
+ return val === null || val === void 0 ? void 0 : val.split(floatSeparators.group).join("").replace(floatSeparators.decimal, ".");
80
+ },
81
+ }, validations: Object.assign({ pattern: {
82
+ value: NUMBER_VALIDATION_REGEX,
83
+ message: t("errors.notANumber"),
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,6 +5,5 @@ 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
9
8
  } }, props.validations) })));
10
9
  }
@@ -30,7 +30,6 @@ 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
34
33
  } }, props.validations) })));
35
34
  }
36
35
  function hasPeriodAtEnd(value) {
@@ -1,9 +1,8 @@
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
5
4
  export function useFormController({ name, value, validations, }) {
6
- var _a;
5
+ var _a, _b;
7
6
  const fieldName = useControlName(name);
8
7
  const form = useForm({
9
8
  mode: "onTouched",
@@ -25,13 +24,12 @@ export function useFormController({ name, value, validations, }) {
25
24
  let error;
26
25
  if (fieldIdentifiers.length === 3) {
27
26
  const [section, item, identifier] = fieldIdentifiers;
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];
27
+ error = (_b = (_a = errors[section]) === null || _a === void 0 ? void 0 : _a[item]) === null || _b === void 0 ? void 0 : _b[identifier];
30
28
  }
31
29
  else {
32
30
  error = errors[fieldName];
33
31
  }
34
- return { error: error, field };
32
+ return { error, field };
35
33
  }
36
34
  function useControlName(name) {
37
35
  const [identifier] = useState(v1());