@jobber/components 7.5.0 → 7.7.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 (56) hide show
  1. package/dist/Autocomplete/index.cjs +6 -5
  2. package/dist/Autocomplete/index.mjs +3 -2
  3. package/dist/DataList/components/DataListSearch/index.cjs +1 -0
  4. package/dist/DataList/components/DataListSearch/index.mjs +1 -0
  5. package/dist/DataList/index.cjs +1 -0
  6. package/dist/DataList/index.mjs +1 -0
  7. package/dist/DataTable/index.cjs +2 -14
  8. package/dist/DataTable/index.mjs +2 -14
  9. package/dist/DataTable-cjs.js +3 -3
  10. package/dist/DataTable-es.js +1 -1
  11. package/dist/FormField/index.cjs +14 -13
  12. package/dist/FormField/index.mjs +5 -4
  13. package/dist/FormField-cjs.js +8 -281
  14. package/dist/FormField-es.js +3 -263
  15. package/dist/InputDate/InputDate.d.ts +1 -1
  16. package/dist/InputDate/InputDate.types.d.ts +2 -30
  17. package/dist/InputDate/index.cjs +22 -163
  18. package/dist/InputDate/index.d.ts +2 -4
  19. package/dist/InputDate/index.mjs +21 -166
  20. package/dist/InputDate/useInputDateActivatorActions.d.ts +2 -2
  21. package/dist/InputDate-cjs.js +96 -0
  22. package/dist/InputDate-es.js +94 -0
  23. package/dist/InputEmail/index.cjs +7 -6
  24. package/dist/InputEmail/index.mjs +4 -3
  25. package/dist/InputNumber/index.cjs +1 -0
  26. package/dist/InputNumber/index.mjs +2 -1
  27. package/dist/InputPassword/index.cjs +1 -0
  28. package/dist/InputPassword/index.mjs +1 -0
  29. package/dist/InputPassword-es.js +1 -1
  30. package/dist/InputPhoneNumber/index.cjs +6 -5
  31. package/dist/InputPhoneNumber/index.mjs +2 -1
  32. package/dist/InputText/index.cjs +8 -7
  33. package/dist/InputText/index.mjs +4 -3
  34. package/dist/InputTime/index.cjs +5 -4
  35. package/dist/InputTime/index.mjs +2 -1
  36. package/dist/RecurringSelect/index.cjs +3 -14
  37. package/dist/RecurringSelect/index.mjs +3 -14
  38. package/dist/RecurringSelect-cjs.js +6 -6
  39. package/dist/RecurringSelect-es.js +1 -1
  40. package/dist/Select/Select.d.ts +6 -2
  41. package/dist/Select/Select.types.d.ts +2 -16
  42. package/dist/Select/index.cjs +11 -103
  43. package/dist/Select/index.d.ts +2 -9
  44. package/dist/Select/index.mjs +9 -105
  45. package/dist/Select-cjs.js +78 -0
  46. package/dist/Select-es.js +75 -0
  47. package/dist/docs/InputDate/InputDate.md +31 -19
  48. package/dist/docs/Select/Select.md +69 -33
  49. package/dist/docs/usage-guidelines/usage-guidelines.md +9 -13
  50. package/dist/index.cjs +16 -15
  51. package/dist/index.mjs +4 -3
  52. package/dist/mergeRefs-cjs.js +279 -0
  53. package/dist/mergeRefs-es.js +265 -0
  54. package/package.json +2 -2
  55. package/dist/InputDate/InputDate.rebuilt.d.ts +0 -3
  56. package/dist/Select/Select.rebuilt.d.ts +0 -3
@@ -13,7 +13,7 @@ var Typography = require('../Typography-cjs.js');
13
13
  var Icon = require('../Icon-cjs.js');
14
14
  var Glimmer = require('../Glimmer-cjs.js');
15
15
  var InputText_index = require('../InputText/index.cjs');
16
- var FormField = require('../FormField-cjs.js');
16
+ var mergeRefs = require('../mergeRefs-cjs.js');
17
17
  var tslib_es6 = require('../tslib.es6-cjs.js');
18
18
  require('react-hook-form');
19
19
  require('../Button-cjs.js');
@@ -22,11 +22,12 @@ require('../index.esm-cjs.js');
22
22
  require('react/jsx-runtime');
23
23
  require('react-dom');
24
24
  require('../Content-cjs.js');
25
+ require('../FormField-cjs.js');
25
26
  require('framer-motion');
27
+ require('react-router-dom');
26
28
  require('../useFormFieldFocus-cjs.js');
27
29
  require('../InputValidation-cjs.js');
28
30
  require('../Spinner-cjs.js');
29
- require('react-router-dom');
30
31
 
31
32
  const AUTOCOMPLETE_MAX_HEIGHT$1 = 300;
32
33
  /** Stable empty array for cleared/empty selection state. Reuse to avoid reference churn. */
@@ -1209,7 +1210,7 @@ function AutocompleteRebuiltInternal(props, forwardedRef) {
1209
1210
  }
1210
1211
  }
1211
1212
  }, [setReferenceElement, props.multiple]);
1212
- const mergedInputRef = React.useMemo(() => FormField.mergeRefs([
1213
+ const mergedInputRef = React.useMemo(() => mergeRefs.mergeRefs([
1213
1214
  referenceInputRef,
1214
1215
  internalInputRef,
1215
1216
  forwardedRef,
@@ -1299,7 +1300,7 @@ function MultipleSelectionLayout({ selectedValues, inputValue, disabled, error,
1299
1300
  }, []);
1300
1301
  return (React.createElement("div", { "data-testid": "ATL-AutocompleteRebuilt", onFocus: handleFocusIn, onBlur: handleFocusOut },
1301
1302
  React.createElement("div", { className: styles$1.multiSelectField, "data-testid": "ATL-AutocompleteRebuilt-multiSelectContainer" },
1302
- React.createElement(FormField.FormFieldWrapper, { disabled: disabled, size: sizeProp ? sizeProp : undefined, error: (_a = error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(error || invalid), identifier: inputId, descriptionIdentifier: descriptionId, description: description, clearable: clearable !== null && clearable !== void 0 ? clearable : "never", onClear: () => {
1303
+ React.createElement(mergeRefs.FormFieldWrapper, { disabled: disabled, size: sizeProp ? sizeProp : undefined, error: (_a = error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(error || invalid), identifier: inputId, descriptionIdentifier: descriptionId, description: description, clearable: clearable !== null && clearable !== void 0 ? clearable : "never", onClear: () => {
1303
1304
  var _a;
1304
1305
  clearAll();
1305
1306
  (_a = internalInputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
@@ -1583,7 +1584,7 @@ function AutocompleteInternal(_a, ref) {
1583
1584
  updateInput((_a = value === null || value === void 0 ? void 0 : value.label) !== null && _a !== void 0 ? _a : "");
1584
1585
  }, [value]);
1585
1586
  return (React.createElement("div", { className: styles.autocomplete, ref: setAutocompleteRef },
1586
- React.createElement(InputText_index.InputText, Object.assign({ ref: FormField.mergeRefs([ref, inputRef]), autocomplete: false, size: size, value: inputText, onChange: handleInputChange, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur, validations: validations }, inputProps)),
1587
+ React.createElement(InputText_index.InputText, Object.assign({ ref: mergeRefs.mergeRefs([ref, inputRef]), autocomplete: false, size: size, value: inputText, onChange: handleInputChange, placeholder: placeholder, onFocus: handleInputFocus, onBlur: handleInputBlur, validations: validations }, inputProps)),
1587
1588
  React.createElement(Menu, { attachTo: autocompleteRef, inputRef: inputRef, inputFocused: inputFocused, options: options, customRenderMenu: customRenderMenu, selectedOption: value, onOptionSelect: handleMenuChange })));
1588
1589
  function updateInput(newText) {
1589
1590
  setInputText(newText);
@@ -11,7 +11,7 @@ import { T as Typography } from '../Typography-es.js';
11
11
  import { I as Icon } from '../Icon-es.js';
12
12
  import { G as Glimmer } from '../Glimmer-es.js';
13
13
  import { InputText } from '../InputText/index.mjs';
14
- import { n as mergeRefs, f as FormFieldWrapper } from '../FormField-es.js';
14
+ import { m as mergeRefs, c as FormFieldWrapper } from '../mergeRefs-es.js';
15
15
  import { _ as __rest, a as __awaiter } from '../tslib.es6-es.js';
16
16
  import 'react-hook-form';
17
17
  import '../Button-es.js';
@@ -20,11 +20,12 @@ import '../index.esm-es.js';
20
20
  import 'react/jsx-runtime';
21
21
  import 'react-dom';
22
22
  import '../Content-es.js';
23
+ import '../FormField-es.js';
23
24
  import 'framer-motion';
25
+ import 'react-router-dom';
24
26
  import '../useFormFieldFocus-es.js';
25
27
  import '../InputValidation-es.js';
26
28
  import '../Spinner-es.js';
27
- import 'react-router-dom';
28
29
 
29
30
  const AUTOCOMPLETE_MAX_HEIGHT$1 = 300;
30
31
  /** Stable empty array for cleared/empty selection state. Reuse to avoid reference churn. */
@@ -7,6 +7,7 @@ require('@jobber/design');
7
7
  require('@jobber/hooks');
8
8
  require('../../../InputText/index.cjs');
9
9
  require('../../../FormField-cjs.js');
10
+ require('../../../mergeRefs-cjs.js');
10
11
  require('framer-motion');
11
12
  require('../../../Button-cjs.js');
12
13
  require('../../../tslib.es6-cjs.js');
@@ -5,6 +5,7 @@ import '@jobber/design';
5
5
  import '@jobber/hooks';
6
6
  import '../../../InputText/index.mjs';
7
7
  import '../../../FormField-es.js';
8
+ import '../../../mergeRefs-es.js';
8
9
  import 'framer-motion';
9
10
  import '../../../Button-es.js';
10
11
  import '../../../tslib.es6-es.js';
@@ -81,6 +81,7 @@ require('../DataListStickyHeader-cjs.js');
81
81
  require('../DataListSearch-cjs.js');
82
82
  require('../InputText/index.cjs');
83
83
  require('../FormField-cjs.js');
84
+ require('../mergeRefs-cjs.js');
84
85
  require('../useFormFieldFocus-cjs.js');
85
86
  require('../InputValidation-cjs.js');
86
87
  require('react-hook-form');
@@ -79,6 +79,7 @@ import '../DataListStickyHeader-es.js';
79
79
  import '../DataListSearch-es.js';
80
80
  import '../InputText/index.mjs';
81
81
  import '../FormField-es.js';
82
+ import '../mergeRefs-es.js';
82
83
  import '../useFormFieldFocus-es.js';
83
84
  import '../InputValidation-es.js';
84
85
  import 'react-hook-form';
@@ -10,20 +10,8 @@ require('@jobber/hooks');
10
10
  require('../Glimmer-cjs.js');
11
11
  require('../tslib.es6-cjs.js');
12
12
  require('../Content-cjs.js');
13
- require('../Select/index.cjs');
14
- require('../omit-cjs.js');
15
- require('../_commonjsHelpers-cjs.js');
16
- require('../_getAllKeys-cjs.js');
17
- require('../isTypedArray-cjs.js');
18
- require('../isObjectLike-cjs.js');
19
- require('../isSymbol-cjs.js');
20
- require('../identity-cjs.js');
21
- require('../_getTag-cjs.js');
22
- require('../keysIn-cjs.js');
23
- require('../_baseAssignValue-cjs.js');
24
- require('../_baseFlatten-cjs.js');
25
- require('../_setToString-cjs.js');
26
- require('../FormField-cjs.js');
13
+ require('../Select-cjs.js');
14
+ require('../mergeRefs-cjs.js');
27
15
  require('framer-motion');
28
16
  require('@jobber/design');
29
17
  require('../Button-cjs.js');
@@ -8,20 +8,8 @@ import '@jobber/hooks';
8
8
  import '../Glimmer-es.js';
9
9
  import '../tslib.es6-es.js';
10
10
  import '../Content-es.js';
11
- import '../Select/index.mjs';
12
- import '../omit-es.js';
13
- import '../_commonjsHelpers-es.js';
14
- import '../_getAllKeys-es.js';
15
- import '../isTypedArray-es.js';
16
- import '../isObjectLike-es.js';
17
- import '../isSymbol-es.js';
18
- import '../identity-es.js';
19
- import '../_getTag-es.js';
20
- import '../keysIn-es.js';
21
- import '../_baseAssignValue-es.js';
22
- import '../_baseFlatten-es.js';
23
- import '../_setToString-es.js';
24
- import '../FormField-es.js';
11
+ import '../Select-es.js';
12
+ import '../mergeRefs-es.js';
25
13
  import 'framer-motion';
26
14
  import '@jobber/design';
27
15
  import '../Button-es.js';
@@ -6,7 +6,7 @@ var React = require('react');
6
6
  var jobberHooks = require('@jobber/hooks');
7
7
  var Glimmer = require('./Glimmer-cjs.js');
8
8
  var tslib_es6 = require('./tslib.es6-cjs.js');
9
- var Select_index = require('./Select/index.cjs');
9
+ var Select = require('./Select-cjs.js');
10
10
  var Button = require('./Button-cjs.js');
11
11
  var Text = require('./Text-cjs.js');
12
12
  var DataTableTable = require('./DataTableTable-cjs.js');
@@ -111,9 +111,9 @@ function Pagination({ table, itemsPerPage, totalItems, loading, onPageChange, })
111
111
  React.createElement("div", { className: styles$1.paginationInfo }, `Showing ${firstPosition}-${secondPosition} of ${totalRows} items`),
112
112
  React.createElement("div", { className: styles$1.paginationNav },
113
113
  React.createElement("div", { className: styles$1.paginationSelect },
114
- React.createElement(Select_index.Select, { value: table.getState().pagination.pageSize, onChange: value => {
114
+ React.createElement(Select.Select, { value: table.getState().pagination.pageSize, onChange: value => {
115
115
  table.setPageSize(Number(value));
116
- }, size: "small" }, itemsPerPageOptions.map(numOfPages => (React.createElement(Select_index.Option, { key: numOfPages, value: numOfPages }, numOfPages)))),
116
+ }, size: "small" }, itemsPerPageOptions.map(numOfPages => (React.createElement(Select.SelectOption, { key: numOfPages, value: numOfPages }, numOfPages)))),
117
117
  React.createElement("span", { className: styles$1.paginationSelectLabel }, "per page")),
118
118
  React.createElement("div", { className: styles$1.paginationButtons },
119
119
  React.createElement(Button.Button, { type: "secondary", variation: "subtle", icon: "arrowLeft", ariaLabel: "arrowLeft", onClick: () => {
@@ -4,7 +4,7 @@ import React__default, { useCallback, useMemo } from 'react';
4
4
  import { useResizeObserver, Breakpoints } from '@jobber/hooks';
5
5
  import { G as Glimmer } from './Glimmer-es.js';
6
6
  import { _ as __rest } from './tslib.es6-es.js';
7
- import { Select, Option as SelectOption } from './Select/index.mjs';
7
+ import { a as Select, S as SelectOption } from './Select-es.js';
8
8
  import { B as Button } from './Button-es.js';
9
9
  import { T as Text } from './Text-es.js';
10
10
  import { S as SortIcon, a as SortDirection, m as DataTableTable, f as DataTableHeader, g as DataTableHeaderCell, j as DataTableRow, c as DataTableCell, k as DataTableRowActions, D as DataTableActions, b as DataTableBody, d as DataTableContainer, l as DataTableSortableHeader, e as DataTableFooter, h as DataTablePagination, i as DataTablePaginationButton } from './DataTableTable-es.js';
@@ -1,13 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var FormField = require('../FormField-cjs.js');
4
+ var mergeRefs = require('../mergeRefs-cjs.js');
4
5
  require('react');
6
+ require('classnames');
7
+ require('../tslib.es6-cjs.js');
8
+ require('react-hook-form');
5
9
  require('@jobber/hooks');
6
10
  require('framer-motion');
7
11
  require('@jobber/design');
8
- require('classnames');
9
12
  require('../Button-cjs.js');
10
- require('../tslib.es6-cjs.js');
11
13
  require('react-router-dom');
12
14
  require('../Icon-cjs.js');
13
15
  require('../Typography-cjs.js');
@@ -15,21 +17,20 @@ require('../Text-cjs.js');
15
17
  require('../useFormFieldFocus-cjs.js');
16
18
  require('../InputValidation-cjs.js');
17
19
  require('../Spinner-cjs.js');
18
- require('react-hook-form');
19
20
 
20
21
 
21
22
 
22
- exports.AffixIcon = FormField.AffixIcon;
23
- exports.AffixLabel = FormField.AffixLabel;
24
23
  exports.FormField = FormField.FormField;
25
- exports.FormFieldInputHorizontalWrapper = FormField.FormFieldInputHorizontalWrapper;
26
- exports.FormFieldInputWrapperStyles = FormField.FormFieldInputWrapperStyles;
27
- exports.FormFieldLabel = FormField.FormFieldLabel;
28
- exports.FormFieldWrapper = FormField.FormFieldWrapper;
29
- exports.FormFieldWrapperMain = FormField.FormFieldWrapperMain;
30
- exports.FormFieldWrapperToolbar = FormField.FormFieldWrapperToolbar;
31
24
  exports.useAtlantisFormField = FormField.useAtlantisFormField;
32
25
  exports.useAtlantisFormFieldActions = FormField.useAtlantisFormFieldActions;
33
- exports.useAtlantisFormFieldName = FormField.useAtlantisFormFieldName;
34
26
  exports.useAtlantisReactHookForm = FormField.useAtlantisReactHookForm;
35
- exports.useFormFieldWrapperStyles = FormField.useFormFieldWrapperStyles;
27
+ exports.AffixIcon = mergeRefs.AffixIcon;
28
+ exports.AffixLabel = mergeRefs.AffixLabel;
29
+ exports.FormFieldInputHorizontalWrapper = mergeRefs.FormFieldInputHorizontalWrapper;
30
+ exports.FormFieldInputWrapperStyles = mergeRefs.FormFieldInputWrapperStyles;
31
+ exports.FormFieldLabel = mergeRefs.FormFieldLabel;
32
+ exports.FormFieldWrapper = mergeRefs.FormFieldWrapper;
33
+ exports.FormFieldWrapperMain = mergeRefs.FormFieldWrapperMain;
34
+ exports.FormFieldWrapperToolbar = mergeRefs.FormFieldWrapperToolbar;
35
+ exports.useAtlantisFormFieldName = mergeRefs.useAtlantisFormFieldName;
36
+ exports.useFormFieldWrapperStyles = mergeRefs.useFormFieldWrapperStyles;
@@ -1,11 +1,13 @@
1
- export { A as AffixIcon, i as AffixLabel, k as FormField, F as FormFieldInputHorizontalWrapper, d as FormFieldInputWrapperStyles, e as FormFieldLabel, f as FormFieldWrapper, g as FormFieldWrapperMain, h as FormFieldWrapperToolbar, u as useAtlantisFormField, a as useAtlantisFormFieldActions, b as useAtlantisFormFieldName, c as useAtlantisReactHookForm, j as useFormFieldWrapperStyles } from '../FormField-es.js';
1
+ export { F as FormField, u as useAtlantisFormField, a as useAtlantisFormFieldActions, b as useAtlantisReactHookForm } from '../FormField-es.js';
2
+ export { A as AffixIcon, f as AffixLabel, F as FormFieldInputHorizontalWrapper, a as FormFieldInputWrapperStyles, b as FormFieldLabel, c as FormFieldWrapper, d as FormFieldWrapperMain, e as FormFieldWrapperToolbar, u as useAtlantisFormFieldName, g as useFormFieldWrapperStyles } from '../mergeRefs-es.js';
2
3
  import 'react';
4
+ import 'classnames';
5
+ import '../tslib.es6-es.js';
6
+ import 'react-hook-form';
3
7
  import '@jobber/hooks';
4
8
  import 'framer-motion';
5
9
  import '@jobber/design';
6
- import 'classnames';
7
10
  import '../Button-es.js';
8
- import '../tslib.es6-es.js';
9
11
  import 'react-router-dom';
10
12
  import '../Icon-es.js';
11
13
  import '../Typography-es.js';
@@ -13,4 +15,3 @@ import '../Text-es.js';
13
15
  import '../useFormFieldFocus-es.js';
14
16
  import '../InputValidation-es.js';
15
17
  import '../Spinner-es.js';
16
- import 'react-hook-form';
@@ -1,244 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
- var jobberHooks = require('@jobber/hooks');
5
- var framerMotion = require('framer-motion');
6
- var design = require('@jobber/design');
4
+ var mergeRefs = require('./mergeRefs-cjs.js');
7
5
  var classnames = require('classnames');
8
- var Button = require('./Button-cjs.js');
9
- var Icon = require('./Icon-cjs.js');
10
- var Text = require('./Text-cjs.js');
11
- var useFormFieldFocus = require('./useFormFieldFocus-cjs.js');
12
- var InputValidation = require('./InputValidation-cjs.js');
13
- var Spinner = require('./Spinner-cjs.js');
14
6
  var tslib_es6 = require('./tslib.es6-cjs.js');
15
7
  var reactHookForm = require('react-hook-form');
16
8
 
17
- var formFieldStyles = {"container":"YL-mNv-Bl6g-","wrapper":"_8lhbGTQ-hhg-","disabled":"Tz9LK9ABKMk-","horizontalWrapper":"b5mv1x1H7YE-","textarea":"hGr6YW4AeLM-","safari":"QBCWi9GBgMs-","timeInputLabel":"_0pmqVa2zSE4-","miniLabel":"F1t76G6bDKo-","large":"_9tjyT9QUtP8-","text":"QmMiyoAWp-g-","invalid":"XWDSfe6weSY-","small":"Sw5O4I0lMJg-","inline":"SaORbL7SYWY-","center":"ozy2UoT2vsg-","right":"_3TJdT91YD3c-","maxLength":"W6GrMqLy2qk-","inputWrapper":"-LmjnYRU0r0-","childrenWrapper":"yVXYv6hkuOA-","input":"vtSDcuzNr9Q-","emptyPhoneNumber":"MVhuQuzUBUs-","label":"Dgk00tzlODA-","select":"NwQGiWBWIsc-","externalLabel":"Qb8zQ8n-8vc-","postfix":"yTDzs9h1otI-","affixIcon":"m0YpdssD2dY-","suffix":"_-3mMnjSh6ok-","affixLabel":"-Wzcb0pBh5I-","description":"DHX5ijY3xIw-","toolbar":"AL-2brNI7dk-","spinning":"_8Rzv7CcDW80-"};
18
-
19
- /**
20
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
21
- */
22
- function AffixLabel({ label, variation = "prefix", labelRef, }) {
23
- const affixLabelClass = classnames(formFieldStyles.affixLabel, {
24
- [formFieldStyles.suffix]: variation === "suffix",
25
- });
26
- if (!label)
27
- return null;
28
- return (React.createElement("div", { ref: labelRef, className: affixLabelClass }, label));
29
- }
30
- function AffixIcon({ icon, onClick, ariaLabel, variation = "prefix", size, }) {
31
- const affixIconClass = classnames(formFieldStyles.affixIcon, {
32
- [formFieldStyles.suffix]: variation === "suffix",
33
- });
34
- const iconSize = size === "small" ? "small" : "base";
35
- if (!icon)
36
- return null;
37
- return (React.createElement("div", { className: affixIconClass }, onClick ? (React.createElement(Button.Button
38
- /**
39
- * We can cast the ariaLabel here as a `Suffix`
40
- * requires an ariaLabel if there is an action
41
- */
42
- , {
43
- /**
44
- * We can cast the ariaLabel here as a `Suffix`
45
- * requires an ariaLabel if there is an action
46
- */
47
- ariaLabel: ariaLabel, icon: icon, onClick: onClick, variation: "subtle", type: "tertiary", size: iconSize })) : (React.createElement(Icon.Icon, { name: icon, size: iconSize, color: "greyBlue" }))));
48
- }
49
-
50
- function FormFieldDescription({ id, description, visible = true, }) {
51
- if (!visible)
52
- return null;
53
- const useStringFormat = !description || typeof description === "string";
54
- return (React.createElement("div", { id: id, className: formFieldStyles.description }, useStringFormat ? (React.createElement(Text.Text, { size: "small", variation: "subdued" }, description)) : (description)));
55
- }
56
-
57
- var styles = {"clearInput":"YmRTd-KeXv4-","spinning":"B25z9B8I3gs-"};
58
-
59
- function ClearAction({ onClick, visible, }) {
60
- if (!visible)
61
- return null;
62
- return (React.createElement("button", { className: styles.clearInput, onClick: onClick, type: "button", "aria-label": "Clear input", "data-testid": "ATL-FormField-clearButton" },
63
- React.createElement(Icon.Icon, { name: "remove", size: "small" })));
64
- }
65
-
66
- function useToolbar(props) {
67
- const isToolbarVisible = props.toolbar !== undefined &&
68
- (props.toolbarVisibility === "always" || props.focused);
69
- const toolbarAnimationEnd = { opacity: 0, height: 0 };
70
- const toolbarAnimationStart = { opacity: 1, height: "auto" };
71
- return {
72
- isToolbarVisible,
73
- toolbarAnimationEnd,
74
- toolbarAnimationStart,
75
- };
76
- }
77
-
78
- function useIsSafari() {
79
- return (globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator)
80
- ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
81
- : false;
82
- }
83
-
84
- /**
85
- * Hook for getting the correct styles for the FormField and its children
86
- */
87
- function useFormFieldWrapperStyles({ size, align, placeholder, value, invalid, error, max, prefixRef, suffixRef, maxLength, type, disabled, inline, showMiniLabel = true, }) {
88
- const isSafari = useIsSafari();
89
- const wrapperClasses = classnames(formFieldStyles.wrapper, size && formFieldStyles[size], align && formFieldStyles[align], {
90
- [formFieldStyles.miniLabel]: (showMiniLabel && placeholder && value !== "") ||
91
- (placeholder && type === "select") ||
92
- // Naively assume that if the the type is tel, it is the InputPhoneNumber
93
- (placeholder && type === "tel"),
94
- [formFieldStyles.text]: type === "textarea" || type === "text",
95
- [formFieldStyles.textarea]: type === "textarea",
96
- [formFieldStyles.safari]: isSafari && type === "textarea",
97
- [formFieldStyles.select]: type === "select",
98
- [formFieldStyles.invalid]: invalid !== null && invalid !== void 0 ? invalid : error,
99
- [formFieldStyles.disabled]: disabled,
100
- [formFieldStyles.maxLength]: maxLength,
101
- [formFieldStyles.timeInputLabel]: placeholder && type === "time" && placeholder && value === "",
102
- });
103
- const containerClasses = classnames(formFieldStyles.container, {
104
- [formFieldStyles.inline]: inline,
105
- });
106
- const wrapperInlineStyle = {
107
- ["--formField-maxLength"]: maxLength || max,
108
- };
109
- const [labelStyle, setLabelStyle] = React.useState({
110
- paddingLeft: undefined,
111
- paddingRight: undefined,
112
- });
113
- React.useEffect(() => {
114
- var _a, _b;
115
- setLabelStyle(getAffixPaddding({
116
- value,
117
- type,
118
- prefixWidth: ((_a = prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0,
119
- suffixWidth: ((_b = suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0,
120
- }));
121
- }, [value]);
122
- return {
123
- inputStyle: formFieldStyles.input,
124
- wrapperClasses,
125
- containerClasses,
126
- wrapperInlineStyle,
127
- labelStyle,
128
- setLabelStyle,
129
- };
130
- }
131
- function getAffixPaddding({ value, type, prefixWidth, suffixWidth, }) {
132
- const hasValue = value !== "";
133
- const newPadding = {
134
- paddingLeft: undefined,
135
- paddingRight: undefined,
136
- };
137
- // Naively assume that if the the type is tel, it is the InputPhoneNumber
138
- if (type === "tel")
139
- return newPadding;
140
- if (prefixWidth && !hasValue) {
141
- newPadding.paddingLeft = offset(prefixWidth);
142
- }
143
- if (suffixWidth && !hasValue) {
144
- newPadding.paddingRight = offset(suffixWidth);
145
- }
146
- function offset(width) {
147
- return `calc(${width}px + var(--space-smallest)`;
148
- }
149
- return newPadding;
150
- }
151
-
152
- function FormFieldWrapper({ align, description, descriptionIdentifier, placeholder, value, children, invalid, error, size, prefix, suffix, max, maxLength, type, disabled, inline, identifier, clearable, onClear, readonly, toolbar, toolbarVisibility = "while-editing", showMiniLabel = true, wrapperRef, }) {
153
- const prefixRef = React.useRef(null);
154
- const suffixRef = React.useRef(null);
155
- const { wrapperClasses, containerClasses, wrapperInlineStyle, labelStyle } = useFormFieldWrapperStyles({
156
- align,
157
- max,
158
- maxLength,
159
- prefixRef,
160
- suffixRef,
161
- placeholder,
162
- value,
163
- invalid,
164
- error,
165
- type,
166
- disabled,
167
- inline,
168
- size,
169
- showMiniLabel,
170
- });
171
- const { focused } = useFormFieldFocus.useFormFieldFocus({ wrapperRef });
172
- const showClear = jobberHooks.useShowClear({
173
- clearable,
174
- multiline: type === "textarea",
175
- focused,
176
- hasValue: Boolean(value),
177
- disabled,
178
- readonly,
179
- });
180
- const { isToolbarVisible, toolbarAnimationEnd, toolbarAnimationStart } = useToolbar({
181
- focused,
182
- toolbar,
183
- toolbarVisibility,
184
- });
185
- return (React.createElement("div", { className: containerClasses },
186
- React.createElement("div", { className: wrapperClasses, style: wrapperInlineStyle, "data-testid": "Form-Field-Wrapper", ref: wrapperRef },
187
- React.createElement(FormFieldInputHorizontalWrapper, null,
188
- React.createElement(AffixIcon, Object.assign({}, prefix, { size: size })),
189
- React.createElement(FormFieldInputWrapperStyles, null,
190
- (showMiniLabel || !value) && (React.createElement(FormFieldLabel, { htmlFor: identifier, style: (prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) || (suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current)
191
- ? labelStyle
192
- : undefined }, placeholder)),
193
- React.createElement(AffixLabel, Object.assign({}, prefix, { labelRef: prefixRef })),
194
- React.createElement(FormFieldWrapperMain, null, children),
195
- React.createElement(AffixLabel, Object.assign({}, suffix, { labelRef: suffixRef, variation: "suffix" }))),
196
- React.createElement(ClearAction, { onClick: onClear, visible: showClear }),
197
- React.createElement(AffixIcon, Object.assign({}, suffix, { variation: "suffix", size: size }))),
198
- React.createElement(FormFieldWrapperToolbar, { toolbarVisibility: toolbarVisibility, isToolbarVisible: isToolbarVisible, toolbarAnimationEnd: toolbarAnimationEnd, toolbarAnimationStart: toolbarAnimationStart, toolbar: toolbar })),
199
- React.createElement(FormFieldDescription, { visible: !!description && !inline, id: descriptionIdentifier, description: description }),
200
- React.createElement(InputValidation.InputValidation, { message: error, visible: !!error && !inline })));
201
- }
202
- /**
203
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
204
- */
205
- function FormFieldInputHorizontalWrapper({ children, }) {
206
- return React.createElement("div", { className: formFieldStyles.horizontalWrapper }, children);
207
- }
208
- /**
209
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
210
- */
211
- function FormFieldInputWrapperStyles({ children, }) {
212
- return React.createElement("div", { className: formFieldStyles.inputWrapper }, children);
213
- }
214
- /**
215
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
216
- */
217
- function FormFieldWrapperMain({ children, tabIndex = -1, }) {
218
- return (React.createElement("div", { className: formFieldStyles.childrenWrapper, tabIndex: tabIndex }, children));
219
- }
220
- function FormFieldLabel({ children, htmlFor, style, external = false, }) {
221
- if (!children)
222
- return null;
223
- return (React.createElement("label", { className: external ? formFieldStyles.externalLabel : formFieldStyles.label, htmlFor: htmlFor, style: style }, children));
224
- }
225
- /**
226
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
227
- */
228
- function FormFieldWrapperToolbar({ toolbar, isToolbarVisible, toolbarAnimationEnd, toolbarAnimationStart, toolbarVisibility, }) {
229
- return (React.createElement(framerMotion.AnimatePresence, { initial: toolbarVisibility === "always" ? false : true }, isToolbarVisible && (React.createElement(framerMotion.motion.div, { key: "toolbar", initial: toolbarAnimationEnd, animate: toolbarAnimationStart, exit: toolbarAnimationEnd, transition: {
230
- duration: design.tokens["timing-base"] / 1000,
231
- ease: "easeInOut",
232
- }, tabIndex: -1 },
233
- React.createElement("div", { className: formFieldStyles.toolbar, "data-testid": "ATL-InputText-Toolbar" }, toolbar)))));
234
- }
235
-
236
- function FormFieldPostFix({ variation, visible = true, className, }) {
237
- if (!visible)
238
- return null;
239
- return (React.createElement("span", { className: classnames(formFieldStyles.postfix, className) }, variation === "select" ? (React.createElement(Icon.Icon, { name: "arrowDown" })) : (React.createElement(Spinner.Spinner, { size: "small" }))));
240
- }
241
-
242
9
  /**
243
10
  * Combines the actions from the props of the FormField with the actions from react-hook-form. This is used to
244
11
  * manage the form state of a field through react-hook-form while providing support for additional callbacks
@@ -299,8 +66,8 @@ function useAtlantisFormFieldActions({ name, onChange, inputRef, onControllerCha
299
66
  */
300
67
  function useAtlantisFormField({ id, nameProp, name, useControllerField: useControllerField, description, disabled, readonly, keyboard, autofocus, pattern, type, value, handleChange, handleBlur, handleFocus, inline, validations, handleKeyDown, handleValidation, errorMessage, }) {
301
68
  const descriptionIdentifier = `descriptionUUID--${id}`;
302
- const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(formFieldStyles.input, {
303
- [formFieldStyles.emptyPhoneNumber]: shouldAddPhoneNumberClass(type, value, pattern),
69
+ const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(mergeRefs.formFieldStyles.input, {
70
+ [mergeRefs.formFieldStyles.emptyPhoneNumber]: shouldAddPhoneNumberClass(type, value, pattern),
304
71
  }), name: (validations || nameProp) && name, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, autoFocus: autofocus }), (description &&
305
72
  !inline && { "aria-describedby": descriptionIdentifier }));
306
73
  const textFieldProps = Object.assign(Object.assign({}, fieldProps), { autoFocus: autofocus, onKeyDown: handleKeyDown });
@@ -311,33 +78,6 @@ function shouldAddPhoneNumberClass(type, value, pattern) {
311
78
  return type === "tel" && !value && pattern && pattern[0] === "(";
312
79
  }
313
80
 
314
- function useAtlantisFormFieldName({ id, nameProp, }) {
315
- /**
316
- * Generate a name if one is not supplied, this is the name
317
- * that will be used for react-hook-form and not neccessarily
318
- * attached to the DOM
319
- */
320
- const name = nameProp ? nameProp : `generatedName--${id}`;
321
- return { name };
322
- }
323
-
324
- /**
325
- * Given an array of refs, merge them into a single ref callback.
326
- * This is useful for cases where you need to pass a multiple refs to a component.
327
- */
328
- function mergeRefs(refs) {
329
- return value => {
330
- refs.forEach(ref => {
331
- if (typeof ref === "function") {
332
- ref(value);
333
- }
334
- else if (ref != null) {
335
- ref.current = value;
336
- }
337
- });
338
- };
339
- }
340
-
341
81
  /**
342
82
  * Hook used to manage the form state of a field through react-hook-form
343
83
  */
@@ -363,7 +103,7 @@ function useAtlantisReactHookForm({ actionsRef, name, defaultValue, value, valid
363
103
  setValue(name, value);
364
104
  }
365
105
  }, [value, watch(name)]);
366
- const inputRefs = mergeRefs([inputRef, fieldRef]);
106
+ const inputRefs = mergeRefs.mergeRefs([inputRef, fieldRef]);
367
107
  return {
368
108
  inputRefs,
369
109
  useControllerField,
@@ -385,7 +125,7 @@ function FormField(props) {
385
125
  function FormFieldInternal(props) {
386
126
  var _a;
387
127
  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;
388
- const { name } = useAtlantisFormFieldName({ id, nameProp });
128
+ const { name } = mergeRefs.useAtlantisFormFieldName({ id, nameProp });
389
129
  const { errorMessage, inputRefs, useControllerField, setValue, onControllerBlur, onControllerChange, } = useAtlantisReactHookForm({
390
130
  actionsRef,
391
131
  name,
@@ -433,19 +173,19 @@ function FormFieldInternal(props) {
433
173
  // Ensure focus tracking works by providing a wrapperRef when none is passed
434
174
  const internalWrapperRef = React.useRef(null);
435
175
  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()));
176
+ return (React.createElement(mergeRefs.FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
437
177
  function renderField() {
438
178
  switch (type) {
439
179
  case "select":
440
180
  return (React.createElement(React.Fragment, null,
441
181
  React.createElement("select", Object.assign({}, fieldProps), children),
442
- React.createElement(FormFieldPostFix, { variation: "select" })));
182
+ React.createElement(mergeRefs.FormFieldPostFix, { variation: "select" })));
443
183
  case "textarea":
444
184
  return React.createElement("textarea", Object.assign({}, textFieldProps, { rows: rows, ref: inputRefs }));
445
185
  default:
446
186
  return (React.createElement(React.Fragment, null,
447
187
  React.createElement("input", Object.assign({}, textFieldProps, { autoComplete: setAutocomplete(autocomplete), type: type, maxLength: maxLength, max: max, min: min, ref: inputRefs, onKeyUp: onKeyUp })),
448
- loading && React.createElement(FormFieldPostFix, { variation: "spinner" }),
188
+ loading && React.createElement(mergeRefs.FormFieldPostFix, { variation: "spinner" }),
449
189
  children));
450
190
  }
451
191
  }
@@ -460,20 +200,7 @@ function setAutocomplete(autocompleteSetting) {
460
200
  return autocompleteSetting;
461
201
  }
462
202
 
463
- exports.AffixIcon = AffixIcon;
464
- exports.AffixLabel = AffixLabel;
465
203
  exports.FormField = FormField;
466
- exports.FormFieldInputHorizontalWrapper = FormFieldInputHorizontalWrapper;
467
- exports.FormFieldInputWrapperStyles = FormFieldInputWrapperStyles;
468
- exports.FormFieldLabel = FormFieldLabel;
469
- exports.FormFieldPostFix = FormFieldPostFix;
470
- exports.FormFieldWrapper = FormFieldWrapper;
471
- exports.FormFieldWrapperMain = FormFieldWrapperMain;
472
- exports.FormFieldWrapperToolbar = FormFieldWrapperToolbar;
473
- exports.formFieldStyles = formFieldStyles;
474
- exports.mergeRefs = mergeRefs;
475
204
  exports.useAtlantisFormField = useAtlantisFormField;
476
205
  exports.useAtlantisFormFieldActions = useAtlantisFormFieldActions;
477
- exports.useAtlantisFormFieldName = useAtlantisFormFieldName;
478
206
  exports.useAtlantisReactHookForm = useAtlantisReactHookForm;
479
- exports.useFormFieldWrapperStyles = useFormFieldWrapperStyles;