@underverse-ui/underverse 0.2.89 → 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 CHANGED
@@ -730,6 +730,7 @@ var defaultTranslations = {
730
730
  month: "Month",
731
731
  week: "Week",
732
732
  day: "Day",
733
+ resourcesHeader: "Resources",
733
734
  expandGroup: "Expand group",
734
735
  collapseGroup: "Collapse group",
735
736
  more: "+{n} more"
@@ -805,6 +806,7 @@ var defaultTranslations = {
805
806
  month: "Th\xE1ng",
806
807
  week: "Tu\u1EA7n",
807
808
  day: "Ng\xE0y",
809
+ resourcesHeader: "T\xE0i nguy\xEAn",
808
810
  expandGroup: "M\u1EDF nh\xF3m",
809
811
  collapseGroup: "Thu g\u1ECDn nh\xF3m",
810
812
  more: "+{n} th\xEAm"
@@ -880,6 +882,7 @@ var defaultTranslations = {
880
882
  month: "\uC6D4",
881
883
  week: "\uC8FC",
882
884
  day: "\uC77C",
885
+ resourcesHeader: "\uB9AC\uC18C\uC2A4",
883
886
  expandGroup: "\uADF8\uB8F9 \uD3BC\uCE58\uAE30",
884
887
  collapseGroup: "\uADF8\uB8F9 \uC811\uAE30",
885
888
  more: "+{n}\uAC1C \uB354"
@@ -955,6 +958,7 @@ var defaultTranslations = {
955
958
  month: "\u6708",
956
959
  week: "\u9031",
957
960
  day: "\u65E5",
961
+ resourcesHeader: "\u30EA\u30BD\u30FC\u30B9",
958
962
  expandGroup: "\u30B0\u30EB\u30FC\u30D7\u3092\u5C55\u958B",
959
963
  collapseGroup: "\u30B0\u30EB\u30FC\u30D7\u3092\u6298\u308A\u305F\u305F\u3080",
960
964
  more: "+{n}\u4EF6"
@@ -5755,11 +5759,6 @@ var ScrollArea = (0, import_react14.forwardRef)(
5755
5759
  );
5756
5760
  ScrollArea.displayName = "ScrollArea";
5757
5761
 
5758
- // ../../components/ui/DatePicker.tsx
5759
- var React23 = __toESM(require("react"), 1);
5760
- var import_react15 = require("react");
5761
- var import_lucide_react14 = require("lucide-react");
5762
-
5763
5762
  // ../../lib/utils/date.ts
5764
5763
  function formatDateShort(date) {
5765
5764
  if (!date) return "";
@@ -5773,6 +5772,9 @@ function formatDateShort(date) {
5773
5772
  }
5774
5773
 
5775
5774
  // ../../components/ui/DatePicker.tsx
5775
+ var import_lucide_react14 = require("lucide-react");
5776
+ var React23 = __toESM(require("react"), 1);
5777
+ var import_react15 = require("react");
5776
5778
  var import_jsx_runtime29 = require("react/jsx-runtime");
5777
5779
  var DatePicker = ({
5778
5780
  id,
@@ -5787,7 +5789,9 @@ var DatePicker = ({
5787
5789
  todayLabel,
5788
5790
  clearLabel,
5789
5791
  weekdayLabels,
5790
- disablePastDates = false
5792
+ disablePastDates = false,
5793
+ minDate,
5794
+ maxDate
5791
5795
  }) => {
5792
5796
  const t = useTranslations("DatePicker");
5793
5797
  const locale = useLocale();
@@ -5797,6 +5801,27 @@ var DatePicker = ({
5797
5801
  const triggerRef = React23.useRef(null);
5798
5802
  const wheelContainerRef = React23.useRef(null);
5799
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
+ );
5800
5825
  useShadCNAnimations();
5801
5826
  React23.useEffect(() => {
5802
5827
  if (value) {
@@ -5881,21 +5906,19 @@ var DatePicker = ({
5881
5906
  for (let i = 0; i < firstDayOfMonth; i++) {
5882
5907
  days.push(/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: size === "sm" ? "w-7 h-7" : "w-8 h-8" }, `empty-${i}`));
5883
5908
  }
5884
- const today = /* @__PURE__ */ new Date();
5885
- today.setHours(0, 0, 0, 0);
5886
5909
  for (let day = 1; day <= daysInMonth; day++) {
5887
5910
  const date = new Date(viewDate.getFullYear(), viewDate.getMonth(), day);
5888
5911
  const isSelected = value && date.getDate() === value.getDate() && date.getMonth() === value.getMonth() && date.getFullYear() === value.getFullYear();
5889
5912
  const isToday2 = date.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
5890
- const isPastDate = disablePastDates && date < today;
5913
+ const isDisabled = isDateDisabled(date);
5891
5914
  const totalDaysFromStart = firstDayOfMonth + day - 1;
5892
5915
  const rowIndex = Math.floor(totalDaysFromStart / 7);
5893
5916
  days.push(
5894
5917
  /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
5895
5918
  "button",
5896
5919
  {
5897
- onClick: () => !isPastDate && handleDateSelect(date),
5898
- disabled: isPastDate,
5920
+ onClick: () => !isDisabled && handleDateSelect(date),
5921
+ disabled: isDisabled,
5899
5922
  style: {
5900
5923
  animationDelay: isOpen ? `${rowIndex * 40}ms` : "0ms"
5901
5924
  },
@@ -5903,8 +5926,8 @@ var DatePicker = ({
5903
5926
  size === "sm" ? "w-7 h-7 text-[12px]" : "w-8 h-8 text-sm",
5904
5927
  "datepicker-day rounded-lg focus:outline-none relative cursor-pointer",
5905
5928
  "transition-all duration-200 font-medium",
5906
- isPastDate && "opacity-30 cursor-not-allowed text-muted-foreground",
5907
- 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" : !isPastDate && "hover:bg-accent/80 hover:text-accent-foreground hover:scale-105 focus:bg-accent focus:text-accent-foreground",
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",
5908
5931
  isToday2 && !isSelected && "bg-primary/15 text-primary font-bold ring-2 ring-primary/30"
5909
5932
  ),
5910
5933
  children: [
@@ -6052,15 +6075,18 @@ var DatePicker = ({
6052
6075
  type: "button",
6053
6076
  onClick: () => {
6054
6077
  const today = /* @__PURE__ */ new Date();
6078
+ if (isDateDisabled(today)) return;
6055
6079
  handleDateSelect(today);
6056
6080
  },
6081
+ disabled: isDateDisabled(/* @__PURE__ */ new Date()),
6057
6082
  className: cn(
6058
6083
  "flex-1 font-semibold rounded-xl",
6059
6084
  "bg-linear-to-r from-primary/10 to-primary/5 border border-primary/30",
6060
6085
  "text-primary hover:from-primary/20 hover:to-primary/10 hover:border-primary/50",
6061
6086
  "transition-all duration-300 flex items-center justify-center",
6062
6087
  "hover:scale-[1.02] active:scale-[0.98] hover:shadow-md hover:shadow-primary/10",
6063
- 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"
6064
6090
  ),
6065
6091
  children: [
6066
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" }),
@@ -6219,7 +6245,7 @@ var DatePicker = ({
6219
6245
  )
6220
6246
  ] });
6221
6247
  };
6222
- 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" }) => {
6223
6249
  const locale = useLocale();
6224
6250
  const t = useTranslations("DatePicker");
6225
6251
  const [isOpen, setIsOpen] = React23.useState(false);
@@ -6229,6 +6255,8 @@ var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select dat
6229
6255
  if (!date) return null;
6230
6256
  return new Date(date.getFullYear(), date.getMonth(), date.getDate());
6231
6257
  };
6258
+ const minDay = React23.useMemo(() => normalizeToLocal(minDate), [minDate]);
6259
+ const maxDay = React23.useMemo(() => normalizeToLocal(maxDate), [maxDate]);
6232
6260
  const [viewDate, setViewDate] = React23.useState(startDate || /* @__PURE__ */ new Date());
6233
6261
  const [tempStart, setTempStart] = React23.useState(normalizeToLocal(startDate));
6234
6262
  const [tempEnd, setTempEnd] = React23.useState(normalizeToLocal(endDate));
@@ -6308,6 +6336,8 @@ var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select dat
6308
6336
  for (let d = 1; d <= daysInMonth; d++) {
6309
6337
  const date = new Date(viewDate.getFullYear(), viewDate.getMonth(), d);
6310
6338
  const isPastDate = disablePastDates && date < today;
6339
+ const isOutOfRange = !!minDay && date < minDay || !!maxDay && date > maxDay;
6340
+ const isDisabled = isPastDate || isOutOfRange;
6311
6341
  const isSelectedStart = isSameDay2(date, tempStart);
6312
6342
  const isSelectedEnd = isSameDay2(date, tempEnd);
6313
6343
  const isHovering = hoveredDate && tempStart && !tempEnd;
@@ -6333,17 +6363,17 @@ var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select dat
6333
6363
  /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
6334
6364
  "button",
6335
6365
  {
6336
- onClick: () => !isPastDate && handleSelect(date),
6337
- disabled: isPastDate,
6338
- onMouseEnter: () => !isPastDate && tempStart && !tempEnd && setHoveredDate(date),
6366
+ onClick: () => !isDisabled && handleSelect(date),
6367
+ disabled: isDisabled,
6368
+ onMouseEnter: () => !isDisabled && tempStart && !tempEnd && setHoveredDate(date),
6339
6369
  onMouseLeave: () => tempStart && !tempEnd && setHoveredDate(null),
6340
6370
  className: cn(
6341
6371
  "transition-all duration-200 focus:outline-none relative font-medium cursor-pointer",
6342
6372
  size === "sm" ? "w-6 h-6 text-xs" : "w-8 h-8 text-sm",
6343
6373
  // Disabled/past date state
6344
- isPastDate && "opacity-30 cursor-not-allowed text-muted-foreground",
6374
+ isDisabled && "opacity-30 cursor-not-allowed text-muted-foreground",
6345
6375
  // Default state
6346
- !isPastDate && !isInRange && !isRangeStart && !isRangeEnd && "hover:bg-accent/80 hover:text-accent-foreground hover:scale-105 rounded-lg",
6376
+ !isDisabled && !isInRange && !isRangeStart && !isRangeEnd && "hover:bg-accent/80 hover:text-accent-foreground hover:scale-105 rounded-lg",
6347
6377
  // Range selection styling - smooth continuous background with gradient
6348
6378
  isInRange && "bg-primary/15 text-foreground",
6349
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",
@@ -6353,8 +6383,8 @@ var DateRangePicker = ({ startDate, endDate, onChange, placeholder = "Select dat
6353
6383
  isRangeStart && isRangeEnd && "rounded-lg",
6354
6384
  // Single day selection
6355
6385
  // Hover effects for range
6356
- isInRange && !isPastDate && "hover:bg-primary/25",
6357
- !isPastDate && "focus:bg-accent focus:text-accent-foreground focus:z-10 focus:shadow-md"
6386
+ isInRange && !isDisabled && "hover:bg-primary/25",
6387
+ !isDisabled && "focus:bg-accent focus:text-accent-foreground focus:z-10 focus:shadow-md"
6358
6388
  ),
6359
6389
  children: d
6360
6390
  },
@@ -16141,6 +16171,7 @@ var en_default = {
16141
16171
  month: "Month",
16142
16172
  week: "Week",
16143
16173
  day: "Day",
16174
+ resourcesHeader: "Resources",
16144
16175
  expandGroup: "Expand group",
16145
16176
  collapseGroup: "Collapse group",
16146
16177
  more: "+{n} more"
@@ -16227,6 +16258,7 @@ var vi_default = {
16227
16258
  month: "Th\xE1ng",
16228
16259
  week: "Tu\u1EA7n",
16229
16260
  day: "Ng\xE0y",
16261
+ resourcesHeader: "T\xE0i nguy\xEAn",
16230
16262
  expandGroup: "M\u1EDF nh\xF3m",
16231
16263
  collapseGroup: "Thu g\u1ECDn nh\xF3m",
16232
16264
  more: "+{n} th\xEAm"
@@ -16313,6 +16345,7 @@ var ko_default = {
16313
16345
  month: "\uC6D4",
16314
16346
  week: "\uC8FC",
16315
16347
  day: "\uC77C",
16348
+ resourcesHeader: "\uB9AC\uC18C\uC2A4",
16316
16349
  expandGroup: "\uADF8\uB8F9 \uD3BC\uCE58\uAE30",
16317
16350
  collapseGroup: "\uADF8\uB8F9 \uC811\uAE30",
16318
16351
  more: "+{n}\uAC1C \uB354"
@@ -16399,6 +16432,7 @@ var ja_default = {
16399
16432
  month: "\u6708",
16400
16433
  week: "\u9031",
16401
16434
  day: "\u65E5",
16435
+ resourcesHeader: "\u30EA\u30BD\u30FC\u30B9",
16402
16436
  expandGroup: "\u30B0\u30EB\u30FC\u30D7\u3092\u5C55\u958B",
16403
16437
  collapseGroup: "\u30B0\u30EB\u30FC\u30D7\u3092\u6298\u308A\u305F\u305F\u3080",
16404
16438
  more: "+{n}\u4EF6"