@jobber/components 6.101.4 → 6.101.5-JOB-140604-4487daa.55
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/Autocomplete.types.d.ts +11 -51
- package/dist/Autocomplete/components/MenuList.d.ts +3 -2
- package/dist/Autocomplete/components/PersistentRegion.d.ts +3 -2
- package/dist/Autocomplete/hooks/useAutocompleteListNav.d.ts +3 -2
- package/dist/Autocomplete/index.cjs +95 -51
- package/dist/Autocomplete/index.mjs +97 -53
- package/dist/Autocomplete/tests/Autocomplete.setup.d.ts +14 -1
- package/dist/Autocomplete/useAutocomplete.d.ts +4 -3
- package/dist/Autocomplete/utils/interactionUtils.d.ts +14 -0
- package/dist/Card-cjs.js +1 -1
- package/dist/Card-es.js +1 -1
- package/dist/Checkbox/Checkbox.rebuilt.d.ts +2 -2
- package/dist/Checkbox/Checkbox.types.d.ts +24 -18
- package/dist/Checkbox/index.cjs +9 -2
- package/dist/Checkbox/index.mjs +9 -2
- package/dist/Chip/Chip.d.ts +1 -2
- package/dist/Chip/hooks/useChildComponent.d.ts +4 -3
- package/dist/Chip/index.cjs +1 -1
- package/dist/Chip-cjs.js +5 -4
- package/dist/Chip-es.js +5 -4
- package/dist/ChipDismissible-cjs.js +4 -4
- package/dist/ChipDismissible-es.js +5 -5
- package/dist/Chips/InternalChipDismissible/hooks/index.cjs +2 -2
- package/dist/Chips/InternalChipDismissible/hooks/index.mjs +2 -2
- package/dist/Chips/InternalChipDismissible/hooks/useInView.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/useInternalChipDismissibleInput.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/hooks/useScrollToActive.d.ts +1 -1
- package/dist/Chips/InternalChipDismissible/index.cjs +2 -2
- package/dist/Chips/InternalChipDismissible/index.mjs +2 -2
- package/dist/Chips/index.cjs +2 -2
- package/dist/Chips/index.mjs +2 -2
- package/dist/Combobox/Combobox.d.ts +2 -1
- package/dist/Combobox/Combobox.types.d.ts +2 -2
- package/dist/Combobox/ComboboxProvider.d.ts +3 -3
- package/dist/Combobox/components/ComboboxActivator/ComboboxActivator.d.ts +1 -1
- package/dist/Combobox/components/ComboboxContent/ComboboxContent.d.ts +2 -1
- package/dist/Combobox/components/ComboboxContent/ComboboxContentHeader/ComboboxContentHeader.d.ts +2 -1
- package/dist/Combobox/components/ComboboxContent/ComboboxContentList/ComboboxContentList.d.ts +2 -1
- package/dist/Combobox/components/ComboboxContent/ComboboxContentSearch/ComboboxContentSearch.d.ts +2 -1
- package/dist/Combobox/hooks/useCombobox.d.ts +1 -1
- package/dist/Combobox/hooks/useComboboxAccessibility.d.ts +2 -2
- package/dist/Combobox/hooks/useComboboxContent.d.ts +2 -1
- package/dist/Combobox/hooks/useMakeComboboxHandlers.d.ts +1 -1
- package/dist/ComboboxActivator-cjs.js +2 -2
- package/dist/ComboboxActivator-es.js +3 -3
- package/dist/ComboboxTrigger-cjs.js +1 -1
- package/dist/ComboboxTrigger-es.js +2 -2
- package/dist/DataList/DataList.types.d.ts +2 -2
- package/dist/DataList/DataList.utils.d.ts +2 -2
- package/dist/DataList/components/DataListHeader/index.cjs +1 -0
- package/dist/DataList/components/DataListHeader/index.mjs +1 -0
- package/dist/DataList/components/DataListHeaderTile/components/DataListSortingOptions.d.ts +2 -2
- package/dist/DataList/components/DataListItem/DataListItemInternal.d.ts +2 -2
- package/dist/DataList/components/DataListItem/index.cjs +1 -0
- package/dist/DataList/components/DataListItem/index.mjs +1 -0
- package/dist/DataList/components/DataListItems/index.cjs +1 -0
- package/dist/DataList/components/DataListItems/index.mjs +1 -0
- package/dist/DataList/components/DataListLayout/index.cjs +1 -0
- package/dist/DataList/components/DataListLayout/index.mjs +1 -0
- package/dist/DataList/components/DataListSearch/index.cjs +2 -12
- package/dist/DataList/components/DataListSearch/index.mjs +2 -12
- package/dist/DataList/hooks/useGetItemActions.d.ts +1 -1
- package/dist/DataList/index.cjs +1 -8
- package/dist/DataList/index.mjs +1 -8
- package/dist/DataListActions-cjs.js +4 -2
- package/dist/DataListActions-es.js +4 -2
- package/dist/DataListItem-cjs.js +8 -7
- package/dist/DataListItem-es.js +9 -8
- package/dist/DataListSort-cjs.js +1 -1
- package/dist/DataListSort-es.js +2 -2
- package/dist/DataTable/SortIcon.d.ts +2 -1
- package/dist/DataTable/components/DataTableSortableHeader.d.ts +1 -1
- package/dist/DataTable/index.cjs +3 -2
- package/dist/DataTable/index.mjs +3 -2
- package/dist/DatePicker/DatePicker.d.ts +5 -1
- package/dist/DatePicker/index.cjs +2 -2
- package/dist/DatePicker/index.mjs +2 -2
- package/dist/DatePicker/useFocusOnSelectedDate.d.ts +1 -2
- package/dist/DatePicker-cjs.js +4 -2
- package/dist/DatePicker-es.js +5 -3
- package/dist/FormField/FormFieldAffix.d.ts +2 -2
- package/dist/FormField/FormFieldTypes.d.ts +3 -5
- package/dist/FormField/FormFieldWrapper.d.ts +5 -1
- package/dist/FormField/hooks/useFormFieldFocus.d.ts +1 -1
- package/dist/FormField/hooks/useFormFieldWrapperStyles.d.ts +9 -4
- package/dist/FormField-cjs.js +35 -31
- package/dist/FormField-es.js +35 -31
- package/dist/InputDate/InputDate.types.d.ts +12 -7
- package/dist/InputDate/index.cjs +35 -12
- package/dist/InputDate/index.mjs +35 -12
- package/dist/InputDate/useInputDateActivatorActions.d.ts +4 -8
- package/dist/InputEmail/InputEmail.types.d.ts +10 -20
- package/dist/InputEmail/hooks/useInputEmailActions.d.ts +10 -4
- package/dist/InputEmail/index.cjs +43 -60
- package/dist/InputEmail/index.mjs +44 -61
- package/dist/InputFile-cjs.js +5 -2
- package/dist/InputFile-es.js +5 -2
- package/dist/InputGroup-cjs.js +5 -2
- package/dist/InputGroup-es.js +5 -2
- package/dist/InputNumber/InputNumber.rebuilt.types.d.ts +7 -15
- package/dist/InputNumber/index.cjs +7 -5
- package/dist/InputNumber/index.mjs +7 -5
- package/dist/InputPhoneNumber/InputPhoneNumber.types.d.ts +12 -28
- package/dist/InputPhoneNumber/hooks/useInputPhoneActions.d.ts +9 -4
- package/dist/InputPhoneNumber/index.cjs +37 -36
- package/dist/InputPhoneNumber/index.mjs +38 -37
- package/dist/InputText/InputText.d.ts +2 -2
- package/dist/InputText/InputText.types.d.ts +30 -25
- package/dist/InputText/index.cjs +54 -62
- package/dist/InputText/index.mjs +55 -63
- package/dist/InputText/useInputTextActions.d.ts +11 -5
- package/dist/InputText/useTextAreaResize.d.ts +2 -2
- package/dist/InputTime/InputTime.rebuilt.d.ts +1 -1
- package/dist/InputTime/InputTime.types.d.ts +13 -4
- package/dist/InputTime/hooks/useInputTimeActions.d.ts +21 -0
- package/dist/InputTime/index.cjs +90 -30
- package/dist/InputTime/index.mjs +93 -33
- package/dist/InternalChipDismissible-cjs.js +3 -3
- package/dist/InternalChipDismissible-es.js +4 -4
- package/dist/List/index.cjs +2 -2
- package/dist/List/index.mjs +2 -2
- package/dist/Menu/Menu.d.ts +2 -4
- package/dist/Menu/Menu.types.d.ts +21 -5
- package/dist/Menu-cjs.js +9 -9
- package/dist/Menu-es.js +9 -9
- package/dist/Modal/Modal.types.d.ts +3 -3
- package/dist/Modal/ModalContext.rebuilt.d.ts +2 -2
- package/dist/MultiSelect/DropDownMenu.d.ts +1 -1
- package/dist/MultiSelect/index.cjs +1 -0
- package/dist/MultiSelect/index.mjs +1 -0
- package/dist/MultiSelect-cjs.js +13 -7
- package/dist/MultiSelect-es.js +13 -7
- package/dist/RadioGroup/RadioGroup.d.ts +2 -1
- package/dist/RadioGroup/RadioOption.d.ts +1 -1
- package/dist/RecurringSelect/index.cjs +3 -2
- package/dist/RecurringSelect/index.mjs +3 -2
- package/dist/Select/Select.types.d.ts +7 -3
- package/dist/Select/hooks/useSelectActions.d.ts +5 -5
- package/dist/Select/index.cjs +27 -42
- package/dist/Select/index.mjs +29 -44
- package/dist/StatusLabel/StatusLabel.d.ts +2 -1
- package/dist/Tabs/hooks/useTabsOverflow.d.ts +2 -2
- package/dist/Tabs-cjs.js +4 -2
- package/dist/Tabs-es.js +5 -3
- package/dist/Tooltip/useTooltipPositioning.d.ts +1 -1
- package/dist/_baseEach-cjs.js +12 -12
- package/dist/_baseEach-es.js +1 -1
- package/dist/_baseFlatten-cjs.js +2 -2
- package/dist/_baseFlatten-es.js +1 -1
- package/dist/{_baseGet-cjs.js → _getAllKeys-cjs.js} +181 -181
- package/dist/{_baseGet-es.js → _getAllKeys-es.js} +182 -182
- package/dist/debounce-es.js +1 -1
- package/dist/filterDataAttributes-cjs.js +26 -0
- package/dist/filterDataAttributes-es.js +24 -0
- package/dist/floating-ui.react-cjs.js +115 -0
- package/dist/floating-ui.react-es.js +115 -1
- package/dist/helpers-cjs.js +1 -1
- package/dist/helpers-es.js +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.mjs +3 -2
- package/dist/omit-cjs.js +14 -14
- package/dist/omit-es.js +1 -1
- package/dist/sharedHelpers/filterDataAttributes.d.ts +17 -0
- package/dist/sharedHelpers/types.d.ts +231 -0
- package/dist/showToast-cjs.js +2 -2
- package/dist/showToast-es.js +2 -2
- package/dist/styles.css +32 -23
- package/dist/useChildComponent-cjs.js +1 -1
- package/dist/useChildComponent-es.js +1 -1
- package/dist/useScrollToActive-cjs.js +3 -3
- package/dist/useScrollToActive-es.js +2 -2
- package/dist/utils/mergeRefs.d.ts +2 -2
- package/package.json +2 -2
- package/dist/InputEmail/hooks/useInputEmailFormField.d.ts +0 -32
- package/dist/InputPhoneNumber/hooks/useInputPhoneFormField.d.ts +0 -71
- package/dist/InputText/useInputTextFormField.d.ts +0 -352
- package/dist/Select/hooks/useSelectFormField.d.ts +0 -34
package/dist/FormField-cjs.js
CHANGED
|
@@ -14,22 +14,22 @@ var Spinner = require('./Spinner-cjs.js');
|
|
|
14
14
|
var tslib_es6 = require('./tslib.es6-cjs.js');
|
|
15
15
|
var reactHookForm = require('react-hook-form');
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
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-"};
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
21
21
|
*/
|
|
22
22
|
function AffixLabel({ label, variation = "prefix", labelRef, }) {
|
|
23
|
-
const affixLabelClass = classnames(
|
|
24
|
-
[
|
|
23
|
+
const affixLabelClass = classnames(formFieldStyles.affixLabel, {
|
|
24
|
+
[formFieldStyles.suffix]: variation === "suffix",
|
|
25
25
|
});
|
|
26
26
|
if (!label)
|
|
27
27
|
return null;
|
|
28
28
|
return (React.createElement("div", { ref: labelRef, className: affixLabelClass }, label));
|
|
29
29
|
}
|
|
30
30
|
function AffixIcon({ icon, onClick, ariaLabel, variation = "prefix", size, }) {
|
|
31
|
-
const affixIconClass = classnames(
|
|
32
|
-
[
|
|
31
|
+
const affixIconClass = classnames(formFieldStyles.affixIcon, {
|
|
32
|
+
[formFieldStyles.suffix]: variation === "suffix",
|
|
33
33
|
});
|
|
34
34
|
const iconSize = size === "small" ? "small" : "base";
|
|
35
35
|
if (!icon)
|
|
@@ -51,7 +51,7 @@ function FormFieldDescription({ id, description, visible = true, }) {
|
|
|
51
51
|
if (!visible)
|
|
52
52
|
return null;
|
|
53
53
|
const useStringFormat = !description || typeof description === "string";
|
|
54
|
-
return (React.createElement("div", { id: id, className:
|
|
54
|
+
return (React.createElement("div", { id: id, className: formFieldStyles.description }, useStringFormat ? (React.createElement(Text.Text, { size: "small", variation: "subdued" }, description)) : (description)));
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
var styles = {"clearInput":"YmRTd-KeXv4-","spinning":"B25z9B8I3gs-"};
|
|
@@ -86,22 +86,22 @@ function useIsSafari() {
|
|
|
86
86
|
*/
|
|
87
87
|
function useFormFieldWrapperStyles({ size, align, placeholder, value, invalid, error, max, prefixRef, suffixRef, maxLength, type, disabled, inline, showMiniLabel = true, }) {
|
|
88
88
|
const isSafari = useIsSafari();
|
|
89
|
-
const wrapperClasses = classnames(
|
|
90
|
-
[
|
|
89
|
+
const wrapperClasses = classnames(formFieldStyles.wrapper, size && formFieldStyles[size], align && formFieldStyles[align], {
|
|
90
|
+
[formFieldStyles.miniLabel]: (showMiniLabel && placeholder && value !== "") ||
|
|
91
91
|
(placeholder && type === "select") ||
|
|
92
92
|
// Naively assume that if the the type is tel, it is the InputPhoneNumber
|
|
93
93
|
(placeholder && type === "tel"),
|
|
94
|
-
[
|
|
95
|
-
[
|
|
96
|
-
[
|
|
97
|
-
[
|
|
98
|
-
[
|
|
99
|
-
[
|
|
100
|
-
[
|
|
101
|
-
[
|
|
94
|
+
[formFieldStyles.text]: type === "textarea" || type === "text",
|
|
95
|
+
[formFieldStyles.textarea]: type === "textarea",
|
|
96
|
+
[formFieldStyles.safari]: isSafari && type === "textarea",
|
|
97
|
+
[formFieldStyles.select]: type === "select",
|
|
98
|
+
[formFieldStyles.invalid]: invalid !== null && invalid !== void 0 ? invalid : error,
|
|
99
|
+
[formFieldStyles.disabled]: disabled,
|
|
100
|
+
[formFieldStyles.maxLength]: maxLength,
|
|
101
|
+
[formFieldStyles.timeInputLabel]: placeholder && type === "time" && placeholder && value === "",
|
|
102
102
|
});
|
|
103
|
-
const containerClasses = classnames(
|
|
104
|
-
[
|
|
103
|
+
const containerClasses = classnames(formFieldStyles.container, {
|
|
104
|
+
[formFieldStyles.inline]: inline,
|
|
105
105
|
});
|
|
106
106
|
const wrapperInlineStyle = {
|
|
107
107
|
["--formField-maxLength"]: maxLength || max,
|
|
@@ -120,7 +120,7 @@ function useFormFieldWrapperStyles({ size, align, placeholder, value, invalid, e
|
|
|
120
120
|
}));
|
|
121
121
|
}, [value]);
|
|
122
122
|
return {
|
|
123
|
-
inputStyle:
|
|
123
|
+
inputStyle: formFieldStyles.input,
|
|
124
124
|
wrapperClasses,
|
|
125
125
|
containerClasses,
|
|
126
126
|
wrapperInlineStyle,
|
|
@@ -150,8 +150,8 @@ function getAffixPaddding({ value, type, prefixWidth, suffixWidth, }) {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
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, }) {
|
|
153
|
-
const prefixRef = React.useRef();
|
|
154
|
-
const suffixRef = React.useRef();
|
|
153
|
+
const prefixRef = React.useRef(null);
|
|
154
|
+
const suffixRef = React.useRef(null);
|
|
155
155
|
const { wrapperClasses, containerClasses, wrapperInlineStyle, labelStyle } = useFormFieldWrapperStyles({
|
|
156
156
|
align,
|
|
157
157
|
max,
|
|
@@ -203,24 +203,24 @@ function FormFieldWrapper({ align, description, descriptionIdentifier, placehold
|
|
|
203
203
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
204
204
|
*/
|
|
205
205
|
function FormFieldInputHorizontalWrapper({ children, }) {
|
|
206
|
-
return React.createElement("div", { className:
|
|
206
|
+
return React.createElement("div", { className: formFieldStyles.horizontalWrapper }, children);
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
210
210
|
*/
|
|
211
211
|
function FormFieldInputWrapperStyles({ children, }) {
|
|
212
|
-
return React.createElement("div", { className:
|
|
212
|
+
return React.createElement("div", { className: formFieldStyles.inputWrapper }, children);
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
215
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
216
216
|
*/
|
|
217
217
|
function FormFieldWrapperMain({ children, tabIndex = -1, }) {
|
|
218
|
-
return (React.createElement("div", { className:
|
|
218
|
+
return (React.createElement("div", { className: formFieldStyles.childrenWrapper, tabIndex: tabIndex }, children));
|
|
219
219
|
}
|
|
220
220
|
function FormFieldLabel({ children, htmlFor, style, external = false, }) {
|
|
221
221
|
if (!children)
|
|
222
222
|
return null;
|
|
223
|
-
return (React.createElement("label", { className: external ?
|
|
223
|
+
return (React.createElement("label", { className: external ? formFieldStyles.externalLabel : formFieldStyles.label, htmlFor: htmlFor, style: style }, children));
|
|
224
224
|
}
|
|
225
225
|
/**
|
|
226
226
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
@@ -230,13 +230,13 @@ function FormFieldWrapperToolbar({ toolbar, isToolbarVisible, toolbarAnimationEn
|
|
|
230
230
|
duration: design.tokens["timing-base"] / 1000,
|
|
231
231
|
ease: "easeInOut",
|
|
232
232
|
}, tabIndex: -1 },
|
|
233
|
-
React.createElement("div", { className:
|
|
233
|
+
React.createElement("div", { className: formFieldStyles.toolbar, "data-testid": "ATL-InputText-Toolbar" }, toolbar)))));
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
function FormFieldPostFix({ variation, visible = true, className, }) {
|
|
237
237
|
if (!visible)
|
|
238
238
|
return null;
|
|
239
|
-
return (React.createElement("span", { className: classnames(
|
|
239
|
+
return (React.createElement("span", { className: classnames(formFieldStyles.postfix, className) }, variation === "select" ? (React.createElement(Icon.Icon, { name: "arrowDown" })) : (React.createElement(Spinner.Spinner, { size: "small" }))));
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
/**
|
|
@@ -299,8 +299,8 @@ function useAtlantisFormFieldActions({ name, onChange, inputRef, onControllerCha
|
|
|
299
299
|
*/
|
|
300
300
|
function useAtlantisFormField({ id, nameProp, name, useControllerField: useControllerField, description, disabled, readonly, keyboard, autofocus, pattern, type, value, handleChange, handleBlur, handleFocus, inline, validations, handleKeyDown, handleValidation, errorMessage, }) {
|
|
301
301
|
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
302
|
-
const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(
|
|
303
|
-
[
|
|
302
|
+
const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(formFieldStyles.input, {
|
|
303
|
+
[formFieldStyles.emptyPhoneNumber]: shouldAddPhoneNumberClass(type, value, pattern),
|
|
304
304
|
}), name: (validations || nameProp) && name, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, autoFocus: autofocus }), (description &&
|
|
305
305
|
!inline && { "aria-describedby": descriptionIdentifier }));
|
|
306
306
|
const textFieldProps = Object.assign(Object.assign({}, fieldProps), { autoFocus: autofocus, onKeyDown: handleKeyDown });
|
|
@@ -383,6 +383,7 @@ function FormField(props) {
|
|
|
383
383
|
return React.createElement(FormFieldInternal, Object.assign({}, props, { id: id }));
|
|
384
384
|
}
|
|
385
385
|
function FormFieldInternal(props) {
|
|
386
|
+
var _a;
|
|
386
387
|
const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, id, inputRef, inline, keyboard, max, maxLength, min, name: nameProp, pattern, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, onKeyUp, clearable = "never", autofocus, } = props;
|
|
387
388
|
const { name } = useAtlantisFormFieldName({ id, nameProp });
|
|
388
389
|
const { errorMessage, inputRefs, useControllerField, setValue, onControllerBlur, onControllerChange, } = useAtlantisReactHookForm({
|
|
@@ -429,7 +430,10 @@ function FormFieldInternal(props) {
|
|
|
429
430
|
handleValidation,
|
|
430
431
|
handleKeyDown,
|
|
431
432
|
});
|
|
432
|
-
|
|
433
|
+
// Ensure focus tracking works by providing a wrapperRef when none is passed
|
|
434
|
+
const internalWrapperRef = React.useRef(null);
|
|
435
|
+
const wrapperRef = (_a = props.wrapperRef) !== null && _a !== void 0 ? _a : internalWrapperRef;
|
|
436
|
+
return (React.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
|
|
433
437
|
function renderField() {
|
|
434
438
|
switch (type) {
|
|
435
439
|
case "select":
|
|
@@ -466,8 +470,8 @@ exports.FormFieldPostFix = FormFieldPostFix;
|
|
|
466
470
|
exports.FormFieldWrapper = FormFieldWrapper;
|
|
467
471
|
exports.FormFieldWrapperMain = FormFieldWrapperMain;
|
|
468
472
|
exports.FormFieldWrapperToolbar = FormFieldWrapperToolbar;
|
|
473
|
+
exports.formFieldStyles = formFieldStyles;
|
|
469
474
|
exports.mergeRefs = mergeRefs;
|
|
470
|
-
exports.styles = styles$1;
|
|
471
475
|
exports.useAtlantisFormField = useAtlantisFormField;
|
|
472
476
|
exports.useAtlantisFormFieldActions = useAtlantisFormFieldActions;
|
|
473
477
|
exports.useAtlantisFormFieldName = useAtlantisFormFieldName;
|
package/dist/FormField-es.js
CHANGED
|
@@ -12,22 +12,22 @@ import { S as Spinner } from './Spinner-es.js';
|
|
|
12
12
|
import { _ as __rest } from './tslib.es6-es.js';
|
|
13
13
|
import { useFormContext, useForm, useController } from 'react-hook-form';
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var formFieldStyles = {"container":"YL-mNv-Bl6g-","wrapper":"_8lhbGTQ-hhg-","disabled":"Tz9LK9ABKMk-","horizontalWrapper":"b5mv1x1H7YE-","textarea":"hGr6YW4AeLM-","safari":"QBCWi9GBgMs-","timeInputLabel":"_0pmqVa2zSE4-","miniLabel":"F1t76G6bDKo-","large":"_9tjyT9QUtP8-","text":"QmMiyoAWp-g-","invalid":"XWDSfe6weSY-","small":"Sw5O4I0lMJg-","inline":"SaORbL7SYWY-","center":"ozy2UoT2vsg-","right":"_3TJdT91YD3c-","maxLength":"W6GrMqLy2qk-","inputWrapper":"-LmjnYRU0r0-","childrenWrapper":"yVXYv6hkuOA-","input":"vtSDcuzNr9Q-","emptyPhoneNumber":"MVhuQuzUBUs-","label":"Dgk00tzlODA-","select":"NwQGiWBWIsc-","externalLabel":"Qb8zQ8n-8vc-","postfix":"yTDzs9h1otI-","affixIcon":"m0YpdssD2dY-","suffix":"_-3mMnjSh6ok-","affixLabel":"-Wzcb0pBh5I-","description":"DHX5ijY3xIw-","toolbar":"AL-2brNI7dk-","spinning":"_8Rzv7CcDW80-"};
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
19
19
|
*/
|
|
20
20
|
function AffixLabel({ label, variation = "prefix", labelRef, }) {
|
|
21
|
-
const affixLabelClass = classnames(
|
|
22
|
-
[
|
|
21
|
+
const affixLabelClass = classnames(formFieldStyles.affixLabel, {
|
|
22
|
+
[formFieldStyles.suffix]: variation === "suffix",
|
|
23
23
|
});
|
|
24
24
|
if (!label)
|
|
25
25
|
return null;
|
|
26
26
|
return (React__default.createElement("div", { ref: labelRef, className: affixLabelClass }, label));
|
|
27
27
|
}
|
|
28
28
|
function AffixIcon({ icon, onClick, ariaLabel, variation = "prefix", size, }) {
|
|
29
|
-
const affixIconClass = classnames(
|
|
30
|
-
[
|
|
29
|
+
const affixIconClass = classnames(formFieldStyles.affixIcon, {
|
|
30
|
+
[formFieldStyles.suffix]: variation === "suffix",
|
|
31
31
|
});
|
|
32
32
|
const iconSize = size === "small" ? "small" : "base";
|
|
33
33
|
if (!icon)
|
|
@@ -49,7 +49,7 @@ function FormFieldDescription({ id, description, visible = true, }) {
|
|
|
49
49
|
if (!visible)
|
|
50
50
|
return null;
|
|
51
51
|
const useStringFormat = !description || typeof description === "string";
|
|
52
|
-
return (React__default.createElement("div", { id: id, className:
|
|
52
|
+
return (React__default.createElement("div", { id: id, className: formFieldStyles.description }, useStringFormat ? (React__default.createElement(Text, { size: "small", variation: "subdued" }, description)) : (description)));
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
var styles = {"clearInput":"YmRTd-KeXv4-","spinning":"B25z9B8I3gs-"};
|
|
@@ -84,22 +84,22 @@ function useIsSafari() {
|
|
|
84
84
|
*/
|
|
85
85
|
function useFormFieldWrapperStyles({ size, align, placeholder, value, invalid, error, max, prefixRef, suffixRef, maxLength, type, disabled, inline, showMiniLabel = true, }) {
|
|
86
86
|
const isSafari = useIsSafari();
|
|
87
|
-
const wrapperClasses = classnames(
|
|
88
|
-
[
|
|
87
|
+
const wrapperClasses = classnames(formFieldStyles.wrapper, size && formFieldStyles[size], align && formFieldStyles[align], {
|
|
88
|
+
[formFieldStyles.miniLabel]: (showMiniLabel && placeholder && value !== "") ||
|
|
89
89
|
(placeholder && type === "select") ||
|
|
90
90
|
// Naively assume that if the the type is tel, it is the InputPhoneNumber
|
|
91
91
|
(placeholder && type === "tel"),
|
|
92
|
-
[
|
|
93
|
-
[
|
|
94
|
-
[
|
|
95
|
-
[
|
|
96
|
-
[
|
|
97
|
-
[
|
|
98
|
-
[
|
|
99
|
-
[
|
|
92
|
+
[formFieldStyles.text]: type === "textarea" || type === "text",
|
|
93
|
+
[formFieldStyles.textarea]: type === "textarea",
|
|
94
|
+
[formFieldStyles.safari]: isSafari && type === "textarea",
|
|
95
|
+
[formFieldStyles.select]: type === "select",
|
|
96
|
+
[formFieldStyles.invalid]: invalid !== null && invalid !== void 0 ? invalid : error,
|
|
97
|
+
[formFieldStyles.disabled]: disabled,
|
|
98
|
+
[formFieldStyles.maxLength]: maxLength,
|
|
99
|
+
[formFieldStyles.timeInputLabel]: placeholder && type === "time" && placeholder && value === "",
|
|
100
100
|
});
|
|
101
|
-
const containerClasses = classnames(
|
|
102
|
-
[
|
|
101
|
+
const containerClasses = classnames(formFieldStyles.container, {
|
|
102
|
+
[formFieldStyles.inline]: inline,
|
|
103
103
|
});
|
|
104
104
|
const wrapperInlineStyle = {
|
|
105
105
|
["--formField-maxLength"]: maxLength || max,
|
|
@@ -118,7 +118,7 @@ function useFormFieldWrapperStyles({ size, align, placeholder, value, invalid, e
|
|
|
118
118
|
}));
|
|
119
119
|
}, [value]);
|
|
120
120
|
return {
|
|
121
|
-
inputStyle:
|
|
121
|
+
inputStyle: formFieldStyles.input,
|
|
122
122
|
wrapperClasses,
|
|
123
123
|
containerClasses,
|
|
124
124
|
wrapperInlineStyle,
|
|
@@ -148,8 +148,8 @@ function getAffixPaddding({ value, type, prefixWidth, suffixWidth, }) {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
function FormFieldWrapper({ align, description, descriptionIdentifier, placeholder, value, children, invalid, error, size, prefix, suffix, max, maxLength, type, disabled, inline, identifier, clearable, onClear, readonly, toolbar, toolbarVisibility = "while-editing", showMiniLabel = true, wrapperRef, }) {
|
|
151
|
-
const prefixRef = useRef();
|
|
152
|
-
const suffixRef = useRef();
|
|
151
|
+
const prefixRef = useRef(null);
|
|
152
|
+
const suffixRef = useRef(null);
|
|
153
153
|
const { wrapperClasses, containerClasses, wrapperInlineStyle, labelStyle } = useFormFieldWrapperStyles({
|
|
154
154
|
align,
|
|
155
155
|
max,
|
|
@@ -201,24 +201,24 @@ function FormFieldWrapper({ align, description, descriptionIdentifier, placehold
|
|
|
201
201
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
202
202
|
*/
|
|
203
203
|
function FormFieldInputHorizontalWrapper({ children, }) {
|
|
204
|
-
return React__default.createElement("div", { className:
|
|
204
|
+
return React__default.createElement("div", { className: formFieldStyles.horizontalWrapper }, children);
|
|
205
205
|
}
|
|
206
206
|
/**
|
|
207
207
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
208
208
|
*/
|
|
209
209
|
function FormFieldInputWrapperStyles({ children, }) {
|
|
210
|
-
return React__default.createElement("div", { className:
|
|
210
|
+
return React__default.createElement("div", { className: formFieldStyles.inputWrapper }, children);
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
213
213
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
214
214
|
*/
|
|
215
215
|
function FormFieldWrapperMain({ children, tabIndex = -1, }) {
|
|
216
|
-
return (React__default.createElement("div", { className:
|
|
216
|
+
return (React__default.createElement("div", { className: formFieldStyles.childrenWrapper, tabIndex: tabIndex }, children));
|
|
217
217
|
}
|
|
218
218
|
function FormFieldLabel({ children, htmlFor, style, external = false, }) {
|
|
219
219
|
if (!children)
|
|
220
220
|
return null;
|
|
221
|
-
return (React__default.createElement("label", { className: external ?
|
|
221
|
+
return (React__default.createElement("label", { className: external ? formFieldStyles.externalLabel : formFieldStyles.label, htmlFor: htmlFor, style: style }, children));
|
|
222
222
|
}
|
|
223
223
|
/**
|
|
224
224
|
* @internal Reach out to UX Foundations if using this component since it is possible it might change
|
|
@@ -228,13 +228,13 @@ function FormFieldWrapperToolbar({ toolbar, isToolbarVisible, toolbarAnimationEn
|
|
|
228
228
|
duration: tokens["timing-base"] / 1000,
|
|
229
229
|
ease: "easeInOut",
|
|
230
230
|
}, tabIndex: -1 },
|
|
231
|
-
React__default.createElement("div", { className:
|
|
231
|
+
React__default.createElement("div", { className: formFieldStyles.toolbar, "data-testid": "ATL-InputText-Toolbar" }, toolbar)))));
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
function FormFieldPostFix({ variation, visible = true, className, }) {
|
|
235
235
|
if (!visible)
|
|
236
236
|
return null;
|
|
237
|
-
return (React__default.createElement("span", { className: classnames(
|
|
237
|
+
return (React__default.createElement("span", { className: classnames(formFieldStyles.postfix, className) }, variation === "select" ? (React__default.createElement(Icon, { name: "arrowDown" })) : (React__default.createElement(Spinner, { size: "small" }))));
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
/**
|
|
@@ -297,8 +297,8 @@ function useAtlantisFormFieldActions({ name, onChange, inputRef, onControllerCha
|
|
|
297
297
|
*/
|
|
298
298
|
function useAtlantisFormField({ id, nameProp, name, useControllerField: useControllerField, description, disabled, readonly, keyboard, autofocus, pattern, type, value, handleChange, handleBlur, handleFocus, inline, validations, handleKeyDown, handleValidation, errorMessage, }) {
|
|
299
299
|
const descriptionIdentifier = `descriptionUUID--${id}`;
|
|
300
|
-
const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(
|
|
301
|
-
[
|
|
300
|
+
const fieldProps = Object.assign(Object.assign(Object.assign({}, useControllerField), { id, className: classnames(formFieldStyles.input, {
|
|
301
|
+
[formFieldStyles.emptyPhoneNumber]: shouldAddPhoneNumberClass(type, value, pattern),
|
|
302
302
|
}), name: (validations || nameProp) && name, disabled: disabled, readOnly: readonly, inputMode: keyboard, onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, autoFocus: autofocus }), (description &&
|
|
303
303
|
!inline && { "aria-describedby": descriptionIdentifier }));
|
|
304
304
|
const textFieldProps = Object.assign(Object.assign({}, fieldProps), { autoFocus: autofocus, onKeyDown: handleKeyDown });
|
|
@@ -381,6 +381,7 @@ function FormField(props) {
|
|
|
381
381
|
return React__default.createElement(FormFieldInternal, Object.assign({}, props, { id: id }));
|
|
382
382
|
}
|
|
383
383
|
function FormFieldInternal(props) {
|
|
384
|
+
var _a;
|
|
384
385
|
const { actionsRef, autocomplete = true, children, defaultValue, description, disabled, id, inputRef, inline, keyboard, max, maxLength, min, name: nameProp, pattern, readonly, rows, loading, type = "text", validations, value, onChange, onEnter, onFocus, onBlur, onValidation, onKeyUp, clearable = "never", autofocus, } = props;
|
|
385
386
|
const { name } = useAtlantisFormFieldName({ id, nameProp });
|
|
386
387
|
const { errorMessage, inputRefs, useControllerField, setValue, onControllerBlur, onControllerChange, } = useAtlantisReactHookForm({
|
|
@@ -427,7 +428,10 @@ function FormFieldInternal(props) {
|
|
|
427
428
|
handleValidation,
|
|
428
429
|
handleKeyDown,
|
|
429
430
|
});
|
|
430
|
-
|
|
431
|
+
// Ensure focus tracking works by providing a wrapperRef when none is passed
|
|
432
|
+
const internalWrapperRef = useRef(null);
|
|
433
|
+
const wrapperRef = (_a = props.wrapperRef) !== null && _a !== void 0 ? _a : internalWrapperRef;
|
|
434
|
+
return (React__default.createElement(FormFieldWrapper, Object.assign({}, props, { value: useControllerField.value, error: errorMessage, identifier: id, descriptionIdentifier: descriptionIdentifier, clearable: clearable, onClear: handleClear, wrapperRef: wrapperRef }), renderField()));
|
|
431
435
|
function renderField() {
|
|
432
436
|
switch (type) {
|
|
433
437
|
case "select":
|
|
@@ -454,4 +458,4 @@ function setAutocomplete(autocompleteSetting) {
|
|
|
454
458
|
return autocompleteSetting;
|
|
455
459
|
}
|
|
456
460
|
|
|
457
|
-
export { AffixIcon as A, FormFieldInputHorizontalWrapper as F, useAtlantisFormFieldActions as a, useAtlantisFormFieldName as b, useAtlantisReactHookForm as c, FormFieldInputWrapperStyles as d, FormFieldLabel as e, FormFieldWrapper as f, FormFieldWrapperMain as g, FormFieldWrapperToolbar as h, AffixLabel as i, useFormFieldWrapperStyles as j, FormField as k,
|
|
461
|
+
export { AffixIcon as A, FormFieldInputHorizontalWrapper as F, useAtlantisFormFieldActions as a, useAtlantisFormFieldName as b, useAtlantisReactHookForm as c, FormFieldInputWrapperStyles as d, FormFieldLabel as e, FormFieldWrapper as f, FormFieldWrapperMain as g, FormFieldWrapperToolbar as h, AffixLabel as i, useFormFieldWrapperStyles as j, FormField as k, formFieldStyles as l, FormFieldPostFix as m, mergeRefs as n, useAtlantisFormField as u };
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import type { CommonFormFieldProps, FormFieldProps } from "../FormField";
|
|
2
|
-
import type {
|
|
3
|
-
export interface InputDateRebuiltProps extends
|
|
2
|
+
import type { FocusEvents, HTMLInputBaseProps, KeyboardEvents, RebuiltInputCommonProps } from "../sharedHelpers/types";
|
|
3
|
+
export interface InputDateRebuiltProps extends HTMLInputBaseProps, FocusEvents<HTMLInputElement | HTMLTextAreaElement>, KeyboardEvents<HTMLInputElement | HTMLTextAreaElement>, Omit<RebuiltInputCommonProps, "clearable" | "prefix" | "suffix"> {
|
|
4
4
|
/**
|
|
5
5
|
* A Date object value
|
|
6
6
|
* (e.g., `new Date("11/11/2011")`)
|
|
7
7
|
* */
|
|
8
8
|
readonly value?: Date;
|
|
9
|
+
/**
|
|
10
|
+
* Callback for value changes.
|
|
11
|
+
* @param newValue - The new Date value
|
|
12
|
+
* @param event - Optional change event
|
|
13
|
+
*/
|
|
14
|
+
readonly onChange: (newValue: Date, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `onKeyDown` or `onKeyUp` instead.
|
|
17
|
+
*/
|
|
18
|
+
readonly onEnter?: FormFieldProps["onEnter"];
|
|
9
19
|
/**
|
|
10
20
|
* The maximum selectable date.
|
|
11
21
|
*/
|
|
@@ -23,11 +33,6 @@ export interface InputDateRebuiltProps extends Omit<InputTextRebuiltProps, "clea
|
|
|
23
33
|
* Text to display instead of a date value
|
|
24
34
|
*/
|
|
25
35
|
readonly emptyValueLabel?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Version 2 is highly experimental, avoid using it unless you have talked with Atlantis first.
|
|
28
|
-
*/
|
|
29
|
-
readonly version: 2;
|
|
30
|
-
readonly onChange: (newValue: Date, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
31
36
|
}
|
|
32
37
|
export interface InputDateProps extends Omit<CommonFormFieldProps, "clearable">, Pick<FormFieldProps, "readonly" | "disabled" | "onEnter" | "onFocus" | "inputRef" | "validations" | "placeholder" | "onChange" | "onBlur"> {
|
|
33
38
|
/**
|
package/dist/InputDate/index.cjs
CHANGED
|
@@ -13,12 +13,12 @@ require('../Button-cjs.js');
|
|
|
13
13
|
var DatePicker = require('../DatePicker-cjs.js');
|
|
14
14
|
var InputText_index = require('../InputText/index.cjs');
|
|
15
15
|
require('../_commonjsHelpers-cjs.js');
|
|
16
|
-
require('../
|
|
16
|
+
require('../_getAllKeys-cjs.js');
|
|
17
17
|
require('../isTypedArray-cjs.js');
|
|
18
18
|
require('../isObjectLike-cjs.js');
|
|
19
|
+
require('../isSymbol-cjs.js');
|
|
19
20
|
require('../identity-cjs.js');
|
|
20
21
|
require('../_getTag-cjs.js');
|
|
21
|
-
require('../isSymbol-cjs.js');
|
|
22
22
|
require('../keysIn-cjs.js');
|
|
23
23
|
require('../_baseAssignValue-cjs.js');
|
|
24
24
|
require('../_baseFlatten-cjs.js');
|
|
@@ -35,6 +35,7 @@ require('../floating-ui.react-cjs.js');
|
|
|
35
35
|
require('react/jsx-runtime');
|
|
36
36
|
require('react-dom');
|
|
37
37
|
require('../AtlantisContext-cjs.js');
|
|
38
|
+
require('../filterDataAttributes-cjs.js');
|
|
38
39
|
|
|
39
40
|
function InputDate$1(inputProps) {
|
|
40
41
|
const formFieldActionsRef = React.useRef(null);
|
|
@@ -79,13 +80,9 @@ function InputDate$1(inputProps) {
|
|
|
79
80
|
} }));
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
/**
|
|
83
|
-
* Combines the actions on the InputDate such as onChange, onFocus, onBlur to forward event handler passed to the InputDate component to the DatePicker component.
|
|
84
|
-
* 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.
|
|
85
|
-
*/
|
|
86
83
|
function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
87
84
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
88
|
-
function handleChange(
|
|
85
|
+
function handleChange(_newValue, event) {
|
|
89
86
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
90
87
|
}
|
|
91
88
|
function handleFocus(event) {
|
|
@@ -93,8 +90,8 @@ function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
|
93
90
|
setIsFocused(true);
|
|
94
91
|
}
|
|
95
92
|
function handleBlur(event) {
|
|
96
|
-
setIsFocused(false);
|
|
97
93
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
94
|
+
setIsFocused(false);
|
|
98
95
|
}
|
|
99
96
|
return {
|
|
100
97
|
handleBlur,
|
|
@@ -106,21 +103,47 @@ function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
|
106
103
|
|
|
107
104
|
const InputDateRebuilt = React.forwardRef((props, forwardedRef) => {
|
|
108
105
|
const { onChange } = props;
|
|
106
|
+
const isCalendarOpenRef = React.useRef(false);
|
|
107
|
+
const inputFocusedRef = React.useRef(false);
|
|
108
|
+
const compositeFocusedRef = React.useRef(false);
|
|
109
|
+
const lastBlurEventRef = React.useRef(null);
|
|
109
110
|
return (React.createElement(DatePicker.DatePicker, { selected: props.value, onChange: newValue => {
|
|
110
111
|
onChange(newValue);
|
|
111
|
-
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator
|
|
112
|
+
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator, onOpenChange: open => {
|
|
113
|
+
var _a;
|
|
114
|
+
isCalendarOpenRef.current = open;
|
|
115
|
+
// When calendar closes, fire onBlur if input is also not focused
|
|
116
|
+
if (!open &&
|
|
117
|
+
!inputFocusedRef.current &&
|
|
118
|
+
compositeFocusedRef.current &&
|
|
119
|
+
lastBlurEventRef.current) {
|
|
120
|
+
compositeFocusedRef.current = false;
|
|
121
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, lastBlurEventRef.current);
|
|
122
|
+
}
|
|
123
|
+
} }));
|
|
112
124
|
function InputDateActivator(activatorProps) {
|
|
113
125
|
const { onClick, value } = activatorProps;
|
|
114
126
|
const { handleChange, handleFocus, handleBlur, isFocused } = useInputDateActivatorActions({
|
|
115
127
|
onChange: activatorProps.onChange,
|
|
116
128
|
onFocus: event => {
|
|
117
129
|
var _a, _b;
|
|
118
|
-
|
|
130
|
+
inputFocusedRef.current = true;
|
|
131
|
+
// Fire parent's onFocus only when the composite component first receives focus
|
|
132
|
+
if (!compositeFocusedRef.current) {
|
|
133
|
+
compositeFocusedRef.current = true;
|
|
134
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
135
|
+
}
|
|
119
136
|
(_b = activatorProps.onFocus) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
120
137
|
},
|
|
121
138
|
onBlur: event => {
|
|
122
139
|
var _a, _b;
|
|
123
|
-
|
|
140
|
+
inputFocusedRef.current = false;
|
|
141
|
+
lastBlurEventRef.current = event;
|
|
142
|
+
// Only fire parent's onBlur if calendar is also closed
|
|
143
|
+
if (!isCalendarOpenRef.current && compositeFocusedRef.current) {
|
|
144
|
+
compositeFocusedRef.current = false;
|
|
145
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
146
|
+
}
|
|
124
147
|
(_b = activatorProps.onBlur) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
125
148
|
},
|
|
126
149
|
});
|
|
@@ -135,7 +158,7 @@ const InputDateRebuilt = React.forwardRef((props, forwardedRef) => {
|
|
|
135
158
|
return (
|
|
136
159
|
// 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
|
|
137
160
|
React.createElement("div", { onClick: onClick },
|
|
138
|
-
React.createElement(InputText_index.InputText, { "aria-describedby": activatorProps.ariaDescribedBy, "aria-
|
|
161
|
+
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, 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, name: props.name, version: 2, value: showEmptyValueLabel ? props.emptyValueLabel || "" : value || "", ref: forwardedRef, suffix: suffix, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: event => {
|
|
139
162
|
var _a, _b;
|
|
140
163
|
if (props.showIcon === false && event.key === "ArrowDown") {
|
|
141
164
|
(_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
|
package/dist/InputDate/index.mjs
CHANGED
|
@@ -11,12 +11,12 @@ import '../Button-es.js';
|
|
|
11
11
|
import { D as DatePicker } from '../DatePicker-es.js';
|
|
12
12
|
import { InputText } from '../InputText/index.mjs';
|
|
13
13
|
import '../_commonjsHelpers-es.js';
|
|
14
|
-
import '../
|
|
14
|
+
import '../_getAllKeys-es.js';
|
|
15
15
|
import '../isTypedArray-es.js';
|
|
16
16
|
import '../isObjectLike-es.js';
|
|
17
|
+
import '../isSymbol-es.js';
|
|
17
18
|
import '../identity-es.js';
|
|
18
19
|
import '../_getTag-es.js';
|
|
19
|
-
import '../isSymbol-es.js';
|
|
20
20
|
import '../keysIn-es.js';
|
|
21
21
|
import '../_baseAssignValue-es.js';
|
|
22
22
|
import '../_baseFlatten-es.js';
|
|
@@ -33,6 +33,7 @@ import '../floating-ui.react-es.js';
|
|
|
33
33
|
import 'react/jsx-runtime';
|
|
34
34
|
import 'react-dom';
|
|
35
35
|
import '../AtlantisContext-es.js';
|
|
36
|
+
import '../filterDataAttributes-es.js';
|
|
36
37
|
|
|
37
38
|
function InputDate$1(inputProps) {
|
|
38
39
|
const formFieldActionsRef = useRef(null);
|
|
@@ -77,13 +78,9 @@ function InputDate$1(inputProps) {
|
|
|
77
78
|
} }));
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
/**
|
|
81
|
-
* Combines the actions on the InputDate such as onChange, onFocus, onBlur to forward event handler passed to the InputDate component to the DatePicker component.
|
|
82
|
-
* 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.
|
|
83
|
-
*/
|
|
84
81
|
function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
85
82
|
const [isFocused, setIsFocused] = useState(false);
|
|
86
|
-
function handleChange(
|
|
83
|
+
function handleChange(_newValue, event) {
|
|
87
84
|
onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
|
88
85
|
}
|
|
89
86
|
function handleFocus(event) {
|
|
@@ -91,8 +88,8 @@ function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
|
91
88
|
setIsFocused(true);
|
|
92
89
|
}
|
|
93
90
|
function handleBlur(event) {
|
|
94
|
-
setIsFocused(false);
|
|
95
91
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
|
|
92
|
+
setIsFocused(false);
|
|
96
93
|
}
|
|
97
94
|
return {
|
|
98
95
|
handleBlur,
|
|
@@ -104,21 +101,47 @@ function useInputDateActivatorActions({ onChange, onBlur, onFocus, }) {
|
|
|
104
101
|
|
|
105
102
|
const InputDateRebuilt = forwardRef((props, forwardedRef) => {
|
|
106
103
|
const { onChange } = props;
|
|
104
|
+
const isCalendarOpenRef = useRef(false);
|
|
105
|
+
const inputFocusedRef = useRef(false);
|
|
106
|
+
const compositeFocusedRef = useRef(false);
|
|
107
|
+
const lastBlurEventRef = useRef(null);
|
|
107
108
|
return (React__default.createElement(DatePicker, { selected: props.value, onChange: newValue => {
|
|
108
109
|
onChange(newValue);
|
|
109
|
-
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator
|
|
110
|
+
}, disabled: props.disabled, readonly: props.readOnly, fullWidth: !props.inline, minDate: props.minDate, maxDate: props.maxDate, smartAutofocus: false, activator: InputDateActivator, onOpenChange: open => {
|
|
111
|
+
var _a;
|
|
112
|
+
isCalendarOpenRef.current = open;
|
|
113
|
+
// When calendar closes, fire onBlur if input is also not focused
|
|
114
|
+
if (!open &&
|
|
115
|
+
!inputFocusedRef.current &&
|
|
116
|
+
compositeFocusedRef.current &&
|
|
117
|
+
lastBlurEventRef.current) {
|
|
118
|
+
compositeFocusedRef.current = false;
|
|
119
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, lastBlurEventRef.current);
|
|
120
|
+
}
|
|
121
|
+
} }));
|
|
110
122
|
function InputDateActivator(activatorProps) {
|
|
111
123
|
const { onClick, value } = activatorProps;
|
|
112
124
|
const { handleChange, handleFocus, handleBlur, isFocused } = useInputDateActivatorActions({
|
|
113
125
|
onChange: activatorProps.onChange,
|
|
114
126
|
onFocus: event => {
|
|
115
127
|
var _a, _b;
|
|
116
|
-
|
|
128
|
+
inputFocusedRef.current = true;
|
|
129
|
+
// Fire parent's onFocus only when the composite component first receives focus
|
|
130
|
+
if (!compositeFocusedRef.current) {
|
|
131
|
+
compositeFocusedRef.current = true;
|
|
132
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
133
|
+
}
|
|
117
134
|
(_b = activatorProps.onFocus) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
118
135
|
},
|
|
119
136
|
onBlur: event => {
|
|
120
137
|
var _a, _b;
|
|
121
|
-
|
|
138
|
+
inputFocusedRef.current = false;
|
|
139
|
+
lastBlurEventRef.current = event;
|
|
140
|
+
// Only fire parent's onBlur if calendar is also closed
|
|
141
|
+
if (!isCalendarOpenRef.current && compositeFocusedRef.current) {
|
|
142
|
+
compositeFocusedRef.current = false;
|
|
143
|
+
(_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
144
|
+
}
|
|
122
145
|
(_b = activatorProps.onBlur) === null || _b === void 0 ? void 0 : _b.call(activatorProps);
|
|
123
146
|
},
|
|
124
147
|
});
|
|
@@ -133,7 +156,7 @@ const InputDateRebuilt = forwardRef((props, forwardedRef) => {
|
|
|
133
156
|
return (
|
|
134
157
|
// 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
|
|
135
158
|
React__default.createElement("div", { onClick: onClick },
|
|
136
|
-
React__default.createElement(InputText, { "aria-describedby": activatorProps.ariaDescribedBy, "aria-
|
|
159
|
+
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, 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, name: props.name, version: 2, value: showEmptyValueLabel ? props.emptyValueLabel || "" : value || "", ref: forwardedRef, suffix: suffix, onFocus: handleFocus, onBlur: handleBlur, onKeyDown: event => {
|
|
137
160
|
var _a, _b;
|
|
138
161
|
if (props.showIcon === false && event.key === "ArrowDown") {
|
|
139
162
|
(_a = activatorProps.onClick) === null || _a === void 0 ? void 0 : _a.call(activatorProps);
|