@jobber/components 6.103.2-JOB-140609-8386817.45 → 6.103.2-JOB-141426-ee803fd.19

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.
Files changed (87) hide show
  1. package/dist/Autocomplete/Autocomplete.types.d.ts +1 -12
  2. package/dist/Autocomplete/components/MenuList.d.ts +2 -1
  3. package/dist/Autocomplete/components/PersistentRegion.d.ts +2 -1
  4. package/dist/Autocomplete/hooks/useAutocompleteListNav.d.ts +2 -1
  5. package/dist/Autocomplete/index.cjs +85 -35
  6. package/dist/Autocomplete/index.mjs +86 -36
  7. package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +13 -0
  8. package/dist/Autocomplete/useAutocomplete.d.ts +1 -0
  9. package/dist/Checkbox/Checkbox.types.d.ts +9 -2
  10. package/dist/Checkbox/index.cjs +2 -4
  11. package/dist/Checkbox/index.mjs +2 -4
  12. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
  13. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
  14. package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
  15. package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
  16. package/dist/Chips/index.cjs +2 -2
  17. package/dist/Chips/index.mjs +2 -2
  18. package/dist/DataList/components/DataListSearch/index.cjs +12 -1
  19. package/dist/DataList/components/DataListSearch/index.mjs +12 -1
  20. package/dist/DataList/index.cjs +8 -0
  21. package/dist/DataList/index.mjs +8 -0
  22. package/dist/DataTable/index.cjs +2 -2
  23. package/dist/DataTable/index.mjs +2 -2
  24. package/dist/DatePicker/index.cjs +2 -2
  25. package/dist/DatePicker/index.mjs +2 -2
  26. package/dist/DatePicker-es.js +1 -1
  27. package/dist/FormField/FormFieldTypes.d.ts +2 -0
  28. package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +2 -7
  29. package/dist/FormField-cjs.js +6 -1
  30. package/dist/FormField-es.js +6 -2
  31. package/dist/InputDate/index.cjs +9 -5
  32. package/dist/InputDate/index.mjs +9 -5
  33. package/dist/InputDate/useInputDateActivatorActions.d.ts +8 -4
  34. package/dist/InputEmail/InputEmail.types.d.ts +20 -12
  35. package/dist/InputEmail/hooks/useInputEmailActions.d.ts +1 -1
  36. package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +32 -0
  37. package/dist/InputEmail/index.cjs +44 -8
  38. package/dist/InputEmail/index.mjs +44 -8
  39. package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +3 -20
  40. package/dist/InputNumber/index.cjs +3 -3
  41. package/dist/InputNumber/index.mjs +3 -3
  42. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +27 -13
  43. package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +1 -1
  44. package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +71 -0
  45. package/dist/InputPhoneNumber/index.cjs +34 -17
  46. package/dist/InputPhoneNumber/index.mjs +34 -17
  47. package/dist/InputText/InputText.types.d.ts +24 -24
  48. package/dist/InputText/index.cjs +54 -54
  49. package/dist/InputText/index.mjs +55 -55
  50. package/dist/InputText/useInputTextActions.d.ts +1 -1
  51. package/dist/InputText/useInputTextFormField.d.ts +352 -0
  52. package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
  53. package/dist/InputTime/InputTime.types.d.ts +1 -21
  54. package/dist/InputTime/index.cjs +33 -63
  55. package/dist/InputTime/index.d.ts +1 -1
  56. package/dist/InputTime/index.mjs +36 -66
  57. package/dist/List/index.cjs +2 -2
  58. package/dist/List/index.mjs +2 -2
  59. package/dist/RecurringSelect/index.cjs +2 -2
  60. package/dist/RecurringSelect/index.mjs +2 -2
  61. package/dist/Select/Select.rebuilt.d.ts +1 -1
  62. package/dist/Select/Select.types.d.ts +1 -14
  63. package/dist/Select/hooks/useSelectActions.d.ts +5 -5
  64. package/dist/Select/hooks/useSelectFormField.d.ts +34 -0
  65. package/dist/Select/index.cjs +41 -28
  66. package/dist/Select/index.d.ts +5 -7
  67. package/dist/Select/index.mjs +43 -30
  68. package/dist/Tabs-es.js +1 -1
  69. package/dist/_baseEach-cjs.js +12 -12
  70. package/dist/_baseEach-es.js +1 -1
  71. package/dist/_baseFlatten-cjs.js +2 -2
  72. package/dist/_baseFlatten-es.js +1 -1
  73. package/dist/{_getAllKeys-cjs.js → _baseGet-cjs.js} +181 -181
  74. package/dist/{_getAllKeys-es.js → _baseGet-es.js} +182 -182
  75. package/dist/debounce-es.js +1 -1
  76. package/dist/floating-ui.react-cjs.js +115 -0
  77. package/dist/floating-ui.react-es.js +115 -1
  78. package/dist/index.cjs +2 -2
  79. package/dist/index.mjs +2 -2
  80. package/dist/omit-cjs.js +14 -14
  81. package/dist/omit-es.js +1 -1
  82. package/dist/sharedHelpers/types.d.ts +0 -235
  83. package/dist/styles.css +3 -0
  84. package/dist/useScrollToActive-cjs.js +3 -3
  85. package/dist/useScrollToActive-es.js +2 -2
  86. package/package.json +2 -2
  87. package/dist/InputTime/hooks/useInputTimeActions.d.ts +0 -16
@@ -2740,9 +2740,9 @@ const InputNumberRebuilt = React.forwardRef((props, ref) => {
2740
2740
  }
2741
2741
  },
2742
2742
  }));
2743
- const { align, description, disabled, error, inline, invalid, placeholder, readOnly, showMiniLabel = true, size, minValue, maxValue } = props, ariaNumberFieldProps = tslib_es6.__rest(props, ["align", "description", "disabled", "error", "inline", "invalid", "placeholder", "readOnly", "showMiniLabel", "size", "minValue", "maxValue"]);
2743
+ const { align, description, disabled, error, inline, invalid, placeholder, readonly, showMiniLabel = true, size, minValue, maxValue } = props, ariaNumberFieldProps = tslib_es6.__rest(props, ["align", "description", "disabled", "error", "inline", "invalid", "placeholder", "readonly", "showMiniLabel", "size", "minValue", "maxValue"]);
2744
2744
  const stringDescription = typeof description === "string";
2745
- return (React.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions, id: props.id, isDisabled: disabled, isInvalid: invalid, isReadOnly: readOnly, minValue: minValue, maxValue: maxValue, onBlur: e => { var _a; return (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onFocus: e => { var _a; return (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onChange: handleChange }),
2745
+ return (React.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions, isDisabled: disabled, isInvalid: invalid, isReadOnly: readonly, minValue: minValue, maxValue: maxValue, onBlur: e => { var _a; return (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onFocus: e => { var _a; return (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onChange: handleChange }),
2746
2746
  React.createElement($a049562f99e7db0e$export$eb2fcfdbd7ba97d4, { className: classnames(styles.wrapper, align && styles[align], invalid && styles.invalid, disabled && styles.disabled) },
2747
2747
  React.createElement("div", { className: styles.horizontalWrapper },
2748
2748
  React.createElement("div", { className: classnames(styles.inputWrapper, disabled && styles.disabled, !showMiniLabel && styles.hideLabel, size && styles[size]) },
@@ -2773,7 +2773,7 @@ function InputNumberInternal(props, ref) {
2773
2773
  }
2774
2774
  },
2775
2775
  }));
2776
- return (React.createElement(FormField.FormField, Object.assign({}, props, { type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
2776
+ return (React.createElement(FormField.FormField, Object.assign({}, props, { clearable: "never", type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
2777
2777
  function customValidators(validators) {
2778
2778
  if (validators == null) {
2779
2779
  return getOverLimitMessage;
@@ -2738,9 +2738,9 @@ const InputNumberRebuilt = forwardRef((props, ref) => {
2738
2738
  }
2739
2739
  },
2740
2740
  }));
2741
- const { align, description, disabled, error, inline, invalid, placeholder, readOnly, showMiniLabel = true, size, minValue, maxValue } = props, ariaNumberFieldProps = __rest(props, ["align", "description", "disabled", "error", "inline", "invalid", "placeholder", "readOnly", "showMiniLabel", "size", "minValue", "maxValue"]);
2741
+ const { align, description, disabled, error, inline, invalid, placeholder, readonly, showMiniLabel = true, size, minValue, maxValue } = props, ariaNumberFieldProps = __rest(props, ["align", "description", "disabled", "error", "inline", "invalid", "placeholder", "readonly", "showMiniLabel", "size", "minValue", "maxValue"]);
2742
2742
  const stringDescription = typeof description === "string";
2743
- return (React__default.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions, id: props.id, isDisabled: disabled, isInvalid: invalid, isReadOnly: readOnly, minValue: minValue, maxValue: maxValue, onBlur: e => { var _a; return (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onFocus: e => { var _a; return (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onChange: handleChange }),
2743
+ return (React__default.createElement($b91743d66a0ed188$export$63c5fa0b2fdccd2e, Object.assign({}, ariaNumberFieldProps, { className: classnames(styles.container, inline && styles.inline), formatOptions: mergedFormatOptions, isDisabled: disabled, isInvalid: invalid, isReadOnly: readonly, minValue: minValue, maxValue: maxValue, onBlur: e => { var _a; return (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onFocus: e => { var _a; return (_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, e); }, onChange: handleChange }),
2744
2744
  React__default.createElement($a049562f99e7db0e$export$eb2fcfdbd7ba97d4, { className: classnames(styles.wrapper, align && styles[align], invalid && styles.invalid, disabled && styles.disabled) },
2745
2745
  React__default.createElement("div", { className: styles.horizontalWrapper },
2746
2746
  React__default.createElement("div", { className: classnames(styles.inputWrapper, disabled && styles.disabled, !showMiniLabel && styles.hideLabel, size && styles[size]) },
@@ -2771,7 +2771,7 @@ function InputNumberInternal(props, ref) {
2771
2771
  }
2772
2772
  },
2773
2773
  }));
2774
- return (React__default.createElement(FormField, Object.assign({}, props, { type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
2774
+ return (React__default.createElement(FormField, Object.assign({}, props, { clearable: "never", type: "number", inputRef: inputRef, onChange: handleChange, validations: Object.assign(Object.assign({}, props.validations), { validate: customValidators((_a = props.validations) === null || _a === void 0 ? void 0 : _a.validate) }) })));
2775
2775
  function customValidators(validators) {
2776
2776
  if (validators == null) {
2777
2777
  return getOverLimitMessage;
@@ -1,6 +1,6 @@
1
+ import type { Clearable } from "@jobber/hooks";
1
2
  import type { InputMaskProps } from "./InputMask";
2
3
  import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
3
- import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
4
4
  export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps, "align">, Pick<FormFieldProps, "autocomplete" | "onEnter" | "onFocus" | "onBlur" | "validations" | "readonly" | "prefix" | "suffix"> {
5
5
  readonly value: string;
6
6
  readonly onChange: (value: string) => void;
@@ -16,21 +16,20 @@ export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps,
16
16
  */
17
17
  readonly required?: boolean;
18
18
  }
19
- export interface InputPhoneNumberRebuiltProps extends Omit<HTMLInputBaseProps, "type" | "maxLength" | "minLength">, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, RebuiltInputCommonProps {
20
- /**
21
- * The current value of the input.
22
- */
19
+ export interface InputPhoneNumberRebuiltProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "onBlur" | "size" | "suffix" | "prefix" | "value" | "max" | "min" | "defaultValue" | "readOnly" | "type" | "maxLength" | "minLength"> {
20
+ readonly error?: string;
21
+ readonly invalid?: boolean;
22
+ readonly identifier?: string;
23
+ readonly autocomplete?: boolean | string;
24
+ readonly loading?: boolean;
25
+ readonly onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
26
+ readonly children?: React.ReactNode;
27
+ readonly clearable?: Clearable;
23
28
  readonly value: string;
24
- /**
25
- * Custom onChange handler that provides the new value as the first argument.
26
- */
27
29
  readonly onChange: (value: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
28
- /**
29
- * A callback to handle "Enter" keypress. This will only run
30
- * if Enter is the only key. Will not run if Shift or Control
31
- * are being held.
32
- */
30
+ readonly onBlur?: (event?: React.FocusEvent<HTMLInputElement>) => void;
33
31
  readonly onEnter?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
32
+ readonly onFocus?: (event?: React.FocusEvent<HTMLInputElement>) => void;
34
33
  /**
35
34
  * A pattern to specify the format to display the phone number in.
36
35
  * For example if you want to display the format for [Denmark](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers#Denmark)
@@ -38,5 +37,20 @@ export interface InputPhoneNumberRebuiltProps extends Omit<HTMLInputBaseProps, "
38
37
  * @default "(***) ***-****"
39
38
  */
40
39
  readonly pattern?: InputMaskProps["pattern"];
40
+ /**
41
+ * Shows a "required" validation message when the component is left empty.
42
+ */
43
+ readonly required?: boolean;
44
+ /**
45
+ * Version 2 is highly experimental, avoid using it unless you have talked with Atlantis first.
46
+ */
47
+ readonly version: 2;
48
+ readonly size?: FormFieldProps["size"];
49
+ readonly inline?: FormFieldProps["inline"];
50
+ readonly align?: FormFieldProps["align"];
51
+ readonly prefix?: FormFieldProps["prefix"];
52
+ readonly suffix?: FormFieldProps["suffix"];
53
+ readonly description?: FormFieldProps["description"];
54
+ readonly readonly?: boolean;
41
55
  }
42
56
  export declare const DEFAULT_PATTERN = "(***) ***-****";
@@ -11,6 +11,6 @@ export declare function useInputPhoneActions({ onChange, inputRef, onFocus, onBl
11
11
  handleClear: () => void;
12
12
  handleChange: (event: ChangeEvent<HTMLInputElement>) => void;
13
13
  handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
14
- handleBlur: (event: FocusEvent<HTMLInputElement>) => void;
14
+ handleBlur: (event?: FocusEvent<HTMLInputElement>) => void;
15
15
  handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
16
16
  };
@@ -0,0 +1,71 @@
1
+ import type { ChangeEvent, FocusEvent, KeyboardEvent, ReactNode } from "react";
2
+ export interface useInputPhoneFormFieldProps {
3
+ /**
4
+ * The html id for the field
5
+ */
6
+ readonly id: string;
7
+ /**
8
+ * The auto-generated name for the html input field if a nameProp is not provided
9
+ */
10
+ readonly name: string;
11
+ /**
12
+ * The error message for the field
13
+ */
14
+ readonly error?: string;
15
+ /**
16
+ * Adjusts the form field to go inline with a content. This also silences the
17
+ * given `validations` prop. You'd have to used the `onValidate` prop to
18
+ * capture the message and render it somewhere else using the
19
+ * `InputValidation` component.
20
+ */
21
+ readonly inline?: boolean;
22
+ /**
23
+ * Further description of the input, can be used for a hint.
24
+ */
25
+ readonly description?: ReactNode;
26
+ /**
27
+ * Callback for when the field value changes
28
+ */
29
+ handleChange: (event: ChangeEvent<HTMLInputElement>) => void;
30
+ /**
31
+ * Callback for when the field loses focus
32
+ */
33
+ handleBlur: () => void;
34
+ /**
35
+ * Callback for when the field gains focus
36
+ */
37
+ handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
38
+ /**
39
+ * Callback for when keydown event is triggered on the field
40
+ */
41
+ handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
42
+ readonly invalid?: boolean;
43
+ readonly disabled?: boolean;
44
+ readonly autofocus?: boolean;
45
+ readonly value?: string;
46
+ readonly readonly?: boolean;
47
+ }
48
+ export interface UseInputPhoneFormFieldReturn {
49
+ fieldProps: React.InputHTMLAttributes<HTMLInputElement>;
50
+ }
51
+ /**
52
+ * Provides the props for the html fields rendered by the html input.
53
+ * DO not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
54
+ */
55
+ export declare function useInputPhoneFormField({ id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error, disabled, autofocus, value, readonly, ...rest }: useInputPhoneFormFieldProps): {
56
+ fieldProps: {
57
+ readOnly: boolean | undefined;
58
+ "aria-describedby"?: string | undefined;
59
+ id: string;
60
+ name: string;
61
+ disabled: boolean | undefined;
62
+ autoFocus: boolean | undefined;
63
+ onChange: (event: ChangeEvent<HTMLInputElement>) => void;
64
+ onBlur: () => void;
65
+ onFocus: (event: FocusEvent<HTMLInputElement>) => void;
66
+ onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
67
+ value: string | undefined;
68
+ invalid: string | undefined;
69
+ };
70
+ descriptionIdentifier: string;
71
+ };
@@ -115,6 +115,7 @@ const DEFAULT_PATTERN = "(***) ***-****";
115
115
  function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }) {
116
116
  function handleClear() {
117
117
  var _a;
118
+ handleBlur();
118
119
  onChange && onChange("");
119
120
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
120
121
  }
@@ -148,22 +149,26 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
148
149
  };
149
150
  }
150
151
 
152
+ /**
153
+ * Provides the props for the html fields rendered by the html input.
154
+ * DO not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
155
+ */
156
+ function useInputPhoneFormField(_a) {
157
+ var { id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error, disabled, autofocus, value, readonly } = _a, rest = tslib_es6.__rest(_a, ["id", "name", "description", "inline", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error", "disabled", "autofocus", "value", "readonly"]);
158
+ const descriptionIdentifier = `descriptionUUID--${id}`;
159
+ const fieldProps = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { id,
160
+ name,
161
+ disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
162
+ !inline && { "aria-describedby": descriptionIdentifier })), { readOnly: readonly });
163
+ return { fieldProps, descriptionIdentifier };
164
+ }
165
+
151
166
  const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberInternal(_a, ref) {
152
167
  var _b, _c, _d, _e;
153
168
  var { pattern = DEFAULT_PATTERN } = _a, props = tslib_es6.__rest(_a, ["pattern"]);
154
169
  const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React.useRef(null);
155
170
  const wrapperRef = React.useRef(null);
156
- const { inputStyle } = FormField.useFormFieldWrapperStyles({
157
- size: props.size,
158
- align: props.align,
159
- placeholder: props.placeholder,
160
- value: props.value,
161
- invalid: props.invalid,
162
- error: props.error,
163
- disabled: props.disabled,
164
- inline: props.inline,
165
- type: "tel",
166
- });
171
+ const { inputStyle } = FormField.useFormFieldWrapperStyles(Object.assign(Object.assign({}, props), { type: "tel" }));
167
172
  const generatedId = React.useId();
168
173
  const id = props.id || generatedId;
169
174
  const { name } = FormField.useAtlantisFormFieldName({
@@ -183,13 +188,25 @@ const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberIntern
183
188
  onEnter: props.onEnter,
184
189
  inputRef: inputPhoneNumberRef,
185
190
  });
186
- const descriptionIdentifier = `descriptionUUID--${id}`;
187
- const hasDescription = props.description && !props.inline;
188
- const isInvalid = Boolean(props.error || props.invalid);
189
- return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, loading: props.loading },
190
- React.createElement("input", { id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(inputStyle, {
191
+ const { fieldProps, descriptionIdentifier } = useInputPhoneFormField({
192
+ id,
193
+ name,
194
+ handleChange,
195
+ handleBlur,
196
+ handleFocus,
197
+ handleKeyDown,
198
+ autofocus: props.autoFocus,
199
+ disabled: props.disabled,
200
+ readonly: props.readonly,
201
+ invalid: props.invalid,
202
+ error: props.error,
203
+ description: props.description,
204
+ inline: props.inline,
205
+ });
206
+ return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readonly, loading: props.loading },
207
+ React.createElement("input", Object.assign({ type: "tel" }, fieldProps, { ref: inputPhoneNumberRef, className: classnames(inputStyle, {
191
208
  [styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
192
- }), value: formattedValue, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props.ariaLabel, "aria-describedby": hasDescription ? descriptionIdentifier : props.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-controls": props.ariaControls, "aria-expanded": props.ariaExpanded, "aria-activedescendant": props.ariaActiveDescendant, "aria-autocomplete": props.ariaAutocomplete, "aria-required": props.ariaRequired, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown }),
209
+ }), value: formattedValue })),
193
210
  React.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
194
211
  React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
195
212
  });
@@ -113,6 +113,7 @@ const DEFAULT_PATTERN = "(***) ***-****";
113
113
  function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }) {
114
114
  function handleClear() {
115
115
  var _a;
116
+ handleBlur();
116
117
  onChange && onChange("");
117
118
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
118
119
  }
@@ -146,22 +147,26 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
146
147
  };
147
148
  }
148
149
 
150
+ /**
151
+ * Provides the props for the html fields rendered by the html input.
152
+ * DO not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
153
+ */
154
+ function useInputPhoneFormField(_a) {
155
+ var { id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error, disabled, autofocus, value, readonly } = _a, rest = __rest(_a, ["id", "name", "description", "inline", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error", "disabled", "autofocus", "value", "readonly"]);
156
+ const descriptionIdentifier = `descriptionUUID--${id}`;
157
+ const fieldProps = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { id,
158
+ name,
159
+ disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
160
+ !inline && { "aria-describedby": descriptionIdentifier })), { readOnly: readonly });
161
+ return { fieldProps, descriptionIdentifier };
162
+ }
163
+
149
164
  const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a, ref) {
150
165
  var _b, _c, _d, _e;
151
166
  var { pattern = DEFAULT_PATTERN } = _a, props = __rest(_a, ["pattern"]);
152
167
  const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React__default.useRef(null);
153
168
  const wrapperRef = React__default.useRef(null);
154
- const { inputStyle } = useFormFieldWrapperStyles({
155
- size: props.size,
156
- align: props.align,
157
- placeholder: props.placeholder,
158
- value: props.value,
159
- invalid: props.invalid,
160
- error: props.error,
161
- disabled: props.disabled,
162
- inline: props.inline,
163
- type: "tel",
164
- });
169
+ const { inputStyle } = useFormFieldWrapperStyles(Object.assign(Object.assign({}, props), { type: "tel" }));
165
170
  const generatedId = useId();
166
171
  const id = props.id || generatedId;
167
172
  const { name } = useAtlantisFormFieldName({
@@ -181,13 +186,25 @@ const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a,
181
186
  onEnter: props.onEnter,
182
187
  inputRef: inputPhoneNumberRef,
183
188
  });
184
- const descriptionIdentifier = `descriptionUUID--${id}`;
185
- const hasDescription = props.description && !props.inline;
186
- const isInvalid = Boolean(props.error || props.invalid);
187
- return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, loading: props.loading },
188
- React__default.createElement("input", { id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(inputStyle, {
189
+ const { fieldProps, descriptionIdentifier } = useInputPhoneFormField({
190
+ id,
191
+ name,
192
+ handleChange,
193
+ handleBlur,
194
+ handleFocus,
195
+ handleKeyDown,
196
+ autofocus: props.autoFocus,
197
+ disabled: props.disabled,
198
+ readonly: props.readonly,
199
+ invalid: props.invalid,
200
+ error: props.error,
201
+ description: props.description,
202
+ inline: props.inline,
203
+ });
204
+ return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readonly, loading: props.loading },
205
+ React__default.createElement("input", Object.assign({ type: "tel" }, fieldProps, { ref: inputPhoneNumberRef, className: classnames(inputStyle, {
189
206
  [styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
190
- }), value: formattedValue, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props.ariaLabel, "aria-describedby": hasDescription ? descriptionIdentifier : props.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-controls": props.ariaControls, "aria-expanded": props.ariaExpanded, "aria-activedescendant": props.ariaActiveDescendant, "aria-autocomplete": props.ariaAutocomplete, "aria-required": props.ariaRequired, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown }),
207
+ }), value: formattedValue })),
191
208
  React__default.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
192
209
  React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
193
210
  });
@@ -1,6 +1,6 @@
1
+ import type { Clearable } from "@jobber/hooks";
1
2
  import type { XOR } from "ts-xor";
2
- import type { CommonFormFieldProps, FormFieldProps, FormFieldTypes } from "../FormField";
3
- import type { FocusEvents, HTMLInputBaseProps, InputLengthConstraint, KeyboardEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
3
+ import type { AutocompleteTypes, CommonFormFieldProps, FormFieldProps, FormFieldTypes } from "../FormField";
4
4
  export interface RowRange {
5
5
  min: number;
6
6
  max: number;
@@ -10,7 +10,15 @@ export type InputTextVersion = 1 | 2 | undefined;
10
10
  * Experimental version 2 of the InputText component.
11
11
  * Do not use unless you have talked with Atlantis first.
12
12
  */
13
- export interface InputTextRebuiltProps extends HTMLInputBaseProps, FocusEvents<HTMLInputElement | HTMLTextAreaElement>, KeyboardEvents<HTMLInputElement | HTMLTextAreaElement>, RebuiltInputCommonProps, InputLengthConstraint {
13
+ export interface InputTextRebuiltProps extends Omit<React.InputHTMLAttributes<HTMLInputElement | HTMLTextAreaElement>, "onChange" | "onBlur" | "maxLength" | "rows" | "size" | "suffix" | "prefix" | "value" | "max" | "min" | "defaultValue"> {
14
+ readonly error?: string;
15
+ readonly invalid?: boolean;
16
+ readonly identifier?: string;
17
+ readonly autocomplete?: boolean | AutocompleteTypes;
18
+ readonly loading?: boolean;
19
+ readonly onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
20
+ readonly children?: React.ReactNode;
21
+ readonly clearable?: Clearable;
14
22
  /**
15
23
  * Use this when you're expecting a long answer.
16
24
  */
@@ -22,32 +30,24 @@ export interface InputTextRebuiltProps extends HTMLInputBaseProps, FocusEvents<H
22
30
  * maximum number of visible rows.
23
31
  */
24
32
  readonly rows?: number | RowRange;
25
- /**
26
- * Determines what kind of form field should the component give you.
27
- */
28
33
  readonly type?: FormFieldTypes;
29
34
  /**
30
- * Toolbar to render content below the input.
31
- */
32
- readonly toolbar?: React.ReactNode;
33
- /**
34
- * Determines the visibility of the toolbar.
35
- */
36
- readonly toolbarVisibility?: "always" | "while-editing";
37
- /**
38
- * The current value of the input.
39
- */
40
- readonly value: string;
41
- /**
42
- * Custom onChange handler that provides the new value as the first argument.
35
+ * Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
43
36
  */
37
+ readonly version: 2;
44
38
  readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
45
- /**
46
- * A callback to handle "Enter" keypress. This will only run
47
- * if Enter is the only key. Will not run if Shift or Control
48
- * are being held.
49
- */
50
39
  readonly onEnter?: FormFieldProps["onEnter"];
40
+ readonly onBlur?: FormFieldProps["onBlur"];
41
+ readonly value: string;
42
+ readonly maxLength?: number;
43
+ readonly size?: FormFieldProps["size"];
44
+ readonly inline?: FormFieldProps["inline"];
45
+ readonly align?: FormFieldProps["align"];
46
+ readonly toolbar?: FormFieldProps["toolbar"];
47
+ readonly toolbarVisibility?: FormFieldProps["toolbarVisibility"];
48
+ readonly prefix?: FormFieldProps["prefix"];
49
+ readonly suffix?: FormFieldProps["suffix"];
50
+ readonly description?: FormFieldProps["description"];
51
51
  }
52
52
  interface BaseProps extends CommonFormFieldProps, Pick<FormFieldProps, "autofocus" | "maxLength" | "readonly" | "autocomplete" | "keyboard" | "onEnter" | "onFocus" | "onBlur" | "onChange" | "inputRef" | "validations" | "defaultValue" | "prefix" | "suffix" | "toolbar" | "toolbarVisibility" | "version"> {
53
53
  multiline?: boolean;
@@ -4,11 +4,12 @@ var React = require('react');
4
4
  var jobberHooks = require('@jobber/hooks');
5
5
  var FormField = require('../FormField-cjs.js');
6
6
  require('classnames');
7
- require('../tslib.es6-cjs.js');
7
+ var tslib_es6 = require('../tslib.es6-cjs.js');
8
8
  require('react-hook-form');
9
9
  require('framer-motion');
10
10
  require('@jobber/design');
11
11
  require('../Button-cjs.js');
12
+ var omit = require('../omit-cjs.js');
12
13
  require('../Icon-cjs.js');
13
14
  require('../Text-cjs.js');
14
15
  require('../Typography-cjs.js');
@@ -16,6 +17,17 @@ require('../useFormFieldFocus-cjs.js');
16
17
  require('../InputValidation-cjs.js');
17
18
  require('../Spinner-cjs.js');
18
19
  require('react-router-dom');
20
+ require('../_commonjsHelpers-cjs.js');
21
+ require('../_baseGet-cjs.js');
22
+ require('../isTypedArray-cjs.js');
23
+ require('../isObjectLike-cjs.js');
24
+ require('../identity-cjs.js');
25
+ require('../_getTag-cjs.js');
26
+ require('../isSymbol-cjs.js');
27
+ require('../keysIn-cjs.js');
28
+ require('../_baseAssignValue-cjs.js');
29
+ require('../_baseFlatten-cjs.js');
30
+ require('../_setToString-cjs.js');
19
31
 
20
32
  /**
21
33
  * Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
@@ -150,6 +162,7 @@ function insertAtCursor(input, newText) {
150
162
  function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
151
163
  function handleClear() {
152
164
  var _a;
165
+ handleBlur();
153
166
  onChange && onChange("");
154
167
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
155
168
  }
@@ -183,10 +196,23 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
183
196
  };
184
197
  }
185
198
 
199
+ /**
200
+ * Provides the props for the html fields rendered by the html input.
201
+ * DO not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
202
+ */
203
+ function useInputTextFormField(_a) {
204
+ var { id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = tslib_es6.__rest(_a, ["id", "name", "description", "inline", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
205
+ const descriptionIdentifier = `descriptionUUID--${id}`;
206
+ const fieldProps = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { id, className: FormField.styles.input, name, disabled: rest.disabled, inputMode: rest.inputMode, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus }), (description &&
207
+ !inline && { "aria-describedby": descriptionIdentifier })), { "aria-invalid": rest["aria-invalid"] || error || rest.invalid ? true : undefined, autoFocus: rest.autoFocus, invalid: error || rest.invalid ? "true" : undefined, onKeyDown: handleKeyDown });
208
+ return { fieldProps, descriptionIdentifier };
209
+ }
210
+
186
211
  const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRefs) {
187
212
  var _a, _b, _c;
188
213
  const inputTextRef = React.useRef(null);
189
214
  const wrapperRef = React.useRef(null);
215
+ const legacyPropHelper = Object.assign(Object.assign({}, props), { version: 1 });
190
216
  const id = useInputTextId(props);
191
217
  const { rowRange } = useTextAreaResize({
192
218
  rows: props.rows,
@@ -194,18 +220,8 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
194
220
  inputRef: inputTextRef,
195
221
  wrapperRef: wrapperRef,
196
222
  });
197
- const { inputStyle } = FormField.useFormFieldWrapperStyles({
198
- size: props.size,
199
- align: props.align,
200
- placeholder: props.placeholder,
201
- value: props.value,
202
- invalid: props.invalid,
203
- error: props.error,
204
- maxLength: props.maxLength,
205
- type: props.multiline ? "textarea" : "text",
206
- disabled: props.disabled,
207
- inline: props.inline,
208
- });
223
+ const type = props.multiline ? "textarea" : "text";
224
+ const { inputStyle } = FormField.useFormFieldWrapperStyles(legacyPropHelper);
209
225
  const { name } = FormField.useAtlantisFormFieldName({
210
226
  nameProp: props.name,
211
227
  id: id,
@@ -218,43 +234,27 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
218
234
  onEnter: props.onEnter,
219
235
  inputRef: inputTextRef,
220
236
  });
221
- const descriptionIdentifier = `descriptionUUID--${id}`;
222
- const hasDescription = props.description && !props.inline;
223
- const isInvalid = Boolean(props.error || props.invalid);
224
- // Shared props for both TextArea and TextInput
225
- const commonInputProps = {
226
- id,
237
+ const inputProps = omit.omit(props, [
238
+ "onChange",
239
+ "onBlur",
240
+ "onFocus",
241
+ "onEnter",
242
+ "size",
243
+ "placeholder",
244
+ "multiline",
245
+ "prefix",
246
+ "suffix",
247
+ "version",
248
+ ]);
249
+ const { fieldProps, descriptionIdentifier } = useInputTextFormField(Object.assign(Object.assign({}, inputProps), { id,
227
250
  name,
228
- className: inputStyle,
229
- value: props.value,
230
- disabled: props.disabled,
231
- readOnly: props.readOnly,
232
- autoFocus: props.autoFocus,
233
- autoComplete: props.autoComplete,
234
- inputMode: props.inputMode,
235
- tabIndex: props.tabIndex,
236
- maxLength: props.maxLength,
237
- role: props.role,
238
- "aria-label": props.ariaLabel,
239
- "aria-describedby": hasDescription
240
- ? descriptionIdentifier
241
- : props.ariaDescribedBy,
242
- "aria-invalid": isInvalid ? true : undefined,
243
- "aria-controls": props.ariaControls,
244
- "aria-expanded": props.ariaExpanded,
245
- "aria-activedescendant": props.ariaActiveDescendant,
246
- "aria-autocomplete": props.ariaAutocomplete,
247
- "aria-required": props.ariaRequired,
248
- onChange: handleChange,
249
- onBlur: handleBlur,
250
- onFocus: handleFocus,
251
- onKeyDown: handleKeyDown,
252
- onKeyUp: props.onKeyUp,
253
- ref: FormField.mergeRefs([inputRefs, inputTextRef]),
254
- };
255
- return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, autofocus: props.autoFocus, name: name, wrapperRef: wrapperRef, error: (_a = props.error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", maxLength: props.maxLength, onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
251
+ handleChange,
252
+ handleBlur,
253
+ handleFocus,
254
+ handleKeyDown }));
255
+ return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, autofocus: props.autoFocus, name: name, wrapperRef: wrapperRef, error: (_a = props.error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
256
256
  React.createElement(React.Fragment, null,
257
- props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
257
+ type === "textarea" ? (React.createElement(TextArea, { fieldProps: fieldProps, rowRange: rowRange, inputRefs: [inputRefs, inputTextRef], value: props.value, inputStyle: inputStyle })) : (React.createElement(TextInput, { fieldProps: fieldProps, inputRefs: [inputRefs, inputTextRef], value: props.value, inputStyle: inputStyle })),
258
258
  React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
259
259
  props.children)));
260
260
  });
@@ -262,12 +262,12 @@ function useInputTextId(props) {
262
262
  const generatedId = React.useId();
263
263
  return props.id || generatedId;
264
264
  }
265
- const TextArea = React.forwardRef(function TextArea(props, ref) {
266
- return React.createElement("textarea", Object.assign({}, props, { ref: ref }));
267
- });
268
- const TextInput = React.forwardRef(function TextInput(props, ref) {
269
- return React.createElement("input", Object.assign({}, props, { ref: ref }));
270
- });
265
+ function TextArea({ fieldProps, rowRange, inputRefs, value, inputStyle, }) {
266
+ return (React.createElement("textarea", Object.assign({}, fieldProps, { rows: rowRange.min, ref: FormField.mergeRefs(inputRefs), className: inputStyle, value: value })));
267
+ }
268
+ function TextInput({ fieldProps, inputRefs, value, inputStyle, }) {
269
+ return (React.createElement("input", Object.assign({}, fieldProps, { ref: FormField.mergeRefs(inputRefs), className: inputStyle, value: value })));
270
+ }
271
271
 
272
272
  function isNewInputTextProps(props) {
273
273
  return props.version === 2;