@jobber/components 6.104.0 → 6.105.0

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 (92) hide show
  1. package/dist/Autocomplete/Autocomplete.types.d.ts +9 -51
  2. package/dist/Autocomplete/index.cjs +10 -20
  3. package/dist/Autocomplete/index.mjs +10 -20
  4. package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +1 -1
  5. package/dist/Autocomplete/useAutocomplete.d.ts +2 -2
  6. package/dist/Checkbox/Checkbox.rebuilt.d.ts +2 -2
  7. package/dist/Checkbox/Checkbox.types.d.ts +24 -18
  8. package/dist/Checkbox/index.cjs +9 -2
  9. package/dist/Checkbox/index.mjs +9 -2
  10. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
  11. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
  12. package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
  13. package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
  14. package/dist/Chips/index.cjs +2 -2
  15. package/dist/Chips/index.mjs +2 -2
  16. package/dist/DataList/components/DataListHeader/index.cjs +1 -0
  17. package/dist/DataList/components/DataListHeader/index.mjs +1 -0
  18. package/dist/DataList/components/DataListItem/index.cjs +1 -0
  19. package/dist/DataList/components/DataListItem/index.mjs +1 -0
  20. package/dist/DataList/components/DataListItems/index.cjs +1 -0
  21. package/dist/DataList/components/DataListItems/index.mjs +1 -0
  22. package/dist/DataList/components/DataListLayout/index.cjs +1 -0
  23. package/dist/DataList/components/DataListLayout/index.mjs +1 -0
  24. package/dist/DataList/components/DataListSearch/index.cjs +2 -12
  25. package/dist/DataList/components/DataListSearch/index.mjs +2 -12
  26. package/dist/DataList/index.cjs +1 -8
  27. package/dist/DataList/index.mjs +1 -8
  28. package/dist/DataTable/index.cjs +3 -2
  29. package/dist/DataTable/index.mjs +3 -2
  30. package/dist/DatePicker/index.cjs +2 -2
  31. package/dist/DatePicker/index.mjs +2 -2
  32. package/dist/FormField/FormFieldTypes.d.ts +0 -2
  33. package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +7 -2
  34. package/dist/FormField-cjs.js +0 -1
  35. package/dist/FormField-es.js +1 -1
  36. package/dist/InputDate/InputDate.types.d.ts +12 -7
  37. package/dist/InputDate/index.cjs +6 -9
  38. package/dist/InputDate/index.mjs +6 -9
  39. package/dist/InputDate/useInputDateActivatorActions.d.ts +4 -8
  40. package/dist/InputEmail/InputEmail.types.d.ts +10 -20
  41. package/dist/InputEmail/hooks/useInputEmailActions.d.ts +10 -4
  42. package/dist/InputEmail/index.cjs +43 -49
  43. package/dist/InputEmail/index.mjs +43 -49
  44. package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +7 -15
  45. package/dist/InputNumber/index.cjs +6 -4
  46. package/dist/InputNumber/index.mjs +6 -4
  47. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +12 -28
  48. package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +9 -4
  49. package/dist/InputPhoneNumber/index.cjs +48 -36
  50. package/dist/InputPhoneNumber/index.mjs +48 -36
  51. package/dist/InputText/InputText.types.d.ts +31 -25
  52. package/dist/InputText/index.cjs +66 -62
  53. package/dist/InputText/index.mjs +67 -63
  54. package/dist/InputText/useInputTextActions.d.ts +10 -4
  55. package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
  56. package/dist/InputTime/InputTime.types.d.ts +13 -4
  57. package/dist/InputTime/hooks/useInputTimeActions.d.ts +21 -0
  58. package/dist/InputTime/index.cjs +91 -30
  59. package/dist/InputTime/index.mjs +94 -33
  60. package/dist/List/index.cjs +2 -2
  61. package/dist/List/index.mjs +2 -2
  62. package/dist/MultiSelect/index.cjs +1 -0
  63. package/dist/MultiSelect/index.mjs +1 -0
  64. package/dist/RecurringSelect/index.cjs +3 -2
  65. package/dist/RecurringSelect/index.mjs +3 -2
  66. package/dist/Select/Select.types.d.ts +7 -3
  67. package/dist/Select/hooks/useSelectActions.d.ts +5 -5
  68. package/dist/Select/index.cjs +27 -41
  69. package/dist/Select/index.mjs +29 -43
  70. package/dist/Tabs-es.js +1 -1
  71. package/dist/_baseEach-cjs.js +12 -12
  72. package/dist/_baseEach-es.js +1 -1
  73. package/dist/_baseFlatten-cjs.js +2 -2
  74. package/dist/_baseFlatten-es.js +1 -1
  75. package/dist/{_baseGet-cjs.js → _getAllKeys-cjs.js} +181 -181
  76. package/dist/{_baseGet-es.js → _getAllKeys-es.js} +182 -182
  77. package/dist/debounce-es.js +1 -1
  78. package/dist/filterDataAttributes-cjs.js +26 -0
  79. package/dist/filterDataAttributes-es.js +24 -0
  80. package/dist/index.cjs +3 -2
  81. package/dist/index.mjs +3 -2
  82. package/dist/omit-cjs.js +14 -14
  83. package/dist/omit-es.js +1 -1
  84. package/dist/sharedHelpers/filterDataAttributes.d.ts +17 -0
  85. package/dist/sharedHelpers/types.d.ts +231 -0
  86. package/dist/useScrollToActive-cjs.js +3 -3
  87. package/dist/useScrollToActive-es.js +2 -2
  88. package/package.json +2 -2
  89. package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +0 -32
  90. package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +0 -71
  91. package/dist/InputText/useInputTextFormField.d.ts +0 -366
  92. package/dist/Select/hooks/useSelectFormField.d.ts +0 -34
@@ -1,24 +1,28 @@
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
+ * Maximum character length for the input.
15
+ * Note: This affects both HTML validation AND visual width of the component.
16
+ * Future work will separate these concerns.
17
+ */
18
+ readonly maxLength?: number;
19
+ }
8
20
  export type InputTextVersion = 1 | 2 | undefined;
9
21
  /**
10
22
  * Experimental version 2 of the InputText component.
11
23
  * Do not use unless you have talked with Atlantis first.
12
24
  */
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;
25
+ export interface InputTextRebuiltProps extends HTMLInputBaseProps, MouseEvents<HTMLInputElement | HTMLTextAreaElement>, FocusEvents<HTMLInputElement | HTMLTextAreaElement>, KeyboardEvents<HTMLInputElement | HTMLTextAreaElement>, RebuiltInputCommonProps, InputLengthConstraint {
22
26
  /**
23
27
  * Use this when you're expecting a long answer.
24
28
  */
@@ -30,24 +34,26 @@ export interface InputTextRebuiltProps extends Omit<React.InputHTMLAttributes<HT
30
34
  * maximum number of visible rows.
31
35
  */
32
36
  readonly rows?: number | RowRange;
33
- readonly type?: FormFieldTypes;
34
37
  /**
35
- * Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
38
+ * Toolbar to render content below the input.
36
39
  */
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
40
  readonly toolbar?: FormFieldProps["toolbar"];
41
+ /**
42
+ * Determines the visibility of the toolbar.
43
+ */
47
44
  readonly toolbarVisibility?: FormFieldProps["toolbarVisibility"];
48
- readonly prefix?: FormFieldProps["prefix"];
49
- readonly suffix?: FormFieldProps["suffix"];
50
- readonly description?: FormFieldProps["description"];
45
+ /**
46
+ * The current value of the input.
47
+ */
48
+ readonly value: string;
49
+ /**
50
+ * Custom onChange handler that provides the new value as the first argument.
51
+ */
52
+ readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
53
+ /**
54
+ * @deprecated Use `onKeyDown` or `onKeyUp` instead.
55
+ */
56
+ readonly onEnter?: FormFieldProps["onEnter"];
51
57
  }
52
58
  interface BaseProps extends CommonFormFieldProps, Pick<FormFieldProps, "autofocus" | "maxLength" | "readonly" | "autocomplete" | "keyboard" | "onEnter" | "onFocus" | "onBlur" | "onChange" | "inputRef" | "validations" | "defaultValue" | "prefix" | "suffix" | "toolbar" | "toolbarVisibility" | "version"> {
53
59
  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,60 @@ 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);
221
+ const { inputStyle } = FormField.useFormFieldWrapperStyles({
222
+ size: props.size,
223
+ align: props.align,
224
+ placeholder: props.placeholder,
225
+ value: props.value,
226
+ invalid: props.invalid,
227
+ error: props.error,
228
+ maxLength: props.maxLength,
229
+ type: props.multiline ? "textarea" : "text",
230
+ disabled: props.disabled,
231
+ inline: props.inline,
232
+ });
225
233
  const { name } = FormField.useAtlantisFormFieldName({
226
234
  nameProp: props.name,
227
235
  id: id,
228
236
  });
229
- const { handleChange, handleBlur, handleFocus, handleKeyDown, handleClear } = useInputTextActions({
237
+ const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, handleClick, } = useInputTextActions({
230
238
  onChange: props.onChange,
231
239
  onBlur: props.onBlur,
232
240
  onFocus: props.onFocus,
241
+ onMouseDown: props.onMouseDown,
242
+ onMouseUp: props.onMouseUp,
243
+ onPointerDown: props.onPointerDown,
244
+ onPointerUp: props.onPointerUp,
245
+ onClick: props.onClick,
233
246
  onKeyDown: props.onKeyDown,
247
+ onKeyUp: props.onKeyUp,
234
248
  onEnter: props.onEnter,
235
249
  inputRef: inputTextRef,
236
250
  });
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 },
251
+ const descriptionIdentifier = `descriptionUUID--${id}`;
252
+ const descriptionVisible = props.description && !props.inline;
253
+ const isInvalid = Boolean(props.error || props.invalid);
254
+ const dataAttrs = filterDataAttributes.filterDataAttributes(props);
255
+ // Shared props for both TextArea and TextInput
256
+ const commonInputProps = Object.assign({ id,
257
+ name, className: inputStyle, 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
258
+ ? descriptionIdentifier
259
+ : 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);
260
+ 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", maxLength: props.maxLength, onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
256
261
  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)));
262
+ props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
263
+ React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
260
264
  });
261
265
  function useInputTextId(props) {
262
266
  const generatedId = React.useId();
263
267
  return props.id || generatedId;
264
268
  }
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
- }
269
+ const TextArea = React.forwardRef(function TextArea(props, ref) {
270
+ return React.createElement("textarea", Object.assign({}, props, { ref: ref }));
271
+ });
272
+ const TextInput = React.forwardRef(function TextInput(props, ref) {
273
+ return React.createElement("input", Object.assign({}, props, { ref: ref }));
274
+ });
271
275
 
272
276
  function isNewInputTextProps(props) {
273
277
  return props.version === 2;
@@ -1,13 +1,13 @@
1
1
  import React__default, { forwardRef, useRef, useImperativeHandle, useId } from 'react';
2
2
  import { useSafeLayoutEffect } from '@jobber/hooks';
3
- import { k as FormField, s as styles, j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, f as FormFieldWrapper, l as FormFieldPostFix, m as mergeRefs } from '../FormField-es.js';
3
+ import { k as FormField, j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, m as mergeRefs, f as FormFieldWrapper, l as FormFieldPostFix } from '../FormField-es.js';
4
4
  import 'classnames';
5
- import { _ as __rest } from '../tslib.es6-es.js';
5
+ import '../tslib.es6-es.js';
6
6
  import 'react-hook-form';
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';
10
+ import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
11
11
  import '../Icon-es.js';
12
12
  import '../Text-es.js';
13
13
  import '../Typography-es.js';
@@ -15,17 +15,6 @@ import '../useFormFieldFocus-es.js';
15
15
  import '../InputValidation-es.js';
16
16
  import '../Spinner-es.js';
17
17
  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
18
 
30
19
  /**
31
20
  * Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
@@ -157,10 +146,9 @@ function insertAtCursor(input, newText) {
157
146
  * Combines the actions on the InputText such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputText.
158
147
  * 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.
159
148
  */
160
- function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
149
+ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, onKeyUp, onMouseDown, onMouseUp, onPointerDown, onPointerUp, onClick, }) {
161
150
  function handleClear() {
162
151
  var _a;
163
- handleBlur();
164
152
  onChange && onChange("");
165
153
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
166
154
  }
@@ -179,38 +167,48 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
179
167
  event.preventDefault();
180
168
  onEnter && onEnter(event);
181
169
  }
170
+ function handleKeyUp(event) {
171
+ onKeyUp === null || onKeyUp === void 0 ? void 0 : onKeyUp(event);
172
+ }
182
173
  function handleFocus(event) {
183
174
  onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
184
175
  }
185
176
  function handleBlur(event) {
186
177
  onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
187
178
  }
179
+ function handleMouseDown(event) {
180
+ onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
181
+ }
182
+ function handleMouseUp(event) {
183
+ onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
184
+ }
185
+ function handlePointerDown(event) {
186
+ onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
187
+ }
188
+ function handlePointerUp(event) {
189
+ onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
190
+ }
191
+ function handleClick(event) {
192
+ onClick === null || onClick === void 0 ? void 0 : onClick(event);
193
+ }
188
194
  return {
189
195
  handleClear,
190
196
  handleChange,
191
197
  handleKeyDown,
198
+ handleKeyUp,
192
199
  handleFocus,
193
200
  handleBlur,
201
+ handleMouseDown,
202
+ handleMouseUp,
203
+ handlePointerDown,
204
+ handlePointerUp,
205
+ handleClick,
194
206
  };
195
207
  }
196
208
 
197
- /**
198
- * Provides the props for the html fields rendered by the html input.
199
- * 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.
200
- */
201
- function useInputTextFormField(_a) {
202
- var { id, name, description, inline, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = __rest(_a, ["id", "name", "description", "inline", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
203
- const descriptionIdentifier = `descriptionUUID--${id}`;
204
- const fieldProps = Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { id, className: styles.input, name, disabled: rest.disabled, inputMode: rest.inputMode, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus }), (description &&
205
- !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 });
206
- return { fieldProps, descriptionIdentifier };
207
- }
208
-
209
- const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
209
+ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRef) {
210
210
  var _a, _b, _c;
211
- const inputTextRef = React__default.useRef(null);
212
- const wrapperRef = React__default.useRef(null);
213
- const legacyPropHelper = Object.assign(Object.assign({}, props), { version: 1 });
211
+ const inputTextRef = React__default.useRef(null), wrapperRef = React__default.useRef(null);
214
212
  const id = useInputTextId(props);
215
213
  const { rowRange } = useTextAreaResize({
216
214
  rows: props.rows,
@@ -218,54 +216,60 @@ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
218
216
  inputRef: inputTextRef,
219
217
  wrapperRef: wrapperRef,
220
218
  });
221
- const type = props.multiline ? "textarea" : "text";
222
- const { inputStyle } = useFormFieldWrapperStyles(legacyPropHelper);
219
+ const { inputStyle } = useFormFieldWrapperStyles({
220
+ size: props.size,
221
+ align: props.align,
222
+ placeholder: props.placeholder,
223
+ value: props.value,
224
+ invalid: props.invalid,
225
+ error: props.error,
226
+ maxLength: props.maxLength,
227
+ type: props.multiline ? "textarea" : "text",
228
+ disabled: props.disabled,
229
+ inline: props.inline,
230
+ });
223
231
  const { name } = useAtlantisFormFieldName({
224
232
  nameProp: props.name,
225
233
  id: id,
226
234
  });
227
- const { handleChange, handleBlur, handleFocus, handleKeyDown, handleClear } = useInputTextActions({
235
+ const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, handleClick, } = useInputTextActions({
228
236
  onChange: props.onChange,
229
237
  onBlur: props.onBlur,
230
238
  onFocus: props.onFocus,
239
+ onMouseDown: props.onMouseDown,
240
+ onMouseUp: props.onMouseUp,
241
+ onPointerDown: props.onPointerDown,
242
+ onPointerUp: props.onPointerUp,
243
+ onClick: props.onClick,
231
244
  onKeyDown: props.onKeyDown,
245
+ onKeyUp: props.onKeyUp,
232
246
  onEnter: props.onEnter,
233
247
  inputRef: inputTextRef,
234
248
  });
235
- const inputProps = omit(props, [
236
- "onChange",
237
- "onBlur",
238
- "onFocus",
239
- "onEnter",
240
- "size",
241
- "placeholder",
242
- "multiline",
243
- "prefix",
244
- "suffix",
245
- "version",
246
- ]);
247
- const { fieldProps, descriptionIdentifier } = useInputTextFormField(Object.assign(Object.assign({}, inputProps), { id,
248
- name,
249
- handleChange,
250
- handleBlur,
251
- handleFocus,
252
- handleKeyDown }));
253
- return (React__default.createElement(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 },
249
+ const descriptionIdentifier = `descriptionUUID--${id}`;
250
+ const descriptionVisible = props.description && !props.inline;
251
+ const isInvalid = Boolean(props.error || props.invalid);
252
+ const dataAttrs = filterDataAttributes(props);
253
+ // Shared props for both TextArea and TextInput
254
+ const commonInputProps = Object.assign({ id,
255
+ name, className: inputStyle, 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
256
+ ? descriptionIdentifier
257
+ : 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: mergeRefs([inputRef, inputTextRef]) }, dataAttrs);
258
+ return (React__default.createElement(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", maxLength: props.maxLength, onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility },
254
259
  React__default.createElement(React__default.Fragment, null,
255
- type === "textarea" ? (React__default.createElement(TextArea, { fieldProps: fieldProps, rowRange: rowRange, inputRefs: [inputRefs, inputTextRef], value: props.value, inputStyle: inputStyle })) : (React__default.createElement(TextInput, { fieldProps: fieldProps, inputRefs: [inputRefs, inputTextRef], value: props.value, inputStyle: inputStyle })),
256
- React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
257
- props.children)));
260
+ props.multiline ? (React__default.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React__default.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
261
+ React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
258
262
  });
259
263
  function useInputTextId(props) {
260
264
  const generatedId = useId();
261
265
  return props.id || generatedId;
262
266
  }
263
- function TextArea({ fieldProps, rowRange, inputRefs, value, inputStyle, }) {
264
- return (React__default.createElement("textarea", Object.assign({}, fieldProps, { rows: rowRange.min, ref: mergeRefs(inputRefs), className: inputStyle, value: value })));
265
- }
266
- function TextInput({ fieldProps, inputRefs, value, inputStyle, }) {
267
- return (React__default.createElement("input", Object.assign({}, fieldProps, { ref: mergeRefs(inputRefs), className: inputStyle, value: value })));
268
- }
267
+ const TextArea = forwardRef(function TextArea(props, ref) {
268
+ return React__default.createElement("textarea", Object.assign({}, props, { ref: ref }));
269
+ });
270
+ const TextInput = forwardRef(function TextInput(props, ref) {
271
+ return React__default.createElement("input", Object.assign({}, props, { ref: ref }));
272
+ });
269
273
 
270
274
  function isNewInputTextProps(props) {
271
275
  return props.version === 2;
@@ -1,16 +1,22 @@
1
- import type { ChangeEvent, FocusEvent, KeyboardEvent } from "react";
1
+ import type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent, PointerEvent } from "react";
2
2
  import type { InputTextRebuiltProps } from "./InputText.types";
3
- export interface useInputTextActionsProps extends Pick<InputTextRebuiltProps, "onChange" | "onEnter" | "onFocus" | "onBlur" | "onKeyDown"> {
3
+ export interface useInputTextActionsProps extends Pick<InputTextRebuiltProps, "onChange" | "onEnter" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "onMouseDown" | "onMouseUp" | "onPointerDown" | "onPointerUp" | "onClick"> {
4
4
  inputRef?: React.RefObject<HTMLInputElement | HTMLTextAreaElement | null>;
5
5
  }
6
6
  /**
7
7
  * Combines the actions on the InputText such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputText.
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 useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }: useInputTextActionsProps): {
10
+ export declare function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, onKeyUp, onMouseDown, onMouseUp, onPointerDown, onPointerUp, onClick, }: useInputTextActionsProps): {
11
11
  handleClear: () => void;
12
12
  handleChange: (event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
13
13
  handleKeyDown: (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
14
+ handleKeyUp: (event: KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
14
15
  handleFocus: (event: FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
15
- handleBlur: (event?: FocusEvent) => void;
16
+ handleBlur: (event: FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
17
+ handleMouseDown: (event: MouseEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
18
+ handleMouseUp: (event: MouseEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
19
+ handlePointerDown: (event: PointerEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
20
+ handlePointerUp: (event: PointerEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
21
+ handleClick: (event: MouseEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
16
22
  };
@@ -1,3 +1,3 @@
1
1
  import React from "react";
2
2
  import type { InputTimeRebuiltProps } from "./InputTime.types";
3
- export declare function InputTimeRebuilt({ value, onChange, ...params }: InputTimeRebuiltProps): React.JSX.Element;
3
+ export declare function InputTimeRebuilt({ value, onChange, readOnly, autoComplete, inputRef, ...props }: InputTimeRebuiltProps): React.JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
2
+ import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, MouseEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
2
3
  export interface InputTimeProps extends Pick<CommonFormFieldProps, "id" | "align" | "description" | "disabled" | "invalid" | "inline" | "loading" | "name" | "onValidation" | "placeholder" | "size" | "clearable">, Pick<FormFieldProps, "maxLength" | "readonly" | "autocomplete" | "max" | "min" | "onEnter" | "onFocus" | "onBlur" | "inputRef" | "validations"> {
3
4
  /**
4
5
  * Intial value of the input. Only use this when you need to prepopulate the
@@ -18,10 +19,18 @@ export interface InputTimeProps extends Pick<CommonFormFieldProps, "id" | "align
18
19
  export interface InputTimeLegacyProps extends InputTimeProps {
19
20
  version?: 1;
20
21
  }
21
- export interface InputTimeRebuiltProps extends Omit<InputTimeProps, "defaultValue" | "version" | "validations" | "onValidation"> {
22
+ export interface InputTimeRebuiltProps extends HTMLInputBaseProps, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, MouseEvents<HTMLInputElement>, RebuiltInputCommonProps, Pick<InputTimeProps, "value" | "onChange"> {
22
23
  /**
23
- * Version 2 is highly experimental, avoid using it unless you have talked with Atlantis first.
24
+ * Maximum numerical or date value.
24
25
  */
25
- version: 2;
26
- error?: string;
26
+ readonly max?: number;
27
+ /**
28
+ * Minimum numerical or date value.
29
+ */
30
+ readonly min?: number;
31
+ readonly inputRef?: FormFieldProps["inputRef"];
32
+ /**
33
+ * @deprecated Use `onKeyDown` or `onKeyUp` instead.
34
+ */
35
+ readonly onEnter?: FormFieldProps["onEnter"];
27
36
  }
@@ -0,0 +1,21 @@
1
+ import type { ChangeEvent, FocusEvent, KeyboardEvent, MouseEvent, PointerEvent } from "react";
2
+ import type { InputTimeRebuiltProps } from "../InputTime.types";
3
+ export interface UseInputTimeActionsProps extends Pick<InputTimeRebuiltProps, "onChange" | "onFocus" | "onBlur" | "onKeyDown" | "onClick" | "onMouseDown" | "onMouseUp" | "onPointerDown" | "onPointerUp"> {
4
+ readonly value?: Date;
5
+ readonly readOnly?: boolean;
6
+ readonly disabled?: boolean;
7
+ readonly inputRef?: React.RefObject<HTMLInputElement | null>;
8
+ }
9
+ export declare function useInputTimeActions({ onChange, value, inputRef, onFocus, onBlur, onKeyDown, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }: UseInputTimeActionsProps): {
10
+ handleChangeEvent: (event: ChangeEvent<HTMLInputElement>) => void;
11
+ handleChange: (newValue: string) => void;
12
+ handleBlur: (event: FocusEvent<HTMLInputElement>) => void;
13
+ handleClear: () => void;
14
+ handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
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;
21
+ };