@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 +10 -3
- package/dist/click-ui.bundled.es.js +359 -65
- package/dist/click-ui.bundled.es.js.map +1 -1
- package/dist/click-ui.bundled.umd.js +359 -65
- package/dist/click-ui.bundled.umd.js.map +1 -1
- package/dist/click-ui.es.js +359 -65
- package/dist/click-ui.es.js.map +1 -1
- package/dist/click-ui.umd.js +359 -65
- package/dist/click-ui.umd.js.map +1 -1
- package/dist/components/ConfirmationDialog/ConfirmationDialog.d.ts +2 -2
- package/dist/components/DatePicker/DateRangePicker.d.ts +7 -2
- package/dist/components/DatePicker/utils.d.ts +10 -0
- package/dist/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/click-ui.es.js
CHANGED
|
@@ -90,7 +90,7 @@ const Building = (props) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.
|
|
|
90
90
|
/* @__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" })
|
|
91
91
|
] });
|
|
92
92
|
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" }) });
|
|
93
|
-
const Calendar$
|
|
93
|
+
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: [
|
|
94
94
|
/* @__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" }),
|
|
95
95
|
/* @__PURE__ */ jsx("path", { d: "M21.0036 7.99826H2.99609", stroke: "#161517", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
96
96
|
/* @__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" }),
|
|
@@ -782,7 +782,7 @@ const ICONS_MAP = {
|
|
|
782
782
|
briefcase: Briefcase,
|
|
783
783
|
building: Building,
|
|
784
784
|
"burger-menu": BurgerMenu,
|
|
785
|
-
calendar: Calendar$
|
|
785
|
+
calendar: Calendar$2,
|
|
786
786
|
"calendar-with-time": CalendarWithTime,
|
|
787
787
|
cards: Cards,
|
|
788
788
|
"cell-tower": CellTower,
|
|
@@ -16027,12 +16027,62 @@ const InputEndContent = styled.div.withConfig({
|
|
|
16027
16027
|
align-self: stretch;
|
|
16028
16028
|
align-items: center;
|
|
16029
16029
|
`);
|
|
16030
|
-
const locale = "en-US";
|
|
16031
|
-
const selectedDateFormatter = new Intl.DateTimeFormat(locale, {
|
|
16030
|
+
const locale$1 = "en-US";
|
|
16031
|
+
const selectedDateFormatter = new Intl.DateTimeFormat(locale$1, {
|
|
16032
16032
|
day: "2-digit",
|
|
16033
16033
|
month: "short",
|
|
16034
16034
|
year: "numeric"
|
|
16035
16035
|
});
|
|
16036
|
+
const weekdayFormatter = new Intl.DateTimeFormat(locale$1, {
|
|
16037
|
+
weekday: "short"
|
|
16038
|
+
});
|
|
16039
|
+
const headerDateFormatter = new Intl.DateTimeFormat(locale$1, {
|
|
16040
|
+
month: "short",
|
|
16041
|
+
year: "numeric"
|
|
16042
|
+
});
|
|
16043
|
+
const getPredefinedMonthsForDateRangePicker = (numberOfMonths) => {
|
|
16044
|
+
const now2 = dayjs();
|
|
16045
|
+
if (numberOfMonths < 0) {
|
|
16046
|
+
const lastSixMonths = [];
|
|
16047
|
+
for (let i = 0; i < Math.abs(numberOfMonths); i++) {
|
|
16048
|
+
const date = now2.subtract(i, "month");
|
|
16049
|
+
if (date.date() === 1 && date.month() === now2.month()) {
|
|
16050
|
+
continue;
|
|
16051
|
+
}
|
|
16052
|
+
lastSixMonths.push({
|
|
16053
|
+
startDate: date.startOf("month").toDate(),
|
|
16054
|
+
endDate: i === 0 ? now2.toDate() : date.endOf("month").toDate()
|
|
16055
|
+
});
|
|
16056
|
+
}
|
|
16057
|
+
return lastSixMonths.reverse();
|
|
16058
|
+
}
|
|
16059
|
+
const nextSixMonths = [];
|
|
16060
|
+
for (let i = 0; i < numberOfMonths; i++) {
|
|
16061
|
+
const date = now2.add(i, "month");
|
|
16062
|
+
nextSixMonths.push({
|
|
16063
|
+
startDate: date.startOf("month").toDate(),
|
|
16064
|
+
endDate: date.endOf("month").toDate()
|
|
16065
|
+
});
|
|
16066
|
+
}
|
|
16067
|
+
return nextSixMonths;
|
|
16068
|
+
};
|
|
16069
|
+
const datesAreWithinMaxRange = (startDate, endDate, maxRangeLength) => {
|
|
16070
|
+
const daysDifference = Math.abs(dayjs(startDate).diff(dayjs(endDate), "days"));
|
|
16071
|
+
return daysDifference <= maxRangeLength;
|
|
16072
|
+
};
|
|
16073
|
+
const isDateRangeTheWholeMonth = ({
|
|
16074
|
+
startDate,
|
|
16075
|
+
endDate
|
|
16076
|
+
}) => {
|
|
16077
|
+
if (startDate.getMonth() !== endDate.getMonth()) {
|
|
16078
|
+
return false;
|
|
16079
|
+
}
|
|
16080
|
+
const start = dayjs(startDate);
|
|
16081
|
+
const end = dayjs(endDate);
|
|
16082
|
+
const startDateIsFirstDay = start.isSame(start.startOf("month"), "day");
|
|
16083
|
+
const endDateIsLastDay = end.isSame(end.endOf("month"), "day");
|
|
16084
|
+
return startDateIsFirstDay && endDateIsLastDay;
|
|
16085
|
+
};
|
|
16036
16086
|
const explicitWidth = "250px";
|
|
16037
16087
|
const HighlightedInputWrapper = styled$1(InputWrapper).withConfig({
|
|
16038
16088
|
componentId: "sc-1m6g9rm-0"
|
|
@@ -16056,13 +16106,37 @@ const DatePickerInput = ({
|
|
|
16056
16106
|
/* @__PURE__ */ jsx(InputElement, { $hasStartContent: true, "data-testid": "datepicker-input", placeholder, readOnly: true, value: formattedSelectedDate })
|
|
16057
16107
|
] });
|
|
16058
16108
|
};
|
|
16059
|
-
const
|
|
16060
|
-
|
|
16061
|
-
|
|
16062
|
-
|
|
16063
|
-
|
|
16064
|
-
|
|
16065
|
-
|
|
16109
|
+
const DateRangePickerInput = ({
|
|
16110
|
+
isActive,
|
|
16111
|
+
disabled,
|
|
16112
|
+
id,
|
|
16113
|
+
placeholder,
|
|
16114
|
+
selectedEndDate,
|
|
16115
|
+
selectedStartDate
|
|
16116
|
+
}) => {
|
|
16117
|
+
const defaultId = useId();
|
|
16118
|
+
let formattedValue = /* @__PURE__ */ jsx(Text, { color: "muted", component: "span", children: placeholder ?? "" });
|
|
16119
|
+
if (selectedStartDate) {
|
|
16120
|
+
if (selectedEndDate) {
|
|
16121
|
+
formattedValue = /* @__PURE__ */ jsxs("span", { children: [
|
|
16122
|
+
selectedDateFormatter.format(selectedStartDate),
|
|
16123
|
+
" –",
|
|
16124
|
+
" ",
|
|
16125
|
+
selectedDateFormatter.format(selectedEndDate)
|
|
16126
|
+
] });
|
|
16127
|
+
} else {
|
|
16128
|
+
formattedValue = /* @__PURE__ */ jsxs("span", { children: [
|
|
16129
|
+
selectedDateFormatter.format(selectedStartDate),
|
|
16130
|
+
" ",
|
|
16131
|
+
/* @__PURE__ */ jsx(Text, { color: "muted", component: "span", children: "– end date" })
|
|
16132
|
+
] });
|
|
16133
|
+
}
|
|
16134
|
+
}
|
|
16135
|
+
return /* @__PURE__ */ jsxs(HighlightedInputWrapper, { $isActive: isActive, disabled, id: id ?? defaultId, children: [
|
|
16136
|
+
/* @__PURE__ */ jsx(InputStartContent, { children: /* @__PURE__ */ jsx(SvgImage, { name: "calendar" }) }),
|
|
16137
|
+
/* @__PURE__ */ jsx(InputElement, { $hasStartContent: true, as: "div", "data-testid": "daterangepicker-input", children: formattedValue })
|
|
16138
|
+
] });
|
|
16139
|
+
};
|
|
16066
16140
|
const DatePickerContainer = styled$1(Container).withConfig({
|
|
16067
16141
|
componentId: "sc-1m6g9rm-1"
|
|
16068
16142
|
})(["background:", ";"], ({
|
|
@@ -16148,9 +16222,9 @@ const CalendarRenderer = ({
|
|
|
16148
16222
|
headerDate.setFullYear(year);
|
|
16149
16223
|
return /* @__PURE__ */ jsxs(DatePickerContainer, { "data-testid": "datepicker-calendar-container", isResponsive: false, fillWidth: false, orientation: "vertical", padding: "sm", ...props, children: [
|
|
16150
16224
|
/* @__PURE__ */ jsxs(Container, { isResponsive: false, justifyContent: "space-between", orientation: "horizontal", children: [
|
|
16151
|
-
/* @__PURE__ */ jsx(IconButton$1, { icon: "chevron-left", onClick: handlePreviousClick, size: "sm", type: "ghost" }),
|
|
16225
|
+
/* @__PURE__ */ jsx(IconButton$1, { "data-testid": "calendar-previous-month", icon: "chevron-left", onClick: handlePreviousClick, size: "sm", type: "ghost" }),
|
|
16152
16226
|
/* @__PURE__ */ jsx(UnselectableTitle, { children: headerDateFormatter.format(headerDate) }),
|
|
16153
|
-
/* @__PURE__ */ jsx(IconButton$1, { icon: "chevron-right", onClick: handleNextClick, size: "sm", type: "ghost" })
|
|
16227
|
+
/* @__PURE__ */ jsx(IconButton$1, { "data-testid": "calendar-next-month", icon: "chevron-right", onClick: handleNextClick, size: "sm", type: "ghost" })
|
|
16154
16228
|
] }),
|
|
16155
16229
|
/* @__PURE__ */ jsxs(DateTable, { children: [
|
|
16156
16230
|
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: headers.weekDays.map(({
|
|
@@ -16163,7 +16237,7 @@ const CalendarRenderer = ({
|
|
|
16163
16237
|
] })
|
|
16164
16238
|
] });
|
|
16165
16239
|
};
|
|
16166
|
-
const Calendar = ({
|
|
16240
|
+
const Calendar$1 = ({
|
|
16167
16241
|
calendarBody,
|
|
16168
16242
|
closeDatepicker,
|
|
16169
16243
|
futureDatesDisabled,
|
|
@@ -16222,7 +16296,275 @@ const DatePicker = ({
|
|
|
16222
16296
|
};
|
|
16223
16297
|
return /* @__PURE__ */ jsxs(Dropdown, { onOpenChange: setIsOpen, open: isOpen, children: [
|
|
16224
16298
|
/* @__PURE__ */ jsx(Dropdown.Trigger, { disabled, children: /* @__PURE__ */ jsx(DatePickerInput, { "data-testid": "datepicker-input-container", disabled, isActive: isOpen, placeholder, selectedDate }) }),
|
|
16225
|
-
/* @__PURE__ */ jsx(Dropdown.Content, { align: "start", children: /* @__PURE__ */ jsx(CalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsx(Calendar, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, selectedDate, setSelectedDate: handleSelectDate }) }) })
|
|
16299
|
+
/* @__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 }) }) })
|
|
16300
|
+
] });
|
|
16301
|
+
};
|
|
16302
|
+
const Panel = ({
|
|
16303
|
+
alignItems = "center",
|
|
16304
|
+
children,
|
|
16305
|
+
color,
|
|
16306
|
+
cursor,
|
|
16307
|
+
fillHeight,
|
|
16308
|
+
fillWidth,
|
|
16309
|
+
gap,
|
|
16310
|
+
hasBorder,
|
|
16311
|
+
hasShadow,
|
|
16312
|
+
height,
|
|
16313
|
+
orientation = "horizontal",
|
|
16314
|
+
padding,
|
|
16315
|
+
radii = "sm",
|
|
16316
|
+
width,
|
|
16317
|
+
...props
|
|
16318
|
+
}) => /* @__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 });
|
|
16319
|
+
const Wrapper$2 = styled.div.withConfig({
|
|
16320
|
+
componentId: "sc-1q78udp-0"
|
|
16321
|
+
})(["display:flex;flex-flow:", ";align-items:", ";width:", ";height:", ";background-color:", ";border-radius:", ";padding:", ";border:", ";box-shadow:", ";gap:", ";", ";"], ({
|
|
16322
|
+
$orientation = "horizontal"
|
|
16323
|
+
}) => $orientation === "horizontal" ? "row wrap" : "column", ({
|
|
16324
|
+
$alignItems = "center"
|
|
16325
|
+
}) => $alignItems === "center" ? "center" : `flex-${$alignItems}`, ({
|
|
16326
|
+
$width,
|
|
16327
|
+
$fillWidth
|
|
16328
|
+
}) => $fillWidth ? "100%" : $width, ({
|
|
16329
|
+
$height,
|
|
16330
|
+
$fillHeight
|
|
16331
|
+
}) => $fillHeight ? "100%" : $height, ({
|
|
16332
|
+
$color = "default",
|
|
16333
|
+
theme: theme2
|
|
16334
|
+
}) => theme2.click.panel.color.background[$color], ({
|
|
16335
|
+
$radii = "sm",
|
|
16336
|
+
theme: theme2
|
|
16337
|
+
}) => theme2.click.panel.radii[$radii], ({
|
|
16338
|
+
$padding = "md",
|
|
16339
|
+
theme: theme2
|
|
16340
|
+
}) => theme2.click.panel.space.y[$padding], ({
|
|
16341
|
+
$hasBorder,
|
|
16342
|
+
theme: theme2
|
|
16343
|
+
}) => $hasBorder ? `1px solid ${theme2.click.global.color.stroke.default}` : "none", ({
|
|
16344
|
+
$hasShadow,
|
|
16345
|
+
theme: theme2
|
|
16346
|
+
}) => $hasShadow ? theme2.shadow[1] : "none", ({
|
|
16347
|
+
$gap = "sm",
|
|
16348
|
+
theme: theme2
|
|
16349
|
+
}) => theme2.click.panel.space.gap[$gap], ({
|
|
16350
|
+
$cursor
|
|
16351
|
+
}) => $cursor && `cursor: ${$cursor}`);
|
|
16352
|
+
const PredefinedCalendarContainer = styled(Panel).withConfig({
|
|
16353
|
+
componentId: "sc-1f4vu20-0"
|
|
16354
|
+
})(["align-items:start;background:", ";"], ({
|
|
16355
|
+
theme: theme2
|
|
16356
|
+
}) => theme2.click.panel.color.background.muted);
|
|
16357
|
+
const PredefinedDatesContainer = styled(Container).withConfig({
|
|
16358
|
+
componentId: "sc-1f4vu20-1"
|
|
16359
|
+
})(["width:275px;"]);
|
|
16360
|
+
const CalendarRendererContainer = styled.div.withConfig({
|
|
16361
|
+
componentId: "sc-1f4vu20-2"
|
|
16362
|
+
})(["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;"], ({
|
|
16363
|
+
theme: theme2
|
|
16364
|
+
}) => `${theme2.click.datePicker.dateOption.stroke} solid ${theme2.click.datePicker.dateOption.color.background.range}`, ({
|
|
16365
|
+
theme: theme2
|
|
16366
|
+
}) => theme2.click.datePicker.dateOption.radii.default);
|
|
16367
|
+
const StyledCalendarRenderer = styled(CalendarRenderer).withConfig({
|
|
16368
|
+
componentId: "sc-1f4vu20-3"
|
|
16369
|
+
})(["border-radius:", ";min-height:221px;"], ({
|
|
16370
|
+
theme: theme2
|
|
16371
|
+
}) => theme2.click.datePicker.dateOption.radii.default);
|
|
16372
|
+
const StyledDropdownItem = styled(Dropdown.Item).withConfig({
|
|
16373
|
+
componentId: "sc-1f4vu20-4"
|
|
16374
|
+
})(["min-height:24px;"]);
|
|
16375
|
+
const ScrollableContainer = styled(Container).withConfig({
|
|
16376
|
+
componentId: "sc-1f4vu20-5"
|
|
16377
|
+
})(["max-height:210px;overflow-y:auto;"]);
|
|
16378
|
+
const DateRangeTableCell = styled(DateTableCell).withConfig({
|
|
16379
|
+
componentId: "sc-1f4vu20-6"
|
|
16380
|
+
})(["", ""], ({
|
|
16381
|
+
$shouldShowRangeIndicator,
|
|
16382
|
+
theme: theme2
|
|
16383
|
+
}) => $shouldShowRangeIndicator && `
|
|
16384
|
+
background: ${theme2.click.datePicker.dateOption.color.background.range};
|
|
16385
|
+
border: ${theme2.click.datePicker.dateOption.stroke} solid ${theme2.click.datePicker.dateOption.color.background.range};
|
|
16386
|
+
border-radius: 0;
|
|
16387
|
+
`);
|
|
16388
|
+
const Calendar = ({
|
|
16389
|
+
calendarBody,
|
|
16390
|
+
closeDatepicker,
|
|
16391
|
+
futureDatesDisabled,
|
|
16392
|
+
futureStartDatesDisabled,
|
|
16393
|
+
maxRangeLength,
|
|
16394
|
+
setSelectedDate,
|
|
16395
|
+
startDate,
|
|
16396
|
+
endDate
|
|
16397
|
+
}) => {
|
|
16398
|
+
const [hoveredDate, setHoveredDate] = useState();
|
|
16399
|
+
const handleMouseOut = () => {
|
|
16400
|
+
setHoveredDate(void 0);
|
|
16401
|
+
};
|
|
16402
|
+
return calendarBody.value.map(({
|
|
16403
|
+
key: weekKey,
|
|
16404
|
+
value: week
|
|
16405
|
+
}) => {
|
|
16406
|
+
return /* @__PURE__ */ jsx("tr", { children: week.map(({
|
|
16407
|
+
date,
|
|
16408
|
+
isCurrentMonth,
|
|
16409
|
+
key: dayKey,
|
|
16410
|
+
value: fullDate
|
|
16411
|
+
}) => {
|
|
16412
|
+
const isSelected = startDate && isSameDate(startDate, fullDate) || endDate && isSameDate(endDate, fullDate);
|
|
16413
|
+
const today = /* @__PURE__ */ new Date();
|
|
16414
|
+
const isCurrentDate = isSameDate(today, fullDate);
|
|
16415
|
+
const isBetweenStartAndEndDates = Boolean(startDate && endDate && fullDate > startDate && fullDate < endDate);
|
|
16416
|
+
let isDisabled = false;
|
|
16417
|
+
if (futureDatesDisabled && fullDate > today) {
|
|
16418
|
+
isDisabled = true;
|
|
16419
|
+
}
|
|
16420
|
+
if (futureStartDatesDisabled && !startDate && fullDate > today) {
|
|
16421
|
+
isDisabled = true;
|
|
16422
|
+
}
|
|
16423
|
+
if (maxRangeLength > 1 && startDate && !datesAreWithinMaxRange(startDate, fullDate, maxRangeLength)) {
|
|
16424
|
+
isDisabled = true;
|
|
16425
|
+
}
|
|
16426
|
+
const shouldShowRangeIndicator = !endDate && Boolean(startDate && hoveredDate && fullDate > startDate && fullDate < hoveredDate);
|
|
16427
|
+
const handleMouseEnter = () => {
|
|
16428
|
+
setHoveredDate(fullDate);
|
|
16429
|
+
};
|
|
16430
|
+
const handleClick = () => {
|
|
16431
|
+
if (isDisabled) {
|
|
16432
|
+
return false;
|
|
16433
|
+
}
|
|
16434
|
+
setSelectedDate(fullDate);
|
|
16435
|
+
if (startDate && endDate) {
|
|
16436
|
+
return;
|
|
16437
|
+
}
|
|
16438
|
+
if (startDate && fullDate < startDate) {
|
|
16439
|
+
return;
|
|
16440
|
+
}
|
|
16441
|
+
if (startDate && !isSameDate(fullDate, startDate)) {
|
|
16442
|
+
closeDatepicker();
|
|
16443
|
+
return;
|
|
16444
|
+
}
|
|
16445
|
+
};
|
|
16446
|
+
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);
|
|
16447
|
+
}) }, weekKey);
|
|
16448
|
+
});
|
|
16449
|
+
};
|
|
16450
|
+
const locale = "en-US";
|
|
16451
|
+
const monthFormatter = new Intl.DateTimeFormat(locale, {
|
|
16452
|
+
month: "short",
|
|
16453
|
+
year: "numeric"
|
|
16454
|
+
});
|
|
16455
|
+
const PredefinedDates = ({
|
|
16456
|
+
onSelectDateRange,
|
|
16457
|
+
predefinedDatesList,
|
|
16458
|
+
selectedEndDate,
|
|
16459
|
+
selectedStartDate,
|
|
16460
|
+
setEndDate,
|
|
16461
|
+
setStartDate,
|
|
16462
|
+
shouldShowCustomRange,
|
|
16463
|
+
showCustomDateRange
|
|
16464
|
+
}) => {
|
|
16465
|
+
const handleCustomTimePeriodClick = (event) => {
|
|
16466
|
+
event.preventDefault();
|
|
16467
|
+
showCustomDateRange(!shouldShowCustomRange);
|
|
16468
|
+
};
|
|
16469
|
+
return /* @__PURE__ */ jsxs(PredefinedDatesContainer, { "data-testid": "predefined-dates-list", isResponsive: false, orientation: "vertical", children: [
|
|
16470
|
+
/* @__PURE__ */ jsx(ScrollableContainer, { orientation: "vertical", children: predefinedDatesList.map(({
|
|
16471
|
+
startDate,
|
|
16472
|
+
endDate
|
|
16473
|
+
}) => {
|
|
16474
|
+
const handleItemClick = () => {
|
|
16475
|
+
setStartDate(startDate);
|
|
16476
|
+
setEndDate(endDate);
|
|
16477
|
+
onSelectDateRange(startDate, endDate);
|
|
16478
|
+
};
|
|
16479
|
+
const rangeIsSelected = selectedEndDate && isSameDate(selectedEndDate, endDate) && selectedStartDate && isSameDate(selectedStartDate, startDate);
|
|
16480
|
+
const isWholeMonth = isDateRangeTheWholeMonth({
|
|
16481
|
+
startDate,
|
|
16482
|
+
endDate
|
|
16483
|
+
});
|
|
16484
|
+
const formattedText = isWholeMonth ? monthFormatter.format(startDate) : `${selectedDateFormatter.format(startDate)} - ${selectedDateFormatter.format(endDate)}`.trim();
|
|
16485
|
+
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: [
|
|
16486
|
+
formattedText,
|
|
16487
|
+
rangeIsSelected && /* @__PURE__ */ jsx(SvgImage, { name: "check" })
|
|
16488
|
+
] }) }, startDate.toISOString());
|
|
16489
|
+
}) }),
|
|
16490
|
+
/* @__PURE__ */ jsx(StyledDropdownItem, { onClick: handleCustomTimePeriodClick, children: /* @__PURE__ */ jsxs(Container, { justifyContent: "space-between", orientation: "horizontal", children: [
|
|
16491
|
+
"Custom time period ",
|
|
16492
|
+
/* @__PURE__ */ jsx(SvgImage, { name: "chevron-right" })
|
|
16493
|
+
] }) })
|
|
16494
|
+
] });
|
|
16495
|
+
};
|
|
16496
|
+
const DateRangePicker = ({
|
|
16497
|
+
endDate,
|
|
16498
|
+
startDate,
|
|
16499
|
+
disabled = false,
|
|
16500
|
+
futureDatesDisabled = false,
|
|
16501
|
+
futureStartDatesDisabled = false,
|
|
16502
|
+
maxRangeLength = -1,
|
|
16503
|
+
onSelectDateRange,
|
|
16504
|
+
placeholder = "start date – end date",
|
|
16505
|
+
predefinedDatesList
|
|
16506
|
+
}) => {
|
|
16507
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
16508
|
+
const [selectedStartDate, setSelectedStartDate] = useState();
|
|
16509
|
+
const [selectedEndDate, setSelectedEndDate] = useState();
|
|
16510
|
+
const [shouldShowCustomRange, setShouldShowCustomRange] = useState(false);
|
|
16511
|
+
const calendarOptions = {};
|
|
16512
|
+
if (selectedStartDate) {
|
|
16513
|
+
calendarOptions.defaultDate = selectedStartDate;
|
|
16514
|
+
}
|
|
16515
|
+
useEffect(() => {
|
|
16516
|
+
if (startDate) {
|
|
16517
|
+
setSelectedStartDate(startDate);
|
|
16518
|
+
}
|
|
16519
|
+
}, [startDate]);
|
|
16520
|
+
useEffect(() => {
|
|
16521
|
+
if (endDate) {
|
|
16522
|
+
setSelectedEndDate(endDate);
|
|
16523
|
+
}
|
|
16524
|
+
}, [endDate]);
|
|
16525
|
+
const closeDatePicker = useCallback(() => {
|
|
16526
|
+
setIsOpen(false);
|
|
16527
|
+
setShouldShowCustomRange(false);
|
|
16528
|
+
}, []);
|
|
16529
|
+
const handleOpenChange = (isOpen2) => {
|
|
16530
|
+
setIsOpen(isOpen2);
|
|
16531
|
+
if (!isOpen2) {
|
|
16532
|
+
setShouldShowCustomRange(false);
|
|
16533
|
+
}
|
|
16534
|
+
};
|
|
16535
|
+
const handleSelectDate = useCallback((selectedDate) => {
|
|
16536
|
+
if (selectedStartDate && selectedEndDate) {
|
|
16537
|
+
if (futureStartDatesDisabled && selectedDate > /* @__PURE__ */ new Date()) {
|
|
16538
|
+
setSelectedEndDate(void 0);
|
|
16539
|
+
return;
|
|
16540
|
+
}
|
|
16541
|
+
setSelectedStartDate(selectedDate);
|
|
16542
|
+
setSelectedEndDate(void 0);
|
|
16543
|
+
return;
|
|
16544
|
+
}
|
|
16545
|
+
if (selectedStartDate) {
|
|
16546
|
+
if (isSameDate(selectedStartDate, selectedDate)) {
|
|
16547
|
+
setSelectedStartDate(void 0);
|
|
16548
|
+
return;
|
|
16549
|
+
}
|
|
16550
|
+
if (selectedDate < selectedStartDate) {
|
|
16551
|
+
setSelectedStartDate(selectedDate);
|
|
16552
|
+
return;
|
|
16553
|
+
}
|
|
16554
|
+
setSelectedEndDate(selectedDate);
|
|
16555
|
+
onSelectDateRange(selectedStartDate, selectedDate);
|
|
16556
|
+
setShouldShowCustomRange(false);
|
|
16557
|
+
return;
|
|
16558
|
+
}
|
|
16559
|
+
setSelectedStartDate(selectedDate);
|
|
16560
|
+
}, [futureStartDatesDisabled, onSelectDateRange, selectedEndDate, selectedStartDate]);
|
|
16561
|
+
const shouldShowPredefinedDates = predefinedDatesList !== void 0 && predefinedDatesList.length > 0;
|
|
16562
|
+
return /* @__PURE__ */ jsxs(Dropdown, { onOpenChange: handleOpenChange, open: isOpen, children: [
|
|
16563
|
+
/* @__PURE__ */ jsx(Dropdown.Trigger, { disabled, children: /* @__PURE__ */ jsx(DateRangePickerInput, { "data-testid": "datepicker-input-container", disabled, isActive: isOpen, placeholder, selectedEndDate, selectedStartDate }) }),
|
|
16564
|
+
/* @__PURE__ */ jsx(Dropdown.Content, { align: "start", children: shouldShowPredefinedDates ? /* @__PURE__ */ jsxs(PredefinedCalendarContainer, { gap: "none", orientation: "horizontal", padding: "none", children: [
|
|
16565
|
+
/* @__PURE__ */ jsx(PredefinedDates, { onSelectDateRange, predefinedDatesList, selectedEndDate, selectedStartDate, setEndDate: setSelectedEndDate, setStartDate: setSelectedStartDate, shouldShowCustomRange, showCustomDateRange: setShouldShowCustomRange }),
|
|
16566
|
+
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 }) }) })
|
|
16567
|
+
] }) : /* @__PURE__ */ jsx(CalendarRenderer, { calendarOptions, children: (body) => /* @__PURE__ */ jsx(Calendar, { calendarBody: body, closeDatepicker: closeDatePicker, futureDatesDisabled, futureStartDatesDisabled, maxRangeLength, setSelectedDate: handleSelectDate, startDate: selectedStartDate, endDate: selectedEndDate }) }) })
|
|
16226
16568
|
] });
|
|
16227
16569
|
};
|
|
16228
16570
|
const $5d3850c4d0b4e6c7$var$DIALOG_NAME = "Dialog";
|
|
@@ -34348,56 +34690,6 @@ const Pagination = ({
|
|
|
34348
34690
|
] })
|
|
34349
34691
|
] });
|
|
34350
34692
|
};
|
|
34351
|
-
const Panel = ({
|
|
34352
|
-
alignItems = "center",
|
|
34353
|
-
children,
|
|
34354
|
-
color,
|
|
34355
|
-
cursor,
|
|
34356
|
-
fillHeight,
|
|
34357
|
-
fillWidth,
|
|
34358
|
-
gap,
|
|
34359
|
-
hasBorder,
|
|
34360
|
-
hasShadow,
|
|
34361
|
-
height,
|
|
34362
|
-
orientation = "horizontal",
|
|
34363
|
-
padding,
|
|
34364
|
-
radii = "sm",
|
|
34365
|
-
width,
|
|
34366
|
-
...props
|
|
34367
|
-
}) => /* @__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 });
|
|
34368
|
-
const Wrapper$2 = styled.div.withConfig({
|
|
34369
|
-
componentId: "sc-1q78udp-0"
|
|
34370
|
-
})(["display:flex;flex-flow:", ";align-items:", ";width:", ";height:", ";background-color:", ";border-radius:", ";padding:", ";border:", ";box-shadow:", ";gap:", ";", ";"], ({
|
|
34371
|
-
$orientation = "horizontal"
|
|
34372
|
-
}) => $orientation === "horizontal" ? "row wrap" : "column", ({
|
|
34373
|
-
$alignItems = "center"
|
|
34374
|
-
}) => $alignItems === "center" ? "center" : `flex-${$alignItems}`, ({
|
|
34375
|
-
$width,
|
|
34376
|
-
$fillWidth
|
|
34377
|
-
}) => $fillWidth ? "100%" : $width, ({
|
|
34378
|
-
$height,
|
|
34379
|
-
$fillHeight
|
|
34380
|
-
}) => $fillHeight ? "100%" : $height, ({
|
|
34381
|
-
$color = "default",
|
|
34382
|
-
theme: theme2
|
|
34383
|
-
}) => theme2.click.panel.color.background[$color], ({
|
|
34384
|
-
$radii = "sm",
|
|
34385
|
-
theme: theme2
|
|
34386
|
-
}) => theme2.click.panel.radii[$radii], ({
|
|
34387
|
-
$padding = "md",
|
|
34388
|
-
theme: theme2
|
|
34389
|
-
}) => theme2.click.panel.space.y[$padding], ({
|
|
34390
|
-
$hasBorder,
|
|
34391
|
-
theme: theme2
|
|
34392
|
-
}) => $hasBorder ? `1px solid ${theme2.click.global.color.stroke.default}` : "none", ({
|
|
34393
|
-
$hasShadow,
|
|
34394
|
-
theme: theme2
|
|
34395
|
-
}) => $hasShadow ? theme2.shadow[1] : "none", ({
|
|
34396
|
-
$gap = "sm",
|
|
34397
|
-
theme: theme2
|
|
34398
|
-
}) => theme2.click.panel.space.gap[$gap], ({
|
|
34399
|
-
$cursor
|
|
34400
|
-
}) => $cursor && `cursor: ${$cursor}`);
|
|
34401
34693
|
const ProgressContainer = styled.div.withConfig({
|
|
34402
34694
|
componentId: "sc-16gr3cg-0"
|
|
34403
34695
|
})(["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;", ";"], ({
|
|
@@ -51422,6 +51714,7 @@ export {
|
|
|
51422
51714
|
DangerAlert,
|
|
51423
51715
|
DateDetails,
|
|
51424
51716
|
DatePicker,
|
|
51717
|
+
DateRangePicker,
|
|
51425
51718
|
Dialog,
|
|
51426
51719
|
Dropdown,
|
|
51427
51720
|
EllipsisContent,
|
|
@@ -51477,6 +51770,7 @@ export {
|
|
|
51477
51770
|
VerticalStepper,
|
|
51478
51771
|
WarningAlert,
|
|
51479
51772
|
createToast,
|
|
51773
|
+
getPredefinedMonthsForDateRangePicker,
|
|
51480
51774
|
linkStyles,
|
|
51481
51775
|
themes,
|
|
51482
51776
|
useCUITheme,
|