@underverse-ui/underverse 1.0.123 → 1.0.125
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 +574 -549
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -2
- package/dist/index.d.ts +16 -2
- package/dist/index.js +766 -741
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4501,6 +4501,9 @@ var Label = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
4501
4501
|
));
|
|
4502
4502
|
Label.displayName = "Label";
|
|
4503
4503
|
|
|
4504
|
+
// src/components/Avatar.tsx
|
|
4505
|
+
import * as React16 from "react";
|
|
4506
|
+
|
|
4504
4507
|
// src/components/SmartImage.tsx
|
|
4505
4508
|
import Image2 from "next/image";
|
|
4506
4509
|
import React15 from "react";
|
|
@@ -4522,55 +4525,55 @@ function SmartImage({
|
|
|
4522
4525
|
quality = 80,
|
|
4523
4526
|
fit = "cover",
|
|
4524
4527
|
objectPosition,
|
|
4525
|
-
fallbackSrc = DEFAULT_FALLBACK
|
|
4528
|
+
fallbackSrc = DEFAULT_FALLBACK,
|
|
4529
|
+
transition = false,
|
|
4530
|
+
unoptimized = false
|
|
4526
4531
|
}) {
|
|
4527
|
-
const normalize2 = (
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4532
|
+
const normalize2 = React15.useCallback(
|
|
4533
|
+
(input) => {
|
|
4534
|
+
if (!input || input.length === 0) return fallbackSrc;
|
|
4535
|
+
const raw = input.trim();
|
|
4536
|
+
if (raw.startsWith("/images/products/") && /\.(jpg|jpeg)($|\?)/i.test(raw)) {
|
|
4537
|
+
return raw.replace(/\.(jpg|jpeg)(?=$|\?)/i, ".png");
|
|
4538
|
+
}
|
|
4539
|
+
if (raw.startsWith("//")) {
|
|
4540
|
+
return `https:${raw}`;
|
|
4541
|
+
}
|
|
4542
|
+
if (/^(https?:|data:|blob:)/i.test(raw)) {
|
|
4543
|
+
return FAILED_SRCS.has(raw) ? fallbackSrc : raw;
|
|
4544
|
+
}
|
|
4545
|
+
if (raw.startsWith("/")) {
|
|
4546
|
+
return FAILED_SRCS.has(raw) ? fallbackSrc : raw;
|
|
4547
|
+
}
|
|
4548
|
+
const normalized = `/${raw.replace(/^\.\/?/, "")}`;
|
|
4549
|
+
return FAILED_SRCS.has(normalized) ? fallbackSrc : normalized;
|
|
4550
|
+
},
|
|
4551
|
+
[fallbackSrc]
|
|
4552
|
+
);
|
|
4545
4553
|
const [resolvedSrc, setResolvedSrc] = React15.useState(() => normalize2(src));
|
|
4546
4554
|
React15.useEffect(() => {
|
|
4547
|
-
|
|
4548
|
-
|
|
4555
|
+
const next = normalize2(src);
|
|
4556
|
+
setResolvedSrc((current) => current === next ? current : next);
|
|
4557
|
+
}, [normalize2, src]);
|
|
4549
4558
|
const handleError = () => {
|
|
4550
4559
|
if (resolvedSrc && resolvedSrc !== fallbackSrc) FAILED_SRCS.add(resolvedSrc);
|
|
4551
|
-
if (
|
|
4552
|
-
const next = resolvedSrc.replace(/\.jpg(
|
|
4560
|
+
if (/\.(jpg|jpeg)(\?.*)?$/i.test(resolvedSrc)) {
|
|
4561
|
+
const next = resolvedSrc.replace(/\.(jpg|jpeg)(?=$|\?)/i, ".png");
|
|
4553
4562
|
setResolvedSrc(next);
|
|
4554
4563
|
} else if (resolvedSrc !== fallbackSrc) {
|
|
4555
4564
|
setResolvedSrc(fallbackSrc);
|
|
4556
4565
|
}
|
|
4557
4566
|
};
|
|
4558
|
-
const
|
|
4559
|
-
"
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0",
|
|
4565
|
-
ratioClass,
|
|
4566
|
-
roundedClass,
|
|
4567
|
-
className
|
|
4568
|
-
),
|
|
4569
|
-
children
|
|
4570
|
-
}
|
|
4567
|
+
const wrapperClass = cn(
|
|
4568
|
+
"relative overflow-hidden bg-muted/30",
|
|
4569
|
+
"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0",
|
|
4570
|
+
ratioClass,
|
|
4571
|
+
roundedClass,
|
|
4572
|
+
className
|
|
4571
4573
|
);
|
|
4574
|
+
const imgClass = cn(transition ? "transition-opacity duration-300" : "transition-none", imageClassName);
|
|
4572
4575
|
if (fill) {
|
|
4573
|
-
return /* @__PURE__ */ jsx17(
|
|
4576
|
+
return /* @__PURE__ */ jsx17("div", { className: wrapperClass, children: /* @__PURE__ */ jsx17(
|
|
4574
4577
|
Image2,
|
|
4575
4578
|
{
|
|
4576
4579
|
src: resolvedSrc,
|
|
@@ -4580,8 +4583,9 @@ function SmartImage({
|
|
|
4580
4583
|
onError: handleError,
|
|
4581
4584
|
priority,
|
|
4582
4585
|
quality,
|
|
4586
|
+
unoptimized,
|
|
4583
4587
|
style: { objectFit: fit, objectPosition },
|
|
4584
|
-
className:
|
|
4588
|
+
className: imgClass
|
|
4585
4589
|
}
|
|
4586
4590
|
) });
|
|
4587
4591
|
}
|
|
@@ -4605,8 +4609,9 @@ function SmartImage({
|
|
|
4605
4609
|
onError: handleError,
|
|
4606
4610
|
priority,
|
|
4607
4611
|
quality,
|
|
4612
|
+
unoptimized,
|
|
4608
4613
|
style: { objectFit: fit, objectPosition, width: "100%", height: "100%" },
|
|
4609
|
-
className:
|
|
4614
|
+
className: imgClass
|
|
4610
4615
|
}
|
|
4611
4616
|
)
|
|
4612
4617
|
}
|
|
@@ -4634,7 +4639,7 @@ var statusDotSizes = {
|
|
|
4634
4639
|
lg: "w-4 h-4 border-2",
|
|
4635
4640
|
xl: "w-5 h-5 border-[3px]"
|
|
4636
4641
|
};
|
|
4637
|
-
var Avatar = ({
|
|
4642
|
+
var Avatar = React16.memo(function Avatar2({
|
|
4638
4643
|
src,
|
|
4639
4644
|
alt = "avatar",
|
|
4640
4645
|
fallback = "?",
|
|
@@ -4642,11 +4647,15 @@ var Avatar = ({
|
|
|
4642
4647
|
showStatus = true,
|
|
4643
4648
|
status = "online",
|
|
4644
4649
|
hideStatusOnHover = true,
|
|
4650
|
+
imageStrategy = "img",
|
|
4651
|
+
imageLoading = "lazy",
|
|
4652
|
+
imageFetchPriority,
|
|
4645
4653
|
className,
|
|
4646
4654
|
onClick,
|
|
4647
4655
|
...props
|
|
4648
|
-
})
|
|
4656
|
+
}) {
|
|
4649
4657
|
const hasValidSrc = !!(src && src.trim().length > 0);
|
|
4658
|
+
const fallbackText = (fallback || "?").trim().charAt(0).toUpperCase() || "?";
|
|
4650
4659
|
return /* @__PURE__ */ jsxs10(
|
|
4651
4660
|
"div",
|
|
4652
4661
|
{
|
|
@@ -4660,7 +4669,19 @@ var Avatar = ({
|
|
|
4660
4669
|
...props,
|
|
4661
4670
|
children: [
|
|
4662
4671
|
/* @__PURE__ */ jsxs10("div", { className: "absolute inset-0 overflow-hidden rounded-full", children: [
|
|
4663
|
-
hasValidSrc && /* @__PURE__ */ jsx18(
|
|
4672
|
+
hasValidSrc && imageStrategy === "img" && /* @__PURE__ */ jsx18(
|
|
4673
|
+
"img",
|
|
4674
|
+
{
|
|
4675
|
+
src,
|
|
4676
|
+
alt,
|
|
4677
|
+
loading: imageLoading,
|
|
4678
|
+
decoding: "async",
|
|
4679
|
+
draggable: false,
|
|
4680
|
+
fetchPriority: imageFetchPriority,
|
|
4681
|
+
className: "h-full w-full object-cover"
|
|
4682
|
+
}
|
|
4683
|
+
),
|
|
4684
|
+
hasValidSrc && imageStrategy === "next-image" && /* @__PURE__ */ jsx18(
|
|
4664
4685
|
SmartImage,
|
|
4665
4686
|
{
|
|
4666
4687
|
src,
|
|
@@ -4671,7 +4692,8 @@ var Avatar = ({
|
|
|
4671
4692
|
roundedClass: "rounded-full",
|
|
4672
4693
|
fit: "cover",
|
|
4673
4694
|
objectPosition: "center",
|
|
4674
|
-
quality: 80
|
|
4695
|
+
quality: 80,
|
|
4696
|
+
imageClassName: "transition-none"
|
|
4675
4697
|
}
|
|
4676
4698
|
),
|
|
4677
4699
|
!hasValidSrc && /* @__PURE__ */ jsx18("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsx18(
|
|
@@ -4681,7 +4703,7 @@ var Avatar = ({
|
|
|
4681
4703
|
"font-bold uppercase bg-linear-to-br from-primary to-primary/80 bg-clip-text text-transparent",
|
|
4682
4704
|
"transition-all duration-200 animate-fade-in"
|
|
4683
4705
|
),
|
|
4684
|
-
children:
|
|
4706
|
+
children: fallbackText
|
|
4685
4707
|
}
|
|
4686
4708
|
) })
|
|
4687
4709
|
] }),
|
|
@@ -4700,7 +4722,7 @@ var Avatar = ({
|
|
|
4700
4722
|
]
|
|
4701
4723
|
}
|
|
4702
4724
|
);
|
|
4703
|
-
};
|
|
4725
|
+
});
|
|
4704
4726
|
var Avatar_default = Avatar;
|
|
4705
4727
|
|
|
4706
4728
|
// src/components/Skeleton.tsx
|
|
@@ -4828,7 +4850,7 @@ var SkeletonTable = ({ rows = 5, columns = 4, className }) => {
|
|
|
4828
4850
|
var Skeleton_default = Skeleton;
|
|
4829
4851
|
|
|
4830
4852
|
// src/components/Progress.tsx
|
|
4831
|
-
import
|
|
4853
|
+
import React17 from "react";
|
|
4832
4854
|
import { Check as Check2, X as X4, Clock } from "lucide-react";
|
|
4833
4855
|
import { Fragment as Fragment4, jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4834
4856
|
var variantStyles3 = {
|
|
@@ -4862,8 +4884,8 @@ var Progress = ({
|
|
|
4862
4884
|
const percentage = Math.min(Math.max(value / max * 100, 0), 100);
|
|
4863
4885
|
const isComplete = status === "complete" || percentage >= 100;
|
|
4864
4886
|
const isError = status === "error";
|
|
4865
|
-
const labelId =
|
|
4866
|
-
const descId =
|
|
4887
|
+
const labelId = React17.useId();
|
|
4888
|
+
const descId = React17.useId();
|
|
4867
4889
|
const getStatusIcon = () => {
|
|
4868
4890
|
if (isComplete) return /* @__PURE__ */ jsx20(Check2, { className: "w-4 h-4 text-success" });
|
|
4869
4891
|
if (isError) return /* @__PURE__ */ jsx20(X4, { className: "w-4 h-4 text-destructive" });
|
|
@@ -5196,7 +5218,7 @@ var LoadingProgress = ({
|
|
|
5196
5218
|
};
|
|
5197
5219
|
|
|
5198
5220
|
// src/components/Modal.tsx
|
|
5199
|
-
import * as
|
|
5221
|
+
import * as React18 from "react";
|
|
5200
5222
|
import { createPortal as createPortal2 } from "react-dom";
|
|
5201
5223
|
import { X as X5 } from "lucide-react";
|
|
5202
5224
|
import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
@@ -5226,17 +5248,17 @@ var Modal = ({
|
|
|
5226
5248
|
height
|
|
5227
5249
|
}) => {
|
|
5228
5250
|
const gi18n = useGlobalI18n();
|
|
5229
|
-
const [isMounted, setIsMounted] =
|
|
5230
|
-
const [isVisible, setIsVisible] =
|
|
5231
|
-
const [isAnimating, setIsAnimating] =
|
|
5232
|
-
const mouseDownTarget =
|
|
5233
|
-
const modalContentRef =
|
|
5234
|
-
|
|
5251
|
+
const [isMounted, setIsMounted] = React18.useState(false);
|
|
5252
|
+
const [isVisible, setIsVisible] = React18.useState(false);
|
|
5253
|
+
const [isAnimating, setIsAnimating] = React18.useState(true);
|
|
5254
|
+
const mouseDownTarget = React18.useRef(null);
|
|
5255
|
+
const modalContentRef = React18.useRef(null);
|
|
5256
|
+
React18.useEffect(() => {
|
|
5235
5257
|
setIsMounted(true);
|
|
5236
5258
|
return () => setIsMounted(false);
|
|
5237
5259
|
}, []);
|
|
5238
|
-
const animationRef =
|
|
5239
|
-
|
|
5260
|
+
const animationRef = React18.useRef(false);
|
|
5261
|
+
React18.useEffect(() => {
|
|
5240
5262
|
if (isOpen) {
|
|
5241
5263
|
if (animationRef.current) return;
|
|
5242
5264
|
animationRef.current = true;
|
|
@@ -5256,7 +5278,7 @@ var Modal = ({
|
|
|
5256
5278
|
}
|
|
5257
5279
|
}
|
|
5258
5280
|
}, [isOpen, isVisible]);
|
|
5259
|
-
|
|
5281
|
+
React18.useEffect(() => {
|
|
5260
5282
|
if (!isOpen || !closeOnEsc) return;
|
|
5261
5283
|
const handleEscape = (event) => {
|
|
5262
5284
|
if (event.key === "Escape") {
|
|
@@ -5266,7 +5288,7 @@ var Modal = ({
|
|
|
5266
5288
|
document.addEventListener("keydown", handleEscape);
|
|
5267
5289
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
5268
5290
|
}, [isOpen, closeOnEsc, onClose]);
|
|
5269
|
-
|
|
5291
|
+
React18.useEffect(() => {
|
|
5270
5292
|
if (isOpen) {
|
|
5271
5293
|
document.body.style.overflow = "hidden";
|
|
5272
5294
|
} else {
|
|
@@ -5552,7 +5574,7 @@ var ToastComponent = ({ toast, onRemove }) => {
|
|
|
5552
5574
|
var Toast_default = ToastProvider;
|
|
5553
5575
|
|
|
5554
5576
|
// src/components/Popover.tsx
|
|
5555
|
-
import * as
|
|
5577
|
+
import * as React20 from "react";
|
|
5556
5578
|
import { createPortal as createPortal3 } from "react-dom";
|
|
5557
5579
|
|
|
5558
5580
|
// src/utils/animations.ts
|
|
@@ -5842,14 +5864,14 @@ var Popover = ({
|
|
|
5842
5864
|
contentWidth
|
|
5843
5865
|
}) => {
|
|
5844
5866
|
const isControlled = open !== void 0;
|
|
5845
|
-
const [internalOpen, setInternalOpen] =
|
|
5846
|
-
const triggerRef =
|
|
5847
|
-
const positionerRef =
|
|
5848
|
-
const panelRef =
|
|
5849
|
-
const lastAppliedRef =
|
|
5867
|
+
const [internalOpen, setInternalOpen] = React20.useState(false);
|
|
5868
|
+
const triggerRef = React20.useRef(null);
|
|
5869
|
+
const positionerRef = React20.useRef(null);
|
|
5870
|
+
const panelRef = React20.useRef(null);
|
|
5871
|
+
const lastAppliedRef = React20.useRef(null);
|
|
5850
5872
|
useShadCNAnimations();
|
|
5851
5873
|
const isOpen = isControlled ? open : internalOpen;
|
|
5852
|
-
const setIsOpen =
|
|
5874
|
+
const setIsOpen = React20.useCallback(
|
|
5853
5875
|
(next) => {
|
|
5854
5876
|
if (!isControlled) setInternalOpen(next);
|
|
5855
5877
|
onOpenChange?.(next);
|
|
@@ -5858,16 +5880,16 @@ var Popover = ({
|
|
|
5858
5880
|
);
|
|
5859
5881
|
const offset = 4;
|
|
5860
5882
|
const padding = 8;
|
|
5861
|
-
const triggerSelector =
|
|
5862
|
-
const initialPlacement =
|
|
5863
|
-
|
|
5883
|
+
const triggerSelector = React20.useId();
|
|
5884
|
+
const initialPlacement = React20.useMemo(() => normalizePlacement(placement), [placement]);
|
|
5885
|
+
React20.useLayoutEffect(() => {
|
|
5864
5886
|
if (typeof document === "undefined") return;
|
|
5865
5887
|
const triggerEl = document.querySelector(`[data-underverse-popover-trigger="${triggerSelector}"]`);
|
|
5866
5888
|
if (triggerEl) {
|
|
5867
5889
|
triggerRef.current = triggerEl;
|
|
5868
5890
|
}
|
|
5869
5891
|
}, [triggerSelector, trigger]);
|
|
5870
|
-
const updatePosition =
|
|
5892
|
+
const updatePosition = React20.useCallback(() => {
|
|
5871
5893
|
const triggerEl = triggerRef.current;
|
|
5872
5894
|
const positionerEl = positionerRef.current;
|
|
5873
5895
|
const panelEl = panelRef.current;
|
|
@@ -5904,7 +5926,7 @@ var Popover = ({
|
|
|
5904
5926
|
if (positionerEl.style.visibility !== "visible") positionerEl.style.visibility = "visible";
|
|
5905
5927
|
if (positionerEl.style.pointerEvents !== "auto") positionerEl.style.pointerEvents = "auto";
|
|
5906
5928
|
}, [placement, matchTriggerWidth, contentWidth]);
|
|
5907
|
-
|
|
5929
|
+
React20.useLayoutEffect(() => {
|
|
5908
5930
|
if (!isOpen) return;
|
|
5909
5931
|
updatePosition();
|
|
5910
5932
|
let raf1 = 0;
|
|
@@ -5918,7 +5940,7 @@ var Popover = ({
|
|
|
5918
5940
|
cancelAnimationFrame(raf2);
|
|
5919
5941
|
};
|
|
5920
5942
|
}, [isOpen, updatePosition]);
|
|
5921
|
-
|
|
5943
|
+
React20.useEffect(() => {
|
|
5922
5944
|
if (!isOpen) return;
|
|
5923
5945
|
let raf = 0;
|
|
5924
5946
|
const tick = () => {
|
|
@@ -5928,7 +5950,7 @@ var Popover = ({
|
|
|
5928
5950
|
raf = window.requestAnimationFrame(tick);
|
|
5929
5951
|
return () => window.cancelAnimationFrame(raf);
|
|
5930
5952
|
}, [isOpen, updatePosition]);
|
|
5931
|
-
|
|
5953
|
+
React20.useEffect(() => {
|
|
5932
5954
|
if (!isOpen) return;
|
|
5933
5955
|
let raf = 0;
|
|
5934
5956
|
const handler = () => {
|
|
@@ -5946,7 +5968,7 @@ var Popover = ({
|
|
|
5946
5968
|
document.removeEventListener("scroll", handler, true);
|
|
5947
5969
|
};
|
|
5948
5970
|
}, [isOpen, updatePosition]);
|
|
5949
|
-
|
|
5971
|
+
React20.useEffect(() => {
|
|
5950
5972
|
if (!isOpen) return;
|
|
5951
5973
|
if (typeof ResizeObserver === "undefined") return;
|
|
5952
5974
|
const ro = new ResizeObserver(() => updatePosition());
|
|
@@ -5954,13 +5976,13 @@ var Popover = ({
|
|
|
5954
5976
|
if (triggerRef.current) ro.observe(triggerRef.current);
|
|
5955
5977
|
return () => ro.disconnect();
|
|
5956
5978
|
}, [isOpen, updatePosition]);
|
|
5957
|
-
|
|
5979
|
+
React20.useLayoutEffect(() => {
|
|
5958
5980
|
if (!isOpen) {
|
|
5959
5981
|
lastAppliedRef.current = null;
|
|
5960
5982
|
return;
|
|
5961
5983
|
}
|
|
5962
5984
|
}, [isOpen]);
|
|
5963
|
-
|
|
5985
|
+
React20.useEffect(() => {
|
|
5964
5986
|
if (!isOpen) return;
|
|
5965
5987
|
const handleClickOutside = (event) => {
|
|
5966
5988
|
const target = event.target;
|
|
@@ -6046,7 +6068,7 @@ var Popover = ({
|
|
|
6046
6068
|
(() => {
|
|
6047
6069
|
const triggerProps = trigger.props;
|
|
6048
6070
|
const childRef = triggerProps.ref;
|
|
6049
|
-
return
|
|
6071
|
+
return React20.cloneElement(trigger, {
|
|
6050
6072
|
...triggerProps,
|
|
6051
6073
|
ref: mergeRefs(childRef, (node) => {
|
|
6052
6074
|
triggerRef.current = node;
|
|
@@ -6076,7 +6098,7 @@ var Popover = ({
|
|
|
6076
6098
|
};
|
|
6077
6099
|
|
|
6078
6100
|
// src/components/Sheet.tsx
|
|
6079
|
-
import * as
|
|
6101
|
+
import * as React21 from "react";
|
|
6080
6102
|
import { createPortal as createPortal4 } from "react-dom";
|
|
6081
6103
|
import { X as X7 } from "lucide-react";
|
|
6082
6104
|
import { jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
@@ -6162,19 +6184,19 @@ var Sheet = ({
|
|
|
6162
6184
|
onResize
|
|
6163
6185
|
}) => {
|
|
6164
6186
|
const gi18n = useGlobalI18n();
|
|
6165
|
-
const [mounted, setMounted] =
|
|
6166
|
-
const [isAnimating, setIsAnimating] =
|
|
6167
|
-
const [isVisible, setIsVisible] =
|
|
6168
|
-
const [isResizing, setIsResizing] =
|
|
6169
|
-
const [sheetSize, setSheetSize] =
|
|
6170
|
-
const sheetRef =
|
|
6171
|
-
const resizeStateRef =
|
|
6187
|
+
const [mounted, setMounted] = React21.useState(false);
|
|
6188
|
+
const [isAnimating, setIsAnimating] = React21.useState(true);
|
|
6189
|
+
const [isVisible, setIsVisible] = React21.useState(false);
|
|
6190
|
+
const [isResizing, setIsResizing] = React21.useState(false);
|
|
6191
|
+
const [sheetSize, setSheetSize] = React21.useState(null);
|
|
6192
|
+
const sheetRef = React21.useRef(null);
|
|
6193
|
+
const resizeStateRef = React21.useRef(null);
|
|
6172
6194
|
const isHorizontalSheet = side === "left" || side === "right";
|
|
6173
6195
|
const canResize = resizable && size !== "full";
|
|
6174
|
-
|
|
6196
|
+
React21.useEffect(() => {
|
|
6175
6197
|
setMounted(true);
|
|
6176
6198
|
}, []);
|
|
6177
|
-
|
|
6199
|
+
React21.useEffect(() => {
|
|
6178
6200
|
if (!closeOnEscape) return;
|
|
6179
6201
|
const handleEscape = (e) => {
|
|
6180
6202
|
if (e.key === "Escape" && open) {
|
|
@@ -6184,7 +6206,7 @@ var Sheet = ({
|
|
|
6184
6206
|
document.addEventListener("keydown", handleEscape);
|
|
6185
6207
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
6186
6208
|
}, [open, closeOnEscape, onOpenChange]);
|
|
6187
|
-
|
|
6209
|
+
React21.useEffect(() => {
|
|
6188
6210
|
if (open) {
|
|
6189
6211
|
document.body.style.overflow = "hidden";
|
|
6190
6212
|
} else {
|
|
@@ -6194,7 +6216,7 @@ var Sheet = ({
|
|
|
6194
6216
|
document.body.style.overflow = "unset";
|
|
6195
6217
|
};
|
|
6196
6218
|
}, [open]);
|
|
6197
|
-
|
|
6219
|
+
React21.useEffect(() => {
|
|
6198
6220
|
if (open) {
|
|
6199
6221
|
setIsVisible(true);
|
|
6200
6222
|
setIsAnimating(true);
|
|
@@ -6217,19 +6239,19 @@ var Sheet = ({
|
|
|
6217
6239
|
const handleClose = () => {
|
|
6218
6240
|
onOpenChange(false);
|
|
6219
6241
|
};
|
|
6220
|
-
const clampResizeSize =
|
|
6242
|
+
const clampResizeSize = React21.useCallback((nextSize) => {
|
|
6221
6243
|
const viewportSize = isHorizontalSheet ? window.innerWidth : window.innerHeight;
|
|
6222
6244
|
const resolvedMaxSize = maxSize ?? Math.round(viewportSize * 0.9);
|
|
6223
6245
|
return Math.min(Math.max(nextSize, minSize), resolvedMaxSize);
|
|
6224
6246
|
}, [isHorizontalSheet, maxSize, minSize]);
|
|
6225
|
-
const endResize =
|
|
6247
|
+
const endResize = React21.useCallback(() => {
|
|
6226
6248
|
if (!resizeStateRef.current) return;
|
|
6227
6249
|
resizeStateRef.current = null;
|
|
6228
6250
|
setIsResizing(false);
|
|
6229
6251
|
document.body.style.cursor = "";
|
|
6230
6252
|
document.body.style.userSelect = "";
|
|
6231
6253
|
}, []);
|
|
6232
|
-
const handleResizePointerMove =
|
|
6254
|
+
const handleResizePointerMove = React21.useCallback((event) => {
|
|
6233
6255
|
const resizeState = resizeStateRef.current;
|
|
6234
6256
|
if (!resizeState || event.pointerId !== resizeState.pointerId) return;
|
|
6235
6257
|
const delta = isHorizontalSheet ? side === "right" ? resizeState.startClientX - event.clientX : event.clientX - resizeState.startClientX : side === "bottom" ? resizeState.startClientY - event.clientY : event.clientY - resizeState.startClientY;
|
|
@@ -6237,12 +6259,12 @@ var Sheet = ({
|
|
|
6237
6259
|
setSheetSize(nextSize);
|
|
6238
6260
|
onResize?.(nextSize);
|
|
6239
6261
|
}, [clampResizeSize, isHorizontalSheet, onResize, side]);
|
|
6240
|
-
const handleResizePointerUp =
|
|
6262
|
+
const handleResizePointerUp = React21.useCallback((event) => {
|
|
6241
6263
|
const resizeState = resizeStateRef.current;
|
|
6242
6264
|
if (!resizeState || event.pointerId !== resizeState.pointerId) return;
|
|
6243
6265
|
endResize();
|
|
6244
6266
|
}, [endResize]);
|
|
6245
|
-
|
|
6267
|
+
React21.useEffect(() => {
|
|
6246
6268
|
if (!isResizing) return void 0;
|
|
6247
6269
|
window.addEventListener("pointermove", handleResizePointerMove);
|
|
6248
6270
|
window.addEventListener("pointerup", handleResizePointerUp);
|
|
@@ -6253,10 +6275,10 @@ var Sheet = ({
|
|
|
6253
6275
|
window.removeEventListener("pointercancel", handleResizePointerUp);
|
|
6254
6276
|
};
|
|
6255
6277
|
}, [handleResizePointerMove, handleResizePointerUp, isResizing]);
|
|
6256
|
-
|
|
6278
|
+
React21.useEffect(() => {
|
|
6257
6279
|
if (!open) endResize();
|
|
6258
6280
|
}, [endResize, open]);
|
|
6259
|
-
|
|
6281
|
+
React21.useEffect(() => endResize, [endResize]);
|
|
6260
6282
|
const handleResizePointerDown = (event) => {
|
|
6261
6283
|
if (!canResize || !sheetRef.current) return;
|
|
6262
6284
|
const rect = sheetRef.current.getBoundingClientRect();
|
|
@@ -6474,7 +6496,7 @@ var Alert = ({
|
|
|
6474
6496
|
var Alert_default = Alert;
|
|
6475
6497
|
|
|
6476
6498
|
// src/components/GlobalLoading.tsx
|
|
6477
|
-
import
|
|
6499
|
+
import React22, { useEffect as useEffect10, useState as useState14 } from "react";
|
|
6478
6500
|
import { Activity as Activity2 } from "lucide-react";
|
|
6479
6501
|
|
|
6480
6502
|
// src/utils/loading.ts
|
|
@@ -6580,7 +6602,7 @@ var InlineLoading = ({ isLoading, text, className, size = "md" }) => {
|
|
|
6580
6602
|
] });
|
|
6581
6603
|
};
|
|
6582
6604
|
var ButtonLoading = ({ isLoading, children, className, disabled, loadingText }) => {
|
|
6583
|
-
const child =
|
|
6605
|
+
const child = React22.isValidElement(children) ? React22.cloneElement(children, {
|
|
6584
6606
|
disabled: (children.props?.disabled ?? false) || disabled || isLoading,
|
|
6585
6607
|
"aria-busy": isLoading || void 0
|
|
6586
6608
|
}) : children;
|
|
@@ -6594,7 +6616,7 @@ var ButtonLoading = ({ isLoading, children, className, disabled, loadingText })
|
|
|
6594
6616
|
};
|
|
6595
6617
|
|
|
6596
6618
|
// src/components/Breadcrumb.tsx
|
|
6597
|
-
import * as
|
|
6619
|
+
import * as React23 from "react";
|
|
6598
6620
|
import { ChevronRight, Home, MoreHorizontal } from "lucide-react";
|
|
6599
6621
|
import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
6600
6622
|
var NextLink = null;
|
|
@@ -6642,8 +6664,8 @@ var Breadcrumb = ({
|
|
|
6642
6664
|
collapsible = true
|
|
6643
6665
|
}) => {
|
|
6644
6666
|
const gi18n = useGlobalI18n();
|
|
6645
|
-
const [isCollapsed, setIsCollapsed] =
|
|
6646
|
-
|
|
6667
|
+
const [isCollapsed, setIsCollapsed] = React23.useState(false);
|
|
6668
|
+
React23.useEffect(() => {
|
|
6647
6669
|
if (collapsible && items.length > maxItems) {
|
|
6648
6670
|
setIsCollapsed(true);
|
|
6649
6671
|
}
|
|
@@ -6661,7 +6683,7 @@ var Breadcrumb = ({
|
|
|
6661
6683
|
const SeparatorComponent = separator;
|
|
6662
6684
|
return /* @__PURE__ */ jsx27(SeparatorComponent, { className: cn("text-muted-foreground", sizeStyles5[size].icon) });
|
|
6663
6685
|
};
|
|
6664
|
-
const processedItems =
|
|
6686
|
+
const processedItems = React23.useMemo(() => {
|
|
6665
6687
|
let finalItems = [...items];
|
|
6666
6688
|
if (showHome && finalItems[0]?.href !== homeHref) {
|
|
6667
6689
|
finalItems.unshift({
|
|
@@ -6734,7 +6756,7 @@ var Breadcrumb = ({
|
|
|
6734
6756
|
var Breadcrumb_default = Breadcrumb;
|
|
6735
6757
|
|
|
6736
6758
|
// src/components/Tab.tsx
|
|
6737
|
-
import * as
|
|
6759
|
+
import * as React24 from "react";
|
|
6738
6760
|
import { jsx as jsx28, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
6739
6761
|
var sizeStyles6 = {
|
|
6740
6762
|
sm: {
|
|
@@ -6832,11 +6854,11 @@ var Tabs = ({
|
|
|
6832
6854
|
noContentPadding = false,
|
|
6833
6855
|
animateContent = true
|
|
6834
6856
|
}) => {
|
|
6835
|
-
const [active, setActive] =
|
|
6836
|
-
const [underlineStyle, setUnderlineStyle] =
|
|
6837
|
-
const tabRefs =
|
|
6838
|
-
const autoId =
|
|
6839
|
-
const baseId =
|
|
6857
|
+
const [active, setActive] = React24.useState(defaultValue || tabs[0]?.value);
|
|
6858
|
+
const [underlineStyle, setUnderlineStyle] = React24.useState({});
|
|
6859
|
+
const tabRefs = React24.useRef([]);
|
|
6860
|
+
const autoId = React24.useId();
|
|
6861
|
+
const baseId = React24.useMemo(() => getTabsBaseId(tabs, id, autoId), [autoId, id, tabs]);
|
|
6840
6862
|
const handleTabChange = (value) => {
|
|
6841
6863
|
setActive(value);
|
|
6842
6864
|
onTabChange?.(value);
|
|
@@ -6863,7 +6885,7 @@ var Tabs = ({
|
|
|
6863
6885
|
tabRefs.current[next]?.focus();
|
|
6864
6886
|
}
|
|
6865
6887
|
};
|
|
6866
|
-
|
|
6888
|
+
React24.useEffect(() => {
|
|
6867
6889
|
if (variant === "underline" && orientation === "horizontal") {
|
|
6868
6890
|
const activeIndex2 = tabs.findIndex((tab) => tab.value === active);
|
|
6869
6891
|
const activeTab2 = tabRefs.current[activeIndex2];
|
|
@@ -6876,7 +6898,7 @@ var Tabs = ({
|
|
|
6876
6898
|
}
|
|
6877
6899
|
}
|
|
6878
6900
|
}, [active, variant, orientation, tabs]);
|
|
6879
|
-
|
|
6901
|
+
React24.useEffect(() => {
|
|
6880
6902
|
if (typeof window === "undefined") return;
|
|
6881
6903
|
const syncFromHash = () => {
|
|
6882
6904
|
const nextValue = resolveTabValueFromHash(window.location.hash, tabs, baseId);
|
|
@@ -7006,12 +7028,12 @@ var VerticalTabs = ({ sidebarWidth = "w-48", className, ...props }) => {
|
|
|
7006
7028
|
};
|
|
7007
7029
|
|
|
7008
7030
|
// src/components/DropdownMenu.tsx
|
|
7009
|
-
import
|
|
7031
|
+
import React25, { useState as useState17 } from "react";
|
|
7010
7032
|
import { jsx as jsx29, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
7011
7033
|
function useResettingIndex(resetToken) {
|
|
7012
|
-
const [state, setState] =
|
|
7034
|
+
const [state, setState] = React25.useState({ resetToken, index: -1 });
|
|
7013
7035
|
const activeIndex = Object.is(state.resetToken, resetToken) ? state.index : -1;
|
|
7014
|
-
const setActiveIndex =
|
|
7036
|
+
const setActiveIndex = React25.useCallback((nextIndex) => {
|
|
7015
7037
|
setState((prev) => {
|
|
7016
7038
|
const prevIndex = Object.is(prev.resetToken, resetToken) ? prev.index : -1;
|
|
7017
7039
|
return {
|
|
@@ -7037,12 +7059,12 @@ var DropdownMenu = ({
|
|
|
7037
7059
|
const [internalOpen, setInternalOpen] = useState17(false);
|
|
7038
7060
|
const open = isOpen !== void 0 ? isOpen : internalOpen;
|
|
7039
7061
|
const setOpen = onOpenChange || setInternalOpen;
|
|
7040
|
-
const triggerRef =
|
|
7041
|
-
const menuRef =
|
|
7042
|
-
const itemsRef =
|
|
7062
|
+
const triggerRef = React25.useRef(null);
|
|
7063
|
+
const menuRef = React25.useRef(null);
|
|
7064
|
+
const itemsRef = React25.useRef([]);
|
|
7043
7065
|
const [activeIndex, setActiveIndex] = useResettingIndex(open);
|
|
7044
7066
|
useShadCNAnimations();
|
|
7045
|
-
|
|
7067
|
+
React25.useEffect(() => {
|
|
7046
7068
|
if (!open) return;
|
|
7047
7069
|
const handleKeyNav = (e) => {
|
|
7048
7070
|
const active = document.activeElement;
|
|
@@ -7118,7 +7140,7 @@ var DropdownMenu = ({
|
|
|
7118
7140
|
}) : children });
|
|
7119
7141
|
const triggerProps = trigger.props;
|
|
7120
7142
|
const childRef = triggerProps.ref;
|
|
7121
|
-
const enhancedTrigger =
|
|
7143
|
+
const enhancedTrigger = React25.cloneElement(trigger, {
|
|
7122
7144
|
...triggerProps,
|
|
7123
7145
|
ref: mergeRefs(childRef, (node) => {
|
|
7124
7146
|
triggerRef.current = node;
|
|
@@ -7228,11 +7250,11 @@ var SelectDropdown = ({ options, value, onChange, placeholder = "Select...", cla
|
|
|
7228
7250
|
var DropdownMenu_default = DropdownMenu;
|
|
7229
7251
|
|
|
7230
7252
|
// src/components/Pagination.tsx
|
|
7231
|
-
import * as
|
|
7253
|
+
import * as React27 from "react";
|
|
7232
7254
|
import { ChevronLeft, ChevronRight as ChevronRight2, ChevronsLeft, ChevronsRight } from "lucide-react";
|
|
7233
7255
|
|
|
7234
7256
|
// src/components/Combobox.tsx
|
|
7235
|
-
import * as
|
|
7257
|
+
import * as React26 from "react";
|
|
7236
7258
|
import { useId as useId6 } from "react";
|
|
7237
7259
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
7238
7260
|
import { ChevronDown, Search as Search4, SearchX, Check as Check3, X as X9 } from "lucide-react";
|
|
@@ -7314,13 +7336,13 @@ var Combobox = ({
|
|
|
7314
7336
|
const searchPlaceholder = searchPlaceholderProp ?? gi18n.searchPlaceholder ?? "Search\u2026";
|
|
7315
7337
|
const emptyText = emptyTextProp ?? gi18n.noResults ?? "No results found";
|
|
7316
7338
|
const loadingText = loadingTextProp ?? gi18n.loading ?? "Loading...";
|
|
7317
|
-
const [open, setOpen] =
|
|
7318
|
-
const [query, setQuery] =
|
|
7319
|
-
const [activeIndex, setActiveIndex] =
|
|
7320
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
7339
|
+
const [open, setOpen] = React26.useState(false);
|
|
7340
|
+
const [query, setQuery] = React26.useState("");
|
|
7341
|
+
const [activeIndex, setActiveIndex] = React26.useState(null);
|
|
7342
|
+
const [localRequiredError, setLocalRequiredError] = React26.useState();
|
|
7321
7343
|
useShadCNAnimations();
|
|
7322
|
-
const inputRef =
|
|
7323
|
-
const optionsViewportRef =
|
|
7344
|
+
const inputRef = React26.useRef(null);
|
|
7345
|
+
const optionsViewportRef = React26.useRef(null);
|
|
7324
7346
|
useOverlayScrollbarTarget(optionsViewportRef, { enabled: open && useOverlayScrollbar && !virtualized });
|
|
7325
7347
|
const autoId = useId6();
|
|
7326
7348
|
const resolvedId = id ? String(id) : `combobox-${autoId}`;
|
|
@@ -7329,7 +7351,7 @@ var Combobox = ({
|
|
|
7329
7351
|
const trimmedQuery = query.trim();
|
|
7330
7352
|
const queryMeetsMinimum = trimmedQuery.length >= minSearchLength;
|
|
7331
7353
|
const shouldPromptForSearch = minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
7332
|
-
const filteredOptions =
|
|
7354
|
+
const filteredOptions = React26.useMemo(
|
|
7333
7355
|
() => {
|
|
7334
7356
|
if (shouldPromptForSearch) return [];
|
|
7335
7357
|
if (!enableSearch || searchMode === "manual") return options;
|
|
@@ -7339,7 +7361,7 @@ var Combobox = ({
|
|
|
7339
7361
|
},
|
|
7340
7362
|
[enableSearch, options, searchMode, shouldPromptForSearch, trimmedQuery]
|
|
7341
7363
|
);
|
|
7342
|
-
const renderLimitedOptions =
|
|
7364
|
+
const renderLimitedOptions = React26.useMemo(
|
|
7343
7365
|
() => {
|
|
7344
7366
|
if (trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
7345
7367
|
return filteredOptions;
|
|
@@ -7358,15 +7380,15 @@ var Combobox = ({
|
|
|
7358
7380
|
enabled: canVirtualize
|
|
7359
7381
|
});
|
|
7360
7382
|
const virtualItems = canVirtualize ? optionVirtualizer.getVirtualItems() : [];
|
|
7361
|
-
const triggerRef =
|
|
7362
|
-
const scrollVirtualListToIndex =
|
|
7383
|
+
const triggerRef = React26.useRef(null);
|
|
7384
|
+
const scrollVirtualListToIndex = React26.useCallback((index) => {
|
|
7363
7385
|
if (!canVirtualize || renderLimitedOptions.length === 0) return;
|
|
7364
7386
|
optionVirtualizer.scrollToIndex(index, { align: "auto" });
|
|
7365
7387
|
}, [canVirtualize, optionVirtualizer, renderLimitedOptions.length]);
|
|
7366
|
-
const scrollVirtualListToStart =
|
|
7388
|
+
const scrollVirtualListToStart = React26.useCallback(() => {
|
|
7367
7389
|
scrollVirtualListToIndex(0);
|
|
7368
7390
|
}, [scrollVirtualListToIndex]);
|
|
7369
|
-
const moveActiveIndex =
|
|
7391
|
+
const moveActiveIndex = React26.useCallback((direction) => {
|
|
7370
7392
|
if (renderLimitedOptions.length === 0) return;
|
|
7371
7393
|
const next = activeIndex === null ? direction === 1 ? 0 : renderLimitedOptions.length - 1 : (activeIndex + direction + renderLimitedOptions.length) % renderLimitedOptions.length;
|
|
7372
7394
|
setActiveIndex(next);
|
|
@@ -7390,7 +7412,7 @@ var Combobox = ({
|
|
|
7390
7412
|
onChange(null);
|
|
7391
7413
|
setOpen(false);
|
|
7392
7414
|
};
|
|
7393
|
-
|
|
7415
|
+
React26.useEffect(() => {
|
|
7394
7416
|
if (!open) {
|
|
7395
7417
|
setQuery("");
|
|
7396
7418
|
setActiveIndex(null);
|
|
@@ -7401,12 +7423,12 @@ var Combobox = ({
|
|
|
7401
7423
|
}, 100);
|
|
7402
7424
|
}
|
|
7403
7425
|
}, [enableSearch, open, scrollVirtualListToStart]);
|
|
7404
|
-
|
|
7426
|
+
React26.useEffect(() => {
|
|
7405
7427
|
if (!onSearchChange) return void 0;
|
|
7406
7428
|
const timeoutId = window.setTimeout(() => onSearchChange(query), searchDebounceMs);
|
|
7407
7429
|
return () => window.clearTimeout(timeoutId);
|
|
7408
7430
|
}, [onSearchChange, query, searchDebounceMs]);
|
|
7409
|
-
|
|
7431
|
+
React26.useEffect(() => {
|
|
7410
7432
|
if (process.env.NODE_ENV !== "production" && options.length > 300 && !virtualized && searchMode !== "manual" && maxInitialOptions === void 0) {
|
|
7411
7433
|
console.warn(
|
|
7412
7434
|
'[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.'
|
|
@@ -7418,12 +7440,12 @@ var Combobox = ({
|
|
|
7418
7440
|
const selectedIcon = selectedOption ? getOptionIcon(selectedOption) : void 0;
|
|
7419
7441
|
const hasValue = value !== void 0 && value !== null && value !== "";
|
|
7420
7442
|
const effectiveError = error ?? localRequiredError;
|
|
7421
|
-
|
|
7443
|
+
React26.useEffect(() => {
|
|
7422
7444
|
if (disabled || !required || hasValue) {
|
|
7423
7445
|
setLocalRequiredError(void 0);
|
|
7424
7446
|
}
|
|
7425
7447
|
}, [disabled, hasValue, required]);
|
|
7426
|
-
const groupedOptions =
|
|
7448
|
+
const groupedOptions = React26.useMemo(() => {
|
|
7427
7449
|
if (!groupBy) return null;
|
|
7428
7450
|
const groups = {};
|
|
7429
7451
|
renderLimitedOptions.forEach((opt) => {
|
|
@@ -7840,7 +7862,7 @@ var Pagination = ({
|
|
|
7840
7862
|
labels
|
|
7841
7863
|
}) => {
|
|
7842
7864
|
const t = useSmartTranslations("Pagination");
|
|
7843
|
-
|
|
7865
|
+
React27.useEffect(() => {
|
|
7844
7866
|
if (disabled) return;
|
|
7845
7867
|
const handleKey = (e) => {
|
|
7846
7868
|
if (e.target && e.target.tagName === "INPUT") return;
|
|
@@ -8145,7 +8167,7 @@ var CompactPagination = ({ page, totalPages, onChange, className, disabled = fal
|
|
|
8145
8167
|
};
|
|
8146
8168
|
|
|
8147
8169
|
// src/components/Section.tsx
|
|
8148
|
-
import
|
|
8170
|
+
import React28 from "react";
|
|
8149
8171
|
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
8150
8172
|
var gradientDirectionMap = {
|
|
8151
8173
|
"to-r": "to right",
|
|
@@ -8178,7 +8200,7 @@ var variantClasses = {
|
|
|
8178
8200
|
accent: "bg-accent/10",
|
|
8179
8201
|
gradient: ""
|
|
8180
8202
|
};
|
|
8181
|
-
var Section =
|
|
8203
|
+
var Section = React28.forwardRef(
|
|
8182
8204
|
({
|
|
8183
8205
|
children,
|
|
8184
8206
|
className,
|
|
@@ -8491,7 +8513,7 @@ function formatDateSmart(date, locale = "en") {
|
|
|
8491
8513
|
|
|
8492
8514
|
// src/components/DatePicker.tsx
|
|
8493
8515
|
import { Calendar, ChevronLeft as ChevronLeft2, ChevronRight as ChevronRight3, Sparkles, X as XIcon } from "lucide-react";
|
|
8494
|
-
import * as
|
|
8516
|
+
import * as React30 from "react";
|
|
8495
8517
|
import { useId as useId7 } from "react";
|
|
8496
8518
|
import { Fragment as Fragment7, jsx as jsx35, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
8497
8519
|
var DatePicker = ({
|
|
@@ -8515,20 +8537,20 @@ var DatePicker = ({
|
|
|
8515
8537
|
const t = useSmartTranslations("DatePicker");
|
|
8516
8538
|
const tv = useSmartTranslations("ValidationInput");
|
|
8517
8539
|
const locale = useSmartLocale();
|
|
8518
|
-
const [isOpen, setIsOpen] =
|
|
8519
|
-
const [viewDate, setViewDate] =
|
|
8520
|
-
const [viewMode, setViewMode] =
|
|
8521
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
8522
|
-
const triggerRef =
|
|
8523
|
-
const wheelContainerRef =
|
|
8524
|
-
const wheelDeltaRef =
|
|
8525
|
-
const normalizeToLocalDay =
|
|
8540
|
+
const [isOpen, setIsOpen] = React30.useState(false);
|
|
8541
|
+
const [viewDate, setViewDate] = React30.useState(value || /* @__PURE__ */ new Date());
|
|
8542
|
+
const [viewMode, setViewMode] = React30.useState("calendar");
|
|
8543
|
+
const [localRequiredError, setLocalRequiredError] = React30.useState();
|
|
8544
|
+
const triggerRef = React30.useRef(null);
|
|
8545
|
+
const wheelContainerRef = React30.useRef(null);
|
|
8546
|
+
const wheelDeltaRef = React30.useRef(0);
|
|
8547
|
+
const normalizeToLocalDay = React30.useCallback((date) => {
|
|
8526
8548
|
if (!date) return null;
|
|
8527
8549
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
8528
8550
|
}, []);
|
|
8529
|
-
const minDay =
|
|
8530
|
-
const maxDay =
|
|
8531
|
-
const isDateDisabled =
|
|
8551
|
+
const minDay = React30.useMemo(() => normalizeToLocalDay(minDate), [minDate, normalizeToLocalDay]);
|
|
8552
|
+
const maxDay = React30.useMemo(() => normalizeToLocalDay(maxDate), [maxDate, normalizeToLocalDay]);
|
|
8553
|
+
const isDateDisabled = React30.useCallback(
|
|
8532
8554
|
(date) => {
|
|
8533
8555
|
const day = normalizeToLocalDay(date);
|
|
8534
8556
|
if (!day) return false;
|
|
@@ -8597,19 +8619,19 @@ var DatePicker = ({
|
|
|
8597
8619
|
footerMargin: "mt-5 pt-4 gap-2.5"
|
|
8598
8620
|
}
|
|
8599
8621
|
};
|
|
8600
|
-
|
|
8622
|
+
React30.useEffect(() => {
|
|
8601
8623
|
if (value) {
|
|
8602
8624
|
setViewDate(value);
|
|
8603
8625
|
} else {
|
|
8604
8626
|
setViewDate(/* @__PURE__ */ new Date());
|
|
8605
8627
|
}
|
|
8606
8628
|
}, [value]);
|
|
8607
|
-
|
|
8629
|
+
React30.useEffect(() => {
|
|
8608
8630
|
if (disabled || !required || value) {
|
|
8609
8631
|
setLocalRequiredError(void 0);
|
|
8610
8632
|
}
|
|
8611
8633
|
}, [disabled, required, value]);
|
|
8612
|
-
|
|
8634
|
+
React30.useEffect(() => {
|
|
8613
8635
|
if (!isOpen) {
|
|
8614
8636
|
setViewMode("calendar");
|
|
8615
8637
|
}
|
|
@@ -8639,7 +8661,7 @@ var DatePicker = ({
|
|
|
8639
8661
|
const getFirstDayOfMonth = (date) => {
|
|
8640
8662
|
return new Date(date.getFullYear(), date.getMonth(), 1).getDay();
|
|
8641
8663
|
};
|
|
8642
|
-
const navigateMonth =
|
|
8664
|
+
const navigateMonth = React30.useCallback((direction) => {
|
|
8643
8665
|
setViewDate((prev) => {
|
|
8644
8666
|
const newDate = new Date(prev);
|
|
8645
8667
|
newDate.setMonth(prev.getMonth() + (direction === "next" ? 1 : -1));
|
|
@@ -8653,7 +8675,7 @@ var DatePicker = ({
|
|
|
8653
8675
|
const node = el;
|
|
8654
8676
|
return node.scrollHeight > node.clientHeight + 1;
|
|
8655
8677
|
};
|
|
8656
|
-
|
|
8678
|
+
React30.useEffect(() => {
|
|
8657
8679
|
if (!isOpen) return;
|
|
8658
8680
|
const container = wheelContainerRef.current;
|
|
8659
8681
|
if (!container) return;
|
|
@@ -9068,11 +9090,11 @@ var DateRangePicker = ({
|
|
|
9068
9090
|
const locale = useSmartLocale();
|
|
9069
9091
|
const t = useSmartTranslations("DatePicker");
|
|
9070
9092
|
const tv = useSmartTranslations("ValidationInput");
|
|
9071
|
-
const [isOpen, setIsOpen] =
|
|
9072
|
-
const [viewMode, setViewMode] =
|
|
9073
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
9074
|
-
const wheelContainerRef =
|
|
9075
|
-
const wheelDeltaRef =
|
|
9093
|
+
const [isOpen, setIsOpen] = React30.useState(false);
|
|
9094
|
+
const [viewMode, setViewMode] = React30.useState("calendar");
|
|
9095
|
+
const [localRequiredError, setLocalRequiredError] = React30.useState();
|
|
9096
|
+
const wheelContainerRef = React30.useRef(null);
|
|
9097
|
+
const wheelDeltaRef = React30.useRef(0);
|
|
9076
9098
|
const sizeStyles8 = {
|
|
9077
9099
|
sm: {
|
|
9078
9100
|
trigger: "px-2.5 py-1.5 text-sm h-8 md:h-7 md:text-xs md:py-1",
|
|
@@ -9130,24 +9152,24 @@ var DateRangePicker = ({
|
|
|
9130
9152
|
if (!date) return null;
|
|
9131
9153
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
9132
9154
|
};
|
|
9133
|
-
const minDay =
|
|
9134
|
-
const maxDay =
|
|
9135
|
-
const [viewDate, setViewDate] =
|
|
9136
|
-
const [tempStart, setTempStart] =
|
|
9137
|
-
const [tempEnd, setTempEnd] =
|
|
9138
|
-
const [hoveredDate, setHoveredDate] =
|
|
9139
|
-
|
|
9155
|
+
const minDay = React30.useMemo(() => normalizeToLocal(minDate), [minDate]);
|
|
9156
|
+
const maxDay = React30.useMemo(() => normalizeToLocal(maxDate), [maxDate]);
|
|
9157
|
+
const [viewDate, setViewDate] = React30.useState(startDate || /* @__PURE__ */ new Date());
|
|
9158
|
+
const [tempStart, setTempStart] = React30.useState(normalizeToLocal(startDate));
|
|
9159
|
+
const [tempEnd, setTempEnd] = React30.useState(normalizeToLocal(endDate));
|
|
9160
|
+
const [hoveredDate, setHoveredDate] = React30.useState(null);
|
|
9161
|
+
React30.useEffect(() => {
|
|
9140
9162
|
setTempStart(normalizeToLocal(startDate));
|
|
9141
9163
|
}, [startDate]);
|
|
9142
|
-
|
|
9164
|
+
React30.useEffect(() => {
|
|
9143
9165
|
setTempEnd(normalizeToLocal(endDate));
|
|
9144
9166
|
}, [endDate]);
|
|
9145
|
-
|
|
9167
|
+
React30.useEffect(() => {
|
|
9146
9168
|
if (!isOpen) {
|
|
9147
9169
|
setViewMode("calendar");
|
|
9148
9170
|
}
|
|
9149
9171
|
}, [isOpen]);
|
|
9150
|
-
|
|
9172
|
+
React30.useEffect(() => {
|
|
9151
9173
|
if (!required || startDate && endDate) {
|
|
9152
9174
|
setLocalRequiredError(void 0);
|
|
9153
9175
|
}
|
|
@@ -9159,10 +9181,10 @@ var DateRangePicker = ({
|
|
|
9159
9181
|
const inRange = (d, s, e) => d > s && d < e;
|
|
9160
9182
|
const getDaysInMonth = (d) => new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();
|
|
9161
9183
|
const getFirstDayOfMonth = (d) => new Date(d.getFullYear(), d.getMonth(), 1).getDay();
|
|
9162
|
-
const navigateMonth =
|
|
9184
|
+
const navigateMonth = React30.useCallback((direction) => {
|
|
9163
9185
|
setViewDate((prev) => new Date(prev.getFullYear(), prev.getMonth() + (direction === "next" ? 1 : -1), 1));
|
|
9164
9186
|
}, []);
|
|
9165
|
-
const navigateYearRange =
|
|
9187
|
+
const navigateYearRange = React30.useCallback((direction) => {
|
|
9166
9188
|
setViewDate((prev) => new Date(prev.getFullYear() + (direction === "next" ? 12 : -12), prev.getMonth(), 1));
|
|
9167
9189
|
}, []);
|
|
9168
9190
|
const isElementVerticallyScrollable = (el) => {
|
|
@@ -9172,7 +9194,7 @@ var DateRangePicker = ({
|
|
|
9172
9194
|
const node = el;
|
|
9173
9195
|
return node.scrollHeight > node.clientHeight + 1;
|
|
9174
9196
|
};
|
|
9175
|
-
|
|
9197
|
+
React30.useEffect(() => {
|
|
9176
9198
|
if (!isOpen) return;
|
|
9177
9199
|
const container = wheelContainerRef.current;
|
|
9178
9200
|
if (!container) return;
|
|
@@ -9351,7 +9373,7 @@ var DateRangePicker = ({
|
|
|
9351
9373
|
);
|
|
9352
9374
|
}) });
|
|
9353
9375
|
};
|
|
9354
|
-
const todayDate =
|
|
9376
|
+
const todayDate = React30.useMemo(() => {
|
|
9355
9377
|
const today = /* @__PURE__ */ new Date();
|
|
9356
9378
|
return new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
9357
9379
|
}, []);
|
|
@@ -9593,15 +9615,15 @@ var CompactDatePicker = ({ value, onChange, className }) => {
|
|
|
9593
9615
|
};
|
|
9594
9616
|
|
|
9595
9617
|
// src/components/DateTimePicker.tsx
|
|
9596
|
-
import * as
|
|
9618
|
+
import * as React34 from "react";
|
|
9597
9619
|
import { Calendar as CalendarIcon, X as X12 } from "lucide-react";
|
|
9598
9620
|
|
|
9599
9621
|
// src/components/Calendar.tsx
|
|
9600
9622
|
import { ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight4 } from "lucide-react";
|
|
9601
|
-
import * as
|
|
9623
|
+
import * as React32 from "react";
|
|
9602
9624
|
|
|
9603
9625
|
// src/components/MonthYearPicker.tsx
|
|
9604
|
-
import * as
|
|
9626
|
+
import * as React31 from "react";
|
|
9605
9627
|
import { Calendar as Calendar2, X as X10, Check as Check4, ChevronDown as ChevronDown2 } from "lucide-react";
|
|
9606
9628
|
import { jsx as jsx36, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
9607
9629
|
var DEFAULT_MONTH_NAMES = [
|
|
@@ -9644,20 +9666,20 @@ function WheelColumn({
|
|
|
9644
9666
|
}) {
|
|
9645
9667
|
const height = itemHeight * WHEEL_VISIBLE_ITEMS;
|
|
9646
9668
|
const paddingY = (height - itemHeight) / 2;
|
|
9647
|
-
const rafRef =
|
|
9648
|
-
const lastVirtualIndexRef =
|
|
9649
|
-
const wheelDeltaRef =
|
|
9650
|
-
const scrollEndTimeoutRef =
|
|
9651
|
-
const suppressScrollSelectUntilRef =
|
|
9652
|
-
const suppressItemClickUntilRef =
|
|
9653
|
-
const dragRef =
|
|
9654
|
-
const draggingRef =
|
|
9655
|
-
const inertialRef =
|
|
9656
|
-
const inertiaRafRef =
|
|
9657
|
-
const inertiaVelocityRef =
|
|
9658
|
-
const inertiaLastTimeRef =
|
|
9659
|
-
const moveSamplesRef =
|
|
9660
|
-
const ui =
|
|
9669
|
+
const rafRef = React31.useRef(0);
|
|
9670
|
+
const lastVirtualIndexRef = React31.useRef(null);
|
|
9671
|
+
const wheelDeltaRef = React31.useRef(0);
|
|
9672
|
+
const scrollEndTimeoutRef = React31.useRef(null);
|
|
9673
|
+
const suppressScrollSelectUntilRef = React31.useRef(0);
|
|
9674
|
+
const suppressItemClickUntilRef = React31.useRef(0);
|
|
9675
|
+
const dragRef = React31.useRef(null);
|
|
9676
|
+
const draggingRef = React31.useRef(false);
|
|
9677
|
+
const inertialRef = React31.useRef(false);
|
|
9678
|
+
const inertiaRafRef = React31.useRef(null);
|
|
9679
|
+
const inertiaVelocityRef = React31.useRef(0);
|
|
9680
|
+
const inertiaLastTimeRef = React31.useRef(0);
|
|
9681
|
+
const moveSamplesRef = React31.useRef([]);
|
|
9682
|
+
const ui = React31.useMemo(() => {
|
|
9661
9683
|
if (size === "sm") {
|
|
9662
9684
|
return {
|
|
9663
9685
|
columnWidth: column === "month" ? "min-w-24 max-w-32" : "min-w-16 max-w-20",
|
|
@@ -9684,9 +9706,9 @@ function WheelColumn({
|
|
|
9684
9706
|
fadeHeight: "h-12"
|
|
9685
9707
|
};
|
|
9686
9708
|
}, [size, column]);
|
|
9687
|
-
const baseOffset =
|
|
9688
|
-
const extendedItems =
|
|
9689
|
-
const getNearestVirtualIndex =
|
|
9709
|
+
const baseOffset = React31.useMemo(() => loop ? items.length : 0, [items.length, loop]);
|
|
9710
|
+
const extendedItems = React31.useMemo(() => loop ? [...items, ...items, ...items] : items, [items, loop]);
|
|
9711
|
+
const getNearestVirtualIndex = React31.useCallback(
|
|
9690
9712
|
(realIndex, fromVirtual) => {
|
|
9691
9713
|
const len = items.length;
|
|
9692
9714
|
if (len <= 0) return 0;
|
|
@@ -9705,7 +9727,7 @@ function WheelColumn({
|
|
|
9705
9727
|
},
|
|
9706
9728
|
[items.length, loop]
|
|
9707
9729
|
);
|
|
9708
|
-
|
|
9730
|
+
React31.useLayoutEffect(() => {
|
|
9709
9731
|
const el = scrollRef.current;
|
|
9710
9732
|
if (!el) return;
|
|
9711
9733
|
const maxVirtual = Math.max(0, extendedItems.length - 1);
|
|
@@ -9733,7 +9755,7 @@ function WheelColumn({
|
|
|
9733
9755
|
cancelAnimationFrame(rafRef.current);
|
|
9734
9756
|
};
|
|
9735
9757
|
}, [animate, baseOffset, extendedItems.length, getNearestVirtualIndex, itemHeight, loop, scrollRef, valueIndex]);
|
|
9736
|
-
|
|
9758
|
+
React31.useEffect(() => {
|
|
9737
9759
|
const el = scrollRef.current;
|
|
9738
9760
|
if (!el) return;
|
|
9739
9761
|
const lastWheelSignRef = { current: 0 };
|
|
@@ -9821,11 +9843,11 @@ function WheelColumn({
|
|
|
9821
9843
|
}, 120);
|
|
9822
9844
|
});
|
|
9823
9845
|
};
|
|
9824
|
-
const currentVirtual =
|
|
9846
|
+
const currentVirtual = React31.useMemo(() => {
|
|
9825
9847
|
if (!loop || items.length <= 0) return valueIndex;
|
|
9826
9848
|
return baseOffset + valueIndex;
|
|
9827
9849
|
}, [baseOffset, items.length, loop, valueIndex]);
|
|
9828
|
-
const commitFromScrollTop =
|
|
9850
|
+
const commitFromScrollTop = React31.useCallback(
|
|
9829
9851
|
(behavior) => {
|
|
9830
9852
|
const el = scrollRef.current;
|
|
9831
9853
|
if (!el) return;
|
|
@@ -9903,7 +9925,7 @@ function WheelColumn({
|
|
|
9903
9925
|
if (dt > 0) inertiaVelocityRef.current = (el.scrollTop - oldest.top) / dt;
|
|
9904
9926
|
}
|
|
9905
9927
|
};
|
|
9906
|
-
const startInertia =
|
|
9928
|
+
const startInertia = React31.useCallback(() => {
|
|
9907
9929
|
const el = scrollRef.current;
|
|
9908
9930
|
if (!el) return;
|
|
9909
9931
|
if (items.length <= 0) return;
|
|
@@ -10088,36 +10110,36 @@ function MonthYearPicker({
|
|
|
10088
10110
|
};
|
|
10089
10111
|
const isControlled = value !== void 0;
|
|
10090
10112
|
const initial = parseValue(isControlled ? value : defaultValue) ?? { month: now.getMonth(), year: currentYear };
|
|
10091
|
-
const [open, setOpen] =
|
|
10092
|
-
const [parts, setParts] =
|
|
10093
|
-
const [focusedColumn, setFocusedColumn] =
|
|
10094
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
10095
|
-
const [hasCommittedValue, setHasCommittedValue] =
|
|
10096
|
-
const monthScrollRef =
|
|
10097
|
-
const yearScrollRef =
|
|
10098
|
-
|
|
10113
|
+
const [open, setOpen] = React31.useState(false);
|
|
10114
|
+
const [parts, setParts] = React31.useState(initial);
|
|
10115
|
+
const [focusedColumn, setFocusedColumn] = React31.useState(null);
|
|
10116
|
+
const [localRequiredError, setLocalRequiredError] = React31.useState();
|
|
10117
|
+
const [hasCommittedValue, setHasCommittedValue] = React31.useState(Boolean(parseValue(isControlled ? value : defaultValue)));
|
|
10118
|
+
const monthScrollRef = React31.useRef(null);
|
|
10119
|
+
const yearScrollRef = React31.useRef(null);
|
|
10120
|
+
React31.useEffect(() => {
|
|
10099
10121
|
if (isControlled) {
|
|
10100
10122
|
const parsed = parseValue(value);
|
|
10101
10123
|
if (parsed) setParts(parsed);
|
|
10102
10124
|
}
|
|
10103
10125
|
}, [value, isControlled]);
|
|
10104
|
-
|
|
10126
|
+
React31.useEffect(() => {
|
|
10105
10127
|
if (isControlled) {
|
|
10106
10128
|
setHasCommittedValue(Boolean(parseValue(value)));
|
|
10107
10129
|
}
|
|
10108
10130
|
}, [isControlled, value]);
|
|
10109
10131
|
const hasValue = hasCommittedValue;
|
|
10110
10132
|
const effectiveError = error ?? localRequiredError;
|
|
10111
|
-
|
|
10133
|
+
React31.useEffect(() => {
|
|
10112
10134
|
if (disabled || !required || hasValue) {
|
|
10113
10135
|
setLocalRequiredError(void 0);
|
|
10114
10136
|
}
|
|
10115
10137
|
}, [disabled, hasValue, required]);
|
|
10116
|
-
const years =
|
|
10138
|
+
const years = React31.useMemo(() => {
|
|
10117
10139
|
return Array.from({ length: resolvedMaxYear - resolvedMinYear + 1 }, (_, i) => resolvedMinYear + i);
|
|
10118
10140
|
}, [resolvedMinYear, resolvedMaxYear]);
|
|
10119
|
-
const months =
|
|
10120
|
-
const isDateInRange =
|
|
10141
|
+
const months = React31.useMemo(() => Array.from({ length: 12 }, (_, i) => i), []);
|
|
10142
|
+
const isDateInRange = React31.useCallback(
|
|
10121
10143
|
(month, year) => {
|
|
10122
10144
|
if (minDate) {
|
|
10123
10145
|
const minMonth = minDate.getMonth();
|
|
@@ -10133,7 +10155,7 @@ function MonthYearPicker({
|
|
|
10133
10155
|
},
|
|
10134
10156
|
[minDate, maxDate]
|
|
10135
10157
|
);
|
|
10136
|
-
const emit =
|
|
10158
|
+
const emit = React31.useCallback(
|
|
10137
10159
|
(next) => {
|
|
10138
10160
|
if (!next) {
|
|
10139
10161
|
setLocalRequiredError(void 0);
|
|
@@ -10149,7 +10171,7 @@ function MonthYearPicker({
|
|
|
10149
10171
|
},
|
|
10150
10172
|
[isControlled, isDateInRange, onChange]
|
|
10151
10173
|
);
|
|
10152
|
-
const tryUpdate =
|
|
10174
|
+
const tryUpdate = React31.useCallback(
|
|
10153
10175
|
(next) => {
|
|
10154
10176
|
if (!isDateInRange(next.month, next.year)) return false;
|
|
10155
10177
|
setParts(next);
|
|
@@ -10585,12 +10607,12 @@ function Calendar3({
|
|
|
10585
10607
|
...rest
|
|
10586
10608
|
}) {
|
|
10587
10609
|
const isControlledMonth = month != null;
|
|
10588
|
-
const [view, setView] =
|
|
10589
|
-
|
|
10610
|
+
const [view, setView] = React32.useState(() => month ?? defaultMonth ?? /* @__PURE__ */ new Date());
|
|
10611
|
+
React32.useEffect(() => {
|
|
10590
10612
|
if (isControlledMonth && month) setView(month);
|
|
10591
10613
|
}, [isControlledMonth, month]);
|
|
10592
10614
|
const isControlledValue = value !== void 0;
|
|
10593
|
-
const [internal, setInternal] =
|
|
10615
|
+
const [internal, setInternal] = React32.useState(defaultValue);
|
|
10594
10616
|
const selected = isControlledValue ? value : internal;
|
|
10595
10617
|
const goByView = (delta) => {
|
|
10596
10618
|
const next = display === "week" ? addDays(view, delta * 7) : addMonths(view, delta);
|
|
@@ -10602,7 +10624,7 @@ function Calendar3({
|
|
|
10602
10624
|
const weekdays = rotate(weekNames, weekStartsOn);
|
|
10603
10625
|
const days = getMonthGrid(view, weekStartsOn);
|
|
10604
10626
|
const today = /* @__PURE__ */ new Date();
|
|
10605
|
-
const byDay =
|
|
10627
|
+
const byDay = React32.useMemo(() => {
|
|
10606
10628
|
const map = /* @__PURE__ */ new Map();
|
|
10607
10629
|
for (const e of events) {
|
|
10608
10630
|
const d = toDate(e.date);
|
|
@@ -10614,11 +10636,11 @@ function Calendar3({
|
|
|
10614
10636
|
}, [events]);
|
|
10615
10637
|
const effectiveEnableEventSheet = enableEventSheet ?? !!renderEventSheet;
|
|
10616
10638
|
const isEventSheetOpenControlled = eventSheetOpen !== void 0;
|
|
10617
|
-
const [internalEventSheetOpen, setInternalEventSheetOpen] =
|
|
10639
|
+
const [internalEventSheetOpen, setInternalEventSheetOpen] = React32.useState(false);
|
|
10618
10640
|
const activeEventSheetOpen = isEventSheetOpenControlled ? !!eventSheetOpen : internalEventSheetOpen;
|
|
10619
10641
|
const isSelectedEventControlled = selectedEventId !== void 0;
|
|
10620
|
-
const [internalSelectedEventRef, setInternalSelectedEventRef] =
|
|
10621
|
-
const setEventSheetOpen =
|
|
10642
|
+
const [internalSelectedEventRef, setInternalSelectedEventRef] = React32.useState(null);
|
|
10643
|
+
const setEventSheetOpen = React32.useCallback(
|
|
10622
10644
|
(open) => {
|
|
10623
10645
|
if (!isEventSheetOpenControlled) setInternalEventSheetOpen(open);
|
|
10624
10646
|
onEventSheetOpenChange?.(open);
|
|
@@ -10629,7 +10651,7 @@ function Calendar3({
|
|
|
10629
10651
|
},
|
|
10630
10652
|
[isEventSheetOpenControlled, isSelectedEventControlled, onEventSheetOpenChange, onSelectedEventIdChange]
|
|
10631
10653
|
);
|
|
10632
|
-
const selectedEventRef =
|
|
10654
|
+
const selectedEventRef = React32.useMemo(() => {
|
|
10633
10655
|
if (isSelectedEventControlled && selectedEventId != null) {
|
|
10634
10656
|
const ev = events.find((e) => e.id === selectedEventId);
|
|
10635
10657
|
if (!ev) return null;
|
|
@@ -10639,7 +10661,7 @@ function Calendar3({
|
|
|
10639
10661
|
}
|
|
10640
10662
|
return internalSelectedEventRef;
|
|
10641
10663
|
}, [events, internalSelectedEventRef, isSelectedEventControlled, selectedEventId]);
|
|
10642
|
-
const selectedEvent =
|
|
10664
|
+
const selectedEvent = React32.useMemo(() => {
|
|
10643
10665
|
if (!selectedEventRef) return null;
|
|
10644
10666
|
const list = byDay.get(selectedEventRef.dayKey) || [];
|
|
10645
10667
|
if (selectedEventRef.eventId != null) {
|
|
@@ -10648,13 +10670,13 @@ function Calendar3({
|
|
|
10648
10670
|
const idx = selectedEventRef.index ?? -1;
|
|
10649
10671
|
return idx >= 0 && idx < list.length ? list[idx] : null;
|
|
10650
10672
|
}, [byDay, selectedEventRef]);
|
|
10651
|
-
const selectedEventDate =
|
|
10673
|
+
const selectedEventDate = React32.useMemo(() => {
|
|
10652
10674
|
if (!selectedEventRef) return null;
|
|
10653
10675
|
const [y, m, d] = selectedEventRef.dayKey.split("-").map((x) => Number(x));
|
|
10654
10676
|
if (!Number.isFinite(y) || !Number.isFinite(m) || !Number.isFinite(d)) return null;
|
|
10655
10677
|
return new Date(y, m, d);
|
|
10656
10678
|
}, [selectedEventRef]);
|
|
10657
|
-
const handleEventActivate =
|
|
10679
|
+
const handleEventActivate = React32.useCallback(
|
|
10658
10680
|
(event, date, dayKey, index) => {
|
|
10659
10681
|
onEventClick?.(event, date);
|
|
10660
10682
|
onSelectedEventIdChange?.(event.id ?? void 0);
|
|
@@ -10707,7 +10729,7 @@ function Calendar3({
|
|
|
10707
10729
|
}
|
|
10708
10730
|
}
|
|
10709
10731
|
};
|
|
10710
|
-
const isDateDisabled =
|
|
10732
|
+
const isDateDisabled = React32.useCallback(
|
|
10711
10733
|
(d) => {
|
|
10712
10734
|
if (minDate && d < new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate())) return true;
|
|
10713
10735
|
if (maxDate && d > new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate())) return true;
|
|
@@ -10741,7 +10763,7 @@ function Calendar3({
|
|
|
10741
10763
|
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",
|
|
10742
10764
|
minimal: "bg-transparent"
|
|
10743
10765
|
};
|
|
10744
|
-
const weekDays =
|
|
10766
|
+
const weekDays = React32.useMemo(() => {
|
|
10745
10767
|
const s = startOfWeek(view, weekStartsOn);
|
|
10746
10768
|
return Array.from({ length: 7 }, (_, i) => addDays(s, i));
|
|
10747
10769
|
}, [view, weekStartsOn]);
|
|
@@ -10762,7 +10784,7 @@ function Calendar3({
|
|
|
10762
10784
|
const holidayMatch = isHoliday(d, holidays);
|
|
10763
10785
|
const isHolidayDay = highlightHolidays && !!holidayMatch;
|
|
10764
10786
|
const customDay = renderDay?.({ date: d, isCurrentMonth: inMonth, isToday: isToday2, isSelected: selectedDay, events: dayEvents });
|
|
10765
|
-
if (customDay) return /* @__PURE__ */ jsx37(
|
|
10787
|
+
if (customDay) return /* @__PURE__ */ jsx37(React32.Fragment, { children: customDay }, `${monthLabel}-${idx}`);
|
|
10766
10788
|
if (cellMode === "events") {
|
|
10767
10789
|
const limit = Math.max(0, maxEventsPerDay);
|
|
10768
10790
|
const visibleEvents = dayEvents.slice(0, limit);
|
|
@@ -10881,9 +10903,9 @@ function Calendar3({
|
|
|
10881
10903
|
}) })
|
|
10882
10904
|
] });
|
|
10883
10905
|
};
|
|
10884
|
-
const minBound =
|
|
10885
|
-
const maxBound =
|
|
10886
|
-
const prevDisabled =
|
|
10906
|
+
const minBound = React32.useMemo(() => minDate ? new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate()) : void 0, [minDate]);
|
|
10907
|
+
const maxBound = React32.useMemo(() => maxDate ? new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate()) : void 0, [maxDate]);
|
|
10908
|
+
const prevDisabled = React32.useMemo(() => {
|
|
10887
10909
|
if (!minBound) return false;
|
|
10888
10910
|
if (display === "week") {
|
|
10889
10911
|
const start = startOfWeek(view, weekStartsOn);
|
|
@@ -10893,7 +10915,7 @@ function Calendar3({
|
|
|
10893
10915
|
const prevEnd = endOfMonth(addMonths(view, -1));
|
|
10894
10916
|
return prevEnd < minBound;
|
|
10895
10917
|
}, [display, view, weekStartsOn, minBound]);
|
|
10896
|
-
const nextDisabled =
|
|
10918
|
+
const nextDisabled = React32.useMemo(() => {
|
|
10897
10919
|
if (!maxBound) return false;
|
|
10898
10920
|
if (display === "week") {
|
|
10899
10921
|
const start = startOfWeek(view, weekStartsOn);
|
|
@@ -10970,7 +10992,7 @@ function Calendar3({
|
|
|
10970
10992
|
const holidayMatch = isHoliday(d, holidays);
|
|
10971
10993
|
const isHolidayDay = highlightHolidays && !!holidayMatch;
|
|
10972
10994
|
const customDay = renderDay?.({ date: d, isCurrentMonth: inMonth, isToday: isToday2, isSelected: selectedDay, events: dayEvents });
|
|
10973
|
-
if (customDay) return /* @__PURE__ */ jsx37(
|
|
10995
|
+
if (customDay) return /* @__PURE__ */ jsx37(React32.Fragment, { children: customDay }, `wd-${idx}`);
|
|
10974
10996
|
if (cellMode === "events") {
|
|
10975
10997
|
const limit = Math.max(0, maxEventsPerDay);
|
|
10976
10998
|
const visibleEvents = dayEvents.slice(0, limit);
|
|
@@ -11081,7 +11103,7 @@ function Calendar3({
|
|
|
11081
11103
|
`wd-${idx}`
|
|
11082
11104
|
);
|
|
11083
11105
|
}) })
|
|
11084
|
-
] }) : /* @__PURE__ */ jsx37("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__ */ jsx37(
|
|
11106
|
+
] }) : /* @__PURE__ */ jsx37("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__ */ jsx37(React32.Fragment, { children: renderMonth(addMonths(view, i)) }, `cal-month-${view.getFullYear()}-${view.getMonth()}-${i}`)) }),
|
|
11085
11107
|
effectiveEnableEventSheet && selectedEvent && selectedEventDate ? /* @__PURE__ */ jsx37(
|
|
11086
11108
|
Sheet,
|
|
11087
11109
|
{
|
|
@@ -11111,7 +11133,7 @@ function Calendar3({
|
|
|
11111
11133
|
}
|
|
11112
11134
|
|
|
11113
11135
|
// src/components/TimePicker.tsx
|
|
11114
|
-
import * as
|
|
11136
|
+
import * as React33 from "react";
|
|
11115
11137
|
import { Clock as Clock2, X as X11, Check as Check5, Sun, Moon, Sunset, Coffee } from "lucide-react";
|
|
11116
11138
|
import { Fragment as Fragment10, jsx as jsx38, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
11117
11139
|
var pad = (n) => n.toString().padStart(2, "0");
|
|
@@ -11138,21 +11160,21 @@ function WheelColumn2({
|
|
|
11138
11160
|
}) {
|
|
11139
11161
|
const height = itemHeight * WHEEL_VISIBLE_ITEMS2;
|
|
11140
11162
|
const paddingY = (height - itemHeight) / 2;
|
|
11141
|
-
const rafRef =
|
|
11142
|
-
const lastVirtualIndexRef =
|
|
11143
|
-
const wheelDeltaRef =
|
|
11144
|
-
const scrollEndTimeoutRef =
|
|
11145
|
-
const suppressScrollSelectUntilRef =
|
|
11146
|
-
const suppressItemClickUntilRef =
|
|
11147
|
-
const dragRef =
|
|
11148
|
-
const draggingRef =
|
|
11149
|
-
const inertialRef =
|
|
11150
|
-
const inertiaRafRef =
|
|
11151
|
-
const inertiaVelocityRef =
|
|
11152
|
-
const inertiaLastTimeRef =
|
|
11153
|
-
const moveSamplesRef =
|
|
11163
|
+
const rafRef = React33.useRef(0);
|
|
11164
|
+
const lastVirtualIndexRef = React33.useRef(null);
|
|
11165
|
+
const wheelDeltaRef = React33.useRef(0);
|
|
11166
|
+
const scrollEndTimeoutRef = React33.useRef(null);
|
|
11167
|
+
const suppressScrollSelectUntilRef = React33.useRef(0);
|
|
11168
|
+
const suppressItemClickUntilRef = React33.useRef(0);
|
|
11169
|
+
const dragRef = React33.useRef(null);
|
|
11170
|
+
const draggingRef = React33.useRef(false);
|
|
11171
|
+
const inertialRef = React33.useRef(false);
|
|
11172
|
+
const inertiaRafRef = React33.useRef(null);
|
|
11173
|
+
const inertiaVelocityRef = React33.useRef(0);
|
|
11174
|
+
const inertiaLastTimeRef = React33.useRef(0);
|
|
11175
|
+
const moveSamplesRef = React33.useRef([]);
|
|
11154
11176
|
const loop = true;
|
|
11155
|
-
const ui =
|
|
11177
|
+
const ui = React33.useMemo(() => {
|
|
11156
11178
|
if (size === "sm") {
|
|
11157
11179
|
return {
|
|
11158
11180
|
columnWidth: "min-w-16 max-w-21",
|
|
@@ -11179,9 +11201,9 @@ function WheelColumn2({
|
|
|
11179
11201
|
fadeHeight: "h-12"
|
|
11180
11202
|
};
|
|
11181
11203
|
}, [size]);
|
|
11182
|
-
const baseOffset =
|
|
11183
|
-
const extendedItems =
|
|
11184
|
-
const getNearestVirtualIndex =
|
|
11204
|
+
const baseOffset = React33.useMemo(() => loop ? items.length : 0, [items.length, loop]);
|
|
11205
|
+
const extendedItems = React33.useMemo(() => loop ? [...items, ...items, ...items] : items, [items, loop]);
|
|
11206
|
+
const getNearestVirtualIndex = React33.useCallback(
|
|
11185
11207
|
(realIndex, fromVirtual) => {
|
|
11186
11208
|
const len = items.length;
|
|
11187
11209
|
if (len <= 0) return 0;
|
|
@@ -11200,7 +11222,7 @@ function WheelColumn2({
|
|
|
11200
11222
|
},
|
|
11201
11223
|
[items.length, loop]
|
|
11202
11224
|
);
|
|
11203
|
-
|
|
11225
|
+
React33.useLayoutEffect(() => {
|
|
11204
11226
|
const el = scrollRef.current;
|
|
11205
11227
|
if (!el) return;
|
|
11206
11228
|
const maxVirtual = Math.max(0, extendedItems.length - 1);
|
|
@@ -11228,7 +11250,7 @@ function WheelColumn2({
|
|
|
11228
11250
|
cancelAnimationFrame(rafRef.current);
|
|
11229
11251
|
};
|
|
11230
11252
|
}, [animate, baseOffset, extendedItems.length, getNearestVirtualIndex, itemHeight, loop, scrollRef, valueIndex]);
|
|
11231
|
-
|
|
11253
|
+
React33.useEffect(() => {
|
|
11232
11254
|
const el = scrollRef.current;
|
|
11233
11255
|
if (!el) return;
|
|
11234
11256
|
const lastWheelSignRef = { current: 0 };
|
|
@@ -11316,11 +11338,11 @@ function WheelColumn2({
|
|
|
11316
11338
|
}, 120);
|
|
11317
11339
|
});
|
|
11318
11340
|
};
|
|
11319
|
-
const currentVirtual =
|
|
11341
|
+
const currentVirtual = React33.useMemo(() => {
|
|
11320
11342
|
if (!loop || items.length <= 0) return valueIndex;
|
|
11321
11343
|
return baseOffset + valueIndex;
|
|
11322
11344
|
}, [baseOffset, items.length, loop, valueIndex]);
|
|
11323
|
-
const commitFromScrollTop =
|
|
11345
|
+
const commitFromScrollTop = React33.useCallback(
|
|
11324
11346
|
(behavior) => {
|
|
11325
11347
|
const el = scrollRef.current;
|
|
11326
11348
|
if (!el) return;
|
|
@@ -11398,7 +11420,7 @@ function WheelColumn2({
|
|
|
11398
11420
|
if (dt > 0) inertiaVelocityRef.current = (el.scrollTop - oldest.top) / dt;
|
|
11399
11421
|
}
|
|
11400
11422
|
};
|
|
11401
|
-
const startInertia =
|
|
11423
|
+
const startInertia = React33.useCallback(() => {
|
|
11402
11424
|
const el = scrollRef.current;
|
|
11403
11425
|
if (!el) return;
|
|
11404
11426
|
if (items.length <= 0) return;
|
|
@@ -11599,44 +11621,44 @@ function TimePicker({
|
|
|
11599
11621
|
}) {
|
|
11600
11622
|
const tv = useSmartTranslations("ValidationInput");
|
|
11601
11623
|
const gi18n = useGlobalI18n();
|
|
11602
|
-
const autoId =
|
|
11624
|
+
const autoId = React33.useId();
|
|
11603
11625
|
const isControlled = value !== void 0;
|
|
11604
11626
|
const now = /* @__PURE__ */ new Date();
|
|
11605
11627
|
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() });
|
|
11606
|
-
const [open, setOpen] =
|
|
11607
|
-
const [parts, setParts] =
|
|
11608
|
-
const [manualInput, setManualInput] =
|
|
11609
|
-
const [isDirectEditing, setIsDirectEditing] =
|
|
11610
|
-
const [focusedColumn, setFocusedColumn] =
|
|
11611
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
11612
|
-
const [hasCommittedValue, setHasCommittedValue] =
|
|
11613
|
-
const hourScrollRef =
|
|
11614
|
-
const minuteScrollRef =
|
|
11615
|
-
const secondScrollRef =
|
|
11616
|
-
const periodRef =
|
|
11617
|
-
const directEditInputRef =
|
|
11628
|
+
const [open, setOpen] = React33.useState(false);
|
|
11629
|
+
const [parts, setParts] = React33.useState(initial);
|
|
11630
|
+
const [manualInput, setManualInput] = React33.useState(formatTime2(initial, format, includeSeconds));
|
|
11631
|
+
const [isDirectEditing, setIsDirectEditing] = React33.useState(false);
|
|
11632
|
+
const [focusedColumn, setFocusedColumn] = React33.useState(null);
|
|
11633
|
+
const [localRequiredError, setLocalRequiredError] = React33.useState();
|
|
11634
|
+
const [hasCommittedValue, setHasCommittedValue] = React33.useState(Boolean(isControlled ? value : defaultValue));
|
|
11635
|
+
const hourScrollRef = React33.useRef(null);
|
|
11636
|
+
const minuteScrollRef = React33.useRef(null);
|
|
11637
|
+
const secondScrollRef = React33.useRef(null);
|
|
11638
|
+
const periodRef = React33.useRef(null);
|
|
11639
|
+
const directEditInputRef = React33.useRef(null);
|
|
11618
11640
|
const triggerId = `time-picker-trigger-${autoId}`;
|
|
11619
11641
|
const labelId = label ? `time-picker-label-${autoId}` : void 0;
|
|
11620
|
-
|
|
11642
|
+
React33.useEffect(() => {
|
|
11621
11643
|
if (isControlled) {
|
|
11622
11644
|
const parsed = parseTime(value, format, includeSeconds);
|
|
11623
11645
|
if (parsed) setParts(parsed);
|
|
11624
11646
|
}
|
|
11625
11647
|
}, [value, isControlled, format, includeSeconds]);
|
|
11626
|
-
|
|
11648
|
+
React33.useEffect(() => {
|
|
11627
11649
|
setManualInput(formatTime2(parts, format, includeSeconds));
|
|
11628
11650
|
}, [format, includeSeconds, parts]);
|
|
11629
|
-
|
|
11651
|
+
React33.useEffect(() => {
|
|
11630
11652
|
if (!isDirectEditing) return;
|
|
11631
11653
|
directEditInputRef.current?.focus();
|
|
11632
11654
|
directEditInputRef.current?.select();
|
|
11633
11655
|
}, [isDirectEditing]);
|
|
11634
|
-
|
|
11656
|
+
React33.useEffect(() => {
|
|
11635
11657
|
if (isControlled) {
|
|
11636
11658
|
setHasCommittedValue(Boolean(value));
|
|
11637
11659
|
}
|
|
11638
11660
|
}, [isControlled, value]);
|
|
11639
|
-
const isTimeDisabled =
|
|
11661
|
+
const isTimeDisabled = React33.useCallback(
|
|
11640
11662
|
(timeStr) => {
|
|
11641
11663
|
if (!disabledTimes) return false;
|
|
11642
11664
|
if (typeof disabledTimes === "function") return disabledTimes(timeStr);
|
|
@@ -11646,7 +11668,7 @@ function TimePicker({
|
|
|
11646
11668
|
);
|
|
11647
11669
|
const resolvedMinTime = minTime ?? min;
|
|
11648
11670
|
const resolvedMaxTime = maxTime ?? max;
|
|
11649
|
-
const toSeconds =
|
|
11671
|
+
const toSeconds = React33.useCallback(
|
|
11650
11672
|
(p) => {
|
|
11651
11673
|
let h = p.h;
|
|
11652
11674
|
if (format === "12") {
|
|
@@ -11658,7 +11680,7 @@ function TimePicker({
|
|
|
11658
11680
|
},
|
|
11659
11681
|
[format, includeSeconds]
|
|
11660
11682
|
);
|
|
11661
|
-
const isTimeInRange =
|
|
11683
|
+
const isTimeInRange = React33.useCallback(
|
|
11662
11684
|
(timeStr) => {
|
|
11663
11685
|
if (!resolvedMinTime && !resolvedMaxTime) return true;
|
|
11664
11686
|
const parsed = parseTime(timeStr, format, includeSeconds);
|
|
@@ -11676,7 +11698,7 @@ function TimePicker({
|
|
|
11676
11698
|
},
|
|
11677
11699
|
[format, includeSeconds, resolvedMaxTime, resolvedMinTime, toSeconds]
|
|
11678
11700
|
);
|
|
11679
|
-
const canEmit =
|
|
11701
|
+
const canEmit = React33.useCallback(
|
|
11680
11702
|
(next) => {
|
|
11681
11703
|
const timeStr = next ? formatTime2(next, format, includeSeconds) : void 0;
|
|
11682
11704
|
if (!timeStr) return true;
|
|
@@ -11686,7 +11708,7 @@ function TimePicker({
|
|
|
11686
11708
|
},
|
|
11687
11709
|
[format, includeSeconds, isTimeDisabled, isTimeInRange]
|
|
11688
11710
|
);
|
|
11689
|
-
const emit =
|
|
11711
|
+
const emit = React33.useCallback(
|
|
11690
11712
|
(next) => {
|
|
11691
11713
|
const timeStr = next ? formatTime2(next, format, includeSeconds) : void 0;
|
|
11692
11714
|
if (!canEmit(next)) return;
|
|
@@ -11698,7 +11720,7 @@ function TimePicker({
|
|
|
11698
11720
|
},
|
|
11699
11721
|
[canEmit, format, includeSeconds, isControlled, onChange]
|
|
11700
11722
|
);
|
|
11701
|
-
const tryUpdate =
|
|
11723
|
+
const tryUpdate = React33.useCallback(
|
|
11702
11724
|
(next) => {
|
|
11703
11725
|
if (!canEmit(next)) return false;
|
|
11704
11726
|
setParts(next);
|
|
@@ -11716,17 +11738,17 @@ function TimePicker({
|
|
|
11716
11738
|
setFocusedColumn(null);
|
|
11717
11739
|
}
|
|
11718
11740
|
};
|
|
11719
|
-
|
|
11741
|
+
React33.useEffect(() => {
|
|
11720
11742
|
if (disabled || !required || hasCommittedValue) {
|
|
11721
11743
|
setLocalRequiredError(void 0);
|
|
11722
11744
|
}
|
|
11723
11745
|
}, [disabled, hasCommittedValue, required]);
|
|
11724
|
-
const focusColumn =
|
|
11746
|
+
const focusColumn = React33.useCallback((column) => {
|
|
11725
11747
|
if (!column) return;
|
|
11726
11748
|
const target = column === "hour" ? hourScrollRef.current : column === "minute" ? minuteScrollRef.current : column === "second" ? secondScrollRef.current : periodRef.current;
|
|
11727
11749
|
target?.focus({ preventScroll: true });
|
|
11728
11750
|
}, []);
|
|
11729
|
-
|
|
11751
|
+
React33.useEffect(() => {
|
|
11730
11752
|
if (variant !== "inline" && !open) return;
|
|
11731
11753
|
focusColumn(focusedColumn);
|
|
11732
11754
|
}, [focusColumn, focusedColumn, open, variant]);
|
|
@@ -11808,7 +11830,7 @@ function TimePicker({
|
|
|
11808
11830
|
}
|
|
11809
11831
|
}
|
|
11810
11832
|
};
|
|
11811
|
-
const commitManualInput =
|
|
11833
|
+
const commitManualInput = React33.useCallback(
|
|
11812
11834
|
(input) => {
|
|
11813
11835
|
const trimmed = input.trim();
|
|
11814
11836
|
if (!trimmed) {
|
|
@@ -11839,12 +11861,12 @@ function TimePicker({
|
|
|
11839
11861
|
},
|
|
11840
11862
|
[display, format, includeSeconds, isTimeDisabled, isTimeInRange, tryUpdate]
|
|
11841
11863
|
);
|
|
11842
|
-
const startDirectEdit =
|
|
11864
|
+
const startDirectEdit = React33.useCallback(() => {
|
|
11843
11865
|
if (disabled) return;
|
|
11844
11866
|
setManualInput(display);
|
|
11845
11867
|
setIsDirectEditing(true);
|
|
11846
11868
|
}, [disabled, display]);
|
|
11847
|
-
const stopDirectEdit =
|
|
11869
|
+
const stopDirectEdit = React33.useCallback(
|
|
11848
11870
|
(mode) => {
|
|
11849
11871
|
if (mode === "commit") {
|
|
11850
11872
|
commitManualInput(manualInput);
|
|
@@ -12420,8 +12442,8 @@ var DateTimePicker = ({
|
|
|
12420
12442
|
const t = useSmartTranslations("DateTimePicker");
|
|
12421
12443
|
const tv = useSmartTranslations("ValidationInput");
|
|
12422
12444
|
const locale = useSmartLocale();
|
|
12423
|
-
const [open, setOpen] =
|
|
12424
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
12445
|
+
const [open, setOpen] = React34.useState(false);
|
|
12446
|
+
const [localRequiredError, setLocalRequiredError] = React34.useState();
|
|
12425
12447
|
const sizeStyles8 = {
|
|
12426
12448
|
sm: {
|
|
12427
12449
|
trigger: "h-8 px-2.5 py-1.5 text-sm md:h-7 md:text-xs",
|
|
@@ -12454,13 +12476,13 @@ var DateTimePicker = ({
|
|
|
12454
12476
|
gap: "gap-4"
|
|
12455
12477
|
}
|
|
12456
12478
|
};
|
|
12457
|
-
const [tempDate, setTempDate] =
|
|
12458
|
-
const [calendarMonth, setCalendarMonth] =
|
|
12459
|
-
|
|
12479
|
+
const [tempDate, setTempDate] = React34.useState(value);
|
|
12480
|
+
const [calendarMonth, setCalendarMonth] = React34.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
12481
|
+
React34.useEffect(() => {
|
|
12460
12482
|
setTempDate(value);
|
|
12461
12483
|
setCalendarMonth(value ?? /* @__PURE__ */ new Date());
|
|
12462
12484
|
}, [value, open]);
|
|
12463
|
-
|
|
12485
|
+
React34.useEffect(() => {
|
|
12464
12486
|
if (disabled || !required || value) {
|
|
12465
12487
|
setLocalRequiredError(void 0);
|
|
12466
12488
|
}
|
|
@@ -12679,7 +12701,7 @@ var DateTimePicker = ({
|
|
|
12679
12701
|
};
|
|
12680
12702
|
|
|
12681
12703
|
// src/components/CalendarTimeline/CalendarTimeline.tsx
|
|
12682
|
-
import * as
|
|
12704
|
+
import * as React40 from "react";
|
|
12683
12705
|
import { Plus as Plus2 } from "lucide-react";
|
|
12684
12706
|
|
|
12685
12707
|
// src/components/CalendarTimeline/date.ts
|
|
@@ -12919,10 +12941,10 @@ function intervalPack(items) {
|
|
|
12919
12941
|
}
|
|
12920
12942
|
|
|
12921
12943
|
// src/components/CalendarTimeline/hooks.ts
|
|
12922
|
-
import * as
|
|
12944
|
+
import * as React35 from "react";
|
|
12923
12945
|
function useHorizontalScrollSync(args) {
|
|
12924
12946
|
const { bodyRef, headerRef, leftRef } = args;
|
|
12925
|
-
|
|
12947
|
+
React35.useEffect(() => {
|
|
12926
12948
|
const body = bodyRef.current;
|
|
12927
12949
|
const header = headerRef.current;
|
|
12928
12950
|
const left = leftRef?.current ?? null;
|
|
@@ -12980,9 +13002,9 @@ function lowerBound(arr, target) {
|
|
|
12980
13002
|
function useVirtualVariableRows(args) {
|
|
12981
13003
|
const { enabled, overscan, rowHeights, scrollRef } = args;
|
|
12982
13004
|
const itemCount = rowHeights.length;
|
|
12983
|
-
const [viewportHeight, setViewportHeight] =
|
|
12984
|
-
const [scrollTop, setScrollTop] =
|
|
12985
|
-
|
|
13005
|
+
const [viewportHeight, setViewportHeight] = React35.useState(0);
|
|
13006
|
+
const [scrollTop, setScrollTop] = React35.useState(0);
|
|
13007
|
+
React35.useEffect(() => {
|
|
12986
13008
|
if (!enabled) {
|
|
12987
13009
|
setViewportHeight(0);
|
|
12988
13010
|
return;
|
|
@@ -12995,7 +13017,7 @@ function useVirtualVariableRows(args) {
|
|
|
12995
13017
|
ro.observe(el);
|
|
12996
13018
|
return () => ro.disconnect();
|
|
12997
13019
|
}, [enabled, scrollRef]);
|
|
12998
|
-
|
|
13020
|
+
React35.useEffect(() => {
|
|
12999
13021
|
if (!enabled) {
|
|
13000
13022
|
setScrollTop(0);
|
|
13001
13023
|
return;
|
|
@@ -13020,7 +13042,7 @@ function useVirtualVariableRows(args) {
|
|
|
13020
13042
|
el.removeEventListener("scroll", onScroll);
|
|
13021
13043
|
};
|
|
13022
13044
|
}, [enabled, scrollRef]);
|
|
13023
|
-
const prefix =
|
|
13045
|
+
const prefix = React35.useMemo(() => {
|
|
13024
13046
|
const out = new Array(itemCount + 1);
|
|
13025
13047
|
out[0] = 0;
|
|
13026
13048
|
for (let i = 0; i < itemCount; i++) {
|
|
@@ -13028,7 +13050,7 @@ function useVirtualVariableRows(args) {
|
|
|
13028
13050
|
}
|
|
13029
13051
|
return out;
|
|
13030
13052
|
}, [itemCount, rowHeights]);
|
|
13031
|
-
return
|
|
13053
|
+
return React35.useMemo(() => {
|
|
13032
13054
|
if (!enabled) {
|
|
13033
13055
|
return { startIndex: 0, endIndex: itemCount, topSpacer: 0, bottomSpacer: 0, totalHeight: prefix[itemCount] ?? 0 };
|
|
13034
13056
|
}
|
|
@@ -13044,8 +13066,8 @@ function useVirtualVariableRows(args) {
|
|
|
13044
13066
|
}, [enabled, itemCount, overscan, prefix, scrollTop, viewportHeight]);
|
|
13045
13067
|
}
|
|
13046
13068
|
function useClientWidth(ref) {
|
|
13047
|
-
const [width, setWidth] =
|
|
13048
|
-
|
|
13069
|
+
const [width, setWidth] = React35.useState(0);
|
|
13070
|
+
React35.useEffect(() => {
|
|
13049
13071
|
const el = ref.current;
|
|
13050
13072
|
if (!el) return;
|
|
13051
13073
|
const update = () => setWidth(el.clientWidth);
|
|
@@ -13268,7 +13290,7 @@ function resourcesById(resources) {
|
|
|
13268
13290
|
}
|
|
13269
13291
|
|
|
13270
13292
|
// src/components/CalendarTimeline/CalendarTimelineHeader.tsx
|
|
13271
|
-
import * as
|
|
13293
|
+
import * as React36 from "react";
|
|
13272
13294
|
import { Calendar as Calendar4, CalendarDays, CalendarRange, ChevronLeft as ChevronLeft4, ChevronRight as ChevronRight5, GripVertical, Plus } from "lucide-react";
|
|
13273
13295
|
import { jsx as jsx41, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
13274
13296
|
var VIEW_ICONS = {
|
|
@@ -13299,7 +13321,7 @@ function CalendarTimelineHeader(props) {
|
|
|
13299
13321
|
headerRef,
|
|
13300
13322
|
slotHeaderNodes
|
|
13301
13323
|
} = props;
|
|
13302
|
-
const resolvedAvailableViews =
|
|
13324
|
+
const resolvedAvailableViews = React36.useMemo(
|
|
13303
13325
|
() => availableViews?.length ? availableViews : ["month", "week", "day", "sprint"],
|
|
13304
13326
|
[availableViews]
|
|
13305
13327
|
);
|
|
@@ -13308,22 +13330,22 @@ function CalendarTimelineHeader(props) {
|
|
|
13308
13330
|
const gi18n = useGlobalI18n();
|
|
13309
13331
|
const dt = useSmartTranslations("DateTimePicker");
|
|
13310
13332
|
const locale = useSmartLocale();
|
|
13311
|
-
const [todayOpen, setTodayOpen] =
|
|
13312
|
-
const [tempDate, setTempDate] =
|
|
13313
|
-
const [calendarMonth, setCalendarMonth] =
|
|
13314
|
-
|
|
13333
|
+
const [todayOpen, setTodayOpen] = React36.useState(false);
|
|
13334
|
+
const [tempDate, setTempDate] = React36.useState(() => now);
|
|
13335
|
+
const [calendarMonth, setCalendarMonth] = React36.useState(() => now);
|
|
13336
|
+
React36.useEffect(() => {
|
|
13315
13337
|
if (!todayOpen) return;
|
|
13316
13338
|
setTempDate(now);
|
|
13317
13339
|
setCalendarMonth(now);
|
|
13318
13340
|
}, [now, todayOpen]);
|
|
13319
|
-
const monthLabel =
|
|
13341
|
+
const monthLabel = React36.useCallback(
|
|
13320
13342
|
(date) => date.toLocaleDateString(locale === "vi" ? "vi-VN" : "en-US", {
|
|
13321
13343
|
month: "long",
|
|
13322
13344
|
year: "numeric"
|
|
13323
13345
|
}),
|
|
13324
13346
|
[locale]
|
|
13325
13347
|
);
|
|
13326
|
-
const weekdays =
|
|
13348
|
+
const weekdays = React36.useMemo(() => {
|
|
13327
13349
|
switch (locale) {
|
|
13328
13350
|
case "vi":
|
|
13329
13351
|
return ["CN", "T2", "T3", "T4", "T5", "T6", "T7"];
|
|
@@ -13335,12 +13357,12 @@ function CalendarTimelineHeader(props) {
|
|
|
13335
13357
|
return ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
13336
13358
|
}
|
|
13337
13359
|
}, [locale]);
|
|
13338
|
-
const getTimeString =
|
|
13360
|
+
const getTimeString = React36.useCallback((date) => {
|
|
13339
13361
|
const h = date.getHours();
|
|
13340
13362
|
const m = date.getMinutes();
|
|
13341
13363
|
return `${h.toString().padStart(2, "0")}:${m.toString().padStart(2, "0")}`;
|
|
13342
13364
|
}, []);
|
|
13343
|
-
const handleDateSelect =
|
|
13365
|
+
const handleDateSelect = React36.useCallback((date) => {
|
|
13344
13366
|
if (!(date instanceof Date)) return;
|
|
13345
13367
|
setTempDate((prev) => {
|
|
13346
13368
|
const next = new Date(date);
|
|
@@ -13348,7 +13370,7 @@ function CalendarTimelineHeader(props) {
|
|
|
13348
13370
|
return next;
|
|
13349
13371
|
});
|
|
13350
13372
|
}, []);
|
|
13351
|
-
const handleTimeChange =
|
|
13373
|
+
const handleTimeChange = React36.useCallback((timeStr) => {
|
|
13352
13374
|
if (!timeStr) return;
|
|
13353
13375
|
const [hStr, mStr] = timeStr.split(":");
|
|
13354
13376
|
const h = parseInt(hStr, 10);
|
|
@@ -13360,7 +13382,7 @@ function CalendarTimelineHeader(props) {
|
|
|
13360
13382
|
return next;
|
|
13361
13383
|
});
|
|
13362
13384
|
}, []);
|
|
13363
|
-
const applyDateTime =
|
|
13385
|
+
const applyDateTime = React36.useCallback(() => {
|
|
13364
13386
|
onApplyDateTime(tempDate);
|
|
13365
13387
|
setTodayOpen(false);
|
|
13366
13388
|
}, [onApplyDateTime, tempDate]);
|
|
@@ -13624,9 +13646,9 @@ function ResourceRowCell(props) {
|
|
|
13624
13646
|
}
|
|
13625
13647
|
|
|
13626
13648
|
// src/components/CalendarTimeline/CalendarTimelineGridOverlay.tsx
|
|
13627
|
-
import * as
|
|
13649
|
+
import * as React37 from "react";
|
|
13628
13650
|
import { jsx as jsx43, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
13629
|
-
var CalendarTimelineGridOverlay =
|
|
13651
|
+
var CalendarTimelineGridOverlay = React37.memo(function CalendarTimelineGridOverlay2(props) {
|
|
13630
13652
|
const {
|
|
13631
13653
|
gridWidth,
|
|
13632
13654
|
height,
|
|
@@ -13674,12 +13696,12 @@ var CalendarTimelineGridOverlay = React36.memo(function CalendarTimelineGridOver
|
|
|
13674
13696
|
});
|
|
13675
13697
|
|
|
13676
13698
|
// src/components/CalendarTimeline/CalendarTimelineSlotHeaderCell.tsx
|
|
13677
|
-
import * as
|
|
13699
|
+
import * as React38 from "react";
|
|
13678
13700
|
import { Dot } from "lucide-react";
|
|
13679
13701
|
import { jsx as jsx44, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
13680
|
-
var CalendarTimelineSlotHeaderCell =
|
|
13702
|
+
var CalendarTimelineSlotHeaderCell = React38.memo(function CalendarTimelineSlotHeaderCell2(props) {
|
|
13681
13703
|
const { width, activeView, isToday: isToday2, label, ariaLabel, borderClassName, dayHeaderMarks, idx, className } = props;
|
|
13682
|
-
const content =
|
|
13704
|
+
const content = React38.useMemo(() => {
|
|
13683
13705
|
if (activeView === "day" && dayHeaderMarks) {
|
|
13684
13706
|
if (dayHeaderMarks.showEllipsis[idx]) return /* @__PURE__ */ jsx44("span", { className: "text-xs text-muted-foreground/70 select-none", children: "\u2026" });
|
|
13685
13707
|
if (!dayHeaderMarks.showTime[idx]) return null;
|
|
@@ -13702,7 +13724,7 @@ var CalendarTimelineSlotHeaderCell = React37.memo(function CalendarTimelineSlotH
|
|
|
13702
13724
|
});
|
|
13703
13725
|
|
|
13704
13726
|
// src/components/CalendarTimeline/internal-hooks.ts
|
|
13705
|
-
import * as
|
|
13727
|
+
import * as React39 from "react";
|
|
13706
13728
|
function useTimelineSlots(args) {
|
|
13707
13729
|
const {
|
|
13708
13730
|
activeView,
|
|
@@ -13717,7 +13739,7 @@ function useTimelineSlots(args) {
|
|
|
13717
13739
|
formatters,
|
|
13718
13740
|
dueDateSprint
|
|
13719
13741
|
} = args;
|
|
13720
|
-
const { slots, range } =
|
|
13742
|
+
const { slots, range } = React39.useMemo(() => {
|
|
13721
13743
|
const { start, end, slotStarts: slotStarts2 } = computeSlotStarts({
|
|
13722
13744
|
view: activeView,
|
|
13723
13745
|
date: activeDate,
|
|
@@ -13772,18 +13794,18 @@ function useTimelineSlots(args) {
|
|
|
13772
13794
|
const match = matchSprintDef(s, idx);
|
|
13773
13795
|
if (match && sprintRangeText) {
|
|
13774
13796
|
const rangeText = sprintRangeText(match.startMs, match.endMs);
|
|
13775
|
-
return
|
|
13797
|
+
return React39.createElement(
|
|
13776
13798
|
"span",
|
|
13777
13799
|
{ className: "inline-flex flex-col items-center leading-tight" },
|
|
13778
|
-
|
|
13779
|
-
|
|
13800
|
+
React39.createElement("span", { className: "text-[11px] font-semibold text-foreground truncate max-w-32" }, match.title),
|
|
13801
|
+
React39.createElement("span", { className: "text-[10px] font-medium text-muted-foreground/70" }, rangeText)
|
|
13780
13802
|
);
|
|
13781
13803
|
}
|
|
13782
|
-
return
|
|
13804
|
+
return React39.createElement(
|
|
13783
13805
|
"span",
|
|
13784
13806
|
{ className: "inline-flex flex-col items-center leading-tight" },
|
|
13785
|
-
|
|
13786
|
-
|
|
13807
|
+
React39.createElement("span", { className: "text-[10px] font-medium uppercase tracking-wider text-muted-foreground/70" }, "S"),
|
|
13808
|
+
React39.createElement("span", { className: "text-sm font-semibold text-foreground" }, String(idx + 1).padStart(2, "0"))
|
|
13787
13809
|
);
|
|
13788
13810
|
})(),
|
|
13789
13811
|
isToday: (() => {
|
|
@@ -13811,9 +13833,9 @@ function useTimelineSlots(args) {
|
|
|
13811
13833
|
weekStartsOn,
|
|
13812
13834
|
workHours
|
|
13813
13835
|
]);
|
|
13814
|
-
const slotStarts =
|
|
13815
|
-
const todaySlotIdx =
|
|
13816
|
-
const weekendSlotIdxs =
|
|
13836
|
+
const slotStarts = React39.useMemo(() => slots.map((s) => s.start), [slots]);
|
|
13837
|
+
const todaySlotIdx = React39.useMemo(() => slots.findIndex((s) => s.isToday), [slots]);
|
|
13838
|
+
const weekendSlotIdxs = React39.useMemo(() => {
|
|
13817
13839
|
const out = [];
|
|
13818
13840
|
for (let i = 0; i < slots.length; i++) if (slots[i]?.isWeekend) out.push(i);
|
|
13819
13841
|
return out;
|
|
@@ -13822,16 +13844,16 @@ function useTimelineSlots(args) {
|
|
|
13822
13844
|
}
|
|
13823
13845
|
function useNormalizedEvents(args) {
|
|
13824
13846
|
const { events, range, activeView, resolvedTimeZone, resources } = args;
|
|
13825
|
-
const normalizedEvents =
|
|
13847
|
+
const normalizedEvents = React39.useMemo(() => {
|
|
13826
13848
|
return normalizeEvents({ events, range, view: activeView, timeZone: resolvedTimeZone });
|
|
13827
13849
|
}, [activeView, events, range, resolvedTimeZone]);
|
|
13828
|
-
const eventsByResource =
|
|
13829
|
-
const resourceById =
|
|
13850
|
+
const eventsByResource = React39.useMemo(() => eventsByResourceId(normalizedEvents), [normalizedEvents]);
|
|
13851
|
+
const resourceById = React39.useMemo(() => resourcesById(resources), [resources]);
|
|
13830
13852
|
return { normalizedEvents, eventsByResource, resourceById };
|
|
13831
13853
|
}
|
|
13832
13854
|
function useDayHeaderMarks(args) {
|
|
13833
13855
|
const { enabled, activeView, normalizedEvents, slotStarts, slotCount } = args;
|
|
13834
|
-
return
|
|
13856
|
+
return React39.useMemo(() => {
|
|
13835
13857
|
if (!enabled) return null;
|
|
13836
13858
|
if (activeView !== "day") return null;
|
|
13837
13859
|
const n = slotCount;
|
|
@@ -13866,14 +13888,14 @@ function useSlotMetrics(args) {
|
|
|
13866
13888
|
dayHeaderSmart,
|
|
13867
13889
|
daySlotCompression
|
|
13868
13890
|
} = args;
|
|
13869
|
-
const fixedSlotWidth =
|
|
13891
|
+
const fixedSlotWidth = React39.useMemo(() => {
|
|
13870
13892
|
const baseSlotWidth = activeView === "month" || activeView === "day" ? effectiveSlotMinWidth * 3 : effectiveSlotMinWidth;
|
|
13871
13893
|
if (activeView !== "week") return baseSlotWidth;
|
|
13872
13894
|
if (bodyClientWidth <= 0) return baseSlotWidth;
|
|
13873
13895
|
if (slotsLength <= 0) return baseSlotWidth;
|
|
13874
13896
|
return Math.max(baseSlotWidth, bodyClientWidth / slotsLength);
|
|
13875
13897
|
}, [activeView, bodyClientWidth, effectiveSlotMinWidth, slotsLength]);
|
|
13876
|
-
const slotMetrics =
|
|
13898
|
+
const slotMetrics = React39.useMemo(() => {
|
|
13877
13899
|
const n = slotsLength;
|
|
13878
13900
|
const widths = new Array(n).fill(fixedSlotWidth);
|
|
13879
13901
|
const isAdaptiveView = activeView === "month" || activeView === "day";
|
|
@@ -14004,7 +14026,7 @@ function useSlotMetrics(args) {
|
|
|
14004
14026
|
}
|
|
14005
14027
|
function useLayoutsByResource(args) {
|
|
14006
14028
|
const { eventsByResource, preview, slotStarts, slotsLength, slotLefts, getResourceRowHeight, laneGap, lanePaddingY, effectiveMaxLanesPerRow, eventHeight } = args;
|
|
14007
|
-
return
|
|
14029
|
+
return React39.useMemo(() => {
|
|
14008
14030
|
const map = /* @__PURE__ */ new Map();
|
|
14009
14031
|
for (const [resourceId, list] of eventsByResource.entries()) {
|
|
14010
14032
|
const mapped = list.map((ev) => {
|
|
@@ -14051,9 +14073,9 @@ function lowerBound2(arr, target) {
|
|
|
14051
14073
|
}
|
|
14052
14074
|
function useVisibleSlotRange(args) {
|
|
14053
14075
|
const { enabled, overscan, scrollRef, slotLefts, slotCount } = args;
|
|
14054
|
-
const [scrollLeft, setScrollLeft] =
|
|
14055
|
-
const [viewportWidth, setViewportWidth] =
|
|
14056
|
-
|
|
14076
|
+
const [scrollLeft, setScrollLeft] = React39.useState(0);
|
|
14077
|
+
const [viewportWidth, setViewportWidth] = React39.useState(0);
|
|
14078
|
+
React39.useEffect(() => {
|
|
14057
14079
|
if (!enabled) return;
|
|
14058
14080
|
const el = scrollRef.current;
|
|
14059
14081
|
if (!el) return;
|
|
@@ -14080,7 +14102,7 @@ function useVisibleSlotRange(args) {
|
|
|
14080
14102
|
el.removeEventListener("scroll", onScroll);
|
|
14081
14103
|
};
|
|
14082
14104
|
}, [enabled, scrollRef]);
|
|
14083
|
-
return
|
|
14105
|
+
return React39.useMemo(() => {
|
|
14084
14106
|
if (!enabled) return { startIdx: 0, endIdx: slotCount };
|
|
14085
14107
|
if (slotCount <= 0) return { startIdx: 0, endIdx: 0 };
|
|
14086
14108
|
if (viewportWidth <= 0) return { startIdx: 0, endIdx: slotCount };
|
|
@@ -14179,14 +14201,14 @@ function CalendarTimeline({
|
|
|
14179
14201
|
}) {
|
|
14180
14202
|
const t = useSmartTranslations("CalendarTimeline");
|
|
14181
14203
|
const detectedLocale = useSmartLocale();
|
|
14182
|
-
const resolvedLocale =
|
|
14183
|
-
const resolvedTimeZone =
|
|
14204
|
+
const resolvedLocale = React40.useMemo(() => localeToBCP47(locale ?? detectedLocale), [locale, detectedLocale]);
|
|
14205
|
+
const resolvedTimeZone = React40.useMemo(() => timeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone ?? "UTC", [timeZone]);
|
|
14184
14206
|
const effectiveEnableEventSheet = enableEventSheet ?? Boolean(renderEventSheet);
|
|
14185
14207
|
const isViewOnly = interactions?.mode === "view";
|
|
14186
14208
|
const isControlledSelectedEventId = selectedEventId !== void 0;
|
|
14187
|
-
const [internalSelectedEventId, setInternalSelectedEventId] =
|
|
14209
|
+
const [internalSelectedEventId, setInternalSelectedEventId] = React40.useState(defaultSelectedEventId ?? null);
|
|
14188
14210
|
const activeSelectedEventId = isControlledSelectedEventId ? selectedEventId : internalSelectedEventId;
|
|
14189
|
-
const setSelectedEventId =
|
|
14211
|
+
const setSelectedEventId = React40.useCallback(
|
|
14190
14212
|
(next) => {
|
|
14191
14213
|
if (!isControlledSelectedEventId) setInternalSelectedEventId(next);
|
|
14192
14214
|
onSelectedEventIdChange?.(next);
|
|
@@ -14194,9 +14216,9 @@ function CalendarTimeline({
|
|
|
14194
14216
|
[isControlledSelectedEventId, onSelectedEventIdChange]
|
|
14195
14217
|
);
|
|
14196
14218
|
const isControlledEventSheetOpen = eventSheetOpen !== void 0;
|
|
14197
|
-
const [internalEventSheetOpen, setInternalEventSheetOpen] =
|
|
14219
|
+
const [internalEventSheetOpen, setInternalEventSheetOpen] = React40.useState(defaultEventSheetOpen ?? false);
|
|
14198
14220
|
const activeEventSheetOpen = isControlledEventSheetOpen ? Boolean(eventSheetOpen) : internalEventSheetOpen;
|
|
14199
|
-
const setEventSheetOpen =
|
|
14221
|
+
const setEventSheetOpen = React40.useCallback(
|
|
14200
14222
|
(next) => {
|
|
14201
14223
|
if (!isControlledEventSheetOpen) setInternalEventSheetOpen(next);
|
|
14202
14224
|
onEventSheetOpenChange?.(next);
|
|
@@ -14205,12 +14227,12 @@ function CalendarTimeline({
|
|
|
14205
14227
|
[isControlledEventSheetOpen, onEventSheetOpenChange, setSelectedEventId]
|
|
14206
14228
|
);
|
|
14207
14229
|
const showResourceColumn = !hideResourceColumn;
|
|
14208
|
-
const sizeConfig =
|
|
14230
|
+
const sizeConfig = React40.useMemo(() => getSizeConfig(size), [size]);
|
|
14209
14231
|
const densityClass = sizeConfig.densityClass;
|
|
14210
14232
|
const eventHeight = sizeConfig.eventHeight;
|
|
14211
14233
|
const laneGap = sizeConfig.laneGap;
|
|
14212
14234
|
const lanePaddingY = sizeConfig.lanePaddingY;
|
|
14213
|
-
const canResizeColumn =
|
|
14235
|
+
const canResizeColumn = React40.useMemo(() => {
|
|
14214
14236
|
const cfg = enableLayoutResize;
|
|
14215
14237
|
if (!cfg) return false;
|
|
14216
14238
|
if (isViewOnly) return false;
|
|
@@ -14218,7 +14240,7 @@ function CalendarTimeline({
|
|
|
14218
14240
|
if (cfg === true) return true;
|
|
14219
14241
|
return cfg.column !== false;
|
|
14220
14242
|
}, [enableLayoutResize, isViewOnly, showResourceColumn]);
|
|
14221
|
-
const canResizeRow =
|
|
14243
|
+
const canResizeRow = React40.useMemo(() => {
|
|
14222
14244
|
const cfg = enableLayoutResize;
|
|
14223
14245
|
if (!cfg) return false;
|
|
14224
14246
|
if (isViewOnly) return false;
|
|
@@ -14227,19 +14249,19 @@ function CalendarTimeline({
|
|
|
14227
14249
|
return cfg.row !== false;
|
|
14228
14250
|
}, [enableLayoutResize, isViewOnly, showResourceColumn]);
|
|
14229
14251
|
const isControlledResourceColumnWidth = resourceColumnWidth !== void 0;
|
|
14230
|
-
const [internalResourceColumnWidth, setInternalResourceColumnWidth] =
|
|
14252
|
+
const [internalResourceColumnWidth, setInternalResourceColumnWidth] = React40.useState(() => {
|
|
14231
14253
|
const init = defaultResourceColumnWidth ?? sizeConfig.resourceColumnWidth;
|
|
14232
14254
|
return typeof init === "number" ? init : sizeConfig.resourceColumnWidth;
|
|
14233
14255
|
});
|
|
14234
|
-
|
|
14256
|
+
React40.useEffect(() => {
|
|
14235
14257
|
if (isControlledResourceColumnWidth) return;
|
|
14236
14258
|
if (defaultResourceColumnWidth == null) return;
|
|
14237
14259
|
setInternalResourceColumnWidth(defaultResourceColumnWidth);
|
|
14238
14260
|
}, [defaultResourceColumnWidth, isControlledResourceColumnWidth]);
|
|
14239
14261
|
const effectiveResourceColumnWidth = showResourceColumn ? isControlledResourceColumnWidth ? resourceColumnWidth : internalResourceColumnWidth : 0;
|
|
14240
14262
|
const isControlledRowHeight = rowHeight !== void 0;
|
|
14241
|
-
const [internalRowHeight, setInternalRowHeight] =
|
|
14242
|
-
|
|
14263
|
+
const [internalRowHeight, setInternalRowHeight] = React40.useState(() => defaultRowHeight ?? sizeConfig.rowHeight);
|
|
14264
|
+
React40.useEffect(() => {
|
|
14243
14265
|
if (isControlledRowHeight) return;
|
|
14244
14266
|
if (defaultRowHeight == null) return;
|
|
14245
14267
|
setInternalRowHeight(defaultRowHeight);
|
|
@@ -14250,14 +14272,14 @@ function CalendarTimeline({
|
|
|
14250
14272
|
const colMax = maxResourceColumnWidth ?? 520;
|
|
14251
14273
|
const rowMin = minRowHeight ?? 36;
|
|
14252
14274
|
const rowMax = maxRowHeight ?? 120;
|
|
14253
|
-
const viewList =
|
|
14254
|
-
const availableViews =
|
|
14275
|
+
const viewList = React40.useMemo(() => Array.isArray(view) ? view : void 0, [view]);
|
|
14276
|
+
const availableViews = React40.useMemo(() => {
|
|
14255
14277
|
if (onlyView) return [onlyView];
|
|
14256
14278
|
if (viewList?.length) return viewList;
|
|
14257
14279
|
return ["month", "week", "day", "sprint"];
|
|
14258
14280
|
}, [onlyView, viewList]);
|
|
14259
14281
|
const isControlledView = view !== void 0 && !Array.isArray(view);
|
|
14260
|
-
const [internalView, setInternalView] =
|
|
14282
|
+
const [internalView, setInternalView] = React40.useState(() => {
|
|
14261
14283
|
if (onlyView) return onlyView;
|
|
14262
14284
|
if (viewList?.length) {
|
|
14263
14285
|
if (defaultView && viewList.includes(defaultView)) return defaultView;
|
|
@@ -14266,13 +14288,13 @@ function CalendarTimeline({
|
|
|
14266
14288
|
return defaultView ?? "month";
|
|
14267
14289
|
});
|
|
14268
14290
|
const activeView = onlyView ? onlyView : isControlledView ? view : internalView;
|
|
14269
|
-
|
|
14291
|
+
React40.useEffect(() => {
|
|
14270
14292
|
if (onlyView || isControlledView) return;
|
|
14271
14293
|
if (!availableViews.includes(internalView)) {
|
|
14272
14294
|
setInternalView(availableViews[0] ?? "month");
|
|
14273
14295
|
}
|
|
14274
14296
|
}, [availableViews, internalView, isControlledView, onlyView]);
|
|
14275
|
-
const effectiveSlotMinWidth =
|
|
14297
|
+
const effectiveSlotMinWidth = React40.useMemo(() => {
|
|
14276
14298
|
if (slotMinWidth == null) {
|
|
14277
14299
|
if (activeView === "month" && monthEventStyle === "compact") {
|
|
14278
14300
|
return clamp5(Math.round(sizeConfig.slotMinWidth * 0.55), 32, sizeConfig.slotMinWidth);
|
|
@@ -14284,17 +14306,17 @@ function CalendarTimeline({
|
|
|
14284
14306
|
return baseSlotMinWidth;
|
|
14285
14307
|
}, [activeView, baseSlotMinWidth, monthEventStyle, sizeConfig.slotMinWidth, slotMinWidth]);
|
|
14286
14308
|
const isControlledDate = date !== void 0;
|
|
14287
|
-
const [internalDate, setInternalDate] =
|
|
14309
|
+
const [internalDate, setInternalDate] = React40.useState(() => defaultDate ?? /* @__PURE__ */ new Date());
|
|
14288
14310
|
const activeDate = isControlledDate ? date : internalDate;
|
|
14289
|
-
const resolvedNow =
|
|
14290
|
-
const formatToken =
|
|
14311
|
+
const resolvedNow = React40.useMemo(() => now ?? /* @__PURE__ */ new Date(), [now]);
|
|
14312
|
+
const formatToken = React40.useCallback((key, params) => {
|
|
14291
14313
|
let message = t(key);
|
|
14292
14314
|
for (const [name, value] of Object.entries(params)) {
|
|
14293
14315
|
message = message.replaceAll(`{${name}}`, String(value));
|
|
14294
14316
|
}
|
|
14295
14317
|
return message;
|
|
14296
14318
|
}, [t]);
|
|
14297
|
-
const l =
|
|
14319
|
+
const l = React40.useMemo(
|
|
14298
14320
|
() => ({
|
|
14299
14321
|
today: labels?.today ?? t("today"),
|
|
14300
14322
|
prev: labels?.prev ?? t("prev"),
|
|
@@ -14317,7 +14339,7 @@ function CalendarTimeline({
|
|
|
14317
14339
|
}),
|
|
14318
14340
|
[formatToken, labels, t]
|
|
14319
14341
|
);
|
|
14320
|
-
const setView =
|
|
14342
|
+
const setView = React40.useCallback(
|
|
14321
14343
|
(next) => {
|
|
14322
14344
|
if (onlyView) return;
|
|
14323
14345
|
if (!availableViews.includes(next)) return;
|
|
@@ -14326,14 +14348,14 @@ function CalendarTimeline({
|
|
|
14326
14348
|
},
|
|
14327
14349
|
[availableViews, isControlledView, onViewChange, onlyView]
|
|
14328
14350
|
);
|
|
14329
|
-
const setDate =
|
|
14351
|
+
const setDate = React40.useCallback(
|
|
14330
14352
|
(next) => {
|
|
14331
14353
|
if (!isControlledDate) setInternalDate(next);
|
|
14332
14354
|
onDateChange?.(next);
|
|
14333
14355
|
},
|
|
14334
14356
|
[isControlledDate, onDateChange]
|
|
14335
14357
|
);
|
|
14336
|
-
const navigate =
|
|
14358
|
+
const navigate = React40.useCallback(
|
|
14337
14359
|
(dir) => {
|
|
14338
14360
|
const base2 = activeDate;
|
|
14339
14361
|
if (activeView === "month") {
|
|
@@ -14352,17 +14374,17 @@ function CalendarTimeline({
|
|
|
14352
14374
|
},
|
|
14353
14375
|
[activeDate, activeView, resolvedTimeZone, setDate]
|
|
14354
14376
|
);
|
|
14355
|
-
const [internalCollapsed, setInternalCollapsed] =
|
|
14377
|
+
const [internalCollapsed, setInternalCollapsed] = React40.useState(() => defaultGroupCollapsed ?? {});
|
|
14356
14378
|
const collapsed = groupCollapsed ?? internalCollapsed;
|
|
14357
|
-
const setCollapsed =
|
|
14379
|
+
const setCollapsed = React40.useCallback(
|
|
14358
14380
|
(next) => {
|
|
14359
14381
|
if (!groupCollapsed) setInternalCollapsed(next);
|
|
14360
14382
|
onGroupCollapsedChange?.(next);
|
|
14361
14383
|
},
|
|
14362
14384
|
[groupCollapsed, onGroupCollapsedChange]
|
|
14363
14385
|
);
|
|
14364
|
-
const rows =
|
|
14365
|
-
const groupResourceCounts =
|
|
14386
|
+
const rows = React40.useMemo(() => buildRows({ resources, groups, collapsed }), [resources, groups, collapsed]);
|
|
14387
|
+
const groupResourceCounts = React40.useMemo(() => getGroupResourceCounts(resources), [resources]);
|
|
14366
14388
|
const { slots, range, slotStarts, todaySlotIdx, weekendSlotIdxs } = useTimelineSlots({
|
|
14367
14389
|
activeView,
|
|
14368
14390
|
activeDate,
|
|
@@ -14376,12 +14398,12 @@ function CalendarTimeline({
|
|
|
14376
14398
|
formatters,
|
|
14377
14399
|
dueDateSprint
|
|
14378
14400
|
});
|
|
14379
|
-
|
|
14401
|
+
React40.useEffect(() => {
|
|
14380
14402
|
onRangeChange?.(range);
|
|
14381
14403
|
}, [range, onRangeChange]);
|
|
14382
|
-
const leftRef =
|
|
14383
|
-
const bodyRef =
|
|
14384
|
-
const headerRef =
|
|
14404
|
+
const leftRef = React40.useRef(null);
|
|
14405
|
+
const bodyRef = React40.useRef(null);
|
|
14406
|
+
const headerRef = React40.useRef(null);
|
|
14385
14407
|
const bodyClientWidth = useClientWidth(bodyRef);
|
|
14386
14408
|
const { normalizedEvents, eventsByResource, resourceById } = useNormalizedEvents({
|
|
14387
14409
|
events,
|
|
@@ -14413,16 +14435,16 @@ function CalendarTimeline({
|
|
|
14413
14435
|
slotLefts,
|
|
14414
14436
|
slotCount: slots.length
|
|
14415
14437
|
});
|
|
14416
|
-
const selectedEvent =
|
|
14438
|
+
const selectedEvent = React40.useMemo(() => {
|
|
14417
14439
|
if (!activeSelectedEventId) return null;
|
|
14418
14440
|
const found2 = normalizedEvents.find((e) => e.id === activeSelectedEventId);
|
|
14419
14441
|
return found2 ?? null;
|
|
14420
14442
|
}, [activeSelectedEventId, normalizedEvents]);
|
|
14421
|
-
const selectedResource =
|
|
14443
|
+
const selectedResource = React40.useMemo(() => {
|
|
14422
14444
|
if (!selectedEvent) return void 0;
|
|
14423
14445
|
return resourceById.get(selectedEvent.resourceId);
|
|
14424
14446
|
}, [resourceById, selectedEvent]);
|
|
14425
|
-
const selectedTimeText =
|
|
14447
|
+
const selectedTimeText = React40.useMemo(() => {
|
|
14426
14448
|
if (!selectedEvent) return "";
|
|
14427
14449
|
return formatters?.eventTime?.({
|
|
14428
14450
|
start: selectedEvent._start,
|
|
@@ -14432,7 +14454,7 @@ function CalendarTimeline({
|
|
|
14432
14454
|
view: activeView
|
|
14433
14455
|
}) ?? defaultEventTime({ start: selectedEvent._start, end: selectedEvent._end, locale: resolvedLocale, timeZone: resolvedTimeZone, view: activeView });
|
|
14434
14456
|
}, [activeView, formatters, resolvedLocale, resolvedTimeZone, selectedEvent]);
|
|
14435
|
-
|
|
14457
|
+
React40.useEffect(() => {
|
|
14436
14458
|
if (!effectiveEnableEventSheet) return;
|
|
14437
14459
|
if (activeEventSheetOpen && activeSelectedEventId && !selectedEvent) {
|
|
14438
14460
|
setEventSheetOpen(false);
|
|
@@ -14442,24 +14464,24 @@ function CalendarTimeline({
|
|
|
14442
14464
|
const virt = virtualization == null ? rows.length > 60 : Boolean(virtualization.enabled);
|
|
14443
14465
|
const overscan = virtualization?.overscan ?? 8;
|
|
14444
14466
|
const isControlledRowHeights = rowHeights !== void 0;
|
|
14445
|
-
const [internalRowHeights, setInternalRowHeights] =
|
|
14446
|
-
|
|
14467
|
+
const [internalRowHeights, setInternalRowHeights] = React40.useState(() => defaultRowHeights ?? {});
|
|
14468
|
+
React40.useEffect(() => {
|
|
14447
14469
|
if (isControlledRowHeights) return;
|
|
14448
14470
|
if (!defaultRowHeights) return;
|
|
14449
14471
|
setInternalRowHeights(defaultRowHeights);
|
|
14450
14472
|
}, [defaultRowHeights, isControlledRowHeights]);
|
|
14451
14473
|
const activeRowHeights = isControlledRowHeights ? rowHeights : internalRowHeights;
|
|
14452
|
-
const autoRowHeightCfg =
|
|
14474
|
+
const autoRowHeightCfg = React40.useMemo(() => {
|
|
14453
14475
|
if (!autoRowHeight) return null;
|
|
14454
14476
|
return autoRowHeight === true ? {} : autoRowHeight;
|
|
14455
14477
|
}, [autoRowHeight]);
|
|
14456
|
-
const effectiveMaxLanesPerRow =
|
|
14478
|
+
const effectiveMaxLanesPerRow = React40.useMemo(() => {
|
|
14457
14479
|
if (!autoRowHeightCfg) return maxLanesPerRow;
|
|
14458
14480
|
const maxLanes = autoRowHeightCfg.maxLanesPerRow;
|
|
14459
14481
|
if (typeof maxLanes === "number" && Number.isFinite(maxLanes) && maxLanes > 0) return Math.floor(maxLanes);
|
|
14460
14482
|
return Number.POSITIVE_INFINITY;
|
|
14461
14483
|
}, [autoRowHeightCfg, maxLanesPerRow]);
|
|
14462
|
-
const autoRowHeightsByResource =
|
|
14484
|
+
const autoRowHeightsByResource = React40.useMemo(() => {
|
|
14463
14485
|
if (!autoRowHeightCfg) return null;
|
|
14464
14486
|
const maxRowHeight2 = autoRowHeightCfg.maxRowHeight;
|
|
14465
14487
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -14477,7 +14499,7 @@ function CalendarTimeline({
|
|
|
14477
14499
|
}
|
|
14478
14500
|
return out;
|
|
14479
14501
|
}, [autoRowHeightCfg, eventHeight, eventsByResource, laneGap, lanePaddingY, slotStarts, slots.length, effectiveMaxLanesPerRow]);
|
|
14480
|
-
const getResourceRowHeight =
|
|
14502
|
+
const getResourceRowHeight = React40.useCallback(
|
|
14481
14503
|
(resourceId) => {
|
|
14482
14504
|
const h = activeRowHeights[resourceId];
|
|
14483
14505
|
const base2 = typeof h === "number" && Number.isFinite(h) && h > 0 ? h : effectiveRowHeight;
|
|
@@ -14487,7 +14509,7 @@ function CalendarTimeline({
|
|
|
14487
14509
|
},
|
|
14488
14510
|
[activeRowHeights, autoRowHeightsByResource, effectiveRowHeight]
|
|
14489
14511
|
);
|
|
14490
|
-
const setRowHeightForResource =
|
|
14512
|
+
const setRowHeightForResource = React40.useCallback(
|
|
14491
14513
|
(resourceId, height) => {
|
|
14492
14514
|
const clamped = clamp5(Math.round(height), rowMin, rowMax);
|
|
14493
14515
|
onRowHeightChange?.(clamped);
|
|
@@ -14504,7 +14526,7 @@ function CalendarTimeline({
|
|
|
14504
14526
|
},
|
|
14505
14527
|
[activeRowHeights, isControlledRowHeights, onRowHeightChange, onRowHeightsChange, rowMax, rowMin]
|
|
14506
14528
|
);
|
|
14507
|
-
const rowHeightsArray =
|
|
14529
|
+
const rowHeightsArray = React40.useMemo(() => {
|
|
14508
14530
|
return rows.map((r) => {
|
|
14509
14531
|
if (r.kind === "resource") return getResourceRowHeight(r.resource.id);
|
|
14510
14532
|
return sizeConfig.groupRowHeight;
|
|
@@ -14520,13 +14542,13 @@ function CalendarTimeline({
|
|
|
14520
14542
|
const endRow = virt ? virtualResult.endIndex : rows.length;
|
|
14521
14543
|
const topSpacer = virt ? virtualResult.topSpacer : 0;
|
|
14522
14544
|
const bottomSpacer = virt ? virtualResult.bottomSpacer : 0;
|
|
14523
|
-
const renderedRowsHeight =
|
|
14545
|
+
const renderedRowsHeight = React40.useMemo(() => {
|
|
14524
14546
|
let h = 0;
|
|
14525
14547
|
for (let i = startRow; i < endRow; i++) h += rowHeightsArray[i] ?? effectiveRowHeight;
|
|
14526
14548
|
return h;
|
|
14527
14549
|
}, [effectiveRowHeight, endRow, rowHeightsArray, startRow]);
|
|
14528
|
-
const resizeRef =
|
|
14529
|
-
const setResourceColumnWidth =
|
|
14550
|
+
const resizeRef = React40.useRef(null);
|
|
14551
|
+
const setResourceColumnWidth = React40.useCallback(
|
|
14530
14552
|
(next) => {
|
|
14531
14553
|
const clamped = clamp5(Math.round(next), colMin, colMax);
|
|
14532
14554
|
if (!isControlledResourceColumnWidth) setInternalResourceColumnWidth(clamped);
|
|
@@ -14534,7 +14556,7 @@ function CalendarTimeline({
|
|
|
14534
14556
|
},
|
|
14535
14557
|
[colMax, colMin, isControlledResourceColumnWidth, onResourceColumnWidthChange]
|
|
14536
14558
|
);
|
|
14537
|
-
const startResize =
|
|
14559
|
+
const startResize = React40.useCallback(
|
|
14538
14560
|
(mode, e, args) => {
|
|
14539
14561
|
if (e.button !== 0 || e.ctrlKey) return;
|
|
14540
14562
|
resizeRef.current = {
|
|
@@ -14577,7 +14599,7 @@ function CalendarTimeline({
|
|
|
14577
14599
|
},
|
|
14578
14600
|
[setResourceColumnWidth, setRowHeightForResource]
|
|
14579
14601
|
);
|
|
14580
|
-
|
|
14602
|
+
React40.useEffect(() => {
|
|
14581
14603
|
return () => {
|
|
14582
14604
|
if (!resizeRef.current) return;
|
|
14583
14605
|
resizeRef.current = null;
|
|
@@ -14585,7 +14607,7 @@ function CalendarTimeline({
|
|
|
14585
14607
|
document.body.style.userSelect = "";
|
|
14586
14608
|
};
|
|
14587
14609
|
}, []);
|
|
14588
|
-
const beginResizeColumn =
|
|
14610
|
+
const beginResizeColumn = React40.useCallback(
|
|
14589
14611
|
(e) => {
|
|
14590
14612
|
if (!canResizeColumn) return;
|
|
14591
14613
|
if (typeof effectiveResourceColumnWidth !== "number") return;
|
|
@@ -14593,7 +14615,7 @@ function CalendarTimeline({
|
|
|
14593
14615
|
},
|
|
14594
14616
|
[canResizeColumn, effectiveResourceColumnWidth, effectiveRowHeight, startResize]
|
|
14595
14617
|
);
|
|
14596
|
-
const beginResizeResourceRow =
|
|
14618
|
+
const beginResizeResourceRow = React40.useCallback(
|
|
14597
14619
|
(resourceId) => (e) => {
|
|
14598
14620
|
if (!canResizeRow) return;
|
|
14599
14621
|
startResize("row", e, {
|
|
@@ -14604,7 +14626,7 @@ function CalendarTimeline({
|
|
|
14604
14626
|
},
|
|
14605
14627
|
[canResizeRow, effectiveResourceColumnWidth, getResourceRowHeight, startResize]
|
|
14606
14628
|
);
|
|
14607
|
-
const title =
|
|
14629
|
+
const title = React40.useMemo(() => {
|
|
14608
14630
|
if (activeView === "month") {
|
|
14609
14631
|
return formatters?.monthTitle?.(activeDate, { locale: resolvedLocale, timeZone: resolvedTimeZone }) ?? defaultMonthTitle(activeDate, resolvedLocale, resolvedTimeZone);
|
|
14610
14632
|
}
|
|
@@ -14631,11 +14653,11 @@ function CalendarTimeline({
|
|
|
14631
14653
|
}, [activeDate, activeView, formatToken, formatters, l.sprint, l.week, range.end, range.start, resolvedLocale, resolvedTimeZone, slots.length]);
|
|
14632
14654
|
const createMode = interactions?.createMode ?? "drag";
|
|
14633
14655
|
const canCreate = !isViewOnly && (interactions?.creatable ?? false) && !!onCreateEvent;
|
|
14634
|
-
const [createOpen, setCreateOpen] =
|
|
14635
|
-
const [createResourceId, setCreateResourceId] =
|
|
14636
|
-
const [createStartIdx, setCreateStartIdx] =
|
|
14637
|
-
const [createEndIdx, setCreateEndIdx] =
|
|
14638
|
-
const resourceOptions =
|
|
14656
|
+
const [createOpen, setCreateOpen] = React40.useState(false);
|
|
14657
|
+
const [createResourceId, setCreateResourceId] = React40.useState(null);
|
|
14658
|
+
const [createStartIdx, setCreateStartIdx] = React40.useState(0);
|
|
14659
|
+
const [createEndIdx, setCreateEndIdx] = React40.useState(1);
|
|
14660
|
+
const resourceOptions = React40.useMemo(() => {
|
|
14639
14661
|
return resources.map((r) => ({
|
|
14640
14662
|
label: typeof r.label === "string" ? r.label : r.id,
|
|
14641
14663
|
value: r.id,
|
|
@@ -14643,7 +14665,7 @@ function CalendarTimeline({
|
|
|
14643
14665
|
disabled: r.disabled ?? false
|
|
14644
14666
|
}));
|
|
14645
14667
|
}, [resources]);
|
|
14646
|
-
const formatCreateBoundaryLabel =
|
|
14668
|
+
const formatCreateBoundaryLabel = React40.useMemo(() => {
|
|
14647
14669
|
const timeFmt = getDtf(resolvedLocale, resolvedTimeZone, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" });
|
|
14648
14670
|
const dayFmt = getDtf(resolvedLocale, resolvedTimeZone, { weekday: "short", month: "short", day: "numeric" });
|
|
14649
14671
|
const yearFmt = getDtf(resolvedLocale, resolvedTimeZone, { year: "numeric" });
|
|
@@ -14691,7 +14713,7 @@ function CalendarTimeline({
|
|
|
14691
14713
|
return dayFmt.format(d);
|
|
14692
14714
|
};
|
|
14693
14715
|
}, [activeView, dueDateSprint, l.sprint, resolvedLocale, resolvedTimeZone, slotStarts]);
|
|
14694
|
-
const openCreate =
|
|
14716
|
+
const openCreate = React40.useCallback(() => {
|
|
14695
14717
|
if (!canCreate) return;
|
|
14696
14718
|
if (activeEventSheetOpen) setEventSheetOpen(false);
|
|
14697
14719
|
const firstResource = resources.find((r) => !r.disabled)?.id ?? resources[0]?.id ?? null;
|
|
@@ -14723,13 +14745,13 @@ function CalendarTimeline({
|
|
|
14723
14745
|
slotStarts,
|
|
14724
14746
|
slots.length
|
|
14725
14747
|
]);
|
|
14726
|
-
|
|
14748
|
+
React40.useEffect(() => {
|
|
14727
14749
|
setCreateEndIdx((prev) => Math.min(slots.length, Math.max(prev, createStartIdx + 1)));
|
|
14728
14750
|
}, [createStartIdx, slots.length]);
|
|
14729
|
-
const createStartOptions =
|
|
14751
|
+
const createStartOptions = React40.useMemo(() => {
|
|
14730
14752
|
return slotStarts.map((d, idx) => ({ label: formatCreateBoundaryLabel(d, { kind: "start", boundaryIdx: idx }), value: idx }));
|
|
14731
14753
|
}, [formatCreateBoundaryLabel, slotStarts]);
|
|
14732
|
-
const createEndOptions =
|
|
14754
|
+
const createEndOptions = React40.useMemo(() => {
|
|
14733
14755
|
const out = [];
|
|
14734
14756
|
for (let idx = createStartIdx + 1; idx <= slotStarts.length; idx++) {
|
|
14735
14757
|
const boundary = idx >= slotStarts.length ? range.end : slotStarts[idx];
|
|
@@ -14737,7 +14759,7 @@ function CalendarTimeline({
|
|
|
14737
14759
|
}
|
|
14738
14760
|
return out;
|
|
14739
14761
|
}, [createStartIdx, formatCreateBoundaryLabel, range.end, slotStarts]);
|
|
14740
|
-
const commitCreate =
|
|
14762
|
+
const commitCreate = React40.useCallback(() => {
|
|
14741
14763
|
if (!onCreateEvent) return;
|
|
14742
14764
|
if (!createResourceId) return;
|
|
14743
14765
|
const start = slotStarts[clamp5(createStartIdx, 0, Math.max(0, slotStarts.length - 1))];
|
|
@@ -14748,38 +14770,38 @@ function CalendarTimeline({
|
|
|
14748
14770
|
onCreateEvent({ resourceId: createResourceId, start, end: endBoundary });
|
|
14749
14771
|
setCreateOpen(false);
|
|
14750
14772
|
}, [createEndIdx, createResourceId, createStartIdx, onCreateEvent, range.end, slotStarts]);
|
|
14751
|
-
const dragRef =
|
|
14752
|
-
const [preview, setPreviewState] =
|
|
14753
|
-
const previewRef =
|
|
14754
|
-
const setPreview =
|
|
14773
|
+
const dragRef = React40.useRef(null);
|
|
14774
|
+
const [preview, setPreviewState] = React40.useState(null);
|
|
14775
|
+
const previewRef = React40.useRef(null);
|
|
14776
|
+
const setPreview = React40.useCallback((next) => {
|
|
14755
14777
|
previewRef.current = next;
|
|
14756
14778
|
setPreviewState(next);
|
|
14757
14779
|
}, []);
|
|
14758
|
-
const suppressNextEventClickRef =
|
|
14759
|
-
const [hoverCell, setHoverCellState] =
|
|
14760
|
-
const hoverCellRef =
|
|
14761
|
-
const setHoverCell =
|
|
14780
|
+
const suppressNextEventClickRef = React40.useRef(false);
|
|
14781
|
+
const [hoverCell, setHoverCellState] = React40.useState(null);
|
|
14782
|
+
const hoverCellRef = React40.useRef(null);
|
|
14783
|
+
const setHoverCell = React40.useCallback((next) => {
|
|
14762
14784
|
hoverCellRef.current = next;
|
|
14763
14785
|
setHoverCellState(next);
|
|
14764
14786
|
}, []);
|
|
14765
|
-
const autoScrollStateRef =
|
|
14787
|
+
const autoScrollStateRef = React40.useRef({
|
|
14766
14788
|
dir: 0,
|
|
14767
14789
|
speed: 0,
|
|
14768
14790
|
lastClientX: 0,
|
|
14769
14791
|
lastClientY: 0
|
|
14770
14792
|
});
|
|
14771
|
-
const autoScrollRafRef =
|
|
14772
|
-
const dragPreviewRafRef =
|
|
14773
|
-
const dragPreviewPointRef =
|
|
14774
|
-
const hoverCellRafRef =
|
|
14775
|
-
const hoverCellPendingRef =
|
|
14776
|
-
const stopAutoScroll =
|
|
14793
|
+
const autoScrollRafRef = React40.useRef(null);
|
|
14794
|
+
const dragPreviewRafRef = React40.useRef(null);
|
|
14795
|
+
const dragPreviewPointRef = React40.useRef(null);
|
|
14796
|
+
const hoverCellRafRef = React40.useRef(null);
|
|
14797
|
+
const hoverCellPendingRef = React40.useRef(null);
|
|
14798
|
+
const stopAutoScroll = React40.useCallback(() => {
|
|
14777
14799
|
if (autoScrollRafRef.current != null) cancelAnimationFrame(autoScrollRafRef.current);
|
|
14778
14800
|
autoScrollRafRef.current = null;
|
|
14779
14801
|
autoScrollStateRef.current.dir = 0;
|
|
14780
14802
|
autoScrollStateRef.current.speed = 0;
|
|
14781
14803
|
}, []);
|
|
14782
|
-
const getPointerContext =
|
|
14804
|
+
const getPointerContext = React40.useCallback(
|
|
14783
14805
|
(clientX, clientY, opts) => {
|
|
14784
14806
|
const body = bodyRef.current;
|
|
14785
14807
|
if (!body) return null;
|
|
@@ -14797,7 +14819,7 @@ function CalendarTimeline({
|
|
|
14797
14819
|
},
|
|
14798
14820
|
[xToSlotIdx]
|
|
14799
14821
|
);
|
|
14800
|
-
const slotToDate =
|
|
14822
|
+
const slotToDate = React40.useCallback(
|
|
14801
14823
|
(slotIdx) => {
|
|
14802
14824
|
const start = slotStarts[clamp5(slotIdx, 0, slotStarts.length - 1)];
|
|
14803
14825
|
if (activeView === "day") {
|
|
@@ -14811,7 +14833,7 @@ function CalendarTimeline({
|
|
|
14811
14833
|
},
|
|
14812
14834
|
[activeView, dayTimeStepMinutes, resolvedTimeZone, slotStarts]
|
|
14813
14835
|
);
|
|
14814
|
-
const updateDragPreview =
|
|
14836
|
+
const updateDragPreview = React40.useCallback(
|
|
14815
14837
|
(clientX, clientY) => {
|
|
14816
14838
|
const drag = dragRef.current;
|
|
14817
14839
|
if (!drag) return;
|
|
@@ -14855,13 +14877,13 @@ function CalendarTimeline({
|
|
|
14855
14877
|
},
|
|
14856
14878
|
[getPointerContext, range.end, range.start, setPreview, slotToDate, slots.length]
|
|
14857
14879
|
);
|
|
14858
|
-
const flushDragPreview =
|
|
14880
|
+
const flushDragPreview = React40.useCallback(() => {
|
|
14859
14881
|
dragPreviewRafRef.current = null;
|
|
14860
14882
|
const point = dragPreviewPointRef.current;
|
|
14861
14883
|
if (!point) return;
|
|
14862
14884
|
updateDragPreview(point.x, point.y);
|
|
14863
14885
|
}, [updateDragPreview]);
|
|
14864
|
-
const scheduleDragPreview =
|
|
14886
|
+
const scheduleDragPreview = React40.useCallback(
|
|
14865
14887
|
(clientX, clientY) => {
|
|
14866
14888
|
dragPreviewPointRef.current = { x: clientX, y: clientY };
|
|
14867
14889
|
if (dragPreviewRafRef.current != null) return;
|
|
@@ -14869,7 +14891,7 @@ function CalendarTimeline({
|
|
|
14869
14891
|
},
|
|
14870
14892
|
[flushDragPreview]
|
|
14871
14893
|
);
|
|
14872
|
-
const applyHoverCell =
|
|
14894
|
+
const applyHoverCell = React40.useCallback(
|
|
14873
14895
|
(next) => {
|
|
14874
14896
|
const prev = hoverCellRef.current;
|
|
14875
14897
|
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;
|
|
@@ -14878,11 +14900,11 @@ function CalendarTimeline({
|
|
|
14878
14900
|
},
|
|
14879
14901
|
[setHoverCell]
|
|
14880
14902
|
);
|
|
14881
|
-
const flushHoverCell =
|
|
14903
|
+
const flushHoverCell = React40.useCallback(() => {
|
|
14882
14904
|
hoverCellRafRef.current = null;
|
|
14883
14905
|
applyHoverCell(hoverCellPendingRef.current);
|
|
14884
14906
|
}, [applyHoverCell]);
|
|
14885
|
-
const scheduleHoverCell =
|
|
14907
|
+
const scheduleHoverCell = React40.useCallback(
|
|
14886
14908
|
(next) => {
|
|
14887
14909
|
hoverCellPendingRef.current = next;
|
|
14888
14910
|
if (hoverCellRafRef.current != null) return;
|
|
@@ -14890,7 +14912,7 @@ function CalendarTimeline({
|
|
|
14890
14912
|
},
|
|
14891
14913
|
[flushHoverCell]
|
|
14892
14914
|
);
|
|
14893
|
-
const autoScrollTick =
|
|
14915
|
+
const autoScrollTick = React40.useCallback(() => {
|
|
14894
14916
|
const drag = dragRef.current;
|
|
14895
14917
|
const body = bodyRef.current;
|
|
14896
14918
|
const st = autoScrollStateRef.current;
|
|
@@ -14909,7 +14931,7 @@ function CalendarTimeline({
|
|
|
14909
14931
|
updateDragPreview(st.lastClientX, st.lastClientY);
|
|
14910
14932
|
autoScrollRafRef.current = requestAnimationFrame(autoScrollTick);
|
|
14911
14933
|
}, [stopAutoScroll, updateDragPreview]);
|
|
14912
|
-
const updateAutoScrollFromPointer =
|
|
14934
|
+
const updateAutoScrollFromPointer = React40.useCallback(
|
|
14913
14935
|
(clientX, clientY) => {
|
|
14914
14936
|
const body = bodyRef.current;
|
|
14915
14937
|
if (!body) return;
|
|
@@ -14940,8 +14962,8 @@ function CalendarTimeline({
|
|
|
14940
14962
|
},
|
|
14941
14963
|
[autoScrollTick, stopAutoScroll]
|
|
14942
14964
|
);
|
|
14943
|
-
|
|
14944
|
-
|
|
14965
|
+
React40.useEffect(() => stopAutoScroll, [stopAutoScroll]);
|
|
14966
|
+
React40.useEffect(() => {
|
|
14945
14967
|
return () => {
|
|
14946
14968
|
if (dragPreviewRafRef.current != null) cancelAnimationFrame(dragPreviewRafRef.current);
|
|
14947
14969
|
if (hoverCellRafRef.current != null) cancelAnimationFrame(hoverCellRafRef.current);
|
|
@@ -15088,7 +15110,7 @@ function CalendarTimeline({
|
|
|
15088
15110
|
}
|
|
15089
15111
|
setPreview(null);
|
|
15090
15112
|
};
|
|
15091
|
-
const onBodyPointerLeave =
|
|
15113
|
+
const onBodyPointerLeave = React40.useCallback(() => {
|
|
15092
15114
|
hoverCellPendingRef.current = null;
|
|
15093
15115
|
if (hoverCellRafRef.current != null) {
|
|
15094
15116
|
cancelAnimationFrame(hoverCellRafRef.current);
|
|
@@ -15115,7 +15137,7 @@ function CalendarTimeline({
|
|
|
15115
15137
|
}
|
|
15116
15138
|
);
|
|
15117
15139
|
};
|
|
15118
|
-
const slotHeaderNodes =
|
|
15140
|
+
const slotHeaderNodes = React40.useMemo(() => {
|
|
15119
15141
|
const startIdx = colVirtEnabled ? visibleSlots.startIdx : 0;
|
|
15120
15142
|
const endIdx = colVirtEnabled ? visibleSlots.endIdx : slots.length;
|
|
15121
15143
|
const leftSpacer = startIdx > 0 ? slotLefts[startIdx] ?? 0 : 0;
|
|
@@ -15441,7 +15463,7 @@ function CalendarTimeline({
|
|
|
15441
15463
|
]
|
|
15442
15464
|
}
|
|
15443
15465
|
);
|
|
15444
|
-
if (!enableEventTooltips) return /* @__PURE__ */ jsx45(
|
|
15466
|
+
if (!enableEventTooltips) return /* @__PURE__ */ jsx45(React40.Fragment, { children: block }, ev.id);
|
|
15445
15467
|
const tooltipContent = /* @__PURE__ */ jsxs34("div", { className: "flex flex-col gap-0.5", children: [
|
|
15446
15468
|
/* @__PURE__ */ jsx45("div", { className: "font-semibold", children: tooltipTitle }),
|
|
15447
15469
|
/* @__PURE__ */ jsx45("div", { className: "text-xs opacity-80", children: timeText }),
|
|
@@ -15598,7 +15620,7 @@ function CalendarTimeline({
|
|
|
15598
15620
|
}
|
|
15599
15621
|
|
|
15600
15622
|
// src/components/MultiCombobox.tsx
|
|
15601
|
-
import * as
|
|
15623
|
+
import * as React41 from "react";
|
|
15602
15624
|
import { useId as useId9 } from "react";
|
|
15603
15625
|
import { useVirtualizer as useVirtualizer2 } from "@tanstack/react-virtual";
|
|
15604
15626
|
import { ChevronDown as ChevronDown4, Search as Search5, Check as Check6, SearchX as SearchX2, Loader2 as Loader23, X as X13, Sparkles as Sparkles2 } from "lucide-react";
|
|
@@ -15666,17 +15688,17 @@ var MultiCombobox = ({
|
|
|
15666
15688
|
const searchPlaceholder = searchPlaceholderProp ?? gi18n.searchPlaceholder ?? "Search...";
|
|
15667
15689
|
const loadingText = loadingTextProp ?? gi18n.loading ?? "Loading...";
|
|
15668
15690
|
const emptyText = emptyTextProp ?? gi18n.noResults ?? "No results found";
|
|
15669
|
-
const [query, setQuery] =
|
|
15670
|
-
const [open, setOpen] =
|
|
15671
|
-
const [activeIndex, setActiveIndex] =
|
|
15672
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
15673
|
-
const inputRef =
|
|
15674
|
-
const listRef =
|
|
15675
|
-
const optionsListRef =
|
|
15691
|
+
const [query, setQuery] = React41.useState("");
|
|
15692
|
+
const [open, setOpen] = React41.useState(false);
|
|
15693
|
+
const [activeIndex, setActiveIndex] = React41.useState(null);
|
|
15694
|
+
const [localRequiredError, setLocalRequiredError] = React41.useState();
|
|
15695
|
+
const inputRef = React41.useRef(null);
|
|
15696
|
+
const listRef = React41.useRef([]);
|
|
15697
|
+
const optionsListRef = React41.useRef(null);
|
|
15676
15698
|
useOverlayScrollbarTarget(optionsListRef, { enabled: open && useOverlayScrollbar && !virtualized });
|
|
15677
|
-
const triggerRef =
|
|
15699
|
+
const triggerRef = React41.useRef(null);
|
|
15678
15700
|
useShadCNAnimations();
|
|
15679
|
-
const normalizedOptions =
|
|
15701
|
+
const normalizedOptions = React41.useMemo(
|
|
15680
15702
|
() => options.map(
|
|
15681
15703
|
(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 }
|
|
15682
15704
|
),
|
|
@@ -15686,7 +15708,7 @@ var MultiCombobox = ({
|
|
|
15686
15708
|
const trimmedQuery = query.trim();
|
|
15687
15709
|
const queryMeetsMinimum = trimmedQuery.length >= minSearchLength;
|
|
15688
15710
|
const shouldPromptForSearch = minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
15689
|
-
const filtered =
|
|
15711
|
+
const filtered = React41.useMemo(() => {
|
|
15690
15712
|
if (shouldPromptForSearch) return [];
|
|
15691
15713
|
if (!enableSearch || searchMode === "manual") return normalizedOptions;
|
|
15692
15714
|
const normalizedQuery = trimmedQuery.toLowerCase();
|
|
@@ -15695,7 +15717,7 @@ var MultiCombobox = ({
|
|
|
15695
15717
|
(opt) => opt.label.toLowerCase().includes(normalizedQuery) || opt.description?.toLowerCase().includes(normalizedQuery)
|
|
15696
15718
|
);
|
|
15697
15719
|
}, [enableSearch, normalizedOptions, searchMode, shouldPromptForSearch, trimmedQuery]);
|
|
15698
|
-
const renderLimitedOptions =
|
|
15720
|
+
const renderLimitedOptions = React41.useMemo(() => {
|
|
15699
15721
|
if (trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
15700
15722
|
return filtered;
|
|
15701
15723
|
}
|
|
@@ -15711,14 +15733,14 @@ var MultiCombobox = ({
|
|
|
15711
15733
|
enabled: canVirtualize
|
|
15712
15734
|
});
|
|
15713
15735
|
const virtualItems = canVirtualize ? optionVirtualizer.getVirtualItems() : [];
|
|
15714
|
-
const scrollVirtualListToIndex =
|
|
15736
|
+
const scrollVirtualListToIndex = React41.useCallback((index) => {
|
|
15715
15737
|
if (!canVirtualize || renderLimitedOptions.length === 0) return;
|
|
15716
15738
|
optionVirtualizer.scrollToIndex(index, { align: "auto" });
|
|
15717
15739
|
}, [canVirtualize, optionVirtualizer, renderLimitedOptions.length]);
|
|
15718
|
-
const scrollVirtualListToStart =
|
|
15740
|
+
const scrollVirtualListToStart = React41.useCallback(() => {
|
|
15719
15741
|
scrollVirtualListToIndex(0);
|
|
15720
15742
|
}, [scrollVirtualListToIndex]);
|
|
15721
|
-
const groupedOptions =
|
|
15743
|
+
const groupedOptions = React41.useMemo(() => {
|
|
15722
15744
|
if (!groupBy) return null;
|
|
15723
15745
|
const groups = /* @__PURE__ */ new Map();
|
|
15724
15746
|
renderLimitedOptions.forEach((opt) => {
|
|
@@ -15771,12 +15793,12 @@ var MultiCombobox = ({
|
|
|
15771
15793
|
onChange([]);
|
|
15772
15794
|
};
|
|
15773
15795
|
const effectiveError = error ?? localRequiredError;
|
|
15774
|
-
|
|
15796
|
+
React41.useEffect(() => {
|
|
15775
15797
|
if (disabled || !required || value.length > 0) {
|
|
15776
15798
|
setLocalRequiredError(void 0);
|
|
15777
15799
|
}
|
|
15778
15800
|
}, [disabled, required, value.length]);
|
|
15779
|
-
|
|
15801
|
+
React41.useEffect(() => {
|
|
15780
15802
|
if (open && enableSearch) {
|
|
15781
15803
|
setTimeout(() => {
|
|
15782
15804
|
inputRef.current?.focus();
|
|
@@ -15787,12 +15809,12 @@ var MultiCombobox = ({
|
|
|
15787
15809
|
scrollVirtualListToStart();
|
|
15788
15810
|
}
|
|
15789
15811
|
}, [enableSearch, open, scrollVirtualListToStart]);
|
|
15790
|
-
|
|
15812
|
+
React41.useEffect(() => {
|
|
15791
15813
|
if (!onSearchChange) return void 0;
|
|
15792
15814
|
const timeoutId = window.setTimeout(() => onSearchChange(query), searchDebounceMs);
|
|
15793
15815
|
return () => window.clearTimeout(timeoutId);
|
|
15794
15816
|
}, [onSearchChange, query, searchDebounceMs]);
|
|
15795
|
-
|
|
15817
|
+
React41.useEffect(() => {
|
|
15796
15818
|
if (process.env.NODE_ENV !== "production" && normalizedOptions.length > 300 && !virtualized && searchMode !== "manual" && maxInitialOptions === void 0) {
|
|
15797
15819
|
console.warn(
|
|
15798
15820
|
'[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.'
|
|
@@ -16031,7 +16053,7 @@ var MultiCombobox = ({
|
|
|
16031
16053
|
}
|
|
16032
16054
|
)
|
|
16033
16055
|
] });
|
|
16034
|
-
const selectedOptionFallbackMap =
|
|
16056
|
+
const selectedOptionFallbackMap = React41.useMemo(
|
|
16035
16057
|
() => new Map((selectedOptionsProp ?? []).map((option) => [option.value, option])),
|
|
16036
16058
|
[selectedOptionsProp]
|
|
16037
16059
|
);
|
|
@@ -16065,7 +16087,7 @@ var MultiCombobox = ({
|
|
|
16065
16087
|
/* @__PURE__ */ jsx46("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__ */ jsxs35(Fragment14, { children: [
|
|
16066
16088
|
visibleTags.map((option) => {
|
|
16067
16089
|
if (renderTag) {
|
|
16068
|
-
return /* @__PURE__ */ jsx46(
|
|
16090
|
+
return /* @__PURE__ */ jsx46(React41.Fragment, { children: renderTag(option, () => handleRemove(option.value)) }, option.value);
|
|
16069
16091
|
}
|
|
16070
16092
|
return /* @__PURE__ */ jsxs35(
|
|
16071
16093
|
"span",
|
|
@@ -16227,17 +16249,17 @@ var MultiCombobox = ({
|
|
|
16227
16249
|
};
|
|
16228
16250
|
|
|
16229
16251
|
// src/components/RadioGroup.tsx
|
|
16230
|
-
import * as
|
|
16252
|
+
import * as React42 from "react";
|
|
16231
16253
|
import { jsx as jsx47, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
16232
|
-
var RadioGroupContext =
|
|
16254
|
+
var RadioGroupContext = React42.createContext(void 0);
|
|
16233
16255
|
var useRadioGroup = () => {
|
|
16234
|
-
const context =
|
|
16256
|
+
const context = React42.useContext(RadioGroupContext);
|
|
16235
16257
|
if (!context) {
|
|
16236
16258
|
throw new Error("RadioGroupItem must be used within a RadioGroup");
|
|
16237
16259
|
}
|
|
16238
16260
|
return context;
|
|
16239
16261
|
};
|
|
16240
|
-
var RadioGroup =
|
|
16262
|
+
var RadioGroup = React42.forwardRef(
|
|
16241
16263
|
({
|
|
16242
16264
|
value,
|
|
16243
16265
|
defaultValue,
|
|
@@ -16253,7 +16275,7 @@ var RadioGroup = React41.forwardRef(
|
|
|
16253
16275
|
error = false,
|
|
16254
16276
|
errorMessage
|
|
16255
16277
|
}, ref) => {
|
|
16256
|
-
const [internalValue, setInternalValue] =
|
|
16278
|
+
const [internalValue, setInternalValue] = React42.useState(defaultValue || "");
|
|
16257
16279
|
const isControlled = value !== void 0;
|
|
16258
16280
|
const currentValue = isControlled ? value : internalValue;
|
|
16259
16281
|
const handleValueChange = (newValue) => {
|
|
@@ -16264,7 +16286,7 @@ var RadioGroup = React41.forwardRef(
|
|
|
16264
16286
|
onValueChange?.(newValue);
|
|
16265
16287
|
}
|
|
16266
16288
|
};
|
|
16267
|
-
const uniqueId =
|
|
16289
|
+
const uniqueId = React42.useId();
|
|
16268
16290
|
const radioName = name || `radio-group-${uniqueId}`;
|
|
16269
16291
|
return /* @__PURE__ */ jsx47(
|
|
16270
16292
|
RadioGroupContext.Provider,
|
|
@@ -16322,7 +16344,7 @@ var sizeStyles7 = {
|
|
|
16322
16344
|
padding: "p-4"
|
|
16323
16345
|
}
|
|
16324
16346
|
};
|
|
16325
|
-
var RadioGroupItem =
|
|
16347
|
+
var RadioGroupItem = React42.forwardRef(
|
|
16326
16348
|
({ value, id, disabled, className, children, label, labelClassName, description, icon }, ref) => {
|
|
16327
16349
|
const { value: selectedValue, onValueChange, name, disabled: groupDisabled, size = "md", variant = "default" } = useRadioGroup();
|
|
16328
16350
|
const isDisabled = disabled || groupDisabled;
|
|
@@ -16500,7 +16522,7 @@ var RadioGroupItem = React41.forwardRef(
|
|
|
16500
16522
|
RadioGroupItem.displayName = "RadioGroupItem";
|
|
16501
16523
|
|
|
16502
16524
|
// src/components/Slider.tsx
|
|
16503
|
-
import * as
|
|
16525
|
+
import * as React43 from "react";
|
|
16504
16526
|
import { Fragment as Fragment15, jsx as jsx48, jsxs as jsxs37 } from "react/jsx-runtime";
|
|
16505
16527
|
var SIZE_STYLES = {
|
|
16506
16528
|
sm: {
|
|
@@ -16553,7 +16575,7 @@ function SliderTooltip({
|
|
|
16553
16575
|
}
|
|
16554
16576
|
);
|
|
16555
16577
|
}
|
|
16556
|
-
var Slider =
|
|
16578
|
+
var Slider = React43.forwardRef(
|
|
16557
16579
|
({
|
|
16558
16580
|
className,
|
|
16559
16581
|
mode = "single",
|
|
@@ -16589,28 +16611,28 @@ var Slider = React42.forwardRef(
|
|
|
16589
16611
|
}, ref) => {
|
|
16590
16612
|
const gi18n = useGlobalI18n();
|
|
16591
16613
|
const isRange = mode === "range";
|
|
16592
|
-
const trackRef =
|
|
16593
|
-
const [internalValue, setInternalValue] =
|
|
16594
|
-
const [internalRange, setInternalRange] =
|
|
16614
|
+
const trackRef = React43.useRef(null);
|
|
16615
|
+
const [internalValue, setInternalValue] = React43.useState(defaultValue);
|
|
16616
|
+
const [internalRange, setInternalRange] = React43.useState(() => {
|
|
16595
16617
|
if (defaultRangeValue) return defaultRangeValue;
|
|
16596
16618
|
const v = clamp6(defaultValue, min, max);
|
|
16597
16619
|
return [min, v];
|
|
16598
16620
|
});
|
|
16599
|
-
const [activeThumb, setActiveThumb] =
|
|
16600
|
-
const dragRef =
|
|
16601
|
-
const [isHovering, setIsHovering] =
|
|
16602
|
-
const [isDragging, setIsDragging] =
|
|
16621
|
+
const [activeThumb, setActiveThumb] = React43.useState(null);
|
|
16622
|
+
const dragRef = React43.useRef(null);
|
|
16623
|
+
const [isHovering, setIsHovering] = React43.useState(false);
|
|
16624
|
+
const [isDragging, setIsDragging] = React43.useState(false);
|
|
16603
16625
|
const isControlled = value !== void 0;
|
|
16604
16626
|
const currentValue = isControlled ? value : internalValue;
|
|
16605
16627
|
const isRangeControlled = rangeValue !== void 0;
|
|
16606
16628
|
const currentRange = isRangeControlled ? rangeValue : internalRange;
|
|
16607
16629
|
const rangeMin = clamp6(currentRange[0] ?? min, min, max);
|
|
16608
16630
|
const rangeMax = clamp6(currentRange[1] ?? max, min, max);
|
|
16609
|
-
const normalizedRange =
|
|
16631
|
+
const normalizedRange = React43.useMemo(
|
|
16610
16632
|
() => rangeMin <= rangeMax ? [rangeMin, rangeMax] : [rangeMax, rangeMin],
|
|
16611
16633
|
[rangeMax, rangeMin]
|
|
16612
16634
|
);
|
|
16613
|
-
const handleSingleChange =
|
|
16635
|
+
const handleSingleChange = React43.useCallback(
|
|
16614
16636
|
(e) => {
|
|
16615
16637
|
const newValue = Number(e.target.value);
|
|
16616
16638
|
if (!isControlled) {
|
|
@@ -16621,14 +16643,14 @@ var Slider = React42.forwardRef(
|
|
|
16621
16643
|
},
|
|
16622
16644
|
[isControlled, onChange, onValueChange]
|
|
16623
16645
|
);
|
|
16624
|
-
const emitRange =
|
|
16646
|
+
const emitRange = React43.useCallback(
|
|
16625
16647
|
(next) => {
|
|
16626
16648
|
onRangeChange?.(next);
|
|
16627
16649
|
onRangeValueChange?.(next);
|
|
16628
16650
|
},
|
|
16629
16651
|
[onRangeChange, onRangeValueChange]
|
|
16630
16652
|
);
|
|
16631
|
-
const handleRangeChange =
|
|
16653
|
+
const handleRangeChange = React43.useCallback(
|
|
16632
16654
|
(thumb) => (e) => {
|
|
16633
16655
|
const nextVal = Number(e.target.value);
|
|
16634
16656
|
const [curMin, curMax] = normalizedRange;
|
|
@@ -16644,7 +16666,7 @@ var Slider = React42.forwardRef(
|
|
|
16644
16666
|
const rangeEndPct = (normalizedRange[1] - min) / denom * 100;
|
|
16645
16667
|
const sizeStyles8 = SIZE_STYLES[size];
|
|
16646
16668
|
const tooltipVisible = showTooltip && !disabled && (isHovering || isDragging);
|
|
16647
|
-
const displayValue =
|
|
16669
|
+
const displayValue = React43.useMemo(() => {
|
|
16648
16670
|
if (isRange) {
|
|
16649
16671
|
const a = formatValue ? formatValue(normalizedRange[0]) : normalizedRange[0].toString();
|
|
16650
16672
|
const b = formatValue ? formatValue(normalizedRange[1]) : normalizedRange[1].toString();
|
|
@@ -16652,7 +16674,7 @@ var Slider = React42.forwardRef(
|
|
|
16652
16674
|
}
|
|
16653
16675
|
return formatValue ? formatValue(currentValue) : currentValue.toString();
|
|
16654
16676
|
}, [currentValue, formatValue, isRange, normalizedRange]);
|
|
16655
|
-
const quantize =
|
|
16677
|
+
const quantize = React43.useCallback(
|
|
16656
16678
|
(v) => {
|
|
16657
16679
|
const stepped = Math.round((v - min) / step) * step + min;
|
|
16658
16680
|
const fixed = Number(stepped.toFixed(10));
|
|
@@ -16660,7 +16682,7 @@ var Slider = React42.forwardRef(
|
|
|
16660
16682
|
},
|
|
16661
16683
|
[max, min, step]
|
|
16662
16684
|
);
|
|
16663
|
-
const valueFromClientX =
|
|
16685
|
+
const valueFromClientX = React43.useCallback(
|
|
16664
16686
|
(clientX) => {
|
|
16665
16687
|
const el = trackRef.current;
|
|
16666
16688
|
if (!el) return min;
|
|
@@ -16917,7 +16939,7 @@ Slider.displayName = "Slider";
|
|
|
16917
16939
|
|
|
16918
16940
|
// src/components/OverlayControls.tsx
|
|
16919
16941
|
import { Dot as Dot2, Maximize2, Pause, Play, RotateCcw, RotateCw, Volume2, VolumeX } from "lucide-react";
|
|
16920
|
-
import
|
|
16942
|
+
import React44 from "react";
|
|
16921
16943
|
import { Fragment as Fragment16, jsx as jsx49, jsxs as jsxs38 } from "react/jsx-runtime";
|
|
16922
16944
|
function resolveKeyboardEventElement(target) {
|
|
16923
16945
|
if (target instanceof Element) return target;
|
|
@@ -16967,24 +16989,24 @@ function OverlayControls({
|
|
|
16967
16989
|
}) {
|
|
16968
16990
|
const hoverClasses = showOnHover ? "opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto" : "opacity-100 pointer-events-auto";
|
|
16969
16991
|
const showControlsBar = mode === "review";
|
|
16970
|
-
const [rateOpen, setRateOpen] =
|
|
16971
|
-
const rateWrapRef =
|
|
16972
|
-
const [controlsVisible, setControlsVisible] =
|
|
16973
|
-
const hideTimerRef =
|
|
16974
|
-
const [previewData, setPreviewData] =
|
|
16975
|
-
const sliderRef =
|
|
16976
|
-
const [isDragging, setIsDragging] =
|
|
16977
|
-
const [dragValue, setDragValue] =
|
|
16978
|
-
|
|
16992
|
+
const [rateOpen, setRateOpen] = React44.useState(false);
|
|
16993
|
+
const rateWrapRef = React44.useRef(null);
|
|
16994
|
+
const [controlsVisible, setControlsVisible] = React44.useState(true);
|
|
16995
|
+
const hideTimerRef = React44.useRef(null);
|
|
16996
|
+
const [previewData, setPreviewData] = React44.useState(null);
|
|
16997
|
+
const sliderRef = React44.useRef(null);
|
|
16998
|
+
const [isDragging, setIsDragging] = React44.useState(false);
|
|
16999
|
+
const [dragValue, setDragValue] = React44.useState(value);
|
|
17000
|
+
React44.useEffect(() => {
|
|
16979
17001
|
if (!isDragging) {
|
|
16980
17002
|
setDragValue(value);
|
|
16981
17003
|
}
|
|
16982
17004
|
}, [value, isDragging]);
|
|
16983
|
-
const [keyboardFeedback, setKeyboardFeedback] =
|
|
16984
|
-
const feedbackTimerRef =
|
|
16985
|
-
const seekAccumulatorRef =
|
|
16986
|
-
const seekAccumulatorTimerRef =
|
|
16987
|
-
|
|
17005
|
+
const [keyboardFeedback, setKeyboardFeedback] = React44.useState(null);
|
|
17006
|
+
const feedbackTimerRef = React44.useRef(null);
|
|
17007
|
+
const seekAccumulatorRef = React44.useRef(0);
|
|
17008
|
+
const seekAccumulatorTimerRef = React44.useRef(null);
|
|
17009
|
+
React44.useEffect(() => {
|
|
16988
17010
|
const onDocDown = (e) => {
|
|
16989
17011
|
if (!rateOpen) return;
|
|
16990
17012
|
const wrap = rateWrapRef.current;
|
|
@@ -16995,7 +17017,7 @@ function OverlayControls({
|
|
|
16995
17017
|
document.addEventListener("mousedown", onDocDown);
|
|
16996
17018
|
return () => document.removeEventListener("mousedown", onDocDown);
|
|
16997
17019
|
}, [rateOpen]);
|
|
16998
|
-
|
|
17020
|
+
React44.useEffect(() => {
|
|
16999
17021
|
if (!autoHide || showOnHover) return;
|
|
17000
17022
|
const resetTimer = () => {
|
|
17001
17023
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
@@ -17018,14 +17040,14 @@ function OverlayControls({
|
|
|
17018
17040
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
17019
17041
|
};
|
|
17020
17042
|
}, [autoHide, autoHideDelay, showOnHover]);
|
|
17021
|
-
const showFeedback =
|
|
17043
|
+
const showFeedback = React44.useCallback((type, value2) => {
|
|
17022
17044
|
if (feedbackTimerRef.current) clearTimeout(feedbackTimerRef.current);
|
|
17023
17045
|
setKeyboardFeedback({ type, value: value2 });
|
|
17024
17046
|
feedbackTimerRef.current = setTimeout(() => {
|
|
17025
17047
|
setKeyboardFeedback(null);
|
|
17026
17048
|
}, 800);
|
|
17027
17049
|
}, []);
|
|
17028
|
-
const accumulateSeek =
|
|
17050
|
+
const accumulateSeek = React44.useCallback((seconds) => {
|
|
17029
17051
|
if (seekAccumulatorTimerRef.current) clearTimeout(seekAccumulatorTimerRef.current);
|
|
17030
17052
|
seekAccumulatorRef.current += seconds;
|
|
17031
17053
|
showFeedback("seek", seekAccumulatorRef.current);
|
|
@@ -17033,7 +17055,7 @@ function OverlayControls({
|
|
|
17033
17055
|
seekAccumulatorRef.current = 0;
|
|
17034
17056
|
}, 1e3);
|
|
17035
17057
|
}, [showFeedback]);
|
|
17036
|
-
|
|
17058
|
+
React44.useEffect(() => {
|
|
17037
17059
|
if (!enableKeyboardShortcuts) return;
|
|
17038
17060
|
const handleKeyDown2 = (e) => {
|
|
17039
17061
|
if (isEditableKeyboardTarget(e.target)) return;
|
|
@@ -19012,7 +19034,7 @@ function FileUpload({
|
|
|
19012
19034
|
}
|
|
19013
19035
|
|
|
19014
19036
|
// src/components/Carousel.tsx
|
|
19015
|
-
import * as
|
|
19037
|
+
import * as React46 from "react";
|
|
19016
19038
|
import { ChevronLeft as ChevronLeft5, ChevronRight as ChevronRight7 } from "lucide-react";
|
|
19017
19039
|
import { Fragment as Fragment18, jsx as jsx53, jsxs as jsxs42 } from "react/jsx-runtime";
|
|
19018
19040
|
function Carousel({
|
|
@@ -19038,16 +19060,16 @@ function Carousel({
|
|
|
19038
19060
|
effectOptions
|
|
19039
19061
|
}) {
|
|
19040
19062
|
const gi18n = useGlobalI18n();
|
|
19041
|
-
const [currentIndex, setCurrentIndex] =
|
|
19042
|
-
const [isPaused, setIsPaused] =
|
|
19043
|
-
const progressElRef =
|
|
19044
|
-
const carouselRef =
|
|
19045
|
-
const rafRef =
|
|
19046
|
-
const isDraggingRef =
|
|
19047
|
-
const dragDistanceRef =
|
|
19048
|
-
const startPosRef =
|
|
19049
|
-
const lastDragPositionRef =
|
|
19050
|
-
const slides =
|
|
19063
|
+
const [currentIndex, setCurrentIndex] = React46.useState(0);
|
|
19064
|
+
const [isPaused, setIsPaused] = React46.useState(false);
|
|
19065
|
+
const progressElRef = React46.useRef(null);
|
|
19066
|
+
const carouselRef = React46.useRef(null);
|
|
19067
|
+
const rafRef = React46.useRef(null);
|
|
19068
|
+
const isDraggingRef = React46.useRef(false);
|
|
19069
|
+
const dragDistanceRef = React46.useRef(0);
|
|
19070
|
+
const startPosRef = React46.useRef(0);
|
|
19071
|
+
const lastDragPositionRef = React46.useRef(0);
|
|
19072
|
+
const slides = React46.useMemo(() => React46.Children.toArray(children), [children]);
|
|
19051
19073
|
const totalSlides = slides.length;
|
|
19052
19074
|
const isHorizontal = orientation === "horizontal";
|
|
19053
19075
|
const effectiveAnimation = slidesToShow > 1 && !["slide", "coverflow", "stack"].includes(animation) ? "slide" : animation;
|
|
@@ -19055,7 +19077,7 @@ function Carousel({
|
|
|
19055
19077
|
const effectiveSlidesToShow = isDeckAnimation ? 1 : slidesToShow;
|
|
19056
19078
|
const maxIndex = Math.max(0, totalSlides - effectiveSlidesToShow);
|
|
19057
19079
|
const shouldShowArrows = showArrows && isHorizontal;
|
|
19058
|
-
const presetEffectOptions =
|
|
19080
|
+
const presetEffectOptions = React46.useMemo(() => {
|
|
19059
19081
|
if (effectPreset === "cinematic") {
|
|
19060
19082
|
return effectiveAnimation === "stack" ? {
|
|
19061
19083
|
mainScale: 1.08,
|
|
@@ -19150,7 +19172,7 @@ function Carousel({
|
|
|
19150
19172
|
}
|
|
19151
19173
|
return {};
|
|
19152
19174
|
}, [effectPreset, effectiveAnimation]);
|
|
19153
|
-
const mergedEffectOptions =
|
|
19175
|
+
const mergedEffectOptions = React46.useMemo(
|
|
19154
19176
|
() => ({
|
|
19155
19177
|
mainScale: 1.04,
|
|
19156
19178
|
sideScale: effectiveAnimation === "stack" ? 0.93 : 0.88,
|
|
@@ -19169,7 +19191,7 @@ function Carousel({
|
|
|
19169
19191
|
}),
|
|
19170
19192
|
[effectOptions, effectiveAnimation, presetEffectOptions]
|
|
19171
19193
|
);
|
|
19172
|
-
const scrollPrev =
|
|
19194
|
+
const scrollPrev = React46.useCallback(() => {
|
|
19173
19195
|
setCurrentIndex((prev) => {
|
|
19174
19196
|
if (prev === 0) {
|
|
19175
19197
|
return loop ? maxIndex : 0;
|
|
@@ -19177,7 +19199,7 @@ function Carousel({
|
|
|
19177
19199
|
return Math.max(0, prev - slidesToScroll);
|
|
19178
19200
|
});
|
|
19179
19201
|
}, [loop, maxIndex, slidesToScroll]);
|
|
19180
|
-
const scrollNext =
|
|
19202
|
+
const scrollNext = React46.useCallback(() => {
|
|
19181
19203
|
setCurrentIndex((prev) => {
|
|
19182
19204
|
if (prev >= maxIndex) {
|
|
19183
19205
|
return loop ? 0 : maxIndex;
|
|
@@ -19185,13 +19207,13 @@ function Carousel({
|
|
|
19185
19207
|
return Math.min(maxIndex, prev + slidesToScroll);
|
|
19186
19208
|
});
|
|
19187
19209
|
}, [loop, maxIndex, slidesToScroll]);
|
|
19188
|
-
const scrollTo =
|
|
19210
|
+
const scrollTo = React46.useCallback(
|
|
19189
19211
|
(index) => {
|
|
19190
19212
|
setCurrentIndex(Math.min(maxIndex, Math.max(0, index)));
|
|
19191
19213
|
},
|
|
19192
19214
|
[maxIndex]
|
|
19193
19215
|
);
|
|
19194
|
-
const handleKeyDown2 =
|
|
19216
|
+
const handleKeyDown2 = React46.useCallback(
|
|
19195
19217
|
(e) => {
|
|
19196
19218
|
if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
|
|
19197
19219
|
e.preventDefault();
|
|
@@ -19209,7 +19231,7 @@ function Carousel({
|
|
|
19209
19231
|
},
|
|
19210
19232
|
[scrollPrev, scrollNext, scrollTo, maxIndex]
|
|
19211
19233
|
);
|
|
19212
|
-
|
|
19234
|
+
React46.useEffect(() => {
|
|
19213
19235
|
const stop = () => {
|
|
19214
19236
|
if (rafRef.current != null) {
|
|
19215
19237
|
cancelAnimationFrame(rafRef.current);
|
|
@@ -19269,7 +19291,7 @@ function Carousel({
|
|
|
19269
19291
|
startPosRef.current = 0;
|
|
19270
19292
|
lastDragPositionRef.current = 0;
|
|
19271
19293
|
};
|
|
19272
|
-
const handleDeckAreaClick =
|
|
19294
|
+
const handleDeckAreaClick = React46.useCallback((event) => {
|
|
19273
19295
|
if (!isDeckAnimation || dragDistanceRef.current > 8) {
|
|
19274
19296
|
dragDistanceRef.current = 0;
|
|
19275
19297
|
return;
|
|
@@ -19286,7 +19308,7 @@ function Carousel({
|
|
|
19286
19308
|
scrollNext();
|
|
19287
19309
|
}
|
|
19288
19310
|
}, [isDeckAnimation, scrollNext, scrollPrev]);
|
|
19289
|
-
|
|
19311
|
+
React46.useEffect(() => {
|
|
19290
19312
|
onSlideChange?.(currentIndex);
|
|
19291
19313
|
}, [currentIndex, onSlideChange]);
|
|
19292
19314
|
const getAnimationStyles2 = () => {
|
|
@@ -19300,7 +19322,7 @@ function Carousel({
|
|
|
19300
19322
|
};
|
|
19301
19323
|
};
|
|
19302
19324
|
const slideWidth = 100 / effectiveSlidesToShow;
|
|
19303
|
-
const getLoopDistance =
|
|
19325
|
+
const getLoopDistance = React46.useCallback(
|
|
19304
19326
|
(index) => {
|
|
19305
19327
|
if (totalSlides <= 0) return 0;
|
|
19306
19328
|
const forward = index - currentIndex;
|
|
@@ -19312,7 +19334,7 @@ function Carousel({
|
|
|
19312
19334
|
},
|
|
19313
19335
|
[currentIndex, loop, totalSlides]
|
|
19314
19336
|
);
|
|
19315
|
-
const getDeckSlideStyles =
|
|
19337
|
+
const getDeckSlideStyles = React46.useCallback(
|
|
19316
19338
|
(index) => {
|
|
19317
19339
|
const distance = getLoopDistance(index);
|
|
19318
19340
|
const absDistance = Math.abs(distance);
|
|
@@ -19392,7 +19414,7 @@ function Carousel({
|
|
|
19392
19414
|
"aria-atomic": "false",
|
|
19393
19415
|
"aria-live": autoScroll ? "off" : "polite",
|
|
19394
19416
|
children: slides.map((child, idx) => {
|
|
19395
|
-
const key =
|
|
19417
|
+
const key = React46.isValidElement(child) && child.key || idx;
|
|
19396
19418
|
const ariaHidden = effectiveAnimation === "slide" ? idx < currentIndex || idx >= currentIndex + slidesToShow : idx !== currentIndex;
|
|
19397
19419
|
if (isDeckAnimation) {
|
|
19398
19420
|
return /* @__PURE__ */ jsx53(
|
|
@@ -19515,7 +19537,7 @@ function Carousel({
|
|
|
19515
19537
|
"max-md:gap-1.5 max-md:p-2",
|
|
19516
19538
|
isHorizontal ? "flex-row" : "flex-col"
|
|
19517
19539
|
),
|
|
19518
|
-
children:
|
|
19540
|
+
children: React46.Children.map(children, (child, idx) => /* @__PURE__ */ jsx53(
|
|
19519
19541
|
"button",
|
|
19520
19542
|
{
|
|
19521
19543
|
onClick: () => scrollTo(idx),
|
|
@@ -19537,7 +19559,7 @@ function Carousel({
|
|
|
19537
19559
|
}
|
|
19538
19560
|
|
|
19539
19561
|
// src/components/FallingIcons.tsx
|
|
19540
|
-
import
|
|
19562
|
+
import React47 from "react";
|
|
19541
19563
|
import { jsx as jsx54, jsxs as jsxs43 } from "react/jsx-runtime";
|
|
19542
19564
|
var DEFAULT_COUNT = 24;
|
|
19543
19565
|
var DEFAULT_SPEED_RANGE = [6, 14];
|
|
@@ -19565,10 +19587,10 @@ function FallingIcons({
|
|
|
19565
19587
|
physics,
|
|
19566
19588
|
easingFunction = "linear"
|
|
19567
19589
|
}) {
|
|
19568
|
-
const uid =
|
|
19569
|
-
const containerRef =
|
|
19570
|
-
const [fallDist, setFallDist] =
|
|
19571
|
-
const idRef =
|
|
19590
|
+
const uid = React47.useId().replace(/[:]/g, "");
|
|
19591
|
+
const containerRef = React47.useRef(null);
|
|
19592
|
+
const [fallDist, setFallDist] = React47.useState(null);
|
|
19593
|
+
const idRef = React47.useRef(1);
|
|
19572
19594
|
const gravity = physics?.gravity ?? 1;
|
|
19573
19595
|
const windDirection = physics?.windDirection ?? 0;
|
|
19574
19596
|
const windStrength = physics?.windStrength ?? 0;
|
|
@@ -19582,7 +19604,7 @@ function FallingIcons({
|
|
|
19582
19604
|
bounce: "cubic-bezier(0.68, -0.55, 0.265, 1.55)",
|
|
19583
19605
|
elastic: "cubic-bezier(0.175, 0.885, 0.32, 1.275)"
|
|
19584
19606
|
};
|
|
19585
|
-
const makeParticle =
|
|
19607
|
+
const makeParticle = React47.useCallback(() => {
|
|
19586
19608
|
const rnd = (min, max) => min + Math.random() * (max - min);
|
|
19587
19609
|
return {
|
|
19588
19610
|
leftPct: rnd(0, 100),
|
|
@@ -19596,12 +19618,12 @@ function FallingIcons({
|
|
|
19596
19618
|
key: idRef.current++
|
|
19597
19619
|
};
|
|
19598
19620
|
}, [sizeRange, speedRange, horizontalDrift, gravity, windDirection, windStrength]);
|
|
19599
|
-
const [particles, setParticles] =
|
|
19600
|
-
|
|
19621
|
+
const [particles, setParticles] = React47.useState([]);
|
|
19622
|
+
React47.useEffect(() => {
|
|
19601
19623
|
const arr = Array.from({ length: Math.max(0, count) }).map(() => makeParticle());
|
|
19602
19624
|
setParticles(arr);
|
|
19603
19625
|
}, [count, makeParticle]);
|
|
19604
|
-
|
|
19626
|
+
React47.useEffect(() => {
|
|
19605
19627
|
if (fullScreen) {
|
|
19606
19628
|
const measure2 = () => setFallDist(window.innerHeight + 200);
|
|
19607
19629
|
measure2();
|
|
@@ -19626,14 +19648,14 @@ function FallingIcons({
|
|
|
19626
19648
|
const SpinName = `uv-spin-${uid}`;
|
|
19627
19649
|
const PopName = `uv-pop-${uid}`;
|
|
19628
19650
|
const PhysicsSpinName = `uv-physics-spin-${uid}`;
|
|
19629
|
-
const glowStyles =
|
|
19651
|
+
const glowStyles = React47.useMemo(() => {
|
|
19630
19652
|
if (!glow) return {};
|
|
19631
19653
|
const intensity = Math.max(0, Math.min(1, glowIntensity));
|
|
19632
19654
|
return {
|
|
19633
19655
|
filter: `drop-shadow(0 0 ${4 * intensity}px ${glowColor}) drop-shadow(0 0 ${8 * intensity}px ${glowColor})`
|
|
19634
19656
|
};
|
|
19635
19657
|
}, [glow, glowColor, glowIntensity]);
|
|
19636
|
-
const FallbackIcon =
|
|
19658
|
+
const FallbackIcon = React47.useMemo(
|
|
19637
19659
|
() => function FallingIconsFallbackIcon(props) {
|
|
19638
19660
|
return /* @__PURE__ */ jsx54("svg", { viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", ...props, children: /* @__PURE__ */ jsx54("circle", { cx: "12", cy: "12", r: "10" }) });
|
|
19639
19661
|
},
|
|
@@ -19695,7 +19717,7 @@ function FallingIcons({
|
|
|
19695
19717
|
});
|
|
19696
19718
|
};
|
|
19697
19719
|
const trailParticles = trail ? Array.from({ length: Math.min(5, Math.max(1, trailLength)) }) : [];
|
|
19698
|
-
return /* @__PURE__ */ jsxs43(
|
|
19720
|
+
return /* @__PURE__ */ jsxs43(React47.Fragment, { children: [
|
|
19699
19721
|
trail && trailParticles.map((_, trailIndex) => {
|
|
19700
19722
|
const trailDelay = p.delay - (trailIndex + 1) * 0.15;
|
|
19701
19723
|
const trailOpacity = 1 - (trailIndex + 1) * (1 / (trailParticles.length + 1));
|
|
@@ -19813,7 +19835,7 @@ function FallingIcons({
|
|
|
19813
19835
|
}
|
|
19814
19836
|
|
|
19815
19837
|
// src/components/List.tsx
|
|
19816
|
-
import * as
|
|
19838
|
+
import * as React48 from "react";
|
|
19817
19839
|
import { ChevronRight as ChevronRight8 } from "lucide-react";
|
|
19818
19840
|
import { Fragment as Fragment19, jsx as jsx55, jsxs as jsxs44 } from "react/jsx-runtime";
|
|
19819
19841
|
var SIZE_STYLES2 = {
|
|
@@ -19839,7 +19861,7 @@ var ListItemSkeleton = ({ size }) => {
|
|
|
19839
19861
|
] })
|
|
19840
19862
|
] });
|
|
19841
19863
|
};
|
|
19842
|
-
var ListRoot =
|
|
19864
|
+
var ListRoot = React48.forwardRef(
|
|
19843
19865
|
({
|
|
19844
19866
|
as = "ul",
|
|
19845
19867
|
ordered,
|
|
@@ -19860,7 +19882,7 @@ var ListRoot = React47.forwardRef(
|
|
|
19860
19882
|
...rest
|
|
19861
19883
|
}, ref) => {
|
|
19862
19884
|
const Comp = ordered ? "ol" : as;
|
|
19863
|
-
const childCount =
|
|
19885
|
+
const childCount = React48.Children.count(children);
|
|
19864
19886
|
const hasChildren = childCount > 0;
|
|
19865
19887
|
const variantClasses3 = {
|
|
19866
19888
|
plain: "",
|
|
@@ -19914,14 +19936,14 @@ var ListRoot = React47.forwardRef(
|
|
|
19914
19936
|
className
|
|
19915
19937
|
),
|
|
19916
19938
|
...rest,
|
|
19917
|
-
children:
|
|
19918
|
-
if (!
|
|
19939
|
+
children: React48.Children.map(children, (child, idx) => {
|
|
19940
|
+
if (!React48.isValidElement(child)) return child;
|
|
19919
19941
|
const childClass = cn(
|
|
19920
19942
|
child.props?.className,
|
|
19921
19943
|
hoverable && variant !== "flush" && "hover:bg-accent/50 focus:bg-accent/60 focus:outline-none transition-colors",
|
|
19922
19944
|
variant === "flush" && "hover:bg-accent/30"
|
|
19923
19945
|
);
|
|
19924
|
-
return
|
|
19946
|
+
return React48.cloneElement(child, {
|
|
19925
19947
|
className: childClass,
|
|
19926
19948
|
// Pass global item class to contentClassName of ListItem
|
|
19927
19949
|
contentClassName: cn(itemClassName, child.props?.contentClassName),
|
|
@@ -19936,7 +19958,7 @@ var ListRoot = React47.forwardRef(
|
|
|
19936
19958
|
}
|
|
19937
19959
|
);
|
|
19938
19960
|
ListRoot.displayName = "List";
|
|
19939
|
-
var ListItem =
|
|
19961
|
+
var ListItem = React48.forwardRef(
|
|
19940
19962
|
({
|
|
19941
19963
|
as = "li",
|
|
19942
19964
|
selected = false,
|
|
@@ -19959,7 +19981,7 @@ var ListItem = React47.forwardRef(
|
|
|
19959
19981
|
children,
|
|
19960
19982
|
...rest
|
|
19961
19983
|
}, ref) => {
|
|
19962
|
-
const [internalExpanded, setInternalExpanded] =
|
|
19984
|
+
const [internalExpanded, setInternalExpanded] = React48.useState(false);
|
|
19963
19985
|
const isExpanded = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
|
|
19964
19986
|
const sizeAttr = rest["data-size"];
|
|
19965
19987
|
const resolvedSize = sizeAttr && ["xs", "sm", "md", "lg"].includes(sizeAttr) ? sizeAttr : "md";
|
|
@@ -20027,7 +20049,7 @@ var List = Object.assign(ListRoot, { Item: ListItem });
|
|
|
20027
20049
|
var List_default = List;
|
|
20028
20050
|
|
|
20029
20051
|
// src/components/Watermark.tsx
|
|
20030
|
-
import * as
|
|
20052
|
+
import * as React49 from "react";
|
|
20031
20053
|
import { createPortal as createPortal5 } from "react-dom";
|
|
20032
20054
|
import { Fragment as Fragment20, jsx as jsx56, jsxs as jsxs45 } from "react/jsx-runtime";
|
|
20033
20055
|
var PRESETS2 = {
|
|
@@ -20039,8 +20061,8 @@ var PRESETS2 = {
|
|
|
20039
20061
|
internal: { text: "INTERNAL USE ONLY", color: "rgba(156, 163, 175, 0.15)", rotate: -22, fontSize: 13, fontWeight: "600" }
|
|
20040
20062
|
};
|
|
20041
20063
|
function useWatermarkDataURL(opts) {
|
|
20042
|
-
const [url, setUrl] =
|
|
20043
|
-
|
|
20064
|
+
const [url, setUrl] = React49.useState(null);
|
|
20065
|
+
React49.useEffect(() => {
|
|
20044
20066
|
let cancelled = false;
|
|
20045
20067
|
const text = opts.text;
|
|
20046
20068
|
const image = opts.image;
|
|
@@ -20217,9 +20239,9 @@ var Watermark = ({
|
|
|
20217
20239
|
children,
|
|
20218
20240
|
...rest
|
|
20219
20241
|
}) => {
|
|
20220
|
-
const [visible, setVisible] =
|
|
20221
|
-
const [isDark, setIsDark] =
|
|
20222
|
-
|
|
20242
|
+
const [visible, setVisible] = React49.useState(true);
|
|
20243
|
+
const [isDark, setIsDark] = React49.useState(false);
|
|
20244
|
+
React49.useEffect(() => {
|
|
20223
20245
|
if (!darkMode) return;
|
|
20224
20246
|
const checkDarkMode = () => {
|
|
20225
20247
|
const isDarkMode = document.documentElement.classList.contains("dark") || window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
@@ -20321,7 +20343,7 @@ var Watermark = ({
|
|
|
20321
20343
|
var Watermark_default = Watermark;
|
|
20322
20344
|
|
|
20323
20345
|
// src/components/Timeline.tsx
|
|
20324
|
-
import * as
|
|
20346
|
+
import * as React50 from "react";
|
|
20325
20347
|
import { ChevronDown as ChevronDown6 } from "lucide-react";
|
|
20326
20348
|
import { jsx as jsx57, jsxs as jsxs46 } from "react/jsx-runtime";
|
|
20327
20349
|
var SIZE_STYLE = {
|
|
@@ -20374,7 +20396,7 @@ var STATUS_COLOR = {
|
|
|
20374
20396
|
error: "bg-destructive",
|
|
20375
20397
|
info: "bg-info"
|
|
20376
20398
|
};
|
|
20377
|
-
var TimelineContext =
|
|
20399
|
+
var TimelineContext = React50.createContext(null);
|
|
20378
20400
|
var LINE_STYLE_MAP = {
|
|
20379
20401
|
solid: "border-solid",
|
|
20380
20402
|
dashed: "border-dashed",
|
|
@@ -20402,7 +20424,7 @@ var Marker = ({ index, last, size, color, status = "default", lineColor, lineSty
|
|
|
20402
20424
|
!last && showLine && /* @__PURE__ */ jsx57("div", { className: cn("flex-1 border-l-2", LINE_STYLE_MAP[lineStyle]), style: { borderColor: lineColor || "hsl(var(--border))" } })
|
|
20403
20425
|
] });
|
|
20404
20426
|
};
|
|
20405
|
-
var TimelineRoot =
|
|
20427
|
+
var TimelineRoot = React50.forwardRef(
|
|
20406
20428
|
({
|
|
20407
20429
|
align = "left",
|
|
20408
20430
|
variant = "default",
|
|
@@ -20432,7 +20454,7 @@ var TimelineRoot = React49.forwardRef(
|
|
|
20432
20454
|
}
|
|
20433
20455
|
);
|
|
20434
20456
|
TimelineRoot.displayName = "Timeline";
|
|
20435
|
-
var TimelineItem =
|
|
20457
|
+
var TimelineItem = React50.forwardRef(
|
|
20436
20458
|
({
|
|
20437
20459
|
title,
|
|
20438
20460
|
description,
|
|
@@ -20451,11 +20473,11 @@ var TimelineItem = React49.forwardRef(
|
|
|
20451
20473
|
children,
|
|
20452
20474
|
...rest
|
|
20453
20475
|
}, ref) => {
|
|
20454
|
-
const ctx =
|
|
20476
|
+
const ctx = React50.useContext(TimelineContext);
|
|
20455
20477
|
const idx = rest["data-index"];
|
|
20456
20478
|
const isLast = Boolean(rest["data-last"]);
|
|
20457
20479
|
const sz = SIZE_STYLE[ctx.size];
|
|
20458
|
-
const [internalExpanded, setInternalExpanded] =
|
|
20480
|
+
const [internalExpanded, setInternalExpanded] = React50.useState(false);
|
|
20459
20481
|
const isExpanded = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
|
|
20460
20482
|
const toggleExpanded = () => {
|
|
20461
20483
|
const newExpanded = !isExpanded;
|
|
@@ -20597,7 +20619,7 @@ var Timeline = Object.assign(TimelineRoot, { Item: TimelineItem });
|
|
|
20597
20619
|
var Timeline_default = Timeline;
|
|
20598
20620
|
|
|
20599
20621
|
// src/components/ColorPicker.tsx
|
|
20600
|
-
import * as
|
|
20622
|
+
import * as React51 from "react";
|
|
20601
20623
|
import { Pipette, X as X16, Copy, Check as Check9, Palette, History } from "lucide-react";
|
|
20602
20624
|
import { jsx as jsx58, jsxs as jsxs47 } from "react/jsx-runtime";
|
|
20603
20625
|
var clamp7 = (n, min, max) => Math.max(min, Math.min(max, n));
|
|
@@ -20792,12 +20814,12 @@ function ColorPicker({
|
|
|
20792
20814
|
const gi18n = useGlobalI18n();
|
|
20793
20815
|
const isControlled = value !== void 0;
|
|
20794
20816
|
const initial = parseAnyColor(isControlled ? value : defaultValue) || { r: 79, g: 70, b: 229, a: 1 };
|
|
20795
|
-
const [rgba, setRgba] =
|
|
20796
|
-
const [open, setOpen] =
|
|
20797
|
-
const [text, setText] =
|
|
20798
|
-
const [copied, setCopied] =
|
|
20799
|
-
const [recentColors, setRecentColors] =
|
|
20800
|
-
|
|
20817
|
+
const [rgba, setRgba] = React51.useState(initial);
|
|
20818
|
+
const [open, setOpen] = React51.useState(false);
|
|
20819
|
+
const [text, setText] = React51.useState(() => formatOutput(initial, withAlpha, format));
|
|
20820
|
+
const [copied, setCopied] = React51.useState(false);
|
|
20821
|
+
const [recentColors, setRecentColors] = React51.useState([]);
|
|
20822
|
+
React51.useEffect(() => {
|
|
20801
20823
|
if (isControlled) {
|
|
20802
20824
|
const parsed = parseAnyColor(value);
|
|
20803
20825
|
if (parsed) {
|
|
@@ -21484,7 +21506,7 @@ var MusicPlayer = ({
|
|
|
21484
21506
|
var MusicPlayer_default = MusicPlayer;
|
|
21485
21507
|
|
|
21486
21508
|
// src/components/Grid.tsx
|
|
21487
|
-
import
|
|
21509
|
+
import React53, { useId as useId12 } from "react";
|
|
21488
21510
|
import { Fragment as Fragment21, jsx as jsx60, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
21489
21511
|
var BP_MIN = {
|
|
21490
21512
|
sm: 640,
|
|
@@ -21524,7 +21546,7 @@ function getVariantClasses(variant = "default", outlined) {
|
|
|
21524
21546
|
};
|
|
21525
21547
|
return variants[variant] || "";
|
|
21526
21548
|
}
|
|
21527
|
-
var GridRoot =
|
|
21549
|
+
var GridRoot = React53.forwardRef(
|
|
21528
21550
|
({
|
|
21529
21551
|
columns,
|
|
21530
21552
|
rows,
|
|
@@ -21608,7 +21630,7 @@ var GridRoot = React52.forwardRef(
|
|
|
21608
21630
|
}
|
|
21609
21631
|
);
|
|
21610
21632
|
GridRoot.displayName = "Grid";
|
|
21611
|
-
var GridItem =
|
|
21633
|
+
var GridItem = React53.forwardRef(
|
|
21612
21634
|
({
|
|
21613
21635
|
colSpan,
|
|
21614
21636
|
rowSpan,
|
|
@@ -21768,7 +21790,7 @@ var LoadingBar = ({
|
|
|
21768
21790
|
};
|
|
21769
21791
|
|
|
21770
21792
|
// src/components/Table.tsx
|
|
21771
|
-
import
|
|
21793
|
+
import React54 from "react";
|
|
21772
21794
|
import { jsx as jsx63, jsxs as jsxs51 } from "react/jsx-runtime";
|
|
21773
21795
|
var TABLE_BASE_CLASS = "w-full border-collapse caption-bottom text-sm";
|
|
21774
21796
|
var TABLE_CONTAINER_BASE_CLASS = [
|
|
@@ -21786,8 +21808,8 @@ function assignRef(ref, value) {
|
|
|
21786
21808
|
ref.current = value;
|
|
21787
21809
|
}
|
|
21788
21810
|
}
|
|
21789
|
-
var TableContainer =
|
|
21790
|
-
const containerRef =
|
|
21811
|
+
var TableContainer = React54.forwardRef(({ className, useOverlayScrollbar = false, ...props }, ref) => {
|
|
21812
|
+
const containerRef = React54.useRef(null);
|
|
21791
21813
|
useOverlayScrollbarTarget(containerRef, { enabled: useOverlayScrollbar });
|
|
21792
21814
|
return /* @__PURE__ */ jsx63(
|
|
21793
21815
|
"div",
|
|
@@ -21802,7 +21824,7 @@ var TableContainer = React53.forwardRef(({ className, useOverlayScrollbar = fals
|
|
|
21802
21824
|
);
|
|
21803
21825
|
});
|
|
21804
21826
|
TableContainer.displayName = "TableContainer";
|
|
21805
|
-
var Table =
|
|
21827
|
+
var Table = React54.forwardRef(
|
|
21806
21828
|
({ className, containerClassName, disableContainer = false, useOverlayScrollbar = false, ...props }, ref) => {
|
|
21807
21829
|
if (disableContainer) {
|
|
21808
21830
|
return /* @__PURE__ */ jsx63("table", { ref, className: cn(TABLE_BASE_CLASS, className), ...props });
|
|
@@ -21811,16 +21833,16 @@ var Table = React53.forwardRef(
|
|
|
21811
21833
|
}
|
|
21812
21834
|
);
|
|
21813
21835
|
Table.displayName = "Table";
|
|
21814
|
-
var TableHeader =
|
|
21836
|
+
var TableHeader = React54.forwardRef(({ className, children, filterRow, ...props }, ref) => /* @__PURE__ */ jsxs51("thead", { ref, className: cn("[&_tr]:border-b [&_tr]:border-border/50", "bg-muted", className), ...props, children: [
|
|
21815
21837
|
children,
|
|
21816
21838
|
filterRow
|
|
21817
21839
|
] }));
|
|
21818
21840
|
TableHeader.displayName = "TableHeader";
|
|
21819
|
-
var TableBody =
|
|
21841
|
+
var TableBody = React54.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63("tbody", { ref, className: cn("[&_tr:last-child]:border-0", className), ...props }));
|
|
21820
21842
|
TableBody.displayName = "TableBody";
|
|
21821
|
-
var TableFooter =
|
|
21843
|
+
var TableFooter = React54.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63("tfoot", { ref, className: cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className), ...props }));
|
|
21822
21844
|
TableFooter.displayName = "TableFooter";
|
|
21823
|
-
var TableRow =
|
|
21845
|
+
var TableRow = React54.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63(
|
|
21824
21846
|
"tr",
|
|
21825
21847
|
{
|
|
21826
21848
|
ref,
|
|
@@ -21834,7 +21856,7 @@ var TableRow = React53.forwardRef(({ className, ...props }, ref) => /* @__PURE__
|
|
|
21834
21856
|
}
|
|
21835
21857
|
));
|
|
21836
21858
|
TableRow.displayName = "TableRow";
|
|
21837
|
-
var TableHead =
|
|
21859
|
+
var TableHead = React54.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63(
|
|
21838
21860
|
"th",
|
|
21839
21861
|
{
|
|
21840
21862
|
ref,
|
|
@@ -21843,26 +21865,26 @@ var TableHead = React53.forwardRef(({ className, ...props }, ref) => /* @__PURE_
|
|
|
21843
21865
|
}
|
|
21844
21866
|
));
|
|
21845
21867
|
TableHead.displayName = "TableHead";
|
|
21846
|
-
var TableCell =
|
|
21868
|
+
var TableCell = React54.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63("td", { ref, className: cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className), ...props }));
|
|
21847
21869
|
TableCell.displayName = "TableCell";
|
|
21848
|
-
var TableCaption =
|
|
21870
|
+
var TableCaption = React54.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx63("caption", { ref, className: cn("mt-4 text-sm text-muted-foreground", className), ...props }));
|
|
21849
21871
|
TableCaption.displayName = "TableCaption";
|
|
21850
21872
|
|
|
21851
21873
|
// src/components/DataTable/DataTable.tsx
|
|
21852
21874
|
import { useVirtualizer as useVirtualizer4 } from "@tanstack/react-virtual";
|
|
21853
|
-
import
|
|
21875
|
+
import React64 from "react";
|
|
21854
21876
|
|
|
21855
21877
|
// src/components/DataTable/components/DataTableBody.tsx
|
|
21856
|
-
import
|
|
21878
|
+
import React55 from "react";
|
|
21857
21879
|
import { Fragment as Fragment23, jsx as jsx64, jsxs as jsxs52 } from "react/jsx-runtime";
|
|
21858
21880
|
function DataTableOverflowText({
|
|
21859
21881
|
text,
|
|
21860
21882
|
align
|
|
21861
21883
|
}) {
|
|
21862
|
-
const triggerId =
|
|
21863
|
-
const [isOverflowing, setIsOverflowing] =
|
|
21884
|
+
const triggerId = React55.useId();
|
|
21885
|
+
const [isOverflowing, setIsOverflowing] = React55.useState(false);
|
|
21864
21886
|
const alignClass = align === "right" ? "text-right" : align === "center" ? "text-center" : "text-left";
|
|
21865
|
-
const measureOverflow =
|
|
21887
|
+
const measureOverflow = React55.useCallback(() => {
|
|
21866
21888
|
if (typeof document === "undefined") return;
|
|
21867
21889
|
const element = document.querySelector(`[data-underverse-datatable-cell="${triggerId}"]`);
|
|
21868
21890
|
if (!element) return;
|
|
@@ -21870,10 +21892,10 @@ function DataTableOverflowText({
|
|
|
21870
21892
|
element.scrollWidth - element.clientWidth > 1 || element.scrollHeight - element.clientHeight > 1
|
|
21871
21893
|
);
|
|
21872
21894
|
}, [triggerId]);
|
|
21873
|
-
|
|
21895
|
+
React55.useLayoutEffect(() => {
|
|
21874
21896
|
measureOverflow();
|
|
21875
21897
|
}, [measureOverflow, text]);
|
|
21876
|
-
|
|
21898
|
+
React55.useEffect(() => {
|
|
21877
21899
|
if (typeof document === "undefined") return;
|
|
21878
21900
|
const element = document.querySelector(`[data-underverse-datatable-cell="${triggerId}"]`);
|
|
21879
21901
|
if (!element) return;
|
|
@@ -21994,7 +22016,7 @@ function DataTableBodyRows({
|
|
|
21994
22016
|
}
|
|
21995
22017
|
|
|
21996
22018
|
// src/components/DataTable/components/DataTableHeader.tsx
|
|
21997
|
-
import
|
|
22019
|
+
import React56 from "react";
|
|
21998
22020
|
import { Filter as FilterIcon } from "lucide-react";
|
|
21999
22021
|
import { Fragment as Fragment24, jsx as jsx65, jsxs as jsxs53 } from "react/jsx-runtime";
|
|
22000
22022
|
function getColumnLabel(title) {
|
|
@@ -22004,7 +22026,7 @@ function getColumnLabel(title) {
|
|
|
22004
22026
|
if (Array.isArray(title)) {
|
|
22005
22027
|
return title.map((item) => getColumnLabel(item)).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
22006
22028
|
}
|
|
22007
|
-
if (
|
|
22029
|
+
if (React56.isValidElement(title)) {
|
|
22008
22030
|
return getColumnLabel(title.props.children);
|
|
22009
22031
|
}
|
|
22010
22032
|
return "";
|
|
@@ -22030,7 +22052,7 @@ function DataTableHeader({
|
|
|
22030
22052
|
t
|
|
22031
22053
|
}) {
|
|
22032
22054
|
const gi18n = useGlobalI18n();
|
|
22033
|
-
const renderFilterControl =
|
|
22055
|
+
const renderFilterControl = React56.useCallback(
|
|
22034
22056
|
(col) => {
|
|
22035
22057
|
if (!col.filter) return null;
|
|
22036
22058
|
const key = col.key;
|
|
@@ -22084,7 +22106,7 @@ function DataTableHeader({
|
|
|
22084
22106
|
},
|
|
22085
22107
|
[filters, setCurPage, setFilters, size]
|
|
22086
22108
|
);
|
|
22087
|
-
const renderHeaderContent =
|
|
22109
|
+
const renderHeaderContent = React56.useCallback(
|
|
22088
22110
|
(col, isLeaf) => {
|
|
22089
22111
|
if (!isLeaf) {
|
|
22090
22112
|
return /* @__PURE__ */ jsx65(
|
|
@@ -22301,7 +22323,7 @@ function DataTableHeader({
|
|
|
22301
22323
|
}
|
|
22302
22324
|
|
|
22303
22325
|
// src/components/DataTable/components/Pagination.tsx
|
|
22304
|
-
import
|
|
22326
|
+
import React57 from "react";
|
|
22305
22327
|
import { jsx as jsx66, jsxs as jsxs54 } from "react/jsx-runtime";
|
|
22306
22328
|
function DataTablePagination({
|
|
22307
22329
|
totalItems,
|
|
@@ -22313,7 +22335,7 @@ function DataTablePagination({
|
|
|
22313
22335
|
size
|
|
22314
22336
|
}) {
|
|
22315
22337
|
const totalPages = Math.ceil(totalItems / curPageSize);
|
|
22316
|
-
const pages =
|
|
22338
|
+
const pages = React57.useMemo(() => {
|
|
22317
22339
|
const result = [];
|
|
22318
22340
|
if (totalPages <= 5) {
|
|
22319
22341
|
for (let i = 1; i <= totalPages; i++) result.push(i);
|
|
@@ -22395,7 +22417,7 @@ function DataTablePagination({
|
|
|
22395
22417
|
}
|
|
22396
22418
|
|
|
22397
22419
|
// src/components/DataTable/components/Toolbar.tsx
|
|
22398
|
-
import
|
|
22420
|
+
import React58 from "react";
|
|
22399
22421
|
|
|
22400
22422
|
// src/components/DataTable/utils/headers.ts
|
|
22401
22423
|
function isLeafColumn(col) {
|
|
@@ -22516,7 +22538,7 @@ function DataTableToolbar({
|
|
|
22516
22538
|
const controlButtonClass = size === "sm" ? "h-7 px-2 text-xs" : size === "lg" ? "h-9 px-3 text-sm" : "h-8 px-2";
|
|
22517
22539
|
const iconClass = size === "sm" ? "w-3.5 h-3.5 mr-1" : "w-4 h-4 mr-1";
|
|
22518
22540
|
const captionClass = size === "sm" ? "text-xs" : size === "lg" ? "text-sm" : "text-sm";
|
|
22519
|
-
const leafCols =
|
|
22541
|
+
const leafCols = React58.useMemo(() => getLeafColumns(columns), [columns]);
|
|
22520
22542
|
return /* @__PURE__ */ jsxs55("div", { className: "flex items-center justify-between gap-4 mb-1", children: [
|
|
22521
22543
|
/* @__PURE__ */ jsx67("div", { className: captionClass + " text-muted-foreground", children: caption }),
|
|
22522
22544
|
/* @__PURE__ */ jsxs55("div", { className: "flex items-center gap-2", children: [
|
|
@@ -22584,10 +22606,10 @@ function DataTableToolbar({
|
|
|
22584
22606
|
}
|
|
22585
22607
|
|
|
22586
22608
|
// src/components/DataTable/hooks/useDebounced.ts
|
|
22587
|
-
import
|
|
22609
|
+
import React59 from "react";
|
|
22588
22610
|
function useDebounced(value, delay = 300) {
|
|
22589
|
-
const [debounced, setDebounced] =
|
|
22590
|
-
|
|
22611
|
+
const [debounced, setDebounced] = React59.useState(value);
|
|
22612
|
+
React59.useEffect(() => {
|
|
22591
22613
|
const id = setTimeout(() => setDebounced(value), delay);
|
|
22592
22614
|
return () => clearTimeout(id);
|
|
22593
22615
|
}, [value, delay]);
|
|
@@ -22595,7 +22617,7 @@ function useDebounced(value, delay = 300) {
|
|
|
22595
22617
|
}
|
|
22596
22618
|
|
|
22597
22619
|
// src/components/DataTable/hooks/useDataTableModel.ts
|
|
22598
|
-
import
|
|
22620
|
+
import React60 from "react";
|
|
22599
22621
|
|
|
22600
22622
|
// src/components/DataTable/utils/columns.ts
|
|
22601
22623
|
function getColumnWidth(col, fallback = 150) {
|
|
@@ -22623,22 +22645,22 @@ function useDataTableModel({
|
|
|
22623
22645
|
isServerMode,
|
|
22624
22646
|
total
|
|
22625
22647
|
}) {
|
|
22626
|
-
const visibleColsSet =
|
|
22627
|
-
const allLeafColumns =
|
|
22628
|
-
const columnMap =
|
|
22648
|
+
const visibleColsSet = React60.useMemo(() => new Set(visibleCols), [visibleCols]);
|
|
22649
|
+
const allLeafColumns = React60.useMemo(() => getLeafColumns(columns), [columns]);
|
|
22650
|
+
const columnMap = React60.useMemo(() => {
|
|
22629
22651
|
return new Map(allLeafColumns.map((column) => [column.key, column]));
|
|
22630
22652
|
}, [allLeafColumns]);
|
|
22631
|
-
const visibleColumns =
|
|
22653
|
+
const visibleColumns = React60.useMemo(() => {
|
|
22632
22654
|
return filterVisibleColumns(columns, visibleColsSet);
|
|
22633
22655
|
}, [columns, visibleColsSet]);
|
|
22634
|
-
const leafColumns =
|
|
22656
|
+
const leafColumns = React60.useMemo(() => {
|
|
22635
22657
|
return getLeafColumnsWithFixedInheritance(visibleColumns);
|
|
22636
22658
|
}, [visibleColumns]);
|
|
22637
|
-
const headerRows =
|
|
22638
|
-
const totalColumnsWidth =
|
|
22659
|
+
const headerRows = React60.useMemo(() => buildHeaderRows(visibleColumns), [visibleColumns]);
|
|
22660
|
+
const totalColumnsWidth = React60.useMemo(() => {
|
|
22639
22661
|
return leafColumns.reduce((sum, column) => sum + getColumnWidth(column), 0);
|
|
22640
22662
|
}, [leafColumns]);
|
|
22641
|
-
const processedData =
|
|
22663
|
+
const processedData = React60.useMemo(() => {
|
|
22642
22664
|
if (isServerMode) return data;
|
|
22643
22665
|
let result = [...data];
|
|
22644
22666
|
if (Object.keys(filters).length > 0) {
|
|
@@ -22670,7 +22692,7 @@ function useDataTableModel({
|
|
|
22670
22692
|
return result;
|
|
22671
22693
|
}, [columnMap, data, filters, isServerMode, sort]);
|
|
22672
22694
|
const totalItems = isServerMode ? total : processedData.length;
|
|
22673
|
-
const displayedData =
|
|
22695
|
+
const displayedData = React60.useMemo(() => {
|
|
22674
22696
|
if (isServerMode) return data;
|
|
22675
22697
|
const start = (curPage - 1) * curPageSize;
|
|
22676
22698
|
return processedData.slice(start, start + curPageSize);
|
|
@@ -22686,10 +22708,10 @@ function useDataTableModel({
|
|
|
22686
22708
|
}
|
|
22687
22709
|
|
|
22688
22710
|
// src/components/DataTable/hooks/useDataTableState.ts
|
|
22689
|
-
import
|
|
22711
|
+
import React62 from "react";
|
|
22690
22712
|
|
|
22691
22713
|
// src/components/DataTable/hooks/usePageSizeStorage.ts
|
|
22692
|
-
import
|
|
22714
|
+
import React61 from "react";
|
|
22693
22715
|
function readStoredPageSize(storageKey) {
|
|
22694
22716
|
if (typeof window === "undefined" || !storageKey) return null;
|
|
22695
22717
|
try {
|
|
@@ -22702,8 +22724,8 @@ function readStoredPageSize(storageKey) {
|
|
|
22702
22724
|
}
|
|
22703
22725
|
}
|
|
22704
22726
|
function usePageSizeStorage({ pageSize, storageKey }) {
|
|
22705
|
-
const storedPageSize =
|
|
22706
|
-
const [overrideState, setOverrideState] =
|
|
22727
|
+
const storedPageSize = React61.useMemo(() => readStoredPageSize(storageKey), [storageKey]);
|
|
22728
|
+
const [overrideState, setOverrideState] = React61.useState({
|
|
22707
22729
|
storageKey,
|
|
22708
22730
|
pageSize: null
|
|
22709
22731
|
});
|
|
@@ -22711,7 +22733,7 @@ function usePageSizeStorage({ pageSize, storageKey }) {
|
|
|
22711
22733
|
const persistedPageSize = storageKey ? overridePageSize ?? storedPageSize : null;
|
|
22712
22734
|
const loadedFromStorage = persistedPageSize != null;
|
|
22713
22735
|
const curPageSize = storageKey ? persistedPageSize ?? pageSize : overridePageSize ?? pageSize;
|
|
22714
|
-
const setCurPageSize =
|
|
22736
|
+
const setCurPageSize = React61.useCallback(
|
|
22715
22737
|
(nextPageSize) => {
|
|
22716
22738
|
const baseValue = storageKey ? persistedPageSize ?? pageSize : overridePageSize ?? pageSize;
|
|
22717
22739
|
const resolved = typeof nextPageSize === "function" ? nextPageSize(baseValue) : nextPageSize;
|
|
@@ -22740,17 +22762,17 @@ function useDataTableState({
|
|
|
22740
22762
|
size,
|
|
22741
22763
|
storageKey
|
|
22742
22764
|
}) {
|
|
22743
|
-
const allLeafColumns =
|
|
22744
|
-
const defaultVisibleLeafKeys =
|
|
22745
|
-
const knownLeafKeysRef =
|
|
22746
|
-
const [headerAlign, setHeaderAlign] =
|
|
22747
|
-
const [visibleCols, setVisibleCols] =
|
|
22748
|
-
const [filters, setFilters] =
|
|
22749
|
-
const [sort, setSort] =
|
|
22750
|
-
const [density, setDensity] =
|
|
22751
|
-
const [curPage, setCurPage] =
|
|
22765
|
+
const allLeafColumns = React62.useMemo(() => getLeafColumns(columns), [columns]);
|
|
22766
|
+
const defaultVisibleLeafKeys = React62.useMemo(() => allLeafColumns.filter((column) => column.visible !== false).map((column) => column.key), [allLeafColumns]);
|
|
22767
|
+
const knownLeafKeysRef = React62.useRef(new Set(defaultVisibleLeafKeys));
|
|
22768
|
+
const [headerAlign, setHeaderAlign] = React62.useState("left");
|
|
22769
|
+
const [visibleCols, setVisibleCols] = React62.useState(defaultVisibleLeafKeys);
|
|
22770
|
+
const [filters, setFilters] = React62.useState({});
|
|
22771
|
+
const [sort, setSort] = React62.useState(null);
|
|
22772
|
+
const [density, setDensity] = React62.useState(() => SIZE_TO_DENSITY[size]);
|
|
22773
|
+
const [curPage, setCurPage] = React62.useState(page);
|
|
22752
22774
|
const { curPageSize, setCurPageSize } = usePageSizeStorage({ pageSize, storageKey });
|
|
22753
|
-
|
|
22775
|
+
React62.useEffect(() => {
|
|
22754
22776
|
const knownLeafKeys = knownLeafKeysRef.current;
|
|
22755
22777
|
setVisibleCols((prev) => {
|
|
22756
22778
|
const prevSet = new Set(prev);
|
|
@@ -22758,10 +22780,10 @@ function useDataTableState({
|
|
|
22758
22780
|
});
|
|
22759
22781
|
knownLeafKeysRef.current = new Set(allLeafColumns.map((column) => column.key));
|
|
22760
22782
|
}, [allLeafColumns]);
|
|
22761
|
-
|
|
22783
|
+
React62.useEffect(() => {
|
|
22762
22784
|
setCurPage(page);
|
|
22763
22785
|
}, [page]);
|
|
22764
|
-
|
|
22786
|
+
React62.useEffect(() => {
|
|
22765
22787
|
setDensity(SIZE_TO_DENSITY[size]);
|
|
22766
22788
|
}, [size]);
|
|
22767
22789
|
return {
|
|
@@ -22783,7 +22805,7 @@ function useDataTableState({
|
|
|
22783
22805
|
}
|
|
22784
22806
|
|
|
22785
22807
|
// src/components/DataTable/hooks/useStickyColumns.ts
|
|
22786
|
-
import
|
|
22808
|
+
import React63 from "react";
|
|
22787
22809
|
|
|
22788
22810
|
// src/components/DataTable/utils/sticky.ts
|
|
22789
22811
|
function buildStickyLayout(visibleColumns) {
|
|
@@ -22830,8 +22852,8 @@ function resolveGroupStickyPosition(column, positions) {
|
|
|
22830
22852
|
|
|
22831
22853
|
// src/components/DataTable/hooks/useStickyColumns.ts
|
|
22832
22854
|
function useStickyColumns(visibleColumns) {
|
|
22833
|
-
const { positions, leftBoundaryKey, rightBoundaryKey } =
|
|
22834
|
-
const getStickyColumnStyle =
|
|
22855
|
+
const { positions, leftBoundaryKey, rightBoundaryKey } = React63.useMemo(() => buildStickyLayout(visibleColumns), [visibleColumns]);
|
|
22856
|
+
const getStickyColumnStyle = React63.useCallback(
|
|
22835
22857
|
(col) => {
|
|
22836
22858
|
const pos = resolveStickyPosition(col, positions);
|
|
22837
22859
|
if (!pos) return {};
|
|
@@ -22842,7 +22864,7 @@ function useStickyColumns(visibleColumns) {
|
|
|
22842
22864
|
},
|
|
22843
22865
|
[positions]
|
|
22844
22866
|
);
|
|
22845
|
-
const getBoundaryShadowClass =
|
|
22867
|
+
const getBoundaryShadowClass = React63.useCallback(
|
|
22846
22868
|
(col) => {
|
|
22847
22869
|
if (col.fixed === "left" && col.key === leftBoundaryKey) {
|
|
22848
22870
|
return "border-r border-border/80 shadow-[10px_0_16px_-10px_rgba(0,0,0,0.55)]";
|
|
@@ -22854,14 +22876,14 @@ function useStickyColumns(visibleColumns) {
|
|
|
22854
22876
|
},
|
|
22855
22877
|
[leftBoundaryKey, rightBoundaryKey]
|
|
22856
22878
|
);
|
|
22857
|
-
const getStickyHeaderClass =
|
|
22879
|
+
const getStickyHeaderClass = React63.useCallback(
|
|
22858
22880
|
(col) => {
|
|
22859
22881
|
if (!col.fixed) return "";
|
|
22860
22882
|
return cn("sticky", col.fixed === "left" && "left-0", col.fixed === "right" && "right-0", getBoundaryShadowClass(col), "z-50 !bg-muted");
|
|
22861
22883
|
},
|
|
22862
22884
|
[getBoundaryShadowClass]
|
|
22863
22885
|
);
|
|
22864
|
-
const getStickyCellClass =
|
|
22886
|
+
const getStickyCellClass = React63.useCallback(
|
|
22865
22887
|
(col, isStripedRow) => {
|
|
22866
22888
|
if (!col.fixed) return "";
|
|
22867
22889
|
return cn(
|
|
@@ -22874,7 +22896,7 @@ function useStickyColumns(visibleColumns) {
|
|
|
22874
22896
|
},
|
|
22875
22897
|
[getBoundaryShadowClass]
|
|
22876
22898
|
);
|
|
22877
|
-
const getStickyHeaderCellStyle =
|
|
22899
|
+
const getStickyHeaderCellStyle = React63.useCallback(
|
|
22878
22900
|
(headerCell) => {
|
|
22879
22901
|
const col = headerCell.column;
|
|
22880
22902
|
if (headerCell.isLeaf) {
|
|
@@ -23065,8 +23087,8 @@ function DataTable({
|
|
|
23065
23087
|
labels
|
|
23066
23088
|
}) {
|
|
23067
23089
|
const t = useSmartTranslations("Common");
|
|
23068
|
-
const [columnWidthOverrides, setColumnWidthOverrides] =
|
|
23069
|
-
const columnsWithWidthOverrides =
|
|
23090
|
+
const [columnWidthOverrides, setColumnWidthOverrides] = React64.useState({});
|
|
23091
|
+
const columnsWithWidthOverrides = React64.useMemo(
|
|
23070
23092
|
() => applyColumnWidthOverrides(columns, columnWidthOverrides),
|
|
23071
23093
|
[columnWidthOverrides, columns]
|
|
23072
23094
|
);
|
|
@@ -23092,7 +23114,7 @@ function DataTable({
|
|
|
23092
23114
|
size,
|
|
23093
23115
|
storageKey
|
|
23094
23116
|
});
|
|
23095
|
-
|
|
23117
|
+
React64.useEffect(() => {
|
|
23096
23118
|
if (process.env.NODE_ENV === "development") {
|
|
23097
23119
|
const warnings = validateColumns(columnsWithWidthOverrides);
|
|
23098
23120
|
warnings.forEach((w) => console.warn(`[DataTable] ${w}`));
|
|
@@ -23100,8 +23122,8 @@ function DataTable({
|
|
|
23100
23122
|
}, [columnsWithWidthOverrides]);
|
|
23101
23123
|
const debouncedFilters = useDebounced(filters, 350);
|
|
23102
23124
|
const isServerMode = Boolean(onQueryChange);
|
|
23103
|
-
const hasEmittedQuery =
|
|
23104
|
-
|
|
23125
|
+
const hasEmittedQuery = React64.useRef(false);
|
|
23126
|
+
React64.useEffect(() => {
|
|
23105
23127
|
if (!onQueryChange) return;
|
|
23106
23128
|
if (!hasEmittedQuery.current) {
|
|
23107
23129
|
hasEmittedQuery.current = true;
|
|
@@ -23109,7 +23131,7 @@ function DataTable({
|
|
|
23109
23131
|
}
|
|
23110
23132
|
onQueryChange({ filters: debouncedFilters, sort, page: curPage, pageSize: curPageSize });
|
|
23111
23133
|
}, [debouncedFilters, sort, curPage, curPageSize, onQueryChange]);
|
|
23112
|
-
|
|
23134
|
+
React64.useEffect(() => {
|
|
23113
23135
|
if (process.env.NODE_ENV !== "development" || rowKey) return;
|
|
23114
23136
|
const hasQueryFeatures = columns.some((column) => column.sortable || column.filter) || Boolean(pageSizeOptions?.length) || isServerMode;
|
|
23115
23137
|
if (!hasQueryFeatures) return;
|
|
@@ -23142,8 +23164,8 @@ function DataTable({
|
|
|
23142
23164
|
if (typeof rowKey === "function") return String(rowKey(row));
|
|
23143
23165
|
return String(row[rowKey]);
|
|
23144
23166
|
};
|
|
23145
|
-
const viewportRef =
|
|
23146
|
-
const tableRef =
|
|
23167
|
+
const viewportRef = React64.useRef(null);
|
|
23168
|
+
const tableRef = React64.useRef(null);
|
|
23147
23169
|
const canVirtualizeRows = virtualizedRows && !loading2 && displayedData.length > 0;
|
|
23148
23170
|
const shouldUseScrollViewport = stickyHeader || canVirtualizeRows;
|
|
23149
23171
|
const rowVirtualizer = useVirtualizer4({
|
|
@@ -23164,7 +23186,7 @@ function DataTable({
|
|
|
23164
23186
|
enabled: useOverlayScrollbar && !canVirtualizeRows,
|
|
23165
23187
|
overflowX: overlayOverflowX
|
|
23166
23188
|
});
|
|
23167
|
-
const autoFitColumn =
|
|
23189
|
+
const autoFitColumn = React64.useCallback((columnKey) => {
|
|
23168
23190
|
const tableElement = tableRef.current;
|
|
23169
23191
|
if (!tableElement) return;
|
|
23170
23192
|
const nodes = Array.from(
|
|
@@ -23308,10 +23330,10 @@ function DataTable({
|
|
|
23308
23330
|
var DataTable_default = DataTable;
|
|
23309
23331
|
|
|
23310
23332
|
// src/components/Form.tsx
|
|
23311
|
-
import * as
|
|
23333
|
+
import * as React65 from "react";
|
|
23312
23334
|
import { Controller, FormProvider, useFormContext, useForm } from "react-hook-form";
|
|
23313
23335
|
import { jsx as jsx69, jsxs as jsxs57 } from "react/jsx-runtime";
|
|
23314
|
-
var FormConfigContext =
|
|
23336
|
+
var FormConfigContext = React65.createContext({ size: "md" });
|
|
23315
23337
|
var FormWrapper = ({
|
|
23316
23338
|
children,
|
|
23317
23339
|
onSubmit,
|
|
@@ -23324,7 +23346,7 @@ var FormWrapper = ({
|
|
|
23324
23346
|
const methods = useForm({
|
|
23325
23347
|
defaultValues: initialValues
|
|
23326
23348
|
});
|
|
23327
|
-
|
|
23349
|
+
React65.useEffect(() => {
|
|
23328
23350
|
if (initialValues) {
|
|
23329
23351
|
methods.reset(initialValues);
|
|
23330
23352
|
}
|
|
@@ -23333,15 +23355,15 @@ var FormWrapper = ({
|
|
|
23333
23355
|
return /* @__PURE__ */ jsx69(FormProvider, { ...methods, children: /* @__PURE__ */ jsx69(FormConfigContext.Provider, { value: { size }, children: /* @__PURE__ */ jsx69("form", { onSubmit: methods.handleSubmit(onSubmit), className, ...formProps, children }) }) });
|
|
23334
23356
|
};
|
|
23335
23357
|
var Form = FormWrapper;
|
|
23336
|
-
var FormFieldContext =
|
|
23358
|
+
var FormFieldContext = React65.createContext({});
|
|
23337
23359
|
var FormField = ({
|
|
23338
23360
|
...props
|
|
23339
23361
|
}) => {
|
|
23340
23362
|
return /* @__PURE__ */ jsx69(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx69(Controller, { ...props }) });
|
|
23341
23363
|
};
|
|
23342
23364
|
var useFormField = () => {
|
|
23343
|
-
const fieldContext =
|
|
23344
|
-
const itemContext =
|
|
23365
|
+
const fieldContext = React65.useContext(FormFieldContext);
|
|
23366
|
+
const itemContext = React65.useContext(FormItemContext);
|
|
23345
23367
|
const { getFieldState, formState } = useFormContext();
|
|
23346
23368
|
if (!fieldContext) {
|
|
23347
23369
|
throw new Error("useFormField must be used within FormField");
|
|
@@ -23357,16 +23379,16 @@ var useFormField = () => {
|
|
|
23357
23379
|
...fieldState
|
|
23358
23380
|
};
|
|
23359
23381
|
};
|
|
23360
|
-
var FormItemContext =
|
|
23361
|
-
var FormItem =
|
|
23362
|
-
const id =
|
|
23382
|
+
var FormItemContext = React65.createContext({});
|
|
23383
|
+
var FormItem = React65.forwardRef(({ className, ...props }, ref) => {
|
|
23384
|
+
const id = React65.useId();
|
|
23363
23385
|
return /* @__PURE__ */ jsx69(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx69("div", { ref, className: cn("group space-y-2", className), ...props }) });
|
|
23364
23386
|
});
|
|
23365
23387
|
FormItem.displayName = "FormItem";
|
|
23366
|
-
var FormLabel =
|
|
23388
|
+
var FormLabel = React65.forwardRef(
|
|
23367
23389
|
({ className, children, required, ...props }, ref) => {
|
|
23368
23390
|
const { error, formItemId } = useFormField();
|
|
23369
|
-
const config =
|
|
23391
|
+
const config = React65.useContext(FormConfigContext);
|
|
23370
23392
|
const sizeClass = config.size === "sm" ? "text-xs" : config.size === "lg" ? "text-base" : "text-sm";
|
|
23371
23393
|
return /* @__PURE__ */ jsxs57(
|
|
23372
23394
|
Label,
|
|
@@ -23389,7 +23411,7 @@ var FormLabel = React64.forwardRef(
|
|
|
23389
23411
|
}
|
|
23390
23412
|
);
|
|
23391
23413
|
FormLabel.displayName = "FormLabel";
|
|
23392
|
-
var FormControl =
|
|
23414
|
+
var FormControl = React65.forwardRef(({ ...props }, ref) => {
|
|
23393
23415
|
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
23394
23416
|
return /* @__PURE__ */ jsx69(
|
|
23395
23417
|
"div",
|
|
@@ -23403,12 +23425,12 @@ var FormControl = React64.forwardRef(({ ...props }, ref) => {
|
|
|
23403
23425
|
);
|
|
23404
23426
|
});
|
|
23405
23427
|
FormControl.displayName = "FormControl";
|
|
23406
|
-
var FormDescription =
|
|
23428
|
+
var FormDescription = React65.forwardRef(({ className, ...props }, ref) => {
|
|
23407
23429
|
const { formDescriptionId } = useFormField();
|
|
23408
23430
|
return /* @__PURE__ */ jsx69("p", { ref, id: formDescriptionId, className: cn("text-sm text-muted-foreground", className), ...props });
|
|
23409
23431
|
});
|
|
23410
23432
|
FormDescription.displayName = "FormDescription";
|
|
23411
|
-
var FormMessage =
|
|
23433
|
+
var FormMessage = React65.forwardRef(({ className, children, ...props }, ref) => {
|
|
23412
23434
|
const { error, formMessageId } = useFormField();
|
|
23413
23435
|
const body = error ? String(error?.message) : children;
|
|
23414
23436
|
if (!body) {
|
|
@@ -23417,7 +23439,7 @@ var FormMessage = React64.forwardRef(({ className, children, ...props }, ref) =>
|
|
|
23417
23439
|
return /* @__PURE__ */ jsx69("p", { ref, id: formMessageId, className: cn("text-sm font-medium text-destructive", className), ...props, children: body });
|
|
23418
23440
|
});
|
|
23419
23441
|
FormMessage.displayName = "FormMessage";
|
|
23420
|
-
var FormInput =
|
|
23442
|
+
var FormInput = React65.forwardRef(({ name, ...props }, ref) => /* @__PURE__ */ jsx69(FormConfigContext.Consumer, { children: ({ size }) => /* @__PURE__ */ jsx69(
|
|
23421
23443
|
FormField,
|
|
23422
23444
|
{
|
|
23423
23445
|
name,
|
|
@@ -23428,7 +23450,7 @@ var FormInput = React64.forwardRef(({ name, ...props }, ref) => /* @__PURE__ */
|
|
|
23428
23450
|
}
|
|
23429
23451
|
) }));
|
|
23430
23452
|
FormInput.displayName = "FormInput";
|
|
23431
|
-
var FormCheckbox =
|
|
23453
|
+
var FormCheckbox = React65.forwardRef(({ name, ...props }, ref) => /* @__PURE__ */ jsx69(FormConfigContext.Consumer, { children: ({ size }) => /* @__PURE__ */ jsx69(
|
|
23432
23454
|
FormField,
|
|
23433
23455
|
{
|
|
23434
23456
|
name,
|
|
@@ -23452,9 +23474,9 @@ var FormCheckbox = React64.forwardRef(({ name, ...props }, ref) => /* @__PURE__
|
|
|
23452
23474
|
}
|
|
23453
23475
|
) }));
|
|
23454
23476
|
FormCheckbox.displayName = "FormCheckbox";
|
|
23455
|
-
var FormActions =
|
|
23477
|
+
var FormActions = React65.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx69("div", { ref, className: cn("flex gap-2 justify-end", className), ...props }));
|
|
23456
23478
|
FormActions.displayName = "FormActions";
|
|
23457
|
-
var FormSubmitButton =
|
|
23479
|
+
var FormSubmitButton = React65.forwardRef(
|
|
23458
23480
|
({ children, loading: loading2, ...props }, ref) => /* @__PURE__ */ jsx69(FormConfigContext.Consumer, { children: ({ size }) => /* @__PURE__ */ jsx69(Button_default, { ref, type: "submit", size: props.size ?? size, disabled: loading2, ...props, children }) })
|
|
23459
23481
|
);
|
|
23460
23482
|
FormSubmitButton.displayName = "FormSubmitButton";
|
|
@@ -23744,7 +23766,7 @@ var VARIANT_STYLES_ALERT = {
|
|
|
23744
23766
|
};
|
|
23745
23767
|
|
|
23746
23768
|
// src/contexts/translation-adapter.tsx
|
|
23747
|
-
import * as
|
|
23769
|
+
import * as React67 from "react";
|
|
23748
23770
|
import { jsx as jsx74 } from "react/jsx-runtime";
|
|
23749
23771
|
function isUnresolvedTranslation2(value, namespace, key) {
|
|
23750
23772
|
return value === key || value === `${namespace}.${key}`;
|
|
@@ -23769,7 +23791,7 @@ function useTranslations(namespace) {
|
|
|
23769
23791
|
const nextIntlBridge = useNextIntlBridge();
|
|
23770
23792
|
const internalLocale = useUnderverseLocale();
|
|
23771
23793
|
const internalT = useUnderverseTranslations(namespace);
|
|
23772
|
-
return
|
|
23794
|
+
return React67.useCallback((key, params) => {
|
|
23773
23795
|
if (nextIntlBridge) {
|
|
23774
23796
|
const nextIntlResult = nextIntlBridge.translate(namespace, key, params);
|
|
23775
23797
|
if (nextIntlResult.translated && !isUnresolvedTranslation2(nextIntlResult.translated, namespace, key)) {
|
|
@@ -23794,7 +23816,7 @@ function useLocale2() {
|
|
|
23794
23816
|
}
|
|
23795
23817
|
|
|
23796
23818
|
// src/components/UEditor/UEditor.tsx
|
|
23797
|
-
import
|
|
23819
|
+
import React78, { useEffect as useEffect36, useImperativeHandle as useImperativeHandle3, useMemo as useMemo24, useRef as useRef34 } from "react";
|
|
23798
23820
|
import { useEditor, EditorContent } from "@tiptap/react";
|
|
23799
23821
|
|
|
23800
23822
|
// src/components/UEditor/extensions.ts
|
|
@@ -23833,7 +23855,7 @@ import { common, createLowlight } from "lowlight";
|
|
|
23833
23855
|
import { Extension } from "@tiptap/core";
|
|
23834
23856
|
import Suggestion from "@tiptap/suggestion";
|
|
23835
23857
|
import { ReactRenderer } from "@tiptap/react";
|
|
23836
|
-
import
|
|
23858
|
+
import React68, { forwardRef as forwardRef14, useEffect as useEffect31, useImperativeHandle, useRef as useRef27 } from "react";
|
|
23837
23859
|
import {
|
|
23838
23860
|
FileCode as FileCode2,
|
|
23839
23861
|
Heading1,
|
|
@@ -23896,9 +23918,9 @@ var DEFAULT_MESSAGES = {
|
|
|
23896
23918
|
tableDesc: "Insert a table"
|
|
23897
23919
|
};
|
|
23898
23920
|
function useResettingIndex2(resetToken) {
|
|
23899
|
-
const [state, setState] =
|
|
23921
|
+
const [state, setState] = React68.useState({ resetToken, index: 0 });
|
|
23900
23922
|
const selectedIndex = Object.is(state.resetToken, resetToken) ? state.index : 0;
|
|
23901
|
-
const setSelectedIndex =
|
|
23923
|
+
const setSelectedIndex = React68.useCallback((nextIndex) => {
|
|
23902
23924
|
setState((prev) => {
|
|
23903
23925
|
const prevIndex = Object.is(prev.resetToken, resetToken) ? prev.index : 0;
|
|
23904
23926
|
return {
|
|
@@ -24324,13 +24346,13 @@ import { Extension as Extension3 } from "@tiptap/core";
|
|
|
24324
24346
|
import Suggestion2 from "@tiptap/suggestion";
|
|
24325
24347
|
import { ReactRenderer as ReactRenderer2 } from "@tiptap/react";
|
|
24326
24348
|
import { PluginKey } from "@tiptap/pm/state";
|
|
24327
|
-
import
|
|
24349
|
+
import React69, { forwardRef as forwardRef15, useImperativeHandle as useImperativeHandle2 } from "react";
|
|
24328
24350
|
import { Smile as Smile2 } from "lucide-react";
|
|
24329
24351
|
import { jsx as jsx76, jsxs as jsxs63 } from "react/jsx-runtime";
|
|
24330
24352
|
function useResettingIndex3(resetToken) {
|
|
24331
|
-
const [state, setState] =
|
|
24353
|
+
const [state, setState] = React69.useState({ resetToken, index: 0 });
|
|
24332
24354
|
const selectedIndex = Object.is(state.resetToken, resetToken) ? state.index : 0;
|
|
24333
|
-
const setSelectedIndex =
|
|
24355
|
+
const setSelectedIndex = React69.useCallback((nextIndex) => {
|
|
24334
24356
|
setState((prev) => {
|
|
24335
24357
|
const prevIndex = Object.is(prev.resetToken, resetToken) ? prev.index : 0;
|
|
24336
24358
|
return {
|
|
@@ -25213,7 +25235,7 @@ function buildUEditorExtensions({
|
|
|
25213
25235
|
types: ["heading", "paragraph", "image"]
|
|
25214
25236
|
}),
|
|
25215
25237
|
table_align_default.configure({
|
|
25216
|
-
resizable:
|
|
25238
|
+
resizable: editable,
|
|
25217
25239
|
handleWidth: 10,
|
|
25218
25240
|
allowTableNodeSelection: true,
|
|
25219
25241
|
HTMLAttributes: {
|
|
@@ -25259,7 +25281,7 @@ function buildUEditorExtensions({
|
|
|
25259
25281
|
}
|
|
25260
25282
|
|
|
25261
25283
|
// src/components/UEditor/toolbar.tsx
|
|
25262
|
-
import
|
|
25284
|
+
import React73, { useRef as useRef30, useState as useState44 } from "react";
|
|
25263
25285
|
import {
|
|
25264
25286
|
AlignCenter,
|
|
25265
25287
|
AlignJustify,
|
|
@@ -25609,7 +25631,7 @@ function fileToDataUrl2(file) {
|
|
|
25609
25631
|
function formatTableInsertLabel(template, rows, cols) {
|
|
25610
25632
|
return template.replace("{rows}", String(rows)).replace("{cols}", String(cols));
|
|
25611
25633
|
}
|
|
25612
|
-
var ToolbarButton =
|
|
25634
|
+
var ToolbarButton = React73.forwardRef(({ onClick, onMouseDown, active, disabled, children, title, className }, ref) => {
|
|
25613
25635
|
const button = /* @__PURE__ */ jsx81(
|
|
25614
25636
|
"button",
|
|
25615
25637
|
{
|
|
@@ -25645,7 +25667,7 @@ var TableInsertGrid = ({
|
|
|
25645
25667
|
previewTemplate,
|
|
25646
25668
|
onInsert
|
|
25647
25669
|
}) => {
|
|
25648
|
-
const [selection, setSelection] =
|
|
25670
|
+
const [selection, setSelection] = React73.useState({ rows: 3, cols: 3 });
|
|
25649
25671
|
const maxRows = 8;
|
|
25650
25672
|
const maxCols = 8;
|
|
25651
25673
|
return /* @__PURE__ */ jsxs67("div", { className: "mb-2 rounded-xl border border-border/60 bg-muted/20 p-2", children: [
|
|
@@ -25717,19 +25739,19 @@ var EditorToolbar = ({
|
|
|
25717
25739
|
const currentFontSize = normalizeStyleValue(textStyleAttrs.fontSize);
|
|
25718
25740
|
const currentLineHeight = normalizeStyleValue(textStyleAttrs.lineHeight);
|
|
25719
25741
|
const currentLetterSpacing = normalizeStyleValue(textStyleAttrs.letterSpacing);
|
|
25720
|
-
const availableFontFamilies =
|
|
25742
|
+
const availableFontFamilies = React73.useMemo(
|
|
25721
25743
|
() => fontFamilies ?? getDefaultFontFamilies(t),
|
|
25722
25744
|
[fontFamilies, t]
|
|
25723
25745
|
);
|
|
25724
|
-
const availableFontSizes =
|
|
25746
|
+
const availableFontSizes = React73.useMemo(
|
|
25725
25747
|
() => fontSizes ?? getDefaultFontSizes(),
|
|
25726
25748
|
[fontSizes]
|
|
25727
25749
|
);
|
|
25728
|
-
const availableLineHeights =
|
|
25750
|
+
const availableLineHeights = React73.useMemo(
|
|
25729
25751
|
() => lineHeights ?? getDefaultLineHeights(),
|
|
25730
25752
|
[lineHeights]
|
|
25731
25753
|
);
|
|
25732
|
-
const availableLetterSpacings =
|
|
25754
|
+
const availableLetterSpacings = React73.useMemo(
|
|
25733
25755
|
() => letterSpacings ?? getDefaultLetterSpacings(),
|
|
25734
25756
|
[letterSpacings]
|
|
25735
25757
|
);
|
|
@@ -25737,7 +25759,7 @@ var EditorToolbar = ({
|
|
|
25737
25759
|
const currentFontSizeLabel = availableFontSizes.find((option) => normalizeStyleValue(option.value) === currentFontSize)?.label ?? t("toolbar.sizeDefault");
|
|
25738
25760
|
const currentLineHeightLabel = availableLineHeights.find((option) => normalizeStyleValue(option.value) === currentLineHeight)?.label ?? t("toolbar.lineHeightDefault");
|
|
25739
25761
|
const currentLetterSpacingLabel = availableLetterSpacings.find((option) => normalizeStyleValue(option.value) === currentLetterSpacing)?.label ?? t("toolbar.letterSpacingDefault");
|
|
25740
|
-
|
|
25762
|
+
React73.useEffect(() => {
|
|
25741
25763
|
setFontSizeDraft(currentFontSize.replace(/px$/i, ""));
|
|
25742
25764
|
}, [currentFontSize]);
|
|
25743
25765
|
const applyFontSizeDraft = () => {
|
|
@@ -27227,7 +27249,7 @@ async function prepareUEditorContentForSave({
|
|
|
27227
27249
|
}
|
|
27228
27250
|
|
|
27229
27251
|
// src/components/UEditor/table-controls.tsx
|
|
27230
|
-
import
|
|
27252
|
+
import React75 from "react";
|
|
27231
27253
|
|
|
27232
27254
|
// node_modules/prosemirror-model/dist/index.js
|
|
27233
27255
|
function findDiffStart(a, b, pos) {
|
|
@@ -31707,16 +31729,16 @@ function collectChildren(node) {
|
|
|
31707
31729
|
}
|
|
31708
31730
|
function TableControls({ editor, containerRef }) {
|
|
31709
31731
|
const t = useSmartTranslations("UEditor");
|
|
31710
|
-
const [layout, setLayout] =
|
|
31711
|
-
const [dragPreview, setDragPreview] =
|
|
31712
|
-
const [hoverState, setHoverState] =
|
|
31713
|
-
const [openMenuKey, setOpenMenuKey] =
|
|
31714
|
-
const layoutRef =
|
|
31715
|
-
const dragStateRef =
|
|
31716
|
-
|
|
31732
|
+
const [layout, setLayout] = React75.useState(null);
|
|
31733
|
+
const [dragPreview, setDragPreview] = React75.useState(null);
|
|
31734
|
+
const [hoverState, setHoverState] = React75.useState(DEFAULT_HOVER_STATE);
|
|
31735
|
+
const [openMenuKey, setOpenMenuKey] = React75.useState(null);
|
|
31736
|
+
const layoutRef = React75.useRef(null);
|
|
31737
|
+
const dragStateRef = React75.useRef(null);
|
|
31738
|
+
React75.useEffect(() => {
|
|
31717
31739
|
layoutRef.current = layout;
|
|
31718
31740
|
}, [layout]);
|
|
31719
|
-
const syncFromCell =
|
|
31741
|
+
const syncFromCell = React75.useCallback((cell) => {
|
|
31720
31742
|
const surface = containerRef.current;
|
|
31721
31743
|
if (!surface || !cell) {
|
|
31722
31744
|
setLayout(null);
|
|
@@ -31724,10 +31746,10 @@ function TableControls({ editor, containerRef }) {
|
|
|
31724
31746
|
}
|
|
31725
31747
|
setLayout(buildLayout(editor, surface, cell));
|
|
31726
31748
|
}, [containerRef, editor]);
|
|
31727
|
-
const syncFromSelection =
|
|
31749
|
+
const syncFromSelection = React75.useCallback(() => {
|
|
31728
31750
|
syncFromCell(getSelectedCell(editor));
|
|
31729
31751
|
}, [editor, syncFromCell]);
|
|
31730
|
-
const refreshCurrentLayout =
|
|
31752
|
+
const refreshCurrentLayout = React75.useCallback(() => {
|
|
31731
31753
|
setLayout((prev) => {
|
|
31732
31754
|
if (!prev) return prev;
|
|
31733
31755
|
const surface = containerRef.current;
|
|
@@ -31737,12 +31759,12 @@ function TableControls({ editor, containerRef }) {
|
|
|
31737
31759
|
return cell ? buildLayout(editor, surface, cell) : null;
|
|
31738
31760
|
});
|
|
31739
31761
|
}, [containerRef, editor]);
|
|
31740
|
-
const clearDrag =
|
|
31762
|
+
const clearDrag = React75.useCallback(() => {
|
|
31741
31763
|
dragStateRef.current = null;
|
|
31742
31764
|
setDragPreview(null);
|
|
31743
31765
|
document.body.style.cursor = "";
|
|
31744
31766
|
}, []);
|
|
31745
|
-
const updateHoverState =
|
|
31767
|
+
const updateHoverState = React75.useCallback((event) => {
|
|
31746
31768
|
const activeLayout = layoutRef.current;
|
|
31747
31769
|
const surface = containerRef.current;
|
|
31748
31770
|
if (!activeLayout || !surface || dragStateRef.current) {
|
|
@@ -31780,7 +31802,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31780
31802
|
};
|
|
31781
31803
|
});
|
|
31782
31804
|
}, [containerRef]);
|
|
31783
|
-
|
|
31805
|
+
React75.useEffect(() => {
|
|
31784
31806
|
const proseMirror = editor.view.dom;
|
|
31785
31807
|
const surface = containerRef.current;
|
|
31786
31808
|
if (!surface) return void 0;
|
|
@@ -31825,7 +31847,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31825
31847
|
editor.off("update", refreshCurrentLayout);
|
|
31826
31848
|
};
|
|
31827
31849
|
}, [clearDrag, containerRef, editor, refreshCurrentLayout, syncFromCell, syncFromSelection, updateHoverState]);
|
|
31828
|
-
const runAtCellPos =
|
|
31850
|
+
const runAtCellPos = React75.useCallback((cellPos, command, options) => {
|
|
31829
31851
|
if (cellPos == null) return false;
|
|
31830
31852
|
focusCell(editor, cellPos);
|
|
31831
31853
|
const result = command(editor.chain().focus(null, { scrollIntoView: false })).run();
|
|
@@ -31834,17 +31856,17 @@ function TableControls({ editor, containerRef }) {
|
|
|
31834
31856
|
}
|
|
31835
31857
|
return result;
|
|
31836
31858
|
}, [editor, syncFromSelection]);
|
|
31837
|
-
const runAtActiveCell =
|
|
31859
|
+
const runAtActiveCell = React75.useCallback((command, options) => {
|
|
31838
31860
|
return runAtCellPos(layoutRef.current?.cellPos ?? null, command, options);
|
|
31839
31861
|
}, [runAtCellPos]);
|
|
31840
|
-
const getCurrentCornerCellPos =
|
|
31862
|
+
const getCurrentCornerCellPos = React75.useCallback(() => {
|
|
31841
31863
|
const activePos = layoutRef.current?.cellPos ?? editor.state.selection.from;
|
|
31842
31864
|
return getLastCellPosFromState(editor, activePos);
|
|
31843
31865
|
}, [editor]);
|
|
31844
|
-
const runAtCornerCell =
|
|
31866
|
+
const runAtCornerCell = React75.useCallback((command, options) => {
|
|
31845
31867
|
return runAtCellPos(getCurrentCornerCellPos(), command, options);
|
|
31846
31868
|
}, [getCurrentCornerCellPos, runAtCellPos]);
|
|
31847
|
-
const replaceTableAtCellPos =
|
|
31869
|
+
const replaceTableAtCellPos = React75.useCallback((cellPos, updateTable) => {
|
|
31848
31870
|
if (cellPos == null) return false;
|
|
31849
31871
|
const tableInfo = findTableInfo(editor, cellPos);
|
|
31850
31872
|
if (!tableInfo) return false;
|
|
@@ -31854,10 +31876,10 @@ function TableControls({ editor, containerRef }) {
|
|
|
31854
31876
|
requestAnimationFrame(syncFromSelection);
|
|
31855
31877
|
return true;
|
|
31856
31878
|
}, [editor, syncFromSelection]);
|
|
31857
|
-
const createEmptyCellNode =
|
|
31879
|
+
const createEmptyCellNode = React75.useCallback((cellNode) => {
|
|
31858
31880
|
return cellNode.type.createAndFill(cellNode.attrs) ?? cellNode;
|
|
31859
31881
|
}, []);
|
|
31860
|
-
const duplicateRowAt =
|
|
31882
|
+
const duplicateRowAt = React75.useCallback((rowIndex, cellPos) => {
|
|
31861
31883
|
return replaceTableAtCellPos(cellPos, (tableNode) => {
|
|
31862
31884
|
const rows = collectChildren(tableNode);
|
|
31863
31885
|
const rowNode = rows[rowIndex];
|
|
@@ -31866,7 +31888,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31866
31888
|
return tableNode.type.create(tableNode.attrs, rows);
|
|
31867
31889
|
});
|
|
31868
31890
|
}, [replaceTableAtCellPos]);
|
|
31869
|
-
const clearRowAt =
|
|
31891
|
+
const clearRowAt = React75.useCallback((rowIndex, cellPos) => {
|
|
31870
31892
|
return replaceTableAtCellPos(cellPos, (tableNode) => {
|
|
31871
31893
|
const rows = collectChildren(tableNode);
|
|
31872
31894
|
const rowNode = rows[rowIndex];
|
|
@@ -31876,7 +31898,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31876
31898
|
return tableNode.type.create(tableNode.attrs, rows);
|
|
31877
31899
|
});
|
|
31878
31900
|
}, [createEmptyCellNode, replaceTableAtCellPos]);
|
|
31879
|
-
const duplicateColumnAt =
|
|
31901
|
+
const duplicateColumnAt = React75.useCallback((columnIndex, cellPos) => {
|
|
31880
31902
|
return replaceTableAtCellPos(cellPos, (tableNode) => {
|
|
31881
31903
|
const rows = collectChildren(tableNode).map((rowNode) => {
|
|
31882
31904
|
const cells = collectChildren(rowNode);
|
|
@@ -31888,7 +31910,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31888
31910
|
return tableNode.type.create(tableNode.attrs, rows);
|
|
31889
31911
|
});
|
|
31890
31912
|
}, [replaceTableAtCellPos]);
|
|
31891
|
-
const clearColumnAt =
|
|
31913
|
+
const clearColumnAt = React75.useCallback((columnIndex, cellPos) => {
|
|
31892
31914
|
return replaceTableAtCellPos(cellPos, (tableNode) => {
|
|
31893
31915
|
const rows = collectChildren(tableNode).map((rowNode) => {
|
|
31894
31916
|
const cells = collectChildren(rowNode);
|
|
@@ -31900,7 +31922,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
31900
31922
|
return tableNode.type.create(tableNode.attrs, rows);
|
|
31901
31923
|
});
|
|
31902
31924
|
}, [createEmptyCellNode, replaceTableAtCellPos]);
|
|
31903
|
-
const expandTableBy =
|
|
31925
|
+
const expandTableBy = React75.useCallback((rows, cols) => {
|
|
31904
31926
|
let ok = true;
|
|
31905
31927
|
for (let index = 0; index < rows; index += 1) {
|
|
31906
31928
|
ok = runAtCornerCell((chain) => chain.addRowAfter(), { sync: false });
|
|
@@ -31916,9 +31938,9 @@ function TableControls({ editor, containerRef }) {
|
|
|
31916
31938
|
const canExpandTable = Boolean(layout);
|
|
31917
31939
|
const controlsVisible = dragPreview !== null;
|
|
31918
31940
|
const tableMenuOpen = openMenuKey === "table";
|
|
31919
|
-
const getRowMenuKey =
|
|
31920
|
-
const getColumnMenuKey =
|
|
31921
|
-
|
|
31941
|
+
const getRowMenuKey = React75.useCallback((index) => `row:${index}`, []);
|
|
31942
|
+
const getColumnMenuKey = React75.useCallback((index) => `column:${index}`, []);
|
|
31943
|
+
React75.useEffect(() => {
|
|
31922
31944
|
const handleMouseMove = (event) => {
|
|
31923
31945
|
const dragState = dragStateRef.current;
|
|
31924
31946
|
const activeLayout = layoutRef.current;
|
|
@@ -32005,7 +32027,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
32005
32027
|
window.removeEventListener("blur", clearDrag);
|
|
32006
32028
|
};
|
|
32007
32029
|
}, [clearDrag, containerRef, editor, expandTableBy, syncFromSelection]);
|
|
32008
|
-
const menuItems =
|
|
32030
|
+
const menuItems = React75.useMemo(() => {
|
|
32009
32031
|
if (!layout) return [];
|
|
32010
32032
|
return [
|
|
32011
32033
|
{
|
|
@@ -32073,7 +32095,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
32073
32095
|
}
|
|
32074
32096
|
];
|
|
32075
32097
|
}, [layout, runAtActiveCell, t]);
|
|
32076
|
-
const getRowHandleMenuItems =
|
|
32098
|
+
const getRowHandleMenuItems = React75.useCallback((rowHandle) => [
|
|
32077
32099
|
{
|
|
32078
32100
|
label: t("tableMenu.addRowBefore"),
|
|
32079
32101
|
icon: ArrowUp2,
|
|
@@ -32101,7 +32123,7 @@ function TableControls({ editor, containerRef }) {
|
|
|
32101
32123
|
destructive: true
|
|
32102
32124
|
}
|
|
32103
32125
|
], [clearRowAt, duplicateRowAt, runAtCellPos, t]);
|
|
32104
|
-
const getColumnHandleMenuItems =
|
|
32126
|
+
const getColumnHandleMenuItems = React75.useCallback((columnHandle) => [
|
|
32105
32127
|
{
|
|
32106
32128
|
label: t("tableMenu.addColumnBefore"),
|
|
32107
32129
|
icon: ArrowLeft2,
|
|
@@ -32650,10 +32672,10 @@ var UEDITOR_PROSEMIRROR_CLASS_NAME = cn(
|
|
|
32650
32672
|
);
|
|
32651
32673
|
|
|
32652
32674
|
// src/components/UEditor/use-table-interactions.ts
|
|
32653
|
-
import
|
|
32675
|
+
import React77, { useEffect as useEffect35, useRef as useRef33 } from "react";
|
|
32654
32676
|
|
|
32655
32677
|
// src/components/UEditor/use-table-row-resize.ts
|
|
32656
|
-
import
|
|
32678
|
+
import React76, { useRef as useRef32 } from "react";
|
|
32657
32679
|
function useTableRowResize({
|
|
32658
32680
|
editor,
|
|
32659
32681
|
setHoveredTableCell,
|
|
@@ -32664,7 +32686,7 @@ function useTableRowResize({
|
|
|
32664
32686
|
}) {
|
|
32665
32687
|
const commitFrameRef = useRef32(null);
|
|
32666
32688
|
const stateRef = useRef32(null);
|
|
32667
|
-
const commitPreview =
|
|
32689
|
+
const commitPreview = React76.useCallback(() => {
|
|
32668
32690
|
if (!editor) return;
|
|
32669
32691
|
const state = stateRef.current;
|
|
32670
32692
|
if (!state) return;
|
|
@@ -32699,22 +32721,22 @@ function useTableRowResize({
|
|
|
32699
32721
|
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
32700
32722
|
scheduleTableLayoutSync();
|
|
32701
32723
|
}, [editor, scheduleTableLayoutSync, showRowGuide]);
|
|
32702
|
-
const scheduleCommit =
|
|
32724
|
+
const scheduleCommit = React76.useCallback(() => {
|
|
32703
32725
|
if (commitFrameRef.current !== null) return;
|
|
32704
32726
|
commitFrameRef.current = window.requestAnimationFrame(() => {
|
|
32705
32727
|
commitFrameRef.current = null;
|
|
32706
32728
|
commitPreview();
|
|
32707
32729
|
});
|
|
32708
32730
|
}, [commitPreview]);
|
|
32709
|
-
const syncActiveGuide =
|
|
32731
|
+
const syncActiveGuide = React76.useCallback(() => {
|
|
32710
32732
|
const state = stateRef.current;
|
|
32711
32733
|
if (!state) return false;
|
|
32712
32734
|
setHoveredTableCell(state.cellElement);
|
|
32713
32735
|
showRowGuide(state.tableElement, state.rowElement, state.cellElement);
|
|
32714
32736
|
return true;
|
|
32715
32737
|
}, [setHoveredTableCell, showRowGuide]);
|
|
32716
|
-
const isResizing =
|
|
32717
|
-
const beginResize =
|
|
32738
|
+
const isResizing = React76.useCallback(() => stateRef.current !== null, []);
|
|
32739
|
+
const beginResize = React76.useCallback((event, table, row, cell) => {
|
|
32718
32740
|
if (!editor || !isRowResizeHotspot(cell, event.clientX, event.clientY)) {
|
|
32719
32741
|
return false;
|
|
32720
32742
|
}
|
|
@@ -32740,7 +32762,7 @@ function useTableRowResize({
|
|
|
32740
32762
|
event.stopPropagation();
|
|
32741
32763
|
return true;
|
|
32742
32764
|
}, [editor, setHoveredTableCell, showRowGuide]);
|
|
32743
|
-
const handlePointerMove =
|
|
32765
|
+
const handlePointerMove = React76.useCallback((event) => {
|
|
32744
32766
|
const state = stateRef.current;
|
|
32745
32767
|
if (!state) return;
|
|
32746
32768
|
const nextHeight = Math.max(
|
|
@@ -32756,7 +32778,7 @@ function useTableRowResize({
|
|
|
32756
32778
|
document.body.style.cursor = "row-resize";
|
|
32757
32779
|
scheduleCommit();
|
|
32758
32780
|
}, [scheduleCommit, showRowGuide]);
|
|
32759
|
-
const handlePointerUp =
|
|
32781
|
+
const handlePointerUp = React76.useCallback((event) => {
|
|
32760
32782
|
if (!editor) return;
|
|
32761
32783
|
const state = stateRef.current;
|
|
32762
32784
|
if (!state) return;
|
|
@@ -32786,7 +32808,7 @@ function useTableRowResize({
|
|
|
32786
32808
|
clearAllTableResizeHover();
|
|
32787
32809
|
scheduleTableLayoutSync();
|
|
32788
32810
|
}, [clearAllTableResizeHover, clearHoveredTableCell, commitPreview, editor, scheduleTableLayoutSync]);
|
|
32789
|
-
const cancelResize =
|
|
32811
|
+
const cancelResize = React76.useCallback(() => {
|
|
32790
32812
|
if (!stateRef.current) return;
|
|
32791
32813
|
if (commitFrameRef.current !== null) {
|
|
32792
32814
|
window.cancelAnimationFrame(commitFrameRef.current);
|
|
@@ -32798,7 +32820,7 @@ function useTableRowResize({
|
|
|
32798
32820
|
clearAllTableResizeHover();
|
|
32799
32821
|
scheduleTableLayoutSync();
|
|
32800
32822
|
}, [clearAllTableResizeHover, clearHoveredTableCell, scheduleTableLayoutSync]);
|
|
32801
|
-
const cleanup =
|
|
32823
|
+
const cleanup = React76.useCallback(() => {
|
|
32802
32824
|
if (commitFrameRef.current !== null) {
|
|
32803
32825
|
window.cancelAnimationFrame(commitFrameRef.current);
|
|
32804
32826
|
commitFrameRef.current = null;
|
|
@@ -32818,7 +32840,7 @@ function useTableRowResize({
|
|
|
32818
32840
|
}
|
|
32819
32841
|
|
|
32820
32842
|
// src/components/UEditor/use-table-interactions.ts
|
|
32821
|
-
function useUEditorTableInteractions(editor) {
|
|
32843
|
+
function useUEditorTableInteractions(editor, editable = true) {
|
|
32822
32844
|
const editorContentRef = useRef33(null);
|
|
32823
32845
|
const tableColumnGuideRef = useRef33(null);
|
|
32824
32846
|
const tableRowGuideRef = useRef33(null);
|
|
@@ -32827,32 +32849,32 @@ function useUEditorTableInteractions(editor) {
|
|
|
32827
32849
|
const activeTableCellRef = useRef33(null);
|
|
32828
32850
|
const suppressActiveCellHighlightRef = useRef33(false);
|
|
32829
32851
|
const tableLayoutSyncFrameRef = useRef33(null);
|
|
32830
|
-
const setEditorResizeCursor =
|
|
32852
|
+
const setEditorResizeCursor = React77.useCallback((cursor) => {
|
|
32831
32853
|
const proseMirror = editorContentRef.current?.querySelector(".ProseMirror");
|
|
32832
32854
|
if (proseMirror) {
|
|
32833
32855
|
proseMirror.style.cursor = cursor;
|
|
32834
32856
|
}
|
|
32835
32857
|
}, []);
|
|
32836
|
-
const hideColumnGuide =
|
|
32858
|
+
const hideColumnGuide = React77.useCallback(() => {
|
|
32837
32859
|
editorContentRef.current?.classList.remove("resize-cursor");
|
|
32838
32860
|
const guide = tableColumnGuideRef.current;
|
|
32839
32861
|
if (guide) {
|
|
32840
32862
|
guide.style.opacity = "0";
|
|
32841
32863
|
}
|
|
32842
32864
|
}, []);
|
|
32843
|
-
const hideRowGuide =
|
|
32865
|
+
const hideRowGuide = React77.useCallback(() => {
|
|
32844
32866
|
editorContentRef.current?.classList.remove("resize-row-cursor");
|
|
32845
32867
|
const guide = tableRowGuideRef.current;
|
|
32846
32868
|
if (guide) {
|
|
32847
32869
|
guide.style.opacity = "0";
|
|
32848
32870
|
}
|
|
32849
32871
|
}, []);
|
|
32850
|
-
const clearAllTableResizeHover =
|
|
32872
|
+
const clearAllTableResizeHover = React77.useCallback(() => {
|
|
32851
32873
|
setEditorResizeCursor("");
|
|
32852
32874
|
hideColumnGuide();
|
|
32853
32875
|
hideRowGuide();
|
|
32854
32876
|
}, [hideColumnGuide, hideRowGuide, setEditorResizeCursor]);
|
|
32855
|
-
const updateActiveCellHighlight =
|
|
32877
|
+
const updateActiveCellHighlight = React77.useCallback((cell) => {
|
|
32856
32878
|
const surface = editorContentRef.current;
|
|
32857
32879
|
const highlight = activeTableCellHighlightRef.current;
|
|
32858
32880
|
if (!highlight) return;
|
|
@@ -32867,7 +32889,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32867
32889
|
highlight.style.width = `${metrics.width}px`;
|
|
32868
32890
|
highlight.style.height = `${metrics.height}px`;
|
|
32869
32891
|
}, []);
|
|
32870
|
-
const scheduleTableLayoutSync =
|
|
32892
|
+
const scheduleTableLayoutSync = React77.useCallback(() => {
|
|
32871
32893
|
if (tableLayoutSyncFrameRef.current !== null) return;
|
|
32872
32894
|
tableLayoutSyncFrameRef.current = window.requestAnimationFrame(() => {
|
|
32873
32895
|
tableLayoutSyncFrameRef.current = null;
|
|
@@ -32875,22 +32897,22 @@ function useUEditorTableInteractions(editor) {
|
|
|
32875
32897
|
editorContentRef.current?.dispatchEvent(new CustomEvent(UEDITOR_TABLE_LAYOUT_CHANGE_EVENT));
|
|
32876
32898
|
});
|
|
32877
32899
|
}, [updateActiveCellHighlight]);
|
|
32878
|
-
const setActiveTableCell =
|
|
32900
|
+
const setActiveTableCell = React77.useCallback((cell) => {
|
|
32879
32901
|
if (activeTableCellRef.current === cell) return;
|
|
32880
32902
|
activeTableCellRef.current = cell;
|
|
32881
32903
|
updateActiveCellHighlight(activeTableCellRef.current);
|
|
32882
32904
|
}, [updateActiveCellHighlight]);
|
|
32883
|
-
const clearActiveTableCell =
|
|
32905
|
+
const clearActiveTableCell = React77.useCallback(() => {
|
|
32884
32906
|
activeTableCellRef.current = null;
|
|
32885
32907
|
updateActiveCellHighlight(null);
|
|
32886
32908
|
}, [updateActiveCellHighlight]);
|
|
32887
|
-
const setHoveredTableCell =
|
|
32909
|
+
const setHoveredTableCell = React77.useCallback((cell) => {
|
|
32888
32910
|
hoveredTableCellRef.current = cell;
|
|
32889
32911
|
}, []);
|
|
32890
|
-
const clearHoveredTableCell =
|
|
32912
|
+
const clearHoveredTableCell = React77.useCallback(() => {
|
|
32891
32913
|
hoveredTableCellRef.current = null;
|
|
32892
32914
|
}, []);
|
|
32893
|
-
const showColumnGuide =
|
|
32915
|
+
const showColumnGuide = React77.useCallback((table, row, cell) => {
|
|
32894
32916
|
const surface = editorContentRef.current;
|
|
32895
32917
|
const guide = tableColumnGuideRef.current;
|
|
32896
32918
|
if (!surface || !guide) return;
|
|
@@ -32903,7 +32925,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
32903
32925
|
surface.classList.add("resize-cursor");
|
|
32904
32926
|
setEditorResizeCursor("col-resize");
|
|
32905
32927
|
}, [setEditorResizeCursor]);
|
|
32906
|
-
const showRowGuide =
|
|
32928
|
+
const showRowGuide = React77.useCallback((table, row, cell) => {
|
|
32907
32929
|
const surface = editorContentRef.current;
|
|
32908
32930
|
const guide = tableRowGuideRef.current;
|
|
32909
32931
|
if (!surface || !guide) return;
|
|
@@ -32932,12 +32954,12 @@ function useUEditorTableInteractions(editor) {
|
|
|
32932
32954
|
clearAllTableResizeHover,
|
|
32933
32955
|
scheduleTableLayoutSync
|
|
32934
32956
|
});
|
|
32935
|
-
const syncActiveTableCellFromSelection =
|
|
32957
|
+
const syncActiveTableCellFromSelection = React77.useCallback(() => {
|
|
32936
32958
|
if (!editor) return;
|
|
32937
32959
|
setActiveTableCell(getSelectionTableCell(editor.view));
|
|
32938
32960
|
}, [editor, setActiveTableCell]);
|
|
32939
32961
|
useEffect35(() => {
|
|
32940
|
-
if (!editor) return void 0;
|
|
32962
|
+
if (!editor || !editable) return void 0;
|
|
32941
32963
|
const proseMirror = editor.view.dom;
|
|
32942
32964
|
const surface = editorContentRef.current;
|
|
32943
32965
|
let selectionSyncTimeoutId = 0;
|
|
@@ -33086,7 +33108,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
33086
33108
|
clearHoveredTableCell();
|
|
33087
33109
|
clearAllTableResizeHover();
|
|
33088
33110
|
};
|
|
33089
|
-
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
33111
|
+
}, [beginResize, cancelResize, cleanupRowResize, clearActiveTableCell, clearAllTableResizeHover, clearHoveredTableCell, editable, editor, handleRowResizePointerMove, handleRowResizePointerUp, hideColumnGuide, hideRowGuide, isRowResizing, showColumnGuide, showRowGuide, syncActiveRowResizeGuide, syncActiveTableCellFromSelection, updateActiveCellHighlight]);
|
|
33090
33112
|
return {
|
|
33091
33113
|
editorContentRef,
|
|
33092
33114
|
tableColumnGuideRef,
|
|
@@ -33097,7 +33119,7 @@ function useUEditorTableInteractions(editor) {
|
|
|
33097
33119
|
|
|
33098
33120
|
// src/components/UEditor/UEditor.tsx
|
|
33099
33121
|
import { jsx as jsx84, jsxs as jsxs71 } from "react/jsx-runtime";
|
|
33100
|
-
var UEditor =
|
|
33122
|
+
var UEditor = React78.forwardRef(({
|
|
33101
33123
|
content = "",
|
|
33102
33124
|
onChange,
|
|
33103
33125
|
onHtmlChange,
|
|
@@ -33189,7 +33211,7 @@ var UEditor = React77.forwardRef(({
|
|
|
33189
33211
|
tableColumnGuideRef,
|
|
33190
33212
|
tableRowGuideRef,
|
|
33191
33213
|
activeTableCellHighlightRef
|
|
33192
|
-
} = useUEditorTableInteractions(editor);
|
|
33214
|
+
} = useUEditorTableInteractions(editor, editable);
|
|
33193
33215
|
useImperativeHandle3(
|
|
33194
33216
|
ref,
|
|
33195
33217
|
() => ({
|
|
@@ -33236,11 +33258,14 @@ var UEditor = React77.forwardRef(({
|
|
|
33236
33258
|
"div",
|
|
33237
33259
|
{
|
|
33238
33260
|
className: cn(
|
|
33239
|
-
"group relative flex flex-col
|
|
33240
|
-
|
|
33241
|
-
|
|
33242
|
-
|
|
33243
|
-
|
|
33261
|
+
"group relative flex flex-col text-card-foreground",
|
|
33262
|
+
editable ? [
|
|
33263
|
+
"rounded-2xl md:rounded-3xl border border-border/50 bg-card overflow-hidden",
|
|
33264
|
+
"transition-[transform,box-shadow,border-color,background-color] duration-300 ease-soft",
|
|
33265
|
+
"shadow-sm focus-within:shadow-md focus-within:border-primary/15",
|
|
33266
|
+
"backdrop-blur-sm",
|
|
33267
|
+
variant === "notion" && "hover:shadow-md"
|
|
33268
|
+
] : "rounded-none",
|
|
33244
33269
|
className
|
|
33245
33270
|
),
|
|
33246
33271
|
children: [
|
|
@@ -33274,7 +33299,7 @@ var UEditor = React77.forwardRef(({
|
|
|
33274
33299
|
ref: editorContentRef,
|
|
33275
33300
|
className: "relative flex-1 overflow-y-auto",
|
|
33276
33301
|
style: {
|
|
33277
|
-
minHeight,
|
|
33302
|
+
minHeight: editable ? minHeight : void 0,
|
|
33278
33303
|
maxHeight
|
|
33279
33304
|
},
|
|
33280
33305
|
children: [
|