@mlw-packages/react-components 1.7.15 → 1.7.16
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 +95 -154
- package/dist/index.d.ts +95 -154
- package/dist/index.js +929 -1064
- package/dist/index.mjs +721 -849
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2051,7 +2051,14 @@ function AvatarCombobox({
|
|
|
2051
2051
|
}
|
|
2052
2052
|
|
|
2053
2053
|
// src/components/charts/Chart.tsx
|
|
2054
|
-
import {
|
|
2054
|
+
import {
|
|
2055
|
+
useState as useState7,
|
|
2056
|
+
useEffect as useEffect5,
|
|
2057
|
+
useCallback as useCallback5,
|
|
2058
|
+
useMemo as useMemo5,
|
|
2059
|
+
useRef as useRef3,
|
|
2060
|
+
useLayoutEffect
|
|
2061
|
+
} from "react";
|
|
2055
2062
|
import {
|
|
2056
2063
|
ComposedChart,
|
|
2057
2064
|
Bar,
|
|
@@ -3480,107 +3487,8 @@ var TooltipSimple = ({
|
|
|
3480
3487
|
};
|
|
3481
3488
|
var TooltipSimple_default = TooltipSimple;
|
|
3482
3489
|
|
|
3483
|
-
// src/components/charts/NoData.tsx
|
|
3484
|
-
import { jsx as jsx27, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3485
|
-
var NoData = ({
|
|
3486
|
-
paddingLeft = 0,
|
|
3487
|
-
height = 360,
|
|
3488
|
-
message = "Sem dados para exibir",
|
|
3489
|
-
className
|
|
3490
|
-
}) => {
|
|
3491
|
-
const svgHeight = typeof height === "number" ? height : 360;
|
|
3492
|
-
const bars = [
|
|
3493
|
-
{ x: 120, w: 120, h: svgHeight * 0.45, label: "Label 0" },
|
|
3494
|
-
{ x: 260, w: 120, h: svgHeight * 0.75, label: "Label 1" },
|
|
3495
|
-
{ x: 400, w: 120, h: svgHeight * 0.65, label: "Label 2" },
|
|
3496
|
-
{ x: 540, w: 120, h: svgHeight * 0.55, label: "Label 3" },
|
|
3497
|
-
{ x: 680, w: 120, h: svgHeight * 0.25, label: "Label 4" }
|
|
3498
|
-
];
|
|
3499
|
-
const styleVars = {
|
|
3500
|
-
["--pl"]: `${paddingLeft}px`,
|
|
3501
|
-
["--svg-h"]: typeof height === "number" ? `${height}px` : String(height)
|
|
3502
|
-
};
|
|
3503
|
-
return /* @__PURE__ */ jsx27(
|
|
3504
|
-
"div",
|
|
3505
|
-
{
|
|
3506
|
-
className: cn(
|
|
3507
|
-
"rounded-lg bg-card p-2 relative overflow-visible w-full",
|
|
3508
|
-
className
|
|
3509
|
-
),
|
|
3510
|
-
style: styleVars,
|
|
3511
|
-
role: "img",
|
|
3512
|
-
"aria-label": message,
|
|
3513
|
-
children: /* @__PURE__ */ jsx27("div", { className: "w-full flex items-center justify-center pl-[var(--pl)] pr-3 h-[var(--svg-h)]", children: /* @__PURE__ */ jsxs22("div", { className: "w-full max-w-[900px] relative", children: [
|
|
3514
|
-
/* @__PURE__ */ jsxs22(
|
|
3515
|
-
"svg",
|
|
3516
|
-
{
|
|
3517
|
-
className: "w-full h-[var(--svg-h)]",
|
|
3518
|
-
width: "100%",
|
|
3519
|
-
viewBox: `0 0 900 ${svgHeight}`,
|
|
3520
|
-
preserveAspectRatio: "none",
|
|
3521
|
-
children: [
|
|
3522
|
-
/* @__PURE__ */ jsx27(
|
|
3523
|
-
"rect",
|
|
3524
|
-
{
|
|
3525
|
-
x: 0,
|
|
3526
|
-
y: 0,
|
|
3527
|
-
width: 900,
|
|
3528
|
-
height: svgHeight,
|
|
3529
|
-
fill: "transparent"
|
|
3530
|
-
}
|
|
3531
|
-
),
|
|
3532
|
-
Array.from({ length: 5 }).map((_, i) => {
|
|
3533
|
-
const y = 40 + (svgHeight - 80) / 4 * i;
|
|
3534
|
-
return /* @__PURE__ */ jsx27(
|
|
3535
|
-
"line",
|
|
3536
|
-
{
|
|
3537
|
-
x1: 60,
|
|
3538
|
-
x2: 840,
|
|
3539
|
-
y1: y,
|
|
3540
|
-
y2: y,
|
|
3541
|
-
stroke: "rgba(0,0,0,0.06)",
|
|
3542
|
-
strokeWidth: 1
|
|
3543
|
-
},
|
|
3544
|
-
`g-${i}`
|
|
3545
|
-
);
|
|
3546
|
-
}),
|
|
3547
|
-
bars.map((b, i) => /* @__PURE__ */ jsxs22("g", { children: [
|
|
3548
|
-
/* @__PURE__ */ jsx27(
|
|
3549
|
-
"rect",
|
|
3550
|
-
{
|
|
3551
|
-
x: b.x,
|
|
3552
|
-
y: svgHeight - 60 - b.h,
|
|
3553
|
-
width: b.w,
|
|
3554
|
-
height: b.h,
|
|
3555
|
-
rx: 6,
|
|
3556
|
-
fill: "rgba(0,0,0,0.06)",
|
|
3557
|
-
stroke: "rgba(0,0,0,0.04)"
|
|
3558
|
-
}
|
|
3559
|
-
),
|
|
3560
|
-
/* @__PURE__ */ jsx27(
|
|
3561
|
-
"text",
|
|
3562
|
-
{
|
|
3563
|
-
x: b.x + b.w / 2,
|
|
3564
|
-
y: svgHeight - 20,
|
|
3565
|
-
fill: "rgba(0,0,0,0.35)",
|
|
3566
|
-
fontSize: 12,
|
|
3567
|
-
textAnchor: "middle",
|
|
3568
|
-
children: b.label
|
|
3569
|
-
}
|
|
3570
|
-
)
|
|
3571
|
-
] }, `barg-${i}`))
|
|
3572
|
-
]
|
|
3573
|
-
}
|
|
3574
|
-
),
|
|
3575
|
-
/* @__PURE__ */ jsx27("div", { className: "absolute inset-0 flex items-center justify-center pointer-events-none h-[var(--svg-h)]", children: /* @__PURE__ */ jsx27("div", { className: "pointer-events-auto bg-transparent px-3", children: /* @__PURE__ */ jsx27("div", { className: "text-2xl font-extrabold text-black/80", children: message }) }) })
|
|
3576
|
-
] }) })
|
|
3577
|
-
}
|
|
3578
|
-
);
|
|
3579
|
-
};
|
|
3580
|
-
var NoData_default = NoData;
|
|
3581
|
-
|
|
3582
3490
|
// src/components/charts/utils/pillLabelRenderer.tsx
|
|
3583
|
-
import { jsx as
|
|
3491
|
+
import { jsx as jsx27, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3584
3492
|
var formatCompactNumber = (value) => {
|
|
3585
3493
|
const isNegative = value < 0;
|
|
3586
3494
|
const absValue = Math.abs(value);
|
|
@@ -3625,7 +3533,7 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
|
|
|
3625
3533
|
40,
|
|
3626
3534
|
String(text).length * approxCharWidth + paddingX * 2
|
|
3627
3535
|
);
|
|
3628
|
-
const pillHeight =
|
|
3536
|
+
const pillHeight = 14;
|
|
3629
3537
|
const xNum = parseNumber(x);
|
|
3630
3538
|
const px = parseNumber(props.x);
|
|
3631
3539
|
const pWidth = parseNumber(props.width);
|
|
@@ -3671,8 +3579,8 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
|
|
|
3671
3579
|
} else {
|
|
3672
3580
|
textColor = "#374151";
|
|
3673
3581
|
}
|
|
3674
|
-
return /* @__PURE__ */
|
|
3675
|
-
/* @__PURE__ */
|
|
3582
|
+
return /* @__PURE__ */ jsxs22("g", { children: [
|
|
3583
|
+
/* @__PURE__ */ jsx27(
|
|
3676
3584
|
"rect",
|
|
3677
3585
|
{
|
|
3678
3586
|
x: rectX,
|
|
@@ -3685,13 +3593,13 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
|
|
|
3685
3593
|
strokeWidth: rectStroke ? 1 : 0
|
|
3686
3594
|
}
|
|
3687
3595
|
),
|
|
3688
|
-
/* @__PURE__ */
|
|
3596
|
+
/* @__PURE__ */ jsx27(
|
|
3689
3597
|
"text",
|
|
3690
3598
|
{
|
|
3691
3599
|
x: textX,
|
|
3692
|
-
y: textY +
|
|
3600
|
+
y: textY + 1,
|
|
3693
3601
|
fill: textColor,
|
|
3694
|
-
fontSize:
|
|
3602
|
+
fontSize: 10,
|
|
3695
3603
|
fontWeight: 700,
|
|
3696
3604
|
textAnchor: "middle",
|
|
3697
3605
|
dominantBaseline: "central",
|
|
@@ -3703,324 +3611,64 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
|
|
|
3703
3611
|
};
|
|
3704
3612
|
};
|
|
3705
3613
|
var pillLabelRenderer_default = renderPillLabel;
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
const
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
}
|
|
3717
|
-
}
|
|
3718
|
-
return max;
|
|
3719
|
-
}
|
|
3720
|
-
function minForKeys(processedData, keys) {
|
|
3721
|
-
let min = 0;
|
|
3722
|
-
for (const row of processedData) {
|
|
3723
|
-
const r = row;
|
|
3724
|
-
for (const key of keys) {
|
|
3725
|
-
const v = r[key];
|
|
3726
|
-
if (typeof v === "number" && Number.isFinite(v) && v < min)
|
|
3727
|
-
min = v;
|
|
3728
|
-
}
|
|
3729
|
-
}
|
|
3730
|
-
return min;
|
|
3731
|
-
}
|
|
3732
|
-
|
|
3733
|
-
// src/components/charts/utils/formatters.ts
|
|
3734
|
-
var TITLE_CLASSNAME = "text-xl font-semibold text-foreground mb-3";
|
|
3735
|
-
function buildPercentFormatter(decimals = 0) {
|
|
3736
|
-
return (v) => {
|
|
3737
|
-
const n = Number(String(v));
|
|
3738
|
-
if (Number.isNaN(n)) return String(v ?? "");
|
|
3739
|
-
const value = Math.abs(n) <= 1 ? n * 100 : n;
|
|
3740
|
-
return `${value.toFixed(decimals)}%`;
|
|
3741
|
-
};
|
|
3742
|
-
}
|
|
3743
|
-
function createFinalValueFormatter(valueFormatter2, formatBR) {
|
|
3744
|
-
const nf = new Intl.NumberFormat("pt-BR", {
|
|
3745
|
-
minimumFractionDigits: 2,
|
|
3746
|
-
maximumFractionDigits: 2
|
|
3747
|
-
});
|
|
3748
|
-
if (valueFormatter2) {
|
|
3749
|
-
if (formatBR) {
|
|
3750
|
-
const wrapped = (props) => {
|
|
3751
|
-
const { value, formattedValue } = props;
|
|
3752
|
-
let num = NaN;
|
|
3753
|
-
if (typeof value === "number") num = value;
|
|
3754
|
-
else if (typeof value === "string" && value.trim() !== "") {
|
|
3755
|
-
const parsed = Number(value);
|
|
3756
|
-
num = Number.isNaN(parsed) ? NaN : parsed;
|
|
3757
|
-
}
|
|
3758
|
-
const brFormatted = !Number.isNaN(num) ? nf.format(num) : String(formattedValue ?? value ?? "");
|
|
3759
|
-
return valueFormatter2({
|
|
3760
|
-
...props,
|
|
3761
|
-
formattedValue: brFormatted,
|
|
3762
|
-
value: void 0
|
|
3763
|
-
});
|
|
3764
|
-
};
|
|
3765
|
-
return wrapped;
|
|
3766
|
-
}
|
|
3767
|
-
return valueFormatter2;
|
|
3768
|
-
}
|
|
3769
|
-
if (!formatBR) return void 0;
|
|
3770
|
-
const builtIn = (props) => {
|
|
3771
|
-
const { value, formattedValue } = props;
|
|
3772
|
-
let num = NaN;
|
|
3773
|
-
if (typeof value === "number") num = value;
|
|
3774
|
-
else if (typeof value === "string" && value.trim() !== "") {
|
|
3775
|
-
const parsed = Number(value);
|
|
3776
|
-
num = Number.isNaN(parsed) ? NaN : parsed;
|
|
3777
|
-
}
|
|
3778
|
-
if (!Number.isNaN(num)) return String(nf.format(num));
|
|
3779
|
-
return String(formattedValue ?? value ?? "");
|
|
3780
|
-
};
|
|
3781
|
-
return builtIn;
|
|
3782
|
-
}
|
|
3783
|
-
function createYTickFormatter(finalValueFormatter) {
|
|
3784
|
-
const nf = new Intl.NumberFormat("pt-BR", {
|
|
3785
|
-
minimumFractionDigits: 2,
|
|
3786
|
-
maximumFractionDigits: 2
|
|
3787
|
-
});
|
|
3788
|
-
const stripCurrency = (s) => String(s).replace(/^\s*R\$\s?/, "");
|
|
3789
|
-
if (finalValueFormatter) {
|
|
3790
|
-
return (v) => {
|
|
3791
|
-
const num = Number(String(v));
|
|
3792
|
-
const formatted = Number.isNaN(num) ? String(v ?? "") : nf.format(num);
|
|
3793
|
-
const out = finalValueFormatter({
|
|
3794
|
-
value: v,
|
|
3795
|
-
formattedValue: formatted
|
|
3796
|
-
});
|
|
3797
|
-
return stripCurrency(String(out));
|
|
3614
|
+
var renderInsideBarLabel = (color, valueFormatter2) => {
|
|
3615
|
+
return (props) => {
|
|
3616
|
+
const { x, y, value, width, height, viewBox, cx, cy, index } = props;
|
|
3617
|
+
const defaultFormatted = typeof value === "number" ? formatCompactNumber(value) : String(value ?? "");
|
|
3618
|
+
const text = valueFormatter2 ? valueFormatter2({ value, formattedValue: defaultFormatted, ...props }) : defaultFormatted;
|
|
3619
|
+
const parseNumberLocal = (v) => {
|
|
3620
|
+
if (typeof v === "number") return v;
|
|
3621
|
+
if (typeof v === "string" && v.trim() !== "" && !Number.isNaN(Number(v)))
|
|
3622
|
+
return Number(v);
|
|
3623
|
+
return void 0;
|
|
3798
3624
|
};
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
const
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
}
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
else if (typeof
|
|
3823
|
-
|
|
3824
|
-
else
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
ctx.font = "12px system-ui, -apple-system, 'Segoe UI', Roboto";
|
|
3840
|
-
const w = Math.ceil(ctx.measureText(s).width) + 12;
|
|
3841
|
-
return Math.min(300, w);
|
|
3842
|
-
}
|
|
3843
|
-
|
|
3844
|
-
// src/components/charts/utils/chartHelpers.ts
|
|
3845
|
-
function computeSeriesOrder(series, mapperConfig) {
|
|
3846
|
-
const seriesOrder = [];
|
|
3847
|
-
if (series) {
|
|
3848
|
-
if (series.bar)
|
|
3849
|
-
series.bar.forEach((k) => seriesOrder.push({ type: "bar", key: k }));
|
|
3850
|
-
if (series.line)
|
|
3851
|
-
series.line.forEach((k) => seriesOrder.push({ type: "line", key: k }));
|
|
3852
|
-
if (series.area)
|
|
3853
|
-
series.area.forEach((k) => seriesOrder.push({ type: "area", key: k }));
|
|
3854
|
-
} else {
|
|
3855
|
-
Object.keys(mapperConfig).forEach(
|
|
3856
|
-
(k) => seriesOrder.push({ type: "bar", key: k })
|
|
3857
|
-
);
|
|
3858
|
-
}
|
|
3859
|
-
return seriesOrder;
|
|
3860
|
-
}
|
|
3861
|
-
function computeProcessedData(data, xAxisKey) {
|
|
3862
|
-
return data.map((item) => ({
|
|
3863
|
-
...item,
|
|
3864
|
-
name: String(item[xAxisKey] ?? "N/A")
|
|
3865
|
-
}));
|
|
3866
|
-
}
|
|
3867
|
-
function computeAllKeys(seriesOrder) {
|
|
3868
|
-
return seriesOrder.map((s) => s.key).filter(Boolean);
|
|
3869
|
-
}
|
|
3870
|
-
function computeLeftRightKeys(allKeys, yAxisMap) {
|
|
3871
|
-
const normalize = (v) => {
|
|
3872
|
-
if (v === "left" || v === "right") return v;
|
|
3873
|
-
if (v === 1 || v === "1" || v === true) return "right";
|
|
3874
|
-
return "left";
|
|
3875
|
-
};
|
|
3876
|
-
const leftKeys = !yAxisMap ? allKeys : allKeys.filter((k) => normalize(yAxisMap?.[k]) === "left");
|
|
3877
|
-
const rightKeys = !yAxisMap ? [] : allKeys.filter((k) => normalize(yAxisMap?.[k]) === "right");
|
|
3878
|
-
return { leftKeys, rightKeys };
|
|
3879
|
-
}
|
|
3880
|
-
function computeNiceMax(value) {
|
|
3881
|
-
let padding = 0.08;
|
|
3882
|
-
if (value > 1e6) padding = 0.05;
|
|
3883
|
-
if (value > 1e7) padding = 0.03;
|
|
3884
|
-
if (value === 0) padding = 0.12;
|
|
3885
|
-
const padded = value * (1 + padding);
|
|
3886
|
-
return padded;
|
|
3887
|
-
}
|
|
3888
|
-
function computeChartWidth(dataLength, seriesCounts, niceMax, opts) {
|
|
3889
|
-
const basePerPoint = 60;
|
|
3890
|
-
const perBarExtra = seriesCounts.bar > 0 ? Math.max(0, seriesCounts.bar - 1) * 8 : 0;
|
|
3891
|
-
const perOtherExtra = (seriesCounts.line + seriesCounts.area) * 4;
|
|
3892
|
-
let sizeFactor = 1;
|
|
3893
|
-
if (niceMax > 1e5) sizeFactor = 1.1;
|
|
3894
|
-
if (niceMax > 1e6) sizeFactor = 1.2;
|
|
3895
|
-
if (niceMax > 1e7) sizeFactor = 1.3;
|
|
3896
|
-
const perPoint = Math.round(
|
|
3897
|
-
(basePerPoint + perBarExtra + perOtherExtra) * sizeFactor
|
|
3898
|
-
);
|
|
3899
|
-
const marginExtra = 120;
|
|
3900
|
-
const calculated = Math.max(1, dataLength) * perPoint + marginExtra;
|
|
3901
|
-
const minWidth = opts?.minWidth ?? 300;
|
|
3902
|
-
const maxWidth = opts?.maxWidth ?? 1800;
|
|
3903
|
-
return Math.max(minWidth, Math.min(maxWidth, calculated));
|
|
3904
|
-
}
|
|
3905
|
-
function computeLabelSample(keys, candidates, yTickFormatter) {
|
|
3906
|
-
if (!keys || keys.length === 0) return "";
|
|
3907
|
-
return String(
|
|
3908
|
-
candidates.map((v) => yTickFormatter(v)).sort((a, b) => String(b).length - String(a).length)[0] ?? ""
|
|
3909
|
-
);
|
|
3910
|
-
}
|
|
3911
|
-
function computeEstimatedAxisNeeded(labelSample, axisLabel, containerPaddingLeft = 16, defaultLeftMargin = 0) {
|
|
3912
|
-
const tickW = labelSample ? estimateTextWidth(labelSample) : 0;
|
|
3913
|
-
const axisW = axisLabel ? estimateTextWidth(axisLabel) + 8 : 0;
|
|
3914
|
-
return Math.max(
|
|
3915
|
-
defaultLeftMargin,
|
|
3916
|
-
Math.ceil(tickW + axisW + containerPaddingLeft / 2)
|
|
3917
|
-
);
|
|
3918
|
-
}
|
|
3919
|
-
function computeAxisLabelWidth(label) {
|
|
3920
|
-
return label ? estimateTextWidth(label) : 0;
|
|
3921
|
-
}
|
|
3922
|
-
|
|
3923
|
-
// src/components/charts/hooks/useMeasureWidth.ts
|
|
3924
|
-
import { useLayoutEffect, useRef as useRef3, useState as useState7 } from "react";
|
|
3925
|
-
function useMeasureWidth() {
|
|
3926
|
-
const wrapperRef = useRef3(null);
|
|
3927
|
-
const [measuredWidth, setMeasuredWidth] = useState7(null);
|
|
3928
|
-
useLayoutEffect(() => {
|
|
3929
|
-
const el = wrapperRef.current;
|
|
3930
|
-
if (!el) return;
|
|
3931
|
-
const ro = new ResizeObserver((entries) => {
|
|
3932
|
-
const r = entries[0];
|
|
3933
|
-
if (r && typeof r.contentRect.width === "number") {
|
|
3934
|
-
setMeasuredWidth(Math.round(r.contentRect.width));
|
|
3625
|
+
const px = parseNumberLocal(x);
|
|
3626
|
+
const py = parseNumberLocal(y);
|
|
3627
|
+
const pWidth = parseNumberLocal(width);
|
|
3628
|
+
const pHeight = parseNumberLocal(height);
|
|
3629
|
+
const cxNum = parseNumberLocal(cx);
|
|
3630
|
+
const vb = viewBox;
|
|
3631
|
+
let centerX;
|
|
3632
|
+
if (typeof px === "number" && typeof pWidth === "number") {
|
|
3633
|
+
centerX = px + pWidth / 2;
|
|
3634
|
+
} else if (typeof cxNum === "number") {
|
|
3635
|
+
centerX = cxNum;
|
|
3636
|
+
} else if (vb && typeof vb.x === "number" && typeof vb.width === "number") {
|
|
3637
|
+
const approxCols = Math.max(1, index + 1);
|
|
3638
|
+
const colWidth = vb.width / approxCols;
|
|
3639
|
+
centerX = (vb.x ?? 0) + colWidth * (index + 0.5);
|
|
3640
|
+
} else {
|
|
3641
|
+
centerX = typeof index === "number" ? index * 40 + 24 : 0;
|
|
3642
|
+
}
|
|
3643
|
+
let centerY;
|
|
3644
|
+
if (typeof py === "number" && typeof pHeight === "number") {
|
|
3645
|
+
centerY = py + pHeight / 2;
|
|
3646
|
+
} else if (typeof cy === "number") {
|
|
3647
|
+
centerY = cy;
|
|
3648
|
+
} else if (vb && typeof vb.y === "number" && typeof vb.height === "number") {
|
|
3649
|
+
centerY = (vb.y ?? 0) + (vb.height ?? 0) / 2;
|
|
3650
|
+
} else {
|
|
3651
|
+
centerY = 0;
|
|
3652
|
+
}
|
|
3653
|
+
return /* @__PURE__ */ jsx27(
|
|
3654
|
+
"text",
|
|
3655
|
+
{
|
|
3656
|
+
x: centerX,
|
|
3657
|
+
y: centerY,
|
|
3658
|
+
fill: "#ffffff",
|
|
3659
|
+
fontSize: 10,
|
|
3660
|
+
fontWeight: 700,
|
|
3661
|
+
textAnchor: "middle",
|
|
3662
|
+
dominantBaseline: "central",
|
|
3663
|
+
style: { pointerEvents: "none" },
|
|
3664
|
+
children: text
|
|
3935
3665
|
}
|
|
3936
|
-
|
|
3937
|
-
ro.observe(el);
|
|
3938
|
-
setMeasuredWidth(Math.round(el.getBoundingClientRect().width));
|
|
3939
|
-
return () => ro.disconnect();
|
|
3940
|
-
}, []);
|
|
3941
|
-
return { wrapperRef, measuredWidth };
|
|
3942
|
-
}
|
|
3943
|
-
|
|
3944
|
-
// src/components/charts/hooks/useChartLayout.ts
|
|
3945
|
-
import { useMemo as useMemo5 } from "react";
|
|
3946
|
-
function useChartLayout(args) {
|
|
3947
|
-
const {
|
|
3948
|
-
width,
|
|
3949
|
-
measuredWidth,
|
|
3950
|
-
points,
|
|
3951
|
-
seriesCounts,
|
|
3952
|
-
niceMax,
|
|
3953
|
-
yAxes,
|
|
3954
|
-
yAxisLabel,
|
|
3955
|
-
chartMargin,
|
|
3956
|
-
showLabels,
|
|
3957
|
-
showLegend,
|
|
3958
|
-
xAxisLabel,
|
|
3959
|
-
leftLabelSample,
|
|
3960
|
-
rightLabelSample
|
|
3961
|
-
} = args;
|
|
3962
|
-
const containerPaddingLeft = 16;
|
|
3963
|
-
const defaultChartRightMargin = 30;
|
|
3964
|
-
const defaultChartLeftMargin = 0;
|
|
3965
|
-
const computedWidth = useMemo5(() => {
|
|
3966
|
-
if (typeof width === "number") return width;
|
|
3967
|
-
return computeChartWidth(points, seriesCounts, niceMax, {
|
|
3968
|
-
minWidth: 300,
|
|
3969
|
-
maxWidth: 1800
|
|
3970
|
-
});
|
|
3971
|
-
}, [
|
|
3972
|
-
width,
|
|
3973
|
-
points,
|
|
3974
|
-
seriesCounts.bar,
|
|
3975
|
-
seriesCounts.line,
|
|
3976
|
-
seriesCounts.area,
|
|
3977
|
-
niceMax
|
|
3978
|
-
]);
|
|
3979
|
-
const measuredInner = measuredWidth ? Math.max(0, measuredWidth - 32) : void 0;
|
|
3980
|
-
const effectiveChartWidth = typeof width === "number" ? width : measuredInner ?? computedWidth;
|
|
3981
|
-
const estimatedLeftNeeded = computeEstimatedAxisNeeded(
|
|
3982
|
-
leftLabelSample ?? "",
|
|
3983
|
-
yAxisLabel,
|
|
3984
|
-
containerPaddingLeft,
|
|
3985
|
-
defaultChartLeftMargin
|
|
3986
|
-
);
|
|
3987
|
-
const estimatedRightNeeded = computeEstimatedAxisNeeded(
|
|
3988
|
-
rightLabelSample ?? "",
|
|
3989
|
-
yAxes?.right?.label,
|
|
3990
|
-
containerPaddingLeft,
|
|
3991
|
-
defaultChartRightMargin
|
|
3992
|
-
);
|
|
3993
|
-
const finalChartLeftMargin = chartMargin?.left ?? Math.max(estimatedLeftNeeded, yAxisLabel ? 40 : defaultChartLeftMargin);
|
|
3994
|
-
const finalChartRightMargin = chartMargin?.right ?? Math.max(defaultChartRightMargin, estimatedRightNeeded);
|
|
3995
|
-
const finalChartTopMargin = chartMargin?.top ?? (showLabels ? 48 : 20);
|
|
3996
|
-
const baseBottom = chartMargin?.bottom ?? 5;
|
|
3997
|
-
const extraForXAxisLabel = xAxisLabel ? 22 : 0;
|
|
3998
|
-
const extraForLegend = showLegend ? 36 : 0;
|
|
3999
|
-
const finalChartBottomMargin = baseBottom + extraForXAxisLabel + extraForLegend;
|
|
4000
|
-
const chartInnerWidth = effectiveChartWidth - finalChartLeftMargin - finalChartRightMargin;
|
|
4001
|
-
const leftAxisLabelWidth = computeAxisLabelWidth(
|
|
4002
|
-
yAxes?.left?.label ?? yAxisLabel
|
|
4003
|
-
);
|
|
4004
|
-
const rightAxisLabelWidth = computeAxisLabelWidth(yAxes?.right?.label);
|
|
4005
|
-
const leftYAxisLabelDx = Math.ceil(leftAxisLabelWidth / 2) + 8;
|
|
4006
|
-
const rightYAxisLabelDx = Math.ceil(rightAxisLabelWidth / 2) + 8;
|
|
4007
|
-
return {
|
|
4008
|
-
containerPaddingLeft,
|
|
4009
|
-
computedWidth,
|
|
4010
|
-
measuredInner,
|
|
4011
|
-
effectiveChartWidth,
|
|
4012
|
-
chartInnerWidth,
|
|
4013
|
-
finalChartLeftMargin,
|
|
4014
|
-
finalChartRightMargin,
|
|
4015
|
-
finalChartTopMargin,
|
|
4016
|
-
finalChartBottomMargin,
|
|
4017
|
-
leftYAxisLabelDx,
|
|
4018
|
-
rightYAxisLabelDx
|
|
3666
|
+
);
|
|
4019
3667
|
};
|
|
4020
|
-
}
|
|
3668
|
+
};
|
|
4021
3669
|
|
|
4022
3670
|
// src/components/charts/Chart.tsx
|
|
4023
|
-
import {
|
|
3671
|
+
import { jsx as jsx28, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4024
3672
|
var DEFAULT_COLORS2 = ["#55af7d", "#8e68ff", "#2273e1"];
|
|
4025
3673
|
var Chart = ({
|
|
4026
3674
|
data,
|
|
@@ -4037,6 +3685,7 @@ var Chart = ({
|
|
|
4037
3685
|
titlePosition = "left",
|
|
4038
3686
|
showLabels = false,
|
|
4039
3687
|
xAxis,
|
|
3688
|
+
biaxial,
|
|
4040
3689
|
xAxisLabel,
|
|
4041
3690
|
yAxisLabel,
|
|
4042
3691
|
labelMap,
|
|
@@ -4047,14 +3696,12 @@ var Chart = ({
|
|
|
4047
3696
|
enablePeriodsDropdown = false,
|
|
4048
3697
|
enableDraggableTooltips = false,
|
|
4049
3698
|
showTooltipTotal = false,
|
|
3699
|
+
periodLabel = "Per\xEDodo",
|
|
4050
3700
|
maxTooltips = 5,
|
|
4051
3701
|
formatBR = false,
|
|
4052
|
-
chartMargin
|
|
4053
|
-
yAxisMap,
|
|
4054
|
-
yAxes,
|
|
4055
|
-
periodLabel = "Per\xEDodo"
|
|
3702
|
+
chartMargin
|
|
4056
3703
|
}) => {
|
|
4057
|
-
const smartConfig =
|
|
3704
|
+
const smartConfig = useMemo5(() => {
|
|
4058
3705
|
const resolvedXAxisKey = typeof xAxis === "string" ? xAxis : xAxis && xAxis.dataKey || detectXAxis(data);
|
|
4059
3706
|
const xAxisConfig2 = typeof xAxis === "string" ? {
|
|
4060
3707
|
dataKey: resolvedXAxisKey,
|
|
@@ -4078,34 +3725,98 @@ var Chart = ({
|
|
|
4078
3725
|
return { xAxisConfig: xAxisConfig2, mapperConfig: mapperConfig2 };
|
|
4079
3726
|
}, [data, xAxis, labelMap]);
|
|
4080
3727
|
const { xAxisConfig, mapperConfig } = smartConfig;
|
|
4081
|
-
const [activeTooltips, setActiveTooltips] =
|
|
4082
|
-
const [highlightedSeries, setHighlightedSeries] =
|
|
3728
|
+
const [activeTooltips, setActiveTooltips] = useState7([]);
|
|
3729
|
+
const [highlightedSeries, setHighlightedSeries] = useState7(
|
|
4083
3730
|
/* @__PURE__ */ new Set()
|
|
4084
3731
|
);
|
|
4085
|
-
const [showOnlyHighlighted, setShowOnlyHighlighted] =
|
|
3732
|
+
const [showOnlyHighlighted, setShowOnlyHighlighted] = useState7(false);
|
|
4086
3733
|
useEffect5(() => {
|
|
4087
3734
|
if (highlightedSeries.size === 0 && showOnlyHighlighted) {
|
|
4088
3735
|
setShowOnlyHighlighted(false);
|
|
4089
3736
|
}
|
|
4090
3737
|
}, [highlightedSeries, showOnlyHighlighted]);
|
|
4091
|
-
const processedData =
|
|
4092
|
-
|
|
4093
|
-
xAxisConfig.dataKey
|
|
4094
|
-
);
|
|
4095
|
-
const
|
|
4096
|
-
const
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
()
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
|
|
3738
|
+
const processedData = data.map((item) => ({
|
|
3739
|
+
...item,
|
|
3740
|
+
name: String(item[xAxisConfig.dataKey] || "N/A")
|
|
3741
|
+
}));
|
|
3742
|
+
const wrapperRef = useRef3(null);
|
|
3743
|
+
const [measuredWidth, setMeasuredWidth] = useState7(null);
|
|
3744
|
+
useLayoutEffect(() => {
|
|
3745
|
+
const el = wrapperRef.current;
|
|
3746
|
+
if (!el) return;
|
|
3747
|
+
const ro = new ResizeObserver((entries) => {
|
|
3748
|
+
const r = entries[0];
|
|
3749
|
+
if (r && typeof r.contentRect.width === "number") {
|
|
3750
|
+
setMeasuredWidth(Math.round(r.contentRect.width));
|
|
3751
|
+
}
|
|
3752
|
+
});
|
|
3753
|
+
ro.observe(el);
|
|
3754
|
+
setMeasuredWidth(Math.round(el.getBoundingClientRect().width));
|
|
3755
|
+
return () => ro.disconnect();
|
|
3756
|
+
}, []);
|
|
3757
|
+
const seriesOrder = [];
|
|
3758
|
+
if (series) {
|
|
3759
|
+
if (series.bar)
|
|
3760
|
+
series.bar.forEach((k) => seriesOrder.push({ type: "bar", key: k }));
|
|
3761
|
+
if (series.line)
|
|
3762
|
+
series.line.forEach((k) => seriesOrder.push({ type: "line", key: k }));
|
|
3763
|
+
if (series.area)
|
|
3764
|
+
series.area.forEach((k) => seriesOrder.push({ type: "area", key: k }));
|
|
3765
|
+
} else {
|
|
3766
|
+
Object.keys(mapperConfig).forEach(
|
|
3767
|
+
(k) => seriesOrder.push({ type: "bar", key: k })
|
|
3768
|
+
);
|
|
3769
|
+
}
|
|
3770
|
+
const allKeys = seriesOrder.map((s) => s.key).filter(Boolean);
|
|
3771
|
+
const generateColors = useCallback5(
|
|
3772
|
+
(dataKeys) => {
|
|
3773
|
+
const colorMap = {};
|
|
3774
|
+
const allColors = generateAdditionalColors(colors2, dataKeys.length);
|
|
3775
|
+
dataKeys.forEach((key, index) => {
|
|
3776
|
+
colorMap[key] = mapperConfig[key]?.color || allColors[index] || colors2[index % colors2.length];
|
|
3777
|
+
});
|
|
3778
|
+
return colorMap;
|
|
3779
|
+
},
|
|
3780
|
+
[colors2, mapperConfig]
|
|
3781
|
+
);
|
|
3782
|
+
const finalColors = useMemo5(
|
|
3783
|
+
() => generateColors(allKeys),
|
|
3784
|
+
[generateColors, allKeys]
|
|
3785
|
+
);
|
|
3786
|
+
const biaxialConfigNormalized = useMemo5(() => {
|
|
3787
|
+
if (!biaxial) return null;
|
|
3788
|
+
if (typeof biaxial === "string") return { key: [biaxial] };
|
|
3789
|
+
if (Array.isArray(biaxial)) return { key: biaxial };
|
|
3790
|
+
return biaxial;
|
|
3791
|
+
}, [biaxial]);
|
|
3792
|
+
useMemo5(() => {
|
|
3793
|
+
if (!biaxialConfigNormalized) return;
|
|
3794
|
+
const leftLabelMissing = !yAxisLabel || String(yAxisLabel).trim() === "";
|
|
3795
|
+
const rightLabelMissing = !biaxialConfigNormalized.label || String(biaxialConfigNormalized.label).trim() === "";
|
|
3796
|
+
if (leftLabelMissing || rightLabelMissing) {
|
|
3797
|
+
throw new Error(
|
|
3798
|
+
"When using `biaxial`, you must provide both `yAxisLabel` (left axis) and `biaxial.label` (right axis)."
|
|
3799
|
+
);
|
|
3800
|
+
}
|
|
3801
|
+
}, [biaxialConfigNormalized, yAxisLabel]);
|
|
3802
|
+
const rightKeys = useMemo5(
|
|
3803
|
+
() => biaxialConfigNormalized?.key ?? [],
|
|
3804
|
+
[biaxialConfigNormalized]
|
|
3805
|
+
);
|
|
3806
|
+
const leftKeys = useMemo5(
|
|
3807
|
+
() => allKeys.filter((k) => !rightKeys.includes(k)),
|
|
3808
|
+
[allKeys, rightKeys]
|
|
3809
|
+
);
|
|
3810
|
+
const adaptDataForTooltip = useCallback5(
|
|
3811
|
+
(universalData) => ({
|
|
3812
|
+
...universalData,
|
|
3813
|
+
name: String(universalData[xAxisConfig.dataKey] || "N/A")
|
|
3814
|
+
}),
|
|
4104
3815
|
[xAxisConfig.dataKey]
|
|
4105
3816
|
);
|
|
4106
|
-
const activePeriods =
|
|
4107
|
-
() => activeTooltips.map((t) =>
|
|
4108
|
-
[activeTooltips,
|
|
3817
|
+
const activePeriods = useMemo5(
|
|
3818
|
+
() => activeTooltips.map((t) => adaptDataForTooltip(t.data).name),
|
|
3819
|
+
[activeTooltips, adaptDataForTooltip]
|
|
4109
3820
|
);
|
|
4110
3821
|
useEffect5(() => {
|
|
4111
3822
|
window.dispatchEvent(new Event("recountTooltips"));
|
|
@@ -4118,46 +3829,103 @@ var Chart = ({
|
|
|
4118
3829
|
return next;
|
|
4119
3830
|
});
|
|
4120
3831
|
}, []);
|
|
4121
|
-
const
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
);
|
|
4133
|
-
const
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
3832
|
+
const maxLeftDataValue = useMemo5(() => {
|
|
3833
|
+
let max = 0;
|
|
3834
|
+
const numericKeys = leftKeys.length > 0 ? leftKeys : allKeys;
|
|
3835
|
+
for (const row of processedData) {
|
|
3836
|
+
const r = row;
|
|
3837
|
+
for (const key of numericKeys) {
|
|
3838
|
+
const v = r[key];
|
|
3839
|
+
if (typeof v === "number" && Number.isFinite(v) && v > max) max = v;
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
return max;
|
|
3843
|
+
}, [processedData, leftKeys, allKeys]);
|
|
3844
|
+
const minLeftDataValue = useMemo5(() => {
|
|
3845
|
+
let min = 0;
|
|
3846
|
+
const numericKeys = leftKeys.length > 0 ? leftKeys : allKeys;
|
|
3847
|
+
for (const row of processedData) {
|
|
3848
|
+
const r = row;
|
|
3849
|
+
for (const key of numericKeys) {
|
|
3850
|
+
const v = r[key];
|
|
3851
|
+
if (typeof v === "number" && Number.isFinite(v) && v < min)
|
|
3852
|
+
min = v;
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
return min;
|
|
3856
|
+
}, [processedData, leftKeys, allKeys]);
|
|
3857
|
+
const maxRightDataValue = useMemo5(() => {
|
|
3858
|
+
let max = 0;
|
|
3859
|
+
if (rightKeys.length === 0) return max;
|
|
3860
|
+
for (const row of processedData) {
|
|
3861
|
+
const r = row;
|
|
3862
|
+
for (const key of rightKeys) {
|
|
3863
|
+
const v = r[key];
|
|
3864
|
+
if (typeof v === "number" && Number.isFinite(v) && v > max) max = v;
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
return max;
|
|
3868
|
+
}, [processedData, rightKeys]);
|
|
3869
|
+
const minRightDataValue = useMemo5(() => {
|
|
3870
|
+
let min = 0;
|
|
3871
|
+
if (rightKeys.length === 0) return min;
|
|
3872
|
+
for (const row of processedData) {
|
|
3873
|
+
const r = row;
|
|
3874
|
+
for (const key of rightKeys) {
|
|
3875
|
+
const v = r[key];
|
|
3876
|
+
if (typeof v === "number" && Number.isFinite(v) && v < min)
|
|
3877
|
+
min = v;
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
return min;
|
|
3881
|
+
}, [processedData, rightKeys]);
|
|
3882
|
+
const computeNiceMax = useCallback5((maxValue) => {
|
|
3883
|
+
let padding = 0.08;
|
|
3884
|
+
if (maxValue > 1e6) padding = 0.05;
|
|
3885
|
+
if (maxValue > 1e7) padding = 0.03;
|
|
3886
|
+
if (maxValue === 0) padding = 0.12;
|
|
3887
|
+
const padded = maxValue * (1 + padding);
|
|
3888
|
+
return niceCeil(padded);
|
|
3889
|
+
}, []);
|
|
3890
|
+
const niceMaxLeft = useMemo5(
|
|
3891
|
+
() => computeNiceMax(maxLeftDataValue),
|
|
3892
|
+
[computeNiceMax, maxLeftDataValue]
|
|
4156
3893
|
);
|
|
4157
|
-
const
|
|
4158
|
-
() =>
|
|
4159
|
-
[
|
|
3894
|
+
const niceMaxRight = useMemo5(
|
|
3895
|
+
() => computeNiceMax(maxRightDataValue),
|
|
3896
|
+
[computeNiceMax, maxRightDataValue]
|
|
4160
3897
|
);
|
|
3898
|
+
const computedWidth = useMemo5(() => {
|
|
3899
|
+
if (typeof width === "number") return width;
|
|
3900
|
+
const points = Math.max(1, processedData.length);
|
|
3901
|
+
const barCount = series?.bar?.length ?? 0;
|
|
3902
|
+
const lineCount = series?.line?.length ?? 0;
|
|
3903
|
+
const areaCount = series?.area?.length ?? 0;
|
|
3904
|
+
const basePerPoint = 60;
|
|
3905
|
+
const perBarExtra = barCount > 0 ? Math.max(0, barCount - 1) * 8 : 0;
|
|
3906
|
+
const perOtherExtra = (lineCount + areaCount) * 4;
|
|
3907
|
+
const overallNiceMax = Math.max(niceMaxLeft || 0, niceMaxRight || 0);
|
|
3908
|
+
let sizeFactor = 1;
|
|
3909
|
+
if (overallNiceMax > 1e5) sizeFactor = 1.1;
|
|
3910
|
+
if (overallNiceMax > 1e6) sizeFactor = 1.2;
|
|
3911
|
+
if (overallNiceMax > 1e7) sizeFactor = 1.3;
|
|
3912
|
+
const perPoint = Math.round(
|
|
3913
|
+
(basePerPoint + perBarExtra + perOtherExtra) * sizeFactor
|
|
3914
|
+
);
|
|
3915
|
+
const marginExtra = 120;
|
|
3916
|
+
const calculated = points * perPoint + marginExtra;
|
|
3917
|
+
const minWidth = 300;
|
|
3918
|
+
const maxWidth = 1800;
|
|
3919
|
+
return Math.max(minWidth, Math.min(maxWidth, calculated));
|
|
3920
|
+
}, [
|
|
3921
|
+
width,
|
|
3922
|
+
processedData.length,
|
|
3923
|
+
series?.bar?.length,
|
|
3924
|
+
series?.line?.length,
|
|
3925
|
+
series?.area?.length,
|
|
3926
|
+
niceMaxLeft,
|
|
3927
|
+
niceMaxRight
|
|
3928
|
+
]);
|
|
4161
3929
|
const toggleTooltip = useCallback5(
|
|
4162
3930
|
(tooltipId, data2, basePosition) => {
|
|
4163
3931
|
const existingIndex = activeTooltips.findIndex((t) => t.id === tooltipId);
|
|
@@ -4238,74 +4006,93 @@ var Chart = ({
|
|
|
4238
4006
|
},
|
|
4239
4007
|
[]
|
|
4240
4008
|
);
|
|
4241
|
-
const titleClassName =
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
[valueFormatter2, formatBR]
|
|
4245
|
-
);
|
|
4246
|
-
const yTickFormatter = useMemo6(
|
|
4247
|
-
() => createYTickFormatter(finalValueFormatter),
|
|
4248
|
-
[finalValueFormatter]
|
|
4009
|
+
const titleClassName = useMemo5(
|
|
4010
|
+
() => "text-xl font-semibold text-foreground mb-3",
|
|
4011
|
+
[]
|
|
4249
4012
|
);
|
|
4013
|
+
const finalValueFormatter = useMemo5(() => {
|
|
4014
|
+
const nf = new Intl.NumberFormat("pt-BR", {
|
|
4015
|
+
minimumFractionDigits: 2,
|
|
4016
|
+
maximumFractionDigits: 2
|
|
4017
|
+
});
|
|
4018
|
+
if (valueFormatter2) {
|
|
4019
|
+
if (formatBR) {
|
|
4020
|
+
const wrapped = (props) => {
|
|
4021
|
+
const { value, formattedValue } = props;
|
|
4022
|
+
let num = NaN;
|
|
4023
|
+
if (typeof value === "number") num = value;
|
|
4024
|
+
else if (typeof value === "string" && value.trim() !== "") {
|
|
4025
|
+
const parsed = Number(value);
|
|
4026
|
+
num = Number.isNaN(parsed) ? NaN : parsed;
|
|
4027
|
+
}
|
|
4028
|
+
const brFormatted = !Number.isNaN(num) ? nf.format(num) : String(formattedValue ?? value ?? "");
|
|
4029
|
+
return valueFormatter2({
|
|
4030
|
+
...props,
|
|
4031
|
+
formattedValue: brFormatted,
|
|
4032
|
+
value: void 0
|
|
4033
|
+
});
|
|
4034
|
+
};
|
|
4035
|
+
return wrapped;
|
|
4036
|
+
}
|
|
4037
|
+
return valueFormatter2;
|
|
4038
|
+
}
|
|
4039
|
+
if (!formatBR) return void 0;
|
|
4040
|
+
const builtIn = (props) => {
|
|
4041
|
+
const { value, formattedValue } = props;
|
|
4042
|
+
let num = NaN;
|
|
4043
|
+
if (typeof value === "number") num = value;
|
|
4044
|
+
else if (typeof value === "string" && value.trim() !== "") {
|
|
4045
|
+
const parsed = Number(value);
|
|
4046
|
+
num = Number.isNaN(parsed) ? NaN : parsed;
|
|
4047
|
+
}
|
|
4048
|
+
if (!Number.isNaN(num)) return nf.format(num);
|
|
4049
|
+
return String(formattedValue ?? value ?? "");
|
|
4050
|
+
};
|
|
4051
|
+
return builtIn;
|
|
4052
|
+
}, [valueFormatter2, formatBR]);
|
|
4053
|
+
const yTickFormatter = useMemo5(() => {
|
|
4054
|
+
const nf = new Intl.NumberFormat("pt-BR", {
|
|
4055
|
+
minimumFractionDigits: 2,
|
|
4056
|
+
maximumFractionDigits: 2
|
|
4057
|
+
});
|
|
4058
|
+
const stripCurrency = (s) => String(s).replace(/^\s*R\$\s?/, "");
|
|
4059
|
+
if (finalValueFormatter) {
|
|
4060
|
+
return (v) => {
|
|
4061
|
+
const num = Number(String(v));
|
|
4062
|
+
const formatted = Number.isNaN(num) ? String(v ?? "") : nf.format(num);
|
|
4063
|
+
const out = finalValueFormatter({
|
|
4064
|
+
value: v,
|
|
4065
|
+
formattedValue: formatted
|
|
4066
|
+
});
|
|
4067
|
+
return stripCurrency(String(out));
|
|
4068
|
+
};
|
|
4069
|
+
}
|
|
4070
|
+
return (value) => {
|
|
4071
|
+
const num = Number(String(value));
|
|
4072
|
+
return Number.isNaN(num) ? String(value ?? "") : nf.format(num);
|
|
4073
|
+
};
|
|
4074
|
+
}, [finalValueFormatter]);
|
|
4250
4075
|
const finalEnableHighlights = enableHighlights;
|
|
4251
4076
|
const finalEnableShowOnly = enableShowOnly;
|
|
4252
4077
|
const finalEnablePeriodsDropdown = enablePeriodsDropdown && enableDraggableTooltips;
|
|
4253
|
-
const
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
const
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
const
|
|
4270
|
-
|
|
4271
|
-
computedWidth,
|
|
4272
|
-
measuredInner,
|
|
4273
|
-
chartInnerWidth,
|
|
4274
|
-
finalChartLeftMargin,
|
|
4275
|
-
finalChartRightMargin,
|
|
4276
|
-
finalChartTopMargin,
|
|
4277
|
-
finalChartBottomMargin,
|
|
4278
|
-
leftYAxisLabelDx,
|
|
4279
|
-
rightYAxisLabelDx
|
|
4280
|
-
} = useChartLayout({
|
|
4281
|
-
width,
|
|
4282
|
-
measuredWidth,
|
|
4283
|
-
points: Math.max(1, processedData.length),
|
|
4284
|
-
seriesCounts: {
|
|
4285
|
-
bar: series?.bar?.length ?? 0,
|
|
4286
|
-
line: series?.line?.length ?? 0,
|
|
4287
|
-
area: series?.area?.length ?? 0
|
|
4288
|
-
},
|
|
4289
|
-
niceMax,
|
|
4290
|
-
yAxes,
|
|
4291
|
-
yAxisLabel,
|
|
4292
|
-
chartMargin,
|
|
4293
|
-
showLabels,
|
|
4294
|
-
showLegend,
|
|
4295
|
-
xAxisLabel,
|
|
4296
|
-
leftLabelSample,
|
|
4297
|
-
rightLabelSample
|
|
4298
|
-
});
|
|
4299
|
-
const leftAxisTickFormatter = useMemo6(() => {
|
|
4300
|
-
if (yAxes?.left?.percent)
|
|
4301
|
-
return buildPercentFormatter(yAxes.left.percentDecimals ?? 0);
|
|
4302
|
-
return yTickFormatter;
|
|
4303
|
-
}, [yAxes?.left, yTickFormatter]);
|
|
4304
|
-
const rightAxisTickFormatter = useMemo6(() => {
|
|
4305
|
-
if (yAxes?.right?.percent)
|
|
4306
|
-
return buildPercentFormatter(yAxes.right.percentDecimals ?? 0);
|
|
4307
|
-
return yTickFormatter;
|
|
4308
|
-
}, [yAxes?.right, yTickFormatter]);
|
|
4078
|
+
const defaultChartRightMargin = 30;
|
|
4079
|
+
const defaultChartLeftMargin = 0;
|
|
4080
|
+
const axisLabelMargin = 56;
|
|
4081
|
+
const containerPaddingLeft = 16;
|
|
4082
|
+
const finalChartRightMargin = chartMargin?.right ?? (rightKeys.length > 0 ? axisLabelMargin : defaultChartRightMargin);
|
|
4083
|
+
const finalChartLeftMargin = chartMargin?.left ?? (yAxisLabel ? axisLabelMargin : defaultChartLeftMargin);
|
|
4084
|
+
const composedChartLeftMargin = chartMargin?.left ?? defaultChartLeftMargin;
|
|
4085
|
+
const composedChartRightMargin = chartMargin?.right ?? defaultChartRightMargin;
|
|
4086
|
+
const finalChartTopMargin = chartMargin?.top ?? (showLabels ? 48 : 20);
|
|
4087
|
+
const baseBottom = chartMargin?.bottom ?? 5;
|
|
4088
|
+
const extraForXAxisLabel = xAxisLabel ? 22 : 0;
|
|
4089
|
+
const extraForLegend = showLegend ? 36 : 0;
|
|
4090
|
+
const finalChartBottomMargin = baseBottom + extraForXAxisLabel + extraForLegend;
|
|
4091
|
+
const measuredInner = measuredWidth ? Math.max(0, measuredWidth - 32) : void 0;
|
|
4092
|
+
const effectiveChartWidth = typeof width === "number" ? width : measuredInner ?? computedWidth;
|
|
4093
|
+
const chartInnerWidth = effectiveChartWidth - composedChartLeftMargin - composedChartRightMargin;
|
|
4094
|
+
const leftYAxisLabelDx = -Math.max(12, Math.round(finalChartLeftMargin / 2));
|
|
4095
|
+
const rightYAxisLabelDx = Math.max(12, Math.round(finalChartRightMargin / 2));
|
|
4309
4096
|
const openTooltipForPeriod = useCallback5(
|
|
4310
4097
|
(periodName) => {
|
|
4311
4098
|
if (!enableDraggableTooltips) return;
|
|
@@ -4351,31 +4138,41 @@ var Chart = ({
|
|
|
4351
4138
|
);
|
|
4352
4139
|
if (!data) return null;
|
|
4353
4140
|
if (Array.isArray(data) && data.length === 0) {
|
|
4354
|
-
return /* @__PURE__ */
|
|
4355
|
-
|
|
4141
|
+
return /* @__PURE__ */ jsx28(
|
|
4142
|
+
"div",
|
|
4356
4143
|
{
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4144
|
+
className: cn(
|
|
4145
|
+
"rounded-lg bg-card p-4 relative w-full text-muted-foreground"
|
|
4146
|
+
),
|
|
4147
|
+
children: /* @__PURE__ */ jsx28(
|
|
4148
|
+
"div",
|
|
4149
|
+
{
|
|
4150
|
+
style: {
|
|
4151
|
+
paddingLeft: `${containerPaddingLeft + finalChartLeftMargin}px`
|
|
4152
|
+
},
|
|
4153
|
+
children: "Sem dados para exibir"
|
|
4154
|
+
}
|
|
4155
|
+
)
|
|
4360
4156
|
}
|
|
4361
4157
|
);
|
|
4362
4158
|
}
|
|
4363
|
-
return /* @__PURE__ */
|
|
4159
|
+
return /* @__PURE__ */ jsx28(
|
|
4364
4160
|
"div",
|
|
4365
4161
|
{
|
|
4366
4162
|
ref: wrapperRef,
|
|
4367
4163
|
style: {
|
|
4368
4164
|
width: "100%",
|
|
4369
|
-
|
|
4165
|
+
overflowX: "hidden",
|
|
4166
|
+
overflowY: "hidden",
|
|
4370
4167
|
minWidth: 0
|
|
4371
4168
|
},
|
|
4372
|
-
children: /* @__PURE__ */
|
|
4169
|
+
children: /* @__PURE__ */ jsxs23(
|
|
4373
4170
|
"div",
|
|
4374
4171
|
{
|
|
4375
4172
|
className: cn("rounded-lg bg-card p-2 relative", className),
|
|
4376
4173
|
style: { width: "100%", maxWidth: "100%", minWidth: 0 },
|
|
4377
4174
|
children: [
|
|
4378
|
-
title && /* @__PURE__ */
|
|
4175
|
+
title && /* @__PURE__ */ jsx28(
|
|
4379
4176
|
"div",
|
|
4380
4177
|
{
|
|
4381
4178
|
style: {
|
|
@@ -4386,10 +4183,10 @@ var Chart = ({
|
|
|
4386
4183
|
alignItems: "center",
|
|
4387
4184
|
marginTop: 4
|
|
4388
4185
|
},
|
|
4389
|
-
children: /* @__PURE__ */
|
|
4186
|
+
children: /* @__PURE__ */ jsx28("h3", { className: titleClassName, children: title })
|
|
4390
4187
|
}
|
|
4391
4188
|
),
|
|
4392
|
-
allKeys.length > 0 && (finalEnableHighlights || finalEnableShowOnly) && /* @__PURE__ */
|
|
4189
|
+
allKeys.length > 0 && (finalEnableHighlights || finalEnableShowOnly) && /* @__PURE__ */ jsxs23(
|
|
4393
4190
|
"div",
|
|
4394
4191
|
{
|
|
4395
4192
|
className: "flex items-center w-full",
|
|
@@ -4401,7 +4198,7 @@ var Chart = ({
|
|
|
4401
4198
|
gap: "0.5rem"
|
|
4402
4199
|
},
|
|
4403
4200
|
children: [
|
|
4404
|
-
finalEnableHighlights && /* @__PURE__ */
|
|
4201
|
+
finalEnableHighlights && /* @__PURE__ */ jsx28(
|
|
4405
4202
|
Highlights_default,
|
|
4406
4203
|
{
|
|
4407
4204
|
allKeys,
|
|
@@ -4412,7 +4209,7 @@ var Chart = ({
|
|
|
4412
4209
|
containerWidth: chartInnerWidth
|
|
4413
4210
|
}
|
|
4414
4211
|
),
|
|
4415
|
-
finalEnableShowOnly && /* @__PURE__ */
|
|
4212
|
+
finalEnableShowOnly && /* @__PURE__ */ jsx28(
|
|
4416
4213
|
ShowOnly_default,
|
|
4417
4214
|
{
|
|
4418
4215
|
showOnlyHighlighted,
|
|
@@ -4421,7 +4218,7 @@ var Chart = ({
|
|
|
4421
4218
|
clearHighlights: () => setHighlightedSeries(/* @__PURE__ */ new Set())
|
|
4422
4219
|
}
|
|
4423
4220
|
),
|
|
4424
|
-
finalEnablePeriodsDropdown && /* @__PURE__ */
|
|
4221
|
+
finalEnablePeriodsDropdown && /* @__PURE__ */ jsx28(
|
|
4425
4222
|
"div",
|
|
4426
4223
|
{
|
|
4427
4224
|
style: {
|
|
@@ -4429,7 +4226,7 @@ var Chart = ({
|
|
|
4429
4226
|
display: "flex",
|
|
4430
4227
|
alignItems: "center"
|
|
4431
4228
|
},
|
|
4432
|
-
children: /* @__PURE__ */
|
|
4229
|
+
children: /* @__PURE__ */ jsx28(
|
|
4433
4230
|
PeriodsDropdown_default,
|
|
4434
4231
|
{
|
|
4435
4232
|
processedData,
|
|
@@ -4443,7 +4240,7 @@ var Chart = ({
|
|
|
4443
4240
|
]
|
|
4444
4241
|
}
|
|
4445
4242
|
),
|
|
4446
|
-
!(allKeys.length > 0 && (finalEnableHighlights || finalEnableShowOnly)) && finalEnablePeriodsDropdown && /* @__PURE__ */
|
|
4243
|
+
!(allKeys.length > 0 && (finalEnableHighlights || finalEnableShowOnly)) && finalEnablePeriodsDropdown && /* @__PURE__ */ jsx28(
|
|
4447
4244
|
"div",
|
|
4448
4245
|
{
|
|
4449
4246
|
style: {
|
|
@@ -4454,7 +4251,7 @@ var Chart = ({
|
|
|
4454
4251
|
display: "flex",
|
|
4455
4252
|
justifyContent: "flex-end"
|
|
4456
4253
|
},
|
|
4457
|
-
children: /* @__PURE__ */
|
|
4254
|
+
children: /* @__PURE__ */ jsx28(
|
|
4458
4255
|
PeriodsDropdown_default,
|
|
4459
4256
|
{
|
|
4460
4257
|
processedData,
|
|
@@ -4464,7 +4261,7 @@ var Chart = ({
|
|
|
4464
4261
|
)
|
|
4465
4262
|
}
|
|
4466
4263
|
),
|
|
4467
|
-
/* @__PURE__ */
|
|
4264
|
+
/* @__PURE__ */ jsx28(ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxs23(
|
|
4468
4265
|
ComposedChart,
|
|
4469
4266
|
{
|
|
4470
4267
|
data: processedData,
|
|
@@ -4477,7 +4274,7 @@ var Chart = ({
|
|
|
4477
4274
|
},
|
|
4478
4275
|
onClick: handleChartClick,
|
|
4479
4276
|
children: [
|
|
4480
|
-
showGrid && /* @__PURE__ */
|
|
4277
|
+
showGrid && /* @__PURE__ */ jsx28(
|
|
4481
4278
|
CartesianGrid,
|
|
4482
4279
|
{
|
|
4483
4280
|
strokeDasharray: "3 3",
|
|
@@ -4485,7 +4282,7 @@ var Chart = ({
|
|
|
4485
4282
|
opacity: 0.5
|
|
4486
4283
|
}
|
|
4487
4284
|
),
|
|
4488
|
-
/* @__PURE__ */
|
|
4285
|
+
/* @__PURE__ */ jsx28(
|
|
4489
4286
|
XAxis,
|
|
4490
4287
|
{
|
|
4491
4288
|
dataKey: xAxisConfig.dataKey,
|
|
@@ -4502,8 +4299,8 @@ var Chart = ({
|
|
|
4502
4299
|
},
|
|
4503
4300
|
label: xAxisLabel ? {
|
|
4504
4301
|
value: xAxisLabel,
|
|
4505
|
-
position: "
|
|
4506
|
-
offset:
|
|
4302
|
+
position: "insideBottomRight",
|
|
4303
|
+
offset: -5,
|
|
4507
4304
|
style: {
|
|
4508
4305
|
fontSize: 12,
|
|
4509
4306
|
fill: "hsl(var(--muted-foreground))",
|
|
@@ -4512,75 +4309,23 @@ var Chart = ({
|
|
|
4512
4309
|
} : void 0
|
|
4513
4310
|
}
|
|
4514
4311
|
),
|
|
4515
|
-
|
|
4516
|
-
/* @__PURE__ */ jsx29(
|
|
4517
|
-
YAxis,
|
|
4518
|
-
{
|
|
4519
|
-
yAxisId: "left",
|
|
4520
|
-
stroke: yAxes?.left?.stroke || "hsl(var(--muted-foreground))",
|
|
4521
|
-
width: yAxes?.left?.width,
|
|
4522
|
-
fontSize: 12,
|
|
4523
|
-
tickLine: false,
|
|
4524
|
-
axisLine: false,
|
|
4525
|
-
tickFormatter: leftAxisTickFormatter,
|
|
4526
|
-
domain: [Math.min(minLeft, 0), niceMaxLeft],
|
|
4527
|
-
tickCount: 6,
|
|
4528
|
-
label: yAxes?.left?.label ?? yAxisLabel ? {
|
|
4529
|
-
value: yAxes?.left?.label ?? yAxisLabel,
|
|
4530
|
-
angle: -90,
|
|
4531
|
-
position: "left",
|
|
4532
|
-
dx: -leftYAxisLabelDx,
|
|
4533
|
-
style: {
|
|
4534
|
-
fontSize: 12,
|
|
4535
|
-
fill: "hsl(var(--muted-foreground))",
|
|
4536
|
-
fontWeight: 500,
|
|
4537
|
-
textAnchor: "middle"
|
|
4538
|
-
}
|
|
4539
|
-
} : void 0
|
|
4540
|
-
}
|
|
4541
|
-
),
|
|
4542
|
-
/* @__PURE__ */ jsx29(
|
|
4543
|
-
YAxis,
|
|
4544
|
-
{
|
|
4545
|
-
yAxisId: "right",
|
|
4546
|
-
orientation: "right",
|
|
4547
|
-
stroke: yAxes?.right?.stroke || "hsl(var(--muted-foreground))",
|
|
4548
|
-
width: yAxes?.right?.width,
|
|
4549
|
-
fontSize: 12,
|
|
4550
|
-
tickLine: false,
|
|
4551
|
-
axisLine: false,
|
|
4552
|
-
tickFormatter: rightAxisTickFormatter,
|
|
4553
|
-
domain: [Math.min(minRight, 0), niceMaxRight],
|
|
4554
|
-
tickCount: 6,
|
|
4555
|
-
label: yAxes?.right?.label ? {
|
|
4556
|
-
value: yAxes?.right?.label,
|
|
4557
|
-
angle: -90,
|
|
4558
|
-
position: "right",
|
|
4559
|
-
dx: rightYAxisLabelDx,
|
|
4560
|
-
style: {
|
|
4561
|
-
fontSize: 12,
|
|
4562
|
-
fill: "hsl(var(--muted-foreground))",
|
|
4563
|
-
fontWeight: 500,
|
|
4564
|
-
textAnchor: "middle"
|
|
4565
|
-
}
|
|
4566
|
-
} : void 0
|
|
4567
|
-
}
|
|
4568
|
-
)
|
|
4569
|
-
] }) : /* @__PURE__ */ jsx29(Fragment7, { children: /* @__PURE__ */ jsx29(
|
|
4312
|
+
/* @__PURE__ */ jsx28(
|
|
4570
4313
|
YAxis,
|
|
4571
4314
|
{
|
|
4315
|
+
yAxisId: "left",
|
|
4316
|
+
width: finalChartLeftMargin,
|
|
4572
4317
|
stroke: "hsl(var(--muted-foreground))",
|
|
4573
4318
|
fontSize: 12,
|
|
4574
4319
|
tickLine: false,
|
|
4575
4320
|
axisLine: false,
|
|
4576
4321
|
tickFormatter: yTickFormatter,
|
|
4577
|
-
domain: [Math.min(
|
|
4322
|
+
domain: [Math.min(minLeftDataValue, 0), niceMaxLeft],
|
|
4578
4323
|
tickCount: 6,
|
|
4579
4324
|
label: yAxisLabel ? {
|
|
4580
4325
|
value: yAxisLabel,
|
|
4581
4326
|
angle: -90,
|
|
4582
4327
|
position: "left",
|
|
4583
|
-
dx:
|
|
4328
|
+
dx: leftYAxisLabelDx,
|
|
4584
4329
|
style: {
|
|
4585
4330
|
fontSize: 12,
|
|
4586
4331
|
fill: "hsl(var(--muted-foreground))",
|
|
@@ -4589,44 +4334,94 @@ var Chart = ({
|
|
|
4589
4334
|
}
|
|
4590
4335
|
} : void 0
|
|
4591
4336
|
}
|
|
4592
|
-
)
|
|
4593
|
-
|
|
4337
|
+
),
|
|
4338
|
+
minLeftDataValue < 0 && /* @__PURE__ */ jsx28(
|
|
4594
4339
|
ReferenceLine,
|
|
4595
4340
|
{
|
|
4596
4341
|
y: 0,
|
|
4342
|
+
yAxisId: "left",
|
|
4597
4343
|
stroke: "hsl(var(--muted-foreground))",
|
|
4598
4344
|
strokeWidth: 1,
|
|
4599
4345
|
strokeDasharray: "4 4"
|
|
4600
4346
|
}
|
|
4601
4347
|
),
|
|
4602
|
-
|
|
4348
|
+
rightKeys.length > 0 && (() => {
|
|
4349
|
+
const decimals = typeof biaxialConfigNormalized?.decimals === "number" ? Math.max(0, Math.floor(biaxialConfigNormalized.decimals)) : 2;
|
|
4350
|
+
const rightTickFormatter = (v) => {
|
|
4351
|
+
if (biaxialConfigNormalized?.percentage) {
|
|
4352
|
+
const num = Number(String(v));
|
|
4353
|
+
const nf = new Intl.NumberFormat("pt-BR", {
|
|
4354
|
+
minimumFractionDigits: decimals,
|
|
4355
|
+
maximumFractionDigits: decimals
|
|
4356
|
+
});
|
|
4357
|
+
const out = Number.isNaN(num) ? String(v ?? "") : nf.format(num);
|
|
4358
|
+
return `${out}%`;
|
|
4359
|
+
}
|
|
4360
|
+
return yTickFormatter(v);
|
|
4361
|
+
};
|
|
4362
|
+
const firstRightKey = biaxialConfigNormalized?.key && biaxialConfigNormalized.key[0];
|
|
4363
|
+
const defaultRightColor = firstRightKey && finalColors[firstRightKey] || "hsl(var(--muted-foreground))";
|
|
4364
|
+
const rightAxisColor = (() => {
|
|
4365
|
+
if (!biaxialConfigNormalized) return defaultRightColor;
|
|
4366
|
+
if (typeof biaxialConfigNormalized.stroke === "string")
|
|
4367
|
+
return biaxialConfigNormalized.stroke;
|
|
4368
|
+
if (biaxialConfigNormalized.stroke && firstRightKey && typeof biaxialConfigNormalized.stroke === "object")
|
|
4369
|
+
return biaxialConfigNormalized.stroke[firstRightKey] || defaultRightColor;
|
|
4370
|
+
return defaultRightColor;
|
|
4371
|
+
})();
|
|
4372
|
+
return /* @__PURE__ */ jsx28(
|
|
4373
|
+
YAxis,
|
|
4374
|
+
{
|
|
4375
|
+
yAxisId: "right",
|
|
4376
|
+
width: finalChartRightMargin,
|
|
4377
|
+
orientation: "right",
|
|
4378
|
+
stroke: "hsl(var(--muted-foreground))",
|
|
4379
|
+
fontSize: 12,
|
|
4380
|
+
tickLine: false,
|
|
4381
|
+
axisLine: false,
|
|
4382
|
+
tick: { fill: rightAxisColor },
|
|
4383
|
+
tickFormatter: rightTickFormatter,
|
|
4384
|
+
domain: [Math.min(minRightDataValue, 0), niceMaxRight],
|
|
4385
|
+
tickCount: 6,
|
|
4386
|
+
label: biaxialConfigNormalized?.label ? {
|
|
4387
|
+
value: biaxialConfigNormalized.label,
|
|
4388
|
+
angle: -90,
|
|
4389
|
+
position: "right",
|
|
4390
|
+
dx: rightYAxisLabelDx,
|
|
4391
|
+
style: {
|
|
4392
|
+
fontSize: 12,
|
|
4393
|
+
fill: "hsl(var(--muted-foreground))",
|
|
4394
|
+
fontWeight: 500,
|
|
4395
|
+
textAnchor: "middle"
|
|
4396
|
+
}
|
|
4397
|
+
} : void 0
|
|
4398
|
+
}
|
|
4399
|
+
);
|
|
4400
|
+
})(),
|
|
4401
|
+
showTooltip && /* @__PURE__ */ jsx28(
|
|
4603
4402
|
Tooltip,
|
|
4604
4403
|
{
|
|
4605
|
-
content: showTooltipTotal ? /* @__PURE__ */
|
|
4404
|
+
content: showTooltipTotal ? /* @__PURE__ */ jsx28(
|
|
4606
4405
|
TooltipWithTotal_default,
|
|
4607
4406
|
{
|
|
4608
|
-
periodLabel,
|
|
4609
4407
|
finalColors,
|
|
4610
4408
|
valueFormatter: finalValueFormatter,
|
|
4611
4409
|
categoryFormatter,
|
|
4612
|
-
|
|
4613
|
-
isBiaxial: rightKeys.length > 0
|
|
4410
|
+
periodLabel
|
|
4614
4411
|
}
|
|
4615
|
-
) : /* @__PURE__ */
|
|
4412
|
+
) : /* @__PURE__ */ jsx28(
|
|
4616
4413
|
TooltipSimple_default,
|
|
4617
4414
|
{
|
|
4618
|
-
periodLabel,
|
|
4619
4415
|
finalColors,
|
|
4620
4416
|
valueFormatter: finalValueFormatter,
|
|
4621
4417
|
categoryFormatter,
|
|
4622
|
-
|
|
4623
|
-
isBiaxial: rightKeys.length > 0
|
|
4418
|
+
periodLabel
|
|
4624
4419
|
}
|
|
4625
4420
|
),
|
|
4626
4421
|
cursor: { fill: "hsl(var(--muted))", opacity: 0.1 }
|
|
4627
4422
|
}
|
|
4628
4423
|
),
|
|
4629
|
-
showLegend && /* @__PURE__ */
|
|
4424
|
+
showLegend && /* @__PURE__ */ jsx28(
|
|
4630
4425
|
Legend,
|
|
4631
4426
|
{
|
|
4632
4427
|
wrapperStyle: {
|
|
@@ -4638,25 +4433,23 @@ var Chart = ({
|
|
|
4638
4433
|
),
|
|
4639
4434
|
seriesOrder.map((s) => {
|
|
4640
4435
|
const key = s.key;
|
|
4641
|
-
const rawMapped = rightKeys.length > 0 ? yAxisMap?.[key] ?? "left" : void 0;
|
|
4642
|
-
const seriesYAxisId = (() => {
|
|
4643
|
-
if (rawMapped === void 0) return void 0;
|
|
4644
|
-
if (rawMapped === "left" || rawMapped === "right")
|
|
4645
|
-
return rawMapped;
|
|
4646
|
-
if (rawMapped === 1 || rawMapped === "1" || rawMapped === "right")
|
|
4647
|
-
return "right";
|
|
4648
|
-
return "left";
|
|
4649
|
-
})();
|
|
4650
4436
|
if (showOnlyHighlighted && !highlightedSeries.has(key))
|
|
4651
4437
|
return null;
|
|
4652
4438
|
const label = mapperConfig[key]?.label ?? labelMap?.[key] ?? formatFieldName(key);
|
|
4653
|
-
|
|
4439
|
+
let color = finalColors[key];
|
|
4440
|
+
if (rightKeys.includes(key) && biaxialConfigNormalized?.stroke) {
|
|
4441
|
+
if (typeof biaxialConfigNormalized.stroke === "string") {
|
|
4442
|
+
color = biaxialConfigNormalized.stroke;
|
|
4443
|
+
} else {
|
|
4444
|
+
color = biaxialConfigNormalized.stroke[key] ?? color;
|
|
4445
|
+
}
|
|
4446
|
+
}
|
|
4654
4447
|
if (s.type === "bar") {
|
|
4655
|
-
return /* @__PURE__ */
|
|
4448
|
+
return /* @__PURE__ */ jsx28(
|
|
4656
4449
|
Bar,
|
|
4657
4450
|
{
|
|
4658
|
-
yAxisId: seriesYAxisId,
|
|
4659
4451
|
dataKey: key,
|
|
4452
|
+
yAxisId: rightKeys.includes(key) ? "right" : "left",
|
|
4660
4453
|
name: label,
|
|
4661
4454
|
fill: color,
|
|
4662
4455
|
radius: [4, 4, 0, 0],
|
|
@@ -4665,7 +4458,7 @@ var Chart = ({
|
|
|
4665
4458
|
cursor: "pointer",
|
|
4666
4459
|
opacity: highlightedSeries.size > 0 ? highlightedSeries.has(key) ? 1 : 0.25 : 1
|
|
4667
4460
|
},
|
|
4668
|
-
activeBar: /* @__PURE__ */
|
|
4461
|
+
activeBar: /* @__PURE__ */ jsx28(
|
|
4669
4462
|
Rectangle,
|
|
4670
4463
|
{
|
|
4671
4464
|
fill: color,
|
|
@@ -4674,17 +4467,16 @@ var Chart = ({
|
|
|
4674
4467
|
opacity: 0.8
|
|
4675
4468
|
}
|
|
4676
4469
|
),
|
|
4677
|
-
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */
|
|
4470
|
+
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsx28(
|
|
4678
4471
|
LabelList,
|
|
4679
4472
|
{
|
|
4680
4473
|
dataKey: key,
|
|
4681
|
-
position: "
|
|
4682
|
-
content:
|
|
4474
|
+
position: "insideTop",
|
|
4475
|
+
content: renderInsideBarLabel(
|
|
4683
4476
|
color,
|
|
4684
|
-
"filled",
|
|
4685
4477
|
finalValueFormatter
|
|
4686
4478
|
),
|
|
4687
|
-
offset:
|
|
4479
|
+
offset: 0
|
|
4688
4480
|
}
|
|
4689
4481
|
) : null
|
|
4690
4482
|
},
|
|
@@ -4692,11 +4484,11 @@ var Chart = ({
|
|
|
4692
4484
|
);
|
|
4693
4485
|
}
|
|
4694
4486
|
if (s.type === "line") {
|
|
4695
|
-
return /* @__PURE__ */
|
|
4487
|
+
return /* @__PURE__ */ jsx28(
|
|
4696
4488
|
Line,
|
|
4697
4489
|
{
|
|
4698
|
-
yAxisId: seriesYAxisId,
|
|
4699
4490
|
dataKey: key,
|
|
4491
|
+
yAxisId: rightKeys.includes(key) ? "right" : "left",
|
|
4700
4492
|
name: label,
|
|
4701
4493
|
stroke: color,
|
|
4702
4494
|
strokeWidth: 2,
|
|
@@ -4708,7 +4500,7 @@ var Chart = ({
|
|
|
4708
4500
|
pointerEvents: "all",
|
|
4709
4501
|
opacity: highlightedSeries.size > 0 ? highlightedSeries.has(key) ? 1 : 0.25 : 1
|
|
4710
4502
|
},
|
|
4711
|
-
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */
|
|
4503
|
+
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsx28(
|
|
4712
4504
|
LabelList,
|
|
4713
4505
|
{
|
|
4714
4506
|
dataKey: key,
|
|
@@ -4726,11 +4518,11 @@ var Chart = ({
|
|
|
4726
4518
|
);
|
|
4727
4519
|
}
|
|
4728
4520
|
if (s.type === "area") {
|
|
4729
|
-
return /* @__PURE__ */
|
|
4521
|
+
return /* @__PURE__ */ jsx28(
|
|
4730
4522
|
Area,
|
|
4731
4523
|
{
|
|
4732
|
-
yAxisId: seriesYAxisId,
|
|
4733
4524
|
dataKey: key,
|
|
4525
|
+
yAxisId: rightKeys.includes(key) ? "right" : "left",
|
|
4734
4526
|
name: label,
|
|
4735
4527
|
stroke: color,
|
|
4736
4528
|
fill: color,
|
|
@@ -4742,7 +4534,7 @@ var Chart = ({
|
|
|
4742
4534
|
pointerEvents: "all",
|
|
4743
4535
|
opacity: highlightedSeries.size > 0 ? highlightedSeries.has(key) ? 1 : 0.25 : 1
|
|
4744
4536
|
},
|
|
4745
|
-
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */
|
|
4537
|
+
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsx28(
|
|
4746
4538
|
LabelList,
|
|
4747
4539
|
{
|
|
4748
4540
|
dataKey: key,
|
|
@@ -4764,11 +4556,11 @@ var Chart = ({
|
|
|
4764
4556
|
]
|
|
4765
4557
|
}
|
|
4766
4558
|
) }),
|
|
4767
|
-
enableDraggableTooltips && activeTooltips.map((tooltip) => /* @__PURE__ */
|
|
4559
|
+
enableDraggableTooltips && activeTooltips.map((tooltip) => /* @__PURE__ */ jsx28(
|
|
4768
4560
|
DraggableTooltip_default,
|
|
4769
4561
|
{
|
|
4770
4562
|
id: tooltip.id,
|
|
4771
|
-
data:
|
|
4563
|
+
data: adaptDataForTooltip(tooltip.data),
|
|
4772
4564
|
position: tooltip.position,
|
|
4773
4565
|
title,
|
|
4774
4566
|
dataKeys: allKeys,
|
|
@@ -4789,7 +4581,7 @@ var Chart = ({
|
|
|
4789
4581
|
},
|
|
4790
4582
|
tooltip.id
|
|
4791
4583
|
)),
|
|
4792
|
-
enableDraggableTooltips && activeTooltips.length > 1 && /* @__PURE__ */
|
|
4584
|
+
enableDraggableTooltips && activeTooltips.length > 1 && /* @__PURE__ */ jsx28(
|
|
4793
4585
|
CloseAllButton_default,
|
|
4794
4586
|
{
|
|
4795
4587
|
count: activeTooltips.length,
|
|
@@ -4807,7 +4599,7 @@ var Chart = ({
|
|
|
4807
4599
|
var Chart_default = Chart;
|
|
4808
4600
|
|
|
4809
4601
|
// src/components/charts/BarChart.tsx
|
|
4810
|
-
import { useState as
|
|
4602
|
+
import { useState as useState8, useEffect as useEffect6, useCallback as useCallback6, useMemo as useMemo6 } from "react";
|
|
4811
4603
|
import {
|
|
4812
4604
|
BarChart as RechartsBarChart,
|
|
4813
4605
|
Bar as Bar2,
|
|
@@ -4819,7 +4611,7 @@ import {
|
|
|
4819
4611
|
Legend as Legend2,
|
|
4820
4612
|
LabelList as LabelList2
|
|
4821
4613
|
} from "recharts";
|
|
4822
|
-
import { jsx as
|
|
4614
|
+
import { jsx as jsx29, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
4823
4615
|
var DEFAULT_COLORS3 = ["#55af7d", "#8e68ff", "#2273e1"];
|
|
4824
4616
|
var BarChart = ({
|
|
4825
4617
|
data,
|
|
@@ -4849,7 +4641,7 @@ var BarChart = ({
|
|
|
4849
4641
|
containerPaddingLeft,
|
|
4850
4642
|
16
|
|
4851
4643
|
);
|
|
4852
|
-
const smartConfig =
|
|
4644
|
+
const smartConfig = useMemo6(() => {
|
|
4853
4645
|
const providedMapper = yAxis ?? mapper;
|
|
4854
4646
|
if (autoDetect === true || xAxis == null || providedMapper == null) {
|
|
4855
4647
|
const detectedXAxis = detectXAxis(data);
|
|
@@ -4899,20 +4691,20 @@ var BarChart = ({
|
|
|
4899
4691
|
return { xAxisConfig: xAxisConfig2, mapperConfig: mapperConfig2 };
|
|
4900
4692
|
}, [data, xAxis, mapper, yAxis, autoDetect, labelMap]);
|
|
4901
4693
|
const { xAxisConfig, mapperConfig } = smartConfig;
|
|
4902
|
-
const [activeTooltips, setActiveTooltips] =
|
|
4903
|
-
const [isDragging, setIsDragging] =
|
|
4904
|
-
const [dragOffset, setDragOffset] =
|
|
4694
|
+
const [activeTooltips, setActiveTooltips] = useState8([]);
|
|
4695
|
+
const [isDragging, setIsDragging] = useState8(null);
|
|
4696
|
+
const [dragOffset, setDragOffset] = useState8({
|
|
4905
4697
|
x: 0,
|
|
4906
4698
|
y: 0
|
|
4907
4699
|
});
|
|
4908
|
-
const [globalTooltipCount, setGlobalTooltipCount] =
|
|
4909
|
-
const [alignmentGuides, setAlignmentGuides] =
|
|
4700
|
+
const [globalTooltipCount, setGlobalTooltipCount] = useState8(0);
|
|
4701
|
+
const [alignmentGuides, setAlignmentGuides] = useState8([]);
|
|
4910
4702
|
const processedData = data.map((item) => ({
|
|
4911
4703
|
...item,
|
|
4912
4704
|
name: String(item[xAxisConfig.dataKey] || "N/A")
|
|
4913
4705
|
// Garantir propriedade 'name' para tooltip
|
|
4914
4706
|
}));
|
|
4915
|
-
const
|
|
4707
|
+
const generateColors = (dataKeys2) => {
|
|
4916
4708
|
const colorMap = {};
|
|
4917
4709
|
const allColors = generateAdditionalColors(colors2, dataKeys2.length);
|
|
4918
4710
|
dataKeys2.forEach((key, index) => {
|
|
@@ -4921,15 +4713,15 @@ var BarChart = ({
|
|
|
4921
4713
|
return colorMap;
|
|
4922
4714
|
};
|
|
4923
4715
|
const dataKeys = Object.keys(mapperConfig);
|
|
4924
|
-
const finalColors =
|
|
4925
|
-
const
|
|
4716
|
+
const finalColors = generateColors(dataKeys);
|
|
4717
|
+
const adaptDataForTooltip = (universalData) => {
|
|
4926
4718
|
return {
|
|
4927
4719
|
...universalData,
|
|
4928
4720
|
name: String(universalData[xAxisConfig.dataKey] || "N/A")
|
|
4929
4721
|
// Garantir que tem a propriedade 'name'
|
|
4930
4722
|
};
|
|
4931
4723
|
};
|
|
4932
|
-
const maxDataValue =
|
|
4724
|
+
const maxDataValue = useMemo6(() => {
|
|
4933
4725
|
let max = 0;
|
|
4934
4726
|
const keys = Object.keys(mapperConfig);
|
|
4935
4727
|
for (const row of processedData) {
|
|
@@ -4942,7 +4734,7 @@ var BarChart = ({
|
|
|
4942
4734
|
}
|
|
4943
4735
|
return max;
|
|
4944
4736
|
}, [processedData, mapperConfig]);
|
|
4945
|
-
const niceMax =
|
|
4737
|
+
const niceMax = useMemo6(() => {
|
|
4946
4738
|
let padding2 = 0.08;
|
|
4947
4739
|
if (maxDataValue > 1e6) padding2 = 0.05;
|
|
4948
4740
|
if (maxDataValue > 1e7) padding2 = 0.03;
|
|
@@ -5240,25 +5032,25 @@ var BarChart = ({
|
|
|
5240
5032
|
label
|
|
5241
5033
|
}) => {
|
|
5242
5034
|
if (!active || !payload) return null;
|
|
5243
|
-
return /* @__PURE__ */
|
|
5244
|
-
/* @__PURE__ */
|
|
5035
|
+
return /* @__PURE__ */ jsxs24("div", { className: "bg-card border border-border rounded-lg p-3 shadow-lg", children: [
|
|
5036
|
+
/* @__PURE__ */ jsx29("p", { className: "font-medium text-foreground mb-2", children: label }),
|
|
5245
5037
|
payload.map(
|
|
5246
|
-
(entry, index) => /* @__PURE__ */
|
|
5247
|
-
/* @__PURE__ */
|
|
5038
|
+
(entry, index) => /* @__PURE__ */ jsxs24("div", { className: "flex items-center gap-2 text-sm", children: [
|
|
5039
|
+
/* @__PURE__ */ jsx29(
|
|
5248
5040
|
"div",
|
|
5249
5041
|
{
|
|
5250
5042
|
className: "w-3 h-3 rounded-sm",
|
|
5251
5043
|
style: { backgroundColor: entry.color }
|
|
5252
5044
|
}
|
|
5253
5045
|
),
|
|
5254
|
-
/* @__PURE__ */
|
|
5046
|
+
/* @__PURE__ */ jsxs24("span", { className: "text-muted-foreground", children: [
|
|
5255
5047
|
entry.name,
|
|
5256
5048
|
":"
|
|
5257
5049
|
] }),
|
|
5258
|
-
/* @__PURE__ */
|
|
5050
|
+
/* @__PURE__ */ jsx29("span", { className: "text-foreground font-medium", children: entry.value?.toLocaleString("pt-BR") })
|
|
5259
5051
|
] }, index)
|
|
5260
5052
|
),
|
|
5261
|
-
/* @__PURE__ */
|
|
5053
|
+
/* @__PURE__ */ jsx29("p", { className: "text-xs text-muted-foreground mt-1", children: "Clique para fixar este tooltip" })
|
|
5262
5054
|
] });
|
|
5263
5055
|
};
|
|
5264
5056
|
const getTitleClassName = (position) => {
|
|
@@ -5272,7 +5064,7 @@ var BarChart = ({
|
|
|
5272
5064
|
return `${baseClasses} text-left`;
|
|
5273
5065
|
}
|
|
5274
5066
|
};
|
|
5275
|
-
return /* @__PURE__ */
|
|
5067
|
+
return /* @__PURE__ */ jsxs24(
|
|
5276
5068
|
"div",
|
|
5277
5069
|
{
|
|
5278
5070
|
className: cn("rounded-lg bg-card p-4 relative", className),
|
|
@@ -5281,8 +5073,8 @@ var BarChart = ({
|
|
|
5281
5073
|
maxWidth: "100%"
|
|
5282
5074
|
},
|
|
5283
5075
|
children: [
|
|
5284
|
-
title && /* @__PURE__ */
|
|
5285
|
-
/* @__PURE__ */
|
|
5076
|
+
title && /* @__PURE__ */ jsx29("div", { style: { paddingLeft: `${resolvedContainerPaddingLeft}px` }, children: /* @__PURE__ */ jsx29("h3", { className: getTitleClassName(titlePosition), children: title }) }),
|
|
5077
|
+
/* @__PURE__ */ jsxs24(
|
|
5286
5078
|
RechartsBarChart,
|
|
5287
5079
|
{
|
|
5288
5080
|
data: processedData,
|
|
@@ -5291,7 +5083,7 @@ var BarChart = ({
|
|
|
5291
5083
|
margin: resolveChartMargins(margins, chartMargins, showLabels),
|
|
5292
5084
|
onClick: handleChartClick,
|
|
5293
5085
|
children: [
|
|
5294
|
-
showGrid && /* @__PURE__ */
|
|
5086
|
+
showGrid && /* @__PURE__ */ jsx29(
|
|
5295
5087
|
CartesianGrid2,
|
|
5296
5088
|
{
|
|
5297
5089
|
strokeDasharray: "3 3",
|
|
@@ -5299,7 +5091,7 @@ var BarChart = ({
|
|
|
5299
5091
|
opacity: 0.5
|
|
5300
5092
|
}
|
|
5301
5093
|
),
|
|
5302
|
-
/* @__PURE__ */
|
|
5094
|
+
/* @__PURE__ */ jsx29(
|
|
5303
5095
|
XAxis2,
|
|
5304
5096
|
{
|
|
5305
5097
|
dataKey: xAxisConfig.dataKey,
|
|
@@ -5310,7 +5102,7 @@ var BarChart = ({
|
|
|
5310
5102
|
tickFormatter: xAxisConfig.valueFormatter
|
|
5311
5103
|
}
|
|
5312
5104
|
),
|
|
5313
|
-
/* @__PURE__ */
|
|
5105
|
+
/* @__PURE__ */ jsx29(
|
|
5314
5106
|
YAxis2,
|
|
5315
5107
|
{
|
|
5316
5108
|
stroke: "hsl(var(--muted-foreground))",
|
|
@@ -5322,14 +5114,14 @@ var BarChart = ({
|
|
|
5322
5114
|
tickCount: 6
|
|
5323
5115
|
}
|
|
5324
5116
|
),
|
|
5325
|
-
showTooltip && /* @__PURE__ */
|
|
5117
|
+
showTooltip && /* @__PURE__ */ jsx29(
|
|
5326
5118
|
Tooltip2,
|
|
5327
5119
|
{
|
|
5328
|
-
content: /* @__PURE__ */
|
|
5120
|
+
content: /* @__PURE__ */ jsx29(CustomTooltip, {}),
|
|
5329
5121
|
cursor: { fill: "hsl(var(--muted))", opacity: 0.1 }
|
|
5330
5122
|
}
|
|
5331
5123
|
),
|
|
5332
|
-
showLegend && /* @__PURE__ */
|
|
5124
|
+
showLegend && /* @__PURE__ */ jsx29(
|
|
5333
5125
|
Legend2,
|
|
5334
5126
|
{
|
|
5335
5127
|
wrapperStyle: {
|
|
@@ -5340,7 +5132,7 @@ var BarChart = ({
|
|
|
5340
5132
|
),
|
|
5341
5133
|
dataKeys.map((key) => {
|
|
5342
5134
|
const fieldConfig = mapperConfig[key];
|
|
5343
|
-
return /* @__PURE__ */
|
|
5135
|
+
return /* @__PURE__ */ jsx29(
|
|
5344
5136
|
Bar2,
|
|
5345
5137
|
{
|
|
5346
5138
|
dataKey: key,
|
|
@@ -5349,7 +5141,7 @@ var BarChart = ({
|
|
|
5349
5141
|
radius: [4, 4, 0, 0],
|
|
5350
5142
|
onClick: handleBarClick,
|
|
5351
5143
|
style: { cursor: "pointer" },
|
|
5352
|
-
activeBar: /* @__PURE__ */
|
|
5144
|
+
activeBar: /* @__PURE__ */ jsx29(
|
|
5353
5145
|
Rectangle2,
|
|
5354
5146
|
{
|
|
5355
5147
|
fill: finalColors[key],
|
|
@@ -5358,7 +5150,7 @@ var BarChart = ({
|
|
|
5358
5150
|
opacity: 0.8
|
|
5359
5151
|
}
|
|
5360
5152
|
),
|
|
5361
|
-
children: showLabels && /* @__PURE__ */
|
|
5153
|
+
children: showLabels && /* @__PURE__ */ jsx29(
|
|
5362
5154
|
LabelList2,
|
|
5363
5155
|
{
|
|
5364
5156
|
dataKey: key,
|
|
@@ -5395,8 +5187,8 @@ var BarChart = ({
|
|
|
5395
5187
|
guide.sourceTooltip.top + guide.sourceTooltip.height / 2,
|
|
5396
5188
|
guide.targetTooltip.top + guide.targetTooltip.height / 2
|
|
5397
5189
|
);
|
|
5398
|
-
return /* @__PURE__ */
|
|
5399
|
-
/* @__PURE__ */
|
|
5190
|
+
return /* @__PURE__ */ jsxs24("div", { children: [
|
|
5191
|
+
/* @__PURE__ */ jsx29(
|
|
5400
5192
|
"div",
|
|
5401
5193
|
{
|
|
5402
5194
|
className: "fixed pointer-events-none z-30",
|
|
@@ -5415,7 +5207,7 @@ var BarChart = ({
|
|
|
5415
5207
|
}
|
|
5416
5208
|
}
|
|
5417
5209
|
),
|
|
5418
|
-
/* @__PURE__ */
|
|
5210
|
+
/* @__PURE__ */ jsx29(
|
|
5419
5211
|
"div",
|
|
5420
5212
|
{
|
|
5421
5213
|
className: "fixed pointer-events-none z-31",
|
|
@@ -5431,7 +5223,7 @@ var BarChart = ({
|
|
|
5431
5223
|
}
|
|
5432
5224
|
}
|
|
5433
5225
|
),
|
|
5434
|
-
/* @__PURE__ */
|
|
5226
|
+
/* @__PURE__ */ jsx29(
|
|
5435
5227
|
"div",
|
|
5436
5228
|
{
|
|
5437
5229
|
className: "fixed pointer-events-none z-31",
|
|
@@ -5449,11 +5241,11 @@ var BarChart = ({
|
|
|
5449
5241
|
)
|
|
5450
5242
|
] }, index);
|
|
5451
5243
|
}),
|
|
5452
|
-
activeTooltips.map((tooltip, index) => /* @__PURE__ */
|
|
5244
|
+
activeTooltips.map((tooltip, index) => /* @__PURE__ */ jsx29(
|
|
5453
5245
|
DraggableTooltip_default,
|
|
5454
5246
|
{
|
|
5455
5247
|
id: tooltip.id,
|
|
5456
|
-
data:
|
|
5248
|
+
data: adaptDataForTooltip(tooltip.data),
|
|
5457
5249
|
position: tooltip.position,
|
|
5458
5250
|
isDragging: isDragging === tooltip.id,
|
|
5459
5251
|
title,
|
|
@@ -5482,7 +5274,7 @@ var BarChart = ({
|
|
|
5482
5274
|
var BarChart_default = BarChart;
|
|
5483
5275
|
|
|
5484
5276
|
// src/components/charts/LineChart.tsx
|
|
5485
|
-
import { useState as
|
|
5277
|
+
import { useState as useState9, useEffect as useEffect7, useCallback as useCallback7, useMemo as useMemo7 } from "react";
|
|
5486
5278
|
import {
|
|
5487
5279
|
LineChart as RechartsLineChart,
|
|
5488
5280
|
Line as Line2,
|
|
@@ -5493,7 +5285,7 @@ import {
|
|
|
5493
5285
|
Legend as Legend3,
|
|
5494
5286
|
LabelList as LabelList3
|
|
5495
5287
|
} from "recharts";
|
|
5496
|
-
import { jsx as
|
|
5288
|
+
import { jsx as jsx30, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5497
5289
|
var defaultData = [
|
|
5498
5290
|
{ name: "A", value: 100 },
|
|
5499
5291
|
{ name: "B", value: 200 },
|
|
@@ -5525,15 +5317,15 @@ var CustomLineChart = ({
|
|
|
5525
5317
|
containerPaddingLeft,
|
|
5526
5318
|
16
|
|
5527
5319
|
);
|
|
5528
|
-
const [activeTooltips, setActiveTooltips] =
|
|
5529
|
-
const [isDragging, setIsDragging] =
|
|
5530
|
-
const [dragOffset, setDragOffset] =
|
|
5320
|
+
const [activeTooltips, setActiveTooltips] = useState9([]);
|
|
5321
|
+
const [isDragging, setIsDragging] = useState9(null);
|
|
5322
|
+
const [dragOffset, setDragOffset] = useState9({
|
|
5531
5323
|
x: 0,
|
|
5532
5324
|
y: 0
|
|
5533
5325
|
});
|
|
5534
|
-
const [globalTooltipCount, setGlobalTooltipCount] =
|
|
5535
|
-
const [alignmentGuides, setAlignmentGuides] =
|
|
5536
|
-
const
|
|
5326
|
+
const [globalTooltipCount, setGlobalTooltipCount] = useState9(0);
|
|
5327
|
+
const [alignmentGuides, setAlignmentGuides] = useState9([]);
|
|
5328
|
+
const generateColors = (dataKeys2) => {
|
|
5537
5329
|
const colorMap = {};
|
|
5538
5330
|
const allColors = generateAdditionalColors(colors2, dataKeys2.length);
|
|
5539
5331
|
dataKeys2.forEach((key, index) => {
|
|
@@ -5541,12 +5333,12 @@ var CustomLineChart = ({
|
|
|
5541
5333
|
});
|
|
5542
5334
|
return colorMap;
|
|
5543
5335
|
};
|
|
5544
|
-
const dataKeys =
|
|
5336
|
+
const dataKeys = useMemo7(
|
|
5545
5337
|
() => data.length > 0 ? Object.keys(data[0]).filter((key) => key !== "name") : [],
|
|
5546
5338
|
[data]
|
|
5547
5339
|
);
|
|
5548
|
-
const finalColors =
|
|
5549
|
-
const maxDataValue =
|
|
5340
|
+
const finalColors = generateColors(dataKeys);
|
|
5341
|
+
const maxDataValue = useMemo7(() => {
|
|
5550
5342
|
let max = 0;
|
|
5551
5343
|
for (const row of data) {
|
|
5552
5344
|
const r = row;
|
|
@@ -5558,7 +5350,7 @@ var CustomLineChart = ({
|
|
|
5558
5350
|
}
|
|
5559
5351
|
return max;
|
|
5560
5352
|
}, [data, dataKeys]);
|
|
5561
|
-
const niceMax =
|
|
5353
|
+
const niceMax = useMemo7(() => {
|
|
5562
5354
|
let padding2 = 0.08;
|
|
5563
5355
|
if (maxDataValue > 1e6) padding2 = 0.05;
|
|
5564
5356
|
if (maxDataValue > 1e7) padding2 = 0.03;
|
|
@@ -5592,7 +5384,7 @@ var CustomLineChart = ({
|
|
|
5592
5384
|
setActiveTooltips((prev) => [...prev, newTooltip]);
|
|
5593
5385
|
}
|
|
5594
5386
|
};
|
|
5595
|
-
return /* @__PURE__ */
|
|
5387
|
+
return /* @__PURE__ */ jsx30(
|
|
5596
5388
|
"circle",
|
|
5597
5389
|
{
|
|
5598
5390
|
cx,
|
|
@@ -5875,7 +5667,7 @@ var CustomLineChart = ({
|
|
|
5875
5667
|
return "text-left";
|
|
5876
5668
|
}
|
|
5877
5669
|
};
|
|
5878
|
-
return /* @__PURE__ */
|
|
5670
|
+
return /* @__PURE__ */ jsx30("div", { className: cn("relative", className), children: /* @__PURE__ */ jsxs25(
|
|
5879
5671
|
"div",
|
|
5880
5672
|
{
|
|
5881
5673
|
className: "rounded-lg bg-card p-4 relative border border-border",
|
|
@@ -5885,8 +5677,8 @@ var CustomLineChart = ({
|
|
|
5885
5677
|
},
|
|
5886
5678
|
onClick: handleChartBackgroundClick,
|
|
5887
5679
|
children: [
|
|
5888
|
-
title && /* @__PURE__ */
|
|
5889
|
-
/* @__PURE__ */
|
|
5680
|
+
title && /* @__PURE__ */ jsx30("div", { style: { paddingLeft: `${resolvedContainerPaddingLeft}px` }, children: /* @__PURE__ */ jsx30("div", { className: cn("mb-4", getTitleClass()), children: /* @__PURE__ */ jsx30("h3", { className: "text-lg font-semibold text-foreground", children: title }) }) }),
|
|
5681
|
+
/* @__PURE__ */ jsxs25(
|
|
5890
5682
|
RechartsLineChart,
|
|
5891
5683
|
{
|
|
5892
5684
|
data,
|
|
@@ -5895,7 +5687,7 @@ var CustomLineChart = ({
|
|
|
5895
5687
|
margin: resolveChartMargins(margins, chartMargins, showLabels),
|
|
5896
5688
|
onClick: handleChartClick,
|
|
5897
5689
|
children: [
|
|
5898
|
-
showGrid && /* @__PURE__ */
|
|
5690
|
+
showGrid && /* @__PURE__ */ jsx30(
|
|
5899
5691
|
CartesianGrid3,
|
|
5900
5692
|
{
|
|
5901
5693
|
strokeDasharray: "3 3",
|
|
@@ -5903,7 +5695,7 @@ var CustomLineChart = ({
|
|
|
5903
5695
|
opacity: 0.3
|
|
5904
5696
|
}
|
|
5905
5697
|
),
|
|
5906
|
-
/* @__PURE__ */
|
|
5698
|
+
/* @__PURE__ */ jsx30(
|
|
5907
5699
|
XAxis3,
|
|
5908
5700
|
{
|
|
5909
5701
|
dataKey: "name",
|
|
@@ -5911,7 +5703,7 @@ var CustomLineChart = ({
|
|
|
5911
5703
|
fontSize: 12
|
|
5912
5704
|
}
|
|
5913
5705
|
),
|
|
5914
|
-
/* @__PURE__ */
|
|
5706
|
+
/* @__PURE__ */ jsx30(
|
|
5915
5707
|
YAxis3,
|
|
5916
5708
|
{
|
|
5917
5709
|
className: "fill-muted-foreground text-xs",
|
|
@@ -5921,8 +5713,8 @@ var CustomLineChart = ({
|
|
|
5921
5713
|
tickCount: 6
|
|
5922
5714
|
}
|
|
5923
5715
|
),
|
|
5924
|
-
showTooltip && /* @__PURE__ */
|
|
5925
|
-
showLegend && /* @__PURE__ */
|
|
5716
|
+
showTooltip && /* @__PURE__ */ jsx30(Tooltip3, { content: () => null }),
|
|
5717
|
+
showLegend && /* @__PURE__ */ jsx30(
|
|
5926
5718
|
Legend3,
|
|
5927
5719
|
{
|
|
5928
5720
|
wrapperStyle: {
|
|
@@ -5931,7 +5723,7 @@ var CustomLineChart = ({
|
|
|
5931
5723
|
}
|
|
5932
5724
|
}
|
|
5933
5725
|
),
|
|
5934
|
-
dataKeys.map((key) => /* @__PURE__ */
|
|
5726
|
+
dataKeys.map((key) => /* @__PURE__ */ jsx30(
|
|
5935
5727
|
Line2,
|
|
5936
5728
|
{
|
|
5937
5729
|
type: "monotone",
|
|
@@ -5939,8 +5731,8 @@ var CustomLineChart = ({
|
|
|
5939
5731
|
stroke: finalColors[key],
|
|
5940
5732
|
strokeWidth,
|
|
5941
5733
|
dot: showDots ? { r: 4, cursor: "pointer" } : false,
|
|
5942
|
-
activeDot: (props) => /* @__PURE__ */
|
|
5943
|
-
children: showLabels && /* @__PURE__ */
|
|
5734
|
+
activeDot: (props) => /* @__PURE__ */ jsx30(ClickableDot, { ...props, dataKey: key }),
|
|
5735
|
+
children: showLabels && /* @__PURE__ */ jsx30(
|
|
5944
5736
|
LabelList3,
|
|
5945
5737
|
{
|
|
5946
5738
|
dataKey: key,
|
|
@@ -5977,8 +5769,8 @@ var CustomLineChart = ({
|
|
|
5977
5769
|
guide.sourceTooltip.top + guide.sourceTooltip.height / 2,
|
|
5978
5770
|
guide.targetTooltip.top + guide.targetTooltip.height / 2
|
|
5979
5771
|
);
|
|
5980
|
-
return /* @__PURE__ */
|
|
5981
|
-
/* @__PURE__ */
|
|
5772
|
+
return /* @__PURE__ */ jsxs25("div", { children: [
|
|
5773
|
+
/* @__PURE__ */ jsx30(
|
|
5982
5774
|
"div",
|
|
5983
5775
|
{
|
|
5984
5776
|
className: "fixed pointer-events-none z-30",
|
|
@@ -5997,7 +5789,7 @@ var CustomLineChart = ({
|
|
|
5997
5789
|
}
|
|
5998
5790
|
}
|
|
5999
5791
|
),
|
|
6000
|
-
/* @__PURE__ */
|
|
5792
|
+
/* @__PURE__ */ jsx30(
|
|
6001
5793
|
"div",
|
|
6002
5794
|
{
|
|
6003
5795
|
className: "fixed pointer-events-none z-31",
|
|
@@ -6013,7 +5805,7 @@ var CustomLineChart = ({
|
|
|
6013
5805
|
}
|
|
6014
5806
|
}
|
|
6015
5807
|
),
|
|
6016
|
-
/* @__PURE__ */
|
|
5808
|
+
/* @__PURE__ */ jsx30(
|
|
6017
5809
|
"div",
|
|
6018
5810
|
{
|
|
6019
5811
|
className: "fixed pointer-events-none z-31",
|
|
@@ -6031,7 +5823,7 @@ var CustomLineChart = ({
|
|
|
6031
5823
|
)
|
|
6032
5824
|
] }, index);
|
|
6033
5825
|
}),
|
|
6034
|
-
activeTooltips.map((tooltip, index) => /* @__PURE__ */
|
|
5826
|
+
activeTooltips.map((tooltip, index) => /* @__PURE__ */ jsx30(
|
|
6035
5827
|
DraggableTooltip_default,
|
|
6036
5828
|
{
|
|
6037
5829
|
id: tooltip.id,
|
|
@@ -6070,7 +5862,7 @@ import {
|
|
|
6070
5862
|
Tooltip as Tooltip4,
|
|
6071
5863
|
Legend as Legend4
|
|
6072
5864
|
} from "recharts";
|
|
6073
|
-
import { jsx as
|
|
5865
|
+
import { jsx as jsx31, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
6074
5866
|
var defaultData2 = [
|
|
6075
5867
|
{ name: "Vendas", value: 4e3 },
|
|
6076
5868
|
{ name: "Marketing", value: 3e3 },
|
|
@@ -6108,7 +5900,7 @@ var renderCustomizedLabel = ({
|
|
|
6108
5900
|
const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
|
|
6109
5901
|
const x = cx + radius * Math.cos(-midAngle * RADIAN);
|
|
6110
5902
|
const y = cy + radius * Math.sin(-midAngle * RADIAN);
|
|
6111
|
-
return /* @__PURE__ */
|
|
5903
|
+
return /* @__PURE__ */ jsx31(
|
|
6112
5904
|
"text",
|
|
6113
5905
|
{
|
|
6114
5906
|
x,
|
|
@@ -6137,8 +5929,8 @@ var CustomPieChart = ({
|
|
|
6137
5929
|
centerY = "50%"
|
|
6138
5930
|
}) => {
|
|
6139
5931
|
const finalColors = colors2 || DEFAULT_COLORS5;
|
|
6140
|
-
return /* @__PURE__ */
|
|
6141
|
-
/* @__PURE__ */
|
|
5932
|
+
return /* @__PURE__ */ jsx31("div", { className: cn("w-full rounded-lg bg-card p-4", className), children: /* @__PURE__ */ jsx31(ResponsiveContainer2, { width, height, children: /* @__PURE__ */ jsxs26(RechartsPieChart, { children: [
|
|
5933
|
+
/* @__PURE__ */ jsx31(
|
|
6142
5934
|
Pie,
|
|
6143
5935
|
{
|
|
6144
5936
|
data,
|
|
@@ -6150,7 +5942,7 @@ var CustomPieChart = ({
|
|
|
6150
5942
|
innerRadius,
|
|
6151
5943
|
fill: "#8884d8",
|
|
6152
5944
|
dataKey: "value",
|
|
6153
|
-
children: data.map((entry, index) => /* @__PURE__ */
|
|
5945
|
+
children: data.map((entry, index) => /* @__PURE__ */ jsx31(
|
|
6154
5946
|
Cell,
|
|
6155
5947
|
{
|
|
6156
5948
|
fill: finalColors[index % finalColors.length]
|
|
@@ -6159,7 +5951,7 @@ var CustomPieChart = ({
|
|
|
6159
5951
|
))
|
|
6160
5952
|
}
|
|
6161
5953
|
),
|
|
6162
|
-
showTooltip && /* @__PURE__ */
|
|
5954
|
+
showTooltip && /* @__PURE__ */ jsx31(
|
|
6163
5955
|
Tooltip4,
|
|
6164
5956
|
{
|
|
6165
5957
|
contentStyle: {
|
|
@@ -6170,18 +5962,18 @@ var CustomPieChart = ({
|
|
|
6170
5962
|
}
|
|
6171
5963
|
}
|
|
6172
5964
|
),
|
|
6173
|
-
showLegend && /* @__PURE__ */
|
|
5965
|
+
showLegend && /* @__PURE__ */ jsx31(Legend4, {})
|
|
6174
5966
|
] }) }) });
|
|
6175
5967
|
};
|
|
6176
5968
|
var PieChart_default = CustomPieChart;
|
|
6177
5969
|
|
|
6178
5970
|
// src/components/charts/hooks/useChartHighlights.tsx
|
|
6179
|
-
import { useState as
|
|
5971
|
+
import { useState as useState10, useCallback as useCallback8 } from "react";
|
|
6180
5972
|
var useChartHighlights = () => {
|
|
6181
|
-
const [highlightedSeries, setHighlightedSeries] =
|
|
5973
|
+
const [highlightedSeries, setHighlightedSeries] = useState10(
|
|
6182
5974
|
/* @__PURE__ */ new Set()
|
|
6183
5975
|
);
|
|
6184
|
-
const [showOnlyHighlighted, setShowOnlyHighlighted] =
|
|
5976
|
+
const [showOnlyHighlighted, setShowOnlyHighlighted] = useState10(false);
|
|
6185
5977
|
const toggleHighlight = useCallback8((key) => {
|
|
6186
5978
|
setHighlightedSeries((prev) => {
|
|
6187
5979
|
const next = new Set(prev);
|
|
@@ -6248,6 +6040,105 @@ var useChartHighlights = () => {
|
|
|
6248
6040
|
};
|
|
6249
6041
|
};
|
|
6250
6042
|
|
|
6043
|
+
// src/components/charts/NoData.tsx
|
|
6044
|
+
import { jsx as jsx32, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
6045
|
+
var NoData = ({
|
|
6046
|
+
paddingLeft = 0,
|
|
6047
|
+
height = 360,
|
|
6048
|
+
message = "Sem dados para exibir",
|
|
6049
|
+
className
|
|
6050
|
+
}) => {
|
|
6051
|
+
const svgHeight = typeof height === "number" ? height : 360;
|
|
6052
|
+
const bars = [
|
|
6053
|
+
{ x: 120, w: 120, h: svgHeight * 0.45, label: "Label 0" },
|
|
6054
|
+
{ x: 260, w: 120, h: svgHeight * 0.75, label: "Label 1" },
|
|
6055
|
+
{ x: 400, w: 120, h: svgHeight * 0.65, label: "Label 2" },
|
|
6056
|
+
{ x: 540, w: 120, h: svgHeight * 0.55, label: "Label 3" },
|
|
6057
|
+
{ x: 680, w: 120, h: svgHeight * 0.25, label: "Label 4" }
|
|
6058
|
+
];
|
|
6059
|
+
const styleVars = {
|
|
6060
|
+
["--pl"]: `${paddingLeft}px`,
|
|
6061
|
+
["--svg-h"]: typeof height === "number" ? `${height}px` : String(height)
|
|
6062
|
+
};
|
|
6063
|
+
return /* @__PURE__ */ jsx32(
|
|
6064
|
+
"div",
|
|
6065
|
+
{
|
|
6066
|
+
className: cn(
|
|
6067
|
+
"rounded-lg bg-card p-2 relative overflow-visible w-full",
|
|
6068
|
+
className
|
|
6069
|
+
),
|
|
6070
|
+
style: styleVars,
|
|
6071
|
+
role: "img",
|
|
6072
|
+
"aria-label": message,
|
|
6073
|
+
children: /* @__PURE__ */ jsx32("div", { className: "w-full flex items-center justify-center pl-[var(--pl)] pr-3 h-[var(--svg-h)]", children: /* @__PURE__ */ jsxs27("div", { className: "w-full max-w-[900px] relative", children: [
|
|
6074
|
+
/* @__PURE__ */ jsxs27(
|
|
6075
|
+
"svg",
|
|
6076
|
+
{
|
|
6077
|
+
className: "w-full h-[var(--svg-h)]",
|
|
6078
|
+
width: "100%",
|
|
6079
|
+
viewBox: `0 0 900 ${svgHeight}`,
|
|
6080
|
+
preserveAspectRatio: "none",
|
|
6081
|
+
children: [
|
|
6082
|
+
/* @__PURE__ */ jsx32(
|
|
6083
|
+
"rect",
|
|
6084
|
+
{
|
|
6085
|
+
x: 0,
|
|
6086
|
+
y: 0,
|
|
6087
|
+
width: 900,
|
|
6088
|
+
height: svgHeight,
|
|
6089
|
+
fill: "transparent"
|
|
6090
|
+
}
|
|
6091
|
+
),
|
|
6092
|
+
Array.from({ length: 5 }).map((_, i) => {
|
|
6093
|
+
const y = 40 + (svgHeight - 80) / 4 * i;
|
|
6094
|
+
return /* @__PURE__ */ jsx32(
|
|
6095
|
+
"line",
|
|
6096
|
+
{
|
|
6097
|
+
x1: 60,
|
|
6098
|
+
x2: 840,
|
|
6099
|
+
y1: y,
|
|
6100
|
+
y2: y,
|
|
6101
|
+
stroke: "rgba(0,0,0,0.06)",
|
|
6102
|
+
strokeWidth: 1
|
|
6103
|
+
},
|
|
6104
|
+
`g-${i}`
|
|
6105
|
+
);
|
|
6106
|
+
}),
|
|
6107
|
+
bars.map((b, i) => /* @__PURE__ */ jsxs27("g", { children: [
|
|
6108
|
+
/* @__PURE__ */ jsx32(
|
|
6109
|
+
"rect",
|
|
6110
|
+
{
|
|
6111
|
+
x: b.x,
|
|
6112
|
+
y: svgHeight - 60 - b.h,
|
|
6113
|
+
width: b.w,
|
|
6114
|
+
height: b.h,
|
|
6115
|
+
rx: 6,
|
|
6116
|
+
fill: "rgba(0,0,0,0.06)",
|
|
6117
|
+
stroke: "rgba(0,0,0,0.04)"
|
|
6118
|
+
}
|
|
6119
|
+
),
|
|
6120
|
+
/* @__PURE__ */ jsx32(
|
|
6121
|
+
"text",
|
|
6122
|
+
{
|
|
6123
|
+
x: b.x + b.w / 2,
|
|
6124
|
+
y: svgHeight - 20,
|
|
6125
|
+
fill: "rgba(0,0,0,0.35)",
|
|
6126
|
+
fontSize: 12,
|
|
6127
|
+
textAnchor: "middle",
|
|
6128
|
+
children: b.label
|
|
6129
|
+
}
|
|
6130
|
+
)
|
|
6131
|
+
] }, `barg-${i}`))
|
|
6132
|
+
]
|
|
6133
|
+
}
|
|
6134
|
+
),
|
|
6135
|
+
/* @__PURE__ */ jsx32("div", { className: "absolute inset-0 flex items-center justify-center pointer-events-none h-[var(--svg-h)]", children: /* @__PURE__ */ jsx32("div", { className: "pointer-events-auto bg-transparent px-3", children: /* @__PURE__ */ jsx32("div", { className: "text-2xl font-extrabold text-black/80", children: message }) }) })
|
|
6136
|
+
] }) })
|
|
6137
|
+
}
|
|
6138
|
+
);
|
|
6139
|
+
};
|
|
6140
|
+
var NoData_default = NoData;
|
|
6141
|
+
|
|
6251
6142
|
// src/components/ui/data/AvatarBase.tsx
|
|
6252
6143
|
import * as React16 from "react";
|
|
6253
6144
|
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
@@ -6481,7 +6372,7 @@ import {
|
|
|
6481
6372
|
FilePptIcon,
|
|
6482
6373
|
FileDocIcon
|
|
6483
6374
|
} from "@phosphor-icons/react";
|
|
6484
|
-
import { Fragment as
|
|
6375
|
+
import { Fragment as Fragment7, jsx as jsx37, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
6485
6376
|
var formatFileSize = (bytes) => {
|
|
6486
6377
|
if (bytes === 0) return "0 Bytes";
|
|
6487
6378
|
const k = 1024;
|
|
@@ -6876,7 +6767,7 @@ var FileUploader = React18.forwardRef(
|
|
|
6876
6767
|
),
|
|
6877
6768
|
/* @__PURE__ */ jsxs28("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
6878
6769
|
/* @__PURE__ */ jsx37("span", { children: formatFileSize(file.size) }),
|
|
6879
|
-
file.type && /* @__PURE__ */ jsxs28(
|
|
6770
|
+
file.type && /* @__PURE__ */ jsxs28(Fragment7, { children: [
|
|
6880
6771
|
/* @__PURE__ */ jsx37("span", { children: "\u2022" }),
|
|
6881
6772
|
/* @__PURE__ */ jsx37("span", { className: "uppercase", children: getFileExtension(file.name) })
|
|
6882
6773
|
] })
|
|
@@ -10394,7 +10285,7 @@ function DrawerDescriptionBase({
|
|
|
10394
10285
|
}
|
|
10395
10286
|
|
|
10396
10287
|
// src/hooks/use-universal-tooltip.tsx
|
|
10397
|
-
import { createContext as createContext4, useContext as useContext5, useState as
|
|
10288
|
+
import { createContext as createContext4, useContext as useContext5, useState as useState17, useCallback as useCallback11, useEffect as useEffect15, useRef as useRef7 } from "react";
|
|
10398
10289
|
import { jsx as jsx62 } from "react/jsx-runtime";
|
|
10399
10290
|
var UniversalTooltipContext = createContext4(null);
|
|
10400
10291
|
var useUniversalTooltip = () => {
|
|
@@ -10694,7 +10585,7 @@ CalendarBase2.displayName = "CalendarBase";
|
|
|
10694
10585
|
|
|
10695
10586
|
// src/components/picker/DateTimePicker.tsx
|
|
10696
10587
|
import { ptBR } from "date-fns/locale";
|
|
10697
|
-
import { useEffect as useEffect16, useState as
|
|
10588
|
+
import { useEffect as useEffect16, useState as useState19 } from "react";
|
|
10698
10589
|
|
|
10699
10590
|
// src/components/picker/TimePicker.tsx
|
|
10700
10591
|
import { motion as motion14, AnimatePresence as AnimatePresence10 } from "framer-motion";
|
|
@@ -11043,7 +10934,7 @@ var TimePickerInput = React41.forwardRef(
|
|
|
11043
10934
|
TimePickerInput.displayName = "TimePickerInput";
|
|
11044
10935
|
|
|
11045
10936
|
// src/components/picker/TimePicker.tsx
|
|
11046
|
-
import { Fragment as
|
|
10937
|
+
import { Fragment as Fragment9, jsx as jsx66, jsxs as jsxs49 } from "react/jsx-runtime";
|
|
11047
10938
|
function TimePicker({
|
|
11048
10939
|
date,
|
|
11049
10940
|
setDate,
|
|
@@ -11113,7 +11004,7 @@ function TimePicker({
|
|
|
11113
11004
|
)
|
|
11114
11005
|
}
|
|
11115
11006
|
),
|
|
11116
|
-
/* @__PURE__ */ jsx66(AnimatePresence10, { children: !hideSeconds && /* @__PURE__ */ jsx66(
|
|
11007
|
+
/* @__PURE__ */ jsx66(AnimatePresence10, { children: !hideSeconds && /* @__PURE__ */ jsx66(Fragment9, { children: /* @__PURE__ */ jsx66(
|
|
11117
11008
|
motion14.div,
|
|
11118
11009
|
{
|
|
11119
11010
|
variants: itemVariants2,
|
|
@@ -11155,9 +11046,9 @@ function DateTimePicker({
|
|
|
11155
11046
|
className,
|
|
11156
11047
|
error
|
|
11157
11048
|
}) {
|
|
11158
|
-
const [internalDate, setInternalDate] =
|
|
11159
|
-
const [open, setOpen] =
|
|
11160
|
-
const [timePickerOpen, setTimePickerOpen] =
|
|
11049
|
+
const [internalDate, setInternalDate] = useState19(date);
|
|
11050
|
+
const [open, setOpen] = useState19(false);
|
|
11051
|
+
const [timePickerOpen, setTimePickerOpen] = useState19(false);
|
|
11161
11052
|
const handleSelect = (newDay) => {
|
|
11162
11053
|
if (!newDay) return;
|
|
11163
11054
|
if (!internalDate) {
|
|
@@ -12142,7 +12033,7 @@ function StatusIndicator({
|
|
|
12142
12033
|
}
|
|
12143
12034
|
|
|
12144
12035
|
// src/components/ui/form/DebouncedInput.tsx
|
|
12145
|
-
import { useEffect as useEffect18, useState as
|
|
12036
|
+
import { useEffect as useEffect18, useState as useState21 } from "react";
|
|
12146
12037
|
import { CircleNotchIcon as CircleNotchIcon2 } from "@phosphor-icons/react";
|
|
12147
12038
|
import { jsx as jsx72 } from "react/jsx-runtime";
|
|
12148
12039
|
function DebouncedInput({
|
|
@@ -12158,8 +12049,8 @@ function DebouncedInput({
|
|
|
12158
12049
|
error,
|
|
12159
12050
|
...props
|
|
12160
12051
|
}) {
|
|
12161
|
-
const [value, setValue] =
|
|
12162
|
-
const [isDebouncing, setIsDebouncing] =
|
|
12052
|
+
const [value, setValue] = useState21(initialValue);
|
|
12053
|
+
const [isDebouncing, setIsDebouncing] = useState21(false);
|
|
12163
12054
|
useEffect18(() => {
|
|
12164
12055
|
setValue(initialValue);
|
|
12165
12056
|
}, [initialValue]);
|
|
@@ -12201,7 +12092,7 @@ function DebouncedInput({
|
|
|
12201
12092
|
// src/components/event-calendar/AgendaView.tsx
|
|
12202
12093
|
import { addDays, format as format3, isToday } from "date-fns";
|
|
12203
12094
|
import { ptBR as ptBR3 } from "date-fns/locale";
|
|
12204
|
-
import { useMemo as
|
|
12095
|
+
import { useMemo as useMemo9 } from "react";
|
|
12205
12096
|
import { CalendarIcon as CalendarIcon2 } from "@phosphor-icons/react";
|
|
12206
12097
|
import { jsx as jsx73, jsxs as jsxs55 } from "react/jsx-runtime";
|
|
12207
12098
|
function AgendaView({
|
|
@@ -12209,7 +12100,7 @@ function AgendaView({
|
|
|
12209
12100
|
events,
|
|
12210
12101
|
onEventSelect
|
|
12211
12102
|
}) {
|
|
12212
|
-
const days =
|
|
12103
|
+
const days = useMemo9(() => {
|
|
12213
12104
|
console.log("Agenda view updating with date:", currentDate.toISOString());
|
|
12214
12105
|
return Array.from(
|
|
12215
12106
|
{ length: AgendaDaysToShow },
|
|
@@ -12274,7 +12165,7 @@ import {
|
|
|
12274
12165
|
useSensors
|
|
12275
12166
|
} from "@dnd-kit/core";
|
|
12276
12167
|
import { addMinutes, differenceInMinutes } from "date-fns";
|
|
12277
|
-
import { useId as useId2, useRef as useRef9, useState as
|
|
12168
|
+
import { useId as useId2, useRef as useRef9, useState as useState22 } from "react";
|
|
12278
12169
|
|
|
12279
12170
|
// src/components/event-calendar/hooks.ts
|
|
12280
12171
|
import { createContext as createContext5, useContext as useContext6 } from "react";
|
|
@@ -12296,16 +12187,16 @@ function CalendarDndProvider({
|
|
|
12296
12187
|
children,
|
|
12297
12188
|
onEventUpdate
|
|
12298
12189
|
}) {
|
|
12299
|
-
const [activeEvent, setActiveEvent] =
|
|
12300
|
-
const [activeId, setActiveId] =
|
|
12301
|
-
const [activeView, setActiveView] =
|
|
12190
|
+
const [activeEvent, setActiveEvent] = useState22(null);
|
|
12191
|
+
const [activeId, setActiveId] = useState22(null);
|
|
12192
|
+
const [activeView, setActiveView] = useState22(
|
|
12302
12193
|
null
|
|
12303
12194
|
);
|
|
12304
|
-
const [currentTime, setCurrentTime] =
|
|
12305
|
-
const [eventHeight, setEventHeight] =
|
|
12306
|
-
const [isMultiDay, setIsMultiDay] =
|
|
12307
|
-
const [multiDayWidth, setMultiDayWidth] =
|
|
12308
|
-
const [dragHandlePosition, setDragHandlePosition] =
|
|
12195
|
+
const [currentTime, setCurrentTime] = useState22(null);
|
|
12196
|
+
const [eventHeight, setEventHeight] = useState22(null);
|
|
12197
|
+
const [isMultiDay, setIsMultiDay] = useState22(false);
|
|
12198
|
+
const [multiDayWidth, setMultiDayWidth] = useState22(null);
|
|
12199
|
+
const [dragHandlePosition, setDragHandlePosition] = useState22(null);
|
|
12309
12200
|
const eventDimensions = useRef9({ height: 0 });
|
|
12310
12201
|
const sensors = useSensors(
|
|
12311
12202
|
useSensor(MouseSensor, {
|
|
@@ -12530,7 +12421,7 @@ import {
|
|
|
12530
12421
|
isSameDay,
|
|
12531
12422
|
startOfDay
|
|
12532
12423
|
} from "date-fns";
|
|
12533
|
-
import { useMemo as
|
|
12424
|
+
import { useMemo as useMemo10 } from "react";
|
|
12534
12425
|
import { jsx as jsx75, jsxs as jsxs57 } from "react/jsx-runtime";
|
|
12535
12426
|
function DayView({
|
|
12536
12427
|
currentDate,
|
|
@@ -12538,14 +12429,14 @@ function DayView({
|
|
|
12538
12429
|
onEventSelect,
|
|
12539
12430
|
onEventCreate
|
|
12540
12431
|
}) {
|
|
12541
|
-
const hours =
|
|
12432
|
+
const hours = useMemo10(() => {
|
|
12542
12433
|
const dayStart = startOfDay(currentDate);
|
|
12543
12434
|
return eachHourOfInterval({
|
|
12544
12435
|
end: addHours(dayStart, EndHour - 1),
|
|
12545
12436
|
start: addHours(dayStart, StartHour)
|
|
12546
12437
|
});
|
|
12547
12438
|
}, [currentDate]);
|
|
12548
|
-
const dayEvents =
|
|
12439
|
+
const dayEvents = useMemo10(() => {
|
|
12549
12440
|
return events.filter((event) => {
|
|
12550
12441
|
const eventStart = new Date(event.start);
|
|
12551
12442
|
const eventEnd = new Date(event.end);
|
|
@@ -12554,17 +12445,17 @@ function DayView({
|
|
|
12554
12445
|
(a, b) => new Date(a.start).getTime() - new Date(b.start).getTime()
|
|
12555
12446
|
);
|
|
12556
12447
|
}, [currentDate, events]);
|
|
12557
|
-
const allDayEvents =
|
|
12448
|
+
const allDayEvents = useMemo10(() => {
|
|
12558
12449
|
return dayEvents.filter((event) => {
|
|
12559
12450
|
return event.allDay || isMultiDayEvent(event);
|
|
12560
12451
|
});
|
|
12561
12452
|
}, [dayEvents]);
|
|
12562
|
-
const timeEvents =
|
|
12453
|
+
const timeEvents = useMemo10(() => {
|
|
12563
12454
|
return dayEvents.filter((event) => {
|
|
12564
12455
|
return !event.allDay && !isMultiDayEvent(event);
|
|
12565
12456
|
});
|
|
12566
12457
|
}, [dayEvents]);
|
|
12567
|
-
const positionedEvents =
|
|
12458
|
+
const positionedEvents = useMemo10(() => {
|
|
12568
12459
|
const result = [];
|
|
12569
12460
|
const dayStart = startOfDay(currentDate);
|
|
12570
12461
|
const sortedEvents = [...timeEvents].sort((a, b) => {
|
|
@@ -12745,7 +12636,7 @@ function DayView({
|
|
|
12745
12636
|
import { useDraggable } from "@dnd-kit/core";
|
|
12746
12637
|
import { CSS } from "@dnd-kit/utilities";
|
|
12747
12638
|
import { differenceInDays } from "date-fns";
|
|
12748
|
-
import { useRef as useRef10, useState as
|
|
12639
|
+
import { useRef as useRef10, useState as useState23 } from "react";
|
|
12749
12640
|
import { jsx as jsx76 } from "react/jsx-runtime";
|
|
12750
12641
|
function DraggableEvent({
|
|
12751
12642
|
event,
|
|
@@ -12761,7 +12652,7 @@ function DraggableEvent({
|
|
|
12761
12652
|
}) {
|
|
12762
12653
|
const { activeId } = useCalendarDnd();
|
|
12763
12654
|
const elementRef = useRef10(null);
|
|
12764
|
-
const [dragHandlePosition, setDragHandlePosition] =
|
|
12655
|
+
const [dragHandlePosition, setDragHandlePosition] = useState23(null);
|
|
12765
12656
|
const eventStart = new Date(event.start);
|
|
12766
12657
|
const eventEnd = new Date(event.end);
|
|
12767
12658
|
const isMultiDayEvent2 = isMultiDay || event.allDay || differenceInDays(eventEnd, eventStart) >= 1;
|
|
@@ -12896,7 +12787,7 @@ import {
|
|
|
12896
12787
|
subWeeks
|
|
12897
12788
|
} from "date-fns";
|
|
12898
12789
|
import { ptBR as ptBR4 } from "date-fns/locale";
|
|
12899
|
-
import { useEffect as useEffect19, useMemo as
|
|
12790
|
+
import { useEffect as useEffect19, useMemo as useMemo11, useState as useState24, useCallback as useCallback12 } from "react";
|
|
12900
12791
|
import { toast as toast3 } from "sonner";
|
|
12901
12792
|
import {
|
|
12902
12793
|
ArrowDownIcon,
|
|
@@ -12905,7 +12796,7 @@ import {
|
|
|
12905
12796
|
CalendarIcon as CalendarIcon3,
|
|
12906
12797
|
PlusIcon as PlusIcon3
|
|
12907
12798
|
} from "@phosphor-icons/react";
|
|
12908
|
-
import { Fragment as
|
|
12799
|
+
import { Fragment as Fragment10, jsx as jsx78, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
12909
12800
|
function EventCalendar({
|
|
12910
12801
|
events = [],
|
|
12911
12802
|
onEventAdd,
|
|
@@ -12914,9 +12805,9 @@ function EventCalendar({
|
|
|
12914
12805
|
className,
|
|
12915
12806
|
initialView = "month"
|
|
12916
12807
|
}) {
|
|
12917
|
-
const [currentDate, setCurrentDate] =
|
|
12918
|
-
const [view, setView] =
|
|
12919
|
-
const [isFading, setIsFading] =
|
|
12808
|
+
const [currentDate, setCurrentDate] = useState24(/* @__PURE__ */ new Date());
|
|
12809
|
+
const [view, setView] = useState24(initialView);
|
|
12810
|
+
const [isFading, setIsFading] = useState24(false);
|
|
12920
12811
|
const FADE_DURATION = 220;
|
|
12921
12812
|
const changeView = useCallback12(
|
|
12922
12813
|
(next) => {
|
|
@@ -12929,8 +12820,8 @@ function EventCalendar({
|
|
|
12929
12820
|
},
|
|
12930
12821
|
[view]
|
|
12931
12822
|
);
|
|
12932
|
-
const [isPaging, setIsPaging] =
|
|
12933
|
-
const [pageDirection, setPageDirection] =
|
|
12823
|
+
const [isPaging, setIsPaging] = useState24(false);
|
|
12824
|
+
const [pageDirection, setPageDirection] = useState24(
|
|
12934
12825
|
null
|
|
12935
12826
|
);
|
|
12936
12827
|
const PAGE_DURATION = 200;
|
|
@@ -12948,8 +12839,8 @@ function EventCalendar({
|
|
|
12948
12839
|
},
|
|
12949
12840
|
[]
|
|
12950
12841
|
);
|
|
12951
|
-
const [isEventDialogOpen, setIsEventDialogOpen] =
|
|
12952
|
-
const [selectedEvent, setSelectedEvent] =
|
|
12842
|
+
const [isEventDialogOpen, setIsEventDialogOpen] = useState24(false);
|
|
12843
|
+
const [selectedEvent, setSelectedEvent] = useState24(
|
|
12953
12844
|
null
|
|
12954
12845
|
);
|
|
12955
12846
|
useEffect19(() => {
|
|
@@ -13087,7 +12978,7 @@ function EventCalendar({
|
|
|
13087
12978
|
position: "bottom-left"
|
|
13088
12979
|
});
|
|
13089
12980
|
};
|
|
13090
|
-
const viewTitle =
|
|
12981
|
+
const viewTitle = useMemo11(() => {
|
|
13091
12982
|
const capitalize = (s) => s && s.length > 0 ? s.charAt(0).toUpperCase() + s.slice(1) : s;
|
|
13092
12983
|
if (view === "month") {
|
|
13093
12984
|
return capitalize(format5(currentDate, "MMMM yyyy", { locale: ptBR4 }));
|
|
@@ -13108,7 +12999,7 @@ function EventCalendar({
|
|
|
13108
12999
|
const year = format5(currentDate, "yyyy", { locale: ptBR4 });
|
|
13109
13000
|
const short = `${dayNum} de ${month} de ${year}`;
|
|
13110
13001
|
const long = `${format5(currentDate, "EEE", { locale: ptBR4 })}, ${dayNum} de ${month} de ${year}`;
|
|
13111
|
-
return /* @__PURE__ */ jsxs58(
|
|
13002
|
+
return /* @__PURE__ */ jsxs58(Fragment10, { children: [
|
|
13112
13003
|
/* @__PURE__ */ jsx78("span", { "aria-hidden": "true", className: "min-[480px]:hidden", children: short }),
|
|
13113
13004
|
/* @__PURE__ */ jsx78("span", { "aria-hidden": "true", className: "max-[479px]:hidden min-md:hidden", children: short }),
|
|
13114
13005
|
/* @__PURE__ */ jsx78("span", { className: "max-md:hidden", children: long })
|
|
@@ -13339,7 +13230,7 @@ function EventCalendar({
|
|
|
13339
13230
|
|
|
13340
13231
|
// src/components/event-calendar/EventDialog.tsx
|
|
13341
13232
|
import { format as format6, isBefore } from "date-fns";
|
|
13342
|
-
import { useCallback as useCallback13, useEffect as useEffect20, useMemo as
|
|
13233
|
+
import { useCallback as useCallback13, useEffect as useEffect20, useMemo as useMemo12, useState as useState25 } from "react";
|
|
13343
13234
|
import { RadioGroup as RadioGroup3, RadioGroupItem } from "@radix-ui/react-radio-group";
|
|
13344
13235
|
import { motion as motion16 } from "framer-motion";
|
|
13345
13236
|
import { ptBR as ptBR5 } from "date-fns/locale";
|
|
@@ -13352,18 +13243,18 @@ function EventDialog({
|
|
|
13352
13243
|
onSave,
|
|
13353
13244
|
onDelete
|
|
13354
13245
|
}) {
|
|
13355
|
-
const [title, setTitle] =
|
|
13356
|
-
const [description, setDescription] =
|
|
13357
|
-
const [startDate, setStartDate] =
|
|
13358
|
-
const [endDate, setEndDate] =
|
|
13359
|
-
const [startTime, setStartTime] =
|
|
13360
|
-
const [endTime, setEndTime] =
|
|
13361
|
-
const [allDay, setAllDay] =
|
|
13362
|
-
const [location, setLocation] =
|
|
13363
|
-
const [color, setColor] =
|
|
13364
|
-
const [error, setError] =
|
|
13365
|
-
const [startDateOpen, setStartDateOpen] =
|
|
13366
|
-
const [endDateOpen, setEndDateOpen] =
|
|
13246
|
+
const [title, setTitle] = useState25("");
|
|
13247
|
+
const [description, setDescription] = useState25("");
|
|
13248
|
+
const [startDate, setStartDate] = useState25(/* @__PURE__ */ new Date());
|
|
13249
|
+
const [endDate, setEndDate] = useState25(/* @__PURE__ */ new Date());
|
|
13250
|
+
const [startTime, setStartTime] = useState25(`${DefaultStartHour}:00`);
|
|
13251
|
+
const [endTime, setEndTime] = useState25(`${DefaultEndHour}:00`);
|
|
13252
|
+
const [allDay, setAllDay] = useState25(false);
|
|
13253
|
+
const [location, setLocation] = useState25("");
|
|
13254
|
+
const [color, setColor] = useState25("sky");
|
|
13255
|
+
const [error, setError] = useState25(null);
|
|
13256
|
+
const [startDateOpen, setStartDateOpen] = useState25(false);
|
|
13257
|
+
const [endDateOpen, setEndDateOpen] = useState25(false);
|
|
13367
13258
|
useEffect20(() => {
|
|
13368
13259
|
}, [event]);
|
|
13369
13260
|
const resetForm = useCallback13(() => {
|
|
@@ -13401,7 +13292,7 @@ function EventDialog({
|
|
|
13401
13292
|
resetForm();
|
|
13402
13293
|
}
|
|
13403
13294
|
}, [event, formatTimeForInput, resetForm]);
|
|
13404
|
-
const timeOptions =
|
|
13295
|
+
const timeOptions = useMemo12(() => {
|
|
13405
13296
|
const options = [];
|
|
13406
13297
|
for (let hour = StartHour; hour <= EndHour; hour++) {
|
|
13407
13298
|
for (let minute = 0; minute < 60; minute += 15) {
|
|
@@ -13801,8 +13692,8 @@ function EventDialog({
|
|
|
13801
13692
|
|
|
13802
13693
|
// src/components/event-calendar/EventItem.tsx
|
|
13803
13694
|
import { differenceInMinutes as differenceInMinutes3, format as format7, isPast } from "date-fns";
|
|
13804
|
-
import { useMemo as
|
|
13805
|
-
import { Fragment as
|
|
13695
|
+
import { useMemo as useMemo13 } from "react";
|
|
13696
|
+
import { Fragment as Fragment11, jsx as jsx80, jsxs as jsxs60 } from "react/jsx-runtime";
|
|
13806
13697
|
var formatTimeWithOptionalMinutes = (date) => {
|
|
13807
13698
|
return format7(date, "HH:mm");
|
|
13808
13699
|
};
|
|
@@ -13864,15 +13755,15 @@ function EventItem({
|
|
|
13864
13755
|
onTouchStart
|
|
13865
13756
|
}) {
|
|
13866
13757
|
const eventColor = event.color;
|
|
13867
|
-
const displayStart =
|
|
13758
|
+
const displayStart = useMemo13(() => {
|
|
13868
13759
|
return currentTime || new Date(event.start);
|
|
13869
13760
|
}, [currentTime, event.start]);
|
|
13870
|
-
const displayEnd =
|
|
13761
|
+
const displayEnd = useMemo13(() => {
|
|
13871
13762
|
return currentTime ? new Date(
|
|
13872
13763
|
new Date(currentTime).getTime() + (new Date(event.end).getTime() - new Date(event.start).getTime())
|
|
13873
13764
|
) : new Date(event.end);
|
|
13874
13765
|
}, [currentTime, event.start, event.end]);
|
|
13875
|
-
const durationMinutes =
|
|
13766
|
+
const durationMinutes = useMemo13(() => {
|
|
13876
13767
|
return differenceInMinutes3(displayEnd, displayStart);
|
|
13877
13768
|
}, [displayStart, displayEnd]);
|
|
13878
13769
|
const getEventTime = () => {
|
|
@@ -13937,7 +13828,7 @@ function EventItem({
|
|
|
13937
13828
|
children: durationMinutes < 45 ? /* @__PURE__ */ jsxs60("div", { className: "flex items-center justify-between w-full", children: [
|
|
13938
13829
|
/* @__PURE__ */ jsx80("div", { className: "truncate", children: event.title }),
|
|
13939
13830
|
showTime && /* @__PURE__ */ jsx80("span", { className: "ml-2 inline-block bg-white/10 px-2 py-0.5 rounded-full text-[11px] opacity-90", children: formatTimeWithOptionalMinutes(displayStart) })
|
|
13940
|
-
] }) : /* @__PURE__ */ jsxs60(
|
|
13831
|
+
] }) : /* @__PURE__ */ jsxs60(Fragment11, { children: [
|
|
13941
13832
|
/* @__PURE__ */ jsx80("div", { className: "truncate font-medium", children: event.title }),
|
|
13942
13833
|
showTime && /* @__PURE__ */ jsx80("div", { className: "truncate font-normal opacity-70 sm:text-[11px]", children: /* @__PURE__ */ jsx80("span", { className: "inline-block bg-white/5 px-2 py-0.5 rounded-full", children: getEventTime() }) })
|
|
13943
13834
|
] })
|
|
@@ -13995,7 +13886,7 @@ function EventItem({
|
|
|
13995
13886
|
// src/components/event-calendar/EventsPopUp.tsx
|
|
13996
13887
|
import { format as format8, isSameDay as isSameDay2 } from "date-fns";
|
|
13997
13888
|
import { ptBR as ptBR6 } from "date-fns/locale";
|
|
13998
|
-
import { useEffect as useEffect21, useMemo as
|
|
13889
|
+
import { useEffect as useEffect21, useMemo as useMemo14, useRef as useRef11 } from "react";
|
|
13999
13890
|
import { motion as motion17 } from "framer-motion";
|
|
14000
13891
|
import { XIcon as XIcon11 } from "@phosphor-icons/react";
|
|
14001
13892
|
import { jsx as jsx81, jsxs as jsxs61 } from "react/jsx-runtime";
|
|
@@ -14033,7 +13924,7 @@ function EventsPopup({
|
|
|
14033
13924
|
onEventSelect(event);
|
|
14034
13925
|
onClose();
|
|
14035
13926
|
};
|
|
14036
|
-
const adjustedPosition =
|
|
13927
|
+
const adjustedPosition = useMemo14(() => {
|
|
14037
13928
|
const positionCopy = { ...position };
|
|
14038
13929
|
if (popupRef.current) {
|
|
14039
13930
|
const rect = popupRef.current.getBoundingClientRect();
|
|
@@ -14112,10 +14003,10 @@ function EventsPopup({
|
|
|
14112
14003
|
// src/components/event-calendar/hooks/use-current-time-indicator.ts
|
|
14113
14004
|
import { endOfWeek as endOfWeek2, isSameDay as isSameDay3, isWithinInterval, startOfWeek as startOfWeek2 } from "date-fns";
|
|
14114
14005
|
import { ptBR as ptBR7 } from "date-fns/locale";
|
|
14115
|
-
import { useEffect as useEffect22, useState as
|
|
14006
|
+
import { useEffect as useEffect22, useState as useState26 } from "react";
|
|
14116
14007
|
function useCurrentTimeIndicator(currentDate, view) {
|
|
14117
|
-
const [currentTimePosition, setCurrentTimePosition] =
|
|
14118
|
-
const [currentTimeVisible, setCurrentTimeVisible] =
|
|
14008
|
+
const [currentTimePosition, setCurrentTimePosition] = useState26(0);
|
|
14009
|
+
const [currentTimeVisible, setCurrentTimeVisible] = useState26(false);
|
|
14119
14010
|
useEffect22(() => {
|
|
14120
14011
|
const calculateTimePosition = () => {
|
|
14121
14012
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -14147,14 +14038,14 @@ function useCurrentTimeIndicator(currentDate, view) {
|
|
|
14147
14038
|
}
|
|
14148
14039
|
|
|
14149
14040
|
// src/components/event-calendar/hooks/use-event-visibility.ts
|
|
14150
|
-
import { useLayoutEffect as useLayoutEffect2, useMemo as
|
|
14041
|
+
import { useLayoutEffect as useLayoutEffect2, useMemo as useMemo15, useRef as useRef12, useState as useState27 } from "react";
|
|
14151
14042
|
function useEventVisibility({
|
|
14152
14043
|
eventHeight,
|
|
14153
14044
|
eventGap
|
|
14154
14045
|
}) {
|
|
14155
14046
|
const contentRef = useRef12(null);
|
|
14156
14047
|
const observerRef = useRef12(null);
|
|
14157
|
-
const [contentHeight, setContentHeight] =
|
|
14048
|
+
const [contentHeight, setContentHeight] = useState27(null);
|
|
14158
14049
|
useLayoutEffect2(() => {
|
|
14159
14050
|
if (!contentRef.current) return;
|
|
14160
14051
|
const updateHeight = () => {
|
|
@@ -14175,7 +14066,7 @@ function useEventVisibility({
|
|
|
14175
14066
|
}
|
|
14176
14067
|
};
|
|
14177
14068
|
}, []);
|
|
14178
|
-
const getVisibleEventCount =
|
|
14069
|
+
const getVisibleEventCount = useMemo15(() => {
|
|
14179
14070
|
return (totalEvents) => {
|
|
14180
14071
|
if (!contentHeight) return totalEvents;
|
|
14181
14072
|
const maxEvents = Math.floor(contentHeight / (eventHeight + eventGap));
|
|
@@ -14206,7 +14097,7 @@ import {
|
|
|
14206
14097
|
startOfWeek as startOfWeek3
|
|
14207
14098
|
} from "date-fns";
|
|
14208
14099
|
import { ptBR as ptBR8 } from "date-fns/locale";
|
|
14209
|
-
import { useEffect as useEffect23, useMemo as
|
|
14100
|
+
import { useEffect as useEffect23, useMemo as useMemo16, useState as useState28 } from "react";
|
|
14210
14101
|
import { jsx as jsx82, jsxs as jsxs62 } from "react/jsx-runtime";
|
|
14211
14102
|
function MonthView({
|
|
14212
14103
|
currentDate,
|
|
@@ -14214,21 +14105,21 @@ function MonthView({
|
|
|
14214
14105
|
onEventSelect,
|
|
14215
14106
|
onEventCreate
|
|
14216
14107
|
}) {
|
|
14217
|
-
const days =
|
|
14108
|
+
const days = useMemo16(() => {
|
|
14218
14109
|
const monthStart = startOfMonth(currentDate);
|
|
14219
14110
|
const monthEnd = endOfMonth(monthStart);
|
|
14220
14111
|
const calendarStart = startOfWeek3(monthStart, { weekStartsOn: 0 });
|
|
14221
14112
|
const calendarEnd = endOfWeek3(monthEnd, { weekStartsOn: 0 });
|
|
14222
14113
|
return eachDayOfInterval({ end: calendarEnd, start: calendarStart });
|
|
14223
14114
|
}, [currentDate]);
|
|
14224
|
-
const weekdays =
|
|
14115
|
+
const weekdays = useMemo16(() => {
|
|
14225
14116
|
return Array.from({ length: 7 }).map((_, i) => {
|
|
14226
14117
|
const date = addDays3(startOfWeek3(/* @__PURE__ */ new Date(), { weekStartsOn: 0 }), i);
|
|
14227
14118
|
const short = format9(date, "EEE", { locale: ptBR8 });
|
|
14228
14119
|
return short.charAt(0).toUpperCase() + short.slice(1);
|
|
14229
14120
|
});
|
|
14230
14121
|
}, []);
|
|
14231
|
-
const weeks =
|
|
14122
|
+
const weeks = useMemo16(() => {
|
|
14232
14123
|
const result = [];
|
|
14233
14124
|
let week = [];
|
|
14234
14125
|
for (let i = 0; i < days.length; i++) {
|
|
@@ -14244,7 +14135,7 @@ function MonthView({
|
|
|
14244
14135
|
e.stopPropagation();
|
|
14245
14136
|
onEventSelect(event);
|
|
14246
14137
|
};
|
|
14247
|
-
const [isMounted, setIsMounted] =
|
|
14138
|
+
const [isMounted, setIsMounted] = useState28(false);
|
|
14248
14139
|
const { contentRef, getVisibleEventCount } = useEventVisibility({
|
|
14249
14140
|
eventGap: EventGap,
|
|
14250
14141
|
eventHeight: EventHeight
|
|
@@ -14521,7 +14412,7 @@ import {
|
|
|
14521
14412
|
startOfWeek as startOfWeek4
|
|
14522
14413
|
} from "date-fns";
|
|
14523
14414
|
import { ptBR as ptBR9 } from "date-fns/locale";
|
|
14524
|
-
import { useMemo as
|
|
14415
|
+
import { useMemo as useMemo17 } from "react";
|
|
14525
14416
|
import { jsx as jsx83, jsxs as jsxs63 } from "react/jsx-runtime";
|
|
14526
14417
|
function WeekView({
|
|
14527
14418
|
currentDate,
|
|
@@ -14529,23 +14420,23 @@ function WeekView({
|
|
|
14529
14420
|
onEventSelect,
|
|
14530
14421
|
onEventCreate
|
|
14531
14422
|
}) {
|
|
14532
|
-
const days =
|
|
14423
|
+
const days = useMemo17(() => {
|
|
14533
14424
|
const weekStart2 = startOfWeek4(currentDate, { weekStartsOn: 0 });
|
|
14534
14425
|
const weekEnd = endOfWeek4(currentDate, { weekStartsOn: 0 });
|
|
14535
14426
|
return eachDayOfInterval2({ end: weekEnd, start: weekStart2 });
|
|
14536
14427
|
}, [currentDate]);
|
|
14537
|
-
const weekStart =
|
|
14428
|
+
const weekStart = useMemo17(
|
|
14538
14429
|
() => startOfWeek4(currentDate, { weekStartsOn: 0 }),
|
|
14539
14430
|
[currentDate]
|
|
14540
14431
|
);
|
|
14541
|
-
const hours =
|
|
14432
|
+
const hours = useMemo17(() => {
|
|
14542
14433
|
const dayStart = startOfDay2(currentDate);
|
|
14543
14434
|
return eachHourOfInterval2({
|
|
14544
14435
|
end: addHours2(dayStart, EndHour - 1),
|
|
14545
14436
|
start: addHours2(dayStart, StartHour)
|
|
14546
14437
|
});
|
|
14547
14438
|
}, [currentDate]);
|
|
14548
|
-
const allDayEvents =
|
|
14439
|
+
const allDayEvents = useMemo17(() => {
|
|
14549
14440
|
return events.filter((event) => {
|
|
14550
14441
|
return event.allDay || isMultiDayEvent(event);
|
|
14551
14442
|
}).filter((event) => {
|
|
@@ -14556,7 +14447,7 @@ function WeekView({
|
|
|
14556
14447
|
);
|
|
14557
14448
|
});
|
|
14558
14449
|
}, [events, days]);
|
|
14559
|
-
const processedDayEvents =
|
|
14450
|
+
const processedDayEvents = useMemo17(() => {
|
|
14560
14451
|
const result = days.map((day) => {
|
|
14561
14452
|
const dayEvents = events.filter((event) => {
|
|
14562
14453
|
if (event.allDay || isMultiDayEvent(event)) return false;
|
|
@@ -14802,11 +14693,11 @@ function WeekView({
|
|
|
14802
14693
|
}
|
|
14803
14694
|
|
|
14804
14695
|
// src/components/ui/form/CheckBoxThree.tsx
|
|
14805
|
-
import { useCallback as useCallback14, useMemo as
|
|
14696
|
+
import { useCallback as useCallback14, useMemo as useMemo18, useState as useState29, useEffect as useEffect24, useRef as useRef13 } from "react";
|
|
14806
14697
|
import { motion as motion18, AnimatePresence as AnimatePresence12 } from "framer-motion";
|
|
14807
14698
|
import { jsx as jsx84, jsxs as jsxs64 } from "react/jsx-runtime";
|
|
14808
14699
|
function useCheckboxTree(initialTree) {
|
|
14809
|
-
const initialCheckedNodes =
|
|
14700
|
+
const initialCheckedNodes = useMemo18(() => {
|
|
14810
14701
|
const checkedSet = /* @__PURE__ */ new Set();
|
|
14811
14702
|
const initializeCheckedNodes = (node) => {
|
|
14812
14703
|
if (node.defaultChecked) {
|
|
@@ -14817,7 +14708,7 @@ function useCheckboxTree(initialTree) {
|
|
|
14817
14708
|
initializeCheckedNodes(initialTree);
|
|
14818
14709
|
return checkedSet;
|
|
14819
14710
|
}, [initialTree]);
|
|
14820
|
-
const [checkedNodes, setCheckedNodes] =
|
|
14711
|
+
const [checkedNodes, setCheckedNodes] = useState29(initialCheckedNodes);
|
|
14821
14712
|
const isChecked = useCallback14(
|
|
14822
14713
|
(node) => {
|
|
14823
14714
|
if (!node.children) {
|
|
@@ -14866,7 +14757,7 @@ function CheckboxTree({ tree, renderNode }) {
|
|
|
14866
14757
|
onCheckedChange,
|
|
14867
14758
|
children
|
|
14868
14759
|
}) => {
|
|
14869
|
-
const [open, setOpen] =
|
|
14760
|
+
const [open, setOpen] = useState29(() => !!node.children && status !== false);
|
|
14870
14761
|
const checkboxRef = useRef13(null);
|
|
14871
14762
|
useEffect24(() => {
|
|
14872
14763
|
if (checkboxRef.current) {
|
|
@@ -14952,10 +14843,10 @@ function CheckboxTree({ tree, renderNode }) {
|
|
|
14952
14843
|
}
|
|
14953
14844
|
|
|
14954
14845
|
// src/hooks/use-drag.tsx
|
|
14955
|
-
import { useState as
|
|
14846
|
+
import { useState as useState30, useCallback as useCallback15, useRef as useRef14, useEffect as useEffect25 } from "react";
|
|
14956
14847
|
var useDrag = (options = {}) => {
|
|
14957
|
-
const [isDragging, setIsDragging] =
|
|
14958
|
-
const [positions, setPositions] =
|
|
14848
|
+
const [isDragging, setIsDragging] = useState30(null);
|
|
14849
|
+
const [positions, setPositions] = useState30({});
|
|
14959
14850
|
const dragStartPos = useRef14(null);
|
|
14960
14851
|
const dragId = useRef14(null);
|
|
14961
14852
|
const handleMouseDown = useCallback15((id, e) => {
|
|
@@ -15272,7 +15163,6 @@ export {
|
|
|
15272
15163
|
StartHour,
|
|
15273
15164
|
StatusIndicator,
|
|
15274
15165
|
SwitchBase,
|
|
15275
|
-
TITLE_CLASSNAME,
|
|
15276
15166
|
TableBase,
|
|
15277
15167
|
TableBodyBase,
|
|
15278
15168
|
TableCaptionBase,
|
|
@@ -15304,31 +15194,16 @@ export {
|
|
|
15304
15194
|
VisibilityButton,
|
|
15305
15195
|
WeekCellsHeight,
|
|
15306
15196
|
WeekView,
|
|
15307
|
-
adaptDataForTooltip,
|
|
15308
15197
|
addHoursToDate,
|
|
15309
15198
|
badgeVariants,
|
|
15310
|
-
buildPercentFormatter,
|
|
15311
15199
|
buttonVariantsBase,
|
|
15312
15200
|
compactTick,
|
|
15313
|
-
computeAllKeys,
|
|
15314
|
-
computeAxisLabelWidth,
|
|
15315
|
-
computeChartWidth,
|
|
15316
|
-
computeEstimatedAxisNeeded,
|
|
15317
|
-
computeLabelSample,
|
|
15318
|
-
computeLeftRightKeys,
|
|
15319
|
-
computeNiceMax,
|
|
15320
|
-
computeProcessedData,
|
|
15321
|
-
computeSeriesOrder,
|
|
15322
15201
|
convert12HourTo24Hour,
|
|
15323
|
-
createFinalValueFormatter,
|
|
15324
|
-
createYTickFormatter,
|
|
15325
15202
|
detectDataFields,
|
|
15326
15203
|
detectXAxis,
|
|
15327
15204
|
display12HourValue,
|
|
15328
|
-
estimateTextWidth,
|
|
15329
15205
|
formatFieldName,
|
|
15330
15206
|
generateAdditionalColors,
|
|
15331
|
-
generateColors,
|
|
15332
15207
|
getAgendaEventsForDay,
|
|
15333
15208
|
getAllEventsForDay,
|
|
15334
15209
|
getArrowByType,
|
|
@@ -15349,9 +15224,8 @@ export {
|
|
|
15349
15224
|
isValid12Hour,
|
|
15350
15225
|
isValidHour,
|
|
15351
15226
|
isValidMinuteOrSecond,
|
|
15352
|
-
maxForKeys,
|
|
15353
|
-
minForKeys,
|
|
15354
15227
|
niceCeil,
|
|
15228
|
+
renderInsideBarLabel,
|
|
15355
15229
|
pillLabelRenderer_default as renderPillLabel,
|
|
15356
15230
|
resolveChartMargins,
|
|
15357
15231
|
resolveContainerPaddingLeft,
|
|
@@ -15364,11 +15238,9 @@ export {
|
|
|
15364
15238
|
toast2 as toast,
|
|
15365
15239
|
useCalendarDnd,
|
|
15366
15240
|
useChartHighlights,
|
|
15367
|
-
useChartLayout,
|
|
15368
15241
|
useCurrentTimeIndicator,
|
|
15369
15242
|
useDrag,
|
|
15370
15243
|
useEventVisibility,
|
|
15371
15244
|
useIsMobile,
|
|
15372
|
-
useMeasureWidth,
|
|
15373
15245
|
useTheme
|
|
15374
15246
|
};
|