@jobber/components 4.9.2-give-mini-.13 → 4.9.2-give-mini-.14

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-70adf24f.js');
16
+ var InputText = require('../InputText-5e6a8085.js');
17
17
  require('../Typography-fd6f932a.js');
18
18
  require('@jobber/design');
19
- require('../FormField-833a390b.js');
19
+ require('../FormField-c7047a5f.js');
20
20
  require('uuid');
21
21
  require('react-hook-form');
22
22
  require('../Button-7698424c.js');
@@ -191,7 +191,6 @@ function Autocomplete({ initialOptions = [], value, allowFreeForm = true, size =
191
191
  if (allowFreeForm) {
192
192
  onChange({ label: newText });
193
193
  }
194
- setMenuVisible(true);
195
194
  }
196
195
  function handleInputBlur() {
197
196
  setMenuVisible(false);
@@ -2,9 +2,12 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var Checkbox = require('../Checkbox-36f63689.js');
5
+ var Checkbox = require('../Checkbox-3bccf65c.js');
6
+ require('../tslib.es6-5b8768b7.js');
6
7
  require('react');
8
+ require('uuid');
7
9
  require('classnames');
10
+ require('react-hook-form');
8
11
  require('../style-inject.es-9d2f5f4e.js');
9
12
  require('../Icon-405a216c.js');
10
13
  require('@jobber/design');
@@ -1,7 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var tslib_es6 = require('./tslib.es6-5b8768b7.js');
3
4
  var React = require('react');
5
+ var uuid = require('uuid');
4
6
  var classnames = require('classnames');
7
+ var reactHookForm = require('react-hook-form');
5
8
  var styleInject_es = require('./style-inject.es-9d2f5f4e.js');
6
9
  var Icon = require('./Icon-405a216c.js');
7
10
  var Text = require('./Text-e7ed0974.js');
@@ -16,25 +19,46 @@ var styles = {"checkbox":"d-2MyyzKGN0-","wrapper":"OFHQaLxY8zI-","disabled":"HRr
16
19
  styleInject_es.styleInject(css_248z);
17
20
 
18
21
  function Checkbox({ checked, defaultChecked, disabled, label, name, value, indeterminate = false, description, children, onChange, onFocus, }) {
22
+ const { control, setValue, watch } = reactHookForm.useFormContext() != undefined
23
+ ? reactHookForm.useFormContext()
24
+ : // If there isn't a Form Context being provided, get a form for this field.
25
+ reactHookForm.useForm({ mode: "onTouched" });
26
+ const [identifier] = React.useState(uuid.v1());
27
+ /**
28
+ * Generate a name if one is not supplied, this is the name
29
+ * that will be used for react-hook-form and not neccessarily
30
+ * attached to the DOM
31
+ */
32
+ const [controlledName] = React.useState(name ? name : `generatedName--${identifier}`);
33
+ React.useEffect(() => {
34
+ if (value != undefined) {
35
+ setValue(controlledName, value);
36
+ }
37
+ }, [value, watch(controlledName)]);
19
38
  const wrapperClassName = classnames__default["default"](styles.wrapper, disabled && styles.disabled);
20
39
  const inputClassName = classnames__default["default"](styles.input, {
21
40
  [styles.indeterminate]: indeterminate,
22
41
  });
23
42
  const iconName = indeterminate ? "minus2" : "checkmark";
24
43
  const labelText = label ? React__default["default"].createElement(Text.Text, null, label) : children;
25
- return (React__default["default"].createElement("div", { className: styles.checkbox },
26
- React__default["default"].createElement("label", { className: wrapperClassName },
27
- React__default["default"].createElement("span", { className: styles.checkHolder },
28
- React__default["default"].createElement("input", { type: "checkbox", checked: checked, defaultChecked: defaultChecked, className: inputClassName, "aria-label": label, onChange: handleChange, value: value, name: name, disabled: disabled, onFocus: onFocus }),
29
- React__default["default"].createElement("span", { className: styles.checkBox },
30
- React__default["default"].createElement(Icon.Icon, { name: iconName, size: "small", color: "white" }))),
31
- labelText && React__default["default"].createElement("span", { className: styles.label }, labelText)),
32
- description && (React__default["default"].createElement("div", { className: styles.description },
33
- React__default["default"].createElement(Text.Text, { variation: "subdued", size: "small" }, description)))));
34
- function handleChange(event) {
35
- const newChecked = event.currentTarget.checked;
36
- onChange && onChange(newChecked);
37
- }
44
+ return (React__default["default"].createElement(reactHookForm.Controller, { control: control, name: controlledName, defaultValue: defaultChecked, render: (_a) => {
45
+ var _b = _a.field, { onChange: onControllerChange, name: controllerName } = _b, rest = tslib_es6.__rest(_b, ["onChange", "name"]);
46
+ const fieldProps = Object.assign(Object.assign({}, rest), { id: identifier, className: inputClassName, name: name && controllerName, onChange: handleChange, disabled: disabled });
47
+ return (React__default["default"].createElement("div", { className: styles.checkbox },
48
+ React__default["default"].createElement("label", { className: wrapperClassName },
49
+ React__default["default"].createElement("span", { className: styles.checkHolder },
50
+ React__default["default"].createElement("input", Object.assign({}, fieldProps, { type: "checkbox", checked: checked, defaultChecked: defaultChecked, "aria-label": label, onChange: handleChange, onFocus: onFocus })),
51
+ React__default["default"].createElement("span", { className: styles.checkBox },
52
+ React__default["default"].createElement(Icon.Icon, { name: iconName, size: "small", color: "white" }))),
53
+ labelText && React__default["default"].createElement("span", { className: styles.label }, labelText)),
54
+ description && (React__default["default"].createElement("div", { className: styles.description },
55
+ React__default["default"].createElement(Text.Text, { variation: "subdued", size: "small" }, description)))));
56
+ function handleChange(event) {
57
+ const newChecked = event.currentTarget.checked;
58
+ onChange && onChange(newChecked);
59
+ onControllerChange(event);
60
+ }
61
+ } }));
38
62
  }
39
63
 
40
64
  exports.Checkbox = Checkbox;
@@ -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-cf1ec08c.js');
11
+ var Option = require('../Option-de240090.js');
12
12
  var Button = require('../Button-7698424c.js');
13
13
  var Text = require('../Text-e7ed0974.js');
14
- require('../FormField-833a390b.js');
14
+ require('../FormField-c7047a5f.js');
15
15
  require('uuid');
16
16
  require('react-hook-form');
17
17
  require('../Icon-405a216c.js');
@@ -18,7 +18,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
18
18
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
19
19
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
20
20
 
21
- var css_248z$1 = ":root {\n --drawer-width: calc(var(--space-base) * 17.5);\n --drawer--base-padding: var(--space-base);\n}\n\n.IJAyrFb2GpA- {\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1001;\n z-index: var(--elevation-modal);\n overflow: hidden;\n\n /* SPECIAL CASE:\n Drawer is primarily used in Jobber Online and is currently used in a layout\n that rearranges at 640px. For compatibility, this is hardcoded here\n rather than using the breakpoint custom properties.\n DO NOT COPY THIS - USE THE BREAKPOINTS DEFINED IN THE @jobber/design package!\n */\n}\n\n@media (min-width: 640px), print {\n\n.IJAyrFb2GpA- {\n position: relative;\n z-index: auto;\n width: calc((16px * 1) * 17.5);\n width: calc(calc(16px * 1) * 17.5);\n width: var(--drawer-width);\n}\n }\n\n@media (min-width:1440px) {\n\n.IJAyrFb2GpA- {\n --drawer-width: calc(var(--space-base) * 26.25);\n}\n }\n\n@media (--large-screens-and-up) {\n\n.IJAyrFb2GpA- {\n --drawer-width: calc(var(--space-base) * 26.25);\n}\n }\n\n.Hsmk6Pg14PQ- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-border);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n -ms-flex-direction: column;\n flex-direction: column;\n}\n\n.DwF3Q9EMPvQ- {\n display: -ms-flexbox;\n display: flex;\n}\n\n.TcdyXiTbnMU- {\n display: -ms-flexbox;\n display: flex;\n padding: calc(16px / 2) calc(16px * 1);\n padding: var(--space-small) var(--drawer--base-padding);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.srL7xqEzwhM- {\n display: -ms-flexbox;\n display: flex;\n width: 100%;\n height: 100%;\n -ms-flex-direction: row;\n flex-direction: row;\n overflow-y: auto;\n}\n\n.p6-yqttoIJI- {\n width: 100%;\n}\n\n/* Adjust `Content` components public padding to match the cards */\n\n.p6-yqttoIJI- > * {\n --public-content--padding: var(--drawer--base-padding);\n}\n\n/* Remove the nested `Content` components public padding */\n\n.p6-yqttoIJI- > * > * {\n --public-content--padding: 0;\n}\n";
21
+ var css_248z$1 = ":root {\n --drawer-width: calc(var(--space-base) * 17.5);\n --drawer--base-padding: var(--space-base);\n}\n\n.IJAyrFb2GpA- {\n display: none;\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1001;\n z-index: var(--elevation-modal);\n overflow: hidden;\n\n /* SPECIAL CASE:\n Drawer is primarily used in Jobber Online and is currently used in a layout\n that rearranges at 640px. For compatibility, this is hardcoded here\n rather than using the breakpoint custom properties.\n DO NOT COPY THIS - USE THE BREAKPOINTS DEFINED IN THE @jobber/design package!\n */\n}\n\n@media (min-width: 640px), print {\n\n.IJAyrFb2GpA- {\n position: relative;\n z-index: auto;\n width: calc((16px * 1) * 17.5);\n width: calc(calc(16px * 1) * 17.5);\n width: var(--drawer-width);\n}\n }\n\n@media (min-width:1080) {\n\n.IJAyrFb2GpA- {\n --drawer-width: calc(var(--space-base) * 26.25);\n}\n }\n\n@media (--large-screens-and-up) {\n\n.IJAyrFb2GpA- {\n --drawer-width: calc(var(--space-base) * 26.25);\n}\n }\n\n.Hsmk6Pg14PQ- {\n display: -ms-flexbox;\n display: flex;\n position: relative;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n border: calc(16px / 16) solid rgb(225, 225, 225);\n border: var(--border-base) solid var(--color-border);\n background-color: rgba(255, 255, 255, 1);\n background-color: var(--color-surface);\n -ms-flex-direction: column;\n flex-direction: column;\n}\n\n.DwF3Q9EMPvQ- {\n display: -ms-flexbox;\n display: flex;\n}\n\n.TcdyXiTbnMU- {\n display: -ms-flexbox;\n display: flex;\n padding: calc(16px / 2) calc(16px * 1);\n padding: var(--space-small) var(--drawer--base-padding);\n background-color: rgb(244, 244, 244);\n background-color: var(--color-surface--background);\n -ms-flex-pack: justify;\n justify-content: space-between;\n -ms-flex-align: center;\n align-items: center;\n}\n\n.srL7xqEzwhM- {\n display: -ms-flexbox;\n display: flex;\n width: 100%;\n height: 100%;\n -ms-flex-direction: row;\n flex-direction: row;\n overflow-y: auto;\n}\n\n.p6-yqttoIJI- {\n width: 100%;\n}\n\n/* Adjust `Content` components public padding to match the cards */\n\n.p6-yqttoIJI- > * {\n --public-content--padding: var(--drawer--base-padding);\n}\n\n/* Remove the nested `Content` components public padding */\n\n.p6-yqttoIJI- > * > * {\n --public-content--padding: 0;\n}\n";
22
22
  var styles$1 = {"container":"IJAyrFb2GpA-","drawer":"Hsmk6Pg14PQ-","open":"DwF3Q9EMPvQ-","header":"TcdyXiTbnMU-","contentScroll":"srL7xqEzwhM-","content":"p6-yqttoIJI-"};
23
23
  styleInject_es.styleInject(css_248z$1);
24
24
 
@@ -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-833a390b.js');
5
+ var FormField = require('../FormField-c7047a5f.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
  }
@@ -12,7 +12,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
12
12
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
13
13
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
14
14
 
15
- var css_248z$2 = ".YJHtDDKq6WI- {\n grid-column: initial;\n grid-column-end: span var(--gridCell--size-xs);\n}@media (min-width:490px) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-sm);\n}\n }@media (--small-screens-and-up) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-sm);\n}\n }@media (min-width:768px) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-md);\n}\n }@media (--medium-screens-and-up) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-md);\n}\n }@media (min-width:1440px) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-lg);\n}\n }@media (--large-screens-and-up) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-lg);\n}\n }@media (min-width:1680px) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-xl);\n}\n }@media (--extra-large-screens-and-up) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-xl);\n}\n }\n";
15
+ var css_248z$2 = ".YJHtDDKq6WI- {\n grid-column: initial;\n grid-column-end: span var(--gridCell--size-xs);\n}@media (min-width:490px) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-sm);\n}\n }@media (--small-screens-and-up) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-sm);\n}\n }@media (min-width:768px) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-md);\n}\n }@media (--medium-screens-and-up) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-md);\n}\n }@media (min-width:1080) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-lg);\n}\n }@media (--large-screens-and-up) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-lg);\n}\n }@media (min-width:1440) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-xl);\n}\n }@media (--extra-large-screens-and-up) {.YJHtDDKq6WI- {\n grid-column-end: span var(--gridCell--size-xl);\n}\n }\n";
16
16
  var styles$1 = {"gridCell":"YJHtDDKq6WI-"};
17
17
  styleInject_es.styleInject(css_248z$2);
18
18
 
@@ -45,7 +45,7 @@ function getSizeCSSVariables(size) {
45
45
  };
46
46
  }
47
47
 
48
- var css_248z$1 = ".NqFGJV-UF3Q- {\n display: grid;\n grid-template-columns: repeat(12, minmax(0, 1fr));\n}\n\n.IZLiiSquUTM- {\n gap: calc(16px / 2);\n gap: var(--space-small);\n}\n\n@media (min-width:768px) {\n .IZLiiSquUTM- {\n gap: calc(16px * 1);\n gap: var(--space-base);\n }\n}\n\n@media (--medium-screens-and-up) {\n .IZLiiSquUTM- {\n gap: calc(16px * 1);\n gap: var(--space-base);\n }\n}\n";
48
+ var css_248z$1 = ".NqFGJV-UF3Q- {\n display: grid;\n grid-template-columns: repeat(12, minmax(0, 1fr));\n}\n\n.IZLiiSquUTM- {\n gap: calc(16px * 1);\n gap: var(--space-base);\n}\n\n@media (min-width:768px) {\n .IZLiiSquUTM- {\n gap: calc(16px * 1.5);\n gap: var(--space-large);\n }\n}\n\n@media (--medium-screens-and-up) {\n .IZLiiSquUTM- {\n gap: calc(16px * 1.5);\n gap: var(--space-large);\n }\n}\n";
49
49
  var styles = {"grid":"NqFGJV-UF3Q-","gap":"IZLiiSquUTM-"};
50
50
  styleInject_es.styleInject(css_248z$1);
51
51
 
@@ -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-833a390b.js');
7
+ var FormField = require('../FormField-c7047a5f.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-833a390b.js');
6
+ var FormField = require('../FormField-c7047a5f.js');
7
7
  require('../tslib.es6-5b8768b7.js');
8
8
  require('uuid');
9
9
  require('react-hook-form');
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  import { CommonFormFieldProps, FormFieldProps } from "../FormField";
3
- interface InputNumberProps extends CommonFormFieldProps, Pick<FormFieldProps, "maxLength" | "autocomplete" | "max" | "min" | "onEnter" | "onFocus" | "onBlur" | "inputRef" | "validations" | "readonly" | "defaultValue" | "keyboard"> {
3
+ interface InputNumberProps extends CommonFormFieldProps, Pick<FormFieldProps, "maxLength" | "autocomplete" | "max" | "min" | "onEnter" | "onFocus" | "onBlur" | "inputRef" | "validations" | "readonly" | "defaultValue" | "keyboard" | "prefix" | "suffix"> {
4
4
  value?: number;
5
5
  }
6
6
  export interface InputNumberRef {
@@ -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-833a390b.js');
6
+ var FormField = require('../FormField-c7047a5f.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-833a390b.js');
6
+ var FormField = require('../FormField-c7047a5f.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-833a390b.js');
9
+ var FormField = require('../FormField-c7047a5f.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?: 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-70adf24f.js');
5
+ var InputText = require('../InputText-5e6a8085.js');
6
6
  require('react');
7
- require('../FormField-833a390b.js');
7
+ require('../FormField-c7047a5f.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-833a390b.js');
4
+ var FormField = require('./FormField-c7047a5f.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-833a390b.js');
9
+ var FormField = require('../FormField-c7047a5f.js');
10
10
  require('uuid');
11
11
  require('react-hook-form');
12
12
  require('../style-inject.es-9d2f5f4e.js');
@@ -6,9 +6,12 @@ var React = require('react');
6
6
  var classnames = require('classnames');
7
7
  var useOnKeyDown = require('@jobber/hooks/useOnKeyDown');
8
8
  var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
9
- var Checkbox = require('../Checkbox-36f63689.js');
9
+ var Checkbox = require('../Checkbox-3bccf65c.js');
10
10
  var Text = require('../Text-e7ed0974.js');
11
11
  var Icon = require('../Icon-405a216c.js');
12
+ require('../tslib.es6-5b8768b7.js');
13
+ require('uuid');
14
+ require('react-hook-form');
12
15
  require('../Typography-fd6f932a.js');
13
16
  require('@jobber/design');
14
17
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var FormField = require('./FormField-833a390b.js');
4
+ var FormField = require('./FormField-c7047a5f.js');
5
5
 
6
6
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
7
7
 
@@ -27,7 +27,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
27
27
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28
28
  var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
29
29
 
30
- var css_248z = ".pVEdXlwstrc- {\n width: 100%;\n box-sizing: border-box;\n padding: calc(16px * 1.5);\n padding: var(--space-large);\n}\n\n._9r84iz--C5M- {\n max-width: none;\n}\n\n._0LO26JFXU9g- {\n max-width: calc(16px * 80);\n max-width: calc(var(--base-unit) * 80);\n}\n\n.KiMIF8eFbuE- {\n max-width: calc(16px * 64);\n max-width: calc(var(--base-unit) * 64);\n}\n\n.GCeQrLFyml4- h1 {\n -ms-flex: 0 1 auto;\n flex: 0 1 auto;\n margin-bottom: calc(16px * 1);\n margin-bottom: var(--space-base);\n}\n\n.GCeQrLFyml4- > .KP-BTjB82iQ- {\n -ms-flex: 1 0 auto;\n flex: 1 0 auto;\n}\n\n.GCeQrLFyml4-.GuFU-PgC1j4-,\n.GCeQrLFyml4-.qiwlkB5pxkA- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n -ms-flex-pack: justify;\n justify-content: space-between;\n}\n\n.GCeQrLFyml4-.CbPnpIk7-EE- .KP-BTjB82iQ- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n -ms-flex-pack: justify;\n justify-content: space-between;\n}\n\n.GCeQrLFyml4-.qiwlkB5pxkA- .KP-BTjB82iQ-,\n.GCeQrLFyml4-.GuFU-PgC1j4- .KP-BTjB82iQ- {\n -ms-flex-wrap: nowrap;\n flex-wrap: nowrap;\n}\n\n.GCeQrLFyml4-.qiwlkB5pxkA- .KP-BTjB82iQ- {\n -ms-flex-pack: end;\n justify-content: flex-end;\n}\n\n.E5FEsck9zwg- {\n -ms-flex: 0 0 100%;\n flex: 0 0 100%;\n margin-bottom: calc(16px / 2);\n margin-bottom: var(--space-small);\n}\n\n.Sn3-wJuNCqk- {\n margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n -ms-flex: 1;\n flex: 1;\n}\n\n.Sn3-wJuNCqk- > div {\n width: 100%;\n}\n\n.GCeQrLFyml4-.CbPnpIk7-EE- .Sn3-wJuNCqk- {\n margin-top: 0;\n}\n\n.GCeQrLFyml4-.qiwlkB5pxkA- .E5FEsck9zwg-,\n.GCeQrLFyml4-.qiwlkB5pxkA- .Sn3-wJuNCqk- {\n margin: 0;\n -ms-flex: 0 auto;\n flex: 0 auto;\n}\n\n.GCeQrLFyml4-.qiwlkB5pxkA- .Sn3-wJuNCqk- {\n margin-left: calc(16px / 2);\n margin-left: var(--space-small);\n}\n\n.GCeQrLFyml4-.CbPnpIk7-EE- .Sn3-wJuNCqk- + .Sn3-wJuNCqk- {\n margin-left: calc(16px / 2);\n margin-left: var(--space-small);\n}\n\n.GCeQrLFyml4- ._9ZKFDK2jL80- {\n margin-bottom: calc(16px * 1);\n margin-bottom: var(--space-base);\n}\n";
30
+ var css_248z = ".pVEdXlwstrc- {\n width: 100%;\n box-sizing: border-box;\n padding: calc(16px * 1);\n padding: var(--space-base);\n}\n\n@media (min-width:768px) {\n\n.pVEdXlwstrc- {\n padding: calc(16px * 1.5);\n padding: var(--space-large);\n}\n }\n\n@media (--medium-screens-and-up) {\n\n.pVEdXlwstrc- {\n padding: calc(16px * 1.5);\n padding: var(--space-large);\n}\n }\n\n._9r84iz--C5M- {\n max-width: none;\n}\n\n._0LO26JFXU9g- {\n max-width: calc(16px * 80);\n max-width: calc(var(--base-unit) * 80);\n}\n\n.KiMIF8eFbuE- {\n max-width: calc(16px * 64);\n max-width: calc(var(--base-unit) * 64);\n}\n\n.GCeQrLFyml4- h1 {\n -ms-flex: 0 1 auto;\n flex: 0 1 auto;\n margin-bottom: calc(16px * 1);\n margin-bottom: var(--space-base);\n}\n\n.GCeQrLFyml4- > .KP-BTjB82iQ- {\n -ms-flex: 1 0 auto;\n flex: 1 0 auto;\n}\n\n.GCeQrLFyml4-.GuFU-PgC1j4-,\n.GCeQrLFyml4-.qiwlkB5pxkA- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n -ms-flex-pack: justify;\n justify-content: space-between;\n}\n\n.GCeQrLFyml4-.CbPnpIk7-EE- .KP-BTjB82iQ- {\n display: -ms-flexbox;\n display: flex;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n -ms-flex-pack: justify;\n justify-content: space-between;\n}\n\n.GCeQrLFyml4-.qiwlkB5pxkA- .KP-BTjB82iQ-,\n.GCeQrLFyml4-.GuFU-PgC1j4- .KP-BTjB82iQ- {\n -ms-flex-wrap: nowrap;\n flex-wrap: nowrap;\n}\n\n.GCeQrLFyml4-.qiwlkB5pxkA- .KP-BTjB82iQ- {\n -ms-flex-pack: end;\n justify-content: flex-end;\n}\n\n.E5FEsck9zwg- {\n -ms-flex: 0 0 100%;\n flex: 0 0 100%;\n margin-bottom: calc(16px / 2);\n margin-bottom: var(--space-small);\n}\n\n.Sn3-wJuNCqk- {\n margin-top: calc(16px / 2);\n margin-top: var(--space-small);\n -ms-flex: 1;\n flex: 1;\n}\n\n.Sn3-wJuNCqk- > div {\n width: 100%;\n}\n\n.GCeQrLFyml4-.CbPnpIk7-EE- .Sn3-wJuNCqk- {\n margin-top: 0;\n}\n\n.GCeQrLFyml4-.qiwlkB5pxkA- .E5FEsck9zwg-,\n.GCeQrLFyml4-.qiwlkB5pxkA- .Sn3-wJuNCqk- {\n margin: 0;\n -ms-flex: 0 auto;\n flex: 0 auto;\n}\n\n.GCeQrLFyml4-.qiwlkB5pxkA- .Sn3-wJuNCqk- {\n margin-left: calc(16px / 2);\n margin-left: var(--space-small);\n}\n\n.GCeQrLFyml4-.CbPnpIk7-EE- .Sn3-wJuNCqk- + .Sn3-wJuNCqk- {\n margin-left: calc(16px / 2);\n margin-left: var(--space-small);\n}\n\n.GCeQrLFyml4- ._9ZKFDK2jL80- {\n margin-bottom: calc(16px * 1);\n margin-bottom: var(--space-base);\n}\n";
31
31
  var styles = {"page":"pVEdXlwstrc-","fill":"_9r84iz--C5M-","standard":"_0LO26JFXU9g-","narrow":"KiMIF8eFbuE-","titleBar":"GCeQrLFyml4-","actionGroup":"KP-BTjB82iQ-","large":"GuFU-PgC1j4-","medium":"qiwlkB5pxkA-","small":"CbPnpIk7-EE-","primaryAction":"E5FEsck9zwg-","actionButton":"Sn3-wJuNCqk-","subtitle":"_9ZKFDK2jL80-"};
32
32
  styleInject_es.styleInject(css_248z);
33
33
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var Option = require('../Option-cf1ec08c.js');
5
+ var Option = require('../Option-de240090.js');
6
6
  require('react');
7
- require('../FormField-833a390b.js');
7
+ require('../FormField-c7047a5f.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.9.2-give-mini-.13+688669bd",
3
+ "version": "4.9.2-give-mini-.14+86bee619",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,9 +19,9 @@
19
19
  "dist/*"
20
20
  ],
21
21
  "dependencies": {
22
- "@jobber/design": "^0.40.0",
22
+ "@jobber/design": "^0.36.1-give-mini-.14+86bee619",
23
23
  "@jobber/formatters": "^0.2.2",
24
- "@jobber/hooks": "^2.1.2",
24
+ "@jobber/hooks": "^2.1.1-give-mini-.23+86bee619",
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": "^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": "688669bd3297ff588badf6212c7ba27f9ebde38f"
86
+ "gitHead": "86bee6198078dbd1e2d3e7f2c1f75c4db2c176fc"
87
87
  }