@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.
- package/dist/Autocomplete/index.cjs +3 -2
- package/dist/Autocomplete/index.mjs +2 -1
- package/dist/DataList/components/DataListSearch/index.cjs +2 -1
- package/dist/DataList/components/DataListSearch/index.mjs +2 -1
- package/dist/DataList/index.cjs +2 -1
- package/dist/DataList/index.mjs +2 -1
- package/dist/DataTable/index.cjs +2 -1
- package/dist/DataTable/index.mjs +2 -1
- package/dist/FormField/index.cjs +11 -10
- package/dist/FormField/index.mjs +2 -1
- package/dist/FormField-cjs.js +7 -6
- package/dist/FormField-es.js +2 -1
- package/dist/FormFieldPostFix-cjs.js +250 -0
- package/dist/FormFieldPostFix-es.js +238 -0
- package/dist/InputDate/index.cjs +2 -1
- package/dist/InputDate/index.mjs +2 -1
- package/dist/InputEmail/index.cjs +1 -0
- package/dist/InputEmail/index.mjs +1 -0
- package/dist/InputEmail-cjs.js +4 -3
- package/dist/InputEmail-es.js +2 -1
- package/dist/InputNumber/index.cjs +2 -1
- package/dist/InputNumber/index.mjs +2 -1
- package/dist/InputPassword/index.cjs +2 -1
- package/dist/InputPassword/index.mjs +2 -1
- package/dist/InputPhoneNumber/InputPhoneNumber.d.ts +2 -2
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +2 -20
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +2 -2
- package/dist/InputPhoneNumber/index.cjs +13 -250
- package/dist/InputPhoneNumber/index.d.ts +2 -5
- package/dist/InputPhoneNumber/index.mjs +12 -253
- package/dist/InputPhoneNumber-cjs.js +190 -0
- package/dist/InputPhoneNumber-es.js +188 -0
- package/dist/InputText/index.cjs +5 -4
- package/dist/InputText/index.mjs +2 -1
- package/dist/InputTime/index.cjs +4 -3
- package/dist/InputTime/index.mjs +2 -1
- package/dist/RecurringSelect/index.cjs +2 -1
- package/dist/RecurringSelect/index.mjs +2 -1
- package/dist/Select/index.cjs +2 -1
- package/dist/Select/index.mjs +2 -1
- package/dist/Select-cjs.js +5 -4
- package/dist/Select-es.js +2 -1
- package/dist/docs/InputPhoneNumber/InputPhoneNumber.md +40 -21
- package/dist/docs/usage-guidelines/usage-guidelines.md +7 -8
- package/dist/index.cjs +13 -12
- package/dist/index.mjs +3 -2
- package/dist/mergeRefs-cjs.js +0 -248
- package/dist/mergeRefs-es.js +1 -238
- package/package.json +2 -2
- package/dist/InputPhoneNumber/InputPhoneNumber.rebuilt.d.ts +0 -3
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('./tslib.es6-cjs.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var classnames = require('classnames');
|
|
6
|
+
var FormFieldPostFix = require('./FormFieldPostFix-cjs.js');
|
|
7
|
+
var useAtlantisFormFieldName = require('./useAtlantisFormFieldName-cjs.js');
|
|
8
|
+
require('react-hook-form');
|
|
9
|
+
require('./Button-cjs.js');
|
|
10
|
+
require('@jobber/design');
|
|
11
|
+
var filterDataAttributes = require('./filterDataAttributes-cjs.js');
|
|
12
|
+
|
|
13
|
+
var styles = {"mask":"_78-Lxj78xPg-","hiddenValue":"GoiXVXaU1Qs-","emptyValue":"oOrjwubmsVA-","spinning":"T3VvmDmzs-4-"};
|
|
14
|
+
|
|
15
|
+
function useInputMask({ value = "", pattern, delimiter = "*", strict = true, onChange, }) {
|
|
16
|
+
const [isMasking, setIsMasking] = React.useState(!value);
|
|
17
|
+
const patternInfo = React.useMemo(() => {
|
|
18
|
+
const patternChars = pattern.split("");
|
|
19
|
+
const specialChars = patternChars.filter(char => char !== delimiter);
|
|
20
|
+
const maxCleanChars = patternChars.filter(char => char === delimiter).length;
|
|
21
|
+
return {
|
|
22
|
+
patternChars,
|
|
23
|
+
specialChars,
|
|
24
|
+
maxCleanChars,
|
|
25
|
+
};
|
|
26
|
+
}, [pattern, delimiter]);
|
|
27
|
+
const inputValue = React.useMemo(() => {
|
|
28
|
+
return value
|
|
29
|
+
.split("")
|
|
30
|
+
.filter(char => !patternInfo.specialChars.includes(char))
|
|
31
|
+
.join("");
|
|
32
|
+
}, [value, patternInfo.specialChars]);
|
|
33
|
+
const formatValue = React.useCallback((unformattedValue) => {
|
|
34
|
+
const { patternChars, specialChars, maxCleanChars } = patternInfo;
|
|
35
|
+
const cleanValueChars = unformattedValue
|
|
36
|
+
.split("")
|
|
37
|
+
.filter(char => !specialChars.includes(char) && !Number.isNaN(Number(char)));
|
|
38
|
+
const isOverCharLimit = cleanValueChars.length > maxCleanChars;
|
|
39
|
+
if (!strict && isOverCharLimit) {
|
|
40
|
+
return cleanValueChars.join("");
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const formattedValue = patternChars.reduce(getMaskedValue([...cleanValueChars], specialChars), "");
|
|
44
|
+
return formattedValue;
|
|
45
|
+
}
|
|
46
|
+
}, [patternInfo, strict]);
|
|
47
|
+
const maskedOnChange = React.useCallback((newValue, event) => {
|
|
48
|
+
const formatted = formatValue(newValue);
|
|
49
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(formatted, event);
|
|
50
|
+
}, [formatValue, onChange]);
|
|
51
|
+
const formattedValue = React.useMemo(() => formatValue(value), [formatValue, value]);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
const shouldMask = strict || inputValue.length < patternInfo.maxCleanChars;
|
|
54
|
+
setIsMasking(shouldMask);
|
|
55
|
+
}, [inputValue, patternInfo.maxCleanChars, strict]);
|
|
56
|
+
const placeholderMask = React.useMemo(() => pattern
|
|
57
|
+
.replace(new RegExp(`\\${delimiter}`, "g"), "_")
|
|
58
|
+
.slice(value.length), [pattern, delimiter, value]);
|
|
59
|
+
return {
|
|
60
|
+
formattedValue,
|
|
61
|
+
placeholderMask,
|
|
62
|
+
isMasking,
|
|
63
|
+
maskedOnChange,
|
|
64
|
+
inputValue,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function getMaskedValue(cleanVal, specialChars) {
|
|
68
|
+
return (result, nextCharacter) => {
|
|
69
|
+
if (!cleanVal.length)
|
|
70
|
+
return result;
|
|
71
|
+
if (specialChars.includes(nextCharacter))
|
|
72
|
+
return result + nextCharacter;
|
|
73
|
+
const nextValue = cleanVal.shift();
|
|
74
|
+
return result + (nextValue !== undefined ? nextValue : "");
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function MaskElement({ isMasking, formattedValue, placeholderMask, }) {
|
|
79
|
+
if (!isMasking) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
return (React.createElement("div", { className: styles.mask, "aria-hidden": "true" },
|
|
83
|
+
React.createElement("span", { className: styles.hiddenValue }, formattedValue),
|
|
84
|
+
React.createElement("span", null, placeholderMask)));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const DEFAULT_PATTERN = "(***) ***-****";
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Combines the actions on the InputPhoneNumber such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputPhoneNumber.
|
|
91
|
+
* Do not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
|
|
92
|
+
*/
|
|
93
|
+
function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
|
|
94
|
+
function handleClear() {
|
|
95
|
+
var _a;
|
|
96
|
+
onChange && onChange("");
|
|
97
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
98
|
+
}
|
|
99
|
+
function handleChange(event) {
|
|
100
|
+
const newValue = event.currentTarget.value;
|
|
101
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, event);
|
|
102
|
+
}
|
|
103
|
+
function handleFocus(event) {
|
|
104
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
105
|
+
}
|
|
106
|
+
function handleKeyDown(event) {
|
|
107
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
108
|
+
if (!onEnter)
|
|
109
|
+
return;
|
|
110
|
+
if (event.key !== "Enter")
|
|
111
|
+
return;
|
|
112
|
+
if (event.shiftKey || event.ctrlKey)
|
|
113
|
+
return;
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
onEnter === null || onEnter === void 0 ? void 0 : onEnter(event);
|
|
116
|
+
}
|
|
117
|
+
function handleBlur(event) {
|
|
118
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
119
|
+
}
|
|
120
|
+
function handleClick(event) {
|
|
121
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
122
|
+
}
|
|
123
|
+
function handleMouseDown(event) {
|
|
124
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
125
|
+
}
|
|
126
|
+
function handleMouseUp(event) {
|
|
127
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
128
|
+
}
|
|
129
|
+
function handlePointerDown(event) {
|
|
130
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
131
|
+
}
|
|
132
|
+
function handlePointerUp(event) {
|
|
133
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
handleClear,
|
|
137
|
+
handleChange,
|
|
138
|
+
handleFocus,
|
|
139
|
+
handleBlur,
|
|
140
|
+
handleKeyDown,
|
|
141
|
+
handleClick,
|
|
142
|
+
handleMouseDown,
|
|
143
|
+
handleMouseUp,
|
|
144
|
+
handlePointerDown,
|
|
145
|
+
handlePointerUp,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const InputPhoneNumber = React.forwardRef(function InputPhoneNumberInternal(_a, ref) {
|
|
150
|
+
var _b, _c, _d, _e;
|
|
151
|
+
var { pattern = DEFAULT_PATTERN } = _a, props = tslib_es6.__rest(_a, ["pattern"]);
|
|
152
|
+
const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React.useRef(null);
|
|
153
|
+
const wrapperRef = React.useRef(null);
|
|
154
|
+
const generatedId = React.useId();
|
|
155
|
+
const id = props.id || generatedId;
|
|
156
|
+
const { name } = useAtlantisFormFieldName.useAtlantisFormFieldName({
|
|
157
|
+
nameProp: props.name,
|
|
158
|
+
id: id,
|
|
159
|
+
});
|
|
160
|
+
const { formattedValue, isMasking, placeholderMask, inputValue, maskedOnChange, } = useInputMask({
|
|
161
|
+
value: props.value,
|
|
162
|
+
pattern,
|
|
163
|
+
strict: false,
|
|
164
|
+
onChange: props.onChange,
|
|
165
|
+
});
|
|
166
|
+
const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputPhoneActions({
|
|
167
|
+
onChange: maskedOnChange,
|
|
168
|
+
onBlur: props.onBlur,
|
|
169
|
+
onFocus: props.onFocus,
|
|
170
|
+
onEnter: props.onEnter,
|
|
171
|
+
onKeyDown: props.onKeyDown,
|
|
172
|
+
onClick: props.onClick,
|
|
173
|
+
onMouseDown: props.onMouseDown,
|
|
174
|
+
onMouseUp: props.onMouseUp,
|
|
175
|
+
onPointerDown: props.onPointerDown,
|
|
176
|
+
onPointerUp: props.onPointerUp,
|
|
177
|
+
inputRef: inputPhoneNumberRef,
|
|
178
|
+
});
|
|
179
|
+
const descriptionIdentifier = `descriptionUUID--${id}`, descriptionVisible = props.description && !props.inline;
|
|
180
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
181
|
+
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
182
|
+
return (React.createElement(FormFieldPostFix.FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, loading: props.loading },
|
|
183
|
+
React.createElement("input", Object.assign({ id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(FormFieldPostFix.formFieldStyles.input, {
|
|
184
|
+
[styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
|
|
185
|
+
}), value: formattedValue, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, required: props.required, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp }, dataAttrs)),
|
|
186
|
+
React.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
|
|
187
|
+
React.createElement(FormFieldPostFix.FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
exports.InputPhoneNumber = InputPhoneNumber;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { _ as __rest } from './tslib.es6-es.js';
|
|
2
|
+
import React__default, { useState, useMemo, useCallback, useEffect, forwardRef, useId } from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { c as FormFieldWrapper, g as formFieldStyles, h as FormFieldPostFix } from './FormFieldPostFix-es.js';
|
|
5
|
+
import { u as useAtlantisFormFieldName } from './useAtlantisFormFieldName-es.js';
|
|
6
|
+
import 'react-hook-form';
|
|
7
|
+
import './Button-es.js';
|
|
8
|
+
import '@jobber/design';
|
|
9
|
+
import { f as filterDataAttributes } from './filterDataAttributes-es.js';
|
|
10
|
+
|
|
11
|
+
var styles = {"mask":"_78-Lxj78xPg-","hiddenValue":"GoiXVXaU1Qs-","emptyValue":"oOrjwubmsVA-","spinning":"T3VvmDmzs-4-"};
|
|
12
|
+
|
|
13
|
+
function useInputMask({ value = "", pattern, delimiter = "*", strict = true, onChange, }) {
|
|
14
|
+
const [isMasking, setIsMasking] = useState(!value);
|
|
15
|
+
const patternInfo = useMemo(() => {
|
|
16
|
+
const patternChars = pattern.split("");
|
|
17
|
+
const specialChars = patternChars.filter(char => char !== delimiter);
|
|
18
|
+
const maxCleanChars = patternChars.filter(char => char === delimiter).length;
|
|
19
|
+
return {
|
|
20
|
+
patternChars,
|
|
21
|
+
specialChars,
|
|
22
|
+
maxCleanChars,
|
|
23
|
+
};
|
|
24
|
+
}, [pattern, delimiter]);
|
|
25
|
+
const inputValue = useMemo(() => {
|
|
26
|
+
return value
|
|
27
|
+
.split("")
|
|
28
|
+
.filter(char => !patternInfo.specialChars.includes(char))
|
|
29
|
+
.join("");
|
|
30
|
+
}, [value, patternInfo.specialChars]);
|
|
31
|
+
const formatValue = useCallback((unformattedValue) => {
|
|
32
|
+
const { patternChars, specialChars, maxCleanChars } = patternInfo;
|
|
33
|
+
const cleanValueChars = unformattedValue
|
|
34
|
+
.split("")
|
|
35
|
+
.filter(char => !specialChars.includes(char) && !Number.isNaN(Number(char)));
|
|
36
|
+
const isOverCharLimit = cleanValueChars.length > maxCleanChars;
|
|
37
|
+
if (!strict && isOverCharLimit) {
|
|
38
|
+
return cleanValueChars.join("");
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const formattedValue = patternChars.reduce(getMaskedValue([...cleanValueChars], specialChars), "");
|
|
42
|
+
return formattedValue;
|
|
43
|
+
}
|
|
44
|
+
}, [patternInfo, strict]);
|
|
45
|
+
const maskedOnChange = useCallback((newValue, event) => {
|
|
46
|
+
const formatted = formatValue(newValue);
|
|
47
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(formatted, event);
|
|
48
|
+
}, [formatValue, onChange]);
|
|
49
|
+
const formattedValue = useMemo(() => formatValue(value), [formatValue, value]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const shouldMask = strict || inputValue.length < patternInfo.maxCleanChars;
|
|
52
|
+
setIsMasking(shouldMask);
|
|
53
|
+
}, [inputValue, patternInfo.maxCleanChars, strict]);
|
|
54
|
+
const placeholderMask = useMemo(() => pattern
|
|
55
|
+
.replace(new RegExp(`\\${delimiter}`, "g"), "_")
|
|
56
|
+
.slice(value.length), [pattern, delimiter, value]);
|
|
57
|
+
return {
|
|
58
|
+
formattedValue,
|
|
59
|
+
placeholderMask,
|
|
60
|
+
isMasking,
|
|
61
|
+
maskedOnChange,
|
|
62
|
+
inputValue,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function getMaskedValue(cleanVal, specialChars) {
|
|
66
|
+
return (result, nextCharacter) => {
|
|
67
|
+
if (!cleanVal.length)
|
|
68
|
+
return result;
|
|
69
|
+
if (specialChars.includes(nextCharacter))
|
|
70
|
+
return result + nextCharacter;
|
|
71
|
+
const nextValue = cleanVal.shift();
|
|
72
|
+
return result + (nextValue !== undefined ? nextValue : "");
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function MaskElement({ isMasking, formattedValue, placeholderMask, }) {
|
|
77
|
+
if (!isMasking) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return (React__default.createElement("div", { className: styles.mask, "aria-hidden": "true" },
|
|
81
|
+
React__default.createElement("span", { className: styles.hiddenValue }, formattedValue),
|
|
82
|
+
React__default.createElement("span", null, placeholderMask)));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const DEFAULT_PATTERN = "(***) ***-****";
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Combines the actions on the InputPhoneNumber such as onChange, onEnter, onFocus, onBlur, and onClear to forward information to the consumers of the InputPhoneNumber.
|
|
89
|
+
* Do not repeat this pattern. We are doing this as a proof of concept relating to the refactoring of Form inputs to see what can be removed.
|
|
90
|
+
*/
|
|
91
|
+
function useInputPhoneActions({ onChange, inputRef, onFocus, onBlur, onKeyDown, onEnter, onClick, onMouseDown, onMouseUp, onPointerDown, onPointerUp, }) {
|
|
92
|
+
function handleClear() {
|
|
93
|
+
var _a;
|
|
94
|
+
onChange && onChange("");
|
|
95
|
+
(_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
96
|
+
}
|
|
97
|
+
function handleChange(event) {
|
|
98
|
+
const newValue = event.currentTarget.value;
|
|
99
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue, event);
|
|
100
|
+
}
|
|
101
|
+
function handleFocus(event) {
|
|
102
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
103
|
+
}
|
|
104
|
+
function handleKeyDown(event) {
|
|
105
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
106
|
+
if (!onEnter)
|
|
107
|
+
return;
|
|
108
|
+
if (event.key !== "Enter")
|
|
109
|
+
return;
|
|
110
|
+
if (event.shiftKey || event.ctrlKey)
|
|
111
|
+
return;
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
onEnter === null || onEnter === void 0 ? void 0 : onEnter(event);
|
|
114
|
+
}
|
|
115
|
+
function handleBlur(event) {
|
|
116
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
117
|
+
}
|
|
118
|
+
function handleClick(event) {
|
|
119
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
120
|
+
}
|
|
121
|
+
function handleMouseDown(event) {
|
|
122
|
+
onMouseDown === null || onMouseDown === void 0 ? void 0 : onMouseDown(event);
|
|
123
|
+
}
|
|
124
|
+
function handleMouseUp(event) {
|
|
125
|
+
onMouseUp === null || onMouseUp === void 0 ? void 0 : onMouseUp(event);
|
|
126
|
+
}
|
|
127
|
+
function handlePointerDown(event) {
|
|
128
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
129
|
+
}
|
|
130
|
+
function handlePointerUp(event) {
|
|
131
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
handleClear,
|
|
135
|
+
handleChange,
|
|
136
|
+
handleFocus,
|
|
137
|
+
handleBlur,
|
|
138
|
+
handleKeyDown,
|
|
139
|
+
handleClick,
|
|
140
|
+
handleMouseDown,
|
|
141
|
+
handleMouseUp,
|
|
142
|
+
handlePointerDown,
|
|
143
|
+
handlePointerUp,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const InputPhoneNumber = forwardRef(function InputPhoneNumberInternal(_a, ref) {
|
|
148
|
+
var _b, _c, _d, _e;
|
|
149
|
+
var { pattern = DEFAULT_PATTERN } = _a, props = __rest(_a, ["pattern"]);
|
|
150
|
+
const inputPhoneNumberRef = (_b = ref) !== null && _b !== void 0 ? _b : React__default.useRef(null);
|
|
151
|
+
const wrapperRef = React__default.useRef(null);
|
|
152
|
+
const generatedId = useId();
|
|
153
|
+
const id = props.id || generatedId;
|
|
154
|
+
const { name } = useAtlantisFormFieldName({
|
|
155
|
+
nameProp: props.name,
|
|
156
|
+
id: id,
|
|
157
|
+
});
|
|
158
|
+
const { formattedValue, isMasking, placeholderMask, inputValue, maskedOnChange, } = useInputMask({
|
|
159
|
+
value: props.value,
|
|
160
|
+
pattern,
|
|
161
|
+
strict: false,
|
|
162
|
+
onChange: props.onChange,
|
|
163
|
+
});
|
|
164
|
+
const { handleChange, handleBlur, handleFocus, handleClear, handleKeyDown, handleClick, handleMouseDown, handleMouseUp, handlePointerDown, handlePointerUp, } = useInputPhoneActions({
|
|
165
|
+
onChange: maskedOnChange,
|
|
166
|
+
onBlur: props.onBlur,
|
|
167
|
+
onFocus: props.onFocus,
|
|
168
|
+
onEnter: props.onEnter,
|
|
169
|
+
onKeyDown: props.onKeyDown,
|
|
170
|
+
onClick: props.onClick,
|
|
171
|
+
onMouseDown: props.onMouseDown,
|
|
172
|
+
onMouseUp: props.onMouseUp,
|
|
173
|
+
onPointerDown: props.onPointerDown,
|
|
174
|
+
onPointerUp: props.onPointerUp,
|
|
175
|
+
inputRef: inputPhoneNumberRef,
|
|
176
|
+
});
|
|
177
|
+
const descriptionIdentifier = `descriptionUUID--${id}`, descriptionVisible = props.description && !props.inline;
|
|
178
|
+
const isInvalid = Boolean(props.error || props.invalid);
|
|
179
|
+
const dataAttrs = filterDataAttributes(props);
|
|
180
|
+
return (React__default.createElement(FormFieldWrapper, { disabled: props.disabled, size: props.size, inline: props.inline, wrapperRef: wrapperRef, error: (_c = props.error) !== null && _c !== void 0 ? _c : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_d = props.clearable) !== null && _d !== void 0 ? _d : "never", onClear: handleClear, type: "tel", placeholder: props.placeholder, value: formattedValue, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, loading: props.loading },
|
|
181
|
+
React__default.createElement("input", Object.assign({ id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(formFieldStyles.input, {
|
|
182
|
+
[styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
|
|
183
|
+
}), value: formattedValue, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, required: props.required, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp }, dataAttrs)),
|
|
184
|
+
React__default.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
|
|
185
|
+
React__default.createElement(FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
export { InputPhoneNumber as I };
|
package/dist/InputText/index.cjs
CHANGED
|
@@ -9,8 +9,9 @@ require('react-hook-form');
|
|
|
9
9
|
require('framer-motion');
|
|
10
10
|
require('@jobber/design');
|
|
11
11
|
require('../Button-cjs.js');
|
|
12
|
-
var
|
|
12
|
+
var FormFieldPostFix = require('../FormFieldPostFix-cjs.js');
|
|
13
13
|
var useAtlantisFormFieldName = require('../useAtlantisFormFieldName-cjs.js');
|
|
14
|
+
var mergeRefs = require('../mergeRefs-cjs.js');
|
|
14
15
|
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
15
16
|
require('react-router-dom');
|
|
16
17
|
require('../Icon-cjs.js');
|
|
@@ -247,13 +248,13 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
|
|
|
247
248
|
const mergedRef = React.useMemo(() => mergeRefs.mergeRefs([inputRef, inputTextRef]), []);
|
|
248
249
|
// Shared props for both TextArea and TextInput
|
|
249
250
|
const commonInputProps = Object.assign({ id,
|
|
250
|
-
name, className:
|
|
251
|
+
name, className: FormFieldPostFix.formFieldStyles.input, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, inputMode: props.inputMode, tabIndex: props.tabIndex, maxLength: props.maxLength, required: props.required, role: props.role, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
|
|
251
252
|
? descriptionIdentifier
|
|
252
253
|
: props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-controls": props["aria-controls"], "aria-expanded": props["aria-expanded"], "aria-activedescendant": props["aria-activedescendant"], "aria-autocomplete": props["aria-autocomplete"], "aria-required": props["aria-required"], onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onClick: handleClick, ref: mergedRef }, dataAttrs);
|
|
253
|
-
return (React.createElement(
|
|
254
|
+
return (React.createElement(FormFieldPostFix.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, name: name, wrapperRef: wrapperRef, error: (_a = props.error) !== null && _a !== void 0 ? _a : "", invalid: Boolean(props.error || props.invalid), identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: props.multiline ? "textarea" : "text", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, readonly: props.readOnly, rows: rowRange.min, toolbar: props.toolbar, toolbarVisibility: props.toolbarVisibility, showMiniLabel: props.showMiniLabel },
|
|
254
255
|
React.createElement(React.Fragment, null,
|
|
255
256
|
props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
|
|
256
|
-
React.createElement(
|
|
257
|
+
React.createElement(FormFieldPostFix.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
|
|
257
258
|
});
|
|
258
259
|
function useInputTextId(props) {
|
|
259
260
|
const generatedId = React.useId();
|
package/dist/InputText/index.mjs
CHANGED
|
@@ -7,8 +7,9 @@ import 'react-hook-form';
|
|
|
7
7
|
import 'framer-motion';
|
|
8
8
|
import '@jobber/design';
|
|
9
9
|
import '../Button-es.js';
|
|
10
|
-
import {
|
|
10
|
+
import { g as formFieldStyles, c as FormFieldWrapper, h as FormFieldPostFix } from '../FormFieldPostFix-es.js';
|
|
11
11
|
import { u as useAtlantisFormFieldName } from '../useAtlantisFormFieldName-es.js';
|
|
12
|
+
import { m as mergeRefs } from '../mergeRefs-es.js';
|
|
12
13
|
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
13
14
|
import 'react-router-dom';
|
|
14
15
|
import '../Icon-es.js';
|
package/dist/InputTime/index.cjs
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var tslib_es6 = require('../tslib.es6-cjs.js');
|
|
5
5
|
var debounce = require('../debounce-cjs.js');
|
|
6
|
-
var
|
|
6
|
+
var FormFieldPostFix = require('../FormFieldPostFix-cjs.js');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('@jobber/design');
|
|
9
9
|
require('react-hook-form');
|
|
10
|
+
var mergeRefs = require('../mergeRefs-cjs.js');
|
|
10
11
|
require('../Button-cjs.js');
|
|
11
12
|
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
12
13
|
var omit = require('../omit-cjs.js');
|
|
@@ -309,8 +310,8 @@ function InputTimeRebuilt(_a) {
|
|
|
309
310
|
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
310
311
|
const descriptionVisible = props.description && !props.inline;
|
|
311
312
|
const isInvalid = Boolean(props.error || props.invalid);
|
|
312
|
-
return (React.createElement(
|
|
313
|
-
React.createElement("input", Object.assign({ ref: mergedRef, type: "time", name: props.name, className:
|
|
313
|
+
return (React.createElement(FormFieldPostFix.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, name: props.name, error: props.error || "", identifier: id, descriptionIdentifier: descriptionIdentifier, invalid: props.invalid, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, type: "time", readonly: readOnly, placeholder: props.placeholder, value: dateToTimeString(value, step % 60 !== 0), wrapperRef: wrapperRef },
|
|
314
|
+
React.createElement("input", Object.assign({ ref: mergedRef, type: "time", name: props.name, className: FormFieldPostFix.formFieldStyles.input, id: id, disabled: props.disabled, readOnly: readOnly, autoComplete: autoComplete, autoFocus: props.autoFocus, required: props.required, max: props.max, min: props.min, step: step, value: dateToTimeString(value, step % 60 !== 0), onChange: handleChangeEvent, onBlur: handleBlur, onFocus: handleFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, "data-testid": "ATL-InputTime-input", "aria-label": props["aria-label"], "aria-describedby": descriptionVisible ? descriptionIdentifier : props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"] }, dataAttrs))));
|
|
314
315
|
}
|
|
315
316
|
function useInputTimeRefs(inputRef) {
|
|
316
317
|
const internalRef = React.useRef(null);
|
package/dist/InputTime/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React__default, { useState, useCallback, useEffect, useId, useRef } from 'react';
|
|
2
2
|
import { _ as __rest } from '../tslib.es6-es.js';
|
|
3
3
|
import { a as debounce } from '../debounce-es.js';
|
|
4
|
-
import { c as FormFieldWrapper, g as formFieldStyles
|
|
4
|
+
import { c as FormFieldWrapper, g as formFieldStyles } from '../FormFieldPostFix-es.js';
|
|
5
5
|
import 'classnames';
|
|
6
6
|
import '@jobber/design';
|
|
7
7
|
import 'react-hook-form';
|
|
8
|
+
import { m as mergeRefs } from '../mergeRefs-es.js';
|
|
8
9
|
import '../Button-es.js';
|
|
9
10
|
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
10
11
|
import { o as omit } from '../omit-es.js';
|
|
@@ -7,7 +7,7 @@ require('../Text-cjs.js');
|
|
|
7
7
|
require('../Typography-cjs.js');
|
|
8
8
|
require('classnames');
|
|
9
9
|
require('../Select-cjs.js');
|
|
10
|
-
require('../
|
|
10
|
+
require('../FormFieldPostFix-cjs.js');
|
|
11
11
|
require('@jobber/hooks');
|
|
12
12
|
require('framer-motion');
|
|
13
13
|
require('@jobber/design');
|
|
@@ -20,6 +20,7 @@ require('../InputValidation-cjs.js');
|
|
|
20
20
|
require('../Spinner-cjs.js');
|
|
21
21
|
require('../useAtlantisFormFieldName-cjs.js');
|
|
22
22
|
require('react-hook-form');
|
|
23
|
+
require('../mergeRefs-cjs.js');
|
|
23
24
|
require('../filterDataAttributes-cjs.js');
|
|
24
25
|
require('../InputNumber/index.cjs');
|
|
25
26
|
require('../clsx-cjs.js');
|
|
@@ -5,7 +5,7 @@ import '../Text-es.js';
|
|
|
5
5
|
import '../Typography-es.js';
|
|
6
6
|
import 'classnames';
|
|
7
7
|
import '../Select-es.js';
|
|
8
|
-
import '../
|
|
8
|
+
import '../FormFieldPostFix-es.js';
|
|
9
9
|
import '@jobber/hooks';
|
|
10
10
|
import 'framer-motion';
|
|
11
11
|
import '@jobber/design';
|
|
@@ -18,6 +18,7 @@ import '../InputValidation-es.js';
|
|
|
18
18
|
import '../Spinner-es.js';
|
|
19
19
|
import '../useAtlantisFormFieldName-es.js';
|
|
20
20
|
import 'react-hook-form';
|
|
21
|
+
import '../mergeRefs-es.js';
|
|
21
22
|
import '../filterDataAttributes-es.js';
|
|
22
23
|
import '../InputNumber/index.mjs';
|
|
23
24
|
import '../clsx-es.js';
|
package/dist/Select/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var Select = require('../Select-cjs.js');
|
|
4
4
|
require('react');
|
|
5
5
|
require('classnames');
|
|
6
|
-
require('../
|
|
6
|
+
require('../FormFieldPostFix-cjs.js');
|
|
7
7
|
require('@jobber/hooks');
|
|
8
8
|
require('framer-motion');
|
|
9
9
|
require('@jobber/design');
|
|
@@ -18,6 +18,7 @@ require('../InputValidation-cjs.js');
|
|
|
18
18
|
require('../Spinner-cjs.js');
|
|
19
19
|
require('../useAtlantisFormFieldName-cjs.js');
|
|
20
20
|
require('react-hook-form');
|
|
21
|
+
require('../mergeRefs-cjs.js');
|
|
21
22
|
require('../filterDataAttributes-cjs.js');
|
|
22
23
|
|
|
23
24
|
|
package/dist/Select/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { S as Option, a as Select } from '../Select-es.js';
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'classnames';
|
|
4
|
-
import '../
|
|
4
|
+
import '../FormFieldPostFix-es.js';
|
|
5
5
|
import '@jobber/hooks';
|
|
6
6
|
import 'framer-motion';
|
|
7
7
|
import '@jobber/design';
|
|
@@ -16,4 +16,5 @@ import '../InputValidation-es.js';
|
|
|
16
16
|
import '../Spinner-es.js';
|
|
17
17
|
import '../useAtlantisFormFieldName-es.js';
|
|
18
18
|
import 'react-hook-form';
|
|
19
|
+
import '../mergeRefs-es.js';
|
|
19
20
|
import '../filterDataAttributes-es.js';
|
package/dist/Select-cjs.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var classnames = require('classnames');
|
|
5
|
-
var
|
|
5
|
+
var FormFieldPostFix = require('./FormFieldPostFix-cjs.js');
|
|
6
6
|
var useAtlantisFormFieldName = require('./useAtlantisFormFieldName-cjs.js');
|
|
7
7
|
require('./tslib.es6-cjs.js');
|
|
8
8
|
require('react-hook-form');
|
|
9
|
+
var mergeRefs = require('./mergeRefs-cjs.js');
|
|
9
10
|
require('./Button-cjs.js');
|
|
10
11
|
require('@jobber/design');
|
|
11
12
|
var filterDataAttributes = require('./filterDataAttributes-cjs.js');
|
|
@@ -59,12 +60,12 @@ function Select(props) {
|
|
|
59
60
|
});
|
|
60
61
|
const descriptionVisible = props.description && !props.inline;
|
|
61
62
|
const isInvalid = Boolean(props.error || props.invalid);
|
|
62
|
-
return (React.createElement(
|
|
63
|
+
return (React.createElement(FormFieldPostFix.FormFieldWrapper, { disabled: props.disabled, size: props.size, align: props.align, inline: props.inline, name: name, wrapperRef: wrapperRef, error: (_a = props.error) !== null && _a !== void 0 ? _a : "", invalid: props.invalid, identifier: id, descriptionIdentifier: descriptionIdentifier, description: props.description, type: "select", placeholder: props.placeholder, value: props.value, prefix: props.prefix, suffix: props.suffix, clearable: "never" },
|
|
63
64
|
React.createElement(React.Fragment, null,
|
|
64
65
|
React.createElement("select", Object.assign({ id: id, name: name, disabled: props.disabled, autoFocus: props.autoFocus, required: props.required, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, value: props.value, "aria-label": props["aria-label"], "aria-describedby": descriptionVisible
|
|
65
66
|
? descriptionIdentifier
|
|
66
|
-
: props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], ref: mergedRef, className: classnames(
|
|
67
|
-
React.createElement(
|
|
67
|
+
: props["aria-describedby"], "aria-invalid": isInvalid ? true : undefined, "aria-required": props["aria-required"], ref: mergedRef, className: classnames(FormFieldPostFix.formFieldStyles.input, props.UNSAFE_experimentalStyles && styles.select) }, dataAttrs), props.children),
|
|
68
|
+
React.createElement(FormFieldPostFix.FormFieldPostFix, { variation: "select", className: styles.selectPostfix }))));
|
|
68
69
|
}
|
|
69
70
|
function useSelectRefs(inputRef) {
|
|
70
71
|
const internalRef = React.useRef(null);
|
package/dist/Select-es.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React__default, { useId, useRef } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import { c as FormFieldWrapper, g as formFieldStyles, h as FormFieldPostFix
|
|
3
|
+
import { c as FormFieldWrapper, g as formFieldStyles, h as FormFieldPostFix } from './FormFieldPostFix-es.js';
|
|
4
4
|
import { u as useAtlantisFormFieldName } from './useAtlantisFormFieldName-es.js';
|
|
5
5
|
import './tslib.es6-es.js';
|
|
6
6
|
import 'react-hook-form';
|
|
7
|
+
import { m as mergeRefs } from './mergeRefs-es.js';
|
|
7
8
|
import './Button-es.js';
|
|
8
9
|
import '@jobber/design';
|
|
9
10
|
import { f as filterDataAttributes } from './filterDataAttributes-es.js';
|