@jobber/components 4.17.1 → 4.17.2-install-re.6

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.
@@ -13,10 +13,10 @@ var reactPopper = require('react-popper');
13
13
  var Text = require('../Text-e7ed0974.js');
14
14
  var Icon = require('../Icon-405a216c.js');
15
15
  var Heading = require('../Heading-a1191b15.js');
16
- var InputText = require('../InputText-fce3bd3e.js');
16
+ var InputText = require('../InputText-a8a571c1.js');
17
17
  require('../Typography-fd6f932a.js');
18
18
  require('@jobber/design');
19
- require('../FormField-1a3bafd6.js');
19
+ require('../FormField-c2bc7144.js');
20
20
  require('uuid');
21
21
  require('react-hook-form');
22
22
  require('../Button-7698424c.js');
@@ -8,10 +8,10 @@ var React = require('react');
8
8
  var jobberHooks = require('@jobber/hooks/useResizeObserver');
9
9
  var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
10
10
  var tslib_es6 = require('../tslib.es6-5b8768b7.js');
11
- var Option = require('../Option-7ac3893b.js');
11
+ var Option = require('../Option-2ce89a73.js');
12
12
  var Button = require('../Button-7698424c.js');
13
13
  var Text = require('../Text-e7ed0974.js');
14
- require('../FormField-1a3bafd6.js');
14
+ require('../FormField-c2bc7144.js');
15
15
  require('uuid');
16
16
  require('react-hook-form');
17
17
  require('../Icon-405a216c.js');
@@ -12,7 +12,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
12
 
13
13
  const Form = React.forwardRef(function InternalForm({ onSubmit, children, onStateChange }, ref) {
14
14
  const methods = reactHookForm.useForm({ mode: "onTouched" });
15
- const { errors, trigger, handleSubmit, formState: { isDirty, isValid }, } = methods;
15
+ const { trigger, handleSubmit, formState: { isDirty, isValid, errors }, } = methods;
16
16
  React.useEffect(() => onStateChange && onStateChange({ isDirty, isValid }), [isDirty, isValid]);
17
17
  React.useImperativeHandle(ref, () => ({
18
18
  /**
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var FormField = require('../FormField-1a3bafd6.js');
5
+ var FormField = require('../FormField-c2bc7144.js');
6
6
  require('../tslib.es6-5b8768b7.js');
7
7
  require('react');
8
8
  require('uuid');
@@ -118,10 +118,12 @@ function FormFieldPostFix({ variation }) {
118
118
  return (React__default["default"].createElement("span", { className: styles.postfix }, variation === "select" ? (React__default["default"].createElement(Icon.Icon, { name: "arrowDown" })) : (React__default["default"].createElement(Spinner.Spinner, { size: "small" }))));
119
119
  }
120
120
 
121
+ // Added 13th statement to accommodate getErrorMessage function
122
+ /*eslint max-statements: ["error", 13]*/
121
123
  function FormField(props) {
122
- var _a;
124
+ var _a, _b;
123
125
  const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, inputRef, inline, keyboard, max, maxLength, min, name, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, } = props;
124
- const { control, errors, setValue, watch } = reactHookForm.useFormContext() != undefined
126
+ const { control, formState: { errors }, setValue, watch, } = reactHookForm.useFormContext() != undefined
125
127
  ? reactHookForm.useFormContext()
126
128
  : // If there isn't a Form Context being provided, get a form for this field.
127
129
  reactHookForm.useForm({ mode: "onTouched" });
@@ -143,10 +145,11 @@ function FormField(props) {
143
145
  setValue(controlledName, newValue, { shouldValidate: true });
144
146
  },
145
147
  }));
146
- const error = errors[controlledName] && errors[controlledName].message;
148
+ const message = (_a = errors[controlledName]) === null || _a === void 0 ? void 0 : _a.message;
149
+ const error = getErrorMessage();
147
150
  React.useEffect(() => handleValidation(), [error]);
148
- return (React__default["default"].createElement(reactHookForm.Controller, { control: control, name: controlledName, rules: Object.assign({}, validations), defaultValue: (_a = value !== null && value !== void 0 ? value : defaultValue) !== null && _a !== void 0 ? _a : "", render: (_a) => {
149
- var { onChange: onControllerChange, onBlur: onControllerBlur, name: controllerName } = _a, rest = tslib_es6.__rest(_a, ["onChange", "onBlur", "name"]);
151
+ return (React__default["default"].createElement(reactHookForm.Controller, { control: control, name: controlledName, rules: Object.assign({}, validations), defaultValue: (_b = value !== null && value !== void 0 ? value : defaultValue) !== null && _b !== void 0 ? _b : "", render: (_a) => {
152
+ var _b = _a.field, { onChange: onControllerChange, onBlur: onControllerBlur, name: controllerName } = _b, rest = tslib_es6.__rest(_b, ["onChange", "onBlur", "name"]);
150
153
  const fieldProps = Object.assign(Object.assign(Object.assign({}, rest), { id: identifier, className: styles.input, name: (validations || name) && controllerName, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange }), (description &&
151
154
  !inline && { "aria-describedby": descriptionIdentifier }));
152
155
  const textFieldProps = Object.assign(Object.assign({}, fieldProps), { onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown });
@@ -195,6 +198,12 @@ function FormField(props) {
195
198
  onControllerBlur();
196
199
  }
197
200
  } }));
201
+ function getErrorMessage() {
202
+ if (typeof message === "string") {
203
+ return message;
204
+ }
205
+ return "";
206
+ }
198
207
  function handleValidation() {
199
208
  onValidation && onValidation(error);
200
209
  }
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var lodash = require('lodash');
6
6
  var React = require('react');
7
- var FormField = require('../FormField-1a3bafd6.js');
7
+ var FormField = require('../FormField-c2bc7144.js');
8
8
  var DatePicker = require('../DatePicker-98f03314.js');
9
9
  require('../tslib.es6-5b8768b7.js');
10
10
  require('uuid');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var FormField = require('../FormField-1a3bafd6.js');
6
+ var FormField = require('../FormField-c2bc7144.js');
7
7
  require('../tslib.es6-5b8768b7.js');
8
8
  require('uuid');
9
9
  require('react-hook-form');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var FormField = require('../FormField-1a3bafd6.js');
6
+ var FormField = require('../FormField-c2bc7144.js');
7
7
  require('../tslib.es6-5b8768b7.js');
8
8
  require('uuid');
9
9
  require('react-hook-form');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var FormField = require('../FormField-1a3bafd6.js');
6
+ var FormField = require('../FormField-c2bc7144.js');
7
7
  require('../tslib.es6-5b8768b7.js');
8
8
  require('uuid');
9
9
  require('react-hook-form');
@@ -4,10 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib_es6 = require('../tslib.es6-5b8768b7.js');
6
6
  var React = require('react');
7
+ var reactHookForm = require('react-hook-form');
7
8
  var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
8
- var FormField = require('../FormField-1a3bafd6.js');
9
+ var FormField = require('../FormField-c2bc7144.js');
9
10
  require('uuid');
10
- require('react-hook-form');
11
11
  require('classnames');
12
12
  require('../Button-7698424c.js');
13
13
  require('react-router-dom');
@@ -84,6 +84,7 @@ function InputPhoneNumber(_a) {
84
84
  var { required } = _a, props = tslib_es6.__rest(_a, ["required"]);
85
85
  const { placeholder, validations, pattern = "(***) ***-****" } = props;
86
86
  const errorSubject = placeholder || "Phone number";
87
+ const getValues = reactHookForm.useFormContext();
87
88
  return (React__default["default"].createElement(InputMask, { pattern: pattern, strict: false },
88
89
  React__default["default"].createElement(FormField.FormField, Object.assign({}, props, { type: "tel", validations: Object.assign(Object.assign({ required: {
89
90
  value: Boolean(required),
@@ -103,7 +104,7 @@ function InputPhoneNumber(_a) {
103
104
  return `${errorSubject} must contain ${cleanValueRequiredLength} or more digits`;
104
105
  }
105
106
  if (typeof (validations === null || validations === void 0 ? void 0 : validations.validate) === "function") {
106
- return validations.validate(value);
107
+ return validations.validate(value, getValues);
107
108
  }
108
109
  return true;
109
110
  }
@@ -44,18 +44,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
44
44
  } | undefined;
45
45
  onEnter?: ((event: React.KeyboardEvent<Element>) => void) | undefined;
46
46
  readonly readonly?: boolean | undefined;
47
- readonly validations?: Partial<{
48
- required: string | import("react-hook-form").ValidationRule<boolean>;
49
- min: import("react-hook-form").ValidationRule<string | number>;
50
- max: import("react-hook-form").ValidationRule<string | number>;
51
- maxLength: import("react-hook-form").ValidationRule<string | number>;
52
- minLength: import("react-hook-form").ValidationRule<string | number>;
53
- pattern: import("react-hook-form").ValidationRule<RegExp>;
54
- validate: import("react-hook-form").Validate | Record<string, import("react-hook-form").Validate>;
55
- valueAsNumber: boolean;
56
- valueAsDate: boolean;
57
- setValueAs: (value: any) => any;
58
- }> | undefined;
47
+ readonly validations?: import("react-hook-form").RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
59
48
  } | {
60
49
  rows?: undefined;
61
50
  multiline?: boolean | undefined;
@@ -92,17 +81,6 @@ export declare const InputText: React.ForwardRefExoticComponent<({
92
81
  } | undefined;
93
82
  onEnter?: ((event: React.KeyboardEvent<Element>) => void) | undefined;
94
83
  readonly readonly?: boolean | undefined;
95
- readonly validations?: Partial<{
96
- required: string | import("react-hook-form").ValidationRule<boolean>;
97
- min: import("react-hook-form").ValidationRule<string | number>;
98
- max: import("react-hook-form").ValidationRule<string | number>;
99
- maxLength: import("react-hook-form").ValidationRule<string | number>;
100
- minLength: import("react-hook-form").ValidationRule<string | number>;
101
- pattern: import("react-hook-form").ValidationRule<RegExp>;
102
- validate: import("react-hook-form").Validate | Record<string, import("react-hook-form").Validate>;
103
- valueAsNumber: boolean;
104
- valueAsDate: boolean;
105
- setValueAs: (value: any) => any;
106
- }> | undefined;
84
+ readonly validations?: import("react-hook-form").RegisterOptions<import("react-hook-form").FieldValues, string> | undefined;
107
85
  }) & React.RefAttributes<InputTextRef>>;
108
86
  export {};
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var InputText = require('../InputText-fce3bd3e.js');
5
+ var InputText = require('../InputText-a8a571c1.js');
6
6
  require('react');
7
- require('../FormField-1a3bafd6.js');
7
+ require('../FormField-c2bc7144.js');
8
8
  require('../tslib.es6-5b8768b7.js');
9
9
  require('uuid');
10
10
  require('react-hook-form');
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var FormField = require('./FormField-1a3bafd6.js');
4
+ var FormField = require('./FormField-c2bc7144.js');
5
5
 
6
6
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
7
 
@@ -6,7 +6,7 @@ var tslib_es6 = require('../tslib.es6-5b8768b7.js');
6
6
  var React = require('react');
7
7
  var debounce = require('lodash/debounce');
8
8
  var temporal = require('@std-proposal/temporal');
9
- var FormField = require('../FormField-1a3bafd6.js');
9
+ var FormField = require('../FormField-c2bc7144.js');
10
10
  require('uuid');
11
11
  require('react-hook-form');
12
12
  require('../style-inject.es-9d2f5f4e.js');
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var FormField = require('./FormField-1a3bafd6.js');
4
+ var FormField = require('./FormField-c2bc7144.js');
5
5
 
6
6
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
7
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var Option = require('../Option-7ac3893b.js');
5
+ var Option = require('../Option-2ce89a73.js');
6
6
  require('react');
7
- require('../FormField-1a3bafd6.js');
7
+ require('../FormField-c2bc7144.js');
8
8
  require('../tslib.es6-5b8768b7.js');
9
9
  require('uuid');
10
10
  require('react-hook-form');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.17.1",
3
+ "version": "4.17.2-install-re.6+30145e27",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "@jobber/design": "^0.39.0",
23
- "@jobber/formatters": "*",
23
+ "@jobber/formatters": "^0.2.2",
24
24
  "@jobber/hooks": "^2.1.2",
25
25
  "@popperjs/core": "^2.0.6",
26
26
  "@std-proposal/temporal": "0.0.1",
@@ -41,7 +41,7 @@
41
41
  "react-countdown": "^2.3.2",
42
42
  "react-datepicker": "^4.10.0",
43
43
  "react-dropzone": "^11.0.2",
44
- "react-hook-form": "^6.15.8",
44
+ "react-hook-form": "^7.43.7",
45
45
  "react-markdown": "^8.0.3",
46
46
  "react-popper": "^2.2.5",
47
47
  "react-router-dom": "^5.3.4",
@@ -83,5 +83,5 @@
83
83
  "> 1%",
84
84
  "IE 10"
85
85
  ],
86
- "gitHead": "7889d5b8906357bc48208ece6c383100dac49a6a"
86
+ "gitHead": "30145e27a9cd7b19979dff8533bc8b799c43204c"
87
87
  }