@deepnoid/ui 0.1.203 → 0.1.204
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/.turbo/turbo-build.log +122 -122
- package/dist/{chunk-2EUKWA4W.mjs → chunk-AUGYJPCS.mjs} +89 -47
- package/dist/components/picker/datePicker.d.mts +2 -0
- package/dist/components/picker/datePicker.d.ts +2 -0
- package/dist/components/picker/datePicker.js +90 -48
- package/dist/components/picker/datePicker.mjs +1 -1
- package/dist/components/picker/index.js +90 -48
- package/dist/components/picker/index.mjs +1 -1
- package/dist/index.js +91 -49
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -6716,6 +6716,8 @@ var DatePicker = (0, import_react7.forwardRef)((originalProps, ref) => {
|
|
|
6716
6716
|
confirmTitle,
|
|
6717
6717
|
range = false,
|
|
6718
6718
|
dualCalendar = false,
|
|
6719
|
+
disabledDates,
|
|
6720
|
+
enabledDates,
|
|
6719
6721
|
...inputProps
|
|
6720
6722
|
} = { ...props, ...variantProps };
|
|
6721
6723
|
const [selectedDate, setSelectedDate] = (0, import_react7.useState)(range ? "" : typeof value === "string" ? value || "" : "");
|
|
@@ -6837,29 +6839,18 @@ var DatePicker = (0, import_react7.forwardRef)((originalProps, ref) => {
|
|
|
6837
6839
|
for (let i = 0; i < dates.length; i += 7) weeks.push(dates.slice(i, i + 7));
|
|
6838
6840
|
return weeks;
|
|
6839
6841
|
}, []);
|
|
6840
|
-
const
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
}
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
const newLeftDate = new Date(leftCurrentDate.getFullYear(), leftCurrentDate.getMonth() + 1);
|
|
6849
|
-
setLeftCurrentDate(newLeftDate);
|
|
6850
|
-
if (dualCalendar) {
|
|
6851
|
-
setRightCurrentDate(new Date(newLeftDate.getFullYear(), newLeftDate.getMonth() + 1));
|
|
6852
|
-
}
|
|
6853
|
-
};
|
|
6854
|
-
const handleRightNextMonth = () => {
|
|
6855
|
-
if (!dualCalendar) return;
|
|
6856
|
-
const newRightDate = new Date(rightCurrentDate.getFullYear(), rightCurrentDate.getMonth() + 1);
|
|
6857
|
-
setRightCurrentDate(newRightDate);
|
|
6858
|
-
setLeftCurrentDate(new Date(newRightDate.getFullYear(), newRightDate.getMonth() - 1));
|
|
6859
|
-
};
|
|
6842
|
+
const isDateDisabled = (0, import_react7.useCallback)(
|
|
6843
|
+
(date) => {
|
|
6844
|
+
if (enabledDates) return !enabledDates(date);
|
|
6845
|
+
if (disabledDates) return disabledDates(date);
|
|
6846
|
+
return false;
|
|
6847
|
+
},
|
|
6848
|
+
[disabledDates, enabledDates]
|
|
6849
|
+
);
|
|
6860
6850
|
const handleDateSelect = (date, isCurrentMonth, currentDate) => {
|
|
6861
6851
|
if (!isCurrentMonth) return;
|
|
6862
6852
|
const selected = new Date(currentDate.getFullYear(), currentDate.getMonth(), date);
|
|
6853
|
+
if (isDateDisabled(selected)) return;
|
|
6863
6854
|
const formatted = formatDateToString(selected);
|
|
6864
6855
|
if (range) {
|
|
6865
6856
|
if (rangeSelection === "start") {
|
|
@@ -6870,7 +6861,10 @@ var DatePicker = (0, import_react7.forwardRef)((originalProps, ref) => {
|
|
|
6870
6861
|
if (selected >= startDate) {
|
|
6871
6862
|
setTempSelectedRange({ ...tempSelectedRange, endDate: formatted });
|
|
6872
6863
|
} else {
|
|
6873
|
-
setTempSelectedRange({
|
|
6864
|
+
setTempSelectedRange({
|
|
6865
|
+
startDate: formatted,
|
|
6866
|
+
endDate: tempSelectedRange.startDate
|
|
6867
|
+
});
|
|
6874
6868
|
}
|
|
6875
6869
|
}
|
|
6876
6870
|
} else {
|
|
@@ -6879,6 +6873,7 @@ var DatePicker = (0, import_react7.forwardRef)((originalProps, ref) => {
|
|
|
6879
6873
|
};
|
|
6880
6874
|
const handleSetToday = () => {
|
|
6881
6875
|
const today = /* @__PURE__ */ new Date();
|
|
6876
|
+
if (isDateDisabled(today)) return;
|
|
6882
6877
|
const formatted = formatDateToString(today);
|
|
6883
6878
|
if (range) {
|
|
6884
6879
|
if (rangeSelection === "start") {
|
|
@@ -6889,7 +6884,10 @@ var DatePicker = (0, import_react7.forwardRef)((originalProps, ref) => {
|
|
|
6889
6884
|
if (today >= startDate) {
|
|
6890
6885
|
setTempSelectedRange({ ...tempSelectedRange, endDate: formatted });
|
|
6891
6886
|
} else {
|
|
6892
|
-
setTempSelectedRange({
|
|
6887
|
+
setTempSelectedRange({
|
|
6888
|
+
startDate: formatted,
|
|
6889
|
+
endDate: tempSelectedRange.startDate
|
|
6890
|
+
});
|
|
6893
6891
|
}
|
|
6894
6892
|
}
|
|
6895
6893
|
} else {
|
|
@@ -6901,11 +6899,11 @@ var DatePicker = (0, import_react7.forwardRef)((originalProps, ref) => {
|
|
|
6901
6899
|
const handleConfirmDate = () => {
|
|
6902
6900
|
if (isConfirmDisabled) return;
|
|
6903
6901
|
if (range) {
|
|
6904
|
-
setSelectedRange(tempSelectedRange);
|
|
6905
6902
|
onChange == null ? void 0 : onChange(tempSelectedRange);
|
|
6903
|
+
setSelectedRange(tempSelectedRange);
|
|
6906
6904
|
} else {
|
|
6907
|
-
setSelectedDate(tempSelectedDate);
|
|
6908
6905
|
onChange == null ? void 0 : onChange(tempSelectedDate);
|
|
6906
|
+
setSelectedDate(tempSelectedDate);
|
|
6909
6907
|
}
|
|
6910
6908
|
setIsPanelOpen(false);
|
|
6911
6909
|
};
|
|
@@ -6920,31 +6918,29 @@ var DatePicker = (0, import_react7.forwardRef)((originalProps, ref) => {
|
|
|
6920
6918
|
};
|
|
6921
6919
|
const getDayProps = (0, import_react7.useCallback)(
|
|
6922
6920
|
(dateObj, currentDate) => {
|
|
6921
|
+
const date = new Date(currentDate.getFullYear(), currentDate.getMonth(), dateObj.date);
|
|
6922
|
+
if (isDateDisabled(date)) return "disabled";
|
|
6923
6923
|
const today = /* @__PURE__ */ new Date();
|
|
6924
6924
|
const isToday = today.getDate() === dateObj.date && today.getMonth() === currentDate.getMonth() && today.getFullYear() === currentDate.getFullYear();
|
|
6925
6925
|
if (range) {
|
|
6926
|
-
const
|
|
6927
|
-
const
|
|
6928
|
-
const
|
|
6929
|
-
const
|
|
6930
|
-
const
|
|
6931
|
-
const isInRange =
|
|
6932
|
-
if (
|
|
6933
|
-
if (
|
|
6934
|
-
if (
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
return dateObj.currentMonth && isSelected ? "selected" : dateObj.currentMonth && isToday ? "today" : !dateObj.currentMonth ? "disabled" : "default";
|
|
6941
|
-
}
|
|
6926
|
+
const start = tempSelectedRange.startDate ? formatStringToDate(tempSelectedRange.startDate) : null;
|
|
6927
|
+
const end = tempSelectedRange.endDate ? formatStringToDate(tempSelectedRange.endDate) : null;
|
|
6928
|
+
const current = date;
|
|
6929
|
+
const isStart = start && start.getFullYear() === current.getFullYear() && start.getMonth() === current.getMonth() && start.getDate() === current.getDate();
|
|
6930
|
+
const isEnd = end && end.getFullYear() === current.getFullYear() && end.getMonth() === current.getMonth() && end.getDate() === current.getDate();
|
|
6931
|
+
const isInRange = start && end && current > start && current < end;
|
|
6932
|
+
if (isStart || isEnd) return "selected";
|
|
6933
|
+
if (isInRange) return "period";
|
|
6934
|
+
if (isToday) return "today";
|
|
6935
|
+
return dateObj.currentMonth ? "default" : "disabled";
|
|
6936
|
+
}
|
|
6937
|
+
const selected = tempSelectedDate ? formatStringToDate(tempSelectedDate) : null;
|
|
6938
|
+
const isSelected = selected && selected.getFullYear() === date.getFullYear() && selected.getMonth() === date.getMonth() && selected.getDate() === date.getDate();
|
|
6939
|
+
return isSelected ? "selected" : isToday ? "today" : dateObj.currentMonth ? "default" : "disabled";
|
|
6942
6940
|
},
|
|
6943
|
-
[tempSelectedDate, tempSelectedRange, range]
|
|
6941
|
+
[tempSelectedDate, tempSelectedRange, range, isDateDisabled]
|
|
6944
6942
|
);
|
|
6945
|
-
const getPlaceholderText = () =>
|
|
6946
|
-
return placeholder;
|
|
6947
|
-
};
|
|
6943
|
+
const getPlaceholderText = () => placeholder;
|
|
6948
6944
|
(0, import_react7.useEffect)(() => {
|
|
6949
6945
|
if (range && typeof value === "object") {
|
|
6950
6946
|
setSelectedRange(value || { startDate: "", endDate: "" });
|
|
@@ -6965,17 +6961,63 @@ var DatePicker = (0, import_react7.forwardRef)((originalProps, ref) => {
|
|
|
6965
6961
|
const endContent = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon_default, { name: "calendar", size, className: "cursor-pointer", fill: true, onClick: handleCalendarIconClick });
|
|
6966
6962
|
const renderCalendar = (currentDate, isLeft) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-[5px]", children: [
|
|
6967
6963
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: slots.calendarHead({ class: classNames == null ? void 0 : classNames.calendarHead }), children: dualCalendar ? isLeft ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
6968
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6964
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6965
|
+
icon_button_default,
|
|
6966
|
+
{
|
|
6967
|
+
name: "left",
|
|
6968
|
+
variant: "soft",
|
|
6969
|
+
color: "neutral",
|
|
6970
|
+
onClick: () => {
|
|
6971
|
+
const newLeft = new Date(leftCurrentDate.getFullYear(), leftCurrentDate.getMonth() - 1);
|
|
6972
|
+
setLeftCurrentDate(newLeft);
|
|
6973
|
+
setRightCurrentDate(new Date(newLeft.getFullYear(), newLeft.getMonth() + 1));
|
|
6974
|
+
}
|
|
6975
|
+
}
|
|
6976
|
+
),
|
|
6969
6977
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xl font-extrabold", children: monthYearFormat(currentDate.getFullYear(), currentDate.getMonth()) }),
|
|
6970
6978
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "w-8" })
|
|
6971
6979
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
6972
6980
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "w-8" }),
|
|
6973
6981
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xl font-extrabold", children: monthYearFormat(currentDate.getFullYear(), currentDate.getMonth()) }),
|
|
6974
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6982
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6983
|
+
icon_button_default,
|
|
6984
|
+
{
|
|
6985
|
+
name: "right",
|
|
6986
|
+
variant: "soft",
|
|
6987
|
+
color: "neutral",
|
|
6988
|
+
onClick: () => {
|
|
6989
|
+
const newRight = new Date(rightCurrentDate.getFullYear(), rightCurrentDate.getMonth() + 1);
|
|
6990
|
+
setRightCurrentDate(newRight);
|
|
6991
|
+
setLeftCurrentDate(new Date(newRight.getFullYear(), newRight.getMonth() - 1));
|
|
6992
|
+
}
|
|
6993
|
+
}
|
|
6994
|
+
)
|
|
6975
6995
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
6976
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6996
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
6997
|
+
icon_button_default,
|
|
6998
|
+
{
|
|
6999
|
+
name: "left",
|
|
7000
|
+
variant: "soft",
|
|
7001
|
+
color: "neutral",
|
|
7002
|
+
onClick: () => {
|
|
7003
|
+
const newLeft = new Date(leftCurrentDate.getFullYear(), leftCurrentDate.getMonth() - 1);
|
|
7004
|
+
setLeftCurrentDate(newLeft);
|
|
7005
|
+
}
|
|
7006
|
+
}
|
|
7007
|
+
),
|
|
6977
7008
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "text-xl font-extrabold", children: monthYearFormat(currentDate.getFullYear(), currentDate.getMonth()) }),
|
|
6978
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7009
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7010
|
+
icon_button_default,
|
|
7011
|
+
{
|
|
7012
|
+
name: "right",
|
|
7013
|
+
variant: "soft",
|
|
7014
|
+
color: "neutral",
|
|
7015
|
+
onClick: () => {
|
|
7016
|
+
const newLeft = new Date(leftCurrentDate.getFullYear(), leftCurrentDate.getMonth() + 1);
|
|
7017
|
+
setLeftCurrentDate(newLeft);
|
|
7018
|
+
}
|
|
7019
|
+
}
|
|
7020
|
+
)
|
|
6979
7021
|
] }) }),
|
|
6980
7022
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "grid grid-cols-7", children: daysOfWeek.map((day, index) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(day_default, { variant: "text", children: day }, `${day}-${index}`)) }),
|
|
6981
7023
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "grid grid-cols-7 gap-y-[5px] text-center", children: getCalendarDates(currentDate).map((week, weekIndex) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react7.Fragment, { children: week.map((dateObj, index) => {
|
package/dist/index.js
CHANGED
|
@@ -11428,6 +11428,8 @@ var DatePicker = (0, import_react34.forwardRef)((originalProps, ref) => {
|
|
|
11428
11428
|
confirmTitle,
|
|
11429
11429
|
range = false,
|
|
11430
11430
|
dualCalendar = false,
|
|
11431
|
+
disabledDates,
|
|
11432
|
+
enabledDates,
|
|
11431
11433
|
...inputProps
|
|
11432
11434
|
} = { ...props, ...variantProps };
|
|
11433
11435
|
const [selectedDate, setSelectedDate] = (0, import_react34.useState)(range ? "" : typeof value === "string" ? value || "" : "");
|
|
@@ -11549,29 +11551,18 @@ var DatePicker = (0, import_react34.forwardRef)((originalProps, ref) => {
|
|
|
11549
11551
|
for (let i = 0; i < dates.length; i += 7) weeks.push(dates.slice(i, i + 7));
|
|
11550
11552
|
return weeks;
|
|
11551
11553
|
}, []);
|
|
11552
|
-
const
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
}
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
const newLeftDate = new Date(leftCurrentDate.getFullYear(), leftCurrentDate.getMonth() + 1);
|
|
11561
|
-
setLeftCurrentDate(newLeftDate);
|
|
11562
|
-
if (dualCalendar) {
|
|
11563
|
-
setRightCurrentDate(new Date(newLeftDate.getFullYear(), newLeftDate.getMonth() + 1));
|
|
11564
|
-
}
|
|
11565
|
-
};
|
|
11566
|
-
const handleRightNextMonth = () => {
|
|
11567
|
-
if (!dualCalendar) return;
|
|
11568
|
-
const newRightDate = new Date(rightCurrentDate.getFullYear(), rightCurrentDate.getMonth() + 1);
|
|
11569
|
-
setRightCurrentDate(newRightDate);
|
|
11570
|
-
setLeftCurrentDate(new Date(newRightDate.getFullYear(), newRightDate.getMonth() - 1));
|
|
11571
|
-
};
|
|
11554
|
+
const isDateDisabled = (0, import_react34.useCallback)(
|
|
11555
|
+
(date) => {
|
|
11556
|
+
if (enabledDates) return !enabledDates(date);
|
|
11557
|
+
if (disabledDates) return disabledDates(date);
|
|
11558
|
+
return false;
|
|
11559
|
+
},
|
|
11560
|
+
[disabledDates, enabledDates]
|
|
11561
|
+
);
|
|
11572
11562
|
const handleDateSelect = (date, isCurrentMonth, currentDate) => {
|
|
11573
11563
|
if (!isCurrentMonth) return;
|
|
11574
11564
|
const selected = new Date(currentDate.getFullYear(), currentDate.getMonth(), date);
|
|
11565
|
+
if (isDateDisabled(selected)) return;
|
|
11575
11566
|
const formatted = formatDateToString(selected);
|
|
11576
11567
|
if (range) {
|
|
11577
11568
|
if (rangeSelection === "start") {
|
|
@@ -11582,7 +11573,10 @@ var DatePicker = (0, import_react34.forwardRef)((originalProps, ref) => {
|
|
|
11582
11573
|
if (selected >= startDate) {
|
|
11583
11574
|
setTempSelectedRange({ ...tempSelectedRange, endDate: formatted });
|
|
11584
11575
|
} else {
|
|
11585
|
-
setTempSelectedRange({
|
|
11576
|
+
setTempSelectedRange({
|
|
11577
|
+
startDate: formatted,
|
|
11578
|
+
endDate: tempSelectedRange.startDate
|
|
11579
|
+
});
|
|
11586
11580
|
}
|
|
11587
11581
|
}
|
|
11588
11582
|
} else {
|
|
@@ -11591,6 +11585,7 @@ var DatePicker = (0, import_react34.forwardRef)((originalProps, ref) => {
|
|
|
11591
11585
|
};
|
|
11592
11586
|
const handleSetToday = () => {
|
|
11593
11587
|
const today = /* @__PURE__ */ new Date();
|
|
11588
|
+
if (isDateDisabled(today)) return;
|
|
11594
11589
|
const formatted = formatDateToString(today);
|
|
11595
11590
|
if (range) {
|
|
11596
11591
|
if (rangeSelection === "start") {
|
|
@@ -11601,7 +11596,10 @@ var DatePicker = (0, import_react34.forwardRef)((originalProps, ref) => {
|
|
|
11601
11596
|
if (today >= startDate) {
|
|
11602
11597
|
setTempSelectedRange({ ...tempSelectedRange, endDate: formatted });
|
|
11603
11598
|
} else {
|
|
11604
|
-
setTempSelectedRange({
|
|
11599
|
+
setTempSelectedRange({
|
|
11600
|
+
startDate: formatted,
|
|
11601
|
+
endDate: tempSelectedRange.startDate
|
|
11602
|
+
});
|
|
11605
11603
|
}
|
|
11606
11604
|
}
|
|
11607
11605
|
} else {
|
|
@@ -11613,11 +11611,11 @@ var DatePicker = (0, import_react34.forwardRef)((originalProps, ref) => {
|
|
|
11613
11611
|
const handleConfirmDate = () => {
|
|
11614
11612
|
if (isConfirmDisabled) return;
|
|
11615
11613
|
if (range) {
|
|
11616
|
-
setSelectedRange(tempSelectedRange);
|
|
11617
11614
|
onChange == null ? void 0 : onChange(tempSelectedRange);
|
|
11615
|
+
setSelectedRange(tempSelectedRange);
|
|
11618
11616
|
} else {
|
|
11619
|
-
setSelectedDate(tempSelectedDate);
|
|
11620
11617
|
onChange == null ? void 0 : onChange(tempSelectedDate);
|
|
11618
|
+
setSelectedDate(tempSelectedDate);
|
|
11621
11619
|
}
|
|
11622
11620
|
setIsPanelOpen(false);
|
|
11623
11621
|
};
|
|
@@ -11632,31 +11630,29 @@ var DatePicker = (0, import_react34.forwardRef)((originalProps, ref) => {
|
|
|
11632
11630
|
};
|
|
11633
11631
|
const getDayProps = (0, import_react34.useCallback)(
|
|
11634
11632
|
(dateObj, currentDate) => {
|
|
11633
|
+
const date = new Date(currentDate.getFullYear(), currentDate.getMonth(), dateObj.date);
|
|
11634
|
+
if (isDateDisabled(date)) return "disabled";
|
|
11635
11635
|
const today = /* @__PURE__ */ new Date();
|
|
11636
11636
|
const isToday = today.getDate() === dateObj.date && today.getMonth() === currentDate.getMonth() && today.getFullYear() === currentDate.getFullYear();
|
|
11637
11637
|
if (range) {
|
|
11638
|
-
const
|
|
11639
|
-
const
|
|
11640
|
-
const
|
|
11641
|
-
const
|
|
11642
|
-
const
|
|
11643
|
-
const isInRange =
|
|
11644
|
-
if (
|
|
11645
|
-
if (
|
|
11646
|
-
if (
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
},
|
|
11655
|
-
[tempSelectedDate, tempSelectedRange, range]
|
|
11638
|
+
const start = tempSelectedRange.startDate ? formatStringToDate(tempSelectedRange.startDate) : null;
|
|
11639
|
+
const end = tempSelectedRange.endDate ? formatStringToDate(tempSelectedRange.endDate) : null;
|
|
11640
|
+
const current = date;
|
|
11641
|
+
const isStart = start && start.getFullYear() === current.getFullYear() && start.getMonth() === current.getMonth() && start.getDate() === current.getDate();
|
|
11642
|
+
const isEnd = end && end.getFullYear() === current.getFullYear() && end.getMonth() === current.getMonth() && end.getDate() === current.getDate();
|
|
11643
|
+
const isInRange = start && end && current > start && current < end;
|
|
11644
|
+
if (isStart || isEnd) return "selected";
|
|
11645
|
+
if (isInRange) return "period";
|
|
11646
|
+
if (isToday) return "today";
|
|
11647
|
+
return dateObj.currentMonth ? "default" : "disabled";
|
|
11648
|
+
}
|
|
11649
|
+
const selected = tempSelectedDate ? formatStringToDate(tempSelectedDate) : null;
|
|
11650
|
+
const isSelected = selected && selected.getFullYear() === date.getFullYear() && selected.getMonth() === date.getMonth() && selected.getDate() === date.getDate();
|
|
11651
|
+
return isSelected ? "selected" : isToday ? "today" : dateObj.currentMonth ? "default" : "disabled";
|
|
11652
|
+
},
|
|
11653
|
+
[tempSelectedDate, tempSelectedRange, range, isDateDisabled]
|
|
11656
11654
|
);
|
|
11657
|
-
const getPlaceholderText = () =>
|
|
11658
|
-
return placeholder;
|
|
11659
|
-
};
|
|
11655
|
+
const getPlaceholderText = () => placeholder;
|
|
11660
11656
|
(0, import_react34.useEffect)(() => {
|
|
11661
11657
|
if (range && typeof value === "object") {
|
|
11662
11658
|
setSelectedRange(value || { startDate: "", endDate: "" });
|
|
@@ -11677,17 +11673,63 @@ var DatePicker = (0, import_react34.forwardRef)((originalProps, ref) => {
|
|
|
11677
11673
|
const endContent = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Icon_default, { name: "calendar", size, className: "cursor-pointer", fill: true, onClick: handleCalendarIconClick });
|
|
11678
11674
|
const renderCalendar = (currentDate, isLeft) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-col gap-[5px]", children: [
|
|
11679
11675
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: slots.calendarHead({ class: classNames == null ? void 0 : classNames.calendarHead }), children: dualCalendar ? isLeft ? /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
11680
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11676
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11677
|
+
icon_button_default,
|
|
11678
|
+
{
|
|
11679
|
+
name: "left",
|
|
11680
|
+
variant: "soft",
|
|
11681
|
+
color: "neutral",
|
|
11682
|
+
onClick: () => {
|
|
11683
|
+
const newLeft = new Date(leftCurrentDate.getFullYear(), leftCurrentDate.getMonth() - 1);
|
|
11684
|
+
setLeftCurrentDate(newLeft);
|
|
11685
|
+
setRightCurrentDate(new Date(newLeft.getFullYear(), newLeft.getMonth() + 1));
|
|
11686
|
+
}
|
|
11687
|
+
}
|
|
11688
|
+
),
|
|
11681
11689
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "text-xl font-extrabold", children: monthYearFormat(currentDate.getFullYear(), currentDate.getMonth()) }),
|
|
11682
11690
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "w-8" })
|
|
11683
11691
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
11684
11692
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "w-8" }),
|
|
11685
11693
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "text-xl font-extrabold", children: monthYearFormat(currentDate.getFullYear(), currentDate.getMonth()) }),
|
|
11686
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11694
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11695
|
+
icon_button_default,
|
|
11696
|
+
{
|
|
11697
|
+
name: "right",
|
|
11698
|
+
variant: "soft",
|
|
11699
|
+
color: "neutral",
|
|
11700
|
+
onClick: () => {
|
|
11701
|
+
const newRight = new Date(rightCurrentDate.getFullYear(), rightCurrentDate.getMonth() + 1);
|
|
11702
|
+
setRightCurrentDate(newRight);
|
|
11703
|
+
setLeftCurrentDate(new Date(newRight.getFullYear(), newRight.getMonth() - 1));
|
|
11704
|
+
}
|
|
11705
|
+
}
|
|
11706
|
+
)
|
|
11687
11707
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
11688
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11708
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11709
|
+
icon_button_default,
|
|
11710
|
+
{
|
|
11711
|
+
name: "left",
|
|
11712
|
+
variant: "soft",
|
|
11713
|
+
color: "neutral",
|
|
11714
|
+
onClick: () => {
|
|
11715
|
+
const newLeft = new Date(leftCurrentDate.getFullYear(), leftCurrentDate.getMonth() - 1);
|
|
11716
|
+
setLeftCurrentDate(newLeft);
|
|
11717
|
+
}
|
|
11718
|
+
}
|
|
11719
|
+
),
|
|
11689
11720
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: "text-xl font-extrabold", children: monthYearFormat(currentDate.getFullYear(), currentDate.getMonth()) }),
|
|
11690
|
-
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11721
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
11722
|
+
icon_button_default,
|
|
11723
|
+
{
|
|
11724
|
+
name: "right",
|
|
11725
|
+
variant: "soft",
|
|
11726
|
+
color: "neutral",
|
|
11727
|
+
onClick: () => {
|
|
11728
|
+
const newLeft = new Date(leftCurrentDate.getFullYear(), leftCurrentDate.getMonth() + 1);
|
|
11729
|
+
setLeftCurrentDate(newLeft);
|
|
11730
|
+
}
|
|
11731
|
+
}
|
|
11732
|
+
)
|
|
11691
11733
|
] }) }),
|
|
11692
11734
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "grid grid-cols-7", children: daysOfWeek.map((day, index) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(day_default, { variant: "text", children: day }, `${day}-${index}`)) }),
|
|
11693
11735
|
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "grid grid-cols-7 gap-y-[5px] text-center", children: getCalendarDates(currentDate).map((week, weekIndex) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_react34.Fragment, { children: week.map((dateObj, index) => {
|
package/dist/index.mjs
CHANGED