@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
@@ -1,240 +1,3 @@
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';
5
- import classnames from 'classnames';
6
- import { B as Button } from './Button-es.js';
7
- 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
- import { S as Spinner } from './Spinner-es.js';
12
-
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
- function FormFieldPostFix({ variation, visible = true, className, }) {
233
- if (!visible)
234
- return null;
235
- 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
- }
237
-
238
1
  /**
239
2
  * Given an array of refs, merge them into a single ref callback.
240
3
  * This is useful for cases where you need to pass a multiple refs to a component.
@@ -252,4 +15,4 @@ function mergeRefs(refs) {
252
15
  };
253
16
  }
254
17
 
255
- 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, mergeRefs as m, useFormFieldWrapperStyles as u };
18
+ export { mergeRefs as m };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "7.13.2",
3
+ "version": "7.14.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -583,5 +583,5 @@
583
583
  "> 1%",
584
584
  "IE 10"
585
585
  ],
586
- "gitHead": "5b5ba24c16ea60c7c46b9cb0d8245ff9d8329fb1"
586
+ "gitHead": "b694decc6a81ad978973a183dee13aed9e8dbc14"
587
587
  }
@@ -1,3 +0,0 @@
1
- import React from "react";
2
- import type { InputPhoneNumberRebuiltProps } from "./InputPhoneNumber.types";
3
- export declare const InputPhoneNumberRebuilt: React.ForwardRefExoticComponent<InputPhoneNumberRebuiltProps & React.RefAttributes<HTMLInputElement>>;