@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.
package/README.md CHANGED
@@ -2,16 +2,17 @@
2
2
 
3
3
  The home of the ClickHouse design system and component library. Click UI is in very early development and subject to change, we do not recommend using it for production purposes.
4
4
 
5
- ### Using Click UI in an external app
5
+ ## Using Click UI in an external app
6
6
 
7
7
  Click UI has been tested in NextJS, Gatsby, and Vite. If you run into problems using it in your app, please create an issue and our team will try to answer.
8
+
8
9
  1. Navigate to your app's route and run
9
10
  `npm i @clickhouse/click-ui`
10
11
  or
11
12
  `yarn add @clickhouse/click-ui`
12
13
  2. Make sure to wrap your application in the Click UI `ClickUIProvider`, without doing this, you may run into issues with styled-components. Once thats done, you'll be able to import the individual components that you want to use on each page. Here's an example an `App.tsx` in NextJS.
13
14
 
14
- ```ts
15
+ ```typescript
15
16
  import { ClickUIProvider, Text, ThemeName, Title, Switch } from '@clickhouse/click-ui'
16
17
 
17
18
  function App() {
@@ -34,7 +35,7 @@ function App() {
34
35
  export default App
35
36
  ```
36
37
 
37
- ### To develop this library locally 🚀
38
+ ## To develop this library locally 🚀
38
39
 
39
40
  1. Clone this repo, cd into the `click-ui` directory
40
41
  2. To install dependencies, run `npm i`
@@ -43,3 +44,9 @@ export default App
43
44
  5. To run Storybook locally, run `npm run storybook` and navigate to https://localhost:6006
44
45
 
45
46
  Enjoy!
47
+
48
+ ## Releases and Versions
49
+
50
+ New versions and release notes are available at [GitHub Releases](https://github.com/ClickHouse/click-ui/releases).
51
+
52
+ To create a new release and publish a new version, follow the instructions in [publish.md](./docs/publish.md).
@@ -1286,7 +1286,7 @@ const Building = (props) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.
1286
1286
  /* @__PURE__ */ 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" })
1287
1287
  ] });
1288
1288
  const BurgerMenu = (props) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", ...props, children: /* @__PURE__ */ 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" }) });
1289
- const Calendar$1 = (props) => /* @__PURE__ */ jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
1289
+ const Calendar$2 = (props) => /* @__PURE__ */ jsxs("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, children: [
1290
1290
  /* @__PURE__ */ 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" }),
1291
1291
  /* @__PURE__ */ jsx("path", { d: "M21.0036 7.99826H2.99609", stroke: "#161517", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
1292
1292
  /* @__PURE__ */ 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" }),
@@ -1978,7 +1978,7 @@ const ICONS_MAP = {
1978
1978
  briefcase: Briefcase,
1979
1979
  building: Building,
1980
1980
  "burger-menu": BurgerMenu,
1981
- calendar: Calendar$1,
1981
+ calendar: Calendar$2,
1982
1982
  "calendar-with-time": CalendarWithTime,
1983
1983
  cards: Cards,
1984
1984
  "cell-tower": CellTower,
@@ -17195,12 +17195,62 @@ const InputEndContent = pt.div.withConfig({
17195
17195
  align-self: stretch;
17196
17196
  align-items: center;
17197
17197
  `);
17198
- const locale = "en-US";
17199
- const selectedDateFormatter = new Intl.DateTimeFormat(locale, {
17198
+ const locale$1 = "en-US";
17199
+ const selectedDateFormatter = new Intl.DateTimeFormat(locale$1, {
17200
17200
  day: "2-digit",
17201
17201
  month: "short",
17202
17202
  year: "numeric"
17203
17203
  });
17204
+ const weekdayFormatter = new Intl.DateTimeFormat(locale$1, {
17205
+ weekday: "short"
17206
+ });
17207
+ const headerDateFormatter = new Intl.DateTimeFormat(locale$1, {
17208
+ month: "short",
17209
+ year: "numeric"
17210
+ });
17211
+ const getPredefinedMonthsForDateRangePicker = (numberOfMonths) => {
17212
+ const now2 = dayjs();
17213
+ if (numberOfMonths < 0) {
17214
+ const lastSixMonths = [];
17215
+ for (let i = 0; i < Math.abs(numberOfMonths); i++) {
17216
+ const date = now2.subtract(i, "month");
17217
+ if (date.date() === 1 && date.month() === now2.month()) {
17218
+ continue;
17219
+ }
17220
+ lastSixMonths.push({
17221
+ startDate: date.startOf("month").toDate(),
17222
+ endDate: i === 0 ? now2.toDate() : date.endOf("month").toDate()
17223
+ });
17224
+ }
17225
+ return lastSixMonths.reverse();
17226
+ }
17227
+ const nextSixMonths = [];
17228
+ for (let i = 0; i < numberOfMonths; i++) {
17229
+ const date = now2.add(i, "month");
17230
+ nextSixMonths.push({
17231
+ startDate: date.startOf("month").toDate(),
17232
+ endDate: date.endOf("month").toDate()
17233
+ });
17234
+ }
17235
+ return nextSixMonths;
17236
+ };
17237
+ const datesAreWithinMaxRange = (startDate, endDate, maxRangeLength) => {
17238
+ const daysDifference = Math.abs(dayjs(startDate).diff(dayjs(endDate), "days"));
17239
+ return daysDifference <= maxRangeLength;
17240
+ };
17241
+ const isDateRangeTheWholeMonth = ({
17242
+ startDate,
17243
+ endDate
17244
+ }) => {
17245
+ if (startDate.getMonth() !== endDate.getMonth()) {
17246
+ return false;
17247
+ }
17248
+ const start = dayjs(startDate);
17249
+ const end = dayjs(endDate);
17250
+ const startDateIsFirstDay = start.isSame(start.startOf("month"), "day");
17251
+ const endDateIsLastDay = end.isSame(end.endOf("month"), "day");
17252
+ return startDateIsFirstDay && endDateIsLastDay;
17253
+ };
17204
17254
  const explicitWidth = "250px";
17205
17255
  const HighlightedInputWrapper = pt(InputWrapper).withConfig({
17206
17256
  componentId: "sc-1m6g9rm-0"
@@ -17224,13 +17274,37 @@ const DatePickerInput = ({
17224
17274
  /* @__PURE__ */ jsx(InputElement, { $hasStartContent: true, "data-testid": "datepicker-input", placeholder, readOnly: true, value: formattedSelectedDate })
17225
17275
  ] });
17226
17276
  };
17227
- const weekdayFormatter = new Intl.DateTimeFormat(locale, {
17228
- weekday: "short"
17229
- });
17230
- const headerDateFormatter = new Intl.DateTimeFormat(locale, {
17231
- month: "short",
17232
- year: "numeric"
17233
- });
17277
+ const DateRangePickerInput = ({
17278
+ isActive,
17279
+ disabled,
17280
+ id,
17281
+ placeholder,
17282
+ selectedEndDate,
17283
+ selectedStartDate
17284
+ }) => {
17285
+ const defaultId = useId();
17286
+ let formattedValue = /* @__PURE__ */ jsx(Text, { color: "muted", component: "span", children: placeholder ?? "" });
17287
+ if (selectedStartDate) {
17288
+ if (selectedEndDate) {
17289
+ formattedValue = /* @__PURE__ */ jsxs("span", { children: [
17290
+ selectedDateFormatter.format(selectedStartDate),
17291
+ " –",
17292
+ " ",
17293
+ selectedDateFormatter.format(selectedEndDate)
17294
+ ] });
17295
+ } else {
17296
+ formattedValue = /* @__PURE__ */ jsxs("span", { children: [
17297
+ selectedDateFormatter.format(selectedStartDate),
17298
+ " ",
17299
+ /* @__PURE__ */ jsx(Text, { color: "muted", component: "span", children: "– end date" })
17300
+ ] });
17301
+ }
17302
+ }
17303
+ return /* @__PURE__ */ jsxs(HighlightedInputWrapper, { $isActive: isActive, disabled, id: id ?? defaultId, children: [
17304
+ /* @__PURE__ */ jsx(InputStartContent, { children: /* @__PURE__ */ jsx(SvgImage, { name: "calendar" }) }),
17305
+ /* @__PURE__ */ jsx(InputElement, { $hasStartContent: true, as: "div", "data-testid": "daterangepicker-input", children: formattedValue })
17306
+ ] });
17307
+ };
17234
17308
  const DatePickerContainer = pt(Container).withConfig({
17235
17309
  componentId: "sc-1m6g9rm-1"
17236
17310
  })(["background:", ";"], ({
@@ -17316,9 +17390,9 @@ const CalendarRenderer = ({
17316
17390
  headerDate.setFullYear(year);
17317
17391
  return /* @__PURE__ */ jsxs(DatePickerContainer, { "data-testid": "datepicker-calendar-container", isResponsive: false, fillWidth: false, orientation: "vertical", padding: "sm", ...props, children: [
17318
17392
  /* @__PURE__ */ jsxs(Container, { isResponsive: false, justifyContent: "space-between", orientation: "horizontal", children: [
17319
- /* @__PURE__ */ jsx(IconButton$1, { icon: "chevron-left", onClick: handlePreviousClick, size: "sm", type: "ghost" }),
17393
+ /* @__PURE__ */ jsx(IconButton$1, { "data-testid": "calendar-previous-month", icon: "chevron-left", onClick: handlePreviousClick, size: "sm", type: "ghost" }),
17320
17394
  /* @__PURE__ */ jsx(UnselectableTitle, { children: headerDateFormatter.format(headerDate) }),
17321
- /* @__PURE__ */ jsx(IconButton$1, { icon: "chevron-right", onClick: handleNextClick, size: "sm", type: "ghost" })
17395
+ /* @__PURE__ */ jsx(IconButton$1, { "data-testid": "calendar-next-month", icon: "chevron-right", onClick: handleNextClick, size: "sm", type: "ghost" })
17322
17396
  ] }),
17323
17397
  /* @__PURE__ */ jsxs(DateTable, { children: [
17324
17398
  /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: headers.weekDays.map(({
@@ -17331,7 +17405,7 @@ const CalendarRenderer = ({
17331
17405
  ] })
17332
17406
  ] });
17333
17407
  };
17334
- const Calendar = ({
17408
+ const Calendar$1 = ({
17335
17409
  calendarBody,
17336
17410
  closeDatepicker,
17337
17411
  futureDatesDisabled,
@@ -17390,7 +17464,275 @@ const DatePicker = ({
17390
17464
  };
17391
17465
  return /* @__PURE__ */ jsxs(Dropdown, { onOpenChange: setIsOpen, open: isOpen, children: [
17392
17466
  /* @__PURE__ */ jsx(Dropdown.Trigger, { disabled, children: /* @__PURE__ */ jsx(DatePickerInput, { "data-testid": "datepicker-input-container", disabled, isActive: isOpen, placeholder, selectedDate }) }),
17393
- /* @__PURE__ */ jsx(Dropdown.Content, { align: "start", children: /* @__PURE__ */ jsx(CalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsx(Calendar, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, selectedDate, setSelectedDate: handleSelectDate }) }) })
17467
+ /* @__PURE__ */ jsx(Dropdown.Content, { align: "start", children: /* @__PURE__ */ jsx(CalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsx(Calendar$1, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, selectedDate, setSelectedDate: handleSelectDate }) }) })
17468
+ ] });
17469
+ };
17470
+ const Panel = ({
17471
+ alignItems = "center",
17472
+ children,
17473
+ color,
17474
+ cursor,
17475
+ fillHeight,
17476
+ fillWidth,
17477
+ gap,
17478
+ hasBorder,
17479
+ hasShadow,
17480
+ height,
17481
+ orientation = "horizontal",
17482
+ padding,
17483
+ radii = "sm",
17484
+ width,
17485
+ ...props
17486
+ }) => /* @__PURE__ */ 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 });
17487
+ const Wrapper$2 = pt.div.withConfig({
17488
+ componentId: "sc-1q78udp-0"
17489
+ })(["display:flex;flex-flow:", ";align-items:", ";width:", ";height:", ";background-color:", ";border-radius:", ";padding:", ";border:", ";box-shadow:", ";gap:", ";", ";"], ({
17490
+ $orientation = "horizontal"
17491
+ }) => $orientation === "horizontal" ? "row wrap" : "column", ({
17492
+ $alignItems = "center"
17493
+ }) => $alignItems === "center" ? "center" : `flex-${$alignItems}`, ({
17494
+ $width,
17495
+ $fillWidth
17496
+ }) => $fillWidth ? "100%" : $width, ({
17497
+ $height,
17498
+ $fillHeight
17499
+ }) => $fillHeight ? "100%" : $height, ({
17500
+ $color = "default",
17501
+ theme: theme2
17502
+ }) => theme2.click.panel.color.background[$color], ({
17503
+ $radii = "sm",
17504
+ theme: theme2
17505
+ }) => theme2.click.panel.radii[$radii], ({
17506
+ $padding = "md",
17507
+ theme: theme2
17508
+ }) => theme2.click.panel.space.y[$padding], ({
17509
+ $hasBorder,
17510
+ theme: theme2
17511
+ }) => $hasBorder ? `1px solid ${theme2.click.global.color.stroke.default}` : "none", ({
17512
+ $hasShadow,
17513
+ theme: theme2
17514
+ }) => $hasShadow ? theme2.shadow[1] : "none", ({
17515
+ $gap = "sm",
17516
+ theme: theme2
17517
+ }) => theme2.click.panel.space.gap[$gap], ({
17518
+ $cursor
17519
+ }) => $cursor && `cursor: ${$cursor}`);
17520
+ const PredefinedCalendarContainer = pt(Panel).withConfig({
17521
+ componentId: "sc-1f4vu20-0"
17522
+ })(["align-items:start;background:", ";"], ({
17523
+ theme: theme2
17524
+ }) => theme2.click.panel.color.background.muted);
17525
+ const PredefinedDatesContainer = pt(Container).withConfig({
17526
+ componentId: "sc-1f4vu20-1"
17527
+ })(["width:275px;"]);
17528
+ const CalendarRendererContainer = pt.div.withConfig({
17529
+ componentId: "sc-1f4vu20-2"
17530
+ })(["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;"], ({
17531
+ theme: theme2
17532
+ }) => `${theme2.click.datePicker.dateOption.stroke} solid ${theme2.click.datePicker.dateOption.color.background.range}`, ({
17533
+ theme: theme2
17534
+ }) => theme2.click.datePicker.dateOption.radii.default);
17535
+ const StyledCalendarRenderer = pt(CalendarRenderer).withConfig({
17536
+ componentId: "sc-1f4vu20-3"
17537
+ })(["border-radius:", ";min-height:221px;"], ({
17538
+ theme: theme2
17539
+ }) => theme2.click.datePicker.dateOption.radii.default);
17540
+ const StyledDropdownItem = pt(Dropdown.Item).withConfig({
17541
+ componentId: "sc-1f4vu20-4"
17542
+ })(["min-height:24px;"]);
17543
+ const ScrollableContainer = pt(Container).withConfig({
17544
+ componentId: "sc-1f4vu20-5"
17545
+ })(["max-height:210px;overflow-y:auto;"]);
17546
+ const DateRangeTableCell = pt(DateTableCell).withConfig({
17547
+ componentId: "sc-1f4vu20-6"
17548
+ })(["", ""], ({
17549
+ $shouldShowRangeIndicator,
17550
+ theme: theme2
17551
+ }) => $shouldShowRangeIndicator && `
17552
+ background: ${theme2.click.datePicker.dateOption.color.background.range};
17553
+ border: ${theme2.click.datePicker.dateOption.stroke} solid ${theme2.click.datePicker.dateOption.color.background.range};
17554
+ border-radius: 0;
17555
+ `);
17556
+ const Calendar = ({
17557
+ calendarBody,
17558
+ closeDatepicker,
17559
+ futureDatesDisabled,
17560
+ futureStartDatesDisabled,
17561
+ maxRangeLength,
17562
+ setSelectedDate,
17563
+ startDate,
17564
+ endDate
17565
+ }) => {
17566
+ const [hoveredDate, setHoveredDate] = useState();
17567
+ const handleMouseOut = () => {
17568
+ setHoveredDate(void 0);
17569
+ };
17570
+ return calendarBody.value.map(({
17571
+ key: weekKey,
17572
+ value: week
17573
+ }) => {
17574
+ return /* @__PURE__ */ jsx("tr", { children: week.map(({
17575
+ date,
17576
+ isCurrentMonth,
17577
+ key: dayKey,
17578
+ value: fullDate
17579
+ }) => {
17580
+ const isSelected = startDate && isSameDate(startDate, fullDate) || endDate && isSameDate(endDate, fullDate);
17581
+ const today = /* @__PURE__ */ new Date();
17582
+ const isCurrentDate = isSameDate(today, fullDate);
17583
+ const isBetweenStartAndEndDates = Boolean(startDate && endDate && fullDate > startDate && fullDate < endDate);
17584
+ let isDisabled = false;
17585
+ if (futureDatesDisabled && fullDate > today) {
17586
+ isDisabled = true;
17587
+ }
17588
+ if (futureStartDatesDisabled && !startDate && fullDate > today) {
17589
+ isDisabled = true;
17590
+ }
17591
+ if (maxRangeLength > 1 && startDate && !datesAreWithinMaxRange(startDate, fullDate, maxRangeLength)) {
17592
+ isDisabled = true;
17593
+ }
17594
+ const shouldShowRangeIndicator = !endDate && Boolean(startDate && hoveredDate && fullDate > startDate && fullDate < hoveredDate);
17595
+ const handleMouseEnter = () => {
17596
+ setHoveredDate(fullDate);
17597
+ };
17598
+ const handleClick = () => {
17599
+ if (isDisabled) {
17600
+ return false;
17601
+ }
17602
+ setSelectedDate(fullDate);
17603
+ if (startDate && endDate) {
17604
+ return;
17605
+ }
17606
+ if (startDate && fullDate < startDate) {
17607
+ return;
17608
+ }
17609
+ if (startDate && !isSameDate(fullDate, startDate)) {
17610
+ closeDatepicker();
17611
+ return;
17612
+ }
17613
+ };
17614
+ return /* @__PURE__ */ jsx(DateRangeTableCell, { $shouldShowRangeIndicator: !isSelected && (shouldShowRangeIndicator || isBetweenStartAndEndDates), $isCurrentMonth: isCurrentMonth, $isDisabled: isDisabled, $isSelected: isSelected, $isToday: isCurrentDate, onClick: handleClick, onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseOut, children: date }, dayKey);
17615
+ }) }, weekKey);
17616
+ });
17617
+ };
17618
+ const locale = "en-US";
17619
+ const monthFormatter = new Intl.DateTimeFormat(locale, {
17620
+ month: "short",
17621
+ year: "numeric"
17622
+ });
17623
+ const PredefinedDates = ({
17624
+ onSelectDateRange,
17625
+ predefinedDatesList,
17626
+ selectedEndDate,
17627
+ selectedStartDate,
17628
+ setEndDate,
17629
+ setStartDate,
17630
+ shouldShowCustomRange,
17631
+ showCustomDateRange
17632
+ }) => {
17633
+ const handleCustomTimePeriodClick = (event) => {
17634
+ event.preventDefault();
17635
+ showCustomDateRange(!shouldShowCustomRange);
17636
+ };
17637
+ return /* @__PURE__ */ jsxs(PredefinedDatesContainer, { "data-testid": "predefined-dates-list", isResponsive: false, orientation: "vertical", children: [
17638
+ /* @__PURE__ */ jsx(ScrollableContainer, { orientation: "vertical", children: predefinedDatesList.map(({
17639
+ startDate,
17640
+ endDate
17641
+ }) => {
17642
+ const handleItemClick = () => {
17643
+ setStartDate(startDate);
17644
+ setEndDate(endDate);
17645
+ onSelectDateRange(startDate, endDate);
17646
+ };
17647
+ const rangeIsSelected = selectedEndDate && isSameDate(selectedEndDate, endDate) && selectedStartDate && isSameDate(selectedStartDate, startDate);
17648
+ const isWholeMonth = isDateRangeTheWholeMonth({
17649
+ startDate,
17650
+ endDate
17651
+ });
17652
+ const formattedText = isWholeMonth ? monthFormatter.format(startDate) : `${selectedDateFormatter.format(startDate)} - ${selectedDateFormatter.format(endDate)}`.trim();
17653
+ return /* @__PURE__ */ jsx(StyledDropdownItem, { "data-testid": `predefined-date-${startDate.getTime()}`, onClick: handleItemClick, children: /* @__PURE__ */ jsxs(Container, { "data-selected": rangeIsSelected, "data-testid": formattedText, justifyContent: "space-between", orientation: "horizontal", children: [
17654
+ formattedText,
17655
+ rangeIsSelected && /* @__PURE__ */ jsx(SvgImage, { name: "check" })
17656
+ ] }) }, startDate.toISOString());
17657
+ }) }),
17658
+ /* @__PURE__ */ jsx(StyledDropdownItem, { onClick: handleCustomTimePeriodClick, children: /* @__PURE__ */ jsxs(Container, { justifyContent: "space-between", orientation: "horizontal", children: [
17659
+ "Custom time period ",
17660
+ /* @__PURE__ */ jsx(SvgImage, { name: "chevron-right" })
17661
+ ] }) })
17662
+ ] });
17663
+ };
17664
+ const DateRangePicker = ({
17665
+ endDate,
17666
+ startDate,
17667
+ disabled = false,
17668
+ futureDatesDisabled = false,
17669
+ futureStartDatesDisabled = false,
17670
+ maxRangeLength = -1,
17671
+ onSelectDateRange,
17672
+ placeholder = "start date – end date",
17673
+ predefinedDatesList
17674
+ }) => {
17675
+ const [isOpen, setIsOpen] = useState(false);
17676
+ const [selectedStartDate, setSelectedStartDate] = useState();
17677
+ const [selectedEndDate, setSelectedEndDate] = useState();
17678
+ const [shouldShowCustomRange, setShouldShowCustomRange] = useState(false);
17679
+ const calendarOptions = {};
17680
+ if (selectedStartDate) {
17681
+ calendarOptions.defaultDate = selectedStartDate;
17682
+ }
17683
+ useEffect(() => {
17684
+ if (startDate) {
17685
+ setSelectedStartDate(startDate);
17686
+ }
17687
+ }, [startDate]);
17688
+ useEffect(() => {
17689
+ if (endDate) {
17690
+ setSelectedEndDate(endDate);
17691
+ }
17692
+ }, [endDate]);
17693
+ const closeDatePicker = useCallback(() => {
17694
+ setIsOpen(false);
17695
+ setShouldShowCustomRange(false);
17696
+ }, []);
17697
+ const handleOpenChange = (isOpen2) => {
17698
+ setIsOpen(isOpen2);
17699
+ if (!isOpen2) {
17700
+ setShouldShowCustomRange(false);
17701
+ }
17702
+ };
17703
+ const handleSelectDate = useCallback((selectedDate) => {
17704
+ if (selectedStartDate && selectedEndDate) {
17705
+ if (futureStartDatesDisabled && selectedDate > /* @__PURE__ */ new Date()) {
17706
+ setSelectedEndDate(void 0);
17707
+ return;
17708
+ }
17709
+ setSelectedStartDate(selectedDate);
17710
+ setSelectedEndDate(void 0);
17711
+ return;
17712
+ }
17713
+ if (selectedStartDate) {
17714
+ if (isSameDate(selectedStartDate, selectedDate)) {
17715
+ setSelectedStartDate(void 0);
17716
+ return;
17717
+ }
17718
+ if (selectedDate < selectedStartDate) {
17719
+ setSelectedStartDate(selectedDate);
17720
+ return;
17721
+ }
17722
+ setSelectedEndDate(selectedDate);
17723
+ onSelectDateRange(selectedStartDate, selectedDate);
17724
+ setShouldShowCustomRange(false);
17725
+ return;
17726
+ }
17727
+ setSelectedStartDate(selectedDate);
17728
+ }, [futureStartDatesDisabled, onSelectDateRange, selectedEndDate, selectedStartDate]);
17729
+ const shouldShowPredefinedDates = predefinedDatesList !== void 0 && predefinedDatesList.length > 0;
17730
+ return /* @__PURE__ */ jsxs(Dropdown, { onOpenChange: handleOpenChange, open: isOpen, children: [
17731
+ /* @__PURE__ */ jsx(Dropdown.Trigger, { disabled, children: /* @__PURE__ */ jsx(DateRangePickerInput, { "data-testid": "datepicker-input-container", disabled, isActive: isOpen, placeholder, selectedEndDate, selectedStartDate }) }),
17732
+ /* @__PURE__ */ jsx(Dropdown.Content, { align: "start", children: shouldShowPredefinedDates ? /* @__PURE__ */ jsxs(PredefinedCalendarContainer, { gap: "none", orientation: "horizontal", padding: "none", children: [
17733
+ /* @__PURE__ */ jsx(PredefinedDates, { onSelectDateRange, predefinedDatesList, selectedEndDate, selectedStartDate, setEndDate: setSelectedEndDate, setStartDate: setSelectedStartDate, shouldShowCustomRange, showCustomDateRange: setShouldShowCustomRange }),
17734
+ shouldShowCustomRange && /* @__PURE__ */ jsx(CalendarRendererContainer, { children: /* @__PURE__ */ jsx(StyledCalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsx(Calendar, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, futureStartDatesDisabled, maxRangeLength, setSelectedDate: handleSelectDate, startDate: selectedStartDate, endDate: selectedEndDate }) }) })
17735
+ ] }) : /* @__PURE__ */ jsx(CalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsx(Calendar, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, futureStartDatesDisabled, maxRangeLength, setSelectedDate: handleSelectDate, startDate: selectedStartDate, endDate: selectedEndDate }) }) })
17394
17736
  ] });
17395
17737
  };
17396
17738
  const $5d3850c4d0b4e6c7$var$DIALOG_NAME = "Dialog";
@@ -35516,56 +35858,6 @@ const Pagination = ({
35516
35858
  ] })
35517
35859
  ] });
35518
35860
  };
35519
- const Panel = ({
35520
- alignItems = "center",
35521
- children,
35522
- color,
35523
- cursor,
35524
- fillHeight,
35525
- fillWidth,
35526
- gap,
35527
- hasBorder,
35528
- hasShadow,
35529
- height,
35530
- orientation = "horizontal",
35531
- padding,
35532
- radii = "sm",
35533
- width,
35534
- ...props
35535
- }) => /* @__PURE__ */ 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 });
35536
- const Wrapper$2 = pt.div.withConfig({
35537
- componentId: "sc-1q78udp-0"
35538
- })(["display:flex;flex-flow:", ";align-items:", ";width:", ";height:", ";background-color:", ";border-radius:", ";padding:", ";border:", ";box-shadow:", ";gap:", ";", ";"], ({
35539
- $orientation = "horizontal"
35540
- }) => $orientation === "horizontal" ? "row wrap" : "column", ({
35541
- $alignItems = "center"
35542
- }) => $alignItems === "center" ? "center" : `flex-${$alignItems}`, ({
35543
- $width,
35544
- $fillWidth
35545
- }) => $fillWidth ? "100%" : $width, ({
35546
- $height,
35547
- $fillHeight
35548
- }) => $fillHeight ? "100%" : $height, ({
35549
- $color = "default",
35550
- theme: theme2
35551
- }) => theme2.click.panel.color.background[$color], ({
35552
- $radii = "sm",
35553
- theme: theme2
35554
- }) => theme2.click.panel.radii[$radii], ({
35555
- $padding = "md",
35556
- theme: theme2
35557
- }) => theme2.click.panel.space.y[$padding], ({
35558
- $hasBorder,
35559
- theme: theme2
35560
- }) => $hasBorder ? `1px solid ${theme2.click.global.color.stroke.default}` : "none", ({
35561
- $hasShadow,
35562
- theme: theme2
35563
- }) => $hasShadow ? theme2.shadow[1] : "none", ({
35564
- $gap = "sm",
35565
- theme: theme2
35566
- }) => theme2.click.panel.space.gap[$gap], ({
35567
- $cursor
35568
- }) => $cursor && `cursor: ${$cursor}`);
35569
35861
  const ProgressContainer = pt.div.withConfig({
35570
35862
  componentId: "sc-16gr3cg-0"
35571
35863
  })(["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;", ";"], ({
@@ -52590,6 +52882,7 @@ export {
52590
52882
  DangerAlert,
52591
52883
  DateDetails,
52592
52884
  DatePicker,
52885
+ DateRangePicker,
52593
52886
  Dialog,
52594
52887
  Dropdown,
52595
52888
  EllipsisContent,
@@ -52645,6 +52938,7 @@ export {
52645
52938
  VerticalStepper,
52646
52939
  WarningAlert,
52647
52940
  createToast,
52941
+ getPredefinedMonthsForDateRangePicker,
52648
52942
  linkStyles,
52649
52943
  themes,
52650
52944
  useCUITheme,