@indico-data/design-system 2.60.9 → 2.60.10
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/lib/components/forms/date/inputDateRangePicker/InputDateRangePicker.d.ts +3 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.esm.js +13 -4
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +13 -4
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.stories.tsx +38 -3
- package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.tsx +28 -3
package/lib/index.js
CHANGED
|
@@ -19118,7 +19118,7 @@ function SingleInputDatePicker(props) {
|
|
|
19118
19118
|
}
|
|
19119
19119
|
|
|
19120
19120
|
function InputDateRangePicker(props) {
|
|
19121
|
-
const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, month, id, onSelect, selected, isOpen, inputPlaceholder, inputIconName, toErrorMessage, fromErrorMessage, gutterWidth, fromLabel, toLabel } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "month", "id", "onSelect", "selected", "isOpen", "inputPlaceholder", "inputIconName", "toErrorMessage", "fromErrorMessage", "gutterWidth", "fromLabel", "toLabel"]);
|
|
19121
|
+
const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, month, id, onSelect, selected, isOpen, setIsOpen, inputPlaceholder, inputIconName, toErrorMessage, fromErrorMessage, gutterWidth, fromLabel, toLabel, closeOnSelect, clearOnClose } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "month", "id", "onSelect", "selected", "isOpen", "setIsOpen", "inputPlaceholder", "inputIconName", "toErrorMessage", "fromErrorMessage", "gutterWidth", "fromLabel", "toLabel", "closeOnSelect", "clearOnClose"]);
|
|
19122
19122
|
const inputId = React.useId();
|
|
19123
19123
|
// Hold the input values in state
|
|
19124
19124
|
const [localTextValueFrom, setLocalTextValueFrom] = React.useState((selected === null || selected === void 0 ? void 0 : selected.from) ? formatDateAsString(selected.from) : '');
|
|
@@ -19135,6 +19135,15 @@ function InputDateRangePicker(props) {
|
|
|
19135
19135
|
setLocalTextValueFrom(date.from ? formatDateAsString(date.from) : '');
|
|
19136
19136
|
setLocalTextValueTo(date.to ? formatDateAsString(date.to) : '');
|
|
19137
19137
|
onSelect(date);
|
|
19138
|
+
// Close the picker ONLY when a complete range is selected (from and to are different dates)
|
|
19139
|
+
if (closeOnSelect &&
|
|
19140
|
+
date.from &&
|
|
19141
|
+
date.to &&
|
|
19142
|
+
setIsOpen &&
|
|
19143
|
+
date.from.getTime() !== date.to.getTime() // Ensure from and to are different dates
|
|
19144
|
+
) {
|
|
19145
|
+
setIsOpen(false);
|
|
19146
|
+
}
|
|
19138
19147
|
}
|
|
19139
19148
|
};
|
|
19140
19149
|
// When the text input is changed, update the selected date.
|
|
@@ -19162,13 +19171,13 @@ function InputDateRangePicker(props) {
|
|
|
19162
19171
|
};
|
|
19163
19172
|
// clear selection if clear on close is true
|
|
19164
19173
|
React.useEffect(() => {
|
|
19165
|
-
if (!isOpen) {
|
|
19174
|
+
if (!isOpen && clearOnClose) {
|
|
19166
19175
|
onSelect(undefined);
|
|
19167
19176
|
setLocalTextValueFrom('');
|
|
19168
19177
|
setLocalTextValueTo('');
|
|
19169
19178
|
}
|
|
19170
|
-
}, [isOpen]);
|
|
19171
|
-
return (jsxRuntime.jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [jsxRuntime.jsxs(Row, { gutterWidth: gutterWidth, children: [jsxRuntime.jsx(Col, { children: jsxRuntime.jsx(LabeledInput, { id: `${inputId}-from`, value: localTextValueFrom, placeholder: inputPlaceholder, isDisabled: isDisabled, iconName: inputIconName, onChange: (e) => handleInputChange(e, 'from'), errorMessage: fromErrorMessage, label: fromLabel, name: 'From Date', "data-testid": "date-picker-from" }) }), jsxRuntime.jsx(Col, { children: jsxRuntime.jsx(LabeledInput, { id: `${inputId}-to`, value: localTextValueTo, placeholder: inputPlaceholder, isDisabled: isDisabled, iconName: inputIconName, onChange: (e) => handleInputChange(e, 'to'), errorMessage: toErrorMessage, label: toLabel, name: 'To Date', "data-testid": "date-picker-to" }) })] }), jsxRuntime.jsx(DatePicker, Object.assign({ captionLayout: captionLayout, month: localMonth, onMonthChange: (date) => setLocalMonth(date), mode: "range", selected: selected, onSelect: handleDayPickerSelect }, rest))] }));
|
|
19179
|
+
}, [isOpen, clearOnClose]);
|
|
19180
|
+
return (jsxRuntime.jsxs(FloatUI, { isOpen: isOpen, setIsOpen: setIsOpen, ariaLabel: ariaLabel, children: [jsxRuntime.jsxs(Row, { gutterWidth: gutterWidth, children: [jsxRuntime.jsx(Col, { children: jsxRuntime.jsx(LabeledInput, { id: `${inputId}-from`, value: localTextValueFrom, placeholder: inputPlaceholder, isDisabled: isDisabled, iconName: inputIconName, onChange: (e) => handleInputChange(e, 'from'), errorMessage: fromErrorMessage, label: fromLabel, name: 'From Date', "data-testid": "date-picker-from" }) }), jsxRuntime.jsx(Col, { children: jsxRuntime.jsx(LabeledInput, { id: `${inputId}-to`, value: localTextValueTo, placeholder: inputPlaceholder, isDisabled: isDisabled, iconName: inputIconName, onChange: (e) => handleInputChange(e, 'to'), errorMessage: toErrorMessage, label: toLabel, name: 'To Date', "data-testid": "date-picker-to" }) })] }), jsxRuntime.jsx(DatePicker, Object.assign({ captionLayout: captionLayout, month: localMonth, onMonthChange: (date) => setLocalMonth(date), mode: "range", selected: selected, onSelect: handleDayPickerSelect }, rest))] }));
|
|
19172
19181
|
}
|
|
19173
19182
|
|
|
19174
19183
|
const Form = (_a) => {
|