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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/Autocomplete/Autocomplete.types.d.ts +1 -12
  2. package/dist/Autocomplete/components/MenuList.d.ts +2 -1
  3. package/dist/Autocomplete/components/PersistentRegion.d.ts +2 -1
  4. package/dist/Autocomplete/hooks/useAutocompleteListNav.d.ts +2 -1
  5. package/dist/Autocomplete/index.cjs +85 -35
  6. package/dist/Autocomplete/index.mjs +86 -36
  7. package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +13 -0
  8. package/dist/Autocomplete/useAutocomplete.d.ts +1 -0
  9. package/dist/Checkbox/Checkbox.types.d.ts +9 -2
  10. package/dist/Checkbox/index.cjs +2 -4
  11. package/dist/Checkbox/index.mjs +2 -4
  12. package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
  13. package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
  14. package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
  15. package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
  16. package/dist/Chips/index.cjs +2 -2
  17. package/dist/Chips/index.mjs +2 -2
  18. package/dist/DataList/components/DataListSearch/index.cjs +12 -1
  19. package/dist/DataList/components/DataListSearch/index.mjs +12 -1
  20. package/dist/DataList/index.cjs +8 -0
  21. package/dist/DataList/index.mjs +8 -0
  22. package/dist/DataTable/index.cjs +2 -2
  23. package/dist/DataTable/index.mjs +2 -2
  24. package/dist/DatePicker/index.cjs +2 -2
  25. package/dist/DatePicker/index.mjs +2 -2
  26. package/dist/DatePicker-es.js +1 -1
  27. package/dist/FormField/FormFieldTypes.d.ts +2 -0
  28. package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +2 -7
  29. package/dist/FormField-cjs.js +6 -1
  30. package/dist/FormField-es.js +6 -2
  31. package/dist/InputDate/index.cjs +9 -5
  32. package/dist/InputDate/index.mjs +9 -5
  33. package/dist/InputDate/useInputDateActivatorActions.d.ts +8 -4
  34. package/dist/InputEmail/InputEmail.types.d.ts +20 -12
  35. package/dist/InputEmail/hooks/useInputEmailActions.d.ts +1 -1
  36. package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +32 -0
  37. package/dist/InputEmail/index.cjs +44 -8
  38. package/dist/InputEmail/index.mjs +44 -8
  39. package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +3 -20
  40. package/dist/InputNumber/index.cjs +3 -3
  41. package/dist/InputNumber/index.mjs +3 -3
  42. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +27 -13
  43. package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +1 -1
  44. package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +71 -0
  45. package/dist/InputPhoneNumber/index.cjs +34 -17
  46. package/dist/InputPhoneNumber/index.mjs +34 -17
  47. package/dist/InputText/InputText.types.d.ts +24 -24
  48. package/dist/InputText/index.cjs +54 -54
  49. package/dist/InputText/index.mjs +55 -55
  50. package/dist/InputText/useInputTextActions.d.ts +1 -1
  51. package/dist/InputText/useInputTextFormField.d.ts +352 -0
  52. package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
  53. package/dist/InputTime/InputTime.types.d.ts +1 -21
  54. package/dist/InputTime/index.cjs +33 -63
  55. package/dist/InputTime/index.d.ts +1 -1
  56. package/dist/InputTime/index.mjs +36 -66
  57. package/dist/List/index.cjs +2 -2
  58. package/dist/List/index.mjs +2 -2
  59. package/dist/RecurringSelect/index.cjs +2 -2
  60. package/dist/RecurringSelect/index.mjs +2 -2
  61. package/dist/Select/Select.rebuilt.d.ts +1 -1
  62. package/dist/Select/Select.types.d.ts +1 -14
  63. package/dist/Select/hooks/useSelectActions.d.ts +5 -5
  64. package/dist/Select/hooks/useSelectFormField.d.ts +34 -0
  65. package/dist/Select/index.cjs +41 -28
  66. package/dist/Select/index.d.ts +5 -7
  67. package/dist/Select/index.mjs +43 -30
  68. package/dist/Tabs-es.js +1 -1
  69. package/dist/_baseEach-cjs.js +12 -12
  70. package/dist/_baseEach-es.js +1 -1
  71. package/dist/_baseFlatten-cjs.js +2 -2
  72. package/dist/_baseFlatten-es.js +1 -1
  73. package/dist/{_getAllKeys-cjs.js → _baseGet-cjs.js} +181 -181
  74. package/dist/{_getAllKeys-es.js → _baseGet-es.js} +182 -182
  75. package/dist/debounce-es.js +1 -1
  76. package/dist/floating-ui.react-cjs.js +115 -0
  77. package/dist/floating-ui.react-es.js +115 -1
  78. package/dist/index.cjs +2 -2
  79. package/dist/index.mjs +2 -2
  80. package/dist/omit-cjs.js +14 -14
  81. package/dist/omit-es.js +1 -1
  82. package/dist/sharedHelpers/types.d.ts +0 -235
  83. package/dist/styles.css +3 -0
  84. package/dist/useScrollToActive-cjs.js +3 -3
  85. package/dist/useScrollToActive-es.js +2 -2
  86. package/package.json +2 -2
  87. package/dist/InputTime/hooks/useInputTimeActions.d.ts +0 -16
@@ -13,12 +13,12 @@ require('../Content-cjs.js');
13
13
  require('../Select/index.cjs');
14
14
  require('../omit-cjs.js');
15
15
  require('../_commonjsHelpers-cjs.js');
16
- require('../_getAllKeys-cjs.js');
16
+ require('../_baseGet-cjs.js');
17
17
  require('../isTypedArray-cjs.js');
18
18
  require('../isObjectLike-cjs.js');
19
- require('../isSymbol-cjs.js');
20
19
  require('../identity-cjs.js');
21
20
  require('../_getTag-cjs.js');
21
+ require('../isSymbol-cjs.js');
22
22
  require('../keysIn-cjs.js');
23
23
  require('../_baseAssignValue-cjs.js');
24
24
  require('../_baseFlatten-cjs.js');
@@ -11,12 +11,12 @@ import '../Content-es.js';
11
11
  import '../Select/index.mjs';
12
12
  import '../omit-es.js';
13
13
  import '../_commonjsHelpers-es.js';
14
- import '../_getAllKeys-es.js';
14
+ import '../_baseGet-es.js';
15
15
  import '../isTypedArray-es.js';
16
16
  import '../isObjectLike-es.js';
17
- import '../isSymbol-es.js';
18
17
  import '../identity-es.js';
19
18
  import '../_getTag-es.js';
19
+ import '../isSymbol-es.js';
20
20
  import '../keysIn-es.js';
21
21
  import '../_baseAssignValue-es.js';
22
22
  import '../_baseFlatten-es.js';
@@ -16,12 +16,12 @@ require('../Icon-cjs.js');
16
16
  require('@jobber/design');
17
17
  require('../omit-cjs.js');
18
18
  require('../_commonjsHelpers-cjs.js');
19
- require('../_getAllKeys-cjs.js');
19
+ require('../_baseGet-cjs.js');
20
20
  require('../isTypedArray-cjs.js');
21
21
  require('../isObjectLike-cjs.js');
22
- require('../isSymbol-cjs.js');
23
22
  require('../identity-cjs.js');
24
23
  require('../_getTag-cjs.js');
24
+ require('../isSymbol-cjs.js');
25
25
  require('../keysIn-cjs.js');
26
26
  require('../_baseAssignValue-cjs.js');
27
27
  require('../_baseFlatten-cjs.js');
@@ -14,12 +14,12 @@ import '../Icon-es.js';
14
14
  import '@jobber/design';
15
15
  import '../omit-es.js';
16
16
  import '../_commonjsHelpers-es.js';
17
- import '../_getAllKeys-es.js';
17
+ import '../_baseGet-es.js';
18
18
  import '../isTypedArray-es.js';
19
19
  import '../isObjectLike-es.js';
20
- import '../isSymbol-es.js';
21
20
  import '../identity-es.js';
22
21
  import '../_getTag-es.js';
22
+ import '../isSymbol-es.js';
23
23
  import '../keysIn-es.js';
24
24
  import '../_baseAssignValue-es.js';
25
25
  import '../_baseFlatten-es.js';
@@ -1,7 +1,7 @@
1
1
  import React__default, { cloneElement, Component, createRef, useRef, useCallback, useEffect, createElement, forwardRef, isValidElement, useState } from 'react';
2
2
  import classnames from 'classnames';
3
3
  import { c as clsx } from './clsx-es.js';
4
- import { u as useFloating, b as autoUpdate, f as flip, o as offset, a as arrow, t as FloatingArrow } from './floating-ui.react-es.js';
4
+ import { u as useFloating, b as autoUpdate, f as flip, o as offset, a as arrow, v as FloatingArrow } from './floating-ui.react-es.js';
5
5
  import ReactDOM__default from 'react-dom';
6
6
  import { useRefocusOnActivator } from '@jobber/hooks';
7
7
  import { T as Typography } from './Typography-es.js';
@@ -158,6 +158,8 @@ export interface FormFieldProps extends CommonFormFieldProps {
158
158
  */
159
159
  readonly suffix?: XOR<Affix, Suffix>;
160
160
  /**
161
+ * Simplified onChange handler that only provides the new value.
162
+ * @param newValue
161
163
  * Specifies the minimum numerical or date value that a user can type
162
164
  */
163
165
  readonly min?: number;
@@ -1,12 +1,7 @@
1
1
  import type { RefObject } from "react";
2
2
  import type { FormFieldProps } from "../FormFieldTypes";
3
- export interface useFormFieldWrapperStylesProps extends Pick<FormFieldProps, "size" | "align" | "placeholder" | "value" | "invalid" | "maxLength" | "type" | "disabled" | "inline"> {
3
+ export interface useFormFieldWrapperStylesProps extends Pick<FormFieldProps, "size" | "align" | "placeholder" | "value" | "invalid" | "max" | "maxLength" | "type" | "disabled" | "inline"> {
4
4
  readonly error?: string;
5
- /**
6
- * Maximum numerical or date value
7
- * In v2 components, this is typically undefined.
8
- */
9
- readonly max?: number | string;
10
5
  suffixRef?: RefObject<HTMLDivElement>;
11
6
  prefixRef?: RefObject<HTMLDivElement>;
12
7
  showMiniLabel?: boolean;
@@ -23,7 +18,7 @@ export declare function useFormFieldWrapperStyles({ size, align, placeholder, va
23
18
  wrapperClasses: string;
24
19
  containerClasses: string;
25
20
  wrapperInlineStyle: {
26
- [x: string]: string | number | undefined;
21
+ [x: string]: number | undefined;
27
22
  };
28
23
  labelStyle: LabelPadding;
29
24
  setLabelStyle: import("react").Dispatch<import("react").SetStateAction<LabelPadding>>;
@@ -383,6 +383,7 @@ function FormField(props) {
383
383
  return React.createElement(FormFieldInternal, Object.assign({}, props, { id: id }));
384
384
  }
385
385
  function FormFieldInternal(props) {
386
+ var _a;
386
387
  const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, id, inputRef, inline, keyboard, max, maxLength, min, name: nameProp, pattern, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, onKeyUp, clearable = "never", autofocus, } = props;
387
388
  const { name } = useAtlantisFormFieldName({ id, nameProp });
388
389
  const { errorMessage, inputRefs, useControllerField, setValue, onControllerBlur, onControllerChange, } = useAtlantisReactHookForm({
@@ -429,7 +430,10 @@ function FormFieldInternal(props) {
429
430
  handleValidation,
430
431
  handleKeyDown,
431
432
  });
432
- return (React.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear }), renderField()));
433
+ // Ensure focus tracking works by providing a wrapperRef when none is passed
434
+ const internalWrapperRef = React.useRef(null);
435
+ const wrapperRef = (_a = props.wrapperRef) !== null && _a !== void 0 ? _a : internalWrapperRef;
436
+ return (React.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
433
437
  function renderField() {
434
438
  switch (type) {
435
439
  case "select":
@@ -467,6 +471,7 @@ exports.FormFieldWrapper = FormFieldWrapper;
467
471
  exports.FormFieldWrapperMain = FormFieldWrapperMain;
468
472
  exports.FormFieldWrapperToolbar = FormFieldWrapperToolbar;
469
473
  exports.mergeRefs = mergeRefs;
474
+ exports.styles = styles$1;
470
475
  exports.useAtlantisFormField = useAtlantisFormField;
471
476
  exports.useAtlantisFormFieldActions = useAtlantisFormFieldActions;
472
477
  exports.useAtlantisFormFieldName = useAtlantisFormFieldName;
@@ -381,6 +381,7 @@ function FormField(props) {
381
381
  return React__default.createElement(FormFieldInternal, Object.assign({}, props, { id: id }));
382
382
  }
383
383
  function FormFieldInternal(props) {
384
+ var _a;
384
385
  const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, id, inputRef, inline, keyboard, max, maxLength, min, name: nameProp, pattern, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, onKeyUp, clearable = "never", autofocus, } = props;
385
386
  const { name } = useAtlantisFormFieldName({ id, nameProp });
386
387
  const { errorMessage, inputRefs, useControllerField, setValue, onControllerBlur, onControllerChange, } = useAtlantisReactHookForm({
@@ -427,7 +428,10 @@ function FormFieldInternal(props) {
427
428
  handleValidation,
428
429
  handleKeyDown,
429
430
  });
430
- return (React__default.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear }), renderField()));
431
+ // Ensure focus tracking works by providing a wrapperRef when none is passed
432
+ const internalWrapperRef = useRef(null);
433
+ const wrapperRef = (_a = props.wrapperRef) !== null && _a !== void 0 ? _a : internalWrapperRef;
434
+ return (React__default.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
431
435
  function renderField() {
432
436
  switch (type) {
433
437
  case "select":
@@ -454,4 +458,4 @@ function setAutocomplete(autocompleteSetting) {
454
458
  return autocompleteSetting;
455
459
  }
456
460
 
457
- export { AffixIcon as A, FormFieldInputHorizontalWrapper as F, useAtlantisFormFieldActions as a, useAtlantisFormFieldName as b, useAtlantisReactHookForm as c, FormFieldInputWrapperStyles as d, FormFieldLabel as e, FormFieldWrapper as f, FormFieldWrapperMain as g, FormFieldWrapperToolbar as h, AffixLabel as i, useFormFieldWrapperStyles as j, FormField as k, FormFieldPostFix as l, mergeRefs as m, useAtlantisFormField as u };
461
+ export { AffixIcon as A, FormFieldInputHorizontalWrapper as F, useAtlantisFormFieldActions as a, useAtlantisFormFieldName as b, useAtlantisReactHookForm as c, FormFieldInputWrapperStyles as d, FormFieldLabel as e, FormFieldWrapper as f, FormFieldWrapperMain as g, FormFieldWrapperToolbar as h, AffixLabel as i, useFormFieldWrapperStyles as j, FormField as k, FormFieldPostFix as l, mergeRefs as m, styles$1 as s, useAtlantisFormField as u };
@@ -13,12 +13,12 @@ require('../Button-cjs.js');
13
13
  var DatePicker = require('../DatePicker-cjs.js');
14
14
  var InputText_index = require('../InputText/index.cjs');
15
15
  require('../_commonjsHelpers-cjs.js');
16
- require('../_getAllKeys-cjs.js');
16
+ require('../_baseGet-cjs.js');
17
17
  require('../isTypedArray-cjs.js');
18
18
  require('../isObjectLike-cjs.js');
19
- require('../isSymbol-cjs.js');
20
19
  require('../identity-cjs.js');
21
20
  require('../_getTag-cjs.js');
21
+ require('../isSymbol-cjs.js');
22
22
  require('../keysIn-cjs.js');
23
23
  require('../_baseAssignValue-cjs.js');
24
24
  require('../_baseFlatten-cjs.js');
@@ -79,9 +79,13 @@ function InputDate$1(inputProps) {
79
79
  } }));
80
80
  }
81
81
 
82
+ /**
83
+ * Combines the actions on the InputDate such as onChange, onFocus, onBlur to forward event handler passed to the InputDate component to the DatePicker component.
84
+ * 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.
85
+ */
82
86
  function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
83
87
  const [isFocused, setIsFocused] = React.useState(false);
84
- function handleChange(_newValue, event) {
88
+ function handleChange(_, event) {
85
89
  onChange === null || onChange === void 0 ? void 0 : onChange(event);
86
90
  }
87
91
  function handleFocus(event) {
@@ -89,8 +93,8 @@ function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
89
93
  setIsFocused(true);
90
94
  }
91
95
  function handleBlur(event) {
92
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
93
96
  setIsFocused(false);
97
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
94
98
  }
95
99
  return {
96
100
  handleBlur,
@@ -131,7 +135,7 @@ const InputDateRebuilt = React.forwardRef((props, forwardedRef) => {
131
135
  return (
132
136
  // We prevent the picker from opening on focus for keyboard navigation, so to maintain a good UX for mouse users we want to open the picker on click
133
137
  React.createElement("div", { onClick: onClick },
134
- React.createElement(InputText_index.InputText, { "aria-describedby": activatorProps.ariaDescribedBy, "aria-labelledby": activatorProps.ariaLabelledBy, "aria-required": activatorProps.ariaRequired === "true" ? true : false, id: activatorProps.id, disabled: props.disabled, error: props.error, readOnly: props.readOnly, placeholder: props.placeholder, size: props.size, inline: props.inline, align: props.align, description: props.description, invalid: props.invalid, name: props.name, version: 2, value: showEmptyValueLabel ? props.emptyValueLabel || "" : value || "", ref: forwardedRef, suffix: suffix, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: event => {
138
+ React.createElement(InputText_index.InputText, { "aria-describedby": activatorProps.ariaDescribedBy, "aria-invalid": activatorProps.ariaInvalid === "true" ? true : false, "aria-labelledby": activatorProps.ariaLabelledBy, "aria-required": activatorProps.ariaRequired === "true" ? true : false, id: activatorProps.id, disabled: props.disabled, error: props.error, readOnly: props.readOnly, placeholder: props.placeholder, size: props.size, inline: props.inline, align: props.align, description: props.description, invalid: props.invalid, name: props.name, version: 2, value: showEmptyValueLabel ? props.emptyValueLabel || "" : value || "", ref: forwardedRef, suffix: suffix, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: event => {
135
139
  var _a, _b;
136
140
  if (props.showIcon === false && event.key === "ArrowDown") {
137
141
  (_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
@@ -11,12 +11,12 @@ import '../Button-es.js';
11
11
  import { D as DatePicker } from '../DatePicker-es.js';
12
12
  import { InputText } from '../InputText/index.mjs';
13
13
  import '../_commonjsHelpers-es.js';
14
- import '../_getAllKeys-es.js';
14
+ import '../_baseGet-es.js';
15
15
  import '../isTypedArray-es.js';
16
16
  import '../isObjectLike-es.js';
17
- import '../isSymbol-es.js';
18
17
  import '../identity-es.js';
19
18
  import '../_getTag-es.js';
19
+ import '../isSymbol-es.js';
20
20
  import '../keysIn-es.js';
21
21
  import '../_baseAssignValue-es.js';
22
22
  import '../_baseFlatten-es.js';
@@ -77,9 +77,13 @@ function InputDate$1(inputProps) {
77
77
  } }));
78
78
  }
79
79
 
80
+ /**
81
+ * Combines the actions on the InputDate such as onChange, onFocus, onBlur to forward event handler passed to the InputDate component to the DatePicker component.
82
+ * 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.
83
+ */
80
84
  function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
81
85
  const [isFocused, setIsFocused] = useState(false);
82
- function handleChange(_newValue, event) {
86
+ function handleChange(_, event) {
83
87
  onChange === null || onChange === void 0 ? void 0 : onChange(event);
84
88
  }
85
89
  function handleFocus(event) {
@@ -87,8 +91,8 @@ function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
87
91
  setIsFocused(true);
88
92
  }
89
93
  function handleBlur(event) {
90
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
91
94
  setIsFocused(false);
95
+ onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
92
96
  }
93
97
  return {
94
98
  handleBlur,
@@ -129,7 +133,7 @@ const InputDateRebuilt = forwardRef((props, forwardedRef) => {
129
133
  return (
130
134
  // We prevent the picker from opening on focus for keyboard navigation, so to maintain a good UX for mouse users we want to open the picker on click
131
135
  React__default.createElement("div", { onClick: onClick },
132
- React__default.createElement(InputText, { "aria-describedby": activatorProps.ariaDescribedBy, "aria-labelledby": activatorProps.ariaLabelledBy, "aria-required": activatorProps.ariaRequired === "true" ? true : false, id: activatorProps.id, disabled: props.disabled, error: props.error, readOnly: props.readOnly, placeholder: props.placeholder, size: props.size, inline: props.inline, align: props.align, description: props.description, invalid: props.invalid, name: props.name, version: 2, value: showEmptyValueLabel ? props.emptyValueLabel || "" : value || "", ref: forwardedRef, suffix: suffix, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: event => {
136
+ React__default.createElement(InputText, { "aria-describedby": activatorProps.ariaDescribedBy, "aria-invalid": activatorProps.ariaInvalid === "true" ? true : false, "aria-labelledby": activatorProps.ariaLabelledBy, "aria-required": activatorProps.ariaRequired === "true" ? true : false, id: activatorProps.id, disabled: props.disabled, error: props.error, readOnly: props.readOnly, placeholder: props.placeholder, size: props.size, inline: props.inline, align: props.align, description: props.description, invalid: props.invalid, name: props.name, version: 2, value: showEmptyValueLabel ? props.emptyValueLabel || "" : value || "", ref: forwardedRef, suffix: suffix, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: event => {
133
137
  var _a, _b;
134
138
  if (props.showIcon === false && event.key === "ArrowDown") {
135
139
  (_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
@@ -1,12 +1,16 @@
1
- import type { ChangeEvent } from "react";
1
+ import type { ChangeEvent, FocusEvent } from "react";
2
2
  import type { InputDateRebuiltProps } from "./InputDate.types";
3
3
  import type { DatePickerActivatorProps } from "../DatePicker/DatePickerActivator";
4
4
  export interface useInputDateActivatorActionsProps extends Pick<InputDateRebuiltProps, "onFocus" | "onBlur"> {
5
5
  onChange: DatePickerActivatorProps["onChange"];
6
6
  }
7
+ /**
8
+ * Combines the actions on the InputDate such as onChange, onFocus, onBlur to forward event handler passed to the InputDate component to the DatePicker component.
9
+ * 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.
10
+ */
7
11
  export declare function useInputDateActivatorActions({ onChange, onBlur, onFocus, }: useInputDateActivatorActionsProps): {
8
- handleBlur: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
9
- handleChange: (_newValue: string, event?: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
10
- handleFocus: (event: React.FocusEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
12
+ handleBlur: (event: FocusEvent<HTMLInputElement>) => void;
13
+ handleChange: (_: unknown, event?: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
14
+ handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
11
15
  isFocused: boolean;
12
16
  };
@@ -1,5 +1,5 @@
1
+ import type { Clearable } from "@jobber/hooks";
1
2
  import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
2
- import type { FocusEvents, HTMLInputBaseProps, InputLengthConstraint, KeyboardEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
3
3
  export type InputEmailLegacyProps = CommonFormFieldProps & Pick<FormFieldProps, "maxLength" | "readonly" | "validations" | "defaultValue">;
4
4
  export declare const validationMessage = "Please enter a valid email";
5
5
  export type InputEmailVersion = 1 | 2 | undefined;
@@ -7,19 +7,27 @@ export type InputEmailVersion = 1 | 2 | undefined;
7
7
  * Experimental version 2 of the InputEmail component.
8
8
  * Do not use unless you have talked with Atlantis first.
9
9
  */
10
- export interface InputEmailRebuiltProps extends HTMLInputBaseProps, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, RebuiltInputCommonProps, InputLengthConstraint {
10
+ export interface InputEmailRebuiltProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "onBlur" | "size" | "suffix" | "prefix" | "value" | "max" | "min" | "defaultValue"> {
11
+ readonly error?: string;
12
+ readonly invalid?: boolean;
13
+ readonly identifier?: string;
14
+ readonly autocomplete?: boolean | string;
15
+ readonly loading?: boolean;
16
+ readonly onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
17
+ readonly children?: React.ReactNode;
18
+ readonly clearable?: Clearable;
11
19
  /**
12
- * The current value of the input.
13
- */
14
- readonly value?: string;
15
- /**
16
- * Custom onChange handler that provides the new value as the first argument.
20
+ * Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.
17
21
  */
22
+ readonly version: 2;
18
23
  readonly onChange?: (newValue: string, event?: React.ChangeEvent<HTMLInputElement>) => void;
19
- /**
20
- * A callback to handle "Enter" keypress. This will only run
21
- * if Enter is the only key. Will not run if Shift or Control
22
- * are being held.
23
- */
24
24
  readonly onEnter?: FormFieldProps["onEnter"];
25
+ readonly onBlur?: FormFieldProps["onBlur"];
26
+ readonly value?: string;
27
+ readonly size?: FormFieldProps["size"];
28
+ readonly inline?: FormFieldProps["inline"];
29
+ readonly align?: FormFieldProps["align"];
30
+ readonly prefix?: FormFieldProps["prefix"];
31
+ readonly suffix?: FormFieldProps["suffix"];
32
+ readonly description?: FormFieldProps["description"];
25
33
  }
@@ -8,5 +8,5 @@ export declare function useInputEmailActions({ onChange, inputRef, onEnter, onFo
8
8
  handleChange: (event: ChangeEvent<HTMLInputElement>) => void;
9
9
  handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
10
10
  handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
11
- handleBlur: (event: FocusEvent<HTMLInputElement>) => void;
11
+ handleBlur: (event?: FocusEvent) => void;
12
12
  };
@@ -0,0 +1,32 @@
1
+ import type { ChangeEvent, FocusEvent, KeyboardEvent, ReactNode } from "react";
2
+ export interface UseInputEmailFormFieldProps {
3
+ readonly id: string;
4
+ readonly name: string;
5
+ readonly disabled?: boolean;
6
+ readonly autofocus?: boolean;
7
+ readonly error?: string;
8
+ readonly inline?: boolean;
9
+ readonly description?: ReactNode;
10
+ readonly invalid?: boolean;
11
+ readonly value?: string;
12
+ readonly handleChange: (event: ChangeEvent<HTMLInputElement>) => void;
13
+ readonly handleBlur: (event?: FocusEvent<HTMLInputElement>) => void;
14
+ readonly handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
15
+ readonly handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
16
+ }
17
+ export interface UseInputEmailFormFieldReturn {
18
+ readonly fieldProps: {
19
+ readonly id: string;
20
+ readonly name: string;
21
+ readonly disabled?: boolean;
22
+ readonly autofocus?: boolean;
23
+ readonly onChange: (event: ChangeEvent<HTMLInputElement>) => void;
24
+ readonly onBlur: (event?: FocusEvent<HTMLInputElement>) => void;
25
+ readonly onFocus: (event: FocusEvent<HTMLInputElement>) => void;
26
+ readonly onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
27
+ readonly value?: string;
28
+ readonly "aria-describedby"?: string;
29
+ };
30
+ readonly descriptionIdentifier: string;
31
+ }
32
+ export declare function useInputEmailFormField({ id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, handleKeyDown, error, ...rest }: UseInputEmailFormFieldProps): UseInputEmailFormFieldReturn;
@@ -3,12 +3,13 @@
3
3
  var React = require('react');
4
4
  var FormField = require('../FormField-cjs.js');
5
5
  require('classnames');
6
- require('../tslib.es6-cjs.js');
6
+ var tslib_es6 = require('../tslib.es6-cjs.js');
7
7
  require('react-hook-form');
8
8
  require('@jobber/hooks');
9
9
  require('framer-motion');
10
10
  require('@jobber/design');
11
11
  require('../Button-cjs.js');
12
+ var omit = require('../omit-cjs.js');
12
13
  require('../Icon-cjs.js');
13
14
  require('../Text-cjs.js');
14
15
  require('../Typography-cjs.js');
@@ -16,6 +17,17 @@ require('../useFormFieldFocus-cjs.js');
16
17
  require('../InputValidation-cjs.js');
17
18
  require('../Spinner-cjs.js');
18
19
  require('react-router-dom');
20
+ require('../_commonjsHelpers-cjs.js');
21
+ require('../_baseGet-cjs.js');
22
+ require('../isTypedArray-cjs.js');
23
+ require('../isObjectLike-cjs.js');
24
+ require('../identity-cjs.js');
25
+ require('../_getTag-cjs.js');
26
+ require('../isSymbol-cjs.js');
27
+ require('../keysIn-cjs.js');
28
+ require('../_baseAssignValue-cjs.js');
29
+ require('../_baseFlatten-cjs.js');
30
+ require('../_setToString-cjs.js');
19
31
 
20
32
  const validationMessage = "Please enter a valid email";
21
33
 
@@ -37,6 +49,7 @@ function InputEmail$1(props) {
37
49
  function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
38
50
  function handleClear() {
39
51
  var _a;
52
+ handleBlur();
40
53
  onChange === null || onChange === void 0 ? void 0 : onChange("");
41
54
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
42
55
  }
@@ -70,10 +83,19 @@ function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, on
70
83
  };
71
84
  }
72
85
 
86
+ function useInputEmailFormField(_a) {
87
+ var { id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = tslib_es6.__rest(_a, ["id", "name", "disabled", "autofocus", "description", "inline", "value", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
88
+ const descriptionIdentifier = `descriptionUUID--${id}`;
89
+ const fieldProps = Object.assign(Object.assign(Object.assign({}, rest), { id,
90
+ name,
91
+ disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
92
+ !inline && { "aria-describedby": descriptionIdentifier }));
93
+ return { fieldProps, descriptionIdentifier };
94
+ }
95
+
73
96
  const InputEmailRebuilt = React.forwardRef(function InputEmailInternal(props, ref) {
74
97
  var _a, _b, _c;
75
- const generatedId = React.useId();
76
- const id = props.id || generatedId;
98
+ const id = React.useId();
77
99
  const inputRef = (_a = ref) !== null && _a !== void 0 ? _a : React.useRef(null);
78
100
  const wrapperRef = React.useRef(null);
79
101
  const { inputStyle } = FormField.useFormFieldWrapperStyles({
@@ -100,11 +122,25 @@ const InputEmailRebuilt = React.forwardRef(function InputEmailInternal(props, re
100
122
  onEnter: props.onEnter,
101
123
  inputRef,
102
124
  });
103
- const descriptionIdentifier = `descriptionUUID--${id}`;
104
- const hasDescription = props.description && !props.inline;
105
- const isInvalid = Boolean(props.error || props.invalid);
106
- return (React.createElement(FormField.FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, maxLength: props.maxLength, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, autofocus: props.autoFocus, name: name },
107
- React.createElement("input", { id: id, name: name, type: "email", ref: inputRef, className: inputStyle, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, maxLength: props.maxLength, pattern: props.pattern, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props.ariaLabel, "aria-describedby": hasDescription ? descriptionIdentifier : props.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-controls": props.ariaControls, "aria-expanded": props.ariaExpanded, "aria-activedescendant": props.ariaActiveDescendant, "aria-autocomplete": props.ariaAutocomplete, "aria-required": props.ariaRequired, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: props.onKeyUp, "data-testid": "ATL-InputEmail-input" }),
125
+ const inputProps = omit.omit(props, [
126
+ "placeholder",
127
+ "onChange",
128
+ "onBlur",
129
+ "onFocus",
130
+ "onEnter",
131
+ "size",
132
+ "prefix",
133
+ "suffix",
134
+ "version",
135
+ ]);
136
+ const { fieldProps, descriptionIdentifier } = useInputEmailFormField(Object.assign(Object.assign({}, inputProps), { id,
137
+ name,
138
+ handleChange,
139
+ handleBlur,
140
+ handleFocus,
141
+ handleKeyDown }));
142
+ return (React.createElement(FormField.FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: props.identifier || id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, maxLength: props.maxLength, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, autofocus: props.autoFocus, name: name },
143
+ React.createElement("input", Object.assign({}, fieldProps, { ref: inputRef, type: "email", className: inputStyle, value: props.value, "data-testid": "ATL-InputEmail-input" })),
108
144
  React.createElement(FormField.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
109
145
  props.children));
110
146
  });
@@ -1,12 +1,13 @@
1
1
  import React__default, { forwardRef, useId, useRef } from 'react';
2
2
  import { k as FormField, j as useFormFieldWrapperStyles, b as useAtlantisFormFieldName, f as FormFieldWrapper, l as FormFieldPostFix } from '../FormField-es.js';
3
3
  import 'classnames';
4
- import '../tslib.es6-es.js';
4
+ import { _ as __rest } from '../tslib.es6-es.js';
5
5
  import 'react-hook-form';
6
6
  import '@jobber/hooks';
7
7
  import 'framer-motion';
8
8
  import '@jobber/design';
9
9
  import '../Button-es.js';
10
+ import { o as omit } from '../omit-es.js';
10
11
  import '../Icon-es.js';
11
12
  import '../Text-es.js';
12
13
  import '../Typography-es.js';
@@ -14,6 +15,17 @@ import '../useFormFieldFocus-es.js';
14
15
  import '../InputValidation-es.js';
15
16
  import '../Spinner-es.js';
16
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';
17
29
 
18
30
  const validationMessage = "Please enter a valid email";
19
31
 
@@ -35,6 +47,7 @@ function InputEmail$1(props) {
35
47
  function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, onKeyDown, }) {
36
48
  function handleClear() {
37
49
  var _a;
50
+ handleBlur();
38
51
  onChange === null || onChange === void 0 ? void 0 : onChange("");
39
52
  (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
40
53
  }
@@ -68,10 +81,19 @@ function useInputEmailActions({ onChange, inputRef, onEnter, onFocus, onBlur, on
68
81
  };
69
82
  }
70
83
 
84
+ function useInputEmailFormField(_a) {
85
+ var { id, name, disabled, autofocus, description, inline, value, handleChange, handleBlur, handleFocus, handleKeyDown, error } = _a, rest = __rest(_a, ["id", "name", "disabled", "autofocus", "description", "inline", "value", "handleChange", "handleBlur", "handleFocus", "handleKeyDown", "error"]);
86
+ const descriptionIdentifier = `descriptionUUID--${id}`;
87
+ const fieldProps = Object.assign(Object.assign(Object.assign({}, rest), { id,
88
+ name,
89
+ disabled, autoFocus: autofocus, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, value, invalid: error || rest.invalid ? "true" : undefined }), (description &&
90
+ !inline && { "aria-describedby": descriptionIdentifier }));
91
+ return { fieldProps, descriptionIdentifier };
92
+ }
93
+
71
94
  const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
72
95
  var _a, _b, _c;
73
- const generatedId = useId();
74
- const id = props.id || generatedId;
96
+ const id = useId();
75
97
  const inputRef = (_a = ref) !== null && _a !== void 0 ? _a : useRef(null);
76
98
  const wrapperRef = useRef(null);
77
99
  const { inputStyle } = useFormFieldWrapperStyles({
@@ -98,11 +120,25 @@ const InputEmailRebuilt = forwardRef(function InputEmailInternal(props, ref) {
98
120
  onEnter: props.onEnter,
99
121
  inputRef,
100
122
  });
101
- const descriptionIdentifier = `descriptionUUID--${id}`;
102
- const hasDescription = props.description && !props.inline;
103
- const isInvalid = Boolean(props.error || props.invalid);
104
- return (React__default.createElement(FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, maxLength: props.maxLength, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, autofocus: props.autoFocus, name: name },
105
- React__default.createElement("input", { id: id, name: name, type: "email", ref: inputRef, className: inputStyle, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, maxLength: props.maxLength, pattern: props.pattern, inputMode: props.inputMode, tabIndex: props.tabIndex, role: props.role, "aria-label": props.ariaLabel, "aria-describedby": hasDescription ? descriptionIdentifier : props.ariaDescribedBy, "aria-invalid": isInvalid ? true : undefined, "aria-controls": props.ariaControls, "aria-expanded": props.ariaExpanded, "aria-activedescendant": props.ariaActiveDescendant, "aria-autocomplete": props.ariaAutocomplete, "aria-required": props.ariaRequired, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: props.onKeyUp, "data-testid": "ATL-InputEmail-input" }),
123
+ const inputProps = omit(props, [
124
+ "placeholder",
125
+ "onChange",
126
+ "onBlur",
127
+ "onFocus",
128
+ "onEnter",
129
+ "size",
130
+ "prefix",
131
+ "suffix",
132
+ "version",
133
+ ]);
134
+ const { fieldProps, descriptionIdentifier } = useInputEmailFormField(Object.assign(Object.assign({}, inputProps), { id,
135
+ name,
136
+ handleChange,
137
+ handleBlur,
138
+ handleFocus,
139
+ handleKeyDown }));
140
+ return (React__default.createElement(FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: props.identifier || id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, wrapperRef: wrapperRef, maxLength: props.maxLength, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, autofocus: props.autoFocus, name: name },
141
+ React__default.createElement("input", Object.assign({}, fieldProps, { ref: inputRef, type: "email", className: inputStyle, value: props.value, "data-testid": "ATL-InputEmail-input" })),
106
142
  React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }),
107
143
  props.children));
108
144
  });
@@ -1,39 +1,22 @@
1
1
  import type { ReactNode } from "react";
2
2
  import type React from "react";
3
3
  import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
4
- import type { AriaInputProps, FocusEvents, InputConstraintProps, KeyboardEvents } from "../sharedHelpers/types";
5
4
  export type InputNumberVersion = 1 | 2 | undefined;
6
- export interface InputNumberRebuiltProps extends Omit<CommonFormFieldProps, "version">, AriaInputProps, FocusEvents<HTMLInputElement>, KeyboardEvents<HTMLInputElement>, InputConstraintProps {
5
+ export interface InputNumberRebuiltProps extends Omit<CommonFormFieldProps, "version">, Pick<FormFieldProps, "onFocus" | "onBlur" | "inputRef" | "readonly" | "size"> {
7
6
  readonly align?: "center" | "right";
8
- /**
9
- * HTML autocomplete attribute for browser autofill.
10
- */
11
- readonly autoComplete?: string;
7
+ readonly autocomplete?: boolean;
12
8
  readonly autoFocus?: boolean;
13
9
  readonly defaultValue?: number;
14
10
  readonly description?: ReactNode;
15
11
  readonly error?: string;
16
12
  readonly formatOptions?: Intl.NumberFormatOptions;
17
- /**
18
- * The ID of the input element.
19
- */
20
- readonly id?: string;
13
+ readonly identifier?: string;
21
14
  readonly inline?: boolean;
22
15
  readonly invalid?: boolean;
23
16
  readonly maxValue?: number;
24
17
  readonly minValue?: number;
25
- /**
26
- * Callback for value changes.
27
- * @param newValue - The new numeric value
28
- * @param event - Optional change event
29
- */
30
18
  readonly onChange?: (newValue: number, event?: React.ChangeEvent<HTMLInputElement>) => void;
31
- /**
32
- * Whether the input is read-only.
33
- */
34
- readonly readOnly?: boolean;
35
19
  readonly showMiniLabel?: boolean;
36
- readonly size?: FormFieldProps["size"];
37
20
  readonly value?: number;
38
21
  /**
39
22
  * Version 2 is highly experimental. Avoid using it unless you have talked with Atlantis first.