@indico-data/design-system 3.0.8 → 3.0.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.
Files changed (36) hide show
  1. package/lib/components/floatUI/FloatUI.d.ts +1 -1
  2. package/lib/components/floatUI/types.d.ts +1 -0
  3. package/lib/components/forms/date/datePicker/types.d.ts +7 -0
  4. package/lib/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.d.ts +5 -0
  5. package/lib/components/forms/date/inputDatePicker/SingleInputDatePicker.d.ts +8 -0
  6. package/lib/components/forms/date/inputDateRangePicker/InputDateRangePicker.d.ts +10 -0
  7. package/lib/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.d.ts +10 -0
  8. package/lib/components/forms/input/Input.d.ts +1 -0
  9. package/lib/components/forms/textarea/Textarea.d.ts +1 -0
  10. package/lib/components/forms/timePicker/TimePicker.d.ts +7 -1
  11. package/lib/index.css +10 -0
  12. package/lib/index.d.ts +43 -2
  13. package/lib/index.esm.css +10 -0
  14. package/lib/index.esm.js +130 -124
  15. package/lib/index.esm.js.map +1 -1
  16. package/lib/index.js +130 -124
  17. package/lib/index.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/components/floatUI/FloatUI.tsx +2 -1
  20. package/src/components/floatUI/types.ts +1 -0
  21. package/src/components/forms/date/datePicker/DatePicker.tsx +11 -1
  22. package/src/components/forms/date/datePicker/styles/DatePicker.scss +10 -0
  23. package/src/components/forms/date/datePicker/types.ts +8 -0
  24. package/src/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.stories.tsx +30 -0
  25. package/src/components/forms/date/iconTriggerDatePicker/IconTriggerDatePicker.tsx +15 -1
  26. package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.stories.tsx +51 -0
  27. package/src/components/forms/date/inputDatePicker/SingleInputDatePicker.tsx +24 -2
  28. package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.stories.tsx +58 -0
  29. package/src/components/forms/date/inputDateRangePicker/InputDateRangePicker.tsx +31 -2
  30. package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.stories.tsx +59 -0
  31. package/src/components/forms/date/inputDateTimePicker/SingleInputDateTimePicker.tsx +40 -5
  32. package/src/components/forms/input/Input.tsx +3 -0
  33. package/src/components/forms/textarea/Textarea.tsx +3 -0
  34. package/src/components/forms/timePicker/TimePicker.tsx +39 -1
  35. package/src/components/forms/timePicker/__tests__/TimePicker.test.tsx +4 -2
  36. package/src/storybook/formArgTypes.ts +14 -0
package/lib/index.esm.js CHANGED
@@ -5467,7 +5467,7 @@ const DisplayFormError = (_a) => {
5467
5467
  };
5468
5468
 
5469
5469
  const Input = React__default.forwardRef((_a, ref) => {
5470
- var { id, name, placeholder, isRequired, isDisabled, readonly, isClearable, errorMessage, helpText, maxLength, iconName, onChange, onBlur, onKeyDown, className } = _a, rest = __rest(_a, ["id", "name", "placeholder", "isRequired", "isDisabled", "readonly", "isClearable", "errorMessage", "helpText", "maxLength", "iconName", "onChange", "onBlur", "onKeyDown", "className"]);
5470
+ var { id, name, placeholder, isRequired, isDisabled, readonly, isClearable, errorMessage, helpText, maxLength, iconName, tabIndex, onChange, onBlur, onKeyDown, className } = _a, rest = __rest(_a, ["id", "name", "placeholder", "isRequired", "isDisabled", "readonly", "isClearable", "errorMessage", "helpText", "maxLength", "iconName", "tabIndex", "onChange", "onBlur", "onKeyDown", "className"]);
5471
5471
  const hasErrors = errorMessage && errorMessage.length > 0;
5472
5472
  const handleClear = () => {
5473
5473
  onChange === null || onChange === void 0 ? void 0 : onChange({ target: { value: '' } });
@@ -5477,7 +5477,7 @@ const Input = React__default.forwardRef((_a, ref) => {
5477
5477
  error: hasErrors,
5478
5478
  'input--has-icon': iconName,
5479
5479
  }, className);
5480
- return (jsxs(Fragment, { children: [jsxs("div", { className: "input-wrapper", children: [iconName && (jsx(Icon, { name: iconName, "data-testid": `${name}-embedded-icon`, className: "embedded-icon" })), jsx("input", Object.assign({ ref: ref, id: id, "data-testid": `form-input-${name}`, name: name, type: "text", disabled: isDisabled, placeholder: placeholder, readOnly: readonly, onChange: onChange, onBlur: onBlur, maxLength: maxLength, onKeyDown: onKeyDown, className: inputClasses, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired }, rest)), isClearable && !isDisabled && (jsx(Icon, { name: "x-close", "data-testid": `${name}-clearable-icon`, size: "sm", onClick: handleClear, className: "clearable-icon" }))] }), hasErrors && jsx(DisplayFormError, { "data-testid": `${name}-error`, message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
5480
+ return (jsxs(Fragment, { children: [jsxs("div", { className: "input-wrapper", children: [iconName && (jsx(Icon, { name: iconName, "data-testid": `${name}-embedded-icon`, className: "embedded-icon" })), jsx("input", Object.assign({ ref: ref, tabIndex: tabIndex, id: id, "data-testid": `form-input-${name}`, name: name, type: "text", disabled: isDisabled, placeholder: placeholder, readOnly: readonly, onChange: onChange, onBlur: onBlur, maxLength: maxLength, onKeyDown: onKeyDown, className: inputClasses, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired }, rest)), isClearable && !isDisabled && (jsx(Icon, { name: "x-close", "data-testid": `${name}-clearable-icon`, size: "sm", onClick: handleClear, className: "clearable-icon" }))] }), hasErrors && jsx(DisplayFormError, { "data-testid": `${name}-error`, message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
5481
5481
  });
5482
5482
  const LabeledInput = withLabel(Input);
5483
5483
 
@@ -5790,10 +5790,10 @@ const Toggle = React__default.forwardRef((_a, ref) => {
5790
5790
  });
5791
5791
 
5792
5792
  const Textarea = React__default.forwardRef((_a, ref) => {
5793
- var { label, name, placeholder, value, onChange, onKeyDown, isRequired, isDisabled, errorMessage, helpText, hasHiddenLabel, rows, cols, readonly, wrap, form, maxLength, autofocus, defaultValue } = _a, rest = __rest(_a, ["label", "name", "placeholder", "value", "onChange", "onKeyDown", "isRequired", "isDisabled", "errorMessage", "helpText", "hasHiddenLabel", "rows", "cols", "readonly", "wrap", "form", "maxLength", "autofocus", "defaultValue"]);
5793
+ var { label, name, placeholder, value, onChange, onKeyDown, isRequired, isDisabled, errorMessage, helpText, hasHiddenLabel, rows, cols, readonly, wrap, form, maxLength, autofocus, defaultValue, tabIndex } = _a, rest = __rest(_a, ["label", "name", "placeholder", "value", "onChange", "onKeyDown", "isRequired", "isDisabled", "errorMessage", "helpText", "hasHiddenLabel", "rows", "cols", "readonly", "wrap", "form", "maxLength", "autofocus", "defaultValue", "tabIndex"]);
5794
5794
  const hasErrors = errorMessage && errorMessage.length > 0;
5795
5795
  const textareaClasses = classNames('textarea', { error: hasErrors });
5796
- return (jsxs(Fragment, { children: [jsx("div", { className: "textarea-wrapper", children: jsx("textarea", Object.assign({ ref: ref, rows: rows, cols: cols, autoFocus: autofocus, wrap: wrap, form: form, maxLength: maxLength, readOnly: readonly, "data-testid": `form-textarea-${name}`, name: name, disabled: isDisabled, placeholder: placeholder, onChange: onChange, onKeyDown: onKeyDown, className: textareaClasses, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired, value: value, defaultValue: defaultValue }, rest)) }), hasErrors && jsx(DisplayFormError, { message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
5796
+ return (jsxs(Fragment, { children: [jsx("div", { className: "textarea-wrapper", children: jsx("textarea", Object.assign({ ref: ref, rows: rows, cols: cols, autoFocus: autofocus, wrap: wrap, form: form, maxLength: maxLength, readOnly: readonly, "data-testid": `form-textarea-${name}`, name: name, disabled: isDisabled, placeholder: placeholder, onChange: onChange, onKeyDown: onKeyDown, className: textareaClasses, "aria-invalid": hasErrors ? true : undefined, "aria-describedby": hasErrors || helpText ? `${name}-helper` : undefined, "aria-required": isRequired, value: value, defaultValue: defaultValue, tabIndex: tabIndex }, rest)) }), hasErrors && jsx(DisplayFormError, { message: errorMessage }), helpText && (jsx("div", { "data-testid": `${name}-help-text`, className: "help-text", id: `${name}-helper`, children: helpText }))] }));
5797
5797
  });
5798
5798
  const LabeledTextarea = withLabel(Textarea);
5799
5799
 
@@ -11836,116 +11836,6 @@ const getCommonProps = (props) => {
11836
11836
  });
11837
11837
  };
11838
11838
 
11839
- const formatTimeValue = (value) => {
11840
- if (!value || value.trim() === '') {
11841
- return '';
11842
- }
11843
- // Normalize the input
11844
- const normalizedValue = value.trim().toLowerCase();
11845
- // Extract time components using regex
11846
- const timeRegex = /^(0?[1-9]|1[0-2]):([0-5][0-9])(\s*)([ap]m)$/i;
11847
- const matches = normalizedValue.match(timeRegex);
11848
- if (matches) {
11849
- const hours = parseInt(matches[1], 10);
11850
- const minutes = parseInt(matches[2], 10);
11851
- const period = matches[4].toUpperCase(); // Convert am/pm to AM/PM
11852
- // Format as hh:mm AM/PM
11853
- return `${hours}:${minutes < 10 ? '0' + minutes : minutes} ${period}`;
11854
- }
11855
- return value; // Return original if no match (shouldn't happen with valid inputs)
11856
- };
11857
- const validateInputValue = (value) => {
11858
- if (!value || value.trim() === '') {
11859
- return ''; // Empty input is allowed
11860
- }
11861
- // Normalize the input (remove extra spaces, convert to lowercase)
11862
- const normalizedValue = value.trim().toLowerCase();
11863
- // Regular expression for valid time formats: 1:10 pm, 01:10 pm, 1:10pm, 01:10pm
11864
- const timeRegex = /^(0?[1-9]|1[0-2]):([0-5][0-9])(\s*)([ap]m)$/i;
11865
- if (!timeRegex.test(normalizedValue)) {
11866
- // Check if the issue might be a 24-hour format
11867
- const hour24Regex = /^([13-9]|1[3-9]|2[0-3]):/i;
11868
- if (hour24Regex.test(normalizedValue)) {
11869
- return 'Please enter time in 12-hour format (e.g., 1:10 pm)';
11870
- }
11871
- return 'Please enter a valid time format (e.g., 1:10 pm)';
11872
- }
11873
- // Extract hours and minutes for additional validation
11874
- const matches = normalizedValue.match(timeRegex);
11875
- if (matches) {
11876
- const hours = parseInt(matches[1], 10);
11877
- const minutes = parseInt(matches[2], 10);
11878
- if (hours < 1 || hours > 12) {
11879
- return 'Hours must be between 1 and 12';
11880
- }
11881
- if (minutes < 0 || minutes > 59) {
11882
- return 'Minutes must be between 0 and 59';
11883
- }
11884
- }
11885
- return ''; // Valid time format
11886
- };
11887
-
11888
- const TimePicker = ({ timeValue = '', label = 'Time Picker', name = 'time-picker', hasHiddenLabel = false, onTimeChange, }) => {
11889
- const [validationError, setValidationError] = useState('');
11890
- const [inputValue, setInputValue] = useState(timeValue);
11891
- const handleTimeChange = (e) => {
11892
- const newValue = e.target.value;
11893
- const error = validateInputValue(newValue);
11894
- setInputValue(newValue);
11895
- setValidationError(error);
11896
- // Only send valid values to parent component
11897
- if (!error || error === '') {
11898
- onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(newValue);
11899
- }
11900
- };
11901
- const handleBlur = (e) => {
11902
- const currentValue = e.target.value;
11903
- // Only format if there's no validation error
11904
- if (validationError === '' && currentValue.trim() !== '') {
11905
- const formattedValue = formatTimeValue(currentValue);
11906
- setInputValue(formattedValue);
11907
- onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(formattedValue);
11908
- }
11909
- };
11910
- return (jsx("div", { className: "time-input-wrapper", children: jsx(LabeledInput, { "data-testid": `${name}-input`, label: label, hasHiddenLabel: hasHiddenLabel, value: inputValue, maxLength: 8, onChange: handleTimeChange, onBlur: handleBlur, name: name, errorMessage: validationError }) }));
11911
- };
11912
-
11913
- const DatePicker = (props) => {
11914
- const { mode = 'single', className, captionLayout = 'dropdown', selected, hasTimePicker = false, id, month, defaultMonth, startMonth, endMonth, components, numberOfMonths, isDisabled, formatters, weekStartsOn, firstWeekContainsDate, today, timeValue, isRequired, min, max, onTimeChange, onSelect, onMonthChange, onNextClick, onPrevClick, onDayClick } = props, rest = __rest(props, ["mode", "className", "captionLayout", "selected", "hasTimePicker", "id", "month", "defaultMonth", "startMonth", "endMonth", "components", "numberOfMonths", "isDisabled", "formatters", "weekStartsOn", "firstWeekContainsDate", "today", "timeValue", "isRequired", "min", "max", "onTimeChange", "onSelect", "onMonthChange", "onNextClick", "onPrevClick", "onDayClick"]);
11915
- const futureDateByYear = (year) => new Date(new Date().getFullYear() + year, 11, 31);
11916
- const endMonthDefault = endMonth !== null && endMonth !== void 0 ? endMonth : futureDateByYear(5);
11917
- const modeMap = {
11918
- single: {
11919
- mode: 'single',
11920
- numberOfMonths: numberOfMonths !== null && numberOfMonths !== void 0 ? numberOfMonths : 1,
11921
- selected: selected,
11922
- onSelect: onSelect,
11923
- endMonth: endMonthDefault,
11924
- },
11925
- multiple: {
11926
- mode: 'multiple',
11927
- numberOfMonths: numberOfMonths !== null && numberOfMonths !== void 0 ? numberOfMonths : 1,
11928
- selected: selected,
11929
- onSelect: onSelect,
11930
- endMonth: endMonthDefault,
11931
- },
11932
- range: {
11933
- mode: 'range',
11934
- numberOfMonths: numberOfMonths !== null && numberOfMonths !== void 0 ? numberOfMonths : 2,
11935
- selected: selected,
11936
- onSelect: onSelect,
11937
- endMonth: endMonthDefault,
11938
- },
11939
- };
11940
- const modeProps = modeMap[mode];
11941
- const commonProps = getCommonProps(props);
11942
- const handleTimeChange = (time) => {
11943
- onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(time);
11944
- };
11945
- const finalProps = Object.assign(Object.assign(Object.assign({}, commonProps), rest), modeProps);
11946
- return (jsxs("div", { className: "date-picker-wrapper", children: [hasTimePicker && (jsx("div", { className: "time-picker-wrapper", children: jsxs(Row, { align: "center", children: [jsx(Col, { xs: "content", children: jsx("p", { className: "ma-0", children: "Select Time" }) }), jsx(Col, { children: jsx(TimePicker, { timeValue: timeValue !== null && timeValue !== void 0 ? timeValue : '', onTimeChange: handleTimeChange }) })] }) })), jsx(DayPicker, Object.assign({}, finalProps))] }));
11947
- };
11948
-
11949
11839
  function getNodeName$1(node) {
11950
11840
  if (isNode$1(node)) {
11951
11841
  return (node.nodeName || '').toLowerCase();
@@ -13619,7 +13509,7 @@ const defaultOptions$1 = {
13619
13509
  placement: 'bottom-start',
13620
13510
  middleware: [offset$2(5), flip$2(), shift$2()],
13621
13511
  };
13622
- function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, isPortal = false, portalOptions = {}, floatingOptions = defaultOptions$1, }) {
13512
+ function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: controlledSetIsOpen, isPortal = false, portalOptions = {}, floatingOptions = defaultOptions$1, className, }) {
13623
13513
  const [internalIsOpen, setInternalIsOpen] = useState(false);
13624
13514
  // Determine whether the component is controlled or uncontrolled
13625
13515
  const isControlled = controlledIsOpen !== undefined && controlledSetIsOpen !== undefined;
@@ -13641,13 +13531,129 @@ function FloatUI({ children, ariaLabel, isOpen: controlledIsOpen, setIsOpen: con
13641
13531
  const click = useClick(context);
13642
13532
  const dismiss = useDismiss(context);
13643
13533
  const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss]);
13644
- const tooltipContent = (jsx("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { style: floatingStyles, role: "dialog", "aria-label": ariaLabel, className: "floatui-container", children: jsx("div", { ref: floatUIContentRef, className: "floatui-content", children: content }) })));
13534
+ const tooltipContent = (jsx("div", Object.assign({ ref: refs.setFloating }, getFloatingProps(), { style: floatingStyles, role: "dialog", "aria-label": ariaLabel, className: `floatui-container ${className}`, children: jsx("div", { ref: floatUIContentRef, className: "floatui-content", children: content }) })));
13645
13535
  return (jsxs(Fragment, { children: [jsx("div", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: trigger })), isOpen &&
13646
13536
  (isPortal ? (jsx(FloatingPortal, { id: portalOptions === null || portalOptions === void 0 ? void 0 : portalOptions.rootId, children: tooltipContent })) : (tooltipContent))] }));
13647
13537
  }
13648
13538
 
13539
+ const formatTimeValue = (value) => {
13540
+ if (!value || value.trim() === '') {
13541
+ return '';
13542
+ }
13543
+ // Normalize the input
13544
+ const normalizedValue = value.trim().toLowerCase();
13545
+ // Extract time components using regex
13546
+ const timeRegex = /^(0?[1-9]|1[0-2]):([0-5][0-9])(\s*)([ap]m)$/i;
13547
+ const matches = normalizedValue.match(timeRegex);
13548
+ if (matches) {
13549
+ const hours = parseInt(matches[1], 10);
13550
+ const minutes = parseInt(matches[2], 10);
13551
+ const period = matches[4].toUpperCase(); // Convert am/pm to AM/PM
13552
+ // Format as hh:mm AM/PM
13553
+ return `${hours}:${minutes < 10 ? '0' + minutes : minutes} ${period}`;
13554
+ }
13555
+ return value; // Return original if no match (shouldn't happen with valid inputs)
13556
+ };
13557
+ const validateInputValue = (value) => {
13558
+ if (!value || value.trim() === '') {
13559
+ return ''; // Empty input is allowed
13560
+ }
13561
+ // Normalize the input (remove extra spaces, convert to lowercase)
13562
+ const normalizedValue = value.trim().toLowerCase();
13563
+ // Regular expression for valid time formats: 1:10 pm, 01:10 pm, 1:10pm, 01:10pm
13564
+ const timeRegex = /^(0?[1-9]|1[0-2]):([0-5][0-9])(\s*)([ap]m)$/i;
13565
+ if (!timeRegex.test(normalizedValue)) {
13566
+ // Check if the issue might be a 24-hour format
13567
+ const hour24Regex = /^([13-9]|1[3-9]|2[0-3]):/i;
13568
+ if (hour24Regex.test(normalizedValue)) {
13569
+ return 'Please enter time in 12-hour format (e.g., 1:10 pm)';
13570
+ }
13571
+ return 'Please enter a valid time format (e.g., 1:10 pm)';
13572
+ }
13573
+ // Extract hours and minutes for additional validation
13574
+ const matches = normalizedValue.match(timeRegex);
13575
+ if (matches) {
13576
+ const hours = parseInt(matches[1], 10);
13577
+ const minutes = parseInt(matches[2], 10);
13578
+ if (hours < 1 || hours > 12) {
13579
+ return 'Hours must be between 1 and 12';
13580
+ }
13581
+ if (minutes < 0 || minutes > 59) {
13582
+ return 'Minutes must be between 0 and 59';
13583
+ }
13584
+ }
13585
+ return ''; // Valid time format
13586
+ };
13587
+
13588
+ const TimePicker = (_a) => {
13589
+ var { ref, timeValue = '', label = 'Time Picker', name = 'time-picker', hasHiddenLabel = false, onTimeChange, className, isDisabled, isReadOnly, tabIndex } = _a, rest = __rest(_a, ["ref", "timeValue", "label", "name", "hasHiddenLabel", "onTimeChange", "className", "isDisabled", "isReadOnly", "tabIndex"]);
13590
+ const [validationError, setValidationError] = useState('');
13591
+ const [inputValue, setInputValue] = useState(timeValue);
13592
+ const handleTimeChange = (e) => {
13593
+ const newValue = e.target.value;
13594
+ const error = validateInputValue(newValue);
13595
+ setInputValue(newValue);
13596
+ setValidationError(error);
13597
+ // Only send valid values to parent component
13598
+ if (!error || error === '') {
13599
+ onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(newValue);
13600
+ }
13601
+ };
13602
+ const handleBlur = (e) => {
13603
+ const currentValue = e.target.value;
13604
+ // Only format if there's no validation error
13605
+ if (validationError === '' && currentValue.trim() !== '') {
13606
+ const formattedValue = formatTimeValue(currentValue);
13607
+ setInputValue(formattedValue);
13608
+ onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(formattedValue);
13609
+ }
13610
+ };
13611
+ return (jsxs("div", { className: "time-input-wrapper", children: [jsx(LabeledInput, Object.assign({ ref: ref, tabIndex: tabIndex, className: className, "data-testid": `${name}-input`, label: label, hasHiddenLabel: hasHiddenLabel, value: inputValue, maxLength: 8, onChange: handleTimeChange, onBlur: handleBlur, name: name, readonly: isReadOnly, isDisabled: isDisabled }, rest)), jsxs(FloatUI, { ariaLabel: "Time validation error", isOpen: !!validationError, setIsOpen: () => { }, isPortal: true, portalOptions: {
13612
+ rootId: 'theme-root' ,
13613
+ }, floatingOptions: {
13614
+ placement: 'bottom-start',
13615
+ middleware: [offset$2(5), flip$2(), shift$2()],
13616
+ }, children: [jsx("div", {}), jsx("div", { className: "time-validation-error", children: validationError && jsx("div", { className: "error-message", children: validationError }) })] })] }));
13617
+ };
13618
+
13619
+ const DatePicker = (props) => {
13620
+ const { mode = 'single', className, captionLayout = 'dropdown', selected, hasTimePicker = false, id, month, defaultMonth, startMonth, endMonth, components, numberOfMonths, isDisabled, formatters, weekStartsOn, firstWeekContainsDate, today, timeValue, isRequired, min, max, onTimeChange, onSelect, onMonthChange, onNextClick, onPrevClick, onDayClick, isReadOnly, ref, timeTabIndex, dateTabIndex } = props, rest = __rest(props, ["mode", "className", "captionLayout", "selected", "hasTimePicker", "id", "month", "defaultMonth", "startMonth", "endMonth", "components", "numberOfMonths", "isDisabled", "formatters", "weekStartsOn", "firstWeekContainsDate", "today", "timeValue", "isRequired", "min", "max", "onTimeChange", "onSelect", "onMonthChange", "onNextClick", "onPrevClick", "onDayClick", "isReadOnly", "ref", "timeTabIndex", "dateTabIndex"]);
13621
+ const futureDateByYear = (year) => new Date(new Date().getFullYear() + year, 11, 31);
13622
+ const endMonthDefault = endMonth !== null && endMonth !== void 0 ? endMonth : futureDateByYear(5);
13623
+ const modeMap = {
13624
+ single: {
13625
+ mode: 'single',
13626
+ numberOfMonths: numberOfMonths !== null && numberOfMonths !== void 0 ? numberOfMonths : 1,
13627
+ selected: selected,
13628
+ onSelect: onSelect,
13629
+ endMonth: endMonthDefault,
13630
+ },
13631
+ multiple: {
13632
+ mode: 'multiple',
13633
+ numberOfMonths: numberOfMonths !== null && numberOfMonths !== void 0 ? numberOfMonths : 1,
13634
+ selected: selected,
13635
+ onSelect: onSelect,
13636
+ endMonth: endMonthDefault,
13637
+ },
13638
+ range: {
13639
+ mode: 'range',
13640
+ numberOfMonths: numberOfMonths !== null && numberOfMonths !== void 0 ? numberOfMonths : 2,
13641
+ selected: selected,
13642
+ onSelect: onSelect,
13643
+ endMonth: endMonthDefault,
13644
+ },
13645
+ };
13646
+ const modeProps = modeMap[mode];
13647
+ const commonProps = getCommonProps(props);
13648
+ const handleTimeChange = (time) => {
13649
+ onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(time);
13650
+ };
13651
+ const finalProps = Object.assign(Object.assign(Object.assign({}, commonProps), rest), modeProps);
13652
+ return (jsxs("div", { className: "date-picker-wrapper", children: [hasTimePicker && (jsx("div", { className: "time-picker-wrapper", children: jsxs(Row, { align: "center", children: [jsx(Col, { xs: "content", children: jsx("p", { className: "ma-0", children: "Select Time" }) }), jsx(Col, { children: jsx(TimePicker, { ref: ref, timeValue: timeValue !== null && timeValue !== void 0 ? timeValue : '', onTimeChange: handleTimeChange, readonly: isReadOnly, tabIndex: timeTabIndex }) })] }) })), jsx(DayPicker, Object.assign({}, finalProps))] }));
13653
+ };
13654
+
13649
13655
  const IconTriggerDatePicker = (props) => {
13650
- const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, id, label, onSelect, selected, triggerIcon, triggerIconSize, mode, isOpen, clearOnClose, initialMonth } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "id", "label", "onSelect", "selected", "triggerIcon", "triggerIconSize", "mode", "isOpen", "clearOnClose", "initialMonth"]);
13656
+ const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, id, label, onSelect, selected, triggerIcon, triggerIconSize, mode, isOpen, clearOnClose, initialMonth, portalOptions, floatingOptions, isPortal } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "id", "label", "onSelect", "selected", "triggerIcon", "triggerIconSize", "mode", "isOpen", "clearOnClose", "initialMonth", "portalOptions", "floatingOptions", "isPortal"]);
13651
13657
  const [localMonth, setLocalMonth] = useState(initialMonth !== null && initialMonth !== void 0 ? initialMonth : new Date());
13652
13658
  const handleSelect = (date) => {
13653
13659
  if (!date) {
@@ -13663,7 +13669,7 @@ const IconTriggerDatePicker = (props) => {
13663
13669
  onSelect && onSelect(undefined);
13664
13670
  }
13665
13671
  }, [isOpen, clearOnClose]);
13666
- return (jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [jsx(Icon, { "aria-label": "Open date picker", name: triggerIcon, size: triggerIconSize, className: "date__picker__trigger", "data-testid": `datepicker-trigger-for-${id}` }), jsx(DatePicker, Object.assign({ isDisabled: isDisabled, mode: mode, selected: selected, onSelect: handleSelect, month: localMonth, startMonth: disableBeforeDate, endMonth: disableAfterDate, onMonthChange: setLocalMonth }, rest))] }));
13672
+ return (jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, isPortal: isPortal, portalOptions: portalOptions, floatingOptions: floatingOptions, children: [jsx(Icon, { "aria-label": "Open date picker", name: triggerIcon, size: triggerIconSize, className: "date__picker__trigger", "data-testid": `datepicker-trigger-for-${id}` }), jsx(DatePicker, Object.assign({ isDisabled: isDisabled, mode: mode, selected: selected, onSelect: handleSelect, month: localMonth, startMonth: disableBeforeDate, endMonth: disableAfterDate, onMonthChange: setLocalMonth }, rest))] }));
13667
13673
  };
13668
13674
 
13669
13675
  /**
@@ -19056,7 +19062,7 @@ const formatDateAsString$1 = (date) => format(date, 'MM/dd/yyyy');
19056
19062
 
19057
19063
  function SingleInputDatePicker(props) {
19058
19064
  var _a;
19059
- 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"]);
19065
+ const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, initialMonth, id, label, selected, isOpen, inputPlaceholder, clearOnClose, inputIconName, isClearable, errorMessage, onSelect, hasHiddenLabel, ref, isReadOnly, tabIndex, portalOptions, floatingOptions, isPortal } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "initialMonth", "id", "label", "selected", "isOpen", "inputPlaceholder", "clearOnClose", "inputIconName", "isClearable", "errorMessage", "onSelect", "hasHiddenLabel", "ref", "isReadOnly", "tabIndex", "portalOptions", "floatingOptions", "isPortal"]);
19060
19066
  const inputId = useId$1();
19061
19067
  // The text value is assumed to be unneeded by the consumer.
19062
19068
  const [localTextValue, setLocalTextValue] = useState(selected ? formatDateAsString$1(selected) : '');
@@ -19090,11 +19096,11 @@ function SingleInputDatePicker(props) {
19090
19096
  setLocalTextValue('');
19091
19097
  }
19092
19098
  }, [isOpen, clearOnClose]);
19093
- return (jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [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' }), jsx(DatePicker, Object.assign({ captionLayout: captionLayout, mode: "single", selected: selected, onSelect: handleDayPickerSelect, month: localMonth, onMonthChange: setLocalMonth }, rest))] }));
19099
+ return (jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, isPortal: isPortal, portalOptions: portalOptions, floatingOptions: floatingOptions, children: [jsx(LabeledInput, { id: inputId, value: localTextValue, placeholder: inputPlaceholder, isDisabled: isDisabled, hasHiddenLabel: hasHiddenLabel, iconName: inputIconName, isClearable: isClearable, onChange: handleInputChange, errorMessage: errorMessage, label: 'Single Date Picker', tabIndex: tabIndex, name: 'Date Picker', ref: ref, readonly: isReadOnly }), jsx(DatePicker, Object.assign({ captionLayout: captionLayout, mode: "single", selected: selected, onSelect: handleDayPickerSelect, month: localMonth, onMonthChange: setLocalMonth }, rest))] }));
19094
19100
  }
19095
19101
 
19096
19102
  function InputDateRangePicker(props) {
19097
- 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"]);
19103
+ const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, month, id, onSelect, selected, isOpen, setIsOpen, inputPlaceholder, inputIconName, toErrorMessage, fromErrorMessage, gutterWidth, fromLabel, toLabel, closeOnSelect, clearOnClose, hasHiddenLabel, ref, isFromReadOnly, isToReadOnly, toTabIndex, fromTabIndex, portalOptions, floatingOptions, isPortal } = 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", "ref", "isFromReadOnly", "isToReadOnly", "toTabIndex", "fromTabIndex", "portalOptions", "floatingOptions", "isPortal"]);
19098
19104
  const inputId = useId$1();
19099
19105
  // Hold the input values in state
19100
19106
  const [localTextValueFrom, setLocalTextValueFrom] = useState((selected === null || selected === void 0 ? void 0 : selected.from) ? formatDateAsString$1(selected.from) : '');
@@ -19153,14 +19159,14 @@ function InputDateRangePicker(props) {
19153
19159
  setLocalTextValueTo('');
19154
19160
  }
19155
19161
  }, [isOpen, clearOnClose]);
19156
- return (jsxs(FloatUI, { isOpen: isOpen, setIsOpen: setIsOpen, ariaLabel: ariaLabel, children: [jsxs(Row, { gutterWidth: gutterWidth, children: [jsx(Col, { children: 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 }) }), jsx(Col, { children: 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 }) })] }), jsx(DatePicker, Object.assign({ captionLayout: captionLayout, month: localMonth, onMonthChange: (date) => setLocalMonth(date), mode: "range", selected: selected, onSelect: handleDayPickerSelect }, rest))] }));
19162
+ return (jsxs(FloatUI, { isOpen: isOpen, setIsOpen: setIsOpen, ariaLabel: ariaLabel, portalOptions: portalOptions, floatingOptions: floatingOptions, children: [jsxs(Row, { gutterWidth: gutterWidth, children: [jsx(Col, { children: 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, ref: ref, readonly: isFromReadOnly, tabIndex: fromTabIndex }) }), jsx(Col, { children: 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, ref: ref, readonly: isToReadOnly, tabIndex: toTabIndex }) })] }), jsx(DatePicker, Object.assign({ captionLayout: captionLayout, month: localMonth, onMonthChange: (date) => setLocalMonth(date), mode: "range", selected: selected, onSelect: handleDayPickerSelect }, rest))] }));
19157
19163
  }
19158
19164
 
19159
19165
  const formatDateAsString = (date) => format(date, 'MM/dd/yyyy');
19160
19166
 
19161
19167
  function SingleInputDateTimePicker(props) {
19162
19168
  var _a;
19163
- 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"]);
19169
+ const { ariaLabel, className, isDisabled, disableBeforeDate, disableAfterDate, captionLayout, initialMonth, id, label, selected, isOpen, inputPlaceholder, clearOnClose, inputIconName, isClearable, errorMessage, onSelect, timeValue, onTimeChange, hasHiddenLabel, isReadOnly, timePickerRef, dateTabIndex, timeTabIndex, ref, portalOptions, floatingOptions, isPortal } = props, rest = __rest(props, ["ariaLabel", "className", "isDisabled", "disableBeforeDate", "disableAfterDate", "captionLayout", "initialMonth", "id", "label", "selected", "isOpen", "inputPlaceholder", "clearOnClose", "inputIconName", "isClearable", "errorMessage", "onSelect", "timeValue", "onTimeChange", "hasHiddenLabel", "isReadOnly", "timePickerRef", "dateTabIndex", "timeTabIndex", "ref", "portalOptions", "floatingOptions", "isPortal"]);
19164
19170
  const inputId = useId$1();
19165
19171
  // The text value is assumed to be unneeded by the consumer.
19166
19172
  const [localTextValue, setLocalTextValue] = useState(selected ? formatDateAsString(selected) : '');
@@ -19197,7 +19203,7 @@ function SingleInputDateTimePicker(props) {
19197
19203
  const handleTimeChange = (time) => {
19198
19204
  onTimeChange === null || onTimeChange === void 0 ? void 0 : onTimeChange(time);
19199
19205
  };
19200
- return (jsxs(Row, { children: [jsx(Col, { children: jsxs(FloatUI, { isOpen: isOpen, ariaLabel: ariaLabel, children: [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` }), jsx(DatePicker, Object.assign({ captionLayout: captionLayout, mode: "single", selected: selected, onSelect: handleDayPickerSelect, month: localMonth, onMonthChange: setLocalMonth }, rest))] }) }), jsx(Col, { xs: "content", children: jsx(TimePicker, { timeValue: timeValue, name: `${id}-time-picker`, hasHiddenLabel: true, onTimeChange: handleTimeChange }) })] }));
19206
+ return (jsxs(Row, { className: "date-time-picker-row", children: [jsx(Col, { className: "date-picker-col", children: jsxs(FloatUI, { className: "date-picker-float-ui", isOpen: isOpen, ariaLabel: ariaLabel, isPortal: isPortal, portalOptions: portalOptions, floatingOptions: floatingOptions, children: [jsx(LabeledInput, { ref: ref, className: `date-picker-input`, id: inputId, value: localTextValue, placeholder: inputPlaceholder, isDisabled: isReadOnly || isDisabled, readonly: isReadOnly, iconName: inputIconName, isClearable: isClearable, onChange: handleInputChange, errorMessage: errorMessage, hasHiddenLabel: hasHiddenLabel, label: 'Single Date Picker', name: `${id}-date-picker`, tabIndex: dateTabIndex }), jsx(DatePicker, Object.assign({ captionLayout: captionLayout, mode: "single", selected: selected, onSelect: handleDayPickerSelect, month: localMonth, onMonthChange: setLocalMonth, isReadOnly: isReadOnly }, rest))] }) }), jsx(Col, { xs: "content", className: "time-picker-col", children: jsx(TimePicker, { ref: timePickerRef, className: `time-picker-input`, timeValue: timeValue, name: `${id}-time-picker`, hasHiddenLabel: true, onTimeChange: handleTimeChange, isReadOnly: isReadOnly, isDisabled: isDisabled, tabIndex: timeTabIndex }) })] }));
19201
19207
  }
19202
19208
 
19203
19209
  const Form = (_a) => {