@underverse-ui/underverse 0.2.90 → 0.2.91
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/dist/index.cjs +45 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +68 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5789,7 +5789,9 @@ var DatePicker = ({
|
|
|
5789
5789
|
todayLabel,
|
|
5790
5790
|
clearLabel,
|
|
5791
5791
|
weekdayLabels,
|
|
5792
|
-
disablePastDates = false
|
|
5792
|
+
disablePastDates = false,
|
|
5793
|
+
minDate,
|
|
5794
|
+
maxDate
|
|
5793
5795
|
}) => {
|
|
5794
5796
|
const t = useTranslations("DatePicker");
|
|
5795
5797
|
const locale = useLocale();
|
|
@@ -5799,6 +5801,27 @@ var DatePicker = ({
|
|
|
5799
5801
|
const triggerRef = React23.useRef(null);
|
|
5800
5802
|
const wheelContainerRef = React23.useRef(null);
|
|
5801
5803
|
const wheelDeltaRef = React23.useRef(0);
|
|
5804
|
+
const normalizeToLocalDay = React23.useCallback((date) => {
|
|
5805
|
+
if (!date) return null;
|
|
5806
|
+
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
5807
|
+
}, []);
|
|
5808
|
+
const minDay = React23.useMemo(() => normalizeToLocalDay(minDate), [minDate, normalizeToLocalDay]);
|
|
5809
|
+
const maxDay = React23.useMemo(() => normalizeToLocalDay(maxDate), [maxDate, normalizeToLocalDay]);
|
|
5810
|
+
const isDateDisabled = React23.useCallback(
|
|
5811
|
+
(date) => {
|
|
5812
|
+
const day = normalizeToLocalDay(date);
|
|
5813
|
+
if (!day) return false;
|
|
5814
|
+
if (disablePastDates) {
|
|
5815
|
+
const today = /* @__PURE__ */ new Date();
|
|
5816
|
+
today.setHours(0, 0, 0, 0);
|
|
5817
|
+
if (day < today) return true;
|
|
5818
|
+
}
|
|
5819
|
+
if (minDay && day < minDay) return true;
|
|
5820
|
+
if (maxDay && day > maxDay) return true;
|
|
5821
|
+
return false;
|
|
5822
|
+
},
|
|
5823
|
+
[disablePastDates, maxDay, minDay, normalizeToLocalDay]
|
|
5824
|
+
);
|
|
5802
5825
|
useShadCNAnimations();
|
|
5803
5826
|
React23.useEffect(() => {
|
|
5804
5827
|
if (value) {
|
|
@@ -5883,21 +5906,19 @@ var DatePicker = ({
|
|
|
5883
5906
|
for (let i = 0; i < firstDayOfMonth; i++) {
|
|
5884
5907
|
days.push(/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: size === "sm" ? "w-7 h-7" : "w-8 h-8" }, `empty-${i}`));
|
|
5885
5908
|
}
|
|
5886
|
-
const today = /* @__PURE__ */ new Date();
|
|
5887
|
-
today.setHours(0, 0, 0, 0);
|
|
5888
5909
|
for (let day = 1; day <= daysInMonth; day++) {
|
|
5889
5910
|
const date = new Date(viewDate.getFullYear(), viewDate.getMonth(), day);
|
|
5890
5911
|
const isSelected = value && date.getDate() === value.getDate() && date.getMonth() === value.getMonth() && date.getFullYear() === value.getFullYear();
|
|
5891
5912
|
const isToday2 = date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
|
|
5892
|
-
const
|
|
5913
|
+
const isDisabled = isDateDisabled(date);
|
|
5893
5914
|
const totalDaysFromStart = firstDayOfMonth + day - 1;
|
|
5894
5915
|
const rowIndex = Math.floor(totalDaysFromStart / 7);
|
|
5895
5916
|
days.push(
|
|
5896
5917
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
5897
5918
|
"button",
|
|
5898
5919
|
{
|
|
5899
|
-
onClick: () => !
|
|
5900
|
-
disabled:
|
|
5920
|
+
onClick: () => !isDisabled && handleDateSelect(date),
|
|
5921
|
+
disabled: isDisabled,
|
|
5901
5922
|
style: {
|
|
5902
5923
|
animationDelay: isOpen ? `${rowIndex * 40}ms` : "0ms"
|
|
5903
5924
|
},
|
|
@@ -5905,8 +5926,8 @@ var DatePicker = ({
|
|
|
5905
5926
|
size === "sm" ? "w-7 h-7 text-[12px]" : "w-8 h-8 text-sm",
|
|
5906
5927
|
"datepicker-day rounded-lg focus:outline-none relative cursor-pointer",
|
|
5907
5928
|
"transition-all duration-200 font-medium",
|
|
5908
|
-
|
|
5909
|
-
isSelected ? "bg-linear-to-br from-primary to-primary/80 text-primary-foreground font-bold shadow-lg shadow-primary/30 scale-110 z-10 hover:from-primary hover:to-primary/70" : !
|
|
5929
|
+
isDisabled && "opacity-30 cursor-not-allowed text-muted-foreground",
|
|
5930
|
+
isSelected ? "bg-linear-to-br from-primary to-primary/80 text-primary-foreground font-bold shadow-lg shadow-primary/30 scale-110 z-10 hover:from-primary hover:to-primary/70" : !isDisabled && "hover:bg-accent/80 hover:text-accent-foreground hover:scale-105 focus:bg-accent focus:text-accent-foreground",
|
|
5910
5931
|
isToday2 && !isSelected && "bg-primary/15 text-primary font-bold ring-2 ring-primary/30"
|
|
5911
5932
|
),
|
|
5912
5933
|
children: [
|
|
@@ -6054,15 +6075,18 @@ var DatePicker = ({
|
|
|
6054
6075
|
type: "button",
|
|
6055
6076
|
onClick: () => {
|
|
6056
6077
|
const today = /* @__PURE__ */ new Date();
|
|
6078
|
+
if (isDateDisabled(today)) return;
|
|
6057
6079
|
handleDateSelect(today);
|
|
6058
6080
|
},
|
|
6081
|
+
disabled: isDateDisabled(/* @__PURE__ */ new Date()),
|
|
6059
6082
|
className: cn(
|
|
6060
6083
|
"flex-1 font-semibold rounded-xl",
|
|
6061
6084
|
"bg-linear-to-r from-primary/10 to-primary/5 border border-primary/30",
|
|
6062
6085
|
"text-primary hover:from-primary/20 hover:to-primary/10 hover:border-primary/50",
|
|
6063
6086
|
"transition-all duration-300 flex items-center justify-center",
|
|
6064
6087
|
"hover:scale-[1.02] active:scale-[0.98] hover:shadow-md hover:shadow-primary/10",
|
|
6065
|
-
size === "sm" ? "px-2 py-1 text-[10px] gap-1" : "px-3 py-2 text-xs gap-2"
|
|
6088
|
+
size === "sm" ? "px-2 py-1 text-[10px] gap-1" : "px-3 py-2 text-xs gap-2",
|
|
6089
|
+
isDateDisabled(/* @__PURE__ */ new Date()) && "opacity-50 cursor-not-allowed hover:scale-100 active:scale-100"
|
|
6066
6090
|
),
|
|
6067
6091
|
children: [
|
|
6068
6092
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_lucide_react14.Sparkles, { className: size === "sm" ? "w-2.5 h-2.5" : "w-3.5 h-3.5" }),
|
|
@@ -6221,7 +6245,7 @@ var DatePicker = ({
|
|
|
6221
6245
|
)
|
|
6222
6246
|
] });
|
|
6223
6247
|
};
|
|
6224
|
-
var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select date range...", className, disablePastDates = false, size = "md" }) => {
|
|
6248
|
+
var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select date range...", className, disablePastDates = false, minDate, maxDate, size = "md" }) => {
|
|
6225
6249
|
const locale = useLocale();
|
|
6226
6250
|
const t = useTranslations("DatePicker");
|
|
6227
6251
|
const [isOpen, setIsOpen] = React23.useState(false);
|
|
@@ -6231,6 +6255,8 @@ var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select dat
|
|
|
6231
6255
|
if (!date) return null;
|
|
6232
6256
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
6233
6257
|
};
|
|
6258
|
+
const minDay = React23.useMemo(() => normalizeToLocal(minDate), [minDate]);
|
|
6259
|
+
const maxDay = React23.useMemo(() => normalizeToLocal(maxDate), [maxDate]);
|
|
6234
6260
|
const [viewDate, setViewDate] = React23.useState(startDate || /* @__PURE__ */ new Date());
|
|
6235
6261
|
const [tempStart, setTempStart] = React23.useState(normalizeToLocal(startDate));
|
|
6236
6262
|
const [tempEnd, setTempEnd] = React23.useState(normalizeToLocal(endDate));
|
|
@@ -6310,6 +6336,8 @@ var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select dat
|
|
|
6310
6336
|
for (let d = 1; d <= daysInMonth; d++) {
|
|
6311
6337
|
const date = new Date(viewDate.getFullYear(), viewDate.getMonth(), d);
|
|
6312
6338
|
const isPastDate = disablePastDates && date < today;
|
|
6339
|
+
const isOutOfRange = !!minDay && date < minDay || !!maxDay && date > maxDay;
|
|
6340
|
+
const isDisabled = isPastDate || isOutOfRange;
|
|
6313
6341
|
const isSelectedStart = isSameDay2(date, tempStart);
|
|
6314
6342
|
const isSelectedEnd = isSameDay2(date, tempEnd);
|
|
6315
6343
|
const isHovering = hoveredDate && tempStart && !tempEnd;
|
|
@@ -6335,17 +6363,17 @@ var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select dat
|
|
|
6335
6363
|
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
6336
6364
|
"button",
|
|
6337
6365
|
{
|
|
6338
|
-
onClick: () => !
|
|
6339
|
-
disabled:
|
|
6340
|
-
onMouseEnter: () => !
|
|
6366
|
+
onClick: () => !isDisabled && handleSelect(date),
|
|
6367
|
+
disabled: isDisabled,
|
|
6368
|
+
onMouseEnter: () => !isDisabled && tempStart && !tempEnd && setHoveredDate(date),
|
|
6341
6369
|
onMouseLeave: () => tempStart && !tempEnd && setHoveredDate(null),
|
|
6342
6370
|
className: cn(
|
|
6343
6371
|
"transition-all duration-200 focus:outline-none relative font-medium cursor-pointer",
|
|
6344
6372
|
size === "sm" ? "w-6 h-6 text-xs" : "w-8 h-8 text-sm",
|
|
6345
6373
|
// Disabled/past date state
|
|
6346
|
-
|
|
6374
|
+
isDisabled && "opacity-30 cursor-not-allowed text-muted-foreground",
|
|
6347
6375
|
// Default state
|
|
6348
|
-
!
|
|
6376
|
+
!isDisabled && !isInRange && !isRangeStart && !isRangeEnd && "hover:bg-accent/80 hover:text-accent-foreground hover:scale-105 rounded-lg",
|
|
6349
6377
|
// Range selection styling - smooth continuous background with gradient
|
|
6350
6378
|
isInRange && "bg-primary/15 text-foreground",
|
|
6351
6379
|
(isRangeStart || isRangeEnd) && "bg-linear-to-br from-primary to-primary/80 text-primary-foreground hover:from-primary hover:to-primary/70 shadow-lg shadow-primary/25",
|
|
@@ -6355,8 +6383,8 @@ var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select dat
|
|
|
6355
6383
|
isRangeStart && isRangeEnd && "rounded-lg",
|
|
6356
6384
|
// Single day selection
|
|
6357
6385
|
// Hover effects for range
|
|
6358
|
-
isInRange && !
|
|
6359
|
-
!
|
|
6386
|
+
isInRange && !isDisabled && "hover:bg-primary/25",
|
|
6387
|
+
!isDisabled && "focus:bg-accent focus:text-accent-foreground focus:z-10 focus:shadow-md"
|
|
6360
6388
|
),
|
|
6361
6389
|
children: d
|
|
6362
6390
|
},
|