@marcoschwartz/lite-ui 0.26.4 → 0.27.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +38 -1
- package/dist/index.d.ts +38 -1
- package/dist/index.js +866 -651
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +833 -619
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -123,6 +123,7 @@ __export(index_exports, {
|
|
|
123
123
|
SaveIcon: () => SaveIcon,
|
|
124
124
|
ScatterChart: () => ScatterChart,
|
|
125
125
|
SearchIcon: () => SearchIcon,
|
|
126
|
+
SegmentedControl: () => SegmentedControl,
|
|
126
127
|
Select: () => Select,
|
|
127
128
|
SettingsIcon: () => SettingsIcon,
|
|
128
129
|
ShieldIcon: () => ShieldIcon,
|
|
@@ -3687,8 +3688,221 @@ var Radio = ({
|
|
|
3687
3688
|
}) });
|
|
3688
3689
|
};
|
|
3689
3690
|
|
|
3690
|
-
// src/components/
|
|
3691
|
+
// src/components/SegmentedControl.tsx
|
|
3692
|
+
var import_react20 = require("react");
|
|
3691
3693
|
var import_jsx_runtime99 = require("react/jsx-runtime");
|
|
3694
|
+
function normalizeData(data) {
|
|
3695
|
+
return data.map(
|
|
3696
|
+
(item) => typeof item === "string" ? { value: item, label: item } : item
|
|
3697
|
+
);
|
|
3698
|
+
}
|
|
3699
|
+
var sizeConfig = {
|
|
3700
|
+
xs: {
|
|
3701
|
+
padding: "px-2 py-0.5",
|
|
3702
|
+
text: "text-xs",
|
|
3703
|
+
height: "h-6",
|
|
3704
|
+
minWidth: "min-w-[2rem]"
|
|
3705
|
+
},
|
|
3706
|
+
sm: {
|
|
3707
|
+
padding: "px-2.5 py-1",
|
|
3708
|
+
text: "text-sm",
|
|
3709
|
+
height: "h-8",
|
|
3710
|
+
minWidth: "min-w-[2.5rem]"
|
|
3711
|
+
},
|
|
3712
|
+
md: {
|
|
3713
|
+
padding: "px-3 py-1.5",
|
|
3714
|
+
text: "text-sm",
|
|
3715
|
+
height: "h-9",
|
|
3716
|
+
minWidth: "min-w-[3rem]"
|
|
3717
|
+
},
|
|
3718
|
+
lg: {
|
|
3719
|
+
padding: "px-4 py-2",
|
|
3720
|
+
text: "text-base",
|
|
3721
|
+
height: "h-11",
|
|
3722
|
+
minWidth: "min-w-[3.5rem]"
|
|
3723
|
+
}
|
|
3724
|
+
};
|
|
3725
|
+
var radiusConfig = {
|
|
3726
|
+
none: "rounded-none",
|
|
3727
|
+
sm: "rounded-sm",
|
|
3728
|
+
md: "rounded-md",
|
|
3729
|
+
lg: "rounded-lg",
|
|
3730
|
+
full: "rounded-full"
|
|
3731
|
+
};
|
|
3732
|
+
var colorConfig = {
|
|
3733
|
+
primary: "bg-[hsl(var(--primary))]",
|
|
3734
|
+
secondary: "bg-[hsl(var(--secondary))]",
|
|
3735
|
+
neutral: "bg-[hsl(var(--muted))]"
|
|
3736
|
+
};
|
|
3737
|
+
var activeTextConfig = {
|
|
3738
|
+
primary: "text-[hsl(var(--primary-foreground))]",
|
|
3739
|
+
secondary: "text-[hsl(var(--secondary-foreground))]",
|
|
3740
|
+
neutral: "text-[hsl(var(--foreground))]"
|
|
3741
|
+
};
|
|
3742
|
+
var SegmentedControl = ({
|
|
3743
|
+
data,
|
|
3744
|
+
value: controlledValue,
|
|
3745
|
+
defaultValue,
|
|
3746
|
+
onChange,
|
|
3747
|
+
size = "md",
|
|
3748
|
+
radius = "md",
|
|
3749
|
+
color = "primary",
|
|
3750
|
+
fullWidth = false,
|
|
3751
|
+
disabled = false,
|
|
3752
|
+
orientation = "horizontal",
|
|
3753
|
+
className = "",
|
|
3754
|
+
transitionDuration = 200,
|
|
3755
|
+
name,
|
|
3756
|
+
ariaLabel
|
|
3757
|
+
}) => {
|
|
3758
|
+
const groupId = (0, import_react20.useId)();
|
|
3759
|
+
const groupName = name || `segmented-control-${groupId}`;
|
|
3760
|
+
const options = (0, import_react20.useMemo)(() => normalizeData(data), [data]);
|
|
3761
|
+
const [internalValue, setInternalValue] = (0, import_react20.useState)(
|
|
3762
|
+
defaultValue || options[0]?.value || ""
|
|
3763
|
+
);
|
|
3764
|
+
const isControlled = controlledValue !== void 0;
|
|
3765
|
+
const currentValue = isControlled ? controlledValue : internalValue;
|
|
3766
|
+
const [hasInteracted, setHasInteracted] = (0, import_react20.useState)(false);
|
|
3767
|
+
const activeIndex = options.findIndex((opt) => opt.value === currentValue);
|
|
3768
|
+
const handleChange = (0, import_react20.useCallback)((newValue) => {
|
|
3769
|
+
if (disabled) return;
|
|
3770
|
+
setHasInteracted(true);
|
|
3771
|
+
if (!isControlled) {
|
|
3772
|
+
setInternalValue(newValue);
|
|
3773
|
+
}
|
|
3774
|
+
onChange?.(newValue);
|
|
3775
|
+
}, [disabled, isControlled, onChange]);
|
|
3776
|
+
const handleKeyDown = (0, import_react20.useCallback)((e) => {
|
|
3777
|
+
const enabledOptions = options.filter((opt) => !opt.disabled);
|
|
3778
|
+
const currentEnabledIndex = enabledOptions.findIndex((opt) => opt.value === currentValue);
|
|
3779
|
+
let nextIndex = -1;
|
|
3780
|
+
if (orientation === "horizontal") {
|
|
3781
|
+
if (e.key === "ArrowRight") {
|
|
3782
|
+
nextIndex = (currentEnabledIndex + 1) % enabledOptions.length;
|
|
3783
|
+
} else if (e.key === "ArrowLeft") {
|
|
3784
|
+
nextIndex = (currentEnabledIndex - 1 + enabledOptions.length) % enabledOptions.length;
|
|
3785
|
+
}
|
|
3786
|
+
} else {
|
|
3787
|
+
if (e.key === "ArrowDown") {
|
|
3788
|
+
nextIndex = (currentEnabledIndex + 1) % enabledOptions.length;
|
|
3789
|
+
} else if (e.key === "ArrowUp") {
|
|
3790
|
+
nextIndex = (currentEnabledIndex - 1 + enabledOptions.length) % enabledOptions.length;
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
if (e.key === "Home") {
|
|
3794
|
+
nextIndex = 0;
|
|
3795
|
+
} else if (e.key === "End") {
|
|
3796
|
+
nextIndex = enabledOptions.length - 1;
|
|
3797
|
+
}
|
|
3798
|
+
if (nextIndex !== -1) {
|
|
3799
|
+
e.preventDefault();
|
|
3800
|
+
const nextOption = enabledOptions[nextIndex];
|
|
3801
|
+
handleChange(nextOption.value);
|
|
3802
|
+
}
|
|
3803
|
+
}, [options, currentValue, orientation, handleChange]);
|
|
3804
|
+
const sizeStyles2 = sizeConfig[size];
|
|
3805
|
+
const radiusStyle = radiusConfig[radius];
|
|
3806
|
+
const totalOptions = options.length;
|
|
3807
|
+
const indicatorStyle = activeIndex >= 0 ? orientation === "horizontal" ? {
|
|
3808
|
+
width: `calc(${100 / totalOptions}% - ${totalOptions > 1 ? 0 : 0}px)`,
|
|
3809
|
+
height: "calc(100% - 8px)",
|
|
3810
|
+
left: `calc(${activeIndex / totalOptions * 100}% + 4px)`,
|
|
3811
|
+
top: "4px",
|
|
3812
|
+
transition: hasInteracted ? `left ${transitionDuration}ms ease, width ${transitionDuration}ms ease` : "none"
|
|
3813
|
+
} : {
|
|
3814
|
+
width: "calc(100% - 8px)",
|
|
3815
|
+
height: `calc(${100 / totalOptions}% - ${totalOptions > 1 ? 0 : 0}px)`,
|
|
3816
|
+
left: "4px",
|
|
3817
|
+
top: `calc(${activeIndex / totalOptions * 100}% + 4px)`,
|
|
3818
|
+
transition: hasInteracted ? `top ${transitionDuration}ms ease, height ${transitionDuration}ms ease` : "none"
|
|
3819
|
+
} : { display: "none" };
|
|
3820
|
+
const containerClasses = [
|
|
3821
|
+
"relative inline-flex p-1",
|
|
3822
|
+
"bg-[hsl(var(--muted))]",
|
|
3823
|
+
radiusStyle,
|
|
3824
|
+
orientation === "vertical" ? "flex-col" : "flex-row",
|
|
3825
|
+
fullWidth ? "w-full" : "",
|
|
3826
|
+
disabled ? "opacity-50 cursor-not-allowed" : "",
|
|
3827
|
+
className
|
|
3828
|
+
].filter(Boolean).join(" ");
|
|
3829
|
+
return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
|
|
3830
|
+
"div",
|
|
3831
|
+
{
|
|
3832
|
+
role: "radiogroup",
|
|
3833
|
+
"aria-label": ariaLabel || "Segmented control",
|
|
3834
|
+
className: containerClasses,
|
|
3835
|
+
children: [
|
|
3836
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
3837
|
+
"div",
|
|
3838
|
+
{
|
|
3839
|
+
className: [
|
|
3840
|
+
"absolute z-0",
|
|
3841
|
+
radiusStyle,
|
|
3842
|
+
colorConfig[color],
|
|
3843
|
+
"shadow-sm"
|
|
3844
|
+
].join(" "),
|
|
3845
|
+
style: indicatorStyle,
|
|
3846
|
+
"aria-hidden": "true"
|
|
3847
|
+
}
|
|
3848
|
+
),
|
|
3849
|
+
options.map((option, index) => {
|
|
3850
|
+
const isActive = option.value === currentValue;
|
|
3851
|
+
const isDisabled = disabled || option.disabled;
|
|
3852
|
+
const buttonClasses = [
|
|
3853
|
+
"relative z-10 flex items-center justify-center",
|
|
3854
|
+
"font-medium select-none",
|
|
3855
|
+
"transition-colors duration-150",
|
|
3856
|
+
sizeStyles2.padding,
|
|
3857
|
+
sizeStyles2.text,
|
|
3858
|
+
sizeStyles2.minWidth,
|
|
3859
|
+
radiusStyle,
|
|
3860
|
+
fullWidth ? "flex-1" : "",
|
|
3861
|
+
isActive ? activeTextConfig[color] : "text-[hsl(var(--muted-foreground))]",
|
|
3862
|
+
isDisabled ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:text-[hsl(var(--foreground))]",
|
|
3863
|
+
"focus:outline-none focus-visible:ring-2 focus-visible:ring-[hsl(var(--ring))] focus-visible:ring-offset-1"
|
|
3864
|
+
].filter(Boolean).join(" ");
|
|
3865
|
+
return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
|
|
3866
|
+
"button",
|
|
3867
|
+
{
|
|
3868
|
+
type: "button",
|
|
3869
|
+
role: "radio",
|
|
3870
|
+
"aria-checked": isActive,
|
|
3871
|
+
"data-segment-button": true,
|
|
3872
|
+
"data-value": option.value,
|
|
3873
|
+
disabled: isDisabled,
|
|
3874
|
+
tabIndex: isActive ? 0 : -1,
|
|
3875
|
+
className: buttonClasses,
|
|
3876
|
+
onClick: () => !isDisabled && handleChange(option.value),
|
|
3877
|
+
onKeyDown: handleKeyDown,
|
|
3878
|
+
children: [
|
|
3879
|
+
option.label,
|
|
3880
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
3881
|
+
"input",
|
|
3882
|
+
{
|
|
3883
|
+
type: "radio",
|
|
3884
|
+
name: groupName,
|
|
3885
|
+
value: option.value,
|
|
3886
|
+
checked: isActive,
|
|
3887
|
+
disabled: isDisabled,
|
|
3888
|
+
onChange: () => {
|
|
3889
|
+
},
|
|
3890
|
+
className: "sr-only",
|
|
3891
|
+
"aria-hidden": "true"
|
|
3892
|
+
}
|
|
3893
|
+
)
|
|
3894
|
+
]
|
|
3895
|
+
},
|
|
3896
|
+
option.value
|
|
3897
|
+
);
|
|
3898
|
+
})
|
|
3899
|
+
]
|
|
3900
|
+
}
|
|
3901
|
+
);
|
|
3902
|
+
};
|
|
3903
|
+
|
|
3904
|
+
// src/components/ProgressBar.tsx
|
|
3905
|
+
var import_jsx_runtime100 = require("react/jsx-runtime");
|
|
3692
3906
|
var ProgressBar = ({
|
|
3693
3907
|
value,
|
|
3694
3908
|
max = 100,
|
|
@@ -3710,15 +3924,15 @@ var ProgressBar = ({
|
|
|
3710
3924
|
warning: "bg-[hsl(var(--warning))]",
|
|
3711
3925
|
danger: "bg-[hsl(var(--destructive))]"
|
|
3712
3926
|
};
|
|
3713
|
-
return /* @__PURE__ */ (0,
|
|
3714
|
-
(showLabel || label) && /* @__PURE__ */ (0,
|
|
3715
|
-
label && /* @__PURE__ */ (0,
|
|
3716
|
-
showLabel && /* @__PURE__ */ (0,
|
|
3927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("div", { className: `w-full ${className}`, children: [
|
|
3928
|
+
(showLabel || label) && /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("div", { className: "flex justify-between items-center mb-1", children: [
|
|
3929
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("span", { className: "text-sm font-medium text-[hsl(var(--foreground))]", children: label }),
|
|
3930
|
+
showLabel && /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)("span", { className: "text-sm font-medium text-[hsl(var(--muted-foreground))]", children: [
|
|
3717
3931
|
Math.round(percentage),
|
|
3718
3932
|
"%"
|
|
3719
3933
|
] })
|
|
3720
3934
|
] }),
|
|
3721
|
-
/* @__PURE__ */ (0,
|
|
3935
|
+
/* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
|
|
3722
3936
|
"div",
|
|
3723
3937
|
{
|
|
3724
3938
|
className: `w-full bg-[hsl(var(--muted))] rounded-full overflow-hidden ${sizeClasses7[size]}`,
|
|
@@ -3726,7 +3940,7 @@ var ProgressBar = ({
|
|
|
3726
3940
|
"aria-valuenow": value,
|
|
3727
3941
|
"aria-valuemin": 0,
|
|
3728
3942
|
"aria-valuemax": max,
|
|
3729
|
-
children: /* @__PURE__ */ (0,
|
|
3943
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
|
|
3730
3944
|
"div",
|
|
3731
3945
|
{
|
|
3732
3946
|
className: `${sizeClasses7[size]} ${variantClasses[variant]} rounded-full transition-all duration-300 ease-out`,
|
|
@@ -3739,8 +3953,8 @@ var ProgressBar = ({
|
|
|
3739
3953
|
};
|
|
3740
3954
|
|
|
3741
3955
|
// src/components/Slider.tsx
|
|
3742
|
-
var
|
|
3743
|
-
var
|
|
3956
|
+
var import_react21 = __toESM(require("react"));
|
|
3957
|
+
var import_jsx_runtime101 = require("react/jsx-runtime");
|
|
3744
3958
|
var Slider = ({
|
|
3745
3959
|
value: controlledValue,
|
|
3746
3960
|
defaultValue = 50,
|
|
@@ -3757,10 +3971,10 @@ var Slider = ({
|
|
|
3757
3971
|
defaultRangeValue = [25, 75],
|
|
3758
3972
|
onRangeChange
|
|
3759
3973
|
}) => {
|
|
3760
|
-
const [internalValue, setInternalValue] =
|
|
3761
|
-
const [internalRangeValue, setInternalRangeValue] =
|
|
3762
|
-
const trackRef = (0,
|
|
3763
|
-
const [isDragging, setIsDragging] =
|
|
3974
|
+
const [internalValue, setInternalValue] = import_react21.default.useState(defaultValue);
|
|
3975
|
+
const [internalRangeValue, setInternalRangeValue] = import_react21.default.useState(defaultRangeValue);
|
|
3976
|
+
const trackRef = (0, import_react21.useRef)(null);
|
|
3977
|
+
const [isDragging, setIsDragging] = import_react21.default.useState(null);
|
|
3764
3978
|
const value = controlledValue !== void 0 ? controlledValue : internalValue;
|
|
3765
3979
|
const rangeValue = controlledRangeValue !== void 0 ? controlledRangeValue : internalRangeValue;
|
|
3766
3980
|
const handleChange = (e) => {
|
|
@@ -3808,7 +4022,7 @@ var Slider = ({
|
|
|
3808
4022
|
const handleRangeEnd = () => {
|
|
3809
4023
|
setIsDragging(null);
|
|
3810
4024
|
};
|
|
3811
|
-
|
|
4025
|
+
import_react21.default.useEffect(() => {
|
|
3812
4026
|
if (isDragging) {
|
|
3813
4027
|
document.addEventListener("mousemove", handleRangeMouseMove);
|
|
3814
4028
|
document.addEventListener("mouseup", handleRangeEnd);
|
|
@@ -3826,18 +4040,18 @@ var Slider = ({
|
|
|
3826
4040
|
const minPercentage = (rangeValue[0] - min) / (max - min) * 100;
|
|
3827
4041
|
const maxPercentage = (rangeValue[1] - min) / (max - min) * 100;
|
|
3828
4042
|
if (range) {
|
|
3829
|
-
return /* @__PURE__ */ (0,
|
|
3830
|
-
(label || showValue) && /* @__PURE__ */ (0,
|
|
3831
|
-
label && /* @__PURE__ */ (0,
|
|
3832
|
-
showValue && /* @__PURE__ */ (0,
|
|
4043
|
+
return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: `w-full ${className}`, children: [
|
|
4044
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "flex justify-between items-center mb-2", children: [
|
|
4045
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("label", { className: "text-sm font-medium text-[hsl(var(--foreground))]", children: label }),
|
|
4046
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("span", { className: "text-sm font-medium text-[hsl(var(--muted-foreground))]", children: [
|
|
3833
4047
|
rangeValue[0],
|
|
3834
4048
|
" - ",
|
|
3835
4049
|
rangeValue[1]
|
|
3836
4050
|
] })
|
|
3837
4051
|
] }),
|
|
3838
|
-
/* @__PURE__ */ (0,
|
|
3839
|
-
/* @__PURE__ */ (0,
|
|
3840
|
-
/* @__PURE__ */ (0,
|
|
4052
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "relative h-10 flex items-center", ref: trackRef, children: [
|
|
4053
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "absolute w-full h-2 bg-[hsl(var(--muted))] rounded-full" }),
|
|
4054
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
3841
4055
|
"div",
|
|
3842
4056
|
{
|
|
3843
4057
|
className: "absolute h-2 bg-[hsl(var(--primary))] rounded-full pointer-events-none",
|
|
@@ -3847,7 +4061,7 @@ var Slider = ({
|
|
|
3847
4061
|
}
|
|
3848
4062
|
}
|
|
3849
4063
|
),
|
|
3850
|
-
/* @__PURE__ */ (0,
|
|
4064
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
3851
4065
|
"div",
|
|
3852
4066
|
{
|
|
3853
4067
|
className: `absolute w-4 h-4 -ml-2 rounded-full bg-[hsl(var(--background))] border-2 border-[hsl(var(--primary))] shadow-md cursor-pointer z-10
|
|
@@ -3864,7 +4078,7 @@ var Slider = ({
|
|
|
3864
4078
|
tabIndex: disabled ? -1 : 0
|
|
3865
4079
|
}
|
|
3866
4080
|
),
|
|
3867
|
-
/* @__PURE__ */ (0,
|
|
4081
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
3868
4082
|
"div",
|
|
3869
4083
|
{
|
|
3870
4084
|
className: `absolute w-4 h-4 -ml-2 rounded-full bg-[hsl(var(--background))] border-2 border-[hsl(var(--primary))] shadow-md cursor-pointer z-10
|
|
@@ -3884,21 +4098,21 @@ var Slider = ({
|
|
|
3884
4098
|
] })
|
|
3885
4099
|
] });
|
|
3886
4100
|
}
|
|
3887
|
-
return /* @__PURE__ */ (0,
|
|
3888
|
-
(label || showValue) && /* @__PURE__ */ (0,
|
|
3889
|
-
label && /* @__PURE__ */ (0,
|
|
3890
|
-
showValue && /* @__PURE__ */ (0,
|
|
4101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: `w-full ${className}`, children: [
|
|
4102
|
+
(label || showValue) && /* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "flex justify-between items-center mb-2", children: [
|
|
4103
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("label", { className: "text-sm font-medium text-[hsl(var(--foreground))]", children: label }),
|
|
4104
|
+
showValue && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("span", { className: "text-sm font-medium text-[hsl(var(--muted-foreground))]", children: value })
|
|
3891
4105
|
] }),
|
|
3892
|
-
/* @__PURE__ */ (0,
|
|
3893
|
-
/* @__PURE__ */ (0,
|
|
3894
|
-
/* @__PURE__ */ (0,
|
|
4106
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsxs)("div", { className: "relative h-10 flex items-center", children: [
|
|
4107
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: "absolute w-full h-2 bg-[hsl(var(--muted))] rounded-full" }),
|
|
4108
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
3895
4109
|
"div",
|
|
3896
4110
|
{
|
|
3897
4111
|
className: "absolute h-2 bg-[hsl(var(--primary))] rounded-full pointer-events-none",
|
|
3898
4112
|
style: { width: `${percentage}%` }
|
|
3899
4113
|
}
|
|
3900
4114
|
),
|
|
3901
|
-
/* @__PURE__ */ (0,
|
|
4115
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
3902
4116
|
"div",
|
|
3903
4117
|
{
|
|
3904
4118
|
className: `absolute w-4 h-4 -ml-2 rounded-full bg-[hsl(var(--background))] border-2 border-[hsl(var(--primary))] shadow-md pointer-events-none z-10
|
|
@@ -3907,7 +4121,7 @@ var Slider = ({
|
|
|
3907
4121
|
style: { left: `${percentage}%` }
|
|
3908
4122
|
}
|
|
3909
4123
|
),
|
|
3910
|
-
/* @__PURE__ */ (0,
|
|
4124
|
+
/* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
3911
4125
|
"input",
|
|
3912
4126
|
{
|
|
3913
4127
|
type: "range",
|
|
@@ -3929,8 +4143,8 @@ var Slider = ({
|
|
|
3929
4143
|
};
|
|
3930
4144
|
|
|
3931
4145
|
// src/components/Avatar.tsx
|
|
3932
|
-
var
|
|
3933
|
-
var
|
|
4146
|
+
var import_react22 = __toESM(require("react"));
|
|
4147
|
+
var import_jsx_runtime102 = require("react/jsx-runtime");
|
|
3934
4148
|
var Avatar = ({
|
|
3935
4149
|
src,
|
|
3936
4150
|
alt,
|
|
@@ -3940,7 +4154,7 @@ var Avatar = ({
|
|
|
3940
4154
|
className = "",
|
|
3941
4155
|
fallbackColor = "bg-[hsl(var(--primary))]"
|
|
3942
4156
|
}) => {
|
|
3943
|
-
const [imageError, setImageError] =
|
|
4157
|
+
const [imageError, setImageError] = import_react22.default.useState(false);
|
|
3944
4158
|
const sizeClasses7 = {
|
|
3945
4159
|
xs: "w-6 h-6 text-xs",
|
|
3946
4160
|
sm: "w-8 h-8 text-sm",
|
|
@@ -3958,11 +4172,11 @@ var Avatar = ({
|
|
|
3958
4172
|
};
|
|
3959
4173
|
const showImage = src && !imageError;
|
|
3960
4174
|
const showInitials = !showImage && name;
|
|
3961
|
-
return /* @__PURE__ */ (0,
|
|
4175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
|
|
3962
4176
|
"div",
|
|
3963
4177
|
{
|
|
3964
4178
|
className: `${sizeClasses7[size]} ${shapeClass} flex items-center justify-center overflow-hidden ${showImage ? "bg-[hsl(var(--muted))]" : `${fallbackColor} text-white`} ${className}`,
|
|
3965
|
-
children: showImage ? /* @__PURE__ */ (0,
|
|
4179
|
+
children: showImage ? /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
|
|
3966
4180
|
"img",
|
|
3967
4181
|
{
|
|
3968
4182
|
src,
|
|
@@ -3970,13 +4184,13 @@ var Avatar = ({
|
|
|
3970
4184
|
className: "w-full h-full object-cover",
|
|
3971
4185
|
onError: () => setImageError(true)
|
|
3972
4186
|
}
|
|
3973
|
-
) : showInitials ? /* @__PURE__ */ (0,
|
|
4187
|
+
) : showInitials ? /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("span", { className: "font-semibold select-none", children: getInitials(name) }) : /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
|
|
3974
4188
|
"svg",
|
|
3975
4189
|
{
|
|
3976
4190
|
className: "w-full h-full text-[hsl(var(--muted-foreground))]",
|
|
3977
4191
|
fill: "currentColor",
|
|
3978
4192
|
viewBox: "0 0 24 24",
|
|
3979
|
-
children: /* @__PURE__ */ (0,
|
|
4193
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("path", { d: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" })
|
|
3980
4194
|
}
|
|
3981
4195
|
)
|
|
3982
4196
|
}
|
|
@@ -3984,7 +4198,7 @@ var Avatar = ({
|
|
|
3984
4198
|
};
|
|
3985
4199
|
|
|
3986
4200
|
// src/components/Textarea.tsx
|
|
3987
|
-
var
|
|
4201
|
+
var import_jsx_runtime103 = require("react/jsx-runtime");
|
|
3988
4202
|
var Textarea = ({
|
|
3989
4203
|
label,
|
|
3990
4204
|
error,
|
|
@@ -4011,9 +4225,9 @@ var Textarea = ({
|
|
|
4011
4225
|
bg-transparent text-[hsl(var(--foreground))]
|
|
4012
4226
|
placeholder:text-[hsl(var(--muted-foreground))]
|
|
4013
4227
|
disabled:opacity-50 disabled:cursor-not-allowed disabled:bg-[hsl(var(--muted))]`;
|
|
4014
|
-
return /* @__PURE__ */ (0,
|
|
4015
|
-
label && /* @__PURE__ */ (0,
|
|
4016
|
-
/* @__PURE__ */ (0,
|
|
4228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)("div", { className: `w-full ${className}`, children: [
|
|
4229
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("label", { className: "block text-sm font-medium text-[hsl(var(--foreground))] mb-1.5", children: label }),
|
|
4230
|
+
/* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
|
|
4017
4231
|
"textarea",
|
|
4018
4232
|
{
|
|
4019
4233
|
className: `${baseClasses} ${sizeClasses7[size]} ${resizeClasses[resize]}`,
|
|
@@ -4021,14 +4235,14 @@ var Textarea = ({
|
|
|
4021
4235
|
...props
|
|
4022
4236
|
}
|
|
4023
4237
|
),
|
|
4024
|
-
error && /* @__PURE__ */ (0,
|
|
4025
|
-
helperText && !error && /* @__PURE__ */ (0,
|
|
4238
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { className: "mt-1.5 text-sm text-[hsl(var(--destructive))]", children: error }),
|
|
4239
|
+
helperText && !error && /* @__PURE__ */ (0, import_jsx_runtime103.jsx)("p", { className: "mt-1.5 text-sm text-[hsl(var(--muted-foreground))]", children: helperText })
|
|
4026
4240
|
] });
|
|
4027
4241
|
};
|
|
4028
4242
|
|
|
4029
4243
|
// src/components/RichTextEditor.tsx
|
|
4030
|
-
var
|
|
4031
|
-
var
|
|
4244
|
+
var import_react23 = require("react");
|
|
4245
|
+
var import_jsx_runtime104 = require("react/jsx-runtime");
|
|
4032
4246
|
var RichTextEditor = ({
|
|
4033
4247
|
value = "",
|
|
4034
4248
|
onChange,
|
|
@@ -4042,16 +4256,16 @@ var RichTextEditor = ({
|
|
|
4042
4256
|
helperText
|
|
4043
4257
|
}) => {
|
|
4044
4258
|
const { themeName } = useTheme();
|
|
4045
|
-
const editorRef = (0,
|
|
4046
|
-
const [isFocused, setIsFocused] = (0,
|
|
4047
|
-
const [activeFormats, setActiveFormats] = (0,
|
|
4048
|
-
const [showLinkModal, setShowLinkModal] = (0,
|
|
4049
|
-
const [linkUrl, setLinkUrl] = (0,
|
|
4050
|
-
const [showImageModal, setShowImageModal] = (0,
|
|
4051
|
-
const [imageUrl, setImageUrl] = (0,
|
|
4052
|
-
const [imageAlt, setImageAlt] = (0,
|
|
4053
|
-
const savedSelection = (0,
|
|
4054
|
-
(0,
|
|
4259
|
+
const editorRef = (0, import_react23.useRef)(null);
|
|
4260
|
+
const [isFocused, setIsFocused] = (0, import_react23.useState)(false);
|
|
4261
|
+
const [activeFormats, setActiveFormats] = (0, import_react23.useState)(/* @__PURE__ */ new Set());
|
|
4262
|
+
const [showLinkModal, setShowLinkModal] = (0, import_react23.useState)(false);
|
|
4263
|
+
const [linkUrl, setLinkUrl] = (0, import_react23.useState)("");
|
|
4264
|
+
const [showImageModal, setShowImageModal] = (0, import_react23.useState)(false);
|
|
4265
|
+
const [imageUrl, setImageUrl] = (0, import_react23.useState)("");
|
|
4266
|
+
const [imageAlt, setImageAlt] = (0, import_react23.useState)("");
|
|
4267
|
+
const savedSelection = (0, import_react23.useRef)(null);
|
|
4268
|
+
(0, import_react23.useLayoutEffect)(() => {
|
|
4055
4269
|
const styleId = "rich-text-editor-styles";
|
|
4056
4270
|
if (!document.getElementById(styleId)) {
|
|
4057
4271
|
const style = document.createElement("style");
|
|
@@ -4113,9 +4327,9 @@ var RichTextEditor = ({
|
|
|
4113
4327
|
document.head.appendChild(style);
|
|
4114
4328
|
}
|
|
4115
4329
|
}, []);
|
|
4116
|
-
const isInitialRender = (0,
|
|
4117
|
-
const isInternalUpdate = (0,
|
|
4118
|
-
(0,
|
|
4330
|
+
const isInitialRender = (0, import_react23.useRef)(true);
|
|
4331
|
+
const isInternalUpdate = (0, import_react23.useRef)(false);
|
|
4332
|
+
(0, import_react23.useEffect)(() => {
|
|
4119
4333
|
if (isInitialRender.current && editorRef.current) {
|
|
4120
4334
|
editorRef.current.innerHTML = value;
|
|
4121
4335
|
isInitialRender.current = false;
|
|
@@ -4126,7 +4340,7 @@ var RichTextEditor = ({
|
|
|
4126
4340
|
}
|
|
4127
4341
|
}
|
|
4128
4342
|
}, []);
|
|
4129
|
-
(0,
|
|
4343
|
+
(0, import_react23.useEffect)(() => {
|
|
4130
4344
|
if (!isInitialRender.current && !isInternalUpdate.current && editorRef.current) {
|
|
4131
4345
|
const currentHtml = editorRef.current.innerHTML;
|
|
4132
4346
|
if (currentHtml !== value) {
|
|
@@ -4169,7 +4383,7 @@ var RichTextEditor = ({
|
|
|
4169
4383
|
}
|
|
4170
4384
|
isInternalUpdate.current = false;
|
|
4171
4385
|
}, [value]);
|
|
4172
|
-
const updateActiveFormats = (0,
|
|
4386
|
+
const updateActiveFormats = (0, import_react23.useCallback)(() => {
|
|
4173
4387
|
const formats = /* @__PURE__ */ new Set();
|
|
4174
4388
|
if (document.queryCommandState("bold")) formats.add("bold");
|
|
4175
4389
|
if (document.queryCommandState("italic")) formats.add("italic");
|
|
@@ -4186,14 +4400,14 @@ var RichTextEditor = ({
|
|
|
4186
4400
|
}
|
|
4187
4401
|
setActiveFormats(formats);
|
|
4188
4402
|
}, []);
|
|
4189
|
-
const handleInput = (0,
|
|
4403
|
+
const handleInput = (0, import_react23.useCallback)(() => {
|
|
4190
4404
|
if (editorRef.current && onChange) {
|
|
4191
4405
|
isInternalUpdate.current = true;
|
|
4192
4406
|
onChange(editorRef.current.innerHTML);
|
|
4193
4407
|
}
|
|
4194
4408
|
updateActiveFormats();
|
|
4195
4409
|
}, [onChange, updateActiveFormats]);
|
|
4196
|
-
const handleFocus = (0,
|
|
4410
|
+
const handleFocus = (0, import_react23.useCallback)(() => {
|
|
4197
4411
|
setIsFocused(true);
|
|
4198
4412
|
if (editorRef.current && (!editorRef.current.innerHTML || editorRef.current.innerHTML === "")) {
|
|
4199
4413
|
editorRef.current.innerHTML = "<p><br></p>";
|
|
@@ -4207,28 +4421,28 @@ var RichTextEditor = ({
|
|
|
4207
4421
|
}
|
|
4208
4422
|
}
|
|
4209
4423
|
}, []);
|
|
4210
|
-
const handleFormat = (0,
|
|
4424
|
+
const handleFormat = (0, import_react23.useCallback)((command) => {
|
|
4211
4425
|
if (disabled) return;
|
|
4212
4426
|
document.execCommand(command, false);
|
|
4213
4427
|
editorRef.current?.focus();
|
|
4214
4428
|
updateActiveFormats();
|
|
4215
4429
|
handleInput();
|
|
4216
4430
|
}, [disabled, updateActiveFormats, handleInput]);
|
|
4217
|
-
const handleList = (0,
|
|
4431
|
+
const handleList = (0, import_react23.useCallback)((command) => {
|
|
4218
4432
|
if (disabled) return;
|
|
4219
4433
|
document.execCommand(command, false);
|
|
4220
4434
|
editorRef.current?.focus();
|
|
4221
4435
|
updateActiveFormats();
|
|
4222
4436
|
handleInput();
|
|
4223
4437
|
}, [disabled, updateActiveFormats, handleInput]);
|
|
4224
|
-
const handleHeading = (0,
|
|
4438
|
+
const handleHeading = (0, import_react23.useCallback)((level) => {
|
|
4225
4439
|
if (disabled) return;
|
|
4226
4440
|
document.execCommand("formatBlock", false, level);
|
|
4227
4441
|
editorRef.current?.focus();
|
|
4228
4442
|
updateActiveFormats();
|
|
4229
4443
|
handleInput();
|
|
4230
4444
|
}, [disabled, updateActiveFormats, handleInput]);
|
|
4231
|
-
const handleLink = (0,
|
|
4445
|
+
const handleLink = (0, import_react23.useCallback)(() => {
|
|
4232
4446
|
if (disabled) return;
|
|
4233
4447
|
const selection = window.getSelection();
|
|
4234
4448
|
if (selection && selection.rangeCount > 0) {
|
|
@@ -4236,7 +4450,7 @@ var RichTextEditor = ({
|
|
|
4236
4450
|
}
|
|
4237
4451
|
setShowLinkModal(true);
|
|
4238
4452
|
}, [disabled]);
|
|
4239
|
-
const insertLink = (0,
|
|
4453
|
+
const insertLink = (0, import_react23.useCallback)(() => {
|
|
4240
4454
|
if (!linkUrl || !editorRef.current) return;
|
|
4241
4455
|
const selection = window.getSelection();
|
|
4242
4456
|
if (savedSelection.current && selection) {
|
|
@@ -4254,7 +4468,7 @@ var RichTextEditor = ({
|
|
|
4254
4468
|
editorRef.current?.focus();
|
|
4255
4469
|
handleInput();
|
|
4256
4470
|
}, [linkUrl, handleInput]);
|
|
4257
|
-
const handleCode = (0,
|
|
4471
|
+
const handleCode = (0, import_react23.useCallback)(() => {
|
|
4258
4472
|
if (disabled) return;
|
|
4259
4473
|
const selection = window.getSelection();
|
|
4260
4474
|
if (selection && selection.rangeCount > 0) {
|
|
@@ -4270,7 +4484,7 @@ var RichTextEditor = ({
|
|
|
4270
4484
|
}
|
|
4271
4485
|
editorRef.current?.focus();
|
|
4272
4486
|
}, [disabled, handleInput]);
|
|
4273
|
-
const handleImage = (0,
|
|
4487
|
+
const handleImage = (0, import_react23.useCallback)(() => {
|
|
4274
4488
|
if (disabled) return;
|
|
4275
4489
|
const selection = window.getSelection();
|
|
4276
4490
|
if (selection && selection.rangeCount > 0) {
|
|
@@ -4278,7 +4492,7 @@ var RichTextEditor = ({
|
|
|
4278
4492
|
}
|
|
4279
4493
|
setShowImageModal(true);
|
|
4280
4494
|
}, [disabled]);
|
|
4281
|
-
const insertImage = (0,
|
|
4495
|
+
const insertImage = (0, import_react23.useCallback)(() => {
|
|
4282
4496
|
if (!imageUrl || !editorRef.current) return;
|
|
4283
4497
|
editorRef.current.focus();
|
|
4284
4498
|
const img = document.createElement("img");
|
|
@@ -4358,11 +4572,11 @@ var RichTextEditor = ({
|
|
|
4358
4572
|
const editorBaseClass = themeName === "minimalistic" ? "bg-transparent border-2 border-white text-white placeholder:text-[hsl(var(--muted-foreground))]" : "bg-[hsl(var(--card))] border border-[hsl(var(--input))] text-[hsl(var(--foreground))]";
|
|
4359
4573
|
const focusClass = isFocused && !disabled ? themeName === "minimalistic" ? "border-white" : "border-[hsl(var(--primary))] ring-1 ring-[hsl(var(--ring))]/50" : "";
|
|
4360
4574
|
const errorClass = error ? "border-red-500 dark:border-red-400" : "";
|
|
4361
|
-
return /* @__PURE__ */ (0,
|
|
4362
|
-
label && /* @__PURE__ */ (0,
|
|
4363
|
-
/* @__PURE__ */ (0,
|
|
4364
|
-
/* @__PURE__ */ (0,
|
|
4365
|
-
/* @__PURE__ */ (0,
|
|
4575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: `w-full ${className}`, children: [
|
|
4576
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("label", { className: "block text-sm font-medium text-[hsl(var(--foreground))] mb-2", children: label }),
|
|
4577
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: `rounded-t-lg border-b ${editorBaseClass} p-2 flex flex-wrap gap-1`, children: [
|
|
4578
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex gap-1", children: [
|
|
4579
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4366
4580
|
"button",
|
|
4367
4581
|
{
|
|
4368
4582
|
type: "button",
|
|
@@ -4370,10 +4584,10 @@ var RichTextEditor = ({
|
|
|
4370
4584
|
className: getButtonClass(activeFormats.has("bold")),
|
|
4371
4585
|
disabled,
|
|
4372
4586
|
title: "Bold (Ctrl+B)",
|
|
4373
|
-
children: /* @__PURE__ */ (0,
|
|
4587
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("path", { d: "M12.78 4c1.09 0 2.04.38 2.84 1.14.8.76 1.2 1.74 1.2 2.94 0 .9-.25 1.68-.76 2.36-.51.68-1.2 1.14-2.04 1.38v.08c1.06.22 1.89.7 2.48 1.44.59.74.88 1.64.88 2.7 0 1.34-.47 2.43-1.41 3.27C14.96 19.77 13.74 20 12.24 20H4V4h8.78zm-.66 7.14c.62 0 1.12-.18 1.5-.54.38-.36.57-.84.57-1.44 0-.6-.19-1.08-.57-1.44-.38-.36-.88-.54-1.5-.54H7.5v3.96h4.62zm.24 6.86c.68 0 1.24-.19 1.68-.57.44-.38.66-.9.66-1.56 0-.66-.22-1.18-.66-1.56-.44-.38-1-.57-1.68-.57H7.5v4.26h4.86z" }) })
|
|
4374
4588
|
}
|
|
4375
4589
|
),
|
|
4376
|
-
/* @__PURE__ */ (0,
|
|
4590
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4377
4591
|
"button",
|
|
4378
4592
|
{
|
|
4379
4593
|
type: "button",
|
|
@@ -4381,10 +4595,10 @@ var RichTextEditor = ({
|
|
|
4381
4595
|
className: getButtonClass(activeFormats.has("italic")),
|
|
4382
4596
|
disabled,
|
|
4383
4597
|
title: "Italic (Ctrl+I)",
|
|
4384
|
-
children: /* @__PURE__ */ (0,
|
|
4598
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("path", { d: "M11.59 4H16v2h-1.71l-3.58 8H13v2H8v-2h1.71l3.58-8H11.59V4z" }) })
|
|
4385
4599
|
}
|
|
4386
4600
|
),
|
|
4387
|
-
/* @__PURE__ */ (0,
|
|
4601
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4388
4602
|
"button",
|
|
4389
4603
|
{
|
|
4390
4604
|
type: "button",
|
|
@@ -4392,10 +4606,10 @@ var RichTextEditor = ({
|
|
|
4392
4606
|
className: getButtonClass(activeFormats.has("underline")),
|
|
4393
4607
|
disabled,
|
|
4394
4608
|
title: "Underline (Ctrl+U)",
|
|
4395
|
-
children: /* @__PURE__ */ (0,
|
|
4609
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("path", { d: "M10 16c-2.21 0-4-1.79-4-4V4h2v8c0 1.1.9 2 2 2s2-.9 2-2V4h2v8c0 2.21-1.79 4-4 4zM4 18h12v2H4v-2z" }) })
|
|
4396
4610
|
}
|
|
4397
4611
|
),
|
|
4398
|
-
/* @__PURE__ */ (0,
|
|
4612
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4399
4613
|
"button",
|
|
4400
4614
|
{
|
|
4401
4615
|
type: "button",
|
|
@@ -4403,13 +4617,13 @@ var RichTextEditor = ({
|
|
|
4403
4617
|
className: getButtonClass(activeFormats.has("strikeThrough")),
|
|
4404
4618
|
disabled,
|
|
4405
4619
|
title: "Strikethrough",
|
|
4406
|
-
children: /* @__PURE__ */ (0,
|
|
4620
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("path", { d: "M10 4c-2 0-3.5.5-4.5 1.5S4 7.5 4 9h2c0-.7.2-1.2.6-1.6.4-.4 1-.6 1.9-.6.8 0 1.4.2 1.8.5.4.3.7.8.7 1.4 0 .5-.2.9-.5 1.2-.3.3-.9.6-1.8.9l-.7.2c-1.2.3-2.1.7-2.7 1.2C4.2 12.7 4 13.5 4 14.5c0 1.1.4 2 1.1 2.6.7.6 1.7.9 3 .9 2.1 0 3.6-.5 4.6-1.5.9-1 1.3-2.3 1.3-3.8h-2c0 .9-.2 1.6-.7 2.1-.5.5-1.2.7-2.2.7-.8 0-1.4-.2-1.8-.5-.4-.3-.6-.8-.6-1.4 0-.5.2-.9.5-1.2.3-.3.9-.6 1.8-.9l.7-.2c1.2-.3 2.1-.7 2.7-1.2.6-.5.9-1.3.9-2.3 0-1.2-.4-2.1-1.2-2.8-.8-.7-1.9-1-3.3-1zM2 10h16v1H2v-1z" }) })
|
|
4407
4621
|
}
|
|
4408
4622
|
)
|
|
4409
4623
|
] }),
|
|
4410
|
-
/* @__PURE__ */ (0,
|
|
4411
|
-
/* @__PURE__ */ (0,
|
|
4412
|
-
/* @__PURE__ */ (0,
|
|
4624
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "w-px bg-[hsl(var(--border))] mx-1" }),
|
|
4625
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex gap-1", children: [
|
|
4626
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4413
4627
|
"button",
|
|
4414
4628
|
{
|
|
4415
4629
|
type: "button",
|
|
@@ -4417,10 +4631,10 @@ var RichTextEditor = ({
|
|
|
4417
4631
|
className: getButtonClass(activeFormats.has("h1")),
|
|
4418
4632
|
disabled,
|
|
4419
4633
|
title: "Heading 1",
|
|
4420
|
-
children: /* @__PURE__ */ (0,
|
|
4634
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("text", { x: "2", y: "16", fontSize: "14", fontWeight: "bold", children: "H1" }) })
|
|
4421
4635
|
}
|
|
4422
4636
|
),
|
|
4423
|
-
/* @__PURE__ */ (0,
|
|
4637
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4424
4638
|
"button",
|
|
4425
4639
|
{
|
|
4426
4640
|
type: "button",
|
|
@@ -4428,10 +4642,10 @@ var RichTextEditor = ({
|
|
|
4428
4642
|
className: getButtonClass(activeFormats.has("h2")),
|
|
4429
4643
|
disabled,
|
|
4430
4644
|
title: "Heading 2",
|
|
4431
|
-
children: /* @__PURE__ */ (0,
|
|
4645
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("text", { x: "2", y: "16", fontSize: "14", fontWeight: "bold", children: "H2" }) })
|
|
4432
4646
|
}
|
|
4433
4647
|
),
|
|
4434
|
-
/* @__PURE__ */ (0,
|
|
4648
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4435
4649
|
"button",
|
|
4436
4650
|
{
|
|
4437
4651
|
type: "button",
|
|
@@ -4439,13 +4653,13 @@ var RichTextEditor = ({
|
|
|
4439
4653
|
className: getButtonClass(activeFormats.has("h3")),
|
|
4440
4654
|
disabled,
|
|
4441
4655
|
title: "Heading 3",
|
|
4442
|
-
children: /* @__PURE__ */ (0,
|
|
4656
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("text", { x: "2", y: "16", fontSize: "14", fontWeight: "bold", children: "H3" }) })
|
|
4443
4657
|
}
|
|
4444
4658
|
)
|
|
4445
4659
|
] }),
|
|
4446
|
-
/* @__PURE__ */ (0,
|
|
4447
|
-
/* @__PURE__ */ (0,
|
|
4448
|
-
/* @__PURE__ */ (0,
|
|
4660
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "w-px bg-[hsl(var(--border))] mx-1" }),
|
|
4661
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex gap-1", children: [
|
|
4662
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4449
4663
|
"button",
|
|
4450
4664
|
{
|
|
4451
4665
|
type: "button",
|
|
@@ -4453,10 +4667,10 @@ var RichTextEditor = ({
|
|
|
4453
4667
|
className: getButtonClass(activeFormats.has("ul")),
|
|
4454
4668
|
disabled,
|
|
4455
4669
|
title: "Bullet List",
|
|
4456
|
-
children: /* @__PURE__ */ (0,
|
|
4670
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("path", { d: "M4 4h2v2H4V4zm4 0h8v2H8V4zM4 8h2v2H4V8zm4 0h8v2H8V8zm-4 4h2v2H4v-2zm4 0h8v2H8v-2zm-4 4h2v2H4v-2zm4 0h8v2H8v-2z" }) })
|
|
4457
4671
|
}
|
|
4458
4672
|
),
|
|
4459
|
-
/* @__PURE__ */ (0,
|
|
4673
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4460
4674
|
"button",
|
|
4461
4675
|
{
|
|
4462
4676
|
type: "button",
|
|
@@ -4464,13 +4678,13 @@ var RichTextEditor = ({
|
|
|
4464
4678
|
className: getButtonClass(activeFormats.has("ol")),
|
|
4465
4679
|
disabled,
|
|
4466
4680
|
title: "Numbered List",
|
|
4467
|
-
children: /* @__PURE__ */ (0,
|
|
4681
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("path", { d: "M4 4h1v3H4V4zm0 4h1v1H3V8h2v1H4zm1 2H3v1h2v1H3v1h2v-3zM8 4h8v2H8V4zm0 4h8v2H8V8zm0 4h8v2H8v-2zm0 4h8v2H8v-2z" }) })
|
|
4468
4682
|
}
|
|
4469
4683
|
)
|
|
4470
4684
|
] }),
|
|
4471
|
-
/* @__PURE__ */ (0,
|
|
4472
|
-
/* @__PURE__ */ (0,
|
|
4473
|
-
/* @__PURE__ */ (0,
|
|
4685
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: "w-px bg-[hsl(var(--border))] mx-1" }),
|
|
4686
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex gap-1", children: [
|
|
4687
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4474
4688
|
"button",
|
|
4475
4689
|
{
|
|
4476
4690
|
type: "button",
|
|
@@ -4478,10 +4692,10 @@ var RichTextEditor = ({
|
|
|
4478
4692
|
className: getButtonClass(false),
|
|
4479
4693
|
disabled,
|
|
4480
4694
|
title: "Insert Link",
|
|
4481
|
-
children: /* @__PURE__ */ (0,
|
|
4695
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1" }) })
|
|
4482
4696
|
}
|
|
4483
4697
|
),
|
|
4484
|
-
/* @__PURE__ */ (0,
|
|
4698
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4485
4699
|
"button",
|
|
4486
4700
|
{
|
|
4487
4701
|
type: "button",
|
|
@@ -4489,10 +4703,10 @@ var RichTextEditor = ({
|
|
|
4489
4703
|
className: getButtonClass(false),
|
|
4490
4704
|
disabled,
|
|
4491
4705
|
title: "Insert Image/Video",
|
|
4492
|
-
children: /* @__PURE__ */ (0,
|
|
4706
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" }) })
|
|
4493
4707
|
}
|
|
4494
4708
|
),
|
|
4495
|
-
/* @__PURE__ */ (0,
|
|
4709
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4496
4710
|
"button",
|
|
4497
4711
|
{
|
|
4498
4712
|
type: "button",
|
|
@@ -4500,12 +4714,12 @@ var RichTextEditor = ({
|
|
|
4500
4714
|
className: getButtonClass(false),
|
|
4501
4715
|
disabled,
|
|
4502
4716
|
title: "Code",
|
|
4503
|
-
children: /* @__PURE__ */ (0,
|
|
4717
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4" }) })
|
|
4504
4718
|
}
|
|
4505
4719
|
)
|
|
4506
4720
|
] })
|
|
4507
4721
|
] }),
|
|
4508
|
-
/* @__PURE__ */ (0,
|
|
4722
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4509
4723
|
"div",
|
|
4510
4724
|
{
|
|
4511
4725
|
ref: editorRef,
|
|
@@ -4529,9 +4743,9 @@ var RichTextEditor = ({
|
|
|
4529
4743
|
suppressContentEditableWarning: true
|
|
4530
4744
|
}
|
|
4531
4745
|
),
|
|
4532
|
-
error && /* @__PURE__ */ (0,
|
|
4533
|
-
helperText && !error && /* @__PURE__ */ (0,
|
|
4534
|
-
/* @__PURE__ */ (0,
|
|
4746
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("p", { className: "mt-1 text-sm text-red-600 dark:text-red-400", children: error }),
|
|
4747
|
+
helperText && !error && /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("p", { className: "mt-1 text-sm text-[hsl(var(--muted-foreground))]", children: helperText }),
|
|
4748
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4535
4749
|
Modal,
|
|
4536
4750
|
{
|
|
4537
4751
|
isOpen: showLinkModal,
|
|
@@ -4541,8 +4755,8 @@ var RichTextEditor = ({
|
|
|
4541
4755
|
},
|
|
4542
4756
|
title: "Insert Link",
|
|
4543
4757
|
size: "sm",
|
|
4544
|
-
children: /* @__PURE__ */ (0,
|
|
4545
|
-
/* @__PURE__ */ (0,
|
|
4758
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "space-y-4", children: [
|
|
4759
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4546
4760
|
TextInput,
|
|
4547
4761
|
{
|
|
4548
4762
|
label: "URL",
|
|
@@ -4558,8 +4772,8 @@ var RichTextEditor = ({
|
|
|
4558
4772
|
}
|
|
4559
4773
|
}
|
|
4560
4774
|
),
|
|
4561
|
-
/* @__PURE__ */ (0,
|
|
4562
|
-
/* @__PURE__ */ (0,
|
|
4775
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex gap-2 justify-end", children: [
|
|
4776
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4563
4777
|
Button,
|
|
4564
4778
|
{
|
|
4565
4779
|
variant: "secondary",
|
|
@@ -4570,7 +4784,7 @@ var RichTextEditor = ({
|
|
|
4570
4784
|
children: "Cancel"
|
|
4571
4785
|
}
|
|
4572
4786
|
),
|
|
4573
|
-
/* @__PURE__ */ (0,
|
|
4787
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4574
4788
|
Button,
|
|
4575
4789
|
{
|
|
4576
4790
|
variant: "primary",
|
|
@@ -4583,7 +4797,7 @@ var RichTextEditor = ({
|
|
|
4583
4797
|
] })
|
|
4584
4798
|
}
|
|
4585
4799
|
),
|
|
4586
|
-
/* @__PURE__ */ (0,
|
|
4800
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4587
4801
|
Modal,
|
|
4588
4802
|
{
|
|
4589
4803
|
isOpen: showImageModal,
|
|
@@ -4594,8 +4808,8 @@ var RichTextEditor = ({
|
|
|
4594
4808
|
},
|
|
4595
4809
|
title: "Insert Image",
|
|
4596
4810
|
size: "sm",
|
|
4597
|
-
children: /* @__PURE__ */ (0,
|
|
4598
|
-
/* @__PURE__ */ (0,
|
|
4811
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "space-y-4", children: [
|
|
4812
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4599
4813
|
TextInput,
|
|
4600
4814
|
{
|
|
4601
4815
|
label: "Image URL",
|
|
@@ -4611,7 +4825,7 @@ var RichTextEditor = ({
|
|
|
4611
4825
|
}
|
|
4612
4826
|
}
|
|
4613
4827
|
),
|
|
4614
|
-
/* @__PURE__ */ (0,
|
|
4828
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4615
4829
|
TextInput,
|
|
4616
4830
|
{
|
|
4617
4831
|
label: "Alt Text (optional)",
|
|
@@ -4620,8 +4834,8 @@ var RichTextEditor = ({
|
|
|
4620
4834
|
placeholder: "Describe the image"
|
|
4621
4835
|
}
|
|
4622
4836
|
),
|
|
4623
|
-
/* @__PURE__ */ (0,
|
|
4624
|
-
/* @__PURE__ */ (0,
|
|
4837
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsxs)("div", { className: "flex gap-2 justify-end", children: [
|
|
4838
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4625
4839
|
Button,
|
|
4626
4840
|
{
|
|
4627
4841
|
variant: "secondary",
|
|
@@ -4633,7 +4847,7 @@ var RichTextEditor = ({
|
|
|
4633
4847
|
children: "Cancel"
|
|
4634
4848
|
}
|
|
4635
4849
|
),
|
|
4636
|
-
/* @__PURE__ */ (0,
|
|
4850
|
+
/* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
|
|
4637
4851
|
Button,
|
|
4638
4852
|
{
|
|
4639
4853
|
variant: "primary",
|
|
@@ -4650,19 +4864,19 @@ var RichTextEditor = ({
|
|
|
4650
4864
|
};
|
|
4651
4865
|
|
|
4652
4866
|
// src/components/Toast.tsx
|
|
4653
|
-
var
|
|
4654
|
-
var
|
|
4655
|
-
var ToastContext = (0,
|
|
4867
|
+
var import_react24 = require("react");
|
|
4868
|
+
var import_jsx_runtime105 = require("react/jsx-runtime");
|
|
4869
|
+
var ToastContext = (0, import_react24.createContext)(void 0);
|
|
4656
4870
|
var useToast = () => {
|
|
4657
|
-
const context = (0,
|
|
4871
|
+
const context = (0, import_react24.useContext)(ToastContext);
|
|
4658
4872
|
if (!context) {
|
|
4659
4873
|
throw new Error("useToast must be used within a ToastProvider");
|
|
4660
4874
|
}
|
|
4661
4875
|
return context;
|
|
4662
4876
|
};
|
|
4663
4877
|
var ToastProvider = ({ children, position = "top-right" }) => {
|
|
4664
|
-
const [toasts, setToasts] = (0,
|
|
4665
|
-
const addToast = (0,
|
|
4878
|
+
const [toasts, setToasts] = (0, import_react24.useState)([]);
|
|
4879
|
+
const addToast = (0, import_react24.useCallback)((toast2) => {
|
|
4666
4880
|
const id = Math.random().toString(36).substring(7);
|
|
4667
4881
|
const newToast = { ...toast2, id };
|
|
4668
4882
|
setToasts((prev) => [...prev, newToast]);
|
|
@@ -4671,7 +4885,7 @@ var ToastProvider = ({ children, position = "top-right" }) => {
|
|
|
4671
4885
|
removeToast(id);
|
|
4672
4886
|
}, duration);
|
|
4673
4887
|
}, []);
|
|
4674
|
-
const removeToast = (0,
|
|
4888
|
+
const removeToast = (0, import_react24.useCallback)((id) => {
|
|
4675
4889
|
setToasts((prev) => prev.filter((toast2) => toast2.id !== id));
|
|
4676
4890
|
}, []);
|
|
4677
4891
|
const positionClasses2 = {
|
|
@@ -4682,9 +4896,9 @@ var ToastProvider = ({ children, position = "top-right" }) => {
|
|
|
4682
4896
|
"top-center": "top-4 left-1/2 -translate-x-1/2",
|
|
4683
4897
|
"bottom-center": "bottom-4 left-1/2 -translate-x-1/2"
|
|
4684
4898
|
};
|
|
4685
|
-
return /* @__PURE__ */ (0,
|
|
4899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(ToastContext.Provider, { value: { toasts, addToast, removeToast }, children: [
|
|
4686
4900
|
children,
|
|
4687
|
-
/* @__PURE__ */ (0,
|
|
4901
|
+
/* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: `fixed ${positionClasses2[position]} z-50 flex flex-col gap-2 max-w-md`, children: toasts.map((toast2) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(ToastItem, { toast: toast2, onClose: () => removeToast(toast2.id) }, toast2.id)) })
|
|
4688
4902
|
] });
|
|
4689
4903
|
};
|
|
4690
4904
|
var ToastItem = ({ toast: toast2, onClose }) => {
|
|
@@ -4695,27 +4909,27 @@ var ToastItem = ({ toast: toast2, onClose }) => {
|
|
|
4695
4909
|
info: "bg-[hsl(var(--info))]/10 border-[hsl(var(--info))] text-[hsl(var(--info))]"
|
|
4696
4910
|
};
|
|
4697
4911
|
const typeIcons = {
|
|
4698
|
-
success: /* @__PURE__ */ (0,
|
|
4699
|
-
error: /* @__PURE__ */ (0,
|
|
4700
|
-
warning: /* @__PURE__ */ (0,
|
|
4701
|
-
info: /* @__PURE__ */ (0,
|
|
4912
|
+
success: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(CheckIcon, { size: "sm", className: "text-[hsl(var(--success))]" }),
|
|
4913
|
+
error: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(CloseIcon, { size: "sm", className: "text-[hsl(var(--destructive))]" }),
|
|
4914
|
+
warning: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("svg", { className: "w-4 h-4 text-[hsl(var(--warning))]", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("path", { fillRule: "evenodd", d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z", clipRule: "evenodd" }) }),
|
|
4915
|
+
info: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("svg", { className: "w-4 h-4 text-[hsl(var(--info))]", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", clipRule: "evenodd" }) })
|
|
4702
4916
|
};
|
|
4703
4917
|
const type = toast2.type || "info";
|
|
4704
|
-
return /* @__PURE__ */ (0,
|
|
4918
|
+
return /* @__PURE__ */ (0, import_jsx_runtime105.jsxs)(
|
|
4705
4919
|
"div",
|
|
4706
4920
|
{
|
|
4707
4921
|
className: `flex items-start gap-3 p-4 rounded-md border-l-4 shadow-lg bg-[hsl(var(--card))] ${typeStyles[type]} animate-slide-in`,
|
|
4708
4922
|
role: "alert",
|
|
4709
4923
|
children: [
|
|
4710
|
-
/* @__PURE__ */ (0,
|
|
4711
|
-
/* @__PURE__ */ (0,
|
|
4712
|
-
/* @__PURE__ */ (0,
|
|
4924
|
+
/* @__PURE__ */ (0, import_jsx_runtime105.jsx)("div", { className: "flex-shrink-0 mt-0.5", children: typeIcons[type] }),
|
|
4925
|
+
/* @__PURE__ */ (0, import_jsx_runtime105.jsx)("p", { className: "flex-1 text-sm font-medium text-[hsl(var(--foreground))]", children: toast2.message }),
|
|
4926
|
+
/* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
|
|
4713
4927
|
"button",
|
|
4714
4928
|
{
|
|
4715
4929
|
onClick: onClose,
|
|
4716
4930
|
className: "flex-shrink-0 text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors",
|
|
4717
4931
|
"aria-label": "Close",
|
|
4718
|
-
children: /* @__PURE__ */ (0,
|
|
4932
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(CloseIcon, { size: "sm" })
|
|
4719
4933
|
}
|
|
4720
4934
|
)
|
|
4721
4935
|
]
|
|
@@ -4746,8 +4960,8 @@ var toast = {
|
|
|
4746
4960
|
};
|
|
4747
4961
|
|
|
4748
4962
|
// src/components/Stepper.tsx
|
|
4749
|
-
var
|
|
4750
|
-
var
|
|
4963
|
+
var import_react25 = __toESM(require("react"));
|
|
4964
|
+
var import_jsx_runtime106 = require("react/jsx-runtime");
|
|
4751
4965
|
var Stepper = ({
|
|
4752
4966
|
steps,
|
|
4753
4967
|
currentStep,
|
|
@@ -4767,8 +4981,8 @@ var Stepper = ({
|
|
|
4767
4981
|
return { mobile: mobileVisible, desktop: desktopVisible };
|
|
4768
4982
|
};
|
|
4769
4983
|
const shouldShowCounter = isHorizontal && steps.length > 3;
|
|
4770
|
-
return /* @__PURE__ */ (0,
|
|
4771
|
-
shouldShowCounter && /* @__PURE__ */ (0,
|
|
4984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)("div", { className: `${isHorizontal ? "flex items-start w-full" : "flex flex-col"} ${className}`, children: [
|
|
4985
|
+
shouldShowCounter && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "md:hidden flex items-center mr-4 flex-shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)("span", { className: "text-sm font-medium text-[hsl(var(--muted-foreground))]", children: [
|
|
4772
4986
|
currentStep,
|
|
4773
4987
|
"/",
|
|
4774
4988
|
steps.length
|
|
@@ -4781,19 +4995,19 @@ var Stepper = ({
|
|
|
4781
4995
|
const visibility = getStepVisibility(index);
|
|
4782
4996
|
const visibleMobileSteps = steps.filter((_, i) => getStepVisibility(i).mobile);
|
|
4783
4997
|
const isLastVisibleMobile = index === steps.map((_, i) => i).filter((i) => getStepVisibility(i).mobile).slice(-1)[0];
|
|
4784
|
-
return /* @__PURE__ */ (0,
|
|
4785
|
-
/* @__PURE__ */ (0,
|
|
4998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(import_react25.default.Fragment, { children: [
|
|
4999
|
+
/* @__PURE__ */ (0, import_jsx_runtime106.jsxs)("div", { className: `
|
|
4786
5000
|
flex ${isHorizontal ? "flex-col items-center flex-shrink-0" : "flex-row items-start"}
|
|
4787
5001
|
${isHorizontal ? "" : isLast ? "" : "mb-6"}
|
|
4788
5002
|
${!visibility.mobile ? "hidden md:flex" : ""}
|
|
4789
5003
|
${!visibility.desktop && visibility.mobile ? "md:hidden" : ""}
|
|
4790
5004
|
`, children: [
|
|
4791
|
-
/* @__PURE__ */ (0,
|
|
4792
|
-
/* @__PURE__ */ (0,
|
|
5005
|
+
/* @__PURE__ */ (0, import_jsx_runtime106.jsxs)("div", { className: `flex ${isHorizontal ? "flex-col items-center" : "flex-col items-center flex-shrink-0"}`, children: [
|
|
5006
|
+
/* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
|
|
4793
5007
|
"div",
|
|
4794
5008
|
{
|
|
4795
5009
|
className: `flex items-center justify-center w-10 h-10 rounded-full border-2 transition-all ${isCompleted ? "bg-[hsl(var(--primary))] border-[hsl(var(--primary))]" : isActive ? "border-[hsl(var(--primary))] bg-[hsl(var(--background))]" : "border-[hsl(var(--border))] bg-[hsl(var(--background))]"}`,
|
|
4796
|
-
children: isCompleted ? /* @__PURE__ */ (0,
|
|
5010
|
+
children: isCompleted ? /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(CheckIcon, { size: "sm", className: "text-[hsl(var(--primary-foreground))]" }) : /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
|
|
4797
5011
|
"span",
|
|
4798
5012
|
{
|
|
4799
5013
|
className: `text-sm font-semibold ${isActive ? "text-[hsl(var(--primary))]" : "text-[hsl(var(--muted-foreground))]"}`,
|
|
@@ -4802,29 +5016,29 @@ var Stepper = ({
|
|
|
4802
5016
|
)
|
|
4803
5017
|
}
|
|
4804
5018
|
),
|
|
4805
|
-
!isLast && !isHorizontal && /* @__PURE__ */ (0,
|
|
5019
|
+
!isLast && !isHorizontal && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
|
|
4806
5020
|
"div",
|
|
4807
5021
|
{
|
|
4808
5022
|
className: `w-0.5 flex-1 min-h-[24px] ${isCompleted ? "bg-[hsl(var(--primary))]" : "bg-[hsl(var(--border))]"}`
|
|
4809
5023
|
}
|
|
4810
5024
|
)
|
|
4811
5025
|
] }),
|
|
4812
|
-
/* @__PURE__ */ (0,
|
|
4813
|
-
/* @__PURE__ */ (0,
|
|
5026
|
+
/* @__PURE__ */ (0, import_jsx_runtime106.jsxs)("div", { className: `${isHorizontal ? "mt-3 text-center" : "ml-4 flex-1 min-h-[40px] flex flex-col justify-center"}`, children: [
|
|
5027
|
+
/* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
|
|
4814
5028
|
"p",
|
|
4815
5029
|
{
|
|
4816
5030
|
className: `text-sm font-medium whitespace-nowrap ${isActive || isCompleted ? "text-[hsl(var(--foreground))]" : "text-[hsl(var(--muted-foreground))]"}`,
|
|
4817
5031
|
children: step.label
|
|
4818
5032
|
}
|
|
4819
5033
|
),
|
|
4820
|
-
step.description && /* @__PURE__ */ (0,
|
|
5034
|
+
step.description && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("p", { className: "text-xs text-[hsl(var(--muted-foreground))] mt-1 whitespace-nowrap", children: step.description })
|
|
4821
5035
|
] })
|
|
4822
5036
|
] }),
|
|
4823
|
-
!isLast && isHorizontal && /* @__PURE__ */ (0,
|
|
5037
|
+
!isLast && isHorizontal && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: `
|
|
4824
5038
|
flex items-start pt-5 mx-4 min-w-[80px] max-w-[200px] flex-1
|
|
4825
5039
|
${!visibility.mobile || isLastVisibleMobile ? "hidden md:flex" : ""}
|
|
4826
5040
|
${!visibility.desktop && visibility.mobile ? "md:hidden" : ""}
|
|
4827
|
-
`, children: /* @__PURE__ */ (0,
|
|
5041
|
+
`, children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
|
|
4828
5042
|
"div",
|
|
4829
5043
|
{
|
|
4830
5044
|
className: `h-0.5 w-full ${isCompleted ? "bg-[hsl(var(--primary))]" : "bg-[hsl(var(--border))]"}`
|
|
@@ -4836,7 +5050,7 @@ var Stepper = ({
|
|
|
4836
5050
|
};
|
|
4837
5051
|
|
|
4838
5052
|
// src/components/Divider.tsx
|
|
4839
|
-
var
|
|
5053
|
+
var import_jsx_runtime107 = require("react/jsx-runtime");
|
|
4840
5054
|
var Divider = ({
|
|
4841
5055
|
orientation = "horizontal",
|
|
4842
5056
|
variant = "solid",
|
|
@@ -4855,14 +5069,14 @@ var Divider = ({
|
|
|
4855
5069
|
center: "justify-center",
|
|
4856
5070
|
right: "justify-end"
|
|
4857
5071
|
};
|
|
4858
|
-
return /* @__PURE__ */ (0,
|
|
4859
|
-
labelPosition !== "left" && /* @__PURE__ */ (0,
|
|
4860
|
-
/* @__PURE__ */ (0,
|
|
4861
|
-
labelPosition !== "right" && /* @__PURE__ */ (0,
|
|
5072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)("div", { className: `flex items-center ${alignmentClasses[labelPosition]} ${className}`, role: "separator", children: [
|
|
5073
|
+
labelPosition !== "left" && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { className: `flex-1 border-t ${variantClasses[variant]} border-[hsl(var(--input))]` }),
|
|
5074
|
+
/* @__PURE__ */ (0, import_jsx_runtime107.jsx)("span", { className: "px-4 text-sm text-[hsl(var(--muted-foreground))]", children: label }),
|
|
5075
|
+
labelPosition !== "right" && /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("div", { className: `flex-1 border-t ${variantClasses[variant]} border-[hsl(var(--input))]` })
|
|
4862
5076
|
] });
|
|
4863
5077
|
}
|
|
4864
5078
|
if (orientation === "vertical") {
|
|
4865
|
-
return /* @__PURE__ */ (0,
|
|
5079
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
|
|
4866
5080
|
"div",
|
|
4867
5081
|
{
|
|
4868
5082
|
className: `inline-block h-full border-l ${variantClasses[variant]} border-[hsl(var(--input))] ${className}`,
|
|
@@ -4871,7 +5085,7 @@ var Divider = ({
|
|
|
4871
5085
|
}
|
|
4872
5086
|
);
|
|
4873
5087
|
}
|
|
4874
|
-
return /* @__PURE__ */ (0,
|
|
5088
|
+
return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
|
|
4875
5089
|
"hr",
|
|
4876
5090
|
{
|
|
4877
5091
|
className: `border-t ${variantClasses[variant]} border-[hsl(var(--input))] ${className}`,
|
|
@@ -4881,8 +5095,8 @@ var Divider = ({
|
|
|
4881
5095
|
};
|
|
4882
5096
|
|
|
4883
5097
|
// src/components/FileUpload.tsx
|
|
4884
|
-
var
|
|
4885
|
-
var
|
|
5098
|
+
var import_react26 = require("react");
|
|
5099
|
+
var import_jsx_runtime108 = require("react/jsx-runtime");
|
|
4886
5100
|
var FileUpload = ({
|
|
4887
5101
|
accept,
|
|
4888
5102
|
multiple = false,
|
|
@@ -4895,9 +5109,9 @@ var FileUpload = ({
|
|
|
4895
5109
|
label,
|
|
4896
5110
|
helperText
|
|
4897
5111
|
}) => {
|
|
4898
|
-
const [files, setFiles] = (0,
|
|
4899
|
-
const [isDragging, setIsDragging] = (0,
|
|
4900
|
-
const fileInputRef = (0,
|
|
5112
|
+
const [files, setFiles] = (0, import_react26.useState)([]);
|
|
5113
|
+
const [isDragging, setIsDragging] = (0, import_react26.useState)(false);
|
|
5114
|
+
const fileInputRef = (0, import_react26.useRef)(null);
|
|
4901
5115
|
const formatFileSize = (bytes) => {
|
|
4902
5116
|
if (bytes === 0) return "0 Bytes";
|
|
4903
5117
|
const k = 1024;
|
|
@@ -4955,9 +5169,9 @@ var FileUpload = ({
|
|
|
4955
5169
|
setFiles(newFiles);
|
|
4956
5170
|
onChange?.(newFiles);
|
|
4957
5171
|
};
|
|
4958
|
-
return /* @__PURE__ */ (0,
|
|
4959
|
-
label && /* @__PURE__ */ (0,
|
|
4960
|
-
/* @__PURE__ */ (0,
|
|
5172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: `w-full ${className}`, children: [
|
|
5173
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("label", { className: "block text-sm font-medium text-[hsl(var(--foreground))] mb-2", children: label }),
|
|
5174
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsxs)(
|
|
4961
5175
|
"div",
|
|
4962
5176
|
{
|
|
4963
5177
|
onDrop: handleDrop,
|
|
@@ -4966,7 +5180,7 @@ var FileUpload = ({
|
|
|
4966
5180
|
onClick: handleClick,
|
|
4967
5181
|
className: `relative border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-all ${isDragging ? "border-[hsl(var(--primary))] bg-[hsl(var(--primary))]/10" : "border-[hsl(var(--input))] hover:border-[hsl(var(--muted-foreground))]"} ${disabled ? "opacity-50 cursor-not-allowed" : ""}`,
|
|
4968
5182
|
children: [
|
|
4969
|
-
/* @__PURE__ */ (0,
|
|
5183
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
|
|
4970
5184
|
"input",
|
|
4971
5185
|
{
|
|
4972
5186
|
ref: fileInputRef,
|
|
@@ -4978,14 +5192,14 @@ var FileUpload = ({
|
|
|
4978
5192
|
className: "hidden"
|
|
4979
5193
|
}
|
|
4980
5194
|
),
|
|
4981
|
-
/* @__PURE__ */ (0,
|
|
4982
|
-
/* @__PURE__ */ (0,
|
|
4983
|
-
/* @__PURE__ */ (0,
|
|
4984
|
-
/* @__PURE__ */ (0,
|
|
4985
|
-
/* @__PURE__ */ (0,
|
|
5195
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "flex flex-col items-center gap-2", children: [
|
|
5196
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "w-12 h-12 rounded-full bg-[hsl(var(--muted))] flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(UploadIcon, { size: "lg", className: "text-[hsl(var(--muted-foreground))]" }) }),
|
|
5197
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { children: [
|
|
5198
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("p", { className: "text-sm font-medium text-[hsl(var(--foreground))]", children: [
|
|
5199
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)("span", { className: "text-[hsl(var(--primary))]", children: "Click to upload" }),
|
|
4986
5200
|
" or drag and drop"
|
|
4987
5201
|
] }),
|
|
4988
|
-
/* @__PURE__ */ (0,
|
|
5202
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("p", { className: "text-xs text-[hsl(var(--muted-foreground))] mt-1", children: [
|
|
4989
5203
|
accept ? `Accepted: ${accept}` : "Any file type",
|
|
4990
5204
|
maxSize && ` \u2022 Max size: ${formatFileSize(maxSize)}`
|
|
4991
5205
|
] })
|
|
@@ -4994,17 +5208,17 @@ var FileUpload = ({
|
|
|
4994
5208
|
]
|
|
4995
5209
|
}
|
|
4996
5210
|
),
|
|
4997
|
-
helperText && /* @__PURE__ */ (0,
|
|
4998
|
-
files.length > 0 && /* @__PURE__ */ (0,
|
|
5211
|
+
helperText && /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("p", { className: "mt-2 text-sm text-[hsl(var(--muted-foreground))]", children: helperText }),
|
|
5212
|
+
files.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime108.jsx)("div", { className: "mt-4 space-y-2", children: files.map((file, index) => /* @__PURE__ */ (0, import_jsx_runtime108.jsxs)(
|
|
4999
5213
|
"div",
|
|
5000
5214
|
{
|
|
5001
5215
|
className: "flex items-center justify-between p-3 bg-[hsl(var(--muted))] rounded-lg border border-[hsl(var(--border))]",
|
|
5002
5216
|
children: [
|
|
5003
|
-
/* @__PURE__ */ (0,
|
|
5004
|
-
/* @__PURE__ */ (0,
|
|
5005
|
-
/* @__PURE__ */ (0,
|
|
5217
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
5218
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)("p", { className: "text-sm font-medium text-[hsl(var(--foreground))] truncate", children: file.name }),
|
|
5219
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)("p", { className: "text-xs text-[hsl(var(--muted-foreground))]", children: formatFileSize(file.size) })
|
|
5006
5220
|
] }),
|
|
5007
|
-
/* @__PURE__ */ (0,
|
|
5221
|
+
/* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
|
|
5008
5222
|
"button",
|
|
5009
5223
|
{
|
|
5010
5224
|
onClick: (e) => {
|
|
@@ -5013,7 +5227,7 @@ var FileUpload = ({
|
|
|
5013
5227
|
},
|
|
5014
5228
|
className: "ml-4 text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--destructive))] transition-colors",
|
|
5015
5229
|
"aria-label": "Remove file",
|
|
5016
|
-
children: /* @__PURE__ */ (0,
|
|
5230
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(CloseIcon, { size: "sm" })
|
|
5017
5231
|
}
|
|
5018
5232
|
)
|
|
5019
5233
|
]
|
|
@@ -5024,8 +5238,8 @@ var FileUpload = ({
|
|
|
5024
5238
|
};
|
|
5025
5239
|
|
|
5026
5240
|
// src/components/AudioPlayer.tsx
|
|
5027
|
-
var
|
|
5028
|
-
var
|
|
5241
|
+
var import_react27 = require("react");
|
|
5242
|
+
var import_jsx_runtime109 = require("react/jsx-runtime");
|
|
5029
5243
|
var AudioPlayer = ({
|
|
5030
5244
|
src,
|
|
5031
5245
|
title,
|
|
@@ -5048,18 +5262,18 @@ var AudioPlayer = ({
|
|
|
5048
5262
|
showChapters = true,
|
|
5049
5263
|
onChapterChange
|
|
5050
5264
|
}) => {
|
|
5051
|
-
const audioRef = (0,
|
|
5052
|
-
const [isPlaying, setIsPlaying] = (0,
|
|
5053
|
-
const [currentTime, setCurrentTime] = (0,
|
|
5054
|
-
const [duration, setDuration] = (0,
|
|
5055
|
-
const [volume, setVolume] = (0,
|
|
5056
|
-
const [isMuted, setIsMuted] = (0,
|
|
5057
|
-
const [isLoading, setIsLoading] = (0,
|
|
5058
|
-
const [currentChapter, setCurrentChapter] = (0,
|
|
5059
|
-
const [showChapterList, setShowChapterList] = (0,
|
|
5060
|
-
const [hoveredChapter, setHoveredChapter] = (0,
|
|
5061
|
-
const [hoverPosition, setHoverPosition] = (0,
|
|
5062
|
-
(0,
|
|
5265
|
+
const audioRef = (0, import_react27.useRef)(null);
|
|
5266
|
+
const [isPlaying, setIsPlaying] = (0, import_react27.useState)(false);
|
|
5267
|
+
const [currentTime, setCurrentTime] = (0, import_react27.useState)(0);
|
|
5268
|
+
const [duration, setDuration] = (0, import_react27.useState)(0);
|
|
5269
|
+
const [volume, setVolume] = (0, import_react27.useState)(1);
|
|
5270
|
+
const [isMuted, setIsMuted] = (0, import_react27.useState)(false);
|
|
5271
|
+
const [isLoading, setIsLoading] = (0, import_react27.useState)(true);
|
|
5272
|
+
const [currentChapter, setCurrentChapter] = (0, import_react27.useState)(null);
|
|
5273
|
+
const [showChapterList, setShowChapterList] = (0, import_react27.useState)(false);
|
|
5274
|
+
const [hoveredChapter, setHoveredChapter] = (0, import_react27.useState)(null);
|
|
5275
|
+
const [hoverPosition, setHoverPosition] = (0, import_react27.useState)({ x: 0, y: 0 });
|
|
5276
|
+
(0, import_react27.useEffect)(() => {
|
|
5063
5277
|
const audio = audioRef.current;
|
|
5064
5278
|
if (!audio) return;
|
|
5065
5279
|
const handleLoadedMetadata = () => {
|
|
@@ -5123,7 +5337,7 @@ var AudioPlayer = ({
|
|
|
5123
5337
|
audio.removeEventListener("error", handleError);
|
|
5124
5338
|
};
|
|
5125
5339
|
}, [onPlay, onPause, onEnded, onTimeUpdate]);
|
|
5126
|
-
(0,
|
|
5340
|
+
(0, import_react27.useEffect)(() => {
|
|
5127
5341
|
const audio = audioRef.current;
|
|
5128
5342
|
if (!audio) return;
|
|
5129
5343
|
audio.load();
|
|
@@ -5210,9 +5424,9 @@ var AudioPlayer = ({
|
|
|
5210
5424
|
};
|
|
5211
5425
|
const progress = duration > 0 ? currentTime / duration * 100 : 0;
|
|
5212
5426
|
if (variant === "mini") {
|
|
5213
|
-
return /* @__PURE__ */ (0,
|
|
5214
|
-
/* @__PURE__ */ (0,
|
|
5215
|
-
/* @__PURE__ */ (0,
|
|
5427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: `flex items-center gap-2 p-2 bg-[hsl(var(--card))] rounded-lg border border-[hsl(var(--border))] ${className}`, children: [
|
|
5428
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("audio", { ref: audioRef, src, preload, loop, autoPlay }),
|
|
5429
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5216
5430
|
Button,
|
|
5217
5431
|
{
|
|
5218
5432
|
iconOnly: true,
|
|
@@ -5221,16 +5435,16 @@ var AudioPlayer = ({
|
|
|
5221
5435
|
onClick: togglePlayPause,
|
|
5222
5436
|
disabled: isLoading,
|
|
5223
5437
|
"aria-label": isPlaying ? "Pause" : "Play",
|
|
5224
|
-
children: isPlaying ? /* @__PURE__ */ (0,
|
|
5438
|
+
children: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PauseIcon, { size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PlayIcon, { size: "sm" })
|
|
5225
5439
|
}
|
|
5226
5440
|
),
|
|
5227
|
-
title && /* @__PURE__ */ (0,
|
|
5441
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "text-sm font-medium text-[hsl(var(--foreground))] truncate", children: title })
|
|
5228
5442
|
] });
|
|
5229
5443
|
}
|
|
5230
5444
|
if (variant === "compact") {
|
|
5231
|
-
return /* @__PURE__ */ (0,
|
|
5232
|
-
/* @__PURE__ */ (0,
|
|
5233
|
-
/* @__PURE__ */ (0,
|
|
5445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: `flex items-center gap-3 p-3 bg-[hsl(var(--card))] rounded-lg border border-[hsl(var(--border))] shadow-sm ${className}`, children: [
|
|
5446
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("audio", { ref: audioRef, src, preload, loop, autoPlay }),
|
|
5447
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5234
5448
|
Button,
|
|
5235
5449
|
{
|
|
5236
5450
|
iconOnly: true,
|
|
@@ -5239,17 +5453,17 @@ var AudioPlayer = ({
|
|
|
5239
5453
|
onClick: togglePlayPause,
|
|
5240
5454
|
disabled: isLoading,
|
|
5241
5455
|
"aria-label": isPlaying ? "Pause" : "Play",
|
|
5242
|
-
children: isPlaying ? /* @__PURE__ */ (0,
|
|
5456
|
+
children: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PauseIcon, { size: "md" }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PlayIcon, { size: "md" })
|
|
5243
5457
|
}
|
|
5244
5458
|
),
|
|
5245
|
-
/* @__PURE__ */ (0,
|
|
5246
|
-
title && /* @__PURE__ */ (0,
|
|
5247
|
-
artist && /* @__PURE__ */ (0,
|
|
5459
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
5460
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "text-sm font-medium text-[hsl(var(--foreground))] truncate", children: title }),
|
|
5461
|
+
artist && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "text-xs text-[hsl(var(--muted-foreground))] truncate", children: artist })
|
|
5248
5462
|
] }),
|
|
5249
|
-
/* @__PURE__ */ (0,
|
|
5250
|
-
/* @__PURE__ */ (0,
|
|
5251
|
-
/* @__PURE__ */ (0,
|
|
5252
|
-
/* @__PURE__ */ (0,
|
|
5463
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex items-center gap-2 flex-1", children: [
|
|
5464
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "text-xs text-[hsl(var(--muted-foreground))] tabular-nums", children: formatTime(currentTime) }),
|
|
5465
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "relative flex-1 h-1.5 bg-[hsl(var(--muted))] rounded-full overflow-visible", children: [
|
|
5466
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5253
5467
|
"div",
|
|
5254
5468
|
{
|
|
5255
5469
|
className: "absolute h-full bg-[hsl(var(--primary))] rounded-full transition-all",
|
|
@@ -5258,7 +5472,7 @@ var AudioPlayer = ({
|
|
|
5258
5472
|
),
|
|
5259
5473
|
showChapters && chapters.length > 0 && chapters.map((chapter, index) => {
|
|
5260
5474
|
const markerPosition = duration > 0 ? chapter.startTime / duration * 100 : 0;
|
|
5261
|
-
return /* @__PURE__ */ (0,
|
|
5475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5262
5476
|
"div",
|
|
5263
5477
|
{
|
|
5264
5478
|
className: "absolute top-0 bottom-0 w-1 -ml-0.5 bg-[hsl(var(--background))] opacity-70 hover:opacity-100 hover:w-1.5 hover:-ml-0.5 cursor-pointer z-10 transition-all",
|
|
@@ -5274,7 +5488,7 @@ var AudioPlayer = ({
|
|
|
5274
5488
|
index
|
|
5275
5489
|
);
|
|
5276
5490
|
}),
|
|
5277
|
-
/* @__PURE__ */ (0,
|
|
5491
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5278
5492
|
"input",
|
|
5279
5493
|
{
|
|
5280
5494
|
type: "range",
|
|
@@ -5288,23 +5502,23 @@ var AudioPlayer = ({
|
|
|
5288
5502
|
}
|
|
5289
5503
|
)
|
|
5290
5504
|
] }),
|
|
5291
|
-
/* @__PURE__ */ (0,
|
|
5292
|
-
currentChapter && showChapters && /* @__PURE__ */ (0,
|
|
5505
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "text-xs text-[hsl(var(--muted-foreground))] tabular-nums", children: formatTime(duration) }),
|
|
5506
|
+
currentChapter && showChapters && /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("span", { className: "text-xs text-[hsl(var(--primary))] font-medium truncate max-w-[120px]", children: [
|
|
5293
5507
|
"\u2022 ",
|
|
5294
5508
|
currentChapter.title
|
|
5295
5509
|
] })
|
|
5296
5510
|
] }),
|
|
5297
|
-
/* @__PURE__ */ (0,
|
|
5298
|
-
/* @__PURE__ */ (0,
|
|
5511
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
5512
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5299
5513
|
"button",
|
|
5300
5514
|
{
|
|
5301
5515
|
onClick: toggleMute,
|
|
5302
5516
|
className: "text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))]",
|
|
5303
5517
|
"aria-label": isMuted ? "Unmute" : "Mute",
|
|
5304
|
-
children: isMuted ? /* @__PURE__ */ (0,
|
|
5518
|
+
children: isMuted ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(VolumeOffIcon, { size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(VolumeUpIcon, { size: "sm" })
|
|
5305
5519
|
}
|
|
5306
5520
|
),
|
|
5307
|
-
/* @__PURE__ */ (0,
|
|
5521
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5308
5522
|
"input",
|
|
5309
5523
|
{
|
|
5310
5524
|
type: "range",
|
|
@@ -5318,24 +5532,24 @@ var AudioPlayer = ({
|
|
|
5318
5532
|
}
|
|
5319
5533
|
)
|
|
5320
5534
|
] }),
|
|
5321
|
-
hoveredChapter && showChapters && /* @__PURE__ */ (0,
|
|
5535
|
+
hoveredChapter && showChapters && /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
|
|
5322
5536
|
"div",
|
|
5323
5537
|
{
|
|
5324
5538
|
className: "fixed z-50 px-3 py-2 bg-[hsl(var(--popover))] text-white text-xs font-medium rounded shadow-lg pointer-events-none transform -translate-x-1/2 -translate-y-full",
|
|
5325
5539
|
style: { left: hoverPosition.x, top: hoverPosition.y - 8 },
|
|
5326
5540
|
children: [
|
|
5327
|
-
/* @__PURE__ */ (0,
|
|
5328
|
-
/* @__PURE__ */ (0,
|
|
5329
|
-
/* @__PURE__ */ (0,
|
|
5541
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "whitespace-nowrap", children: hoveredChapter.title }),
|
|
5542
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "text-[hsl(var(--muted-foreground))] text-[10px] mt-0.5", children: formatTime(hoveredChapter.startTime) }),
|
|
5543
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "absolute left-1/2 -bottom-1 w-2 h-2 bg-[hsl(var(--popover))] transform -translate-x-1/2 rotate-45" })
|
|
5330
5544
|
]
|
|
5331
5545
|
}
|
|
5332
5546
|
)
|
|
5333
5547
|
] });
|
|
5334
5548
|
}
|
|
5335
|
-
return /* @__PURE__ */ (0,
|
|
5336
|
-
/* @__PURE__ */ (0,
|
|
5337
|
-
/* @__PURE__ */ (0,
|
|
5338
|
-
coverArt && /* @__PURE__ */ (0,
|
|
5549
|
+
return /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: `bg-[hsl(var(--card))] rounded-lg border border-[hsl(var(--border))] shadow-md overflow-hidden ${className}`, children: [
|
|
5550
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("audio", { ref: audioRef, src, preload, loop, autoPlay }),
|
|
5551
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex items-center gap-4 p-4 border-b border-[hsl(var(--border))]", children: [
|
|
5552
|
+
coverArt && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "w-16 h-16 flex-shrink-0 rounded-md overflow-hidden bg-[hsl(var(--muted))]", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5339
5553
|
"img",
|
|
5340
5554
|
{
|
|
5341
5555
|
src: coverArt,
|
|
@@ -5343,15 +5557,15 @@ var AudioPlayer = ({
|
|
|
5343
5557
|
className: "w-full h-full object-cover"
|
|
5344
5558
|
}
|
|
5345
5559
|
) }),
|
|
5346
|
-
/* @__PURE__ */ (0,
|
|
5347
|
-
title && /* @__PURE__ */ (0,
|
|
5348
|
-
artist && /* @__PURE__ */ (0,
|
|
5349
|
-
album && /* @__PURE__ */ (0,
|
|
5560
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex-1 min-w-0", children: [
|
|
5561
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("h3", { className: "text-base font-semibold text-[hsl(var(--foreground))] truncate", children: title }),
|
|
5562
|
+
artist && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "text-sm text-[hsl(var(--muted-foreground))] truncate", children: artist }),
|
|
5563
|
+
album && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("p", { className: "text-xs text-[hsl(var(--muted-foreground))] truncate", children: album })
|
|
5350
5564
|
] })
|
|
5351
5565
|
] }),
|
|
5352
|
-
/* @__PURE__ */ (0,
|
|
5353
|
-
/* @__PURE__ */ (0,
|
|
5354
|
-
/* @__PURE__ */ (0,
|
|
5566
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "px-4 pt-4", children: [
|
|
5567
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "relative h-2 bg-[hsl(var(--muted))] rounded-full overflow-visible", children: [
|
|
5568
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5355
5569
|
"div",
|
|
5356
5570
|
{
|
|
5357
5571
|
className: "absolute h-full bg-[hsl(var(--primary))] rounded-full transition-all",
|
|
@@ -5360,7 +5574,7 @@ var AudioPlayer = ({
|
|
|
5360
5574
|
),
|
|
5361
5575
|
showChapters && chapters.length > 0 && chapters.map((chapter, index) => {
|
|
5362
5576
|
const markerPosition = duration > 0 ? chapter.startTime / duration * 100 : 0;
|
|
5363
|
-
return /* @__PURE__ */ (0,
|
|
5577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5364
5578
|
"div",
|
|
5365
5579
|
{
|
|
5366
5580
|
className: "absolute top-0 bottom-0 w-1 -ml-0.5 bg-[hsl(var(--background))] opacity-70 hover:opacity-100 hover:w-1.5 hover:-ml-0.5 cursor-pointer z-10 transition-all",
|
|
@@ -5376,19 +5590,19 @@ var AudioPlayer = ({
|
|
|
5376
5590
|
index
|
|
5377
5591
|
);
|
|
5378
5592
|
}),
|
|
5379
|
-
hoveredChapter && showChapters && /* @__PURE__ */ (0,
|
|
5593
|
+
hoveredChapter && showChapters && /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
|
|
5380
5594
|
"div",
|
|
5381
5595
|
{
|
|
5382
5596
|
className: "fixed z-50 px-3 py-2 bg-[hsl(var(--popover))] text-white text-xs font-medium rounded shadow-lg pointer-events-none transform -translate-x-1/2 -translate-y-full",
|
|
5383
5597
|
style: { left: hoverPosition.x, top: hoverPosition.y - 8 },
|
|
5384
5598
|
children: [
|
|
5385
|
-
/* @__PURE__ */ (0,
|
|
5386
|
-
/* @__PURE__ */ (0,
|
|
5387
|
-
/* @__PURE__ */ (0,
|
|
5599
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "whitespace-nowrap", children: hoveredChapter.title }),
|
|
5600
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "text-[hsl(var(--muted-foreground))] text-[10px] mt-0.5", children: formatTime(hoveredChapter.startTime) }),
|
|
5601
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "absolute left-1/2 -bottom-1 w-2 h-2 bg-[hsl(var(--popover))] transform -translate-x-1/2 rotate-45" })
|
|
5388
5602
|
]
|
|
5389
5603
|
}
|
|
5390
5604
|
),
|
|
5391
|
-
/* @__PURE__ */ (0,
|
|
5605
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5392
5606
|
"input",
|
|
5393
5607
|
{
|
|
5394
5608
|
type: "range",
|
|
@@ -5402,24 +5616,24 @@ var AudioPlayer = ({
|
|
|
5402
5616
|
}
|
|
5403
5617
|
)
|
|
5404
5618
|
] }),
|
|
5405
|
-
/* @__PURE__ */ (0,
|
|
5406
|
-
/* @__PURE__ */ (0,
|
|
5407
|
-
currentChapter && showChapters && /* @__PURE__ */ (0,
|
|
5408
|
-
/* @__PURE__ */ (0,
|
|
5619
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex justify-between items-center mt-1 text-xs text-[hsl(var(--muted-foreground))] tabular-nums", children: [
|
|
5620
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { children: formatTime(currentTime) }),
|
|
5621
|
+
currentChapter && showChapters && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "text-[hsl(var(--primary))] font-medium truncate max-w-[200px]", children: currentChapter.title }),
|
|
5622
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { children: formatTime(duration) })
|
|
5409
5623
|
] })
|
|
5410
5624
|
] }),
|
|
5411
|
-
/* @__PURE__ */ (0,
|
|
5412
|
-
/* @__PURE__ */ (0,
|
|
5413
|
-
/* @__PURE__ */ (0,
|
|
5625
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex items-center justify-between px-4 py-4", children: [
|
|
5626
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex items-center gap-2 flex-1", children: [
|
|
5627
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5414
5628
|
"button",
|
|
5415
5629
|
{
|
|
5416
5630
|
onClick: toggleMute,
|
|
5417
5631
|
className: "text-[hsl(var(--muted-foreground))] hover:text-[hsl(var(--foreground))] transition-colors",
|
|
5418
5632
|
"aria-label": isMuted ? "Unmute" : "Mute",
|
|
5419
|
-
children: isMuted ? /* @__PURE__ */ (0,
|
|
5633
|
+
children: isMuted ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(VolumeOffIcon, { size: "md" }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(VolumeUpIcon, { size: "md" })
|
|
5420
5634
|
}
|
|
5421
5635
|
),
|
|
5422
|
-
/* @__PURE__ */ (0,
|
|
5636
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5423
5637
|
"input",
|
|
5424
5638
|
{
|
|
5425
5639
|
type: "range",
|
|
@@ -5433,8 +5647,8 @@ var AudioPlayer = ({
|
|
|
5433
5647
|
}
|
|
5434
5648
|
)
|
|
5435
5649
|
] }),
|
|
5436
|
-
/* @__PURE__ */ (0,
|
|
5437
|
-
showSkipButtons && /* @__PURE__ */ (0,
|
|
5650
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
5651
|
+
showSkipButtons && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5438
5652
|
Button,
|
|
5439
5653
|
{
|
|
5440
5654
|
iconOnly: true,
|
|
@@ -5443,10 +5657,10 @@ var AudioPlayer = ({
|
|
|
5443
5657
|
onClick: handleSkipBack,
|
|
5444
5658
|
disabled: isLoading,
|
|
5445
5659
|
"aria-label": "Skip back 10 seconds",
|
|
5446
|
-
children: /* @__PURE__ */ (0,
|
|
5660
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SkipBackIcon, { size: "md" })
|
|
5447
5661
|
}
|
|
5448
5662
|
),
|
|
5449
|
-
/* @__PURE__ */ (0,
|
|
5663
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5450
5664
|
Button,
|
|
5451
5665
|
{
|
|
5452
5666
|
iconOnly: true,
|
|
@@ -5455,10 +5669,10 @@ var AudioPlayer = ({
|
|
|
5455
5669
|
onClick: togglePlayPause,
|
|
5456
5670
|
disabled: isLoading,
|
|
5457
5671
|
"aria-label": isPlaying ? "Pause" : "Play",
|
|
5458
|
-
children: isPlaying ? /* @__PURE__ */ (0,
|
|
5672
|
+
children: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PauseIcon, { size: "lg" }) : /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(PlayIcon, { size: "lg" })
|
|
5459
5673
|
}
|
|
5460
5674
|
),
|
|
5461
|
-
showSkipButtons && /* @__PURE__ */ (0,
|
|
5675
|
+
showSkipButtons && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5462
5676
|
Button,
|
|
5463
5677
|
{
|
|
5464
5678
|
iconOnly: true,
|
|
@@ -5467,11 +5681,11 @@ var AudioPlayer = ({
|
|
|
5467
5681
|
onClick: handleSkipForward,
|
|
5468
5682
|
disabled: isLoading,
|
|
5469
5683
|
"aria-label": "Skip forward 10 seconds",
|
|
5470
|
-
children: /* @__PURE__ */ (0,
|
|
5684
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(SkipForwardIcon, { size: "md" })
|
|
5471
5685
|
}
|
|
5472
5686
|
)
|
|
5473
5687
|
] }),
|
|
5474
|
-
/* @__PURE__ */ (0,
|
|
5688
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "flex-1 flex justify-end", children: showChapters && chapters.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)(
|
|
5475
5689
|
"button",
|
|
5476
5690
|
{
|
|
5477
5691
|
onClick: () => setShowChapterList(!showChapterList),
|
|
@@ -5485,16 +5699,16 @@ var AudioPlayer = ({
|
|
|
5485
5699
|
}
|
|
5486
5700
|
) })
|
|
5487
5701
|
] }),
|
|
5488
|
-
showChapters && showChapterList && chapters.length > 0 && /* @__PURE__ */ (0,
|
|
5702
|
+
showChapters && showChapterList && chapters.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime109.jsx)("div", { className: "border-t border-[hsl(var(--border))] bg-[hsl(var(--muted))]/50 max-h-48 overflow-y-auto", children: chapters.map((chapter, index) => {
|
|
5489
5703
|
const isCurrentChapter = currentChapter?.startTime === chapter.startTime;
|
|
5490
|
-
return /* @__PURE__ */ (0,
|
|
5704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(
|
|
5491
5705
|
"button",
|
|
5492
5706
|
{
|
|
5493
5707
|
onClick: () => jumpToChapter(chapter),
|
|
5494
5708
|
className: `w-full text-left px-4 py-2 hover:bg-[hsl(var(--accent))] transition-colors ${isCurrentChapter ? "bg-[hsl(var(--primary))]/10 border-l-2 border-[hsl(var(--primary))]" : ""}`,
|
|
5495
|
-
children: /* @__PURE__ */ (0,
|
|
5496
|
-
/* @__PURE__ */ (0,
|
|
5497
|
-
/* @__PURE__ */ (0,
|
|
5709
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime109.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
5710
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: `text-sm font-medium ${isCurrentChapter ? "text-[hsl(var(--primary))]" : "text-[hsl(var(--foreground))]"}`, children: chapter.title }),
|
|
5711
|
+
/* @__PURE__ */ (0, import_jsx_runtime109.jsx)("span", { className: "text-xs text-[hsl(var(--muted-foreground))] tabular-nums", children: formatTime(chapter.startTime) })
|
|
5498
5712
|
] })
|
|
5499
5713
|
},
|
|
5500
5714
|
index
|
|
@@ -5504,8 +5718,8 @@ var AudioPlayer = ({
|
|
|
5504
5718
|
};
|
|
5505
5719
|
|
|
5506
5720
|
// src/components/VideoPlayer.tsx
|
|
5507
|
-
var
|
|
5508
|
-
var
|
|
5721
|
+
var import_react28 = require("react");
|
|
5722
|
+
var import_jsx_runtime110 = require("react/jsx-runtime");
|
|
5509
5723
|
var VideoPlayer = ({
|
|
5510
5724
|
src,
|
|
5511
5725
|
poster,
|
|
@@ -5529,21 +5743,21 @@ var VideoPlayer = ({
|
|
|
5529
5743
|
showChapters = true,
|
|
5530
5744
|
onChapterChange
|
|
5531
5745
|
}) => {
|
|
5532
|
-
const videoRef = (0,
|
|
5533
|
-
const containerRef = (0,
|
|
5534
|
-
const [isPlaying, setIsPlaying] = (0,
|
|
5535
|
-
const [currentTime, setCurrentTime] = (0,
|
|
5536
|
-
const [duration, setDuration] = (0,
|
|
5537
|
-
const [volume, setVolume] = (0,
|
|
5538
|
-
const [isMuted, setIsMuted] = (0,
|
|
5539
|
-
const [isLoading, setIsLoading] = (0,
|
|
5540
|
-
const [isFullscreen, setIsFullscreen] = (0,
|
|
5541
|
-
const [showControlsOverlay, setShowControlsOverlay] = (0,
|
|
5542
|
-
const hideControlsTimeout = (0,
|
|
5543
|
-
const [currentChapter, setCurrentChapter] = (0,
|
|
5544
|
-
const [hoveredChapter, setHoveredChapter] = (0,
|
|
5545
|
-
const [hoverPosition, setHoverPosition] = (0,
|
|
5546
|
-
(0,
|
|
5746
|
+
const videoRef = (0, import_react28.useRef)(null);
|
|
5747
|
+
const containerRef = (0, import_react28.useRef)(null);
|
|
5748
|
+
const [isPlaying, setIsPlaying] = (0, import_react28.useState)(false);
|
|
5749
|
+
const [currentTime, setCurrentTime] = (0, import_react28.useState)(0);
|
|
5750
|
+
const [duration, setDuration] = (0, import_react28.useState)(0);
|
|
5751
|
+
const [volume, setVolume] = (0, import_react28.useState)(muted ? 0 : 1);
|
|
5752
|
+
const [isMuted, setIsMuted] = (0, import_react28.useState)(muted);
|
|
5753
|
+
const [isLoading, setIsLoading] = (0, import_react28.useState)(true);
|
|
5754
|
+
const [isFullscreen, setIsFullscreen] = (0, import_react28.useState)(false);
|
|
5755
|
+
const [showControlsOverlay, setShowControlsOverlay] = (0, import_react28.useState)(true);
|
|
5756
|
+
const hideControlsTimeout = (0, import_react28.useRef)(null);
|
|
5757
|
+
const [currentChapter, setCurrentChapter] = (0, import_react28.useState)(null);
|
|
5758
|
+
const [hoveredChapter, setHoveredChapter] = (0, import_react28.useState)(null);
|
|
5759
|
+
const [hoverPosition, setHoverPosition] = (0, import_react28.useState)({ x: 0, y: 0 });
|
|
5760
|
+
(0, import_react28.useEffect)(() => {
|
|
5547
5761
|
const video = videoRef.current;
|
|
5548
5762
|
if (!video) return;
|
|
5549
5763
|
const handleLoadedMetadata = () => {
|
|
@@ -5612,12 +5826,12 @@ var VideoPlayer = ({
|
|
|
5612
5826
|
document.removeEventListener("fullscreenchange", handleFullscreenChange);
|
|
5613
5827
|
};
|
|
5614
5828
|
}, [onPlay, onPause, onEnded, onTimeUpdate]);
|
|
5615
|
-
(0,
|
|
5829
|
+
(0, import_react28.useEffect)(() => {
|
|
5616
5830
|
const video = videoRef.current;
|
|
5617
5831
|
if (!video) return;
|
|
5618
5832
|
video.load();
|
|
5619
5833
|
}, [src]);
|
|
5620
|
-
(0,
|
|
5834
|
+
(0, import_react28.useEffect)(() => {
|
|
5621
5835
|
if (!isPlaying) {
|
|
5622
5836
|
setShowControlsOverlay(true);
|
|
5623
5837
|
return;
|
|
@@ -5733,7 +5947,7 @@ var VideoPlayer = ({
|
|
|
5733
5947
|
}
|
|
5734
5948
|
};
|
|
5735
5949
|
if (variant === "compact") {
|
|
5736
|
-
return /* @__PURE__ */ (0,
|
|
5950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
|
|
5737
5951
|
"div",
|
|
5738
5952
|
{
|
|
5739
5953
|
ref: containerRef,
|
|
@@ -5741,7 +5955,7 @@ var VideoPlayer = ({
|
|
|
5741
5955
|
style: { width, height },
|
|
5742
5956
|
onMouseMove: handleMouseMove,
|
|
5743
5957
|
children: [
|
|
5744
|
-
/* @__PURE__ */ (0,
|
|
5958
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5745
5959
|
"video",
|
|
5746
5960
|
{
|
|
5747
5961
|
ref: videoRef,
|
|
@@ -5755,8 +5969,8 @@ var VideoPlayer = ({
|
|
|
5755
5969
|
onClick: togglePlayPause
|
|
5756
5970
|
}
|
|
5757
5971
|
),
|
|
5758
|
-
showControls && /* @__PURE__ */ (0,
|
|
5759
|
-
/* @__PURE__ */ (0,
|
|
5972
|
+
showControls && /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: `absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent transition-opacity duration-300 ${showControlsOverlay || !isPlaying ? "opacity-100" : "opacity-0 pointer-events-none"}`, children: [
|
|
5973
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5760
5974
|
"button",
|
|
5761
5975
|
{
|
|
5762
5976
|
onClick: togglePlayPause,
|
|
@@ -5764,12 +5978,12 @@ var VideoPlayer = ({
|
|
|
5764
5978
|
className: "flex items-center justify-center w-16 h-16 rounded-full bg-white/20 hover:bg-white/30 backdrop-blur-sm text-white transition-all disabled:opacity-50 disabled:cursor-not-allowed",
|
|
5765
5979
|
style: { width: 64, height: 64, borderRadius: "50%" },
|
|
5766
5980
|
"aria-label": isPlaying ? "Pause" : "Play",
|
|
5767
|
-
children: isPlaying ? /* @__PURE__ */ (0,
|
|
5981
|
+
children: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(PauseIcon, { size: "xl" }) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(PlayIcon, { size: "xl" })
|
|
5768
5982
|
}
|
|
5769
5983
|
) }),
|
|
5770
|
-
/* @__PURE__ */ (0,
|
|
5771
|
-
/* @__PURE__ */ (0,
|
|
5772
|
-
/* @__PURE__ */ (0,
|
|
5984
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "absolute bottom-0 left-0 right-0 p-3 space-y-2", children: [
|
|
5985
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "relative h-1 bg-white/30 rounded-full overflow-visible", children: [
|
|
5986
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5773
5987
|
"div",
|
|
5774
5988
|
{
|
|
5775
5989
|
className: "absolute h-full bg-[hsl(var(--primary))] rounded-full transition-all",
|
|
@@ -5778,7 +5992,7 @@ var VideoPlayer = ({
|
|
|
5778
5992
|
),
|
|
5779
5993
|
showChapters && chapters.length > 0 && chapters.map((chapter, index) => {
|
|
5780
5994
|
const markerPosition = duration > 0 ? chapter.startTime / duration * 100 : 0;
|
|
5781
|
-
return /* @__PURE__ */ (0,
|
|
5995
|
+
return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5782
5996
|
"div",
|
|
5783
5997
|
{
|
|
5784
5998
|
className: "absolute top-0 bottom-0 w-1 -ml-0.5 bg-white opacity-70 hover:opacity-100 hover:w-1.5 hover:-ml-0.5 cursor-pointer z-10 transition-all",
|
|
@@ -5794,7 +6008,7 @@ var VideoPlayer = ({
|
|
|
5794
6008
|
index
|
|
5795
6009
|
);
|
|
5796
6010
|
}),
|
|
5797
|
-
/* @__PURE__ */ (0,
|
|
6011
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5798
6012
|
"input",
|
|
5799
6013
|
{
|
|
5800
6014
|
type: "range",
|
|
@@ -5808,50 +6022,50 @@ var VideoPlayer = ({
|
|
|
5808
6022
|
}
|
|
5809
6023
|
)
|
|
5810
6024
|
] }),
|
|
5811
|
-
/* @__PURE__ */ (0,
|
|
5812
|
-
/* @__PURE__ */ (0,
|
|
5813
|
-
/* @__PURE__ */ (0,
|
|
6025
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
6026
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
6027
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "text-xs text-white tabular-nums", children: [
|
|
5814
6028
|
formatTime(currentTime),
|
|
5815
6029
|
" / ",
|
|
5816
6030
|
formatTime(duration)
|
|
5817
6031
|
] }),
|
|
5818
|
-
currentChapter && showChapters && /* @__PURE__ */ (0,
|
|
6032
|
+
currentChapter && showChapters && /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "text-xs text-white/90 font-medium truncate max-w-[150px]", children: [
|
|
5819
6033
|
"\u2022 ",
|
|
5820
6034
|
currentChapter.title
|
|
5821
6035
|
] })
|
|
5822
6036
|
] }),
|
|
5823
|
-
/* @__PURE__ */ (0,
|
|
5824
|
-
/* @__PURE__ */ (0,
|
|
6037
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
6038
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5825
6039
|
"button",
|
|
5826
6040
|
{
|
|
5827
6041
|
onClick: toggleMute,
|
|
5828
6042
|
className: "text-white/80 hover:text-white transition-colors",
|
|
5829
6043
|
"aria-label": isMuted ? "Unmute" : "Mute",
|
|
5830
|
-
children: isMuted ? /* @__PURE__ */ (0,
|
|
6044
|
+
children: isMuted ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(VolumeOffIcon, { size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(VolumeUpIcon, { size: "sm" })
|
|
5831
6045
|
}
|
|
5832
6046
|
),
|
|
5833
|
-
/* @__PURE__ */ (0,
|
|
6047
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5834
6048
|
"button",
|
|
5835
6049
|
{
|
|
5836
6050
|
onClick: toggleFullscreen,
|
|
5837
6051
|
className: "text-white/80 hover:text-white transition-colors",
|
|
5838
6052
|
"aria-label": isFullscreen ? "Exit fullscreen" : "Enter fullscreen",
|
|
5839
|
-
children: isFullscreen ? /* @__PURE__ */ (0,
|
|
6053
|
+
children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(FullscreenExitIcon, { size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(FullscreenIcon, { size: "sm" })
|
|
5840
6054
|
}
|
|
5841
6055
|
)
|
|
5842
6056
|
] })
|
|
5843
6057
|
] })
|
|
5844
6058
|
] })
|
|
5845
6059
|
] }),
|
|
5846
|
-
hoveredChapter && showChapters && /* @__PURE__ */ (0,
|
|
6060
|
+
hoveredChapter && showChapters && /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
|
|
5847
6061
|
"div",
|
|
5848
6062
|
{
|
|
5849
6063
|
className: "fixed z-50 px-3 py-2 bg-[hsl(var(--popover))] text-white text-xs font-medium rounded shadow-lg pointer-events-none transform -translate-x-1/2 -translate-y-full",
|
|
5850
6064
|
style: { left: hoverPosition.x, top: hoverPosition.y - 8 },
|
|
5851
6065
|
children: [
|
|
5852
|
-
/* @__PURE__ */ (0,
|
|
5853
|
-
/* @__PURE__ */ (0,
|
|
5854
|
-
/* @__PURE__ */ (0,
|
|
6066
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "whitespace-nowrap", children: hoveredChapter.title }),
|
|
6067
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "text-[hsl(var(--muted-foreground))] text-[10px] mt-0.5", children: formatTime(hoveredChapter.startTime) }),
|
|
6068
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "absolute left-1/2 -bottom-1 w-2 h-2 bg-[hsl(var(--popover))] transform -translate-x-1/2 rotate-45" })
|
|
5855
6069
|
]
|
|
5856
6070
|
}
|
|
5857
6071
|
)
|
|
@@ -5859,9 +6073,9 @@ var VideoPlayer = ({
|
|
|
5859
6073
|
}
|
|
5860
6074
|
);
|
|
5861
6075
|
}
|
|
5862
|
-
return /* @__PURE__ */ (0,
|
|
5863
|
-
title && /* @__PURE__ */ (0,
|
|
5864
|
-
/* @__PURE__ */ (0,
|
|
6076
|
+
return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: `bg-[hsl(var(--card))] rounded-lg border border-[hsl(var(--border))] shadow-md overflow-hidden ${className}`, children: [
|
|
6077
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "px-4 py-3 border-b border-[hsl(var(--border))]", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)("h3", { className: "text-base font-semibold text-[hsl(var(--foreground))] truncate", children: title }) }),
|
|
6078
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
|
|
5865
6079
|
"div",
|
|
5866
6080
|
{
|
|
5867
6081
|
ref: containerRef,
|
|
@@ -5869,7 +6083,7 @@ var VideoPlayer = ({
|
|
|
5869
6083
|
style: { width, height },
|
|
5870
6084
|
onMouseMove: handleMouseMove,
|
|
5871
6085
|
children: [
|
|
5872
|
-
/* @__PURE__ */ (0,
|
|
6086
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5873
6087
|
"video",
|
|
5874
6088
|
{
|
|
5875
6089
|
ref: videoRef,
|
|
@@ -5884,8 +6098,8 @@ var VideoPlayer = ({
|
|
|
5884
6098
|
onClick: togglePlayPause
|
|
5885
6099
|
}
|
|
5886
6100
|
),
|
|
5887
|
-
showControls && !controls && /* @__PURE__ */ (0,
|
|
5888
|
-
/* @__PURE__ */ (0,
|
|
6101
|
+
showControls && !controls && /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: `absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent transition-opacity duration-300 ${showControlsOverlay || !isPlaying ? "opacity-100" : "opacity-0 pointer-events-none"}`, children: [
|
|
6102
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5889
6103
|
"button",
|
|
5890
6104
|
{
|
|
5891
6105
|
onClick: togglePlayPause,
|
|
@@ -5893,12 +6107,12 @@ var VideoPlayer = ({
|
|
|
5893
6107
|
className: "flex items-center justify-center w-20 h-20 rounded-full bg-white/20 hover:bg-white/30 backdrop-blur-sm text-white transition-all disabled:opacity-50 disabled:cursor-not-allowed",
|
|
5894
6108
|
style: { width: 80, height: 80, borderRadius: "50%" },
|
|
5895
6109
|
"aria-label": isPlaying ? "Pause" : "Play",
|
|
5896
|
-
children: isPlaying ? /* @__PURE__ */ (0,
|
|
6110
|
+
children: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(PauseIcon, { size: "xl" }) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(PlayIcon, { size: "xl" })
|
|
5897
6111
|
}
|
|
5898
6112
|
) }),
|
|
5899
|
-
/* @__PURE__ */ (0,
|
|
5900
|
-
/* @__PURE__ */ (0,
|
|
5901
|
-
/* @__PURE__ */ (0,
|
|
6113
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "absolute bottom-0 left-0 right-0 p-4 space-y-3", children: [
|
|
6114
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "relative h-1.5 bg-white/30 rounded-full overflow-visible", children: [
|
|
6115
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5902
6116
|
"div",
|
|
5903
6117
|
{
|
|
5904
6118
|
className: "absolute h-full bg-[hsl(var(--primary))] rounded-full transition-all",
|
|
@@ -5907,7 +6121,7 @@ var VideoPlayer = ({
|
|
|
5907
6121
|
),
|
|
5908
6122
|
showChapters && chapters.length > 0 && chapters.map((chapter, index) => {
|
|
5909
6123
|
const markerPosition = duration > 0 ? chapter.startTime / duration * 100 : 0;
|
|
5910
|
-
return /* @__PURE__ */ (0,
|
|
6124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5911
6125
|
"div",
|
|
5912
6126
|
{
|
|
5913
6127
|
className: "absolute top-0 bottom-0 w-1 -ml-0.5 bg-white opacity-70 hover:opacity-100 hover:w-1.5 hover:-ml-0.5 cursor-pointer z-10 transition-all",
|
|
@@ -5923,7 +6137,7 @@ var VideoPlayer = ({
|
|
|
5923
6137
|
index
|
|
5924
6138
|
);
|
|
5925
6139
|
}),
|
|
5926
|
-
/* @__PURE__ */ (0,
|
|
6140
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5927
6141
|
"input",
|
|
5928
6142
|
{
|
|
5929
6143
|
type: "range",
|
|
@@ -5937,42 +6151,42 @@ var VideoPlayer = ({
|
|
|
5937
6151
|
}
|
|
5938
6152
|
)
|
|
5939
6153
|
] }),
|
|
5940
|
-
/* @__PURE__ */ (0,
|
|
5941
|
-
/* @__PURE__ */ (0,
|
|
5942
|
-
/* @__PURE__ */ (0,
|
|
6154
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
6155
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
6156
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5943
6157
|
"button",
|
|
5944
6158
|
{
|
|
5945
6159
|
onClick: togglePlayPause,
|
|
5946
6160
|
disabled: isLoading,
|
|
5947
6161
|
className: "flex items-center justify-center w-10 h-10 rounded-lg bg-white/20 hover:bg-white/30 backdrop-blur-sm text-white transition-all disabled:opacity-50 disabled:cursor-not-allowed",
|
|
5948
6162
|
"aria-label": isPlaying ? "Pause" : "Play",
|
|
5949
|
-
children: isPlaying ? /* @__PURE__ */ (0,
|
|
6163
|
+
children: isPlaying ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(PauseIcon, { size: "md" }) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(PlayIcon, { size: "md" })
|
|
5950
6164
|
}
|
|
5951
6165
|
),
|
|
5952
|
-
/* @__PURE__ */ (0,
|
|
5953
|
-
/* @__PURE__ */ (0,
|
|
6166
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
6167
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "text-sm text-white tabular-nums", children: [
|
|
5954
6168
|
formatTime(currentTime),
|
|
5955
6169
|
" / ",
|
|
5956
6170
|
formatTime(duration)
|
|
5957
6171
|
] }),
|
|
5958
|
-
currentChapter && showChapters && /* @__PURE__ */ (0,
|
|
6172
|
+
currentChapter && showChapters && /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("span", { className: "text-sm text-white/90 font-medium truncate max-w-[200px]", children: [
|
|
5959
6173
|
"\u2022 ",
|
|
5960
6174
|
currentChapter.title
|
|
5961
6175
|
] })
|
|
5962
6176
|
] })
|
|
5963
6177
|
] }),
|
|
5964
|
-
/* @__PURE__ */ (0,
|
|
5965
|
-
/* @__PURE__ */ (0,
|
|
5966
|
-
/* @__PURE__ */ (0,
|
|
6178
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
6179
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
6180
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5967
6181
|
"button",
|
|
5968
6182
|
{
|
|
5969
6183
|
onClick: toggleMute,
|
|
5970
6184
|
className: "text-white/80 hover:text-white transition-colors",
|
|
5971
6185
|
"aria-label": isMuted ? "Unmute" : "Mute",
|
|
5972
|
-
children: isMuted ? /* @__PURE__ */ (0,
|
|
6186
|
+
children: isMuted ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(VolumeOffIcon, { size: "md" }) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(VolumeUpIcon, { size: "md" })
|
|
5973
6187
|
}
|
|
5974
6188
|
),
|
|
5975
|
-
/* @__PURE__ */ (0,
|
|
6189
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5976
6190
|
"input",
|
|
5977
6191
|
{
|
|
5978
6192
|
type: "range",
|
|
@@ -5986,28 +6200,28 @@ var VideoPlayer = ({
|
|
|
5986
6200
|
}
|
|
5987
6201
|
)
|
|
5988
6202
|
] }),
|
|
5989
|
-
/* @__PURE__ */ (0,
|
|
6203
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)(
|
|
5990
6204
|
"button",
|
|
5991
6205
|
{
|
|
5992
6206
|
onClick: toggleFullscreen,
|
|
5993
6207
|
className: "text-white/80 hover:text-white transition-colors",
|
|
5994
6208
|
"aria-label": isFullscreen ? "Exit fullscreen" : "Enter fullscreen",
|
|
5995
|
-
children: isFullscreen ? /* @__PURE__ */ (0,
|
|
6209
|
+
children: isFullscreen ? /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(FullscreenExitIcon, { size: "md" }) : /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(FullscreenIcon, { size: "md" })
|
|
5996
6210
|
}
|
|
5997
6211
|
)
|
|
5998
6212
|
] })
|
|
5999
6213
|
] })
|
|
6000
6214
|
] })
|
|
6001
6215
|
] }),
|
|
6002
|
-
hoveredChapter && showChapters && /* @__PURE__ */ (0,
|
|
6216
|
+
hoveredChapter && showChapters && /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
|
|
6003
6217
|
"div",
|
|
6004
6218
|
{
|
|
6005
6219
|
className: "fixed z-50 px-3 py-2 bg-[hsl(var(--popover))] text-white text-xs font-medium rounded shadow-lg pointer-events-none transform -translate-x-1/2 -translate-y-full",
|
|
6006
6220
|
style: { left: hoverPosition.x, top: hoverPosition.y - 8 },
|
|
6007
6221
|
children: [
|
|
6008
|
-
/* @__PURE__ */ (0,
|
|
6009
|
-
/* @__PURE__ */ (0,
|
|
6010
|
-
/* @__PURE__ */ (0,
|
|
6222
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "whitespace-nowrap", children: hoveredChapter.title }),
|
|
6223
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "text-[hsl(var(--muted-foreground))] text-[10px] mt-0.5", children: formatTime(hoveredChapter.startTime) }),
|
|
6224
|
+
/* @__PURE__ */ (0, import_jsx_runtime110.jsx)("div", { className: "absolute left-1/2 -bottom-1 w-2 h-2 bg-[hsl(var(--popover))] transform -translate-x-1/2 rotate-45" })
|
|
6011
6225
|
]
|
|
6012
6226
|
}
|
|
6013
6227
|
)
|
|
@@ -6018,7 +6232,7 @@ var VideoPlayer = ({
|
|
|
6018
6232
|
};
|
|
6019
6233
|
|
|
6020
6234
|
// src/charts/LineChart.tsx
|
|
6021
|
-
var
|
|
6235
|
+
var import_react32 = __toESM(require("react"));
|
|
6022
6236
|
|
|
6023
6237
|
// src/charts/constants.ts
|
|
6024
6238
|
var CHART_DEFAULTS = {
|
|
@@ -6085,7 +6299,7 @@ var CHART_DEFAULTS = {
|
|
|
6085
6299
|
};
|
|
6086
6300
|
|
|
6087
6301
|
// src/charts/hooks/useResponsiveChart.ts
|
|
6088
|
-
var
|
|
6302
|
+
var import_react29 = require("react");
|
|
6089
6303
|
var BREAKPOINTS = {
|
|
6090
6304
|
mobile: 640,
|
|
6091
6305
|
// < 640px
|
|
@@ -6104,8 +6318,8 @@ var DEFAULT_ASPECT_RATIOS = {
|
|
|
6104
6318
|
desktop: 2
|
|
6105
6319
|
};
|
|
6106
6320
|
function useBreakpoint() {
|
|
6107
|
-
const [breakpoint, setBreakpoint] = (0,
|
|
6108
|
-
(0,
|
|
6321
|
+
const [breakpoint, setBreakpoint] = (0, import_react29.useState)("desktop");
|
|
6322
|
+
(0, import_react29.useEffect)(() => {
|
|
6109
6323
|
const update = () => {
|
|
6110
6324
|
const width = window.innerWidth;
|
|
6111
6325
|
if (width < BREAKPOINTS.mobile) {
|
|
@@ -6402,8 +6616,8 @@ function createTickFormatter(domain) {
|
|
|
6402
6616
|
}
|
|
6403
6617
|
|
|
6404
6618
|
// src/charts/components/ChartTooltip.tsx
|
|
6405
|
-
var
|
|
6406
|
-
var
|
|
6619
|
+
var import_react30 = __toESM(require("react"));
|
|
6620
|
+
var import_jsx_runtime111 = require("react/jsx-runtime");
|
|
6407
6621
|
var DefaultTooltipContent = ({
|
|
6408
6622
|
active,
|
|
6409
6623
|
label,
|
|
@@ -6415,22 +6629,22 @@ var DefaultTooltipContent = ({
|
|
|
6415
6629
|
return null;
|
|
6416
6630
|
}
|
|
6417
6631
|
const formattedLabel = labelFormatter ? labelFormatter(label ?? "") : String(label ?? "");
|
|
6418
|
-
return /* @__PURE__ */ (0,
|
|
6419
|
-
formattedLabel && /* @__PURE__ */ (0,
|
|
6420
|
-
/* @__PURE__ */ (0,
|
|
6632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "bg-[hsl(var(--popover))] text-white rounded-lg shadow-xl border border-[hsl(var(--border))] overflow-hidden min-w-[120px]", children: [
|
|
6633
|
+
formattedLabel && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "px-3 py-2 bg-[hsl(var(--popover))] border-b border-[hsl(var(--border))]", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "text-sm font-medium text-[hsl(var(--muted-foreground))]", children: formattedLabel }) }),
|
|
6634
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)("div", { className: "px-3 py-2 space-y-1", children: payload.map((item, index) => {
|
|
6421
6635
|
const formattedValue = formatter ? formatter(item.value, item.name, item) : String(item.value);
|
|
6422
|
-
return /* @__PURE__ */ (0,
|
|
6423
|
-
/* @__PURE__ */ (0,
|
|
6424
|
-
item.color && /* @__PURE__ */ (0,
|
|
6636
|
+
return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
6637
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
6638
|
+
item.color && /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
6425
6639
|
"span",
|
|
6426
6640
|
{
|
|
6427
6641
|
className: "w-2.5 h-2.5 rounded-full flex-shrink-0",
|
|
6428
6642
|
style: { backgroundColor: item.color }
|
|
6429
6643
|
}
|
|
6430
6644
|
),
|
|
6431
|
-
/* @__PURE__ */ (0,
|
|
6645
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "text-xs text-[hsl(var(--muted-foreground))]", children: item.name })
|
|
6432
6646
|
] }),
|
|
6433
|
-
/* @__PURE__ */ (0,
|
|
6647
|
+
/* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { className: "text-sm font-semibold text-white", children: formattedValue })
|
|
6434
6648
|
] }, `${item.name}-${index}`);
|
|
6435
6649
|
}) })
|
|
6436
6650
|
] });
|
|
@@ -6449,10 +6663,10 @@ var ChartTooltip = ({
|
|
|
6449
6663
|
containerBounds,
|
|
6450
6664
|
animationDuration = 150
|
|
6451
6665
|
}) => {
|
|
6452
|
-
const tooltipRef = (0,
|
|
6453
|
-
const [position, setPosition] = (0,
|
|
6454
|
-
const [isVisible, setIsVisible] = (0,
|
|
6455
|
-
(0,
|
|
6666
|
+
const tooltipRef = (0, import_react30.useRef)(null);
|
|
6667
|
+
const [position, setPosition] = (0, import_react30.useState)({ x: 0, y: 0 });
|
|
6668
|
+
const [isVisible, setIsVisible] = (0, import_react30.useState)(false);
|
|
6669
|
+
(0, import_react30.useEffect)(() => {
|
|
6456
6670
|
if (!active || !tooltipRef.current) {
|
|
6457
6671
|
setIsVisible(false);
|
|
6458
6672
|
return;
|
|
@@ -6481,19 +6695,19 @@ var ChartTooltip = ({
|
|
|
6481
6695
|
if (!active) {
|
|
6482
6696
|
return null;
|
|
6483
6697
|
}
|
|
6484
|
-
const tooltipContent = content ?
|
|
6698
|
+
const tooltipContent = content ? import_react30.default.isValidElement(content) ? import_react30.default.cloneElement(content, {
|
|
6485
6699
|
active,
|
|
6486
6700
|
label,
|
|
6487
6701
|
payload,
|
|
6488
6702
|
formatter,
|
|
6489
6703
|
labelFormatter
|
|
6490
|
-
}) :
|
|
6704
|
+
}) : import_react30.default.createElement(content, {
|
|
6491
6705
|
active,
|
|
6492
6706
|
label,
|
|
6493
6707
|
payload,
|
|
6494
6708
|
formatter,
|
|
6495
6709
|
labelFormatter
|
|
6496
|
-
}) : /* @__PURE__ */ (0,
|
|
6710
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
6497
6711
|
DefaultTooltipContent,
|
|
6498
6712
|
{
|
|
6499
6713
|
active,
|
|
@@ -6503,7 +6717,7 @@ var ChartTooltip = ({
|
|
|
6503
6717
|
labelFormatter
|
|
6504
6718
|
}
|
|
6505
6719
|
);
|
|
6506
|
-
return /* @__PURE__ */ (0,
|
|
6720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
|
|
6507
6721
|
"div",
|
|
6508
6722
|
{
|
|
6509
6723
|
ref: tooltipRef,
|
|
@@ -6520,26 +6734,26 @@ var ChartTooltip = ({
|
|
|
6520
6734
|
);
|
|
6521
6735
|
};
|
|
6522
6736
|
function useTooltip() {
|
|
6523
|
-
const [tooltipData, setTooltipData] = (0,
|
|
6737
|
+
const [tooltipData, setTooltipData] = (0, import_react30.useState)({
|
|
6524
6738
|
active: false,
|
|
6525
6739
|
x: 0,
|
|
6526
6740
|
y: 0,
|
|
6527
6741
|
label: void 0,
|
|
6528
6742
|
payload: void 0
|
|
6529
6743
|
});
|
|
6530
|
-
const showTooltip =
|
|
6744
|
+
const showTooltip = import_react30.default.useCallback((data) => {
|
|
6531
6745
|
setTooltipData({
|
|
6532
6746
|
active: true,
|
|
6533
6747
|
...data
|
|
6534
6748
|
});
|
|
6535
6749
|
}, []);
|
|
6536
|
-
const hideTooltip =
|
|
6750
|
+
const hideTooltip = import_react30.default.useCallback(() => {
|
|
6537
6751
|
setTooltipData((prev) => ({
|
|
6538
6752
|
...prev,
|
|
6539
6753
|
active: false
|
|
6540
6754
|
}));
|
|
6541
6755
|
}, []);
|
|
6542
|
-
const updatePosition =
|
|
6756
|
+
const updatePosition = import_react30.default.useCallback((x, y) => {
|
|
6543
6757
|
setTooltipData((prev) => ({
|
|
6544
6758
|
...prev,
|
|
6545
6759
|
x,
|
|
@@ -6555,7 +6769,7 @@ function useTooltip() {
|
|
|
6555
6769
|
}
|
|
6556
6770
|
|
|
6557
6771
|
// src/charts/components/Legend.tsx
|
|
6558
|
-
var
|
|
6772
|
+
var import_jsx_runtime112 = require("react/jsx-runtime");
|
|
6559
6773
|
var Legend = ({
|
|
6560
6774
|
items = [],
|
|
6561
6775
|
layout = "horizontal",
|
|
@@ -6579,7 +6793,7 @@ var Legend = ({
|
|
|
6579
6793
|
const style = { backgroundColor: item.color };
|
|
6580
6794
|
switch (item.type) {
|
|
6581
6795
|
case "line":
|
|
6582
|
-
return /* @__PURE__ */ (0,
|
|
6796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
6583
6797
|
"div",
|
|
6584
6798
|
{
|
|
6585
6799
|
className: "flex-shrink-0",
|
|
@@ -6591,7 +6805,7 @@ var Legend = ({
|
|
|
6591
6805
|
}
|
|
6592
6806
|
);
|
|
6593
6807
|
case "circle":
|
|
6594
|
-
return /* @__PURE__ */ (0,
|
|
6808
|
+
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
6595
6809
|
"div",
|
|
6596
6810
|
{
|
|
6597
6811
|
className: "rounded-full flex-shrink-0",
|
|
@@ -6605,7 +6819,7 @@ var Legend = ({
|
|
|
6605
6819
|
case "rect":
|
|
6606
6820
|
case "square":
|
|
6607
6821
|
default:
|
|
6608
|
-
return /* @__PURE__ */ (0,
|
|
6822
|
+
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
6609
6823
|
"div",
|
|
6610
6824
|
{
|
|
6611
6825
|
className: "rounded-sm flex-shrink-0",
|
|
@@ -6618,12 +6832,12 @@ var Legend = ({
|
|
|
6618
6832
|
);
|
|
6619
6833
|
}
|
|
6620
6834
|
};
|
|
6621
|
-
return /* @__PURE__ */ (0,
|
|
6835
|
+
return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
|
|
6622
6836
|
"div",
|
|
6623
6837
|
{
|
|
6624
6838
|
className: `flex gap-4 px-4 py-2 ${layoutClass} ${alignClass} ${className}`,
|
|
6625
6839
|
style: wrapperStyle,
|
|
6626
|
-
children: items.map((item, index) => /* @__PURE__ */ (0,
|
|
6840
|
+
children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
|
|
6627
6841
|
"button",
|
|
6628
6842
|
{
|
|
6629
6843
|
type: "button",
|
|
@@ -6637,7 +6851,7 @@ var Legend = ({
|
|
|
6637
6851
|
onMouseLeave,
|
|
6638
6852
|
children: [
|
|
6639
6853
|
renderIcon(item),
|
|
6640
|
-
/* @__PURE__ */ (0,
|
|
6854
|
+
/* @__PURE__ */ (0, import_jsx_runtime112.jsx)("span", { className: "text-[hsl(var(--foreground))]", children: formatter ? formatter(item.name, item, index) : item.name })
|
|
6641
6855
|
]
|
|
6642
6856
|
},
|
|
6643
6857
|
`${item.name}-${index}`
|
|
@@ -6647,7 +6861,7 @@ var Legend = ({
|
|
|
6647
6861
|
};
|
|
6648
6862
|
|
|
6649
6863
|
// src/charts/components/ReferenceLine.tsx
|
|
6650
|
-
var
|
|
6864
|
+
var import_jsx_runtime113 = require("react/jsx-runtime");
|
|
6651
6865
|
var ReferenceLine = ({
|
|
6652
6866
|
x,
|
|
6653
6867
|
y,
|
|
@@ -6759,8 +6973,8 @@ var ReferenceLine = ({
|
|
|
6759
6973
|
} else {
|
|
6760
6974
|
return null;
|
|
6761
6975
|
}
|
|
6762
|
-
return /* @__PURE__ */ (0,
|
|
6763
|
-
/* @__PURE__ */ (0,
|
|
6976
|
+
return /* @__PURE__ */ (0, import_jsx_runtime113.jsxs)("g", { className: `reference-line ${className}`, children: [
|
|
6977
|
+
/* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
|
|
6764
6978
|
"line",
|
|
6765
6979
|
{
|
|
6766
6980
|
x1,
|
|
@@ -6772,7 +6986,7 @@ var ReferenceLine = ({
|
|
|
6772
6986
|
strokeDasharray
|
|
6773
6987
|
}
|
|
6774
6988
|
),
|
|
6775
|
-
label && (typeof label === "string" ? /* @__PURE__ */ (0,
|
|
6989
|
+
label && (typeof label === "string" ? /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
|
|
6776
6990
|
"text",
|
|
6777
6991
|
{
|
|
6778
6992
|
x: labelX,
|
|
@@ -6784,7 +6998,7 @@ var ReferenceLine = ({
|
|
|
6784
6998
|
className: "fill-[hsl(var(--muted-foreground))]",
|
|
6785
6999
|
children: label
|
|
6786
7000
|
}
|
|
6787
|
-
) : /* @__PURE__ */ (0,
|
|
7001
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(
|
|
6788
7002
|
"foreignObject",
|
|
6789
7003
|
{
|
|
6790
7004
|
x: labelX - 50,
|
|
@@ -6798,7 +7012,7 @@ var ReferenceLine = ({
|
|
|
6798
7012
|
};
|
|
6799
7013
|
|
|
6800
7014
|
// src/charts/components/ReferenceArea.tsx
|
|
6801
|
-
var
|
|
7015
|
+
var import_jsx_runtime114 = require("react/jsx-runtime");
|
|
6802
7016
|
var ReferenceArea = ({
|
|
6803
7017
|
x1,
|
|
6804
7018
|
x2,
|
|
@@ -6906,8 +7120,8 @@ var ReferenceArea = ({
|
|
|
6906
7120
|
labelX = rectX + rectWidth / 2;
|
|
6907
7121
|
labelY = rectY + rectHeight / 2;
|
|
6908
7122
|
}
|
|
6909
|
-
return /* @__PURE__ */ (0,
|
|
6910
|
-
/* @__PURE__ */ (0,
|
|
7123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)("g", { className: `reference-area ${className}`, children: [
|
|
7124
|
+
/* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
|
|
6911
7125
|
"rect",
|
|
6912
7126
|
{
|
|
6913
7127
|
x: rectX,
|
|
@@ -6920,7 +7134,7 @@ var ReferenceArea = ({
|
|
|
6920
7134
|
strokeWidth
|
|
6921
7135
|
}
|
|
6922
7136
|
),
|
|
6923
|
-
label && (typeof label === "string" ? /* @__PURE__ */ (0,
|
|
7137
|
+
label && (typeof label === "string" ? /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
|
|
6924
7138
|
"text",
|
|
6925
7139
|
{
|
|
6926
7140
|
x: labelX,
|
|
@@ -6932,7 +7146,7 @@ var ReferenceArea = ({
|
|
|
6932
7146
|
className: "fill-[hsl(var(--muted-foreground))]",
|
|
6933
7147
|
children: label
|
|
6934
7148
|
}
|
|
6935
|
-
) : /* @__PURE__ */ (0,
|
|
7149
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
|
|
6936
7150
|
"foreignObject",
|
|
6937
7151
|
{
|
|
6938
7152
|
x: labelX - 50,
|
|
@@ -6946,8 +7160,8 @@ var ReferenceArea = ({
|
|
|
6946
7160
|
};
|
|
6947
7161
|
|
|
6948
7162
|
// src/charts/components/CartesianGrid.tsx
|
|
6949
|
-
var
|
|
6950
|
-
var
|
|
7163
|
+
var import_react31 = require("react");
|
|
7164
|
+
var import_jsx_runtime115 = require("react/jsx-runtime");
|
|
6951
7165
|
var CartesianGrid = ({
|
|
6952
7166
|
horizontal = true,
|
|
6953
7167
|
vertical = true,
|
|
@@ -6964,18 +7178,18 @@ var CartesianGrid = ({
|
|
|
6964
7178
|
return null;
|
|
6965
7179
|
}
|
|
6966
7180
|
const { width, height } = _chartDimensions;
|
|
6967
|
-
const hPoints = (0,
|
|
7181
|
+
const hPoints = (0, import_react31.useMemo)(() => {
|
|
6968
7182
|
if (horizontalPoints) return horizontalPoints;
|
|
6969
7183
|
const count = 5;
|
|
6970
7184
|
return Array.from({ length: count + 1 }, (_, i) => height / count * i);
|
|
6971
7185
|
}, [horizontalPoints, height]);
|
|
6972
|
-
const vPoints = (0,
|
|
7186
|
+
const vPoints = (0, import_react31.useMemo)(() => {
|
|
6973
7187
|
if (verticalPoints) return verticalPoints;
|
|
6974
7188
|
const count = 6;
|
|
6975
7189
|
return Array.from({ length: count + 1 }, (_, i) => width / count * i);
|
|
6976
7190
|
}, [verticalPoints, width]);
|
|
6977
|
-
return /* @__PURE__ */ (0,
|
|
6978
|
-
horizontal && hPoints.map((y, i) => /* @__PURE__ */ (0,
|
|
7191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)("g", { className: `cartesian-grid ${className}`, children: [
|
|
7192
|
+
horizontal && hPoints.map((y, i) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
|
|
6979
7193
|
"line",
|
|
6980
7194
|
{
|
|
6981
7195
|
x1: 0,
|
|
@@ -6990,7 +7204,7 @@ var CartesianGrid = ({
|
|
|
6990
7204
|
},
|
|
6991
7205
|
`h-${i}`
|
|
6992
7206
|
)),
|
|
6993
|
-
vertical && vPoints.map((x, i) => /* @__PURE__ */ (0,
|
|
7207
|
+
vertical && vPoints.map((x, i) => /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(
|
|
6994
7208
|
"line",
|
|
6995
7209
|
{
|
|
6996
7210
|
x1: x,
|
|
@@ -7009,7 +7223,7 @@ var CartesianGrid = ({
|
|
|
7009
7223
|
};
|
|
7010
7224
|
|
|
7011
7225
|
// src/charts/LineChart.tsx
|
|
7012
|
-
var
|
|
7226
|
+
var import_jsx_runtime116 = require("react/jsx-runtime");
|
|
7013
7227
|
var LineChart = ({
|
|
7014
7228
|
data,
|
|
7015
7229
|
width: providedWidth,
|
|
@@ -7045,10 +7259,10 @@ var LineChart = ({
|
|
|
7045
7259
|
colors = CHART_DEFAULTS.colors,
|
|
7046
7260
|
ariaLabel
|
|
7047
7261
|
}) => {
|
|
7048
|
-
const containerRef = (0,
|
|
7049
|
-
const svgRef = (0,
|
|
7050
|
-
const [hoveredPoint, setHoveredPoint] = (0,
|
|
7051
|
-
const [crosshairX, setCrosshairX] = (0,
|
|
7262
|
+
const containerRef = (0, import_react32.useRef)(null);
|
|
7263
|
+
const svgRef = (0, import_react32.useRef)(null);
|
|
7264
|
+
const [hoveredPoint, setHoveredPoint] = (0, import_react32.useState)(null);
|
|
7265
|
+
const [crosshairX, setCrosshairX] = (0, import_react32.useState)(null);
|
|
7052
7266
|
const { tooltipData, showTooltip: showTooltipFn, hideTooltip } = useTooltip();
|
|
7053
7267
|
const {
|
|
7054
7268
|
width,
|
|
@@ -7066,7 +7280,7 @@ var LineChart = ({
|
|
|
7066
7280
|
providedHeight
|
|
7067
7281
|
});
|
|
7068
7282
|
const animate = animateProp && !_isResizing;
|
|
7069
|
-
const padding = (0,
|
|
7283
|
+
const padding = (0, import_react32.useMemo)(() => ({
|
|
7070
7284
|
top: customPadding?.top ?? CHART_DEFAULTS.padding.top,
|
|
7071
7285
|
right: customPadding?.right ?? (showValueLabels ? 80 : CHART_DEFAULTS.padding.right),
|
|
7072
7286
|
bottom: customPadding?.bottom ?? (showXAxis ? 60 : CHART_DEFAULTS.padding.bottom),
|
|
@@ -7074,17 +7288,17 @@ var LineChart = ({
|
|
|
7074
7288
|
}), [customPadding, showXAxis, showYAxis, showValueLabels]);
|
|
7075
7289
|
const chartWidth = width - padding.left - padding.right;
|
|
7076
7290
|
const chartHeight = height - padding.top - padding.bottom;
|
|
7077
|
-
const allPoints = (0,
|
|
7291
|
+
const allPoints = (0, import_react32.useMemo)(
|
|
7078
7292
|
() => data.flatMap((series) => series.data),
|
|
7079
7293
|
[data]
|
|
7080
7294
|
);
|
|
7081
|
-
const xValueType = (0,
|
|
7295
|
+
const xValueType = (0, import_react32.useMemo)(() => {
|
|
7082
7296
|
const firstX = data[0]?.data[0]?.x;
|
|
7083
7297
|
if (firstX instanceof Date) return "date";
|
|
7084
7298
|
if (typeof firstX === "number") return "number";
|
|
7085
7299
|
return "string";
|
|
7086
7300
|
}, [data]);
|
|
7087
|
-
const xDomainCalc = (0,
|
|
7301
|
+
const xDomainCalc = (0, import_react32.useMemo)(() => {
|
|
7088
7302
|
if (xValueType === "date") {
|
|
7089
7303
|
const dates = allPoints.map((p) => p.x.getTime());
|
|
7090
7304
|
return [Math.min(...dates), Math.max(...dates)];
|
|
@@ -7096,12 +7310,12 @@ var LineChart = ({
|
|
|
7096
7310
|
const maxLen = Math.max(...data.map((s) => s.data.length));
|
|
7097
7311
|
return [0, maxLen - 1];
|
|
7098
7312
|
}, [allPoints, xValueType, data]);
|
|
7099
|
-
const yDomainCalc = (0,
|
|
7313
|
+
const yDomainCalc = (0, import_react32.useMemo)(() => {
|
|
7100
7314
|
if (yDomain) return yDomain;
|
|
7101
7315
|
const yValues = allPoints.map((p) => p.y);
|
|
7102
7316
|
return calculateDomain(yValues, { includeZero: true, padding: 0.1 });
|
|
7103
7317
|
}, [allPoints, yDomain]);
|
|
7104
|
-
const xScale = (0,
|
|
7318
|
+
const xScale = (0, import_react32.useMemo)(() => {
|
|
7105
7319
|
if (xValueType === "date") {
|
|
7106
7320
|
return (value) => {
|
|
7107
7321
|
const time = value instanceof Date ? value.getTime() : Number(value);
|
|
@@ -7124,18 +7338,18 @@ var LineChart = ({
|
|
|
7124
7338
|
return index / maxLen * chartWidth;
|
|
7125
7339
|
};
|
|
7126
7340
|
}, [xValueType, xDomainCalc, chartWidth, data]);
|
|
7127
|
-
const yScale = (0,
|
|
7341
|
+
const yScale = (0, import_react32.useMemo)(
|
|
7128
7342
|
() => scaleLinear({
|
|
7129
7343
|
domain: yDomainCalc,
|
|
7130
7344
|
range: [chartHeight, 0]
|
|
7131
7345
|
}),
|
|
7132
7346
|
[yDomainCalc, chartHeight]
|
|
7133
7347
|
);
|
|
7134
|
-
const yTicks = (0,
|
|
7348
|
+
const yTicks = (0, import_react32.useMemo)(
|
|
7135
7349
|
() => getTicks(yDomainCalc, yAxisTickCount),
|
|
7136
7350
|
[yDomainCalc, yAxisTickCount]
|
|
7137
7351
|
);
|
|
7138
|
-
const xTicks = (0,
|
|
7352
|
+
const xTicks = (0, import_react32.useMemo)(() => {
|
|
7139
7353
|
if (xValueType === "string") {
|
|
7140
7354
|
return data[0]?.data.map((p, i) => ({ value: p.x, index: i })) || [];
|
|
7141
7355
|
}
|
|
@@ -7143,7 +7357,7 @@ var LineChart = ({
|
|
|
7143
7357
|
const ticks = getTicks(xDomainCalc, tickCount);
|
|
7144
7358
|
return ticks.map((t) => ({ value: t, index: 0 }));
|
|
7145
7359
|
}, [xValueType, xDomainCalc, data]);
|
|
7146
|
-
const xFormatter = (0,
|
|
7360
|
+
const xFormatter = (0, import_react32.useCallback)((value) => {
|
|
7147
7361
|
if (formatXValue) return formatXValue(value);
|
|
7148
7362
|
if (value instanceof Date) {
|
|
7149
7363
|
const range = xDomainCalc[1] - xDomainCalc[0];
|
|
@@ -7151,11 +7365,11 @@ var LineChart = ({
|
|
|
7151
7365
|
}
|
|
7152
7366
|
return String(value);
|
|
7153
7367
|
}, [formatXValue, xDomainCalc]);
|
|
7154
|
-
const yFormatter = (0,
|
|
7368
|
+
const yFormatter = (0, import_react32.useMemo)(() => {
|
|
7155
7369
|
if (formatYValue) return formatYValue;
|
|
7156
7370
|
return createTickFormatter(yDomainCalc);
|
|
7157
7371
|
}, [formatYValue, yDomainCalc]);
|
|
7158
|
-
const seriesPaths = (0,
|
|
7372
|
+
const seriesPaths = (0, import_react32.useMemo)(() => {
|
|
7159
7373
|
return data.map((series) => {
|
|
7160
7374
|
const points = series.data.map((point, i) => ({
|
|
7161
7375
|
x: xScale(point.x, i),
|
|
@@ -7180,7 +7394,7 @@ var LineChart = ({
|
|
|
7180
7394
|
return { points, path };
|
|
7181
7395
|
});
|
|
7182
7396
|
}, [data, xScale, yScale]);
|
|
7183
|
-
const handlePointEnter = (0,
|
|
7397
|
+
const handlePointEnter = (0, import_react32.useCallback)((e, seriesIndex, pointIndex) => {
|
|
7184
7398
|
const series = data[seriesIndex];
|
|
7185
7399
|
const point = series.data[pointIndex];
|
|
7186
7400
|
const scaledPoint = seriesPaths[seriesIndex].points[pointIndex];
|
|
@@ -7207,17 +7421,17 @@ var LineChart = ({
|
|
|
7207
7421
|
}
|
|
7208
7422
|
onPointHover?.(point, seriesIndex, pointIndex);
|
|
7209
7423
|
}, [data, seriesPaths, showCrosshair, showTooltip, colors, xFormatter, showTooltipFn, onPointHover]);
|
|
7210
|
-
const handlePointLeave = (0,
|
|
7424
|
+
const handlePointLeave = (0, import_react32.useCallback)(() => {
|
|
7211
7425
|
setHoveredPoint(null);
|
|
7212
7426
|
setCrosshairX(null);
|
|
7213
7427
|
hideTooltip();
|
|
7214
7428
|
onPointHover?.(null, -1, -1);
|
|
7215
7429
|
}, [hideTooltip, onPointHover]);
|
|
7216
|
-
const handlePointClick = (0,
|
|
7430
|
+
const handlePointClick = (0, import_react32.useCallback)((seriesIndex, pointIndex) => {
|
|
7217
7431
|
const point = data[seriesIndex].data[pointIndex];
|
|
7218
7432
|
onPointClick?.(point, seriesIndex, pointIndex);
|
|
7219
7433
|
}, [data, onPointClick]);
|
|
7220
|
-
const legendItems = (0,
|
|
7434
|
+
const legendItems = (0, import_react32.useMemo)(
|
|
7221
7435
|
() => data.map((series, i) => ({
|
|
7222
7436
|
name: series.name,
|
|
7223
7437
|
color: series.color || colors[i % colors.length],
|
|
@@ -7225,7 +7439,7 @@ var LineChart = ({
|
|
|
7225
7439
|
})),
|
|
7226
7440
|
[data, colors]
|
|
7227
7441
|
);
|
|
7228
|
-
const referenceElements = (0,
|
|
7442
|
+
const referenceElements = (0, import_react32.useMemo)(() => {
|
|
7229
7443
|
if (!children) return null;
|
|
7230
7444
|
const chartDimensions = {
|
|
7231
7445
|
width: chartWidth,
|
|
@@ -7242,10 +7456,10 @@ var LineChart = ({
|
|
|
7242
7456
|
},
|
|
7243
7457
|
yScale
|
|
7244
7458
|
};
|
|
7245
|
-
return
|
|
7246
|
-
if (!
|
|
7459
|
+
return import_react32.default.Children.map(children, (child) => {
|
|
7460
|
+
if (!import_react32.default.isValidElement(child)) return child;
|
|
7247
7461
|
if (child.type === ReferenceLine || child.type === ReferenceArea || child.type === CartesianGrid) {
|
|
7248
|
-
return
|
|
7462
|
+
return import_react32.default.cloneElement(child, {
|
|
7249
7463
|
_chartDimensions: chartDimensions,
|
|
7250
7464
|
_scales: scales
|
|
7251
7465
|
});
|
|
@@ -7253,19 +7467,19 @@ var LineChart = ({
|
|
|
7253
7467
|
return child;
|
|
7254
7468
|
});
|
|
7255
7469
|
}, [children, chartWidth, chartHeight, padding, xScale, yScale, xValueType, data]);
|
|
7256
|
-
const accessibleDescription = (0,
|
|
7470
|
+
const accessibleDescription = (0, import_react32.useMemo)(() => {
|
|
7257
7471
|
if (ariaLabel) return ariaLabel;
|
|
7258
7472
|
const seriesNames = data.map((s) => s.name).join(", ");
|
|
7259
7473
|
return `Line chart with ${data.length} series: ${seriesNames}`;
|
|
7260
7474
|
}, [data, ariaLabel]);
|
|
7261
|
-
return /* @__PURE__ */ (0,
|
|
7475
|
+
return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
|
|
7262
7476
|
"div",
|
|
7263
7477
|
{
|
|
7264
7478
|
ref: containerRef,
|
|
7265
7479
|
className: `relative ${className}`,
|
|
7266
7480
|
style: containerStyle,
|
|
7267
7481
|
children: [
|
|
7268
|
-
/* @__PURE__ */ (0,
|
|
7482
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
|
|
7269
7483
|
"svg",
|
|
7270
7484
|
{
|
|
7271
7485
|
ref: svgRef,
|
|
@@ -7278,14 +7492,14 @@ var LineChart = ({
|
|
|
7278
7492
|
className: "bg-[hsl(var(--card))]",
|
|
7279
7493
|
style: svgStyle,
|
|
7280
7494
|
children: [
|
|
7281
|
-
/* @__PURE__ */ (0,
|
|
7495
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)("defs", { children: animate && data.map((series, i) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("style", { children: `
|
|
7282
7496
|
@keyframes drawLine${i} {
|
|
7283
7497
|
from { stroke-dashoffset: 2000; }
|
|
7284
7498
|
to { stroke-dashoffset: 0; }
|
|
7285
7499
|
}
|
|
7286
7500
|
` }, `anim-${i}`)) }),
|
|
7287
|
-
/* @__PURE__ */ (0,
|
|
7288
|
-
showGrid && /* @__PURE__ */ (0,
|
|
7501
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("g", { transform: `translate(${padding.left}, ${padding.top})`, children: [
|
|
7502
|
+
showGrid && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7289
7503
|
CartesianGrid,
|
|
7290
7504
|
{
|
|
7291
7505
|
_chartDimensions: { width: chartWidth, height: chartHeight },
|
|
@@ -7293,7 +7507,7 @@ var LineChart = ({
|
|
|
7293
7507
|
}
|
|
7294
7508
|
),
|
|
7295
7509
|
referenceElements,
|
|
7296
|
-
showCrosshair && crosshairX !== null && /* @__PURE__ */ (0,
|
|
7510
|
+
showCrosshair && crosshairX !== null && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7297
7511
|
"line",
|
|
7298
7512
|
{
|
|
7299
7513
|
x1: crosshairX,
|
|
@@ -7311,7 +7525,7 @@ var LineChart = ({
|
|
|
7311
7525
|
const { path } = seriesPaths[seriesIndex];
|
|
7312
7526
|
const color = series.color || colors[seriesIndex % colors.length];
|
|
7313
7527
|
const strokeWidth = series.strokeWidth || CHART_DEFAULTS.line.strokeWidth;
|
|
7314
|
-
return /* @__PURE__ */ (0,
|
|
7528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7315
7529
|
"path",
|
|
7316
7530
|
{
|
|
7317
7531
|
d: path,
|
|
@@ -7336,7 +7550,7 @@ var LineChart = ({
|
|
|
7336
7550
|
return points.map((point, pointIndex) => {
|
|
7337
7551
|
const isHovered = hoveredPoint?.seriesIndex === seriesIndex && hoveredPoint?.pointIndex === pointIndex;
|
|
7338
7552
|
const animateDots = animate && !isResponsive;
|
|
7339
|
-
return /* @__PURE__ */ (0,
|
|
7553
|
+
return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7340
7554
|
"circle",
|
|
7341
7555
|
{
|
|
7342
7556
|
cx: point.x,
|
|
@@ -7364,8 +7578,8 @@ var LineChart = ({
|
|
|
7364
7578
|
const lastScaled = points[points.length - 1];
|
|
7365
7579
|
const color = series.color || colors[seriesIndex % colors.length];
|
|
7366
7580
|
if (!lastPoint || !lastScaled) return null;
|
|
7367
|
-
return /* @__PURE__ */ (0,
|
|
7368
|
-
/* @__PURE__ */ (0,
|
|
7581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("g", { children: [
|
|
7582
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7369
7583
|
"circle",
|
|
7370
7584
|
{
|
|
7371
7585
|
cx: chartWidth + 12,
|
|
@@ -7374,7 +7588,7 @@ var LineChart = ({
|
|
|
7374
7588
|
fill: color
|
|
7375
7589
|
}
|
|
7376
7590
|
),
|
|
7377
|
-
/* @__PURE__ */ (0,
|
|
7591
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7378
7592
|
"text",
|
|
7379
7593
|
{
|
|
7380
7594
|
x: chartWidth + 22,
|
|
@@ -7388,8 +7602,8 @@ var LineChart = ({
|
|
|
7388
7602
|
)
|
|
7389
7603
|
] }, `label-${seriesIndex}`);
|
|
7390
7604
|
}),
|
|
7391
|
-
showXAxis && /* @__PURE__ */ (0,
|
|
7392
|
-
/* @__PURE__ */ (0,
|
|
7605
|
+
showXAxis && /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("g", { transform: `translate(0, ${chartHeight})`, children: [
|
|
7606
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7393
7607
|
"line",
|
|
7394
7608
|
{
|
|
7395
7609
|
x1: 0,
|
|
@@ -7402,9 +7616,9 @@ var LineChart = ({
|
|
|
7402
7616
|
),
|
|
7403
7617
|
xTicks.map((tick, i) => {
|
|
7404
7618
|
const x = xValueType === "string" ? xScale(tick.value, tick.index) : xScale(xValueType === "date" ? new Date(tick.value) : tick.value, 0);
|
|
7405
|
-
return /* @__PURE__ */ (0,
|
|
7406
|
-
/* @__PURE__ */ (0,
|
|
7407
|
-
/* @__PURE__ */ (0,
|
|
7619
|
+
return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("g", { transform: `translate(${x}, 0)`, children: [
|
|
7620
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)("line", { y2: 6, className: "stroke-[hsl(var(--border))]" }),
|
|
7621
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7408
7622
|
"text",
|
|
7409
7623
|
{
|
|
7410
7624
|
y: 20,
|
|
@@ -7416,7 +7630,7 @@ var LineChart = ({
|
|
|
7416
7630
|
)
|
|
7417
7631
|
] }, `x-tick-${i}`);
|
|
7418
7632
|
}),
|
|
7419
|
-
xAxisLabel && /* @__PURE__ */ (0,
|
|
7633
|
+
xAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7420
7634
|
"text",
|
|
7421
7635
|
{
|
|
7422
7636
|
x: chartWidth / 2,
|
|
@@ -7429,8 +7643,8 @@ var LineChart = ({
|
|
|
7429
7643
|
}
|
|
7430
7644
|
)
|
|
7431
7645
|
] }),
|
|
7432
|
-
showYAxis && /* @__PURE__ */ (0,
|
|
7433
|
-
/* @__PURE__ */ (0,
|
|
7646
|
+
showYAxis && /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("g", { children: [
|
|
7647
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7434
7648
|
"line",
|
|
7435
7649
|
{
|
|
7436
7650
|
x1: 0,
|
|
@@ -7441,9 +7655,9 @@ var LineChart = ({
|
|
|
7441
7655
|
strokeWidth: 1
|
|
7442
7656
|
}
|
|
7443
7657
|
),
|
|
7444
|
-
yTicks.map((tick, i) => /* @__PURE__ */ (0,
|
|
7445
|
-
/* @__PURE__ */ (0,
|
|
7446
|
-
/* @__PURE__ */ (0,
|
|
7658
|
+
yTicks.map((tick, i) => /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("g", { transform: `translate(0, ${yScale(tick)})`, children: [
|
|
7659
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)("line", { x2: -6, className: "stroke-[hsl(var(--border))]" }),
|
|
7660
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7447
7661
|
"text",
|
|
7448
7662
|
{
|
|
7449
7663
|
x: -12,
|
|
@@ -7455,7 +7669,7 @@ var LineChart = ({
|
|
|
7455
7669
|
}
|
|
7456
7670
|
)
|
|
7457
7671
|
] }, `y-tick-${i}`)),
|
|
7458
|
-
yAxisLabel && /* @__PURE__ */ (0,
|
|
7672
|
+
yAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7459
7673
|
"text",
|
|
7460
7674
|
{
|
|
7461
7675
|
x: -chartHeight / 2,
|
|
@@ -7470,7 +7684,7 @@ var LineChart = ({
|
|
|
7470
7684
|
)
|
|
7471
7685
|
] })
|
|
7472
7686
|
] }),
|
|
7473
|
-
/* @__PURE__ */ (0,
|
|
7687
|
+
/* @__PURE__ */ (0, import_jsx_runtime116.jsx)("style", { children: `
|
|
7474
7688
|
@keyframes fadeIn {
|
|
7475
7689
|
from { opacity: 0; }
|
|
7476
7690
|
to { opacity: 1; }
|
|
@@ -7479,7 +7693,7 @@ var LineChart = ({
|
|
|
7479
7693
|
]
|
|
7480
7694
|
}
|
|
7481
7695
|
),
|
|
7482
|
-
showLegend && /* @__PURE__ */ (0,
|
|
7696
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7483
7697
|
Legend,
|
|
7484
7698
|
{
|
|
7485
7699
|
items: legendItems,
|
|
@@ -7487,7 +7701,7 @@ var LineChart = ({
|
|
|
7487
7701
|
align: "center"
|
|
7488
7702
|
}
|
|
7489
7703
|
),
|
|
7490
|
-
showTooltip && /* @__PURE__ */ (0,
|
|
7704
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
|
|
7491
7705
|
ChartTooltip,
|
|
7492
7706
|
{
|
|
7493
7707
|
...tooltipData,
|
|
@@ -7503,8 +7717,8 @@ var LineChart = ({
|
|
|
7503
7717
|
};
|
|
7504
7718
|
|
|
7505
7719
|
// src/charts/BarChart.tsx
|
|
7506
|
-
var
|
|
7507
|
-
var
|
|
7720
|
+
var import_react33 = __toESM(require("react"));
|
|
7721
|
+
var import_jsx_runtime117 = require("react/jsx-runtime");
|
|
7508
7722
|
var BarChart = ({
|
|
7509
7723
|
data,
|
|
7510
7724
|
width: providedWidth,
|
|
@@ -7540,8 +7754,8 @@ var BarChart = ({
|
|
|
7540
7754
|
colors = CHART_DEFAULTS.colors,
|
|
7541
7755
|
ariaLabel
|
|
7542
7756
|
}) => {
|
|
7543
|
-
const containerRef = (0,
|
|
7544
|
-
const [hoveredBar, setHoveredBar] = (0,
|
|
7757
|
+
const containerRef = (0, import_react33.useRef)(null);
|
|
7758
|
+
const [hoveredBar, setHoveredBar] = (0, import_react33.useState)(null);
|
|
7545
7759
|
const { tooltipData, showTooltip: showTooltipFn, hideTooltip } = useTooltip();
|
|
7546
7760
|
const {
|
|
7547
7761
|
width,
|
|
@@ -7559,7 +7773,7 @@ var BarChart = ({
|
|
|
7559
7773
|
providedHeight
|
|
7560
7774
|
});
|
|
7561
7775
|
const animate = animateProp && !_isResizing && !isResponsive;
|
|
7562
|
-
const padding = (0,
|
|
7776
|
+
const padding = (0, import_react33.useMemo)(() => ({
|
|
7563
7777
|
top: customPadding?.top ?? CHART_DEFAULTS.padding.top,
|
|
7564
7778
|
right: customPadding?.right ?? CHART_DEFAULTS.padding.right,
|
|
7565
7779
|
bottom: customPadding?.bottom ?? (showXAxis ? 70 : CHART_DEFAULTS.padding.bottom),
|
|
@@ -7567,11 +7781,11 @@ var BarChart = ({
|
|
|
7567
7781
|
}), [customPadding, showXAxis, showYAxis]);
|
|
7568
7782
|
const chartWidth = width - padding.left - padding.right;
|
|
7569
7783
|
const chartHeight = height - padding.top - padding.bottom;
|
|
7570
|
-
const categories = (0,
|
|
7784
|
+
const categories = (0, import_react33.useMemo)(() => {
|
|
7571
7785
|
const cats = data[0]?.data.map((d) => String(d.x)) || [];
|
|
7572
7786
|
return [...new Set(cats)];
|
|
7573
7787
|
}, [data]);
|
|
7574
|
-
const yDomainCalc = (0,
|
|
7788
|
+
const yDomainCalc = (0, import_react33.useMemo)(() => {
|
|
7575
7789
|
if (yDomain) return yDomain;
|
|
7576
7790
|
if (stacked) {
|
|
7577
7791
|
const maxStacked = categories.map((_, catIndex) => {
|
|
@@ -7584,7 +7798,7 @@ var BarChart = ({
|
|
|
7584
7798
|
const allY = data.flatMap((s) => s.data.map((d) => d.y));
|
|
7585
7799
|
return calculateDomain(allY, { includeZero: true, padding: 0.1 });
|
|
7586
7800
|
}, [data, categories, stacked, yDomain]);
|
|
7587
|
-
const xBandScale = (0,
|
|
7801
|
+
const xBandScale = (0, import_react33.useMemo)(
|
|
7588
7802
|
() => scaleBand({
|
|
7589
7803
|
domain: categories,
|
|
7590
7804
|
range: horizontal ? [chartHeight, 0] : [0, chartWidth],
|
|
@@ -7592,25 +7806,25 @@ var BarChart = ({
|
|
|
7592
7806
|
}),
|
|
7593
7807
|
[categories, chartWidth, chartHeight, horizontal, barCategoryGap]
|
|
7594
7808
|
);
|
|
7595
|
-
const yScale = (0,
|
|
7809
|
+
const yScale = (0, import_react33.useMemo)(
|
|
7596
7810
|
() => scaleLinear({
|
|
7597
7811
|
domain: yDomainCalc,
|
|
7598
7812
|
range: horizontal ? [0, chartWidth] : [chartHeight, 0]
|
|
7599
7813
|
}),
|
|
7600
7814
|
[yDomainCalc, chartWidth, chartHeight, horizontal]
|
|
7601
7815
|
);
|
|
7602
|
-
const yTicks = (0,
|
|
7816
|
+
const yTicks = (0, import_react33.useMemo)(
|
|
7603
7817
|
() => getTicks(yDomainCalc, yAxisTickCount),
|
|
7604
7818
|
[yDomainCalc, yAxisTickCount]
|
|
7605
7819
|
);
|
|
7606
|
-
const yFormatter = (0,
|
|
7820
|
+
const yFormatter = (0, import_react33.useMemo)(() => {
|
|
7607
7821
|
if (formatYValue) return formatYValue;
|
|
7608
7822
|
return createTickFormatter(yDomainCalc);
|
|
7609
7823
|
}, [formatYValue, yDomainCalc]);
|
|
7610
7824
|
const numSeries = data.length;
|
|
7611
7825
|
const bandwidth = xBandScale.bandwidth();
|
|
7612
7826
|
const barWidth = stacked ? bandwidth : (bandwidth - bandwidth * barGap * (numSeries - 1)) / numSeries;
|
|
7613
|
-
const handleBarEnter = (0,
|
|
7827
|
+
const handleBarEnter = (0, import_react33.useCallback)((e, seriesIndex, barIndex) => {
|
|
7614
7828
|
const series = data[seriesIndex];
|
|
7615
7829
|
const point = series.data[barIndex];
|
|
7616
7830
|
setHoveredBar({ seriesIndex, barIndex });
|
|
@@ -7633,16 +7847,16 @@ var BarChart = ({
|
|
|
7633
7847
|
}
|
|
7634
7848
|
onBarHover?.(point, seriesIndex, barIndex);
|
|
7635
7849
|
}, [data, showTooltip, colors, showTooltipFn, onBarHover]);
|
|
7636
|
-
const handleBarLeave = (0,
|
|
7850
|
+
const handleBarLeave = (0, import_react33.useCallback)(() => {
|
|
7637
7851
|
setHoveredBar(null);
|
|
7638
7852
|
hideTooltip();
|
|
7639
7853
|
onBarHover?.(null, -1, -1);
|
|
7640
7854
|
}, [hideTooltip, onBarHover]);
|
|
7641
|
-
const handleBarClick = (0,
|
|
7855
|
+
const handleBarClick = (0, import_react33.useCallback)((seriesIndex, barIndex) => {
|
|
7642
7856
|
const point = data[seriesIndex].data[barIndex];
|
|
7643
7857
|
onBarClick?.(point, seriesIndex, barIndex);
|
|
7644
7858
|
}, [data, onBarClick]);
|
|
7645
|
-
const legendItems = (0,
|
|
7859
|
+
const legendItems = (0, import_react33.useMemo)(
|
|
7646
7860
|
() => data.map((series, i) => ({
|
|
7647
7861
|
name: series.name,
|
|
7648
7862
|
color: series.color || colors[i % colors.length],
|
|
@@ -7650,7 +7864,7 @@ var BarChart = ({
|
|
|
7650
7864
|
})),
|
|
7651
7865
|
[data, colors]
|
|
7652
7866
|
);
|
|
7653
|
-
const bars = (0,
|
|
7867
|
+
const bars = (0, import_react33.useMemo)(() => {
|
|
7654
7868
|
const result = [];
|
|
7655
7869
|
const cumulativeValues = {};
|
|
7656
7870
|
data.forEach((series, seriesIndex) => {
|
|
@@ -7690,7 +7904,7 @@ var BarChart = ({
|
|
|
7690
7904
|
}
|
|
7691
7905
|
const isHovered = hoveredBar?.seriesIndex === seriesIndex && hoveredBar?.barIndex === barIndex;
|
|
7692
7906
|
result.push(
|
|
7693
|
-
/* @__PURE__ */ (0,
|
|
7907
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7694
7908
|
"rect",
|
|
7695
7909
|
{
|
|
7696
7910
|
x: barX,
|
|
@@ -7718,7 +7932,7 @@ var BarChart = ({
|
|
|
7718
7932
|
const labelX = horizontal ? barX + barW + 8 : barX + barW / 2;
|
|
7719
7933
|
const labelY = horizontal ? barY + barH / 2 : barY - 8;
|
|
7720
7934
|
result.push(
|
|
7721
|
-
/* @__PURE__ */ (0,
|
|
7935
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7722
7936
|
"text",
|
|
7723
7937
|
{
|
|
7724
7938
|
x: labelX,
|
|
@@ -7762,17 +7976,17 @@ var BarChart = ({
|
|
|
7762
7976
|
handleBarLeave,
|
|
7763
7977
|
handleBarClick
|
|
7764
7978
|
]);
|
|
7765
|
-
const referenceElements = (0,
|
|
7979
|
+
const referenceElements = (0, import_react33.useMemo)(() => {
|
|
7766
7980
|
if (!children) return null;
|
|
7767
7981
|
const chartDimensions = { width: chartWidth, height: chartHeight, padding };
|
|
7768
7982
|
const scales = {
|
|
7769
7983
|
xScale: (value) => xBandScale.scale(String(value)) + bandwidth / 2,
|
|
7770
7984
|
yScale
|
|
7771
7985
|
};
|
|
7772
|
-
return
|
|
7773
|
-
if (!
|
|
7986
|
+
return import_react33.default.Children.map(children, (child) => {
|
|
7987
|
+
if (!import_react33.default.isValidElement(child)) return child;
|
|
7774
7988
|
if (child.type === ReferenceLine || child.type === ReferenceArea || child.type === CartesianGrid) {
|
|
7775
|
-
return
|
|
7989
|
+
return import_react33.default.cloneElement(child, {
|
|
7776
7990
|
_chartDimensions: chartDimensions,
|
|
7777
7991
|
_scales: scales
|
|
7778
7992
|
});
|
|
@@ -7780,19 +7994,19 @@ var BarChart = ({
|
|
|
7780
7994
|
return child;
|
|
7781
7995
|
});
|
|
7782
7996
|
}, [children, chartWidth, chartHeight, padding, xBandScale, bandwidth, yScale]);
|
|
7783
|
-
const accessibleDescription = (0,
|
|
7997
|
+
const accessibleDescription = (0, import_react33.useMemo)(() => {
|
|
7784
7998
|
if (ariaLabel) return ariaLabel;
|
|
7785
7999
|
const seriesNames = data.map((s) => s.name).join(", ");
|
|
7786
8000
|
return `Bar chart with ${data.length} series: ${seriesNames}`;
|
|
7787
8001
|
}, [data, ariaLabel]);
|
|
7788
|
-
return /* @__PURE__ */ (0,
|
|
8002
|
+
return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
|
|
7789
8003
|
"div",
|
|
7790
8004
|
{
|
|
7791
8005
|
ref: containerRef,
|
|
7792
8006
|
className: `relative ${className}`,
|
|
7793
8007
|
style: containerStyle,
|
|
7794
8008
|
children: [
|
|
7795
|
-
/* @__PURE__ */ (0,
|
|
8009
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
|
|
7796
8010
|
"svg",
|
|
7797
8011
|
{
|
|
7798
8012
|
width: svgWidth,
|
|
@@ -7804,7 +8018,7 @@ var BarChart = ({
|
|
|
7804
8018
|
className: "bg-[hsl(var(--card))]",
|
|
7805
8019
|
style: svgStyle,
|
|
7806
8020
|
children: [
|
|
7807
|
-
/* @__PURE__ */ (0,
|
|
8021
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("style", { children: `
|
|
7808
8022
|
@keyframes growY {
|
|
7809
8023
|
from { transform: scaleY(0); }
|
|
7810
8024
|
to { transform: scaleY(1); }
|
|
@@ -7818,8 +8032,8 @@ var BarChart = ({
|
|
|
7818
8032
|
to { opacity: 1; }
|
|
7819
8033
|
}
|
|
7820
8034
|
` }) }),
|
|
7821
|
-
/* @__PURE__ */ (0,
|
|
7822
|
-
showGrid && /* @__PURE__ */ (0,
|
|
8035
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("g", { transform: `translate(${padding.left}, ${padding.top})`, children: [
|
|
8036
|
+
showGrid && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7823
8037
|
CartesianGrid,
|
|
7824
8038
|
{
|
|
7825
8039
|
_chartDimensions: { width: chartWidth, height: chartHeight },
|
|
@@ -7831,8 +8045,8 @@ var BarChart = ({
|
|
|
7831
8045
|
),
|
|
7832
8046
|
referenceElements,
|
|
7833
8047
|
bars,
|
|
7834
|
-
showXAxis && /* @__PURE__ */ (0,
|
|
7835
|
-
/* @__PURE__ */ (0,
|
|
8048
|
+
showXAxis && /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("g", { transform: `translate(0, ${chartHeight})`, children: [
|
|
8049
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7836
8050
|
"line",
|
|
7837
8051
|
{
|
|
7838
8052
|
x1: 0,
|
|
@@ -7844,9 +8058,9 @@ var BarChart = ({
|
|
|
7844
8058
|
),
|
|
7845
8059
|
categories.map((cat, i) => {
|
|
7846
8060
|
const x = xBandScale.scale(cat) + bandwidth / 2;
|
|
7847
|
-
return /* @__PURE__ */ (0,
|
|
7848
|
-
/* @__PURE__ */ (0,
|
|
7849
|
-
/* @__PURE__ */ (0,
|
|
8061
|
+
return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("g", { transform: `translate(${x}, 0)`, children: [
|
|
8062
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)("line", { y2: 6, className: "stroke-[hsl(var(--border))]" }),
|
|
8063
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7850
8064
|
"text",
|
|
7851
8065
|
{
|
|
7852
8066
|
y: 20,
|
|
@@ -7858,7 +8072,7 @@ var BarChart = ({
|
|
|
7858
8072
|
)
|
|
7859
8073
|
] }, `x-tick-${i}`);
|
|
7860
8074
|
}),
|
|
7861
|
-
xAxisLabel && /* @__PURE__ */ (0,
|
|
8075
|
+
xAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7862
8076
|
"text",
|
|
7863
8077
|
{
|
|
7864
8078
|
x: chartWidth / 2,
|
|
@@ -7871,8 +8085,8 @@ var BarChart = ({
|
|
|
7871
8085
|
}
|
|
7872
8086
|
)
|
|
7873
8087
|
] }),
|
|
7874
|
-
showYAxis && /* @__PURE__ */ (0,
|
|
7875
|
-
/* @__PURE__ */ (0,
|
|
8088
|
+
showYAxis && /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("g", { children: [
|
|
8089
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7876
8090
|
"line",
|
|
7877
8091
|
{
|
|
7878
8092
|
x1: 0,
|
|
@@ -7882,9 +8096,9 @@ var BarChart = ({
|
|
|
7882
8096
|
className: "stroke-[hsl(var(--border))]"
|
|
7883
8097
|
}
|
|
7884
8098
|
),
|
|
7885
|
-
yTicks.map((tick, i) => /* @__PURE__ */ (0,
|
|
7886
|
-
/* @__PURE__ */ (0,
|
|
7887
|
-
/* @__PURE__ */ (0,
|
|
8099
|
+
yTicks.map((tick, i) => /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("g", { transform: `translate(0, ${yScale(tick)})`, children: [
|
|
8100
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)("line", { x2: -6, className: "stroke-[hsl(var(--border))]" }),
|
|
8101
|
+
/* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7888
8102
|
"text",
|
|
7889
8103
|
{
|
|
7890
8104
|
x: -12,
|
|
@@ -7896,7 +8110,7 @@ var BarChart = ({
|
|
|
7896
8110
|
}
|
|
7897
8111
|
)
|
|
7898
8112
|
] }, `y-tick-${i}`)),
|
|
7899
|
-
yAxisLabel && /* @__PURE__ */ (0,
|
|
8113
|
+
yAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7900
8114
|
"text",
|
|
7901
8115
|
{
|
|
7902
8116
|
x: -chartHeight / 2,
|
|
@@ -7914,8 +8128,8 @@ var BarChart = ({
|
|
|
7914
8128
|
]
|
|
7915
8129
|
}
|
|
7916
8130
|
),
|
|
7917
|
-
showLegend && /* @__PURE__ */ (0,
|
|
7918
|
-
showTooltip && /* @__PURE__ */ (0,
|
|
8131
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(Legend, { items: legendItems, layout: "horizontal", align: "center" }),
|
|
8132
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
|
|
7919
8133
|
ChartTooltip,
|
|
7920
8134
|
{
|
|
7921
8135
|
...tooltipData,
|
|
@@ -7929,8 +8143,8 @@ var BarChart = ({
|
|
|
7929
8143
|
};
|
|
7930
8144
|
|
|
7931
8145
|
// src/charts/AreaChart.tsx
|
|
7932
|
-
var
|
|
7933
|
-
var
|
|
8146
|
+
var import_react34 = __toESM(require("react"));
|
|
8147
|
+
var import_jsx_runtime118 = require("react/jsx-runtime");
|
|
7934
8148
|
var AreaChart = ({
|
|
7935
8149
|
data,
|
|
7936
8150
|
width: providedWidth,
|
|
@@ -7965,9 +8179,9 @@ var AreaChart = ({
|
|
|
7965
8179
|
colors = CHART_DEFAULTS.colors,
|
|
7966
8180
|
ariaLabel
|
|
7967
8181
|
}) => {
|
|
7968
|
-
const containerRef = (0,
|
|
7969
|
-
const chartId = (0,
|
|
7970
|
-
const [hoveredPoint, setHoveredPoint] = (0,
|
|
8182
|
+
const containerRef = (0, import_react34.useRef)(null);
|
|
8183
|
+
const chartId = (0, import_react34.useId)();
|
|
8184
|
+
const [hoveredPoint, setHoveredPoint] = (0, import_react34.useState)(null);
|
|
7971
8185
|
const { tooltipData, showTooltip: showTooltipFn, hideTooltip } = useTooltip();
|
|
7972
8186
|
const {
|
|
7973
8187
|
width,
|
|
@@ -7985,7 +8199,7 @@ var AreaChart = ({
|
|
|
7985
8199
|
providedHeight
|
|
7986
8200
|
});
|
|
7987
8201
|
const animate = animateProp && !_isResizing && !isResponsive;
|
|
7988
|
-
const padding = (0,
|
|
8202
|
+
const padding = (0, import_react34.useMemo)(() => ({
|
|
7989
8203
|
top: customPadding?.top ?? CHART_DEFAULTS.padding.top,
|
|
7990
8204
|
right: customPadding?.right ?? CHART_DEFAULTS.padding.right,
|
|
7991
8205
|
bottom: customPadding?.bottom ?? (showXAxis ? 60 : CHART_DEFAULTS.padding.bottom),
|
|
@@ -7993,17 +8207,17 @@ var AreaChart = ({
|
|
|
7993
8207
|
}), [customPadding, showXAxis, showYAxis]);
|
|
7994
8208
|
const chartWidth = width - padding.left - padding.right;
|
|
7995
8209
|
const chartHeight = height - padding.top - padding.bottom;
|
|
7996
|
-
const allPoints = (0,
|
|
8210
|
+
const allPoints = (0, import_react34.useMemo)(
|
|
7997
8211
|
() => data.flatMap((series) => series.data),
|
|
7998
8212
|
[data]
|
|
7999
8213
|
);
|
|
8000
|
-
const xValueType = (0,
|
|
8214
|
+
const xValueType = (0, import_react34.useMemo)(() => {
|
|
8001
8215
|
const firstX = data[0]?.data[0]?.x;
|
|
8002
8216
|
if (firstX instanceof Date) return "date";
|
|
8003
8217
|
if (typeof firstX === "number") return "number";
|
|
8004
8218
|
return "string";
|
|
8005
8219
|
}, [data]);
|
|
8006
|
-
const xDomainCalc = (0,
|
|
8220
|
+
const xDomainCalc = (0, import_react34.useMemo)(() => {
|
|
8007
8221
|
if (xValueType === "date") {
|
|
8008
8222
|
const dates = allPoints.map((p) => p.x.getTime());
|
|
8009
8223
|
return [Math.min(...dates), Math.max(...dates)];
|
|
@@ -8015,7 +8229,7 @@ var AreaChart = ({
|
|
|
8015
8229
|
const maxLen = Math.max(...data.map((s) => s.data.length));
|
|
8016
8230
|
return [0, maxLen - 1];
|
|
8017
8231
|
}, [allPoints, xValueType, data]);
|
|
8018
|
-
const yDomainCalc = (0,
|
|
8232
|
+
const yDomainCalc = (0, import_react34.useMemo)(() => {
|
|
8019
8233
|
if (yDomain) return yDomain;
|
|
8020
8234
|
if (stacked) {
|
|
8021
8235
|
const maxPoints = Math.max(...data.map((s) => s.data.length));
|
|
@@ -8027,7 +8241,7 @@ var AreaChart = ({
|
|
|
8027
8241
|
const yValues = allPoints.map((p) => p.y);
|
|
8028
8242
|
return calculateDomain(yValues, { includeZero: true, padding: 0.1 });
|
|
8029
8243
|
}, [allPoints, stacked, data, yDomain]);
|
|
8030
|
-
const xScale = (0,
|
|
8244
|
+
const xScale = (0, import_react34.useMemo)(() => {
|
|
8031
8245
|
if (xValueType === "date") {
|
|
8032
8246
|
return (value) => {
|
|
8033
8247
|
const time = value instanceof Date ? value.getTime() : Number(value);
|
|
@@ -8050,18 +8264,18 @@ var AreaChart = ({
|
|
|
8050
8264
|
return index / maxLen * chartWidth;
|
|
8051
8265
|
};
|
|
8052
8266
|
}, [xValueType, xDomainCalc, chartWidth, data]);
|
|
8053
|
-
const yScale = (0,
|
|
8267
|
+
const yScale = (0, import_react34.useMemo)(
|
|
8054
8268
|
() => scaleLinear({
|
|
8055
8269
|
domain: yDomainCalc,
|
|
8056
8270
|
range: [chartHeight, 0]
|
|
8057
8271
|
}),
|
|
8058
8272
|
[yDomainCalc, chartHeight]
|
|
8059
8273
|
);
|
|
8060
|
-
const yTicks = (0,
|
|
8274
|
+
const yTicks = (0, import_react34.useMemo)(
|
|
8061
8275
|
() => getTicks(yDomainCalc, yAxisTickCount),
|
|
8062
8276
|
[yDomainCalc, yAxisTickCount]
|
|
8063
8277
|
);
|
|
8064
|
-
const xTicks = (0,
|
|
8278
|
+
const xTicks = (0, import_react34.useMemo)(() => {
|
|
8065
8279
|
if (xValueType === "string") {
|
|
8066
8280
|
return data[0]?.data.map((p, i) => ({ value: p.x, index: i })) || [];
|
|
8067
8281
|
}
|
|
@@ -8069,7 +8283,7 @@ var AreaChart = ({
|
|
|
8069
8283
|
const ticks = getTicks(xDomainCalc, tickCount);
|
|
8070
8284
|
return ticks.map((t) => ({ value: t, index: 0 }));
|
|
8071
8285
|
}, [xValueType, xDomainCalc, data]);
|
|
8072
|
-
const xFormatter = (0,
|
|
8286
|
+
const xFormatter = (0, import_react34.useCallback)((value) => {
|
|
8073
8287
|
if (formatXValue) return formatXValue(value);
|
|
8074
8288
|
if (value instanceof Date) {
|
|
8075
8289
|
const range = xDomainCalc[1] - xDomainCalc[0];
|
|
@@ -8077,11 +8291,11 @@ var AreaChart = ({
|
|
|
8077
8291
|
}
|
|
8078
8292
|
return String(value);
|
|
8079
8293
|
}, [formatXValue, xDomainCalc]);
|
|
8080
|
-
const yFormatter = (0,
|
|
8294
|
+
const yFormatter = (0, import_react34.useMemo)(() => {
|
|
8081
8295
|
if (formatYValue) return formatYValue;
|
|
8082
8296
|
return createTickFormatter(yDomainCalc);
|
|
8083
8297
|
}, [formatYValue, yDomainCalc]);
|
|
8084
|
-
const areaPaths = (0,
|
|
8298
|
+
const areaPaths = (0, import_react34.useMemo)(() => {
|
|
8085
8299
|
const paths = [];
|
|
8086
8300
|
const cumulativeY = Array(data[0]?.data.length || 0).fill(0);
|
|
8087
8301
|
data.forEach((series) => {
|
|
@@ -8115,7 +8329,7 @@ var AreaChart = ({
|
|
|
8115
8329
|
});
|
|
8116
8330
|
return paths;
|
|
8117
8331
|
}, [data, xScale, yScale, stacked, curved]);
|
|
8118
|
-
const handlePointEnter = (0,
|
|
8332
|
+
const handlePointEnter = (0, import_react34.useCallback)((e, seriesIndex, pointIndex) => {
|
|
8119
8333
|
const series = data[seriesIndex];
|
|
8120
8334
|
const point = series.data[pointIndex];
|
|
8121
8335
|
setHoveredPoint({ seriesIndex, pointIndex });
|
|
@@ -8138,16 +8352,16 @@ var AreaChart = ({
|
|
|
8138
8352
|
}
|
|
8139
8353
|
onPointHover?.(point, seriesIndex, pointIndex);
|
|
8140
8354
|
}, [data, showTooltip, colors, xFormatter, showTooltipFn, onPointHover]);
|
|
8141
|
-
const handlePointLeave = (0,
|
|
8355
|
+
const handlePointLeave = (0, import_react34.useCallback)(() => {
|
|
8142
8356
|
setHoveredPoint(null);
|
|
8143
8357
|
hideTooltip();
|
|
8144
8358
|
onPointHover?.(null, -1, -1);
|
|
8145
8359
|
}, [hideTooltip, onPointHover]);
|
|
8146
|
-
const handlePointClick = (0,
|
|
8360
|
+
const handlePointClick = (0, import_react34.useCallback)((seriesIndex, pointIndex) => {
|
|
8147
8361
|
const point = data[seriesIndex].data[pointIndex];
|
|
8148
8362
|
onPointClick?.(point, seriesIndex, pointIndex);
|
|
8149
8363
|
}, [data, onPointClick]);
|
|
8150
|
-
const legendItems = (0,
|
|
8364
|
+
const legendItems = (0, import_react34.useMemo)(
|
|
8151
8365
|
() => data.map((series, i) => ({
|
|
8152
8366
|
name: series.name,
|
|
8153
8367
|
color: series.color || colors[i % colors.length],
|
|
@@ -8155,7 +8369,7 @@ var AreaChart = ({
|
|
|
8155
8369
|
})),
|
|
8156
8370
|
[data, colors]
|
|
8157
8371
|
);
|
|
8158
|
-
const referenceElements = (0,
|
|
8372
|
+
const referenceElements = (0, import_react34.useMemo)(() => {
|
|
8159
8373
|
if (!children) return null;
|
|
8160
8374
|
const chartDimensions = { width: chartWidth, height: chartHeight, padding };
|
|
8161
8375
|
const scales = {
|
|
@@ -8168,10 +8382,10 @@ var AreaChart = ({
|
|
|
8168
8382
|
},
|
|
8169
8383
|
yScale
|
|
8170
8384
|
};
|
|
8171
|
-
return
|
|
8172
|
-
if (!
|
|
8385
|
+
return import_react34.default.Children.map(children, (child) => {
|
|
8386
|
+
if (!import_react34.default.isValidElement(child)) return child;
|
|
8173
8387
|
if (child.type === ReferenceLine || child.type === ReferenceArea || child.type === CartesianGrid) {
|
|
8174
|
-
return
|
|
8388
|
+
return import_react34.default.cloneElement(child, {
|
|
8175
8389
|
_chartDimensions: chartDimensions,
|
|
8176
8390
|
_scales: scales
|
|
8177
8391
|
});
|
|
@@ -8179,19 +8393,19 @@ var AreaChart = ({
|
|
|
8179
8393
|
return child;
|
|
8180
8394
|
});
|
|
8181
8395
|
}, [children, chartWidth, chartHeight, padding, xScale, yScale, xValueType, data]);
|
|
8182
|
-
const accessibleDescription = (0,
|
|
8396
|
+
const accessibleDescription = (0, import_react34.useMemo)(() => {
|
|
8183
8397
|
if (ariaLabel) return ariaLabel;
|
|
8184
8398
|
const seriesNames = data.map((s) => s.name).join(", ");
|
|
8185
8399
|
return `Area chart with ${data.length} series: ${seriesNames}`;
|
|
8186
8400
|
}, [data, ariaLabel]);
|
|
8187
|
-
return /* @__PURE__ */ (0,
|
|
8401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
|
|
8188
8402
|
"div",
|
|
8189
8403
|
{
|
|
8190
8404
|
ref: containerRef,
|
|
8191
8405
|
className: `relative ${className}`,
|
|
8192
8406
|
style: containerStyle,
|
|
8193
8407
|
children: [
|
|
8194
|
-
/* @__PURE__ */ (0,
|
|
8408
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
|
|
8195
8409
|
"svg",
|
|
8196
8410
|
{
|
|
8197
8411
|
width: svgWidth,
|
|
@@ -8203,10 +8417,10 @@ var AreaChart = ({
|
|
|
8203
8417
|
className: "bg-[hsl(var(--card))]",
|
|
8204
8418
|
style: svgStyle,
|
|
8205
8419
|
children: [
|
|
8206
|
-
/* @__PURE__ */ (0,
|
|
8420
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("defs", { children: [
|
|
8207
8421
|
data.map((series, i) => {
|
|
8208
8422
|
const color = series.color || colors[i % colors.length];
|
|
8209
|
-
return /* @__PURE__ */ (0,
|
|
8423
|
+
return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(
|
|
8210
8424
|
"linearGradient",
|
|
8211
8425
|
{
|
|
8212
8426
|
id: `area-gradient-${chartId}-${i}`,
|
|
@@ -8215,14 +8429,14 @@ var AreaChart = ({
|
|
|
8215
8429
|
x2: "0",
|
|
8216
8430
|
y2: "1",
|
|
8217
8431
|
children: [
|
|
8218
|
-
/* @__PURE__ */ (0,
|
|
8219
|
-
/* @__PURE__ */ (0,
|
|
8432
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: series.fillOpacity ?? fillOpacity }),
|
|
8433
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.05 })
|
|
8220
8434
|
]
|
|
8221
8435
|
},
|
|
8222
8436
|
`gradient-${i}`
|
|
8223
8437
|
);
|
|
8224
8438
|
}),
|
|
8225
|
-
/* @__PURE__ */ (0,
|
|
8439
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)("style", { children: `
|
|
8226
8440
|
@keyframes fadeIn {
|
|
8227
8441
|
from { opacity: 0; }
|
|
8228
8442
|
to { opacity: 1; }
|
|
@@ -8233,8 +8447,8 @@ var AreaChart = ({
|
|
|
8233
8447
|
}
|
|
8234
8448
|
` })
|
|
8235
8449
|
] }),
|
|
8236
|
-
/* @__PURE__ */ (0,
|
|
8237
|
-
showGrid && /* @__PURE__ */ (0,
|
|
8450
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("g", { transform: `translate(${padding.left}, ${padding.top})`, children: [
|
|
8451
|
+
showGrid && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8238
8452
|
CartesianGrid,
|
|
8239
8453
|
{
|
|
8240
8454
|
_chartDimensions: { width: chartWidth, height: chartHeight },
|
|
@@ -8247,8 +8461,8 @@ var AreaChart = ({
|
|
|
8247
8461
|
const { areaPath, linePath } = areaPaths[seriesIndex];
|
|
8248
8462
|
const color = series.color || colors[seriesIndex % colors.length];
|
|
8249
8463
|
const strokeWidth = series.strokeWidth || CHART_DEFAULTS.line.strokeWidth;
|
|
8250
|
-
return /* @__PURE__ */ (0,
|
|
8251
|
-
/* @__PURE__ */ (0,
|
|
8464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("g", { children: [
|
|
8465
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8252
8466
|
"path",
|
|
8253
8467
|
{
|
|
8254
8468
|
d: areaPath,
|
|
@@ -8259,7 +8473,7 @@ var AreaChart = ({
|
|
|
8259
8473
|
} : void 0
|
|
8260
8474
|
}
|
|
8261
8475
|
),
|
|
8262
|
-
/* @__PURE__ */ (0,
|
|
8476
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8263
8477
|
"path",
|
|
8264
8478
|
{
|
|
8265
8479
|
d: linePath,
|
|
@@ -8283,7 +8497,7 @@ var AreaChart = ({
|
|
|
8283
8497
|
if (!showSeriesDots) return null;
|
|
8284
8498
|
return points.map((point, pointIndex) => {
|
|
8285
8499
|
const isHovered = hoveredPoint?.seriesIndex === seriesIndex && hoveredPoint?.pointIndex === pointIndex;
|
|
8286
|
-
return /* @__PURE__ */ (0,
|
|
8500
|
+
return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8287
8501
|
"circle",
|
|
8288
8502
|
{
|
|
8289
8503
|
cx: point.x,
|
|
@@ -8305,8 +8519,8 @@ var AreaChart = ({
|
|
|
8305
8519
|
);
|
|
8306
8520
|
});
|
|
8307
8521
|
}),
|
|
8308
|
-
showXAxis && /* @__PURE__ */ (0,
|
|
8309
|
-
/* @__PURE__ */ (0,
|
|
8522
|
+
showXAxis && /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("g", { transform: `translate(0, ${chartHeight})`, children: [
|
|
8523
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8310
8524
|
"line",
|
|
8311
8525
|
{
|
|
8312
8526
|
x1: 0,
|
|
@@ -8318,9 +8532,9 @@ var AreaChart = ({
|
|
|
8318
8532
|
),
|
|
8319
8533
|
xTicks.map((tick, i) => {
|
|
8320
8534
|
const x = xValueType === "string" ? xScale(tick.value, tick.index) : xScale(xValueType === "date" ? new Date(tick.value) : tick.value, 0);
|
|
8321
|
-
return /* @__PURE__ */ (0,
|
|
8322
|
-
/* @__PURE__ */ (0,
|
|
8323
|
-
/* @__PURE__ */ (0,
|
|
8535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("g", { transform: `translate(${x}, 0)`, children: [
|
|
8536
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)("line", { y2: 6, className: "stroke-[hsl(var(--border))]" }),
|
|
8537
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8324
8538
|
"text",
|
|
8325
8539
|
{
|
|
8326
8540
|
y: 20,
|
|
@@ -8332,7 +8546,7 @@ var AreaChart = ({
|
|
|
8332
8546
|
)
|
|
8333
8547
|
] }, `x-tick-${i}`);
|
|
8334
8548
|
}),
|
|
8335
|
-
xAxisLabel && /* @__PURE__ */ (0,
|
|
8549
|
+
xAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8336
8550
|
"text",
|
|
8337
8551
|
{
|
|
8338
8552
|
x: chartWidth / 2,
|
|
@@ -8345,8 +8559,8 @@ var AreaChart = ({
|
|
|
8345
8559
|
}
|
|
8346
8560
|
)
|
|
8347
8561
|
] }),
|
|
8348
|
-
showYAxis && /* @__PURE__ */ (0,
|
|
8349
|
-
/* @__PURE__ */ (0,
|
|
8562
|
+
showYAxis && /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("g", { children: [
|
|
8563
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8350
8564
|
"line",
|
|
8351
8565
|
{
|
|
8352
8566
|
x1: 0,
|
|
@@ -8356,9 +8570,9 @@ var AreaChart = ({
|
|
|
8356
8570
|
className: "stroke-[hsl(var(--border))]"
|
|
8357
8571
|
}
|
|
8358
8572
|
),
|
|
8359
|
-
yTicks.map((tick, i) => /* @__PURE__ */ (0,
|
|
8360
|
-
/* @__PURE__ */ (0,
|
|
8361
|
-
/* @__PURE__ */ (0,
|
|
8573
|
+
yTicks.map((tick, i) => /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("g", { transform: `translate(0, ${yScale(tick)})`, children: [
|
|
8574
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)("line", { x2: -6, className: "stroke-[hsl(var(--border))]" }),
|
|
8575
|
+
/* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8362
8576
|
"text",
|
|
8363
8577
|
{
|
|
8364
8578
|
x: -12,
|
|
@@ -8370,7 +8584,7 @@ var AreaChart = ({
|
|
|
8370
8584
|
}
|
|
8371
8585
|
)
|
|
8372
8586
|
] }, `y-tick-${i}`)),
|
|
8373
|
-
yAxisLabel && /* @__PURE__ */ (0,
|
|
8587
|
+
yAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8374
8588
|
"text",
|
|
8375
8589
|
{
|
|
8376
8590
|
x: -chartHeight / 2,
|
|
@@ -8388,8 +8602,8 @@ var AreaChart = ({
|
|
|
8388
8602
|
]
|
|
8389
8603
|
}
|
|
8390
8604
|
),
|
|
8391
|
-
showLegend && /* @__PURE__ */ (0,
|
|
8392
|
-
showTooltip && /* @__PURE__ */ (0,
|
|
8605
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(Legend, { items: legendItems, layout: "horizontal", align: "center" }),
|
|
8606
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
|
|
8393
8607
|
ChartTooltip,
|
|
8394
8608
|
{
|
|
8395
8609
|
...tooltipData,
|
|
@@ -8403,8 +8617,8 @@ var AreaChart = ({
|
|
|
8403
8617
|
};
|
|
8404
8618
|
|
|
8405
8619
|
// src/charts/PieChart.tsx
|
|
8406
|
-
var
|
|
8407
|
-
var
|
|
8620
|
+
var import_react35 = require("react");
|
|
8621
|
+
var import_jsx_runtime119 = require("react/jsx-runtime");
|
|
8408
8622
|
var PieChart = ({
|
|
8409
8623
|
data,
|
|
8410
8624
|
width: providedWidth,
|
|
@@ -8437,9 +8651,9 @@ var PieChart = ({
|
|
|
8437
8651
|
colors = CHART_DEFAULTS.colors,
|
|
8438
8652
|
ariaLabel
|
|
8439
8653
|
}) => {
|
|
8440
|
-
const containerRef = (0,
|
|
8441
|
-
const [hoveredSlice, setHoveredSlice] = (0,
|
|
8442
|
-
const [activeSlice, setActiveSlice] = (0,
|
|
8654
|
+
const containerRef = (0, import_react35.useRef)(null);
|
|
8655
|
+
const [hoveredSlice, setHoveredSlice] = (0, import_react35.useState)(null);
|
|
8656
|
+
const [activeSlice, setActiveSlice] = (0, import_react35.useState)(null);
|
|
8443
8657
|
const { tooltipData, showTooltip: showTooltipFn, hideTooltip } = useTooltip();
|
|
8444
8658
|
const {
|
|
8445
8659
|
width,
|
|
@@ -8466,11 +8680,11 @@ var PieChart = ({
|
|
|
8466
8680
|
const outerRadius = providedOuterRadius || maxRadius;
|
|
8467
8681
|
const innerRadius = providedInnerRadius ?? (donut ? outerRadius * 0.6 : 0);
|
|
8468
8682
|
const isDonut = innerRadius > 0;
|
|
8469
|
-
const total = (0,
|
|
8683
|
+
const total = (0, import_react35.useMemo)(
|
|
8470
8684
|
() => data.reduce((sum, d) => sum + d.value, 0),
|
|
8471
8685
|
[data]
|
|
8472
8686
|
);
|
|
8473
|
-
const slices = (0,
|
|
8687
|
+
const slices = (0, import_react35.useMemo)(() => {
|
|
8474
8688
|
const angleRange = endAngle - startAngle;
|
|
8475
8689
|
let currentAngle = startAngle;
|
|
8476
8690
|
return data.map((item, index) => {
|
|
@@ -8506,7 +8720,7 @@ var PieChart = ({
|
|
|
8506
8720
|
};
|
|
8507
8721
|
});
|
|
8508
8722
|
}, [data, total, startAngle, endAngle, paddingAngle, centerX, centerY, outerRadius, innerRadius, isDonut, colors]);
|
|
8509
|
-
const handleSliceEnter = (0,
|
|
8723
|
+
const handleSliceEnter = (0, import_react35.useCallback)((e, index) => {
|
|
8510
8724
|
const slice = slices[index];
|
|
8511
8725
|
setHoveredSlice(index);
|
|
8512
8726
|
if (showTooltip && containerRef.current) {
|
|
@@ -8528,16 +8742,16 @@ var PieChart = ({
|
|
|
8528
8742
|
}
|
|
8529
8743
|
onSliceHover?.(data[index], index);
|
|
8530
8744
|
}, [slices, data, showTooltip, showTooltipFn, onSliceHover]);
|
|
8531
|
-
const handleSliceLeave = (0,
|
|
8745
|
+
const handleSliceLeave = (0, import_react35.useCallback)(() => {
|
|
8532
8746
|
setHoveredSlice(null);
|
|
8533
8747
|
hideTooltip();
|
|
8534
8748
|
onSliceHover?.(null, -1);
|
|
8535
8749
|
}, [hideTooltip, onSliceHover]);
|
|
8536
|
-
const handleSliceClick = (0,
|
|
8750
|
+
const handleSliceClick = (0, import_react35.useCallback)((index) => {
|
|
8537
8751
|
setActiveSlice((prev) => prev === index ? null : index);
|
|
8538
8752
|
onSliceClick?.(data[index], index);
|
|
8539
8753
|
}, [data, onSliceClick]);
|
|
8540
|
-
const getLabelText = (0,
|
|
8754
|
+
const getLabelText = (0, import_react35.useCallback)((slice) => {
|
|
8541
8755
|
if (labelFormatter) {
|
|
8542
8756
|
return labelFormatter(data[slice.index], slice.percent);
|
|
8543
8757
|
}
|
|
@@ -8552,7 +8766,7 @@ var PieChart = ({
|
|
|
8552
8766
|
return `${slice.percent.toFixed(1)}%`;
|
|
8553
8767
|
}
|
|
8554
8768
|
}, [labelType, labelFormatter, data]);
|
|
8555
|
-
const legendItems = (0,
|
|
8769
|
+
const legendItems = (0, import_react35.useMemo)(
|
|
8556
8770
|
() => data.map((item, i) => ({
|
|
8557
8771
|
name: `${item.label}${showPercentages ? ` (${(item.value / total * 100).toFixed(1)}%)` : ""}`,
|
|
8558
8772
|
color: item.color || colors[i % colors.length],
|
|
@@ -8560,19 +8774,19 @@ var PieChart = ({
|
|
|
8560
8774
|
})),
|
|
8561
8775
|
[data, colors, total, showPercentages]
|
|
8562
8776
|
);
|
|
8563
|
-
const accessibleDescription = (0,
|
|
8777
|
+
const accessibleDescription = (0, import_react35.useMemo)(() => {
|
|
8564
8778
|
if (ariaLabel) return ariaLabel;
|
|
8565
8779
|
const sliceNames = data.map((d) => `${d.label}: ${d.value}`).join(", ");
|
|
8566
8780
|
return `${isDonut ? "Donut" : "Pie"} chart with ${data.length} slices: ${sliceNames}`;
|
|
8567
8781
|
}, [data, isDonut, ariaLabel]);
|
|
8568
|
-
return /* @__PURE__ */ (0,
|
|
8782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(
|
|
8569
8783
|
"div",
|
|
8570
8784
|
{
|
|
8571
8785
|
ref: containerRef,
|
|
8572
8786
|
className: `relative inline-flex flex-col items-center ${className}`,
|
|
8573
8787
|
style: containerStyle,
|
|
8574
8788
|
children: [
|
|
8575
|
-
/* @__PURE__ */ (0,
|
|
8789
|
+
/* @__PURE__ */ (0, import_jsx_runtime119.jsxs)(
|
|
8576
8790
|
"svg",
|
|
8577
8791
|
{
|
|
8578
8792
|
width: svgWidth,
|
|
@@ -8584,7 +8798,7 @@ var PieChart = ({
|
|
|
8584
8798
|
className: "bg-[hsl(var(--card))]",
|
|
8585
8799
|
style: svgStyle,
|
|
8586
8800
|
children: [
|
|
8587
|
-
/* @__PURE__ */ (0,
|
|
8801
|
+
/* @__PURE__ */ (0, import_jsx_runtime119.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime119.jsx)("style", { children: `
|
|
8588
8802
|
@keyframes rotateIn {
|
|
8589
8803
|
from {
|
|
8590
8804
|
transform: rotate(-90deg);
|
|
@@ -8600,7 +8814,7 @@ var PieChart = ({
|
|
|
8600
8814
|
to { opacity: 1; }
|
|
8601
8815
|
}
|
|
8602
8816
|
` }) }),
|
|
8603
|
-
/* @__PURE__ */ (0,
|
|
8817
|
+
/* @__PURE__ */ (0, import_jsx_runtime119.jsx)("g", { style: animate ? {
|
|
8604
8818
|
transformOrigin: `${centerX}px ${centerY}px`,
|
|
8605
8819
|
animation: `rotateIn ${animationDuration}ms ease-out forwards`
|
|
8606
8820
|
} : void 0, children: slices.map((slice) => {
|
|
@@ -8608,8 +8822,8 @@ var PieChart = ({
|
|
|
8608
8822
|
const isActive = activeSlice === slice.index;
|
|
8609
8823
|
const scale = isHovered || isActive ? 1.03 : 1;
|
|
8610
8824
|
const transform = `translate(${centerX}px, ${centerY}px) scale(${scale}) translate(${-centerX}px, ${-centerY}px)`;
|
|
8611
|
-
return /* @__PURE__ */ (0,
|
|
8612
|
-
/* @__PURE__ */ (0,
|
|
8825
|
+
return /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)("g", { children: [
|
|
8826
|
+
/* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
8613
8827
|
"path",
|
|
8614
8828
|
{
|
|
8615
8829
|
d: slice.path,
|
|
@@ -8623,7 +8837,7 @@ var PieChart = ({
|
|
|
8623
8837
|
onClick: () => handleSliceClick(slice.index)
|
|
8624
8838
|
}
|
|
8625
8839
|
),
|
|
8626
|
-
showLabels && slice.percent >= minLabelPercent && /* @__PURE__ */ (0,
|
|
8840
|
+
showLabels && slice.percent >= minLabelPercent && /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
8627
8841
|
"text",
|
|
8628
8842
|
{
|
|
8629
8843
|
x: slice.labelX,
|
|
@@ -8642,8 +8856,8 @@ var PieChart = ({
|
|
|
8642
8856
|
)
|
|
8643
8857
|
] }, slice.index);
|
|
8644
8858
|
}) }),
|
|
8645
|
-
isDonut && (centerLabel || centerValue !== void 0) && /* @__PURE__ */ (0,
|
|
8646
|
-
centerValue !== void 0 && /* @__PURE__ */ (0,
|
|
8859
|
+
isDonut && (centerLabel || centerValue !== void 0) && /* @__PURE__ */ (0, import_jsx_runtime119.jsxs)("g", { children: [
|
|
8860
|
+
centerValue !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
8647
8861
|
"text",
|
|
8648
8862
|
{
|
|
8649
8863
|
x: centerX,
|
|
@@ -8656,7 +8870,7 @@ var PieChart = ({
|
|
|
8656
8870
|
children: typeof centerValue === "number" ? formatNumber(centerValue) : centerValue
|
|
8657
8871
|
}
|
|
8658
8872
|
),
|
|
8659
|
-
centerLabel && (typeof centerLabel === "string" ? /* @__PURE__ */ (0,
|
|
8873
|
+
centerLabel && (typeof centerLabel === "string" ? /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
8660
8874
|
"text",
|
|
8661
8875
|
{
|
|
8662
8876
|
x: centerX,
|
|
@@ -8667,7 +8881,7 @@ var PieChart = ({
|
|
|
8667
8881
|
className: "fill-[hsl(var(--muted-foreground))]",
|
|
8668
8882
|
children: centerLabel
|
|
8669
8883
|
}
|
|
8670
|
-
) : /* @__PURE__ */ (0,
|
|
8884
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
8671
8885
|
"foreignObject",
|
|
8672
8886
|
{
|
|
8673
8887
|
x: centerX - innerRadius * 0.7,
|
|
@@ -8681,7 +8895,7 @@ var PieChart = ({
|
|
|
8681
8895
|
]
|
|
8682
8896
|
}
|
|
8683
8897
|
),
|
|
8684
|
-
showLegend && /* @__PURE__ */ (0,
|
|
8898
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
8685
8899
|
Legend,
|
|
8686
8900
|
{
|
|
8687
8901
|
items: legendItems,
|
|
@@ -8692,7 +8906,7 @@ var PieChart = ({
|
|
|
8692
8906
|
onMouseLeave: () => setHoveredSlice(null)
|
|
8693
8907
|
}
|
|
8694
8908
|
),
|
|
8695
|
-
showTooltip && /* @__PURE__ */ (0,
|
|
8909
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
|
|
8696
8910
|
ChartTooltip,
|
|
8697
8911
|
{
|
|
8698
8912
|
...tooltipData,
|
|
@@ -8706,8 +8920,8 @@ var PieChart = ({
|
|
|
8706
8920
|
};
|
|
8707
8921
|
|
|
8708
8922
|
// src/charts/ScatterChart.tsx
|
|
8709
|
-
var
|
|
8710
|
-
var
|
|
8923
|
+
var import_react36 = __toESM(require("react"));
|
|
8924
|
+
var import_jsx_runtime120 = require("react/jsx-runtime");
|
|
8711
8925
|
function linearRegression(points) {
|
|
8712
8926
|
const n = points.length;
|
|
8713
8927
|
if (n === 0) return { slope: 0, intercept: 0 };
|
|
@@ -8728,7 +8942,7 @@ var renderShape = (shape, x, y, size, color, commonProps) => {
|
|
|
8728
8942
|
const { className, stroke, strokeWidth, onMouseEnter, onMouseLeave, onClick } = commonProps;
|
|
8729
8943
|
switch (shape) {
|
|
8730
8944
|
case "square":
|
|
8731
|
-
return /* @__PURE__ */ (0,
|
|
8945
|
+
return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
8732
8946
|
"rect",
|
|
8733
8947
|
{
|
|
8734
8948
|
x: x - size / 2,
|
|
@@ -8747,7 +8961,7 @@ var renderShape = (shape, x, y, size, color, commonProps) => {
|
|
|
8747
8961
|
case "triangle": {
|
|
8748
8962
|
const h = size * 0.866;
|
|
8749
8963
|
const points = `${x},${y - h / 2} ${x - size / 2},${y + h / 2} ${x + size / 2},${y + h / 2}`;
|
|
8750
|
-
return /* @__PURE__ */ (0,
|
|
8964
|
+
return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
8751
8965
|
"polygon",
|
|
8752
8966
|
{
|
|
8753
8967
|
points,
|
|
@@ -8764,7 +8978,7 @@ var renderShape = (shape, x, y, size, color, commonProps) => {
|
|
|
8764
8978
|
case "diamond": {
|
|
8765
8979
|
const d = size / 1.414;
|
|
8766
8980
|
const diamondPoints = `${x},${y - d} ${x + d},${y} ${x},${y + d} ${x - d},${y}`;
|
|
8767
|
-
return /* @__PURE__ */ (0,
|
|
8981
|
+
return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
8768
8982
|
"polygon",
|
|
8769
8983
|
{
|
|
8770
8984
|
points: diamondPoints,
|
|
@@ -8780,7 +8994,7 @@ var renderShape = (shape, x, y, size, color, commonProps) => {
|
|
|
8780
8994
|
}
|
|
8781
8995
|
case "circle":
|
|
8782
8996
|
default:
|
|
8783
|
-
return /* @__PURE__ */ (0,
|
|
8997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
8784
8998
|
"circle",
|
|
8785
8999
|
{
|
|
8786
9000
|
cx: x,
|
|
@@ -8834,8 +9048,8 @@ var ScatterChart = ({
|
|
|
8834
9048
|
colors = CHART_DEFAULTS.colors,
|
|
8835
9049
|
ariaLabel
|
|
8836
9050
|
}) => {
|
|
8837
|
-
const containerRef = (0,
|
|
8838
|
-
const [hoveredPoint, setHoveredPoint] = (0,
|
|
9051
|
+
const containerRef = (0, import_react36.useRef)(null);
|
|
9052
|
+
const [hoveredPoint, setHoveredPoint] = (0, import_react36.useState)(null);
|
|
8839
9053
|
const { tooltipData, showTooltip: showTooltipFn, hideTooltip } = useTooltip();
|
|
8840
9054
|
const {
|
|
8841
9055
|
width,
|
|
@@ -8853,7 +9067,7 @@ var ScatterChart = ({
|
|
|
8853
9067
|
providedHeight
|
|
8854
9068
|
});
|
|
8855
9069
|
const animate = animateProp && !_isResizing && !isResponsive;
|
|
8856
|
-
const padding = (0,
|
|
9070
|
+
const padding = (0, import_react36.useMemo)(() => ({
|
|
8857
9071
|
top: customPadding?.top ?? CHART_DEFAULTS.padding.top,
|
|
8858
9072
|
right: customPadding?.right ?? CHART_DEFAULTS.padding.right,
|
|
8859
9073
|
bottom: customPadding?.bottom ?? (showXAxis ? 60 : CHART_DEFAULTS.padding.bottom),
|
|
@@ -8861,52 +9075,52 @@ var ScatterChart = ({
|
|
|
8861
9075
|
}), [customPadding, showXAxis, showYAxis]);
|
|
8862
9076
|
const chartWidth = width - padding.left - padding.right;
|
|
8863
9077
|
const chartHeight = height - padding.top - padding.bottom;
|
|
8864
|
-
const allPoints = (0,
|
|
9078
|
+
const allPoints = (0, import_react36.useMemo)(
|
|
8865
9079
|
() => data.flatMap((series) => series.data),
|
|
8866
9080
|
[data]
|
|
8867
9081
|
);
|
|
8868
|
-
const xDomainCalc = (0,
|
|
9082
|
+
const xDomainCalc = (0, import_react36.useMemo)(() => {
|
|
8869
9083
|
if (xDomain) return xDomain;
|
|
8870
9084
|
const xValues = allPoints.map((p) => p.x);
|
|
8871
9085
|
return calculateDomain(xValues, { includeZero: false, padding: 0.1 });
|
|
8872
9086
|
}, [allPoints, xDomain]);
|
|
8873
|
-
const yDomainCalc = (0,
|
|
9087
|
+
const yDomainCalc = (0, import_react36.useMemo)(() => {
|
|
8874
9088
|
if (yDomain) return yDomain;
|
|
8875
9089
|
const yValues = allPoints.map((p) => p.y);
|
|
8876
9090
|
return calculateDomain(yValues, { includeZero: false, padding: 0.1 });
|
|
8877
9091
|
}, [allPoints, yDomain]);
|
|
8878
|
-
const zDomain = (0,
|
|
9092
|
+
const zDomain = (0, import_react36.useMemo)(() => {
|
|
8879
9093
|
if (!bubble) return [0, 1];
|
|
8880
9094
|
const zValues = allPoints.map((p) => p.z || 0).filter((z) => z > 0);
|
|
8881
9095
|
if (zValues.length === 0) return [0, 1];
|
|
8882
9096
|
return [Math.min(...zValues), Math.max(...zValues)];
|
|
8883
9097
|
}, [allPoints, bubble]);
|
|
8884
|
-
const xScale = (0,
|
|
9098
|
+
const xScale = (0, import_react36.useMemo)(
|
|
8885
9099
|
() => scaleLinear({
|
|
8886
9100
|
domain: xDomainCalc,
|
|
8887
9101
|
range: [0, chartWidth]
|
|
8888
9102
|
}),
|
|
8889
9103
|
[xDomainCalc, chartWidth]
|
|
8890
9104
|
);
|
|
8891
|
-
const yScale = (0,
|
|
9105
|
+
const yScale = (0, import_react36.useMemo)(
|
|
8892
9106
|
() => scaleLinear({
|
|
8893
9107
|
domain: yDomainCalc,
|
|
8894
9108
|
range: [chartHeight, 0]
|
|
8895
9109
|
}),
|
|
8896
9110
|
[yDomainCalc, chartHeight]
|
|
8897
9111
|
);
|
|
8898
|
-
const sizeScale = (0,
|
|
9112
|
+
const sizeScale = (0, import_react36.useMemo)(() => {
|
|
8899
9113
|
if (!bubble) return () => pointSize;
|
|
8900
9114
|
return scaleLinear({
|
|
8901
9115
|
domain: zDomain,
|
|
8902
9116
|
range: [minBubbleSize, maxBubbleSize]
|
|
8903
9117
|
});
|
|
8904
9118
|
}, [bubble, zDomain, minBubbleSize, maxBubbleSize, pointSize]);
|
|
8905
|
-
const xTicks = (0,
|
|
8906
|
-
const yTicks = (0,
|
|
8907
|
-
const xFormatter = (0,
|
|
8908
|
-
const yFormatter = (0,
|
|
8909
|
-
const trendLines = (0,
|
|
9119
|
+
const xTicks = (0, import_react36.useMemo)(() => getTicks(xDomainCalc, xAxisTickCount), [xDomainCalc, xAxisTickCount]);
|
|
9120
|
+
const yTicks = (0, import_react36.useMemo)(() => getTicks(yDomainCalc, yAxisTickCount), [yDomainCalc, yAxisTickCount]);
|
|
9121
|
+
const xFormatter = (0, import_react36.useMemo)(() => formatXValue || createTickFormatter(xDomainCalc), [formatXValue, xDomainCalc]);
|
|
9122
|
+
const yFormatter = (0, import_react36.useMemo)(() => formatYValue || createTickFormatter(yDomainCalc), [formatYValue, yDomainCalc]);
|
|
9123
|
+
const trendLines = (0, import_react36.useMemo)(() => {
|
|
8910
9124
|
if (!showTrendLine) return [];
|
|
8911
9125
|
return data.map((series) => {
|
|
8912
9126
|
const regression = linearRegression(series.data);
|
|
@@ -8922,7 +9136,7 @@ var ScatterChart = ({
|
|
|
8922
9136
|
};
|
|
8923
9137
|
});
|
|
8924
9138
|
}, [data, showTrendLine, xDomainCalc, xScale, yScale]);
|
|
8925
|
-
const handlePointEnter = (0,
|
|
9139
|
+
const handlePointEnter = (0, import_react36.useCallback)((e, seriesIndex, pointIndex) => {
|
|
8926
9140
|
const series = data[seriesIndex];
|
|
8927
9141
|
const point = series.data[pointIndex];
|
|
8928
9142
|
setHoveredPoint({ seriesIndex, pointIndex });
|
|
@@ -8946,16 +9160,16 @@ var ScatterChart = ({
|
|
|
8946
9160
|
}
|
|
8947
9161
|
onPointHover?.(point, seriesIndex, pointIndex);
|
|
8948
9162
|
}, [data, showTooltip, colors, bubble, showTooltipFn, onPointHover]);
|
|
8949
|
-
const handlePointLeave = (0,
|
|
9163
|
+
const handlePointLeave = (0, import_react36.useCallback)(() => {
|
|
8950
9164
|
setHoveredPoint(null);
|
|
8951
9165
|
hideTooltip();
|
|
8952
9166
|
onPointHover?.(null, -1, -1);
|
|
8953
9167
|
}, [hideTooltip, onPointHover]);
|
|
8954
|
-
const handlePointClick = (0,
|
|
9168
|
+
const handlePointClick = (0, import_react36.useCallback)((seriesIndex, pointIndex) => {
|
|
8955
9169
|
const point = data[seriesIndex].data[pointIndex];
|
|
8956
9170
|
onPointClick?.(point, seriesIndex, pointIndex);
|
|
8957
9171
|
}, [data, onPointClick]);
|
|
8958
|
-
const legendItems = (0,
|
|
9172
|
+
const legendItems = (0, import_react36.useMemo)(
|
|
8959
9173
|
() => data.map((series, i) => ({
|
|
8960
9174
|
name: series.name,
|
|
8961
9175
|
color: series.color || colors[i % colors.length],
|
|
@@ -8963,14 +9177,14 @@ var ScatterChart = ({
|
|
|
8963
9177
|
})),
|
|
8964
9178
|
[data, colors]
|
|
8965
9179
|
);
|
|
8966
|
-
const referenceElements = (0,
|
|
9180
|
+
const referenceElements = (0, import_react36.useMemo)(() => {
|
|
8967
9181
|
if (!children) return null;
|
|
8968
9182
|
const chartDimensions = { width: chartWidth, height: chartHeight, padding };
|
|
8969
9183
|
const scales = { xScale, yScale };
|
|
8970
|
-
return
|
|
8971
|
-
if (!
|
|
9184
|
+
return import_react36.default.Children.map(children, (child) => {
|
|
9185
|
+
if (!import_react36.default.isValidElement(child)) return child;
|
|
8972
9186
|
if (child.type === ReferenceLine || child.type === ReferenceArea || child.type === CartesianGrid) {
|
|
8973
|
-
return
|
|
9187
|
+
return import_react36.default.cloneElement(child, {
|
|
8974
9188
|
_chartDimensions: chartDimensions,
|
|
8975
9189
|
_scales: scales
|
|
8976
9190
|
});
|
|
@@ -8978,19 +9192,19 @@ var ScatterChart = ({
|
|
|
8978
9192
|
return child;
|
|
8979
9193
|
});
|
|
8980
9194
|
}, [children, chartWidth, chartHeight, padding, xScale, yScale]);
|
|
8981
|
-
const accessibleDescription = (0,
|
|
9195
|
+
const accessibleDescription = (0, import_react36.useMemo)(() => {
|
|
8982
9196
|
if (ariaLabel) return ariaLabel;
|
|
8983
9197
|
const totalPoints = data.reduce((sum, s) => sum + s.data.length, 0);
|
|
8984
9198
|
return `Scatter chart with ${data.length} series and ${totalPoints} data points`;
|
|
8985
9199
|
}, [data, ariaLabel]);
|
|
8986
|
-
return /* @__PURE__ */ (0,
|
|
9200
|
+
return /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(
|
|
8987
9201
|
"div",
|
|
8988
9202
|
{
|
|
8989
9203
|
ref: containerRef,
|
|
8990
9204
|
className: `relative ${className}`,
|
|
8991
9205
|
style: containerStyle,
|
|
8992
9206
|
children: [
|
|
8993
|
-
/* @__PURE__ */ (0,
|
|
9207
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsxs)(
|
|
8994
9208
|
"svg",
|
|
8995
9209
|
{
|
|
8996
9210
|
width: svgWidth,
|
|
@@ -9002,7 +9216,7 @@ var ScatterChart = ({
|
|
|
9002
9216
|
className: "bg-[hsl(var(--card))]",
|
|
9003
9217
|
style: svgStyle,
|
|
9004
9218
|
children: [
|
|
9005
|
-
/* @__PURE__ */ (0,
|
|
9219
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime120.jsx)("style", { children: `
|
|
9006
9220
|
@keyframes popIn {
|
|
9007
9221
|
from {
|
|
9008
9222
|
transform: scale(0);
|
|
@@ -9014,8 +9228,8 @@ var ScatterChart = ({
|
|
|
9014
9228
|
}
|
|
9015
9229
|
}
|
|
9016
9230
|
` }) }),
|
|
9017
|
-
/* @__PURE__ */ (0,
|
|
9018
|
-
showGrid && /* @__PURE__ */ (0,
|
|
9231
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsxs)("g", { transform: `translate(${padding.left}, ${padding.top})`, children: [
|
|
9232
|
+
showGrid && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9019
9233
|
CartesianGrid,
|
|
9020
9234
|
{
|
|
9021
9235
|
_chartDimensions: { width: chartWidth, height: chartHeight },
|
|
@@ -9024,7 +9238,7 @@ var ScatterChart = ({
|
|
|
9024
9238
|
}
|
|
9025
9239
|
),
|
|
9026
9240
|
referenceElements,
|
|
9027
|
-
showTrendLine && trendLines.map((line, i) => /* @__PURE__ */ (0,
|
|
9241
|
+
showTrendLine && trendLines.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9028
9242
|
"line",
|
|
9029
9243
|
{
|
|
9030
9244
|
x1: line.x1,
|
|
@@ -9048,7 +9262,7 @@ var ScatterChart = ({
|
|
|
9048
9262
|
const size = bubble && point.z !== void 0 ? sizeScale(point.z) : baseSize;
|
|
9049
9263
|
const isHovered = hoveredPoint?.seriesIndex === seriesIndex && hoveredPoint?.pointIndex === pointIndex;
|
|
9050
9264
|
const displaySize = isHovered ? size * 1.3 : size;
|
|
9051
|
-
return /* @__PURE__ */ (0,
|
|
9265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9052
9266
|
"g",
|
|
9053
9267
|
{
|
|
9054
9268
|
style: animate ? {
|
|
@@ -9069,8 +9283,8 @@ var ScatterChart = ({
|
|
|
9069
9283
|
);
|
|
9070
9284
|
});
|
|
9071
9285
|
}),
|
|
9072
|
-
showXAxis && /* @__PURE__ */ (0,
|
|
9073
|
-
/* @__PURE__ */ (0,
|
|
9286
|
+
showXAxis && /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)("g", { transform: `translate(0, ${chartHeight})`, children: [
|
|
9287
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9074
9288
|
"line",
|
|
9075
9289
|
{
|
|
9076
9290
|
x1: 0,
|
|
@@ -9080,9 +9294,9 @@ var ScatterChart = ({
|
|
|
9080
9294
|
className: "stroke-[hsl(var(--border))]"
|
|
9081
9295
|
}
|
|
9082
9296
|
),
|
|
9083
|
-
xTicks.map((tick, i) => /* @__PURE__ */ (0,
|
|
9084
|
-
/* @__PURE__ */ (0,
|
|
9085
|
-
/* @__PURE__ */ (0,
|
|
9297
|
+
xTicks.map((tick, i) => /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)("g", { transform: `translate(${xScale(tick)}, 0)`, children: [
|
|
9298
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsx)("line", { y2: 6, className: "stroke-[hsl(var(--border))]" }),
|
|
9299
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9086
9300
|
"text",
|
|
9087
9301
|
{
|
|
9088
9302
|
y: 20,
|
|
@@ -9093,7 +9307,7 @@ var ScatterChart = ({
|
|
|
9093
9307
|
}
|
|
9094
9308
|
)
|
|
9095
9309
|
] }, `x-tick-${i}`)),
|
|
9096
|
-
xAxisLabel && /* @__PURE__ */ (0,
|
|
9310
|
+
xAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9097
9311
|
"text",
|
|
9098
9312
|
{
|
|
9099
9313
|
x: chartWidth / 2,
|
|
@@ -9106,8 +9320,8 @@ var ScatterChart = ({
|
|
|
9106
9320
|
}
|
|
9107
9321
|
)
|
|
9108
9322
|
] }),
|
|
9109
|
-
showYAxis && /* @__PURE__ */ (0,
|
|
9110
|
-
/* @__PURE__ */ (0,
|
|
9323
|
+
showYAxis && /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)("g", { children: [
|
|
9324
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9111
9325
|
"line",
|
|
9112
9326
|
{
|
|
9113
9327
|
x1: 0,
|
|
@@ -9117,9 +9331,9 @@ var ScatterChart = ({
|
|
|
9117
9331
|
className: "stroke-[hsl(var(--border))]"
|
|
9118
9332
|
}
|
|
9119
9333
|
),
|
|
9120
|
-
yTicks.map((tick, i) => /* @__PURE__ */ (0,
|
|
9121
|
-
/* @__PURE__ */ (0,
|
|
9122
|
-
/* @__PURE__ */ (0,
|
|
9334
|
+
yTicks.map((tick, i) => /* @__PURE__ */ (0, import_jsx_runtime120.jsxs)("g", { transform: `translate(0, ${yScale(tick)})`, children: [
|
|
9335
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsx)("line", { x2: -6, className: "stroke-[hsl(var(--border))]" }),
|
|
9336
|
+
/* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9123
9337
|
"text",
|
|
9124
9338
|
{
|
|
9125
9339
|
x: -12,
|
|
@@ -9131,7 +9345,7 @@ var ScatterChart = ({
|
|
|
9131
9345
|
}
|
|
9132
9346
|
)
|
|
9133
9347
|
] }, `y-tick-${i}`)),
|
|
9134
|
-
yAxisLabel && /* @__PURE__ */ (0,
|
|
9348
|
+
yAxisLabel && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9135
9349
|
"text",
|
|
9136
9350
|
{
|
|
9137
9351
|
x: -chartHeight / 2,
|
|
@@ -9149,8 +9363,8 @@ var ScatterChart = ({
|
|
|
9149
9363
|
]
|
|
9150
9364
|
}
|
|
9151
9365
|
),
|
|
9152
|
-
showLegend && /* @__PURE__ */ (0,
|
|
9153
|
-
showTooltip && /* @__PURE__ */ (0,
|
|
9366
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(Legend, { items: legendItems, layout: "horizontal", align: "center" }),
|
|
9367
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(
|
|
9154
9368
|
ChartTooltip,
|
|
9155
9369
|
{
|
|
9156
9370
|
...tooltipData,
|
|
@@ -9164,8 +9378,8 @@ var ScatterChart = ({
|
|
|
9164
9378
|
};
|
|
9165
9379
|
|
|
9166
9380
|
// src/charts/components/ResponsiveContainer.tsx
|
|
9167
|
-
var
|
|
9168
|
-
var
|
|
9381
|
+
var import_react37 = __toESM(require("react"));
|
|
9382
|
+
var import_jsx_runtime121 = require("react/jsx-runtime");
|
|
9169
9383
|
var ResponsiveContainer = ({
|
|
9170
9384
|
width = "100%",
|
|
9171
9385
|
height,
|
|
@@ -9179,13 +9393,13 @@ var ResponsiveContainer = ({
|
|
|
9179
9393
|
children,
|
|
9180
9394
|
onResize
|
|
9181
9395
|
}) => {
|
|
9182
|
-
const containerRef = (0,
|
|
9183
|
-
const [dimensions, setDimensions] = (0,
|
|
9396
|
+
const containerRef = (0, import_react37.useRef)(null);
|
|
9397
|
+
const [dimensions, setDimensions] = (0, import_react37.useState)({
|
|
9184
9398
|
width: 0,
|
|
9185
9399
|
height: 0
|
|
9186
9400
|
});
|
|
9187
|
-
const debounceTimerRef = (0,
|
|
9188
|
-
const calculateDimensions = (0,
|
|
9401
|
+
const debounceTimerRef = (0, import_react37.useRef)(null);
|
|
9402
|
+
const calculateDimensions = (0, import_react37.useCallback)((containerWidth, containerHeight) => {
|
|
9189
9403
|
let finalWidth = containerWidth;
|
|
9190
9404
|
let finalHeight = containerHeight;
|
|
9191
9405
|
if (aspect && !height) {
|
|
@@ -9201,7 +9415,7 @@ var ResponsiveContainer = ({
|
|
|
9201
9415
|
}
|
|
9202
9416
|
return { width: finalWidth, height: finalHeight };
|
|
9203
9417
|
}, [aspect, height, minWidth, minHeight, maxWidth, maxHeight]);
|
|
9204
|
-
const handleResize = (0,
|
|
9418
|
+
const handleResize = (0, import_react37.useCallback)((entries) => {
|
|
9205
9419
|
const entry = entries[0];
|
|
9206
9420
|
if (!entry) return;
|
|
9207
9421
|
const { width: containerWidth, height: containerHeight } = entry.contentRect;
|
|
@@ -9219,7 +9433,7 @@ var ResponsiveContainer = ({
|
|
|
9219
9433
|
updateDimensions();
|
|
9220
9434
|
}
|
|
9221
9435
|
}, [calculateDimensions, debounce, onResize]);
|
|
9222
|
-
(0,
|
|
9436
|
+
(0, import_react37.useEffect)(() => {
|
|
9223
9437
|
const container = containerRef.current;
|
|
9224
9438
|
if (!container) return;
|
|
9225
9439
|
const observer = new ResizeObserver(handleResize);
|
|
@@ -9243,7 +9457,7 @@ var ResponsiveContainer = ({
|
|
|
9243
9457
|
maxHeight: maxHeight ? `${maxHeight}px` : void 0
|
|
9244
9458
|
};
|
|
9245
9459
|
if (dimensions.width === 0 || dimensions.height === 0) {
|
|
9246
|
-
return /* @__PURE__ */ (0,
|
|
9460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
9247
9461
|
"div",
|
|
9248
9462
|
{
|
|
9249
9463
|
ref: containerRef,
|
|
@@ -9252,14 +9466,14 @@ var ResponsiveContainer = ({
|
|
|
9252
9466
|
}
|
|
9253
9467
|
);
|
|
9254
9468
|
}
|
|
9255
|
-
const chartElement =
|
|
9469
|
+
const chartElement = import_react37.default.cloneElement(
|
|
9256
9470
|
children,
|
|
9257
9471
|
{
|
|
9258
9472
|
width: dimensions.width,
|
|
9259
9473
|
height: dimensions.height
|
|
9260
9474
|
}
|
|
9261
9475
|
);
|
|
9262
|
-
return /* @__PURE__ */ (0,
|
|
9476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
|
|
9263
9477
|
"div",
|
|
9264
9478
|
{
|
|
9265
9479
|
ref: containerRef,
|
|
@@ -9271,8 +9485,8 @@ var ResponsiveContainer = ({
|
|
|
9271
9485
|
};
|
|
9272
9486
|
|
|
9273
9487
|
// src/components/Heatmap.tsx
|
|
9274
|
-
var
|
|
9275
|
-
var
|
|
9488
|
+
var import_react38 = __toESM(require("react"));
|
|
9489
|
+
var import_jsx_runtime122 = require("react/jsx-runtime");
|
|
9276
9490
|
var COLOR_SCALES = {
|
|
9277
9491
|
blue: {
|
|
9278
9492
|
light: ["#eff6ff", "#dbeafe", "#bfdbfe", "#93c5fd", "#60a5fa", "#3b82f6", "#2563eb", "#1d4ed8", "#1e40af"],
|
|
@@ -9315,9 +9529,9 @@ var Heatmap = ({
|
|
|
9315
9529
|
formatValue = (v) => v.toFixed(0),
|
|
9316
9530
|
formatTooltip
|
|
9317
9531
|
}) => {
|
|
9318
|
-
const [hoveredCell, setHoveredCell] = (0,
|
|
9319
|
-
const [isDarkMode, setIsDarkMode] = (0,
|
|
9320
|
-
|
|
9532
|
+
const [hoveredCell, setHoveredCell] = (0, import_react38.useState)(null);
|
|
9533
|
+
const [isDarkMode, setIsDarkMode] = (0, import_react38.useState)(false);
|
|
9534
|
+
import_react38.default.useEffect(() => {
|
|
9321
9535
|
const checkDarkMode = () => {
|
|
9322
9536
|
setIsDarkMode(document.documentElement.classList.contains("dark"));
|
|
9323
9537
|
};
|
|
@@ -9326,7 +9540,7 @@ var Heatmap = ({
|
|
|
9326
9540
|
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
|
|
9327
9541
|
return () => observer.disconnect();
|
|
9328
9542
|
}, []);
|
|
9329
|
-
const { uniqueX, uniqueY, dataMap, minValue, maxValue } = (0,
|
|
9543
|
+
const { uniqueX, uniqueY, dataMap, minValue, maxValue } = (0, import_react38.useMemo)(() => {
|
|
9330
9544
|
const xSet = /* @__PURE__ */ new Set();
|
|
9331
9545
|
const ySet = /* @__PURE__ */ new Set();
|
|
9332
9546
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -9377,15 +9591,15 @@ var Heatmap = ({
|
|
|
9377
9591
|
const labelHeight = 30;
|
|
9378
9592
|
const width = labelWidth + uniqueX.length * (cellSize + cellGap);
|
|
9379
9593
|
const height = labelHeight + uniqueY.length * (cellSize + cellGap);
|
|
9380
|
-
return /* @__PURE__ */ (0,
|
|
9381
|
-
/* @__PURE__ */ (0,
|
|
9594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: `relative inline-block ${className}`, children: [
|
|
9595
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
|
|
9382
9596
|
"svg",
|
|
9383
9597
|
{
|
|
9384
9598
|
width,
|
|
9385
9599
|
height,
|
|
9386
9600
|
className: "select-none",
|
|
9387
9601
|
children: [
|
|
9388
|
-
uniqueX.map((label, i) => /* @__PURE__ */ (0,
|
|
9602
|
+
uniqueX.map((label, i) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9389
9603
|
"text",
|
|
9390
9604
|
{
|
|
9391
9605
|
x: labelWidth + i * (cellSize + cellGap) + cellSize / 2,
|
|
@@ -9397,7 +9611,7 @@ var Heatmap = ({
|
|
|
9397
9611
|
},
|
|
9398
9612
|
`x-${label}`
|
|
9399
9613
|
)),
|
|
9400
|
-
uniqueY.map((label, j) => /* @__PURE__ */ (0,
|
|
9614
|
+
uniqueY.map((label, j) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9401
9615
|
"text",
|
|
9402
9616
|
{
|
|
9403
9617
|
x: labelWidth - 8,
|
|
@@ -9415,8 +9629,8 @@ var Heatmap = ({
|
|
|
9415
9629
|
const point = data.find((d) => String(d.x) === xLabel && String(d.y) === yLabel);
|
|
9416
9630
|
const x = labelWidth + i * (cellSize + cellGap);
|
|
9417
9631
|
const y = labelHeight + j * (cellSize + cellGap);
|
|
9418
|
-
return /* @__PURE__ */ (0,
|
|
9419
|
-
/* @__PURE__ */ (0,
|
|
9632
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("g", { children: [
|
|
9633
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9420
9634
|
"rect",
|
|
9421
9635
|
{
|
|
9422
9636
|
x,
|
|
@@ -9439,7 +9653,7 @@ var Heatmap = ({
|
|
|
9439
9653
|
}
|
|
9440
9654
|
}
|
|
9441
9655
|
),
|
|
9442
|
-
showValues && value !== void 0 && /* @__PURE__ */ (0,
|
|
9656
|
+
showValues && value !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9443
9657
|
"text",
|
|
9444
9658
|
{
|
|
9445
9659
|
x: x + cellSize / 2,
|
|
@@ -9456,7 +9670,7 @@ var Heatmap = ({
|
|
|
9456
9670
|
]
|
|
9457
9671
|
}
|
|
9458
9672
|
),
|
|
9459
|
-
showTooltip && hoveredCell && /* @__PURE__ */ (0,
|
|
9673
|
+
showTooltip && hoveredCell && /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
|
|
9460
9674
|
"div",
|
|
9461
9675
|
{
|
|
9462
9676
|
className: "absolute z-50 px-3 py-2 text-sm bg-[hsl(var(--popover))] text-[hsl(var(--popover-foreground))] border border-[hsl(var(--border))] rounded-lg shadow-lg pointer-events-none whitespace-nowrap",
|
|
@@ -9467,7 +9681,7 @@ var Heatmap = ({
|
|
|
9467
9681
|
},
|
|
9468
9682
|
children: [
|
|
9469
9683
|
getTooltipContent(hoveredCell.point),
|
|
9470
|
-
/* @__PURE__ */ (0,
|
|
9684
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9471
9685
|
"div",
|
|
9472
9686
|
{
|
|
9473
9687
|
className: "absolute w-2 h-2 bg-[hsl(var(--popover))] rotate-45",
|
|
@@ -9498,9 +9712,9 @@ var CalendarHeatmap = ({
|
|
|
9498
9712
|
onCellClick,
|
|
9499
9713
|
formatTooltip
|
|
9500
9714
|
}) => {
|
|
9501
|
-
const [hoveredCell, setHoveredCell] = (0,
|
|
9502
|
-
const [isDarkMode, setIsDarkMode] = (0,
|
|
9503
|
-
|
|
9715
|
+
const [hoveredCell, setHoveredCell] = (0, import_react38.useState)(null);
|
|
9716
|
+
const [isDarkMode, setIsDarkMode] = (0, import_react38.useState)(false);
|
|
9717
|
+
import_react38.default.useEffect(() => {
|
|
9504
9718
|
const checkDarkMode = () => {
|
|
9505
9719
|
setIsDarkMode(document.documentElement.classList.contains("dark"));
|
|
9506
9720
|
};
|
|
@@ -9509,7 +9723,7 @@ var CalendarHeatmap = ({
|
|
|
9509
9723
|
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] });
|
|
9510
9724
|
return () => observer.disconnect();
|
|
9511
9725
|
}, []);
|
|
9512
|
-
const { weeks, minValue, maxValue, dataMap, monthLabels } = (0,
|
|
9726
|
+
const { weeks, minValue, maxValue, dataMap, monthLabels } = (0, import_react38.useMemo)(() => {
|
|
9513
9727
|
const map = /* @__PURE__ */ new Map();
|
|
9514
9728
|
let min = Infinity;
|
|
9515
9729
|
let max = -Infinity;
|
|
@@ -9569,9 +9783,9 @@ var CalendarHeatmap = ({
|
|
|
9569
9783
|
const monthLabelHeight = showMonthLabels ? 20 : 0;
|
|
9570
9784
|
const width = dayLabelWidth + weeks.length * (cellSize + cellGap);
|
|
9571
9785
|
const height = monthLabelHeight + 7 * (cellSize + cellGap);
|
|
9572
|
-
return /* @__PURE__ */ (0,
|
|
9573
|
-
/* @__PURE__ */ (0,
|
|
9574
|
-
showMonthLabels && monthLabels.map(({ label, weekIndex }, i) => /* @__PURE__ */ (0,
|
|
9786
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: `relative inline-block ${className}`, children: [
|
|
9787
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("svg", { width, height, className: "select-none", children: [
|
|
9788
|
+
showMonthLabels && monthLabels.map(({ label, weekIndex }, i) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9575
9789
|
"text",
|
|
9576
9790
|
{
|
|
9577
9791
|
x: dayLabelWidth + weekIndex * (cellSize + cellGap),
|
|
@@ -9582,7 +9796,7 @@ var CalendarHeatmap = ({
|
|
|
9582
9796
|
},
|
|
9583
9797
|
`month-${i}`
|
|
9584
9798
|
)),
|
|
9585
|
-
showDayLabels && [1, 3, 5].map((dayIndex) => /* @__PURE__ */ (0,
|
|
9799
|
+
showDayLabels && [1, 3, 5].map((dayIndex) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9586
9800
|
"text",
|
|
9587
9801
|
{
|
|
9588
9802
|
x: dayLabelWidth - 6,
|
|
@@ -9600,7 +9814,7 @@ var CalendarHeatmap = ({
|
|
|
9600
9814
|
const value = dataMap.get(key);
|
|
9601
9815
|
const x = dayLabelWidth + weekIndex * (cellSize + cellGap);
|
|
9602
9816
|
const y = monthLabelHeight + dayIndex * (cellSize + cellGap);
|
|
9603
|
-
return /* @__PURE__ */ (0,
|
|
9817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9604
9818
|
"rect",
|
|
9605
9819
|
{
|
|
9606
9820
|
x,
|
|
@@ -9625,7 +9839,7 @@ var CalendarHeatmap = ({
|
|
|
9625
9839
|
})
|
|
9626
9840
|
)
|
|
9627
9841
|
] }),
|
|
9628
|
-
hoveredCell && /* @__PURE__ */ (0,
|
|
9842
|
+
hoveredCell && /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)(
|
|
9629
9843
|
"div",
|
|
9630
9844
|
{
|
|
9631
9845
|
className: "absolute z-50 px-3 py-2 text-sm bg-[hsl(var(--popover))] text-[hsl(var(--popover-foreground))] border border-[hsl(var(--border))] rounded-lg shadow-lg pointer-events-none whitespace-nowrap",
|
|
@@ -9636,7 +9850,7 @@ var CalendarHeatmap = ({
|
|
|
9636
9850
|
},
|
|
9637
9851
|
children: [
|
|
9638
9852
|
getTooltipContent(hoveredCell.date, hoveredCell.value),
|
|
9639
|
-
/* @__PURE__ */ (0,
|
|
9853
|
+
/* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
|
|
9640
9854
|
"div",
|
|
9641
9855
|
{
|
|
9642
9856
|
className: "absolute w-2 h-2 bg-[hsl(var(--popover))] rotate-45",
|
|
@@ -9654,7 +9868,7 @@ var CalendarHeatmap = ({
|
|
|
9654
9868
|
};
|
|
9655
9869
|
|
|
9656
9870
|
// src/theme/ColorSchemeScript.tsx
|
|
9657
|
-
var
|
|
9871
|
+
var import_jsx_runtime123 = require("react/jsx-runtime");
|
|
9658
9872
|
function getColorSchemeScript(defaultColorMode, localStorageKey) {
|
|
9659
9873
|
return `(function(){try{var d=document.documentElement,s=d.style,c=localStorage.getItem('${localStorageKey}')||'${defaultColorMode}',r=c;if(c==='system'||!c)r=matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light';d.setAttribute('data-color-mode',r);s.colorScheme=r;if(r==='dark'){d.classList.add('dark');s.setProperty('--background','0 0% 3.9%');s.setProperty('--foreground','0 0% 98%');s.setProperty('--card','0 0% 5.9%');s.setProperty('--card-foreground','0 0% 98%');s.setProperty('--popover','0 0% 5.9%');s.setProperty('--popover-foreground','0 0% 98%');s.setProperty('--muted','0 0% 14.9%');s.setProperty('--muted-foreground','0 0% 63.9%');s.setProperty('--border','0 0% 25%');s.setProperty('--input','0 0% 25%');s.setProperty('--primary','217 91% 60%');s.setProperty('--secondary','0 0% 14.9%');s.setProperty('--accent','0 0% 14.9%');s.backgroundColor='hsl(0,0%,3.9%)';s.color='hsl(0,0%,98%)'}else{d.classList.remove('dark');s.backgroundColor='hsl(0,0%,100%)';s.color='hsl(0,0%,3.9%)'}d.setAttribute('data-theme-initialized','true')}catch(e){}})()`;
|
|
9660
9874
|
}
|
|
@@ -9664,7 +9878,7 @@ function ColorSchemeScript({
|
|
|
9664
9878
|
nonce
|
|
9665
9879
|
} = {}) {
|
|
9666
9880
|
const scriptContent = getColorSchemeScript(defaultColorMode, localStorageKey);
|
|
9667
|
-
return /* @__PURE__ */ (0,
|
|
9881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
|
|
9668
9882
|
"script",
|
|
9669
9883
|
{
|
|
9670
9884
|
nonce,
|
|
@@ -9776,6 +9990,7 @@ function getThemeScript() {
|
|
|
9776
9990
|
SaveIcon,
|
|
9777
9991
|
ScatterChart,
|
|
9778
9992
|
SearchIcon,
|
|
9993
|
+
SegmentedControl,
|
|
9779
9994
|
Select,
|
|
9780
9995
|
SettingsIcon,
|
|
9781
9996
|
ShieldIcon,
|