@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.
@@ -105,7 +105,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
105
105
  /* @__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" })
106
106
  ] });
107
107
  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" }) });
108
- 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: [
108
+ 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: [
109
109
  /* @__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" }),
110
110
  /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21.0036 7.99826H2.99609", stroke: "#161517", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
111
111
  /* @__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" }),
@@ -797,7 +797,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
797
797
  briefcase: Briefcase,
798
798
  building: Building,
799
799
  "burger-menu": BurgerMenu,
800
- calendar: Calendar$1,
800
+ calendar: Calendar$2,
801
801
  "calendar-with-time": CalendarWithTime,
802
802
  cards: Cards,
803
803
  "cell-tower": CellTower,
@@ -16042,12 +16042,62 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
16042
16042
  align-self: stretch;
16043
16043
  align-items: center;
16044
16044
  `);
16045
- const locale = "en-US";
16046
- const selectedDateFormatter = new Intl.DateTimeFormat(locale, {
16045
+ const locale$1 = "en-US";
16046
+ const selectedDateFormatter = new Intl.DateTimeFormat(locale$1, {
16047
16047
  day: "2-digit",
16048
16048
  month: "short",
16049
16049
  year: "numeric"
16050
16050
  });
16051
+ const weekdayFormatter = new Intl.DateTimeFormat(locale$1, {
16052
+ weekday: "short"
16053
+ });
16054
+ const headerDateFormatter = new Intl.DateTimeFormat(locale$1, {
16055
+ month: "short",
16056
+ year: "numeric"
16057
+ });
16058
+ const getPredefinedMonthsForDateRangePicker = (numberOfMonths) => {
16059
+ const now2 = dayjs();
16060
+ if (numberOfMonths < 0) {
16061
+ const lastSixMonths = [];
16062
+ for (let i = 0; i < Math.abs(numberOfMonths); i++) {
16063
+ const date = now2.subtract(i, "month");
16064
+ if (date.date() === 1 && date.month() === now2.month()) {
16065
+ continue;
16066
+ }
16067
+ lastSixMonths.push({
16068
+ startDate: date.startOf("month").toDate(),
16069
+ endDate: i === 0 ? now2.toDate() : date.endOf("month").toDate()
16070
+ });
16071
+ }
16072
+ return lastSixMonths.reverse();
16073
+ }
16074
+ const nextSixMonths = [];
16075
+ for (let i = 0; i < numberOfMonths; i++) {
16076
+ const date = now2.add(i, "month");
16077
+ nextSixMonths.push({
16078
+ startDate: date.startOf("month").toDate(),
16079
+ endDate: date.endOf("month").toDate()
16080
+ });
16081
+ }
16082
+ return nextSixMonths;
16083
+ };
16084
+ const datesAreWithinMaxRange = (startDate, endDate, maxRangeLength) => {
16085
+ const daysDifference = Math.abs(dayjs(startDate).diff(dayjs(endDate), "days"));
16086
+ return daysDifference <= maxRangeLength;
16087
+ };
16088
+ const isDateRangeTheWholeMonth = ({
16089
+ startDate,
16090
+ endDate
16091
+ }) => {
16092
+ if (startDate.getMonth() !== endDate.getMonth()) {
16093
+ return false;
16094
+ }
16095
+ const start = dayjs(startDate);
16096
+ const end = dayjs(endDate);
16097
+ const startDateIsFirstDay = start.isSame(start.startOf("month"), "day");
16098
+ const endDateIsLastDay = end.isSame(end.endOf("month"), "day");
16099
+ return startDateIsFirstDay && endDateIsLastDay;
16100
+ };
16051
16101
  const explicitWidth = "250px";
16052
16102
  const HighlightedInputWrapper = styled(InputWrapper).withConfig({
16053
16103
  componentId: "sc-1m6g9rm-0"
@@ -16071,13 +16121,37 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
16071
16121
  /* @__PURE__ */ jsxRuntime.jsx(InputElement, { $hasStartContent: true, "data-testid": "datepicker-input", placeholder, readOnly: true, value: formattedSelectedDate })
16072
16122
  ] });
16073
16123
  };
16074
- const weekdayFormatter = new Intl.DateTimeFormat(locale, {
16075
- weekday: "short"
16076
- });
16077
- const headerDateFormatter = new Intl.DateTimeFormat(locale, {
16078
- month: "short",
16079
- year: "numeric"
16080
- });
16124
+ const DateRangePickerInput = ({
16125
+ isActive,
16126
+ disabled,
16127
+ id,
16128
+ placeholder,
16129
+ selectedEndDate,
16130
+ selectedStartDate
16131
+ }) => {
16132
+ const defaultId = React.useId();
16133
+ let formattedValue = /* @__PURE__ */ jsxRuntime.jsx(Text, { color: "muted", component: "span", children: placeholder ?? "" });
16134
+ if (selectedStartDate) {
16135
+ if (selectedEndDate) {
16136
+ formattedValue = /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
16137
+ selectedDateFormatter.format(selectedStartDate),
16138
+ " –",
16139
+ " ",
16140
+ selectedDateFormatter.format(selectedEndDate)
16141
+ ] });
16142
+ } else {
16143
+ formattedValue = /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
16144
+ selectedDateFormatter.format(selectedStartDate),
16145
+ " ",
16146
+ /* @__PURE__ */ jsxRuntime.jsx(Text, { color: "muted", component: "span", children: "– end date" })
16147
+ ] });
16148
+ }
16149
+ }
16150
+ return /* @__PURE__ */ jsxRuntime.jsxs(HighlightedInputWrapper, { $isActive: isActive, disabled, id: id ?? defaultId, children: [
16151
+ /* @__PURE__ */ jsxRuntime.jsx(InputStartContent, { children: /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { name: "calendar" }) }),
16152
+ /* @__PURE__ */ jsxRuntime.jsx(InputElement, { $hasStartContent: true, as: "div", "data-testid": "daterangepicker-input", children: formattedValue })
16153
+ ] });
16154
+ };
16081
16155
  const DatePickerContainer = styled(Container).withConfig({
16082
16156
  componentId: "sc-1m6g9rm-1"
16083
16157
  })(["background:", ";"], ({
@@ -16163,9 +16237,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
16163
16237
  headerDate.setFullYear(year);
16164
16238
  return /* @__PURE__ */ jsxRuntime.jsxs(DatePickerContainer, { "data-testid": "datepicker-calendar-container", isResponsive: false, fillWidth: false, orientation: "vertical", padding: "sm", ...props, children: [
16165
16239
  /* @__PURE__ */ jsxRuntime.jsxs(Container, { isResponsive: false, justifyContent: "space-between", orientation: "horizontal", children: [
16166
- /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { icon: "chevron-left", onClick: handlePreviousClick, size: "sm", type: "ghost" }),
16240
+ /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { "data-testid": "calendar-previous-month", icon: "chevron-left", onClick: handlePreviousClick, size: "sm", type: "ghost" }),
16167
16241
  /* @__PURE__ */ jsxRuntime.jsx(UnselectableTitle, { children: headerDateFormatter.format(headerDate) }),
16168
- /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { icon: "chevron-right", onClick: handleNextClick, size: "sm", type: "ghost" })
16242
+ /* @__PURE__ */ jsxRuntime.jsx(IconButton$1, { "data-testid": "calendar-next-month", icon: "chevron-right", onClick: handleNextClick, size: "sm", type: "ghost" })
16169
16243
  ] }),
16170
16244
  /* @__PURE__ */ jsxRuntime.jsxs(DateTable, { children: [
16171
16245
  /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsx("tr", { children: headers.weekDays.map(({
@@ -16178,7 +16252,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
16178
16252
  ] })
16179
16253
  ] });
16180
16254
  };
16181
- const Calendar = ({
16255
+ const Calendar$1 = ({
16182
16256
  calendarBody,
16183
16257
  closeDatepicker,
16184
16258
  futureDatesDisabled,
@@ -16237,7 +16311,275 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
16237
16311
  };
16238
16312
  return /* @__PURE__ */ jsxRuntime.jsxs(Dropdown, { onOpenChange: setIsOpen, open: isOpen, children: [
16239
16313
  /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Trigger, { disabled, children: /* @__PURE__ */ jsxRuntime.jsx(DatePickerInput, { "data-testid": "datepicker-input-container", disabled, isActive: isOpen, placeholder, selectedDate }) }),
16240
- /* @__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 }) }) })
16314
+ /* @__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 }) }) })
16315
+ ] });
16316
+ };
16317
+ const Panel = ({
16318
+ alignItems = "center",
16319
+ children,
16320
+ color,
16321
+ cursor,
16322
+ fillHeight,
16323
+ fillWidth,
16324
+ gap,
16325
+ hasBorder,
16326
+ hasShadow,
16327
+ height,
16328
+ orientation = "horizontal",
16329
+ padding,
16330
+ radii = "sm",
16331
+ width,
16332
+ ...props
16333
+ }) => /* @__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 });
16334
+ const Wrapper$2 = styled.styled.div.withConfig({
16335
+ componentId: "sc-1q78udp-0"
16336
+ })(["display:flex;flex-flow:", ";align-items:", ";width:", ";height:", ";background-color:", ";border-radius:", ";padding:", ";border:", ";box-shadow:", ";gap:", ";", ";"], ({
16337
+ $orientation = "horizontal"
16338
+ }) => $orientation === "horizontal" ? "row wrap" : "column", ({
16339
+ $alignItems = "center"
16340
+ }) => $alignItems === "center" ? "center" : `flex-${$alignItems}`, ({
16341
+ $width,
16342
+ $fillWidth
16343
+ }) => $fillWidth ? "100%" : $width, ({
16344
+ $height,
16345
+ $fillHeight
16346
+ }) => $fillHeight ? "100%" : $height, ({
16347
+ $color = "default",
16348
+ theme: theme2
16349
+ }) => theme2.click.panel.color.background[$color], ({
16350
+ $radii = "sm",
16351
+ theme: theme2
16352
+ }) => theme2.click.panel.radii[$radii], ({
16353
+ $padding = "md",
16354
+ theme: theme2
16355
+ }) => theme2.click.panel.space.y[$padding], ({
16356
+ $hasBorder,
16357
+ theme: theme2
16358
+ }) => $hasBorder ? `1px solid ${theme2.click.global.color.stroke.default}` : "none", ({
16359
+ $hasShadow,
16360
+ theme: theme2
16361
+ }) => $hasShadow ? theme2.shadow[1] : "none", ({
16362
+ $gap = "sm",
16363
+ theme: theme2
16364
+ }) => theme2.click.panel.space.gap[$gap], ({
16365
+ $cursor
16366
+ }) => $cursor && `cursor: ${$cursor}`);
16367
+ const PredefinedCalendarContainer = styled.styled(Panel).withConfig({
16368
+ componentId: "sc-1f4vu20-0"
16369
+ })(["align-items:start;background:", ";"], ({
16370
+ theme: theme2
16371
+ }) => theme2.click.panel.color.background.muted);
16372
+ const PredefinedDatesContainer = styled.styled(Container).withConfig({
16373
+ componentId: "sc-1f4vu20-1"
16374
+ })(["width:275px;"]);
16375
+ const CalendarRendererContainer = styled.styled.div.withConfig({
16376
+ componentId: "sc-1f4vu20-2"
16377
+ })(["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;"], ({
16378
+ theme: theme2
16379
+ }) => `${theme2.click.datePicker.dateOption.stroke} solid ${theme2.click.datePicker.dateOption.color.background.range}`, ({
16380
+ theme: theme2
16381
+ }) => theme2.click.datePicker.dateOption.radii.default);
16382
+ const StyledCalendarRenderer = styled.styled(CalendarRenderer).withConfig({
16383
+ componentId: "sc-1f4vu20-3"
16384
+ })(["border-radius:", ";min-height:221px;"], ({
16385
+ theme: theme2
16386
+ }) => theme2.click.datePicker.dateOption.radii.default);
16387
+ const StyledDropdownItem = styled.styled(Dropdown.Item).withConfig({
16388
+ componentId: "sc-1f4vu20-4"
16389
+ })(["min-height:24px;"]);
16390
+ const ScrollableContainer = styled.styled(Container).withConfig({
16391
+ componentId: "sc-1f4vu20-5"
16392
+ })(["max-height:210px;overflow-y:auto;"]);
16393
+ const DateRangeTableCell = styled.styled(DateTableCell).withConfig({
16394
+ componentId: "sc-1f4vu20-6"
16395
+ })(["", ""], ({
16396
+ $shouldShowRangeIndicator,
16397
+ theme: theme2
16398
+ }) => $shouldShowRangeIndicator && `
16399
+ background: ${theme2.click.datePicker.dateOption.color.background.range};
16400
+ border: ${theme2.click.datePicker.dateOption.stroke} solid ${theme2.click.datePicker.dateOption.color.background.range};
16401
+ border-radius: 0;
16402
+ `);
16403
+ const Calendar = ({
16404
+ calendarBody,
16405
+ closeDatepicker,
16406
+ futureDatesDisabled,
16407
+ futureStartDatesDisabled,
16408
+ maxRangeLength,
16409
+ setSelectedDate,
16410
+ startDate,
16411
+ endDate
16412
+ }) => {
16413
+ const [hoveredDate, setHoveredDate] = React.useState();
16414
+ const handleMouseOut = () => {
16415
+ setHoveredDate(void 0);
16416
+ };
16417
+ return calendarBody.value.map(({
16418
+ key: weekKey,
16419
+ value: week
16420
+ }) => {
16421
+ return /* @__PURE__ */ jsxRuntime.jsx("tr", { children: week.map(({
16422
+ date,
16423
+ isCurrentMonth,
16424
+ key: dayKey,
16425
+ value: fullDate
16426
+ }) => {
16427
+ const isSelected = startDate && isSameDate(startDate, fullDate) || endDate && isSameDate(endDate, fullDate);
16428
+ const today = /* @__PURE__ */ new Date();
16429
+ const isCurrentDate = isSameDate(today, fullDate);
16430
+ const isBetweenStartAndEndDates = Boolean(startDate && endDate && fullDate > startDate && fullDate < endDate);
16431
+ let isDisabled = false;
16432
+ if (futureDatesDisabled && fullDate > today) {
16433
+ isDisabled = true;
16434
+ }
16435
+ if (futureStartDatesDisabled && !startDate && fullDate > today) {
16436
+ isDisabled = true;
16437
+ }
16438
+ if (maxRangeLength > 1 && startDate && !datesAreWithinMaxRange(startDate, fullDate, maxRangeLength)) {
16439
+ isDisabled = true;
16440
+ }
16441
+ const shouldShowRangeIndicator = !endDate && Boolean(startDate && hoveredDate && fullDate > startDate && fullDate < hoveredDate);
16442
+ const handleMouseEnter = () => {
16443
+ setHoveredDate(fullDate);
16444
+ };
16445
+ const handleClick = () => {
16446
+ if (isDisabled) {
16447
+ return false;
16448
+ }
16449
+ setSelectedDate(fullDate);
16450
+ if (startDate && endDate) {
16451
+ return;
16452
+ }
16453
+ if (startDate && fullDate < startDate) {
16454
+ return;
16455
+ }
16456
+ if (startDate && !isSameDate(fullDate, startDate)) {
16457
+ closeDatepicker();
16458
+ return;
16459
+ }
16460
+ };
16461
+ 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);
16462
+ }) }, weekKey);
16463
+ });
16464
+ };
16465
+ const locale = "en-US";
16466
+ const monthFormatter = new Intl.DateTimeFormat(locale, {
16467
+ month: "short",
16468
+ year: "numeric"
16469
+ });
16470
+ const PredefinedDates = ({
16471
+ onSelectDateRange,
16472
+ predefinedDatesList,
16473
+ selectedEndDate,
16474
+ selectedStartDate,
16475
+ setEndDate,
16476
+ setStartDate,
16477
+ shouldShowCustomRange,
16478
+ showCustomDateRange
16479
+ }) => {
16480
+ const handleCustomTimePeriodClick = (event) => {
16481
+ event.preventDefault();
16482
+ showCustomDateRange(!shouldShowCustomRange);
16483
+ };
16484
+ return /* @__PURE__ */ jsxRuntime.jsxs(PredefinedDatesContainer, { "data-testid": "predefined-dates-list", isResponsive: false, orientation: "vertical", children: [
16485
+ /* @__PURE__ */ jsxRuntime.jsx(ScrollableContainer, { orientation: "vertical", children: predefinedDatesList.map(({
16486
+ startDate,
16487
+ endDate
16488
+ }) => {
16489
+ const handleItemClick = () => {
16490
+ setStartDate(startDate);
16491
+ setEndDate(endDate);
16492
+ onSelectDateRange(startDate, endDate);
16493
+ };
16494
+ const rangeIsSelected = selectedEndDate && isSameDate(selectedEndDate, endDate) && selectedStartDate && isSameDate(selectedStartDate, startDate);
16495
+ const isWholeMonth = isDateRangeTheWholeMonth({
16496
+ startDate,
16497
+ endDate
16498
+ });
16499
+ const formattedText = isWholeMonth ? monthFormatter.format(startDate) : `${selectedDateFormatter.format(startDate)} - ${selectedDateFormatter.format(endDate)}`.trim();
16500
+ 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: [
16501
+ formattedText,
16502
+ rangeIsSelected && /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { name: "check" })
16503
+ ] }) }, startDate.toISOString());
16504
+ }) }),
16505
+ /* @__PURE__ */ jsxRuntime.jsx(StyledDropdownItem, { onClick: handleCustomTimePeriodClick, children: /* @__PURE__ */ jsxRuntime.jsxs(Container, { justifyContent: "space-between", orientation: "horizontal", children: [
16506
+ "Custom time period ",
16507
+ /* @__PURE__ */ jsxRuntime.jsx(SvgImage, { name: "chevron-right" })
16508
+ ] }) })
16509
+ ] });
16510
+ };
16511
+ const DateRangePicker = ({
16512
+ endDate,
16513
+ startDate,
16514
+ disabled = false,
16515
+ futureDatesDisabled = false,
16516
+ futureStartDatesDisabled = false,
16517
+ maxRangeLength = -1,
16518
+ onSelectDateRange,
16519
+ placeholder = "start date – end date",
16520
+ predefinedDatesList
16521
+ }) => {
16522
+ const [isOpen, setIsOpen] = React.useState(false);
16523
+ const [selectedStartDate, setSelectedStartDate] = React.useState();
16524
+ const [selectedEndDate, setSelectedEndDate] = React.useState();
16525
+ const [shouldShowCustomRange, setShouldShowCustomRange] = React.useState(false);
16526
+ const calendarOptions = {};
16527
+ if (selectedStartDate) {
16528
+ calendarOptions.defaultDate = selectedStartDate;
16529
+ }
16530
+ React.useEffect(() => {
16531
+ if (startDate) {
16532
+ setSelectedStartDate(startDate);
16533
+ }
16534
+ }, [startDate]);
16535
+ React.useEffect(() => {
16536
+ if (endDate) {
16537
+ setSelectedEndDate(endDate);
16538
+ }
16539
+ }, [endDate]);
16540
+ const closeDatePicker = React.useCallback(() => {
16541
+ setIsOpen(false);
16542
+ setShouldShowCustomRange(false);
16543
+ }, []);
16544
+ const handleOpenChange = (isOpen2) => {
16545
+ setIsOpen(isOpen2);
16546
+ if (!isOpen2) {
16547
+ setShouldShowCustomRange(false);
16548
+ }
16549
+ };
16550
+ const handleSelectDate = React.useCallback((selectedDate) => {
16551
+ if (selectedStartDate && selectedEndDate) {
16552
+ if (futureStartDatesDisabled && selectedDate > /* @__PURE__ */ new Date()) {
16553
+ setSelectedEndDate(void 0);
16554
+ return;
16555
+ }
16556
+ setSelectedStartDate(selectedDate);
16557
+ setSelectedEndDate(void 0);
16558
+ return;
16559
+ }
16560
+ if (selectedStartDate) {
16561
+ if (isSameDate(selectedStartDate, selectedDate)) {
16562
+ setSelectedStartDate(void 0);
16563
+ return;
16564
+ }
16565
+ if (selectedDate < selectedStartDate) {
16566
+ setSelectedStartDate(selectedDate);
16567
+ return;
16568
+ }
16569
+ setSelectedEndDate(selectedDate);
16570
+ onSelectDateRange(selectedStartDate, selectedDate);
16571
+ setShouldShowCustomRange(false);
16572
+ return;
16573
+ }
16574
+ setSelectedStartDate(selectedDate);
16575
+ }, [futureStartDatesDisabled, onSelectDateRange, selectedEndDate, selectedStartDate]);
16576
+ const shouldShowPredefinedDates = predefinedDatesList !== void 0 && predefinedDatesList.length > 0;
16577
+ return /* @__PURE__ */ jsxRuntime.jsxs(Dropdown, { onOpenChange: handleOpenChange, open: isOpen, children: [
16578
+ /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Trigger, { disabled, children: /* @__PURE__ */ jsxRuntime.jsx(DateRangePickerInput, { "data-testid": "datepicker-input-container", disabled, isActive: isOpen, placeholder, selectedEndDate, selectedStartDate }) }),
16579
+ /* @__PURE__ */ jsxRuntime.jsx(Dropdown.Content, { align: "start", children: shouldShowPredefinedDates ? /* @__PURE__ */ jsxRuntime.jsxs(PredefinedCalendarContainer, { gap: "none", orientation: "horizontal", padding: "none", children: [
16580
+ /* @__PURE__ */ jsxRuntime.jsx(PredefinedDates, { onSelectDateRange, predefinedDatesList, selectedEndDate, selectedStartDate, setEndDate: setSelectedEndDate, setStartDate: setSelectedStartDate, shouldShowCustomRange, showCustomDateRange: setShouldShowCustomRange }),
16581
+ 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 }) }) })
16582
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(CalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsxRuntime.jsx(Calendar, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, futureStartDatesDisabled, maxRangeLength, setSelectedDate: handleSelectDate, startDate: selectedStartDate, endDate: selectedEndDate }) }) })
16241
16583
  ] });
16242
16584
  };
16243
16585
  const $5d3850c4d0b4e6c7$var$DIALOG_NAME = "Dialog";
@@ -34363,56 +34705,6 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
34363
34705
  ] })
34364
34706
  ] });
34365
34707
  };
34366
- const Panel = ({
34367
- alignItems = "center",
34368
- children,
34369
- color,
34370
- cursor,
34371
- fillHeight,
34372
- fillWidth,
34373
- gap,
34374
- hasBorder,
34375
- hasShadow,
34376
- height,
34377
- orientation = "horizontal",
34378
- padding,
34379
- radii = "sm",
34380
- width,
34381
- ...props
34382
- }) => /* @__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 });
34383
- const Wrapper$2 = styled.styled.div.withConfig({
34384
- componentId: "sc-1q78udp-0"
34385
- })(["display:flex;flex-flow:", ";align-items:", ";width:", ";height:", ";background-color:", ";border-radius:", ";padding:", ";border:", ";box-shadow:", ";gap:", ";", ";"], ({
34386
- $orientation = "horizontal"
34387
- }) => $orientation === "horizontal" ? "row wrap" : "column", ({
34388
- $alignItems = "center"
34389
- }) => $alignItems === "center" ? "center" : `flex-${$alignItems}`, ({
34390
- $width,
34391
- $fillWidth
34392
- }) => $fillWidth ? "100%" : $width, ({
34393
- $height,
34394
- $fillHeight
34395
- }) => $fillHeight ? "100%" : $height, ({
34396
- $color = "default",
34397
- theme: theme2
34398
- }) => theme2.click.panel.color.background[$color], ({
34399
- $radii = "sm",
34400
- theme: theme2
34401
- }) => theme2.click.panel.radii[$radii], ({
34402
- $padding = "md",
34403
- theme: theme2
34404
- }) => theme2.click.panel.space.y[$padding], ({
34405
- $hasBorder,
34406
- theme: theme2
34407
- }) => $hasBorder ? `1px solid ${theme2.click.global.color.stroke.default}` : "none", ({
34408
- $hasShadow,
34409
- theme: theme2
34410
- }) => $hasShadow ? theme2.shadow[1] : "none", ({
34411
- $gap = "sm",
34412
- theme: theme2
34413
- }) => theme2.click.panel.space.gap[$gap], ({
34414
- $cursor
34415
- }) => $cursor && `cursor: ${$cursor}`);
34416
34708
  const ProgressContainer = styled.styled.div.withConfig({
34417
34709
  componentId: "sc-16gr3cg-0"
34418
34710
  })(["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;", ";"], ({
@@ -51436,6 +51728,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
51436
51728
  exports2.DangerAlert = DangerAlert;
51437
51729
  exports2.DateDetails = DateDetails;
51438
51730
  exports2.DatePicker = DatePicker;
51731
+ exports2.DateRangePicker = DateRangePicker;
51439
51732
  exports2.Dialog = Dialog;
51440
51733
  exports2.Dropdown = Dropdown;
51441
51734
  exports2.EllipsisContent = EllipsisContent;
@@ -51491,6 +51784,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
51491
51784
  exports2.VerticalStepper = VerticalStepper;
51492
51785
  exports2.WarningAlert = WarningAlert;
51493
51786
  exports2.createToast = createToast;
51787
+ exports2.getPredefinedMonthsForDateRangePicker = getPredefinedMonthsForDateRangePicker;
51494
51788
  exports2.linkStyles = linkStyles;
51495
51789
  exports2.themes = themes;
51496
51790
  exports2.useCUITheme = useCUITheme;