@jobber/components 6.103.0 → 6.103.2-JOB-140609-f6002b5.12

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 (60) hide show
  1. package/dist/Autocomplete/index.cjs +0 -12
  2. package/dist/Autocomplete/index.mjs +0 -12
  3. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
  4. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
  5. package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
  6. package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
  7. package/dist/Chips/index.cjs +2 -2
  8. package/dist/Chips/index.mjs +2 -2
  9. package/dist/DataList/components/DataListSearch/index.cjs +1 -12
  10. package/dist/DataList/components/DataListSearch/index.mjs +1 -12
  11. package/dist/DataList/index.cjs +0 -8
  12. package/dist/DataList/index.mjs +0 -8
  13. package/dist/DataTable/index.cjs +2 -2
  14. package/dist/DataTable/index.mjs +2 -2
  15. package/dist/DatePicker/index.cjs +2 -2
  16. package/dist/DatePicker/index.mjs +2 -2
  17. package/dist/FormField/FormFieldTypes.d.ts +195 -0
  18. package/dist/FormField-cjs.js +0 -1
  19. package/dist/FormField-es.js +1 -1
  20. package/dist/InputDate/index.cjs +8 -4
  21. package/dist/InputDate/index.mjs +8 -4
  22. package/dist/InputDate/useInputDateActivatorActions.d.ts +2 -2
  23. package/dist/InputEmail/InputEmail.types.d.ts +28 -21
  24. package/dist/InputEmail/hooks/useInputEmailActions.d.ts +1 -1
  25. package/dist/InputEmail/index.cjs +10 -45
  26. package/dist/InputEmail/index.mjs +10 -45
  27. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +25 -24
  28. package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +1 -1
  29. package/dist/InputPhoneNumber/index.cjs +24 -36
  30. package/dist/InputPhoneNumber/index.mjs +24 -36
  31. package/dist/InputText/InputText.d.ts +2 -2
  32. package/dist/InputText/InputText.types.d.ts +39 -24
  33. package/dist/InputText/index.cjs +26 -55
  34. package/dist/InputText/index.mjs +27 -56
  35. package/dist/InputText/useInputTextActions.d.ts +1 -1
  36. package/dist/InputTime/index.cjs +1 -1
  37. package/dist/InputTime/index.mjs +1 -1
  38. package/dist/List/index.cjs +2 -2
  39. package/dist/List/index.mjs +2 -2
  40. package/dist/RecurringSelect/index.cjs +2 -2
  41. package/dist/RecurringSelect/index.mjs +2 -2
  42. package/dist/Select/index.cjs +2 -2
  43. package/dist/Select/index.mjs +2 -2
  44. package/dist/_baseEach-cjs.js +12 -12
  45. package/dist/_baseEach-es.js +1 -1
  46. package/dist/_baseFlatten-cjs.js +2 -2
  47. package/dist/_baseFlatten-es.js +1 -1
  48. package/dist/{_baseGet-cjs.js → _getAllKeys-cjs.js} +181 -181
  49. package/dist/{_baseGet-es.js → _getAllKeys-es.js} +182 -182
  50. package/dist/index.cjs +2 -2
  51. package/dist/index.mjs +2 -2
  52. package/dist/omit-cjs.js +14 -14
  53. package/dist/omit-es.js +1 -1
  54. package/dist/styles.css +11 -3
  55. package/dist/useScrollToActive-cjs.js +3 -3
  56. package/dist/useScrollToActive-es.js +1 -1
  57. package/package.json +2 -2
  58. package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +0 -32
  59. package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +0 -71
  60. package/dist/InputText/useInputTextFormField.d.ts +0 -352
@@ -3,13 +3,12 @@
3
3
  var React = require('react');
4
4
  var FormField = require('../FormField-cjs.js');
5
5
  require('classnames');
6
- var tslib_es6 = require('../tslib.es6-cjs.js');
6
+ require('../tslib.es6-cjs.js');
7
7
  require('react-hook-form');
8
8
  require('@jobber/hooks');
9
9
  require('framer-motion');
10
10
  require('@jobber/design');
11
11
  require('../Button-cjs.js');
12
- var omit = require('../omit-cjs.js');
13
12
  require('../Icon-cjs.js');
14
13
  require('../Text-cjs.js');
15
14
  require('../Typography-cjs.js');
@@ -17,17 +16,6 @@ require('../useFormFieldFocus-cjs.js');
17
16
  require('../InputValidation-cjs.js');
18
17
  require('../Spinner-cjs.js');
19
18
  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');
31
19
 
32
20
  const validationMessage = "Please enter a valid email";
33
21
 
@@ -49,7 +37,7 @@ function InputEmail$1(props) {
49
37
  function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
50
38
  function handleClear() {
51
39
  var _a;
52
- handleBlur();
40
+ // Don't call blur handler when programmatically clearing
53
41
  onChange === null || onChange === void 0 ? void 0 : onChange("");
54
42
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
55
43
  }
@@ -83,19 +71,10 @@ function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, on
83
71
  };
84
72
  }
85
73
 
86
- function useInputEmailFormField(_a) {
87
- var { id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = tslib_es6.__rest(_a, ["id", "name", "disabled", "autofocus", "description", "inline", "value", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
88
- const descriptionIdentifier = `descriptionUUID--${id}`;
89
- const fieldProps = Object.assign(Object.assign(Object.assign({}, rest), { id,
90
- name,
91
- disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
92
- !inline && { "aria-describedby": descriptionIdentifier }));
93
- return { fieldProps, descriptionIdentifier };
94
- }
95
-
96
74
  const InputEmailRebuilt = React.forwardRef(function InputEmailInternal(props, ref) {
97
75
  var _a, _b, _c;
98
- const id = React.useId();
76
+ const generatedId = React.useId();
77
+ const id = props.identifier || props.id || generatedId;
99
78
  const inputRef = (_a = ref) !== null && _a !== void 0 ? _a : React.useRef(null);
100
79
  const wrapperRef = React.useRef(null);
101
80
  const { inputStyle } = FormField.useFormFieldWrapperStyles({
@@ -106,7 +85,7 @@ const InputEmailRebuilt = React.forwardRef(function InputEmailInternal(props, re
106
85
  value: props.value,
107
86
  invalid: props.invalid,
108
87
  error: props.error,
109
- maxLength: props.maxLength,
88
+ maxLength: undefined, // v2: maxLength is for HTML validation only, not for width styling
110
89
  disabled: props.disabled,
111
90
  placeholder: props.placeholder,
112
91
  });
@@ -122,25 +101,11 @@ const InputEmailRebuilt = React.forwardRef(function InputEmailInternal(props, re
122
101
  onEnter: props.onEnter,
123
102
  inputRef,
124
103
  });
125
- const inputProps = omit.omit(props, [
126
- "placeholder",
127
- "onChange",
128
- "onBlur",
129
- "onFocus",
130
- "onEnter",
131
- "size",
132
- "prefix",
133
- "suffix",
134
- "version",
135
- ]);
136
- const { fieldProps, descriptionIdentifier } = useInputEmailFormField(Object.assign(Object.assign({}, inputProps), { id,
137
- name,
138
- handleChange,
139
- handleBlur,
140
- handleFocus,
141
- handleKeyDown }));
142
- return (React.createElement(FormField.FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: props.identifier || id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, maxLength: props.maxLength, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, autofocus: props.autoFocus, name: name },
143
- React.createElement("input", Object.assign({}, fieldProps, { ref: inputRef, type: "email", className: inputStyle, value: props.value, "data-testid": "ATL-InputEmail-input" })),
104
+ const descriptionIdentifier = `descriptionUUID--${id}`;
105
+ const hasDescription = props.description && !props.inline;
106
+ const isInvalid = Boolean(props["aria-invalid"] || props.error || props.invalid);
107
+ return (React.createElement(FormField.FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, maxLength: props.maxLength, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, autofocus: props.autoFocus, name: name },
108
+ React.createElement("input", { id: id, name: name, type: "email", ref: inputRef, className: inputStyle, value: props.value, disabled: props.disabled, readOnly: props.readOnly, required: props.required, autoFocus: props.autoFocus, autoComplete: props.autoComplete, maxLength: props.maxLength, minLength: props.minLength, pattern: props.pattern, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props["aria-label"], "aria-describedby": hasDescription ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: props.onKeyUp, "data-testid": "ATL-InputEmail-input" }),
144
109
  React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
145
110
  props.children));
146
111
  });
@@ -1,13 +1,12 @@
1
1
  import React__default, { forwardRef, useId, useRef } from 'react';
2
2
  import { k as FormField, j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, f as FormFieldWrapper, l as FormFieldPostFix } from '../FormField-es.js';
3
3
  import 'classnames';
4
- import { _ as __rest } from '../tslib.es6-es.js';
4
+ import '../tslib.es6-es.js';
5
5
  import 'react-hook-form';
6
6
  import '@jobber/hooks';
7
7
  import 'framer-motion';
8
8
  import '@jobber/design';
9
9
  import '../Button-es.js';
10
- import { o as omit } from '../omit-es.js';
11
10
  import '../Icon-es.js';
12
11
  import '../Text-es.js';
13
12
  import '../Typography-es.js';
@@ -15,17 +14,6 @@ import '../useFormFieldFocus-es.js';
15
14
  import '../InputValidation-es.js';
16
15
  import '../Spinner-es.js';
17
16
  import 'react-router-dom';
18
- import '../_commonjsHelpers-es.js';
19
- import '../_baseGet-es.js';
20
- import '../isTypedArray-es.js';
21
- import '../isObjectLike-es.js';
22
- import '../identity-es.js';
23
- import '../_getTag-es.js';
24
- import '../isSymbol-es.js';
25
- import '../keysIn-es.js';
26
- import '../_baseAssignValue-es.js';
27
- import '../_baseFlatten-es.js';
28
- import '../_setToString-es.js';
29
17
 
30
18
  const validationMessage = "Please enter a valid email";
31
19
 
@@ -47,7 +35,7 @@ function InputEmail$1(props) {
47
35
  function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
48
36
  function handleClear() {
49
37
  var _a;
50
- handleBlur();
38
+ // Don't call blur handler when programmatically clearing
51
39
  onChange === null || onChange === void 0 ? void 0 : onChange("");
52
40
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
53
41
  }
@@ -81,19 +69,10 @@ function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, on
81
69
  };
82
70
  }
83
71
 
84
- function useInputEmailFormField(_a) {
85
- var { id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = __rest(_a, ["id", "name", "disabled", "autofocus", "description", "inline", "value", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
86
- const descriptionIdentifier = `descriptionUUID--${id}`;
87
- const fieldProps = Object.assign(Object.assign(Object.assign({}, rest), { id,
88
- name,
89
- disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
90
- !inline && { "aria-describedby": descriptionIdentifier }));
91
- return { fieldProps, descriptionIdentifier };
92
- }
93
-
94
72
  const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
95
73
  var _a, _b, _c;
96
- const id = useId();
74
+ const generatedId = useId();
75
+ const id = props.identifier || props.id || generatedId;
97
76
  const inputRef = (_a = ref) !== null && _a !== void 0 ? _a : useRef(null);
98
77
  const wrapperRef = useRef(null);
99
78
  const { inputStyle } = useFormFieldWrapperStyles({
@@ -104,7 +83,7 @@ const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
104
83
  value: props.value,
105
84
  invalid: props.invalid,
106
85
  error: props.error,
107
- maxLength: props.maxLength,
86
+ maxLength: undefined, // v2: maxLength is for HTML validation only, not for width styling
108
87
  disabled: props.disabled,
109
88
  placeholder: props.placeholder,
110
89
  });
@@ -120,25 +99,11 @@ const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
120
99
  onEnter: props.onEnter,
121
100
  inputRef,
122
101
  });
123
- const inputProps = omit(props, [
124
- "placeholder",
125
- "onChange",
126
- "onBlur",
127
- "onFocus",
128
- "onEnter",
129
- "size",
130
- "prefix",
131
- "suffix",
132
- "version",
133
- ]);
134
- const { fieldProps, descriptionIdentifier } = useInputEmailFormField(Object.assign(Object.assign({}, inputProps), { id,
135
- name,
136
- handleChange,
137
- handleBlur,
138
- handleFocus,
139
- handleKeyDown }));
140
- return (React__default.createElement(FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: props.identifier || id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, maxLength: props.maxLength, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, autofocus: props.autoFocus, name: name },
141
- React__default.createElement("input", Object.assign({}, fieldProps, { ref: inputRef, type: "email", className: inputStyle, value: props.value, "data-testid": "ATL-InputEmail-input" })),
102
+ const descriptionIdentifier = `descriptionUUID--${id}`;
103
+ const hasDescription = props.description && !props.inline;
104
+ const isInvalid = Boolean(props["aria-invalid"] || props.error || props.invalid);
105
+ return (React__default.createElement(FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, maxLength: props.maxLength, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, autofocus: props.autoFocus, name: name },
106
+ React__default.createElement("input", { id: id, name: name, type: "email", ref: inputRef, className: inputStyle, value: props.value, disabled: props.disabled, readOnly: props.readOnly, required: props.required, autoFocus: props.autoFocus, autoComplete: props.autoComplete, maxLength: props.maxLength, minLength: props.minLength, pattern: props.pattern, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props["aria-label"], "aria-describedby": hasDescription ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: props.onKeyUp, "data-testid": "ATL-InputEmail-input" }),
142
107
  React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
143
108
  props.children));
144
109
  });
@@ -1,6 +1,5 @@
1
- import type { Clearable } from "@jobber/hooks";
2
1
  import type { InputMaskProps } from "./InputMask";
3
- import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
2
+ import type { CommonFormFieldProps, FocusEvents, FormFieldProps, HTMLInputBaseProps, KeyboardEvents, RebuiltInputCommonProps } from "../FormField";
4
3
  export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps, "align">, Pick<FormFieldProps, "autocomplete" | "onEnter" | "onFocus" | "onBlur" | "validations" | "readonly" | "prefix" | "suffix"> {
5
4
  readonly value: string;
6
5
  readonly onChange: (value: string) => void;
@@ -16,20 +15,21 @@ export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps,
16
15
  */
17
16
  readonly required?: boolean;
18
17
  }
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;
18
+ export interface InputPhoneNumberRebuiltProps extends Omit<HTMLInputBaseProps, "type" | "maxLength" | "minLength">, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, RebuiltInputCommonProps {
19
+ /**
20
+ * The current value of the input.
21
+ */
28
22
  readonly value: string;
23
+ /**
24
+ * Custom onChange handler that provides the new value as the first argument.
25
+ */
29
26
  readonly onChange: (value: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
30
- readonly onBlur?: (event?: React.FocusEvent<HTMLInputElement>) => void;
27
+ /**
28
+ * A callback to handle "Enter" keypress. This will only run
29
+ * if Enter is the only key. Will not run if Shift or Control
30
+ * are being held.
31
+ */
31
32
  readonly onEnter?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
32
- readonly onFocus?: (event?: React.FocusEvent<HTMLInputElement>) => void;
33
33
  /**
34
34
  * A pattern to specify the format to display the phone number in.
35
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,19 +38,20 @@ export interface InputPhoneNumberRebuiltProps extends Omit<React.InputHTMLAttrib
38
38
  */
39
39
  readonly pattern?: InputMaskProps["pattern"];
40
40
  /**
41
- * Shows a "required" validation message when the component is left empty.
41
+ * @deprecated Use `id` instead. This prop will be removed in a future version.
42
42
  */
43
- readonly required?: boolean;
43
+ readonly identifier?: string;
44
+ /**
45
+ * @deprecated Use `autoComplete` with string values instead. This prop will be removed in a future version.
46
+ */
47
+ readonly autocomplete?: never;
48
+ /**
49
+ * @deprecated Use `aria-label` instead. This prop will be removed in a future version.
50
+ */
51
+ readonly ariaLabel?: never;
44
52
  /**
45
- * Version 2 is highly experimental, avoid using it unless you have talked with Atlantis first.
53
+ * @deprecated Use `readOnly` instead. This prop will be removed in a future version.
46
54
  */
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;
55
+ readonly readonly?: never;
55
56
  }
56
57
  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
  };
@@ -115,7 +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
+ // Don't call blur handler when programmatically clearing
119
119
  onChange && onChange("");
120
120
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
121
121
  }
@@ -149,28 +149,27 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
149
149
  };
150
150
  }
151
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
-
166
- const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberInternal(_a, ref) {
152
+ const InputPhoneNumberRebuilt = React.forwardRef(
153
+ // eslint-disable-next-line max-statements
154
+ function InputPhoneNumberInternal(_a, ref) {
167
155
  var _b, _c, _d, _e;
168
156
  var { pattern = DEFAULT_PATTERN } = _a, props = tslib_es6.__rest(_a, ["pattern"]);
169
157
  const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React.useRef(null);
170
158
  const wrapperRef = React.useRef(null);
171
- const { inputStyle } = FormField.useFormFieldWrapperStyles(Object.assign(Object.assign({}, props), { type: "tel" }));
159
+ const { inputStyle } = FormField.useFormFieldWrapperStyles({
160
+ size: props.size,
161
+ align: props.align,
162
+ placeholder: props.placeholder,
163
+ value: props.value,
164
+ invalid: props.invalid,
165
+ error: props.error,
166
+ maxLength: undefined, // v2: maxLength not used for width styling
167
+ disabled: props.disabled,
168
+ inline: props.inline,
169
+ type: "tel",
170
+ });
172
171
  const generatedId = React.useId();
173
- const id = props.id || generatedId;
172
+ const id = props.identifier || props.id || generatedId;
174
173
  const { name } = FormField.useAtlantisFormFieldName({
175
174
  nameProp: props.name,
176
175
  id: id,
@@ -188,25 +187,14 @@ const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberIntern
188
187
  onEnter: props.onEnter,
189
188
  inputRef: inputPhoneNumberRef,
190
189
  });
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, {
190
+ const descriptionIdentifier = `descriptionUUID--${id}`;
191
+ const hasDescription = props.description && !props.inline;
192
+ const isInvalid = Boolean(props["aria-invalid"] || props.error || props.invalid);
193
+ const effectiveReadOnly = props.readonly || props.readOnly;
194
+ 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: effectiveReadOnly, loading: props.loading },
195
+ React.createElement("input", { id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(inputStyle, {
208
196
  [styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
209
- }), value: formattedValue })),
197
+ }), value: formattedValue, disabled: props.disabled, readOnly: effectiveReadOnly, required: props.required, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props["aria-label"], "aria-describedby": hasDescription ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown }),
210
198
  React.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
211
199
  React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
212
200
  });
@@ -113,7 +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
+ // Don't call blur handler when programmatically clearing
117
117
  onChange && onChange("");
118
118
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
119
119
  }
@@ -147,28 +147,27 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
147
147
  };
148
148
  }
149
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
-
164
- const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a, ref) {
150
+ const InputPhoneNumberRebuilt = forwardRef(
151
+ // eslint-disable-next-line max-statements
152
+ function InputPhoneNumberInternal(_a, ref) {
165
153
  var _b, _c, _d, _e;
166
154
  var { pattern = DEFAULT_PATTERN } = _a, props = __rest(_a, ["pattern"]);
167
155
  const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React__default.useRef(null);
168
156
  const wrapperRef = React__default.useRef(null);
169
- const { inputStyle } = useFormFieldWrapperStyles(Object.assign(Object.assign({}, props), { type: "tel" }));
157
+ const { inputStyle } = useFormFieldWrapperStyles({
158
+ size: props.size,
159
+ align: props.align,
160
+ placeholder: props.placeholder,
161
+ value: props.value,
162
+ invalid: props.invalid,
163
+ error: props.error,
164
+ maxLength: undefined, // v2: maxLength not used for width styling
165
+ disabled: props.disabled,
166
+ inline: props.inline,
167
+ type: "tel",
168
+ });
170
169
  const generatedId = useId();
171
- const id = props.id || generatedId;
170
+ const id = props.identifier || props.id || generatedId;
172
171
  const { name } = useAtlantisFormFieldName({
173
172
  nameProp: props.name,
174
173
  id: id,
@@ -186,25 +185,14 @@ const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a,
186
185
  onEnter: props.onEnter,
187
186
  inputRef: inputPhoneNumberRef,
188
187
  });
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, {
188
+ const descriptionIdentifier = `descriptionUUID--${id}`;
189
+ const hasDescription = props.description && !props.inline;
190
+ const isInvalid = Boolean(props["aria-invalid"] || props.error || props.invalid);
191
+ const effectiveReadOnly = props.readonly || props.readOnly;
192
+ 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: effectiveReadOnly, loading: props.loading },
193
+ React__default.createElement("input", { id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(inputStyle, {
206
194
  [styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
207
- }), value: formattedValue })),
195
+ }), value: formattedValue, disabled: props.disabled, readOnly: effectiveReadOnly, required: props.required, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props["aria-label"], "aria-describedby": hasDescription ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown }),
208
196
  React__default.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
209
197
  React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
210
198
  });
@@ -24,11 +24,11 @@ export declare const InputText: React.ForwardRefExoticComponent<({
24
24
  readonly toolbar?: React.ReactNode;
25
25
  readonly defaultValue?: (string | Date) | undefined;
26
26
  readonly prefix?: import("../FormField").Affix | undefined;
27
+ readonly maxLength?: number | undefined;
27
28
  readonly autofocus?: boolean | undefined;
28
29
  readonly autocomplete?: (boolean | import("../FormField").AutocompleteTypes) | undefined;
29
30
  inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
30
31
  readonly keyboard?: ("numeric" | "decimal") | undefined;
31
- readonly maxLength?: number | undefined;
32
32
  readonly suffix?: import("ts-xor").XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
33
33
  onEnter?: ((event: React.KeyboardEvent) => void) | undefined;
34
34
  readonly readonly?: boolean | undefined;
@@ -58,11 +58,11 @@ export declare const InputText: React.ForwardRefExoticComponent<({
58
58
  readonly toolbar?: React.ReactNode;
59
59
  readonly defaultValue?: (string | Date) | undefined;
60
60
  readonly prefix?: import("../FormField").Affix | undefined;
61
+ readonly maxLength?: number | undefined;
61
62
  readonly autofocus?: boolean | undefined;
62
63
  readonly autocomplete?: (boolean | import("../FormField").AutocompleteTypes) | undefined;
63
64
  inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
64
65
  readonly keyboard?: ("numeric" | "decimal") | undefined;
65
- readonly maxLength?: number | undefined;
66
66
  readonly suffix?: import("ts-xor").XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
67
67
  onEnter?: ((event: React.KeyboardEvent) => void) | undefined;
68
68
  readonly readonly?: boolean | undefined;
@@ -1,6 +1,5 @@
1
- import type { Clearable } from "@jobber/hooks";
2
1
  import type { XOR } from "ts-xor";
3
- import type { AutocompleteTypes, CommonFormFieldProps, FormFieldProps, FormFieldTypes } from "../FormField";
2
+ import type { CommonFormFieldProps, FocusEvents, FormFieldProps, FormFieldTypes, HTMLInputBaseProps, KeyboardEvents, RebuiltInputCommonProps } from "../FormField";
4
3
  export interface RowRange {
5
4
  min: number;
6
5
  max: number;
@@ -10,15 +9,7 @@ export type InputTextVersion = 1 | 2 | undefined;
10
9
  * Experimental version 2 of the InputText component.
11
10
  * Do not use unless you have talked with Atlantis first.
12
11
  */
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;
12
+ export interface InputTextRebuiltProps extends HTMLInputBaseProps, FocusEvents<HTMLInputElement | HTMLTextAreaElement>, KeyboardEvents<HTMLInputElement | HTMLTextAreaElement>, RebuiltInputCommonProps {
22
13
  /**
23
14
  * Use this when you're expecting a long answer.
24
15
  */
@@ -30,24 +21,48 @@ export interface InputTextRebuiltProps extends Omit<React.InputHTMLAttributes<HT
30
21
  * maximum number of visible rows.
31
22
  */
32
23
  readonly rows?: number | RowRange;
24
+ /**
25
+ * Determines what kind of form field should the component give you.
26
+ */
33
27
  readonly type?: FormFieldTypes;
34
28
  /**
35
- * Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
29
+ * Toolbar to render content below the input.
30
+ */
31
+ readonly toolbar?: React.ReactNode;
32
+ /**
33
+ * Determines the visibility of the toolbar.
34
+ */
35
+ readonly toolbarVisibility?: "always" | "while-editing";
36
+ /**
37
+ * The current value of the input.
38
+ */
39
+ readonly value: string;
40
+ /**
41
+ * Custom onChange handler that provides the new value as the first argument.
36
42
  */
37
- readonly version: 2;
38
43
  readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
44
+ /**
45
+ * A callback to handle "Enter" keypress. This will only run
46
+ * if Enter is the only key. Will not run if Shift or Control
47
+ * are being held.
48
+ */
39
49
  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"];
50
+ /**
51
+ * @deprecated Use `id` instead. This prop will be removed in a future version.
52
+ */
53
+ readonly identifier?: string;
54
+ /**
55
+ * @deprecated Use `autoComplete` with string values instead. This prop will be removed in a future version.
56
+ */
57
+ readonly autocomplete?: never;
58
+ /**
59
+ * @deprecated Use `aria-label` instead. This prop will be removed in a future version.
60
+ */
61
+ readonly ariaLabel?: never;
62
+ /**
63
+ * @deprecated Use `readOnly` instead. This prop will be removed in a future version.
64
+ */
65
+ readonly readonly?: never;
51
66
  }
52
67
  interface BaseProps extends CommonFormFieldProps, Pick<FormFieldProps, "autofocus" | "maxLength" | "readonly" | "autocomplete" | "keyboard" | "onEnter" | "onFocus" | "onBlur" | "onChange" | "inputRef" | "validations" | "defaultValue" | "prefix" | "suffix" | "toolbar" | "toolbarVisibility" | "version"> {
53
68
  multiline?: boolean;