@jobber/components 7.13.2 → 7.14.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 (50) hide show
  1. package/dist/Autocomplete/index.cjs +3 -2
  2. package/dist/Autocomplete/index.mjs +2 -1
  3. package/dist/DataList/components/DataListSearch/index.cjs +2 -1
  4. package/dist/DataList/components/DataListSearch/index.mjs +2 -1
  5. package/dist/DataList/index.cjs +2 -1
  6. package/dist/DataList/index.mjs +2 -1
  7. package/dist/DataTable/index.cjs +2 -1
  8. package/dist/DataTable/index.mjs +2 -1
  9. package/dist/FormField/index.cjs +11 -10
  10. package/dist/FormField/index.mjs +2 -1
  11. package/dist/FormField-cjs.js +7 -6
  12. package/dist/FormField-es.js +2 -1
  13. package/dist/FormFieldPostFix-cjs.js +250 -0
  14. package/dist/FormFieldPostFix-es.js +238 -0
  15. package/dist/InputDate/index.cjs +2 -1
  16. package/dist/InputDate/index.mjs +2 -1
  17. package/dist/InputEmail/index.cjs +1 -0
  18. package/dist/InputEmail/index.mjs +1 -0
  19. package/dist/InputEmail-cjs.js +4 -3
  20. package/dist/InputEmail-es.js +2 -1
  21. package/dist/InputNumber/index.cjs +2 -1
  22. package/dist/InputNumber/index.mjs +2 -1
  23. package/dist/InputPassword/index.cjs +2 -1
  24. package/dist/InputPassword/index.mjs +2 -1
  25. package/dist/InputPhoneNumber/InputPhoneNumber.d.ts +2 -2
  26. package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +2 -20
  27. package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +2 -2
  28. package/dist/InputPhoneNumber/index.cjs +13 -250
  29. package/dist/InputPhoneNumber/index.d.ts +2 -5
  30. package/dist/InputPhoneNumber/index.mjs +12 -253
  31. package/dist/InputPhoneNumber-cjs.js +190 -0
  32. package/dist/InputPhoneNumber-es.js +188 -0
  33. package/dist/InputText/index.cjs +5 -4
  34. package/dist/InputText/index.mjs +2 -1
  35. package/dist/InputTime/index.cjs +4 -3
  36. package/dist/InputTime/index.mjs +2 -1
  37. package/dist/RecurringSelect/index.cjs +2 -1
  38. package/dist/RecurringSelect/index.mjs +2 -1
  39. package/dist/Select/index.cjs +2 -1
  40. package/dist/Select/index.mjs +2 -1
  41. package/dist/Select-cjs.js +5 -4
  42. package/dist/Select-es.js +2 -1
  43. package/dist/docs/InputPhoneNumber/InputPhoneNumber.md +40 -21
  44. package/dist/docs/usage-guidelines/usage-guidelines.md +7 -8
  45. package/dist/index.cjs +13 -12
  46. package/dist/index.mjs +3 -2
  47. package/dist/mergeRefs-cjs.js +0 -248
  48. package/dist/mergeRefs-es.js +1 -238
  49. package/package.json +2 -2
  50. package/dist/InputPhoneNumber/InputPhoneNumber.rebuilt.d.ts +0 -3
@@ -44,28 +44,47 @@ edits the input.
44
44
 
45
45
  | Prop | Type | Required | Default | Description |
46
46
  |------|------|----------|---------|-------------|
47
- | `onChange` | `(value: string) => void` | Yes | — | onChange handler that provides the new value (or event) |
48
- | `value` | `string` | Yes | — | Set the component to the given value. |
49
- | `autocomplete` | `AutocompleteTypes | boolean` | No | — | Determines if browser form autocomplete is enabled. Note that "one-time-code" is experimental and should not be used ... |
50
- | `clearable` | `Clearable` | No | — | Add a clear action on the input that clears the value. You should always use `while-editing` if you want the input t... |
47
+ | `onChange` | `(value: string, event?: ChangeEvent<HTMLInputElement>) => void` | Yes | — | Custom onChange handler that provides the new value as the first argument. |
48
+ | `value` | `string` | Yes | — | The current value of the input. |
49
+ | `align` | `"center" | "right"` | No | — | Determines the alignment of the text inside the input. |
50
+ | `aria-activedescendant` | `string` | No | — | ID of the currently active descendant element. Used for composite widgets like combobox or listbox. @see {@link https... |
51
+ | `aria-autocomplete` | `"both" | "inline" | "list" | "none"` | No | — | Indicates the type of autocomplete interaction. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-autocomplete} |
52
+ | `aria-controls` | `string` | No | — | Indicates the element that controls the current element. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-controls} |
53
+ | `aria-describedby` | `string` | No | — | Identifies the element (or elements) that describes the object. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-... |
54
+ | `aria-details` | `string` | No | — | Identifies the element (or elements) that provide a detailed, extended description. @see {@link https://www.w3.org/TR... |
55
+ | `aria-expanded` | `Booleanish` | No | — | Indicates whether the element is expanded or collapsed. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-expanded} |
56
+ | `aria-label` | `string` | No | — | Defines a string value that labels the current element. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-label} |
57
+ | `aria-labelledby` | `string` | No | — | Identifies the element (or elements) that labels the current element. @see {@link https://www.w3.org/TR/wai-aria-1.2/... |
58
+ | `aria-required` | `Booleanish` | No | — | Indicates that user input is required before form submission. @see {@link https://www.w3.org/TR/wai-aria-1.2/#aria-re... |
59
+ | `autoComplete` | `string` | No | — | Autocomplete behavior for the input (React casing, string values only). Use standard HTML autocomplete values or "on"... |
60
+ | `autoFocus` | `boolean` | No | — | Whether the input should be auto-focused (React casing). |
61
+ | `clearable` | `Clearable` | No | — | Add a clear action on the input that clears the value. |
51
62
  | `description` | `ReactNode` | No | — | Further description of the input, can be used for a hint. |
52
- | `disabled` | `boolean` | No | — | Disable the input |
53
- | `id` | `string` | No | — | A unique identifier for the input. |
54
- | `inline` | `boolean` | No | — | Adjusts the form field to go inline with a content. This also silences the given `validations` prop. You'd have to us... |
63
+ | `disabled` | `boolean` | No | — | Whether the input is disabled. |
64
+ | `error` | `string` | No | — | Error message to display. This also highlights the field red. |
65
+ | `id` | `string` | No | — | The unique identifier for the input element. |
66
+ | `inline` | `boolean` | No | — | Adjusts the form field to go inline with content. |
67
+ | `inputMode` | `"decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url"` | No | — | Input mode hint for virtual keyboards. |
55
68
  | `invalid` | `boolean` | No | — | Highlights the field red to indicate an error. |
56
- | `loading` | `boolean` | No | — | Show a spinner to indicate loading |
57
- | `name` | `string` | No | — | Name of the input. |
58
- | `onBlur` | `(event?: FocusEvent<Element, Element>) => void` | No | — | Blur callback. |
59
- | `onEnter` | `(event: KeyboardEvent<Element>) => void` | No | — | A callback to handle "Enter" keypress. This will only run if Enter is the only key. Will not run if Shift or Control ... |
60
- | `onFocus` | `(event?: FocusEvent<Element, Element>) => void` | No | — | Focus callback. |
61
- | `onValidation` | `(message: string) => void` | No | — | Callback to get the the status and message when validating a field @param message |
62
- | `pattern` | `string` | No | `"(***) ***-****"` | A pattern to specify the format to display the phone number in. For example if you want to display the format for [De... |
69
+ | `loading` | `boolean` | No | — | Show a spinner to indicate loading. |
70
+ | `name` | `string` | No | — | The name attribute for the input element. |
71
+ | `onBlur` | `(event: FocusEvent<HTMLInputElement, Element>) => void` | No | — | Blur event handler. |
72
+ | `onClick` | `(event: MouseEvent<HTMLInputElement, MouseEvent>) => void` | No | — | Click event handler. |
73
+ | `onEnter` | `(event: KeyboardEvent<Element>) => void` | No | — | @deprecated Use `onKeyDown` or `onKeyUp` instead. |
74
+ | `onFocus` | `(event: FocusEvent<HTMLInputElement, Element>) => void` | No | — | Focus event handler. |
75
+ | `onKeyDown` | `(event: KeyboardEvent<HTMLInputElement>) => void` | No | | Key down event handler. |
76
+ | `onKeyUp` | `(event: KeyboardEvent<HTMLInputElement>) => void` | No | — | Key up event handler. |
77
+ | `onMouseDown` | `(event: MouseEvent<HTMLInputElement, MouseEvent>) => void` | No | — | Mouse down event handler. |
78
+ | `onMouseUp` | `(event: MouseEvent<HTMLInputElement, MouseEvent>) => void` | No | — | Mouse up event handler. |
79
+ | `onPointerDown` | `(event: PointerEvent<HTMLInputElement>) => void` | No | — | Pointer down event handler. |
80
+ | `onPointerUp` | `(event: PointerEvent<HTMLInputElement>) => void` | No | — | Pointer up event handler. |
81
+ | `pattern` | `string` | No | `(***) ***-****` | A pattern to specify the format to display the phone number in. For example if you want to display the format for [De... |
63
82
  | `placeholder` | `string` | No | — | Text that appears inside the input when empty and floats above the value as a mini label once the user enters a value... |
64
- | `prefix` | `Affix` | No | — | Adds a prefix label and icon to the field |
65
- | `readonly` | `boolean` | No | — | Prevents users from editing the value. |
66
- | `required` | `boolean` | No | — | Shows a "required" validation message when the component is left empty. |
67
- | `showMiniLabel` | `boolean` | No | `true` | Controls the visibility of the mini label that appears inside the input when a value is entered. By default, the plac... |
83
+ | `prefix` | `Affix` | No | — | Adds a prefix label and icon to the field. |
84
+ | `readOnly` | `boolean` | No | — | Whether the input is read-only (HTML standard casing). |
85
+ | `ref` | `Ref<HTMLInputElement>` | No | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (... |
86
+ | `required` | `boolean` | No | | Whether the input is required before form submission. |
87
+ | `role` | `string` | No | — | Role attribute for accessibility. |
68
88
  | `size` | `"large" | "small"` | No | — | Adjusts the interface to either have small or large spacing. |
69
- | `suffix` | `{ onClick: () => void; readonly ariaLabel: string; readonly icon: IconNames; readonly label?: string; } | { onClick?: never; ariaLabel?: never; readonly label?: string; readonly icon?: IconNames; }` | No | — | Adds a suffix label and icon with an optional action to the field |
70
- | `validations` | `RegisterOptions` | No | — | Show an error message above the field. This also highlights the the field red if an error message shows up. |
71
- | `version` | `1` | No | — | Experimental: Determine which version of the FormField to use. Right now this isn't used but it will be used in the f... |
89
+ | `suffix` | `{ onClick: () => void; readonly ariaLabel: string; readonly icon: IconNames; readonly label?: string; } | { onClick?: never; ariaLabel?: never; readonly label?: string; readonly icon?: IconNames; }` | No | — | Adds a suffix label and icon with an optional action to the field. |
90
+ | `tabIndex` | `number` | No | — | Tab index for keyboard navigation. |
@@ -11,14 +11,13 @@ The following components have a v2 implementation. **Always pass
11
11
  `version={2}`**. Never generate v1 usage for these components — v1 is
12
12
  deprecated.
13
13
 
14
- | Component | Import | v2 prop |
15
- | ---------------- | ------------------------------------------------------------------------ | ------------------------------------------------- |
16
- | Autocomplete | `import { Autocomplete } from "@jobber/components/Autocomplete"` | `version={2}` — fully controlled, async support |
17
- | InputNumber | `import { InputNumber } from "@jobber/components/InputNumber"` | `version={2}` |
18
- | InputPhoneNumber | `import { InputPhoneNumber } from "@jobber/components/InputPhoneNumber"` | `version={2}` |
19
- | InputText | `import { InputText } from "@jobber/components/InputText"` | `version={2}` |
20
- | InputTime | `import { InputTime } from "@jobber/components/InputTime"` | `version={2}` |
21
- | Modal | `import { Modal } from "@jobber/components/Modal"` | `version={2}` — uses `Modal.Provider` composition |
14
+ | Component | Import | v2 prop |
15
+ | ------------ | ---------------------------------------------------------------- | ------------------------------------------------- |
16
+ | Autocomplete | `import { Autocomplete } from "@jobber/components/Autocomplete"` | `version={2}` — fully controlled, async support |
17
+ | InputNumber | `import { InputNumber } from "@jobber/components/InputNumber"` | `version={2}` |
18
+ | InputText | `import { InputText } from "@jobber/components/InputText"` | `version={2}` |
19
+ | InputTime | `import { InputTime } from "@jobber/components/InputTime"` | `version={2}` |
20
+ | Modal | `import { Modal } from "@jobber/components/Modal"` | `version={2}` — uses `Modal.Provider` composition |
22
21
 
23
22
  ## Deprecated components — do not use
24
23
 
package/dist/index.cjs CHANGED
@@ -44,7 +44,7 @@ var Flex = require('./Flex-cjs.js');
44
44
  var Form = require('./Form-cjs.js');
45
45
  var FormField = require('./FormField-cjs.js');
46
46
  var useAtlantisFormFieldName = require('./useAtlantisFormFieldName-cjs.js');
47
- var mergeRefs = require('./mergeRefs-cjs.js');
47
+ var FormFieldPostFix = require('./FormFieldPostFix-cjs.js');
48
48
  var FormatDate = require('./FormatDate-cjs.js');
49
49
  var FormatEmail = require('./FormatEmail-cjs.js');
50
50
  var FormatFile = require('./FormatFile-cjs.js');
@@ -63,7 +63,7 @@ var InputFile = require('./InputFile-cjs.js');
63
63
  var InputGroup = require('./InputGroup-cjs.js');
64
64
  var InputNumber_index = require('./InputNumber/index.cjs');
65
65
  var InputPassword = require('./InputPassword-cjs.js');
66
- var InputPhoneNumber_index = require('./InputPhoneNumber/index.cjs');
66
+ var InputPhoneNumber = require('./InputPhoneNumber-cjs.js');
67
67
  var InputText_index = require('./InputText/index.cjs');
68
68
  var InputTime_index = require('./InputTime/index.cjs');
69
69
  var InputValidation = require('./InputValidation-cjs.js');
@@ -119,6 +119,7 @@ require('classnames');
119
119
  require('./maxHeight-cjs.js');
120
120
  require('./tslib.es6-cjs.js');
121
121
  require('react-hook-form');
122
+ require('./mergeRefs-cjs.js');
122
123
  require('./filterDataAttributes-cjs.js');
123
124
  require('color');
124
125
  require('react-router-dom');
@@ -265,15 +266,15 @@ exports.useAtlantisFormField = FormField.useAtlantisFormField;
265
266
  exports.useAtlantisFormFieldActions = FormField.useAtlantisFormFieldActions;
266
267
  exports.useAtlantisReactHookForm = FormField.useAtlantisReactHookForm;
267
268
  exports.useAtlantisFormFieldName = useAtlantisFormFieldName.useAtlantisFormFieldName;
268
- exports.AffixIcon = mergeRefs.AffixIcon;
269
- exports.AffixLabel = mergeRefs.AffixLabel;
270
- exports.FormFieldInputHorizontalWrapper = mergeRefs.FormFieldInputHorizontalWrapper;
271
- exports.FormFieldInputWrapperStyles = mergeRefs.FormFieldInputWrapperStyles;
272
- exports.FormFieldLabel = mergeRefs.FormFieldLabel;
273
- exports.FormFieldWrapper = mergeRefs.FormFieldWrapper;
274
- exports.FormFieldWrapperMain = mergeRefs.FormFieldWrapperMain;
275
- exports.FormFieldWrapperToolbar = mergeRefs.FormFieldWrapperToolbar;
276
- exports.useFormFieldWrapperStyles = mergeRefs.useFormFieldWrapperStyles;
269
+ exports.AffixIcon = FormFieldPostFix.AffixIcon;
270
+ exports.AffixLabel = FormFieldPostFix.AffixLabel;
271
+ exports.FormFieldInputHorizontalWrapper = FormFieldPostFix.FormFieldInputHorizontalWrapper;
272
+ exports.FormFieldInputWrapperStyles = FormFieldPostFix.FormFieldInputWrapperStyles;
273
+ exports.FormFieldLabel = FormFieldPostFix.FormFieldLabel;
274
+ exports.FormFieldWrapper = FormFieldPostFix.FormFieldWrapper;
275
+ exports.FormFieldWrapperMain = FormFieldPostFix.FormFieldWrapperMain;
276
+ exports.FormFieldWrapperToolbar = FormFieldPostFix.FormFieldWrapperToolbar;
277
+ exports.useFormFieldWrapperStyles = FormFieldPostFix.useFormFieldWrapperStyles;
277
278
  exports.FormatDate = FormatDate.FormatDate;
278
279
  exports.strFormatDate = FormatDate.strFormatDate;
279
280
  exports.FormatEmail = FormatEmail.FormatEmail;
@@ -300,7 +301,7 @@ exports.useInputFileContentContext = InputFile.useInputFileContentContext;
300
301
  exports.InputGroup = InputGroup.InputGroup;
301
302
  exports.InputNumber = InputNumber_index.InputNumber;
302
303
  exports.InputPassword = InputPassword.InputPassword;
303
- exports.InputPhoneNumber = InputPhoneNumber_index.InputPhoneNumber;
304
+ exports.InputPhoneNumber = InputPhoneNumber.InputPhoneNumber;
304
305
  exports.InputText = InputText_index.InputText;
305
306
  exports.InputTime = InputTime_index.InputTime;
306
307
  exports.InputValidation = InputValidation.InputValidation;
package/dist/index.mjs CHANGED
@@ -42,7 +42,7 @@ export { F as Flex } from './Flex-es.js';
42
42
  export { F as Form } from './Form-es.js';
43
43
  export { F as FormField, u as useAtlantisFormField, a as useAtlantisFormFieldActions, b as useAtlantisReactHookForm } from './FormField-es.js';
44
44
  export { u as useAtlantisFormFieldName } from './useAtlantisFormFieldName-es.js';
45
- 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 useFormFieldWrapperStyles } from './mergeRefs-es.js';
45
+ 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 useFormFieldWrapperStyles } from './FormFieldPostFix-es.js';
46
46
  export { F as FormatDate, s as strFormatDate } from './FormatDate-es.js';
47
47
  export { F as FormatEmail } from './FormatEmail-es.js';
48
48
  export { F as FormatFile, u as useFormatFile, a as useFormatFileStyles } from './FormatFile-es.js';
@@ -61,7 +61,7 @@ export { I as InputFile, a as InputFileContentContext, u as updateFiles, b as us
61
61
  export { I as InputGroup } from './InputGroup-es.js';
62
62
  export { InputNumber } from './InputNumber/index.mjs';
63
63
  export { I as InputPassword } from './InputPassword-es.js';
64
- export { InputPhoneNumber } from './InputPhoneNumber/index.mjs';
64
+ export { I as InputPhoneNumber } from './InputPhoneNumber-es.js';
65
65
  export { InputText } from './InputText/index.mjs';
66
66
  export { InputTime } from './InputTime/index.mjs';
67
67
  export { I as InputValidation } from './InputValidation-es.js';
@@ -117,6 +117,7 @@ import 'classnames';
117
117
  import './maxHeight-es.js';
118
118
  import './tslib.es6-es.js';
119
119
  import 'react-hook-form';
120
+ import './mergeRefs-es.js';
120
121
  import './filterDataAttributes-es.js';
121
122
  import 'color';
122
123
  import 'react-router-dom';
@@ -1,242 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var React = require('react');
4
- var jobberHooks = require('@jobber/hooks');
5
- var framerMotion = require('framer-motion');
6
- var design = require('@jobber/design');
7
- 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
-
15
- 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-"};
16
-
17
- /**
18
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
19
- */
20
- function AffixLabel({ label, variation = "prefix", labelRef, }) {
21
- const affixLabelClass = classnames(formFieldStyles.affixLabel, {
22
- [formFieldStyles.suffix]: variation === "suffix",
23
- });
24
- if (!label)
25
- return null;
26
- return (React.createElement("div", { ref: labelRef, className: affixLabelClass }, label));
27
- }
28
- function AffixIcon({ icon, onClick, ariaLabel, variation = "prefix", size, }) {
29
- const affixIconClass = classnames(formFieldStyles.affixIcon, {
30
- [formFieldStyles.suffix]: variation === "suffix",
31
- });
32
- const iconSize = size === "small" ? "small" : "base";
33
- if (!icon)
34
- return null;
35
- return (React.createElement("div", { className: affixIconClass }, onClick ? (React.createElement(Button.Button
36
- /**
37
- * We can cast the ariaLabel here as a `Suffix`
38
- * requires an ariaLabel if there is an action
39
- */
40
- , {
41
- /**
42
- * We can cast the ariaLabel here as a `Suffix`
43
- * requires an ariaLabel if there is an action
44
- */
45
- ariaLabel: ariaLabel, icon: icon, onClick: onClick, variation: "subtle", type: "tertiary", size: iconSize })) : (React.createElement(Icon.Icon, { name: icon, size: iconSize, color: "greyBlue" }))));
46
- }
47
-
48
- function FormFieldDescription({ id, description, visible = true, }) {
49
- if (!visible)
50
- return null;
51
- const useStringFormat = !description || typeof description === "string";
52
- return (React.createElement("div", { id: id, className: formFieldStyles.description }, useStringFormat ? (React.createElement(Text.Text, { size: "small", variation: "subdued" }, description)) : (description)));
53
- }
54
-
55
- var styles = {"clearInput":"YmRTd-KeXv4-","spinning":"B25z9B8I3gs-"};
56
-
57
- function ClearAction({ onClick, visible, }) {
58
- if (!visible)
59
- return null;
60
- return (React.createElement("button", { className: styles.clearInput, onClick: onClick, type: "button", "aria-label": "Clear input", "data-testid": "ATL-FormField-clearButton" },
61
- React.createElement(Icon.Icon, { name: "remove", size: "small" })));
62
- }
63
-
64
- function useToolbar(props) {
65
- const isToolbarVisible = props.toolbar !== undefined &&
66
- (props.toolbarVisibility === "always" || props.focused);
67
- const toolbarAnimationEnd = { opacity: 0, height: 0 };
68
- const toolbarAnimationStart = { opacity: 1, height: "auto" };
69
- return {
70
- isToolbarVisible,
71
- toolbarAnimationEnd,
72
- toolbarAnimationStart,
73
- };
74
- }
75
-
76
- function useIsSafari() {
77
- return (globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator)
78
- ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
79
- : false;
80
- }
81
-
82
- /**
83
- * Hook for getting the correct styles for the FormField and its children
84
- */
85
- function useFormFieldWrapperStyles({ size, align, placeholder, value, invalid, error, max, prefixRef, suffixRef, maxLength, type, disabled, inline, showMiniLabel = true, }) {
86
- const isSafari = useIsSafari();
87
- const wrapperClasses = classnames(formFieldStyles.wrapper, size && formFieldStyles[size], align && formFieldStyles[align], {
88
- [formFieldStyles.miniLabel]: (showMiniLabel && placeholder && value !== "") ||
89
- (placeholder && type === "select") ||
90
- // Naively assume that if the the type is tel, it is the InputPhoneNumber
91
- (placeholder && type === "tel"),
92
- [formFieldStyles.text]: type === "textarea" || type === "text",
93
- [formFieldStyles.textarea]: type === "textarea",
94
- [formFieldStyles.safari]: isSafari && type === "textarea",
95
- [formFieldStyles.select]: type === "select",
96
- [formFieldStyles.invalid]: invalid !== null && invalid !== void 0 ? invalid : error,
97
- [formFieldStyles.disabled]: disabled,
98
- [formFieldStyles.maxLength]: maxLength,
99
- [formFieldStyles.timeInputLabel]: placeholder && type === "time" && placeholder && value === "",
100
- });
101
- const containerClasses = classnames(formFieldStyles.container, {
102
- [formFieldStyles.inline]: inline,
103
- });
104
- const wrapperInlineStyle = {
105
- ["--formField-maxLength"]: maxLength || max,
106
- };
107
- const [labelStyle, setLabelStyle] = React.useState({
108
- paddingLeft: undefined,
109
- paddingRight: undefined,
110
- });
111
- React.useEffect(() => {
112
- var _a, _b;
113
- setLabelStyle(getAffixPaddding({
114
- value,
115
- type,
116
- prefixWidth: ((_a = prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0,
117
- suffixWidth: ((_b = suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0,
118
- }));
119
- }, [value]);
120
- return {
121
- inputStyle: formFieldStyles.input,
122
- wrapperClasses,
123
- containerClasses,
124
- wrapperInlineStyle,
125
- labelStyle,
126
- setLabelStyle,
127
- };
128
- }
129
- function getAffixPaddding({ value, type, prefixWidth, suffixWidth, }) {
130
- const hasValue = value !== "";
131
- const newPadding = {
132
- paddingLeft: undefined,
133
- paddingRight: undefined,
134
- };
135
- // Naively assume that if the the type is tel, it is the InputPhoneNumber
136
- if (type === "tel")
137
- return newPadding;
138
- if (prefixWidth && !hasValue) {
139
- newPadding.paddingLeft = offset(prefixWidth);
140
- }
141
- if (suffixWidth && !hasValue) {
142
- newPadding.paddingRight = offset(suffixWidth);
143
- }
144
- function offset(width) {
145
- return `calc(${width}px + var(--space-smallest)`;
146
- }
147
- return newPadding;
148
- }
149
-
150
- 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, }) {
151
- const prefixRef = React.useRef(null);
152
- const suffixRef = React.useRef(null);
153
- const { wrapperClasses, containerClasses, wrapperInlineStyle, labelStyle } = useFormFieldWrapperStyles({
154
- align,
155
- max,
156
- maxLength,
157
- prefixRef,
158
- suffixRef,
159
- placeholder,
160
- value,
161
- invalid,
162
- error,
163
- type,
164
- disabled,
165
- inline,
166
- size,
167
- showMiniLabel,
168
- });
169
- const { focused } = useFormFieldFocus.useFormFieldFocus({ wrapperRef });
170
- const showClear = jobberHooks.useShowClear({
171
- clearable,
172
- multiline: type === "textarea",
173
- focused,
174
- hasValue: Boolean(value),
175
- disabled,
176
- readonly,
177
- });
178
- const { isToolbarVisible, toolbarAnimationEnd, toolbarAnimationStart } = useToolbar({
179
- focused,
180
- toolbar,
181
- toolbarVisibility,
182
- });
183
- return (React.createElement("div", { className: containerClasses },
184
- React.createElement("div", { className: wrapperClasses, style: wrapperInlineStyle, "data-testid": "Form-Field-Wrapper", ref: wrapperRef },
185
- React.createElement(FormFieldInputHorizontalWrapper, null,
186
- React.createElement(AffixIcon, Object.assign({}, prefix, { size: size })),
187
- React.createElement(FormFieldInputWrapperStyles, null,
188
- (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)
189
- ? labelStyle
190
- : undefined }, placeholder)),
191
- React.createElement(AffixLabel, Object.assign({}, prefix, { labelRef: prefixRef })),
192
- React.createElement(FormFieldWrapperMain, null, children),
193
- React.createElement(AffixLabel, Object.assign({}, suffix, { labelRef: suffixRef, variation: "suffix" }))),
194
- React.createElement(ClearAction, { onClick: onClear, visible: showClear }),
195
- React.createElement(AffixIcon, Object.assign({}, suffix, { variation: "suffix", size: size }))),
196
- React.createElement(FormFieldWrapperToolbar, { toolbarVisibility: toolbarVisibility, isToolbarVisible: isToolbarVisible, toolbarAnimationEnd: toolbarAnimationEnd, toolbarAnimationStart: toolbarAnimationStart, toolbar: toolbar })),
197
- React.createElement(FormFieldDescription, { visible: !!description && !inline, id: descriptionIdentifier, description: description }),
198
- React.createElement(InputValidation.InputValidation, { message: error, visible: !!error && !inline })));
199
- }
200
- /**
201
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
202
- */
203
- function FormFieldInputHorizontalWrapper({ children, }) {
204
- return React.createElement("div", { className: formFieldStyles.horizontalWrapper }, children);
205
- }
206
- /**
207
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
208
- */
209
- function FormFieldInputWrapperStyles({ children, }) {
210
- return React.createElement("div", { className: formFieldStyles.inputWrapper }, children);
211
- }
212
- /**
213
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
214
- */
215
- function FormFieldWrapperMain({ children, tabIndex = -1, }) {
216
- return (React.createElement("div", { className: formFieldStyles.childrenWrapper, tabIndex: tabIndex }, children));
217
- }
218
- function FormFieldLabel({ children, htmlFor, style, external = false, }) {
219
- if (!children)
220
- return null;
221
- return (React.createElement("label", { className: external ? formFieldStyles.externalLabel : formFieldStyles.label, htmlFor: htmlFor, style: style }, children));
222
- }
223
- /**
224
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
225
- */
226
- function FormFieldWrapperToolbar({ toolbar, isToolbarVisible, toolbarAnimationEnd, toolbarAnimationStart, toolbarVisibility, }) {
227
- 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: {
228
- duration: design.tokens["timing-base"] / 1000,
229
- ease: "easeInOut",
230
- }, tabIndex: -1 },
231
- React.createElement("div", { className: formFieldStyles.toolbar, "data-testid": "ATL-InputText-Toolbar" }, toolbar)))));
232
- }
233
-
234
- function FormFieldPostFix({ variation, visible = true, className, }) {
235
- if (!visible)
236
- return null;
237
- return (React.createElement("span", { className: classnames(formFieldStyles.postfix, className) }, variation === "select" ? (React.createElement(Icon.Icon, { name: "arrowDown" })) : (React.createElement(Spinner.Spinner, { size: "small" }))));
238
- }
239
-
240
3
  /**
241
4
  * Given an array of refs, merge them into a single ref callback.
242
5
  * This is useful for cases where you need to pass a multiple refs to a component.
@@ -254,15 +17,4 @@ function mergeRefs(refs) {
254
17
  };
255
18
  }
256
19
 
257
- exports.AffixIcon = AffixIcon;
258
- exports.AffixLabel = AffixLabel;
259
- exports.FormFieldInputHorizontalWrapper = FormFieldInputHorizontalWrapper;
260
- exports.FormFieldInputWrapperStyles = FormFieldInputWrapperStyles;
261
- exports.FormFieldLabel = FormFieldLabel;
262
- exports.FormFieldPostFix = FormFieldPostFix;
263
- exports.FormFieldWrapper = FormFieldWrapper;
264
- exports.FormFieldWrapperMain = FormFieldWrapperMain;
265
- exports.FormFieldWrapperToolbar = FormFieldWrapperToolbar;
266
- exports.formFieldStyles = formFieldStyles;
267
20
  exports.mergeRefs = mergeRefs;
268
- exports.useFormFieldWrapperStyles = useFormFieldWrapperStyles;