@underverse-ui/underverse 1.0.124 → 1.0.126
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/CHANGELOG.md +12 -0
- package/api-reference.json +1 -1
- package/dist/index.cjs +1336 -942
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -2
- package/dist/index.d.ts +48 -2
- package/dist/index.js +1469 -1076
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -874,6 +874,9 @@ var en_default = {
|
|
|
874
874
|
accent: "Accent",
|
|
875
875
|
textColor: "Text Color",
|
|
876
876
|
highlight: "Highlight",
|
|
877
|
+
automatic: "Automatic",
|
|
878
|
+
moreColors: "More Colors...",
|
|
879
|
+
color: "Color",
|
|
877
880
|
done: "Done"
|
|
878
881
|
},
|
|
879
882
|
toolbar: {
|
|
@@ -888,6 +891,7 @@ var en_default = {
|
|
|
888
891
|
subscript: "Subscript",
|
|
889
892
|
superscript: "Superscript",
|
|
890
893
|
link: "Link",
|
|
894
|
+
removeLink: "Remove Link",
|
|
891
895
|
image: "Insert Image",
|
|
892
896
|
table: "Insert Table",
|
|
893
897
|
alignment: "Alignment",
|
|
@@ -1139,6 +1143,9 @@ var vi_default = {
|
|
|
1139
1143
|
accent: "Nh\u1EA5n",
|
|
1140
1144
|
textColor: "M\xE0u ch\u1EEF",
|
|
1141
1145
|
highlight: "N\u1ED5i b\u1EADt",
|
|
1146
|
+
automatic: "T\u1EF1 \u0111\u1ED9ng",
|
|
1147
|
+
moreColors: "Th\xEAm m\xE0u...",
|
|
1148
|
+
color: "M\xE0u",
|
|
1142
1149
|
done: "Xong"
|
|
1143
1150
|
},
|
|
1144
1151
|
toolbar: {
|
|
@@ -1153,6 +1160,7 @@ var vi_default = {
|
|
|
1153
1160
|
subscript: "Ch\u1EC9 s\u1ED1 d\u01B0\u1EDBi",
|
|
1154
1161
|
superscript: "Ch\u1EC9 s\u1ED1 tr\xEAn",
|
|
1155
1162
|
link: "Li\xEAn k\u1EBFt",
|
|
1163
|
+
removeLink: "G\u1EE1 li\xEAn k\u1EBFt",
|
|
1156
1164
|
image: "Ch\xE8n \u1EA3nh",
|
|
1157
1165
|
table: "Ch\xE8n b\u1EA3ng",
|
|
1158
1166
|
alignment: "C\u0103n ch\u1EC9nh",
|
|
@@ -1404,6 +1412,9 @@ var ko_default = {
|
|
|
1404
1412
|
accent: "\uAC15\uC870",
|
|
1405
1413
|
textColor: "\uD14D\uC2A4\uD2B8 \uC0C9\uC0C1",
|
|
1406
1414
|
highlight: "\uD615\uAD11\uD39C",
|
|
1415
|
+
automatic: "\uC790\uB3D9",
|
|
1416
|
+
moreColors: "\uB2E4\uB978 \uC0C9...",
|
|
1417
|
+
color: "\uC0C9\uC0C1",
|
|
1407
1418
|
done: "\uC644\uB8CC"
|
|
1408
1419
|
},
|
|
1409
1420
|
toolbar: {
|
|
@@ -1418,6 +1429,7 @@ var ko_default = {
|
|
|
1418
1429
|
subscript: "\uC544\uB798 \uCCA8\uC790",
|
|
1419
1430
|
superscript: "\uC704 \uCCA8\uC790",
|
|
1420
1431
|
link: "\uB9C1\uD06C",
|
|
1432
|
+
removeLink: "\uB9C1\uD06C \uC81C\uAC70",
|
|
1421
1433
|
image: "\uC774\uBBF8\uC9C0",
|
|
1422
1434
|
table: "\uD45C",
|
|
1423
1435
|
alignment: "\uC815\uB82C",
|
|
@@ -1668,6 +1680,9 @@ var ja_default = {
|
|
|
1668
1680
|
accent: "\u30A2\u30AF\u30BB\u30F3\u30C8",
|
|
1669
1681
|
textColor: "\u30C6\u30AD\u30B9\u30C8\u8272",
|
|
1670
1682
|
highlight: "\u30CF\u30A4\u30E9\u30A4\u30C8",
|
|
1683
|
+
automatic: "\u81EA\u52D5",
|
|
1684
|
+
moreColors: "\u305D\u306E\u4ED6\u306E\u8272...",
|
|
1685
|
+
color: "\u8272",
|
|
1671
1686
|
done: "\u5B8C\u4E86"
|
|
1672
1687
|
},
|
|
1673
1688
|
toolbar: {
|
|
@@ -1682,6 +1697,7 @@ var ja_default = {
|
|
|
1682
1697
|
subscript: "\u4E0B\u4ED8\u304D",
|
|
1683
1698
|
superscript: "\u4E0A\u4ED8\u304D",
|
|
1684
1699
|
link: "\u30EA\u30F3\u30AF",
|
|
1700
|
+
removeLink: "\u30EA\u30F3\u30AF\u3092\u89E3\u9664",
|
|
1685
1701
|
image: "\u753B\u50CF",
|
|
1686
1702
|
table: "\u8868",
|
|
1687
1703
|
alignment: "\u914D\u7F6E",
|
|
@@ -4687,6 +4703,9 @@ var Label = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
4687
4703
|
));
|
|
4688
4704
|
Label.displayName = "Label";
|
|
4689
4705
|
|
|
4706
|
+
// src/components/Avatar.tsx
|
|
4707
|
+
var React16 = __toESM(require("react"), 1);
|
|
4708
|
+
|
|
4690
4709
|
// src/components/SmartImage.tsx
|
|
4691
4710
|
var import_image = __toESM(require("next/image"), 1);
|
|
4692
4711
|
var import_react8 = __toESM(require("react"), 1);
|
|
@@ -4708,55 +4727,55 @@ function SmartImage({
|
|
|
4708
4727
|
quality = 80,
|
|
4709
4728
|
fit = "cover",
|
|
4710
4729
|
objectPosition,
|
|
4711
|
-
fallbackSrc = DEFAULT_FALLBACK
|
|
4730
|
+
fallbackSrc = DEFAULT_FALLBACK,
|
|
4731
|
+
transition = false,
|
|
4732
|
+
unoptimized = false
|
|
4712
4733
|
}) {
|
|
4713
|
-
const normalize2 = (
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4734
|
+
const normalize2 = import_react8.default.useCallback(
|
|
4735
|
+
(input) => {
|
|
4736
|
+
if (!input || input.length === 0) return fallbackSrc;
|
|
4737
|
+
const raw = input.trim();
|
|
4738
|
+
if (raw.startsWith("/images/products/") && /\.(jpg|jpeg)($|\?)/i.test(raw)) {
|
|
4739
|
+
return raw.replace(/\.(jpg|jpeg)(?=$|\?)/i, ".png");
|
|
4740
|
+
}
|
|
4741
|
+
if (raw.startsWith("//")) {
|
|
4742
|
+
return `https:${raw}`;
|
|
4743
|
+
}
|
|
4744
|
+
if (/^(https?:|data:|blob:)/i.test(raw)) {
|
|
4745
|
+
return FAILED_SRCS.has(raw) ? fallbackSrc : raw;
|
|
4746
|
+
}
|
|
4747
|
+
if (raw.startsWith("/")) {
|
|
4748
|
+
return FAILED_SRCS.has(raw) ? fallbackSrc : raw;
|
|
4749
|
+
}
|
|
4750
|
+
const normalized = `/${raw.replace(/^\.\/?/, "")}`;
|
|
4751
|
+
return FAILED_SRCS.has(normalized) ? fallbackSrc : normalized;
|
|
4752
|
+
},
|
|
4753
|
+
[fallbackSrc]
|
|
4754
|
+
);
|
|
4731
4755
|
const [resolvedSrc, setResolvedSrc] = import_react8.default.useState(() => normalize2(src));
|
|
4732
4756
|
import_react8.default.useEffect(() => {
|
|
4733
|
-
|
|
4734
|
-
|
|
4757
|
+
const next = normalize2(src);
|
|
4758
|
+
setResolvedSrc((current) => current === next ? current : next);
|
|
4759
|
+
}, [normalize2, src]);
|
|
4735
4760
|
const handleError = () => {
|
|
4736
4761
|
if (resolvedSrc && resolvedSrc !== fallbackSrc) FAILED_SRCS.add(resolvedSrc);
|
|
4737
|
-
if (
|
|
4738
|
-
const next = resolvedSrc.replace(/\.jpg(
|
|
4762
|
+
if (/\.(jpg|jpeg)(\?.*)?$/i.test(resolvedSrc)) {
|
|
4763
|
+
const next = resolvedSrc.replace(/\.(jpg|jpeg)(?=$|\?)/i, ".png");
|
|
4739
4764
|
setResolvedSrc(next);
|
|
4740
4765
|
} else if (resolvedSrc !== fallbackSrc) {
|
|
4741
4766
|
setResolvedSrc(fallbackSrc);
|
|
4742
4767
|
}
|
|
4743
4768
|
};
|
|
4744
|
-
const
|
|
4745
|
-
"
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0",
|
|
4751
|
-
ratioClass,
|
|
4752
|
-
roundedClass,
|
|
4753
|
-
className
|
|
4754
|
-
),
|
|
4755
|
-
children
|
|
4756
|
-
}
|
|
4769
|
+
const wrapperClass = cn(
|
|
4770
|
+
"relative overflow-hidden bg-muted/30",
|
|
4771
|
+
"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0",
|
|
4772
|
+
ratioClass,
|
|
4773
|
+
roundedClass,
|
|
4774
|
+
className
|
|
4757
4775
|
);
|
|
4776
|
+
const imgClass = cn(transition ? "transition-opacity duration-300" : "transition-none", imageClassName);
|
|
4758
4777
|
if (fill) {
|
|
4759
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: wrapperClass, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4760
4779
|
import_image.default,
|
|
4761
4780
|
{
|
|
4762
4781
|
src: resolvedSrc,
|
|
@@ -4766,8 +4785,9 @@ function SmartImage({
|
|
|
4766
4785
|
onError: handleError,
|
|
4767
4786
|
priority,
|
|
4768
4787
|
quality,
|
|
4788
|
+
unoptimized,
|
|
4769
4789
|
style: { objectFit: fit, objectPosition },
|
|
4770
|
-
className:
|
|
4790
|
+
className: imgClass
|
|
4771
4791
|
}
|
|
4772
4792
|
) });
|
|
4773
4793
|
}
|
|
@@ -4791,8 +4811,9 @@ function SmartImage({
|
|
|
4791
4811
|
onError: handleError,
|
|
4792
4812
|
priority,
|
|
4793
4813
|
quality,
|
|
4814
|
+
unoptimized,
|
|
4794
4815
|
style: { objectFit: fit, objectPosition, width: "100%", height: "100%" },
|
|
4795
|
-
className:
|
|
4816
|
+
className: imgClass
|
|
4796
4817
|
}
|
|
4797
4818
|
)
|
|
4798
4819
|
}
|
|
@@ -4820,7 +4841,7 @@ var statusDotSizes = {
|
|
|
4820
4841
|
lg: "w-4 h-4 border-2",
|
|
4821
4842
|
xl: "w-5 h-5 border-[3px]"
|
|
4822
4843
|
};
|
|
4823
|
-
var Avatar = ({
|
|
4844
|
+
var Avatar = React16.memo(function Avatar2({
|
|
4824
4845
|
src,
|
|
4825
4846
|
alt = "avatar",
|
|
4826
4847
|
fallback = "?",
|
|
@@ -4828,11 +4849,15 @@ var Avatar = ({
|
|
|
4828
4849
|
showStatus = true,
|
|
4829
4850
|
status = "online",
|
|
4830
4851
|
hideStatusOnHover = true,
|
|
4852
|
+
imageStrategy = "img",
|
|
4853
|
+
imageLoading = "lazy",
|
|
4854
|
+
imageFetchPriority,
|
|
4831
4855
|
className,
|
|
4832
4856
|
onClick,
|
|
4833
4857
|
...props
|
|
4834
|
-
})
|
|
4858
|
+
}) {
|
|
4835
4859
|
const hasValidSrc = !!(src && src.trim().length > 0);
|
|
4860
|
+
const fallbackText = (fallback || "?").trim().charAt(0).toUpperCase() || "?";
|
|
4836
4861
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
4837
4862
|
"div",
|
|
4838
4863
|
{
|
|
@@ -4846,7 +4871,19 @@ var Avatar = ({
|
|
|
4846
4871
|
...props,
|
|
4847
4872
|
children: [
|
|
4848
4873
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "absolute inset-0 overflow-hidden rounded-full", children: [
|
|
4849
|
-
hasValidSrc && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4874
|
+
hasValidSrc && imageStrategy === "img" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4875
|
+
"img",
|
|
4876
|
+
{
|
|
4877
|
+
src,
|
|
4878
|
+
alt,
|
|
4879
|
+
loading: imageLoading,
|
|
4880
|
+
decoding: "async",
|
|
4881
|
+
draggable: false,
|
|
4882
|
+
fetchPriority: imageFetchPriority,
|
|
4883
|
+
className: "h-full w-full object-cover"
|
|
4884
|
+
}
|
|
4885
|
+
),
|
|
4886
|
+
hasValidSrc && imageStrategy === "next-image" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4850
4887
|
SmartImage,
|
|
4851
4888
|
{
|
|
4852
4889
|
src,
|
|
@@ -4857,7 +4894,8 @@ var Avatar = ({
|
|
|
4857
4894
|
roundedClass: "rounded-full",
|
|
4858
4895
|
fit: "cover",
|
|
4859
4896
|
objectPosition: "center",
|
|
4860
|
-
quality: 80
|
|
4897
|
+
quality: 80,
|
|
4898
|
+
imageClassName: "transition-none"
|
|
4861
4899
|
}
|
|
4862
4900
|
),
|
|
4863
4901
|
!hasValidSrc && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
@@ -4867,7 +4905,7 @@ var Avatar = ({
|
|
|
4867
4905
|
"font-bold uppercase bg-linear-to-br from-primary to-primary/80 bg-clip-text text-transparent",
|
|
4868
4906
|
"transition-all duration-200 animate-fade-in"
|
|
4869
4907
|
),
|
|
4870
|
-
children:
|
|
4908
|
+
children: fallbackText
|
|
4871
4909
|
}
|
|
4872
4910
|
) })
|
|
4873
4911
|
] }),
|
|
@@ -4886,7 +4924,7 @@ var Avatar = ({
|
|
|
4886
4924
|
]
|
|
4887
4925
|
}
|
|
4888
4926
|
);
|
|
4889
|
-
};
|
|
4927
|
+
});
|
|
4890
4928
|
var Avatar_default = Avatar;
|
|
4891
4929
|
|
|
4892
4930
|
// src/components/Skeleton.tsx
|
|
@@ -5382,7 +5420,7 @@ var LoadingProgress = ({
|
|
|
5382
5420
|
};
|
|
5383
5421
|
|
|
5384
5422
|
// src/components/Modal.tsx
|
|
5385
|
-
var
|
|
5423
|
+
var React18 = __toESM(require("react"), 1);
|
|
5386
5424
|
var import_react_dom2 = require("react-dom");
|
|
5387
5425
|
var import_lucide_react7 = require("lucide-react");
|
|
5388
5426
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
@@ -5412,17 +5450,17 @@ var Modal = ({
|
|
|
5412
5450
|
height
|
|
5413
5451
|
}) => {
|
|
5414
5452
|
const gi18n = useGlobalI18n();
|
|
5415
|
-
const [isMounted, setIsMounted] =
|
|
5416
|
-
const [isVisible, setIsVisible] =
|
|
5417
|
-
const [isAnimating, setIsAnimating] =
|
|
5418
|
-
const mouseDownTarget =
|
|
5419
|
-
const modalContentRef =
|
|
5420
|
-
|
|
5453
|
+
const [isMounted, setIsMounted] = React18.useState(false);
|
|
5454
|
+
const [isVisible, setIsVisible] = React18.useState(false);
|
|
5455
|
+
const [isAnimating, setIsAnimating] = React18.useState(true);
|
|
5456
|
+
const mouseDownTarget = React18.useRef(null);
|
|
5457
|
+
const modalContentRef = React18.useRef(null);
|
|
5458
|
+
React18.useEffect(() => {
|
|
5421
5459
|
setIsMounted(true);
|
|
5422
5460
|
return () => setIsMounted(false);
|
|
5423
5461
|
}, []);
|
|
5424
|
-
const animationRef =
|
|
5425
|
-
|
|
5462
|
+
const animationRef = React18.useRef(false);
|
|
5463
|
+
React18.useEffect(() => {
|
|
5426
5464
|
if (isOpen) {
|
|
5427
5465
|
if (animationRef.current) return;
|
|
5428
5466
|
animationRef.current = true;
|
|
@@ -5442,7 +5480,7 @@ var Modal = ({
|
|
|
5442
5480
|
}
|
|
5443
5481
|
}
|
|
5444
5482
|
}, [isOpen, isVisible]);
|
|
5445
|
-
|
|
5483
|
+
React18.useEffect(() => {
|
|
5446
5484
|
if (!isOpen || !closeOnEsc) return;
|
|
5447
5485
|
const handleEscape = (event) => {
|
|
5448
5486
|
if (event.key === "Escape") {
|
|
@@ -5452,7 +5490,7 @@ var Modal = ({
|
|
|
5452
5490
|
document.addEventListener("keydown", handleEscape);
|
|
5453
5491
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
5454
5492
|
}, [isOpen, closeOnEsc, onClose]);
|
|
5455
|
-
|
|
5493
|
+
React18.useEffect(() => {
|
|
5456
5494
|
if (isOpen) {
|
|
5457
5495
|
document.body.style.overflow = "hidden";
|
|
5458
5496
|
} else {
|
|
@@ -5738,7 +5776,7 @@ var ToastComponent = ({ toast, onRemove }) => {
|
|
|
5738
5776
|
var Toast_default = ToastProvider;
|
|
5739
5777
|
|
|
5740
5778
|
// src/components/Popover.tsx
|
|
5741
|
-
var
|
|
5779
|
+
var React20 = __toESM(require("react"), 1);
|
|
5742
5780
|
var import_react_dom3 = require("react-dom");
|
|
5743
5781
|
|
|
5744
5782
|
// src/utils/animations.ts
|
|
@@ -6028,14 +6066,14 @@ var Popover = ({
|
|
|
6028
6066
|
contentWidth
|
|
6029
6067
|
}) => {
|
|
6030
6068
|
const isControlled = open !== void 0;
|
|
6031
|
-
const [internalOpen, setInternalOpen] =
|
|
6032
|
-
const triggerRef =
|
|
6033
|
-
const positionerRef =
|
|
6034
|
-
const panelRef =
|
|
6035
|
-
const lastAppliedRef =
|
|
6069
|
+
const [internalOpen, setInternalOpen] = React20.useState(false);
|
|
6070
|
+
const triggerRef = React20.useRef(null);
|
|
6071
|
+
const positionerRef = React20.useRef(null);
|
|
6072
|
+
const panelRef = React20.useRef(null);
|
|
6073
|
+
const lastAppliedRef = React20.useRef(null);
|
|
6036
6074
|
useShadCNAnimations();
|
|
6037
6075
|
const isOpen = isControlled ? open : internalOpen;
|
|
6038
|
-
const setIsOpen =
|
|
6076
|
+
const setIsOpen = React20.useCallback(
|
|
6039
6077
|
(next) => {
|
|
6040
6078
|
if (!isControlled) setInternalOpen(next);
|
|
6041
6079
|
onOpenChange?.(next);
|
|
@@ -6044,16 +6082,16 @@ var Popover = ({
|
|
|
6044
6082
|
);
|
|
6045
6083
|
const offset = 4;
|
|
6046
6084
|
const padding = 8;
|
|
6047
|
-
const triggerSelector =
|
|
6048
|
-
const initialPlacement =
|
|
6049
|
-
|
|
6085
|
+
const triggerSelector = React20.useId();
|
|
6086
|
+
const initialPlacement = React20.useMemo(() => normalizePlacement(placement), [placement]);
|
|
6087
|
+
React20.useLayoutEffect(() => {
|
|
6050
6088
|
if (typeof document === "undefined") return;
|
|
6051
6089
|
const triggerEl = document.querySelector(`[data-underverse-popover-trigger="${triggerSelector}"]`);
|
|
6052
6090
|
if (triggerEl) {
|
|
6053
6091
|
triggerRef.current = triggerEl;
|
|
6054
6092
|
}
|
|
6055
6093
|
}, [triggerSelector, trigger]);
|
|
6056
|
-
const updatePosition =
|
|
6094
|
+
const updatePosition = React20.useCallback(() => {
|
|
6057
6095
|
const triggerEl = triggerRef.current;
|
|
6058
6096
|
const positionerEl = positionerRef.current;
|
|
6059
6097
|
const panelEl = panelRef.current;
|
|
@@ -6090,7 +6128,7 @@ var Popover = ({
|
|
|
6090
6128
|
if (positionerEl.style.visibility !== "visible") positionerEl.style.visibility = "visible";
|
|
6091
6129
|
if (positionerEl.style.pointerEvents !== "auto") positionerEl.style.pointerEvents = "auto";
|
|
6092
6130
|
}, [placement, matchTriggerWidth, contentWidth]);
|
|
6093
|
-
|
|
6131
|
+
React20.useLayoutEffect(() => {
|
|
6094
6132
|
if (!isOpen) return;
|
|
6095
6133
|
updatePosition();
|
|
6096
6134
|
let raf1 = 0;
|
|
@@ -6104,7 +6142,7 @@ var Popover = ({
|
|
|
6104
6142
|
cancelAnimationFrame(raf2);
|
|
6105
6143
|
};
|
|
6106
6144
|
}, [isOpen, updatePosition]);
|
|
6107
|
-
|
|
6145
|
+
React20.useEffect(() => {
|
|
6108
6146
|
if (!isOpen) return;
|
|
6109
6147
|
let raf = 0;
|
|
6110
6148
|
const tick = () => {
|
|
@@ -6114,7 +6152,7 @@ var Popover = ({
|
|
|
6114
6152
|
raf = window.requestAnimationFrame(tick);
|
|
6115
6153
|
return () => window.cancelAnimationFrame(raf);
|
|
6116
6154
|
}, [isOpen, updatePosition]);
|
|
6117
|
-
|
|
6155
|
+
React20.useEffect(() => {
|
|
6118
6156
|
if (!isOpen) return;
|
|
6119
6157
|
let raf = 0;
|
|
6120
6158
|
const handler = () => {
|
|
@@ -6132,7 +6170,7 @@ var Popover = ({
|
|
|
6132
6170
|
document.removeEventListener("scroll", handler, true);
|
|
6133
6171
|
};
|
|
6134
6172
|
}, [isOpen, updatePosition]);
|
|
6135
|
-
|
|
6173
|
+
React20.useEffect(() => {
|
|
6136
6174
|
if (!isOpen) return;
|
|
6137
6175
|
if (typeof ResizeObserver === "undefined") return;
|
|
6138
6176
|
const ro = new ResizeObserver(() => updatePosition());
|
|
@@ -6140,13 +6178,13 @@ var Popover = ({
|
|
|
6140
6178
|
if (triggerRef.current) ro.observe(triggerRef.current);
|
|
6141
6179
|
return () => ro.disconnect();
|
|
6142
6180
|
}, [isOpen, updatePosition]);
|
|
6143
|
-
|
|
6181
|
+
React20.useLayoutEffect(() => {
|
|
6144
6182
|
if (!isOpen) {
|
|
6145
6183
|
lastAppliedRef.current = null;
|
|
6146
6184
|
return;
|
|
6147
6185
|
}
|
|
6148
6186
|
}, [isOpen]);
|
|
6149
|
-
|
|
6187
|
+
React20.useEffect(() => {
|
|
6150
6188
|
if (!isOpen) return;
|
|
6151
6189
|
const handleClickOutside = (event) => {
|
|
6152
6190
|
const target = event.target;
|
|
@@ -6232,7 +6270,7 @@ var Popover = ({
|
|
|
6232
6270
|
(() => {
|
|
6233
6271
|
const triggerProps = trigger.props;
|
|
6234
6272
|
const childRef = triggerProps.ref;
|
|
6235
|
-
return
|
|
6273
|
+
return React20.cloneElement(trigger, {
|
|
6236
6274
|
...triggerProps,
|
|
6237
6275
|
ref: mergeRefs(childRef, (node) => {
|
|
6238
6276
|
triggerRef.current = node;
|
|
@@ -6262,7 +6300,7 @@ var Popover = ({
|
|
|
6262
6300
|
};
|
|
6263
6301
|
|
|
6264
6302
|
// src/components/Sheet.tsx
|
|
6265
|
-
var
|
|
6303
|
+
var React21 = __toESM(require("react"), 1);
|
|
6266
6304
|
var import_react_dom4 = require("react-dom");
|
|
6267
6305
|
var import_lucide_react9 = require("lucide-react");
|
|
6268
6306
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
@@ -6348,19 +6386,19 @@ var Sheet = ({
|
|
|
6348
6386
|
onResize
|
|
6349
6387
|
}) => {
|
|
6350
6388
|
const gi18n = useGlobalI18n();
|
|
6351
|
-
const [mounted, setMounted] =
|
|
6352
|
-
const [isAnimating, setIsAnimating] =
|
|
6353
|
-
const [isVisible, setIsVisible] =
|
|
6354
|
-
const [isResizing, setIsResizing] =
|
|
6355
|
-
const [sheetSize, setSheetSize] =
|
|
6356
|
-
const sheetRef =
|
|
6357
|
-
const resizeStateRef =
|
|
6389
|
+
const [mounted, setMounted] = React21.useState(false);
|
|
6390
|
+
const [isAnimating, setIsAnimating] = React21.useState(true);
|
|
6391
|
+
const [isVisible, setIsVisible] = React21.useState(false);
|
|
6392
|
+
const [isResizing, setIsResizing] = React21.useState(false);
|
|
6393
|
+
const [sheetSize, setSheetSize] = React21.useState(null);
|
|
6394
|
+
const sheetRef = React21.useRef(null);
|
|
6395
|
+
const resizeStateRef = React21.useRef(null);
|
|
6358
6396
|
const isHorizontalSheet = side === "left" || side === "right";
|
|
6359
6397
|
const canResize = resizable && size !== "full";
|
|
6360
|
-
|
|
6398
|
+
React21.useEffect(() => {
|
|
6361
6399
|
setMounted(true);
|
|
6362
6400
|
}, []);
|
|
6363
|
-
|
|
6401
|
+
React21.useEffect(() => {
|
|
6364
6402
|
if (!closeOnEscape) return;
|
|
6365
6403
|
const handleEscape = (e) => {
|
|
6366
6404
|
if (e.key === "Escape" && open) {
|
|
@@ -6370,7 +6408,7 @@ var Sheet = ({
|
|
|
6370
6408
|
document.addEventListener("keydown", handleEscape);
|
|
6371
6409
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
6372
6410
|
}, [open, closeOnEscape, onOpenChange]);
|
|
6373
|
-
|
|
6411
|
+
React21.useEffect(() => {
|
|
6374
6412
|
if (open) {
|
|
6375
6413
|
document.body.style.overflow = "hidden";
|
|
6376
6414
|
} else {
|
|
@@ -6380,7 +6418,7 @@ var Sheet = ({
|
|
|
6380
6418
|
document.body.style.overflow = "unset";
|
|
6381
6419
|
};
|
|
6382
6420
|
}, [open]);
|
|
6383
|
-
|
|
6421
|
+
React21.useEffect(() => {
|
|
6384
6422
|
if (open) {
|
|
6385
6423
|
setIsVisible(true);
|
|
6386
6424
|
setIsAnimating(true);
|
|
@@ -6403,19 +6441,19 @@ var Sheet = ({
|
|
|
6403
6441
|
const handleClose = () => {
|
|
6404
6442
|
onOpenChange(false);
|
|
6405
6443
|
};
|
|
6406
|
-
const clampResizeSize =
|
|
6444
|
+
const clampResizeSize = React21.useCallback((nextSize) => {
|
|
6407
6445
|
const viewportSize = isHorizontalSheet ? window.innerWidth : window.innerHeight;
|
|
6408
6446
|
const resolvedMaxSize = maxSize ?? Math.round(viewportSize * 0.9);
|
|
6409
6447
|
return Math.min(Math.max(nextSize, minSize), resolvedMaxSize);
|
|
6410
6448
|
}, [isHorizontalSheet, maxSize, minSize]);
|
|
6411
|
-
const endResize =
|
|
6449
|
+
const endResize = React21.useCallback(() => {
|
|
6412
6450
|
if (!resizeStateRef.current) return;
|
|
6413
6451
|
resizeStateRef.current = null;
|
|
6414
6452
|
setIsResizing(false);
|
|
6415
6453
|
document.body.style.cursor = "";
|
|
6416
6454
|
document.body.style.userSelect = "";
|
|
6417
6455
|
}, []);
|
|
6418
|
-
const handleResizePointerMove =
|
|
6456
|
+
const handleResizePointerMove = React21.useCallback((event) => {
|
|
6419
6457
|
const resizeState = resizeStateRef.current;
|
|
6420
6458
|
if (!resizeState || event.pointerId !== resizeState.pointerId) return;
|
|
6421
6459
|
const delta = isHorizontalSheet ? side === "right" ? resizeState.startClientX - event.clientX : event.clientX - resizeState.startClientX : side === "bottom" ? resizeState.startClientY - event.clientY : event.clientY - resizeState.startClientY;
|
|
@@ -6423,12 +6461,12 @@ var Sheet = ({
|
|
|
6423
6461
|
setSheetSize(nextSize);
|
|
6424
6462
|
onResize?.(nextSize);
|
|
6425
6463
|
}, [clampResizeSize, isHorizontalSheet, onResize, side]);
|
|
6426
|
-
const handleResizePointerUp =
|
|
6464
|
+
const handleResizePointerUp = React21.useCallback((event) => {
|
|
6427
6465
|
const resizeState = resizeStateRef.current;
|
|
6428
6466
|
if (!resizeState || event.pointerId !== resizeState.pointerId) return;
|
|
6429
6467
|
endResize();
|
|
6430
6468
|
}, [endResize]);
|
|
6431
|
-
|
|
6469
|
+
React21.useEffect(() => {
|
|
6432
6470
|
if (!isResizing) return void 0;
|
|
6433
6471
|
window.addEventListener("pointermove", handleResizePointerMove);
|
|
6434
6472
|
window.addEventListener("pointerup", handleResizePointerUp);
|
|
@@ -6439,10 +6477,10 @@ var Sheet = ({
|
|
|
6439
6477
|
window.removeEventListener("pointercancel", handleResizePointerUp);
|
|
6440
6478
|
};
|
|
6441
6479
|
}, [handleResizePointerMove, handleResizePointerUp, isResizing]);
|
|
6442
|
-
|
|
6480
|
+
React21.useEffect(() => {
|
|
6443
6481
|
if (!open) endResize();
|
|
6444
6482
|
}, [endResize, open]);
|
|
6445
|
-
|
|
6483
|
+
React21.useEffect(() => endResize, [endResize]);
|
|
6446
6484
|
const handleResizePointerDown = (event) => {
|
|
6447
6485
|
if (!canResize || !sheetRef.current) return;
|
|
6448
6486
|
const rect = sheetRef.current.getBoundingClientRect();
|
|
@@ -6780,7 +6818,7 @@ var ButtonLoading = ({ isLoading, children, className, disabled, loadingText })
|
|
|
6780
6818
|
};
|
|
6781
6819
|
|
|
6782
6820
|
// src/components/Breadcrumb.tsx
|
|
6783
|
-
var
|
|
6821
|
+
var React23 = __toESM(require("react"), 1);
|
|
6784
6822
|
var import_lucide_react12 = require("lucide-react");
|
|
6785
6823
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6786
6824
|
var NextLink = null;
|
|
@@ -6828,8 +6866,8 @@ var Breadcrumb = ({
|
|
|
6828
6866
|
collapsible = true
|
|
6829
6867
|
}) => {
|
|
6830
6868
|
const gi18n = useGlobalI18n();
|
|
6831
|
-
const [isCollapsed, setIsCollapsed] =
|
|
6832
|
-
|
|
6869
|
+
const [isCollapsed, setIsCollapsed] = React23.useState(false);
|
|
6870
|
+
React23.useEffect(() => {
|
|
6833
6871
|
if (collapsible && items.length > maxItems) {
|
|
6834
6872
|
setIsCollapsed(true);
|
|
6835
6873
|
}
|
|
@@ -6847,7 +6885,7 @@ var Breadcrumb = ({
|
|
|
6847
6885
|
const SeparatorComponent = separator;
|
|
6848
6886
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SeparatorComponent, { className: cn("text-muted-foreground", sizeStyles5[size].icon) });
|
|
6849
6887
|
};
|
|
6850
|
-
const processedItems =
|
|
6888
|
+
const processedItems = React23.useMemo(() => {
|
|
6851
6889
|
let finalItems = [...items];
|
|
6852
6890
|
if (showHome && finalItems[0]?.href !== homeHref) {
|
|
6853
6891
|
finalItems.unshift({
|
|
@@ -6920,7 +6958,7 @@ var Breadcrumb = ({
|
|
|
6920
6958
|
var Breadcrumb_default = Breadcrumb;
|
|
6921
6959
|
|
|
6922
6960
|
// src/components/Tab.tsx
|
|
6923
|
-
var
|
|
6961
|
+
var React24 = __toESM(require("react"), 1);
|
|
6924
6962
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6925
6963
|
var sizeStyles6 = {
|
|
6926
6964
|
sm: {
|
|
@@ -7018,11 +7056,11 @@ var Tabs = ({
|
|
|
7018
7056
|
noContentPadding = false,
|
|
7019
7057
|
animateContent = true
|
|
7020
7058
|
}) => {
|
|
7021
|
-
const [active, setActive] =
|
|
7022
|
-
const [underlineStyle, setUnderlineStyle] =
|
|
7023
|
-
const tabRefs =
|
|
7024
|
-
const autoId =
|
|
7025
|
-
const baseId =
|
|
7059
|
+
const [active, setActive] = React24.useState(defaultValue || tabs[0]?.value);
|
|
7060
|
+
const [underlineStyle, setUnderlineStyle] = React24.useState({});
|
|
7061
|
+
const tabRefs = React24.useRef([]);
|
|
7062
|
+
const autoId = React24.useId();
|
|
7063
|
+
const baseId = React24.useMemo(() => getTabsBaseId(tabs, id, autoId), [autoId, id, tabs]);
|
|
7026
7064
|
const handleTabChange = (value) => {
|
|
7027
7065
|
setActive(value);
|
|
7028
7066
|
onTabChange?.(value);
|
|
@@ -7049,7 +7087,7 @@ var Tabs = ({
|
|
|
7049
7087
|
tabRefs.current[next]?.focus();
|
|
7050
7088
|
}
|
|
7051
7089
|
};
|
|
7052
|
-
|
|
7090
|
+
React24.useEffect(() => {
|
|
7053
7091
|
if (variant === "underline" && orientation === "horizontal") {
|
|
7054
7092
|
const activeIndex2 = tabs.findIndex((tab) => tab.value === active);
|
|
7055
7093
|
const activeTab2 = tabRefs.current[activeIndex2];
|
|
@@ -7062,7 +7100,7 @@ var Tabs = ({
|
|
|
7062
7100
|
}
|
|
7063
7101
|
}
|
|
7064
7102
|
}, [active, variant, orientation, tabs]);
|
|
7065
|
-
|
|
7103
|
+
React24.useEffect(() => {
|
|
7066
7104
|
if (typeof window === "undefined") return;
|
|
7067
7105
|
const syncFromHash = () => {
|
|
7068
7106
|
const nextValue = resolveTabValueFromHash(window.location.hash, tabs, baseId);
|
|
@@ -7414,11 +7452,11 @@ var SelectDropdown = ({ options, value, onChange, placeholder = "Select...", cla
|
|
|
7414
7452
|
var DropdownMenu_default = DropdownMenu;
|
|
7415
7453
|
|
|
7416
7454
|
// src/components/Pagination.tsx
|
|
7417
|
-
var
|
|
7455
|
+
var React27 = __toESM(require("react"), 1);
|
|
7418
7456
|
var import_lucide_react14 = require("lucide-react");
|
|
7419
7457
|
|
|
7420
7458
|
// src/components/Combobox.tsx
|
|
7421
|
-
var
|
|
7459
|
+
var React26 = __toESM(require("react"), 1);
|
|
7422
7460
|
var import_react15 = require("react");
|
|
7423
7461
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
7424
7462
|
var import_lucide_react13 = require("lucide-react");
|
|
@@ -7500,13 +7538,13 @@ var Combobox = ({
|
|
|
7500
7538
|
const searchPlaceholder = searchPlaceholderProp ?? gi18n.searchPlaceholder ?? "Search\u2026";
|
|
7501
7539
|
const emptyText = emptyTextProp ?? gi18n.noResults ?? "No results found";
|
|
7502
7540
|
const loadingText = loadingTextProp ?? gi18n.loading ?? "Loading...";
|
|
7503
|
-
const [open, setOpen] =
|
|
7504
|
-
const [query, setQuery] =
|
|
7505
|
-
const [activeIndex, setActiveIndex] =
|
|
7506
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
7541
|
+
const [open, setOpen] = React26.useState(false);
|
|
7542
|
+
const [query, setQuery] = React26.useState("");
|
|
7543
|
+
const [activeIndex, setActiveIndex] = React26.useState(null);
|
|
7544
|
+
const [localRequiredError, setLocalRequiredError] = React26.useState();
|
|
7507
7545
|
useShadCNAnimations();
|
|
7508
|
-
const inputRef =
|
|
7509
|
-
const optionsViewportRef =
|
|
7546
|
+
const inputRef = React26.useRef(null);
|
|
7547
|
+
const optionsViewportRef = React26.useRef(null);
|
|
7510
7548
|
useOverlayScrollbarTarget(optionsViewportRef, { enabled: open && useOverlayScrollbar && !virtualized });
|
|
7511
7549
|
const autoId = (0, import_react15.useId)();
|
|
7512
7550
|
const resolvedId = id ? String(id) : `combobox-${autoId}`;
|
|
@@ -7515,7 +7553,7 @@ var Combobox = ({
|
|
|
7515
7553
|
const trimmedQuery = query.trim();
|
|
7516
7554
|
const queryMeetsMinimum = trimmedQuery.length >= minSearchLength;
|
|
7517
7555
|
const shouldPromptForSearch = minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
7518
|
-
const filteredOptions =
|
|
7556
|
+
const filteredOptions = React26.useMemo(
|
|
7519
7557
|
() => {
|
|
7520
7558
|
if (shouldPromptForSearch) return [];
|
|
7521
7559
|
if (!enableSearch || searchMode === "manual") return options;
|
|
@@ -7525,7 +7563,7 @@ var Combobox = ({
|
|
|
7525
7563
|
},
|
|
7526
7564
|
[enableSearch, options, searchMode, shouldPromptForSearch, trimmedQuery]
|
|
7527
7565
|
);
|
|
7528
|
-
const renderLimitedOptions =
|
|
7566
|
+
const renderLimitedOptions = React26.useMemo(
|
|
7529
7567
|
() => {
|
|
7530
7568
|
if (trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
7531
7569
|
return filteredOptions;
|
|
@@ -7544,15 +7582,15 @@ var Combobox = ({
|
|
|
7544
7582
|
enabled: canVirtualize
|
|
7545
7583
|
});
|
|
7546
7584
|
const virtualItems = canVirtualize ? optionVirtualizer.getVirtualItems() : [];
|
|
7547
|
-
const triggerRef =
|
|
7548
|
-
const scrollVirtualListToIndex =
|
|
7585
|
+
const triggerRef = React26.useRef(null);
|
|
7586
|
+
const scrollVirtualListToIndex = React26.useCallback((index) => {
|
|
7549
7587
|
if (!canVirtualize || renderLimitedOptions.length === 0) return;
|
|
7550
7588
|
optionVirtualizer.scrollToIndex(index, { align: "auto" });
|
|
7551
7589
|
}, [canVirtualize, optionVirtualizer, renderLimitedOptions.length]);
|
|
7552
|
-
const scrollVirtualListToStart =
|
|
7590
|
+
const scrollVirtualListToStart = React26.useCallback(() => {
|
|
7553
7591
|
scrollVirtualListToIndex(0);
|
|
7554
7592
|
}, [scrollVirtualListToIndex]);
|
|
7555
|
-
const moveActiveIndex =
|
|
7593
|
+
const moveActiveIndex = React26.useCallback((direction) => {
|
|
7556
7594
|
if (renderLimitedOptions.length === 0) return;
|
|
7557
7595
|
const next = activeIndex === null ? direction === 1 ? 0 : renderLimitedOptions.length - 1 : (activeIndex + direction + renderLimitedOptions.length) % renderLimitedOptions.length;
|
|
7558
7596
|
setActiveIndex(next);
|
|
@@ -7576,7 +7614,7 @@ var Combobox = ({
|
|
|
7576
7614
|
onChange(null);
|
|
7577
7615
|
setOpen(false);
|
|
7578
7616
|
};
|
|
7579
|
-
|
|
7617
|
+
React26.useEffect(() => {
|
|
7580
7618
|
if (!open) {
|
|
7581
7619
|
setQuery("");
|
|
7582
7620
|
setActiveIndex(null);
|
|
@@ -7587,12 +7625,12 @@ var Combobox = ({
|
|
|
7587
7625
|
}, 100);
|
|
7588
7626
|
}
|
|
7589
7627
|
}, [enableSearch, open, scrollVirtualListToStart]);
|
|
7590
|
-
|
|
7628
|
+
React26.useEffect(() => {
|
|
7591
7629
|
if (!onSearchChange) return void 0;
|
|
7592
7630
|
const timeoutId = window.setTimeout(() => onSearchChange(query), searchDebounceMs);
|
|
7593
7631
|
return () => window.clearTimeout(timeoutId);
|
|
7594
7632
|
}, [onSearchChange, query, searchDebounceMs]);
|
|
7595
|
-
|
|
7633
|
+
React26.useEffect(() => {
|
|
7596
7634
|
if (process.env.NODE_ENV !== "production" && options.length > 300 && !virtualized && searchMode !== "manual" && maxInitialOptions === void 0) {
|
|
7597
7635
|
console.warn(
|
|
7598
7636
|
'[Underverse UI] Combobox received more than 300 options without virtualization, manual search, or maxInitialOptions. Use virtualized, searchMode="manual", or maxInitialOptions to avoid rendering a large dropdown.'
|
|
@@ -7604,12 +7642,12 @@ var Combobox = ({
|
|
|
7604
7642
|
const selectedIcon = selectedOption ? getOptionIcon(selectedOption) : void 0;
|
|
7605
7643
|
const hasValue = value !== void 0 && value !== null && value !== "";
|
|
7606
7644
|
const effectiveError = error ?? localRequiredError;
|
|
7607
|
-
|
|
7645
|
+
React26.useEffect(() => {
|
|
7608
7646
|
if (disabled || !required || hasValue) {
|
|
7609
7647
|
setLocalRequiredError(void 0);
|
|
7610
7648
|
}
|
|
7611
7649
|
}, [disabled, hasValue, required]);
|
|
7612
|
-
const groupedOptions =
|
|
7650
|
+
const groupedOptions = React26.useMemo(() => {
|
|
7613
7651
|
if (!groupBy) return null;
|
|
7614
7652
|
const groups = {};
|
|
7615
7653
|
renderLimitedOptions.forEach((opt) => {
|
|
@@ -8026,7 +8064,7 @@ var Pagination = ({
|
|
|
8026
8064
|
labels
|
|
8027
8065
|
}) => {
|
|
8028
8066
|
const t = useSmartTranslations("Pagination");
|
|
8029
|
-
|
|
8067
|
+
React27.useEffect(() => {
|
|
8030
8068
|
if (disabled) return;
|
|
8031
8069
|
const handleKey = (e) => {
|
|
8032
8070
|
if (e.target && e.target.tagName === "INPUT") return;
|
|
@@ -8677,7 +8715,7 @@ function formatDateSmart(date, locale = "en") {
|
|
|
8677
8715
|
|
|
8678
8716
|
// src/components/DatePicker.tsx
|
|
8679
8717
|
var import_lucide_react15 = require("lucide-react");
|
|
8680
|
-
var
|
|
8718
|
+
var React30 = __toESM(require("react"), 1);
|
|
8681
8719
|
var import_react19 = require("react");
|
|
8682
8720
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
8683
8721
|
var DatePicker = ({
|
|
@@ -8701,20 +8739,20 @@ var DatePicker = ({
|
|
|
8701
8739
|
const t = useSmartTranslations("DatePicker");
|
|
8702
8740
|
const tv = useSmartTranslations("ValidationInput");
|
|
8703
8741
|
const locale = useSmartLocale();
|
|
8704
|
-
const [isOpen, setIsOpen] =
|
|
8705
|
-
const [viewDate, setViewDate] =
|
|
8706
|
-
const [viewMode, setViewMode] =
|
|
8707
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
8708
|
-
const triggerRef =
|
|
8709
|
-
const wheelContainerRef =
|
|
8710
|
-
const wheelDeltaRef =
|
|
8711
|
-
const normalizeToLocalDay =
|
|
8742
|
+
const [isOpen, setIsOpen] = React30.useState(false);
|
|
8743
|
+
const [viewDate, setViewDate] = React30.useState(value || /* @__PURE__ */ new Date());
|
|
8744
|
+
const [viewMode, setViewMode] = React30.useState("calendar");
|
|
8745
|
+
const [localRequiredError, setLocalRequiredError] = React30.useState();
|
|
8746
|
+
const triggerRef = React30.useRef(null);
|
|
8747
|
+
const wheelContainerRef = React30.useRef(null);
|
|
8748
|
+
const wheelDeltaRef = React30.useRef(0);
|
|
8749
|
+
const normalizeToLocalDay = React30.useCallback((date) => {
|
|
8712
8750
|
if (!date) return null;
|
|
8713
8751
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
8714
8752
|
}, []);
|
|
8715
|
-
const minDay =
|
|
8716
|
-
const maxDay =
|
|
8717
|
-
const isDateDisabled =
|
|
8753
|
+
const minDay = React30.useMemo(() => normalizeToLocalDay(minDate), [minDate, normalizeToLocalDay]);
|
|
8754
|
+
const maxDay = React30.useMemo(() => normalizeToLocalDay(maxDate), [maxDate, normalizeToLocalDay]);
|
|
8755
|
+
const isDateDisabled = React30.useCallback(
|
|
8718
8756
|
(date) => {
|
|
8719
8757
|
const day = normalizeToLocalDay(date);
|
|
8720
8758
|
if (!day) return false;
|
|
@@ -8783,19 +8821,19 @@ var DatePicker = ({
|
|
|
8783
8821
|
footerMargin: "mt-5 pt-4 gap-2.5"
|
|
8784
8822
|
}
|
|
8785
8823
|
};
|
|
8786
|
-
|
|
8824
|
+
React30.useEffect(() => {
|
|
8787
8825
|
if (value) {
|
|
8788
8826
|
setViewDate(value);
|
|
8789
8827
|
} else {
|
|
8790
8828
|
setViewDate(/* @__PURE__ */ new Date());
|
|
8791
8829
|
}
|
|
8792
8830
|
}, [value]);
|
|
8793
|
-
|
|
8831
|
+
React30.useEffect(() => {
|
|
8794
8832
|
if (disabled || !required || value) {
|
|
8795
8833
|
setLocalRequiredError(void 0);
|
|
8796
8834
|
}
|
|
8797
8835
|
}, [disabled, required, value]);
|
|
8798
|
-
|
|
8836
|
+
React30.useEffect(() => {
|
|
8799
8837
|
if (!isOpen) {
|
|
8800
8838
|
setViewMode("calendar");
|
|
8801
8839
|
}
|
|
@@ -8825,7 +8863,7 @@ var DatePicker = ({
|
|
|
8825
8863
|
const getFirstDayOfMonth = (date) => {
|
|
8826
8864
|
return new Date(date.getFullYear(), date.getMonth(), 1).getDay();
|
|
8827
8865
|
};
|
|
8828
|
-
const navigateMonth =
|
|
8866
|
+
const navigateMonth = React30.useCallback((direction) => {
|
|
8829
8867
|
setViewDate((prev) => {
|
|
8830
8868
|
const newDate = new Date(prev);
|
|
8831
8869
|
newDate.setMonth(prev.getMonth() + (direction === "next" ? 1 : -1));
|
|
@@ -8839,7 +8877,7 @@ var DatePicker = ({
|
|
|
8839
8877
|
const node = el;
|
|
8840
8878
|
return node.scrollHeight > node.clientHeight + 1;
|
|
8841
8879
|
};
|
|
8842
|
-
|
|
8880
|
+
React30.useEffect(() => {
|
|
8843
8881
|
if (!isOpen) return;
|
|
8844
8882
|
const container = wheelContainerRef.current;
|
|
8845
8883
|
if (!container) return;
|
|
@@ -9254,11 +9292,11 @@ var DateRangePicker = ({
|
|
|
9254
9292
|
const locale = useSmartLocale();
|
|
9255
9293
|
const t = useSmartTranslations("DatePicker");
|
|
9256
9294
|
const tv = useSmartTranslations("ValidationInput");
|
|
9257
|
-
const [isOpen, setIsOpen] =
|
|
9258
|
-
const [viewMode, setViewMode] =
|
|
9259
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
9260
|
-
const wheelContainerRef =
|
|
9261
|
-
const wheelDeltaRef =
|
|
9295
|
+
const [isOpen, setIsOpen] = React30.useState(false);
|
|
9296
|
+
const [viewMode, setViewMode] = React30.useState("calendar");
|
|
9297
|
+
const [localRequiredError, setLocalRequiredError] = React30.useState();
|
|
9298
|
+
const wheelContainerRef = React30.useRef(null);
|
|
9299
|
+
const wheelDeltaRef = React30.useRef(0);
|
|
9262
9300
|
const sizeStyles8 = {
|
|
9263
9301
|
sm: {
|
|
9264
9302
|
trigger: "px-2.5 py-1.5 text-sm h-8 md:h-7 md:text-xs md:py-1",
|
|
@@ -9316,24 +9354,24 @@ var DateRangePicker = ({
|
|
|
9316
9354
|
if (!date) return null;
|
|
9317
9355
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
9318
9356
|
};
|
|
9319
|
-
const minDay =
|
|
9320
|
-
const maxDay =
|
|
9321
|
-
const [viewDate, setViewDate] =
|
|
9322
|
-
const [tempStart, setTempStart] =
|
|
9323
|
-
const [tempEnd, setTempEnd] =
|
|
9324
|
-
const [hoveredDate, setHoveredDate] =
|
|
9325
|
-
|
|
9357
|
+
const minDay = React30.useMemo(() => normalizeToLocal(minDate), [minDate]);
|
|
9358
|
+
const maxDay = React30.useMemo(() => normalizeToLocal(maxDate), [maxDate]);
|
|
9359
|
+
const [viewDate, setViewDate] = React30.useState(startDate || /* @__PURE__ */ new Date());
|
|
9360
|
+
const [tempStart, setTempStart] = React30.useState(normalizeToLocal(startDate));
|
|
9361
|
+
const [tempEnd, setTempEnd] = React30.useState(normalizeToLocal(endDate));
|
|
9362
|
+
const [hoveredDate, setHoveredDate] = React30.useState(null);
|
|
9363
|
+
React30.useEffect(() => {
|
|
9326
9364
|
setTempStart(normalizeToLocal(startDate));
|
|
9327
9365
|
}, [startDate]);
|
|
9328
|
-
|
|
9366
|
+
React30.useEffect(() => {
|
|
9329
9367
|
setTempEnd(normalizeToLocal(endDate));
|
|
9330
9368
|
}, [endDate]);
|
|
9331
|
-
|
|
9369
|
+
React30.useEffect(() => {
|
|
9332
9370
|
if (!isOpen) {
|
|
9333
9371
|
setViewMode("calendar");
|
|
9334
9372
|
}
|
|
9335
9373
|
}, [isOpen]);
|
|
9336
|
-
|
|
9374
|
+
React30.useEffect(() => {
|
|
9337
9375
|
if (!required || startDate && endDate) {
|
|
9338
9376
|
setLocalRequiredError(void 0);
|
|
9339
9377
|
}
|
|
@@ -9345,10 +9383,10 @@ var DateRangePicker = ({
|
|
|
9345
9383
|
const inRange = (d, s, e) => d > s && d < e;
|
|
9346
9384
|
const getDaysInMonth = (d) => new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();
|
|
9347
9385
|
const getFirstDayOfMonth = (d) => new Date(d.getFullYear(), d.getMonth(), 1).getDay();
|
|
9348
|
-
const navigateMonth =
|
|
9386
|
+
const navigateMonth = React30.useCallback((direction) => {
|
|
9349
9387
|
setViewDate((prev) => new Date(prev.getFullYear(), prev.getMonth() + (direction === "next" ? 1 : -1), 1));
|
|
9350
9388
|
}, []);
|
|
9351
|
-
const navigateYearRange =
|
|
9389
|
+
const navigateYearRange = React30.useCallback((direction) => {
|
|
9352
9390
|
setViewDate((prev) => new Date(prev.getFullYear() + (direction === "next" ? 12 : -12), prev.getMonth(), 1));
|
|
9353
9391
|
}, []);
|
|
9354
9392
|
const isElementVerticallyScrollable = (el) => {
|
|
@@ -9358,7 +9396,7 @@ var DateRangePicker = ({
|
|
|
9358
9396
|
const node = el;
|
|
9359
9397
|
return node.scrollHeight > node.clientHeight + 1;
|
|
9360
9398
|
};
|
|
9361
|
-
|
|
9399
|
+
React30.useEffect(() => {
|
|
9362
9400
|
if (!isOpen) return;
|
|
9363
9401
|
const container = wheelContainerRef.current;
|
|
9364
9402
|
if (!container) return;
|
|
@@ -9537,7 +9575,7 @@ var DateRangePicker = ({
|
|
|
9537
9575
|
);
|
|
9538
9576
|
}) });
|
|
9539
9577
|
};
|
|
9540
|
-
const todayDate =
|
|
9578
|
+
const todayDate = React30.useMemo(() => {
|
|
9541
9579
|
const today = /* @__PURE__ */ new Date();
|
|
9542
9580
|
return new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
9543
9581
|
}, []);
|
|
@@ -9779,15 +9817,15 @@ var CompactDatePicker = ({ value, onChange, className }) => {
|
|
|
9779
9817
|
};
|
|
9780
9818
|
|
|
9781
9819
|
// src/components/DateTimePicker.tsx
|
|
9782
|
-
var
|
|
9820
|
+
var React34 = __toESM(require("react"), 1);
|
|
9783
9821
|
var import_lucide_react19 = require("lucide-react");
|
|
9784
9822
|
|
|
9785
9823
|
// src/components/Calendar.tsx
|
|
9786
9824
|
var import_lucide_react17 = require("lucide-react");
|
|
9787
|
-
var
|
|
9825
|
+
var React32 = __toESM(require("react"), 1);
|
|
9788
9826
|
|
|
9789
9827
|
// src/components/MonthYearPicker.tsx
|
|
9790
|
-
var
|
|
9828
|
+
var React31 = __toESM(require("react"), 1);
|
|
9791
9829
|
var import_lucide_react16 = require("lucide-react");
|
|
9792
9830
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
9793
9831
|
var DEFAULT_MONTH_NAMES = [
|
|
@@ -9830,20 +9868,20 @@ function WheelColumn({
|
|
|
9830
9868
|
}) {
|
|
9831
9869
|
const height = itemHeight * WHEEL_VISIBLE_ITEMS;
|
|
9832
9870
|
const paddingY = (height - itemHeight) / 2;
|
|
9833
|
-
const rafRef =
|
|
9834
|
-
const lastVirtualIndexRef =
|
|
9835
|
-
const wheelDeltaRef =
|
|
9836
|
-
const scrollEndTimeoutRef =
|
|
9837
|
-
const suppressScrollSelectUntilRef =
|
|
9838
|
-
const suppressItemClickUntilRef =
|
|
9839
|
-
const dragRef =
|
|
9840
|
-
const draggingRef =
|
|
9841
|
-
const inertialRef =
|
|
9842
|
-
const inertiaRafRef =
|
|
9843
|
-
const inertiaVelocityRef =
|
|
9844
|
-
const inertiaLastTimeRef =
|
|
9845
|
-
const moveSamplesRef =
|
|
9846
|
-
const ui =
|
|
9871
|
+
const rafRef = React31.useRef(0);
|
|
9872
|
+
const lastVirtualIndexRef = React31.useRef(null);
|
|
9873
|
+
const wheelDeltaRef = React31.useRef(0);
|
|
9874
|
+
const scrollEndTimeoutRef = React31.useRef(null);
|
|
9875
|
+
const suppressScrollSelectUntilRef = React31.useRef(0);
|
|
9876
|
+
const suppressItemClickUntilRef = React31.useRef(0);
|
|
9877
|
+
const dragRef = React31.useRef(null);
|
|
9878
|
+
const draggingRef = React31.useRef(false);
|
|
9879
|
+
const inertialRef = React31.useRef(false);
|
|
9880
|
+
const inertiaRafRef = React31.useRef(null);
|
|
9881
|
+
const inertiaVelocityRef = React31.useRef(0);
|
|
9882
|
+
const inertiaLastTimeRef = React31.useRef(0);
|
|
9883
|
+
const moveSamplesRef = React31.useRef([]);
|
|
9884
|
+
const ui = React31.useMemo(() => {
|
|
9847
9885
|
if (size === "sm") {
|
|
9848
9886
|
return {
|
|
9849
9887
|
columnWidth: column === "month" ? "min-w-24 max-w-32" : "min-w-16 max-w-20",
|
|
@@ -9870,9 +9908,9 @@ function WheelColumn({
|
|
|
9870
9908
|
fadeHeight: "h-12"
|
|
9871
9909
|
};
|
|
9872
9910
|
}, [size, column]);
|
|
9873
|
-
const baseOffset =
|
|
9874
|
-
const extendedItems =
|
|
9875
|
-
const getNearestVirtualIndex =
|
|
9911
|
+
const baseOffset = React31.useMemo(() => loop ? items.length : 0, [items.length, loop]);
|
|
9912
|
+
const extendedItems = React31.useMemo(() => loop ? [...items, ...items, ...items] : items, [items, loop]);
|
|
9913
|
+
const getNearestVirtualIndex = React31.useCallback(
|
|
9876
9914
|
(realIndex, fromVirtual) => {
|
|
9877
9915
|
const len = items.length;
|
|
9878
9916
|
if (len <= 0) return 0;
|
|
@@ -9891,7 +9929,7 @@ function WheelColumn({
|
|
|
9891
9929
|
},
|
|
9892
9930
|
[items.length, loop]
|
|
9893
9931
|
);
|
|
9894
|
-
|
|
9932
|
+
React31.useLayoutEffect(() => {
|
|
9895
9933
|
const el = scrollRef.current;
|
|
9896
9934
|
if (!el) return;
|
|
9897
9935
|
const maxVirtual = Math.max(0, extendedItems.length - 1);
|
|
@@ -9919,7 +9957,7 @@ function WheelColumn({
|
|
|
9919
9957
|
cancelAnimationFrame(rafRef.current);
|
|
9920
9958
|
};
|
|
9921
9959
|
}, [animate, baseOffset, extendedItems.length, getNearestVirtualIndex, itemHeight, loop, scrollRef, valueIndex]);
|
|
9922
|
-
|
|
9960
|
+
React31.useEffect(() => {
|
|
9923
9961
|
const el = scrollRef.current;
|
|
9924
9962
|
if (!el) return;
|
|
9925
9963
|
const lastWheelSignRef = { current: 0 };
|
|
@@ -10007,11 +10045,11 @@ function WheelColumn({
|
|
|
10007
10045
|
}, 120);
|
|
10008
10046
|
});
|
|
10009
10047
|
};
|
|
10010
|
-
const currentVirtual =
|
|
10048
|
+
const currentVirtual = React31.useMemo(() => {
|
|
10011
10049
|
if (!loop || items.length <= 0) return valueIndex;
|
|
10012
10050
|
return baseOffset + valueIndex;
|
|
10013
10051
|
}, [baseOffset, items.length, loop, valueIndex]);
|
|
10014
|
-
const commitFromScrollTop =
|
|
10052
|
+
const commitFromScrollTop = React31.useCallback(
|
|
10015
10053
|
(behavior) => {
|
|
10016
10054
|
const el = scrollRef.current;
|
|
10017
10055
|
if (!el) return;
|
|
@@ -10089,7 +10127,7 @@ function WheelColumn({
|
|
|
10089
10127
|
if (dt > 0) inertiaVelocityRef.current = (el.scrollTop - oldest.top) / dt;
|
|
10090
10128
|
}
|
|
10091
10129
|
};
|
|
10092
|
-
const startInertia =
|
|
10130
|
+
const startInertia = React31.useCallback(() => {
|
|
10093
10131
|
const el = scrollRef.current;
|
|
10094
10132
|
if (!el) return;
|
|
10095
10133
|
if (items.length <= 0) return;
|
|
@@ -10274,36 +10312,36 @@ function MonthYearPicker({
|
|
|
10274
10312
|
};
|
|
10275
10313
|
const isControlled = value !== void 0;
|
|
10276
10314
|
const initial = parseValue(isControlled ? value : defaultValue) ?? { month: now.getMonth(), year: currentYear };
|
|
10277
|
-
const [open, setOpen] =
|
|
10278
|
-
const [parts, setParts] =
|
|
10279
|
-
const [focusedColumn, setFocusedColumn] =
|
|
10280
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
10281
|
-
const [hasCommittedValue, setHasCommittedValue] =
|
|
10282
|
-
const monthScrollRef =
|
|
10283
|
-
const yearScrollRef =
|
|
10284
|
-
|
|
10315
|
+
const [open, setOpen] = React31.useState(false);
|
|
10316
|
+
const [parts, setParts] = React31.useState(initial);
|
|
10317
|
+
const [focusedColumn, setFocusedColumn] = React31.useState(null);
|
|
10318
|
+
const [localRequiredError, setLocalRequiredError] = React31.useState();
|
|
10319
|
+
const [hasCommittedValue, setHasCommittedValue] = React31.useState(Boolean(parseValue(isControlled ? value : defaultValue)));
|
|
10320
|
+
const monthScrollRef = React31.useRef(null);
|
|
10321
|
+
const yearScrollRef = React31.useRef(null);
|
|
10322
|
+
React31.useEffect(() => {
|
|
10285
10323
|
if (isControlled) {
|
|
10286
10324
|
const parsed = parseValue(value);
|
|
10287
10325
|
if (parsed) setParts(parsed);
|
|
10288
10326
|
}
|
|
10289
10327
|
}, [value, isControlled]);
|
|
10290
|
-
|
|
10328
|
+
React31.useEffect(() => {
|
|
10291
10329
|
if (isControlled) {
|
|
10292
10330
|
setHasCommittedValue(Boolean(parseValue(value)));
|
|
10293
10331
|
}
|
|
10294
10332
|
}, [isControlled, value]);
|
|
10295
10333
|
const hasValue = hasCommittedValue;
|
|
10296
10334
|
const effectiveError = error ?? localRequiredError;
|
|
10297
|
-
|
|
10335
|
+
React31.useEffect(() => {
|
|
10298
10336
|
if (disabled || !required || hasValue) {
|
|
10299
10337
|
setLocalRequiredError(void 0);
|
|
10300
10338
|
}
|
|
10301
10339
|
}, [disabled, hasValue, required]);
|
|
10302
|
-
const years =
|
|
10340
|
+
const years = React31.useMemo(() => {
|
|
10303
10341
|
return Array.from({ length: resolvedMaxYear - resolvedMinYear + 1 }, (_, i) => resolvedMinYear + i);
|
|
10304
10342
|
}, [resolvedMinYear, resolvedMaxYear]);
|
|
10305
|
-
const months =
|
|
10306
|
-
const isDateInRange =
|
|
10343
|
+
const months = React31.useMemo(() => Array.from({ length: 12 }, (_, i) => i), []);
|
|
10344
|
+
const isDateInRange = React31.useCallback(
|
|
10307
10345
|
(month, year) => {
|
|
10308
10346
|
if (minDate) {
|
|
10309
10347
|
const minMonth = minDate.getMonth();
|
|
@@ -10319,7 +10357,7 @@ function MonthYearPicker({
|
|
|
10319
10357
|
},
|
|
10320
10358
|
[minDate, maxDate]
|
|
10321
10359
|
);
|
|
10322
|
-
const emit =
|
|
10360
|
+
const emit = React31.useCallback(
|
|
10323
10361
|
(next) => {
|
|
10324
10362
|
if (!next) {
|
|
10325
10363
|
setLocalRequiredError(void 0);
|
|
@@ -10335,7 +10373,7 @@ function MonthYearPicker({
|
|
|
10335
10373
|
},
|
|
10336
10374
|
[isControlled, isDateInRange, onChange]
|
|
10337
10375
|
);
|
|
10338
|
-
const tryUpdate =
|
|
10376
|
+
const tryUpdate = React31.useCallback(
|
|
10339
10377
|
(next) => {
|
|
10340
10378
|
if (!isDateInRange(next.month, next.year)) return false;
|
|
10341
10379
|
setParts(next);
|
|
@@ -10771,12 +10809,12 @@ function Calendar3({
|
|
|
10771
10809
|
...rest
|
|
10772
10810
|
}) {
|
|
10773
10811
|
const isControlledMonth = month != null;
|
|
10774
|
-
const [view, setView] =
|
|
10775
|
-
|
|
10812
|
+
const [view, setView] = React32.useState(() => month ?? defaultMonth ?? /* @__PURE__ */ new Date());
|
|
10813
|
+
React32.useEffect(() => {
|
|
10776
10814
|
if (isControlledMonth && month) setView(month);
|
|
10777
10815
|
}, [isControlledMonth, month]);
|
|
10778
10816
|
const isControlledValue = value !== void 0;
|
|
10779
|
-
const [internal, setInternal] =
|
|
10817
|
+
const [internal, setInternal] = React32.useState(defaultValue);
|
|
10780
10818
|
const selected = isControlledValue ? value : internal;
|
|
10781
10819
|
const goByView = (delta) => {
|
|
10782
10820
|
const next = display === "week" ? addDays(view, delta * 7) : addMonths(view, delta);
|
|
@@ -10788,7 +10826,7 @@ function Calendar3({
|
|
|
10788
10826
|
const weekdays = rotate(weekNames, weekStartsOn);
|
|
10789
10827
|
const days = getMonthGrid(view, weekStartsOn);
|
|
10790
10828
|
const today = /* @__PURE__ */ new Date();
|
|
10791
|
-
const byDay =
|
|
10829
|
+
const byDay = React32.useMemo(() => {
|
|
10792
10830
|
const map = /* @__PURE__ */ new Map();
|
|
10793
10831
|
for (const e of events) {
|
|
10794
10832
|
const d = toDate(e.date);
|
|
@@ -10800,11 +10838,11 @@ function Calendar3({
|
|
|
10800
10838
|
}, [events]);
|
|
10801
10839
|
const effectiveEnableEventSheet = enableEventSheet ?? !!renderEventSheet;
|
|
10802
10840
|
const isEventSheetOpenControlled = eventSheetOpen !== void 0;
|
|
10803
|
-
const [internalEventSheetOpen, setInternalEventSheetOpen] =
|
|
10841
|
+
const [internalEventSheetOpen, setInternalEventSheetOpen] = React32.useState(false);
|
|
10804
10842
|
const activeEventSheetOpen = isEventSheetOpenControlled ? !!eventSheetOpen : internalEventSheetOpen;
|
|
10805
10843
|
const isSelectedEventControlled = selectedEventId !== void 0;
|
|
10806
|
-
const [internalSelectedEventRef, setInternalSelectedEventRef] =
|
|
10807
|
-
const setEventSheetOpen =
|
|
10844
|
+
const [internalSelectedEventRef, setInternalSelectedEventRef] = React32.useState(null);
|
|
10845
|
+
const setEventSheetOpen = React32.useCallback(
|
|
10808
10846
|
(open) => {
|
|
10809
10847
|
if (!isEventSheetOpenControlled) setInternalEventSheetOpen(open);
|
|
10810
10848
|
onEventSheetOpenChange?.(open);
|
|
@@ -10815,7 +10853,7 @@ function Calendar3({
|
|
|
10815
10853
|
},
|
|
10816
10854
|
[isEventSheetOpenControlled, isSelectedEventControlled, onEventSheetOpenChange, onSelectedEventIdChange]
|
|
10817
10855
|
);
|
|
10818
|
-
const selectedEventRef =
|
|
10856
|
+
const selectedEventRef = React32.useMemo(() => {
|
|
10819
10857
|
if (isSelectedEventControlled && selectedEventId != null) {
|
|
10820
10858
|
const ev = events.find((e) => e.id === selectedEventId);
|
|
10821
10859
|
if (!ev) return null;
|
|
@@ -10825,7 +10863,7 @@ function Calendar3({
|
|
|
10825
10863
|
}
|
|
10826
10864
|
return internalSelectedEventRef;
|
|
10827
10865
|
}, [events, internalSelectedEventRef, isSelectedEventControlled, selectedEventId]);
|
|
10828
|
-
const selectedEvent =
|
|
10866
|
+
const selectedEvent = React32.useMemo(() => {
|
|
10829
10867
|
if (!selectedEventRef) return null;
|
|
10830
10868
|
const list = byDay.get(selectedEventRef.dayKey) || [];
|
|
10831
10869
|
if (selectedEventRef.eventId != null) {
|
|
@@ -10834,13 +10872,13 @@ function Calendar3({
|
|
|
10834
10872
|
const idx = selectedEventRef.index ?? -1;
|
|
10835
10873
|
return idx >= 0 && idx < list.length ? list[idx] : null;
|
|
10836
10874
|
}, [byDay, selectedEventRef]);
|
|
10837
|
-
const selectedEventDate =
|
|
10875
|
+
const selectedEventDate = React32.useMemo(() => {
|
|
10838
10876
|
if (!selectedEventRef) return null;
|
|
10839
10877
|
const [y, m, d] = selectedEventRef.dayKey.split("-").map((x) => Number(x));
|
|
10840
10878
|
if (!Number.isFinite(y) || !Number.isFinite(m) || !Number.isFinite(d)) return null;
|
|
10841
10879
|
return new Date(y, m, d);
|
|
10842
10880
|
}, [selectedEventRef]);
|
|
10843
|
-
const handleEventActivate =
|
|
10881
|
+
const handleEventActivate = React32.useCallback(
|
|
10844
10882
|
(event, date, dayKey, index) => {
|
|
10845
10883
|
onEventClick?.(event, date);
|
|
10846
10884
|
onSelectedEventIdChange?.(event.id ?? void 0);
|
|
@@ -10893,7 +10931,7 @@ function Calendar3({
|
|
|
10893
10931
|
}
|
|
10894
10932
|
}
|
|
10895
10933
|
};
|
|
10896
|
-
const isDateDisabled =
|
|
10934
|
+
const isDateDisabled = React32.useCallback(
|
|
10897
10935
|
(d) => {
|
|
10898
10936
|
if (minDate && d < new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate())) return true;
|
|
10899
10937
|
if (maxDate && d > new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate())) return true;
|
|
@@ -10927,7 +10965,7 @@ function Calendar3({
|
|
|
10927
10965
|
card: "border border-border/50 rounded-3xl bg-linear-to-br from-card via-background/95 to-card shadow-lg hover:shadow-xl transition-shadow duration-300 backdrop-blur-md",
|
|
10928
10966
|
minimal: "bg-transparent"
|
|
10929
10967
|
};
|
|
10930
|
-
const weekDays =
|
|
10968
|
+
const weekDays = React32.useMemo(() => {
|
|
10931
10969
|
const s = startOfWeek(view, weekStartsOn);
|
|
10932
10970
|
return Array.from({ length: 7 }, (_, i) => addDays(s, i));
|
|
10933
10971
|
}, [view, weekStartsOn]);
|
|
@@ -10948,7 +10986,7 @@ function Calendar3({
|
|
|
10948
10986
|
const holidayMatch = isHoliday(d, holidays);
|
|
10949
10987
|
const isHolidayDay = highlightHolidays && !!holidayMatch;
|
|
10950
10988
|
const customDay = renderDay?.({ date: d, isCurrentMonth: inMonth, isToday: isToday2, isSelected: selectedDay, events: dayEvents });
|
|
10951
|
-
if (customDay) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
10989
|
+
if (customDay) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(React32.Fragment, { children: customDay }, `${monthLabel}-${idx}`);
|
|
10952
10990
|
if (cellMode === "events") {
|
|
10953
10991
|
const limit = Math.max(0, maxEventsPerDay);
|
|
10954
10992
|
const visibleEvents = dayEvents.slice(0, limit);
|
|
@@ -11067,9 +11105,9 @@ function Calendar3({
|
|
|
11067
11105
|
}) })
|
|
11068
11106
|
] });
|
|
11069
11107
|
};
|
|
11070
|
-
const minBound =
|
|
11071
|
-
const maxBound =
|
|
11072
|
-
const prevDisabled =
|
|
11108
|
+
const minBound = React32.useMemo(() => minDate ? new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate()) : void 0, [minDate]);
|
|
11109
|
+
const maxBound = React32.useMemo(() => maxDate ? new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate()) : void 0, [maxDate]);
|
|
11110
|
+
const prevDisabled = React32.useMemo(() => {
|
|
11073
11111
|
if (!minBound) return false;
|
|
11074
11112
|
if (display === "week") {
|
|
11075
11113
|
const start = startOfWeek(view, weekStartsOn);
|
|
@@ -11079,7 +11117,7 @@ function Calendar3({
|
|
|
11079
11117
|
const prevEnd = endOfMonth(addMonths(view, -1));
|
|
11080
11118
|
return prevEnd < minBound;
|
|
11081
11119
|
}, [display, view, weekStartsOn, minBound]);
|
|
11082
|
-
const nextDisabled =
|
|
11120
|
+
const nextDisabled = React32.useMemo(() => {
|
|
11083
11121
|
if (!maxBound) return false;
|
|
11084
11122
|
if (display === "week") {
|
|
11085
11123
|
const start = startOfWeek(view, weekStartsOn);
|
|
@@ -11156,7 +11194,7 @@ function Calendar3({
|
|
|
11156
11194
|
const holidayMatch = isHoliday(d, holidays);
|
|
11157
11195
|
const isHolidayDay = highlightHolidays && !!holidayMatch;
|
|
11158
11196
|
const customDay = renderDay?.({ date: d, isCurrentMonth: inMonth, isToday: isToday2, isSelected: selectedDay, events: dayEvents });
|
|
11159
|
-
if (customDay) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11197
|
+
if (customDay) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(React32.Fragment, { children: customDay }, `wd-${idx}`);
|
|
11160
11198
|
if (cellMode === "events") {
|
|
11161
11199
|
const limit = Math.max(0, maxEventsPerDay);
|
|
11162
11200
|
const visibleEvents = dayEvents.slice(0, limit);
|
|
@@ -11267,7 +11305,7 @@ function Calendar3({
|
|
|
11267
11305
|
`wd-${idx}`
|
|
11268
11306
|
);
|
|
11269
11307
|
}) })
|
|
11270
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: cn(months > 1 ? "grid md:grid-cols-2 lg:grid-cols-3 gap-4" : ""), children: Array.from({ length: Math.max(1, months) }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11308
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: cn(months > 1 ? "grid md:grid-cols-2 lg:grid-cols-3 gap-4" : ""), children: Array.from({ length: Math.max(1, months) }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(React32.Fragment, { children: renderMonth(addMonths(view, i)) }, `cal-month-${view.getFullYear()}-${view.getMonth()}-${i}`)) }),
|
|
11271
11309
|
effectiveEnableEventSheet && selectedEvent && selectedEventDate ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11272
11310
|
Sheet,
|
|
11273
11311
|
{
|
|
@@ -11297,7 +11335,7 @@ function Calendar3({
|
|
|
11297
11335
|
}
|
|
11298
11336
|
|
|
11299
11337
|
// src/components/TimePicker.tsx
|
|
11300
|
-
var
|
|
11338
|
+
var React33 = __toESM(require("react"), 1);
|
|
11301
11339
|
var import_lucide_react18 = require("lucide-react");
|
|
11302
11340
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
11303
11341
|
var pad = (n) => n.toString().padStart(2, "0");
|
|
@@ -11324,21 +11362,21 @@ function WheelColumn2({
|
|
|
11324
11362
|
}) {
|
|
11325
11363
|
const height = itemHeight * WHEEL_VISIBLE_ITEMS2;
|
|
11326
11364
|
const paddingY = (height - itemHeight) / 2;
|
|
11327
|
-
const rafRef =
|
|
11328
|
-
const lastVirtualIndexRef =
|
|
11329
|
-
const wheelDeltaRef =
|
|
11330
|
-
const scrollEndTimeoutRef =
|
|
11331
|
-
const suppressScrollSelectUntilRef =
|
|
11332
|
-
const suppressItemClickUntilRef =
|
|
11333
|
-
const dragRef =
|
|
11334
|
-
const draggingRef =
|
|
11335
|
-
const inertialRef =
|
|
11336
|
-
const inertiaRafRef =
|
|
11337
|
-
const inertiaVelocityRef =
|
|
11338
|
-
const inertiaLastTimeRef =
|
|
11339
|
-
const moveSamplesRef =
|
|
11365
|
+
const rafRef = React33.useRef(0);
|
|
11366
|
+
const lastVirtualIndexRef = React33.useRef(null);
|
|
11367
|
+
const wheelDeltaRef = React33.useRef(0);
|
|
11368
|
+
const scrollEndTimeoutRef = React33.useRef(null);
|
|
11369
|
+
const suppressScrollSelectUntilRef = React33.useRef(0);
|
|
11370
|
+
const suppressItemClickUntilRef = React33.useRef(0);
|
|
11371
|
+
const dragRef = React33.useRef(null);
|
|
11372
|
+
const draggingRef = React33.useRef(false);
|
|
11373
|
+
const inertialRef = React33.useRef(false);
|
|
11374
|
+
const inertiaRafRef = React33.useRef(null);
|
|
11375
|
+
const inertiaVelocityRef = React33.useRef(0);
|
|
11376
|
+
const inertiaLastTimeRef = React33.useRef(0);
|
|
11377
|
+
const moveSamplesRef = React33.useRef([]);
|
|
11340
11378
|
const loop = true;
|
|
11341
|
-
const ui =
|
|
11379
|
+
const ui = React33.useMemo(() => {
|
|
11342
11380
|
if (size === "sm") {
|
|
11343
11381
|
return {
|
|
11344
11382
|
columnWidth: "min-w-16 max-w-21",
|
|
@@ -11365,9 +11403,9 @@ function WheelColumn2({
|
|
|
11365
11403
|
fadeHeight: "h-12"
|
|
11366
11404
|
};
|
|
11367
11405
|
}, [size]);
|
|
11368
|
-
const baseOffset =
|
|
11369
|
-
const extendedItems =
|
|
11370
|
-
const getNearestVirtualIndex =
|
|
11406
|
+
const baseOffset = React33.useMemo(() => loop ? items.length : 0, [items.length, loop]);
|
|
11407
|
+
const extendedItems = React33.useMemo(() => loop ? [...items, ...items, ...items] : items, [items, loop]);
|
|
11408
|
+
const getNearestVirtualIndex = React33.useCallback(
|
|
11371
11409
|
(realIndex, fromVirtual) => {
|
|
11372
11410
|
const len = items.length;
|
|
11373
11411
|
if (len <= 0) return 0;
|
|
@@ -11386,7 +11424,7 @@ function WheelColumn2({
|
|
|
11386
11424
|
},
|
|
11387
11425
|
[items.length, loop]
|
|
11388
11426
|
);
|
|
11389
|
-
|
|
11427
|
+
React33.useLayoutEffect(() => {
|
|
11390
11428
|
const el = scrollRef.current;
|
|
11391
11429
|
if (!el) return;
|
|
11392
11430
|
const maxVirtual = Math.max(0, extendedItems.length - 1);
|
|
@@ -11414,7 +11452,7 @@ function WheelColumn2({
|
|
|
11414
11452
|
cancelAnimationFrame(rafRef.current);
|
|
11415
11453
|
};
|
|
11416
11454
|
}, [animate, baseOffset, extendedItems.length, getNearestVirtualIndex, itemHeight, loop, scrollRef, valueIndex]);
|
|
11417
|
-
|
|
11455
|
+
React33.useEffect(() => {
|
|
11418
11456
|
const el = scrollRef.current;
|
|
11419
11457
|
if (!el) return;
|
|
11420
11458
|
const lastWheelSignRef = { current: 0 };
|
|
@@ -11502,11 +11540,11 @@ function WheelColumn2({
|
|
|
11502
11540
|
}, 120);
|
|
11503
11541
|
});
|
|
11504
11542
|
};
|
|
11505
|
-
const currentVirtual =
|
|
11543
|
+
const currentVirtual = React33.useMemo(() => {
|
|
11506
11544
|
if (!loop || items.length <= 0) return valueIndex;
|
|
11507
11545
|
return baseOffset + valueIndex;
|
|
11508
11546
|
}, [baseOffset, items.length, loop, valueIndex]);
|
|
11509
|
-
const commitFromScrollTop =
|
|
11547
|
+
const commitFromScrollTop = React33.useCallback(
|
|
11510
11548
|
(behavior) => {
|
|
11511
11549
|
const el = scrollRef.current;
|
|
11512
11550
|
if (!el) return;
|
|
@@ -11584,7 +11622,7 @@ function WheelColumn2({
|
|
|
11584
11622
|
if (dt > 0) inertiaVelocityRef.current = (el.scrollTop - oldest.top) / dt;
|
|
11585
11623
|
}
|
|
11586
11624
|
};
|
|
11587
|
-
const startInertia =
|
|
11625
|
+
const startInertia = React33.useCallback(() => {
|
|
11588
11626
|
const el = scrollRef.current;
|
|
11589
11627
|
if (!el) return;
|
|
11590
11628
|
if (items.length <= 0) return;
|
|
@@ -11785,44 +11823,44 @@ function TimePicker({
|
|
|
11785
11823
|
}) {
|
|
11786
11824
|
const tv = useSmartTranslations("ValidationInput");
|
|
11787
11825
|
const gi18n = useGlobalI18n();
|
|
11788
|
-
const autoId =
|
|
11826
|
+
const autoId = React33.useId();
|
|
11789
11827
|
const isControlled = value !== void 0;
|
|
11790
11828
|
const now = /* @__PURE__ */ new Date();
|
|
11791
11829
|
const initial = parseTime(isControlled ? value : defaultValue, format, includeSeconds) || (format === "12" ? { h: now.getHours() % 12 || 12, m: now.getMinutes(), s: now.getSeconds(), p: now.getHours() >= 12 ? "PM" : "AM" } : { h: now.getHours(), m: now.getMinutes(), s: now.getSeconds() });
|
|
11792
|
-
const [open, setOpen] =
|
|
11793
|
-
const [parts, setParts] =
|
|
11794
|
-
const [manualInput, setManualInput] =
|
|
11795
|
-
const [isDirectEditing, setIsDirectEditing] =
|
|
11796
|
-
const [focusedColumn, setFocusedColumn] =
|
|
11797
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
11798
|
-
const [hasCommittedValue, setHasCommittedValue] =
|
|
11799
|
-
const hourScrollRef =
|
|
11800
|
-
const minuteScrollRef =
|
|
11801
|
-
const secondScrollRef =
|
|
11802
|
-
const periodRef =
|
|
11803
|
-
const directEditInputRef =
|
|
11830
|
+
const [open, setOpen] = React33.useState(false);
|
|
11831
|
+
const [parts, setParts] = React33.useState(initial);
|
|
11832
|
+
const [manualInput, setManualInput] = React33.useState(formatTime2(initial, format, includeSeconds));
|
|
11833
|
+
const [isDirectEditing, setIsDirectEditing] = React33.useState(false);
|
|
11834
|
+
const [focusedColumn, setFocusedColumn] = React33.useState(null);
|
|
11835
|
+
const [localRequiredError, setLocalRequiredError] = React33.useState();
|
|
11836
|
+
const [hasCommittedValue, setHasCommittedValue] = React33.useState(Boolean(isControlled ? value : defaultValue));
|
|
11837
|
+
const hourScrollRef = React33.useRef(null);
|
|
11838
|
+
const minuteScrollRef = React33.useRef(null);
|
|
11839
|
+
const secondScrollRef = React33.useRef(null);
|
|
11840
|
+
const periodRef = React33.useRef(null);
|
|
11841
|
+
const directEditInputRef = React33.useRef(null);
|
|
11804
11842
|
const triggerId = `time-picker-trigger-${autoId}`;
|
|
11805
11843
|
const labelId = label ? `time-picker-label-${autoId}` : void 0;
|
|
11806
|
-
|
|
11844
|
+
React33.useEffect(() => {
|
|
11807
11845
|
if (isControlled) {
|
|
11808
11846
|
const parsed = parseTime(value, format, includeSeconds);
|
|
11809
11847
|
if (parsed) setParts(parsed);
|
|
11810
11848
|
}
|
|
11811
11849
|
}, [value, isControlled, format, includeSeconds]);
|
|
11812
|
-
|
|
11850
|
+
React33.useEffect(() => {
|
|
11813
11851
|
setManualInput(formatTime2(parts, format, includeSeconds));
|
|
11814
11852
|
}, [format, includeSeconds, parts]);
|
|
11815
|
-
|
|
11853
|
+
React33.useEffect(() => {
|
|
11816
11854
|
if (!isDirectEditing) return;
|
|
11817
11855
|
directEditInputRef.current?.focus();
|
|
11818
11856
|
directEditInputRef.current?.select();
|
|
11819
11857
|
}, [isDirectEditing]);
|
|
11820
|
-
|
|
11858
|
+
React33.useEffect(() => {
|
|
11821
11859
|
if (isControlled) {
|
|
11822
11860
|
setHasCommittedValue(Boolean(value));
|
|
11823
11861
|
}
|
|
11824
11862
|
}, [isControlled, value]);
|
|
11825
|
-
const isTimeDisabled =
|
|
11863
|
+
const isTimeDisabled = React33.useCallback(
|
|
11826
11864
|
(timeStr) => {
|
|
11827
11865
|
if (!disabledTimes) return false;
|
|
11828
11866
|
if (typeof disabledTimes === "function") return disabledTimes(timeStr);
|
|
@@ -11832,7 +11870,7 @@ function TimePicker({
|
|
|
11832
11870
|
);
|
|
11833
11871
|
const resolvedMinTime = minTime ?? min;
|
|
11834
11872
|
const resolvedMaxTime = maxTime ?? max;
|
|
11835
|
-
const toSeconds =
|
|
11873
|
+
const toSeconds = React33.useCallback(
|
|
11836
11874
|
(p) => {
|
|
11837
11875
|
let h = p.h;
|
|
11838
11876
|
if (format === "12") {
|
|
@@ -11844,7 +11882,7 @@ function TimePicker({
|
|
|
11844
11882
|
},
|
|
11845
11883
|
[format, includeSeconds]
|
|
11846
11884
|
);
|
|
11847
|
-
const isTimeInRange =
|
|
11885
|
+
const isTimeInRange = React33.useCallback(
|
|
11848
11886
|
(timeStr) => {
|
|
11849
11887
|
if (!resolvedMinTime && !resolvedMaxTime) return true;
|
|
11850
11888
|
const parsed = parseTime(timeStr, format, includeSeconds);
|
|
@@ -11862,7 +11900,7 @@ function TimePicker({
|
|
|
11862
11900
|
},
|
|
11863
11901
|
[format, includeSeconds, resolvedMaxTime, resolvedMinTime, toSeconds]
|
|
11864
11902
|
);
|
|
11865
|
-
const canEmit =
|
|
11903
|
+
const canEmit = React33.useCallback(
|
|
11866
11904
|
(next) => {
|
|
11867
11905
|
const timeStr = next ? formatTime2(next, format, includeSeconds) : void 0;
|
|
11868
11906
|
if (!timeStr) return true;
|
|
@@ -11872,7 +11910,7 @@ function TimePicker({
|
|
|
11872
11910
|
},
|
|
11873
11911
|
[format, includeSeconds, isTimeDisabled, isTimeInRange]
|
|
11874
11912
|
);
|
|
11875
|
-
const emit =
|
|
11913
|
+
const emit = React33.useCallback(
|
|
11876
11914
|
(next) => {
|
|
11877
11915
|
const timeStr = next ? formatTime2(next, format, includeSeconds) : void 0;
|
|
11878
11916
|
if (!canEmit(next)) return;
|
|
@@ -11884,7 +11922,7 @@ function TimePicker({
|
|
|
11884
11922
|
},
|
|
11885
11923
|
[canEmit, format, includeSeconds, isControlled, onChange]
|
|
11886
11924
|
);
|
|
11887
|
-
const tryUpdate =
|
|
11925
|
+
const tryUpdate = React33.useCallback(
|
|
11888
11926
|
(next) => {
|
|
11889
11927
|
if (!canEmit(next)) return false;
|
|
11890
11928
|
setParts(next);
|
|
@@ -11902,17 +11940,17 @@ function TimePicker({
|
|
|
11902
11940
|
setFocusedColumn(null);
|
|
11903
11941
|
}
|
|
11904
11942
|
};
|
|
11905
|
-
|
|
11943
|
+
React33.useEffect(() => {
|
|
11906
11944
|
if (disabled || !required || hasCommittedValue) {
|
|
11907
11945
|
setLocalRequiredError(void 0);
|
|
11908
11946
|
}
|
|
11909
11947
|
}, [disabled, hasCommittedValue, required]);
|
|
11910
|
-
const focusColumn =
|
|
11948
|
+
const focusColumn = React33.useCallback((column) => {
|
|
11911
11949
|
if (!column) return;
|
|
11912
11950
|
const target = column === "hour" ? hourScrollRef.current : column === "minute" ? minuteScrollRef.current : column === "second" ? secondScrollRef.current : periodRef.current;
|
|
11913
11951
|
target?.focus({ preventScroll: true });
|
|
11914
11952
|
}, []);
|
|
11915
|
-
|
|
11953
|
+
React33.useEffect(() => {
|
|
11916
11954
|
if (variant !== "inline" && !open) return;
|
|
11917
11955
|
focusColumn(focusedColumn);
|
|
11918
11956
|
}, [focusColumn, focusedColumn, open, variant]);
|
|
@@ -11994,7 +12032,7 @@ function TimePicker({
|
|
|
11994
12032
|
}
|
|
11995
12033
|
}
|
|
11996
12034
|
};
|
|
11997
|
-
const commitManualInput =
|
|
12035
|
+
const commitManualInput = React33.useCallback(
|
|
11998
12036
|
(input) => {
|
|
11999
12037
|
const trimmed = input.trim();
|
|
12000
12038
|
if (!trimmed) {
|
|
@@ -12025,12 +12063,12 @@ function TimePicker({
|
|
|
12025
12063
|
},
|
|
12026
12064
|
[display, format, includeSeconds, isTimeDisabled, isTimeInRange, tryUpdate]
|
|
12027
12065
|
);
|
|
12028
|
-
const startDirectEdit =
|
|
12066
|
+
const startDirectEdit = React33.useCallback(() => {
|
|
12029
12067
|
if (disabled) return;
|
|
12030
12068
|
setManualInput(display);
|
|
12031
12069
|
setIsDirectEditing(true);
|
|
12032
12070
|
}, [disabled, display]);
|
|
12033
|
-
const stopDirectEdit =
|
|
12071
|
+
const stopDirectEdit = React33.useCallback(
|
|
12034
12072
|
(mode) => {
|
|
12035
12073
|
if (mode === "commit") {
|
|
12036
12074
|
commitManualInput(manualInput);
|
|
@@ -12606,8 +12644,8 @@ var DateTimePicker = ({
|
|
|
12606
12644
|
const t = useSmartTranslations("DateTimePicker");
|
|
12607
12645
|
const tv = useSmartTranslations("ValidationInput");
|
|
12608
12646
|
const locale = useSmartLocale();
|
|
12609
|
-
const [open, setOpen] =
|
|
12610
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
12647
|
+
const [open, setOpen] = React34.useState(false);
|
|
12648
|
+
const [localRequiredError, setLocalRequiredError] = React34.useState();
|
|
12611
12649
|
const sizeStyles8 = {
|
|
12612
12650
|
sm: {
|
|
12613
12651
|
trigger: "h-8 px-2.5 py-1.5 text-sm md:h-7 md:text-xs",
|
|
@@ -12640,13 +12678,13 @@ var DateTimePicker = ({
|
|
|
12640
12678
|
gap: "gap-4"
|
|
12641
12679
|
}
|
|
12642
12680
|
};
|
|
12643
|
-
const [tempDate, setTempDate] =
|
|
12644
|
-
const [calendarMonth, setCalendarMonth] =
|
|
12645
|
-
|
|
12681
|
+
const [tempDate, setTempDate] = React34.useState(value);
|
|
12682
|
+
const [calendarMonth, setCalendarMonth] = React34.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
12683
|
+
React34.useEffect(() => {
|
|
12646
12684
|
setTempDate(value);
|
|
12647
12685
|
setCalendarMonth(value ?? /* @__PURE__ */ new Date());
|
|
12648
12686
|
}, [value, open]);
|
|
12649
|
-
|
|
12687
|
+
React34.useEffect(() => {
|
|
12650
12688
|
if (disabled || !required || value) {
|
|
12651
12689
|
setLocalRequiredError(void 0);
|
|
12652
12690
|
}
|
|
@@ -12865,7 +12903,7 @@ var DateTimePicker = ({
|
|
|
12865
12903
|
};
|
|
12866
12904
|
|
|
12867
12905
|
// src/components/CalendarTimeline/CalendarTimeline.tsx
|
|
12868
|
-
var
|
|
12906
|
+
var React40 = __toESM(require("react"), 1);
|
|
12869
12907
|
var import_lucide_react23 = require("lucide-react");
|
|
12870
12908
|
|
|
12871
12909
|
// src/components/CalendarTimeline/date.ts
|
|
@@ -13105,10 +13143,10 @@ function intervalPack(items) {
|
|
|
13105
13143
|
}
|
|
13106
13144
|
|
|
13107
13145
|
// src/components/CalendarTimeline/hooks.ts
|
|
13108
|
-
var
|
|
13146
|
+
var React35 = __toESM(require("react"), 1);
|
|
13109
13147
|
function useHorizontalScrollSync(args) {
|
|
13110
13148
|
const { bodyRef, headerRef, leftRef } = args;
|
|
13111
|
-
|
|
13149
|
+
React35.useEffect(() => {
|
|
13112
13150
|
const body = bodyRef.current;
|
|
13113
13151
|
const header = headerRef.current;
|
|
13114
13152
|
const left = leftRef?.current ?? null;
|
|
@@ -13166,9 +13204,9 @@ function lowerBound(arr, target) {
|
|
|
13166
13204
|
function useVirtualVariableRows(args) {
|
|
13167
13205
|
const { enabled, overscan, rowHeights, scrollRef } = args;
|
|
13168
13206
|
const itemCount = rowHeights.length;
|
|
13169
|
-
const [viewportHeight, setViewportHeight] =
|
|
13170
|
-
const [scrollTop, setScrollTop] =
|
|
13171
|
-
|
|
13207
|
+
const [viewportHeight, setViewportHeight] = React35.useState(0);
|
|
13208
|
+
const [scrollTop, setScrollTop] = React35.useState(0);
|
|
13209
|
+
React35.useEffect(() => {
|
|
13172
13210
|
if (!enabled) {
|
|
13173
13211
|
setViewportHeight(0);
|
|
13174
13212
|
return;
|
|
@@ -13181,7 +13219,7 @@ function useVirtualVariableRows(args) {
|
|
|
13181
13219
|
ro.observe(el);
|
|
13182
13220
|
return () => ro.disconnect();
|
|
13183
13221
|
}, [enabled, scrollRef]);
|
|
13184
|
-
|
|
13222
|
+
React35.useEffect(() => {
|
|
13185
13223
|
if (!enabled) {
|
|
13186
13224
|
setScrollTop(0);
|
|
13187
13225
|
return;
|
|
@@ -13206,7 +13244,7 @@ function useVirtualVariableRows(args) {
|
|
|
13206
13244
|
el.removeEventListener("scroll", onScroll);
|
|
13207
13245
|
};
|
|
13208
13246
|
}, [enabled, scrollRef]);
|
|
13209
|
-
const prefix =
|
|
13247
|
+
const prefix = React35.useMemo(() => {
|
|
13210
13248
|
const out = new Array(itemCount + 1);
|
|
13211
13249
|
out[0] = 0;
|
|
13212
13250
|
for (let i = 0; i < itemCount; i++) {
|
|
@@ -13214,7 +13252,7 @@ function useVirtualVariableRows(args) {
|
|
|
13214
13252
|
}
|
|
13215
13253
|
return out;
|
|
13216
13254
|
}, [itemCount, rowHeights]);
|
|
13217
|
-
return
|
|
13255
|
+
return React35.useMemo(() => {
|
|
13218
13256
|
if (!enabled) {
|
|
13219
13257
|
return { startIndex: 0, endIndex: itemCount, topSpacer: 0, bottomSpacer: 0, totalHeight: prefix[itemCount] ?? 0 };
|
|
13220
13258
|
}
|
|
@@ -13230,8 +13268,8 @@ function useVirtualVariableRows(args) {
|
|
|
13230
13268
|
}, [enabled, itemCount, overscan, prefix, scrollTop, viewportHeight]);
|
|
13231
13269
|
}
|
|
13232
13270
|
function useClientWidth(ref) {
|
|
13233
|
-
const [width, setWidth] =
|
|
13234
|
-
|
|
13271
|
+
const [width, setWidth] = React35.useState(0);
|
|
13272
|
+
React35.useEffect(() => {
|
|
13235
13273
|
const el = ref.current;
|
|
13236
13274
|
if (!el) return;
|
|
13237
13275
|
const update = () => setWidth(el.clientWidth);
|
|
@@ -13454,7 +13492,7 @@ function resourcesById(resources) {
|
|
|
13454
13492
|
}
|
|
13455
13493
|
|
|
13456
13494
|
// src/components/CalendarTimeline/CalendarTimelineHeader.tsx
|
|
13457
|
-
var
|
|
13495
|
+
var React36 = __toESM(require("react"), 1);
|
|
13458
13496
|
var import_lucide_react20 = require("lucide-react");
|
|
13459
13497
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
13460
13498
|
var VIEW_ICONS = {
|
|
@@ -13485,7 +13523,7 @@ function CalendarTimelineHeader(props) {
|
|
|
13485
13523
|
headerRef,
|
|
13486
13524
|
slotHeaderNodes
|
|
13487
13525
|
} = props;
|
|
13488
|
-
const resolvedAvailableViews =
|
|
13526
|
+
const resolvedAvailableViews = React36.useMemo(
|
|
13489
13527
|
() => availableViews?.length ? availableViews : ["month", "week", "day", "sprint"],
|
|
13490
13528
|
[availableViews]
|
|
13491
13529
|
);
|
|
@@ -13494,22 +13532,22 @@ function CalendarTimelineHeader(props) {
|
|
|
13494
13532
|
const gi18n = useGlobalI18n();
|
|
13495
13533
|
const dt = useSmartTranslations("DateTimePicker");
|
|
13496
13534
|
const locale = useSmartLocale();
|
|
13497
|
-
const [todayOpen, setTodayOpen] =
|
|
13498
|
-
const [tempDate, setTempDate] =
|
|
13499
|
-
const [calendarMonth, setCalendarMonth] =
|
|
13500
|
-
|
|
13535
|
+
const [todayOpen, setTodayOpen] = React36.useState(false);
|
|
13536
|
+
const [tempDate, setTempDate] = React36.useState(() => now);
|
|
13537
|
+
const [calendarMonth, setCalendarMonth] = React36.useState(() => now);
|
|
13538
|
+
React36.useEffect(() => {
|
|
13501
13539
|
if (!todayOpen) return;
|
|
13502
13540
|
setTempDate(now);
|
|
13503
13541
|
setCalendarMonth(now);
|
|
13504
13542
|
}, [now, todayOpen]);
|
|
13505
|
-
const monthLabel =
|
|
13543
|
+
const monthLabel = React36.useCallback(
|
|
13506
13544
|
(date) => date.toLocaleDateString(locale === "vi" ? "vi-VN" : "en-US", {
|
|
13507
13545
|
month: "long",
|
|
13508
13546
|
year: "numeric"
|
|
13509
13547
|
}),
|
|
13510
13548
|
[locale]
|
|
13511
13549
|
);
|
|
13512
|
-
const weekdays =
|
|
13550
|
+
const weekdays = React36.useMemo(() => {
|
|
13513
13551
|
switch (locale) {
|
|
13514
13552
|
case "vi":
|
|
13515
13553
|
return ["CN", "T2", "T3", "T4", "T5", "T6", "T7"];
|
|
@@ -13521,12 +13559,12 @@ function CalendarTimelineHeader(props) {
|
|
|
13521
13559
|
return ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
13522
13560
|
}
|
|
13523
13561
|
}, [locale]);
|
|
13524
|
-
const getTimeString =
|
|
13562
|
+
const getTimeString = React36.useCallback((date) => {
|
|
13525
13563
|
const h = date.getHours();
|
|
13526
13564
|
const m = date.getMinutes();
|
|
13527
13565
|
return `${h.toString().padStart(2, "0")}:${m.toString().padStart(2, "0")}`;
|
|
13528
13566
|
}, []);
|
|
13529
|
-
const handleDateSelect =
|
|
13567
|
+
const handleDateSelect = React36.useCallback((date) => {
|
|
13530
13568
|
if (!(date instanceof Date)) return;
|
|
13531
13569
|
setTempDate((prev) => {
|
|
13532
13570
|
const next = new Date(date);
|
|
@@ -13534,7 +13572,7 @@ function CalendarTimelineHeader(props) {
|
|
|
13534
13572
|
return next;
|
|
13535
13573
|
});
|
|
13536
13574
|
}, []);
|
|
13537
|
-
const handleTimeChange =
|
|
13575
|
+
const handleTimeChange = React36.useCallback((timeStr) => {
|
|
13538
13576
|
if (!timeStr) return;
|
|
13539
13577
|
const [hStr, mStr] = timeStr.split(":");
|
|
13540
13578
|
const h = parseInt(hStr, 10);
|
|
@@ -13546,7 +13584,7 @@ function CalendarTimelineHeader(props) {
|
|
|
13546
13584
|
return next;
|
|
13547
13585
|
});
|
|
13548
13586
|
}, []);
|
|
13549
|
-
const applyDateTime =
|
|
13587
|
+
const applyDateTime = React36.useCallback(() => {
|
|
13550
13588
|
onApplyDateTime(tempDate);
|
|
13551
13589
|
setTodayOpen(false);
|
|
13552
13590
|
}, [onApplyDateTime, tempDate]);
|
|
@@ -13810,9 +13848,9 @@ function ResourceRowCell(props) {
|
|
|
13810
13848
|
}
|
|
13811
13849
|
|
|
13812
13850
|
// src/components/CalendarTimeline/CalendarTimelineGridOverlay.tsx
|
|
13813
|
-
var
|
|
13851
|
+
var React37 = __toESM(require("react"), 1);
|
|
13814
13852
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
13815
|
-
var CalendarTimelineGridOverlay =
|
|
13853
|
+
var CalendarTimelineGridOverlay = React37.memo(function CalendarTimelineGridOverlay2(props) {
|
|
13816
13854
|
const {
|
|
13817
13855
|
gridWidth,
|
|
13818
13856
|
height,
|
|
@@ -13860,12 +13898,12 @@ var CalendarTimelineGridOverlay = React36.memo(function CalendarTimelineGridOver
|
|
|
13860
13898
|
});
|
|
13861
13899
|
|
|
13862
13900
|
// src/components/CalendarTimeline/CalendarTimelineSlotHeaderCell.tsx
|
|
13863
|
-
var
|
|
13901
|
+
var React38 = __toESM(require("react"), 1);
|
|
13864
13902
|
var import_lucide_react22 = require("lucide-react");
|
|
13865
13903
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
13866
|
-
var CalendarTimelineSlotHeaderCell =
|
|
13904
|
+
var CalendarTimelineSlotHeaderCell = React38.memo(function CalendarTimelineSlotHeaderCell2(props) {
|
|
13867
13905
|
const { width, activeView, isToday: isToday2, label, ariaLabel, borderClassName, dayHeaderMarks, idx, className } = props;
|
|
13868
|
-
const content =
|
|
13906
|
+
const content = React38.useMemo(() => {
|
|
13869
13907
|
if (activeView === "day" && dayHeaderMarks) {
|
|
13870
13908
|
if (dayHeaderMarks.showEllipsis[idx]) return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-xs text-muted-foreground/70 select-none", children: "\u2026" });
|
|
13871
13909
|
if (!dayHeaderMarks.showTime[idx]) return null;
|
|
@@ -13888,7 +13926,7 @@ var CalendarTimelineSlotHeaderCell = React37.memo(function CalendarTimelineSlotH
|
|
|
13888
13926
|
});
|
|
13889
13927
|
|
|
13890
13928
|
// src/components/CalendarTimeline/internal-hooks.ts
|
|
13891
|
-
var
|
|
13929
|
+
var React39 = __toESM(require("react"), 1);
|
|
13892
13930
|
function useTimelineSlots(args) {
|
|
13893
13931
|
const {
|
|
13894
13932
|
activeView,
|
|
@@ -13903,7 +13941,7 @@ function useTimelineSlots(args) {
|
|
|
13903
13941
|
formatters,
|
|
13904
13942
|
dueDateSprint
|
|
13905
13943
|
} = args;
|
|
13906
|
-
const { slots, range } =
|
|
13944
|
+
const { slots, range } = React39.useMemo(() => {
|
|
13907
13945
|
const { start, end, slotStarts: slotStarts2 } = computeSlotStarts({
|
|
13908
13946
|
view: activeView,
|
|
13909
13947
|
date: activeDate,
|
|
@@ -13958,18 +13996,18 @@ function useTimelineSlots(args) {
|
|
|
13958
13996
|
const match = matchSprintDef(s, idx);
|
|
13959
13997
|
if (match && sprintRangeText) {
|
|
13960
13998
|
const rangeText = sprintRangeText(match.startMs, match.endMs);
|
|
13961
|
-
return
|
|
13999
|
+
return React39.createElement(
|
|
13962
14000
|
"span",
|
|
13963
14001
|
{ className: "inline-flex flex-col items-center leading-tight" },
|
|
13964
|
-
|
|
13965
|
-
|
|
14002
|
+
React39.createElement("span", { className: "text-[11px] font-semibold text-foreground truncate max-w-32" }, match.title),
|
|
14003
|
+
React39.createElement("span", { className: "text-[10px] font-medium text-muted-foreground/70" }, rangeText)
|
|
13966
14004
|
);
|
|
13967
14005
|
}
|
|
13968
|
-
return
|
|
14006
|
+
return React39.createElement(
|
|
13969
14007
|
"span",
|
|
13970
14008
|
{ className: "inline-flex flex-col items-center leading-tight" },
|
|
13971
|
-
|
|
13972
|
-
|
|
14009
|
+
React39.createElement("span", { className: "text-[10px] font-medium uppercase tracking-wider text-muted-foreground/70" }, "S"),
|
|
14010
|
+
React39.createElement("span", { className: "text-sm font-semibold text-foreground" }, String(idx + 1).padStart(2, "0"))
|
|
13973
14011
|
);
|
|
13974
14012
|
})(),
|
|
13975
14013
|
isToday: (() => {
|
|
@@ -13997,9 +14035,9 @@ function useTimelineSlots(args) {
|
|
|
13997
14035
|
weekStartsOn,
|
|
13998
14036
|
workHours
|
|
13999
14037
|
]);
|
|
14000
|
-
const slotStarts =
|
|
14001
|
-
const todaySlotIdx =
|
|
14002
|
-
const weekendSlotIdxs =
|
|
14038
|
+
const slotStarts = React39.useMemo(() => slots.map((s) => s.start), [slots]);
|
|
14039
|
+
const todaySlotIdx = React39.useMemo(() => slots.findIndex((s) => s.isToday), [slots]);
|
|
14040
|
+
const weekendSlotIdxs = React39.useMemo(() => {
|
|
14003
14041
|
const out = [];
|
|
14004
14042
|
for (let i = 0; i < slots.length; i++) if (slots[i]?.isWeekend) out.push(i);
|
|
14005
14043
|
return out;
|
|
@@ -14008,16 +14046,16 @@ function useTimelineSlots(args) {
|
|
|
14008
14046
|
}
|
|
14009
14047
|
function useNormalizedEvents(args) {
|
|
14010
14048
|
const { events, range, activeView, resolvedTimeZone, resources } = args;
|
|
14011
|
-
const normalizedEvents =
|
|
14049
|
+
const normalizedEvents = React39.useMemo(() => {
|
|
14012
14050
|
return normalizeEvents({ events, range, view: activeView, timeZone: resolvedTimeZone });
|
|
14013
14051
|
}, [activeView, events, range, resolvedTimeZone]);
|
|
14014
|
-
const eventsByResource =
|
|
14015
|
-
const resourceById =
|
|
14052
|
+
const eventsByResource = React39.useMemo(() => eventsByResourceId(normalizedEvents), [normalizedEvents]);
|
|
14053
|
+
const resourceById = React39.useMemo(() => resourcesById(resources), [resources]);
|
|
14016
14054
|
return { normalizedEvents, eventsByResource, resourceById };
|
|
14017
14055
|
}
|
|
14018
14056
|
function useDayHeaderMarks(args) {
|
|
14019
14057
|
const { enabled, activeView, normalizedEvents, slotStarts, slotCount } = args;
|
|
14020
|
-
return
|
|
14058
|
+
return React39.useMemo(() => {
|
|
14021
14059
|
if (!enabled) return null;
|
|
14022
14060
|
if (activeView !== "day") return null;
|
|
14023
14061
|
const n = slotCount;
|
|
@@ -14052,14 +14090,14 @@ function useSlotMetrics(args) {
|
|
|
14052
14090
|
dayHeaderSmart,
|
|
14053
14091
|
daySlotCompression
|
|
14054
14092
|
} = args;
|
|
14055
|
-
const fixedSlotWidth =
|
|
14093
|
+
const fixedSlotWidth = React39.useMemo(() => {
|
|
14056
14094
|
const baseSlotWidth = activeView === "month" || activeView === "day" ? effectiveSlotMinWidth * 3 : effectiveSlotMinWidth;
|
|
14057
14095
|
if (activeView !== "week") return baseSlotWidth;
|
|
14058
14096
|
if (bodyClientWidth <= 0) return baseSlotWidth;
|
|
14059
14097
|
if (slotsLength <= 0) return baseSlotWidth;
|
|
14060
14098
|
return Math.max(baseSlotWidth, bodyClientWidth / slotsLength);
|
|
14061
14099
|
}, [activeView, bodyClientWidth, effectiveSlotMinWidth, slotsLength]);
|
|
14062
|
-
const slotMetrics =
|
|
14100
|
+
const slotMetrics = React39.useMemo(() => {
|
|
14063
14101
|
const n = slotsLength;
|
|
14064
14102
|
const widths = new Array(n).fill(fixedSlotWidth);
|
|
14065
14103
|
const isAdaptiveView = activeView === "month" || activeView === "day";
|
|
@@ -14190,7 +14228,7 @@ function useSlotMetrics(args) {
|
|
|
14190
14228
|
}
|
|
14191
14229
|
function useLayoutsByResource(args) {
|
|
14192
14230
|
const { eventsByResource, preview, slotStarts, slotsLength, slotLefts, getResourceRowHeight, laneGap, lanePaddingY, effectiveMaxLanesPerRow, eventHeight } = args;
|
|
14193
|
-
return
|
|
14231
|
+
return React39.useMemo(() => {
|
|
14194
14232
|
const map = /* @__PURE__ */ new Map();
|
|
14195
14233
|
for (const [resourceId, list] of eventsByResource.entries()) {
|
|
14196
14234
|
const mapped = list.map((ev) => {
|
|
@@ -14237,9 +14275,9 @@ function lowerBound2(arr, target) {
|
|
|
14237
14275
|
}
|
|
14238
14276
|
function useVisibleSlotRange(args) {
|
|
14239
14277
|
const { enabled, overscan, scrollRef, slotLefts, slotCount } = args;
|
|
14240
|
-
const [scrollLeft, setScrollLeft] =
|
|
14241
|
-
const [viewportWidth, setViewportWidth] =
|
|
14242
|
-
|
|
14278
|
+
const [scrollLeft, setScrollLeft] = React39.useState(0);
|
|
14279
|
+
const [viewportWidth, setViewportWidth] = React39.useState(0);
|
|
14280
|
+
React39.useEffect(() => {
|
|
14243
14281
|
if (!enabled) return;
|
|
14244
14282
|
const el = scrollRef.current;
|
|
14245
14283
|
if (!el) return;
|
|
@@ -14266,7 +14304,7 @@ function useVisibleSlotRange(args) {
|
|
|
14266
14304
|
el.removeEventListener("scroll", onScroll);
|
|
14267
14305
|
};
|
|
14268
14306
|
}, [enabled, scrollRef]);
|
|
14269
|
-
return
|
|
14307
|
+
return React39.useMemo(() => {
|
|
14270
14308
|
if (!enabled) return { startIdx: 0, endIdx: slotCount };
|
|
14271
14309
|
if (slotCount <= 0) return { startIdx: 0, endIdx: 0 };
|
|
14272
14310
|
if (viewportWidth <= 0) return { startIdx: 0, endIdx: slotCount };
|
|
@@ -14365,14 +14403,14 @@ function CalendarTimeline({
|
|
|
14365
14403
|
}) {
|
|
14366
14404
|
const t = useSmartTranslations("CalendarTimeline");
|
|
14367
14405
|
const detectedLocale = useSmartLocale();
|
|
14368
|
-
const resolvedLocale =
|
|
14369
|
-
const resolvedTimeZone =
|
|
14406
|
+
const resolvedLocale = React40.useMemo(() => localeToBCP47(locale ?? detectedLocale), [locale, detectedLocale]);
|
|
14407
|
+
const resolvedTimeZone = React40.useMemo(() => timeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone ?? "UTC", [timeZone]);
|
|
14370
14408
|
const effectiveEnableEventSheet = enableEventSheet ?? Boolean(renderEventSheet);
|
|
14371
14409
|
const isViewOnly = interactions?.mode === "view";
|
|
14372
14410
|
const isControlledSelectedEventId = selectedEventId !== void 0;
|
|
14373
|
-
const [internalSelectedEventId, setInternalSelectedEventId] =
|
|
14411
|
+
const [internalSelectedEventId, setInternalSelectedEventId] = React40.useState(defaultSelectedEventId ?? null);
|
|
14374
14412
|
const activeSelectedEventId = isControlledSelectedEventId ? selectedEventId : internalSelectedEventId;
|
|
14375
|
-
const setSelectedEventId =
|
|
14413
|
+
const setSelectedEventId = React40.useCallback(
|
|
14376
14414
|
(next) => {
|
|
14377
14415
|
if (!isControlledSelectedEventId) setInternalSelectedEventId(next);
|
|
14378
14416
|
onSelectedEventIdChange?.(next);
|
|
@@ -14380,9 +14418,9 @@ function CalendarTimeline({
|
|
|
14380
14418
|
[isControlledSelectedEventId, onSelectedEventIdChange]
|
|
14381
14419
|
);
|
|
14382
14420
|
const isControlledEventSheetOpen = eventSheetOpen !== void 0;
|
|
14383
|
-
const [internalEventSheetOpen, setInternalEventSheetOpen] =
|
|
14421
|
+
const [internalEventSheetOpen, setInternalEventSheetOpen] = React40.useState(defaultEventSheetOpen ?? false);
|
|
14384
14422
|
const activeEventSheetOpen = isControlledEventSheetOpen ? Boolean(eventSheetOpen) : internalEventSheetOpen;
|
|
14385
|
-
const setEventSheetOpen =
|
|
14423
|
+
const setEventSheetOpen = React40.useCallback(
|
|
14386
14424
|
(next) => {
|
|
14387
14425
|
if (!isControlledEventSheetOpen) setInternalEventSheetOpen(next);
|
|
14388
14426
|
onEventSheetOpenChange?.(next);
|
|
@@ -14391,12 +14429,12 @@ function CalendarTimeline({
|
|
|
14391
14429
|
[isControlledEventSheetOpen, onEventSheetOpenChange, setSelectedEventId]
|
|
14392
14430
|
);
|
|
14393
14431
|
const showResourceColumn = !hideResourceColumn;
|
|
14394
|
-
const sizeConfig =
|
|
14432
|
+
const sizeConfig = React40.useMemo(() => getSizeConfig(size), [size]);
|
|
14395
14433
|
const densityClass = sizeConfig.densityClass;
|
|
14396
14434
|
const eventHeight = sizeConfig.eventHeight;
|
|
14397
14435
|
const laneGap = sizeConfig.laneGap;
|
|
14398
14436
|
const lanePaddingY = sizeConfig.lanePaddingY;
|
|
14399
|
-
const canResizeColumn =
|
|
14437
|
+
const canResizeColumn = React40.useMemo(() => {
|
|
14400
14438
|
const cfg = enableLayoutResize;
|
|
14401
14439
|
if (!cfg) return false;
|
|
14402
14440
|
if (isViewOnly) return false;
|
|
@@ -14404,7 +14442,7 @@ function CalendarTimeline({
|
|
|
14404
14442
|
if (cfg === true) return true;
|
|
14405
14443
|
return cfg.column !== false;
|
|
14406
14444
|
}, [enableLayoutResize, isViewOnly, showResourceColumn]);
|
|
14407
|
-
const canResizeRow =
|
|
14445
|
+
const canResizeRow = React40.useMemo(() => {
|
|
14408
14446
|
const cfg = enableLayoutResize;
|
|
14409
14447
|
if (!cfg) return false;
|
|
14410
14448
|
if (isViewOnly) return false;
|
|
@@ -14413,19 +14451,19 @@ function CalendarTimeline({
|
|
|
14413
14451
|
return cfg.row !== false;
|
|
14414
14452
|
}, [enableLayoutResize, isViewOnly, showResourceColumn]);
|
|
14415
14453
|
const isControlledResourceColumnWidth = resourceColumnWidth !== void 0;
|
|
14416
|
-
const [internalResourceColumnWidth, setInternalResourceColumnWidth] =
|
|
14454
|
+
const [internalResourceColumnWidth, setInternalResourceColumnWidth] = React40.useState(() => {
|
|
14417
14455
|
const init = defaultResourceColumnWidth ?? sizeConfig.resourceColumnWidth;
|
|
14418
14456
|
return typeof init === "number" ? init : sizeConfig.resourceColumnWidth;
|
|
14419
14457
|
});
|
|
14420
|
-
|
|
14458
|
+
React40.useEffect(() => {
|
|
14421
14459
|
if (isControlledResourceColumnWidth) return;
|
|
14422
14460
|
if (defaultResourceColumnWidth == null) return;
|
|
14423
14461
|
setInternalResourceColumnWidth(defaultResourceColumnWidth);
|
|
14424
14462
|
}, [defaultResourceColumnWidth, isControlledResourceColumnWidth]);
|
|
14425
14463
|
const effectiveResourceColumnWidth = showResourceColumn ? isControlledResourceColumnWidth ? resourceColumnWidth : internalResourceColumnWidth : 0;
|
|
14426
14464
|
const isControlledRowHeight = rowHeight !== void 0;
|
|
14427
|
-
const [internalRowHeight, setInternalRowHeight] =
|
|
14428
|
-
|
|
14465
|
+
const [internalRowHeight, setInternalRowHeight] = React40.useState(() => defaultRowHeight ?? sizeConfig.rowHeight);
|
|
14466
|
+
React40.useEffect(() => {
|
|
14429
14467
|
if (isControlledRowHeight) return;
|
|
14430
14468
|
if (defaultRowHeight == null) return;
|
|
14431
14469
|
setInternalRowHeight(defaultRowHeight);
|
|
@@ -14436,14 +14474,14 @@ function CalendarTimeline({
|
|
|
14436
14474
|
const colMax = maxResourceColumnWidth ?? 520;
|
|
14437
14475
|
const rowMin = minRowHeight ?? 36;
|
|
14438
14476
|
const rowMax = maxRowHeight ?? 120;
|
|
14439
|
-
const viewList =
|
|
14440
|
-
const availableViews =
|
|
14477
|
+
const viewList = React40.useMemo(() => Array.isArray(view) ? view : void 0, [view]);
|
|
14478
|
+
const availableViews = React40.useMemo(() => {
|
|
14441
14479
|
if (onlyView) return [onlyView];
|
|
14442
14480
|
if (viewList?.length) return viewList;
|
|
14443
14481
|
return ["month", "week", "day", "sprint"];
|
|
14444
14482
|
}, [onlyView, viewList]);
|
|
14445
14483
|
const isControlledView = view !== void 0 && !Array.isArray(view);
|
|
14446
|
-
const [internalView, setInternalView] =
|
|
14484
|
+
const [internalView, setInternalView] = React40.useState(() => {
|
|
14447
14485
|
if (onlyView) return onlyView;
|
|
14448
14486
|
if (viewList?.length) {
|
|
14449
14487
|
if (defaultView && viewList.includes(defaultView)) return defaultView;
|
|
@@ -14452,13 +14490,13 @@ function CalendarTimeline({
|
|
|
14452
14490
|
return defaultView ?? "month";
|
|
14453
14491
|
});
|
|
14454
14492
|
const activeView = onlyView ? onlyView : isControlledView ? view : internalView;
|
|
14455
|
-
|
|
14493
|
+
React40.useEffect(() => {
|
|
14456
14494
|
if (onlyView || isControlledView) return;
|
|
14457
14495
|
if (!availableViews.includes(internalView)) {
|
|
14458
14496
|
setInternalView(availableViews[0] ?? "month");
|
|
14459
14497
|
}
|
|
14460
14498
|
}, [availableViews, internalView, isControlledView, onlyView]);
|
|
14461
|
-
const effectiveSlotMinWidth =
|
|
14499
|
+
const effectiveSlotMinWidth = React40.useMemo(() => {
|
|
14462
14500
|
if (slotMinWidth == null) {
|
|
14463
14501
|
if (activeView === "month" && monthEventStyle === "compact") {
|
|
14464
14502
|
return clamp5(Math.round(sizeConfig.slotMinWidth * 0.55), 32, sizeConfig.slotMinWidth);
|
|
@@ -14470,17 +14508,17 @@ function CalendarTimeline({
|
|
|
14470
14508
|
return baseSlotMinWidth;
|
|
14471
14509
|
}, [activeView, baseSlotMinWidth, monthEventStyle, sizeConfig.slotMinWidth, slotMinWidth]);
|
|
14472
14510
|
const isControlledDate = date !== void 0;
|
|
14473
|
-
const [internalDate, setInternalDate] =
|
|
14511
|
+
const [internalDate, setInternalDate] = React40.useState(() => defaultDate ?? /* @__PURE__ */ new Date());
|
|
14474
14512
|
const activeDate = isControlledDate ? date : internalDate;
|
|
14475
|
-
const resolvedNow =
|
|
14476
|
-
const formatToken =
|
|
14513
|
+
const resolvedNow = React40.useMemo(() => now ?? /* @__PURE__ */ new Date(), [now]);
|
|
14514
|
+
const formatToken = React40.useCallback((key, params) => {
|
|
14477
14515
|
let message = t(key);
|
|
14478
14516
|
for (const [name, value] of Object.entries(params)) {
|
|
14479
14517
|
message = message.replaceAll(`{${name}}`, String(value));
|
|
14480
14518
|
}
|
|
14481
14519
|
return message;
|
|
14482
14520
|
}, [t]);
|
|
14483
|
-
const l =
|
|
14521
|
+
const l = React40.useMemo(
|
|
14484
14522
|
() => ({
|
|
14485
14523
|
today: labels?.today ?? t("today"),
|
|
14486
14524
|
prev: labels?.prev ?? t("prev"),
|
|
@@ -14503,7 +14541,7 @@ function CalendarTimeline({
|
|
|
14503
14541
|
}),
|
|
14504
14542
|
[formatToken, labels, t]
|
|
14505
14543
|
);
|
|
14506
|
-
const setView =
|
|
14544
|
+
const setView = React40.useCallback(
|
|
14507
14545
|
(next) => {
|
|
14508
14546
|
if (onlyView) return;
|
|
14509
14547
|
if (!availableViews.includes(next)) return;
|
|
@@ -14512,14 +14550,14 @@ function CalendarTimeline({
|
|
|
14512
14550
|
},
|
|
14513
14551
|
[availableViews, isControlledView, onViewChange, onlyView]
|
|
14514
14552
|
);
|
|
14515
|
-
const setDate =
|
|
14553
|
+
const setDate = React40.useCallback(
|
|
14516
14554
|
(next) => {
|
|
14517
14555
|
if (!isControlledDate) setInternalDate(next);
|
|
14518
14556
|
onDateChange?.(next);
|
|
14519
14557
|
},
|
|
14520
14558
|
[isControlledDate, onDateChange]
|
|
14521
14559
|
);
|
|
14522
|
-
const navigate =
|
|
14560
|
+
const navigate = React40.useCallback(
|
|
14523
14561
|
(dir) => {
|
|
14524
14562
|
const base2 = activeDate;
|
|
14525
14563
|
if (activeView === "month") {
|
|
@@ -14538,17 +14576,17 @@ function CalendarTimeline({
|
|
|
14538
14576
|
},
|
|
14539
14577
|
[activeDate, activeView, resolvedTimeZone, setDate]
|
|
14540
14578
|
);
|
|
14541
|
-
const [internalCollapsed, setInternalCollapsed] =
|
|
14579
|
+
const [internalCollapsed, setInternalCollapsed] = React40.useState(() => defaultGroupCollapsed ?? {});
|
|
14542
14580
|
const collapsed = groupCollapsed ?? internalCollapsed;
|
|
14543
|
-
const setCollapsed =
|
|
14581
|
+
const setCollapsed = React40.useCallback(
|
|
14544
14582
|
(next) => {
|
|
14545
14583
|
if (!groupCollapsed) setInternalCollapsed(next);
|
|
14546
14584
|
onGroupCollapsedChange?.(next);
|
|
14547
14585
|
},
|
|
14548
14586
|
[groupCollapsed, onGroupCollapsedChange]
|
|
14549
14587
|
);
|
|
14550
|
-
const rows =
|
|
14551
|
-
const groupResourceCounts =
|
|
14588
|
+
const rows = React40.useMemo(() => buildRows({ resources, groups, collapsed }), [resources, groups, collapsed]);
|
|
14589
|
+
const groupResourceCounts = React40.useMemo(() => getGroupResourceCounts(resources), [resources]);
|
|
14552
14590
|
const { slots, range, slotStarts, todaySlotIdx, weekendSlotIdxs } = useTimelineSlots({
|
|
14553
14591
|
activeView,
|
|
14554
14592
|
activeDate,
|
|
@@ -14562,12 +14600,12 @@ function CalendarTimeline({
|
|
|
14562
14600
|
formatters,
|
|
14563
14601
|
dueDateSprint
|
|
14564
14602
|
});
|
|
14565
|
-
|
|
14603
|
+
React40.useEffect(() => {
|
|
14566
14604
|
onRangeChange?.(range);
|
|
14567
14605
|
}, [range, onRangeChange]);
|
|
14568
|
-
const leftRef =
|
|
14569
|
-
const bodyRef =
|
|
14570
|
-
const headerRef =
|
|
14606
|
+
const leftRef = React40.useRef(null);
|
|
14607
|
+
const bodyRef = React40.useRef(null);
|
|
14608
|
+
const headerRef = React40.useRef(null);
|
|
14571
14609
|
const bodyClientWidth = useClientWidth(bodyRef);
|
|
14572
14610
|
const { normalizedEvents, eventsByResource, resourceById } = useNormalizedEvents({
|
|
14573
14611
|
events,
|
|
@@ -14599,16 +14637,16 @@ function CalendarTimeline({
|
|
|
14599
14637
|
slotLefts,
|
|
14600
14638
|
slotCount: slots.length
|
|
14601
14639
|
});
|
|
14602
|
-
const selectedEvent =
|
|
14640
|
+
const selectedEvent = React40.useMemo(() => {
|
|
14603
14641
|
if (!activeSelectedEventId) return null;
|
|
14604
14642
|
const found2 = normalizedEvents.find((e) => e.id === activeSelectedEventId);
|
|
14605
14643
|
return found2 ?? null;
|
|
14606
14644
|
}, [activeSelectedEventId, normalizedEvents]);
|
|
14607
|
-
const selectedResource =
|
|
14645
|
+
const selectedResource = React40.useMemo(() => {
|
|
14608
14646
|
if (!selectedEvent) return void 0;
|
|
14609
14647
|
return resourceById.get(selectedEvent.resourceId);
|
|
14610
14648
|
}, [resourceById, selectedEvent]);
|
|
14611
|
-
const selectedTimeText =
|
|
14649
|
+
const selectedTimeText = React40.useMemo(() => {
|
|
14612
14650
|
if (!selectedEvent) return "";
|
|
14613
14651
|
return formatters?.eventTime?.({
|
|
14614
14652
|
start: selectedEvent._start,
|
|
@@ -14618,7 +14656,7 @@ function CalendarTimeline({
|
|
|
14618
14656
|
view: activeView
|
|
14619
14657
|
}) ?? defaultEventTime({ start: selectedEvent._start, end: selectedEvent._end, locale: resolvedLocale, timeZone: resolvedTimeZone, view: activeView });
|
|
14620
14658
|
}, [activeView, formatters, resolvedLocale, resolvedTimeZone, selectedEvent]);
|
|
14621
|
-
|
|
14659
|
+
React40.useEffect(() => {
|
|
14622
14660
|
if (!effectiveEnableEventSheet) return;
|
|
14623
14661
|
if (activeEventSheetOpen && activeSelectedEventId && !selectedEvent) {
|
|
14624
14662
|
setEventSheetOpen(false);
|
|
@@ -14628,24 +14666,24 @@ function CalendarTimeline({
|
|
|
14628
14666
|
const virt = virtualization == null ? rows.length > 60 : Boolean(virtualization.enabled);
|
|
14629
14667
|
const overscan = virtualization?.overscan ?? 8;
|
|
14630
14668
|
const isControlledRowHeights = rowHeights !== void 0;
|
|
14631
|
-
const [internalRowHeights, setInternalRowHeights] =
|
|
14632
|
-
|
|
14669
|
+
const [internalRowHeights, setInternalRowHeights] = React40.useState(() => defaultRowHeights ?? {});
|
|
14670
|
+
React40.useEffect(() => {
|
|
14633
14671
|
if (isControlledRowHeights) return;
|
|
14634
14672
|
if (!defaultRowHeights) return;
|
|
14635
14673
|
setInternalRowHeights(defaultRowHeights);
|
|
14636
14674
|
}, [defaultRowHeights, isControlledRowHeights]);
|
|
14637
14675
|
const activeRowHeights = isControlledRowHeights ? rowHeights : internalRowHeights;
|
|
14638
|
-
const autoRowHeightCfg =
|
|
14676
|
+
const autoRowHeightCfg = React40.useMemo(() => {
|
|
14639
14677
|
if (!autoRowHeight) return null;
|
|
14640
14678
|
return autoRowHeight === true ? {} : autoRowHeight;
|
|
14641
14679
|
}, [autoRowHeight]);
|
|
14642
|
-
const effectiveMaxLanesPerRow =
|
|
14680
|
+
const effectiveMaxLanesPerRow = React40.useMemo(() => {
|
|
14643
14681
|
if (!autoRowHeightCfg) return maxLanesPerRow;
|
|
14644
14682
|
const maxLanes = autoRowHeightCfg.maxLanesPerRow;
|
|
14645
14683
|
if (typeof maxLanes === "number" && Number.isFinite(maxLanes) && maxLanes > 0) return Math.floor(maxLanes);
|
|
14646
14684
|
return Number.POSITIVE_INFINITY;
|
|
14647
14685
|
}, [autoRowHeightCfg, maxLanesPerRow]);
|
|
14648
|
-
const autoRowHeightsByResource =
|
|
14686
|
+
const autoRowHeightsByResource = React40.useMemo(() => {
|
|
14649
14687
|
if (!autoRowHeightCfg) return null;
|
|
14650
14688
|
const maxRowHeight2 = autoRowHeightCfg.maxRowHeight;
|
|
14651
14689
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -14663,7 +14701,7 @@ function CalendarTimeline({
|
|
|
14663
14701
|
}
|
|
14664
14702
|
return out;
|
|
14665
14703
|
}, [autoRowHeightCfg, eventHeight, eventsByResource, laneGap, lanePaddingY, slotStarts, slots.length, effectiveMaxLanesPerRow]);
|
|
14666
|
-
const getResourceRowHeight =
|
|
14704
|
+
const getResourceRowHeight = React40.useCallback(
|
|
14667
14705
|
(resourceId) => {
|
|
14668
14706
|
const h = activeRowHeights[resourceId];
|
|
14669
14707
|
const base2 = typeof h === "number" && Number.isFinite(h) && h > 0 ? h : effectiveRowHeight;
|
|
@@ -14673,7 +14711,7 @@ function CalendarTimeline({
|
|
|
14673
14711
|
},
|
|
14674
14712
|
[activeRowHeights, autoRowHeightsByResource, effectiveRowHeight]
|
|
14675
14713
|
);
|
|
14676
|
-
const setRowHeightForResource =
|
|
14714
|
+
const setRowHeightForResource = React40.useCallback(
|
|
14677
14715
|
(resourceId, height) => {
|
|
14678
14716
|
const clamped = clamp5(Math.round(height), rowMin, rowMax);
|
|
14679
14717
|
onRowHeightChange?.(clamped);
|
|
@@ -14690,7 +14728,7 @@ function CalendarTimeline({
|
|
|
14690
14728
|
},
|
|
14691
14729
|
[activeRowHeights, isControlledRowHeights, onRowHeightChange, onRowHeightsChange, rowMax, rowMin]
|
|
14692
14730
|
);
|
|
14693
|
-
const rowHeightsArray =
|
|
14731
|
+
const rowHeightsArray = React40.useMemo(() => {
|
|
14694
14732
|
return rows.map((r) => {
|
|
14695
14733
|
if (r.kind === "resource") return getResourceRowHeight(r.resource.id);
|
|
14696
14734
|
return sizeConfig.groupRowHeight;
|
|
@@ -14706,13 +14744,13 @@ function CalendarTimeline({
|
|
|
14706
14744
|
const endRow = virt ? virtualResult.endIndex : rows.length;
|
|
14707
14745
|
const topSpacer = virt ? virtualResult.topSpacer : 0;
|
|
14708
14746
|
const bottomSpacer = virt ? virtualResult.bottomSpacer : 0;
|
|
14709
|
-
const renderedRowsHeight =
|
|
14747
|
+
const renderedRowsHeight = React40.useMemo(() => {
|
|
14710
14748
|
let h = 0;
|
|
14711
14749
|
for (let i = startRow; i < endRow; i++) h += rowHeightsArray[i] ?? effectiveRowHeight;
|
|
14712
14750
|
return h;
|
|
14713
14751
|
}, [effectiveRowHeight, endRow, rowHeightsArray, startRow]);
|
|
14714
|
-
const resizeRef =
|
|
14715
|
-
const setResourceColumnWidth =
|
|
14752
|
+
const resizeRef = React40.useRef(null);
|
|
14753
|
+
const setResourceColumnWidth = React40.useCallback(
|
|
14716
14754
|
(next) => {
|
|
14717
14755
|
const clamped = clamp5(Math.round(next), colMin, colMax);
|
|
14718
14756
|
if (!isControlledResourceColumnWidth) setInternalResourceColumnWidth(clamped);
|
|
@@ -14720,7 +14758,7 @@ function CalendarTimeline({
|
|
|
14720
14758
|
},
|
|
14721
14759
|
[colMax, colMin, isControlledResourceColumnWidth, onResourceColumnWidthChange]
|
|
14722
14760
|
);
|
|
14723
|
-
const startResize =
|
|
14761
|
+
const startResize = React40.useCallback(
|
|
14724
14762
|
(mode, e, args) => {
|
|
14725
14763
|
if (e.button !== 0 || e.ctrlKey) return;
|
|
14726
14764
|
resizeRef.current = {
|
|
@@ -14763,7 +14801,7 @@ function CalendarTimeline({
|
|
|
14763
14801
|
},
|
|
14764
14802
|
[setResourceColumnWidth, setRowHeightForResource]
|
|
14765
14803
|
);
|
|
14766
|
-
|
|
14804
|
+
React40.useEffect(() => {
|
|
14767
14805
|
return () => {
|
|
14768
14806
|
if (!resizeRef.current) return;
|
|
14769
14807
|
resizeRef.current = null;
|
|
@@ -14771,7 +14809,7 @@ function CalendarTimeline({
|
|
|
14771
14809
|
document.body.style.userSelect = "";
|
|
14772
14810
|
};
|
|
14773
14811
|
}, []);
|
|
14774
|
-
const beginResizeColumn =
|
|
14812
|
+
const beginResizeColumn = React40.useCallback(
|
|
14775
14813
|
(e) => {
|
|
14776
14814
|
if (!canResizeColumn) return;
|
|
14777
14815
|
if (typeof effectiveResourceColumnWidth !== "number") return;
|
|
@@ -14779,7 +14817,7 @@ function CalendarTimeline({
|
|
|
14779
14817
|
},
|
|
14780
14818
|
[canResizeColumn, effectiveResourceColumnWidth, effectiveRowHeight, startResize]
|
|
14781
14819
|
);
|
|
14782
|
-
const beginResizeResourceRow =
|
|
14820
|
+
const beginResizeResourceRow = React40.useCallback(
|
|
14783
14821
|
(resourceId) => (e) => {
|
|
14784
14822
|
if (!canResizeRow) return;
|
|
14785
14823
|
startResize("row", e, {
|
|
@@ -14790,7 +14828,7 @@ function CalendarTimeline({
|
|
|
14790
14828
|
},
|
|
14791
14829
|
[canResizeRow, effectiveResourceColumnWidth, getResourceRowHeight, startResize]
|
|
14792
14830
|
);
|
|
14793
|
-
const title =
|
|
14831
|
+
const title = React40.useMemo(() => {
|
|
14794
14832
|
if (activeView === "month") {
|
|
14795
14833
|
return formatters?.monthTitle?.(activeDate, { locale: resolvedLocale, timeZone: resolvedTimeZone }) ?? defaultMonthTitle(activeDate, resolvedLocale, resolvedTimeZone);
|
|
14796
14834
|
}
|
|
@@ -14817,11 +14855,11 @@ function CalendarTimeline({
|
|
|
14817
14855
|
}, [activeDate, activeView, formatToken, formatters, l.sprint, l.week, range.end, range.start, resolvedLocale, resolvedTimeZone, slots.length]);
|
|
14818
14856
|
const createMode = interactions?.createMode ?? "drag";
|
|
14819
14857
|
const canCreate = !isViewOnly && (interactions?.creatable ?? false) && !!onCreateEvent;
|
|
14820
|
-
const [createOpen, setCreateOpen] =
|
|
14821
|
-
const [createResourceId, setCreateResourceId] =
|
|
14822
|
-
const [createStartIdx, setCreateStartIdx] =
|
|
14823
|
-
const [createEndIdx, setCreateEndIdx] =
|
|
14824
|
-
const resourceOptions =
|
|
14858
|
+
const [createOpen, setCreateOpen] = React40.useState(false);
|
|
14859
|
+
const [createResourceId, setCreateResourceId] = React40.useState(null);
|
|
14860
|
+
const [createStartIdx, setCreateStartIdx] = React40.useState(0);
|
|
14861
|
+
const [createEndIdx, setCreateEndIdx] = React40.useState(1);
|
|
14862
|
+
const resourceOptions = React40.useMemo(() => {
|
|
14825
14863
|
return resources.map((r) => ({
|
|
14826
14864
|
label: typeof r.label === "string" ? r.label : r.id,
|
|
14827
14865
|
value: r.id,
|
|
@@ -14829,7 +14867,7 @@ function CalendarTimeline({
|
|
|
14829
14867
|
disabled: r.disabled ?? false
|
|
14830
14868
|
}));
|
|
14831
14869
|
}, [resources]);
|
|
14832
|
-
const formatCreateBoundaryLabel =
|
|
14870
|
+
const formatCreateBoundaryLabel = React40.useMemo(() => {
|
|
14833
14871
|
const timeFmt = getDtf(resolvedLocale, resolvedTimeZone, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" });
|
|
14834
14872
|
const dayFmt = getDtf(resolvedLocale, resolvedTimeZone, { weekday: "short", month: "short", day: "numeric" });
|
|
14835
14873
|
const yearFmt = getDtf(resolvedLocale, resolvedTimeZone, { year: "numeric" });
|
|
@@ -14877,7 +14915,7 @@ function CalendarTimeline({
|
|
|
14877
14915
|
return dayFmt.format(d);
|
|
14878
14916
|
};
|
|
14879
14917
|
}, [activeView, dueDateSprint, l.sprint, resolvedLocale, resolvedTimeZone, slotStarts]);
|
|
14880
|
-
const openCreate =
|
|
14918
|
+
const openCreate = React40.useCallback(() => {
|
|
14881
14919
|
if (!canCreate) return;
|
|
14882
14920
|
if (activeEventSheetOpen) setEventSheetOpen(false);
|
|
14883
14921
|
const firstResource = resources.find((r) => !r.disabled)?.id ?? resources[0]?.id ?? null;
|
|
@@ -14909,13 +14947,13 @@ function CalendarTimeline({
|
|
|
14909
14947
|
slotStarts,
|
|
14910
14948
|
slots.length
|
|
14911
14949
|
]);
|
|
14912
|
-
|
|
14950
|
+
React40.useEffect(() => {
|
|
14913
14951
|
setCreateEndIdx((prev) => Math.min(slots.length, Math.max(prev, createStartIdx + 1)));
|
|
14914
14952
|
}, [createStartIdx, slots.length]);
|
|
14915
|
-
const createStartOptions =
|
|
14953
|
+
const createStartOptions = React40.useMemo(() => {
|
|
14916
14954
|
return slotStarts.map((d, idx) => ({ label: formatCreateBoundaryLabel(d, { kind: "start", boundaryIdx: idx }), value: idx }));
|
|
14917
14955
|
}, [formatCreateBoundaryLabel, slotStarts]);
|
|
14918
|
-
const createEndOptions =
|
|
14956
|
+
const createEndOptions = React40.useMemo(() => {
|
|
14919
14957
|
const out = [];
|
|
14920
14958
|
for (let idx = createStartIdx + 1; idx <= slotStarts.length; idx++) {
|
|
14921
14959
|
const boundary = idx >= slotStarts.length ? range.end : slotStarts[idx];
|
|
@@ -14923,7 +14961,7 @@ function CalendarTimeline({
|
|
|
14923
14961
|
}
|
|
14924
14962
|
return out;
|
|
14925
14963
|
}, [createStartIdx, formatCreateBoundaryLabel, range.end, slotStarts]);
|
|
14926
|
-
const commitCreate =
|
|
14964
|
+
const commitCreate = React40.useCallback(() => {
|
|
14927
14965
|
if (!onCreateEvent) return;
|
|
14928
14966
|
if (!createResourceId) return;
|
|
14929
14967
|
const start = slotStarts[clamp5(createStartIdx, 0, Math.max(0, slotStarts.length - 1))];
|
|
@@ -14934,38 +14972,38 @@ function CalendarTimeline({
|
|
|
14934
14972
|
onCreateEvent({ resourceId: createResourceId, start, end: endBoundary });
|
|
14935
14973
|
setCreateOpen(false);
|
|
14936
14974
|
}, [createEndIdx, createResourceId, createStartIdx, onCreateEvent, range.end, slotStarts]);
|
|
14937
|
-
const dragRef =
|
|
14938
|
-
const [preview, setPreviewState] =
|
|
14939
|
-
const previewRef =
|
|
14940
|
-
const setPreview =
|
|
14975
|
+
const dragRef = React40.useRef(null);
|
|
14976
|
+
const [preview, setPreviewState] = React40.useState(null);
|
|
14977
|
+
const previewRef = React40.useRef(null);
|
|
14978
|
+
const setPreview = React40.useCallback((next) => {
|
|
14941
14979
|
previewRef.current = next;
|
|
14942
14980
|
setPreviewState(next);
|
|
14943
14981
|
}, []);
|
|
14944
|
-
const suppressNextEventClickRef =
|
|
14945
|
-
const [hoverCell, setHoverCellState] =
|
|
14946
|
-
const hoverCellRef =
|
|
14947
|
-
const setHoverCell =
|
|
14982
|
+
const suppressNextEventClickRef = React40.useRef(false);
|
|
14983
|
+
const [hoverCell, setHoverCellState] = React40.useState(null);
|
|
14984
|
+
const hoverCellRef = React40.useRef(null);
|
|
14985
|
+
const setHoverCell = React40.useCallback((next) => {
|
|
14948
14986
|
hoverCellRef.current = next;
|
|
14949
14987
|
setHoverCellState(next);
|
|
14950
14988
|
}, []);
|
|
14951
|
-
const autoScrollStateRef =
|
|
14989
|
+
const autoScrollStateRef = React40.useRef({
|
|
14952
14990
|
dir: 0,
|
|
14953
14991
|
speed: 0,
|
|
14954
14992
|
lastClientX: 0,
|
|
14955
14993
|
lastClientY: 0
|
|
14956
14994
|
});
|
|
14957
|
-
const autoScrollRafRef =
|
|
14958
|
-
const dragPreviewRafRef =
|
|
14959
|
-
const dragPreviewPointRef =
|
|
14960
|
-
const hoverCellRafRef =
|
|
14961
|
-
const hoverCellPendingRef =
|
|
14962
|
-
const stopAutoScroll =
|
|
14995
|
+
const autoScrollRafRef = React40.useRef(null);
|
|
14996
|
+
const dragPreviewRafRef = React40.useRef(null);
|
|
14997
|
+
const dragPreviewPointRef = React40.useRef(null);
|
|
14998
|
+
const hoverCellRafRef = React40.useRef(null);
|
|
14999
|
+
const hoverCellPendingRef = React40.useRef(null);
|
|
15000
|
+
const stopAutoScroll = React40.useCallback(() => {
|
|
14963
15001
|
if (autoScrollRafRef.current != null) cancelAnimationFrame(autoScrollRafRef.current);
|
|
14964
15002
|
autoScrollRafRef.current = null;
|
|
14965
15003
|
autoScrollStateRef.current.dir = 0;
|
|
14966
15004
|
autoScrollStateRef.current.speed = 0;
|
|
14967
15005
|
}, []);
|
|
14968
|
-
const getPointerContext =
|
|
15006
|
+
const getPointerContext = React40.useCallback(
|
|
14969
15007
|
(clientX, clientY, opts) => {
|
|
14970
15008
|
const body = bodyRef.current;
|
|
14971
15009
|
if (!body) return null;
|
|
@@ -14983,7 +15021,7 @@ function CalendarTimeline({
|
|
|
14983
15021
|
},
|
|
14984
15022
|
[xToSlotIdx]
|
|
14985
15023
|
);
|
|
14986
|
-
const slotToDate =
|
|
15024
|
+
const slotToDate = React40.useCallback(
|
|
14987
15025
|
(slotIdx) => {
|
|
14988
15026
|
const start = slotStarts[clamp5(slotIdx, 0, slotStarts.length - 1)];
|
|
14989
15027
|
if (activeView === "day") {
|
|
@@ -14997,7 +15035,7 @@ function CalendarTimeline({
|
|
|
14997
15035
|
},
|
|
14998
15036
|
[activeView, dayTimeStepMinutes, resolvedTimeZone, slotStarts]
|
|
14999
15037
|
);
|
|
15000
|
-
const updateDragPreview =
|
|
15038
|
+
const updateDragPreview = React40.useCallback(
|
|
15001
15039
|
(clientX, clientY) => {
|
|
15002
15040
|
const drag = dragRef.current;
|
|
15003
15041
|
if (!drag) return;
|
|
@@ -15041,13 +15079,13 @@ function CalendarTimeline({
|
|
|
15041
15079
|
},
|
|
15042
15080
|
[getPointerContext, range.end, range.start, setPreview, slotToDate, slots.length]
|
|
15043
15081
|
);
|
|
15044
|
-
const flushDragPreview =
|
|
15082
|
+
const flushDragPreview = React40.useCallback(() => {
|
|
15045
15083
|
dragPreviewRafRef.current = null;
|
|
15046
15084
|
const point = dragPreviewPointRef.current;
|
|
15047
15085
|
if (!point) return;
|
|
15048
15086
|
updateDragPreview(point.x, point.y);
|
|
15049
15087
|
}, [updateDragPreview]);
|
|
15050
|
-
const scheduleDragPreview =
|
|
15088
|
+
const scheduleDragPreview = React40.useCallback(
|
|
15051
15089
|
(clientX, clientY) => {
|
|
15052
15090
|
dragPreviewPointRef.current = { x: clientX, y: clientY };
|
|
15053
15091
|
if (dragPreviewRafRef.current != null) return;
|
|
@@ -15055,7 +15093,7 @@ function CalendarTimeline({
|
|
|
15055
15093
|
},
|
|
15056
15094
|
[flushDragPreview]
|
|
15057
15095
|
);
|
|
15058
|
-
const applyHoverCell =
|
|
15096
|
+
const applyHoverCell = React40.useCallback(
|
|
15059
15097
|
(next) => {
|
|
15060
15098
|
const prev = hoverCellRef.current;
|
|
15061
15099
|
const same = prev == null && next == null || prev != null && next != null && prev.resourceId === next.resourceId && prev.slotIdx === next.slotIdx && Math.abs(prev.y - next.y) <= 0.5;
|
|
@@ -15064,11 +15102,11 @@ function CalendarTimeline({
|
|
|
15064
15102
|
},
|
|
15065
15103
|
[setHoverCell]
|
|
15066
15104
|
);
|
|
15067
|
-
const flushHoverCell =
|
|
15105
|
+
const flushHoverCell = React40.useCallback(() => {
|
|
15068
15106
|
hoverCellRafRef.current = null;
|
|
15069
15107
|
applyHoverCell(hoverCellPendingRef.current);
|
|
15070
15108
|
}, [applyHoverCell]);
|
|
15071
|
-
const scheduleHoverCell =
|
|
15109
|
+
const scheduleHoverCell = React40.useCallback(
|
|
15072
15110
|
(next) => {
|
|
15073
15111
|
hoverCellPendingRef.current = next;
|
|
15074
15112
|
if (hoverCellRafRef.current != null) return;
|
|
@@ -15076,7 +15114,7 @@ function CalendarTimeline({
|
|
|
15076
15114
|
},
|
|
15077
15115
|
[flushHoverCell]
|
|
15078
15116
|
);
|
|
15079
|
-
const autoScrollTick =
|
|
15117
|
+
const autoScrollTick = React40.useCallback(() => {
|
|
15080
15118
|
const drag = dragRef.current;
|
|
15081
15119
|
const body = bodyRef.current;
|
|
15082
15120
|
const st = autoScrollStateRef.current;
|
|
@@ -15095,7 +15133,7 @@ function CalendarTimeline({
|
|
|
15095
15133
|
updateDragPreview(st.lastClientX, st.lastClientY);
|
|
15096
15134
|
autoScrollRafRef.current = requestAnimationFrame(autoScrollTick);
|
|
15097
15135
|
}, [stopAutoScroll, updateDragPreview]);
|
|
15098
|
-
const updateAutoScrollFromPointer =
|
|
15136
|
+
const updateAutoScrollFromPointer = React40.useCallback(
|
|
15099
15137
|
(clientX, clientY) => {
|
|
15100
15138
|
const body = bodyRef.current;
|
|
15101
15139
|
if (!body) return;
|
|
@@ -15126,8 +15164,8 @@ function CalendarTimeline({
|
|
|
15126
15164
|
},
|
|
15127
15165
|
[autoScrollTick, stopAutoScroll]
|
|
15128
15166
|
);
|
|
15129
|
-
|
|
15130
|
-
|
|
15167
|
+
React40.useEffect(() => stopAutoScroll, [stopAutoScroll]);
|
|
15168
|
+
React40.useEffect(() => {
|
|
15131
15169
|
return () => {
|
|
15132
15170
|
if (dragPreviewRafRef.current != null) cancelAnimationFrame(dragPreviewRafRef.current);
|
|
15133
15171
|
if (hoverCellRafRef.current != null) cancelAnimationFrame(hoverCellRafRef.current);
|
|
@@ -15274,7 +15312,7 @@ function CalendarTimeline({
|
|
|
15274
15312
|
}
|
|
15275
15313
|
setPreview(null);
|
|
15276
15314
|
};
|
|
15277
|
-
const onBodyPointerLeave =
|
|
15315
|
+
const onBodyPointerLeave = React40.useCallback(() => {
|
|
15278
15316
|
hoverCellPendingRef.current = null;
|
|
15279
15317
|
if (hoverCellRafRef.current != null) {
|
|
15280
15318
|
cancelAnimationFrame(hoverCellRafRef.current);
|
|
@@ -15301,7 +15339,7 @@ function CalendarTimeline({
|
|
|
15301
15339
|
}
|
|
15302
15340
|
);
|
|
15303
15341
|
};
|
|
15304
|
-
const slotHeaderNodes =
|
|
15342
|
+
const slotHeaderNodes = React40.useMemo(() => {
|
|
15305
15343
|
const startIdx = colVirtEnabled ? visibleSlots.startIdx : 0;
|
|
15306
15344
|
const endIdx = colVirtEnabled ? visibleSlots.endIdx : slots.length;
|
|
15307
15345
|
const leftSpacer = startIdx > 0 ? slotLefts[startIdx] ?? 0 : 0;
|
|
@@ -15627,7 +15665,7 @@ function CalendarTimeline({
|
|
|
15627
15665
|
]
|
|
15628
15666
|
}
|
|
15629
15667
|
);
|
|
15630
|
-
if (!enableEventTooltips) return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
15668
|
+
if (!enableEventTooltips) return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(React40.Fragment, { children: block }, ev.id);
|
|
15631
15669
|
const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-col gap-0.5", children: [
|
|
15632
15670
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "font-semibold", children: tooltipTitle }),
|
|
15633
15671
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "text-xs opacity-80", children: timeText }),
|
|
@@ -15784,7 +15822,7 @@ function CalendarTimeline({
|
|
|
15784
15822
|
}
|
|
15785
15823
|
|
|
15786
15824
|
// src/components/MultiCombobox.tsx
|
|
15787
|
-
var
|
|
15825
|
+
var React41 = __toESM(require("react"), 1);
|
|
15788
15826
|
var import_react20 = require("react");
|
|
15789
15827
|
var import_react_virtual2 = require("@tanstack/react-virtual");
|
|
15790
15828
|
var import_lucide_react24 = require("lucide-react");
|
|
@@ -15852,17 +15890,17 @@ var MultiCombobox = ({
|
|
|
15852
15890
|
const searchPlaceholder = searchPlaceholderProp ?? gi18n.searchPlaceholder ?? "Search...";
|
|
15853
15891
|
const loadingText = loadingTextProp ?? gi18n.loading ?? "Loading...";
|
|
15854
15892
|
const emptyText = emptyTextProp ?? gi18n.noResults ?? "No results found";
|
|
15855
|
-
const [query, setQuery] =
|
|
15856
|
-
const [open, setOpen] =
|
|
15857
|
-
const [activeIndex, setActiveIndex] =
|
|
15858
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
15859
|
-
const inputRef =
|
|
15860
|
-
const listRef =
|
|
15861
|
-
const optionsListRef =
|
|
15893
|
+
const [query, setQuery] = React41.useState("");
|
|
15894
|
+
const [open, setOpen] = React41.useState(false);
|
|
15895
|
+
const [activeIndex, setActiveIndex] = React41.useState(null);
|
|
15896
|
+
const [localRequiredError, setLocalRequiredError] = React41.useState();
|
|
15897
|
+
const inputRef = React41.useRef(null);
|
|
15898
|
+
const listRef = React41.useRef([]);
|
|
15899
|
+
const optionsListRef = React41.useRef(null);
|
|
15862
15900
|
useOverlayScrollbarTarget(optionsListRef, { enabled: open && useOverlayScrollbar && !virtualized });
|
|
15863
|
-
const triggerRef =
|
|
15901
|
+
const triggerRef = React41.useRef(null);
|
|
15864
15902
|
useShadCNAnimations();
|
|
15865
|
-
const normalizedOptions =
|
|
15903
|
+
const normalizedOptions = React41.useMemo(
|
|
15866
15904
|
() => options.map(
|
|
15867
15905
|
(o) => typeof o === "string" ? { value: o, label: o } : { value: o.value, label: o.label, icon: o.icon, description: o.description, disabled: o.disabled, group: o.group }
|
|
15868
15906
|
),
|
|
@@ -15872,7 +15910,7 @@ var MultiCombobox = ({
|
|
|
15872
15910
|
const trimmedQuery = query.trim();
|
|
15873
15911
|
const queryMeetsMinimum = trimmedQuery.length >= minSearchLength;
|
|
15874
15912
|
const shouldPromptForSearch = minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
15875
|
-
const filtered =
|
|
15913
|
+
const filtered = React41.useMemo(() => {
|
|
15876
15914
|
if (shouldPromptForSearch) return [];
|
|
15877
15915
|
if (!enableSearch || searchMode === "manual") return normalizedOptions;
|
|
15878
15916
|
const normalizedQuery = trimmedQuery.toLowerCase();
|
|
@@ -15881,7 +15919,7 @@ var MultiCombobox = ({
|
|
|
15881
15919
|
(opt) => opt.label.toLowerCase().includes(normalizedQuery) || opt.description?.toLowerCase().includes(normalizedQuery)
|
|
15882
15920
|
);
|
|
15883
15921
|
}, [enableSearch, normalizedOptions, searchMode, shouldPromptForSearch, trimmedQuery]);
|
|
15884
|
-
const renderLimitedOptions =
|
|
15922
|
+
const renderLimitedOptions = React41.useMemo(() => {
|
|
15885
15923
|
if (trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
15886
15924
|
return filtered;
|
|
15887
15925
|
}
|
|
@@ -15897,14 +15935,14 @@ var MultiCombobox = ({
|
|
|
15897
15935
|
enabled: canVirtualize
|
|
15898
15936
|
});
|
|
15899
15937
|
const virtualItems = canVirtualize ? optionVirtualizer.getVirtualItems() : [];
|
|
15900
|
-
const scrollVirtualListToIndex =
|
|
15938
|
+
const scrollVirtualListToIndex = React41.useCallback((index) => {
|
|
15901
15939
|
if (!canVirtualize || renderLimitedOptions.length === 0) return;
|
|
15902
15940
|
optionVirtualizer.scrollToIndex(index, { align: "auto" });
|
|
15903
15941
|
}, [canVirtualize, optionVirtualizer, renderLimitedOptions.length]);
|
|
15904
|
-
const scrollVirtualListToStart =
|
|
15942
|
+
const scrollVirtualListToStart = React41.useCallback(() => {
|
|
15905
15943
|
scrollVirtualListToIndex(0);
|
|
15906
15944
|
}, [scrollVirtualListToIndex]);
|
|
15907
|
-
const groupedOptions =
|
|
15945
|
+
const groupedOptions = React41.useMemo(() => {
|
|
15908
15946
|
if (!groupBy) return null;
|
|
15909
15947
|
const groups = /* @__PURE__ */ new Map();
|
|
15910
15948
|
renderLimitedOptions.forEach((opt) => {
|
|
@@ -15957,12 +15995,12 @@ var MultiCombobox = ({
|
|
|
15957
15995
|
onChange([]);
|
|
15958
15996
|
};
|
|
15959
15997
|
const effectiveError = error ?? localRequiredError;
|
|
15960
|
-
|
|
15998
|
+
React41.useEffect(() => {
|
|
15961
15999
|
if (disabled || !required || value.length > 0) {
|
|
15962
16000
|
setLocalRequiredError(void 0);
|
|
15963
16001
|
}
|
|
15964
16002
|
}, [disabled, required, value.length]);
|
|
15965
|
-
|
|
16003
|
+
React41.useEffect(() => {
|
|
15966
16004
|
if (open && enableSearch) {
|
|
15967
16005
|
setTimeout(() => {
|
|
15968
16006
|
inputRef.current?.focus();
|
|
@@ -15973,12 +16011,12 @@ var MultiCombobox = ({
|
|
|
15973
16011
|
scrollVirtualListToStart();
|
|
15974
16012
|
}
|
|
15975
16013
|
}, [enableSearch, open, scrollVirtualListToStart]);
|
|
15976
|
-
|
|
16014
|
+
React41.useEffect(() => {
|
|
15977
16015
|
if (!onSearchChange) return void 0;
|
|
15978
16016
|
const timeoutId = window.setTimeout(() => onSearchChange(query), searchDebounceMs);
|
|
15979
16017
|
return () => window.clearTimeout(timeoutId);
|
|
15980
16018
|
}, [onSearchChange, query, searchDebounceMs]);
|
|
15981
|
-
|
|
16019
|
+
React41.useEffect(() => {
|
|
15982
16020
|
if (process.env.NODE_ENV !== "production" && normalizedOptions.length > 300 && !virtualized && searchMode !== "manual" && maxInitialOptions === void 0) {
|
|
15983
16021
|
console.warn(
|
|
15984
16022
|
'[Underverse UI] MultiCombobox received more than 300 options without virtualization, manual search, or maxInitialOptions. Use virtualized, searchMode="manual", or maxInitialOptions to avoid rendering a large dropdown.'
|
|
@@ -16217,7 +16255,7 @@ var MultiCombobox = ({
|
|
|
16217
16255
|
}
|
|
16218
16256
|
)
|
|
16219
16257
|
] });
|
|
16220
|
-
const selectedOptionFallbackMap =
|
|
16258
|
+
const selectedOptionFallbackMap = React41.useMemo(
|
|
16221
16259
|
() => new Map((selectedOptionsProp ?? []).map((option) => [option.value, option])),
|
|
16222
16260
|
[selectedOptionsProp]
|
|
16223
16261
|
);
|
|
@@ -16251,7 +16289,7 @@ var MultiCombobox = ({
|
|
|
16251
16289
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: cn("flex items-center gap-1.5 flex-1 overflow-hidden", size === "sm" ? "min-h-4" : size === "lg" ? "min-h-8" : "min-h-6"), children: value.length > 0 ? showTags ? /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
|
16252
16290
|
visibleTags.map((option) => {
|
|
16253
16291
|
if (renderTag) {
|
|
16254
|
-
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
16292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(React41.Fragment, { children: renderTag(option, () => handleRemove(option.value)) }, option.value);
|
|
16255
16293
|
}
|
|
16256
16294
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
16257
16295
|
"span",
|
|
@@ -16413,17 +16451,17 @@ var MultiCombobox = ({
|
|
|
16413
16451
|
};
|
|
16414
16452
|
|
|
16415
16453
|
// src/components/RadioGroup.tsx
|
|
16416
|
-
var
|
|
16454
|
+
var React42 = __toESM(require("react"), 1);
|
|
16417
16455
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
16418
|
-
var RadioGroupContext =
|
|
16456
|
+
var RadioGroupContext = React42.createContext(void 0);
|
|
16419
16457
|
var useRadioGroup = () => {
|
|
16420
|
-
const context =
|
|
16458
|
+
const context = React42.useContext(RadioGroupContext);
|
|
16421
16459
|
if (!context) {
|
|
16422
16460
|
throw new Error("RadioGroupItem must be used within a RadioGroup");
|
|
16423
16461
|
}
|
|
16424
16462
|
return context;
|
|
16425
16463
|
};
|
|
16426
|
-
var RadioGroup =
|
|
16464
|
+
var RadioGroup = React42.forwardRef(
|
|
16427
16465
|
({
|
|
16428
16466
|
value,
|
|
16429
16467
|
defaultValue,
|
|
@@ -16439,7 +16477,7 @@ var RadioGroup = React41.forwardRef(
|
|
|
16439
16477
|
error = false,
|
|
16440
16478
|
errorMessage
|
|
16441
16479
|
}, ref) => {
|
|
16442
|
-
const [internalValue, setInternalValue] =
|
|
16480
|
+
const [internalValue, setInternalValue] = React42.useState(defaultValue || "");
|
|
16443
16481
|
const isControlled = value !== void 0;
|
|
16444
16482
|
const currentValue = isControlled ? value : internalValue;
|
|
16445
16483
|
const handleValueChange = (newValue) => {
|
|
@@ -16450,7 +16488,7 @@ var RadioGroup = React41.forwardRef(
|
|
|
16450
16488
|
onValueChange?.(newValue);
|
|
16451
16489
|
}
|
|
16452
16490
|
};
|
|
16453
|
-
const uniqueId =
|
|
16491
|
+
const uniqueId = React42.useId();
|
|
16454
16492
|
const radioName = name || `radio-group-${uniqueId}`;
|
|
16455
16493
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
16456
16494
|
RadioGroupContext.Provider,
|
|
@@ -16508,7 +16546,7 @@ var sizeStyles7 = {
|
|
|
16508
16546
|
padding: "p-4"
|
|
16509
16547
|
}
|
|
16510
16548
|
};
|
|
16511
|
-
var RadioGroupItem =
|
|
16549
|
+
var RadioGroupItem = React42.forwardRef(
|
|
16512
16550
|
({ value, id, disabled, className, children, label, labelClassName, description, icon }, ref) => {
|
|
16513
16551
|
const { value: selectedValue, onValueChange, name, disabled: groupDisabled, size = "md", variant = "default" } = useRadioGroup();
|
|
16514
16552
|
const isDisabled = disabled || groupDisabled;
|
|
@@ -16686,7 +16724,7 @@ var RadioGroupItem = React41.forwardRef(
|
|
|
16686
16724
|
RadioGroupItem.displayName = "RadioGroupItem";
|
|
16687
16725
|
|
|
16688
16726
|
// src/components/Slider.tsx
|
|
16689
|
-
var
|
|
16727
|
+
var React43 = __toESM(require("react"), 1);
|
|
16690
16728
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
16691
16729
|
var SIZE_STYLES = {
|
|
16692
16730
|
sm: {
|
|
@@ -16739,7 +16777,7 @@ function SliderTooltip({
|
|
|
16739
16777
|
}
|
|
16740
16778
|
);
|
|
16741
16779
|
}
|
|
16742
|
-
var Slider =
|
|
16780
|
+
var Slider = React43.forwardRef(
|
|
16743
16781
|
({
|
|
16744
16782
|
className,
|
|
16745
16783
|
mode = "single",
|
|
@@ -16775,28 +16813,28 @@ var Slider = React42.forwardRef(
|
|
|
16775
16813
|
}, ref) => {
|
|
16776
16814
|
const gi18n = useGlobalI18n();
|
|
16777
16815
|
const isRange = mode === "range";
|
|
16778
|
-
const trackRef =
|
|
16779
|
-
const [internalValue, setInternalValue] =
|
|
16780
|
-
const [internalRange, setInternalRange] =
|
|
16816
|
+
const trackRef = React43.useRef(null);
|
|
16817
|
+
const [internalValue, setInternalValue] = React43.useState(defaultValue);
|
|
16818
|
+
const [internalRange, setInternalRange] = React43.useState(() => {
|
|
16781
16819
|
if (defaultRangeValue) return defaultRangeValue;
|
|
16782
16820
|
const v = clamp6(defaultValue, min, max);
|
|
16783
16821
|
return [min, v];
|
|
16784
16822
|
});
|
|
16785
|
-
const [activeThumb, setActiveThumb] =
|
|
16786
|
-
const dragRef =
|
|
16787
|
-
const [isHovering, setIsHovering] =
|
|
16788
|
-
const [isDragging, setIsDragging] =
|
|
16823
|
+
const [activeThumb, setActiveThumb] = React43.useState(null);
|
|
16824
|
+
const dragRef = React43.useRef(null);
|
|
16825
|
+
const [isHovering, setIsHovering] = React43.useState(false);
|
|
16826
|
+
const [isDragging, setIsDragging] = React43.useState(false);
|
|
16789
16827
|
const isControlled = value !== void 0;
|
|
16790
16828
|
const currentValue = isControlled ? value : internalValue;
|
|
16791
16829
|
const isRangeControlled = rangeValue !== void 0;
|
|
16792
16830
|
const currentRange = isRangeControlled ? rangeValue : internalRange;
|
|
16793
16831
|
const rangeMin = clamp6(currentRange[0] ?? min, min, max);
|
|
16794
16832
|
const rangeMax = clamp6(currentRange[1] ?? max, min, max);
|
|
16795
|
-
const normalizedRange =
|
|
16833
|
+
const normalizedRange = React43.useMemo(
|
|
16796
16834
|
() => rangeMin <= rangeMax ? [rangeMin, rangeMax] : [rangeMax, rangeMin],
|
|
16797
16835
|
[rangeMax, rangeMin]
|
|
16798
16836
|
);
|
|
16799
|
-
const handleSingleChange =
|
|
16837
|
+
const handleSingleChange = React43.useCallback(
|
|
16800
16838
|
(e) => {
|
|
16801
16839
|
const newValue = Number(e.target.value);
|
|
16802
16840
|
if (!isControlled) {
|
|
@@ -16807,14 +16845,14 @@ var Slider = React42.forwardRef(
|
|
|
16807
16845
|
},
|
|
16808
16846
|
[isControlled, onChange, onValueChange]
|
|
16809
16847
|
);
|
|
16810
|
-
const emitRange =
|
|
16848
|
+
const emitRange = React43.useCallback(
|
|
16811
16849
|
(next) => {
|
|
16812
16850
|
onRangeChange?.(next);
|
|
16813
16851
|
onRangeValueChange?.(next);
|
|
16814
16852
|
},
|
|
16815
16853
|
[onRangeChange, onRangeValueChange]
|
|
16816
16854
|
);
|
|
16817
|
-
const handleRangeChange =
|
|
16855
|
+
const handleRangeChange = React43.useCallback(
|
|
16818
16856
|
(thumb) => (e) => {
|
|
16819
16857
|
const nextVal = Number(e.target.value);
|
|
16820
16858
|
const [curMin, curMax] = normalizedRange;
|
|
@@ -16830,7 +16868,7 @@ var Slider = React42.forwardRef(
|
|
|
16830
16868
|
const rangeEndPct = (normalizedRange[1] - min) / denom * 100;
|
|
16831
16869
|
const sizeStyles8 = SIZE_STYLES[size];
|
|
16832
16870
|
const tooltipVisible = showTooltip && !disabled && (isHovering || isDragging);
|
|
16833
|
-
const displayValue =
|
|
16871
|
+
const displayValue = React43.useMemo(() => {
|
|
16834
16872
|
if (isRange) {
|
|
16835
16873
|
const a = formatValue ? formatValue(normalizedRange[0]) : normalizedRange[0].toString();
|
|
16836
16874
|
const b = formatValue ? formatValue(normalizedRange[1]) : normalizedRange[1].toString();
|
|
@@ -16838,7 +16876,7 @@ var Slider = React42.forwardRef(
|
|
|
16838
16876
|
}
|
|
16839
16877
|
return formatValue ? formatValue(currentValue) : currentValue.toString();
|
|
16840
16878
|
}, [currentValue, formatValue, isRange, normalizedRange]);
|
|
16841
|
-
const quantize =
|
|
16879
|
+
const quantize = React43.useCallback(
|
|
16842
16880
|
(v) => {
|
|
16843
16881
|
const stepped = Math.round((v - min) / step) * step + min;
|
|
16844
16882
|
const fixed = Number(stepped.toFixed(10));
|
|
@@ -16846,7 +16884,7 @@ var Slider = React42.forwardRef(
|
|
|
16846
16884
|
},
|
|
16847
16885
|
[max, min, step]
|
|
16848
16886
|
);
|
|
16849
|
-
const valueFromClientX =
|
|
16887
|
+
const valueFromClientX = React43.useCallback(
|
|
16850
16888
|
(clientX) => {
|
|
16851
16889
|
const el = trackRef.current;
|
|
16852
16890
|
if (!el) return min;
|
|
@@ -19182,7 +19220,7 @@ function FileUpload({
|
|
|
19182
19220
|
}
|
|
19183
19221
|
|
|
19184
19222
|
// src/components/Carousel.tsx
|
|
19185
|
-
var
|
|
19223
|
+
var React46 = __toESM(require("react"), 1);
|
|
19186
19224
|
var import_lucide_react29 = require("lucide-react");
|
|
19187
19225
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
19188
19226
|
function Carousel({
|
|
@@ -19208,16 +19246,16 @@ function Carousel({
|
|
|
19208
19246
|
effectOptions
|
|
19209
19247
|
}) {
|
|
19210
19248
|
const gi18n = useGlobalI18n();
|
|
19211
|
-
const [currentIndex, setCurrentIndex] =
|
|
19212
|
-
const [isPaused, setIsPaused] =
|
|
19213
|
-
const progressElRef =
|
|
19214
|
-
const carouselRef =
|
|
19215
|
-
const rafRef =
|
|
19216
|
-
const isDraggingRef =
|
|
19217
|
-
const dragDistanceRef =
|
|
19218
|
-
const startPosRef =
|
|
19219
|
-
const lastDragPositionRef =
|
|
19220
|
-
const slides =
|
|
19249
|
+
const [currentIndex, setCurrentIndex] = React46.useState(0);
|
|
19250
|
+
const [isPaused, setIsPaused] = React46.useState(false);
|
|
19251
|
+
const progressElRef = React46.useRef(null);
|
|
19252
|
+
const carouselRef = React46.useRef(null);
|
|
19253
|
+
const rafRef = React46.useRef(null);
|
|
19254
|
+
const isDraggingRef = React46.useRef(false);
|
|
19255
|
+
const dragDistanceRef = React46.useRef(0);
|
|
19256
|
+
const startPosRef = React46.useRef(0);
|
|
19257
|
+
const lastDragPositionRef = React46.useRef(0);
|
|
19258
|
+
const slides = React46.useMemo(() => React46.Children.toArray(children), [children]);
|
|
19221
19259
|
const totalSlides = slides.length;
|
|
19222
19260
|
const isHorizontal = orientation === "horizontal";
|
|
19223
19261
|
const effectiveAnimation = slidesToShow > 1 && !["slide", "coverflow", "stack"].includes(animation) ? "slide" : animation;
|
|
@@ -19225,7 +19263,7 @@ function Carousel({
|
|
|
19225
19263
|
const effectiveSlidesToShow = isDeckAnimation ? 1 : slidesToShow;
|
|
19226
19264
|
const maxIndex = Math.max(0, totalSlides - effectiveSlidesToShow);
|
|
19227
19265
|
const shouldShowArrows = showArrows && isHorizontal;
|
|
19228
|
-
const presetEffectOptions =
|
|
19266
|
+
const presetEffectOptions = React46.useMemo(() => {
|
|
19229
19267
|
if (effectPreset === "cinematic") {
|
|
19230
19268
|
return effectiveAnimation === "stack" ? {
|
|
19231
19269
|
mainScale: 1.08,
|
|
@@ -19320,7 +19358,7 @@ function Carousel({
|
|
|
19320
19358
|
}
|
|
19321
19359
|
return {};
|
|
19322
19360
|
}, [effectPreset, effectiveAnimation]);
|
|
19323
|
-
const mergedEffectOptions =
|
|
19361
|
+
const mergedEffectOptions = React46.useMemo(
|
|
19324
19362
|
() => ({
|
|
19325
19363
|
mainScale: 1.04,
|
|
19326
19364
|
sideScale: effectiveAnimation === "stack" ? 0.93 : 0.88,
|
|
@@ -19339,7 +19377,7 @@ function Carousel({
|
|
|
19339
19377
|
}),
|
|
19340
19378
|
[effectOptions, effectiveAnimation, presetEffectOptions]
|
|
19341
19379
|
);
|
|
19342
|
-
const scrollPrev =
|
|
19380
|
+
const scrollPrev = React46.useCallback(() => {
|
|
19343
19381
|
setCurrentIndex((prev) => {
|
|
19344
19382
|
if (prev === 0) {
|
|
19345
19383
|
return loop ? maxIndex : 0;
|
|
@@ -19347,7 +19385,7 @@ function Carousel({
|
|
|
19347
19385
|
return Math.max(0, prev - slidesToScroll);
|
|
19348
19386
|
});
|
|
19349
19387
|
}, [loop, maxIndex, slidesToScroll]);
|
|
19350
|
-
const scrollNext =
|
|
19388
|
+
const scrollNext = React46.useCallback(() => {
|
|
19351
19389
|
setCurrentIndex((prev) => {
|
|
19352
19390
|
if (prev >= maxIndex) {
|
|
19353
19391
|
return loop ? 0 : maxIndex;
|
|
@@ -19355,13 +19393,13 @@ function Carousel({
|
|
|
19355
19393
|
return Math.min(maxIndex, prev + slidesToScroll);
|
|
19356
19394
|
});
|
|
19357
19395
|
}, [loop, maxIndex, slidesToScroll]);
|
|
19358
|
-
const scrollTo =
|
|
19396
|
+
const scrollTo = React46.useCallback(
|
|
19359
19397
|
(index) => {
|
|
19360
19398
|
setCurrentIndex(Math.min(maxIndex, Math.max(0, index)));
|
|
19361
19399
|
},
|
|
19362
19400
|
[maxIndex]
|
|
19363
19401
|
);
|
|
19364
|
-
const handleKeyDown2 =
|
|
19402
|
+
const handleKeyDown2 = React46.useCallback(
|
|
19365
19403
|
(e) => {
|
|
19366
19404
|
if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
|
|
19367
19405
|
e.preventDefault();
|
|
@@ -19379,7 +19417,7 @@ function Carousel({
|
|
|
19379
19417
|
},
|
|
19380
19418
|
[scrollPrev, scrollNext, scrollTo, maxIndex]
|
|
19381
19419
|
);
|
|
19382
|
-
|
|
19420
|
+
React46.useEffect(() => {
|
|
19383
19421
|
const stop = () => {
|
|
19384
19422
|
if (rafRef.current != null) {
|
|
19385
19423
|
cancelAnimationFrame(rafRef.current);
|
|
@@ -19439,7 +19477,7 @@ function Carousel({
|
|
|
19439
19477
|
startPosRef.current = 0;
|
|
19440
19478
|
lastDragPositionRef.current = 0;
|
|
19441
19479
|
};
|
|
19442
|
-
const handleDeckAreaClick =
|
|
19480
|
+
const handleDeckAreaClick = React46.useCallback((event) => {
|
|
19443
19481
|
if (!isDeckAnimation || dragDistanceRef.current > 8) {
|
|
19444
19482
|
dragDistanceRef.current = 0;
|
|
19445
19483
|
return;
|
|
@@ -19456,7 +19494,7 @@ function Carousel({
|
|
|
19456
19494
|
scrollNext();
|
|
19457
19495
|
}
|
|
19458
19496
|
}, [isDeckAnimation, scrollNext, scrollPrev]);
|
|
19459
|
-
|
|
19497
|
+
React46.useEffect(() => {
|
|
19460
19498
|
onSlideChange?.(currentIndex);
|
|
19461
19499
|
}, [currentIndex, onSlideChange]);
|
|
19462
19500
|
const getAnimationStyles2 = () => {
|
|
@@ -19470,7 +19508,7 @@ function Carousel({
|
|
|
19470
19508
|
};
|
|
19471
19509
|
};
|
|
19472
19510
|
const slideWidth = 100 / effectiveSlidesToShow;
|
|
19473
|
-
const getLoopDistance =
|
|
19511
|
+
const getLoopDistance = React46.useCallback(
|
|
19474
19512
|
(index) => {
|
|
19475
19513
|
if (totalSlides <= 0) return 0;
|
|
19476
19514
|
const forward = index - currentIndex;
|
|
@@ -19482,7 +19520,7 @@ function Carousel({
|
|
|
19482
19520
|
},
|
|
19483
19521
|
[currentIndex, loop, totalSlides]
|
|
19484
19522
|
);
|
|
19485
|
-
const getDeckSlideStyles =
|
|
19523
|
+
const getDeckSlideStyles = React46.useCallback(
|
|
19486
19524
|
(index) => {
|
|
19487
19525
|
const distance = getLoopDistance(index);
|
|
19488
19526
|
const absDistance = Math.abs(distance);
|
|
@@ -19562,7 +19600,7 @@ function Carousel({
|
|
|
19562
19600
|
"aria-atomic": "false",
|
|
19563
19601
|
"aria-live": autoScroll ? "off" : "polite",
|
|
19564
19602
|
children: slides.map((child, idx) => {
|
|
19565
|
-
const key =
|
|
19603
|
+
const key = React46.isValidElement(child) && child.key || idx;
|
|
19566
19604
|
const ariaHidden = effectiveAnimation === "slide" ? idx < currentIndex || idx >= currentIndex + slidesToShow : idx !== currentIndex;
|
|
19567
19605
|
if (isDeckAnimation) {
|
|
19568
19606
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
@@ -19685,7 +19723,7 @@ function Carousel({
|
|
|
19685
19723
|
"max-md:gap-1.5 max-md:p-2",
|
|
19686
19724
|
isHorizontal ? "flex-row" : "flex-col"
|
|
19687
19725
|
),
|
|
19688
|
-
children:
|
|
19726
|
+
children: React46.Children.map(children, (child, idx) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
19689
19727
|
"button",
|
|
19690
19728
|
{
|
|
19691
19729
|
onClick: () => scrollTo(idx),
|
|
@@ -19983,7 +20021,7 @@ function FallingIcons({
|
|
|
19983
20021
|
}
|
|
19984
20022
|
|
|
19985
20023
|
// src/components/List.tsx
|
|
19986
|
-
var
|
|
20024
|
+
var React48 = __toESM(require("react"), 1);
|
|
19987
20025
|
var import_lucide_react30 = require("lucide-react");
|
|
19988
20026
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
19989
20027
|
var SIZE_STYLES2 = {
|
|
@@ -20009,7 +20047,7 @@ var ListItemSkeleton = ({ size }) => {
|
|
|
20009
20047
|
] })
|
|
20010
20048
|
] });
|
|
20011
20049
|
};
|
|
20012
|
-
var ListRoot =
|
|
20050
|
+
var ListRoot = React48.forwardRef(
|
|
20013
20051
|
({
|
|
20014
20052
|
as = "ul",
|
|
20015
20053
|
ordered,
|
|
@@ -20030,7 +20068,7 @@ var ListRoot = React47.forwardRef(
|
|
|
20030
20068
|
...rest
|
|
20031
20069
|
}, ref) => {
|
|
20032
20070
|
const Comp = ordered ? "ol" : as;
|
|
20033
|
-
const childCount =
|
|
20071
|
+
const childCount = React48.Children.count(children);
|
|
20034
20072
|
const hasChildren = childCount > 0;
|
|
20035
20073
|
const variantClasses3 = {
|
|
20036
20074
|
plain: "",
|
|
@@ -20084,14 +20122,14 @@ var ListRoot = React47.forwardRef(
|
|
|
20084
20122
|
className
|
|
20085
20123
|
),
|
|
20086
20124
|
...rest,
|
|
20087
|
-
children:
|
|
20088
|
-
if (!
|
|
20125
|
+
children: React48.Children.map(children, (child, idx) => {
|
|
20126
|
+
if (!React48.isValidElement(child)) return child;
|
|
20089
20127
|
const childClass = cn(
|
|
20090
20128
|
child.props?.className,
|
|
20091
20129
|
hoverable && variant !== "flush" && "hover:bg-accent/50 focus:bg-accent/60 focus:outline-none transition-colors",
|
|
20092
20130
|
variant === "flush" && "hover:bg-accent/30"
|
|
20093
20131
|
);
|
|
20094
|
-
return
|
|
20132
|
+
return React48.cloneElement(child, {
|
|
20095
20133
|
className: childClass,
|
|
20096
20134
|
// Pass global item class to contentClassName of ListItem
|
|
20097
20135
|
contentClassName: cn(itemClassName, child.props?.contentClassName),
|
|
@@ -20106,7 +20144,7 @@ var ListRoot = React47.forwardRef(
|
|
|
20106
20144
|
}
|
|
20107
20145
|
);
|
|
20108
20146
|
ListRoot.displayName = "List";
|
|
20109
|
-
var ListItem =
|
|
20147
|
+
var ListItem = React48.forwardRef(
|
|
20110
20148
|
({
|
|
20111
20149
|
as = "li",
|
|
20112
20150
|
selected = false,
|
|
@@ -20129,7 +20167,7 @@ var ListItem = React47.forwardRef(
|
|
|
20129
20167
|
children,
|
|
20130
20168
|
...rest
|
|
20131
20169
|
}, ref) => {
|
|
20132
|
-
const [internalExpanded, setInternalExpanded] =
|
|
20170
|
+
const [internalExpanded, setInternalExpanded] = React48.useState(false);
|
|
20133
20171
|
const isExpanded = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
|
|
20134
20172
|
const sizeAttr = rest["data-size"];
|
|
20135
20173
|
const resolvedSize = sizeAttr && ["xs", "sm", "md", "lg"].includes(sizeAttr) ? sizeAttr : "md";
|
|
@@ -20197,7 +20235,7 @@ var List = Object.assign(ListRoot, { Item: ListItem });
|
|
|
20197
20235
|
var List_default = List;
|
|
20198
20236
|
|
|
20199
20237
|
// src/components/Watermark.tsx
|
|
20200
|
-
var
|
|
20238
|
+
var React49 = __toESM(require("react"), 1);
|
|
20201
20239
|
var import_react_dom5 = require("react-dom");
|
|
20202
20240
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
20203
20241
|
var PRESETS2 = {
|
|
@@ -20209,8 +20247,8 @@ var PRESETS2 = {
|
|
|
20209
20247
|
internal: { text: "INTERNAL USE ONLY", color: "rgba(156, 163, 175, 0.15)", rotate: -22, fontSize: 13, fontWeight: "600" }
|
|
20210
20248
|
};
|
|
20211
20249
|
function useWatermarkDataURL(opts) {
|
|
20212
|
-
const [url, setUrl] =
|
|
20213
|
-
|
|
20250
|
+
const [url, setUrl] = React49.useState(null);
|
|
20251
|
+
React49.useEffect(() => {
|
|
20214
20252
|
let cancelled = false;
|
|
20215
20253
|
const text = opts.text;
|
|
20216
20254
|
const image = opts.image;
|
|
@@ -20387,9 +20425,9 @@ var Watermark = ({
|
|
|
20387
20425
|
children,
|
|
20388
20426
|
...rest
|
|
20389
20427
|
}) => {
|
|
20390
|
-
const [visible, setVisible] =
|
|
20391
|
-
const [isDark, setIsDark] =
|
|
20392
|
-
|
|
20428
|
+
const [visible, setVisible] = React49.useState(true);
|
|
20429
|
+
const [isDark, setIsDark] = React49.useState(false);
|
|
20430
|
+
React49.useEffect(() => {
|
|
20393
20431
|
if (!darkMode) return;
|
|
20394
20432
|
const checkDarkMode = () => {
|
|
20395
20433
|
const isDarkMode = document.documentElement.classList.contains("dark") || window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
@@ -20491,7 +20529,7 @@ var Watermark = ({
|
|
|
20491
20529
|
var Watermark_default = Watermark;
|
|
20492
20530
|
|
|
20493
20531
|
// src/components/Timeline.tsx
|
|
20494
|
-
var
|
|
20532
|
+
var React50 = __toESM(require("react"), 1);
|
|
20495
20533
|
var import_lucide_react31 = require("lucide-react");
|
|
20496
20534
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
20497
20535
|
var SIZE_STYLE = {
|
|
@@ -20544,7 +20582,7 @@ var STATUS_COLOR = {
|
|
|
20544
20582
|
error: "bg-destructive",
|
|
20545
20583
|
info: "bg-info"
|
|
20546
20584
|
};
|
|
20547
|
-
var TimelineContext =
|
|
20585
|
+
var TimelineContext = React50.createContext(null);
|
|
20548
20586
|
var LINE_STYLE_MAP = {
|
|
20549
20587
|
solid: "border-solid",
|
|
20550
20588
|
dashed: "border-dashed",
|
|
@@ -20572,7 +20610,7 @@ var Marker = ({ index, last, size, color, status = "default", lineColor, lineSty
|
|
|
20572
20610
|
!last && showLine && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: cn("flex-1 border-l-2", LINE_STYLE_MAP[lineStyle]), style: { borderColor: lineColor || "hsl(var(--border))" } })
|
|
20573
20611
|
] });
|
|
20574
20612
|
};
|
|
20575
|
-
var TimelineRoot =
|
|
20613
|
+
var TimelineRoot = React50.forwardRef(
|
|
20576
20614
|
({
|
|
20577
20615
|
align = "left",
|
|
20578
20616
|
variant = "default",
|
|
@@ -20602,7 +20640,7 @@ var TimelineRoot = React49.forwardRef(
|
|
|
20602
20640
|
}
|
|
20603
20641
|
);
|
|
20604
20642
|
TimelineRoot.displayName = "Timeline";
|
|
20605
|
-
var TimelineItem =
|
|
20643
|
+
var TimelineItem = React50.forwardRef(
|
|
20606
20644
|
({
|
|
20607
20645
|
title,
|
|
20608
20646
|
description,
|
|
@@ -20621,11 +20659,11 @@ var TimelineItem = React49.forwardRef(
|
|
|
20621
20659
|
children,
|
|
20622
20660
|
...rest
|
|
20623
20661
|
}, ref) => {
|
|
20624
|
-
const ctx =
|
|
20662
|
+
const ctx = React50.useContext(TimelineContext);
|
|
20625
20663
|
const idx = rest["data-index"];
|
|
20626
20664
|
const isLast = Boolean(rest["data-last"]);
|
|
20627
20665
|
const sz = SIZE_STYLE[ctx.size];
|
|
20628
|
-
const [internalExpanded, setInternalExpanded] =
|
|
20666
|
+
const [internalExpanded, setInternalExpanded] = React50.useState(false);
|
|
20629
20667
|
const isExpanded = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
|
|
20630
20668
|
const toggleExpanded = () => {
|
|
20631
20669
|
const newExpanded = !isExpanded;
|
|
@@ -20767,7 +20805,7 @@ var Timeline = Object.assign(TimelineRoot, { Item: TimelineItem });
|
|
|
20767
20805
|
var Timeline_default = Timeline;
|
|
20768
20806
|
|
|
20769
20807
|
// src/components/ColorPicker.tsx
|
|
20770
|
-
var
|
|
20808
|
+
var React51 = __toESM(require("react"), 1);
|
|
20771
20809
|
var import_lucide_react32 = require("lucide-react");
|
|
20772
20810
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
20773
20811
|
var clamp7 = (n, min, max) => Math.max(min, Math.min(max, n));
|
|
@@ -20962,12 +21000,12 @@ function ColorPicker({
|
|
|
20962
21000
|
const gi18n = useGlobalI18n();
|
|
20963
21001
|
const isControlled = value !== void 0;
|
|
20964
21002
|
const initial = parseAnyColor(isControlled ? value : defaultValue) || { r: 79, g: 70, b: 229, a: 1 };
|
|
20965
|
-
const [rgba, setRgba] =
|
|
20966
|
-
const [open, setOpen] =
|
|
20967
|
-
const [text, setText] =
|
|
20968
|
-
const [copied, setCopied] =
|
|
20969
|
-
const [recentColors, setRecentColors] =
|
|
20970
|
-
|
|
21003
|
+
const [rgba, setRgba] = React51.useState(initial);
|
|
21004
|
+
const [open, setOpen] = React51.useState(false);
|
|
21005
|
+
const [text, setText] = React51.useState(() => formatOutput(initial, withAlpha, format));
|
|
21006
|
+
const [copied, setCopied] = React51.useState(false);
|
|
21007
|
+
const [recentColors, setRecentColors] = React51.useState([]);
|
|
21008
|
+
React51.useEffect(() => {
|
|
20971
21009
|
if (isControlled) {
|
|
20972
21010
|
const parsed = parseAnyColor(value);
|
|
20973
21011
|
if (parsed) {
|
|
@@ -23478,10 +23516,10 @@ function DataTable({
|
|
|
23478
23516
|
var DataTable_default = DataTable;
|
|
23479
23517
|
|
|
23480
23518
|
// src/components/Form.tsx
|
|
23481
|
-
var
|
|
23519
|
+
var React65 = __toESM(require("react"), 1);
|
|
23482
23520
|
var import_react_hook_form = require("react-hook-form");
|
|
23483
23521
|
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
23484
|
-
var FormConfigContext =
|
|
23522
|
+
var FormConfigContext = React65.createContext({ size: "md" });
|
|
23485
23523
|
var FormWrapper = ({
|
|
23486
23524
|
children,
|
|
23487
23525
|
onSubmit,
|
|
@@ -23494,7 +23532,7 @@ var FormWrapper = ({
|
|
|
23494
23532
|
const methods = (0, import_react_hook_form.useForm)({
|
|
23495
23533
|
defaultValues: initialValues
|
|
23496
23534
|
});
|
|
23497
|
-
|
|
23535
|
+
React65.useEffect(() => {
|
|
23498
23536
|
if (initialValues) {
|
|
23499
23537
|
methods.reset(initialValues);
|
|
23500
23538
|
}
|
|
@@ -23503,15 +23541,15 @@ var FormWrapper = ({
|
|
|
23503
23541
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_react_hook_form.FormProvider, { ...methods, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormConfigContext.Provider, { value: { size }, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("form", { onSubmit: methods.handleSubmit(onSubmit), className, ...formProps, children }) }) });
|
|
23504
23542
|
};
|
|
23505
23543
|
var Form = FormWrapper;
|
|
23506
|
-
var FormFieldContext =
|
|
23544
|
+
var FormFieldContext = React65.createContext({});
|
|
23507
23545
|
var FormField = ({
|
|
23508
23546
|
...props
|
|
23509
23547
|
}) => {
|
|
23510
23548
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_react_hook_form.Controller, { ...props }) });
|
|
23511
23549
|
};
|
|
23512
23550
|
var useFormField = () => {
|
|
23513
|
-
const fieldContext =
|
|
23514
|
-
const itemContext =
|
|
23551
|
+
const fieldContext = React65.useContext(FormFieldContext);
|
|
23552
|
+
const itemContext = React65.useContext(FormItemContext);
|
|
23515
23553
|
const { getFieldState, formState } = (0, import_react_hook_form.useFormContext)();
|
|
23516
23554
|
if (!fieldContext) {
|
|
23517
23555
|
throw new Error("useFormField must be used within FormField");
|
|
@@ -23527,16 +23565,16 @@ var useFormField = () => {
|
|
|
23527
23565
|
...fieldState
|
|
23528
23566
|
};
|
|
23529
23567
|
};
|
|
23530
|
-
var FormItemContext =
|
|
23531
|
-
var FormItem =
|
|
23532
|
-
const id =
|
|
23568
|
+
var FormItemContext = React65.createContext({});
|
|
23569
|
+
var FormItem = React65.forwardRef(({ className, ...props }, ref) => {
|
|
23570
|
+
const id = React65.useId();
|
|
23533
23571
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { ref, className: cn("group space-y-2", className), ...props }) });
|
|
23534
23572
|
});
|
|
23535
23573
|
FormItem.displayName = "FormItem";
|
|
23536
|
-
var FormLabel =
|
|
23574
|
+
var FormLabel = React65.forwardRef(
|
|
23537
23575
|
({ className, children, required, ...props }, ref) => {
|
|
23538
23576
|
const { error, formItemId } = useFormField();
|
|
23539
|
-
const config =
|
|
23577
|
+
const config = React65.useContext(FormConfigContext);
|
|
23540
23578
|
const sizeClass = config.size === "sm" ? "text-xs" : config.size === "lg" ? "text-base" : "text-sm";
|
|
23541
23579
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
|
|
23542
23580
|
Label,
|
|
@@ -23559,7 +23597,7 @@ var FormLabel = React64.forwardRef(
|
|
|
23559
23597
|
}
|
|
23560
23598
|
);
|
|
23561
23599
|
FormLabel.displayName = "FormLabel";
|
|
23562
|
-
var FormControl =
|
|
23600
|
+
var FormControl = React65.forwardRef(({ ...props }, ref) => {
|
|
23563
23601
|
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
23564
23602
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23565
23603
|
"div",
|
|
@@ -23573,12 +23611,12 @@ var FormControl = React64.forwardRef(({ ...props }, ref) => {
|
|
|
23573
23611
|
);
|
|
23574
23612
|
});
|
|
23575
23613
|
FormControl.displayName = "FormControl";
|
|
23576
|
-
var FormDescription =
|
|
23614
|
+
var FormDescription = React65.forwardRef(({ className, ...props }, ref) => {
|
|
23577
23615
|
const { formDescriptionId } = useFormField();
|
|
23578
23616
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { ref, id: formDescriptionId, className: cn("text-sm text-muted-foreground", className), ...props });
|
|
23579
23617
|
});
|
|
23580
23618
|
FormDescription.displayName = "FormDescription";
|
|
23581
|
-
var FormMessage =
|
|
23619
|
+
var FormMessage = React65.forwardRef(({ className, children, ...props }, ref) => {
|
|
23582
23620
|
const { error, formMessageId } = useFormField();
|
|
23583
23621
|
const body = error ? String(error?.message) : children;
|
|
23584
23622
|
if (!body) {
|
|
@@ -23587,7 +23625,7 @@ var FormMessage = React64.forwardRef(({ className, children, ...props }, ref) =>
|
|
|
23587
23625
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { ref, id: formMessageId, className: cn("text-sm font-medium text-destructive", className), ...props, children: body });
|
|
23588
23626
|
});
|
|
23589
23627
|
FormMessage.displayName = "FormMessage";
|
|
23590
|
-
var FormInput =
|
|
23628
|
+
var FormInput = React65.forwardRef(({ name, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormConfigContext.Consumer, { children: ({ size }) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23591
23629
|
FormField,
|
|
23592
23630
|
{
|
|
23593
23631
|
name,
|
|
@@ -23598,7 +23636,7 @@ var FormInput = React64.forwardRef(({ name, ...props }, ref) => /* @__PURE__ */
|
|
|
23598
23636
|
}
|
|
23599
23637
|
) }));
|
|
23600
23638
|
FormInput.displayName = "FormInput";
|
|
23601
|
-
var FormCheckbox =
|
|
23639
|
+
var FormCheckbox = React65.forwardRef(({ name, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormConfigContext.Consumer, { children: ({ size }) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23602
23640
|
FormField,
|
|
23603
23641
|
{
|
|
23604
23642
|
name,
|
|
@@ -23622,9 +23660,9 @@ var FormCheckbox = React64.forwardRef(({ name, ...props }, ref) => /* @__PURE__
|
|
|
23622
23660
|
}
|
|
23623
23661
|
) }));
|
|
23624
23662
|
FormCheckbox.displayName = "FormCheckbox";
|
|
23625
|
-
var FormActions =
|
|
23663
|
+
var FormActions = React65.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { ref, className: cn("flex gap-2 justify-end", className), ...props }));
|
|
23626
23664
|
FormActions.displayName = "FormActions";
|
|
23627
|
-
var FormSubmitButton =
|
|
23665
|
+
var FormSubmitButton = React65.forwardRef(
|
|
23628
23666
|
({ children, loading: loading2, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormConfigContext.Consumer, { children: ({ size }) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Button_default, { ref, type: "submit", size: props.size ?? size, disabled: loading2, ...props, children }) })
|
|
23629
23667
|
);
|
|
23630
23668
|
FormSubmitButton.displayName = "FormSubmitButton";
|
|
@@ -23914,7 +23952,7 @@ var VARIANT_STYLES_ALERT = {
|
|
|
23914
23952
|
};
|
|
23915
23953
|
|
|
23916
23954
|
// src/contexts/translation-adapter.tsx
|
|
23917
|
-
var
|
|
23955
|
+
var React67 = __toESM(require("react"), 1);
|
|
23918
23956
|
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
23919
23957
|
function isUnresolvedTranslation2(value, namespace, key) {
|
|
23920
23958
|
return value === key || value === `${namespace}.${key}`;
|
|
@@ -23939,7 +23977,7 @@ function useTranslations(namespace) {
|
|
|
23939
23977
|
const nextIntlBridge = useNextIntlBridge();
|
|
23940
23978
|
const internalLocale = useUnderverseLocale();
|
|
23941
23979
|
const internalT = useUnderverseTranslations(namespace);
|
|
23942
|
-
return
|
|
23980
|
+
return React67.useCallback((key, params) => {
|
|
23943
23981
|
if (nextIntlBridge) {
|
|
23944
23982
|
const nextIntlResult = nextIntlBridge.translate(namespace, key, params);
|
|
23945
23983
|
if (nextIntlResult.translated && !isUnresolvedTranslation2(nextIntlResult.translated, namespace, key)) {
|
|
@@ -23964,8 +24002,8 @@ function useLocale2() {
|
|
|
23964
24002
|
}
|
|
23965
24003
|
|
|
23966
24004
|
// src/components/UEditor/UEditor.tsx
|
|
23967
|
-
var
|
|
23968
|
-
var
|
|
24005
|
+
var import_react56 = __toESM(require("react"), 1);
|
|
24006
|
+
var import_react57 = require("@tiptap/react");
|
|
23969
24007
|
|
|
23970
24008
|
// src/components/UEditor/extensions.ts
|
|
23971
24009
|
var import_extension_document = __toESM(require("@tiptap/extension-document"), 1);
|
|
@@ -25418,12 +25456,113 @@ function buildUEditorExtensions({
|
|
|
25418
25456
|
|
|
25419
25457
|
// src/components/UEditor/toolbar.tsx
|
|
25420
25458
|
var import_react49 = __toESM(require("react"), 1);
|
|
25459
|
+
var import_react_dom8 = require("react-dom");
|
|
25460
|
+
var import_react50 = require("@tiptap/react");
|
|
25421
25461
|
var import_lucide_react44 = require("lucide-react");
|
|
25422
25462
|
|
|
25423
25463
|
// src/components/UEditor/colors.tsx
|
|
25424
25464
|
var import_react47 = require("react");
|
|
25425
25465
|
var import_lucide_react42 = require("lucide-react");
|
|
25426
25466
|
var import_jsx_runtime78 = require("react/jsx-runtime");
|
|
25467
|
+
var TextColorIcon = ({ color }) => {
|
|
25468
|
+
const underlineColor = color && color !== "inherit" ? color : "currentColor";
|
|
25469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("span", { className: "relative flex h-5 w-5 items-center justify-center leading-none", children: [
|
|
25470
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "text-[15px] font-semibold leading-none", children: "A" }),
|
|
25471
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
25472
|
+
"span",
|
|
25473
|
+
{
|
|
25474
|
+
"aria-hidden": "true",
|
|
25475
|
+
className: "absolute bottom-0 left-1/2 h-0.5 w-4 -translate-x-1/2 rounded-full",
|
|
25476
|
+
style: { backgroundColor: underlineColor }
|
|
25477
|
+
}
|
|
25478
|
+
)
|
|
25479
|
+
] });
|
|
25480
|
+
};
|
|
25481
|
+
var HighlightColorIcon = ({ color }) => {
|
|
25482
|
+
const underlineColor = color || "currentColor";
|
|
25483
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("span", { className: "relative flex h-5 w-5 items-center justify-center leading-none", children: [
|
|
25484
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_lucide_react42.Highlighter, { className: "h-4 w-4" }),
|
|
25485
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
25486
|
+
"span",
|
|
25487
|
+
{
|
|
25488
|
+
"aria-hidden": "true",
|
|
25489
|
+
className: "absolute bottom-0 left-1/2 h-0.5 w-4 -translate-x-1/2 rounded-full",
|
|
25490
|
+
style: { backgroundColor: underlineColor }
|
|
25491
|
+
}
|
|
25492
|
+
)
|
|
25493
|
+
] });
|
|
25494
|
+
};
|
|
25495
|
+
var EDITOR_COLOR_SWATCHES = [
|
|
25496
|
+
"#000000",
|
|
25497
|
+
"#3f3f46",
|
|
25498
|
+
"#713f12",
|
|
25499
|
+
"#14532d",
|
|
25500
|
+
"#164e63",
|
|
25501
|
+
"#1e3a8a",
|
|
25502
|
+
"#3730a3",
|
|
25503
|
+
"#404040",
|
|
25504
|
+
"#b91c1c",
|
|
25505
|
+
"#c2410c",
|
|
25506
|
+
"#a16207",
|
|
25507
|
+
"#15803d",
|
|
25508
|
+
"#0f766e",
|
|
25509
|
+
"#2563eb",
|
|
25510
|
+
"#4f46e5",
|
|
25511
|
+
"#737373",
|
|
25512
|
+
"#ef4444",
|
|
25513
|
+
"#f97316",
|
|
25514
|
+
"#eab308",
|
|
25515
|
+
"#22c55e",
|
|
25516
|
+
"#14b8a6",
|
|
25517
|
+
"#3b82f6",
|
|
25518
|
+
"#7c3aed",
|
|
25519
|
+
"#a3a3a3",
|
|
25520
|
+
"#f43f5e",
|
|
25521
|
+
"#f59e0b",
|
|
25522
|
+
"#facc15",
|
|
25523
|
+
"#00e676",
|
|
25524
|
+
"#22d3ee",
|
|
25525
|
+
"#06b6d4",
|
|
25526
|
+
"#be185d",
|
|
25527
|
+
"#bdbdbd",
|
|
25528
|
+
"#f9a8d4",
|
|
25529
|
+
"#fecaca",
|
|
25530
|
+
"#fde68a",
|
|
25531
|
+
"#bbf7d0",
|
|
25532
|
+
"#a7f3d0",
|
|
25533
|
+
"#bae6fd",
|
|
25534
|
+
"#c4b5fd",
|
|
25535
|
+
"#f5f5f5"
|
|
25536
|
+
];
|
|
25537
|
+
var HIGHLIGHT_COLOR_SWATCHES = [
|
|
25538
|
+
"#fef08a",
|
|
25539
|
+
"#fde68a",
|
|
25540
|
+
"#fed7aa",
|
|
25541
|
+
"#fecaca",
|
|
25542
|
+
"#fbcfe8",
|
|
25543
|
+
"#e9d5ff",
|
|
25544
|
+
"#c7d2fe",
|
|
25545
|
+
"#bfdbfe",
|
|
25546
|
+
"#bae6fd",
|
|
25547
|
+
"#ccfbf1",
|
|
25548
|
+
"#bbf7d0",
|
|
25549
|
+
"#d9f99d",
|
|
25550
|
+
"#e5e7eb",
|
|
25551
|
+
"#fca5a5",
|
|
25552
|
+
"#fdba74",
|
|
25553
|
+
"#facc15",
|
|
25554
|
+
"#86efac",
|
|
25555
|
+
"#5eead4",
|
|
25556
|
+
"#7dd3fc",
|
|
25557
|
+
"#a5b4fc",
|
|
25558
|
+
"#d8b4fe",
|
|
25559
|
+
"#f0abfc",
|
|
25560
|
+
"#f9a8d4",
|
|
25561
|
+
"#d4d4d4"
|
|
25562
|
+
];
|
|
25563
|
+
function buildColorOptions(colors, prefix) {
|
|
25564
|
+
return colors.map((color, index) => ({ name: `${prefix} ${index + 1}`, color }));
|
|
25565
|
+
}
|
|
25427
25566
|
var useEditorColors = () => {
|
|
25428
25567
|
const t = useSmartTranslations("UEditor");
|
|
25429
25568
|
const textColors = (0, import_react47.useMemo)(
|
|
@@ -25435,7 +25574,8 @@ var useEditorColors = () => {
|
|
|
25435
25574
|
{ name: t("colors.success"), color: "var(--success)", cssClass: "text-success" },
|
|
25436
25575
|
{ name: t("colors.warning"), color: "var(--warning)", cssClass: "text-warning" },
|
|
25437
25576
|
{ name: t("colors.destructive"), color: "var(--destructive)", cssClass: "text-destructive" },
|
|
25438
|
-
{ name: t("colors.info"), color: "var(--info)", cssClass: "text-info" }
|
|
25577
|
+
{ name: t("colors.info"), color: "var(--info)", cssClass: "text-info" },
|
|
25578
|
+
...buildColorOptions(EDITOR_COLOR_SWATCHES, t("colors.color"))
|
|
25439
25579
|
],
|
|
25440
25580
|
[t]
|
|
25441
25581
|
);
|
|
@@ -25449,7 +25589,8 @@ var useEditorColors = () => {
|
|
|
25449
25589
|
{ name: t("colors.warning"), color: "color-mix(in oklch, var(--warning) 20%, transparent)", cssClass: "bg-warning/20" },
|
|
25450
25590
|
{ name: t("colors.destructive"), color: "color-mix(in oklch, var(--destructive) 20%, transparent)", cssClass: "bg-destructive/20" },
|
|
25451
25591
|
{ name: t("colors.info"), color: "color-mix(in oklch, var(--info) 20%, transparent)", cssClass: "bg-info/20" },
|
|
25452
|
-
{ name: t("colors.accent"), color: "var(--accent)", cssClass: "bg-accent" }
|
|
25592
|
+
{ name: t("colors.accent"), color: "var(--accent)", cssClass: "bg-accent" },
|
|
25593
|
+
...buildColorOptions(HIGHLIGHT_COLOR_SWATCHES, t("colors.color"))
|
|
25453
25594
|
],
|
|
25454
25595
|
[t]
|
|
25455
25596
|
);
|
|
@@ -25460,26 +25601,81 @@ var EditorColorPalette = ({
|
|
|
25460
25601
|
currentColor,
|
|
25461
25602
|
onSelect,
|
|
25462
25603
|
label
|
|
25463
|
-
}) =>
|
|
25464
|
-
|
|
25465
|
-
|
|
25466
|
-
|
|
25467
|
-
|
|
25468
|
-
|
|
25469
|
-
|
|
25470
|
-
|
|
25471
|
-
|
|
25472
|
-
|
|
25473
|
-
|
|
25474
|
-
|
|
25475
|
-
|
|
25476
|
-
|
|
25477
|
-
|
|
25478
|
-
|
|
25479
|
-
|
|
25480
|
-
|
|
25481
|
-
|
|
25482
|
-
|
|
25604
|
+
}) => {
|
|
25605
|
+
const t = useSmartTranslations("UEditor");
|
|
25606
|
+
const colorInputRef = (0, import_react47.useRef)(null);
|
|
25607
|
+
const automaticColor = colors[0]?.color ?? "";
|
|
25608
|
+
const paletteColors = colors.slice(1);
|
|
25609
|
+
return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)("div", { className: "w-56 p-2", children: [
|
|
25610
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: label }),
|
|
25611
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
|
|
25612
|
+
"button",
|
|
25613
|
+
{
|
|
25614
|
+
type: "button",
|
|
25615
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
25616
|
+
onClick: () => onSelect(automaticColor),
|
|
25617
|
+
className: cn(
|
|
25618
|
+
"mt-2 flex h-9 w-full items-center gap-3 rounded-md border px-2 text-sm transition-colors",
|
|
25619
|
+
"bg-muted/50 hover:bg-muted",
|
|
25620
|
+
currentColor === automaticColor ? "border-primary text-primary" : "border-transparent text-foreground"
|
|
25621
|
+
),
|
|
25622
|
+
children: [
|
|
25623
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "flex h-5 w-5 items-center justify-center rounded border border-border bg-background", children: currentColor === automaticColor && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_lucide_react42.Check, { className: "h-3.5 w-3.5" }) }),
|
|
25624
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "flex-1 text-center", children: t("colors.automatic") })
|
|
25625
|
+
]
|
|
25626
|
+
}
|
|
25627
|
+
),
|
|
25628
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("div", { className: "mt-2 grid grid-cols-8 gap-1", children: paletteColors.map((c) => /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Tooltip, { placement: "top", content: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "text-xs font-medium", children: c.name }), children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
25629
|
+
"button",
|
|
25630
|
+
{
|
|
25631
|
+
type: "button",
|
|
25632
|
+
"aria-label": c.name,
|
|
25633
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
25634
|
+
onClick: () => onSelect(c.color),
|
|
25635
|
+
className: cn(
|
|
25636
|
+
"relative h-5 w-5 rounded-[3px] border transition-transform hover:scale-110",
|
|
25637
|
+
currentColor === c.color ? "border-primary ring-2 ring-primary/25" : "border-border/70"
|
|
25638
|
+
),
|
|
25639
|
+
style: { backgroundColor: c.color || "transparent" },
|
|
25640
|
+
children: currentColor === c.color && /* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_lucide_react42.Check, { className: "h-3.5 w-3.5 text-white drop-shadow-[0_1px_1px_rgba(0,0,0,0.8)]" }) })
|
|
25641
|
+
}
|
|
25642
|
+
) }, `${c.name}-${c.color}`)) }),
|
|
25643
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(
|
|
25644
|
+
"button",
|
|
25645
|
+
{
|
|
25646
|
+
type: "button",
|
|
25647
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
25648
|
+
onClick: () => colorInputRef.current?.click(),
|
|
25649
|
+
className: "mt-3 flex h-9 w-full items-center gap-3 rounded-md px-2 text-sm text-foreground transition-colors hover:bg-muted",
|
|
25650
|
+
children: [
|
|
25651
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
25652
|
+
"span",
|
|
25653
|
+
{
|
|
25654
|
+
"aria-hidden": "true",
|
|
25655
|
+
className: "h-5 w-5 rounded border border-border",
|
|
25656
|
+
style: {
|
|
25657
|
+
background: "linear-gradient(135deg, #ff004c 0%, #fffb00 22%, #00ff66 42%, #00d5ff 62%, #2446ff 78%, #ff00d4 100%)"
|
|
25658
|
+
}
|
|
25659
|
+
}
|
|
25660
|
+
),
|
|
25661
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)("span", { className: "flex-1 text-center", children: t("colors.moreColors") }),
|
|
25662
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_lucide_react42.Palette, { className: "h-4 w-4 text-muted-foreground" }),
|
|
25663
|
+
/* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
|
|
25664
|
+
"input",
|
|
25665
|
+
{
|
|
25666
|
+
ref: colorInputRef,
|
|
25667
|
+
type: "color",
|
|
25668
|
+
value: currentColor.startsWith("#") ? currentColor : "#000000",
|
|
25669
|
+
onChange: (event) => onSelect(event.target.value),
|
|
25670
|
+
className: "sr-only",
|
|
25671
|
+
tabIndex: -1
|
|
25672
|
+
}
|
|
25673
|
+
)
|
|
25674
|
+
]
|
|
25675
|
+
}
|
|
25676
|
+
)
|
|
25677
|
+
] });
|
|
25678
|
+
};
|
|
25483
25679
|
|
|
25484
25680
|
// src/components/UEditor/image-commands.ts
|
|
25485
25681
|
var import_state4 = require("@tiptap/pm/state");
|
|
@@ -25691,12 +25887,23 @@ function getDefaultFontFamilies(t) {
|
|
|
25691
25887
|
}
|
|
25692
25888
|
function getDefaultFontSizes() {
|
|
25693
25889
|
return [
|
|
25890
|
+
{ label: "8", value: "8px" },
|
|
25891
|
+
{ label: "9", value: "9px" },
|
|
25892
|
+
{ label: "10", value: "10px" },
|
|
25893
|
+
{ label: "11", value: "11px" },
|
|
25694
25894
|
{ label: "12", value: "12px" },
|
|
25695
25895
|
{ label: "14", value: "14px" },
|
|
25696
25896
|
{ label: "16", value: "16px" },
|
|
25697
25897
|
{ label: "18", value: "18px" },
|
|
25898
|
+
{ label: "20", value: "20px" },
|
|
25899
|
+
{ label: "22", value: "22px" },
|
|
25698
25900
|
{ label: "24", value: "24px" },
|
|
25699
|
-
{ label: "
|
|
25901
|
+
{ label: "26", value: "26px" },
|
|
25902
|
+
{ label: "28", value: "28px" },
|
|
25903
|
+
{ label: "36", value: "36px" },
|
|
25904
|
+
{ label: "48", value: "48px" },
|
|
25905
|
+
{ label: "72", value: "72px" },
|
|
25906
|
+
{ label: "96", value: "96px" }
|
|
25700
25907
|
];
|
|
25701
25908
|
}
|
|
25702
25909
|
function getDefaultLineHeights() {
|
|
@@ -25744,10 +25951,11 @@ var ToolbarButton = import_react49.default.forwardRef(({ onClick, onMouseDown, a
|
|
|
25744
25951
|
onClick,
|
|
25745
25952
|
disabled,
|
|
25746
25953
|
className: cn(
|
|
25747
|
-
"flex items-center justify-center w-8 h-8 rounded-
|
|
25748
|
-
"
|
|
25954
|
+
"flex items-center justify-center w-8 h-8 rounded-md transition-colors duration-150",
|
|
25955
|
+
"gap-0.5 [&_svg+svg]:-ml-1",
|
|
25956
|
+
"hover:bg-accent",
|
|
25749
25957
|
"focus:outline-none focus:ring-2 focus:ring-primary/20",
|
|
25750
|
-
"disabled:opacity-40 disabled:cursor-not-allowed
|
|
25958
|
+
"disabled:opacity-40 disabled:cursor-not-allowed",
|
|
25751
25959
|
active ? "bg-primary/10 text-primary shadow-sm" : "text-muted-foreground hover:text-foreground",
|
|
25752
25960
|
className
|
|
25753
25961
|
),
|
|
@@ -25760,7 +25968,7 @@ var ToolbarButton = import_react49.default.forwardRef(({ onClick, onMouseDown, a
|
|
|
25760
25968
|
return button;
|
|
25761
25969
|
});
|
|
25762
25970
|
ToolbarButton.displayName = "ToolbarButton";
|
|
25763
|
-
var ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "
|
|
25971
|
+
var ToolbarDivider = () => /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border/60" });
|
|
25764
25972
|
var TableInsertGrid = ({
|
|
25765
25973
|
insertLabel,
|
|
25766
25974
|
previewTemplate,
|
|
@@ -25771,39 +25979,32 @@ var TableInsertGrid = ({
|
|
|
25771
25979
|
const maxCols = 8;
|
|
25772
25980
|
return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "mb-2 rounded-xl border border-border/60 bg-muted/20 p-2", children: [
|
|
25773
25981
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "mb-2 text-sm font-medium text-foreground", children: formatTableInsertLabel(previewTemplate, selection.rows, selection.cols) }),
|
|
25774
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25775
|
-
|
|
25776
|
-
|
|
25777
|
-
|
|
25778
|
-
|
|
25779
|
-
|
|
25780
|
-
|
|
25781
|
-
|
|
25782
|
-
|
|
25783
|
-
|
|
25784
|
-
|
|
25785
|
-
|
|
25786
|
-
|
|
25787
|
-
|
|
25788
|
-
|
|
25789
|
-
|
|
25790
|
-
|
|
25791
|
-
|
|
25792
|
-
|
|
25793
|
-
|
|
25794
|
-
|
|
25795
|
-
|
|
25796
|
-
|
|
25797
|
-
|
|
25798
|
-
|
|
25799
|
-
|
|
25800
|
-
})
|
|
25801
|
-
)
|
|
25802
|
-
}
|
|
25803
|
-
),
|
|
25804
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "mt-2 text-xs text-muted-foreground", children: insertLabel })
|
|
25805
|
-
] });
|
|
25806
|
-
};
|
|
25982
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "grid grid-cols-8 gap-1", onMouseLeave: () => setSelection((prev) => prev), children: Array.from({ length: maxRows }).map(
|
|
25983
|
+
(_, rowIndex) => Array.from({ length: maxCols }).map((__, colIndex) => {
|
|
25984
|
+
const rows = rowIndex + 1;
|
|
25985
|
+
const cols = colIndex + 1;
|
|
25986
|
+
const active = rows <= selection.rows && cols <= selection.cols;
|
|
25987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25988
|
+
"button",
|
|
25989
|
+
{
|
|
25990
|
+
type: "button",
|
|
25991
|
+
"aria-label": formatTableInsertLabel(previewTemplate, rows, cols),
|
|
25992
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
25993
|
+
onMouseEnter: () => setSelection({ rows, cols }),
|
|
25994
|
+
onFocus: () => setSelection({ rows, cols }),
|
|
25995
|
+
onClick: () => onInsert(rows, cols),
|
|
25996
|
+
className: cn(
|
|
25997
|
+
"h-5 w-5 rounded-sm border transition-colors",
|
|
25998
|
+
active ? "border-primary bg-primary/20" : "border-border/70 bg-background hover:border-primary/60 hover:bg-primary/10"
|
|
25999
|
+
)
|
|
26000
|
+
},
|
|
26001
|
+
`${rows}-${cols}`
|
|
26002
|
+
);
|
|
26003
|
+
})
|
|
26004
|
+
) }),
|
|
26005
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "mt-2 text-xs text-muted-foreground", children: insertLabel })
|
|
26006
|
+
] });
|
|
26007
|
+
};
|
|
25807
26008
|
var EditorToolbar = ({
|
|
25808
26009
|
editor,
|
|
25809
26010
|
variant,
|
|
@@ -25817,14 +26018,23 @@ var EditorToolbar = ({
|
|
|
25817
26018
|
letterSpacings
|
|
25818
26019
|
}) => {
|
|
25819
26020
|
const t = useSmartTranslations("UEditor");
|
|
26021
|
+
(0, import_react50.useEditorState)({
|
|
26022
|
+
editor,
|
|
26023
|
+
selector: ({ transactionNumber }) => transactionNumber
|
|
26024
|
+
});
|
|
25820
26025
|
const { textColors, highlightColors } = useEditorColors();
|
|
25821
26026
|
const [showImageInput, setShowImageInput] = (0, import_react49.useState)(false);
|
|
26027
|
+
const [showLinkInput, setShowLinkInput] = (0, import_react49.useState)(false);
|
|
25822
26028
|
const [isTableMenuOpen, setIsTableMenuOpen] = (0, import_react49.useState)(false);
|
|
25823
26029
|
const tableCommandAnchorPosRef = (0, import_react49.useRef)(null);
|
|
25824
26030
|
const fileInputRef = (0, import_react49.useRef)(null);
|
|
25825
26031
|
const [isUploadingImage, setIsUploadingImage] = (0, import_react49.useState)(false);
|
|
25826
26032
|
const [imageUploadError, setImageUploadError] = (0, import_react49.useState)(null);
|
|
25827
26033
|
const [fontSizeDraft, setFontSizeDraft] = (0, import_react49.useState)("");
|
|
26034
|
+
const [isFontSizeMenuOpen, setIsFontSizeMenuOpen] = (0, import_react49.useState)(false);
|
|
26035
|
+
const [fontSizeMenuPosition, setFontSizeMenuPosition] = (0, import_react49.useState)({ top: 0, left: 0 });
|
|
26036
|
+
const fontSizeControlRef = (0, import_react49.useRef)(null);
|
|
26037
|
+
const fontSizeMenuRef = (0, import_react49.useRef)(null);
|
|
25828
26038
|
const isImageSelected = editor.isActive("image");
|
|
25829
26039
|
const imageAttrs = editor.getAttributes("image");
|
|
25830
26040
|
const tableAttrs = editor.getAttributes("table");
|
|
@@ -25836,30 +26046,23 @@ var EditorToolbar = ({
|
|
|
25836
26046
|
const hasTableContext = isTableSelected || tableCommandAnchorPosRef.current !== null;
|
|
25837
26047
|
const currentFontFamily = normalizeStyleValue(textStyleAttrs.fontFamily);
|
|
25838
26048
|
const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
|
|
26049
|
+
const currentTextColor = normalizeStyleValue(textStyleAttrs.color) || "inherit";
|
|
26050
|
+
const currentHighlightColor = normalizeStyleValue(editor.getAttributes("highlight").color) || "";
|
|
25839
26051
|
const currentLineHeight = normalizeStyleValue(textStyleAttrs.lineHeight);
|
|
25840
26052
|
const currentLetterSpacing = normalizeStyleValue(textStyleAttrs.letterSpacing);
|
|
25841
|
-
const availableFontFamilies = import_react49.default.useMemo(
|
|
25842
|
-
|
|
25843
|
-
|
|
25844
|
-
);
|
|
25845
|
-
const
|
|
25846
|
-
|
|
25847
|
-
[fontSizes]
|
|
25848
|
-
);
|
|
25849
|
-
const availableLineHeights = import_react49.default.useMemo(
|
|
25850
|
-
() => lineHeights ?? getDefaultLineHeights(),
|
|
25851
|
-
[lineHeights]
|
|
25852
|
-
);
|
|
25853
|
-
const availableLetterSpacings = import_react49.default.useMemo(
|
|
25854
|
-
() => letterSpacings ?? getDefaultLetterSpacings(),
|
|
25855
|
-
[letterSpacings]
|
|
25856
|
-
);
|
|
25857
|
-
const currentFontFamilyLabel = availableFontFamilies.find((option) => normalizeStyleValue(option.value) === currentFontFamily)?.label ?? t("toolbar.fontDefault");
|
|
26053
|
+
const availableFontFamilies = import_react49.default.useMemo(() => fontFamilies ?? getDefaultFontFamilies(t), [fontFamilies, t]);
|
|
26054
|
+
const availableFontSizes = import_react49.default.useMemo(() => fontSizes ?? getDefaultFontSizes(), [fontSizes]);
|
|
26055
|
+
const availableLineHeights = import_react49.default.useMemo(() => lineHeights ?? getDefaultLineHeights(), [lineHeights]);
|
|
26056
|
+
const availableLetterSpacings = import_react49.default.useMemo(() => letterSpacings ?? getDefaultLetterSpacings(), [letterSpacings]);
|
|
26057
|
+
const currentFontFamilyDisplayValue = currentFontFamily.split(",")[0]?.trim() ?? currentFontFamily;
|
|
26058
|
+
const currentFontFamilyLabel = availableFontFamilies.find((option) => normalizeStyleValue(option.value) === currentFontFamily)?.label ?? (currentFontFamilyDisplayValue || t("toolbar.fontDefault"));
|
|
25858
26059
|
const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ?? t("toolbar.sizeDefault");
|
|
25859
26060
|
const currentLineHeightLabel = availableLineHeights.find((option) => normalizeStyleValue(option.value) === currentLineHeight)?.label ?? t("toolbar.lineHeightDefault");
|
|
25860
26061
|
const currentLetterSpacingLabel = availableLetterSpacings.find((option) => normalizeStyleValue(option.value) === currentLetterSpacing)?.label ?? t("toolbar.letterSpacingDefault");
|
|
26062
|
+
const displayedFontFamilyLabel = currentFontFamily ? currentFontFamilyLabel : availableFontFamilies[0]?.label ?? t("toolbar.fontDefault");
|
|
25861
26063
|
import_react49.default.useEffect(() => {
|
|
25862
|
-
|
|
26064
|
+
if (document.activeElement === fontSizeControlRef.current?.querySelector("input")) return;
|
|
26065
|
+
setFontSizeDraft(currentFontSize.replace(/px$/i, "") || "16");
|
|
25863
26066
|
}, [currentFontSize]);
|
|
25864
26067
|
const applyFontSizeDraft = () => {
|
|
25865
26068
|
const normalized = fontSizeDraft.trim();
|
|
@@ -25871,7 +26074,39 @@ var EditorToolbar = ({
|
|
|
25871
26074
|
if (!Number.isFinite(parsed) || parsed <= 0) return;
|
|
25872
26075
|
const clamped = Math.min(96, Math.max(8, parsed));
|
|
25873
26076
|
editor.chain().focus().setFontSize(`${clamped}px`).run();
|
|
26077
|
+
setFontSizeDraft(String(clamped));
|
|
26078
|
+
};
|
|
26079
|
+
const updateFontSizeMenuPosition = import_react49.default.useCallback(() => {
|
|
26080
|
+
const rect = fontSizeControlRef.current?.getBoundingClientRect();
|
|
26081
|
+
if (!rect) return;
|
|
26082
|
+
setFontSizeMenuPosition({
|
|
26083
|
+
top: Math.round(rect.bottom + 4),
|
|
26084
|
+
left: Math.round(rect.left)
|
|
26085
|
+
});
|
|
26086
|
+
}, []);
|
|
26087
|
+
const toggleFontSizeMenu = () => {
|
|
26088
|
+
updateFontSizeMenuPosition();
|
|
26089
|
+
setIsFontSizeMenuOpen((open) => !open);
|
|
25874
26090
|
};
|
|
26091
|
+
import_react49.default.useEffect(() => {
|
|
26092
|
+
if (!isFontSizeMenuOpen) return;
|
|
26093
|
+
updateFontSizeMenuPosition();
|
|
26094
|
+
const handlePointerDown = (event) => {
|
|
26095
|
+
const target = event.target;
|
|
26096
|
+
if (fontSizeControlRef.current?.contains(target)) return;
|
|
26097
|
+
if (fontSizeMenuRef.current?.contains(target)) return;
|
|
26098
|
+
setIsFontSizeMenuOpen(false);
|
|
26099
|
+
};
|
|
26100
|
+
const handleLayoutChange = () => updateFontSizeMenuPosition();
|
|
26101
|
+
document.addEventListener("mousedown", handlePointerDown);
|
|
26102
|
+
window.addEventListener("resize", handleLayoutChange);
|
|
26103
|
+
window.addEventListener("scroll", handleLayoutChange, true);
|
|
26104
|
+
return () => {
|
|
26105
|
+
document.removeEventListener("mousedown", handlePointerDown);
|
|
26106
|
+
window.removeEventListener("resize", handleLayoutChange);
|
|
26107
|
+
window.removeEventListener("scroll", handleLayoutChange, true);
|
|
26108
|
+
};
|
|
26109
|
+
}, [isFontSizeMenuOpen, updateFontSizeMenuPosition]);
|
|
25875
26110
|
const insertImageFiles = async (files) => {
|
|
25876
26111
|
if (files.length === 0) return;
|
|
25877
26112
|
setIsUploadingImage(true);
|
|
@@ -25893,7 +26128,7 @@ var EditorToolbar = ({
|
|
|
25893
26128
|
setIsUploadingImage(false);
|
|
25894
26129
|
};
|
|
25895
26130
|
if (variant === "minimal") {
|
|
25896
|
-
return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-1
|
|
26131
|
+
return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-1 border-b border-border/35 bg-muted/30 p-2", children: [
|
|
25897
26132
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Bold, { className: "w-4 h-4" }) }),
|
|
25898
26133
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive("italic"), title: t("toolbar.italic"), children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Italic, { className: "w-4 h-4" }) }),
|
|
25899
26134
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
@@ -25907,70 +26142,23 @@ var EditorToolbar = ({
|
|
|
25907
26142
|
)
|
|
25908
26143
|
] });
|
|
25909
26144
|
}
|
|
25910
|
-
return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex flex-wrap items-center gap-
|
|
25911
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
25912
|
-
DropdownMenu,
|
|
25913
|
-
{
|
|
25914
|
-
contentClassName: "p-2",
|
|
25915
|
-
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(ToolbarButton, { onClick: () => {
|
|
25916
|
-
}, title: t("toolbar.textStyle"), className: "px-2 w-auto gap-1", children: [
|
|
25917
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Type, { className: "w-4 h-4" }),
|
|
25918
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ChevronDown, { className: "w-3 h-3" })
|
|
25919
|
-
] }),
|
|
25920
|
-
children: [
|
|
25921
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25922
|
-
DropdownMenuItem,
|
|
25923
|
-
{
|
|
25924
|
-
icon: import_lucide_react44.Type,
|
|
25925
|
-
label: t("toolbar.normal"),
|
|
25926
|
-
onClick: () => editor.chain().focus().setParagraph().run(),
|
|
25927
|
-
active: editor.isActive("paragraph")
|
|
25928
|
-
}
|
|
25929
|
-
),
|
|
25930
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25931
|
-
DropdownMenuItem,
|
|
25932
|
-
{
|
|
25933
|
-
icon: import_lucide_react44.Heading1,
|
|
25934
|
-
label: t("toolbar.heading1"),
|
|
25935
|
-
onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
25936
|
-
active: editor.isActive("heading", { level: 1 }),
|
|
25937
|
-
shortcut: "Ctrl+Alt+1"
|
|
25938
|
-
}
|
|
25939
|
-
),
|
|
25940
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25941
|
-
DropdownMenuItem,
|
|
25942
|
-
{
|
|
25943
|
-
icon: import_lucide_react44.Heading2,
|
|
25944
|
-
label: t("toolbar.heading2"),
|
|
25945
|
-
onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
25946
|
-
active: editor.isActive("heading", { level: 2 }),
|
|
25947
|
-
shortcut: "Ctrl+Alt+2"
|
|
25948
|
-
}
|
|
25949
|
-
),
|
|
25950
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
25951
|
-
DropdownMenuItem,
|
|
25952
|
-
{
|
|
25953
|
-
icon: import_lucide_react44.Heading3,
|
|
25954
|
-
label: t("toolbar.heading3"),
|
|
25955
|
-
onClick: () => editor.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
25956
|
-
active: editor.isActive("heading", { level: 3 }),
|
|
25957
|
-
shortcut: "Ctrl+Alt+3"
|
|
25958
|
-
}
|
|
25959
|
-
)
|
|
25960
|
-
]
|
|
25961
|
-
}
|
|
25962
|
-
),
|
|
26145
|
+
return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex flex-wrap items-center gap-0.5 border-b border-border/35 bg-linear-to-r from-muted/25 to-transparent p-1.5", children: [
|
|
25963
26146
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
25964
26147
|
DropdownMenu,
|
|
25965
26148
|
{
|
|
25966
|
-
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.
|
|
25967
|
-
|
|
26149
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
26150
|
+
"button",
|
|
25968
26151
|
{
|
|
25969
|
-
|
|
25970
|
-
|
|
25971
|
-
|
|
25972
|
-
|
|
25973
|
-
|
|
26152
|
+
type: "button",
|
|
26153
|
+
"aria-label": t("toolbar.fontFamily"),
|
|
26154
|
+
className: cn(
|
|
26155
|
+
"flex h-8 min-w-34 max-w-42 items-center justify-between gap-2 rounded-full border border-border/60 bg-muted/30 px-2.5 text-xs text-foreground",
|
|
26156
|
+
"transition-colors hover:bg-accent focus:outline-none focus:ring-2 focus:ring-primary/20"
|
|
26157
|
+
),
|
|
26158
|
+
children: [
|
|
26159
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "truncate", children: displayedFontFamilyLabel }),
|
|
26160
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ChevronDown, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" })
|
|
26161
|
+
]
|
|
25974
26162
|
}
|
|
25975
26163
|
),
|
|
25976
26164
|
contentClassName: "max-h-80 overflow-y-auto min-w-56 p-2",
|
|
@@ -25990,30 +26178,24 @@ var EditorToolbar = ({
|
|
|
25990
26178
|
label: option.label,
|
|
25991
26179
|
onClick: () => editor.chain().focus().setFontFamily(option.value).run(),
|
|
25992
26180
|
active: normalizeStyleValue(option.value) === currentFontFamily,
|
|
25993
|
-
className: "font-medium"
|
|
26181
|
+
className: "font-medium "
|
|
25994
26182
|
},
|
|
25995
26183
|
option.value
|
|
25996
26184
|
))
|
|
25997
26185
|
]
|
|
25998
26186
|
}
|
|
25999
26187
|
),
|
|
26000
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
26001
|
-
|
|
26002
|
-
|
|
26003
|
-
|
|
26004
|
-
|
|
26005
|
-
|
|
26006
|
-
|
|
26007
|
-
|
|
26008
|
-
|
|
26009
|
-
|
|
26010
|
-
|
|
26011
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-[10px] font-semibold leading-none", children: currentFontSize.replace(/px$/i, "") || "T" })
|
|
26012
|
-
}
|
|
26013
|
-
),
|
|
26014
|
-
contentClassName: "max-h-80 overflow-y-auto min-w-44 p-2",
|
|
26015
|
-
children: [
|
|
26016
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "mb-2 rounded-lg border border-border/60 bg-muted/30 p-2", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("label", { className: "flex items-center gap-2", children: [
|
|
26188
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
|
|
26189
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
26190
|
+
"div",
|
|
26191
|
+
{
|
|
26192
|
+
ref: fontSizeControlRef,
|
|
26193
|
+
"aria-label": t("toolbar.fontSize"),
|
|
26194
|
+
className: cn(
|
|
26195
|
+
"flex h-8 min-w-16 items-center overflow-hidden rounded-full border border-border/60 bg-muted/30 text-xs font-semibold text-foreground",
|
|
26196
|
+
"transition-colors focus-within:ring-2 focus-within:ring-primary/20"
|
|
26197
|
+
),
|
|
26198
|
+
children: [
|
|
26017
26199
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26018
26200
|
"input",
|
|
26019
26201
|
{
|
|
@@ -26023,6 +26205,7 @@ var EditorToolbar = ({
|
|
|
26023
26205
|
step: 1,
|
|
26024
26206
|
value: fontSizeDraft,
|
|
26025
26207
|
onChange: (e) => setFontSizeDraft(e.target.value),
|
|
26208
|
+
onBlur: applyFontSizeDraft,
|
|
26026
26209
|
onMouseDown: (e) => e.stopPropagation(),
|
|
26027
26210
|
onClick: (e) => e.stopPropagation(),
|
|
26028
26211
|
onKeyDown: (e) => {
|
|
@@ -26033,48 +26216,116 @@ var EditorToolbar = ({
|
|
|
26033
26216
|
}
|
|
26034
26217
|
},
|
|
26035
26218
|
"aria-label": t("toolbar.fontSize"),
|
|
26036
|
-
className: "h-
|
|
26219
|
+
className: "h-full w-10 bg-transparent px-1 text-center text-xs font-semibold outline-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
|
26037
26220
|
}
|
|
26038
26221
|
),
|
|
26039
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26040
|
-
|
|
26222
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26223
|
+
"button",
|
|
26224
|
+
{
|
|
26225
|
+
type: "button",
|
|
26226
|
+
"aria-label": t("toolbar.fontSize"),
|
|
26227
|
+
"aria-expanded": isFontSizeMenuOpen,
|
|
26228
|
+
onClick: toggleFontSizeMenu,
|
|
26229
|
+
className: "flex h-full w-7 items-center justify-center border-l border-border/50 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
|
|
26230
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ChevronDown, { className: "h-3.5 w-3.5" })
|
|
26231
|
+
}
|
|
26232
|
+
)
|
|
26233
|
+
]
|
|
26234
|
+
}
|
|
26235
|
+
),
|
|
26236
|
+
isFontSizeMenuOpen && typeof document !== "undefined" && (0, import_react_dom8.createPortal)(
|
|
26237
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26238
|
+
"div",
|
|
26239
|
+
{
|
|
26240
|
+
ref: fontSizeMenuRef,
|
|
26241
|
+
className: "fixed z-[10000] max-h-64 w-12 overflow-y-auto rounded-md border border-border/70 bg-popover p-0.5 text-popover-foreground shadow-md",
|
|
26242
|
+
style: { top: fontSizeMenuPosition.top, left: fontSizeMenuPosition.left },
|
|
26243
|
+
children: availableFontSizes.map((option) => {
|
|
26244
|
+
const active = normalizeStyleValue(option.value) === currentFontSize;
|
|
26245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26246
|
+
"button",
|
|
26247
|
+
{
|
|
26248
|
+
type: "button",
|
|
26249
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
26250
|
+
onClick: () => {
|
|
26251
|
+
editor.chain().focus().setFontSize(option.value).run();
|
|
26252
|
+
setFontSizeDraft(option.label);
|
|
26253
|
+
setIsFontSizeMenuOpen(false);
|
|
26254
|
+
},
|
|
26255
|
+
className: cn(
|
|
26256
|
+
"flex h-6 w-full items-center justify-center rounded text-xs leading-none transition-colors",
|
|
26257
|
+
active ? "bg-primary/15 text-primary" : "text-foreground hover:bg-accent hover:text-accent-foreground"
|
|
26258
|
+
),
|
|
26259
|
+
children: option.label
|
|
26260
|
+
},
|
|
26261
|
+
option.value
|
|
26262
|
+
);
|
|
26263
|
+
})
|
|
26264
|
+
}
|
|
26265
|
+
),
|
|
26266
|
+
document.body
|
|
26267
|
+
)
|
|
26268
|
+
] }),
|
|
26269
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
26270
|
+
DropdownMenu,
|
|
26271
|
+
{
|
|
26272
|
+
contentClassName: "p-2",
|
|
26273
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(ToolbarButton, { onClick: () => {
|
|
26274
|
+
}, title: t("toolbar.textStyle"), className: "px-2 w-auto gap-1", children: [
|
|
26275
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Type, { className: "w-4 h-4" }),
|
|
26276
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ChevronDown, { className: "w-3 h-3" })
|
|
26277
|
+
] }),
|
|
26278
|
+
children: [
|
|
26041
26279
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26042
26280
|
DropdownMenuItem,
|
|
26043
26281
|
{
|
|
26044
26282
|
icon: import_lucide_react44.Type,
|
|
26045
|
-
label: t("toolbar.
|
|
26046
|
-
onClick: () => editor.chain().focus().
|
|
26047
|
-
active:
|
|
26283
|
+
label: t("toolbar.normal"),
|
|
26284
|
+
onClick: () => editor.chain().focus().setParagraph().run(),
|
|
26285
|
+
active: editor.isActive("paragraph")
|
|
26048
26286
|
}
|
|
26049
26287
|
),
|
|
26050
|
-
|
|
26288
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26051
26289
|
DropdownMenuItem,
|
|
26052
26290
|
{
|
|
26053
|
-
|
|
26054
|
-
|
|
26055
|
-
|
|
26056
|
-
|
|
26057
|
-
|
|
26058
|
-
|
|
26291
|
+
icon: import_lucide_react44.Heading1,
|
|
26292
|
+
label: t("toolbar.heading1"),
|
|
26293
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
26294
|
+
active: editor.isActive("heading", { level: 1 }),
|
|
26295
|
+
shortcut: "Ctrl+Alt+1"
|
|
26296
|
+
}
|
|
26297
|
+
),
|
|
26298
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26299
|
+
DropdownMenuItem,
|
|
26300
|
+
{
|
|
26301
|
+
icon: import_lucide_react44.Heading2,
|
|
26302
|
+
label: t("toolbar.heading2"),
|
|
26303
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
26304
|
+
active: editor.isActive("heading", { level: 2 }),
|
|
26305
|
+
shortcut: "Ctrl+Alt+2"
|
|
26306
|
+
}
|
|
26307
|
+
),
|
|
26308
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26309
|
+
DropdownMenuItem,
|
|
26310
|
+
{
|
|
26311
|
+
icon: import_lucide_react44.Heading3,
|
|
26312
|
+
label: t("toolbar.heading3"),
|
|
26313
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
26314
|
+
active: editor.isActive("heading", { level: 3 }),
|
|
26315
|
+
shortcut: "Ctrl+Alt+3"
|
|
26316
|
+
}
|
|
26317
|
+
)
|
|
26059
26318
|
]
|
|
26060
26319
|
}
|
|
26061
26320
|
),
|
|
26062
26321
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
26063
26322
|
DropdownMenu,
|
|
26064
26323
|
{
|
|
26065
|
-
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
26066
|
-
|
|
26067
|
-
{
|
|
26068
|
-
|
|
26069
|
-
|
|
26070
|
-
title: t("toolbar.lineHeight"),
|
|
26071
|
-
className: "gap-0.5",
|
|
26072
|
-
children: [
|
|
26073
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ArrowUp, { className: "w-3 h-3" }),
|
|
26074
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ArrowDown, { className: "w-3 h-3" })
|
|
26075
|
-
]
|
|
26076
|
-
}
|
|
26077
|
-
),
|
|
26324
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(ToolbarButton, { onClick: () => {
|
|
26325
|
+
}, title: t("toolbar.lineHeight"), className: "gap-0.5", children: [
|
|
26326
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ArrowUp, { className: "w-3 h-3" }),
|
|
26327
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ArrowDown, { className: "w-3 h-3" })
|
|
26328
|
+
] }),
|
|
26078
26329
|
contentClassName: "max-h-72 overflow-y-auto p-2",
|
|
26079
26330
|
children: [
|
|
26080
26331
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
@@ -26101,19 +26352,11 @@ var EditorToolbar = ({
|
|
|
26101
26352
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
26102
26353
|
DropdownMenu,
|
|
26103
26354
|
{
|
|
26104
|
-
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(
|
|
26105
|
-
|
|
26106
|
-
{
|
|
26107
|
-
|
|
26108
|
-
|
|
26109
|
-
title: t("toolbar.letterSpacing"),
|
|
26110
|
-
className: "gap-0.5",
|
|
26111
|
-
children: [
|
|
26112
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ArrowLeft, { className: "w-3 h-3" }),
|
|
26113
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ArrowRight, { className: "w-3 h-3" })
|
|
26114
|
-
]
|
|
26115
|
-
}
|
|
26116
|
-
),
|
|
26355
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(ToolbarButton, { onClick: () => {
|
|
26356
|
+
}, title: t("toolbar.letterSpacing"), className: "gap-0.5", children: [
|
|
26357
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ArrowLeft, { className: "w-3 h-3" }),
|
|
26358
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ArrowRight, { className: "w-3 h-3" })
|
|
26359
|
+
] }),
|
|
26117
26360
|
contentClassName: "max-h-72 overflow-y-auto p-2",
|
|
26118
26361
|
children: [
|
|
26119
26362
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
@@ -26151,20 +26394,68 @@ var EditorToolbar = ({
|
|
|
26151
26394
|
),
|
|
26152
26395
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleStrike().run(), active: editor.isActive("strike"), title: t("toolbar.strike"), children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Strikethrough, { className: "w-4 h-4" }) }),
|
|
26153
26396
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleCode().run(), active: editor.isActive("code"), title: t("toolbar.code"), children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Code, { className: "w-4 h-4" }) }),
|
|
26397
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26398
|
+
ToolbarButton,
|
|
26399
|
+
{
|
|
26400
|
+
onClick: () => editor.chain().focus().toggleSubscript().run(),
|
|
26401
|
+
active: editor.isActive("subscript"),
|
|
26402
|
+
title: t("toolbar.subscript"),
|
|
26403
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Subscript, { className: "w-4 h-4" })
|
|
26404
|
+
}
|
|
26405
|
+
),
|
|
26406
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26407
|
+
ToolbarButton,
|
|
26408
|
+
{
|
|
26409
|
+
onClick: () => editor.chain().focus().toggleSuperscript().run(),
|
|
26410
|
+
active: editor.isActive("superscript"),
|
|
26411
|
+
title: t("toolbar.superscript"),
|
|
26412
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Superscript, { className: "w-4 h-4" })
|
|
26413
|
+
}
|
|
26414
|
+
),
|
|
26415
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26416
|
+
DropdownMenu,
|
|
26417
|
+
{
|
|
26418
|
+
contentClassName: "min-w-72",
|
|
26419
|
+
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarButton, { onClick: () => setShowLinkInput(!editor.isActive("link")), active: editor.isActive("link"), title: t("toolbar.link"), children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Link, { className: "w-4 h-4" }) }),
|
|
26420
|
+
children: showLinkInput ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26421
|
+
LinkInput,
|
|
26422
|
+
{
|
|
26423
|
+
initialUrl: String(editor.getAttributes("link").href ?? ""),
|
|
26424
|
+
onSubmit: (url) => {
|
|
26425
|
+
editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
26426
|
+
setShowLinkInput(false);
|
|
26427
|
+
},
|
|
26428
|
+
onCancel: () => setShowLinkInput(false)
|
|
26429
|
+
}
|
|
26430
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
|
|
26431
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(DropdownMenuItem, { icon: import_lucide_react44.Link, label: t("toolbar.link"), onClick: () => setShowLinkInput(true), active: editor.isActive("link") }),
|
|
26432
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26433
|
+
DropdownMenuItem,
|
|
26434
|
+
{
|
|
26435
|
+
icon: import_lucide_react44.Trash2,
|
|
26436
|
+
label: t("toolbar.removeLink"),
|
|
26437
|
+
onClick: () => editor.chain().focus().extendMarkRange("link").unsetLink().run(),
|
|
26438
|
+
disabled: !editor.isActive("link"),
|
|
26439
|
+
destructive: true
|
|
26440
|
+
}
|
|
26441
|
+
)
|
|
26442
|
+
] })
|
|
26443
|
+
}
|
|
26444
|
+
),
|
|
26154
26445
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarDivider, {}),
|
|
26155
26446
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26156
26447
|
DropdownMenu,
|
|
26157
26448
|
{
|
|
26158
26449
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(ToolbarButton, { onClick: () => {
|
|
26159
26450
|
}, title: t("colors.textColor"), children: [
|
|
26160
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26451
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(TextColorIcon, { color: currentTextColor }),
|
|
26161
26452
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ChevronDown, { className: "w-3 h-3" })
|
|
26162
26453
|
] }),
|
|
26163
26454
|
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26164
26455
|
EditorColorPalette,
|
|
26165
26456
|
{
|
|
26166
26457
|
colors: textColors,
|
|
26167
|
-
currentColor:
|
|
26458
|
+
currentColor: currentTextColor,
|
|
26168
26459
|
onSelect: (color) => {
|
|
26169
26460
|
if (color === "inherit") {
|
|
26170
26461
|
editor.chain().focus().unsetColor().run();
|
|
@@ -26182,14 +26473,14 @@ var EditorToolbar = ({
|
|
|
26182
26473
|
{
|
|
26183
26474
|
trigger: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(ToolbarButton, { onClick: () => {
|
|
26184
26475
|
}, active: editor.isActive("highlight"), title: t("colors.highlight"), children: [
|
|
26185
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26476
|
+
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(HighlightColorIcon, { color: currentHighlightColor }),
|
|
26186
26477
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.ChevronDown, { className: "w-3 h-3" })
|
|
26187
26478
|
] }),
|
|
26188
26479
|
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26189
26480
|
EditorColorPalette,
|
|
26190
26481
|
{
|
|
26191
26482
|
colors: highlightColors,
|
|
26192
|
-
currentColor:
|
|
26483
|
+
currentColor: currentHighlightColor,
|
|
26193
26484
|
onSelect: (color) => {
|
|
26194
26485
|
if (color === "") {
|
|
26195
26486
|
editor.chain().focus().unsetHighlight().run();
|
|
@@ -26614,41 +26905,23 @@ var EditorToolbar = ({
|
|
|
26614
26905
|
}
|
|
26615
26906
|
),
|
|
26616
26907
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarDivider, {}),
|
|
26617
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26618
|
-
ToolbarButton,
|
|
26619
|
-
{
|
|
26620
|
-
onClick: () => editor.chain().focus().toggleSubscript().run(),
|
|
26621
|
-
active: editor.isActive("subscript"),
|
|
26622
|
-
title: t("toolbar.subscript"),
|
|
26623
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Subscript, { className: "w-4 h-4" })
|
|
26624
|
-
}
|
|
26625
|
-
),
|
|
26626
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
|
|
26627
|
-
ToolbarButton,
|
|
26628
|
-
{
|
|
26629
|
-
onClick: () => editor.chain().focus().toggleSuperscript().run(),
|
|
26630
|
-
active: editor.isActive("superscript"),
|
|
26631
|
-
title: t("toolbar.superscript"),
|
|
26632
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Superscript, { className: "w-4 h-4" })
|
|
26633
|
-
}
|
|
26634
|
-
),
|
|
26635
|
-
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarDivider, {}),
|
|
26636
26908
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().undo().run(), disabled: !editor.can().undo(), title: t("toolbar.undo"), children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Undo, { className: "w-4 h-4" }) }),
|
|
26637
26909
|
/* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().redo().run(), disabled: !editor.can().redo(), title: t("toolbar.redo"), children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_lucide_react44.Redo, { className: "w-4 h-4" }) })
|
|
26638
26910
|
] });
|
|
26639
26911
|
};
|
|
26640
26912
|
|
|
26641
26913
|
// src/components/UEditor/menus.tsx
|
|
26642
|
-
var
|
|
26643
|
-
var
|
|
26914
|
+
var import_react51 = require("react");
|
|
26915
|
+
var import_react52 = require("@tiptap/react");
|
|
26916
|
+
var import_react_dom9 = require("react-dom");
|
|
26644
26917
|
var import_lucide_react45 = require("lucide-react");
|
|
26645
26918
|
var import_jsx_runtime82 = require("react/jsx-runtime");
|
|
26646
26919
|
var FloatingSlashCommandMenu = ({ editor, onClose }) => {
|
|
26647
26920
|
const t = useSmartTranslations("UEditor");
|
|
26648
|
-
const messages = (0,
|
|
26649
|
-
const items = (0,
|
|
26650
|
-
const listRef = (0,
|
|
26651
|
-
(0,
|
|
26921
|
+
const messages = (0, import_react51.useMemo)(() => buildSlashCommandMessages(t), [t]);
|
|
26922
|
+
const items = (0, import_react51.useMemo)(() => buildSlashCommandItems({ query: "", messages }), [messages]);
|
|
26923
|
+
const listRef = (0, import_react51.useRef)(null);
|
|
26924
|
+
(0, import_react51.useEffect)(() => {
|
|
26652
26925
|
const handleKeyDown2 = (event) => {
|
|
26653
26926
|
if (event.key === "Escape") {
|
|
26654
26927
|
event.preventDefault();
|
|
@@ -26678,7 +26951,7 @@ var FloatingSlashCommandMenu = ({ editor, onClose }) => {
|
|
|
26678
26951
|
};
|
|
26679
26952
|
var FloatingMenuContent = ({ editor }) => {
|
|
26680
26953
|
const t = useSmartTranslations("UEditor");
|
|
26681
|
-
const [showCommands, setShowCommands] = (0,
|
|
26954
|
+
const [showCommands, setShowCommands] = (0, import_react51.useState)(false);
|
|
26682
26955
|
if (showCommands) {
|
|
26683
26956
|
return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(FloatingSlashCommandMenu, { editor, onClose: () => setShowCommands(false) });
|
|
26684
26957
|
}
|
|
@@ -26702,28 +26975,52 @@ var BubbleMenuContent = ({
|
|
|
26702
26975
|
lineHeights
|
|
26703
26976
|
}) => {
|
|
26704
26977
|
const t = useSmartTranslations("UEditor");
|
|
26978
|
+
(0, import_react52.useEditorState)({
|
|
26979
|
+
editor,
|
|
26980
|
+
selector: ({ transactionNumber }) => transactionNumber
|
|
26981
|
+
});
|
|
26705
26982
|
const { textColors, highlightColors } = useEditorColors();
|
|
26706
|
-
const [showLinkInput, setShowLinkInput] = (0,
|
|
26707
|
-
const [
|
|
26983
|
+
const [showLinkInput, setShowLinkInput] = (0, import_react51.useState)(false);
|
|
26984
|
+
const [activeColorPalette, setActiveColorPalette] = (0, import_react51.useState)(null);
|
|
26985
|
+
const [showTypographyPanel, setShowTypographyPanel] = (0, import_react51.useState)(false);
|
|
26986
|
+
const [showFontSizeOptions, setShowFontSizeOptions] = (0, import_react51.useState)(false);
|
|
26987
|
+
const [fontSizeDraft, setFontSizeDraft] = (0, import_react51.useState)("");
|
|
26708
26988
|
const isImageSelected = editor.isActive("image");
|
|
26709
26989
|
const imageAttrs = editor.getAttributes("image");
|
|
26710
26990
|
const imageLayout = imageAttrs.imageLayout === "left" || imageAttrs.imageLayout === "right" ? imageAttrs.imageLayout : "block";
|
|
26711
26991
|
const imageWidthPreset = imageAttrs.imageWidthPreset === "sm" || imageAttrs.imageWidthPreset === "md" || imageAttrs.imageWidthPreset === "lg" ? imageAttrs.imageWidthPreset : null;
|
|
26712
26992
|
const textStyleAttrs = editor.getAttributes("textStyle");
|
|
26993
|
+
const currentTextColor = normalizeStyleValue(textStyleAttrs.color) || "inherit";
|
|
26994
|
+
const currentHighlightColor = normalizeStyleValue(editor.getAttributes("highlight").color) || "";
|
|
26713
26995
|
const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
|
|
26714
26996
|
const currentLineHeight = normalizeStyleValue(textStyleAttrs.lineHeight);
|
|
26715
|
-
const quickFontSizes = (0,
|
|
26997
|
+
const quickFontSizes = (0, import_react51.useMemo)(
|
|
26716
26998
|
() => (fontSizes ?? getDefaultFontSizes()).filter((option) => ["14px", "16px", "24px"].includes(option.value)),
|
|
26717
26999
|
[fontSizes]
|
|
26718
27000
|
);
|
|
26719
|
-
const quickLineHeights = (0,
|
|
27001
|
+
const quickLineHeights = (0, import_react51.useMemo)(
|
|
26720
27002
|
() => (lineHeights ?? getDefaultLineHeights()).filter((option) => ["1.2", "1.5", "1.75"].includes(option.value)),
|
|
26721
27003
|
[lineHeights]
|
|
26722
27004
|
);
|
|
26723
|
-
(0,
|
|
27005
|
+
(0, import_react51.useEffect)(() => {
|
|
27006
|
+
setFontSizeDraft(currentFontSize.replace(/px$/i, ""));
|
|
27007
|
+
}, [currentFontSize]);
|
|
27008
|
+
const applyFontSizeDraft = () => {
|
|
27009
|
+
const normalized = fontSizeDraft.trim();
|
|
27010
|
+
if (!normalized) {
|
|
27011
|
+
editor.chain().focus().unsetFontSize().run();
|
|
27012
|
+
return;
|
|
27013
|
+
}
|
|
27014
|
+
const parsed = Number.parseFloat(normalized);
|
|
27015
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return;
|
|
27016
|
+
const clamped = Math.min(96, Math.max(8, parsed));
|
|
27017
|
+
editor.chain().focus().setFontSize(`${clamped}px`).run();
|
|
27018
|
+
setFontSizeDraft(String(clamped));
|
|
27019
|
+
};
|
|
27020
|
+
(0, import_react51.useEffect)(() => {
|
|
26724
27021
|
onKeepOpenChange?.(showLinkInput);
|
|
26725
27022
|
}, [onKeepOpenChange, showLinkInput]);
|
|
26726
|
-
(0,
|
|
27023
|
+
(0, import_react51.useEffect)(() => {
|
|
26727
27024
|
if (!showLinkInput) return;
|
|
26728
27025
|
const close2 = () => setShowLinkInput(false);
|
|
26729
27026
|
editor.on("selectionUpdate", close2);
|
|
@@ -26750,44 +27047,37 @@ var BubbleMenuContent = ({
|
|
|
26750
27047
|
}
|
|
26751
27048
|
);
|
|
26752
27049
|
}
|
|
26753
|
-
if (
|
|
26754
|
-
|
|
26755
|
-
|
|
26756
|
-
EditorColorPalette,
|
|
26757
|
-
{
|
|
26758
|
-
colors: textColors,
|
|
26759
|
-
currentColor: editor.getAttributes("textStyle").color || "inherit",
|
|
26760
|
-
onSelect: (color) => {
|
|
26761
|
-
if (color === "inherit") {
|
|
26762
|
-
editor.chain().focus().unsetColor().run();
|
|
26763
|
-
} else {
|
|
26764
|
-
editor.chain().focus().setColor(color).run();
|
|
26765
|
-
}
|
|
26766
|
-
},
|
|
26767
|
-
label: t("colors.textColor")
|
|
26768
|
-
}
|
|
26769
|
-
),
|
|
26770
|
-
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "border-t my-1" }),
|
|
27050
|
+
if (activeColorPalette) {
|
|
27051
|
+
const isTextPalette = activeColorPalette === "text";
|
|
27052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "w-56", children: [
|
|
26771
27053
|
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26772
27054
|
EditorColorPalette,
|
|
26773
27055
|
{
|
|
26774
|
-
colors: highlightColors,
|
|
26775
|
-
currentColor:
|
|
27056
|
+
colors: isTextPalette ? textColors : highlightColors,
|
|
27057
|
+
currentColor: isTextPalette ? currentTextColor : currentHighlightColor,
|
|
26776
27058
|
onSelect: (color) => {
|
|
26777
|
-
if (
|
|
26778
|
-
|
|
27059
|
+
if (isTextPalette) {
|
|
27060
|
+
if (color === "inherit") {
|
|
27061
|
+
editor.chain().focus().unsetColor().run();
|
|
27062
|
+
} else {
|
|
27063
|
+
editor.chain().focus().setColor(color).run();
|
|
27064
|
+
}
|
|
26779
27065
|
} else {
|
|
26780
|
-
|
|
27066
|
+
if (color === "") {
|
|
27067
|
+
editor.chain().focus().unsetHighlight().run();
|
|
27068
|
+
} else {
|
|
27069
|
+
editor.chain().focus().toggleHighlight({ color }).run();
|
|
27070
|
+
}
|
|
26781
27071
|
}
|
|
26782
27072
|
},
|
|
26783
|
-
label: t("colors.highlight")
|
|
27073
|
+
label: isTextPalette ? t("colors.textColor") : t("colors.highlight")
|
|
26784
27074
|
}
|
|
26785
27075
|
),
|
|
26786
27076
|
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "p-2 border-t", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26787
27077
|
"button",
|
|
26788
27078
|
{
|
|
26789
27079
|
type: "button",
|
|
26790
|
-
onClick: () =>
|
|
27080
|
+
onClick: () => setActiveColorPalette(null),
|
|
26791
27081
|
className: "w-full py-1.5 text-sm rounded-lg hover:bg-muted transition-colors",
|
|
26792
27082
|
children: t("colors.done")
|
|
26793
27083
|
}
|
|
@@ -26808,6 +27098,162 @@ var BubbleMenuContent = ({
|
|
|
26808
27098
|
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToolbarButton, { onClick: () => deleteSelectedImage(editor), title: t("toolbar.imageDelete"), className: "text-destructive hover:text-destructive", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.Trash2, { className: "w-4 h-4" }) })
|
|
26809
27099
|
] });
|
|
26810
27100
|
}
|
|
27101
|
+
if (showTypographyPanel) {
|
|
27102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "w-72 p-2", children: [
|
|
27103
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "mb-2 flex items-center justify-between gap-2", children: [
|
|
27104
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "px-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: t("toolbar.textStyle") }),
|
|
27105
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
27106
|
+
"button",
|
|
27107
|
+
{
|
|
27108
|
+
type: "button",
|
|
27109
|
+
onClick: () => setShowTypographyPanel(false),
|
|
27110
|
+
className: "rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
27111
|
+
children: t("colors.done")
|
|
27112
|
+
}
|
|
27113
|
+
)
|
|
27114
|
+
] }),
|
|
27115
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "space-y-2", children: [
|
|
27116
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { children: [
|
|
27117
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "mb-1 px-1 text-[11px] font-medium text-muted-foreground", children: t("toolbar.fontSize") }),
|
|
27118
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "flex h-9 items-center overflow-hidden rounded-md border border-border/60 bg-muted/40", children: [
|
|
27119
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
27120
|
+
"input",
|
|
27121
|
+
{
|
|
27122
|
+
type: "number",
|
|
27123
|
+
min: 8,
|
|
27124
|
+
max: 96,
|
|
27125
|
+
step: 1,
|
|
27126
|
+
value: fontSizeDraft,
|
|
27127
|
+
onChange: (event) => setFontSizeDraft(event.target.value),
|
|
27128
|
+
onBlur: applyFontSizeDraft,
|
|
27129
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
27130
|
+
onClick: (event) => event.stopPropagation(),
|
|
27131
|
+
onKeyDown: (event) => {
|
|
27132
|
+
event.stopPropagation();
|
|
27133
|
+
if (event.key === "Enter") {
|
|
27134
|
+
event.preventDefault();
|
|
27135
|
+
applyFontSizeDraft();
|
|
27136
|
+
}
|
|
27137
|
+
},
|
|
27138
|
+
"aria-label": t("toolbar.fontSize"),
|
|
27139
|
+
placeholder: "A",
|
|
27140
|
+
className: "h-full min-w-0 flex-1 bg-transparent px-2 text-center text-sm font-semibold text-foreground outline-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
|
|
27141
|
+
}
|
|
27142
|
+
),
|
|
27143
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "border-l border-border/50 px-2 text-[11px] text-muted-foreground", children: "px" }),
|
|
27144
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
27145
|
+
"button",
|
|
27146
|
+
{
|
|
27147
|
+
type: "button",
|
|
27148
|
+
"aria-label": t("toolbar.fontSize"),
|
|
27149
|
+
onClick: () => setShowFontSizeOptions((open) => !open),
|
|
27150
|
+
className: cn(
|
|
27151
|
+
"flex h-full w-9 items-center justify-center border-l border-border/50 transition-colors hover:bg-muted",
|
|
27152
|
+
showFontSizeOptions && "bg-primary/10 text-primary"
|
|
27153
|
+
),
|
|
27154
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.ChevronDown, { className: "h-4 w-4" })
|
|
27155
|
+
}
|
|
27156
|
+
)
|
|
27157
|
+
] }),
|
|
27158
|
+
showFontSizeOptions && /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "mt-1 grid grid-cols-4 gap-1", children: [
|
|
27159
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
27160
|
+
"button",
|
|
27161
|
+
{
|
|
27162
|
+
type: "button",
|
|
27163
|
+
onClick: () => {
|
|
27164
|
+
editor.chain().focus().unsetFontSize().run();
|
|
27165
|
+
setShowFontSizeOptions(false);
|
|
27166
|
+
},
|
|
27167
|
+
className: cn(
|
|
27168
|
+
"h-8 rounded-md text-xs font-semibold transition-colors hover:bg-muted",
|
|
27169
|
+
!currentFontSize ? "bg-primary/10 text-primary" : "bg-muted/40 text-foreground"
|
|
27170
|
+
),
|
|
27171
|
+
children: "A"
|
|
27172
|
+
}
|
|
27173
|
+
),
|
|
27174
|
+
quickFontSizes.map((option) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
27175
|
+
"button",
|
|
27176
|
+
{
|
|
27177
|
+
type: "button",
|
|
27178
|
+
onClick: () => {
|
|
27179
|
+
editor.chain().focus().setFontSize(option.value).run();
|
|
27180
|
+
setShowFontSizeOptions(false);
|
|
27181
|
+
},
|
|
27182
|
+
className: cn(
|
|
27183
|
+
"h-8 rounded-md text-xs font-semibold transition-colors hover:bg-muted",
|
|
27184
|
+
normalizeStyleValue(option.value) === currentFontSize ? "bg-primary/10 text-primary" : "bg-muted/40 text-foreground"
|
|
27185
|
+
),
|
|
27186
|
+
children: option.label
|
|
27187
|
+
},
|
|
27188
|
+
option.value
|
|
27189
|
+
))
|
|
27190
|
+
] })
|
|
27191
|
+
] }),
|
|
27192
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { children: [
|
|
27193
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "mb-1 px-1 text-[11px] font-medium text-muted-foreground", children: t("toolbar.lineHeight") }),
|
|
27194
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "grid grid-cols-4 gap-1", children: [
|
|
27195
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
27196
|
+
"button",
|
|
27197
|
+
{
|
|
27198
|
+
type: "button",
|
|
27199
|
+
onClick: () => editor.chain().focus().unsetLineHeight().run(),
|
|
27200
|
+
className: cn(
|
|
27201
|
+
"h-8 rounded-md text-xs font-semibold transition-colors hover:bg-muted",
|
|
27202
|
+
!currentLineHeight ? "bg-primary/10 text-primary" : "bg-muted/40 text-foreground"
|
|
27203
|
+
),
|
|
27204
|
+
children: "LH"
|
|
27205
|
+
}
|
|
27206
|
+
),
|
|
27207
|
+
quickLineHeights.map((option) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
27208
|
+
"button",
|
|
27209
|
+
{
|
|
27210
|
+
type: "button",
|
|
27211
|
+
onClick: () => editor.chain().focus().setLineHeight(option.value).run(),
|
|
27212
|
+
className: cn(
|
|
27213
|
+
"h-8 rounded-md text-xs font-semibold transition-colors hover:bg-muted",
|
|
27214
|
+
normalizeStyleValue(option.value) === currentLineHeight ? "bg-primary/10 text-primary" : "bg-muted/40 text-foreground"
|
|
27215
|
+
),
|
|
27216
|
+
children: option.label
|
|
27217
|
+
},
|
|
27218
|
+
option.value
|
|
27219
|
+
))
|
|
27220
|
+
] })
|
|
27221
|
+
] }),
|
|
27222
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "grid grid-cols-2 gap-1 border-t border-border/40 pt-2", children: [
|
|
27223
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
|
|
27224
|
+
"button",
|
|
27225
|
+
{
|
|
27226
|
+
type: "button",
|
|
27227
|
+
onClick: () => editor.chain().focus().toggleSubscript().run(),
|
|
27228
|
+
className: cn(
|
|
27229
|
+
"flex h-8 items-center justify-center gap-2 rounded-md text-xs font-semibold transition-colors hover:bg-muted",
|
|
27230
|
+
editor.isActive("subscript") ? "bg-primary/10 text-primary" : "bg-muted/40 text-foreground"
|
|
27231
|
+
),
|
|
27232
|
+
children: [
|
|
27233
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.Subscript, { className: "h-4 w-4" }),
|
|
27234
|
+
t("toolbar.subscript")
|
|
27235
|
+
]
|
|
27236
|
+
}
|
|
27237
|
+
),
|
|
27238
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(
|
|
27239
|
+
"button",
|
|
27240
|
+
{
|
|
27241
|
+
type: "button",
|
|
27242
|
+
onClick: () => editor.chain().focus().toggleSuperscript().run(),
|
|
27243
|
+
className: cn(
|
|
27244
|
+
"flex h-8 items-center justify-center gap-2 rounded-md text-xs font-semibold transition-colors hover:bg-muted",
|
|
27245
|
+
editor.isActive("superscript") ? "bg-primary/10 text-primary" : "bg-muted/40 text-foreground"
|
|
27246
|
+
),
|
|
27247
|
+
children: [
|
|
27248
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.Superscript, { className: "h-4 w-4" }),
|
|
27249
|
+
t("toolbar.superscript")
|
|
27250
|
+
]
|
|
27251
|
+
}
|
|
27252
|
+
)
|
|
27253
|
+
] })
|
|
27254
|
+
] })
|
|
27255
|
+
] });
|
|
27256
|
+
}
|
|
26811
27257
|
return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)("div", { className: "flex items-center gap-0.5 p-1", children: [
|
|
26812
27258
|
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleBold().run(), active: editor.isActive("bold"), title: t("toolbar.bold"), children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.Bold, { className: "w-4 h-4" }) }),
|
|
26813
27259
|
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToolbarButton, { onClick: () => editor.chain().focus().toggleItalic().run(), active: editor.isActive("italic"), title: t("toolbar.italic"), children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.Italic, { className: "w-4 h-4" }) }),
|
|
@@ -26837,68 +27283,16 @@ var BubbleMenuContent = ({
|
|
|
26837
27283
|
children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.Link, { className: "w-4 h-4" })
|
|
26838
27284
|
}
|
|
26839
27285
|
),
|
|
26840
|
-
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToolbarButton, { onClick: () =>
|
|
26841
|
-
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26842
|
-
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26843
|
-
ToolbarButton,
|
|
26844
|
-
{
|
|
26845
|
-
onClick: () => editor.chain().focus().unsetFontSize().run(),
|
|
26846
|
-
active: !currentFontSize,
|
|
26847
|
-
title: t("toolbar.sizeDefault"),
|
|
26848
|
-
className: "px-2 w-auto",
|
|
26849
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "text-[10px] font-semibold", children: "A" })
|
|
26850
|
-
}
|
|
26851
|
-
),
|
|
26852
|
-
quickFontSizes.map((option) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26853
|
-
ToolbarButton,
|
|
26854
|
-
{
|
|
26855
|
-
onClick: () => editor.chain().focus().setFontSize(option.value).run(),
|
|
26856
|
-
active: normalizeStyleValue(option.value) === currentFontSize,
|
|
26857
|
-
title: `${t("toolbar.fontSize")} ${option.label}`,
|
|
26858
|
-
className: "px-2 w-auto",
|
|
26859
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "text-[10px] font-semibold", children: option.label })
|
|
26860
|
-
},
|
|
26861
|
-
option.value
|
|
26862
|
-
)),
|
|
26863
|
-
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "w-px h-6 bg-border/50 mx-1" }),
|
|
26864
|
-
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26865
|
-
ToolbarButton,
|
|
26866
|
-
{
|
|
26867
|
-
onClick: () => editor.chain().focus().unsetLineHeight().run(),
|
|
26868
|
-
active: !currentLineHeight,
|
|
26869
|
-
title: t("toolbar.lineHeightDefault"),
|
|
26870
|
-
className: "px-2 w-auto",
|
|
26871
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "text-[10px] font-semibold leading-none", children: "LH" })
|
|
26872
|
-
}
|
|
26873
|
-
),
|
|
26874
|
-
quickLineHeights.map((option) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26875
|
-
ToolbarButton,
|
|
26876
|
-
{
|
|
26877
|
-
onClick: () => editor.chain().focus().setLineHeight(option.value).run(),
|
|
26878
|
-
active: normalizeStyleValue(option.value) === currentLineHeight,
|
|
26879
|
-
title: `${t("toolbar.lineHeight")} ${option.label}`,
|
|
26880
|
-
className: "px-2 w-auto",
|
|
26881
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("span", { className: "text-[10px] font-semibold", children: option.label })
|
|
26882
|
-
},
|
|
26883
|
-
option.value
|
|
26884
|
-
)),
|
|
27286
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToolbarButton, { onClick: () => setActiveColorPalette("text"), title: t("colors.textColor"), children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(TextColorIcon, { color: currentTextColor }) }),
|
|
27287
|
+
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(ToolbarButton, { onClick: () => setActiveColorPalette("highlight"), active: editor.isActive("highlight"), title: t("colors.highlight"), children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(HighlightColorIcon, { color: currentHighlightColor }) }),
|
|
26885
27288
|
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "w-px h-6 bg-border/50 mx-1" }),
|
|
26886
27289
|
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26887
27290
|
ToolbarButton,
|
|
26888
27291
|
{
|
|
26889
|
-
onClick: () =>
|
|
26890
|
-
active: editor.isActive("subscript"),
|
|
26891
|
-
title: t("toolbar.
|
|
26892
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.
|
|
26893
|
-
}
|
|
26894
|
-
),
|
|
26895
|
-
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26896
|
-
ToolbarButton,
|
|
26897
|
-
{
|
|
26898
|
-
onClick: () => editor.chain().focus().toggleSuperscript().run(),
|
|
26899
|
-
active: editor.isActive("superscript"),
|
|
26900
|
-
title: t("toolbar.superscript"),
|
|
26901
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.Superscript, { className: "w-4 h-4" })
|
|
27292
|
+
onClick: () => setShowTypographyPanel(true),
|
|
27293
|
+
active: Boolean(currentFontSize || currentLineHeight || editor.isActive("subscript") || editor.isActive("superscript")),
|
|
27294
|
+
title: t("toolbar.textStyle"),
|
|
27295
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_lucide_react45.Type, { className: "w-4 h-4" })
|
|
26902
27296
|
}
|
|
26903
27297
|
)
|
|
26904
27298
|
] });
|
|
@@ -26910,16 +27304,16 @@ var CustomBubbleMenu = ({
|
|
|
26910
27304
|
}) => {
|
|
26911
27305
|
const SHOW_DELAY_MS = 180;
|
|
26912
27306
|
const BUBBLE_MENU_OFFSET = 16;
|
|
26913
|
-
const [isVisible, setIsVisible] = (0,
|
|
26914
|
-
const [position, setPosition] = (0,
|
|
26915
|
-
const menuRef = (0,
|
|
26916
|
-
const keepOpenRef = (0,
|
|
26917
|
-
const showTimeoutRef = (0,
|
|
26918
|
-
const setKeepOpen = (0,
|
|
27307
|
+
const [isVisible, setIsVisible] = (0, import_react51.useState)(false);
|
|
27308
|
+
const [position, setPosition] = (0, import_react51.useState)({ top: 0, left: 0 });
|
|
27309
|
+
const menuRef = (0, import_react51.useRef)(null);
|
|
27310
|
+
const keepOpenRef = (0, import_react51.useRef)(false);
|
|
27311
|
+
const showTimeoutRef = (0, import_react51.useRef)(null);
|
|
27312
|
+
const setKeepOpen = (0, import_react51.useCallback)((next) => {
|
|
26919
27313
|
keepOpenRef.current = next;
|
|
26920
27314
|
if (next) setIsVisible(true);
|
|
26921
27315
|
}, []);
|
|
26922
|
-
(0,
|
|
27316
|
+
(0, import_react51.useEffect)(() => {
|
|
26923
27317
|
const clearShowTimeout = () => {
|
|
26924
27318
|
if (showTimeoutRef.current) {
|
|
26925
27319
|
clearTimeout(showTimeoutRef.current);
|
|
@@ -26967,12 +27361,12 @@ var CustomBubbleMenu = ({
|
|
|
26967
27361
|
};
|
|
26968
27362
|
}, [editor]);
|
|
26969
27363
|
if (!isVisible) return null;
|
|
26970
|
-
return (0,
|
|
27364
|
+
return (0, import_react_dom9.createPortal)(
|
|
26971
27365
|
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
26972
27366
|
"div",
|
|
26973
27367
|
{
|
|
26974
27368
|
ref: menuRef,
|
|
26975
|
-
className: "fixed z-50 flex rounded-
|
|
27369
|
+
className: "fixed z-50 flex rounded-xl border border-border/40 bg-card text-card-foreground shadow-lg backdrop-blur-sm overflow-hidden animate-in fade-in-0 zoom-in-95",
|
|
26976
27370
|
style: {
|
|
26977
27371
|
top: `${position.top}px`,
|
|
26978
27372
|
left: `${position.left}px`,
|
|
@@ -26995,9 +27389,9 @@ var CustomBubbleMenu = ({
|
|
|
26995
27389
|
};
|
|
26996
27390
|
var CustomFloatingMenu = ({ editor }) => {
|
|
26997
27391
|
const FLOATING_MENU_OFFSET = 16;
|
|
26998
|
-
const [isVisible, setIsVisible] = (0,
|
|
26999
|
-
const [position, setPosition] = (0,
|
|
27000
|
-
(0,
|
|
27392
|
+
const [isVisible, setIsVisible] = (0, import_react51.useState)(false);
|
|
27393
|
+
const [position, setPosition] = (0, import_react51.useState)({ top: 0, left: 0 });
|
|
27394
|
+
(0, import_react51.useEffect)(() => {
|
|
27001
27395
|
const updatePosition = () => {
|
|
27002
27396
|
const { state, view } = editor;
|
|
27003
27397
|
const { $from, empty } = state.selection;
|
|
@@ -27023,7 +27417,7 @@ var CustomFloatingMenu = ({ editor }) => {
|
|
|
27023
27417
|
};
|
|
27024
27418
|
}, [editor]);
|
|
27025
27419
|
if (!isVisible) return null;
|
|
27026
|
-
return (0,
|
|
27420
|
+
return (0, import_react_dom9.createPortal)(
|
|
27027
27421
|
/* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
|
|
27028
27422
|
"div",
|
|
27029
27423
|
{
|
|
@@ -27332,7 +27726,7 @@ async function prepareUEditorContentForSave({
|
|
|
27332
27726
|
}
|
|
27333
27727
|
|
|
27334
27728
|
// src/components/UEditor/table-controls.tsx
|
|
27335
|
-
var
|
|
27729
|
+
var import_react53 = __toESM(require("react"), 1);
|
|
27336
27730
|
|
|
27337
27731
|
// node_modules/prosemirror-model/dist/index.js
|
|
27338
27732
|
function findDiffStart(a, b, pos) {
|
|
@@ -31798,16 +32192,16 @@ function collectChildren(node) {
|
|
|
31798
32192
|
}
|
|
31799
32193
|
function TableControls({ editor, containerRef }) {
|
|
31800
32194
|
const t = useSmartTranslations("UEditor");
|
|
31801
|
-
const [layout, setLayout] =
|
|
31802
|
-
const [dragPreview, setDragPreview] =
|
|
31803
|
-
const [hoverState, setHoverState] =
|
|
31804
|
-
const [openMenuKey, setOpenMenuKey] =
|
|
31805
|
-
const layoutRef =
|
|
31806
|
-
const dragStateRef =
|
|
31807
|
-
|
|
32195
|
+
const [layout, setLayout] = import_react53.default.useState(null);
|
|
32196
|
+
const [dragPreview, setDragPreview] = import_react53.default.useState(null);
|
|
32197
|
+
const [hoverState, setHoverState] = import_react53.default.useState(DEFAULT_HOVER_STATE);
|
|
32198
|
+
const [openMenuKey, setOpenMenuKey] = import_react53.default.useState(null);
|
|
32199
|
+
const layoutRef = import_react53.default.useRef(null);
|
|
32200
|
+
const dragStateRef = import_react53.default.useRef(null);
|
|
32201
|
+
import_react53.default.useEffect(() => {
|
|
31808
32202
|
layoutRef.current = layout;
|
|
31809
32203
|
}, [layout]);
|
|
31810
|
-
const syncFromCell =
|
|
32204
|
+
const syncFromCell = import_react53.default.useCallback((cell) => {
|
|
31811
32205
|
const surface = containerRef.current;
|
|
31812
32206
|
if (!surface || !cell) {
|
|
31813
32207
|
setLayout(null);
|
|
@@ -31815,10 +32209,10 @@ function TableControls({ editor, containerRef }) {
|
|
|
31815
32209
|
}
|
|
31816
32210
|
setLayout(buildLayout(editor, surface, cell));
|
|
31817
32211
|
}, [containerRef, editor]);
|
|
31818
|
-
const syncFromSelection =
|
|
32212
|
+
const syncFromSelection = import_react53.default.useCallback(() => {
|
|
31819
32213
|
syncFromCell(getSelectedCell(editor));
|
|
31820
32214
|
}, [editor, syncFromCell]);
|
|
31821
|
-
const refreshCurrentLayout =
|
|
32215
|
+
const refreshCurrentLayout = import_react53.default.useCallback(() => {
|
|
31822
32216
|
setLayout((prev) => {
|
|
31823
32217
|
if (!prev) return prev;
|
|
31824
32218
|
const surface = containerRef.current;
|
|
@@ -31828,12 +32222,12 @@ function TableControls({ editor, containerRef }) {
|
|
|
31828
32222
|
return cell ? buildLayout(editor, surface, cell) : null;
|
|
31829
32223
|
});
|
|
31830
32224
|
}, [containerRef, editor]);
|
|
31831
|
-
const clearDrag =
|
|
32225
|
+
const clearDrag = import_react53.default.useCallback(() => {
|
|
31832
32226
|
dragStateRef.current = null;
|
|
31833
32227
|
setDragPreview(null);
|
|
31834
32228
|
document.body.style.cursor = "";
|
|
31835
32229
|
}, []);
|
|
31836
|
-
const updateHoverState =
|
|
32230
|
+
const updateHoverState = import_react53.default.useCallback((event) => {
|
|
31837
32231
|
const activeLayout = layoutRef.current;
|
|
31838
32232
|
const surface = containerRef.current;
|
|
31839
32233
|
if (!activeLayout || !surface || dragStateRef.current) {
|
|
@@ -31871,7 +32265,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31871
32265
|
};
|
|
31872
32266
|
});
|
|
31873
32267
|
}, [containerRef]);
|
|
31874
|
-
|
|
32268
|
+
import_react53.default.useEffect(() => {
|
|
31875
32269
|
const proseMirror = editor.view.dom;
|
|
31876
32270
|
const surface = containerRef.current;
|
|
31877
32271
|
if (!surface) return void 0;
|
|
@@ -31916,7 +32310,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31916
32310
|
editor.off("update", refreshCurrentLayout);
|
|
31917
32311
|
};
|
|
31918
32312
|
}, [clearDrag, containerRef, editor, refreshCurrentLayout, syncFromCell, syncFromSelection, updateHoverState]);
|
|
31919
|
-
const runAtCellPos =
|
|
32313
|
+
const runAtCellPos = import_react53.default.useCallback((cellPos, command, options) => {
|
|
31920
32314
|
if (cellPos == null) return false;
|
|
31921
32315
|
focusCell(editor, cellPos);
|
|
31922
32316
|
const result = command(editor.chain().focus(null, { scrollIntoView: false })).run();
|
|
@@ -31925,17 +32319,17 @@ function TableControls({ editor, containerRef }) {
|
|
|
31925
32319
|
}
|
|
31926
32320
|
return result;
|
|
31927
32321
|
}, [editor, syncFromSelection]);
|
|
31928
|
-
const runAtActiveCell =
|
|
32322
|
+
const runAtActiveCell = import_react53.default.useCallback((command, options) => {
|
|
31929
32323
|
return runAtCellPos(layoutRef.current?.cellPos ?? null, command, options);
|
|
31930
32324
|
}, [runAtCellPos]);
|
|
31931
|
-
const getCurrentCornerCellPos =
|
|
32325
|
+
const getCurrentCornerCellPos = import_react53.default.useCallback(() => {
|
|
31932
32326
|
const activePos = layoutRef.current?.cellPos ?? editor.state.selection.from;
|
|
31933
32327
|
return getLastCellPosFromState(editor, activePos);
|
|
31934
32328
|
}, [editor]);
|
|
31935
|
-
const runAtCornerCell =
|
|
32329
|
+
const runAtCornerCell = import_react53.default.useCallback((command, options) => {
|
|
31936
32330
|
return runAtCellPos(getCurrentCornerCellPos(), command, options);
|
|
31937
32331
|
}, [getCurrentCornerCellPos, runAtCellPos]);
|
|
31938
|
-
const replaceTableAtCellPos =
|
|
32332
|
+
const replaceTableAtCellPos = import_react53.default.useCallback((cellPos, updateTable) => {
|
|
31939
32333
|
if (cellPos == null) return false;
|
|
31940
32334
|
const tableInfo = findTableInfo(editor, cellPos);
|
|
31941
32335
|
if (!tableInfo) return false;
|
|
@@ -31945,10 +32339,10 @@ function TableControls({ editor, containerRef }) {
|
|
|
31945
32339
|
requestAnimationFrame(syncFromSelection);
|
|
31946
32340
|
return true;
|
|
31947
32341
|
}, [editor, syncFromSelection]);
|
|
31948
|
-
const createEmptyCellNode =
|
|
32342
|
+
const createEmptyCellNode = import_react53.default.useCallback((cellNode) => {
|
|
31949
32343
|
return cellNode.type.createAndFill(cellNode.attrs) ?? cellNode;
|
|
31950
32344
|
}, []);
|
|
31951
|
-
const duplicateRowAt =
|
|
32345
|
+
const duplicateRowAt = import_react53.default.useCallback((rowIndex, cellPos) => {
|
|
31952
32346
|
return replaceTableAtCellPos(cellPos, (tableNode) => {
|
|
31953
32347
|
const rows = collectChildren(tableNode);
|
|
31954
32348
|
const rowNode = rows[rowIndex];
|
|
@@ -31957,7 +32351,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31957
32351
|
return tableNode.type.create(tableNode.attrs, rows);
|
|
31958
32352
|
});
|
|
31959
32353
|
}, [replaceTableAtCellPos]);
|
|
31960
|
-
const clearRowAt =
|
|
32354
|
+
const clearRowAt = import_react53.default.useCallback((rowIndex, cellPos) => {
|
|
31961
32355
|
return replaceTableAtCellPos(cellPos, (tableNode) => {
|
|
31962
32356
|
const rows = collectChildren(tableNode);
|
|
31963
32357
|
const rowNode = rows[rowIndex];
|
|
@@ -31967,7 +32361,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31967
32361
|
return tableNode.type.create(tableNode.attrs, rows);
|
|
31968
32362
|
});
|
|
31969
32363
|
}, [createEmptyCellNode, replaceTableAtCellPos]);
|
|
31970
|
-
const duplicateColumnAt =
|
|
32364
|
+
const duplicateColumnAt = import_react53.default.useCallback((columnIndex, cellPos) => {
|
|
31971
32365
|
return replaceTableAtCellPos(cellPos, (tableNode) => {
|
|
31972
32366
|
const rows = collectChildren(tableNode).map((rowNode) => {
|
|
31973
32367
|
const cells = collectChildren(rowNode);
|
|
@@ -31979,7 +32373,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31979
32373
|
return tableNode.type.create(tableNode.attrs, rows);
|
|
31980
32374
|
});
|
|
31981
32375
|
}, [replaceTableAtCellPos]);
|
|
31982
|
-
const clearColumnAt =
|
|
32376
|
+
const clearColumnAt = import_react53.default.useCallback((columnIndex, cellPos) => {
|
|
31983
32377
|
return replaceTableAtCellPos(cellPos, (tableNode) => {
|
|
31984
32378
|
const rows = collectChildren(tableNode).map((rowNode) => {
|
|
31985
32379
|
const cells = collectChildren(rowNode);
|
|
@@ -31991,7 +32385,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31991
32385
|
return tableNode.type.create(tableNode.attrs, rows);
|
|
31992
32386
|
});
|
|
31993
32387
|
}, [createEmptyCellNode, replaceTableAtCellPos]);
|
|
31994
|
-
const expandTableBy =
|
|
32388
|
+
const expandTableBy = import_react53.default.useCallback((rows, cols) => {
|
|
31995
32389
|
let ok = true;
|
|
31996
32390
|
for (let index = 0; index < rows; index += 1) {
|
|
31997
32391
|
ok = runAtCornerCell((chain) => chain.addRowAfter(), { sync: false });
|
|
@@ -32007,9 +32401,9 @@ function TableControls({ editor, containerRef }) {
|
|
|
32007
32401
|
const canExpandTable = Boolean(layout);
|
|
32008
32402
|
const controlsVisible = dragPreview !== null;
|
|
32009
32403
|
const tableMenuOpen = openMenuKey === "table";
|
|
32010
|
-
const getRowMenuKey =
|
|
32011
|
-
const getColumnMenuKey =
|
|
32012
|
-
|
|
32404
|
+
const getRowMenuKey = import_react53.default.useCallback((index) => `row:${index}`, []);
|
|
32405
|
+
const getColumnMenuKey = import_react53.default.useCallback((index) => `column:${index}`, []);
|
|
32406
|
+
import_react53.default.useEffect(() => {
|
|
32013
32407
|
const handleMouseMove = (event) => {
|
|
32014
32408
|
const dragState = dragStateRef.current;
|
|
32015
32409
|
const activeLayout = layoutRef.current;
|
|
@@ -32096,7 +32490,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
32096
32490
|
window.removeEventListener("blur", clearDrag);
|
|
32097
32491
|
};
|
|
32098
32492
|
}, [clearDrag, containerRef, editor, expandTableBy, syncFromSelection]);
|
|
32099
|
-
const menuItems =
|
|
32493
|
+
const menuItems = import_react53.default.useMemo(() => {
|
|
32100
32494
|
if (!layout) return [];
|
|
32101
32495
|
return [
|
|
32102
32496
|
{
|
|
@@ -32164,7 +32558,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
32164
32558
|
}
|
|
32165
32559
|
];
|
|
32166
32560
|
}, [layout, runAtActiveCell, t]);
|
|
32167
|
-
const getRowHandleMenuItems =
|
|
32561
|
+
const getRowHandleMenuItems = import_react53.default.useCallback((rowHandle) => [
|
|
32168
32562
|
{
|
|
32169
32563
|
label: t("tableMenu.addRowBefore"),
|
|
32170
32564
|
icon: import_lucide_react46.ArrowUp,
|
|
@@ -32192,7 +32586,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
32192
32586
|
destructive: true
|
|
32193
32587
|
}
|
|
32194
32588
|
], [clearRowAt, duplicateRowAt, runAtCellPos, t]);
|
|
32195
|
-
const getColumnHandleMenuItems =
|
|
32589
|
+
const getColumnHandleMenuItems = import_react53.default.useCallback((columnHandle) => [
|
|
32196
32590
|
{
|
|
32197
32591
|
label: t("tableMenu.addColumnBefore"),
|
|
32198
32592
|
icon: import_lucide_react46.ArrowLeft,
|
|
@@ -32741,10 +33135,10 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
|
|
|
32741
33135
|
);
|
|
32742
33136
|
|
|
32743
33137
|
// src/components/UEditor/use-table-interactions.ts
|
|
32744
|
-
var
|
|
33138
|
+
var import_react55 = __toESM(require("react"), 1);
|
|
32745
33139
|
|
|
32746
33140
|
// src/components/UEditor/use-table-row-resize.ts
|
|
32747
|
-
var
|
|
33141
|
+
var import_react54 = __toESM(require("react"), 1);
|
|
32748
33142
|
function useTableRowResize({
|
|
32749
33143
|
editor,
|
|
32750
33144
|
setHoveredTableCell,
|
|
@@ -32753,9 +33147,9 @@ function useTableRowResize({
|
|
|
32753
33147
|
clearAllTableResizeHover,
|
|
32754
33148
|
scheduleTableLayoutSync
|
|
32755
33149
|
}) {
|
|
32756
|
-
const commitFrameRef = (0,
|
|
32757
|
-
const stateRef = (0,
|
|
32758
|
-
const commitPreview =
|
|
33150
|
+
const commitFrameRef = (0, import_react54.useRef)(null);
|
|
33151
|
+
const stateRef = (0, import_react54.useRef)(null);
|
|
33152
|
+
const commitPreview = import_react54.default.useCallback(() => {
|
|
32759
33153
|
if (!editor) return;
|
|
32760
33154
|
const state = stateRef.current;
|
|
32761
33155
|
if (!state) return;
|
|
@@ -32790,22 +33184,22 @@ function useTableRowResize({
|
|
|
32790
33184
|
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
32791
33185
|
scheduleTableLayoutSync();
|
|
32792
33186
|
}, [editor, scheduleTableLayoutSync, showRowGuide]);
|
|
32793
|
-
const scheduleCommit =
|
|
33187
|
+
const scheduleCommit = import_react54.default.useCallback(() => {
|
|
32794
33188
|
if (commitFrameRef.current !== null) return;
|
|
32795
33189
|
commitFrameRef.current = window.requestAnimationFrame(() => {
|
|
32796
33190
|
commitFrameRef.current = null;
|
|
32797
33191
|
commitPreview();
|
|
32798
33192
|
});
|
|
32799
33193
|
}, [commitPreview]);
|
|
32800
|
-
const syncActiveGuide =
|
|
33194
|
+
const syncActiveGuide = import_react54.default.useCallback(() => {
|
|
32801
33195
|
const state = stateRef.current;
|
|
32802
33196
|
if (!state) return false;
|
|
32803
33197
|
setHoveredTableCell(state.cellElement);
|
|
32804
33198
|
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
32805
33199
|
return true;
|
|
32806
33200
|
}, [setHoveredTableCell, showRowGuide]);
|
|
32807
|
-
const isResizing =
|
|
32808
|
-
const beginResize =
|
|
33201
|
+
const isResizing = import_react54.default.useCallback(() => stateRef.current !== null, []);
|
|
33202
|
+
const beginResize = import_react54.default.useCallback((event, table, row, cell) => {
|
|
32809
33203
|
if (!editor || !isRowResizeHotspot(cell, event.clientX, event.clientY)) {
|
|
32810
33204
|
return false;
|
|
32811
33205
|
}
|
|
@@ -32831,7 +33225,7 @@ function useTableRowResize({
|
|
|
32831
33225
|
event.stopPropagation();
|
|
32832
33226
|
return true;
|
|
32833
33227
|
}, [editor, setHoveredTableCell, showRowGuide]);
|
|
32834
|
-
const handlePointerMove =
|
|
33228
|
+
const handlePointerMove = import_react54.default.useCallback((event) => {
|
|
32835
33229
|
const state = stateRef.current;
|
|
32836
33230
|
if (!state) return;
|
|
32837
33231
|
const nextHeight = Math.max(
|
|
@@ -32847,7 +33241,7 @@ function useTableRowResize({
|
|
|
32847
33241
|
document.body.style.cursor = "row-resize";
|
|
32848
33242
|
scheduleCommit();
|
|
32849
33243
|
}, [scheduleCommit, showRowGuide]);
|
|
32850
|
-
const handlePointerUp =
|
|
33244
|
+
const handlePointerUp = import_react54.default.useCallback((event) => {
|
|
32851
33245
|
if (!editor) return;
|
|
32852
33246
|
const state = stateRef.current;
|
|
32853
33247
|
if (!state) return;
|
|
@@ -32877,7 +33271,7 @@ function useTableRowResize({
|
|
|
32877
33271
|
clearAllTableResizeHover();
|
|
32878
33272
|
scheduleTableLayoutSync();
|
|
32879
33273
|
}, [clearAllTableResizeHover, clearHoveredTableCell, commitPreview, editor, scheduleTableLayoutSync]);
|
|
32880
|
-
const cancelResize =
|
|
33274
|
+
const cancelResize = import_react54.default.useCallback(() => {
|
|
32881
33275
|
if (!stateRef.current) return;
|
|
32882
33276
|
if (commitFrameRef.current !== null) {
|
|
32883
33277
|
window.cancelAnimationFrame(commitFrameRef.current);
|
|
@@ -32889,7 +33283,7 @@ function useTableRowResize({
|
|
|
32889
33283
|
clearAllTableResizeHover();
|
|
32890
33284
|
scheduleTableLayoutSync();
|
|
32891
33285
|
}, [clearAllTableResizeHover, clearHoveredTableCell, scheduleTableLayoutSync]);
|
|
32892
|
-
const cleanup =
|
|
33286
|
+
const cleanup = import_react54.default.useCallback(() => {
|
|
32893
33287
|
if (commitFrameRef.current !== null) {
|
|
32894
33288
|
window.cancelAnimationFrame(commitFrameRef.current);
|
|
32895
33289
|
commitFrameRef.current = null;
|
|
@@ -32910,40 +33304,40 @@ function useTableRowResize({
|
|
|
32910
33304
|
|
|
32911
33305
|
// src/components/UEditor/use-table-interactions.ts
|
|
32912
33306
|
function useUEditorTableInteractions(editor, editable = true) {
|
|
32913
|
-
const editorContentRef = (0,
|
|
32914
|
-
const tableColumnGuideRef = (0,
|
|
32915
|
-
const tableRowGuideRef = (0,
|
|
32916
|
-
const activeTableCellHighlightRef = (0,
|
|
32917
|
-
const hoveredTableCellRef = (0,
|
|
32918
|
-
const activeTableCellRef = (0,
|
|
32919
|
-
const suppressActiveCellHighlightRef = (0,
|
|
32920
|
-
const tableLayoutSyncFrameRef = (0,
|
|
32921
|
-
const setEditorResizeCursor =
|
|
33307
|
+
const editorContentRef = (0, import_react55.useRef)(null);
|
|
33308
|
+
const tableColumnGuideRef = (0, import_react55.useRef)(null);
|
|
33309
|
+
const tableRowGuideRef = (0, import_react55.useRef)(null);
|
|
33310
|
+
const activeTableCellHighlightRef = (0, import_react55.useRef)(null);
|
|
33311
|
+
const hoveredTableCellRef = (0, import_react55.useRef)(null);
|
|
33312
|
+
const activeTableCellRef = (0, import_react55.useRef)(null);
|
|
33313
|
+
const suppressActiveCellHighlightRef = (0, import_react55.useRef)(false);
|
|
33314
|
+
const tableLayoutSyncFrameRef = (0, import_react55.useRef)(null);
|
|
33315
|
+
const setEditorResizeCursor = import_react55.default.useCallback((cursor) => {
|
|
32922
33316
|
const proseMirror = editorContentRef.current?.querySelector(".ProseMirror");
|
|
32923
33317
|
if (proseMirror) {
|
|
32924
33318
|
proseMirror.style.cursor = cursor;
|
|
32925
33319
|
}
|
|
32926
33320
|
}, []);
|
|
32927
|
-
const hideColumnGuide =
|
|
33321
|
+
const hideColumnGuide = import_react55.default.useCallback(() => {
|
|
32928
33322
|
editorContentRef.current?.classList.remove("resize-cursor");
|
|
32929
33323
|
const guide = tableColumnGuideRef.current;
|
|
32930
33324
|
if (guide) {
|
|
32931
33325
|
guide.style.opacity = "0";
|
|
32932
33326
|
}
|
|
32933
33327
|
}, []);
|
|
32934
|
-
const hideRowGuide =
|
|
33328
|
+
const hideRowGuide = import_react55.default.useCallback(() => {
|
|
32935
33329
|
editorContentRef.current?.classList.remove("resize-row-cursor");
|
|
32936
33330
|
const guide = tableRowGuideRef.current;
|
|
32937
33331
|
if (guide) {
|
|
32938
33332
|
guide.style.opacity = "0";
|
|
32939
33333
|
}
|
|
32940
33334
|
}, []);
|
|
32941
|
-
const clearAllTableResizeHover =
|
|
33335
|
+
const clearAllTableResizeHover = import_react55.default.useCallback(() => {
|
|
32942
33336
|
setEditorResizeCursor("");
|
|
32943
33337
|
hideColumnGuide();
|
|
32944
33338
|
hideRowGuide();
|
|
32945
33339
|
}, [hideColumnGuide, hideRowGuide, setEditorResizeCursor]);
|
|
32946
|
-
const updateActiveCellHighlight =
|
|
33340
|
+
const updateActiveCellHighlight = import_react55.default.useCallback((cell) => {
|
|
32947
33341
|
const surface = editorContentRef.current;
|
|
32948
33342
|
const highlight = activeTableCellHighlightRef.current;
|
|
32949
33343
|
if (!highlight) return;
|
|
@@ -32958,7 +33352,7 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
32958
33352
|
highlight.style.width = `${metrics.width}px`;
|
|
32959
33353
|
highlight.style.height = `${metrics.height}px`;
|
|
32960
33354
|
}, []);
|
|
32961
|
-
const scheduleTableLayoutSync =
|
|
33355
|
+
const scheduleTableLayoutSync = import_react55.default.useCallback(() => {
|
|
32962
33356
|
if (tableLayoutSyncFrameRef.current !== null) return;
|
|
32963
33357
|
tableLayoutSyncFrameRef.current = window.requestAnimationFrame(() => {
|
|
32964
33358
|
tableLayoutSyncFrameRef.current = null;
|
|
@@ -32966,22 +33360,22 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
32966
33360
|
editorContentRef.current?.dispatchEvent(new CustomEvent(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT));
|
|
32967
33361
|
});
|
|
32968
33362
|
}, [updateActiveCellHighlight]);
|
|
32969
|
-
const setActiveTableCell =
|
|
33363
|
+
const setActiveTableCell = import_react55.default.useCallback((cell) => {
|
|
32970
33364
|
if (activeTableCellRef.current === cell) return;
|
|
32971
33365
|
activeTableCellRef.current = cell;
|
|
32972
33366
|
updateActiveCellHighlight(activeTableCellRef.current);
|
|
32973
33367
|
}, [updateActiveCellHighlight]);
|
|
32974
|
-
const clearActiveTableCell =
|
|
33368
|
+
const clearActiveTableCell = import_react55.default.useCallback(() => {
|
|
32975
33369
|
activeTableCellRef.current = null;
|
|
32976
33370
|
updateActiveCellHighlight(null);
|
|
32977
33371
|
}, [updateActiveCellHighlight]);
|
|
32978
|
-
const setHoveredTableCell =
|
|
33372
|
+
const setHoveredTableCell = import_react55.default.useCallback((cell) => {
|
|
32979
33373
|
hoveredTableCellRef.current = cell;
|
|
32980
33374
|
}, []);
|
|
32981
|
-
const clearHoveredTableCell =
|
|
33375
|
+
const clearHoveredTableCell = import_react55.default.useCallback(() => {
|
|
32982
33376
|
hoveredTableCellRef.current = null;
|
|
32983
33377
|
}, []);
|
|
32984
|
-
const showColumnGuide =
|
|
33378
|
+
const showColumnGuide = import_react55.default.useCallback((table, row, cell) => {
|
|
32985
33379
|
const surface = editorContentRef.current;
|
|
32986
33380
|
const guide = tableColumnGuideRef.current;
|
|
32987
33381
|
if (!surface || !guide) return;
|
|
@@ -32994,7 +33388,7 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
32994
33388
|
surface.classList.add("resize-cursor");
|
|
32995
33389
|
setEditorResizeCursor("col-resize");
|
|
32996
33390
|
}, [setEditorResizeCursor]);
|
|
32997
|
-
const showRowGuide =
|
|
33391
|
+
const showRowGuide = import_react55.default.useCallback((table, row, cell) => {
|
|
32998
33392
|
const surface = editorContentRef.current;
|
|
32999
33393
|
const guide = tableRowGuideRef.current;
|
|
33000
33394
|
if (!surface || !guide) return;
|
|
@@ -33023,11 +33417,11 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
33023
33417
|
clearAllTableResizeHover,
|
|
33024
33418
|
scheduleTableLayoutSync
|
|
33025
33419
|
});
|
|
33026
|
-
const syncActiveTableCellFromSelection =
|
|
33420
|
+
const syncActiveTableCellFromSelection = import_react55.default.useCallback(() => {
|
|
33027
33421
|
if (!editor) return;
|
|
33028
33422
|
setActiveTableCell(getSelectionTableCell(editor.view));
|
|
33029
33423
|
}, [editor, setActiveTableCell]);
|
|
33030
|
-
(0,
|
|
33424
|
+
(0, import_react55.useEffect)(() => {
|
|
33031
33425
|
if (!editor || !editable) return void 0;
|
|
33032
33426
|
const proseMirror = editor.view.dom;
|
|
33033
33427
|
const surface = editorContentRef.current;
|
|
@@ -33188,7 +33582,7 @@ function useUEditorTableInteractions(editor, editable = true) {
|
|
|
33188
33582
|
|
|
33189
33583
|
// src/components/UEditor/UEditor.tsx
|
|
33190
33584
|
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
33191
|
-
var UEditor =
|
|
33585
|
+
var UEditor = import_react56.default.forwardRef(({
|
|
33192
33586
|
content = "",
|
|
33193
33587
|
onChange,
|
|
33194
33588
|
onHtmlChange,
|
|
@@ -33219,9 +33613,9 @@ var UEditor = import_react54.default.forwardRef(({
|
|
|
33219
33613
|
}, ref) => {
|
|
33220
33614
|
const t = useSmartTranslations("UEditor");
|
|
33221
33615
|
const effectivePlaceholder = placeholder ?? t("placeholder");
|
|
33222
|
-
const inFlightPrepareRef = (0,
|
|
33223
|
-
const lastAppliedContentRef = (0,
|
|
33224
|
-
const extensions = (0,
|
|
33616
|
+
const inFlightPrepareRef = (0, import_react56.useRef)(null);
|
|
33617
|
+
const lastAppliedContentRef = (0, import_react56.useRef)(content ?? "");
|
|
33618
|
+
const extensions = (0, import_react56.useMemo)(
|
|
33225
33619
|
() => buildUEditorExtensions({
|
|
33226
33620
|
placeholder: effectivePlaceholder,
|
|
33227
33621
|
translate: t,
|
|
@@ -33235,7 +33629,7 @@ var UEditor = import_react54.default.forwardRef(({
|
|
|
33235
33629
|
}),
|
|
33236
33630
|
[effectivePlaceholder, t, maxCharacters, uploadImage, imageInsertMode, maxImageFileSize, allowedImageMimeTypes, fallbackToDataUrl, editable]
|
|
33237
33631
|
);
|
|
33238
|
-
const editor = (0,
|
|
33632
|
+
const editor = (0, import_react57.useEditor)({
|
|
33239
33633
|
immediatelyRender: false,
|
|
33240
33634
|
extensions,
|
|
33241
33635
|
content,
|
|
@@ -33281,7 +33675,7 @@ var UEditor = import_react54.default.forwardRef(({
|
|
|
33281
33675
|
tableRowGuideRef,
|
|
33282
33676
|
activeTableCellHighlightRef
|
|
33283
33677
|
} = useUEditorTableInteractions(editor, editable);
|
|
33284
|
-
(0,
|
|
33678
|
+
(0, import_react56.useImperativeHandle)(
|
|
33285
33679
|
ref,
|
|
33286
33680
|
() => ({
|
|
33287
33681
|
prepareContentForSave: async ({ throwOnError = false } = {}) => {
|
|
@@ -33304,7 +33698,7 @@ var UEditor = import_react54.default.forwardRef(({
|
|
|
33304
33698
|
}),
|
|
33305
33699
|
[content, editor, uploadImageForSave, uploadImageConcurrency]
|
|
33306
33700
|
);
|
|
33307
|
-
(0,
|
|
33701
|
+
(0, import_react56.useEffect)(() => {
|
|
33308
33702
|
if (!editor) return;
|
|
33309
33703
|
const nextContent = content ?? "";
|
|
33310
33704
|
if (lastAppliedContentRef.current === nextContent) return;
|
|
@@ -33399,7 +33793,7 @@ var UEditor = import_react54.default.forwardRef(({
|
|
|
33399
33793
|
),
|
|
33400
33794
|
editable && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(TableControls, { editor, containerRef: editorContentRef }),
|
|
33401
33795
|
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
|
|
33402
|
-
|
|
33796
|
+
import_react57.EditorContent,
|
|
33403
33797
|
{
|
|
33404
33798
|
editor,
|
|
33405
33799
|
className: "min-h-full"
|