@jobber/components 4.18.2 → 4.18.3
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/Autocomplete/index.js +2 -2
- package/dist/DataTable/index.js +2 -2
- package/dist/Form/index.js +1 -1
- package/dist/FormField/index.js +1 -1
- package/dist/{FormField-1a3bafd6.js → FormField-c2bc7144.js} +14 -5
- package/dist/InputDate/index.js +1 -1
- package/dist/InputEmail/index.js +1 -1
- package/dist/InputNumber/index.js +1 -1
- package/dist/InputPassword/index.js +1 -1
- package/dist/InputPhoneNumber/index.js +7 -3
- package/dist/InputText/InputText.d.ts +2 -24
- package/dist/InputText/index.js +2 -2
- package/dist/{InputText-fce3bd3e.js → InputText-a8a571c1.js} +1 -1
- package/dist/InputTime/index.js +1 -1
- package/dist/{Option-7ac3893b.js → Option-2ce89a73.js} +1 -1
- package/dist/Select/index.js +2 -2
- package/package.json +4 -4
|
@@ -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-
|
|
16
|
+
var InputText = require('../InputText-a8a571c1.js');
|
|
17
17
|
require('../Typography-fd6f932a.js');
|
|
18
18
|
require('@jobber/design');
|
|
19
|
-
require('../FormField-
|
|
19
|
+
require('../FormField-c2bc7144.js');
|
|
20
20
|
require('uuid');
|
|
21
21
|
require('react-hook-form');
|
|
22
22
|
require('../Button-7698424c.js');
|
package/dist/DataTable/index.js
CHANGED
|
@@ -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-
|
|
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-
|
|
14
|
+
require('../FormField-c2bc7144.js');
|
|
15
15
|
require('uuid');
|
|
16
16
|
require('react-hook-form');
|
|
17
17
|
require('../Icon-405a216c.js');
|
package/dist/Form/index.js
CHANGED
|
@@ -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 {
|
|
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
|
/**
|
package/dist/FormField/index.js
CHANGED
|
@@ -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
|
|
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: (
|
|
149
|
-
var { onChange: onControllerChange, onBlur: onControllerBlur, name: controllerName } =
|
|
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
|
}
|
package/dist/InputDate/index.js
CHANGED
|
@@ -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-
|
|
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');
|
package/dist/InputEmail/index.js
CHANGED
|
@@ -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-
|
|
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-
|
|
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-
|
|
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-
|
|
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,10 @@ 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() != undefined
|
|
88
|
+
? reactHookForm.useFormContext()
|
|
89
|
+
: // If there isn't a Form Context being provided, get a form for this field.
|
|
90
|
+
reactHookForm.useForm({ mode: "onTouched" });
|
|
87
91
|
return (React__default["default"].createElement(InputMask, { pattern: pattern, strict: false },
|
|
88
92
|
React__default["default"].createElement(FormField.FormField, Object.assign({}, props, { type: "tel", validations: Object.assign(Object.assign({ required: {
|
|
89
93
|
value: Boolean(required),
|
|
@@ -103,7 +107,7 @@ function InputPhoneNumber(_a) {
|
|
|
103
107
|
return `${errorSubject} must contain ${cleanValueRequiredLength} or more digits`;
|
|
104
108
|
}
|
|
105
109
|
if (typeof (validations === null || validations === void 0 ? void 0 : validations.validate) === "function") {
|
|
106
|
-
return validations.validate(value);
|
|
110
|
+
return validations.validate(value, getValues);
|
|
107
111
|
}
|
|
108
112
|
return true;
|
|
109
113
|
}
|
|
@@ -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?:
|
|
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?:
|
|
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 {};
|
package/dist/InputText/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var InputText = require('../InputText-
|
|
5
|
+
var InputText = require('../InputText-a8a571c1.js');
|
|
6
6
|
require('react');
|
|
7
|
-
require('../FormField-
|
|
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-
|
|
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
|
|
package/dist/InputTime/index.js
CHANGED
|
@@ -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-
|
|
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-
|
|
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
|
|
package/dist/Select/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var Option = require('../Option-
|
|
5
|
+
var Option = require('../Option-2ce89a73.js');
|
|
6
6
|
require('react');
|
|
7
|
-
require('../FormField-
|
|
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.18.
|
|
3
|
+
"version": "4.18.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@jobber/design": "^0.41.0",
|
|
23
23
|
"@jobber/formatters": "*",
|
|
24
|
-
"@jobber/hooks": "^2.1.
|
|
24
|
+
"@jobber/hooks": "^2.1.3",
|
|
25
25
|
"@popperjs/core": "^2.0.6",
|
|
26
26
|
"@std-proposal/temporal": "0.0.1",
|
|
27
27
|
"@tanstack/react-table": "8.5.13",
|
|
@@ -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": "^
|
|
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": "
|
|
86
|
+
"gitHead": "cffc83c1ccd41849fa2e2ce859aed98a9c587972"
|
|
87
87
|
}
|