@jobber/components 7.5.0 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Autocomplete/index.cjs +6 -5
- package/dist/Autocomplete/index.mjs +3 -2
- package/dist/DataList/components/DataListSearch/index.cjs +1 -0
- package/dist/DataList/components/DataListSearch/index.mjs +1 -0
- package/dist/DataList/index.cjs +1 -0
- package/dist/DataList/index.mjs +1 -0
- package/dist/DataTable/index.cjs +2 -14
- package/dist/DataTable/index.mjs +2 -14
- package/dist/DataTable-cjs.js +3 -3
- package/dist/DataTable-es.js +1 -1
- package/dist/FormField/index.cjs +14 -13
- package/dist/FormField/index.mjs +5 -4
- package/dist/FormField-cjs.js +8 -281
- package/dist/FormField-es.js +3 -263
- package/dist/InputDate/InputDate.d.ts +1 -1
- package/dist/InputDate/InputDate.types.d.ts +2 -30
- package/dist/InputDate/index.cjs +22 -163
- package/dist/InputDate/index.d.ts +2 -4
- package/dist/InputDate/index.mjs +21 -166
- package/dist/InputDate/useInputDateActivatorActions.d.ts +2 -2
- package/dist/InputDate-cjs.js +96 -0
- package/dist/InputDate-es.js +94 -0
- package/dist/InputEmail/index.cjs +7 -6
- package/dist/InputEmail/index.mjs +4 -3
- package/dist/InputNumber/index.cjs +1 -0
- package/dist/InputNumber/index.mjs +2 -1
- package/dist/InputPassword/index.cjs +1 -0
- package/dist/InputPassword/index.mjs +1 -0
- package/dist/InputPassword-es.js +1 -1
- package/dist/InputPhoneNumber/index.cjs +6 -5
- package/dist/InputPhoneNumber/index.mjs +2 -1
- package/dist/InputText/index.cjs +8 -7
- package/dist/InputText/index.mjs +4 -3
- package/dist/InputTime/index.cjs +5 -4
- package/dist/InputTime/index.mjs +2 -1
- package/dist/RecurringSelect/index.cjs +3 -14
- package/dist/RecurringSelect/index.mjs +3 -14
- package/dist/RecurringSelect-cjs.js +6 -6
- package/dist/RecurringSelect-es.js +1 -1
- package/dist/Select/Select.d.ts +6 -2
- package/dist/Select/Select.types.d.ts +2 -16
- package/dist/Select/index.cjs +11 -103
- package/dist/Select/index.d.ts +2 -9
- package/dist/Select/index.mjs +9 -105
- package/dist/Select-cjs.js +78 -0
- package/dist/Select-es.js +75 -0
- package/dist/docs/InputDate/InputDate.md +31 -19
- package/dist/docs/Select/Select.md +69 -33
- package/dist/docs/usage-guidelines/usage-guidelines.md +9 -13
- package/dist/index.cjs +16 -15
- package/dist/index.mjs +4 -3
- package/dist/mergeRefs-cjs.js +279 -0
- package/dist/mergeRefs-es.js +265 -0
- package/package.json +2 -2
- package/dist/InputDate/InputDate.rebuilt.d.ts +0 -3
- package/dist/Select/Select.rebuilt.d.ts +0 -3
package/dist/InputDate/index.mjs
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
export { I as InputDate } from '../InputDate-es.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '../DatePicker-es.js';
|
|
4
4
|
import 'classnames';
|
|
5
|
-
import '../
|
|
6
|
-
import 'react-
|
|
5
|
+
import '../clsx-es.js';
|
|
6
|
+
import '../floating-ui.react-es.js';
|
|
7
|
+
import '../index.esm-es.js';
|
|
8
|
+
import 'react/jsx-runtime';
|
|
9
|
+
import 'react-dom';
|
|
10
|
+
import '../floating-ui.react-dom-es.js';
|
|
7
11
|
import '@jobber/hooks';
|
|
8
|
-
import '
|
|
9
|
-
import '@jobber/design';
|
|
12
|
+
import '../Typography-es.js';
|
|
10
13
|
import '../Button-es.js';
|
|
11
|
-
import
|
|
12
|
-
import
|
|
14
|
+
import '../tslib.es6-es.js';
|
|
15
|
+
import 'react-router-dom';
|
|
16
|
+
import '../Icon-es.js';
|
|
17
|
+
import '@jobber/design';
|
|
18
|
+
import '../omit-es.js';
|
|
13
19
|
import '../_commonjsHelpers-es.js';
|
|
14
20
|
import '../_getAllKeys-es.js';
|
|
15
21
|
import '../isTypedArray-es.js';
|
|
@@ -21,165 +27,14 @@ import '../keysIn-es.js';
|
|
|
21
27
|
import '../_baseAssignValue-es.js';
|
|
22
28
|
import '../_baseFlatten-es.js';
|
|
23
29
|
import '../_setToString-es.js';
|
|
24
|
-
import '../
|
|
30
|
+
import '../AtlantisContext-es.js';
|
|
31
|
+
import '../InputText/index.mjs';
|
|
32
|
+
import '../FormField-es.js';
|
|
33
|
+
import '../mergeRefs-es.js';
|
|
34
|
+
import 'framer-motion';
|
|
25
35
|
import '../Text-es.js';
|
|
26
|
-
import '../Typography-es.js';
|
|
27
36
|
import '../useFormFieldFocus-es.js';
|
|
28
37
|
import '../InputValidation-es.js';
|
|
29
38
|
import '../Spinner-es.js';
|
|
30
|
-
import 'react-
|
|
31
|
-
import '../clsx-es.js';
|
|
32
|
-
import '../floating-ui.react-es.js';
|
|
33
|
-
import '../index.esm-es.js';
|
|
34
|
-
import 'react/jsx-runtime';
|
|
35
|
-
import 'react-dom';
|
|
36
|
-
import '../floating-ui.react-dom-es.js';
|
|
37
|
-
import '../AtlantisContext-es.js';
|
|
39
|
+
import 'react-hook-form';
|
|
38
40
|
import '../filterDataAttributes-es.js';
|
|
39
|
-
|
|
40
|
-
// eslint-disable-next-line import/no-deprecated
|
|
41
|
-
function InputDate$1(inputProps) {
|
|
42
|
-
const formFieldActionsRef = useRef(null);
|
|
43
|
-
return (React__default.createElement(DatePicker, { selected: inputProps.value, onChange: inputProps.onChange, disabled: inputProps.disabled, readonly: inputProps.readonly, fullWidth: !inputProps.inline, minDate: inputProps.minDate, maxDate: inputProps.maxDate, smartAutofocus: false, activator: activatorProps => {
|
|
44
|
-
const { onChange, onClick, value } = activatorProps;
|
|
45
|
-
const newActivatorProps = omit(activatorProps, ["activator"]);
|
|
46
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
47
|
-
const suffix = inputProps.showIcon !== false
|
|
48
|
-
? {
|
|
49
|
-
icon: "calendar",
|
|
50
|
-
ariaLabel: "Show calendar",
|
|
51
|
-
onClick: !inputProps.disabled && onClick && onClick,
|
|
52
|
-
}
|
|
53
|
-
: undefined;
|
|
54
|
-
// Set form field to formatted date string immediately, to avoid validations
|
|
55
|
-
// triggering incorrectly when it blurs (to handle the datepicker UI click)
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
var _a;
|
|
58
|
-
value && ((_a = formFieldActionsRef.current) === null || _a === void 0 ? void 0 : _a.setValue(value));
|
|
59
|
-
}, [value]);
|
|
60
|
-
const showEmptyValueLabel = !value && !isFocused;
|
|
61
|
-
return (
|
|
62
|
-
// We prevent the picker from opening on focus for keyboard navigation, so to maintain a good UX for mouse users we want to open the picker on click
|
|
63
|
-
React__default.createElement("div", { onClick: onClick },
|
|
64
|
-
React__default.createElement(FormField, Object.assign({}, newActivatorProps, inputProps, { value: showEmptyValueLabel ? inputProps.emptyValueLabel || "" : value, placeholder: inputProps.placeholder, onChange: (_, event) => {
|
|
65
|
-
onChange && onChange(event);
|
|
66
|
-
}, onBlur: () => {
|
|
67
|
-
inputProps.onBlur && inputProps.onBlur();
|
|
68
|
-
activatorProps.onBlur && activatorProps.onBlur();
|
|
69
|
-
setIsFocused(false);
|
|
70
|
-
}, onFocus: () => {
|
|
71
|
-
inputProps.onFocus && inputProps.onFocus();
|
|
72
|
-
activatorProps.onFocus && activatorProps.onFocus();
|
|
73
|
-
setIsFocused(true);
|
|
74
|
-
}, onKeyUp: event => {
|
|
75
|
-
var _a;
|
|
76
|
-
if (inputProps.showIcon === false &&
|
|
77
|
-
event.key === "ArrowDown") {
|
|
78
|
-
(_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
|
|
79
|
-
}
|
|
80
|
-
}, actionsRef: formFieldActionsRef, suffix: suffix }))));
|
|
81
|
-
} }));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
85
|
-
const [isFocused, setIsFocused] = useState(false);
|
|
86
|
-
function handleChange(_newValue, event) {
|
|
87
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
88
|
-
}
|
|
89
|
-
function handleFocus(event) {
|
|
90
|
-
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
91
|
-
setIsFocused(true);
|
|
92
|
-
}
|
|
93
|
-
function handleBlur(event) {
|
|
94
|
-
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
95
|
-
setIsFocused(false);
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
handleBlur,
|
|
99
|
-
handleChange,
|
|
100
|
-
handleFocus,
|
|
101
|
-
isFocused,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const InputDateRebuilt = forwardRef((props, forwardedRef) => {
|
|
106
|
-
const { onChange } = props;
|
|
107
|
-
const isCalendarOpenRef = useRef(false);
|
|
108
|
-
const inputFocusedRef = useRef(false);
|
|
109
|
-
const compositeFocusedRef = useRef(false);
|
|
110
|
-
const lastBlurEventRef = useRef(null);
|
|
111
|
-
return (React__default.createElement(DatePicker, { selected: props.value, onChange: newValue => {
|
|
112
|
-
onChange(newValue);
|
|
113
|
-
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator, onOpenChange: open => {
|
|
114
|
-
var _a;
|
|
115
|
-
isCalendarOpenRef.current = open;
|
|
116
|
-
// When calendar closes, fire onBlur if input is also not focused
|
|
117
|
-
if (!open &&
|
|
118
|
-
!inputFocusedRef.current &&
|
|
119
|
-
compositeFocusedRef.current &&
|
|
120
|
-
lastBlurEventRef.current) {
|
|
121
|
-
compositeFocusedRef.current = false;
|
|
122
|
-
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, lastBlurEventRef.current);
|
|
123
|
-
}
|
|
124
|
-
} }));
|
|
125
|
-
function InputDateActivator(activatorProps) {
|
|
126
|
-
const { onClick, value } = activatorProps;
|
|
127
|
-
const { handleChange, handleFocus, handleBlur, isFocused } = useInputDateActivatorActions({
|
|
128
|
-
onChange: activatorProps.onChange,
|
|
129
|
-
onFocus: event => {
|
|
130
|
-
var _a, _b;
|
|
131
|
-
inputFocusedRef.current = true;
|
|
132
|
-
// Fire parent's onFocus only when the composite component first receives focus
|
|
133
|
-
if (!compositeFocusedRef.current) {
|
|
134
|
-
compositeFocusedRef.current = true;
|
|
135
|
-
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
136
|
-
}
|
|
137
|
-
(_b = activatorProps.onFocus) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
138
|
-
},
|
|
139
|
-
onBlur: event => {
|
|
140
|
-
var _a, _b;
|
|
141
|
-
inputFocusedRef.current = false;
|
|
142
|
-
lastBlurEventRef.current = event;
|
|
143
|
-
// Only fire parent's onBlur if calendar is also closed
|
|
144
|
-
if (!isCalendarOpenRef.current && compositeFocusedRef.current) {
|
|
145
|
-
compositeFocusedRef.current = false;
|
|
146
|
-
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
147
|
-
}
|
|
148
|
-
(_b = activatorProps.onBlur) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
const suffix = props.showIcon !== false
|
|
152
|
-
? {
|
|
153
|
-
icon: "calendar",
|
|
154
|
-
ariaLabel: "Show calendar",
|
|
155
|
-
onClick: !props.disabled && onClick && onClick,
|
|
156
|
-
}
|
|
157
|
-
: undefined;
|
|
158
|
-
const showEmptyValueLabel = !value && !isFocused;
|
|
159
|
-
return (
|
|
160
|
-
// We prevent the picker from opening on focus for keyboard navigation, so to maintain a good UX for mouse users we want to open the picker on click
|
|
161
|
-
React__default.createElement("div", { onClick: onClick },
|
|
162
|
-
React__default.createElement(InputText, { "aria-describedby": activatorProps.ariaDescribedBy, "aria-labelledby": activatorProps.ariaLabelledBy, "aria-required": activatorProps.ariaRequired === "true" ? true : false, autoFocus: props.autoFocus, id: activatorProps.id, autoComplete: props.autoComplete, disabled: props.disabled, error: props.error, readOnly: props.readOnly, placeholder: props.placeholder, size: props.size, inline: props.inline, align: props.align, description: props.description, invalid: props.invalid, required: props.required, name: props.name, version: 2, value: showEmptyValueLabel ? props.emptyValueLabel || "" : value || "", ref: forwardedRef, suffix: suffix, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: event => {
|
|
163
|
-
var _a, _b;
|
|
164
|
-
if (props.showIcon === false && event.key === "ArrowDown") {
|
|
165
|
-
(_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
|
|
166
|
-
}
|
|
167
|
-
(_b = props.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(props, event);
|
|
168
|
-
}, onChange: handleChange })));
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
InputDateRebuilt.displayName = "InputDateRebuilt";
|
|
172
|
-
|
|
173
|
-
function isNewInputDateProps(props) {
|
|
174
|
-
return props.version === 2;
|
|
175
|
-
}
|
|
176
|
-
const InputDate = forwardRef(function InputDateShim(props, ref) {
|
|
177
|
-
if (isNewInputDateProps(props)) {
|
|
178
|
-
return React__default.createElement(InputDateRebuilt, Object.assign({}, props, { ref: ref }));
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
return React__default.createElement(InputDate$1, Object.assign({}, props));
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
export { InputDate };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ChangeEvent } from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { InputDateProps } from "./InputDate.types";
|
|
3
3
|
import type { DatePickerActivatorProps } from "../DatePicker/DatePickerActivator";
|
|
4
|
-
export interface useInputDateActivatorActionsProps extends Pick<
|
|
4
|
+
export interface useInputDateActivatorActionsProps extends Pick<InputDateProps, "onFocus" | "onBlur"> {
|
|
5
5
|
onChange: DatePickerActivatorProps["onChange"];
|
|
6
6
|
}
|
|
7
7
|
export declare function useInputDateActivatorActions({ onChange, onBlur, onFocus, }: useInputDateActivatorActionsProps): {
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var DatePicker = require('./DatePicker-cjs.js');
|
|
5
|
+
var InputText_index = require('./InputText/index.cjs');
|
|
6
|
+
|
|
7
|
+
function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
8
|
+
const [isFocused, setIsFocused] = React.useState(false);
|
|
9
|
+
function handleChange(_newValue, event) {
|
|
10
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
11
|
+
}
|
|
12
|
+
function handleFocus(event) {
|
|
13
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
14
|
+
setIsFocused(true);
|
|
15
|
+
}
|
|
16
|
+
function handleBlur(event) {
|
|
17
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
18
|
+
setIsFocused(false);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
handleBlur,
|
|
22
|
+
handleChange,
|
|
23
|
+
handleFocus,
|
|
24
|
+
isFocused,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const InputDate = React.forwardRef((props, forwardedRef) => {
|
|
29
|
+
const { onChange } = props;
|
|
30
|
+
const isCalendarOpenRef = React.useRef(false);
|
|
31
|
+
const inputFocusedRef = React.useRef(false);
|
|
32
|
+
const compositeFocusedRef = React.useRef(false);
|
|
33
|
+
const lastBlurEventRef = React.useRef(null);
|
|
34
|
+
return (React.createElement(DatePicker.DatePicker, { selected: props.value, onChange: newValue => {
|
|
35
|
+
onChange(newValue);
|
|
36
|
+
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator, onOpenChange: open => {
|
|
37
|
+
var _a;
|
|
38
|
+
isCalendarOpenRef.current = open;
|
|
39
|
+
// When calendar closes, fire onBlur if input is also not focused
|
|
40
|
+
if (!open &&
|
|
41
|
+
!inputFocusedRef.current &&
|
|
42
|
+
compositeFocusedRef.current &&
|
|
43
|
+
lastBlurEventRef.current) {
|
|
44
|
+
compositeFocusedRef.current = false;
|
|
45
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, lastBlurEventRef.current);
|
|
46
|
+
}
|
|
47
|
+
} }));
|
|
48
|
+
function InputDateActivator(activatorProps) {
|
|
49
|
+
const { onClick, value } = activatorProps;
|
|
50
|
+
const { handleChange, handleFocus, handleBlur, isFocused } = useInputDateActivatorActions({
|
|
51
|
+
onChange: activatorProps.onChange,
|
|
52
|
+
onFocus: event => {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
inputFocusedRef.current = true;
|
|
55
|
+
// Fire parent's onFocus only when the composite component first receives focus
|
|
56
|
+
if (!compositeFocusedRef.current) {
|
|
57
|
+
compositeFocusedRef.current = true;
|
|
58
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
59
|
+
}
|
|
60
|
+
(_b = activatorProps.onFocus) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
61
|
+
},
|
|
62
|
+
onBlur: event => {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
inputFocusedRef.current = false;
|
|
65
|
+
lastBlurEventRef.current = event;
|
|
66
|
+
// Only fire parent's onBlur if calendar is also closed
|
|
67
|
+
if (!isCalendarOpenRef.current && compositeFocusedRef.current) {
|
|
68
|
+
compositeFocusedRef.current = false;
|
|
69
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
70
|
+
}
|
|
71
|
+
(_b = activatorProps.onBlur) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
const suffix = props.showIcon !== false
|
|
75
|
+
? {
|
|
76
|
+
icon: "calendar",
|
|
77
|
+
ariaLabel: "Show calendar",
|
|
78
|
+
onClick: !props.disabled && onClick && onClick,
|
|
79
|
+
}
|
|
80
|
+
: undefined;
|
|
81
|
+
const showEmptyValueLabel = !value && !isFocused;
|
|
82
|
+
return (
|
|
83
|
+
// We prevent the picker from opening on focus for keyboard navigation, so to maintain a good UX for mouse users we want to open the picker on click
|
|
84
|
+
React.createElement("div", { onClick: onClick },
|
|
85
|
+
React.createElement(InputText_index.InputText, { "aria-describedby": activatorProps.ariaDescribedBy, "aria-labelledby": activatorProps.ariaLabelledBy, "aria-required": activatorProps.ariaRequired === "true" ? true : false, autoFocus: props.autoFocus, id: activatorProps.id, autoComplete: props.autoComplete, disabled: props.disabled, error: props.error, readOnly: props.readOnly, placeholder: props.placeholder, size: props.size, inline: props.inline, align: props.align, description: props.description, invalid: props.invalid, required: props.required, name: props.name, version: 2, value: showEmptyValueLabel ? props.emptyValueLabel || "" : value || "", ref: forwardedRef, suffix: suffix, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: event => {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
if (props.showIcon === false && event.key === "ArrowDown") {
|
|
88
|
+
(_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
|
|
89
|
+
}
|
|
90
|
+
(_b = props.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(props, event);
|
|
91
|
+
}, onChange: handleChange })));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
InputDate.displayName = "InputDate";
|
|
95
|
+
|
|
96
|
+
exports.InputDate = InputDate;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React__default, { useState, forwardRef, useRef } from 'react';
|
|
2
|
+
import { D as DatePicker } from './DatePicker-es.js';
|
|
3
|
+
import { InputText } from './InputText/index.mjs';
|
|
4
|
+
|
|
5
|
+
function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
6
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
7
|
+
function handleChange(_newValue, event) {
|
|
8
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
9
|
+
}
|
|
10
|
+
function handleFocus(event) {
|
|
11
|
+
onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
|
|
12
|
+
setIsFocused(true);
|
|
13
|
+
}
|
|
14
|
+
function handleBlur(event) {
|
|
15
|
+
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
16
|
+
setIsFocused(false);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
handleBlur,
|
|
20
|
+
handleChange,
|
|
21
|
+
handleFocus,
|
|
22
|
+
isFocused,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const InputDate = forwardRef((props, forwardedRef) => {
|
|
27
|
+
const { onChange } = props;
|
|
28
|
+
const isCalendarOpenRef = useRef(false);
|
|
29
|
+
const inputFocusedRef = useRef(false);
|
|
30
|
+
const compositeFocusedRef = useRef(false);
|
|
31
|
+
const lastBlurEventRef = useRef(null);
|
|
32
|
+
return (React__default.createElement(DatePicker, { selected: props.value, onChange: newValue => {
|
|
33
|
+
onChange(newValue);
|
|
34
|
+
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator, onOpenChange: open => {
|
|
35
|
+
var _a;
|
|
36
|
+
isCalendarOpenRef.current = open;
|
|
37
|
+
// When calendar closes, fire onBlur if input is also not focused
|
|
38
|
+
if (!open &&
|
|
39
|
+
!inputFocusedRef.current &&
|
|
40
|
+
compositeFocusedRef.current &&
|
|
41
|
+
lastBlurEventRef.current) {
|
|
42
|
+
compositeFocusedRef.current = false;
|
|
43
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, lastBlurEventRef.current);
|
|
44
|
+
}
|
|
45
|
+
} }));
|
|
46
|
+
function InputDateActivator(activatorProps) {
|
|
47
|
+
const { onClick, value } = activatorProps;
|
|
48
|
+
const { handleChange, handleFocus, handleBlur, isFocused } = useInputDateActivatorActions({
|
|
49
|
+
onChange: activatorProps.onChange,
|
|
50
|
+
onFocus: event => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
inputFocusedRef.current = true;
|
|
53
|
+
// Fire parent's onFocus only when the composite component first receives focus
|
|
54
|
+
if (!compositeFocusedRef.current) {
|
|
55
|
+
compositeFocusedRef.current = true;
|
|
56
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
57
|
+
}
|
|
58
|
+
(_b = activatorProps.onFocus) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
59
|
+
},
|
|
60
|
+
onBlur: event => {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
inputFocusedRef.current = false;
|
|
63
|
+
lastBlurEventRef.current = event;
|
|
64
|
+
// Only fire parent's onBlur if calendar is also closed
|
|
65
|
+
if (!isCalendarOpenRef.current && compositeFocusedRef.current) {
|
|
66
|
+
compositeFocusedRef.current = false;
|
|
67
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
68
|
+
}
|
|
69
|
+
(_b = activatorProps.onBlur) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
const suffix = props.showIcon !== false
|
|
73
|
+
? {
|
|
74
|
+
icon: "calendar",
|
|
75
|
+
ariaLabel: "Show calendar",
|
|
76
|
+
onClick: !props.disabled && onClick && onClick,
|
|
77
|
+
}
|
|
78
|
+
: undefined;
|
|
79
|
+
const showEmptyValueLabel = !value && !isFocused;
|
|
80
|
+
return (
|
|
81
|
+
// We prevent the picker from opening on focus for keyboard navigation, so to maintain a good UX for mouse users we want to open the picker on click
|
|
82
|
+
React__default.createElement("div", { onClick: onClick },
|
|
83
|
+
React__default.createElement(InputText, { "aria-describedby": activatorProps.ariaDescribedBy, "aria-labelledby": activatorProps.ariaLabelledBy, "aria-required": activatorProps.ariaRequired === "true" ? true : false, autoFocus: props.autoFocus, id: activatorProps.id, autoComplete: props.autoComplete, disabled: props.disabled, error: props.error, readOnly: props.readOnly, placeholder: props.placeholder, size: props.size, inline: props.inline, align: props.align, description: props.description, invalid: props.invalid, required: props.required, name: props.name, version: 2, value: showEmptyValueLabel ? props.emptyValueLabel || "" : value || "", ref: forwardedRef, suffix: suffix, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: event => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
if (props.showIcon === false && event.key === "ArrowDown") {
|
|
86
|
+
(_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
|
|
87
|
+
}
|
|
88
|
+
(_b = props.onKeyDown) === null || _b === void 0 ? void 0 : _b.call(props, event);
|
|
89
|
+
}, onChange: handleChange })));
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
InputDate.displayName = "InputDate";
|
|
93
|
+
|
|
94
|
+
export { InputDate as I };
|
|
@@ -9,14 +9,15 @@ require('@jobber/hooks');
|
|
|
9
9
|
require('framer-motion');
|
|
10
10
|
require('@jobber/design');
|
|
11
11
|
require('../Button-cjs.js');
|
|
12
|
+
var mergeRefs = require('../mergeRefs-cjs.js');
|
|
12
13
|
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
14
|
+
require('react-router-dom');
|
|
13
15
|
require('../Icon-cjs.js');
|
|
14
|
-
require('../Text-cjs.js');
|
|
15
16
|
require('../Typography-cjs.js');
|
|
17
|
+
require('../Text-cjs.js');
|
|
16
18
|
require('../useFormFieldFocus-cjs.js');
|
|
17
19
|
require('../InputValidation-cjs.js');
|
|
18
20
|
require('../Spinner-cjs.js');
|
|
19
|
-
require('react-router-dom');
|
|
20
21
|
|
|
21
22
|
const validationMessage = "Please enter a valid email";
|
|
22
23
|
|
|
@@ -102,7 +103,7 @@ const InputEmailRebuilt = React.forwardRef(function InputEmailInternal(props, re
|
|
|
102
103
|
const id = props.id || generatedId;
|
|
103
104
|
const inputRef = (_a = ref) !== null && _a !== void 0 ? _a : React.useRef(null);
|
|
104
105
|
const wrapperRef = React.useRef(null);
|
|
105
|
-
const { name } =
|
|
106
|
+
const { name } = mergeRefs.useAtlantisFormFieldName({
|
|
106
107
|
nameProp: props.name,
|
|
107
108
|
id,
|
|
108
109
|
});
|
|
@@ -124,9 +125,9 @@ const InputEmailRebuilt = React.forwardRef(function InputEmailInternal(props, re
|
|
|
124
125
|
const descriptionVisible = props.description && !props.inline;
|
|
125
126
|
const isInvalid = Boolean(props.error || props.invalid);
|
|
126
127
|
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
127
|
-
return (React.createElement(
|
|
128
|
-
React.createElement("input", Object.assign({ id: id, name: name, type: "email", ref: inputRef, className:
|
|
129
|
-
React.createElement(
|
|
128
|
+
return (React.createElement(mergeRefs.FormFieldWrapper, { error: props.error || "", invalid: props.invalid, identifier: id, descriptionIdentifier: descriptionIdentifier, size: props.size, inline: props.inline, align: props.align, prefix: props.prefix, suffix: props.suffix, description: props.description, clearable: (_b = props.clearable) !== null && _b !== void 0 ? _b : "never", onClear: handleClear, readonly: props.readOnly, wrapperRef: wrapperRef, disabled: props.disabled, type: "email", value: props.value, placeholder: props.placeholder, name: name },
|
|
129
|
+
React.createElement("input", Object.assign({ id: id, name: name, type: "email", ref: inputRef, className: mergeRefs.formFieldStyles.input, value: props.value, disabled: props.disabled, readOnly: props.readOnly, autoFocus: props.autoFocus, autoComplete: props.autoComplete, pattern: props.pattern, inputMode: props.inputMode, tabIndex: props.tabIndex, maxLength: props.maxLength, 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, onKeyUp: handleKeyUp, onClick: handleClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, "data-testid": "ATL-InputEmail-input" }, dataAttrs)),
|
|
130
|
+
React.createElement(mergeRefs.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false })));
|
|
130
131
|
});
|
|
131
132
|
|
|
132
133
|
function isNewInputEmailProps(props) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default, { forwardRef, useId, useRef } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { F as FormField } from '../FormField-es.js';
|
|
3
3
|
import 'classnames';
|
|
4
4
|
import '../tslib.es6-es.js';
|
|
5
5
|
import 'react-hook-form';
|
|
@@ -7,14 +7,15 @@ import '@jobber/hooks';
|
|
|
7
7
|
import 'framer-motion';
|
|
8
8
|
import '@jobber/design';
|
|
9
9
|
import '../Button-es.js';
|
|
10
|
+
import { u as useAtlantisFormFieldName, c as FormFieldWrapper, h as formFieldStyles, i as FormFieldPostFix } from '../mergeRefs-es.js';
|
|
10
11
|
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
12
|
+
import 'react-router-dom';
|
|
11
13
|
import '../Icon-es.js';
|
|
12
|
-
import '../Text-es.js';
|
|
13
14
|
import '../Typography-es.js';
|
|
15
|
+
import '../Text-es.js';
|
|
14
16
|
import '../useFormFieldFocus-es.js';
|
|
15
17
|
import '../InputValidation-es.js';
|
|
16
18
|
import '../Spinner-es.js';
|
|
17
|
-
import 'react-router-dom';
|
|
18
19
|
|
|
19
20
|
const validationMessage = "Please enter a valid email";
|
|
20
21
|
|
|
@@ -15,6 +15,7 @@ require('@jobber/design');
|
|
|
15
15
|
require('../Button-cjs.js');
|
|
16
16
|
require('../clsx-cjs.js');
|
|
17
17
|
require('../Typography-cjs.js');
|
|
18
|
+
require('../mergeRefs-cjs.js');
|
|
18
19
|
require('../useFormFieldFocus-cjs.js');
|
|
19
20
|
require('../InputValidation-cjs.js');
|
|
20
21
|
require('../Spinner-cjs.js');
|
|
@@ -5,7 +5,7 @@ import classnames from 'classnames';
|
|
|
5
5
|
import { I as Icon } from '../Icon-es.js';
|
|
6
6
|
import { T as Text } from '../Text-es.js';
|
|
7
7
|
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
8
|
-
import {
|
|
8
|
+
import { F as FormField } from '../FormField-es.js';
|
|
9
9
|
import 'react-hook-form';
|
|
10
10
|
import '@jobber/hooks';
|
|
11
11
|
import 'framer-motion';
|
|
@@ -13,6 +13,7 @@ import '@jobber/design';
|
|
|
13
13
|
import '../Button-es.js';
|
|
14
14
|
import '../clsx-es.js';
|
|
15
15
|
import '../Typography-es.js';
|
|
16
|
+
import '../mergeRefs-es.js';
|
|
16
17
|
import '../useFormFieldFocus-es.js';
|
|
17
18
|
import '../InputValidation-es.js';
|
|
18
19
|
import '../Spinner-es.js';
|
package/dist/InputPassword-es.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var tslib_es6 = require('../tslib.es6-cjs.js');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
|
-
var
|
|
6
|
+
var mergeRefs = require('../mergeRefs-cjs.js');
|
|
7
7
|
var reactHookForm = require('react-hook-form');
|
|
8
8
|
require('../Button-cjs.js');
|
|
9
9
|
require('@jobber/design');
|
|
10
10
|
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
11
|
+
var FormField = require('../FormField-cjs.js');
|
|
11
12
|
require('@jobber/hooks');
|
|
12
13
|
require('framer-motion');
|
|
13
14
|
require('../Icon-cjs.js');
|
|
@@ -176,7 +177,7 @@ const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberIntern
|
|
|
176
177
|
const wrapperRef = React.useRef(null);
|
|
177
178
|
const generatedId = React.useId();
|
|
178
179
|
const id = props.id || generatedId;
|
|
179
|
-
const { name } =
|
|
180
|
+
const { name } = mergeRefs.useAtlantisFormFieldName({
|
|
180
181
|
nameProp: props.name,
|
|
181
182
|
id: id,
|
|
182
183
|
});
|
|
@@ -202,14 +203,14 @@ const InputPhoneNumberRebuilt = React.forwardRef(function InputPhoneNumberIntern
|
|
|
202
203
|
const descriptionIdentifier = `descriptionUUID--${id}`, descriptionVisible = props.description && !props.inline;
|
|
203
204
|
const isInvalid = Boolean(props.error || props.invalid);
|
|
204
205
|
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
205
|
-
return (React.createElement(
|
|
206
|
-
React.createElement("input", Object.assign({ id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(
|
|
206
|
+
return (React.createElement(mergeRefs.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 },
|
|
207
|
+
React.createElement("input", Object.assign({ id: id, name: name, type: "tel", ref: inputPhoneNumberRef, className: classnames(mergeRefs.formFieldStyles.input, {
|
|
207
208
|
[styles.emptyValue]: inputValue.length === 0 && pattern[0] === "(",
|
|
208
209
|
}), 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
|
|
209
210
|
? descriptionIdentifier
|
|
210
211
|
: 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)),
|
|
211
212
|
React.createElement(MaskElement, { isMasking: isMasking, formattedValue: formattedValue, placeholderMask: placeholderMask }),
|
|
212
|
-
React.createElement(
|
|
213
|
+
React.createElement(mergeRefs.FormFieldPostFix, { variation: "spinner", visible: (_e = props.loading) !== null && _e !== void 0 ? _e : false })));
|
|
213
214
|
});
|
|
214
215
|
|
|
215
216
|
function InputPhoneNumber$1(_a) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React__default, { useState, useMemo, useCallback, useEffect, cloneElement, forwardRef, useId } from 'react';
|
|
2
2
|
import { _ as __rest } from '../tslib.es6-es.js';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
-
import {
|
|
4
|
+
import { u as useAtlantisFormFieldName, c as FormFieldWrapper, h as formFieldStyles, i as FormFieldPostFix } from '../mergeRefs-es.js';
|
|
5
5
|
import { useFormContext, useForm } from 'react-hook-form';
|
|
6
6
|
import '../Button-es.js';
|
|
7
7
|
import '@jobber/design';
|
|
8
8
|
import { f as filterDataAttributes } from '../filterDataAttributes-es.js';
|
|
9
|
+
import { F as FormField } from '../FormField-es.js';
|
|
9
10
|
import '@jobber/hooks';
|
|
10
11
|
import 'framer-motion';
|
|
11
12
|
import '../Icon-es.js';
|
package/dist/InputText/index.cjs
CHANGED
|
@@ -9,14 +9,15 @@ require('react-hook-form');
|
|
|
9
9
|
require('framer-motion');
|
|
10
10
|
require('@jobber/design');
|
|
11
11
|
require('../Button-cjs.js');
|
|
12
|
+
var mergeRefs = require('../mergeRefs-cjs.js');
|
|
12
13
|
var filterDataAttributes = require('../filterDataAttributes-cjs.js');
|
|
14
|
+
require('react-router-dom');
|
|
13
15
|
require('../Icon-cjs.js');
|
|
14
|
-
require('../Text-cjs.js');
|
|
15
16
|
require('../Typography-cjs.js');
|
|
17
|
+
require('../Text-cjs.js');
|
|
16
18
|
require('../useFormFieldFocus-cjs.js');
|
|
17
19
|
require('../InputValidation-cjs.js');
|
|
18
20
|
require('../Spinner-cjs.js');
|
|
19
|
-
require('react-router-dom');
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Hook for resizing a textarea based on its content. The textarea will grow up to the max number of rows specified.
|
|
@@ -220,7 +221,7 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
|
|
|
220
221
|
inputRef: inputTextRef,
|
|
221
222
|
wrapperRef: wrapperRef,
|
|
222
223
|
});
|
|
223
|
-
const { name } =
|
|
224
|
+
const { name } = mergeRefs.useAtlantisFormFieldName({
|
|
224
225
|
nameProp: props.name,
|
|
225
226
|
id: id,
|
|
226
227
|
});
|
|
@@ -242,16 +243,16 @@ const InputTextSPAR = React.forwardRef(function InputTextInternal(props, inputRe
|
|
|
242
243
|
const descriptionVisible = props.description && !props.inline;
|
|
243
244
|
const isInvalid = Boolean(props.error || props.invalid);
|
|
244
245
|
const dataAttrs = filterDataAttributes.filterDataAttributes(props);
|
|
245
|
-
const mergedRef = React.useMemo(() =>
|
|
246
|
+
const mergedRef = React.useMemo(() => mergeRefs.mergeRefs([inputRef, inputTextRef]), []);
|
|
246
247
|
// Shared props for both TextArea and TextInput
|
|
247
248
|
const commonInputProps = Object.assign({ id,
|
|
248
|
-
name, className:
|
|
249
|
+
name, className: mergeRefs.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
|
|
249
250
|
? descriptionIdentifier
|
|
250
251
|
: 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);
|
|
251
|
-
return (React.createElement(
|
|
252
|
+
return (React.createElement(mergeRefs.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 },
|
|
252
253
|
React.createElement(React.Fragment, null,
|
|
253
254
|
props.multiline ? (React.createElement(TextArea, Object.assign({}, commonInputProps, { rows: rowRange.min }))) : (React.createElement(TextInput, Object.assign({}, commonInputProps, { pattern: props.pattern }))),
|
|
254
|
-
React.createElement(
|
|
255
|
+
React.createElement(mergeRefs.FormFieldPostFix, { variation: "spinner", visible: (_c = props.loading) !== null && _c !== void 0 ? _c : false }))));
|
|
255
256
|
});
|
|
256
257
|
function useInputTextId(props) {
|
|
257
258
|
const generatedId = React.useId();
|