@jobber/components 7.14.3 → 7.15.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 (64) hide show
  1. package/dist/Autocomplete/index.cjs +4 -3
  2. package/dist/Autocomplete/index.mjs +3 -2
  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/DatePicker/index.cjs +0 -1
  10. package/dist/DatePicker/index.mjs +0 -1
  11. package/dist/DatePicker-cjs.js +780 -2
  12. package/dist/DatePicker-es.js +780 -2
  13. package/dist/FormField/index.cjs +14 -13
  14. package/dist/FormField/index.mjs +5 -4
  15. package/dist/FormField-cjs.js +4 -3
  16. package/dist/FormField-es.js +2 -1
  17. package/dist/FormFieldPostFix-cjs.js +2 -237
  18. package/dist/FormFieldPostFix-es.js +3 -228
  19. package/dist/FormFieldWrapper-cjs.js +242 -0
  20. package/dist/FormFieldWrapper-es.js +231 -0
  21. package/dist/InputDate/index.cjs +2 -2
  22. package/dist/InputDate/index.mjs +2 -2
  23. package/dist/InputEmail/index.cjs +2 -1
  24. package/dist/InputEmail/index.mjs +2 -1
  25. package/dist/InputEmail-cjs.js +3 -2
  26. package/dist/InputEmail-es.js +2 -1
  27. package/dist/InputNumber/index.cjs +2 -1
  28. package/dist/InputNumber/index.mjs +2 -1
  29. package/dist/InputPassword/index.cjs +2 -1
  30. package/dist/InputPassword/index.mjs +2 -1
  31. package/dist/InputPhoneNumber/index.cjs +2 -1
  32. package/dist/InputPhoneNumber/index.mjs +2 -1
  33. package/dist/InputPhoneNumber-cjs.js +3 -2
  34. package/dist/InputPhoneNumber-es.js +2 -1
  35. package/dist/InputText/index.cjs +3 -2
  36. package/dist/InputText/index.mjs +2 -1
  37. package/dist/InputTime/InputTime.d.ts +1 -1
  38. package/dist/InputTime/InputTime.types.d.ts +10 -24
  39. package/dist/InputTime/hooks/useInputTimeActions.d.ts +2 -2
  40. package/dist/InputTime/index.cjs +16 -350
  41. package/dist/InputTime/index.d.ts +2 -4
  42. package/dist/InputTime/index.mjs +15 -353
  43. package/dist/InputTime-cjs.js +300 -0
  44. package/dist/InputTime-es.js +298 -0
  45. package/dist/RecurringSelect/index.cjs +2 -1
  46. package/dist/RecurringSelect/index.mjs +2 -1
  47. package/dist/Select/index.cjs +2 -1
  48. package/dist/Select/index.mjs +2 -1
  49. package/dist/Select-cjs.js +3 -2
  50. package/dist/Select-es.js +2 -1
  51. package/dist/Tabs-es.js +1 -1
  52. package/dist/_baseEach-es.js +2 -2
  53. package/dist/_getAllKeys-es.js +1 -1
  54. package/dist/debounce-es.js +1 -1
  55. package/dist/docs/InputTime/InputTime.md +45 -27
  56. package/dist/docs/usage-guidelines/usage-guidelines.md +0 -1
  57. package/dist/index.cjs +13 -13
  58. package/dist/index.mjs +3 -3
  59. package/dist/isTypedArray-es.js +1 -1
  60. package/dist/useScrollToActive-es.js +1 -1
  61. package/package.json +2 -2
  62. package/dist/InputTime/InputTime.rebuilt.d.ts +0 -3
  63. package/dist/omit-cjs.js +0 -783
  64. package/dist/omit-es.js +0 -781
@@ -2,23 +2,24 @@
2
2
 
3
3
  var FormField = require('../FormField-cjs.js');
4
4
  var useAtlantisFormFieldName = require('../useAtlantisFormFieldName-cjs.js');
5
- var FormFieldPostFix = require('../FormFieldPostFix-cjs.js');
5
+ var FormFieldWrapper = require('../FormFieldWrapper-cjs.js');
6
6
  require('react');
7
+ require('../FormFieldPostFix-cjs.js');
7
8
  require('classnames');
9
+ require('../Icon-cjs.js');
10
+ require('@jobber/design');
11
+ require('../Spinner-cjs.js');
8
12
  require('../tslib.es6-cjs.js');
9
13
  require('react-hook-form');
10
14
  require('../mergeRefs-cjs.js');
11
15
  require('@jobber/hooks');
12
16
  require('framer-motion');
13
- require('@jobber/design');
14
17
  require('../Button-cjs.js');
15
18
  require('react-router-dom');
16
- require('../Icon-cjs.js');
17
19
  require('../Typography-cjs.js');
18
20
  require('../Text-cjs.js');
19
21
  require('../useFormFieldFocus-cjs.js');
20
22
  require('../InputValidation-cjs.js');
21
- require('../Spinner-cjs.js');
22
23
 
23
24
 
24
25
 
@@ -27,12 +28,12 @@ exports.useAtlantisFormField = FormField.useAtlantisFormField;
27
28
  exports.useAtlantisFormFieldActions = FormField.useAtlantisFormFieldActions;
28
29
  exports.useAtlantisReactHookForm = FormField.useAtlantisReactHookForm;
29
30
  exports.useAtlantisFormFieldName = useAtlantisFormFieldName.useAtlantisFormFieldName;
30
- exports.AffixIcon = FormFieldPostFix.AffixIcon;
31
- exports.AffixLabel = FormFieldPostFix.AffixLabel;
32
- exports.FormFieldInputHorizontalWrapper = FormFieldPostFix.FormFieldInputHorizontalWrapper;
33
- exports.FormFieldInputWrapperStyles = FormFieldPostFix.FormFieldInputWrapperStyles;
34
- exports.FormFieldLabel = FormFieldPostFix.FormFieldLabel;
35
- exports.FormFieldWrapper = FormFieldPostFix.FormFieldWrapper;
36
- exports.FormFieldWrapperMain = FormFieldPostFix.FormFieldWrapperMain;
37
- exports.FormFieldWrapperToolbar = FormFieldPostFix.FormFieldWrapperToolbar;
38
- exports.useFormFieldWrapperStyles = FormFieldPostFix.useFormFieldWrapperStyles;
31
+ exports.AffixIcon = FormFieldWrapper.AffixIcon;
32
+ exports.AffixLabel = FormFieldWrapper.AffixLabel;
33
+ exports.FormFieldInputHorizontalWrapper = FormFieldWrapper.FormFieldInputHorizontalWrapper;
34
+ exports.FormFieldInputWrapperStyles = FormFieldWrapper.FormFieldInputWrapperStyles;
35
+ exports.FormFieldLabel = FormFieldWrapper.FormFieldLabel;
36
+ exports.FormFieldWrapper = FormFieldWrapper.FormFieldWrapper;
37
+ exports.FormFieldWrapperMain = FormFieldWrapper.FormFieldWrapperMain;
38
+ exports.FormFieldWrapperToolbar = FormFieldWrapper.FormFieldWrapperToolbar;
39
+ exports.useFormFieldWrapperStyles = FormFieldWrapper.useFormFieldWrapperStyles;
@@ -1,19 +1,20 @@
1
1
  export { F as FormField, u as useAtlantisFormField, a as useAtlantisFormFieldActions, b as useAtlantisReactHookForm } from '../FormField-es.js';
2
2
  export { u as useAtlantisFormFieldName } from '../useAtlantisFormFieldName-es.js';
3
- 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';
3
+ 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 '../FormFieldWrapper-es.js';
4
4
  import 'react';
5
+ import '../FormFieldPostFix-es.js';
5
6
  import 'classnames';
7
+ import '../Icon-es.js';
8
+ import '@jobber/design';
9
+ import '../Spinner-es.js';
6
10
  import '../tslib.es6-es.js';
7
11
  import 'react-hook-form';
8
12
  import '../mergeRefs-es.js';
9
13
  import '@jobber/hooks';
10
14
  import 'framer-motion';
11
- import '@jobber/design';
12
15
  import '../Button-es.js';
13
16
  import 'react-router-dom';
14
- import '../Icon-es.js';
15
17
  import '../Typography-es.js';
16
18
  import '../Text-es.js';
17
19
  import '../useFormFieldFocus-es.js';
18
20
  import '../InputValidation-es.js';
19
- import '../Spinner-es.js';
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var FormFieldWrapper = require('./FormFieldWrapper-cjs.js');
4
5
  var FormFieldPostFix = require('./FormFieldPostFix-cjs.js');
5
6
  var classnames = require('classnames');
6
7
  var useAtlantisFormFieldName = require('./useAtlantisFormFieldName-cjs.js');
@@ -68,8 +69,8 @@ function useAtlantisFormFieldActions({ name, onChange, inputRef, onControllerCha
68
69
  */
69
70
  function useAtlantisFormField({ id, nameProp, name, useControllerField: useControllerField, description, disabled, readonly, keyboard, autofocus, pattern, type, value, handleChange, handleBlur, handleFocus, inline, validations, handleKeyDown, handleValidation, errorMessage, }) {
70
71
  const descriptionIdentifier = `descriptionUUID--${id}`;
71
- const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(FormFieldPostFix.formFieldStyles.input, {
72
- [FormFieldPostFix.formFieldStyles.emptyPhoneNumber]: shouldAddPhoneNumberClass(type, value, pattern),
72
+ const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(FormFieldWrapper.formFieldStyles.input, {
73
+ [FormFieldWrapper.formFieldStyles.emptyPhoneNumber]: shouldAddPhoneNumberClass(type, value, pattern),
73
74
  }), name: (validations || nameProp) && name, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, autoFocus: autofocus }), (description &&
74
75
  !inline && { "aria-describedby": descriptionIdentifier }));
75
76
  const textFieldProps = Object.assign(Object.assign({}, fieldProps), { autoFocus: autofocus, onKeyDown: handleKeyDown });
@@ -175,7 +176,7 @@ function FormFieldInternal(props) {
175
176
  // Ensure focus tracking works by providing a wrapperRef when none is passed
176
177
  const internalWrapperRef = React.useRef(null);
177
178
  const wrapperRef = (_a = props.wrapperRef) !== null && _a !== void 0 ? _a : internalWrapperRef;
178
- return (React.createElement(FormFieldPostFix.FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
179
+ return (React.createElement(FormFieldWrapper.FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
179
180
  function renderField() {
180
181
  switch (type) {
181
182
  case "select":
@@ -1,5 +1,6 @@
1
1
  import React__default, { useEffect, useImperativeHandle, useId, useRef } from 'react';
2
- import { g as formFieldStyles, c as FormFieldWrapper, h as FormFieldPostFix } from './FormFieldPostFix-es.js';
2
+ import { g as formFieldStyles, c as FormFieldWrapper } from './FormFieldWrapper-es.js';
3
+ import { F as FormFieldPostFix } from './FormFieldPostFix-es.js';
3
4
  import classnames from 'classnames';
4
5
  import { u as useAtlantisFormFieldName } from './useAtlantisFormFieldName-es.js';
5
6
  import { _ as __rest } from './tslib.es6-es.js';
@@ -1,250 +1,15 @@
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');
7
4
  var classnames = require('classnames');
8
- var Button = require('./Button-cjs.js');
5
+ var FormFieldWrapper = require('./FormFieldWrapper-cjs.js');
9
6
  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
7
  var Spinner = require('./Spinner-cjs.js');
14
8
 
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
9
  function FormFieldPostFix({ variation, visible = true, className, }) {
235
10
  if (!visible)
236
11
  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" }))));
12
+ return (React.createElement("span", { className: classnames(FormFieldWrapper.formFieldStyles.postfix, className) }, variation === "select" ? (React.createElement(Icon.Icon, { name: "arrowDown" })) : (React.createElement(Spinner.Spinner, { size: "small" }))));
238
13
  }
239
14
 
240
- exports.AffixIcon = AffixIcon;
241
- exports.AffixLabel = AffixLabel;
242
- exports.FormFieldInputHorizontalWrapper = FormFieldInputHorizontalWrapper;
243
- exports.FormFieldInputWrapperStyles = FormFieldInputWrapperStyles;
244
- exports.FormFieldLabel = FormFieldLabel;
245
15
  exports.FormFieldPostFix = FormFieldPostFix;
246
- exports.FormFieldWrapper = FormFieldWrapper;
247
- exports.FormFieldWrapperMain = FormFieldWrapperMain;
248
- exports.FormFieldWrapperToolbar = FormFieldWrapperToolbar;
249
- exports.formFieldStyles = formFieldStyles;
250
- exports.useFormFieldWrapperStyles = useFormFieldWrapperStyles;
@@ -1,238 +1,13 @@
1
- import React__default, { useState, useEffect, useRef } from 'react';
2
- import { useShowClear } from '@jobber/hooks';
3
- import { AnimatePresence, motion } from 'framer-motion';
4
- import { tokens } from '@jobber/design';
1
+ import React__default from 'react';
5
2
  import classnames from 'classnames';
6
- import { B as Button } from './Button-es.js';
3
+ import { g as formFieldStyles } from './FormFieldWrapper-es.js';
7
4
  import { I as Icon } from './Icon-es.js';
8
- import { T as Text } from './Text-es.js';
9
- import { u as useFormFieldFocus } from './useFormFieldFocus-es.js';
10
- import { I as InputValidation } from './InputValidation-es.js';
11
5
  import { S as Spinner } from './Spinner-es.js';
12
6
 
13
- 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-"};
14
-
15
- /**
16
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
17
- */
18
- function AffixLabel({ label, variation = "prefix", labelRef, }) {
19
- const affixLabelClass = classnames(formFieldStyles.affixLabel, {
20
- [formFieldStyles.suffix]: variation === "suffix",
21
- });
22
- if (!label)
23
- return null;
24
- return (React__default.createElement("div", { ref: labelRef, className: affixLabelClass }, label));
25
- }
26
- function AffixIcon({ icon, onClick, ariaLabel, variation = "prefix", size, }) {
27
- const affixIconClass = classnames(formFieldStyles.affixIcon, {
28
- [formFieldStyles.suffix]: variation === "suffix",
29
- });
30
- const iconSize = size === "small" ? "small" : "base";
31
- if (!icon)
32
- return null;
33
- return (React__default.createElement("div", { className: affixIconClass }, onClick ? (React__default.createElement(Button
34
- /**
35
- * We can cast the ariaLabel here as a `Suffix`
36
- * requires an ariaLabel if there is an action
37
- */
38
- , {
39
- /**
40
- * We can cast the ariaLabel here as a `Suffix`
41
- * requires an ariaLabel if there is an action
42
- */
43
- ariaLabel: ariaLabel, icon: icon, onClick: onClick, variation: "subtle", type: "tertiary", size: iconSize })) : (React__default.createElement(Icon, { name: icon, size: iconSize, color: "greyBlue" }))));
44
- }
45
-
46
- function FormFieldDescription({ id, description, visible = true, }) {
47
- if (!visible)
48
- return null;
49
- const useStringFormat = !description || typeof description === "string";
50
- return (React__default.createElement("div", { id: id, className: formFieldStyles.description }, useStringFormat ? (React__default.createElement(Text, { size: "small", variation: "subdued" }, description)) : (description)));
51
- }
52
-
53
- var styles = {"clearInput":"YmRTd-KeXv4-","spinning":"B25z9B8I3gs-"};
54
-
55
- function ClearAction({ onClick, visible, }) {
56
- if (!visible)
57
- return null;
58
- return (React__default.createElement("button", { className: styles.clearInput, onClick: onClick, type: "button", "aria-label": "Clear input", "data-testid": "ATL-FormField-clearButton" },
59
- React__default.createElement(Icon, { name: "remove", size: "small" })));
60
- }
61
-
62
- function useToolbar(props) {
63
- const isToolbarVisible = props.toolbar !== undefined &&
64
- (props.toolbarVisibility === "always" || props.focused);
65
- const toolbarAnimationEnd = { opacity: 0, height: 0 };
66
- const toolbarAnimationStart = { opacity: 1, height: "auto" };
67
- return {
68
- isToolbarVisible,
69
- toolbarAnimationEnd,
70
- toolbarAnimationStart,
71
- };
72
- }
73
-
74
- function useIsSafari() {
75
- return (globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator)
76
- ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
77
- : false;
78
- }
79
-
80
- /**
81
- * Hook for getting the correct styles for the FormField and its children
82
- */
83
- function useFormFieldWrapperStyles({ size, align, placeholder, value, invalid, error, max, prefixRef, suffixRef, maxLength, type, disabled, inline, showMiniLabel = true, }) {
84
- const isSafari = useIsSafari();
85
- const wrapperClasses = classnames(formFieldStyles.wrapper, size && formFieldStyles[size], align && formFieldStyles[align], {
86
- [formFieldStyles.miniLabel]: (showMiniLabel && placeholder && value !== "") ||
87
- (placeholder && type === "select") ||
88
- // Naively assume that if the the type is tel, it is the InputPhoneNumber
89
- (placeholder && type === "tel"),
90
- [formFieldStyles.text]: type === "textarea" || type === "text",
91
- [formFieldStyles.textarea]: type === "textarea",
92
- [formFieldStyles.safari]: isSafari && type === "textarea",
93
- [formFieldStyles.select]: type === "select",
94
- [formFieldStyles.invalid]: invalid !== null && invalid !== void 0 ? invalid : error,
95
- [formFieldStyles.disabled]: disabled,
96
- [formFieldStyles.maxLength]: maxLength,
97
- [formFieldStyles.timeInputLabel]: placeholder && type === "time" && placeholder && value === "",
98
- });
99
- const containerClasses = classnames(formFieldStyles.container, {
100
- [formFieldStyles.inline]: inline,
101
- });
102
- const wrapperInlineStyle = {
103
- ["--formField-maxLength"]: maxLength || max,
104
- };
105
- const [labelStyle, setLabelStyle] = useState({
106
- paddingLeft: undefined,
107
- paddingRight: undefined,
108
- });
109
- useEffect(() => {
110
- var _a, _b;
111
- setLabelStyle(getAffixPaddding({
112
- value,
113
- type,
114
- prefixWidth: ((_a = prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0,
115
- suffixWidth: ((_b = suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current) === null || _b === void 0 ? void 0 : _b.offsetWidth) || 0,
116
- }));
117
- }, [value]);
118
- return {
119
- inputStyle: formFieldStyles.input,
120
- wrapperClasses,
121
- containerClasses,
122
- wrapperInlineStyle,
123
- labelStyle,
124
- setLabelStyle,
125
- };
126
- }
127
- function getAffixPaddding({ value, type, prefixWidth, suffixWidth, }) {
128
- const hasValue = value !== "";
129
- const newPadding = {
130
- paddingLeft: undefined,
131
- paddingRight: undefined,
132
- };
133
- // Naively assume that if the the type is tel, it is the InputPhoneNumber
134
- if (type === "tel")
135
- return newPadding;
136
- if (prefixWidth && !hasValue) {
137
- newPadding.paddingLeft = offset(prefixWidth);
138
- }
139
- if (suffixWidth && !hasValue) {
140
- newPadding.paddingRight = offset(suffixWidth);
141
- }
142
- function offset(width) {
143
- return `calc(${width}px + var(--space-smallest)`;
144
- }
145
- return newPadding;
146
- }
147
-
148
- 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, }) {
149
- const prefixRef = useRef(null);
150
- const suffixRef = useRef(null);
151
- const { wrapperClasses, containerClasses, wrapperInlineStyle, labelStyle } = useFormFieldWrapperStyles({
152
- align,
153
- max,
154
- maxLength,
155
- prefixRef,
156
- suffixRef,
157
- placeholder,
158
- value,
159
- invalid,
160
- error,
161
- type,
162
- disabled,
163
- inline,
164
- size,
165
- showMiniLabel,
166
- });
167
- const { focused } = useFormFieldFocus({ wrapperRef });
168
- const showClear = useShowClear({
169
- clearable,
170
- multiline: type === "textarea",
171
- focused,
172
- hasValue: Boolean(value),
173
- disabled,
174
- readonly,
175
- });
176
- const { isToolbarVisible, toolbarAnimationEnd, toolbarAnimationStart } = useToolbar({
177
- focused,
178
- toolbar,
179
- toolbarVisibility,
180
- });
181
- return (React__default.createElement("div", { className: containerClasses },
182
- React__default.createElement("div", { className: wrapperClasses, style: wrapperInlineStyle, "data-testid": "Form-Field-Wrapper", ref: wrapperRef },
183
- React__default.createElement(FormFieldInputHorizontalWrapper, null,
184
- React__default.createElement(AffixIcon, Object.assign({}, prefix, { size: size })),
185
- React__default.createElement(FormFieldInputWrapperStyles, null,
186
- (showMiniLabel || !value) && (React__default.createElement(FormFieldLabel, { htmlFor: identifier, style: (prefixRef === null || prefixRef === void 0 ? void 0 : prefixRef.current) || (suffixRef === null || suffixRef === void 0 ? void 0 : suffixRef.current)
187
- ? labelStyle
188
- : undefined }, placeholder)),
189
- React__default.createElement(AffixLabel, Object.assign({}, prefix, { labelRef: prefixRef })),
190
- React__default.createElement(FormFieldWrapperMain, null, children),
191
- React__default.createElement(AffixLabel, Object.assign({}, suffix, { labelRef: suffixRef, variation: "suffix" }))),
192
- React__default.createElement(ClearAction, { onClick: onClear, visible: showClear }),
193
- React__default.createElement(AffixIcon, Object.assign({}, suffix, { variation: "suffix", size: size }))),
194
- React__default.createElement(FormFieldWrapperToolbar, { toolbarVisibility: toolbarVisibility, isToolbarVisible: isToolbarVisible, toolbarAnimationEnd: toolbarAnimationEnd, toolbarAnimationStart: toolbarAnimationStart, toolbar: toolbar })),
195
- React__default.createElement(FormFieldDescription, { visible: !!description && !inline, id: descriptionIdentifier, description: description }),
196
- React__default.createElement(InputValidation, { message: error, visible: !!error && !inline })));
197
- }
198
- /**
199
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
200
- */
201
- function FormFieldInputHorizontalWrapper({ children, }) {
202
- return React__default.createElement("div", { className: formFieldStyles.horizontalWrapper }, children);
203
- }
204
- /**
205
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
206
- */
207
- function FormFieldInputWrapperStyles({ children, }) {
208
- return React__default.createElement("div", { className: formFieldStyles.inputWrapper }, children);
209
- }
210
- /**
211
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
212
- */
213
- function FormFieldWrapperMain({ children, tabIndex = -1, }) {
214
- return (React__default.createElement("div", { className: formFieldStyles.childrenWrapper, tabIndex: tabIndex }, children));
215
- }
216
- function FormFieldLabel({ children, htmlFor, style, external = false, }) {
217
- if (!children)
218
- return null;
219
- return (React__default.createElement("label", { className: external ? formFieldStyles.externalLabel : formFieldStyles.label, htmlFor: htmlFor, style: style }, children));
220
- }
221
- /**
222
- * @internal Reach out to UX Foundations if using this component since it is possible it might change
223
- */
224
- function FormFieldWrapperToolbar({ toolbar, isToolbarVisible, toolbarAnimationEnd, toolbarAnimationStart, toolbarVisibility, }) {
225
- return (React__default.createElement(AnimatePresence, { initial: toolbarVisibility === "always" ? false : true }, isToolbarVisible && (React__default.createElement(motion.div, { key: "toolbar", initial: toolbarAnimationEnd, animate: toolbarAnimationStart, exit: toolbarAnimationEnd, transition: {
226
- duration: tokens["timing-base"] / 1000,
227
- ease: "easeInOut",
228
- }, tabIndex: -1 },
229
- React__default.createElement("div", { className: formFieldStyles.toolbar, "data-testid": "ATL-InputText-Toolbar" }, toolbar)))));
230
- }
231
-
232
7
  function FormFieldPostFix({ variation, visible = true, className, }) {
233
8
  if (!visible)
234
9
  return null;
235
10
  return (React__default.createElement("span", { className: classnames(formFieldStyles.postfix, className) }, variation === "select" ? (React__default.createElement(Icon, { name: "arrowDown" })) : (React__default.createElement(Spinner, { size: "small" }))));
236
11
  }
237
12
 
238
- export { AffixIcon as A, FormFieldInputHorizontalWrapper as F, FormFieldInputWrapperStyles as a, FormFieldLabel as b, FormFieldWrapper as c, FormFieldWrapperMain as d, FormFieldWrapperToolbar as e, AffixLabel as f, formFieldStyles as g, FormFieldPostFix as h, useFormFieldWrapperStyles as u };
13
+ export { FormFieldPostFix as F };