@underverse-ui/underverse 0.1.21 → 0.1.23
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 +78 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +79 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4764,6 +4764,7 @@ var DatePicker = ({
|
|
|
4764
4764
|
const [dropdownPosition, setDropdownPosition] = React21.useState(null);
|
|
4765
4765
|
const [viewDate, setViewDate] = React21.useState(value || /* @__PURE__ */ new Date());
|
|
4766
4766
|
const triggerRef = React21.useRef(null);
|
|
4767
|
+
const dropdownRef = React21.useRef(null);
|
|
4767
4768
|
useShadCNAnimations();
|
|
4768
4769
|
const calculatePosition = React21.useCallback(() => {
|
|
4769
4770
|
if (!triggerRef.current) return null;
|
|
@@ -4789,15 +4790,24 @@ var DatePicker = ({
|
|
|
4789
4790
|
window.removeEventListener("scroll", handler, true);
|
|
4790
4791
|
};
|
|
4791
4792
|
}, [isOpen, calculatePosition]);
|
|
4793
|
+
React21.useEffect(() => {
|
|
4794
|
+
if (value) {
|
|
4795
|
+
setViewDate(value);
|
|
4796
|
+
} else {
|
|
4797
|
+
setViewDate(/* @__PURE__ */ new Date());
|
|
4798
|
+
}
|
|
4799
|
+
}, [value]);
|
|
4792
4800
|
React21.useEffect(() => {
|
|
4793
4801
|
if (!isOpen) return;
|
|
4794
4802
|
const handleClickOutside = (event) => {
|
|
4795
4803
|
const target = event.target;
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4804
|
+
const trigger = triggerRef.current;
|
|
4805
|
+
const dropdown = dropdownRef.current;
|
|
4806
|
+
if (!trigger || !dropdown) return;
|
|
4807
|
+
const clickedOutsideTrigger = !trigger.contains(target);
|
|
4808
|
+
const clickedOutsideDropdown = !dropdown.contains(target);
|
|
4809
|
+
if (clickedOutsideTrigger && clickedOutsideDropdown) {
|
|
4810
|
+
setIsOpen(false);
|
|
4801
4811
|
}
|
|
4802
4812
|
};
|
|
4803
4813
|
const handleEscape = (event) => {
|
|
@@ -4813,11 +4823,18 @@ var DatePicker = ({
|
|
|
4813
4823
|
};
|
|
4814
4824
|
}, [isOpen]);
|
|
4815
4825
|
const handleDateSelect = (date) => {
|
|
4816
|
-
|
|
4826
|
+
let selectedDate;
|
|
4827
|
+
if (value && (value.getHours() !== 0 || value.getMinutes() !== 0 || value.getSeconds() !== 0)) {
|
|
4828
|
+
selectedDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), value.getHours(), value.getMinutes(), value.getSeconds());
|
|
4829
|
+
} else {
|
|
4830
|
+
const now = /* @__PURE__ */ new Date();
|
|
4831
|
+
selectedDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
|
|
4832
|
+
}
|
|
4833
|
+
onChange(selectedDate);
|
|
4817
4834
|
setIsOpen(false);
|
|
4818
4835
|
};
|
|
4819
4836
|
const formatDateDisplay = (date) => {
|
|
4820
|
-
return
|
|
4837
|
+
return formatDate(date);
|
|
4821
4838
|
};
|
|
4822
4839
|
const getDaysInMonth = (date) => {
|
|
4823
4840
|
return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
|
@@ -4878,7 +4895,8 @@ var DatePicker = ({
|
|
|
4878
4895
|
top: dropdownPosition?.top || 0,
|
|
4879
4896
|
left: dropdownPosition?.left || 0,
|
|
4880
4897
|
width: size === "sm" ? dropdownPosition?.width || 224 : dropdownPosition?.width || 256,
|
|
4881
|
-
zIndex: 9999
|
|
4898
|
+
zIndex: 9999,
|
|
4899
|
+
pointerEvents: "none"
|
|
4882
4900
|
},
|
|
4883
4901
|
"data-state": isOpen ? "open" : "closed",
|
|
4884
4902
|
className: cn(
|
|
@@ -4889,11 +4907,13 @@ var DatePicker = ({
|
|
|
4889
4907
|
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
4890
4908
|
"div",
|
|
4891
4909
|
{
|
|
4910
|
+
ref: dropdownRef,
|
|
4892
4911
|
className: cn(
|
|
4893
4912
|
"rounded-md border bg-popover text-popover-foreground shadow-md",
|
|
4894
4913
|
"backdrop-blur-sm bg-popover/95 border-border/60",
|
|
4895
4914
|
size === "sm" ? "p-3 w-56" : "p-4 w-64"
|
|
4896
4915
|
),
|
|
4916
|
+
style: { pointerEvents: "auto" },
|
|
4897
4917
|
children: [
|
|
4898
4918
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center justify-between mb-4", children: [
|
|
4899
4919
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Button_default, { variant: "ghost", size: "sm", onClick: () => navigateMonth("prev"), className: "p-1 h-auto", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react14.ChevronLeft, { className: "h-4 w-4" }) }),
|
|
@@ -4901,7 +4921,20 @@ var DatePicker = ({
|
|
|
4901
4921
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Button_default, { variant: "ghost", size: "sm", onClick: () => navigateMonth("next"), className: "p-1 h-auto", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react14.ChevronRight, { className: "h-4 w-4" }) })
|
|
4902
4922
|
] }),
|
|
4903
4923
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cn("grid grid-cols-7 gap-1", size === "sm" ? "mb-1" : "mb-2"), children: (weekdayLabels || ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]).map((day) => /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: cn("text-muted-foreground text-center font-medium", size === "sm" ? "text-[10px] py-0.5" : "text-xs py-1"), children: day }, day)) }),
|
|
4904
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "grid grid-cols-7 gap-1", children: renderCalendar() })
|
|
4924
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "grid grid-cols-7 gap-1", children: renderCalendar() }),
|
|
4925
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex items-center justify-end mt-2", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4926
|
+
Button_default,
|
|
4927
|
+
{
|
|
4928
|
+
variant: "outline",
|
|
4929
|
+
size: "sm",
|
|
4930
|
+
onClick: () => {
|
|
4931
|
+
onChange(void 0);
|
|
4932
|
+
setIsOpen(false);
|
|
4933
|
+
setViewDate(/* @__PURE__ */ new Date());
|
|
4934
|
+
},
|
|
4935
|
+
children: clearLabel || t("clear")
|
|
4936
|
+
}
|
|
4937
|
+
) })
|
|
4905
4938
|
]
|
|
4906
4939
|
}
|
|
4907
4940
|
)
|
|
@@ -4959,6 +4992,31 @@ var DatePicker = ({
|
|
|
4959
4992
|
),
|
|
4960
4993
|
children: [
|
|
4961
4994
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: cn("truncate", !value && "text-muted-foreground"), children: value ? formatDateDisplay(value) : placeholder || t("placeholder") }),
|
|
4995
|
+
value && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
4996
|
+
"span",
|
|
4997
|
+
{
|
|
4998
|
+
role: "button",
|
|
4999
|
+
"aria-label": clearLabel || t("clear"),
|
|
5000
|
+
tabIndex: 0,
|
|
5001
|
+
onClick: (e) => {
|
|
5002
|
+
e.preventDefault();
|
|
5003
|
+
e.stopPropagation();
|
|
5004
|
+
onChange(void 0);
|
|
5005
|
+
setViewDate(/* @__PURE__ */ new Date());
|
|
5006
|
+
},
|
|
5007
|
+
onKeyDown: (e) => {
|
|
5008
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
5009
|
+
e.preventDefault();
|
|
5010
|
+
e.stopPropagation();
|
|
5011
|
+
onChange(void 0);
|
|
5012
|
+
setViewDate(/* @__PURE__ */ new Date());
|
|
5013
|
+
}
|
|
5014
|
+
},
|
|
5015
|
+
className: "absolute right-8 inline-flex items-center justify-center rounded-sm text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors cursor-pointer",
|
|
5016
|
+
style: { width: 20, height: 20 },
|
|
5017
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react14.X, { className: "h-3.5 w-3.5" })
|
|
5018
|
+
}
|
|
5019
|
+
),
|
|
4962
5020
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_lucide_react14.Calendar, { className: "h-4 w-4 text-muted-foreground ml-2" })
|
|
4963
5021
|
]
|
|
4964
5022
|
}
|
|
@@ -5383,14 +5441,23 @@ var MultiCombobox = ({
|
|
|
5383
5441
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("span", { className: "inline-flex items-center gap-1 bg-accent text-accent-foreground rounded px-2 py-1 text-xs", children: [
|
|
5384
5442
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "truncate max-w-[120px]", children: option ? displayFormat(option) : itemValue }),
|
|
5385
5443
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
5386
|
-
"
|
|
5444
|
+
"div",
|
|
5387
5445
|
{
|
|
5388
|
-
|
|
5446
|
+
role: "button",
|
|
5447
|
+
tabIndex: 0,
|
|
5448
|
+
"aria-label": `Remove ${option ? option.label : itemValue}`,
|
|
5389
5449
|
onClick: (e) => {
|
|
5390
5450
|
e.preventDefault();
|
|
5391
5451
|
e.stopPropagation();
|
|
5392
5452
|
handleRemove(itemValue);
|
|
5393
5453
|
},
|
|
5454
|
+
onKeyDown: (e) => {
|
|
5455
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
5456
|
+
e.preventDefault();
|
|
5457
|
+
e.stopPropagation();
|
|
5458
|
+
handleRemove(itemValue);
|
|
5459
|
+
}
|
|
5460
|
+
},
|
|
5394
5461
|
className: "hover:text-destructive transition-colors cursor-pointer",
|
|
5395
5462
|
children: "\xD7"
|
|
5396
5463
|
}
|