@homebound/beam 2.304.0 → 2.304.1
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.
|
@@ -26,8 +26,6 @@ function DateFieldBase(props) {
|
|
|
26
26
|
const overlayRef = (0, react_1.useRef)(null);
|
|
27
27
|
// Local focus ref used to avoid updating WIP values
|
|
28
28
|
const isFocused = (0, react_1.useRef)(false);
|
|
29
|
-
// Ref helper to identify when focus is returned to the TextField due to the DatePicker closing.
|
|
30
|
-
const closingDatePicker = (0, react_1.useRef)(false);
|
|
31
29
|
const dateFormat = (0, utils_1.getDateFormat)(format);
|
|
32
30
|
// The `wipValue` allows the "range" mode to set the value to `undefined`, even if the `onChange` response cannot be undefined.
|
|
33
31
|
// This makes working within the DateRangePicker much more user-friendly.
|
|
@@ -45,10 +43,6 @@ function DateFieldBase(props) {
|
|
|
45
43
|
value: inputValue,
|
|
46
44
|
};
|
|
47
45
|
const state = (0, react_stately_1.useOverlayTriggerState)({ isOpen: defaultOpen });
|
|
48
|
-
const onPickerClose = (0, react_1.useCallback)(() => {
|
|
49
|
-
closingDatePicker.current = true;
|
|
50
|
-
state.close();
|
|
51
|
-
}, [state]);
|
|
52
46
|
const { labelProps, inputProps } = (0, react_aria_1.useTextField)({
|
|
53
47
|
...textFieldProps,
|
|
54
48
|
// Setting `inputMode` to none. This disables the virtual keyboard from being triggered on touch devices
|
|
@@ -56,12 +50,6 @@ function DateFieldBase(props) {
|
|
|
56
50
|
onFocus: () => {
|
|
57
51
|
var _a;
|
|
58
52
|
isFocused.current = true;
|
|
59
|
-
// Open overlay on focus of the input, only if the focus is not triggered due to the overlay being closed.
|
|
60
|
-
if (!closingDatePicker.current) {
|
|
61
|
-
state.open();
|
|
62
|
-
}
|
|
63
|
-
// Reset the closingDatePicker ref to false, so that the overlay can be opened again on the next focus event
|
|
64
|
-
closingDatePicker.current = false;
|
|
65
53
|
(0, utils_2.maybeCall)(onFocus);
|
|
66
54
|
if (wipValue && dateFormat !== utils_1.dateFormats.short) {
|
|
67
55
|
// When focused, change to use the "short" date format, as it is simpler to update by hand and parse.
|
|
@@ -74,7 +62,6 @@ function DateFieldBase(props) {
|
|
|
74
62
|
var _a, _b;
|
|
75
63
|
// Resets the ref variables when the input loses focus.
|
|
76
64
|
isFocused.current = false;
|
|
77
|
-
closingDatePicker.current = false;
|
|
78
65
|
// If interacting with the overlay or the input, then assume the user is still working within the DatePicker and return early to not trigger onBlur functionality.
|
|
79
66
|
if ((inputWrapRef.current && inputWrapRef.current.contains(e.relatedTarget)) ||
|
|
80
67
|
(overlayRef.current && overlayRef.current.contains(e.relatedTarget))) {
|
|
@@ -107,18 +94,13 @@ function DateFieldBase(props) {
|
|
|
107
94
|
},
|
|
108
95
|
}, inputRef);
|
|
109
96
|
const { triggerProps, overlayProps } = (0, react_aria_1.useOverlayTrigger)({ type: "dialog" }, state, buttonRef);
|
|
110
|
-
const { buttonProps } = (0, react_aria_1.useButton)({
|
|
111
|
-
...triggerProps,
|
|
112
|
-
isDisabled: isDisabled || isReadOnly,
|
|
113
|
-
// When pressed then move focus the input, which will select the text and trigger the DatePicker to open
|
|
114
|
-
onPress: () => { var _a; return (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
|
|
115
|
-
}, buttonRef);
|
|
97
|
+
const { buttonProps } = (0, react_aria_1.useButton)({ ...triggerProps, isDisabled: isDisabled || isReadOnly, onPress: state.open }, buttonRef);
|
|
116
98
|
const { overlayProps: positionProps } = (0, react_aria_1.useOverlayPosition)({
|
|
117
99
|
targetRef: inputWrapRef,
|
|
118
100
|
overlayRef,
|
|
119
101
|
shouldFlip: true,
|
|
120
102
|
isOpen: state.isOpen,
|
|
121
|
-
onClose:
|
|
103
|
+
onClose: state.close,
|
|
122
104
|
placement: "bottom left",
|
|
123
105
|
shouldUpdatePosition: true,
|
|
124
106
|
offset: 4,
|
|
@@ -164,11 +146,11 @@ function DateFieldBase(props) {
|
|
|
164
146
|
setInputValue("");
|
|
165
147
|
onChange(undefined);
|
|
166
148
|
} })) }));
|
|
167
|
-
const calendarButton = ((0, jsx_runtime_1.jsx)("button", { ref: buttonRef, ...buttonProps, disabled: isDisabled, css: Css_1.Css.if(isDisabled).cursorNotAllowed.$,
|
|
149
|
+
const calendarButton = ((0, jsx_runtime_1.jsx)("button", { ref: buttonRef, ...buttonProps, disabled: isDisabled, css: Css_1.Css.if(isDisabled).cursorNotAllowed.$, ...tid.calendarButton, children: (0, jsx_runtime_1.jsx)(components_1.Icon, { icon: "calendar", color: isDisabled ? Css_1.Palette.Gray400 : Css_1.Palette.Gray700 }) }));
|
|
168
150
|
const EndFieldButtons = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRangeFilterField && clearButton, !hideCalendarIcon && calendarButton] }));
|
|
169
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase, { ...textFieldProps, ...{ internalProps: { forceFocus: state.isOpen } }, errorMsg: errorMsg, helperText: helperText, required: required, labelProps: labelProps, inputProps: { ...inputProps, size: inputSize }, inputRef: inputRef, inputWrapRef: inputWrapRef, onChange: (v) => {
|
|
151
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(TextFieldBase_1.TextFieldBase, { ...textFieldProps, ...{ internalProps: { forceFocus: state.isOpen } }, errorMsg: errorMsg, helperText: helperText, required: required, labelProps: labelProps, inputProps: { ...inputProps, size: inputSize, onClick: state.open }, inputRef: inputRef, inputWrapRef: inputWrapRef, onChange: (v) => {
|
|
170
152
|
// hide the calendar if the user is manually entering the date
|
|
171
|
-
|
|
153
|
+
state.close();
|
|
172
154
|
if (v) {
|
|
173
155
|
setInputValue(v);
|
|
174
156
|
// If changing the value directly (vs using the DatePicker), then we always use the short format
|
|
@@ -179,16 +161,16 @@ function DateFieldBase(props) {
|
|
|
179
161
|
else if (v === undefined) {
|
|
180
162
|
setInputValue("");
|
|
181
163
|
}
|
|
182
|
-
}, endAdornment: !iconLeft && EndFieldButtons, startAdornment: !hideCalendarIcon && iconLeft && calendarButton, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly), ...others }), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, { triggerRef: inputWrapRef, popoverRef: overlayRef, positionProps: positionProps, onClose:
|
|
164
|
+
}, endAdornment: !iconLeft && EndFieldButtons, startAdornment: !hideCalendarIcon && iconLeft && calendarButton, tooltip: (0, components_1.resolveTooltip)(disabled, undefined, readOnly), ...others }), state.isOpen && ((0, jsx_runtime_1.jsx)(internal_1.Popover, { triggerRef: inputWrapRef, popoverRef: overlayRef, positionProps: positionProps, onClose: state.close, isOpen: state.isOpen, children: (0, jsx_runtime_1.jsx)(react_aria_1.FocusScope, { autoFocus: true, contain: true, restoreFocus: true, children: (0, jsx_runtime_1.jsx)(DatePickerOverlay_1.DatePickerOverlay, { overlayProps: overlayProps, children: isRangeMode ? ((0, jsx_runtime_1.jsx)(internal_1.DateRangePicker, { range: wipValue, disabledDays: disabledDays, onSelect: (dr) => {
|
|
183
165
|
var _a;
|
|
184
166
|
// Note: Do not close date range picker on select to allow the user to select multiple dates at a time
|
|
185
167
|
setInputValue((_a = (0, utils_1.formatDateRange)(dr, utils_1.dateFormats.short)) !== null && _a !== void 0 ? _a : "");
|
|
186
168
|
onChange(dr);
|
|
187
169
|
}, useYearPicker: isRangeFilterField, ...tid.datePicker })) : ((0, jsx_runtime_1.jsx)(internal_1.DatePicker, { value: wipValue, disabledDays: disabledDays, onSelect: (d) => {
|
|
188
170
|
var _a;
|
|
171
|
+
state.close();
|
|
189
172
|
setInputValue((_a = (0, utils_1.formatDate)(d, utils_1.dateFormats.short)) !== null && _a !== void 0 ? _a : "");
|
|
190
173
|
onChange(d);
|
|
191
|
-
onPickerClose();
|
|
192
174
|
}, ...tid.datePicker })) }) }) }))] }));
|
|
193
175
|
}
|
|
194
176
|
exports.DateFieldBase = DateFieldBase;
|