@jobber/components 6.104.0 → 6.104.1

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 +1 -2
  7. package/dist/Checkbox/Checkbox.types.d.ts +3 -34
  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 +4 -3
  42. package/dist/InputEmail/index.cjs +18 -49
  43. package/dist/InputEmail/index.mjs +18 -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 +1 -1
  49. package/dist/InputPhoneNumber/index.cjs +20 -34
  50. package/dist/InputPhoneNumber/index.mjs +20 -34
  51. package/dist/InputText/InputText.types.d.ts +31 -25
  52. package/dist/InputText/index.cjs +41 -62
  53. package/dist/InputText/index.mjs +42 -63
  54. package/dist/InputText/useInputTextActions.d.ts +4 -3
  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 +16 -0
  58. package/dist/InputTime/index.cjs +66 -30
  59. package/dist/InputTime/index.mjs +69 -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 +205 -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
@@ -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, }) {
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,6 +169,9 @@ 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
  }
@@ -191,28 +182,15 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
191
182
  handleClear,
192
183
  handleChange,
193
184
  handleKeyDown,
185
+ handleKeyUp,
194
186
  handleFocus,
195
187
  handleBlur,
196
188
  };
197
189
  }
198
190
 
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) {
191
+ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRef) {
212
192
  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 });
193
+ const inputTextRef = React.useRef(null), wrapperRef = React.useRef(null);
216
194
  const id = useInputTextId(props);
217
195
  const { rowRange } = useTextAreaResize({
218
196
  rows: props.rows,
@@ -220,54 +198,55 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
220
198
  inputRef: inputTextRef,
221
199
  wrapperRef: wrapperRef,
222
200
  });
223
- const type = props.multiline ? "textarea" : "text";
224
- const { inputStyle } = FormField.useFormFieldWrapperStyles(legacyPropHelper);
201
+ const { inputStyle } = FormField.useFormFieldWrapperStyles({
202
+ size: props.size,
203
+ align: props.align,
204
+ placeholder: props.placeholder,
205
+ value: props.value,
206
+ invalid: props.invalid,
207
+ error: props.error,
208
+ maxLength: props.maxLength,
209
+ type: props.multiline ? "textarea" : "text",
210
+ disabled: props.disabled,
211
+ inline: props.inline,
212
+ });
225
213
  const { name } = FormField.useAtlantisFormFieldName({
226
214
  nameProp: props.name,
227
215
  id: id,
228
216
  });
229
- const { handleChange, handleBlur, handleFocus, handleKeyDown, handleClear } = useInputTextActions({
217
+ const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, } = useInputTextActions({
230
218
  onChange: props.onChange,
231
219
  onBlur: props.onBlur,
232
220
  onFocus: props.onFocus,
233
221
  onKeyDown: props.onKeyDown,
222
+ onKeyUp: props.onKeyUp,
234
223
  onEnter: props.onEnter,
235
224
  inputRef: inputTextRef,
236
225
  });
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 },
226
+ const descriptionIdentifier = `descriptionUUID--${id}`;
227
+ const descriptionVisible = props.description && !props.inline;
228
+ const isInvalid = Boolean(props.error || props.invalid);
229
+ const dataAttrs = filterDataAttributes.filterDataAttributes(props);
230
+ // Shared props for both TextArea and TextInput
231
+ const commonInputProps = Object.assign({ id,
232
+ 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
233
+ ? descriptionIdentifier
234
+ : 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, ref: FormField.mergeRefs([inputRef, inputTextRef]) }, dataAttrs);
235
+ 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
236
  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)));
237
+ props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
238
+ React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
260
239
  });
261
240
  function useInputTextId(props) {
262
241
  const generatedId = React.useId();
263
242
  return props.id || generatedId;
264
243
  }
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
- }
244
+ const TextArea = React.forwardRef(function TextArea(props, ref) {
245
+ return React.createElement("textarea", Object.assign({}, props, { ref: ref }));
246
+ });
247
+ const TextInput = React.forwardRef(function TextInput(props, ref) {
248
+ return React.createElement("input", Object.assign({}, props, { ref: ref }));
249
+ });
271
250
 
272
251
  function isNewInputTextProps(props) {
273
252
  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, }) {
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,6 +167,9 @@ 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
  }
@@ -189,28 +180,15 @@ function useInputTextActions({ onChange, inputRef, onEnter, onFocus, onBlur, onK
189
180
  handleClear,
190
181
  handleChange,
191
182
  handleKeyDown,
183
+ handleKeyUp,
192
184
  handleFocus,
193
185
  handleBlur,
194
186
  };
195
187
  }
196
188
 
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) {
189
+ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRef) {
210
190
  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 });
191
+ const inputTextRef = React__default.useRef(null), wrapperRef = React__default.useRef(null);
214
192
  const id = useInputTextId(props);
215
193
  const { rowRange } = useTextAreaResize({
216
194
  rows: props.rows,
@@ -218,54 +196,55 @@ const InputTextSPAR = forwardRef(function InputTextInternal(props, inputRefs) {
218
196
  inputRef: inputTextRef,
219
197
  wrapperRef: wrapperRef,
220
198
  });
221
- const type = props.multiline ? "textarea" : "text";
222
- const { inputStyle } = useFormFieldWrapperStyles(legacyPropHelper);
199
+ const { inputStyle } = useFormFieldWrapperStyles({
200
+ size: props.size,
201
+ align: props.align,
202
+ placeholder: props.placeholder,
203
+ value: props.value,
204
+ invalid: props.invalid,
205
+ error: props.error,
206
+ maxLength: props.maxLength,
207
+ type: props.multiline ? "textarea" : "text",
208
+ disabled: props.disabled,
209
+ inline: props.inline,
210
+ });
223
211
  const { name } = useAtlantisFormFieldName({
224
212
  nameProp: props.name,
225
213
  id: id,
226
214
  });
227
- const { handleChange, handleBlur, handleFocus, handleKeyDown, handleClear } = useInputTextActions({
215
+ const { handleChange, handleBlur, handleFocus, handleKeyDown, handleKeyUp, handleClear, } = useInputTextActions({
228
216
  onChange: props.onChange,
229
217
  onBlur: props.onBlur,
230
218
  onFocus: props.onFocus,
231
219
  onKeyDown: props.onKeyDown,
220
+ onKeyUp: props.onKeyUp,
232
221
  onEnter: props.onEnter,
233
222
  inputRef: inputTextRef,
234
223
  });
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 },
224
+ const descriptionIdentifier = `descriptionUUID--${id}`;
225
+ const descriptionVisible = props.description && !props.inline;
226
+ const isInvalid = Boolean(props.error || props.invalid);
227
+ const dataAttrs = filterDataAttributes(props);
228
+ // Shared props for both TextArea and TextInput
229
+ const commonInputProps = Object.assign({ id,
230
+ 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
231
+ ? descriptionIdentifier
232
+ : 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, ref: mergeRefs([inputRef, inputTextRef]) }, dataAttrs);
233
+ 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
234
  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)));
235
+ props.multiline ? (React__default.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React__default.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
236
+ React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
258
237
  });
259
238
  function useInputTextId(props) {
260
239
  const generatedId = useId();
261
240
  return props.id || generatedId;
262
241
  }
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
- }
242
+ const TextArea = forwardRef(function TextArea(props, ref) {
243
+ return React__default.createElement("textarea", Object.assign({}, props, { ref: ref }));
244
+ });
245
+ const TextInput = forwardRef(function TextInput(props, ref) {
246
+ return React__default.createElement("input", Object.assign({}, props, { ref: ref }));
247
+ });
269
248
 
270
249
  function isNewInputTextProps(props) {
271
250
  return props.version === 2;
@@ -1,16 +1,17 @@
1
1
  import type { ChangeEvent, FocusEvent, KeyboardEvent } 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"> {
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, }: 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;
16
17
  };
@@ -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, 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>, 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,16 @@
1
+ import type { ChangeEvent, FocusEvent, KeyboardEvent } from "react";
2
+ import type { InputTimeRebuiltProps } from "../InputTime.types";
3
+ export interface UseInputTimeActionsProps extends Pick<InputTimeRebuiltProps, "onChange" | "onFocus" | "onBlur" | "onKeyDown"> {
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, }: 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
+ };
@@ -8,6 +8,7 @@ require('classnames');
8
8
  require('@jobber/design');
9
9
  require('react-hook-form');
10
10
  require('../Button-cjs.js');
11
+ var filterDataAttributes = require('../filterDataAttributes-cjs.js');
11
12
  var omit = require('../omit-cjs.js');
12
13
  require('@jobber/hooks');
13
14
  require('framer-motion');
@@ -21,7 +22,7 @@ require('../useFormFieldFocus-cjs.js');
21
22
  require('../InputValidation-cjs.js');
22
23
  require('../Spinner-cjs.js');
23
24
  require('react-router-dom');
24
- require('../_baseGet-cjs.js');
25
+ require('../_getAllKeys-cjs.js');
25
26
  require('../isTypedArray-cjs.js');
26
27
  require('../identity-cjs.js');
27
28
  require('../_getTag-cjs.js');
@@ -204,23 +205,7 @@ function timeStringToDate(timeString, baseDate) {
204
205
  }
205
206
  }
206
207
 
207
- function InputTimeRebuilt(_a) {
208
- var _b, _c;
209
- var { value, onChange } = _a, params = tslib_es6.__rest(_a, ["value", "onChange"]);
210
- const ref = (_b = params.inputRef) !== null && _b !== void 0 ? _b : React.useRef(null);
211
- const { setTypedTime } = useTimePredict({
212
- value,
213
- handleChange,
214
- });
215
- const { inputStyle } = FormField.useFormFieldWrapperStyles(params);
216
- const wrapperRef = React.useRef(null);
217
- const id = getId(params);
218
- return (React.createElement(FormField.FormFieldWrapper, { disabled: params.disabled, size: params.size, align: params.align, inline: params.inline, name: params.name, error: params.error || "", identifier: id, descriptionIdentifier: `descriptionUUID--${id}`, invalid: Boolean(params.invalid), description: params.description, clearable: (_c = params.clearable) !== null && _c !== void 0 ? _c : "never", onClear: handleClear, type: "time", readonly: params.readonly, placeholder: params.placeholder, value: dateToTimeString(value), wrapperRef: wrapperRef },
219
- React.createElement("input", { ref: ref, type: "time", name: params.name, className: inputStyle, onBlur: handleBlur, id: id, disabled: params.disabled, readOnly: params.readonly, onChange: handleChangeEvent, onFocus: handleFocus, "data-testid": "ATL-InputTime-input", onKeyUp: e => {
220
- if (params.disabled || params.readonly)
221
- return;
222
- !isNaN(parseInt(e.key, 10)) && setTypedTime(prev => prev + e.key);
223
- }, value: dateToTimeString(value) })));
208
+ function useInputTimeActions({ onChange, value, inputRef, onFocus, onBlur, onKeyDown, }) {
224
209
  function handleChangeEvent(event) {
225
210
  handleChange(event.target.value);
226
211
  }
@@ -228,28 +213,79 @@ function InputTimeRebuilt(_a) {
228
213
  onChange === null || onChange === void 0 ? void 0 : onChange(timeStringToDate(newValue, value));
229
214
  }
230
215
  function handleBlur(event) {
231
- var _a;
232
- (_a = params.onBlur) === null || _a === void 0 ? void 0 : _a.call(params, event);
233
- if (ref.current) {
234
- if (!ref.current.checkValidity()) {
235
- ref.current.value = "";
216
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
217
+ if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
218
+ if (!inputRef.current.checkValidity()) {
219
+ inputRef.current.value = "";
236
220
  }
237
221
  }
238
222
  }
239
223
  function handleClear() {
240
224
  var _a;
241
- handleBlur();
225
+ // Clear the value and refocus without triggering blur event
242
226
  onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
243
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
227
+ (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
244
228
  }
245
229
  function handleFocus(event) {
246
- var _a;
247
- (_a = params.onFocus) === null || _a === void 0 ? void 0 : _a.call(params, event);
230
+ onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
248
231
  }
249
- function getId(props) {
250
- const generatedId = React.useId();
251
- return props.id || generatedId;
232
+ function handleKeyDown(event) {
233
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
234
+ }
235
+ return {
236
+ handleChangeEvent,
237
+ handleChange,
238
+ handleBlur,
239
+ handleClear,
240
+ handleFocus,
241
+ handleKeyDown,
242
+ };
243
+ }
244
+
245
+ function InputTimeRebuilt(_a) {
246
+ var _b;
247
+ var { value, onChange, readOnly, autoComplete, inputRef } = _a, props = tslib_es6.__rest(_a, ["value", "onChange", "readOnly", "autoComplete", "inputRef"]);
248
+ const { internalRef, mergedRef, wrapperRef } = useInputTimeRefs(inputRef);
249
+ const generatedId = React.useId();
250
+ const id = props.id || generatedId;
251
+ const { inputStyle } = FormField.useFormFieldWrapperStyles(props);
252
+ const { handleChangeEvent, handleChange, handleBlur, handleClear, handleFocus, handleKeyDown, } = useInputTimeActions({
253
+ onChange,
254
+ value,
255
+ readOnly,
256
+ disabled: props.disabled,
257
+ inputRef: internalRef,
258
+ onFocus: props.onFocus,
259
+ onBlur: props.onBlur,
260
+ onKeyDown: props.onKeyDown,
261
+ });
262
+ const { setTypedTime } = useTimePredict({
263
+ value,
264
+ handleChange,
265
+ });
266
+ // Kept outside the useInputTimeActions hook to avoid circular dependency via setTypedTime and handleChange
267
+ function handleKeyUp(event) {
268
+ var _a;
269
+ (_a = props.onKeyUp) === null || _a === void 0 ? void 0 : _a.call(props, event);
270
+ if (props.disabled || readOnly)
271
+ return;
272
+ !isNaN(parseInt(event.key, 10)) && setTypedTime(prev => prev + event.key);
252
273
  }
274
+ const dataAttrs = filterDataAttributes.filterDataAttributes(props);
275
+ const descriptionIdentifier = `descriptionUUID--${id}`;
276
+ const descriptionVisible = props.description && !props.inline;
277
+ const isInvalid = Boolean(props.error || props.invalid);
278
+ return (React.createElement(FormField.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, name: props.name, error: props.error || "", identifier: id, descriptionIdentifier: descriptionIdentifier, invalid: props.invalid, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: "time", readonly: readOnly, placeholder: props.placeholder, value: dateToTimeString(value), wrapperRef: wrapperRef },
279
+ React.createElement("input", Object.assign({ ref: mergedRef, type: "time", name: props.name, className: inputStyle, id: id, disabled: props.disabled, readOnly: readOnly, autoComplete: autoComplete, autoFocus: props.autoFocus, max: props.max, min: props.min, value: dateToTimeString(value), onChange: handleChangeEvent, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, "data-testid": "ATL-InputTime-input", "aria-label": props["aria-label"], "aria-describedby": descriptionVisible ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"] }, dataAttrs))));
280
+ }
281
+ function useInputTimeRefs(inputRef) {
282
+ const internalRef = React.useRef(null);
283
+ const mergedRef = FormField.mergeRefs([
284
+ internalRef,
285
+ inputRef,
286
+ ]);
287
+ const wrapperRef = React.useRef(null);
288
+ return { internalRef, mergedRef, wrapperRef };
253
289
  }
254
290
 
255
291
  function InputTime$1(_a) {