@indico-data/design-system 2.60.8 → 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/index.js CHANGED
@@ -5841,13 +5841,14 @@ const OptionComponent = (_a) => {
5841
5841
  return (jsxRuntime.jsx(ReactSelect.components.Option, Object.assign({}, props, { children: jsxRuntime.jsxs("div", { className: "select__items", children: [jsxRuntime.jsx("div", { className: "select__item-value", children: (_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.label }), ((_c = props === null || props === void 0 ? void 0 : props.data) === null || _c === void 0 ? void 0 : _c.detail) && jsxRuntime.jsx("div", { className: "select__item-detail", children: (_d = props === null || props === void 0 ? void 0 : props.data) === null || _d === void 0 ? void 0 : _d.detail })] }) })));
5842
5842
  };
5843
5843
  const Select$1 = (_a) => {
5844
- var { classNamePrefix = 'select', className, components: customComponents } = _a, props = __rest(_a, ["classNamePrefix", "className", "components"]);
5844
+ var { classNamePrefix = 'select', className, components: customComponents, label, hasHiddenLabel, name } = _a, props = __rest(_a, ["classNamePrefix", "className", "components", "label", "hasHiddenLabel", "name"]);
5845
5845
  const defaultComponents = {
5846
5846
  Option: OptionComponent,
5847
5847
  };
5848
5848
  const mergedComponents = Object.assign(Object.assign({}, defaultComponents), customComponents);
5849
5849
  return (jsxRuntime.jsx(ReactSelect__default.default, Object.assign({ classNamePrefix: classNamePrefix, className: classNames('select-wrapper', className), components: mergedComponents }, props)));
5850
5850
  };
5851
+ const LabeledSelect = withLabel(Select$1);
5851
5852
 
5852
5853
  /**
5853
5854
  * The UI elements composing DayPicker. These elements are mapped to
@@ -19117,7 +19118,7 @@ function SingleInputDatePicker(props) {
19117
19118
  }
19118
19119
 
19119
19120
  function InputDateRangePicker(props) {
19120
- const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, month, id, onSelect, selected, isOpen, inputPlaceholder, inputIconName, toErrorMessage, fromErrorMessage } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "month", "id", "onSelect", "selected", "isOpen", "inputPlaceholder", "inputIconName", "toErrorMessage", "fromErrorMessage"]);
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"]);
19121
19122
  const inputId = React.useId();
19122
19123
  // Hold the input values in state
19123
19124
  const [localTextValueFrom, setLocalTextValueFrom] = React.useState((selected === null || selected === void 0 ? void 0 : selected.from) ? formatDateAsString(selected.from) : '');
@@ -19134,6 +19135,15 @@ function InputDateRangePicker(props) {
19134
19135
  setLocalTextValueFrom(date.from ? formatDateAsString(date.from) : '');
19135
19136
  setLocalTextValueTo(date.to ? formatDateAsString(date.to) : '');
19136
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
+ }
19137
19147
  }
19138
19148
  };
19139
19149
  // When the text input is changed, update the selected date.
@@ -19161,13 +19171,13 @@ function InputDateRangePicker(props) {
19161
19171
  };
19162
19172
  // clear selection if clear on close is true
19163
19173
  React.useEffect(() => {
19164
- if (!isOpen) {
19174
+ if (!isOpen && clearOnClose) {
19165
19175
  onSelect(undefined);
19166
19176
  setLocalTextValueFrom('');
19167
19177
  setLocalTextValueTo('');
19168
19178
  }
19169
- }, [isOpen]);
19170
- return (jsxRuntime.jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [jsxRuntime.jsxs(Row, { 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: 'From Date', 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: 'To Date', 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))] }));
19171
19181
  }
19172
19182
 
19173
19183
  const Form = (_a) => {
@@ -43130,7 +43140,7 @@ exports.PasswordInput = LabeledPasswordInput;
43130
43140
  exports.Pill = Pill;
43131
43141
  exports.RadioInput = Radio;
43132
43142
  exports.Row = Row;
43133
- exports.SelectInput = Select$1;
43143
+ exports.SelectInput = LabeledSelect;
43134
43144
  exports.SingleInputDatePicker = SingleInputDatePicker;
43135
43145
  exports.Skeleton = Skeleton;
43136
43146
  exports.Stepper = Stepper;