@underverse-ui/underverse 1.0.124 → 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 +560 -538
- 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 +752 -730
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4687,6 +4687,9 @@ var Label = React14.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
4687
4687
|
));
|
|
4688
4688
|
Label.displayName = "Label";
|
|
4689
4689
|
|
|
4690
|
+
// src/components/Avatar.tsx
|
|
4691
|
+
var React16 = __toESM(require("react"), 1);
|
|
4692
|
+
|
|
4690
4693
|
// src/components/SmartImage.tsx
|
|
4691
4694
|
var import_image = __toESM(require("next/image"), 1);
|
|
4692
4695
|
var import_react8 = __toESM(require("react"), 1);
|
|
@@ -4708,55 +4711,55 @@ function SmartImage({
|
|
|
4708
4711
|
quality = 80,
|
|
4709
4712
|
fit = "cover",
|
|
4710
4713
|
objectPosition,
|
|
4711
|
-
fallbackSrc = DEFAULT_FALLBACK
|
|
4714
|
+
fallbackSrc = DEFAULT_FALLBACK,
|
|
4715
|
+
transition = false,
|
|
4716
|
+
unoptimized = false
|
|
4712
4717
|
}) {
|
|
4713
|
-
const normalize2 = (
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4718
|
+
const normalize2 = import_react8.default.useCallback(
|
|
4719
|
+
(input) => {
|
|
4720
|
+
if (!input || input.length === 0) return fallbackSrc;
|
|
4721
|
+
const raw = input.trim();
|
|
4722
|
+
if (raw.startsWith("/images/products/") && /\.(jpg|jpeg)($|\?)/i.test(raw)) {
|
|
4723
|
+
return raw.replace(/\.(jpg|jpeg)(?=$|\?)/i, ".png");
|
|
4724
|
+
}
|
|
4725
|
+
if (raw.startsWith("//")) {
|
|
4726
|
+
return `https:${raw}`;
|
|
4727
|
+
}
|
|
4728
|
+
if (/^(https?:|data:|blob:)/i.test(raw)) {
|
|
4729
|
+
return FAILED_SRCS.has(raw) ? fallbackSrc : raw;
|
|
4730
|
+
}
|
|
4731
|
+
if (raw.startsWith("/")) {
|
|
4732
|
+
return FAILED_SRCS.has(raw) ? fallbackSrc : raw;
|
|
4733
|
+
}
|
|
4734
|
+
const normalized = `/${raw.replace(/^\.\/?/, "")}`;
|
|
4735
|
+
return FAILED_SRCS.has(normalized) ? fallbackSrc : normalized;
|
|
4736
|
+
},
|
|
4737
|
+
[fallbackSrc]
|
|
4738
|
+
);
|
|
4731
4739
|
const [resolvedSrc, setResolvedSrc] = import_react8.default.useState(() => normalize2(src));
|
|
4732
4740
|
import_react8.default.useEffect(() => {
|
|
4733
|
-
|
|
4734
|
-
|
|
4741
|
+
const next = normalize2(src);
|
|
4742
|
+
setResolvedSrc((current) => current === next ? current : next);
|
|
4743
|
+
}, [normalize2, src]);
|
|
4735
4744
|
const handleError = () => {
|
|
4736
4745
|
if (resolvedSrc && resolvedSrc !== fallbackSrc) FAILED_SRCS.add(resolvedSrc);
|
|
4737
|
-
if (
|
|
4738
|
-
const next = resolvedSrc.replace(/\.jpg(
|
|
4746
|
+
if (/\.(jpg|jpeg)(\?.*)?$/i.test(resolvedSrc)) {
|
|
4747
|
+
const next = resolvedSrc.replace(/\.(jpg|jpeg)(?=$|\?)/i, ".png");
|
|
4739
4748
|
setResolvedSrc(next);
|
|
4740
4749
|
} else if (resolvedSrc !== fallbackSrc) {
|
|
4741
4750
|
setResolvedSrc(fallbackSrc);
|
|
4742
4751
|
}
|
|
4743
4752
|
};
|
|
4744
|
-
const
|
|
4745
|
-
"
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0",
|
|
4751
|
-
ratioClass,
|
|
4752
|
-
roundedClass,
|
|
4753
|
-
className
|
|
4754
|
-
),
|
|
4755
|
-
children
|
|
4756
|
-
}
|
|
4753
|
+
const wrapperClass = cn(
|
|
4754
|
+
"relative overflow-hidden bg-muted/30",
|
|
4755
|
+
"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0",
|
|
4756
|
+
ratioClass,
|
|
4757
|
+
roundedClass,
|
|
4758
|
+
className
|
|
4757
4759
|
);
|
|
4760
|
+
const imgClass = cn(transition ? "transition-opacity duration-300" : "transition-none", imageClassName);
|
|
4758
4761
|
if (fill) {
|
|
4759
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4762
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: wrapperClass, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
4760
4763
|
import_image.default,
|
|
4761
4764
|
{
|
|
4762
4765
|
src: resolvedSrc,
|
|
@@ -4766,8 +4769,9 @@ function SmartImage({
|
|
|
4766
4769
|
onError: handleError,
|
|
4767
4770
|
priority,
|
|
4768
4771
|
quality,
|
|
4772
|
+
unoptimized,
|
|
4769
4773
|
style: { objectFit: fit, objectPosition },
|
|
4770
|
-
className:
|
|
4774
|
+
className: imgClass
|
|
4771
4775
|
}
|
|
4772
4776
|
) });
|
|
4773
4777
|
}
|
|
@@ -4791,8 +4795,9 @@ function SmartImage({
|
|
|
4791
4795
|
onError: handleError,
|
|
4792
4796
|
priority,
|
|
4793
4797
|
quality,
|
|
4798
|
+
unoptimized,
|
|
4794
4799
|
style: { objectFit: fit, objectPosition, width: "100%", height: "100%" },
|
|
4795
|
-
className:
|
|
4800
|
+
className: imgClass
|
|
4796
4801
|
}
|
|
4797
4802
|
)
|
|
4798
4803
|
}
|
|
@@ -4820,7 +4825,7 @@ var statusDotSizes = {
|
|
|
4820
4825
|
lg: "w-4 h-4 border-2",
|
|
4821
4826
|
xl: "w-5 h-5 border-[3px]"
|
|
4822
4827
|
};
|
|
4823
|
-
var Avatar = ({
|
|
4828
|
+
var Avatar = React16.memo(function Avatar2({
|
|
4824
4829
|
src,
|
|
4825
4830
|
alt = "avatar",
|
|
4826
4831
|
fallback = "?",
|
|
@@ -4828,11 +4833,15 @@ var Avatar = ({
|
|
|
4828
4833
|
showStatus = true,
|
|
4829
4834
|
status = "online",
|
|
4830
4835
|
hideStatusOnHover = true,
|
|
4836
|
+
imageStrategy = "img",
|
|
4837
|
+
imageLoading = "lazy",
|
|
4838
|
+
imageFetchPriority,
|
|
4831
4839
|
className,
|
|
4832
4840
|
onClick,
|
|
4833
4841
|
...props
|
|
4834
|
-
})
|
|
4842
|
+
}) {
|
|
4835
4843
|
const hasValidSrc = !!(src && src.trim().length > 0);
|
|
4844
|
+
const fallbackText = (fallback || "?").trim().charAt(0).toUpperCase() || "?";
|
|
4836
4845
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
4837
4846
|
"div",
|
|
4838
4847
|
{
|
|
@@ -4846,7 +4855,19 @@ var Avatar = ({
|
|
|
4846
4855
|
...props,
|
|
4847
4856
|
children: [
|
|
4848
4857
|
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "absolute inset-0 overflow-hidden rounded-full", children: [
|
|
4849
|
-
hasValidSrc && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4858
|
+
hasValidSrc && imageStrategy === "img" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4859
|
+
"img",
|
|
4860
|
+
{
|
|
4861
|
+
src,
|
|
4862
|
+
alt,
|
|
4863
|
+
loading: imageLoading,
|
|
4864
|
+
decoding: "async",
|
|
4865
|
+
draggable: false,
|
|
4866
|
+
fetchPriority: imageFetchPriority,
|
|
4867
|
+
className: "h-full w-full object-cover"
|
|
4868
|
+
}
|
|
4869
|
+
),
|
|
4870
|
+
hasValidSrc && imageStrategy === "next-image" && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
4850
4871
|
SmartImage,
|
|
4851
4872
|
{
|
|
4852
4873
|
src,
|
|
@@ -4857,7 +4878,8 @@ var Avatar = ({
|
|
|
4857
4878
|
roundedClass: "rounded-full",
|
|
4858
4879
|
fit: "cover",
|
|
4859
4880
|
objectPosition: "center",
|
|
4860
|
-
quality: 80
|
|
4881
|
+
quality: 80,
|
|
4882
|
+
imageClassName: "transition-none"
|
|
4861
4883
|
}
|
|
4862
4884
|
),
|
|
4863
4885
|
!hasValidSrc && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
@@ -4867,7 +4889,7 @@ var Avatar = ({
|
|
|
4867
4889
|
"font-bold uppercase bg-linear-to-br from-primary to-primary/80 bg-clip-text text-transparent",
|
|
4868
4890
|
"transition-all duration-200 animate-fade-in"
|
|
4869
4891
|
),
|
|
4870
|
-
children:
|
|
4892
|
+
children: fallbackText
|
|
4871
4893
|
}
|
|
4872
4894
|
) })
|
|
4873
4895
|
] }),
|
|
@@ -4886,7 +4908,7 @@ var Avatar = ({
|
|
|
4886
4908
|
]
|
|
4887
4909
|
}
|
|
4888
4910
|
);
|
|
4889
|
-
};
|
|
4911
|
+
});
|
|
4890
4912
|
var Avatar_default = Avatar;
|
|
4891
4913
|
|
|
4892
4914
|
// src/components/Skeleton.tsx
|
|
@@ -5382,7 +5404,7 @@ var LoadingProgress = ({
|
|
|
5382
5404
|
};
|
|
5383
5405
|
|
|
5384
5406
|
// src/components/Modal.tsx
|
|
5385
|
-
var
|
|
5407
|
+
var React18 = __toESM(require("react"), 1);
|
|
5386
5408
|
var import_react_dom2 = require("react-dom");
|
|
5387
5409
|
var import_lucide_react7 = require("lucide-react");
|
|
5388
5410
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
@@ -5412,17 +5434,17 @@ var Modal = ({
|
|
|
5412
5434
|
height
|
|
5413
5435
|
}) => {
|
|
5414
5436
|
const gi18n = useGlobalI18n();
|
|
5415
|
-
const [isMounted, setIsMounted] =
|
|
5416
|
-
const [isVisible, setIsVisible] =
|
|
5417
|
-
const [isAnimating, setIsAnimating] =
|
|
5418
|
-
const mouseDownTarget =
|
|
5419
|
-
const modalContentRef =
|
|
5420
|
-
|
|
5437
|
+
const [isMounted, setIsMounted] = React18.useState(false);
|
|
5438
|
+
const [isVisible, setIsVisible] = React18.useState(false);
|
|
5439
|
+
const [isAnimating, setIsAnimating] = React18.useState(true);
|
|
5440
|
+
const mouseDownTarget = React18.useRef(null);
|
|
5441
|
+
const modalContentRef = React18.useRef(null);
|
|
5442
|
+
React18.useEffect(() => {
|
|
5421
5443
|
setIsMounted(true);
|
|
5422
5444
|
return () => setIsMounted(false);
|
|
5423
5445
|
}, []);
|
|
5424
|
-
const animationRef =
|
|
5425
|
-
|
|
5446
|
+
const animationRef = React18.useRef(false);
|
|
5447
|
+
React18.useEffect(() => {
|
|
5426
5448
|
if (isOpen) {
|
|
5427
5449
|
if (animationRef.current) return;
|
|
5428
5450
|
animationRef.current = true;
|
|
@@ -5442,7 +5464,7 @@ var Modal = ({
|
|
|
5442
5464
|
}
|
|
5443
5465
|
}
|
|
5444
5466
|
}, [isOpen, isVisible]);
|
|
5445
|
-
|
|
5467
|
+
React18.useEffect(() => {
|
|
5446
5468
|
if (!isOpen || !closeOnEsc) return;
|
|
5447
5469
|
const handleEscape = (event) => {
|
|
5448
5470
|
if (event.key === "Escape") {
|
|
@@ -5452,7 +5474,7 @@ var Modal = ({
|
|
|
5452
5474
|
document.addEventListener("keydown", handleEscape);
|
|
5453
5475
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
5454
5476
|
}, [isOpen, closeOnEsc, onClose]);
|
|
5455
|
-
|
|
5477
|
+
React18.useEffect(() => {
|
|
5456
5478
|
if (isOpen) {
|
|
5457
5479
|
document.body.style.overflow = "hidden";
|
|
5458
5480
|
} else {
|
|
@@ -5738,7 +5760,7 @@ var ToastComponent = ({ toast, onRemove }) => {
|
|
|
5738
5760
|
var Toast_default = ToastProvider;
|
|
5739
5761
|
|
|
5740
5762
|
// src/components/Popover.tsx
|
|
5741
|
-
var
|
|
5763
|
+
var React20 = __toESM(require("react"), 1);
|
|
5742
5764
|
var import_react_dom3 = require("react-dom");
|
|
5743
5765
|
|
|
5744
5766
|
// src/utils/animations.ts
|
|
@@ -6028,14 +6050,14 @@ var Popover = ({
|
|
|
6028
6050
|
contentWidth
|
|
6029
6051
|
}) => {
|
|
6030
6052
|
const isControlled = open !== void 0;
|
|
6031
|
-
const [internalOpen, setInternalOpen] =
|
|
6032
|
-
const triggerRef =
|
|
6033
|
-
const positionerRef =
|
|
6034
|
-
const panelRef =
|
|
6035
|
-
const lastAppliedRef =
|
|
6053
|
+
const [internalOpen, setInternalOpen] = React20.useState(false);
|
|
6054
|
+
const triggerRef = React20.useRef(null);
|
|
6055
|
+
const positionerRef = React20.useRef(null);
|
|
6056
|
+
const panelRef = React20.useRef(null);
|
|
6057
|
+
const lastAppliedRef = React20.useRef(null);
|
|
6036
6058
|
useShadCNAnimations();
|
|
6037
6059
|
const isOpen = isControlled ? open : internalOpen;
|
|
6038
|
-
const setIsOpen =
|
|
6060
|
+
const setIsOpen = React20.useCallback(
|
|
6039
6061
|
(next) => {
|
|
6040
6062
|
if (!isControlled) setInternalOpen(next);
|
|
6041
6063
|
onOpenChange?.(next);
|
|
@@ -6044,16 +6066,16 @@ var Popover = ({
|
|
|
6044
6066
|
);
|
|
6045
6067
|
const offset = 4;
|
|
6046
6068
|
const padding = 8;
|
|
6047
|
-
const triggerSelector =
|
|
6048
|
-
const initialPlacement =
|
|
6049
|
-
|
|
6069
|
+
const triggerSelector = React20.useId();
|
|
6070
|
+
const initialPlacement = React20.useMemo(() => normalizePlacement(placement), [placement]);
|
|
6071
|
+
React20.useLayoutEffect(() => {
|
|
6050
6072
|
if (typeof document === "undefined") return;
|
|
6051
6073
|
const triggerEl = document.querySelector(`[data-underverse-popover-trigger="${triggerSelector}"]`);
|
|
6052
6074
|
if (triggerEl) {
|
|
6053
6075
|
triggerRef.current = triggerEl;
|
|
6054
6076
|
}
|
|
6055
6077
|
}, [triggerSelector, trigger]);
|
|
6056
|
-
const updatePosition =
|
|
6078
|
+
const updatePosition = React20.useCallback(() => {
|
|
6057
6079
|
const triggerEl = triggerRef.current;
|
|
6058
6080
|
const positionerEl = positionerRef.current;
|
|
6059
6081
|
const panelEl = panelRef.current;
|
|
@@ -6090,7 +6112,7 @@ var Popover = ({
|
|
|
6090
6112
|
if (positionerEl.style.visibility !== "visible") positionerEl.style.visibility = "visible";
|
|
6091
6113
|
if (positionerEl.style.pointerEvents !== "auto") positionerEl.style.pointerEvents = "auto";
|
|
6092
6114
|
}, [placement, matchTriggerWidth, contentWidth]);
|
|
6093
|
-
|
|
6115
|
+
React20.useLayoutEffect(() => {
|
|
6094
6116
|
if (!isOpen) return;
|
|
6095
6117
|
updatePosition();
|
|
6096
6118
|
let raf1 = 0;
|
|
@@ -6104,7 +6126,7 @@ var Popover = ({
|
|
|
6104
6126
|
cancelAnimationFrame(raf2);
|
|
6105
6127
|
};
|
|
6106
6128
|
}, [isOpen, updatePosition]);
|
|
6107
|
-
|
|
6129
|
+
React20.useEffect(() => {
|
|
6108
6130
|
if (!isOpen) return;
|
|
6109
6131
|
let raf = 0;
|
|
6110
6132
|
const tick = () => {
|
|
@@ -6114,7 +6136,7 @@ var Popover = ({
|
|
|
6114
6136
|
raf = window.requestAnimationFrame(tick);
|
|
6115
6137
|
return () => window.cancelAnimationFrame(raf);
|
|
6116
6138
|
}, [isOpen, updatePosition]);
|
|
6117
|
-
|
|
6139
|
+
React20.useEffect(() => {
|
|
6118
6140
|
if (!isOpen) return;
|
|
6119
6141
|
let raf = 0;
|
|
6120
6142
|
const handler = () => {
|
|
@@ -6132,7 +6154,7 @@ var Popover = ({
|
|
|
6132
6154
|
document.removeEventListener("scroll", handler, true);
|
|
6133
6155
|
};
|
|
6134
6156
|
}, [isOpen, updatePosition]);
|
|
6135
|
-
|
|
6157
|
+
React20.useEffect(() => {
|
|
6136
6158
|
if (!isOpen) return;
|
|
6137
6159
|
if (typeof ResizeObserver === "undefined") return;
|
|
6138
6160
|
const ro = new ResizeObserver(() => updatePosition());
|
|
@@ -6140,13 +6162,13 @@ var Popover = ({
|
|
|
6140
6162
|
if (triggerRef.current) ro.observe(triggerRef.current);
|
|
6141
6163
|
return () => ro.disconnect();
|
|
6142
6164
|
}, [isOpen, updatePosition]);
|
|
6143
|
-
|
|
6165
|
+
React20.useLayoutEffect(() => {
|
|
6144
6166
|
if (!isOpen) {
|
|
6145
6167
|
lastAppliedRef.current = null;
|
|
6146
6168
|
return;
|
|
6147
6169
|
}
|
|
6148
6170
|
}, [isOpen]);
|
|
6149
|
-
|
|
6171
|
+
React20.useEffect(() => {
|
|
6150
6172
|
if (!isOpen) return;
|
|
6151
6173
|
const handleClickOutside = (event) => {
|
|
6152
6174
|
const target = event.target;
|
|
@@ -6232,7 +6254,7 @@ var Popover = ({
|
|
|
6232
6254
|
(() => {
|
|
6233
6255
|
const triggerProps = trigger.props;
|
|
6234
6256
|
const childRef = triggerProps.ref;
|
|
6235
|
-
return
|
|
6257
|
+
return React20.cloneElement(trigger, {
|
|
6236
6258
|
...triggerProps,
|
|
6237
6259
|
ref: mergeRefs(childRef, (node) => {
|
|
6238
6260
|
triggerRef.current = node;
|
|
@@ -6262,7 +6284,7 @@ var Popover = ({
|
|
|
6262
6284
|
};
|
|
6263
6285
|
|
|
6264
6286
|
// src/components/Sheet.tsx
|
|
6265
|
-
var
|
|
6287
|
+
var React21 = __toESM(require("react"), 1);
|
|
6266
6288
|
var import_react_dom4 = require("react-dom");
|
|
6267
6289
|
var import_lucide_react9 = require("lucide-react");
|
|
6268
6290
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
@@ -6348,19 +6370,19 @@ var Sheet = ({
|
|
|
6348
6370
|
onResize
|
|
6349
6371
|
}) => {
|
|
6350
6372
|
const gi18n = useGlobalI18n();
|
|
6351
|
-
const [mounted, setMounted] =
|
|
6352
|
-
const [isAnimating, setIsAnimating] =
|
|
6353
|
-
const [isVisible, setIsVisible] =
|
|
6354
|
-
const [isResizing, setIsResizing] =
|
|
6355
|
-
const [sheetSize, setSheetSize] =
|
|
6356
|
-
const sheetRef =
|
|
6357
|
-
const resizeStateRef =
|
|
6373
|
+
const [mounted, setMounted] = React21.useState(false);
|
|
6374
|
+
const [isAnimating, setIsAnimating] = React21.useState(true);
|
|
6375
|
+
const [isVisible, setIsVisible] = React21.useState(false);
|
|
6376
|
+
const [isResizing, setIsResizing] = React21.useState(false);
|
|
6377
|
+
const [sheetSize, setSheetSize] = React21.useState(null);
|
|
6378
|
+
const sheetRef = React21.useRef(null);
|
|
6379
|
+
const resizeStateRef = React21.useRef(null);
|
|
6358
6380
|
const isHorizontalSheet = side === "left" || side === "right";
|
|
6359
6381
|
const canResize = resizable && size !== "full";
|
|
6360
|
-
|
|
6382
|
+
React21.useEffect(() => {
|
|
6361
6383
|
setMounted(true);
|
|
6362
6384
|
}, []);
|
|
6363
|
-
|
|
6385
|
+
React21.useEffect(() => {
|
|
6364
6386
|
if (!closeOnEscape) return;
|
|
6365
6387
|
const handleEscape = (e) => {
|
|
6366
6388
|
if (e.key === "Escape" && open) {
|
|
@@ -6370,7 +6392,7 @@ var Sheet = ({
|
|
|
6370
6392
|
document.addEventListener("keydown", handleEscape);
|
|
6371
6393
|
return () => document.removeEventListener("keydown", handleEscape);
|
|
6372
6394
|
}, [open, closeOnEscape, onOpenChange]);
|
|
6373
|
-
|
|
6395
|
+
React21.useEffect(() => {
|
|
6374
6396
|
if (open) {
|
|
6375
6397
|
document.body.style.overflow = "hidden";
|
|
6376
6398
|
} else {
|
|
@@ -6380,7 +6402,7 @@ var Sheet = ({
|
|
|
6380
6402
|
document.body.style.overflow = "unset";
|
|
6381
6403
|
};
|
|
6382
6404
|
}, [open]);
|
|
6383
|
-
|
|
6405
|
+
React21.useEffect(() => {
|
|
6384
6406
|
if (open) {
|
|
6385
6407
|
setIsVisible(true);
|
|
6386
6408
|
setIsAnimating(true);
|
|
@@ -6403,19 +6425,19 @@ var Sheet = ({
|
|
|
6403
6425
|
const handleClose = () => {
|
|
6404
6426
|
onOpenChange(false);
|
|
6405
6427
|
};
|
|
6406
|
-
const clampResizeSize =
|
|
6428
|
+
const clampResizeSize = React21.useCallback((nextSize) => {
|
|
6407
6429
|
const viewportSize = isHorizontalSheet ? window.innerWidth : window.innerHeight;
|
|
6408
6430
|
const resolvedMaxSize = maxSize ?? Math.round(viewportSize * 0.9);
|
|
6409
6431
|
return Math.min(Math.max(nextSize, minSize), resolvedMaxSize);
|
|
6410
6432
|
}, [isHorizontalSheet, maxSize, minSize]);
|
|
6411
|
-
const endResize =
|
|
6433
|
+
const endResize = React21.useCallback(() => {
|
|
6412
6434
|
if (!resizeStateRef.current) return;
|
|
6413
6435
|
resizeStateRef.current = null;
|
|
6414
6436
|
setIsResizing(false);
|
|
6415
6437
|
document.body.style.cursor = "";
|
|
6416
6438
|
document.body.style.userSelect = "";
|
|
6417
6439
|
}, []);
|
|
6418
|
-
const handleResizePointerMove =
|
|
6440
|
+
const handleResizePointerMove = React21.useCallback((event) => {
|
|
6419
6441
|
const resizeState = resizeStateRef.current;
|
|
6420
6442
|
if (!resizeState || event.pointerId !== resizeState.pointerId) return;
|
|
6421
6443
|
const delta = isHorizontalSheet ? side === "right" ? resizeState.startClientX - event.clientX : event.clientX - resizeState.startClientX : side === "bottom" ? resizeState.startClientY - event.clientY : event.clientY - resizeState.startClientY;
|
|
@@ -6423,12 +6445,12 @@ var Sheet = ({
|
|
|
6423
6445
|
setSheetSize(nextSize);
|
|
6424
6446
|
onResize?.(nextSize);
|
|
6425
6447
|
}, [clampResizeSize, isHorizontalSheet, onResize, side]);
|
|
6426
|
-
const handleResizePointerUp =
|
|
6448
|
+
const handleResizePointerUp = React21.useCallback((event) => {
|
|
6427
6449
|
const resizeState = resizeStateRef.current;
|
|
6428
6450
|
if (!resizeState || event.pointerId !== resizeState.pointerId) return;
|
|
6429
6451
|
endResize();
|
|
6430
6452
|
}, [endResize]);
|
|
6431
|
-
|
|
6453
|
+
React21.useEffect(() => {
|
|
6432
6454
|
if (!isResizing) return void 0;
|
|
6433
6455
|
window.addEventListener("pointermove", handleResizePointerMove);
|
|
6434
6456
|
window.addEventListener("pointerup", handleResizePointerUp);
|
|
@@ -6439,10 +6461,10 @@ var Sheet = ({
|
|
|
6439
6461
|
window.removeEventListener("pointercancel", handleResizePointerUp);
|
|
6440
6462
|
};
|
|
6441
6463
|
}, [handleResizePointerMove, handleResizePointerUp, isResizing]);
|
|
6442
|
-
|
|
6464
|
+
React21.useEffect(() => {
|
|
6443
6465
|
if (!open) endResize();
|
|
6444
6466
|
}, [endResize, open]);
|
|
6445
|
-
|
|
6467
|
+
React21.useEffect(() => endResize, [endResize]);
|
|
6446
6468
|
const handleResizePointerDown = (event) => {
|
|
6447
6469
|
if (!canResize || !sheetRef.current) return;
|
|
6448
6470
|
const rect = sheetRef.current.getBoundingClientRect();
|
|
@@ -6780,7 +6802,7 @@ var ButtonLoading = ({ isLoading, children, className, disabled, loadingText })
|
|
|
6780
6802
|
};
|
|
6781
6803
|
|
|
6782
6804
|
// src/components/Breadcrumb.tsx
|
|
6783
|
-
var
|
|
6805
|
+
var React23 = __toESM(require("react"), 1);
|
|
6784
6806
|
var import_lucide_react12 = require("lucide-react");
|
|
6785
6807
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
6786
6808
|
var NextLink = null;
|
|
@@ -6828,8 +6850,8 @@ var Breadcrumb = ({
|
|
|
6828
6850
|
collapsible = true
|
|
6829
6851
|
}) => {
|
|
6830
6852
|
const gi18n = useGlobalI18n();
|
|
6831
|
-
const [isCollapsed, setIsCollapsed] =
|
|
6832
|
-
|
|
6853
|
+
const [isCollapsed, setIsCollapsed] = React23.useState(false);
|
|
6854
|
+
React23.useEffect(() => {
|
|
6833
6855
|
if (collapsible && items.length > maxItems) {
|
|
6834
6856
|
setIsCollapsed(true);
|
|
6835
6857
|
}
|
|
@@ -6847,7 +6869,7 @@ var Breadcrumb = ({
|
|
|
6847
6869
|
const SeparatorComponent = separator;
|
|
6848
6870
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(SeparatorComponent, { className: cn("text-muted-foreground", sizeStyles5[size].icon) });
|
|
6849
6871
|
};
|
|
6850
|
-
const processedItems =
|
|
6872
|
+
const processedItems = React23.useMemo(() => {
|
|
6851
6873
|
let finalItems = [...items];
|
|
6852
6874
|
if (showHome && finalItems[0]?.href !== homeHref) {
|
|
6853
6875
|
finalItems.unshift({
|
|
@@ -6920,7 +6942,7 @@ var Breadcrumb = ({
|
|
|
6920
6942
|
var Breadcrumb_default = Breadcrumb;
|
|
6921
6943
|
|
|
6922
6944
|
// src/components/Tab.tsx
|
|
6923
|
-
var
|
|
6945
|
+
var React24 = __toESM(require("react"), 1);
|
|
6924
6946
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
6925
6947
|
var sizeStyles6 = {
|
|
6926
6948
|
sm: {
|
|
@@ -7018,11 +7040,11 @@ var Tabs = ({
|
|
|
7018
7040
|
noContentPadding = false,
|
|
7019
7041
|
animateContent = true
|
|
7020
7042
|
}) => {
|
|
7021
|
-
const [active, setActive] =
|
|
7022
|
-
const [underlineStyle, setUnderlineStyle] =
|
|
7023
|
-
const tabRefs =
|
|
7024
|
-
const autoId =
|
|
7025
|
-
const baseId =
|
|
7043
|
+
const [active, setActive] = React24.useState(defaultValue || tabs[0]?.value);
|
|
7044
|
+
const [underlineStyle, setUnderlineStyle] = React24.useState({});
|
|
7045
|
+
const tabRefs = React24.useRef([]);
|
|
7046
|
+
const autoId = React24.useId();
|
|
7047
|
+
const baseId = React24.useMemo(() => getTabsBaseId(tabs, id, autoId), [autoId, id, tabs]);
|
|
7026
7048
|
const handleTabChange = (value) => {
|
|
7027
7049
|
setActive(value);
|
|
7028
7050
|
onTabChange?.(value);
|
|
@@ -7049,7 +7071,7 @@ var Tabs = ({
|
|
|
7049
7071
|
tabRefs.current[next]?.focus();
|
|
7050
7072
|
}
|
|
7051
7073
|
};
|
|
7052
|
-
|
|
7074
|
+
React24.useEffect(() => {
|
|
7053
7075
|
if (variant === "underline" && orientation === "horizontal") {
|
|
7054
7076
|
const activeIndex2 = tabs.findIndex((tab) => tab.value === active);
|
|
7055
7077
|
const activeTab2 = tabRefs.current[activeIndex2];
|
|
@@ -7062,7 +7084,7 @@ var Tabs = ({
|
|
|
7062
7084
|
}
|
|
7063
7085
|
}
|
|
7064
7086
|
}, [active, variant, orientation, tabs]);
|
|
7065
|
-
|
|
7087
|
+
React24.useEffect(() => {
|
|
7066
7088
|
if (typeof window === "undefined") return;
|
|
7067
7089
|
const syncFromHash = () => {
|
|
7068
7090
|
const nextValue = resolveTabValueFromHash(window.location.hash, tabs, baseId);
|
|
@@ -7414,11 +7436,11 @@ var SelectDropdown = ({ options, value, onChange, placeholder = "Select...", cla
|
|
|
7414
7436
|
var DropdownMenu_default = DropdownMenu;
|
|
7415
7437
|
|
|
7416
7438
|
// src/components/Pagination.tsx
|
|
7417
|
-
var
|
|
7439
|
+
var React27 = __toESM(require("react"), 1);
|
|
7418
7440
|
var import_lucide_react14 = require("lucide-react");
|
|
7419
7441
|
|
|
7420
7442
|
// src/components/Combobox.tsx
|
|
7421
|
-
var
|
|
7443
|
+
var React26 = __toESM(require("react"), 1);
|
|
7422
7444
|
var import_react15 = require("react");
|
|
7423
7445
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
7424
7446
|
var import_lucide_react13 = require("lucide-react");
|
|
@@ -7500,13 +7522,13 @@ var Combobox = ({
|
|
|
7500
7522
|
const searchPlaceholder = searchPlaceholderProp ?? gi18n.searchPlaceholder ?? "Search\u2026";
|
|
7501
7523
|
const emptyText = emptyTextProp ?? gi18n.noResults ?? "No results found";
|
|
7502
7524
|
const loadingText = loadingTextProp ?? gi18n.loading ?? "Loading...";
|
|
7503
|
-
const [open, setOpen] =
|
|
7504
|
-
const [query, setQuery] =
|
|
7505
|
-
const [activeIndex, setActiveIndex] =
|
|
7506
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
7525
|
+
const [open, setOpen] = React26.useState(false);
|
|
7526
|
+
const [query, setQuery] = React26.useState("");
|
|
7527
|
+
const [activeIndex, setActiveIndex] = React26.useState(null);
|
|
7528
|
+
const [localRequiredError, setLocalRequiredError] = React26.useState();
|
|
7507
7529
|
useShadCNAnimations();
|
|
7508
|
-
const inputRef =
|
|
7509
|
-
const optionsViewportRef =
|
|
7530
|
+
const inputRef = React26.useRef(null);
|
|
7531
|
+
const optionsViewportRef = React26.useRef(null);
|
|
7510
7532
|
useOverlayScrollbarTarget(optionsViewportRef, { enabled: open && useOverlayScrollbar && !virtualized });
|
|
7511
7533
|
const autoId = (0, import_react15.useId)();
|
|
7512
7534
|
const resolvedId = id ? String(id) : `combobox-${autoId}`;
|
|
@@ -7515,7 +7537,7 @@ var Combobox = ({
|
|
|
7515
7537
|
const trimmedQuery = query.trim();
|
|
7516
7538
|
const queryMeetsMinimum = trimmedQuery.length >= minSearchLength;
|
|
7517
7539
|
const shouldPromptForSearch = minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
7518
|
-
const filteredOptions =
|
|
7540
|
+
const filteredOptions = React26.useMemo(
|
|
7519
7541
|
() => {
|
|
7520
7542
|
if (shouldPromptForSearch) return [];
|
|
7521
7543
|
if (!enableSearch || searchMode === "manual") return options;
|
|
@@ -7525,7 +7547,7 @@ var Combobox = ({
|
|
|
7525
7547
|
},
|
|
7526
7548
|
[enableSearch, options, searchMode, shouldPromptForSearch, trimmedQuery]
|
|
7527
7549
|
);
|
|
7528
|
-
const renderLimitedOptions =
|
|
7550
|
+
const renderLimitedOptions = React26.useMemo(
|
|
7529
7551
|
() => {
|
|
7530
7552
|
if (trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
7531
7553
|
return filteredOptions;
|
|
@@ -7544,15 +7566,15 @@ var Combobox = ({
|
|
|
7544
7566
|
enabled: canVirtualize
|
|
7545
7567
|
});
|
|
7546
7568
|
const virtualItems = canVirtualize ? optionVirtualizer.getVirtualItems() : [];
|
|
7547
|
-
const triggerRef =
|
|
7548
|
-
const scrollVirtualListToIndex =
|
|
7569
|
+
const triggerRef = React26.useRef(null);
|
|
7570
|
+
const scrollVirtualListToIndex = React26.useCallback((index) => {
|
|
7549
7571
|
if (!canVirtualize || renderLimitedOptions.length === 0) return;
|
|
7550
7572
|
optionVirtualizer.scrollToIndex(index, { align: "auto" });
|
|
7551
7573
|
}, [canVirtualize, optionVirtualizer, renderLimitedOptions.length]);
|
|
7552
|
-
const scrollVirtualListToStart =
|
|
7574
|
+
const scrollVirtualListToStart = React26.useCallback(() => {
|
|
7553
7575
|
scrollVirtualListToIndex(0);
|
|
7554
7576
|
}, [scrollVirtualListToIndex]);
|
|
7555
|
-
const moveActiveIndex =
|
|
7577
|
+
const moveActiveIndex = React26.useCallback((direction) => {
|
|
7556
7578
|
if (renderLimitedOptions.length === 0) return;
|
|
7557
7579
|
const next = activeIndex === null ? direction === 1 ? 0 : renderLimitedOptions.length - 1 : (activeIndex + direction + renderLimitedOptions.length) % renderLimitedOptions.length;
|
|
7558
7580
|
setActiveIndex(next);
|
|
@@ -7576,7 +7598,7 @@ var Combobox = ({
|
|
|
7576
7598
|
onChange(null);
|
|
7577
7599
|
setOpen(false);
|
|
7578
7600
|
};
|
|
7579
|
-
|
|
7601
|
+
React26.useEffect(() => {
|
|
7580
7602
|
if (!open) {
|
|
7581
7603
|
setQuery("");
|
|
7582
7604
|
setActiveIndex(null);
|
|
@@ -7587,12 +7609,12 @@ var Combobox = ({
|
|
|
7587
7609
|
}, 100);
|
|
7588
7610
|
}
|
|
7589
7611
|
}, [enableSearch, open, scrollVirtualListToStart]);
|
|
7590
|
-
|
|
7612
|
+
React26.useEffect(() => {
|
|
7591
7613
|
if (!onSearchChange) return void 0;
|
|
7592
7614
|
const timeoutId = window.setTimeout(() => onSearchChange(query), searchDebounceMs);
|
|
7593
7615
|
return () => window.clearTimeout(timeoutId);
|
|
7594
7616
|
}, [onSearchChange, query, searchDebounceMs]);
|
|
7595
|
-
|
|
7617
|
+
React26.useEffect(() => {
|
|
7596
7618
|
if (process.env.NODE_ENV !== "production" && options.length > 300 && !virtualized && searchMode !== "manual" && maxInitialOptions === void 0) {
|
|
7597
7619
|
console.warn(
|
|
7598
7620
|
'[Underverse UI] Combobox received more than 300 options without virtualization, manual search, or maxInitialOptions. Use virtualized, searchMode="manual", or maxInitialOptions to avoid rendering a large dropdown.'
|
|
@@ -7604,12 +7626,12 @@ var Combobox = ({
|
|
|
7604
7626
|
const selectedIcon = selectedOption ? getOptionIcon(selectedOption) : void 0;
|
|
7605
7627
|
const hasValue = value !== void 0 && value !== null && value !== "";
|
|
7606
7628
|
const effectiveError = error ?? localRequiredError;
|
|
7607
|
-
|
|
7629
|
+
React26.useEffect(() => {
|
|
7608
7630
|
if (disabled || !required || hasValue) {
|
|
7609
7631
|
setLocalRequiredError(void 0);
|
|
7610
7632
|
}
|
|
7611
7633
|
}, [disabled, hasValue, required]);
|
|
7612
|
-
const groupedOptions =
|
|
7634
|
+
const groupedOptions = React26.useMemo(() => {
|
|
7613
7635
|
if (!groupBy) return null;
|
|
7614
7636
|
const groups = {};
|
|
7615
7637
|
renderLimitedOptions.forEach((opt) => {
|
|
@@ -8026,7 +8048,7 @@ var Pagination = ({
|
|
|
8026
8048
|
labels
|
|
8027
8049
|
}) => {
|
|
8028
8050
|
const t = useSmartTranslations("Pagination");
|
|
8029
|
-
|
|
8051
|
+
React27.useEffect(() => {
|
|
8030
8052
|
if (disabled) return;
|
|
8031
8053
|
const handleKey = (e) => {
|
|
8032
8054
|
if (e.target && e.target.tagName === "INPUT") return;
|
|
@@ -8677,7 +8699,7 @@ function formatDateSmart(date, locale = "en") {
|
|
|
8677
8699
|
|
|
8678
8700
|
// src/components/DatePicker.tsx
|
|
8679
8701
|
var import_lucide_react15 = require("lucide-react");
|
|
8680
|
-
var
|
|
8702
|
+
var React30 = __toESM(require("react"), 1);
|
|
8681
8703
|
var import_react19 = require("react");
|
|
8682
8704
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
8683
8705
|
var DatePicker = ({
|
|
@@ -8701,20 +8723,20 @@ var DatePicker = ({
|
|
|
8701
8723
|
const t = useSmartTranslations("DatePicker");
|
|
8702
8724
|
const tv = useSmartTranslations("ValidationInput");
|
|
8703
8725
|
const locale = useSmartLocale();
|
|
8704
|
-
const [isOpen, setIsOpen] =
|
|
8705
|
-
const [viewDate, setViewDate] =
|
|
8706
|
-
const [viewMode, setViewMode] =
|
|
8707
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
8708
|
-
const triggerRef =
|
|
8709
|
-
const wheelContainerRef =
|
|
8710
|
-
const wheelDeltaRef =
|
|
8711
|
-
const normalizeToLocalDay =
|
|
8726
|
+
const [isOpen, setIsOpen] = React30.useState(false);
|
|
8727
|
+
const [viewDate, setViewDate] = React30.useState(value || /* @__PURE__ */ new Date());
|
|
8728
|
+
const [viewMode, setViewMode] = React30.useState("calendar");
|
|
8729
|
+
const [localRequiredError, setLocalRequiredError] = React30.useState();
|
|
8730
|
+
const triggerRef = React30.useRef(null);
|
|
8731
|
+
const wheelContainerRef = React30.useRef(null);
|
|
8732
|
+
const wheelDeltaRef = React30.useRef(0);
|
|
8733
|
+
const normalizeToLocalDay = React30.useCallback((date) => {
|
|
8712
8734
|
if (!date) return null;
|
|
8713
8735
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
8714
8736
|
}, []);
|
|
8715
|
-
const minDay =
|
|
8716
|
-
const maxDay =
|
|
8717
|
-
const isDateDisabled =
|
|
8737
|
+
const minDay = React30.useMemo(() => normalizeToLocalDay(minDate), [minDate, normalizeToLocalDay]);
|
|
8738
|
+
const maxDay = React30.useMemo(() => normalizeToLocalDay(maxDate), [maxDate, normalizeToLocalDay]);
|
|
8739
|
+
const isDateDisabled = React30.useCallback(
|
|
8718
8740
|
(date) => {
|
|
8719
8741
|
const day = normalizeToLocalDay(date);
|
|
8720
8742
|
if (!day) return false;
|
|
@@ -8783,19 +8805,19 @@ var DatePicker = ({
|
|
|
8783
8805
|
footerMargin: "mt-5 pt-4 gap-2.5"
|
|
8784
8806
|
}
|
|
8785
8807
|
};
|
|
8786
|
-
|
|
8808
|
+
React30.useEffect(() => {
|
|
8787
8809
|
if (value) {
|
|
8788
8810
|
setViewDate(value);
|
|
8789
8811
|
} else {
|
|
8790
8812
|
setViewDate(/* @__PURE__ */ new Date());
|
|
8791
8813
|
}
|
|
8792
8814
|
}, [value]);
|
|
8793
|
-
|
|
8815
|
+
React30.useEffect(() => {
|
|
8794
8816
|
if (disabled || !required || value) {
|
|
8795
8817
|
setLocalRequiredError(void 0);
|
|
8796
8818
|
}
|
|
8797
8819
|
}, [disabled, required, value]);
|
|
8798
|
-
|
|
8820
|
+
React30.useEffect(() => {
|
|
8799
8821
|
if (!isOpen) {
|
|
8800
8822
|
setViewMode("calendar");
|
|
8801
8823
|
}
|
|
@@ -8825,7 +8847,7 @@ var DatePicker = ({
|
|
|
8825
8847
|
const getFirstDayOfMonth = (date) => {
|
|
8826
8848
|
return new Date(date.getFullYear(), date.getMonth(), 1).getDay();
|
|
8827
8849
|
};
|
|
8828
|
-
const navigateMonth =
|
|
8850
|
+
const navigateMonth = React30.useCallback((direction) => {
|
|
8829
8851
|
setViewDate((prev) => {
|
|
8830
8852
|
const newDate = new Date(prev);
|
|
8831
8853
|
newDate.setMonth(prev.getMonth() + (direction === "next" ? 1 : -1));
|
|
@@ -8839,7 +8861,7 @@ var DatePicker = ({
|
|
|
8839
8861
|
const node = el;
|
|
8840
8862
|
return node.scrollHeight > node.clientHeight + 1;
|
|
8841
8863
|
};
|
|
8842
|
-
|
|
8864
|
+
React30.useEffect(() => {
|
|
8843
8865
|
if (!isOpen) return;
|
|
8844
8866
|
const container = wheelContainerRef.current;
|
|
8845
8867
|
if (!container) return;
|
|
@@ -9254,11 +9276,11 @@ var DateRangePicker = ({
|
|
|
9254
9276
|
const locale = useSmartLocale();
|
|
9255
9277
|
const t = useSmartTranslations("DatePicker");
|
|
9256
9278
|
const tv = useSmartTranslations("ValidationInput");
|
|
9257
|
-
const [isOpen, setIsOpen] =
|
|
9258
|
-
const [viewMode, setViewMode] =
|
|
9259
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
9260
|
-
const wheelContainerRef =
|
|
9261
|
-
const wheelDeltaRef =
|
|
9279
|
+
const [isOpen, setIsOpen] = React30.useState(false);
|
|
9280
|
+
const [viewMode, setViewMode] = React30.useState("calendar");
|
|
9281
|
+
const [localRequiredError, setLocalRequiredError] = React30.useState();
|
|
9282
|
+
const wheelContainerRef = React30.useRef(null);
|
|
9283
|
+
const wheelDeltaRef = React30.useRef(0);
|
|
9262
9284
|
const sizeStyles8 = {
|
|
9263
9285
|
sm: {
|
|
9264
9286
|
trigger: "px-2.5 py-1.5 text-sm h-8 md:h-7 md:text-xs md:py-1",
|
|
@@ -9316,24 +9338,24 @@ var DateRangePicker = ({
|
|
|
9316
9338
|
if (!date) return null;
|
|
9317
9339
|
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
9318
9340
|
};
|
|
9319
|
-
const minDay =
|
|
9320
|
-
const maxDay =
|
|
9321
|
-
const [viewDate, setViewDate] =
|
|
9322
|
-
const [tempStart, setTempStart] =
|
|
9323
|
-
const [tempEnd, setTempEnd] =
|
|
9324
|
-
const [hoveredDate, setHoveredDate] =
|
|
9325
|
-
|
|
9341
|
+
const minDay = React30.useMemo(() => normalizeToLocal(minDate), [minDate]);
|
|
9342
|
+
const maxDay = React30.useMemo(() => normalizeToLocal(maxDate), [maxDate]);
|
|
9343
|
+
const [viewDate, setViewDate] = React30.useState(startDate || /* @__PURE__ */ new Date());
|
|
9344
|
+
const [tempStart, setTempStart] = React30.useState(normalizeToLocal(startDate));
|
|
9345
|
+
const [tempEnd, setTempEnd] = React30.useState(normalizeToLocal(endDate));
|
|
9346
|
+
const [hoveredDate, setHoveredDate] = React30.useState(null);
|
|
9347
|
+
React30.useEffect(() => {
|
|
9326
9348
|
setTempStart(normalizeToLocal(startDate));
|
|
9327
9349
|
}, [startDate]);
|
|
9328
|
-
|
|
9350
|
+
React30.useEffect(() => {
|
|
9329
9351
|
setTempEnd(normalizeToLocal(endDate));
|
|
9330
9352
|
}, [endDate]);
|
|
9331
|
-
|
|
9353
|
+
React30.useEffect(() => {
|
|
9332
9354
|
if (!isOpen) {
|
|
9333
9355
|
setViewMode("calendar");
|
|
9334
9356
|
}
|
|
9335
9357
|
}, [isOpen]);
|
|
9336
|
-
|
|
9358
|
+
React30.useEffect(() => {
|
|
9337
9359
|
if (!required || startDate && endDate) {
|
|
9338
9360
|
setLocalRequiredError(void 0);
|
|
9339
9361
|
}
|
|
@@ -9345,10 +9367,10 @@ var DateRangePicker = ({
|
|
|
9345
9367
|
const inRange = (d, s, e) => d > s && d < e;
|
|
9346
9368
|
const getDaysInMonth = (d) => new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();
|
|
9347
9369
|
const getFirstDayOfMonth = (d) => new Date(d.getFullYear(), d.getMonth(), 1).getDay();
|
|
9348
|
-
const navigateMonth =
|
|
9370
|
+
const navigateMonth = React30.useCallback((direction) => {
|
|
9349
9371
|
setViewDate((prev) => new Date(prev.getFullYear(), prev.getMonth() + (direction === "next" ? 1 : -1), 1));
|
|
9350
9372
|
}, []);
|
|
9351
|
-
const navigateYearRange =
|
|
9373
|
+
const navigateYearRange = React30.useCallback((direction) => {
|
|
9352
9374
|
setViewDate((prev) => new Date(prev.getFullYear() + (direction === "next" ? 12 : -12), prev.getMonth(), 1));
|
|
9353
9375
|
}, []);
|
|
9354
9376
|
const isElementVerticallyScrollable = (el) => {
|
|
@@ -9358,7 +9380,7 @@ var DateRangePicker = ({
|
|
|
9358
9380
|
const node = el;
|
|
9359
9381
|
return node.scrollHeight > node.clientHeight + 1;
|
|
9360
9382
|
};
|
|
9361
|
-
|
|
9383
|
+
React30.useEffect(() => {
|
|
9362
9384
|
if (!isOpen) return;
|
|
9363
9385
|
const container = wheelContainerRef.current;
|
|
9364
9386
|
if (!container) return;
|
|
@@ -9537,7 +9559,7 @@ var DateRangePicker = ({
|
|
|
9537
9559
|
);
|
|
9538
9560
|
}) });
|
|
9539
9561
|
};
|
|
9540
|
-
const todayDate =
|
|
9562
|
+
const todayDate = React30.useMemo(() => {
|
|
9541
9563
|
const today = /* @__PURE__ */ new Date();
|
|
9542
9564
|
return new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
9543
9565
|
}, []);
|
|
@@ -9779,15 +9801,15 @@ var CompactDatePicker = ({ value, onChange, className }) => {
|
|
|
9779
9801
|
};
|
|
9780
9802
|
|
|
9781
9803
|
// src/components/DateTimePicker.tsx
|
|
9782
|
-
var
|
|
9804
|
+
var React34 = __toESM(require("react"), 1);
|
|
9783
9805
|
var import_lucide_react19 = require("lucide-react");
|
|
9784
9806
|
|
|
9785
9807
|
// src/components/Calendar.tsx
|
|
9786
9808
|
var import_lucide_react17 = require("lucide-react");
|
|
9787
|
-
var
|
|
9809
|
+
var React32 = __toESM(require("react"), 1);
|
|
9788
9810
|
|
|
9789
9811
|
// src/components/MonthYearPicker.tsx
|
|
9790
|
-
var
|
|
9812
|
+
var React31 = __toESM(require("react"), 1);
|
|
9791
9813
|
var import_lucide_react16 = require("lucide-react");
|
|
9792
9814
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
9793
9815
|
var DEFAULT_MONTH_NAMES = [
|
|
@@ -9830,20 +9852,20 @@ function WheelColumn({
|
|
|
9830
9852
|
}) {
|
|
9831
9853
|
const height = itemHeight * WHEEL_VISIBLE_ITEMS;
|
|
9832
9854
|
const paddingY = (height - itemHeight) / 2;
|
|
9833
|
-
const rafRef =
|
|
9834
|
-
const lastVirtualIndexRef =
|
|
9835
|
-
const wheelDeltaRef =
|
|
9836
|
-
const scrollEndTimeoutRef =
|
|
9837
|
-
const suppressScrollSelectUntilRef =
|
|
9838
|
-
const suppressItemClickUntilRef =
|
|
9839
|
-
const dragRef =
|
|
9840
|
-
const draggingRef =
|
|
9841
|
-
const inertialRef =
|
|
9842
|
-
const inertiaRafRef =
|
|
9843
|
-
const inertiaVelocityRef =
|
|
9844
|
-
const inertiaLastTimeRef =
|
|
9845
|
-
const moveSamplesRef =
|
|
9846
|
-
const ui =
|
|
9855
|
+
const rafRef = React31.useRef(0);
|
|
9856
|
+
const lastVirtualIndexRef = React31.useRef(null);
|
|
9857
|
+
const wheelDeltaRef = React31.useRef(0);
|
|
9858
|
+
const scrollEndTimeoutRef = React31.useRef(null);
|
|
9859
|
+
const suppressScrollSelectUntilRef = React31.useRef(0);
|
|
9860
|
+
const suppressItemClickUntilRef = React31.useRef(0);
|
|
9861
|
+
const dragRef = React31.useRef(null);
|
|
9862
|
+
const draggingRef = React31.useRef(false);
|
|
9863
|
+
const inertialRef = React31.useRef(false);
|
|
9864
|
+
const inertiaRafRef = React31.useRef(null);
|
|
9865
|
+
const inertiaVelocityRef = React31.useRef(0);
|
|
9866
|
+
const inertiaLastTimeRef = React31.useRef(0);
|
|
9867
|
+
const moveSamplesRef = React31.useRef([]);
|
|
9868
|
+
const ui = React31.useMemo(() => {
|
|
9847
9869
|
if (size === "sm") {
|
|
9848
9870
|
return {
|
|
9849
9871
|
columnWidth: column === "month" ? "min-w-24 max-w-32" : "min-w-16 max-w-20",
|
|
@@ -9870,9 +9892,9 @@ function WheelColumn({
|
|
|
9870
9892
|
fadeHeight: "h-12"
|
|
9871
9893
|
};
|
|
9872
9894
|
}, [size, column]);
|
|
9873
|
-
const baseOffset =
|
|
9874
|
-
const extendedItems =
|
|
9875
|
-
const getNearestVirtualIndex =
|
|
9895
|
+
const baseOffset = React31.useMemo(() => loop ? items.length : 0, [items.length, loop]);
|
|
9896
|
+
const extendedItems = React31.useMemo(() => loop ? [...items, ...items, ...items] : items, [items, loop]);
|
|
9897
|
+
const getNearestVirtualIndex = React31.useCallback(
|
|
9876
9898
|
(realIndex, fromVirtual) => {
|
|
9877
9899
|
const len = items.length;
|
|
9878
9900
|
if (len <= 0) return 0;
|
|
@@ -9891,7 +9913,7 @@ function WheelColumn({
|
|
|
9891
9913
|
},
|
|
9892
9914
|
[items.length, loop]
|
|
9893
9915
|
);
|
|
9894
|
-
|
|
9916
|
+
React31.useLayoutEffect(() => {
|
|
9895
9917
|
const el = scrollRef.current;
|
|
9896
9918
|
if (!el) return;
|
|
9897
9919
|
const maxVirtual = Math.max(0, extendedItems.length - 1);
|
|
@@ -9919,7 +9941,7 @@ function WheelColumn({
|
|
|
9919
9941
|
cancelAnimationFrame(rafRef.current);
|
|
9920
9942
|
};
|
|
9921
9943
|
}, [animate, baseOffset, extendedItems.length, getNearestVirtualIndex, itemHeight, loop, scrollRef, valueIndex]);
|
|
9922
|
-
|
|
9944
|
+
React31.useEffect(() => {
|
|
9923
9945
|
const el = scrollRef.current;
|
|
9924
9946
|
if (!el) return;
|
|
9925
9947
|
const lastWheelSignRef = { current: 0 };
|
|
@@ -10007,11 +10029,11 @@ function WheelColumn({
|
|
|
10007
10029
|
}, 120);
|
|
10008
10030
|
});
|
|
10009
10031
|
};
|
|
10010
|
-
const currentVirtual =
|
|
10032
|
+
const currentVirtual = React31.useMemo(() => {
|
|
10011
10033
|
if (!loop || items.length <= 0) return valueIndex;
|
|
10012
10034
|
return baseOffset + valueIndex;
|
|
10013
10035
|
}, [baseOffset, items.length, loop, valueIndex]);
|
|
10014
|
-
const commitFromScrollTop =
|
|
10036
|
+
const commitFromScrollTop = React31.useCallback(
|
|
10015
10037
|
(behavior) => {
|
|
10016
10038
|
const el = scrollRef.current;
|
|
10017
10039
|
if (!el) return;
|
|
@@ -10089,7 +10111,7 @@ function WheelColumn({
|
|
|
10089
10111
|
if (dt > 0) inertiaVelocityRef.current = (el.scrollTop - oldest.top) / dt;
|
|
10090
10112
|
}
|
|
10091
10113
|
};
|
|
10092
|
-
const startInertia =
|
|
10114
|
+
const startInertia = React31.useCallback(() => {
|
|
10093
10115
|
const el = scrollRef.current;
|
|
10094
10116
|
if (!el) return;
|
|
10095
10117
|
if (items.length <= 0) return;
|
|
@@ -10274,36 +10296,36 @@ function MonthYearPicker({
|
|
|
10274
10296
|
};
|
|
10275
10297
|
const isControlled = value !== void 0;
|
|
10276
10298
|
const initial = parseValue(isControlled ? value : defaultValue) ?? { month: now.getMonth(), year: currentYear };
|
|
10277
|
-
const [open, setOpen] =
|
|
10278
|
-
const [parts, setParts] =
|
|
10279
|
-
const [focusedColumn, setFocusedColumn] =
|
|
10280
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
10281
|
-
const [hasCommittedValue, setHasCommittedValue] =
|
|
10282
|
-
const monthScrollRef =
|
|
10283
|
-
const yearScrollRef =
|
|
10284
|
-
|
|
10299
|
+
const [open, setOpen] = React31.useState(false);
|
|
10300
|
+
const [parts, setParts] = React31.useState(initial);
|
|
10301
|
+
const [focusedColumn, setFocusedColumn] = React31.useState(null);
|
|
10302
|
+
const [localRequiredError, setLocalRequiredError] = React31.useState();
|
|
10303
|
+
const [hasCommittedValue, setHasCommittedValue] = React31.useState(Boolean(parseValue(isControlled ? value : defaultValue)));
|
|
10304
|
+
const monthScrollRef = React31.useRef(null);
|
|
10305
|
+
const yearScrollRef = React31.useRef(null);
|
|
10306
|
+
React31.useEffect(() => {
|
|
10285
10307
|
if (isControlled) {
|
|
10286
10308
|
const parsed = parseValue(value);
|
|
10287
10309
|
if (parsed) setParts(parsed);
|
|
10288
10310
|
}
|
|
10289
10311
|
}, [value, isControlled]);
|
|
10290
|
-
|
|
10312
|
+
React31.useEffect(() => {
|
|
10291
10313
|
if (isControlled) {
|
|
10292
10314
|
setHasCommittedValue(Boolean(parseValue(value)));
|
|
10293
10315
|
}
|
|
10294
10316
|
}, [isControlled, value]);
|
|
10295
10317
|
const hasValue = hasCommittedValue;
|
|
10296
10318
|
const effectiveError = error ?? localRequiredError;
|
|
10297
|
-
|
|
10319
|
+
React31.useEffect(() => {
|
|
10298
10320
|
if (disabled || !required || hasValue) {
|
|
10299
10321
|
setLocalRequiredError(void 0);
|
|
10300
10322
|
}
|
|
10301
10323
|
}, [disabled, hasValue, required]);
|
|
10302
|
-
const years =
|
|
10324
|
+
const years = React31.useMemo(() => {
|
|
10303
10325
|
return Array.from({ length: resolvedMaxYear - resolvedMinYear + 1 }, (_, i) => resolvedMinYear + i);
|
|
10304
10326
|
}, [resolvedMinYear, resolvedMaxYear]);
|
|
10305
|
-
const months =
|
|
10306
|
-
const isDateInRange =
|
|
10327
|
+
const months = React31.useMemo(() => Array.from({ length: 12 }, (_, i) => i), []);
|
|
10328
|
+
const isDateInRange = React31.useCallback(
|
|
10307
10329
|
(month, year) => {
|
|
10308
10330
|
if (minDate) {
|
|
10309
10331
|
const minMonth = minDate.getMonth();
|
|
@@ -10319,7 +10341,7 @@ function MonthYearPicker({
|
|
|
10319
10341
|
},
|
|
10320
10342
|
[minDate, maxDate]
|
|
10321
10343
|
);
|
|
10322
|
-
const emit =
|
|
10344
|
+
const emit = React31.useCallback(
|
|
10323
10345
|
(next) => {
|
|
10324
10346
|
if (!next) {
|
|
10325
10347
|
setLocalRequiredError(void 0);
|
|
@@ -10335,7 +10357,7 @@ function MonthYearPicker({
|
|
|
10335
10357
|
},
|
|
10336
10358
|
[isControlled, isDateInRange, onChange]
|
|
10337
10359
|
);
|
|
10338
|
-
const tryUpdate =
|
|
10360
|
+
const tryUpdate = React31.useCallback(
|
|
10339
10361
|
(next) => {
|
|
10340
10362
|
if (!isDateInRange(next.month, next.year)) return false;
|
|
10341
10363
|
setParts(next);
|
|
@@ -10771,12 +10793,12 @@ function Calendar3({
|
|
|
10771
10793
|
...rest
|
|
10772
10794
|
}) {
|
|
10773
10795
|
const isControlledMonth = month != null;
|
|
10774
|
-
const [view, setView] =
|
|
10775
|
-
|
|
10796
|
+
const [view, setView] = React32.useState(() => month ?? defaultMonth ?? /* @__PURE__ */ new Date());
|
|
10797
|
+
React32.useEffect(() => {
|
|
10776
10798
|
if (isControlledMonth && month) setView(month);
|
|
10777
10799
|
}, [isControlledMonth, month]);
|
|
10778
10800
|
const isControlledValue = value !== void 0;
|
|
10779
|
-
const [internal, setInternal] =
|
|
10801
|
+
const [internal, setInternal] = React32.useState(defaultValue);
|
|
10780
10802
|
const selected = isControlledValue ? value : internal;
|
|
10781
10803
|
const goByView = (delta) => {
|
|
10782
10804
|
const next = display === "week" ? addDays(view, delta * 7) : addMonths(view, delta);
|
|
@@ -10788,7 +10810,7 @@ function Calendar3({
|
|
|
10788
10810
|
const weekdays = rotate(weekNames, weekStartsOn);
|
|
10789
10811
|
const days = getMonthGrid(view, weekStartsOn);
|
|
10790
10812
|
const today = /* @__PURE__ */ new Date();
|
|
10791
|
-
const byDay =
|
|
10813
|
+
const byDay = React32.useMemo(() => {
|
|
10792
10814
|
const map = /* @__PURE__ */ new Map();
|
|
10793
10815
|
for (const e of events) {
|
|
10794
10816
|
const d = toDate(e.date);
|
|
@@ -10800,11 +10822,11 @@ function Calendar3({
|
|
|
10800
10822
|
}, [events]);
|
|
10801
10823
|
const effectiveEnableEventSheet = enableEventSheet ?? !!renderEventSheet;
|
|
10802
10824
|
const isEventSheetOpenControlled = eventSheetOpen !== void 0;
|
|
10803
|
-
const [internalEventSheetOpen, setInternalEventSheetOpen] =
|
|
10825
|
+
const [internalEventSheetOpen, setInternalEventSheetOpen] = React32.useState(false);
|
|
10804
10826
|
const activeEventSheetOpen = isEventSheetOpenControlled ? !!eventSheetOpen : internalEventSheetOpen;
|
|
10805
10827
|
const isSelectedEventControlled = selectedEventId !== void 0;
|
|
10806
|
-
const [internalSelectedEventRef, setInternalSelectedEventRef] =
|
|
10807
|
-
const setEventSheetOpen =
|
|
10828
|
+
const [internalSelectedEventRef, setInternalSelectedEventRef] = React32.useState(null);
|
|
10829
|
+
const setEventSheetOpen = React32.useCallback(
|
|
10808
10830
|
(open) => {
|
|
10809
10831
|
if (!isEventSheetOpenControlled) setInternalEventSheetOpen(open);
|
|
10810
10832
|
onEventSheetOpenChange?.(open);
|
|
@@ -10815,7 +10837,7 @@ function Calendar3({
|
|
|
10815
10837
|
},
|
|
10816
10838
|
[isEventSheetOpenControlled, isSelectedEventControlled, onEventSheetOpenChange, onSelectedEventIdChange]
|
|
10817
10839
|
);
|
|
10818
|
-
const selectedEventRef =
|
|
10840
|
+
const selectedEventRef = React32.useMemo(() => {
|
|
10819
10841
|
if (isSelectedEventControlled && selectedEventId != null) {
|
|
10820
10842
|
const ev = events.find((e) => e.id === selectedEventId);
|
|
10821
10843
|
if (!ev) return null;
|
|
@@ -10825,7 +10847,7 @@ function Calendar3({
|
|
|
10825
10847
|
}
|
|
10826
10848
|
return internalSelectedEventRef;
|
|
10827
10849
|
}, [events, internalSelectedEventRef, isSelectedEventControlled, selectedEventId]);
|
|
10828
|
-
const selectedEvent =
|
|
10850
|
+
const selectedEvent = React32.useMemo(() => {
|
|
10829
10851
|
if (!selectedEventRef) return null;
|
|
10830
10852
|
const list = byDay.get(selectedEventRef.dayKey) || [];
|
|
10831
10853
|
if (selectedEventRef.eventId != null) {
|
|
@@ -10834,13 +10856,13 @@ function Calendar3({
|
|
|
10834
10856
|
const idx = selectedEventRef.index ?? -1;
|
|
10835
10857
|
return idx >= 0 && idx < list.length ? list[idx] : null;
|
|
10836
10858
|
}, [byDay, selectedEventRef]);
|
|
10837
|
-
const selectedEventDate =
|
|
10859
|
+
const selectedEventDate = React32.useMemo(() => {
|
|
10838
10860
|
if (!selectedEventRef) return null;
|
|
10839
10861
|
const [y, m, d] = selectedEventRef.dayKey.split("-").map((x) => Number(x));
|
|
10840
10862
|
if (!Number.isFinite(y) || !Number.isFinite(m) || !Number.isFinite(d)) return null;
|
|
10841
10863
|
return new Date(y, m, d);
|
|
10842
10864
|
}, [selectedEventRef]);
|
|
10843
|
-
const handleEventActivate =
|
|
10865
|
+
const handleEventActivate = React32.useCallback(
|
|
10844
10866
|
(event, date, dayKey, index) => {
|
|
10845
10867
|
onEventClick?.(event, date);
|
|
10846
10868
|
onSelectedEventIdChange?.(event.id ?? void 0);
|
|
@@ -10893,7 +10915,7 @@ function Calendar3({
|
|
|
10893
10915
|
}
|
|
10894
10916
|
}
|
|
10895
10917
|
};
|
|
10896
|
-
const isDateDisabled =
|
|
10918
|
+
const isDateDisabled = React32.useCallback(
|
|
10897
10919
|
(d) => {
|
|
10898
10920
|
if (minDate && d < new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate())) return true;
|
|
10899
10921
|
if (maxDate && d > new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate())) return true;
|
|
@@ -10927,7 +10949,7 @@ function Calendar3({
|
|
|
10927
10949
|
card: "border border-border/50 rounded-3xl bg-linear-to-br from-card via-background/95 to-card shadow-lg hover:shadow-xl transition-shadow duration-300 backdrop-blur-md",
|
|
10928
10950
|
minimal: "bg-transparent"
|
|
10929
10951
|
};
|
|
10930
|
-
const weekDays =
|
|
10952
|
+
const weekDays = React32.useMemo(() => {
|
|
10931
10953
|
const s = startOfWeek(view, weekStartsOn);
|
|
10932
10954
|
return Array.from({ length: 7 }, (_, i) => addDays(s, i));
|
|
10933
10955
|
}, [view, weekStartsOn]);
|
|
@@ -10948,7 +10970,7 @@ function Calendar3({
|
|
|
10948
10970
|
const holidayMatch = isHoliday(d, holidays);
|
|
10949
10971
|
const isHolidayDay = highlightHolidays && !!holidayMatch;
|
|
10950
10972
|
const customDay = renderDay?.({ date: d, isCurrentMonth: inMonth, isToday: isToday2, isSelected: selectedDay, events: dayEvents });
|
|
10951
|
-
if (customDay) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
10973
|
+
if (customDay) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(React32.Fragment, { children: customDay }, `${monthLabel}-${idx}`);
|
|
10952
10974
|
if (cellMode === "events") {
|
|
10953
10975
|
const limit = Math.max(0, maxEventsPerDay);
|
|
10954
10976
|
const visibleEvents = dayEvents.slice(0, limit);
|
|
@@ -11067,9 +11089,9 @@ function Calendar3({
|
|
|
11067
11089
|
}) })
|
|
11068
11090
|
] });
|
|
11069
11091
|
};
|
|
11070
|
-
const minBound =
|
|
11071
|
-
const maxBound =
|
|
11072
|
-
const prevDisabled =
|
|
11092
|
+
const minBound = React32.useMemo(() => minDate ? new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate()) : void 0, [minDate]);
|
|
11093
|
+
const maxBound = React32.useMemo(() => maxDate ? new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate()) : void 0, [maxDate]);
|
|
11094
|
+
const prevDisabled = React32.useMemo(() => {
|
|
11073
11095
|
if (!minBound) return false;
|
|
11074
11096
|
if (display === "week") {
|
|
11075
11097
|
const start = startOfWeek(view, weekStartsOn);
|
|
@@ -11079,7 +11101,7 @@ function Calendar3({
|
|
|
11079
11101
|
const prevEnd = endOfMonth(addMonths(view, -1));
|
|
11080
11102
|
return prevEnd < minBound;
|
|
11081
11103
|
}, [display, view, weekStartsOn, minBound]);
|
|
11082
|
-
const nextDisabled =
|
|
11104
|
+
const nextDisabled = React32.useMemo(() => {
|
|
11083
11105
|
if (!maxBound) return false;
|
|
11084
11106
|
if (display === "week") {
|
|
11085
11107
|
const start = startOfWeek(view, weekStartsOn);
|
|
@@ -11156,7 +11178,7 @@ function Calendar3({
|
|
|
11156
11178
|
const holidayMatch = isHoliday(d, holidays);
|
|
11157
11179
|
const isHolidayDay = highlightHolidays && !!holidayMatch;
|
|
11158
11180
|
const customDay = renderDay?.({ date: d, isCurrentMonth: inMonth, isToday: isToday2, isSelected: selectedDay, events: dayEvents });
|
|
11159
|
-
if (customDay) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11181
|
+
if (customDay) return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(React32.Fragment, { children: customDay }, `wd-${idx}`);
|
|
11160
11182
|
if (cellMode === "events") {
|
|
11161
11183
|
const limit = Math.max(0, maxEventsPerDay);
|
|
11162
11184
|
const visibleEvents = dayEvents.slice(0, limit);
|
|
@@ -11267,7 +11289,7 @@ function Calendar3({
|
|
|
11267
11289
|
`wd-${idx}`
|
|
11268
11290
|
);
|
|
11269
11291
|
}) })
|
|
11270
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: cn(months > 1 ? "grid md:grid-cols-2 lg:grid-cols-3 gap-4" : ""), children: Array.from({ length: Math.max(1, months) }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11292
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: cn(months > 1 ? "grid md:grid-cols-2 lg:grid-cols-3 gap-4" : ""), children: Array.from({ length: Math.max(1, months) }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(React32.Fragment, { children: renderMonth(addMonths(view, i)) }, `cal-month-${view.getFullYear()}-${view.getMonth()}-${i}`)) }),
|
|
11271
11293
|
effectiveEnableEventSheet && selectedEvent && selectedEventDate ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
11272
11294
|
Sheet,
|
|
11273
11295
|
{
|
|
@@ -11297,7 +11319,7 @@ function Calendar3({
|
|
|
11297
11319
|
}
|
|
11298
11320
|
|
|
11299
11321
|
// src/components/TimePicker.tsx
|
|
11300
|
-
var
|
|
11322
|
+
var React33 = __toESM(require("react"), 1);
|
|
11301
11323
|
var import_lucide_react18 = require("lucide-react");
|
|
11302
11324
|
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
11303
11325
|
var pad = (n) => n.toString().padStart(2, "0");
|
|
@@ -11324,21 +11346,21 @@ function WheelColumn2({
|
|
|
11324
11346
|
}) {
|
|
11325
11347
|
const height = itemHeight * WHEEL_VISIBLE_ITEMS2;
|
|
11326
11348
|
const paddingY = (height - itemHeight) / 2;
|
|
11327
|
-
const rafRef =
|
|
11328
|
-
const lastVirtualIndexRef =
|
|
11329
|
-
const wheelDeltaRef =
|
|
11330
|
-
const scrollEndTimeoutRef =
|
|
11331
|
-
const suppressScrollSelectUntilRef =
|
|
11332
|
-
const suppressItemClickUntilRef =
|
|
11333
|
-
const dragRef =
|
|
11334
|
-
const draggingRef =
|
|
11335
|
-
const inertialRef =
|
|
11336
|
-
const inertiaRafRef =
|
|
11337
|
-
const inertiaVelocityRef =
|
|
11338
|
-
const inertiaLastTimeRef =
|
|
11339
|
-
const moveSamplesRef =
|
|
11349
|
+
const rafRef = React33.useRef(0);
|
|
11350
|
+
const lastVirtualIndexRef = React33.useRef(null);
|
|
11351
|
+
const wheelDeltaRef = React33.useRef(0);
|
|
11352
|
+
const scrollEndTimeoutRef = React33.useRef(null);
|
|
11353
|
+
const suppressScrollSelectUntilRef = React33.useRef(0);
|
|
11354
|
+
const suppressItemClickUntilRef = React33.useRef(0);
|
|
11355
|
+
const dragRef = React33.useRef(null);
|
|
11356
|
+
const draggingRef = React33.useRef(false);
|
|
11357
|
+
const inertialRef = React33.useRef(false);
|
|
11358
|
+
const inertiaRafRef = React33.useRef(null);
|
|
11359
|
+
const inertiaVelocityRef = React33.useRef(0);
|
|
11360
|
+
const inertiaLastTimeRef = React33.useRef(0);
|
|
11361
|
+
const moveSamplesRef = React33.useRef([]);
|
|
11340
11362
|
const loop = true;
|
|
11341
|
-
const ui =
|
|
11363
|
+
const ui = React33.useMemo(() => {
|
|
11342
11364
|
if (size === "sm") {
|
|
11343
11365
|
return {
|
|
11344
11366
|
columnWidth: "min-w-16 max-w-21",
|
|
@@ -11365,9 +11387,9 @@ function WheelColumn2({
|
|
|
11365
11387
|
fadeHeight: "h-12"
|
|
11366
11388
|
};
|
|
11367
11389
|
}, [size]);
|
|
11368
|
-
const baseOffset =
|
|
11369
|
-
const extendedItems =
|
|
11370
|
-
const getNearestVirtualIndex =
|
|
11390
|
+
const baseOffset = React33.useMemo(() => loop ? items.length : 0, [items.length, loop]);
|
|
11391
|
+
const extendedItems = React33.useMemo(() => loop ? [...items, ...items, ...items] : items, [items, loop]);
|
|
11392
|
+
const getNearestVirtualIndex = React33.useCallback(
|
|
11371
11393
|
(realIndex, fromVirtual) => {
|
|
11372
11394
|
const len = items.length;
|
|
11373
11395
|
if (len <= 0) return 0;
|
|
@@ -11386,7 +11408,7 @@ function WheelColumn2({
|
|
|
11386
11408
|
},
|
|
11387
11409
|
[items.length, loop]
|
|
11388
11410
|
);
|
|
11389
|
-
|
|
11411
|
+
React33.useLayoutEffect(() => {
|
|
11390
11412
|
const el = scrollRef.current;
|
|
11391
11413
|
if (!el) return;
|
|
11392
11414
|
const maxVirtual = Math.max(0, extendedItems.length - 1);
|
|
@@ -11414,7 +11436,7 @@ function WheelColumn2({
|
|
|
11414
11436
|
cancelAnimationFrame(rafRef.current);
|
|
11415
11437
|
};
|
|
11416
11438
|
}, [animate, baseOffset, extendedItems.length, getNearestVirtualIndex, itemHeight, loop, scrollRef, valueIndex]);
|
|
11417
|
-
|
|
11439
|
+
React33.useEffect(() => {
|
|
11418
11440
|
const el = scrollRef.current;
|
|
11419
11441
|
if (!el) return;
|
|
11420
11442
|
const lastWheelSignRef = { current: 0 };
|
|
@@ -11502,11 +11524,11 @@ function WheelColumn2({
|
|
|
11502
11524
|
}, 120);
|
|
11503
11525
|
});
|
|
11504
11526
|
};
|
|
11505
|
-
const currentVirtual =
|
|
11527
|
+
const currentVirtual = React33.useMemo(() => {
|
|
11506
11528
|
if (!loop || items.length <= 0) return valueIndex;
|
|
11507
11529
|
return baseOffset + valueIndex;
|
|
11508
11530
|
}, [baseOffset, items.length, loop, valueIndex]);
|
|
11509
|
-
const commitFromScrollTop =
|
|
11531
|
+
const commitFromScrollTop = React33.useCallback(
|
|
11510
11532
|
(behavior) => {
|
|
11511
11533
|
const el = scrollRef.current;
|
|
11512
11534
|
if (!el) return;
|
|
@@ -11584,7 +11606,7 @@ function WheelColumn2({
|
|
|
11584
11606
|
if (dt > 0) inertiaVelocityRef.current = (el.scrollTop - oldest.top) / dt;
|
|
11585
11607
|
}
|
|
11586
11608
|
};
|
|
11587
|
-
const startInertia =
|
|
11609
|
+
const startInertia = React33.useCallback(() => {
|
|
11588
11610
|
const el = scrollRef.current;
|
|
11589
11611
|
if (!el) return;
|
|
11590
11612
|
if (items.length <= 0) return;
|
|
@@ -11785,44 +11807,44 @@ function TimePicker({
|
|
|
11785
11807
|
}) {
|
|
11786
11808
|
const tv = useSmartTranslations("ValidationInput");
|
|
11787
11809
|
const gi18n = useGlobalI18n();
|
|
11788
|
-
const autoId =
|
|
11810
|
+
const autoId = React33.useId();
|
|
11789
11811
|
const isControlled = value !== void 0;
|
|
11790
11812
|
const now = /* @__PURE__ */ new Date();
|
|
11791
11813
|
const initial = parseTime(isControlled ? value : defaultValue, format, includeSeconds) || (format === "12" ? { h: now.getHours() % 12 || 12, m: now.getMinutes(), s: now.getSeconds(), p: now.getHours() >= 12 ? "PM" : "AM" } : { h: now.getHours(), m: now.getMinutes(), s: now.getSeconds() });
|
|
11792
|
-
const [open, setOpen] =
|
|
11793
|
-
const [parts, setParts] =
|
|
11794
|
-
const [manualInput, setManualInput] =
|
|
11795
|
-
const [isDirectEditing, setIsDirectEditing] =
|
|
11796
|
-
const [focusedColumn, setFocusedColumn] =
|
|
11797
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
11798
|
-
const [hasCommittedValue, setHasCommittedValue] =
|
|
11799
|
-
const hourScrollRef =
|
|
11800
|
-
const minuteScrollRef =
|
|
11801
|
-
const secondScrollRef =
|
|
11802
|
-
const periodRef =
|
|
11803
|
-
const directEditInputRef =
|
|
11814
|
+
const [open, setOpen] = React33.useState(false);
|
|
11815
|
+
const [parts, setParts] = React33.useState(initial);
|
|
11816
|
+
const [manualInput, setManualInput] = React33.useState(formatTime2(initial, format, includeSeconds));
|
|
11817
|
+
const [isDirectEditing, setIsDirectEditing] = React33.useState(false);
|
|
11818
|
+
const [focusedColumn, setFocusedColumn] = React33.useState(null);
|
|
11819
|
+
const [localRequiredError, setLocalRequiredError] = React33.useState();
|
|
11820
|
+
const [hasCommittedValue, setHasCommittedValue] = React33.useState(Boolean(isControlled ? value : defaultValue));
|
|
11821
|
+
const hourScrollRef = React33.useRef(null);
|
|
11822
|
+
const minuteScrollRef = React33.useRef(null);
|
|
11823
|
+
const secondScrollRef = React33.useRef(null);
|
|
11824
|
+
const periodRef = React33.useRef(null);
|
|
11825
|
+
const directEditInputRef = React33.useRef(null);
|
|
11804
11826
|
const triggerId = `time-picker-trigger-${autoId}`;
|
|
11805
11827
|
const labelId = label ? `time-picker-label-${autoId}` : void 0;
|
|
11806
|
-
|
|
11828
|
+
React33.useEffect(() => {
|
|
11807
11829
|
if (isControlled) {
|
|
11808
11830
|
const parsed = parseTime(value, format, includeSeconds);
|
|
11809
11831
|
if (parsed) setParts(parsed);
|
|
11810
11832
|
}
|
|
11811
11833
|
}, [value, isControlled, format, includeSeconds]);
|
|
11812
|
-
|
|
11834
|
+
React33.useEffect(() => {
|
|
11813
11835
|
setManualInput(formatTime2(parts, format, includeSeconds));
|
|
11814
11836
|
}, [format, includeSeconds, parts]);
|
|
11815
|
-
|
|
11837
|
+
React33.useEffect(() => {
|
|
11816
11838
|
if (!isDirectEditing) return;
|
|
11817
11839
|
directEditInputRef.current?.focus();
|
|
11818
11840
|
directEditInputRef.current?.select();
|
|
11819
11841
|
}, [isDirectEditing]);
|
|
11820
|
-
|
|
11842
|
+
React33.useEffect(() => {
|
|
11821
11843
|
if (isControlled) {
|
|
11822
11844
|
setHasCommittedValue(Boolean(value));
|
|
11823
11845
|
}
|
|
11824
11846
|
}, [isControlled, value]);
|
|
11825
|
-
const isTimeDisabled =
|
|
11847
|
+
const isTimeDisabled = React33.useCallback(
|
|
11826
11848
|
(timeStr) => {
|
|
11827
11849
|
if (!disabledTimes) return false;
|
|
11828
11850
|
if (typeof disabledTimes === "function") return disabledTimes(timeStr);
|
|
@@ -11832,7 +11854,7 @@ function TimePicker({
|
|
|
11832
11854
|
);
|
|
11833
11855
|
const resolvedMinTime = minTime ?? min;
|
|
11834
11856
|
const resolvedMaxTime = maxTime ?? max;
|
|
11835
|
-
const toSeconds =
|
|
11857
|
+
const toSeconds = React33.useCallback(
|
|
11836
11858
|
(p) => {
|
|
11837
11859
|
let h = p.h;
|
|
11838
11860
|
if (format === "12") {
|
|
@@ -11844,7 +11866,7 @@ function TimePicker({
|
|
|
11844
11866
|
},
|
|
11845
11867
|
[format, includeSeconds]
|
|
11846
11868
|
);
|
|
11847
|
-
const isTimeInRange =
|
|
11869
|
+
const isTimeInRange = React33.useCallback(
|
|
11848
11870
|
(timeStr) => {
|
|
11849
11871
|
if (!resolvedMinTime && !resolvedMaxTime) return true;
|
|
11850
11872
|
const parsed = parseTime(timeStr, format, includeSeconds);
|
|
@@ -11862,7 +11884,7 @@ function TimePicker({
|
|
|
11862
11884
|
},
|
|
11863
11885
|
[format, includeSeconds, resolvedMaxTime, resolvedMinTime, toSeconds]
|
|
11864
11886
|
);
|
|
11865
|
-
const canEmit =
|
|
11887
|
+
const canEmit = React33.useCallback(
|
|
11866
11888
|
(next) => {
|
|
11867
11889
|
const timeStr = next ? formatTime2(next, format, includeSeconds) : void 0;
|
|
11868
11890
|
if (!timeStr) return true;
|
|
@@ -11872,7 +11894,7 @@ function TimePicker({
|
|
|
11872
11894
|
},
|
|
11873
11895
|
[format, includeSeconds, isTimeDisabled, isTimeInRange]
|
|
11874
11896
|
);
|
|
11875
|
-
const emit =
|
|
11897
|
+
const emit = React33.useCallback(
|
|
11876
11898
|
(next) => {
|
|
11877
11899
|
const timeStr = next ? formatTime2(next, format, includeSeconds) : void 0;
|
|
11878
11900
|
if (!canEmit(next)) return;
|
|
@@ -11884,7 +11906,7 @@ function TimePicker({
|
|
|
11884
11906
|
},
|
|
11885
11907
|
[canEmit, format, includeSeconds, isControlled, onChange]
|
|
11886
11908
|
);
|
|
11887
|
-
const tryUpdate =
|
|
11909
|
+
const tryUpdate = React33.useCallback(
|
|
11888
11910
|
(next) => {
|
|
11889
11911
|
if (!canEmit(next)) return false;
|
|
11890
11912
|
setParts(next);
|
|
@@ -11902,17 +11924,17 @@ function TimePicker({
|
|
|
11902
11924
|
setFocusedColumn(null);
|
|
11903
11925
|
}
|
|
11904
11926
|
};
|
|
11905
|
-
|
|
11927
|
+
React33.useEffect(() => {
|
|
11906
11928
|
if (disabled || !required || hasCommittedValue) {
|
|
11907
11929
|
setLocalRequiredError(void 0);
|
|
11908
11930
|
}
|
|
11909
11931
|
}, [disabled, hasCommittedValue, required]);
|
|
11910
|
-
const focusColumn =
|
|
11932
|
+
const focusColumn = React33.useCallback((column) => {
|
|
11911
11933
|
if (!column) return;
|
|
11912
11934
|
const target = column === "hour" ? hourScrollRef.current : column === "minute" ? minuteScrollRef.current : column === "second" ? secondScrollRef.current : periodRef.current;
|
|
11913
11935
|
target?.focus({ preventScroll: true });
|
|
11914
11936
|
}, []);
|
|
11915
|
-
|
|
11937
|
+
React33.useEffect(() => {
|
|
11916
11938
|
if (variant !== "inline" && !open) return;
|
|
11917
11939
|
focusColumn(focusedColumn);
|
|
11918
11940
|
}, [focusColumn, focusedColumn, open, variant]);
|
|
@@ -11994,7 +12016,7 @@ function TimePicker({
|
|
|
11994
12016
|
}
|
|
11995
12017
|
}
|
|
11996
12018
|
};
|
|
11997
|
-
const commitManualInput =
|
|
12019
|
+
const commitManualInput = React33.useCallback(
|
|
11998
12020
|
(input) => {
|
|
11999
12021
|
const trimmed = input.trim();
|
|
12000
12022
|
if (!trimmed) {
|
|
@@ -12025,12 +12047,12 @@ function TimePicker({
|
|
|
12025
12047
|
},
|
|
12026
12048
|
[display, format, includeSeconds, isTimeDisabled, isTimeInRange, tryUpdate]
|
|
12027
12049
|
);
|
|
12028
|
-
const startDirectEdit =
|
|
12050
|
+
const startDirectEdit = React33.useCallback(() => {
|
|
12029
12051
|
if (disabled) return;
|
|
12030
12052
|
setManualInput(display);
|
|
12031
12053
|
setIsDirectEditing(true);
|
|
12032
12054
|
}, [disabled, display]);
|
|
12033
|
-
const stopDirectEdit =
|
|
12055
|
+
const stopDirectEdit = React33.useCallback(
|
|
12034
12056
|
(mode) => {
|
|
12035
12057
|
if (mode === "commit") {
|
|
12036
12058
|
commitManualInput(manualInput);
|
|
@@ -12606,8 +12628,8 @@ var DateTimePicker = ({
|
|
|
12606
12628
|
const t = useSmartTranslations("DateTimePicker");
|
|
12607
12629
|
const tv = useSmartTranslations("ValidationInput");
|
|
12608
12630
|
const locale = useSmartLocale();
|
|
12609
|
-
const [open, setOpen] =
|
|
12610
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
12631
|
+
const [open, setOpen] = React34.useState(false);
|
|
12632
|
+
const [localRequiredError, setLocalRequiredError] = React34.useState();
|
|
12611
12633
|
const sizeStyles8 = {
|
|
12612
12634
|
sm: {
|
|
12613
12635
|
trigger: "h-8 px-2.5 py-1.5 text-sm md:h-7 md:text-xs",
|
|
@@ -12640,13 +12662,13 @@ var DateTimePicker = ({
|
|
|
12640
12662
|
gap: "gap-4"
|
|
12641
12663
|
}
|
|
12642
12664
|
};
|
|
12643
|
-
const [tempDate, setTempDate] =
|
|
12644
|
-
const [calendarMonth, setCalendarMonth] =
|
|
12645
|
-
|
|
12665
|
+
const [tempDate, setTempDate] = React34.useState(value);
|
|
12666
|
+
const [calendarMonth, setCalendarMonth] = React34.useState(() => value ?? /* @__PURE__ */ new Date());
|
|
12667
|
+
React34.useEffect(() => {
|
|
12646
12668
|
setTempDate(value);
|
|
12647
12669
|
setCalendarMonth(value ?? /* @__PURE__ */ new Date());
|
|
12648
12670
|
}, [value, open]);
|
|
12649
|
-
|
|
12671
|
+
React34.useEffect(() => {
|
|
12650
12672
|
if (disabled || !required || value) {
|
|
12651
12673
|
setLocalRequiredError(void 0);
|
|
12652
12674
|
}
|
|
@@ -12865,7 +12887,7 @@ var DateTimePicker = ({
|
|
|
12865
12887
|
};
|
|
12866
12888
|
|
|
12867
12889
|
// src/components/CalendarTimeline/CalendarTimeline.tsx
|
|
12868
|
-
var
|
|
12890
|
+
var React40 = __toESM(require("react"), 1);
|
|
12869
12891
|
var import_lucide_react23 = require("lucide-react");
|
|
12870
12892
|
|
|
12871
12893
|
// src/components/CalendarTimeline/date.ts
|
|
@@ -13105,10 +13127,10 @@ function intervalPack(items) {
|
|
|
13105
13127
|
}
|
|
13106
13128
|
|
|
13107
13129
|
// src/components/CalendarTimeline/hooks.ts
|
|
13108
|
-
var
|
|
13130
|
+
var React35 = __toESM(require("react"), 1);
|
|
13109
13131
|
function useHorizontalScrollSync(args) {
|
|
13110
13132
|
const { bodyRef, headerRef, leftRef } = args;
|
|
13111
|
-
|
|
13133
|
+
React35.useEffect(() => {
|
|
13112
13134
|
const body = bodyRef.current;
|
|
13113
13135
|
const header = headerRef.current;
|
|
13114
13136
|
const left = leftRef?.current ?? null;
|
|
@@ -13166,9 +13188,9 @@ function lowerBound(arr, target) {
|
|
|
13166
13188
|
function useVirtualVariableRows(args) {
|
|
13167
13189
|
const { enabled, overscan, rowHeights, scrollRef } = args;
|
|
13168
13190
|
const itemCount = rowHeights.length;
|
|
13169
|
-
const [viewportHeight, setViewportHeight] =
|
|
13170
|
-
const [scrollTop, setScrollTop] =
|
|
13171
|
-
|
|
13191
|
+
const [viewportHeight, setViewportHeight] = React35.useState(0);
|
|
13192
|
+
const [scrollTop, setScrollTop] = React35.useState(0);
|
|
13193
|
+
React35.useEffect(() => {
|
|
13172
13194
|
if (!enabled) {
|
|
13173
13195
|
setViewportHeight(0);
|
|
13174
13196
|
return;
|
|
@@ -13181,7 +13203,7 @@ function useVirtualVariableRows(args) {
|
|
|
13181
13203
|
ro.observe(el);
|
|
13182
13204
|
return () => ro.disconnect();
|
|
13183
13205
|
}, [enabled, scrollRef]);
|
|
13184
|
-
|
|
13206
|
+
React35.useEffect(() => {
|
|
13185
13207
|
if (!enabled) {
|
|
13186
13208
|
setScrollTop(0);
|
|
13187
13209
|
return;
|
|
@@ -13206,7 +13228,7 @@ function useVirtualVariableRows(args) {
|
|
|
13206
13228
|
el.removeEventListener("scroll", onScroll);
|
|
13207
13229
|
};
|
|
13208
13230
|
}, [enabled, scrollRef]);
|
|
13209
|
-
const prefix =
|
|
13231
|
+
const prefix = React35.useMemo(() => {
|
|
13210
13232
|
const out = new Array(itemCount + 1);
|
|
13211
13233
|
out[0] = 0;
|
|
13212
13234
|
for (let i = 0; i < itemCount; i++) {
|
|
@@ -13214,7 +13236,7 @@ function useVirtualVariableRows(args) {
|
|
|
13214
13236
|
}
|
|
13215
13237
|
return out;
|
|
13216
13238
|
}, [itemCount, rowHeights]);
|
|
13217
|
-
return
|
|
13239
|
+
return React35.useMemo(() => {
|
|
13218
13240
|
if (!enabled) {
|
|
13219
13241
|
return { startIndex: 0, endIndex: itemCount, topSpacer: 0, bottomSpacer: 0, totalHeight: prefix[itemCount] ?? 0 };
|
|
13220
13242
|
}
|
|
@@ -13230,8 +13252,8 @@ function useVirtualVariableRows(args) {
|
|
|
13230
13252
|
}, [enabled, itemCount, overscan, prefix, scrollTop, viewportHeight]);
|
|
13231
13253
|
}
|
|
13232
13254
|
function useClientWidth(ref) {
|
|
13233
|
-
const [width, setWidth] =
|
|
13234
|
-
|
|
13255
|
+
const [width, setWidth] = React35.useState(0);
|
|
13256
|
+
React35.useEffect(() => {
|
|
13235
13257
|
const el = ref.current;
|
|
13236
13258
|
if (!el) return;
|
|
13237
13259
|
const update = () => setWidth(el.clientWidth);
|
|
@@ -13454,7 +13476,7 @@ function resourcesById(resources) {
|
|
|
13454
13476
|
}
|
|
13455
13477
|
|
|
13456
13478
|
// src/components/CalendarTimeline/CalendarTimelineHeader.tsx
|
|
13457
|
-
var
|
|
13479
|
+
var React36 = __toESM(require("react"), 1);
|
|
13458
13480
|
var import_lucide_react20 = require("lucide-react");
|
|
13459
13481
|
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
13460
13482
|
var VIEW_ICONS = {
|
|
@@ -13485,7 +13507,7 @@ function CalendarTimelineHeader(props) {
|
|
|
13485
13507
|
headerRef,
|
|
13486
13508
|
slotHeaderNodes
|
|
13487
13509
|
} = props;
|
|
13488
|
-
const resolvedAvailableViews =
|
|
13510
|
+
const resolvedAvailableViews = React36.useMemo(
|
|
13489
13511
|
() => availableViews?.length ? availableViews : ["month", "week", "day", "sprint"],
|
|
13490
13512
|
[availableViews]
|
|
13491
13513
|
);
|
|
@@ -13494,22 +13516,22 @@ function CalendarTimelineHeader(props) {
|
|
|
13494
13516
|
const gi18n = useGlobalI18n();
|
|
13495
13517
|
const dt = useSmartTranslations("DateTimePicker");
|
|
13496
13518
|
const locale = useSmartLocale();
|
|
13497
|
-
const [todayOpen, setTodayOpen] =
|
|
13498
|
-
const [tempDate, setTempDate] =
|
|
13499
|
-
const [calendarMonth, setCalendarMonth] =
|
|
13500
|
-
|
|
13519
|
+
const [todayOpen, setTodayOpen] = React36.useState(false);
|
|
13520
|
+
const [tempDate, setTempDate] = React36.useState(() => now);
|
|
13521
|
+
const [calendarMonth, setCalendarMonth] = React36.useState(() => now);
|
|
13522
|
+
React36.useEffect(() => {
|
|
13501
13523
|
if (!todayOpen) return;
|
|
13502
13524
|
setTempDate(now);
|
|
13503
13525
|
setCalendarMonth(now);
|
|
13504
13526
|
}, [now, todayOpen]);
|
|
13505
|
-
const monthLabel =
|
|
13527
|
+
const monthLabel = React36.useCallback(
|
|
13506
13528
|
(date) => date.toLocaleDateString(locale === "vi" ? "vi-VN" : "en-US", {
|
|
13507
13529
|
month: "long",
|
|
13508
13530
|
year: "numeric"
|
|
13509
13531
|
}),
|
|
13510
13532
|
[locale]
|
|
13511
13533
|
);
|
|
13512
|
-
const weekdays =
|
|
13534
|
+
const weekdays = React36.useMemo(() => {
|
|
13513
13535
|
switch (locale) {
|
|
13514
13536
|
case "vi":
|
|
13515
13537
|
return ["CN", "T2", "T3", "T4", "T5", "T6", "T7"];
|
|
@@ -13521,12 +13543,12 @@ function CalendarTimelineHeader(props) {
|
|
|
13521
13543
|
return ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
|
13522
13544
|
}
|
|
13523
13545
|
}, [locale]);
|
|
13524
|
-
const getTimeString =
|
|
13546
|
+
const getTimeString = React36.useCallback((date) => {
|
|
13525
13547
|
const h = date.getHours();
|
|
13526
13548
|
const m = date.getMinutes();
|
|
13527
13549
|
return `${h.toString().padStart(2, "0")}:${m.toString().padStart(2, "0")}`;
|
|
13528
13550
|
}, []);
|
|
13529
|
-
const handleDateSelect =
|
|
13551
|
+
const handleDateSelect = React36.useCallback((date) => {
|
|
13530
13552
|
if (!(date instanceof Date)) return;
|
|
13531
13553
|
setTempDate((prev) => {
|
|
13532
13554
|
const next = new Date(date);
|
|
@@ -13534,7 +13556,7 @@ function CalendarTimelineHeader(props) {
|
|
|
13534
13556
|
return next;
|
|
13535
13557
|
});
|
|
13536
13558
|
}, []);
|
|
13537
|
-
const handleTimeChange =
|
|
13559
|
+
const handleTimeChange = React36.useCallback((timeStr) => {
|
|
13538
13560
|
if (!timeStr) return;
|
|
13539
13561
|
const [hStr, mStr] = timeStr.split(":");
|
|
13540
13562
|
const h = parseInt(hStr, 10);
|
|
@@ -13546,7 +13568,7 @@ function CalendarTimelineHeader(props) {
|
|
|
13546
13568
|
return next;
|
|
13547
13569
|
});
|
|
13548
13570
|
}, []);
|
|
13549
|
-
const applyDateTime =
|
|
13571
|
+
const applyDateTime = React36.useCallback(() => {
|
|
13550
13572
|
onApplyDateTime(tempDate);
|
|
13551
13573
|
setTodayOpen(false);
|
|
13552
13574
|
}, [onApplyDateTime, tempDate]);
|
|
@@ -13810,9 +13832,9 @@ function ResourceRowCell(props) {
|
|
|
13810
13832
|
}
|
|
13811
13833
|
|
|
13812
13834
|
// src/components/CalendarTimeline/CalendarTimelineGridOverlay.tsx
|
|
13813
|
-
var
|
|
13835
|
+
var React37 = __toESM(require("react"), 1);
|
|
13814
13836
|
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
13815
|
-
var CalendarTimelineGridOverlay =
|
|
13837
|
+
var CalendarTimelineGridOverlay = React37.memo(function CalendarTimelineGridOverlay2(props) {
|
|
13816
13838
|
const {
|
|
13817
13839
|
gridWidth,
|
|
13818
13840
|
height,
|
|
@@ -13860,12 +13882,12 @@ var CalendarTimelineGridOverlay = React36.memo(function CalendarTimelineGridOver
|
|
|
13860
13882
|
});
|
|
13861
13883
|
|
|
13862
13884
|
// src/components/CalendarTimeline/CalendarTimelineSlotHeaderCell.tsx
|
|
13863
|
-
var
|
|
13885
|
+
var React38 = __toESM(require("react"), 1);
|
|
13864
13886
|
var import_lucide_react22 = require("lucide-react");
|
|
13865
13887
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
13866
|
-
var CalendarTimelineSlotHeaderCell =
|
|
13888
|
+
var CalendarTimelineSlotHeaderCell = React38.memo(function CalendarTimelineSlotHeaderCell2(props) {
|
|
13867
13889
|
const { width, activeView, isToday: isToday2, label, ariaLabel, borderClassName, dayHeaderMarks, idx, className } = props;
|
|
13868
|
-
const content =
|
|
13890
|
+
const content = React38.useMemo(() => {
|
|
13869
13891
|
if (activeView === "day" && dayHeaderMarks) {
|
|
13870
13892
|
if (dayHeaderMarks.showEllipsis[idx]) return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "text-xs text-muted-foreground/70 select-none", children: "\u2026" });
|
|
13871
13893
|
if (!dayHeaderMarks.showTime[idx]) return null;
|
|
@@ -13888,7 +13910,7 @@ var CalendarTimelineSlotHeaderCell = React37.memo(function CalendarTimelineSlotH
|
|
|
13888
13910
|
});
|
|
13889
13911
|
|
|
13890
13912
|
// src/components/CalendarTimeline/internal-hooks.ts
|
|
13891
|
-
var
|
|
13913
|
+
var React39 = __toESM(require("react"), 1);
|
|
13892
13914
|
function useTimelineSlots(args) {
|
|
13893
13915
|
const {
|
|
13894
13916
|
activeView,
|
|
@@ -13903,7 +13925,7 @@ function useTimelineSlots(args) {
|
|
|
13903
13925
|
formatters,
|
|
13904
13926
|
dueDateSprint
|
|
13905
13927
|
} = args;
|
|
13906
|
-
const { slots, range } =
|
|
13928
|
+
const { slots, range } = React39.useMemo(() => {
|
|
13907
13929
|
const { start, end, slotStarts: slotStarts2 } = computeSlotStarts({
|
|
13908
13930
|
view: activeView,
|
|
13909
13931
|
date: activeDate,
|
|
@@ -13958,18 +13980,18 @@ function useTimelineSlots(args) {
|
|
|
13958
13980
|
const match = matchSprintDef(s, idx);
|
|
13959
13981
|
if (match && sprintRangeText) {
|
|
13960
13982
|
const rangeText = sprintRangeText(match.startMs, match.endMs);
|
|
13961
|
-
return
|
|
13983
|
+
return React39.createElement(
|
|
13962
13984
|
"span",
|
|
13963
13985
|
{ className: "inline-flex flex-col items-center leading-tight" },
|
|
13964
|
-
|
|
13965
|
-
|
|
13986
|
+
React39.createElement("span", { className: "text-[11px] font-semibold text-foreground truncate max-w-32" }, match.title),
|
|
13987
|
+
React39.createElement("span", { className: "text-[10px] font-medium text-muted-foreground/70" }, rangeText)
|
|
13966
13988
|
);
|
|
13967
13989
|
}
|
|
13968
|
-
return
|
|
13990
|
+
return React39.createElement(
|
|
13969
13991
|
"span",
|
|
13970
13992
|
{ className: "inline-flex flex-col items-center leading-tight" },
|
|
13971
|
-
|
|
13972
|
-
|
|
13993
|
+
React39.createElement("span", { className: "text-[10px] font-medium uppercase tracking-wider text-muted-foreground/70" }, "S"),
|
|
13994
|
+
React39.createElement("span", { className: "text-sm font-semibold text-foreground" }, String(idx + 1).padStart(2, "0"))
|
|
13973
13995
|
);
|
|
13974
13996
|
})(),
|
|
13975
13997
|
isToday: (() => {
|
|
@@ -13997,9 +14019,9 @@ function useTimelineSlots(args) {
|
|
|
13997
14019
|
weekStartsOn,
|
|
13998
14020
|
workHours
|
|
13999
14021
|
]);
|
|
14000
|
-
const slotStarts =
|
|
14001
|
-
const todaySlotIdx =
|
|
14002
|
-
const weekendSlotIdxs =
|
|
14022
|
+
const slotStarts = React39.useMemo(() => slots.map((s) => s.start), [slots]);
|
|
14023
|
+
const todaySlotIdx = React39.useMemo(() => slots.findIndex((s) => s.isToday), [slots]);
|
|
14024
|
+
const weekendSlotIdxs = React39.useMemo(() => {
|
|
14003
14025
|
const out = [];
|
|
14004
14026
|
for (let i = 0; i < slots.length; i++) if (slots[i]?.isWeekend) out.push(i);
|
|
14005
14027
|
return out;
|
|
@@ -14008,16 +14030,16 @@ function useTimelineSlots(args) {
|
|
|
14008
14030
|
}
|
|
14009
14031
|
function useNormalizedEvents(args) {
|
|
14010
14032
|
const { events, range, activeView, resolvedTimeZone, resources } = args;
|
|
14011
|
-
const normalizedEvents =
|
|
14033
|
+
const normalizedEvents = React39.useMemo(() => {
|
|
14012
14034
|
return normalizeEvents({ events, range, view: activeView, timeZone: resolvedTimeZone });
|
|
14013
14035
|
}, [activeView, events, range, resolvedTimeZone]);
|
|
14014
|
-
const eventsByResource =
|
|
14015
|
-
const resourceById =
|
|
14036
|
+
const eventsByResource = React39.useMemo(() => eventsByResourceId(normalizedEvents), [normalizedEvents]);
|
|
14037
|
+
const resourceById = React39.useMemo(() => resourcesById(resources), [resources]);
|
|
14016
14038
|
return { normalizedEvents, eventsByResource, resourceById };
|
|
14017
14039
|
}
|
|
14018
14040
|
function useDayHeaderMarks(args) {
|
|
14019
14041
|
const { enabled, activeView, normalizedEvents, slotStarts, slotCount } = args;
|
|
14020
|
-
return
|
|
14042
|
+
return React39.useMemo(() => {
|
|
14021
14043
|
if (!enabled) return null;
|
|
14022
14044
|
if (activeView !== "day") return null;
|
|
14023
14045
|
const n = slotCount;
|
|
@@ -14052,14 +14074,14 @@ function useSlotMetrics(args) {
|
|
|
14052
14074
|
dayHeaderSmart,
|
|
14053
14075
|
daySlotCompression
|
|
14054
14076
|
} = args;
|
|
14055
|
-
const fixedSlotWidth =
|
|
14077
|
+
const fixedSlotWidth = React39.useMemo(() => {
|
|
14056
14078
|
const baseSlotWidth = activeView === "month" || activeView === "day" ? effectiveSlotMinWidth * 3 : effectiveSlotMinWidth;
|
|
14057
14079
|
if (activeView !== "week") return baseSlotWidth;
|
|
14058
14080
|
if (bodyClientWidth <= 0) return baseSlotWidth;
|
|
14059
14081
|
if (slotsLength <= 0) return baseSlotWidth;
|
|
14060
14082
|
return Math.max(baseSlotWidth, bodyClientWidth / slotsLength);
|
|
14061
14083
|
}, [activeView, bodyClientWidth, effectiveSlotMinWidth, slotsLength]);
|
|
14062
|
-
const slotMetrics =
|
|
14084
|
+
const slotMetrics = React39.useMemo(() => {
|
|
14063
14085
|
const n = slotsLength;
|
|
14064
14086
|
const widths = new Array(n).fill(fixedSlotWidth);
|
|
14065
14087
|
const isAdaptiveView = activeView === "month" || activeView === "day";
|
|
@@ -14190,7 +14212,7 @@ function useSlotMetrics(args) {
|
|
|
14190
14212
|
}
|
|
14191
14213
|
function useLayoutsByResource(args) {
|
|
14192
14214
|
const { eventsByResource, preview, slotStarts, slotsLength, slotLefts, getResourceRowHeight, laneGap, lanePaddingY, effectiveMaxLanesPerRow, eventHeight } = args;
|
|
14193
|
-
return
|
|
14215
|
+
return React39.useMemo(() => {
|
|
14194
14216
|
const map = /* @__PURE__ */ new Map();
|
|
14195
14217
|
for (const [resourceId, list] of eventsByResource.entries()) {
|
|
14196
14218
|
const mapped = list.map((ev) => {
|
|
@@ -14237,9 +14259,9 @@ function lowerBound2(arr, target) {
|
|
|
14237
14259
|
}
|
|
14238
14260
|
function useVisibleSlotRange(args) {
|
|
14239
14261
|
const { enabled, overscan, scrollRef, slotLefts, slotCount } = args;
|
|
14240
|
-
const [scrollLeft, setScrollLeft] =
|
|
14241
|
-
const [viewportWidth, setViewportWidth] =
|
|
14242
|
-
|
|
14262
|
+
const [scrollLeft, setScrollLeft] = React39.useState(0);
|
|
14263
|
+
const [viewportWidth, setViewportWidth] = React39.useState(0);
|
|
14264
|
+
React39.useEffect(() => {
|
|
14243
14265
|
if (!enabled) return;
|
|
14244
14266
|
const el = scrollRef.current;
|
|
14245
14267
|
if (!el) return;
|
|
@@ -14266,7 +14288,7 @@ function useVisibleSlotRange(args) {
|
|
|
14266
14288
|
el.removeEventListener("scroll", onScroll);
|
|
14267
14289
|
};
|
|
14268
14290
|
}, [enabled, scrollRef]);
|
|
14269
|
-
return
|
|
14291
|
+
return React39.useMemo(() => {
|
|
14270
14292
|
if (!enabled) return { startIdx: 0, endIdx: slotCount };
|
|
14271
14293
|
if (slotCount <= 0) return { startIdx: 0, endIdx: 0 };
|
|
14272
14294
|
if (viewportWidth <= 0) return { startIdx: 0, endIdx: slotCount };
|
|
@@ -14365,14 +14387,14 @@ function CalendarTimeline({
|
|
|
14365
14387
|
}) {
|
|
14366
14388
|
const t = useSmartTranslations("CalendarTimeline");
|
|
14367
14389
|
const detectedLocale = useSmartLocale();
|
|
14368
|
-
const resolvedLocale =
|
|
14369
|
-
const resolvedTimeZone =
|
|
14390
|
+
const resolvedLocale = React40.useMemo(() => localeToBCP47(locale ?? detectedLocale), [locale, detectedLocale]);
|
|
14391
|
+
const resolvedTimeZone = React40.useMemo(() => timeZone ?? Intl.DateTimeFormat().resolvedOptions().timeZone ?? "UTC", [timeZone]);
|
|
14370
14392
|
const effectiveEnableEventSheet = enableEventSheet ?? Boolean(renderEventSheet);
|
|
14371
14393
|
const isViewOnly = interactions?.mode === "view";
|
|
14372
14394
|
const isControlledSelectedEventId = selectedEventId !== void 0;
|
|
14373
|
-
const [internalSelectedEventId, setInternalSelectedEventId] =
|
|
14395
|
+
const [internalSelectedEventId, setInternalSelectedEventId] = React40.useState(defaultSelectedEventId ?? null);
|
|
14374
14396
|
const activeSelectedEventId = isControlledSelectedEventId ? selectedEventId : internalSelectedEventId;
|
|
14375
|
-
const setSelectedEventId =
|
|
14397
|
+
const setSelectedEventId = React40.useCallback(
|
|
14376
14398
|
(next) => {
|
|
14377
14399
|
if (!isControlledSelectedEventId) setInternalSelectedEventId(next);
|
|
14378
14400
|
onSelectedEventIdChange?.(next);
|
|
@@ -14380,9 +14402,9 @@ function CalendarTimeline({
|
|
|
14380
14402
|
[isControlledSelectedEventId, onSelectedEventIdChange]
|
|
14381
14403
|
);
|
|
14382
14404
|
const isControlledEventSheetOpen = eventSheetOpen !== void 0;
|
|
14383
|
-
const [internalEventSheetOpen, setInternalEventSheetOpen] =
|
|
14405
|
+
const [internalEventSheetOpen, setInternalEventSheetOpen] = React40.useState(defaultEventSheetOpen ?? false);
|
|
14384
14406
|
const activeEventSheetOpen = isControlledEventSheetOpen ? Boolean(eventSheetOpen) : internalEventSheetOpen;
|
|
14385
|
-
const setEventSheetOpen =
|
|
14407
|
+
const setEventSheetOpen = React40.useCallback(
|
|
14386
14408
|
(next) => {
|
|
14387
14409
|
if (!isControlledEventSheetOpen) setInternalEventSheetOpen(next);
|
|
14388
14410
|
onEventSheetOpenChange?.(next);
|
|
@@ -14391,12 +14413,12 @@ function CalendarTimeline({
|
|
|
14391
14413
|
[isControlledEventSheetOpen, onEventSheetOpenChange, setSelectedEventId]
|
|
14392
14414
|
);
|
|
14393
14415
|
const showResourceColumn = !hideResourceColumn;
|
|
14394
|
-
const sizeConfig =
|
|
14416
|
+
const sizeConfig = React40.useMemo(() => getSizeConfig(size), [size]);
|
|
14395
14417
|
const densityClass = sizeConfig.densityClass;
|
|
14396
14418
|
const eventHeight = sizeConfig.eventHeight;
|
|
14397
14419
|
const laneGap = sizeConfig.laneGap;
|
|
14398
14420
|
const lanePaddingY = sizeConfig.lanePaddingY;
|
|
14399
|
-
const canResizeColumn =
|
|
14421
|
+
const canResizeColumn = React40.useMemo(() => {
|
|
14400
14422
|
const cfg = enableLayoutResize;
|
|
14401
14423
|
if (!cfg) return false;
|
|
14402
14424
|
if (isViewOnly) return false;
|
|
@@ -14404,7 +14426,7 @@ function CalendarTimeline({
|
|
|
14404
14426
|
if (cfg === true) return true;
|
|
14405
14427
|
return cfg.column !== false;
|
|
14406
14428
|
}, [enableLayoutResize, isViewOnly, showResourceColumn]);
|
|
14407
|
-
const canResizeRow =
|
|
14429
|
+
const canResizeRow = React40.useMemo(() => {
|
|
14408
14430
|
const cfg = enableLayoutResize;
|
|
14409
14431
|
if (!cfg) return false;
|
|
14410
14432
|
if (isViewOnly) return false;
|
|
@@ -14413,19 +14435,19 @@ function CalendarTimeline({
|
|
|
14413
14435
|
return cfg.row !== false;
|
|
14414
14436
|
}, [enableLayoutResize, isViewOnly, showResourceColumn]);
|
|
14415
14437
|
const isControlledResourceColumnWidth = resourceColumnWidth !== void 0;
|
|
14416
|
-
const [internalResourceColumnWidth, setInternalResourceColumnWidth] =
|
|
14438
|
+
const [internalResourceColumnWidth, setInternalResourceColumnWidth] = React40.useState(() => {
|
|
14417
14439
|
const init = defaultResourceColumnWidth ?? sizeConfig.resourceColumnWidth;
|
|
14418
14440
|
return typeof init === "number" ? init : sizeConfig.resourceColumnWidth;
|
|
14419
14441
|
});
|
|
14420
|
-
|
|
14442
|
+
React40.useEffect(() => {
|
|
14421
14443
|
if (isControlledResourceColumnWidth) return;
|
|
14422
14444
|
if (defaultResourceColumnWidth == null) return;
|
|
14423
14445
|
setInternalResourceColumnWidth(defaultResourceColumnWidth);
|
|
14424
14446
|
}, [defaultResourceColumnWidth, isControlledResourceColumnWidth]);
|
|
14425
14447
|
const effectiveResourceColumnWidth = showResourceColumn ? isControlledResourceColumnWidth ? resourceColumnWidth : internalResourceColumnWidth : 0;
|
|
14426
14448
|
const isControlledRowHeight = rowHeight !== void 0;
|
|
14427
|
-
const [internalRowHeight, setInternalRowHeight] =
|
|
14428
|
-
|
|
14449
|
+
const [internalRowHeight, setInternalRowHeight] = React40.useState(() => defaultRowHeight ?? sizeConfig.rowHeight);
|
|
14450
|
+
React40.useEffect(() => {
|
|
14429
14451
|
if (isControlledRowHeight) return;
|
|
14430
14452
|
if (defaultRowHeight == null) return;
|
|
14431
14453
|
setInternalRowHeight(defaultRowHeight);
|
|
@@ -14436,14 +14458,14 @@ function CalendarTimeline({
|
|
|
14436
14458
|
const colMax = maxResourceColumnWidth ?? 520;
|
|
14437
14459
|
const rowMin = minRowHeight ?? 36;
|
|
14438
14460
|
const rowMax = maxRowHeight ?? 120;
|
|
14439
|
-
const viewList =
|
|
14440
|
-
const availableViews =
|
|
14461
|
+
const viewList = React40.useMemo(() => Array.isArray(view) ? view : void 0, [view]);
|
|
14462
|
+
const availableViews = React40.useMemo(() => {
|
|
14441
14463
|
if (onlyView) return [onlyView];
|
|
14442
14464
|
if (viewList?.length) return viewList;
|
|
14443
14465
|
return ["month", "week", "day", "sprint"];
|
|
14444
14466
|
}, [onlyView, viewList]);
|
|
14445
14467
|
const isControlledView = view !== void 0 && !Array.isArray(view);
|
|
14446
|
-
const [internalView, setInternalView] =
|
|
14468
|
+
const [internalView, setInternalView] = React40.useState(() => {
|
|
14447
14469
|
if (onlyView) return onlyView;
|
|
14448
14470
|
if (viewList?.length) {
|
|
14449
14471
|
if (defaultView && viewList.includes(defaultView)) return defaultView;
|
|
@@ -14452,13 +14474,13 @@ function CalendarTimeline({
|
|
|
14452
14474
|
return defaultView ?? "month";
|
|
14453
14475
|
});
|
|
14454
14476
|
const activeView = onlyView ? onlyView : isControlledView ? view : internalView;
|
|
14455
|
-
|
|
14477
|
+
React40.useEffect(() => {
|
|
14456
14478
|
if (onlyView || isControlledView) return;
|
|
14457
14479
|
if (!availableViews.includes(internalView)) {
|
|
14458
14480
|
setInternalView(availableViews[0] ?? "month");
|
|
14459
14481
|
}
|
|
14460
14482
|
}, [availableViews, internalView, isControlledView, onlyView]);
|
|
14461
|
-
const effectiveSlotMinWidth =
|
|
14483
|
+
const effectiveSlotMinWidth = React40.useMemo(() => {
|
|
14462
14484
|
if (slotMinWidth == null) {
|
|
14463
14485
|
if (activeView === "month" && monthEventStyle === "compact") {
|
|
14464
14486
|
return clamp5(Math.round(sizeConfig.slotMinWidth * 0.55), 32, sizeConfig.slotMinWidth);
|
|
@@ -14470,17 +14492,17 @@ function CalendarTimeline({
|
|
|
14470
14492
|
return baseSlotMinWidth;
|
|
14471
14493
|
}, [activeView, baseSlotMinWidth, monthEventStyle, sizeConfig.slotMinWidth, slotMinWidth]);
|
|
14472
14494
|
const isControlledDate = date !== void 0;
|
|
14473
|
-
const [internalDate, setInternalDate] =
|
|
14495
|
+
const [internalDate, setInternalDate] = React40.useState(() => defaultDate ?? /* @__PURE__ */ new Date());
|
|
14474
14496
|
const activeDate = isControlledDate ? date : internalDate;
|
|
14475
|
-
const resolvedNow =
|
|
14476
|
-
const formatToken =
|
|
14497
|
+
const resolvedNow = React40.useMemo(() => now ?? /* @__PURE__ */ new Date(), [now]);
|
|
14498
|
+
const formatToken = React40.useCallback((key, params) => {
|
|
14477
14499
|
let message = t(key);
|
|
14478
14500
|
for (const [name, value] of Object.entries(params)) {
|
|
14479
14501
|
message = message.replaceAll(`{${name}}`, String(value));
|
|
14480
14502
|
}
|
|
14481
14503
|
return message;
|
|
14482
14504
|
}, [t]);
|
|
14483
|
-
const l =
|
|
14505
|
+
const l = React40.useMemo(
|
|
14484
14506
|
() => ({
|
|
14485
14507
|
today: labels?.today ?? t("today"),
|
|
14486
14508
|
prev: labels?.prev ?? t("prev"),
|
|
@@ -14503,7 +14525,7 @@ function CalendarTimeline({
|
|
|
14503
14525
|
}),
|
|
14504
14526
|
[formatToken, labels, t]
|
|
14505
14527
|
);
|
|
14506
|
-
const setView =
|
|
14528
|
+
const setView = React40.useCallback(
|
|
14507
14529
|
(next) => {
|
|
14508
14530
|
if (onlyView) return;
|
|
14509
14531
|
if (!availableViews.includes(next)) return;
|
|
@@ -14512,14 +14534,14 @@ function CalendarTimeline({
|
|
|
14512
14534
|
},
|
|
14513
14535
|
[availableViews, isControlledView, onViewChange, onlyView]
|
|
14514
14536
|
);
|
|
14515
|
-
const setDate =
|
|
14537
|
+
const setDate = React40.useCallback(
|
|
14516
14538
|
(next) => {
|
|
14517
14539
|
if (!isControlledDate) setInternalDate(next);
|
|
14518
14540
|
onDateChange?.(next);
|
|
14519
14541
|
},
|
|
14520
14542
|
[isControlledDate, onDateChange]
|
|
14521
14543
|
);
|
|
14522
|
-
const navigate =
|
|
14544
|
+
const navigate = React40.useCallback(
|
|
14523
14545
|
(dir) => {
|
|
14524
14546
|
const base2 = activeDate;
|
|
14525
14547
|
if (activeView === "month") {
|
|
@@ -14538,17 +14560,17 @@ function CalendarTimeline({
|
|
|
14538
14560
|
},
|
|
14539
14561
|
[activeDate, activeView, resolvedTimeZone, setDate]
|
|
14540
14562
|
);
|
|
14541
|
-
const [internalCollapsed, setInternalCollapsed] =
|
|
14563
|
+
const [internalCollapsed, setInternalCollapsed] = React40.useState(() => defaultGroupCollapsed ?? {});
|
|
14542
14564
|
const collapsed = groupCollapsed ?? internalCollapsed;
|
|
14543
|
-
const setCollapsed =
|
|
14565
|
+
const setCollapsed = React40.useCallback(
|
|
14544
14566
|
(next) => {
|
|
14545
14567
|
if (!groupCollapsed) setInternalCollapsed(next);
|
|
14546
14568
|
onGroupCollapsedChange?.(next);
|
|
14547
14569
|
},
|
|
14548
14570
|
[groupCollapsed, onGroupCollapsedChange]
|
|
14549
14571
|
);
|
|
14550
|
-
const rows =
|
|
14551
|
-
const groupResourceCounts =
|
|
14572
|
+
const rows = React40.useMemo(() => buildRows({ resources, groups, collapsed }), [resources, groups, collapsed]);
|
|
14573
|
+
const groupResourceCounts = React40.useMemo(() => getGroupResourceCounts(resources), [resources]);
|
|
14552
14574
|
const { slots, range, slotStarts, todaySlotIdx, weekendSlotIdxs } = useTimelineSlots({
|
|
14553
14575
|
activeView,
|
|
14554
14576
|
activeDate,
|
|
@@ -14562,12 +14584,12 @@ function CalendarTimeline({
|
|
|
14562
14584
|
formatters,
|
|
14563
14585
|
dueDateSprint
|
|
14564
14586
|
});
|
|
14565
|
-
|
|
14587
|
+
React40.useEffect(() => {
|
|
14566
14588
|
onRangeChange?.(range);
|
|
14567
14589
|
}, [range, onRangeChange]);
|
|
14568
|
-
const leftRef =
|
|
14569
|
-
const bodyRef =
|
|
14570
|
-
const headerRef =
|
|
14590
|
+
const leftRef = React40.useRef(null);
|
|
14591
|
+
const bodyRef = React40.useRef(null);
|
|
14592
|
+
const headerRef = React40.useRef(null);
|
|
14571
14593
|
const bodyClientWidth = useClientWidth(bodyRef);
|
|
14572
14594
|
const { normalizedEvents, eventsByResource, resourceById } = useNormalizedEvents({
|
|
14573
14595
|
events,
|
|
@@ -14599,16 +14621,16 @@ function CalendarTimeline({
|
|
|
14599
14621
|
slotLefts,
|
|
14600
14622
|
slotCount: slots.length
|
|
14601
14623
|
});
|
|
14602
|
-
const selectedEvent =
|
|
14624
|
+
const selectedEvent = React40.useMemo(() => {
|
|
14603
14625
|
if (!activeSelectedEventId) return null;
|
|
14604
14626
|
const found2 = normalizedEvents.find((e) => e.id === activeSelectedEventId);
|
|
14605
14627
|
return found2 ?? null;
|
|
14606
14628
|
}, [activeSelectedEventId, normalizedEvents]);
|
|
14607
|
-
const selectedResource =
|
|
14629
|
+
const selectedResource = React40.useMemo(() => {
|
|
14608
14630
|
if (!selectedEvent) return void 0;
|
|
14609
14631
|
return resourceById.get(selectedEvent.resourceId);
|
|
14610
14632
|
}, [resourceById, selectedEvent]);
|
|
14611
|
-
const selectedTimeText =
|
|
14633
|
+
const selectedTimeText = React40.useMemo(() => {
|
|
14612
14634
|
if (!selectedEvent) return "";
|
|
14613
14635
|
return formatters?.eventTime?.({
|
|
14614
14636
|
start: selectedEvent._start,
|
|
@@ -14618,7 +14640,7 @@ function CalendarTimeline({
|
|
|
14618
14640
|
view: activeView
|
|
14619
14641
|
}) ?? defaultEventTime({ start: selectedEvent._start, end: selectedEvent._end, locale: resolvedLocale, timeZone: resolvedTimeZone, view: activeView });
|
|
14620
14642
|
}, [activeView, formatters, resolvedLocale, resolvedTimeZone, selectedEvent]);
|
|
14621
|
-
|
|
14643
|
+
React40.useEffect(() => {
|
|
14622
14644
|
if (!effectiveEnableEventSheet) return;
|
|
14623
14645
|
if (activeEventSheetOpen && activeSelectedEventId && !selectedEvent) {
|
|
14624
14646
|
setEventSheetOpen(false);
|
|
@@ -14628,24 +14650,24 @@ function CalendarTimeline({
|
|
|
14628
14650
|
const virt = virtualization == null ? rows.length > 60 : Boolean(virtualization.enabled);
|
|
14629
14651
|
const overscan = virtualization?.overscan ?? 8;
|
|
14630
14652
|
const isControlledRowHeights = rowHeights !== void 0;
|
|
14631
|
-
const [internalRowHeights, setInternalRowHeights] =
|
|
14632
|
-
|
|
14653
|
+
const [internalRowHeights, setInternalRowHeights] = React40.useState(() => defaultRowHeights ?? {});
|
|
14654
|
+
React40.useEffect(() => {
|
|
14633
14655
|
if (isControlledRowHeights) return;
|
|
14634
14656
|
if (!defaultRowHeights) return;
|
|
14635
14657
|
setInternalRowHeights(defaultRowHeights);
|
|
14636
14658
|
}, [defaultRowHeights, isControlledRowHeights]);
|
|
14637
14659
|
const activeRowHeights = isControlledRowHeights ? rowHeights : internalRowHeights;
|
|
14638
|
-
const autoRowHeightCfg =
|
|
14660
|
+
const autoRowHeightCfg = React40.useMemo(() => {
|
|
14639
14661
|
if (!autoRowHeight) return null;
|
|
14640
14662
|
return autoRowHeight === true ? {} : autoRowHeight;
|
|
14641
14663
|
}, [autoRowHeight]);
|
|
14642
|
-
const effectiveMaxLanesPerRow =
|
|
14664
|
+
const effectiveMaxLanesPerRow = React40.useMemo(() => {
|
|
14643
14665
|
if (!autoRowHeightCfg) return maxLanesPerRow;
|
|
14644
14666
|
const maxLanes = autoRowHeightCfg.maxLanesPerRow;
|
|
14645
14667
|
if (typeof maxLanes === "number" && Number.isFinite(maxLanes) && maxLanes > 0) return Math.floor(maxLanes);
|
|
14646
14668
|
return Number.POSITIVE_INFINITY;
|
|
14647
14669
|
}, [autoRowHeightCfg, maxLanesPerRow]);
|
|
14648
|
-
const autoRowHeightsByResource =
|
|
14670
|
+
const autoRowHeightsByResource = React40.useMemo(() => {
|
|
14649
14671
|
if (!autoRowHeightCfg) return null;
|
|
14650
14672
|
const maxRowHeight2 = autoRowHeightCfg.maxRowHeight;
|
|
14651
14673
|
const out = /* @__PURE__ */ new Map();
|
|
@@ -14663,7 +14685,7 @@ function CalendarTimeline({
|
|
|
14663
14685
|
}
|
|
14664
14686
|
return out;
|
|
14665
14687
|
}, [autoRowHeightCfg, eventHeight, eventsByResource, laneGap, lanePaddingY, slotStarts, slots.length, effectiveMaxLanesPerRow]);
|
|
14666
|
-
const getResourceRowHeight =
|
|
14688
|
+
const getResourceRowHeight = React40.useCallback(
|
|
14667
14689
|
(resourceId) => {
|
|
14668
14690
|
const h = activeRowHeights[resourceId];
|
|
14669
14691
|
const base2 = typeof h === "number" && Number.isFinite(h) && h > 0 ? h : effectiveRowHeight;
|
|
@@ -14673,7 +14695,7 @@ function CalendarTimeline({
|
|
|
14673
14695
|
},
|
|
14674
14696
|
[activeRowHeights, autoRowHeightsByResource, effectiveRowHeight]
|
|
14675
14697
|
);
|
|
14676
|
-
const setRowHeightForResource =
|
|
14698
|
+
const setRowHeightForResource = React40.useCallback(
|
|
14677
14699
|
(resourceId, height) => {
|
|
14678
14700
|
const clamped = clamp5(Math.round(height), rowMin, rowMax);
|
|
14679
14701
|
onRowHeightChange?.(clamped);
|
|
@@ -14690,7 +14712,7 @@ function CalendarTimeline({
|
|
|
14690
14712
|
},
|
|
14691
14713
|
[activeRowHeights, isControlledRowHeights, onRowHeightChange, onRowHeightsChange, rowMax, rowMin]
|
|
14692
14714
|
);
|
|
14693
|
-
const rowHeightsArray =
|
|
14715
|
+
const rowHeightsArray = React40.useMemo(() => {
|
|
14694
14716
|
return rows.map((r) => {
|
|
14695
14717
|
if (r.kind === "resource") return getResourceRowHeight(r.resource.id);
|
|
14696
14718
|
return sizeConfig.groupRowHeight;
|
|
@@ -14706,13 +14728,13 @@ function CalendarTimeline({
|
|
|
14706
14728
|
const endRow = virt ? virtualResult.endIndex : rows.length;
|
|
14707
14729
|
const topSpacer = virt ? virtualResult.topSpacer : 0;
|
|
14708
14730
|
const bottomSpacer = virt ? virtualResult.bottomSpacer : 0;
|
|
14709
|
-
const renderedRowsHeight =
|
|
14731
|
+
const renderedRowsHeight = React40.useMemo(() => {
|
|
14710
14732
|
let h = 0;
|
|
14711
14733
|
for (let i = startRow; i < endRow; i++) h += rowHeightsArray[i] ?? effectiveRowHeight;
|
|
14712
14734
|
return h;
|
|
14713
14735
|
}, [effectiveRowHeight, endRow, rowHeightsArray, startRow]);
|
|
14714
|
-
const resizeRef =
|
|
14715
|
-
const setResourceColumnWidth =
|
|
14736
|
+
const resizeRef = React40.useRef(null);
|
|
14737
|
+
const setResourceColumnWidth = React40.useCallback(
|
|
14716
14738
|
(next) => {
|
|
14717
14739
|
const clamped = clamp5(Math.round(next), colMin, colMax);
|
|
14718
14740
|
if (!isControlledResourceColumnWidth) setInternalResourceColumnWidth(clamped);
|
|
@@ -14720,7 +14742,7 @@ function CalendarTimeline({
|
|
|
14720
14742
|
},
|
|
14721
14743
|
[colMax, colMin, isControlledResourceColumnWidth, onResourceColumnWidthChange]
|
|
14722
14744
|
);
|
|
14723
|
-
const startResize =
|
|
14745
|
+
const startResize = React40.useCallback(
|
|
14724
14746
|
(mode, e, args) => {
|
|
14725
14747
|
if (e.button !== 0 || e.ctrlKey) return;
|
|
14726
14748
|
resizeRef.current = {
|
|
@@ -14763,7 +14785,7 @@ function CalendarTimeline({
|
|
|
14763
14785
|
},
|
|
14764
14786
|
[setResourceColumnWidth, setRowHeightForResource]
|
|
14765
14787
|
);
|
|
14766
|
-
|
|
14788
|
+
React40.useEffect(() => {
|
|
14767
14789
|
return () => {
|
|
14768
14790
|
if (!resizeRef.current) return;
|
|
14769
14791
|
resizeRef.current = null;
|
|
@@ -14771,7 +14793,7 @@ function CalendarTimeline({
|
|
|
14771
14793
|
document.body.style.userSelect = "";
|
|
14772
14794
|
};
|
|
14773
14795
|
}, []);
|
|
14774
|
-
const beginResizeColumn =
|
|
14796
|
+
const beginResizeColumn = React40.useCallback(
|
|
14775
14797
|
(e) => {
|
|
14776
14798
|
if (!canResizeColumn) return;
|
|
14777
14799
|
if (typeof effectiveResourceColumnWidth !== "number") return;
|
|
@@ -14779,7 +14801,7 @@ function CalendarTimeline({
|
|
|
14779
14801
|
},
|
|
14780
14802
|
[canResizeColumn, effectiveResourceColumnWidth, effectiveRowHeight, startResize]
|
|
14781
14803
|
);
|
|
14782
|
-
const beginResizeResourceRow =
|
|
14804
|
+
const beginResizeResourceRow = React40.useCallback(
|
|
14783
14805
|
(resourceId) => (e) => {
|
|
14784
14806
|
if (!canResizeRow) return;
|
|
14785
14807
|
startResize("row", e, {
|
|
@@ -14790,7 +14812,7 @@ function CalendarTimeline({
|
|
|
14790
14812
|
},
|
|
14791
14813
|
[canResizeRow, effectiveResourceColumnWidth, getResourceRowHeight, startResize]
|
|
14792
14814
|
);
|
|
14793
|
-
const title =
|
|
14815
|
+
const title = React40.useMemo(() => {
|
|
14794
14816
|
if (activeView === "month") {
|
|
14795
14817
|
return formatters?.monthTitle?.(activeDate, { locale: resolvedLocale, timeZone: resolvedTimeZone }) ?? defaultMonthTitle(activeDate, resolvedLocale, resolvedTimeZone);
|
|
14796
14818
|
}
|
|
@@ -14817,11 +14839,11 @@ function CalendarTimeline({
|
|
|
14817
14839
|
}, [activeDate, activeView, formatToken, formatters, l.sprint, l.week, range.end, range.start, resolvedLocale, resolvedTimeZone, slots.length]);
|
|
14818
14840
|
const createMode = interactions?.createMode ?? "drag";
|
|
14819
14841
|
const canCreate = !isViewOnly && (interactions?.creatable ?? false) && !!onCreateEvent;
|
|
14820
|
-
const [createOpen, setCreateOpen] =
|
|
14821
|
-
const [createResourceId, setCreateResourceId] =
|
|
14822
|
-
const [createStartIdx, setCreateStartIdx] =
|
|
14823
|
-
const [createEndIdx, setCreateEndIdx] =
|
|
14824
|
-
const resourceOptions =
|
|
14842
|
+
const [createOpen, setCreateOpen] = React40.useState(false);
|
|
14843
|
+
const [createResourceId, setCreateResourceId] = React40.useState(null);
|
|
14844
|
+
const [createStartIdx, setCreateStartIdx] = React40.useState(0);
|
|
14845
|
+
const [createEndIdx, setCreateEndIdx] = React40.useState(1);
|
|
14846
|
+
const resourceOptions = React40.useMemo(() => {
|
|
14825
14847
|
return resources.map((r) => ({
|
|
14826
14848
|
label: typeof r.label === "string" ? r.label : r.id,
|
|
14827
14849
|
value: r.id,
|
|
@@ -14829,7 +14851,7 @@ function CalendarTimeline({
|
|
|
14829
14851
|
disabled: r.disabled ?? false
|
|
14830
14852
|
}));
|
|
14831
14853
|
}, [resources]);
|
|
14832
|
-
const formatCreateBoundaryLabel =
|
|
14854
|
+
const formatCreateBoundaryLabel = React40.useMemo(() => {
|
|
14833
14855
|
const timeFmt = getDtf(resolvedLocale, resolvedTimeZone, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" });
|
|
14834
14856
|
const dayFmt = getDtf(resolvedLocale, resolvedTimeZone, { weekday: "short", month: "short", day: "numeric" });
|
|
14835
14857
|
const yearFmt = getDtf(resolvedLocale, resolvedTimeZone, { year: "numeric" });
|
|
@@ -14877,7 +14899,7 @@ function CalendarTimeline({
|
|
|
14877
14899
|
return dayFmt.format(d);
|
|
14878
14900
|
};
|
|
14879
14901
|
}, [activeView, dueDateSprint, l.sprint, resolvedLocale, resolvedTimeZone, slotStarts]);
|
|
14880
|
-
const openCreate =
|
|
14902
|
+
const openCreate = React40.useCallback(() => {
|
|
14881
14903
|
if (!canCreate) return;
|
|
14882
14904
|
if (activeEventSheetOpen) setEventSheetOpen(false);
|
|
14883
14905
|
const firstResource = resources.find((r) => !r.disabled)?.id ?? resources[0]?.id ?? null;
|
|
@@ -14909,13 +14931,13 @@ function CalendarTimeline({
|
|
|
14909
14931
|
slotStarts,
|
|
14910
14932
|
slots.length
|
|
14911
14933
|
]);
|
|
14912
|
-
|
|
14934
|
+
React40.useEffect(() => {
|
|
14913
14935
|
setCreateEndIdx((prev) => Math.min(slots.length, Math.max(prev, createStartIdx + 1)));
|
|
14914
14936
|
}, [createStartIdx, slots.length]);
|
|
14915
|
-
const createStartOptions =
|
|
14937
|
+
const createStartOptions = React40.useMemo(() => {
|
|
14916
14938
|
return slotStarts.map((d, idx) => ({ label: formatCreateBoundaryLabel(d, { kind: "start", boundaryIdx: idx }), value: idx }));
|
|
14917
14939
|
}, [formatCreateBoundaryLabel, slotStarts]);
|
|
14918
|
-
const createEndOptions =
|
|
14940
|
+
const createEndOptions = React40.useMemo(() => {
|
|
14919
14941
|
const out = [];
|
|
14920
14942
|
for (let idx = createStartIdx + 1; idx <= slotStarts.length; idx++) {
|
|
14921
14943
|
const boundary = idx >= slotStarts.length ? range.end : slotStarts[idx];
|
|
@@ -14923,7 +14945,7 @@ function CalendarTimeline({
|
|
|
14923
14945
|
}
|
|
14924
14946
|
return out;
|
|
14925
14947
|
}, [createStartIdx, formatCreateBoundaryLabel, range.end, slotStarts]);
|
|
14926
|
-
const commitCreate =
|
|
14948
|
+
const commitCreate = React40.useCallback(() => {
|
|
14927
14949
|
if (!onCreateEvent) return;
|
|
14928
14950
|
if (!createResourceId) return;
|
|
14929
14951
|
const start = slotStarts[clamp5(createStartIdx, 0, Math.max(0, slotStarts.length - 1))];
|
|
@@ -14934,38 +14956,38 @@ function CalendarTimeline({
|
|
|
14934
14956
|
onCreateEvent({ resourceId: createResourceId, start, end: endBoundary });
|
|
14935
14957
|
setCreateOpen(false);
|
|
14936
14958
|
}, [createEndIdx, createResourceId, createStartIdx, onCreateEvent, range.end, slotStarts]);
|
|
14937
|
-
const dragRef =
|
|
14938
|
-
const [preview, setPreviewState] =
|
|
14939
|
-
const previewRef =
|
|
14940
|
-
const setPreview =
|
|
14959
|
+
const dragRef = React40.useRef(null);
|
|
14960
|
+
const [preview, setPreviewState] = React40.useState(null);
|
|
14961
|
+
const previewRef = React40.useRef(null);
|
|
14962
|
+
const setPreview = React40.useCallback((next) => {
|
|
14941
14963
|
previewRef.current = next;
|
|
14942
14964
|
setPreviewState(next);
|
|
14943
14965
|
}, []);
|
|
14944
|
-
const suppressNextEventClickRef =
|
|
14945
|
-
const [hoverCell, setHoverCellState] =
|
|
14946
|
-
const hoverCellRef =
|
|
14947
|
-
const setHoverCell =
|
|
14966
|
+
const suppressNextEventClickRef = React40.useRef(false);
|
|
14967
|
+
const [hoverCell, setHoverCellState] = React40.useState(null);
|
|
14968
|
+
const hoverCellRef = React40.useRef(null);
|
|
14969
|
+
const setHoverCell = React40.useCallback((next) => {
|
|
14948
14970
|
hoverCellRef.current = next;
|
|
14949
14971
|
setHoverCellState(next);
|
|
14950
14972
|
}, []);
|
|
14951
|
-
const autoScrollStateRef =
|
|
14973
|
+
const autoScrollStateRef = React40.useRef({
|
|
14952
14974
|
dir: 0,
|
|
14953
14975
|
speed: 0,
|
|
14954
14976
|
lastClientX: 0,
|
|
14955
14977
|
lastClientY: 0
|
|
14956
14978
|
});
|
|
14957
|
-
const autoScrollRafRef =
|
|
14958
|
-
const dragPreviewRafRef =
|
|
14959
|
-
const dragPreviewPointRef =
|
|
14960
|
-
const hoverCellRafRef =
|
|
14961
|
-
const hoverCellPendingRef =
|
|
14962
|
-
const stopAutoScroll =
|
|
14979
|
+
const autoScrollRafRef = React40.useRef(null);
|
|
14980
|
+
const dragPreviewRafRef = React40.useRef(null);
|
|
14981
|
+
const dragPreviewPointRef = React40.useRef(null);
|
|
14982
|
+
const hoverCellRafRef = React40.useRef(null);
|
|
14983
|
+
const hoverCellPendingRef = React40.useRef(null);
|
|
14984
|
+
const stopAutoScroll = React40.useCallback(() => {
|
|
14963
14985
|
if (autoScrollRafRef.current != null) cancelAnimationFrame(autoScrollRafRef.current);
|
|
14964
14986
|
autoScrollRafRef.current = null;
|
|
14965
14987
|
autoScrollStateRef.current.dir = 0;
|
|
14966
14988
|
autoScrollStateRef.current.speed = 0;
|
|
14967
14989
|
}, []);
|
|
14968
|
-
const getPointerContext =
|
|
14990
|
+
const getPointerContext = React40.useCallback(
|
|
14969
14991
|
(clientX, clientY, opts) => {
|
|
14970
14992
|
const body = bodyRef.current;
|
|
14971
14993
|
if (!body) return null;
|
|
@@ -14983,7 +15005,7 @@ function CalendarTimeline({
|
|
|
14983
15005
|
},
|
|
14984
15006
|
[xToSlotIdx]
|
|
14985
15007
|
);
|
|
14986
|
-
const slotToDate =
|
|
15008
|
+
const slotToDate = React40.useCallback(
|
|
14987
15009
|
(slotIdx) => {
|
|
14988
15010
|
const start = slotStarts[clamp5(slotIdx, 0, slotStarts.length - 1)];
|
|
14989
15011
|
if (activeView === "day") {
|
|
@@ -14997,7 +15019,7 @@ function CalendarTimeline({
|
|
|
14997
15019
|
},
|
|
14998
15020
|
[activeView, dayTimeStepMinutes, resolvedTimeZone, slotStarts]
|
|
14999
15021
|
);
|
|
15000
|
-
const updateDragPreview =
|
|
15022
|
+
const updateDragPreview = React40.useCallback(
|
|
15001
15023
|
(clientX, clientY) => {
|
|
15002
15024
|
const drag = dragRef.current;
|
|
15003
15025
|
if (!drag) return;
|
|
@@ -15041,13 +15063,13 @@ function CalendarTimeline({
|
|
|
15041
15063
|
},
|
|
15042
15064
|
[getPointerContext, range.end, range.start, setPreview, slotToDate, slots.length]
|
|
15043
15065
|
);
|
|
15044
|
-
const flushDragPreview =
|
|
15066
|
+
const flushDragPreview = React40.useCallback(() => {
|
|
15045
15067
|
dragPreviewRafRef.current = null;
|
|
15046
15068
|
const point = dragPreviewPointRef.current;
|
|
15047
15069
|
if (!point) return;
|
|
15048
15070
|
updateDragPreview(point.x, point.y);
|
|
15049
15071
|
}, [updateDragPreview]);
|
|
15050
|
-
const scheduleDragPreview =
|
|
15072
|
+
const scheduleDragPreview = React40.useCallback(
|
|
15051
15073
|
(clientX, clientY) => {
|
|
15052
15074
|
dragPreviewPointRef.current = { x: clientX, y: clientY };
|
|
15053
15075
|
if (dragPreviewRafRef.current != null) return;
|
|
@@ -15055,7 +15077,7 @@ function CalendarTimeline({
|
|
|
15055
15077
|
},
|
|
15056
15078
|
[flushDragPreview]
|
|
15057
15079
|
);
|
|
15058
|
-
const applyHoverCell =
|
|
15080
|
+
const applyHoverCell = React40.useCallback(
|
|
15059
15081
|
(next) => {
|
|
15060
15082
|
const prev = hoverCellRef.current;
|
|
15061
15083
|
const same = prev == null && next == null || prev != null && next != null && prev.resourceId === next.resourceId && prev.slotIdx === next.slotIdx && Math.abs(prev.y - next.y) <= 0.5;
|
|
@@ -15064,11 +15086,11 @@ function CalendarTimeline({
|
|
|
15064
15086
|
},
|
|
15065
15087
|
[setHoverCell]
|
|
15066
15088
|
);
|
|
15067
|
-
const flushHoverCell =
|
|
15089
|
+
const flushHoverCell = React40.useCallback(() => {
|
|
15068
15090
|
hoverCellRafRef.current = null;
|
|
15069
15091
|
applyHoverCell(hoverCellPendingRef.current);
|
|
15070
15092
|
}, [applyHoverCell]);
|
|
15071
|
-
const scheduleHoverCell =
|
|
15093
|
+
const scheduleHoverCell = React40.useCallback(
|
|
15072
15094
|
(next) => {
|
|
15073
15095
|
hoverCellPendingRef.current = next;
|
|
15074
15096
|
if (hoverCellRafRef.current != null) return;
|
|
@@ -15076,7 +15098,7 @@ function CalendarTimeline({
|
|
|
15076
15098
|
},
|
|
15077
15099
|
[flushHoverCell]
|
|
15078
15100
|
);
|
|
15079
|
-
const autoScrollTick =
|
|
15101
|
+
const autoScrollTick = React40.useCallback(() => {
|
|
15080
15102
|
const drag = dragRef.current;
|
|
15081
15103
|
const body = bodyRef.current;
|
|
15082
15104
|
const st = autoScrollStateRef.current;
|
|
@@ -15095,7 +15117,7 @@ function CalendarTimeline({
|
|
|
15095
15117
|
updateDragPreview(st.lastClientX, st.lastClientY);
|
|
15096
15118
|
autoScrollRafRef.current = requestAnimationFrame(autoScrollTick);
|
|
15097
15119
|
}, [stopAutoScroll, updateDragPreview]);
|
|
15098
|
-
const updateAutoScrollFromPointer =
|
|
15120
|
+
const updateAutoScrollFromPointer = React40.useCallback(
|
|
15099
15121
|
(clientX, clientY) => {
|
|
15100
15122
|
const body = bodyRef.current;
|
|
15101
15123
|
if (!body) return;
|
|
@@ -15126,8 +15148,8 @@ function CalendarTimeline({
|
|
|
15126
15148
|
},
|
|
15127
15149
|
[autoScrollTick, stopAutoScroll]
|
|
15128
15150
|
);
|
|
15129
|
-
|
|
15130
|
-
|
|
15151
|
+
React40.useEffect(() => stopAutoScroll, [stopAutoScroll]);
|
|
15152
|
+
React40.useEffect(() => {
|
|
15131
15153
|
return () => {
|
|
15132
15154
|
if (dragPreviewRafRef.current != null) cancelAnimationFrame(dragPreviewRafRef.current);
|
|
15133
15155
|
if (hoverCellRafRef.current != null) cancelAnimationFrame(hoverCellRafRef.current);
|
|
@@ -15274,7 +15296,7 @@ function CalendarTimeline({
|
|
|
15274
15296
|
}
|
|
15275
15297
|
setPreview(null);
|
|
15276
15298
|
};
|
|
15277
|
-
const onBodyPointerLeave =
|
|
15299
|
+
const onBodyPointerLeave = React40.useCallback(() => {
|
|
15278
15300
|
hoverCellPendingRef.current = null;
|
|
15279
15301
|
if (hoverCellRafRef.current != null) {
|
|
15280
15302
|
cancelAnimationFrame(hoverCellRafRef.current);
|
|
@@ -15301,7 +15323,7 @@ function CalendarTimeline({
|
|
|
15301
15323
|
}
|
|
15302
15324
|
);
|
|
15303
15325
|
};
|
|
15304
|
-
const slotHeaderNodes =
|
|
15326
|
+
const slotHeaderNodes = React40.useMemo(() => {
|
|
15305
15327
|
const startIdx = colVirtEnabled ? visibleSlots.startIdx : 0;
|
|
15306
15328
|
const endIdx = colVirtEnabled ? visibleSlots.endIdx : slots.length;
|
|
15307
15329
|
const leftSpacer = startIdx > 0 ? slotLefts[startIdx] ?? 0 : 0;
|
|
@@ -15627,7 +15649,7 @@ function CalendarTimeline({
|
|
|
15627
15649
|
]
|
|
15628
15650
|
}
|
|
15629
15651
|
);
|
|
15630
|
-
if (!enableEventTooltips) return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
15652
|
+
if (!enableEventTooltips) return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(React40.Fragment, { children: block }, ev.id);
|
|
15631
15653
|
const tooltipContent = /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-col gap-0.5", children: [
|
|
15632
15654
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "font-semibold", children: tooltipTitle }),
|
|
15633
15655
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "text-xs opacity-80", children: timeText }),
|
|
@@ -15784,7 +15806,7 @@ function CalendarTimeline({
|
|
|
15784
15806
|
}
|
|
15785
15807
|
|
|
15786
15808
|
// src/components/MultiCombobox.tsx
|
|
15787
|
-
var
|
|
15809
|
+
var React41 = __toESM(require("react"), 1);
|
|
15788
15810
|
var import_react20 = require("react");
|
|
15789
15811
|
var import_react_virtual2 = require("@tanstack/react-virtual");
|
|
15790
15812
|
var import_lucide_react24 = require("lucide-react");
|
|
@@ -15852,17 +15874,17 @@ var MultiCombobox = ({
|
|
|
15852
15874
|
const searchPlaceholder = searchPlaceholderProp ?? gi18n.searchPlaceholder ?? "Search...";
|
|
15853
15875
|
const loadingText = loadingTextProp ?? gi18n.loading ?? "Loading...";
|
|
15854
15876
|
const emptyText = emptyTextProp ?? gi18n.noResults ?? "No results found";
|
|
15855
|
-
const [query, setQuery] =
|
|
15856
|
-
const [open, setOpen] =
|
|
15857
|
-
const [activeIndex, setActiveIndex] =
|
|
15858
|
-
const [localRequiredError, setLocalRequiredError] =
|
|
15859
|
-
const inputRef =
|
|
15860
|
-
const listRef =
|
|
15861
|
-
const optionsListRef =
|
|
15877
|
+
const [query, setQuery] = React41.useState("");
|
|
15878
|
+
const [open, setOpen] = React41.useState(false);
|
|
15879
|
+
const [activeIndex, setActiveIndex] = React41.useState(null);
|
|
15880
|
+
const [localRequiredError, setLocalRequiredError] = React41.useState();
|
|
15881
|
+
const inputRef = React41.useRef(null);
|
|
15882
|
+
const listRef = React41.useRef([]);
|
|
15883
|
+
const optionsListRef = React41.useRef(null);
|
|
15862
15884
|
useOverlayScrollbarTarget(optionsListRef, { enabled: open && useOverlayScrollbar && !virtualized });
|
|
15863
|
-
const triggerRef =
|
|
15885
|
+
const triggerRef = React41.useRef(null);
|
|
15864
15886
|
useShadCNAnimations();
|
|
15865
|
-
const normalizedOptions =
|
|
15887
|
+
const normalizedOptions = React41.useMemo(
|
|
15866
15888
|
() => options.map(
|
|
15867
15889
|
(o) => typeof o === "string" ? { value: o, label: o } : { value: o.value, label: o.label, icon: o.icon, description: o.description, disabled: o.disabled, group: o.group }
|
|
15868
15890
|
),
|
|
@@ -15872,7 +15894,7 @@ var MultiCombobox = ({
|
|
|
15872
15894
|
const trimmedQuery = query.trim();
|
|
15873
15895
|
const queryMeetsMinimum = trimmedQuery.length >= minSearchLength;
|
|
15874
15896
|
const shouldPromptForSearch = minSearchLength > 0 && !queryMeetsMinimum && (searchMode === "manual" || showSearchPromptWhenEmptyQuery);
|
|
15875
|
-
const filtered =
|
|
15897
|
+
const filtered = React41.useMemo(() => {
|
|
15876
15898
|
if (shouldPromptForSearch) return [];
|
|
15877
15899
|
if (!enableSearch || searchMode === "manual") return normalizedOptions;
|
|
15878
15900
|
const normalizedQuery = trimmedQuery.toLowerCase();
|
|
@@ -15881,7 +15903,7 @@ var MultiCombobox = ({
|
|
|
15881
15903
|
(opt) => opt.label.toLowerCase().includes(normalizedQuery) || opt.description?.toLowerCase().includes(normalizedQuery)
|
|
15882
15904
|
);
|
|
15883
15905
|
}, [enableSearch, normalizedOptions, searchMode, shouldPromptForSearch, trimmedQuery]);
|
|
15884
|
-
const renderLimitedOptions =
|
|
15906
|
+
const renderLimitedOptions = React41.useMemo(() => {
|
|
15885
15907
|
if (trimmedQuery || maxInitialOptions === void 0 || maxInitialOptions < 1) {
|
|
15886
15908
|
return filtered;
|
|
15887
15909
|
}
|
|
@@ -15897,14 +15919,14 @@ var MultiCombobox = ({
|
|
|
15897
15919
|
enabled: canVirtualize
|
|
15898
15920
|
});
|
|
15899
15921
|
const virtualItems = canVirtualize ? optionVirtualizer.getVirtualItems() : [];
|
|
15900
|
-
const scrollVirtualListToIndex =
|
|
15922
|
+
const scrollVirtualListToIndex = React41.useCallback((index) => {
|
|
15901
15923
|
if (!canVirtualize || renderLimitedOptions.length === 0) return;
|
|
15902
15924
|
optionVirtualizer.scrollToIndex(index, { align: "auto" });
|
|
15903
15925
|
}, [canVirtualize, optionVirtualizer, renderLimitedOptions.length]);
|
|
15904
|
-
const scrollVirtualListToStart =
|
|
15926
|
+
const scrollVirtualListToStart = React41.useCallback(() => {
|
|
15905
15927
|
scrollVirtualListToIndex(0);
|
|
15906
15928
|
}, [scrollVirtualListToIndex]);
|
|
15907
|
-
const groupedOptions =
|
|
15929
|
+
const groupedOptions = React41.useMemo(() => {
|
|
15908
15930
|
if (!groupBy) return null;
|
|
15909
15931
|
const groups = /* @__PURE__ */ new Map();
|
|
15910
15932
|
renderLimitedOptions.forEach((opt) => {
|
|
@@ -15957,12 +15979,12 @@ var MultiCombobox = ({
|
|
|
15957
15979
|
onChange([]);
|
|
15958
15980
|
};
|
|
15959
15981
|
const effectiveError = error ?? localRequiredError;
|
|
15960
|
-
|
|
15982
|
+
React41.useEffect(() => {
|
|
15961
15983
|
if (disabled || !required || value.length > 0) {
|
|
15962
15984
|
setLocalRequiredError(void 0);
|
|
15963
15985
|
}
|
|
15964
15986
|
}, [disabled, required, value.length]);
|
|
15965
|
-
|
|
15987
|
+
React41.useEffect(() => {
|
|
15966
15988
|
if (open && enableSearch) {
|
|
15967
15989
|
setTimeout(() => {
|
|
15968
15990
|
inputRef.current?.focus();
|
|
@@ -15973,12 +15995,12 @@ var MultiCombobox = ({
|
|
|
15973
15995
|
scrollVirtualListToStart();
|
|
15974
15996
|
}
|
|
15975
15997
|
}, [enableSearch, open, scrollVirtualListToStart]);
|
|
15976
|
-
|
|
15998
|
+
React41.useEffect(() => {
|
|
15977
15999
|
if (!onSearchChange) return void 0;
|
|
15978
16000
|
const timeoutId = window.setTimeout(() => onSearchChange(query), searchDebounceMs);
|
|
15979
16001
|
return () => window.clearTimeout(timeoutId);
|
|
15980
16002
|
}, [onSearchChange, query, searchDebounceMs]);
|
|
15981
|
-
|
|
16003
|
+
React41.useEffect(() => {
|
|
15982
16004
|
if (process.env.NODE_ENV !== "production" && normalizedOptions.length > 300 && !virtualized && searchMode !== "manual" && maxInitialOptions === void 0) {
|
|
15983
16005
|
console.warn(
|
|
15984
16006
|
'[Underverse UI] MultiCombobox received more than 300 options without virtualization, manual search, or maxInitialOptions. Use virtualized, searchMode="manual", or maxInitialOptions to avoid rendering a large dropdown.'
|
|
@@ -16217,7 +16239,7 @@ var MultiCombobox = ({
|
|
|
16217
16239
|
}
|
|
16218
16240
|
)
|
|
16219
16241
|
] });
|
|
16220
|
-
const selectedOptionFallbackMap =
|
|
16242
|
+
const selectedOptionFallbackMap = React41.useMemo(
|
|
16221
16243
|
() => new Map((selectedOptionsProp ?? []).map((option) => [option.value, option])),
|
|
16222
16244
|
[selectedOptionsProp]
|
|
16223
16245
|
);
|
|
@@ -16251,7 +16273,7 @@ var MultiCombobox = ({
|
|
|
16251
16273
|
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: cn("flex items-center gap-1.5 flex-1 overflow-hidden", size === "sm" ? "min-h-4" : size === "lg" ? "min-h-8" : "min-h-6"), children: value.length > 0 ? showTags ? /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
|
|
16252
16274
|
visibleTags.map((option) => {
|
|
16253
16275
|
if (renderTag) {
|
|
16254
|
-
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
16276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(React41.Fragment, { children: renderTag(option, () => handleRemove(option.value)) }, option.value);
|
|
16255
16277
|
}
|
|
16256
16278
|
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
16257
16279
|
"span",
|
|
@@ -16413,17 +16435,17 @@ var MultiCombobox = ({
|
|
|
16413
16435
|
};
|
|
16414
16436
|
|
|
16415
16437
|
// src/components/RadioGroup.tsx
|
|
16416
|
-
var
|
|
16438
|
+
var React42 = __toESM(require("react"), 1);
|
|
16417
16439
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
16418
|
-
var RadioGroupContext =
|
|
16440
|
+
var RadioGroupContext = React42.createContext(void 0);
|
|
16419
16441
|
var useRadioGroup = () => {
|
|
16420
|
-
const context =
|
|
16442
|
+
const context = React42.useContext(RadioGroupContext);
|
|
16421
16443
|
if (!context) {
|
|
16422
16444
|
throw new Error("RadioGroupItem must be used within a RadioGroup");
|
|
16423
16445
|
}
|
|
16424
16446
|
return context;
|
|
16425
16447
|
};
|
|
16426
|
-
var RadioGroup =
|
|
16448
|
+
var RadioGroup = React42.forwardRef(
|
|
16427
16449
|
({
|
|
16428
16450
|
value,
|
|
16429
16451
|
defaultValue,
|
|
@@ -16439,7 +16461,7 @@ var RadioGroup = React41.forwardRef(
|
|
|
16439
16461
|
error = false,
|
|
16440
16462
|
errorMessage
|
|
16441
16463
|
}, ref) => {
|
|
16442
|
-
const [internalValue, setInternalValue] =
|
|
16464
|
+
const [internalValue, setInternalValue] = React42.useState(defaultValue || "");
|
|
16443
16465
|
const isControlled = value !== void 0;
|
|
16444
16466
|
const currentValue = isControlled ? value : internalValue;
|
|
16445
16467
|
const handleValueChange = (newValue) => {
|
|
@@ -16450,7 +16472,7 @@ var RadioGroup = React41.forwardRef(
|
|
|
16450
16472
|
onValueChange?.(newValue);
|
|
16451
16473
|
}
|
|
16452
16474
|
};
|
|
16453
|
-
const uniqueId =
|
|
16475
|
+
const uniqueId = React42.useId();
|
|
16454
16476
|
const radioName = name || `radio-group-${uniqueId}`;
|
|
16455
16477
|
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
|
|
16456
16478
|
RadioGroupContext.Provider,
|
|
@@ -16508,7 +16530,7 @@ var sizeStyles7 = {
|
|
|
16508
16530
|
padding: "p-4"
|
|
16509
16531
|
}
|
|
16510
16532
|
};
|
|
16511
|
-
var RadioGroupItem =
|
|
16533
|
+
var RadioGroupItem = React42.forwardRef(
|
|
16512
16534
|
({ value, id, disabled, className, children, label, labelClassName, description, icon }, ref) => {
|
|
16513
16535
|
const { value: selectedValue, onValueChange, name, disabled: groupDisabled, size = "md", variant = "default" } = useRadioGroup();
|
|
16514
16536
|
const isDisabled = disabled || groupDisabled;
|
|
@@ -16686,7 +16708,7 @@ var RadioGroupItem = React41.forwardRef(
|
|
|
16686
16708
|
RadioGroupItem.displayName = "RadioGroupItem";
|
|
16687
16709
|
|
|
16688
16710
|
// src/components/Slider.tsx
|
|
16689
|
-
var
|
|
16711
|
+
var React43 = __toESM(require("react"), 1);
|
|
16690
16712
|
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
16691
16713
|
var SIZE_STYLES = {
|
|
16692
16714
|
sm: {
|
|
@@ -16739,7 +16761,7 @@ function SliderTooltip({
|
|
|
16739
16761
|
}
|
|
16740
16762
|
);
|
|
16741
16763
|
}
|
|
16742
|
-
var Slider =
|
|
16764
|
+
var Slider = React43.forwardRef(
|
|
16743
16765
|
({
|
|
16744
16766
|
className,
|
|
16745
16767
|
mode = "single",
|
|
@@ -16775,28 +16797,28 @@ var Slider = React42.forwardRef(
|
|
|
16775
16797
|
}, ref) => {
|
|
16776
16798
|
const gi18n = useGlobalI18n();
|
|
16777
16799
|
const isRange = mode === "range";
|
|
16778
|
-
const trackRef =
|
|
16779
|
-
const [internalValue, setInternalValue] =
|
|
16780
|
-
const [internalRange, setInternalRange] =
|
|
16800
|
+
const trackRef = React43.useRef(null);
|
|
16801
|
+
const [internalValue, setInternalValue] = React43.useState(defaultValue);
|
|
16802
|
+
const [internalRange, setInternalRange] = React43.useState(() => {
|
|
16781
16803
|
if (defaultRangeValue) return defaultRangeValue;
|
|
16782
16804
|
const v = clamp6(defaultValue, min, max);
|
|
16783
16805
|
return [min, v];
|
|
16784
16806
|
});
|
|
16785
|
-
const [activeThumb, setActiveThumb] =
|
|
16786
|
-
const dragRef =
|
|
16787
|
-
const [isHovering, setIsHovering] =
|
|
16788
|
-
const [isDragging, setIsDragging] =
|
|
16807
|
+
const [activeThumb, setActiveThumb] = React43.useState(null);
|
|
16808
|
+
const dragRef = React43.useRef(null);
|
|
16809
|
+
const [isHovering, setIsHovering] = React43.useState(false);
|
|
16810
|
+
const [isDragging, setIsDragging] = React43.useState(false);
|
|
16789
16811
|
const isControlled = value !== void 0;
|
|
16790
16812
|
const currentValue = isControlled ? value : internalValue;
|
|
16791
16813
|
const isRangeControlled = rangeValue !== void 0;
|
|
16792
16814
|
const currentRange = isRangeControlled ? rangeValue : internalRange;
|
|
16793
16815
|
const rangeMin = clamp6(currentRange[0] ?? min, min, max);
|
|
16794
16816
|
const rangeMax = clamp6(currentRange[1] ?? max, min, max);
|
|
16795
|
-
const normalizedRange =
|
|
16817
|
+
const normalizedRange = React43.useMemo(
|
|
16796
16818
|
() => rangeMin <= rangeMax ? [rangeMin, rangeMax] : [rangeMax, rangeMin],
|
|
16797
16819
|
[rangeMax, rangeMin]
|
|
16798
16820
|
);
|
|
16799
|
-
const handleSingleChange =
|
|
16821
|
+
const handleSingleChange = React43.useCallback(
|
|
16800
16822
|
(e) => {
|
|
16801
16823
|
const newValue = Number(e.target.value);
|
|
16802
16824
|
if (!isControlled) {
|
|
@@ -16807,14 +16829,14 @@ var Slider = React42.forwardRef(
|
|
|
16807
16829
|
},
|
|
16808
16830
|
[isControlled, onChange, onValueChange]
|
|
16809
16831
|
);
|
|
16810
|
-
const emitRange =
|
|
16832
|
+
const emitRange = React43.useCallback(
|
|
16811
16833
|
(next) => {
|
|
16812
16834
|
onRangeChange?.(next);
|
|
16813
16835
|
onRangeValueChange?.(next);
|
|
16814
16836
|
},
|
|
16815
16837
|
[onRangeChange, onRangeValueChange]
|
|
16816
16838
|
);
|
|
16817
|
-
const handleRangeChange =
|
|
16839
|
+
const handleRangeChange = React43.useCallback(
|
|
16818
16840
|
(thumb) => (e) => {
|
|
16819
16841
|
const nextVal = Number(e.target.value);
|
|
16820
16842
|
const [curMin, curMax] = normalizedRange;
|
|
@@ -16830,7 +16852,7 @@ var Slider = React42.forwardRef(
|
|
|
16830
16852
|
const rangeEndPct = (normalizedRange[1] - min) / denom * 100;
|
|
16831
16853
|
const sizeStyles8 = SIZE_STYLES[size];
|
|
16832
16854
|
const tooltipVisible = showTooltip && !disabled && (isHovering || isDragging);
|
|
16833
|
-
const displayValue =
|
|
16855
|
+
const displayValue = React43.useMemo(() => {
|
|
16834
16856
|
if (isRange) {
|
|
16835
16857
|
const a = formatValue ? formatValue(normalizedRange[0]) : normalizedRange[0].toString();
|
|
16836
16858
|
const b = formatValue ? formatValue(normalizedRange[1]) : normalizedRange[1].toString();
|
|
@@ -16838,7 +16860,7 @@ var Slider = React42.forwardRef(
|
|
|
16838
16860
|
}
|
|
16839
16861
|
return formatValue ? formatValue(currentValue) : currentValue.toString();
|
|
16840
16862
|
}, [currentValue, formatValue, isRange, normalizedRange]);
|
|
16841
|
-
const quantize =
|
|
16863
|
+
const quantize = React43.useCallback(
|
|
16842
16864
|
(v) => {
|
|
16843
16865
|
const stepped = Math.round((v - min) / step) * step + min;
|
|
16844
16866
|
const fixed = Number(stepped.toFixed(10));
|
|
@@ -16846,7 +16868,7 @@ var Slider = React42.forwardRef(
|
|
|
16846
16868
|
},
|
|
16847
16869
|
[max, min, step]
|
|
16848
16870
|
);
|
|
16849
|
-
const valueFromClientX =
|
|
16871
|
+
const valueFromClientX = React43.useCallback(
|
|
16850
16872
|
(clientX) => {
|
|
16851
16873
|
const el = trackRef.current;
|
|
16852
16874
|
if (!el) return min;
|
|
@@ -19182,7 +19204,7 @@ function FileUpload({
|
|
|
19182
19204
|
}
|
|
19183
19205
|
|
|
19184
19206
|
// src/components/Carousel.tsx
|
|
19185
|
-
var
|
|
19207
|
+
var React46 = __toESM(require("react"), 1);
|
|
19186
19208
|
var import_lucide_react29 = require("lucide-react");
|
|
19187
19209
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
19188
19210
|
function Carousel({
|
|
@@ -19208,16 +19230,16 @@ function Carousel({
|
|
|
19208
19230
|
effectOptions
|
|
19209
19231
|
}) {
|
|
19210
19232
|
const gi18n = useGlobalI18n();
|
|
19211
|
-
const [currentIndex, setCurrentIndex] =
|
|
19212
|
-
const [isPaused, setIsPaused] =
|
|
19213
|
-
const progressElRef =
|
|
19214
|
-
const carouselRef =
|
|
19215
|
-
const rafRef =
|
|
19216
|
-
const isDraggingRef =
|
|
19217
|
-
const dragDistanceRef =
|
|
19218
|
-
const startPosRef =
|
|
19219
|
-
const lastDragPositionRef =
|
|
19220
|
-
const slides =
|
|
19233
|
+
const [currentIndex, setCurrentIndex] = React46.useState(0);
|
|
19234
|
+
const [isPaused, setIsPaused] = React46.useState(false);
|
|
19235
|
+
const progressElRef = React46.useRef(null);
|
|
19236
|
+
const carouselRef = React46.useRef(null);
|
|
19237
|
+
const rafRef = React46.useRef(null);
|
|
19238
|
+
const isDraggingRef = React46.useRef(false);
|
|
19239
|
+
const dragDistanceRef = React46.useRef(0);
|
|
19240
|
+
const startPosRef = React46.useRef(0);
|
|
19241
|
+
const lastDragPositionRef = React46.useRef(0);
|
|
19242
|
+
const slides = React46.useMemo(() => React46.Children.toArray(children), [children]);
|
|
19221
19243
|
const totalSlides = slides.length;
|
|
19222
19244
|
const isHorizontal = orientation === "horizontal";
|
|
19223
19245
|
const effectiveAnimation = slidesToShow > 1 && !["slide", "coverflow", "stack"].includes(animation) ? "slide" : animation;
|
|
@@ -19225,7 +19247,7 @@ function Carousel({
|
|
|
19225
19247
|
const effectiveSlidesToShow = isDeckAnimation ? 1 : slidesToShow;
|
|
19226
19248
|
const maxIndex = Math.max(0, totalSlides - effectiveSlidesToShow);
|
|
19227
19249
|
const shouldShowArrows = showArrows && isHorizontal;
|
|
19228
|
-
const presetEffectOptions =
|
|
19250
|
+
const presetEffectOptions = React46.useMemo(() => {
|
|
19229
19251
|
if (effectPreset === "cinematic") {
|
|
19230
19252
|
return effectiveAnimation === "stack" ? {
|
|
19231
19253
|
mainScale: 1.08,
|
|
@@ -19320,7 +19342,7 @@ function Carousel({
|
|
|
19320
19342
|
}
|
|
19321
19343
|
return {};
|
|
19322
19344
|
}, [effectPreset, effectiveAnimation]);
|
|
19323
|
-
const mergedEffectOptions =
|
|
19345
|
+
const mergedEffectOptions = React46.useMemo(
|
|
19324
19346
|
() => ({
|
|
19325
19347
|
mainScale: 1.04,
|
|
19326
19348
|
sideScale: effectiveAnimation === "stack" ? 0.93 : 0.88,
|
|
@@ -19339,7 +19361,7 @@ function Carousel({
|
|
|
19339
19361
|
}),
|
|
19340
19362
|
[effectOptions, effectiveAnimation, presetEffectOptions]
|
|
19341
19363
|
);
|
|
19342
|
-
const scrollPrev =
|
|
19364
|
+
const scrollPrev = React46.useCallback(() => {
|
|
19343
19365
|
setCurrentIndex((prev) => {
|
|
19344
19366
|
if (prev === 0) {
|
|
19345
19367
|
return loop ? maxIndex : 0;
|
|
@@ -19347,7 +19369,7 @@ function Carousel({
|
|
|
19347
19369
|
return Math.max(0, prev - slidesToScroll);
|
|
19348
19370
|
});
|
|
19349
19371
|
}, [loop, maxIndex, slidesToScroll]);
|
|
19350
|
-
const scrollNext =
|
|
19372
|
+
const scrollNext = React46.useCallback(() => {
|
|
19351
19373
|
setCurrentIndex((prev) => {
|
|
19352
19374
|
if (prev >= maxIndex) {
|
|
19353
19375
|
return loop ? 0 : maxIndex;
|
|
@@ -19355,13 +19377,13 @@ function Carousel({
|
|
|
19355
19377
|
return Math.min(maxIndex, prev + slidesToScroll);
|
|
19356
19378
|
});
|
|
19357
19379
|
}, [loop, maxIndex, slidesToScroll]);
|
|
19358
|
-
const scrollTo =
|
|
19380
|
+
const scrollTo = React46.useCallback(
|
|
19359
19381
|
(index) => {
|
|
19360
19382
|
setCurrentIndex(Math.min(maxIndex, Math.max(0, index)));
|
|
19361
19383
|
},
|
|
19362
19384
|
[maxIndex]
|
|
19363
19385
|
);
|
|
19364
|
-
const handleKeyDown2 =
|
|
19386
|
+
const handleKeyDown2 = React46.useCallback(
|
|
19365
19387
|
(e) => {
|
|
19366
19388
|
if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
|
|
19367
19389
|
e.preventDefault();
|
|
@@ -19379,7 +19401,7 @@ function Carousel({
|
|
|
19379
19401
|
},
|
|
19380
19402
|
[scrollPrev, scrollNext, scrollTo, maxIndex]
|
|
19381
19403
|
);
|
|
19382
|
-
|
|
19404
|
+
React46.useEffect(() => {
|
|
19383
19405
|
const stop = () => {
|
|
19384
19406
|
if (rafRef.current != null) {
|
|
19385
19407
|
cancelAnimationFrame(rafRef.current);
|
|
@@ -19439,7 +19461,7 @@ function Carousel({
|
|
|
19439
19461
|
startPosRef.current = 0;
|
|
19440
19462
|
lastDragPositionRef.current = 0;
|
|
19441
19463
|
};
|
|
19442
|
-
const handleDeckAreaClick =
|
|
19464
|
+
const handleDeckAreaClick = React46.useCallback((event) => {
|
|
19443
19465
|
if (!isDeckAnimation || dragDistanceRef.current > 8) {
|
|
19444
19466
|
dragDistanceRef.current = 0;
|
|
19445
19467
|
return;
|
|
@@ -19456,7 +19478,7 @@ function Carousel({
|
|
|
19456
19478
|
scrollNext();
|
|
19457
19479
|
}
|
|
19458
19480
|
}, [isDeckAnimation, scrollNext, scrollPrev]);
|
|
19459
|
-
|
|
19481
|
+
React46.useEffect(() => {
|
|
19460
19482
|
onSlideChange?.(currentIndex);
|
|
19461
19483
|
}, [currentIndex, onSlideChange]);
|
|
19462
19484
|
const getAnimationStyles2 = () => {
|
|
@@ -19470,7 +19492,7 @@ function Carousel({
|
|
|
19470
19492
|
};
|
|
19471
19493
|
};
|
|
19472
19494
|
const slideWidth = 100 / effectiveSlidesToShow;
|
|
19473
|
-
const getLoopDistance =
|
|
19495
|
+
const getLoopDistance = React46.useCallback(
|
|
19474
19496
|
(index) => {
|
|
19475
19497
|
if (totalSlides <= 0) return 0;
|
|
19476
19498
|
const forward = index - currentIndex;
|
|
@@ -19482,7 +19504,7 @@ function Carousel({
|
|
|
19482
19504
|
},
|
|
19483
19505
|
[currentIndex, loop, totalSlides]
|
|
19484
19506
|
);
|
|
19485
|
-
const getDeckSlideStyles =
|
|
19507
|
+
const getDeckSlideStyles = React46.useCallback(
|
|
19486
19508
|
(index) => {
|
|
19487
19509
|
const distance = getLoopDistance(index);
|
|
19488
19510
|
const absDistance = Math.abs(distance);
|
|
@@ -19562,7 +19584,7 @@ function Carousel({
|
|
|
19562
19584
|
"aria-atomic": "false",
|
|
19563
19585
|
"aria-live": autoScroll ? "off" : "polite",
|
|
19564
19586
|
children: slides.map((child, idx) => {
|
|
19565
|
-
const key =
|
|
19587
|
+
const key = React46.isValidElement(child) && child.key || idx;
|
|
19566
19588
|
const ariaHidden = effectiveAnimation === "slide" ? idx < currentIndex || idx >= currentIndex + slidesToShow : idx !== currentIndex;
|
|
19567
19589
|
if (isDeckAnimation) {
|
|
19568
19590
|
return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
@@ -19685,7 +19707,7 @@ function Carousel({
|
|
|
19685
19707
|
"max-md:gap-1.5 max-md:p-2",
|
|
19686
19708
|
isHorizontal ? "flex-row" : "flex-col"
|
|
19687
19709
|
),
|
|
19688
|
-
children:
|
|
19710
|
+
children: React46.Children.map(children, (child, idx) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
|
|
19689
19711
|
"button",
|
|
19690
19712
|
{
|
|
19691
19713
|
onClick: () => scrollTo(idx),
|
|
@@ -19983,7 +20005,7 @@ function FallingIcons({
|
|
|
19983
20005
|
}
|
|
19984
20006
|
|
|
19985
20007
|
// src/components/List.tsx
|
|
19986
|
-
var
|
|
20008
|
+
var React48 = __toESM(require("react"), 1);
|
|
19987
20009
|
var import_lucide_react30 = require("lucide-react");
|
|
19988
20010
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
19989
20011
|
var SIZE_STYLES2 = {
|
|
@@ -20009,7 +20031,7 @@ var ListItemSkeleton = ({ size }) => {
|
|
|
20009
20031
|
] })
|
|
20010
20032
|
] });
|
|
20011
20033
|
};
|
|
20012
|
-
var ListRoot =
|
|
20034
|
+
var ListRoot = React48.forwardRef(
|
|
20013
20035
|
({
|
|
20014
20036
|
as = "ul",
|
|
20015
20037
|
ordered,
|
|
@@ -20030,7 +20052,7 @@ var ListRoot = React47.forwardRef(
|
|
|
20030
20052
|
...rest
|
|
20031
20053
|
}, ref) => {
|
|
20032
20054
|
const Comp = ordered ? "ol" : as;
|
|
20033
|
-
const childCount =
|
|
20055
|
+
const childCount = React48.Children.count(children);
|
|
20034
20056
|
const hasChildren = childCount > 0;
|
|
20035
20057
|
const variantClasses3 = {
|
|
20036
20058
|
plain: "",
|
|
@@ -20084,14 +20106,14 @@ var ListRoot = React47.forwardRef(
|
|
|
20084
20106
|
className
|
|
20085
20107
|
),
|
|
20086
20108
|
...rest,
|
|
20087
|
-
children:
|
|
20088
|
-
if (!
|
|
20109
|
+
children: React48.Children.map(children, (child, idx) => {
|
|
20110
|
+
if (!React48.isValidElement(child)) return child;
|
|
20089
20111
|
const childClass = cn(
|
|
20090
20112
|
child.props?.className,
|
|
20091
20113
|
hoverable && variant !== "flush" && "hover:bg-accent/50 focus:bg-accent/60 focus:outline-none transition-colors",
|
|
20092
20114
|
variant === "flush" && "hover:bg-accent/30"
|
|
20093
20115
|
);
|
|
20094
|
-
return
|
|
20116
|
+
return React48.cloneElement(child, {
|
|
20095
20117
|
className: childClass,
|
|
20096
20118
|
// Pass global item class to contentClassName of ListItem
|
|
20097
20119
|
contentClassName: cn(itemClassName, child.props?.contentClassName),
|
|
@@ -20106,7 +20128,7 @@ var ListRoot = React47.forwardRef(
|
|
|
20106
20128
|
}
|
|
20107
20129
|
);
|
|
20108
20130
|
ListRoot.displayName = "List";
|
|
20109
|
-
var ListItem =
|
|
20131
|
+
var ListItem = React48.forwardRef(
|
|
20110
20132
|
({
|
|
20111
20133
|
as = "li",
|
|
20112
20134
|
selected = false,
|
|
@@ -20129,7 +20151,7 @@ var ListItem = React47.forwardRef(
|
|
|
20129
20151
|
children,
|
|
20130
20152
|
...rest
|
|
20131
20153
|
}, ref) => {
|
|
20132
|
-
const [internalExpanded, setInternalExpanded] =
|
|
20154
|
+
const [internalExpanded, setInternalExpanded] = React48.useState(false);
|
|
20133
20155
|
const isExpanded = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
|
|
20134
20156
|
const sizeAttr = rest["data-size"];
|
|
20135
20157
|
const resolvedSize = sizeAttr && ["xs", "sm", "md", "lg"].includes(sizeAttr) ? sizeAttr : "md";
|
|
@@ -20197,7 +20219,7 @@ var List = Object.assign(ListRoot, { Item: ListItem });
|
|
|
20197
20219
|
var List_default = List;
|
|
20198
20220
|
|
|
20199
20221
|
// src/components/Watermark.tsx
|
|
20200
|
-
var
|
|
20222
|
+
var React49 = __toESM(require("react"), 1);
|
|
20201
20223
|
var import_react_dom5 = require("react-dom");
|
|
20202
20224
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
20203
20225
|
var PRESETS2 = {
|
|
@@ -20209,8 +20231,8 @@ var PRESETS2 = {
|
|
|
20209
20231
|
internal: { text: "INTERNAL USE ONLY", color: "rgba(156, 163, 175, 0.15)", rotate: -22, fontSize: 13, fontWeight: "600" }
|
|
20210
20232
|
};
|
|
20211
20233
|
function useWatermarkDataURL(opts) {
|
|
20212
|
-
const [url, setUrl] =
|
|
20213
|
-
|
|
20234
|
+
const [url, setUrl] = React49.useState(null);
|
|
20235
|
+
React49.useEffect(() => {
|
|
20214
20236
|
let cancelled = false;
|
|
20215
20237
|
const text = opts.text;
|
|
20216
20238
|
const image = opts.image;
|
|
@@ -20387,9 +20409,9 @@ var Watermark = ({
|
|
|
20387
20409
|
children,
|
|
20388
20410
|
...rest
|
|
20389
20411
|
}) => {
|
|
20390
|
-
const [visible, setVisible] =
|
|
20391
|
-
const [isDark, setIsDark] =
|
|
20392
|
-
|
|
20412
|
+
const [visible, setVisible] = React49.useState(true);
|
|
20413
|
+
const [isDark, setIsDark] = React49.useState(false);
|
|
20414
|
+
React49.useEffect(() => {
|
|
20393
20415
|
if (!darkMode) return;
|
|
20394
20416
|
const checkDarkMode = () => {
|
|
20395
20417
|
const isDarkMode = document.documentElement.classList.contains("dark") || window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
@@ -20491,7 +20513,7 @@ var Watermark = ({
|
|
|
20491
20513
|
var Watermark_default = Watermark;
|
|
20492
20514
|
|
|
20493
20515
|
// src/components/Timeline.tsx
|
|
20494
|
-
var
|
|
20516
|
+
var React50 = __toESM(require("react"), 1);
|
|
20495
20517
|
var import_lucide_react31 = require("lucide-react");
|
|
20496
20518
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
20497
20519
|
var SIZE_STYLE = {
|
|
@@ -20544,7 +20566,7 @@ var STATUS_COLOR = {
|
|
|
20544
20566
|
error: "bg-destructive",
|
|
20545
20567
|
info: "bg-info"
|
|
20546
20568
|
};
|
|
20547
|
-
var TimelineContext =
|
|
20569
|
+
var TimelineContext = React50.createContext(null);
|
|
20548
20570
|
var LINE_STYLE_MAP = {
|
|
20549
20571
|
solid: "border-solid",
|
|
20550
20572
|
dashed: "border-dashed",
|
|
@@ -20572,7 +20594,7 @@ var Marker = ({ index, last, size, color, status = "default", lineColor, lineSty
|
|
|
20572
20594
|
!last && showLine && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: cn("flex-1 border-l-2", LINE_STYLE_MAP[lineStyle]), style: { borderColor: lineColor || "hsl(var(--border))" } })
|
|
20573
20595
|
] });
|
|
20574
20596
|
};
|
|
20575
|
-
var TimelineRoot =
|
|
20597
|
+
var TimelineRoot = React50.forwardRef(
|
|
20576
20598
|
({
|
|
20577
20599
|
align = "left",
|
|
20578
20600
|
variant = "default",
|
|
@@ -20602,7 +20624,7 @@ var TimelineRoot = React49.forwardRef(
|
|
|
20602
20624
|
}
|
|
20603
20625
|
);
|
|
20604
20626
|
TimelineRoot.displayName = "Timeline";
|
|
20605
|
-
var TimelineItem =
|
|
20627
|
+
var TimelineItem = React50.forwardRef(
|
|
20606
20628
|
({
|
|
20607
20629
|
title,
|
|
20608
20630
|
description,
|
|
@@ -20621,11 +20643,11 @@ var TimelineItem = React49.forwardRef(
|
|
|
20621
20643
|
children,
|
|
20622
20644
|
...rest
|
|
20623
20645
|
}, ref) => {
|
|
20624
|
-
const ctx =
|
|
20646
|
+
const ctx = React50.useContext(TimelineContext);
|
|
20625
20647
|
const idx = rest["data-index"];
|
|
20626
20648
|
const isLast = Boolean(rest["data-last"]);
|
|
20627
20649
|
const sz = SIZE_STYLE[ctx.size];
|
|
20628
|
-
const [internalExpanded, setInternalExpanded] =
|
|
20650
|
+
const [internalExpanded, setInternalExpanded] = React50.useState(false);
|
|
20629
20651
|
const isExpanded = controlledExpanded !== void 0 ? controlledExpanded : internalExpanded;
|
|
20630
20652
|
const toggleExpanded = () => {
|
|
20631
20653
|
const newExpanded = !isExpanded;
|
|
@@ -20767,7 +20789,7 @@ var Timeline = Object.assign(TimelineRoot, { Item: TimelineItem });
|
|
|
20767
20789
|
var Timeline_default = Timeline;
|
|
20768
20790
|
|
|
20769
20791
|
// src/components/ColorPicker.tsx
|
|
20770
|
-
var
|
|
20792
|
+
var React51 = __toESM(require("react"), 1);
|
|
20771
20793
|
var import_lucide_react32 = require("lucide-react");
|
|
20772
20794
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
20773
20795
|
var clamp7 = (n, min, max) => Math.max(min, Math.min(max, n));
|
|
@@ -20962,12 +20984,12 @@ function ColorPicker({
|
|
|
20962
20984
|
const gi18n = useGlobalI18n();
|
|
20963
20985
|
const isControlled = value !== void 0;
|
|
20964
20986
|
const initial = parseAnyColor(isControlled ? value : defaultValue) || { r: 79, g: 70, b: 229, a: 1 };
|
|
20965
|
-
const [rgba, setRgba] =
|
|
20966
|
-
const [open, setOpen] =
|
|
20967
|
-
const [text, setText] =
|
|
20968
|
-
const [copied, setCopied] =
|
|
20969
|
-
const [recentColors, setRecentColors] =
|
|
20970
|
-
|
|
20987
|
+
const [rgba, setRgba] = React51.useState(initial);
|
|
20988
|
+
const [open, setOpen] = React51.useState(false);
|
|
20989
|
+
const [text, setText] = React51.useState(() => formatOutput(initial, withAlpha, format));
|
|
20990
|
+
const [copied, setCopied] = React51.useState(false);
|
|
20991
|
+
const [recentColors, setRecentColors] = React51.useState([]);
|
|
20992
|
+
React51.useEffect(() => {
|
|
20971
20993
|
if (isControlled) {
|
|
20972
20994
|
const parsed = parseAnyColor(value);
|
|
20973
20995
|
if (parsed) {
|
|
@@ -23478,10 +23500,10 @@ function DataTable({
|
|
|
23478
23500
|
var DataTable_default = DataTable;
|
|
23479
23501
|
|
|
23480
23502
|
// src/components/Form.tsx
|
|
23481
|
-
var
|
|
23503
|
+
var React65 = __toESM(require("react"), 1);
|
|
23482
23504
|
var import_react_hook_form = require("react-hook-form");
|
|
23483
23505
|
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
23484
|
-
var FormConfigContext =
|
|
23506
|
+
var FormConfigContext = React65.createContext({ size: "md" });
|
|
23485
23507
|
var FormWrapper = ({
|
|
23486
23508
|
children,
|
|
23487
23509
|
onSubmit,
|
|
@@ -23494,7 +23516,7 @@ var FormWrapper = ({
|
|
|
23494
23516
|
const methods = (0, import_react_hook_form.useForm)({
|
|
23495
23517
|
defaultValues: initialValues
|
|
23496
23518
|
});
|
|
23497
|
-
|
|
23519
|
+
React65.useEffect(() => {
|
|
23498
23520
|
if (initialValues) {
|
|
23499
23521
|
methods.reset(initialValues);
|
|
23500
23522
|
}
|
|
@@ -23503,15 +23525,15 @@ var FormWrapper = ({
|
|
|
23503
23525
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_react_hook_form.FormProvider, { ...methods, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormConfigContext.Provider, { value: { size }, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("form", { onSubmit: methods.handleSubmit(onSubmit), className, ...formProps, children }) }) });
|
|
23504
23526
|
};
|
|
23505
23527
|
var Form = FormWrapper;
|
|
23506
|
-
var FormFieldContext =
|
|
23528
|
+
var FormFieldContext = React65.createContext({});
|
|
23507
23529
|
var FormField = ({
|
|
23508
23530
|
...props
|
|
23509
23531
|
}) => {
|
|
23510
23532
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormFieldContext.Provider, { value: { name: props.name }, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_react_hook_form.Controller, { ...props }) });
|
|
23511
23533
|
};
|
|
23512
23534
|
var useFormField = () => {
|
|
23513
|
-
const fieldContext =
|
|
23514
|
-
const itemContext =
|
|
23535
|
+
const fieldContext = React65.useContext(FormFieldContext);
|
|
23536
|
+
const itemContext = React65.useContext(FormItemContext);
|
|
23515
23537
|
const { getFieldState, formState } = (0, import_react_hook_form.useFormContext)();
|
|
23516
23538
|
if (!fieldContext) {
|
|
23517
23539
|
throw new Error("useFormField must be used within FormField");
|
|
@@ -23527,16 +23549,16 @@ var useFormField = () => {
|
|
|
23527
23549
|
...fieldState
|
|
23528
23550
|
};
|
|
23529
23551
|
};
|
|
23530
|
-
var FormItemContext =
|
|
23531
|
-
var FormItem =
|
|
23532
|
-
const id =
|
|
23552
|
+
var FormItemContext = React65.createContext({});
|
|
23553
|
+
var FormItem = React65.forwardRef(({ className, ...props }, ref) => {
|
|
23554
|
+
const id = React65.useId();
|
|
23533
23555
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { ref, className: cn("group space-y-2", className), ...props }) });
|
|
23534
23556
|
});
|
|
23535
23557
|
FormItem.displayName = "FormItem";
|
|
23536
|
-
var FormLabel =
|
|
23558
|
+
var FormLabel = React65.forwardRef(
|
|
23537
23559
|
({ className, children, required, ...props }, ref) => {
|
|
23538
23560
|
const { error, formItemId } = useFormField();
|
|
23539
|
-
const config =
|
|
23561
|
+
const config = React65.useContext(FormConfigContext);
|
|
23540
23562
|
const sizeClass = config.size === "sm" ? "text-xs" : config.size === "lg" ? "text-base" : "text-sm";
|
|
23541
23563
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
|
|
23542
23564
|
Label,
|
|
@@ -23559,7 +23581,7 @@ var FormLabel = React64.forwardRef(
|
|
|
23559
23581
|
}
|
|
23560
23582
|
);
|
|
23561
23583
|
FormLabel.displayName = "FormLabel";
|
|
23562
|
-
var FormControl =
|
|
23584
|
+
var FormControl = React65.forwardRef(({ ...props }, ref) => {
|
|
23563
23585
|
const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
|
|
23564
23586
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23565
23587
|
"div",
|
|
@@ -23573,12 +23595,12 @@ var FormControl = React64.forwardRef(({ ...props }, ref) => {
|
|
|
23573
23595
|
);
|
|
23574
23596
|
});
|
|
23575
23597
|
FormControl.displayName = "FormControl";
|
|
23576
|
-
var FormDescription =
|
|
23598
|
+
var FormDescription = React65.forwardRef(({ className, ...props }, ref) => {
|
|
23577
23599
|
const { formDescriptionId } = useFormField();
|
|
23578
23600
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { ref, id: formDescriptionId, className: cn("text-sm text-muted-foreground", className), ...props });
|
|
23579
23601
|
});
|
|
23580
23602
|
FormDescription.displayName = "FormDescription";
|
|
23581
|
-
var FormMessage =
|
|
23603
|
+
var FormMessage = React65.forwardRef(({ className, children, ...props }, ref) => {
|
|
23582
23604
|
const { error, formMessageId } = useFormField();
|
|
23583
23605
|
const body = error ? String(error?.message) : children;
|
|
23584
23606
|
if (!body) {
|
|
@@ -23587,7 +23609,7 @@ var FormMessage = React64.forwardRef(({ className, children, ...props }, ref) =>
|
|
|
23587
23609
|
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { ref, id: formMessageId, className: cn("text-sm font-medium text-destructive", className), ...props, children: body });
|
|
23588
23610
|
});
|
|
23589
23611
|
FormMessage.displayName = "FormMessage";
|
|
23590
|
-
var FormInput =
|
|
23612
|
+
var FormInput = React65.forwardRef(({ name, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormConfigContext.Consumer, { children: ({ size }) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23591
23613
|
FormField,
|
|
23592
23614
|
{
|
|
23593
23615
|
name,
|
|
@@ -23598,7 +23620,7 @@ var FormInput = React64.forwardRef(({ name, ...props }, ref) => /* @__PURE__ */
|
|
|
23598
23620
|
}
|
|
23599
23621
|
) }));
|
|
23600
23622
|
FormInput.displayName = "FormInput";
|
|
23601
|
-
var FormCheckbox =
|
|
23623
|
+
var FormCheckbox = React65.forwardRef(({ name, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormConfigContext.Consumer, { children: ({ size }) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23602
23624
|
FormField,
|
|
23603
23625
|
{
|
|
23604
23626
|
name,
|
|
@@ -23622,9 +23644,9 @@ var FormCheckbox = React64.forwardRef(({ name, ...props }, ref) => /* @__PURE__
|
|
|
23622
23644
|
}
|
|
23623
23645
|
) }));
|
|
23624
23646
|
FormCheckbox.displayName = "FormCheckbox";
|
|
23625
|
-
var FormActions =
|
|
23647
|
+
var FormActions = React65.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { ref, className: cn("flex gap-2 justify-end", className), ...props }));
|
|
23626
23648
|
FormActions.displayName = "FormActions";
|
|
23627
|
-
var FormSubmitButton =
|
|
23649
|
+
var FormSubmitButton = React65.forwardRef(
|
|
23628
23650
|
({ children, loading: loading2, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(FormConfigContext.Consumer, { children: ({ size }) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Button_default, { ref, type: "submit", size: props.size ?? size, disabled: loading2, ...props, children }) })
|
|
23629
23651
|
);
|
|
23630
23652
|
FormSubmitButton.displayName = "FormSubmitButton";
|
|
@@ -23914,7 +23936,7 @@ var VARIANT_STYLES_ALERT = {
|
|
|
23914
23936
|
};
|
|
23915
23937
|
|
|
23916
23938
|
// src/contexts/translation-adapter.tsx
|
|
23917
|
-
var
|
|
23939
|
+
var React67 = __toESM(require("react"), 1);
|
|
23918
23940
|
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
23919
23941
|
function isUnresolvedTranslation2(value, namespace, key) {
|
|
23920
23942
|
return value === key || value === `${namespace}.${key}`;
|
|
@@ -23939,7 +23961,7 @@ function useTranslations(namespace) {
|
|
|
23939
23961
|
const nextIntlBridge = useNextIntlBridge();
|
|
23940
23962
|
const internalLocale = useUnderverseLocale();
|
|
23941
23963
|
const internalT = useUnderverseTranslations(namespace);
|
|
23942
|
-
return
|
|
23964
|
+
return React67.useCallback((key, params) => {
|
|
23943
23965
|
if (nextIntlBridge) {
|
|
23944
23966
|
const nextIntlResult = nextIntlBridge.translate(namespace, key, params);
|
|
23945
23967
|
if (nextIntlResult.translated && !isUnresolvedTranslation2(nextIntlResult.translated, namespace, key)) {
|