@clickhouse/click-ui 0.0.227 → 0.0.228

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.
@@ -1302,7 +1302,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1302
1302
  /* @__PURE__ */ jsxRuntime.jsx("path", { stroke: "#161517", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M6.998 7.873a.125.125 0 1 0 0 .25.125.125 0 0 0 0-.25M11 7.873a.125.125 0 1 0 0 .25.125.125 0 0 0 0-.25M6.998 11.875a.125.125 0 1 0 0 .25.125.125 0 0 0 0-.25M11 11.875a.125.125 0 1 0 0 .25.125.125 0 0 0 0-.25M6.998 15.877a.125.125 0 1 0 0 .25.125.125 0 0 0 0-.25M11 15.877a.125.125 0 1 0 0 .25.125.125 0 0 0 0-.25M18.002 11.875a.125.125 0 1 0 0 .25.125.125 0 0 0 0-.25M18.002 15.877a.125.125 0 1 0 0 .25.125.125 0 0 0 0-.25" })
1303
1303
  ] });
1304
1304
  const BurgerMenu = (props) => /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", ...props, children: /* @__PURE__ */ jsxRuntime.jsx("path", { stroke: "#161517", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M3.75 7.25h16.5M3.75 12.5h16.5m-16.5 5.25H12" }) });
1305
- const Calendar$1 = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
1305
+ const Calendar$2 = (props) => /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
1306
1306
  /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "2.99609", y: "2.99658", width: "18.0075", height: "18.0075", rx: "3", stroke: "#161517", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
1307
1307
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21.0036 7.99826H2.99609", stroke: "#161517", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
1308
1308
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M17.3022 11.4997C17.3022 11.5273 17.2798 11.5497 17.2522 11.5497C17.2245 11.5497 17.2021 11.5273 17.2021 11.4997C17.2021 11.4721 17.2245 11.4497 17.2522 11.4497", stroke: "#161517", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
@@ -1994,7 +1994,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1994
1994
  briefcase: Briefcase,
1995
1995
  building: Building,
1996
1996
  "burger-menu": BurgerMenu,
1997
- calendar: Calendar$1,
1997
+ calendar: Calendar$2,
1998
1998
  "calendar-with-time": CalendarWithTime,
1999
1999
  cards: Cards,
2000
2000
  "cell-tower": CellTower,
@@ -17211,12 +17211,62 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
17211
17211
  align-self: stretch;
17212
17212
  align-items: center;
17213
17213
  `);
17214
- const locale = "en-US";
17215
- const selectedDateFormatter = new Intl.DateTimeFormat(locale, {
17214
+ const locale$1 = "en-US";
17215
+ const selectedDateFormatter = new Intl.DateTimeFormat(locale$1, {
17216
17216
  day: "2-digit",
17217
17217
  month: "short",
17218
17218
  year: "numeric"
17219
17219
  });
17220
+ const weekdayFormatter = new Intl.DateTimeFormat(locale$1, {
17221
+ weekday: "short"
17222
+ });
17223
+ const headerDateFormatter = new Intl.DateTimeFormat(locale$1, {
17224
+ month: "short",
17225
+ year: "numeric"
17226
+ });
17227
+ const getPredefinedMonthsForDateRangePicker = (numberOfMonths) => {
17228
+ const now2 = dayjs();
17229
+ if (numberOfMonths < 0) {
17230
+ const lastSixMonths = [];
17231
+ for (let i = 0; i < Math.abs(numberOfMonths); i++) {
17232
+ const date = now2.subtract(i, "month");
17233
+ if (date.date() === 1 && date.month() === now2.month()) {
17234
+ continue;
17235
+ }
17236
+ lastSixMonths.push({
17237
+ startDate: date.startOf("month").toDate(),
17238
+ endDate: i === 0 ? now2.toDate() : date.endOf("month").toDate()
17239
+ });
17240
+ }
17241
+ return lastSixMonths.reverse();
17242
+ }
17243
+ const nextSixMonths = [];
17244
+ for (let i = 0; i < numberOfMonths; i++) {
17245
+ const date = now2.add(i, "month");
17246
+ nextSixMonths.push({
17247
+ startDate: date.startOf("month").toDate(),
17248
+ endDate: date.endOf("month").toDate()
17249
+ });
17250
+ }
17251
+ return nextSixMonths;
17252
+ };
17253
+ const datesAreWithinMaxRange = (startDate, endDate, maxRangeLength) => {
17254
+ const daysDifference = Math.abs(dayjs(startDate).diff(dayjs(endDate), "days"));
17255
+ return daysDifference <= maxRangeLength;
17256
+ };
17257
+ const isDateRangeTheWholeMonth = ({
17258
+ startDate,
17259
+ endDate
17260
+ }) => {
17261
+ if (startDate.getMonth() !== endDate.getMonth()) {
17262
+ return false;
17263
+ }
17264
+ const start = dayjs(startDate);
17265
+ const end = dayjs(endDate);
17266
+ const startDateIsFirstDay = start.isSame(start.startOf("month"), "day");
17267
+ const endDateIsLastDay = end.isSame(end.endOf("month"), "day");
17268
+ return startDateIsFirstDay && endDateIsLastDay;
17269
+ };
17220
17270
  const explicitWidth = "250px";
17221
17271
  const HighlightedInputWrapper = pt(InputWrapper).withConfig({
17222
17272
  componentId: "sc-1m6g9rm-0"
@@ -17240,13 +17290,37 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
17240
17290
  /* @__PURE__ */ jsxRuntime.jsx(InputElement, { $hasStartContent: true, "data-testid": "datepicker-input", placeholder, readOnly: true, value: formattedSelectedDate })
17241
17291
  ] });
17242
17292
  };
17243
- const weekdayFormatter = new Intl.DateTimeFormat(locale, {
17244
- weekday: "short"
17245
- });
17246
- const headerDateFormatter = new Intl.DateTimeFormat(locale, {
17247
- month: "short",
17248
- year: "numeric"
17249
- });
17293
+ const DateRangePickerInput = ({
17294
+ isActive,
17295
+ disabled,
17296
+ id,
17297
+ placeholder,
17298
+ selectedEndDate,
17299
+ selectedStartDate
17300
+ }) => {
17301
+ const defaultId = React.useId();
17302
+ let formattedValue = /* @__PURE__ */ jsxRuntime.jsx(Text, { color: "muted", component: "span", children: placeholder ?? "" });
17303
+ if (selectedStartDate) {
17304
+ if (selectedEndDate) {
17305
+ formattedValue = /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
17306
+ selectedDateFormatter.format(selectedStartDate),
17307
+ " –",
17308
+ " ",
17309
+ selectedDateFormatter.format(selectedEndDate)
17310
+ ] });
17311
+ } else {
17312
+ formattedValue = /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
17313
+ selectedDateFormatter.format(selectedStartDate),
17314
+ " ",
17315
+ /* @__PURE__ */ jsxRuntime.jsx(Text, { color: "muted", component: "span", children: "– end date" })
17316
+ ] });
17317
+ }
17318
+ }
17319
+ return /* @__PURE__ */ jsxRuntime.jsxs(HighlightedInputWrapper, { $isActive: isActive, disabled, id: id ?? defaultId, children: [
17320
+ /* @__PURE__ */ jsxRuntime.jsx(InputStartContent, { children: /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { name: "calendar" }) }),
17321
+ /* @__PURE__ */ jsxRuntime.jsx(InputElement, { $hasStartContent: true, as: "div", "data-testid": "daterangepicker-input", children: formattedValue })
17322
+ ] });
17323
+ };
17250
17324
  const DatePickerContainer = pt(Container).withConfig({
17251
17325
  componentId: "sc-1m6g9rm-1"
17252
17326
  })(["background:", ";"], ({
@@ -17332,9 +17406,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
17332
17406
  headerDate.setFullYear(year);
17333
17407
  return /* @__PURE__ */ jsxRuntime.jsxs(DatePickerContainer, { "data-testid": "datepicker-calendar-container", isResponsive: false, fillWidth: false, orientation: "vertical", padding: "sm", ...props, children: [
17334
17408
  /* @__PURE__ */ jsxRuntime.jsxs(Container, { isResponsive: false, justifyContent: "space-between", orientation: "horizontal", children: [
17335
- /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { icon: "chevron-left", onClick: handlePreviousClick, size: "sm", type: "ghost" }),
17409
+ /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { "data-testid": "calendar-previous-month", icon: "chevron-left", onClick: handlePreviousClick, size: "sm", type: "ghost" }),
17336
17410
  /* @__PURE__ */ jsxRuntime.jsx(UnselectableTitle, { children: headerDateFormatter.format(headerDate) }),
17337
- /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { icon: "chevron-right", onClick: handleNextClick, size: "sm", type: "ghost" })
17411
+ /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { "data-testid": "calendar-next-month", icon: "chevron-right", onClick: handleNextClick, size: "sm", type: "ghost" })
17338
17412
  ] }),
17339
17413
  /* @__PURE__ */ jsxRuntime.jsxs(DateTable, { children: [
17340
17414
  /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: headers.weekDays.map(({
@@ -17347,7 +17421,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
17347
17421
  ] })
17348
17422
  ] });
17349
17423
  };
17350
- const Calendar = ({
17424
+ const Calendar$1 = ({
17351
17425
  calendarBody,
17352
17426
  closeDatepicker,
17353
17427
  futureDatesDisabled,
@@ -17406,7 +17480,275 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
17406
17480
  };
17407
17481
  return /* @__PURE__ */ jsxRuntime.jsxs(Dropdown, { onOpenChange: setIsOpen, open: isOpen, children: [
17408
17482
  /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Trigger, { disabled, children: /* @__PURE__ */ jsxRuntime.jsx(DatePickerInput, { "data-testid": "datepicker-input-container", disabled, isActive: isOpen, placeholder, selectedDate }) }),
17409
- /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Content, { align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(CalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsxRuntime.jsx(Calendar, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, selectedDate, setSelectedDate: handleSelectDate }) }) })
17483
+ /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Content, { align: "start", children: /* @__PURE__ */ jsxRuntime.jsx(CalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsxRuntime.jsx(Calendar$1, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, selectedDate, setSelectedDate: handleSelectDate }) }) })
17484
+ ] });
17485
+ };
17486
+ const Panel = ({
17487
+ alignItems = "center",
17488
+ children,
17489
+ color,
17490
+ cursor,
17491
+ fillHeight,
17492
+ fillWidth,
17493
+ gap,
17494
+ hasBorder,
17495
+ hasShadow,
17496
+ height,
17497
+ orientation = "horizontal",
17498
+ padding,
17499
+ radii = "sm",
17500
+ width,
17501
+ ...props
17502
+ }) => /* @__PURE__ */ jsxRuntime.jsx(Wrapper$2, { $alignItems: alignItems, $color: color, $cursor: cursor, $fillHeight: fillHeight, $fillWidth: fillWidth, $gap: gap, $hasBorder: hasBorder, $hasShadow: hasShadow, $height: height, $orientation: orientation, $padding: padding, $radii: radii, $width: width, ...props, children });
17503
+ const Wrapper$2 = pt.div.withConfig({
17504
+ componentId: "sc-1q78udp-0"
17505
+ })(["display:flex;flex-flow:", ";align-items:", ";width:", ";height:", ";background-color:", ";border-radius:", ";padding:", ";border:", ";box-shadow:", ";gap:", ";", ";"], ({
17506
+ $orientation = "horizontal"
17507
+ }) => $orientation === "horizontal" ? "row wrap" : "column", ({
17508
+ $alignItems = "center"
17509
+ }) => $alignItems === "center" ? "center" : `flex-${$alignItems}`, ({
17510
+ $width,
17511
+ $fillWidth
17512
+ }) => $fillWidth ? "100%" : $width, ({
17513
+ $height,
17514
+ $fillHeight
17515
+ }) => $fillHeight ? "100%" : $height, ({
17516
+ $color = "default",
17517
+ theme: theme2
17518
+ }) => theme2.click.panel.color.background[$color], ({
17519
+ $radii = "sm",
17520
+ theme: theme2
17521
+ }) => theme2.click.panel.radii[$radii], ({
17522
+ $padding = "md",
17523
+ theme: theme2
17524
+ }) => theme2.click.panel.space.y[$padding], ({
17525
+ $hasBorder,
17526
+ theme: theme2
17527
+ }) => $hasBorder ? `1px solid ${theme2.click.global.color.stroke.default}` : "none", ({
17528
+ $hasShadow,
17529
+ theme: theme2
17530
+ }) => $hasShadow ? theme2.shadow[1] : "none", ({
17531
+ $gap = "sm",
17532
+ theme: theme2
17533
+ }) => theme2.click.panel.space.gap[$gap], ({
17534
+ $cursor
17535
+ }) => $cursor && `cursor: ${$cursor}`);
17536
+ const PredefinedCalendarContainer = pt(Panel).withConfig({
17537
+ componentId: "sc-1f4vu20-0"
17538
+ })(["align-items:start;background:", ";"], ({
17539
+ theme: theme2
17540
+ }) => theme2.click.panel.color.background.muted);
17541
+ const PredefinedDatesContainer = pt(Container).withConfig({
17542
+ componentId: "sc-1f4vu20-1"
17543
+ })(["width:275px;"]);
17544
+ const CalendarRendererContainer = pt.div.withConfig({
17545
+ componentId: "sc-1f4vu20-2"
17546
+ })(["border:", ";border-radius:", ";box-shadow:lch(6.77 0 0 / 0.15) 4px 4px 6px -1px,lch(6.77 0 0 / 0.15) 2px 2px 4px -1px;left:276px;position:absolute;top:0;"], ({
17547
+ theme: theme2
17548
+ }) => `${theme2.click.datePicker.dateOption.stroke} solid ${theme2.click.datePicker.dateOption.color.background.range}`, ({
17549
+ theme: theme2
17550
+ }) => theme2.click.datePicker.dateOption.radii.default);
17551
+ const StyledCalendarRenderer = pt(CalendarRenderer).withConfig({
17552
+ componentId: "sc-1f4vu20-3"
17553
+ })(["border-radius:", ";min-height:221px;"], ({
17554
+ theme: theme2
17555
+ }) => theme2.click.datePicker.dateOption.radii.default);
17556
+ const StyledDropdownItem = pt(Dropdown.Item).withConfig({
17557
+ componentId: "sc-1f4vu20-4"
17558
+ })(["min-height:24px;"]);
17559
+ const ScrollableContainer = pt(Container).withConfig({
17560
+ componentId: "sc-1f4vu20-5"
17561
+ })(["max-height:210px;overflow-y:auto;"]);
17562
+ const DateRangeTableCell = pt(DateTableCell).withConfig({
17563
+ componentId: "sc-1f4vu20-6"
17564
+ })(["", ""], ({
17565
+ $shouldShowRangeIndicator,
17566
+ theme: theme2
17567
+ }) => $shouldShowRangeIndicator && `
17568
+ background: ${theme2.click.datePicker.dateOption.color.background.range};
17569
+ border: ${theme2.click.datePicker.dateOption.stroke} solid ${theme2.click.datePicker.dateOption.color.background.range};
17570
+ border-radius: 0;
17571
+ `);
17572
+ const Calendar = ({
17573
+ calendarBody,
17574
+ closeDatepicker,
17575
+ futureDatesDisabled,
17576
+ futureStartDatesDisabled,
17577
+ maxRangeLength,
17578
+ setSelectedDate,
17579
+ startDate,
17580
+ endDate
17581
+ }) => {
17582
+ const [hoveredDate, setHoveredDate] = React.useState();
17583
+ const handleMouseOut = () => {
17584
+ setHoveredDate(void 0);
17585
+ };
17586
+ return calendarBody.value.map(({
17587
+ key: weekKey,
17588
+ value: week
17589
+ }) => {
17590
+ return /* @__PURE__ */ jsxRuntime.jsx("tr", { children: week.map(({
17591
+ date,
17592
+ isCurrentMonth,
17593
+ key: dayKey,
17594
+ value: fullDate
17595
+ }) => {
17596
+ const isSelected = startDate && isSameDate(startDate, fullDate) || endDate && isSameDate(endDate, fullDate);
17597
+ const today = /* @__PURE__ */ new Date();
17598
+ const isCurrentDate = isSameDate(today, fullDate);
17599
+ const isBetweenStartAndEndDates = Boolean(startDate && endDate && fullDate > startDate && fullDate < endDate);
17600
+ let isDisabled = false;
17601
+ if (futureDatesDisabled && fullDate > today) {
17602
+ isDisabled = true;
17603
+ }
17604
+ if (futureStartDatesDisabled && !startDate && fullDate > today) {
17605
+ isDisabled = true;
17606
+ }
17607
+ if (maxRangeLength > 1 && startDate && !datesAreWithinMaxRange(startDate, fullDate, maxRangeLength)) {
17608
+ isDisabled = true;
17609
+ }
17610
+ const shouldShowRangeIndicator = !endDate && Boolean(startDate && hoveredDate && fullDate > startDate && fullDate < hoveredDate);
17611
+ const handleMouseEnter = () => {
17612
+ setHoveredDate(fullDate);
17613
+ };
17614
+ const handleClick = () => {
17615
+ if (isDisabled) {
17616
+ return false;
17617
+ }
17618
+ setSelectedDate(fullDate);
17619
+ if (startDate && endDate) {
17620
+ return;
17621
+ }
17622
+ if (startDate && fullDate < startDate) {
17623
+ return;
17624
+ }
17625
+ if (startDate && !isSameDate(fullDate, startDate)) {
17626
+ closeDatepicker();
17627
+ return;
17628
+ }
17629
+ };
17630
+ return /* @__PURE__ */ jsxRuntime.jsx(DateRangeTableCell, { $shouldShowRangeIndicator: !isSelected && (shouldShowRangeIndicator || isBetweenStartAndEndDates), $isCurrentMonth: isCurrentMonth, $isDisabled: isDisabled, $isSelected: isSelected, $isToday: isCurrentDate, onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseOut, children: date }, dayKey);
17631
+ }) }, weekKey);
17632
+ });
17633
+ };
17634
+ const locale = "en-US";
17635
+ const monthFormatter = new Intl.DateTimeFormat(locale, {
17636
+ month: "short",
17637
+ year: "numeric"
17638
+ });
17639
+ const PredefinedDates = ({
17640
+ onSelectDateRange,
17641
+ predefinedDatesList,
17642
+ selectedEndDate,
17643
+ selectedStartDate,
17644
+ setEndDate,
17645
+ setStartDate,
17646
+ shouldShowCustomRange,
17647
+ showCustomDateRange
17648
+ }) => {
17649
+ const handleCustomTimePeriodClick = (event) => {
17650
+ event.preventDefault();
17651
+ showCustomDateRange(!shouldShowCustomRange);
17652
+ };
17653
+ return /* @__PURE__ */ jsxRuntime.jsxs(PredefinedDatesContainer, { "data-testid": "predefined-dates-list", isResponsive: false, orientation: "vertical", children: [
17654
+ /* @__PURE__ */ jsxRuntime.jsx(ScrollableContainer, { orientation: "vertical", children: predefinedDatesList.map(({
17655
+ startDate,
17656
+ endDate
17657
+ }) => {
17658
+ const handleItemClick = () => {
17659
+ setStartDate(startDate);
17660
+ setEndDate(endDate);
17661
+ onSelectDateRange(startDate, endDate);
17662
+ };
17663
+ const rangeIsSelected = selectedEndDate && isSameDate(selectedEndDate, endDate) && selectedStartDate && isSameDate(selectedStartDate, startDate);
17664
+ const isWholeMonth = isDateRangeTheWholeMonth({
17665
+ startDate,
17666
+ endDate
17667
+ });
17668
+ const formattedText = isWholeMonth ? monthFormatter.format(startDate) : `${selectedDateFormatter.format(startDate)} - ${selectedDateFormatter.format(endDate)}`.trim();
17669
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledDropdownItem, { "data-testid": `predefined-date-${startDate.getTime()}`, onClick: handleItemClick, children: /* @__PURE__ */ jsxRuntime.jsxs(Container, { "data-selected": rangeIsSelected, "data-testid": formattedText, justifyContent: "space-between", orientation: "horizontal", children: [
17670
+ formattedText,
17671
+ rangeIsSelected && /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { name: "check" })
17672
+ ] }) }, startDate.toISOString());
17673
+ }) }),
17674
+ /* @__PURE__ */ jsxRuntime.jsx(StyledDropdownItem, { onClick: handleCustomTimePeriodClick, children: /* @__PURE__ */ jsxRuntime.jsxs(Container, { justifyContent: "space-between", orientation: "horizontal", children: [
17675
+ "Custom time period ",
17676
+ /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { name: "chevron-right" })
17677
+ ] }) })
17678
+ ] });
17679
+ };
17680
+ const DateRangePicker = ({
17681
+ endDate,
17682
+ startDate,
17683
+ disabled = false,
17684
+ futureDatesDisabled = false,
17685
+ futureStartDatesDisabled = false,
17686
+ maxRangeLength = -1,
17687
+ onSelectDateRange,
17688
+ placeholder = "start date – end date",
17689
+ predefinedDatesList
17690
+ }) => {
17691
+ const [isOpen, setIsOpen] = React.useState(false);
17692
+ const [selectedStartDate, setSelectedStartDate] = React.useState();
17693
+ const [selectedEndDate, setSelectedEndDate] = React.useState();
17694
+ const [shouldShowCustomRange, setShouldShowCustomRange] = React.useState(false);
17695
+ const calendarOptions = {};
17696
+ if (selectedStartDate) {
17697
+ calendarOptions.defaultDate = selectedStartDate;
17698
+ }
17699
+ React.useEffect(() => {
17700
+ if (startDate) {
17701
+ setSelectedStartDate(startDate);
17702
+ }
17703
+ }, [startDate]);
17704
+ React.useEffect(() => {
17705
+ if (endDate) {
17706
+ setSelectedEndDate(endDate);
17707
+ }
17708
+ }, [endDate]);
17709
+ const closeDatePicker = React.useCallback(() => {
17710
+ setIsOpen(false);
17711
+ setShouldShowCustomRange(false);
17712
+ }, []);
17713
+ const handleOpenChange = (isOpen2) => {
17714
+ setIsOpen(isOpen2);
17715
+ if (!isOpen2) {
17716
+ setShouldShowCustomRange(false);
17717
+ }
17718
+ };
17719
+ const handleSelectDate = React.useCallback((selectedDate) => {
17720
+ if (selectedStartDate && selectedEndDate) {
17721
+ if (futureStartDatesDisabled && selectedDate > /* @__PURE__ */ new Date()) {
17722
+ setSelectedEndDate(void 0);
17723
+ return;
17724
+ }
17725
+ setSelectedStartDate(selectedDate);
17726
+ setSelectedEndDate(void 0);
17727
+ return;
17728
+ }
17729
+ if (selectedStartDate) {
17730
+ if (isSameDate(selectedStartDate, selectedDate)) {
17731
+ setSelectedStartDate(void 0);
17732
+ return;
17733
+ }
17734
+ if (selectedDate < selectedStartDate) {
17735
+ setSelectedStartDate(selectedDate);
17736
+ return;
17737
+ }
17738
+ setSelectedEndDate(selectedDate);
17739
+ onSelectDateRange(selectedStartDate, selectedDate);
17740
+ setShouldShowCustomRange(false);
17741
+ return;
17742
+ }
17743
+ setSelectedStartDate(selectedDate);
17744
+ }, [futureStartDatesDisabled, onSelectDateRange, selectedEndDate, selectedStartDate]);
17745
+ const shouldShowPredefinedDates = predefinedDatesList !== void 0 && predefinedDatesList.length > 0;
17746
+ return /* @__PURE__ */ jsxRuntime.jsxs(Dropdown, { onOpenChange: handleOpenChange, open: isOpen, children: [
17747
+ /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Trigger, { disabled, children: /* @__PURE__ */ jsxRuntime.jsx(DateRangePickerInput, { "data-testid": "datepicker-input-container", disabled, isActive: isOpen, placeholder, selectedEndDate, selectedStartDate }) }),
17748
+ /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Content, { align: "start", children: shouldShowPredefinedDates ? /* @__PURE__ */ jsxRuntime.jsxs(PredefinedCalendarContainer, { gap: "none", orientation: "horizontal", padding: "none", children: [
17749
+ /* @__PURE__ */ jsxRuntime.jsx(PredefinedDates, { onSelectDateRange, predefinedDatesList, selectedEndDate, selectedStartDate, setEndDate: setSelectedEndDate, setStartDate: setSelectedStartDate, shouldShowCustomRange, showCustomDateRange: setShouldShowCustomRange }),
17750
+ shouldShowCustomRange && /* @__PURE__ */ jsxRuntime.jsx(CalendarRendererContainer, { children: /* @__PURE__ */ jsxRuntime.jsx(StyledCalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsxRuntime.jsx(Calendar, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, futureStartDatesDisabled, maxRangeLength, setSelectedDate: handleSelectDate, startDate: selectedStartDate, endDate: selectedEndDate }) }) })
17751
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(CalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsxRuntime.jsx(Calendar, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, futureStartDatesDisabled, maxRangeLength, setSelectedDate: handleSelectDate, startDate: selectedStartDate, endDate: selectedEndDate }) }) })
17410
17752
  ] });
17411
17753
  };
17412
17754
  const $5d3850c4d0b4e6c7$var$DIALOG_NAME = "Dialog";
@@ -35532,56 +35874,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
35532
35874
  ] })
35533
35875
  ] });
35534
35876
  };
35535
- const Panel = ({
35536
- alignItems = "center",
35537
- children,
35538
- color,
35539
- cursor,
35540
- fillHeight,
35541
- fillWidth,
35542
- gap,
35543
- hasBorder,
35544
- hasShadow,
35545
- height,
35546
- orientation = "horizontal",
35547
- padding,
35548
- radii = "sm",
35549
- width,
35550
- ...props
35551
- }) => /* @__PURE__ */ jsxRuntime.jsx(Wrapper$2, { $alignItems: alignItems, $color: color, $cursor: cursor, $fillHeight: fillHeight, $fillWidth: fillWidth, $gap: gap, $hasBorder: hasBorder, $hasShadow: hasShadow, $height: height, $orientation: orientation, $padding: padding, $radii: radii, $width: width, ...props, children });
35552
- const Wrapper$2 = pt.div.withConfig({
35553
- componentId: "sc-1q78udp-0"
35554
- })(["display:flex;flex-flow:", ";align-items:", ";width:", ";height:", ";background-color:", ";border-radius:", ";padding:", ";border:", ";box-shadow:", ";gap:", ";", ";"], ({
35555
- $orientation = "horizontal"
35556
- }) => $orientation === "horizontal" ? "row wrap" : "column", ({
35557
- $alignItems = "center"
35558
- }) => $alignItems === "center" ? "center" : `flex-${$alignItems}`, ({
35559
- $width,
35560
- $fillWidth
35561
- }) => $fillWidth ? "100%" : $width, ({
35562
- $height,
35563
- $fillHeight
35564
- }) => $fillHeight ? "100%" : $height, ({
35565
- $color = "default",
35566
- theme: theme2
35567
- }) => theme2.click.panel.color.background[$color], ({
35568
- $radii = "sm",
35569
- theme: theme2
35570
- }) => theme2.click.panel.radii[$radii], ({
35571
- $padding = "md",
35572
- theme: theme2
35573
- }) => theme2.click.panel.space.y[$padding], ({
35574
- $hasBorder,
35575
- theme: theme2
35576
- }) => $hasBorder ? `1px solid ${theme2.click.global.color.stroke.default}` : "none", ({
35577
- $hasShadow,
35578
- theme: theme2
35579
- }) => $hasShadow ? theme2.shadow[1] : "none", ({
35580
- $gap = "sm",
35581
- theme: theme2
35582
- }) => theme2.click.panel.space.gap[$gap], ({
35583
- $cursor
35584
- }) => $cursor && `cursor: ${$cursor}`);
35585
35877
  const ProgressContainer = pt.div.withConfig({
35586
35878
  componentId: "sc-16gr3cg-0"
35587
35879
  })(["display:flex;justify-content:space-between;align-items:center;overflow:hidden;transition:all 100ms ease-in-out;width:100%;width:-webkit-fill-available;width:fill-available;width:stretch;min-height:2px;", ";"], ({
@@ -52605,6 +52897,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
52605
52897
  exports2.DangerAlert = DangerAlert;
52606
52898
  exports2.DateDetails = DateDetails;
52607
52899
  exports2.DatePicker = DatePicker;
52900
+ exports2.DateRangePicker = DateRangePicker;
52608
52901
  exports2.Dialog = Dialog;
52609
52902
  exports2.Dropdown = Dropdown;
52610
52903
  exports2.EllipsisContent = EllipsisContent;
@@ -52660,6 +52953,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
52660
52953
  exports2.VerticalStepper = VerticalStepper;
52661
52954
  exports2.WarningAlert = WarningAlert;
52662
52955
  exports2.createToast = createToast;
52956
+ exports2.getPredefinedMonthsForDateRangePicker = getPredefinedMonthsForDateRangePicker;
52663
52957
  exports2.linkStyles = linkStyles;
52664
52958
  exports2.themes = themes;
52665
52959
  exports2.useCUITheme = useCUITheme;