@jobber/components 6.101.4 → 6.101.5-JOB-140604-4487daa.55

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 (177) hide show
  1. package/dist/Autocomplete/Autocomplete.types.d.ts +11 -51
  2. package/dist/Autocomplete/components/MenuList.d.ts +3 -2
  3. package/dist/Autocomplete/components/PersistentRegion.d.ts +3 -2
  4. package/dist/Autocomplete/hooks/useAutocompleteListNav.d.ts +3 -2
  5. package/dist/Autocomplete/index.cjs +95 -51
  6. package/dist/Autocomplete/index.mjs +97 -53
  7. package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +14 -1
  8. package/dist/Autocomplete/useAutocomplete.d.ts +4 -3
  9. package/dist/Autocomplete/utils/interactionUtils.d.ts +14 -0
  10. package/dist/Card-cjs.js +1 -1
  11. package/dist/Card-es.js +1 -1
  12. package/dist/Checkbox/Checkbox.rebuilt.d.ts +2 -2
  13. package/dist/Checkbox/Checkbox.types.d.ts +24 -18
  14. package/dist/Checkbox/index.cjs +9 -2
  15. package/dist/Checkbox/index.mjs +9 -2
  16. package/dist/Chip/Chip.d.ts +1 -2
  17. package/dist/Chip/hooks/useChildComponent.d.ts +4 -3
  18. package/dist/Chip/index.cjs +1 -1
  19. package/dist/Chip-cjs.js +5 -4
  20. package/dist/Chip-es.js +5 -4
  21. package/dist/ChipDismissible-cjs.js +4 -4
  22. package/dist/ChipDismissible-es.js +5 -5
  23. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
  24. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
  25. package/dist/Chips/InternalChipDismissible/hooks/useInView.d.ts +1 -1
  26. package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissibleInput.d.ts +1 -1
  27. package/dist/Chips/InternalChipDismissible/hooks/useScrollToActive.d.ts +1 -1
  28. package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
  29. package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
  30. package/dist/Chips/index.cjs +2 -2
  31. package/dist/Chips/index.mjs +2 -2
  32. package/dist/Combobox/Combobox.d.ts +2 -1
  33. package/dist/Combobox/Combobox.types.d.ts +2 -2
  34. package/dist/Combobox/ComboboxProvider.d.ts +3 -3
  35. package/dist/Combobox/components/ComboboxActivator/ComboboxActivator.d.ts +1 -1
  36. package/dist/Combobox/components/ComboboxContent/ComboboxContent.d.ts +2 -1
  37. package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/ComboboxContentHeader.d.ts +2 -1
  38. package/dist/Combobox/components/ComboboxContent/ComboboxContentList/ComboboxContentList.d.ts +2 -1
  39. package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/ComboboxContentSearch.d.ts +2 -1
  40. package/dist/Combobox/hooks/useCombobox.d.ts +1 -1
  41. package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +2 -2
  42. package/dist/Combobox/hooks/useComboboxContent.d.ts +2 -1
  43. package/dist/Combobox/hooks/useMakeComboboxHandlers.d.ts +1 -1
  44. package/dist/ComboboxActivator-cjs.js +2 -2
  45. package/dist/ComboboxActivator-es.js +3 -3
  46. package/dist/ComboboxTrigger-cjs.js +1 -1
  47. package/dist/ComboboxTrigger-es.js +2 -2
  48. package/dist/DataList/DataList.types.d.ts +2 -2
  49. package/dist/DataList/DataList.utils.d.ts +2 -2
  50. package/dist/DataList/components/DataListHeader/index.cjs +1 -0
  51. package/dist/DataList/components/DataListHeader/index.mjs +1 -0
  52. package/dist/DataList/components/DataListHeaderTile/components/DataListSortingOptions.d.ts +2 -2
  53. package/dist/DataList/components/DataListItem/DataListItemInternal.d.ts +2 -2
  54. package/dist/DataList/components/DataListItem/index.cjs +1 -0
  55. package/dist/DataList/components/DataListItem/index.mjs +1 -0
  56. package/dist/DataList/components/DataListItems/index.cjs +1 -0
  57. package/dist/DataList/components/DataListItems/index.mjs +1 -0
  58. package/dist/DataList/components/DataListLayout/index.cjs +1 -0
  59. package/dist/DataList/components/DataListLayout/index.mjs +1 -0
  60. package/dist/DataList/components/DataListSearch/index.cjs +2 -12
  61. package/dist/DataList/components/DataListSearch/index.mjs +2 -12
  62. package/dist/DataList/hooks/useGetItemActions.d.ts +1 -1
  63. package/dist/DataList/index.cjs +1 -8
  64. package/dist/DataList/index.mjs +1 -8
  65. package/dist/DataListActions-cjs.js +4 -2
  66. package/dist/DataListActions-es.js +4 -2
  67. package/dist/DataListItem-cjs.js +8 -7
  68. package/dist/DataListItem-es.js +9 -8
  69. package/dist/DataListSort-cjs.js +1 -1
  70. package/dist/DataListSort-es.js +2 -2
  71. package/dist/DataTable/SortIcon.d.ts +2 -1
  72. package/dist/DataTable/components/DataTableSortableHeader.d.ts +1 -1
  73. package/dist/DataTable/index.cjs +3 -2
  74. package/dist/DataTable/index.mjs +3 -2
  75. package/dist/DatePicker/DatePicker.d.ts +5 -1
  76. package/dist/DatePicker/index.cjs +2 -2
  77. package/dist/DatePicker/index.mjs +2 -2
  78. package/dist/DatePicker/useFocusOnSelectedDate.d.ts +1 -2
  79. package/dist/DatePicker-cjs.js +4 -2
  80. package/dist/DatePicker-es.js +5 -3
  81. package/dist/FormField/FormFieldAffix.d.ts +2 -2
  82. package/dist/FormField/FormFieldTypes.d.ts +3 -5
  83. package/dist/FormField/FormFieldWrapper.d.ts +5 -1
  84. package/dist/FormField/hooks/useFormFieldFocus.d.ts +1 -1
  85. package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +9 -4
  86. package/dist/FormField-cjs.js +35 -31
  87. package/dist/FormField-es.js +35 -31
  88. package/dist/InputDate/InputDate.types.d.ts +12 -7
  89. package/dist/InputDate/index.cjs +35 -12
  90. package/dist/InputDate/index.mjs +35 -12
  91. package/dist/InputDate/useInputDateActivatorActions.d.ts +4 -8
  92. package/dist/InputEmail/InputEmail.types.d.ts +10 -20
  93. package/dist/InputEmail/hooks/useInputEmailActions.d.ts +10 -4
  94. package/dist/InputEmail/index.cjs +43 -60
  95. package/dist/InputEmail/index.mjs +44 -61
  96. package/dist/InputFile-cjs.js +5 -2
  97. package/dist/InputFile-es.js +5 -2
  98. package/dist/InputGroup-cjs.js +5 -2
  99. package/dist/InputGroup-es.js +5 -2
  100. package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +7 -15
  101. package/dist/InputNumber/index.cjs +7 -5
  102. package/dist/InputNumber/index.mjs +7 -5
  103. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +12 -28
  104. package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +9 -4
  105. package/dist/InputPhoneNumber/index.cjs +37 -36
  106. package/dist/InputPhoneNumber/index.mjs +38 -37
  107. package/dist/InputText/InputText.d.ts +2 -2
  108. package/dist/InputText/InputText.types.d.ts +30 -25
  109. package/dist/InputText/index.cjs +54 -62
  110. package/dist/InputText/index.mjs +55 -63
  111. package/dist/InputText/useInputTextActions.d.ts +11 -5
  112. package/dist/InputText/useTextAreaResize.d.ts +2 -2
  113. package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
  114. package/dist/InputTime/InputTime.types.d.ts +13 -4
  115. package/dist/InputTime/hooks/useInputTimeActions.d.ts +21 -0
  116. package/dist/InputTime/index.cjs +90 -30
  117. package/dist/InputTime/index.mjs +93 -33
  118. package/dist/InternalChipDismissible-cjs.js +3 -3
  119. package/dist/InternalChipDismissible-es.js +4 -4
  120. package/dist/List/index.cjs +2 -2
  121. package/dist/List/index.mjs +2 -2
  122. package/dist/Menu/Menu.d.ts +2 -4
  123. package/dist/Menu/Menu.types.d.ts +21 -5
  124. package/dist/Menu-cjs.js +9 -9
  125. package/dist/Menu-es.js +9 -9
  126. package/dist/Modal/Modal.types.d.ts +3 -3
  127. package/dist/Modal/ModalContext.rebuilt.d.ts +2 -2
  128. package/dist/MultiSelect/DropDownMenu.d.ts +1 -1
  129. package/dist/MultiSelect/index.cjs +1 -0
  130. package/dist/MultiSelect/index.mjs +1 -0
  131. package/dist/MultiSelect-cjs.js +13 -7
  132. package/dist/MultiSelect-es.js +13 -7
  133. package/dist/RadioGroup/RadioGroup.d.ts +2 -1
  134. package/dist/RadioGroup/RadioOption.d.ts +1 -1
  135. package/dist/RecurringSelect/index.cjs +3 -2
  136. package/dist/RecurringSelect/index.mjs +3 -2
  137. package/dist/Select/Select.types.d.ts +7 -3
  138. package/dist/Select/hooks/useSelectActions.d.ts +5 -5
  139. package/dist/Select/index.cjs +27 -42
  140. package/dist/Select/index.mjs +29 -44
  141. package/dist/StatusLabel/StatusLabel.d.ts +2 -1
  142. package/dist/Tabs/hooks/useTabsOverflow.d.ts +2 -2
  143. package/dist/Tabs-cjs.js +4 -2
  144. package/dist/Tabs-es.js +5 -3
  145. package/dist/Tooltip/useTooltipPositioning.d.ts +1 -1
  146. package/dist/_baseEach-cjs.js +12 -12
  147. package/dist/_baseEach-es.js +1 -1
  148. package/dist/_baseFlatten-cjs.js +2 -2
  149. package/dist/_baseFlatten-es.js +1 -1
  150. package/dist/{_baseGet-cjs.js → _getAllKeys-cjs.js} +181 -181
  151. package/dist/{_baseGet-es.js → _getAllKeys-es.js} +182 -182
  152. package/dist/debounce-es.js +1 -1
  153. package/dist/filterDataAttributes-cjs.js +26 -0
  154. package/dist/filterDataAttributes-es.js +24 -0
  155. package/dist/floating-ui.react-cjs.js +115 -0
  156. package/dist/floating-ui.react-es.js +115 -1
  157. package/dist/helpers-cjs.js +1 -1
  158. package/dist/helpers-es.js +1 -1
  159. package/dist/index.cjs +4 -3
  160. package/dist/index.mjs +3 -2
  161. package/dist/omit-cjs.js +14 -14
  162. package/dist/omit-es.js +1 -1
  163. package/dist/sharedHelpers/filterDataAttributes.d.ts +17 -0
  164. package/dist/sharedHelpers/types.d.ts +231 -0
  165. package/dist/showToast-cjs.js +2 -2
  166. package/dist/showToast-es.js +2 -2
  167. package/dist/styles.css +32 -23
  168. package/dist/useChildComponent-cjs.js +1 -1
  169. package/dist/useChildComponent-es.js +1 -1
  170. package/dist/useScrollToActive-cjs.js +3 -3
  171. package/dist/useScrollToActive-es.js +2 -2
  172. package/dist/utils/mergeRefs.d.ts +2 -2
  173. package/package.json +2 -2
  174. package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +0 -32
  175. package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +0 -71
  176. package/dist/InputText/useInputTextFormField.d.ts +0 -352
  177. package/dist/Select/hooks/useSelectFormField.d.ts +0 -34
@@ -1,6 +1,6 @@
1
- import type { Clearable } from "@jobber/hooks";
2
1
  import type { InputMaskProps } from "./InputMask";
3
2
  import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
3
+ import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, MouseEvents, 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,20 +16,19 @@ export interface InputPhoneNumberLegacyProps extends Omit<CommonFormFieldProps,
16
16
  */
17
17
  readonly required?: boolean;
18
18
  }
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;
19
+ export interface InputPhoneNumberRebuiltProps extends Omit<HTMLInputBaseProps, "type" | "maxLength" | "minLength">, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, MouseEvents<HTMLInputElement>, RebuiltInputCommonProps {
20
+ /**
21
+ * The current value of the input.
22
+ */
28
23
  readonly value: string;
24
+ /**
25
+ * Custom onChange handler that provides the new value as the first argument.
26
+ */
29
27
  readonly onChange: (value: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
30
- readonly onBlur?: (event?: React.FocusEvent<HTMLInputElement>) => void;
31
- readonly onEnter?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
32
- readonly onFocus?: (event?: React.FocusEvent<HTMLInputElement>) => void;
28
+ /**
29
+ * @deprecated Use `onKeyDown` or `onKeyUp` instead.
30
+ */
31
+ readonly onEnter?: FormFieldProps["onEnter"];
33
32
  /**
34
33
  * A pattern to specify the format to display the phone number in.
35
34
  * For example if you want to display the format for [Denmark](https://en.wikipedia.org/wiki/National_conventions_for_writing_telephone_numbers#Denmark)
@@ -37,20 +36,5 @@ export interface InputPhoneNumberRebuiltProps extends Omit<React.InputHTMLAttrib
37
36
  * @default "(***) ***-****"
38
37
  */
39
38
  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;
55
39
  }
56
40
  export declare const DEFAULT_PATTERN = "(***) ***-****";
@@ -1,16 +1,21 @@
1
- import type { ChangeEvent, FocusEvent, KeyboardEvent } from "react";
1
+ import type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent, PointerEvent } from "react";
2
2
  import type { InputPhoneNumberRebuiltProps } from "../InputPhoneNumber.types";
3
- export interface useInputPhoneActionsProps extends Pick<InputPhoneNumberRebuiltProps, "onChange" | "onEnter" | "onFocus" | "onBlur" | "onKeyDown"> {
3
+ export interface useInputPhoneActionsProps extends Pick<InputPhoneNumberRebuiltProps, "onChange" | "onEnter" | "onFocus" | "onBlur" | "onKeyDown" | "onClick" | "onMouseDown" | "onMouseUp" | "onPointerDown" | "onPointerUp"> {
4
4
  inputRef?: React.RefObject<HTMLInputElement>;
5
5
  }
6
6
  /**
7
7
  * Combines the actions on the InputPhoneNumber such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputPhoneNumber.
8
8
  * 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.
9
9
  */
10
- export declare function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }: useInputPhoneActionsProps): {
10
+ export declare function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }: useInputPhoneActionsProps): {
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
+ handleClick: (event: MouseEvent<HTMLInputElement>) => void;
17
+ handleMouseDown: (event: MouseEvent<HTMLInputElement>) => void;
18
+ handleMouseUp: (event: MouseEvent<HTMLInputElement>) => void;
19
+ handlePointerDown: (event: PointerEvent<HTMLInputElement>) => void;
20
+ handlePointerUp: (event: PointerEvent<HTMLInputElement>) => void;
16
21
  };
@@ -7,6 +7,7 @@ var FormField = require('../FormField-cjs.js');
7
7
  var reactHookForm = require('react-hook-form');
8
8
  require('../Button-cjs.js');
9
9
  require('@jobber/design');
10
+ var filterDataAttributes = require('../filterDataAttributes-cjs.js');
10
11
  require('@jobber/hooks');
11
12
  require('framer-motion');
12
13
  require('../Icon-cjs.js');
@@ -112,10 +113,9 @@ const DEFAULT_PATTERN = "(***) ***-****";
112
113
  * Combines the actions on the InputPhoneNumber such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputPhoneNumber.
113
114
  * 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.
114
115
  */
115
- function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }) {
116
+ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
116
117
  function handleClear() {
117
118
  var _a;
118
- handleBlur();
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
  }
@@ -140,35 +140,40 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
140
140
  function handleBlur(event) {
141
141
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
142
142
  }
143
+ function handleClick(event) {
144
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
145
+ }
146
+ function handleMouseDown(event) {
147
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
148
+ }
149
+ function handleMouseUp(event) {
150
+ onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
151
+ }
152
+ function handlePointerDown(event) {
153
+ onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
154
+ }
155
+ function handlePointerUp(event) {
156
+ onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
157
+ }
143
158
  return {
144
159
  handleClear,
145
160
  handleChange,
146
161
  handleFocus,
147
162
  handleBlur,
148
163
  handleKeyDown,
164
+ handleClick,
165
+ handleMouseDown,
166
+ handleMouseUp,
167
+ handlePointerDown,
168
+ handlePointerUp,
149
169
  };
150
170
  }
151
171
 
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
172
  const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberInternal(_a, ref) {
167
173
  var _b, _c, _d, _e;
168
174
  var { pattern = DEFAULT_PATTERN } = _a, props = tslib_es6.__rest(_a, ["pattern"]);
169
175
  const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React.useRef(null);
170
176
  const wrapperRef = React.useRef(null);
171
- const { inputStyle } = FormField.useFormFieldWrapperStyles(Object.assign(Object.assign({}, props), { type: "tel" }));
172
177
  const generatedId = React.useId();
173
178
  const id = props.id || generatedId;
174
179
  const { name } = FormField.useAtlantisFormFieldName({
@@ -181,32 +186,28 @@ const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberIntern
181
186
  strict: false,
182
187
  onChange: props.onChange,
183
188
  });
184
- const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, } = useInputPhoneActions({
189
+ const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputPhoneActions({
185
190
  onChange: maskedOnChange,
186
191
  onBlur: props.onBlur,
187
192
  onFocus: props.onFocus,
188
193
  onEnter: props.onEnter,
194
+ onKeyDown: props.onKeyDown,
195
+ onClick: props.onClick,
196
+ onMouseDown: props.onMouseDown,
197
+ onMouseUp: props.onMouseUp,
198
+ onPointerDown: props.onPointerDown,
199
+ onPointerUp: props.onPointerUp,
189
200
  inputRef: inputPhoneNumberRef,
190
201
  });
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, {
202
+ const descriptionIdentifier = `descriptionUUID--${id}`, descriptionVisible = props.description && !props.inline;
203
+ const isInvalid = Boolean(props.error || props.invalid);
204
+ const dataAttrs = filterDataAttributes.filterDataAttributes(props);
205
+ 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 },
206
+ React.createElement("input", Object.assign({ id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(FormField.formFieldStyles.input, {
208
207
  [styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
209
- }), value: formattedValue })),
208
+ }), 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["aria-label"], "aria-describedby": descriptionVisible
209
+ ? descriptionIdentifier
210
+ : 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, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp }, dataAttrs)),
210
211
  React.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
211
212
  React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
212
213
  });
@@ -1,10 +1,11 @@
1
1
  import React__default, { useState, useMemo, useCallback, useEffect, cloneElement, forwardRef, useId } from 'react';
2
2
  import { _ as __rest } from '../tslib.es6-es.js';
3
3
  import classnames from 'classnames';
4
- import { j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, f as FormFieldWrapper, l as FormFieldPostFix, k as FormField } from '../FormField-es.js';
4
+ import { b as useAtlantisFormFieldName, f as FormFieldWrapper, l as formFieldStyles, m as FormFieldPostFix, k as FormField } from '../FormField-es.js';
5
5
  import { useFormContext, useForm } from 'react-hook-form';
6
6
  import '../Button-es.js';
7
7
  import '@jobber/design';
8
+ import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
8
9
  import '@jobber/hooks';
9
10
  import 'framer-motion';
10
11
  import '../Icon-es.js';
@@ -110,10 +111,9 @@ const DEFAULT_PATTERN = "(***) ***-****";
110
111
  * Combines the actions on the InputPhoneNumber such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputPhoneNumber.
111
112
  * 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.
112
113
  */
113
- function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, }) {
114
+ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
114
115
  function handleClear() {
115
116
  var _a;
116
- handleBlur();
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
  }
@@ -138,35 +138,40 @@ function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown,
138
138
  function handleBlur(event) {
139
139
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
140
140
  }
141
+ function handleClick(event) {
142
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
143
+ }
144
+ function handleMouseDown(event) {
145
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
146
+ }
147
+ function handleMouseUp(event) {
148
+ onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
149
+ }
150
+ function handlePointerDown(event) {
151
+ onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
152
+ }
153
+ function handlePointerUp(event) {
154
+ onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
155
+ }
141
156
  return {
142
157
  handleClear,
143
158
  handleChange,
144
159
  handleFocus,
145
160
  handleBlur,
146
161
  handleKeyDown,
162
+ handleClick,
163
+ handleMouseDown,
164
+ handleMouseUp,
165
+ handlePointerDown,
166
+ handlePointerUp,
147
167
  };
148
168
  }
149
169
 
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
170
  const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a, ref) {
165
171
  var _b, _c, _d, _e;
166
172
  var { pattern = DEFAULT_PATTERN } = _a, props = __rest(_a, ["pattern"]);
167
173
  const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React__default.useRef(null);
168
174
  const wrapperRef = React__default.useRef(null);
169
- const { inputStyle } = useFormFieldWrapperStyles(Object.assign(Object.assign({}, props), { type: "tel" }));
170
175
  const generatedId = useId();
171
176
  const id = props.id || generatedId;
172
177
  const { name } = useAtlantisFormFieldName({
@@ -179,32 +184,28 @@ const InputPhoneNumberRebuilt = forwardRef(function InputPhoneNumberInternal(_a,
179
184
  strict: false,
180
185
  onChange: props.onChange,
181
186
  });
182
- const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, } = useInputPhoneActions({
187
+ const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputPhoneActions({
183
188
  onChange: maskedOnChange,
184
189
  onBlur: props.onBlur,
185
190
  onFocus: props.onFocus,
186
191
  onEnter: props.onEnter,
192
+ onKeyDown: props.onKeyDown,
193
+ onClick: props.onClick,
194
+ onMouseDown: props.onMouseDown,
195
+ onMouseUp: props.onMouseUp,
196
+ onPointerDown: props.onPointerDown,
197
+ onPointerUp: props.onPointerUp,
187
198
  inputRef: inputPhoneNumberRef,
188
199
  });
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, {
200
+ const descriptionIdentifier = `descriptionUUID--${id}`, descriptionVisible = props.description && !props.inline;
201
+ const isInvalid = Boolean(props.error || props.invalid);
202
+ const dataAttrs = filterDataAttributes(props);
203
+ 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 },
204
+ React__default.createElement("input", Object.assign({ id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(formFieldStyles.input, {
206
205
  [styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
207
- }), value: formattedValue })),
206
+ }), 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["aria-label"], "aria-describedby": descriptionVisible
207
+ ? descriptionIdentifier
208
+ : 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, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp }, dataAttrs)),
208
209
  React__default.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
209
210
  React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
210
211
  });
@@ -26,7 +26,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
26
26
  readonly prefix?: import("../FormField").Affix | undefined;
27
27
  readonly autofocus?: boolean | undefined;
28
28
  readonly autocomplete?: (boolean | import("../FormField").AutocompleteTypes) | undefined;
29
- inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
29
+ inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined;
30
30
  readonly keyboard?: ("numeric" | "decimal") | undefined;
31
31
  readonly maxLength?: number | undefined;
32
32
  readonly suffix?: import("ts-xor").XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
@@ -60,7 +60,7 @@ export declare const InputText: React.ForwardRefExoticComponent<({
60
60
  readonly prefix?: import("../FormField").Affix | undefined;
61
61
  readonly autofocus?: boolean | undefined;
62
62
  readonly autocomplete?: (boolean | import("../FormField").AutocompleteTypes) | undefined;
63
- inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement> | undefined;
63
+ inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined;
64
64
  readonly keyboard?: ("numeric" | "decimal") | undefined;
65
65
  readonly maxLength?: number | undefined;
66
66
  readonly suffix?: import("ts-xor").XOR<import("../FormField").Affix, import("../FormField").Suffix> | undefined;
@@ -1,24 +1,27 @@
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, FormFieldProps } from "../FormField";
3
+ import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, MouseEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
4
4
  export interface RowRange {
5
5
  min: number;
6
6
  max: number;
7
7
  }
8
+ /**
9
+ * Character length constraint for inputs.
10
+ * Only extend this for text-based inputs where character limits make sense.
11
+ */
12
+ interface InputLengthConstraint {
13
+ /**
14
+ * The maximum number of characters supported by the input.
15
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefmaxlength}
16
+ */
17
+ readonly maxLength?: number;
18
+ }
8
19
  export type InputTextVersion = 1 | 2 | undefined;
9
20
  /**
10
21
  * Experimental version 2 of the InputText component.
11
22
  * Do not use unless you have talked with Atlantis first.
12
23
  */
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;
24
+ export interface InputTextRebuiltProps extends HTMLInputBaseProps, MouseEvents<HTMLInputElement | HTMLTextAreaElement>, FocusEvents<HTMLInputElement | HTMLTextAreaElement>, KeyboardEvents<HTMLInputElement | HTMLTextAreaElement>, RebuiltInputCommonProps, InputLengthConstraint {
22
25
  /**
23
26
  * Use this when you're expecting a long answer.
24
27
  */
@@ -30,24 +33,26 @@ export interface InputTextRebuiltProps extends Omit<React.InputHTMLAttributes<HT
30
33
  * maximum number of visible rows.
31
34
  */
32
35
  readonly rows?: number | RowRange;
33
- readonly type?: FormFieldTypes;
34
36
  /**
35
- * Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
37
+ * Toolbar to render content below the input.
36
38
  */
37
- readonly version: 2;
38
- readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
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
39
  readonly toolbar?: FormFieldProps["toolbar"];
40
+ /**
41
+ * Determines the visibility of the toolbar.
42
+ */
47
43
  readonly toolbarVisibility?: FormFieldProps["toolbarVisibility"];
48
- readonly prefix?: FormFieldProps["prefix"];
49
- readonly suffix?: FormFieldProps["suffix"];
50
- readonly description?: FormFieldProps["description"];
44
+ /**
45
+ * The current value of the input.
46
+ */
47
+ readonly value: string;
48
+ /**
49
+ * Custom onChange handler that provides the new value as the first argument.
50
+ */
51
+ readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
52
+ /**
53
+ * @deprecated Use `onKeyDown` or `onKeyUp` instead.
54
+ */
55
+ readonly onEnter?: FormFieldProps["onEnter"];
51
56
  }
52
57
  interface BaseProps extends CommonFormFieldProps, Pick<FormFieldProps, "autofocus" | "maxLength" | "readonly" | "autocomplete" | "keyboard" | "onEnter" | "onFocus" | "onBlur" | "onChange" | "inputRef" | "validations" | "defaultValue" | "prefix" | "suffix" | "toolbar" | "toolbarVisibility" | "version"> {
53
58
  multiline?: boolean;
@@ -4,12 +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
- var tslib_es6 = require('../tslib.es6-cjs.js');
7
+ 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
+ var filterDataAttributes = require('../filterDataAttributes-cjs.js');
13
13
  require('../Icon-cjs.js');
14
14
  require('../Text-cjs.js');
15
15
  require('../Typography-cjs.js');
@@ -17,17 +17,6 @@ require('../useFormFieldFocus-cjs.js');
17
17
  require('../InputValidation-cjs.js');
18
18
  require('../Spinner-cjs.js');
19
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');
31
20
 
32
21
  /**
33
22
  * Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
@@ -159,10 +148,9 @@ function insertAtCursor(input, newText) {
159
148
  * Combines the actions on the InputText such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputText.
160
149
  * 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.
161
150
  */
162
- function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
151
+ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, onKeyUp, onMouseDown, onMouseUp, onPointerDown, onPointerUp, onClick, }) {
163
152
  function handleClear() {
164
153
  var _a;
165
- handleBlur();
166
154
  onChange && onChange("");
167
155
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
168
156
  }
@@ -181,38 +169,48 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
181
169
  event.preventDefault();
182
170
  onEnter && onEnter(event);
183
171
  }
172
+ function handleKeyUp(event) {
173
+ onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event);
174
+ }
184
175
  function handleFocus(event) {
185
176
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
186
177
  }
187
178
  function handleBlur(event) {
188
179
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
189
180
  }
181
+ function handleMouseDown(event) {
182
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
183
+ }
184
+ function handleMouseUp(event) {
185
+ onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
186
+ }
187
+ function handlePointerDown(event) {
188
+ onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
189
+ }
190
+ function handlePointerUp(event) {
191
+ onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
192
+ }
193
+ function handleClick(event) {
194
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
195
+ }
190
196
  return {
191
197
  handleClear,
192
198
  handleChange,
193
199
  handleKeyDown,
200
+ handleKeyUp,
194
201
  handleFocus,
195
202
  handleBlur,
203
+ handleMouseDown,
204
+ handleMouseUp,
205
+ handlePointerDown,
206
+ handlePointerUp,
207
+ handleClick,
196
208
  };
197
209
  }
198
210
 
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
-
211
- const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRefs) {
211
+ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRef) {
212
212
  var _a, _b, _c;
213
- const inputTextRef = React.useRef(null);
214
- const wrapperRef = React.useRef(null);
215
- const legacyPropHelper = Object.assign(Object.assign({}, props), { version: 1 });
213
+ const inputTextRef = React.useRef(null), wrapperRef = React.useRef(null);
216
214
  const id = useInputTextId(props);
217
215
  const { rowRange } = useTextAreaResize({
218
216
  rows: props.rows,
@@ -220,54 +218,48 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
220
218
  inputRef: inputTextRef,
221
219
  wrapperRef: wrapperRef,
222
220
  });
223
- const type = props.multiline ? "textarea" : "text";
224
- const { inputStyle } = FormField.useFormFieldWrapperStyles(legacyPropHelper);
225
221
  const { name } = FormField.useAtlantisFormFieldName({
226
222
  nameProp: props.name,
227
223
  id: id,
228
224
  });
229
- const { handleChange, handleBlur, handleFocus, handleKeyDown, handleClear } = useInputTextActions({
225
+ const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, handleClick, } = useInputTextActions({
230
226
  onChange: props.onChange,
231
227
  onBlur: props.onBlur,
232
228
  onFocus: props.onFocus,
229
+ onMouseDown: props.onMouseDown,
230
+ onMouseUp: props.onMouseUp,
231
+ onPointerDown: props.onPointerDown,
232
+ onPointerUp: props.onPointerUp,
233
+ onClick: props.onClick,
233
234
  onKeyDown: props.onKeyDown,
235
+ onKeyUp: props.onKeyUp,
234
236
  onEnter: props.onEnter,
235
237
  inputRef: inputTextRef,
236
238
  });
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,
250
- name,
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 },
239
+ const descriptionIdentifier = `descriptionUUID--${id}`;
240
+ const descriptionVisible = props.description && !props.inline;
241
+ const isInvalid = Boolean(props.error || props.invalid);
242
+ const dataAttrs = filterDataAttributes.filterDataAttributes(props);
243
+ // Shared props for both TextArea and TextInput
244
+ const commonInputProps = Object.assign({ id,
245
+ name, className: FormField.formFieldStyles.input, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, maxLength: props.maxLength, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
246
+ ? descriptionIdentifier
247
+ : 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: handleKeyUp, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onClick: handleClick, ref: FormField.mergeRefs([inputRef, inputTextRef]) }, dataAttrs);
248
+ return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, 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, readonly: props.readOnly, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
256
249
  React.createElement(React.Fragment, null,
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
- React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
259
- props.children)));
250
+ props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
251
+ React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
260
252
  });
261
253
  function useInputTextId(props) {
262
254
  const generatedId = React.useId();
263
255
  return props.id || generatedId;
264
256
  }
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
- }
257
+ const TextArea = React.forwardRef(function TextArea(props, ref) {
258
+ return React.createElement("textarea", Object.assign({}, props, { ref: ref }));
259
+ });
260
+ const TextInput = React.forwardRef(function TextInput(props, ref) {
261
+ return React.createElement("input", Object.assign({}, props, { ref: ref }));
262
+ });
271
263
 
272
264
  function isNewInputTextProps(props) {
273
265
  return props.version === 2;