@indico-data/design-system 3.0.7 → 3.0.8

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
@@ -19077,14 +19077,14 @@ function cleanEscapedString(input) {
19077
19077
  return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
19078
19078
  }
19079
19079
 
19080
- const formatDateAsString = (date) => format(date, 'MM/dd/yyyy');
19080
+ const formatDateAsString$1 = (date) => format(date, 'MM/dd/yyyy');
19081
19081
 
19082
19082
  function SingleInputDatePicker(props) {
19083
19083
  var _a;
19084
- const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, initialMonth, id, label, selected, isOpen, inputPlaceholder, clearOnClose, inputIconName, isClearable, errorMessage, onSelect } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "initialMonth", "id", "label", "selected", "isOpen", "inputPlaceholder", "clearOnClose", "inputIconName", "isClearable", "errorMessage", "onSelect"]);
19084
+ const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, initialMonth, id, label, selected, isOpen, inputPlaceholder, clearOnClose, inputIconName, isClearable, errorMessage, onSelect, hasHiddenLabel } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "initialMonth", "id", "label", "selected", "isOpen", "inputPlaceholder", "clearOnClose", "inputIconName", "isClearable", "errorMessage", "onSelect", "hasHiddenLabel"]);
19085
19085
  const inputId = React.useId();
19086
19086
  // The text value is assumed to be unneeded by the consumer.
19087
- const [localTextValue, setLocalTextValue] = React.useState(selected ? formatDateAsString(selected) : '');
19087
+ const [localTextValue, setLocalTextValue] = React.useState(selected ? formatDateAsString$1(selected) : '');
19088
19088
  const [localMonth, setLocalMonth] = React.useState((_a = initialMonth !== null && initialMonth !== void 0 ? initialMonth : selected) !== null && _a !== void 0 ? _a : new Date());
19089
19089
  // When the day picker is selected, update the text value.
19090
19090
  const handleDayPickerSelect = (date) => {
@@ -19093,7 +19093,7 @@ function SingleInputDatePicker(props) {
19093
19093
  onSelect(undefined);
19094
19094
  }
19095
19095
  else {
19096
- setLocalTextValue(formatDateAsString(date));
19096
+ setLocalTextValue(formatDateAsString$1(date));
19097
19097
  onSelect(date);
19098
19098
  }
19099
19099
  };
@@ -19115,15 +19115,15 @@ function SingleInputDatePicker(props) {
19115
19115
  setLocalTextValue('');
19116
19116
  }
19117
19117
  }, [isOpen, clearOnClose]);
19118
- return (jsxRuntime.jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [jsxRuntime.jsx(LabeledInput, { id: inputId, value: localTextValue, placeholder: inputPlaceholder, isDisabled: isDisabled, iconName: inputIconName, isClearable: isClearable, onChange: handleInputChange, errorMessage: errorMessage, label: 'Single Date Picker', name: 'Date Picker' }), jsxRuntime.jsx(DatePicker, Object.assign({ captionLayout: captionLayout, mode: "single", selected: selected, onSelect: handleDayPickerSelect, month: localMonth, onMonthChange: setLocalMonth }, rest))] }));
19118
+ return (jsxRuntime.jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [jsxRuntime.jsx(LabeledInput, { id: inputId, value: localTextValue, placeholder: inputPlaceholder, isDisabled: isDisabled, hasHiddenLabel: hasHiddenLabel, iconName: inputIconName, isClearable: isClearable, onChange: handleInputChange, errorMessage: errorMessage, label: 'Single Date Picker', name: 'Date Picker' }), jsxRuntime.jsx(DatePicker, Object.assign({ captionLayout: captionLayout, mode: "single", selected: selected, onSelect: handleDayPickerSelect, month: localMonth, onMonthChange: setLocalMonth }, rest))] }));
19119
19119
  }
19120
19120
 
19121
19121
  function InputDateRangePicker(props) {
19122
- 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
+ const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, month, id, onSelect, selected, isOpen, setIsOpen, inputPlaceholder, inputIconName, toErrorMessage, fromErrorMessage, gutterWidth, fromLabel, toLabel, closeOnSelect, clearOnClose, hasHiddenLabel } = 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", "hasHiddenLabel"]);
19123
19123
  const inputId = React.useId();
19124
19124
  // Hold the input values in state
19125
- const [localTextValueFrom, setLocalTextValueFrom] = React.useState((selected === null || selected === void 0 ? void 0 : selected.from) ? formatDateAsString(selected.from) : '');
19126
- const [localTextValueTo, setLocalTextValueTo] = React.useState((selected === null || selected === void 0 ? void 0 : selected.to) ? formatDateAsString(selected.to) : '');
19125
+ const [localTextValueFrom, setLocalTextValueFrom] = React.useState((selected === null || selected === void 0 ? void 0 : selected.from) ? formatDateAsString$1(selected.from) : '');
19126
+ const [localTextValueTo, setLocalTextValueTo] = React.useState((selected === null || selected === void 0 ? void 0 : selected.to) ? formatDateAsString$1(selected.to) : '');
19127
19127
  const [localMonth, setLocalMonth] = React.useState((selected === null || selected === void 0 ? void 0 : selected.from) || new Date());
19128
19128
  // When the day picker is selected, update the text values.
19129
19129
  const handleDayPickerSelect = (date) => {
@@ -19133,8 +19133,8 @@ function InputDateRangePicker(props) {
19133
19133
  onSelect(undefined);
19134
19134
  }
19135
19135
  else {
19136
- setLocalTextValueFrom(date.from ? formatDateAsString(date.from) : '');
19137
- setLocalTextValueTo(date.to ? formatDateAsString(date.to) : '');
19136
+ setLocalTextValueFrom(date.from ? formatDateAsString$1(date.from) : '');
19137
+ setLocalTextValueTo(date.to ? formatDateAsString$1(date.to) : '');
19138
19138
  onSelect(date);
19139
19139
  // Close the picker ONLY when a complete range is selected (from and to are different dates)
19140
19140
  if (closeOnSelect &&
@@ -19178,7 +19178,51 @@ function InputDateRangePicker(props) {
19178
19178
  setLocalTextValueTo('');
19179
19179
  }
19180
19180
  }, [isOpen, clearOnClose]);
19181
- 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))] }));
19181
+ 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", hasHiddenLabel: hasHiddenLabel }) }), 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", hasHiddenLabel: hasHiddenLabel }) })] }), jsxRuntime.jsx(DatePicker, Object.assign({ captionLayout: captionLayout, month: localMonth, onMonthChange: (date) => setLocalMonth(date), mode: "range", selected: selected, onSelect: handleDayPickerSelect }, rest))] }));
19182
+ }
19183
+
19184
+ const formatDateAsString = (date) => format(date, 'MM/dd/yyyy');
19185
+
19186
+ function SingleInputDateTimePicker(props) {
19187
+ var _a;
19188
+ const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, initialMonth, id, label, selected, isOpen, inputPlaceholder, clearOnClose, inputIconName, isClearable, errorMessage, onSelect, timeValue, onTimeChange, hasHiddenLabel } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "initialMonth", "id", "label", "selected", "isOpen", "inputPlaceholder", "clearOnClose", "inputIconName", "isClearable", "errorMessage", "onSelect", "timeValue", "onTimeChange", "hasHiddenLabel"]);
19189
+ const inputId = React.useId();
19190
+ // The text value is assumed to be unneeded by the consumer.
19191
+ const [localTextValue, setLocalTextValue] = React.useState(selected ? formatDateAsString(selected) : '');
19192
+ const [localMonth, setLocalMonth] = React.useState((_a = initialMonth !== null && initialMonth !== void 0 ? initialMonth : selected) !== null && _a !== void 0 ? _a : new Date());
19193
+ // When the day picker is selected, update the text value.
19194
+ const handleDayPickerSelect = (date) => {
19195
+ if (!date) {
19196
+ setLocalTextValue('');
19197
+ onSelect(undefined);
19198
+ }
19199
+ else {
19200
+ setLocalTextValue(formatDateAsString(date));
19201
+ onSelect(date);
19202
+ }
19203
+ };
19204
+ // When the text input is changed, update the selected date.
19205
+ const handleInputChange = (e) => {
19206
+ setLocalTextValue(e.target.value); // keep the input value in sync
19207
+ const parsedDate = parse(e.target.value, 'MM/dd/yyyy', new Date());
19208
+ if (isValid(parsedDate)) {
19209
+ onSelect(parsedDate);
19210
+ }
19211
+ else {
19212
+ onSelect(undefined);
19213
+ }
19214
+ };
19215
+ // clear selection if clear on close is true
19216
+ React.useEffect(() => {
19217
+ if (!isOpen && clearOnClose) {
19218
+ onSelect(undefined);
19219
+ setLocalTextValue('');
19220
+ }
19221
+ }, [isOpen, clearOnClose]);
19222
+ const handleTimeChange = (time) => {
19223
+ onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(time);
19224
+ };
19225
+ return (jsxRuntime.jsxs(Row, { children: [jsxRuntime.jsx(Col, { children: jsxRuntime.jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [jsxRuntime.jsx(LabeledInput, { id: inputId, value: localTextValue, placeholder: inputPlaceholder, isDisabled: isDisabled, iconName: inputIconName, isClearable: isClearable, onChange: handleInputChange, errorMessage: errorMessage, hasHiddenLabel: hasHiddenLabel, label: 'Single Date Picker', name: `${id}-date-picker` }), jsxRuntime.jsx(DatePicker, Object.assign({ captionLayout: captionLayout, mode: "single", selected: selected, onSelect: handleDayPickerSelect, month: localMonth, onMonthChange: setLocalMonth }, rest))] }) }), jsxRuntime.jsx(Col, { xs: "content", children: jsxRuntime.jsx(TimePicker, { timeValue: timeValue, name: `${id}-time-picker`, hasHiddenLabel: true, onTimeChange: handleTimeChange }) })] }));
19182
19226
  }
19183
19227
 
19184
19228
  const Form = (_a) => {
@@ -43262,6 +43306,7 @@ exports.RadioInput = Radio;
43262
43306
  exports.Row = Row;
43263
43307
  exports.SelectInput = LabeledSelect;
43264
43308
  exports.SingleInputDatePicker = SingleInputDatePicker;
43309
+ exports.SingleInputDateTimePicker = SingleInputDateTimePicker;
43265
43310
  exports.Skeleton = Skeleton;
43266
43311
  exports.Stepper = Stepper;
43267
43312
  exports.Table = Table;