@mlw-packages/react-components 1.8.5 → 1.8.7
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.css +92 -49
- package/dist/index.d.mts +85 -10
- package/dist/index.d.ts +85 -10
- package/dist/index.js +829 -315
- package/dist/index.mjs +808 -286
- package/dist/pwa-512x512-4NJPUGCI.png +0 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -515,6 +515,7 @@ __export(index_exports, {
|
|
|
515
515
|
BreadcrumbListBase: () => BreadcrumbListBase,
|
|
516
516
|
BreadcrumbPageBase: () => BreadcrumbPageBase,
|
|
517
517
|
BreadcrumbSeparatorBase: () => BreadcrumbSeparatorBase,
|
|
518
|
+
Brush: () => Brush_default,
|
|
518
519
|
ButtonBase: () => ButtonBase,
|
|
519
520
|
ButtonGroupBase: () => ButtonGroupBase,
|
|
520
521
|
CalendarBase: () => CalendarBase,
|
|
@@ -768,6 +769,7 @@ __export(index_exports, {
|
|
|
768
769
|
ThemeProviderBase: () => ThemeProviderBase,
|
|
769
770
|
TimePicker: () => TimePicker,
|
|
770
771
|
TimePickerInput: () => TimePickerInput,
|
|
772
|
+
TimeSeries: () => TimeSeries_default,
|
|
771
773
|
Toaster: () => Toaster,
|
|
772
774
|
TooltipBase: () => TooltipBase,
|
|
773
775
|
TooltipContentBase: () => TooltipContentBase,
|
|
@@ -863,6 +865,7 @@ __export(index_exports, {
|
|
|
863
865
|
useEventVisibilityAgenda: () => useEventVisibilityAgenda,
|
|
864
866
|
useIsMobile: () => useIsMobile,
|
|
865
867
|
useTheme: () => useTheme,
|
|
868
|
+
useTimeSeriesRange: () => useTimeSeriesRange,
|
|
866
869
|
visualForItem: () => visualForItem
|
|
867
870
|
});
|
|
868
871
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -1555,45 +1558,55 @@ function SkeletonBase({
|
|
|
1555
1558
|
var import_react2 = require("@phosphor-icons/react");
|
|
1556
1559
|
var import_sonner = require("sonner");
|
|
1557
1560
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1558
|
-
var iconBaseClass = "w-5 h-
|
|
1561
|
+
var iconBaseClass = "w-5 h-5";
|
|
1559
1562
|
var Toaster = ({ testId, ...props }) => {
|
|
1560
1563
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1561
1564
|
import_sonner.Toaster,
|
|
1562
1565
|
{
|
|
1563
1566
|
className: "toaster group",
|
|
1564
1567
|
position: "top-center",
|
|
1568
|
+
duration: 4e3,
|
|
1565
1569
|
toastOptions: {
|
|
1570
|
+
style: {
|
|
1571
|
+
backdropFilter: "blur(8px)",
|
|
1572
|
+
WebkitBackdropFilter: "blur(8px)"
|
|
1573
|
+
},
|
|
1566
1574
|
classNames: {
|
|
1567
1575
|
toast: `
|
|
1568
1576
|
group toast
|
|
1569
|
-
bg-background
|
|
1577
|
+
bg-background/95
|
|
1570
1578
|
text-foreground
|
|
1571
|
-
shadow-
|
|
1579
|
+
shadow-xl rounded-lg
|
|
1572
1580
|
border-l-4
|
|
1573
|
-
|
|
1581
|
+
|
|
1574
1582
|
flex items-center gap-3
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
data-[type=
|
|
1578
|
-
data-[type=
|
|
1583
|
+
transition-all duration-300
|
|
1584
|
+
hover:scale-[1.02] hover:shadow-2xl
|
|
1585
|
+
data-[type=success]:border-l-green-500 data-[type=success]:bg-green-50/95 data-[type=success]:text-green-800 data-[type=success]:border-green-500 data-
|
|
1586
|
+
data-[type=error]:border-l-red-500 data-[type=error]:bg-red-50/95 data-[type=error]:text-red-800 data-[type=error]:border-red-500
|
|
1587
|
+
data-[type=warning]:border-l-yellow-500 data-[type=warning]:bg-yellow-50/95 data-[type=warning]:text-yellow-800 data-[type=warning]:border-yellow-500
|
|
1588
|
+
data-[type=info]:border-l-blue-500 data-[type=info]:bg-blue-50/95 data-[type=info]:text-blue-800 data-[type=info]:border-blue-500
|
|
1579
1589
|
`,
|
|
1580
1590
|
description: `
|
|
1581
|
-
text-
|
|
1591
|
+
text-xs
|
|
1592
|
+
font-semibold
|
|
1582
1593
|
group-[.toast]:text-neutral-600
|
|
1583
1594
|
`,
|
|
1584
1595
|
actionButton: `
|
|
1585
1596
|
ml-auto
|
|
1586
1597
|
rounded-md px-3 py-1 text-sm font-semibold
|
|
1587
1598
|
bg-neutral-800 text-white
|
|
1588
|
-
hover:bg-neutral-700
|
|
1589
|
-
transition-
|
|
1599
|
+
hover:bg-neutral-700 hover:scale-105
|
|
1600
|
+
transition-all duration-200
|
|
1601
|
+
active:scale-95
|
|
1590
1602
|
`,
|
|
1591
1603
|
cancelButton: `
|
|
1592
1604
|
ml-2
|
|
1593
1605
|
rounded-md px-3 py-1 text-sm font-semibold
|
|
1594
1606
|
bg-neutral-100 text-neutral-700
|
|
1595
|
-
hover:bg-neutral-200
|
|
1596
|
-
transition-
|
|
1607
|
+
hover:bg-neutral-200 hover:scale-105
|
|
1608
|
+
transition-all duration-200
|
|
1609
|
+
active:scale-95
|
|
1597
1610
|
`
|
|
1598
1611
|
}
|
|
1599
1612
|
},
|
|
@@ -1603,24 +1616,52 @@ var Toaster = ({ testId, ...props }) => {
|
|
|
1603
1616
|
);
|
|
1604
1617
|
};
|
|
1605
1618
|
var toast = {
|
|
1606
|
-
success: (message) => import_sonner.toast.success(message, {
|
|
1607
|
-
|
|
1619
|
+
success: (message, description) => import_sonner.toast.success(message, {
|
|
1620
|
+
description,
|
|
1621
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1622
|
+
import_react2.CheckCircleIcon,
|
|
1623
|
+
{
|
|
1624
|
+
className: `${iconBaseClass} text-green-600`,
|
|
1625
|
+
weight: "fill"
|
|
1626
|
+
}
|
|
1627
|
+
),
|
|
1608
1628
|
className: "sonner-success"
|
|
1609
1629
|
}),
|
|
1610
|
-
error: (message) => import_sonner.toast.error(message, {
|
|
1611
|
-
|
|
1630
|
+
error: (message, description) => import_sonner.toast.error(message, {
|
|
1631
|
+
description,
|
|
1632
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1633
|
+
import_react2.XCircleIcon,
|
|
1634
|
+
{
|
|
1635
|
+
className: `${iconBaseClass} text-red-600`,
|
|
1636
|
+
weight: "fill"
|
|
1637
|
+
}
|
|
1638
|
+
),
|
|
1612
1639
|
className: "sonner-error"
|
|
1613
1640
|
}),
|
|
1614
|
-
warning: (message) => import_sonner.toast.warning(message, {
|
|
1615
|
-
|
|
1616
|
-
|
|
1641
|
+
warning: (message, description) => import_sonner.toast.warning(message, {
|
|
1642
|
+
description,
|
|
1643
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1644
|
+
import_react2.WarningIcon,
|
|
1645
|
+
{
|
|
1646
|
+
className: `${iconBaseClass} text-yellow-600`,
|
|
1647
|
+
weight: "fill"
|
|
1648
|
+
}
|
|
1649
|
+
),
|
|
1650
|
+
className: "sonner-warning"
|
|
1617
1651
|
}),
|
|
1618
|
-
info: (message) => import_sonner.toast.info(message, {
|
|
1652
|
+
info: (message, description) => import_sonner.toast.info(message, {
|
|
1653
|
+
description,
|
|
1619
1654
|
icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react2.InfoIcon, { className: `${iconBaseClass} text-blue-600`, weight: "fill" }),
|
|
1620
|
-
className: "sonner-
|
|
1655
|
+
className: "sonner-info"
|
|
1621
1656
|
}),
|
|
1622
|
-
loading: (message) => (0, import_sonner.toast)(message, {
|
|
1623
|
-
|
|
1657
|
+
loading: (message, description) => (0, import_sonner.toast)(message, {
|
|
1658
|
+
description,
|
|
1659
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1660
|
+
import_react2.CircleNotchIcon,
|
|
1661
|
+
{
|
|
1662
|
+
className: `${iconBaseClass} animate-spin text-gray-600`
|
|
1663
|
+
}
|
|
1664
|
+
),
|
|
1624
1665
|
className: "sonner-loading"
|
|
1625
1666
|
})
|
|
1626
1667
|
};
|
|
@@ -1768,12 +1809,21 @@ var TooltipTriggerBase = React7.forwardRef(({ children, onPointerDown, ...props
|
|
|
1768
1809
|
},
|
|
1769
1810
|
[onPointerDown]
|
|
1770
1811
|
);
|
|
1812
|
+
const onClick = React7.useCallback(
|
|
1813
|
+
(e) => {
|
|
1814
|
+
if (onPointerDown) {
|
|
1815
|
+
onPointerDown(e);
|
|
1816
|
+
}
|
|
1817
|
+
},
|
|
1818
|
+
[onPointerDown]
|
|
1819
|
+
);
|
|
1771
1820
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1772
1821
|
TooltipPrimitive.Trigger,
|
|
1773
1822
|
{
|
|
1774
1823
|
ref,
|
|
1775
1824
|
tabIndex: -1,
|
|
1776
1825
|
onPointerDown: onPointerDown ? handlePointerDown : void 0,
|
|
1826
|
+
onClick,
|
|
1777
1827
|
"data-tooltip-trigger": true,
|
|
1778
1828
|
"aria-describedby": "tooltip-content",
|
|
1779
1829
|
...props,
|
|
@@ -3139,8 +3189,7 @@ function MultiCombobox({
|
|
|
3139
3189
|
)
|
|
3140
3190
|
]
|
|
3141
3191
|
}
|
|
3142
|
-
)
|
|
3143
|
-
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorMessage_default, { error })
|
|
3192
|
+
)
|
|
3144
3193
|
]
|
|
3145
3194
|
}
|
|
3146
3195
|
);
|
|
@@ -7953,7 +8002,7 @@ function CalendarBase2({
|
|
|
7953
8002
|
selected: "bg-primary text-primary-foreground hover:bg-primary/90 focus:bg-primary/90 font-semibold hover:text-white rounded-md",
|
|
7954
8003
|
today: "bg-muted text-foreground font-bold ring-2 ring-primary/30 ring-inset rounded-md",
|
|
7955
8004
|
outside: "text-muted-foreground opacity-60 aria-selected:bg-muted/50 aria-selected:text-foreground",
|
|
7956
|
-
disabled: "text-muted-foreground cursor-not-allowed
|
|
8005
|
+
disabled: "text-muted-foreground cursor-not-allowed",
|
|
7957
8006
|
range_middle: "aria-selected:bg-muted aria-selected:text-foreground",
|
|
7958
8007
|
hidden: "invisible",
|
|
7959
8008
|
...classNames
|
|
@@ -14205,6 +14254,11 @@ function WeekView({
|
|
|
14205
14254
|
// src/components/ui/selects/AvatarCombobox.tsx
|
|
14206
14255
|
var import_react84 = require("react");
|
|
14207
14256
|
var import_react85 = require("@phosphor-icons/react");
|
|
14257
|
+
|
|
14258
|
+
// public/pwa-512x512.png
|
|
14259
|
+
var pwa_512x512_default = "./pwa-512x512-4NJPUGCI.png";
|
|
14260
|
+
|
|
14261
|
+
// src/components/ui/selects/AvatarCombobox.tsx
|
|
14208
14262
|
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
14209
14263
|
var DEFAULT_COLORS = [
|
|
14210
14264
|
"bg-purple-100 text-purple-700",
|
|
@@ -14253,10 +14307,14 @@ function AvatarCombobox({
|
|
|
14253
14307
|
const allItems = items || (groupItems ? Object.values(groupItems).flat() : []);
|
|
14254
14308
|
const selectedItem = allItems.find((item) => item.value === selected);
|
|
14255
14309
|
const renderItem = (item) => {
|
|
14256
|
-
|
|
14257
|
-
|
|
14310
|
+
let avatarContent;
|
|
14311
|
+
let colorClass;
|
|
14312
|
+
if (!item.img) {
|
|
14313
|
+
avatarContent = item.avatar ?? item.label.charAt(0).toUpperCase();
|
|
14314
|
+
colorClass = item.avatarClassName ?? getColor(item.value, colors2);
|
|
14315
|
+
}
|
|
14258
14316
|
return /* @__PURE__ */ (0, import_jsx_runtime85.jsxs)(import_jsx_runtime85.Fragment, { children: [
|
|
14259
|
-
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Square, { className: colorClass, children: avatarContent }),
|
|
14317
|
+
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)(Square, { className: colorClass, children: !avatarContent ? /* @__PURE__ */ (0, import_jsx_runtime85.jsx)("img", { src: pwa_512x512_default }) : avatarContent }),
|
|
14260
14318
|
/* @__PURE__ */ (0, import_jsx_runtime85.jsx)("span", { className: "truncate", children: item.label })
|
|
14261
14319
|
] });
|
|
14262
14320
|
};
|
|
@@ -14592,13 +14650,13 @@ function MultiSelect({
|
|
|
14592
14650
|
}
|
|
14593
14651
|
|
|
14594
14652
|
// src/components/ui/charts/Chart.tsx
|
|
14595
|
-
var
|
|
14596
|
-
var
|
|
14653
|
+
var import_react97 = require("react");
|
|
14654
|
+
var import_recharts2 = require("recharts");
|
|
14597
14655
|
|
|
14598
14656
|
// src/components/ui/charts/utils/helpers.ts
|
|
14599
14657
|
var formatFieldName = (fieldName) => {
|
|
14600
14658
|
return fieldName.split(/[/_-]/).filter(Boolean).map((word) => {
|
|
14601
|
-
return word.charAt(0).toUpperCase() + word.slice(1)
|
|
14659
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
14602
14660
|
}).join(" ").trim();
|
|
14603
14661
|
};
|
|
14604
14662
|
var detectDataFields = (data, xAxisKey) => {
|
|
@@ -16153,8 +16211,205 @@ var TooltipSimple = ({
|
|
|
16153
16211
|
};
|
|
16154
16212
|
var TooltipSimple_default = TooltipSimple;
|
|
16155
16213
|
|
|
16156
|
-
// src/components/ui/charts/
|
|
16214
|
+
// src/components/ui/charts/components/Brush.tsx
|
|
16215
|
+
var import_recharts = require("recharts");
|
|
16157
16216
|
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
16217
|
+
var Brush = ({
|
|
16218
|
+
data,
|
|
16219
|
+
startIndex,
|
|
16220
|
+
endIndex,
|
|
16221
|
+
onMouseDown,
|
|
16222
|
+
brushRef,
|
|
16223
|
+
xAxisKey,
|
|
16224
|
+
seriesOrder,
|
|
16225
|
+
finalColors,
|
|
16226
|
+
brushHeight = 80,
|
|
16227
|
+
brushColor,
|
|
16228
|
+
miniChartOpacity = 0.3,
|
|
16229
|
+
margin = { left: 0, right: 0 }
|
|
16230
|
+
}) => {
|
|
16231
|
+
const dataLength = data.length;
|
|
16232
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "w-full px-8 pb-4", children: [
|
|
16233
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
|
|
16234
|
+
"div",
|
|
16235
|
+
{
|
|
16236
|
+
className: "relative rounded-md border bg-muted/5 shadow-inner",
|
|
16237
|
+
style: { height: brushHeight },
|
|
16238
|
+
children: [
|
|
16239
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16240
|
+
"div",
|
|
16241
|
+
{
|
|
16242
|
+
className: "absolute inset-0 pointer-events-none rounded-md",
|
|
16243
|
+
style: { opacity: miniChartOpacity },
|
|
16244
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height: brushHeight, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
|
|
16245
|
+
import_recharts.ComposedChart,
|
|
16246
|
+
{
|
|
16247
|
+
data: data.map((item) => ({
|
|
16248
|
+
...item,
|
|
16249
|
+
name: String(item[xAxisKey] || "N/A")
|
|
16250
|
+
})),
|
|
16251
|
+
height: brushHeight,
|
|
16252
|
+
margin: {
|
|
16253
|
+
top: 5,
|
|
16254
|
+
right: margin.right ?? 30,
|
|
16255
|
+
left: margin.left ?? 0,
|
|
16256
|
+
bottom: 5
|
|
16257
|
+
},
|
|
16258
|
+
children: [
|
|
16259
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_recharts.XAxis, { dataKey: xAxisKey, hide: true }),
|
|
16260
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_recharts.YAxis, { yAxisId: "left", hide: true }),
|
|
16261
|
+
seriesOrder.map((s) => {
|
|
16262
|
+
const key = s.key;
|
|
16263
|
+
const color = finalColors[key];
|
|
16264
|
+
if (s.type === "bar") {
|
|
16265
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16266
|
+
import_recharts.Bar,
|
|
16267
|
+
{
|
|
16268
|
+
dataKey: key,
|
|
16269
|
+
yAxisId: "left",
|
|
16270
|
+
fill: color,
|
|
16271
|
+
radius: [2, 2, 0, 0]
|
|
16272
|
+
},
|
|
16273
|
+
`brush-bar-${key}`
|
|
16274
|
+
);
|
|
16275
|
+
}
|
|
16276
|
+
if (s.type === "line") {
|
|
16277
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16278
|
+
import_recharts.Line,
|
|
16279
|
+
{
|
|
16280
|
+
type: "monotone",
|
|
16281
|
+
dataKey: key,
|
|
16282
|
+
yAxisId: "left",
|
|
16283
|
+
stroke: color,
|
|
16284
|
+
strokeWidth: 1.5,
|
|
16285
|
+
dot: false
|
|
16286
|
+
},
|
|
16287
|
+
`brush-line-${key}`
|
|
16288
|
+
);
|
|
16289
|
+
}
|
|
16290
|
+
if (s.type === "area") {
|
|
16291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16292
|
+
import_recharts.Area,
|
|
16293
|
+
{
|
|
16294
|
+
type: "monotone",
|
|
16295
|
+
dataKey: key,
|
|
16296
|
+
yAxisId: "left",
|
|
16297
|
+
stroke: color,
|
|
16298
|
+
fill: `url(#gradient-${key})`,
|
|
16299
|
+
strokeWidth: 1.5
|
|
16300
|
+
},
|
|
16301
|
+
`brush-area-${key}`
|
|
16302
|
+
);
|
|
16303
|
+
}
|
|
16304
|
+
return null;
|
|
16305
|
+
})
|
|
16306
|
+
]
|
|
16307
|
+
}
|
|
16308
|
+
) })
|
|
16309
|
+
}
|
|
16310
|
+
),
|
|
16311
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
|
|
16312
|
+
"div",
|
|
16313
|
+
{
|
|
16314
|
+
ref: brushRef,
|
|
16315
|
+
className: "absolute inset-0 cursor-move rounded-md",
|
|
16316
|
+
style: { userSelect: "none" },
|
|
16317
|
+
children: [
|
|
16318
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16319
|
+
"div",
|
|
16320
|
+
{
|
|
16321
|
+
className: "absolute top-0 bottom-0 left-0 bg-background/80 backdrop-blur-[1px] pointer-events-none rounded-l-md border-r border-border/50",
|
|
16322
|
+
style: {
|
|
16323
|
+
width: `${startIndex / (dataLength - 1) * 100}%`
|
|
16324
|
+
}
|
|
16325
|
+
}
|
|
16326
|
+
),
|
|
16327
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16328
|
+
"div",
|
|
16329
|
+
{
|
|
16330
|
+
className: "absolute top-0 bottom-0 right-0 bg-background/80 backdrop-blur-[1px] pointer-events-none rounded-r-md border-l border-border/50",
|
|
16331
|
+
style: {
|
|
16332
|
+
width: `${(dataLength - 1 - endIndex) / (dataLength - 1) * 100}%`
|
|
16333
|
+
}
|
|
16334
|
+
}
|
|
16335
|
+
),
|
|
16336
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
|
|
16337
|
+
"div",
|
|
16338
|
+
{
|
|
16339
|
+
className: "absolute top-0 bottom-0 border-x-2 border-y border-primary/50 cursor-move group hover:bg-primary/5 rounded-md",
|
|
16340
|
+
style: {
|
|
16341
|
+
left: `${startIndex / (dataLength - 1) * 100}%`,
|
|
16342
|
+
right: `${(dataLength - 1 - endIndex) / (dataLength - 1) * 100}%`,
|
|
16343
|
+
backgroundColor: "transparent"
|
|
16344
|
+
},
|
|
16345
|
+
onMouseDown: (e) => onMouseDown(e, "middle"),
|
|
16346
|
+
children: [
|
|
16347
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16348
|
+
"div",
|
|
16349
|
+
{
|
|
16350
|
+
className: "absolute top-1/2 -translate-y-1/2 -left-3.5 w-7 h-12 flex items-center justify-center cursor-ew-resize group/handle",
|
|
16351
|
+
onMouseDown: (e) => {
|
|
16352
|
+
e.stopPropagation();
|
|
16353
|
+
onMouseDown(e, "start");
|
|
16354
|
+
},
|
|
16355
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16356
|
+
"div",
|
|
16357
|
+
{
|
|
16358
|
+
className: "w-1.5 h-6 rounded-sm flex flex-col items-center justify-center gap-1 border border-primary/20",
|
|
16359
|
+
style: {
|
|
16360
|
+
backgroundColor: brushColor ?? "hsl(var(--primary))"
|
|
16361
|
+
}
|
|
16362
|
+
}
|
|
16363
|
+
)
|
|
16364
|
+
}
|
|
16365
|
+
),
|
|
16366
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16367
|
+
"div",
|
|
16368
|
+
{
|
|
16369
|
+
className: "absolute top-1/2 -translate-y-1/2 -right-3.5 w-7 h-12 flex items-center justify-center cursor-ew-resize group/handle",
|
|
16370
|
+
onMouseDown: (e) => {
|
|
16371
|
+
e.stopPropagation();
|
|
16372
|
+
onMouseDown(e, "end");
|
|
16373
|
+
},
|
|
16374
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
16375
|
+
"div",
|
|
16376
|
+
{
|
|
16377
|
+
className: "w-1.5 h-6 rounded-sm flex flex-col items-center justify-center gap-1 border border-primary/20",
|
|
16378
|
+
style: {
|
|
16379
|
+
backgroundColor: brushColor ?? "hsl(var(--primary))"
|
|
16380
|
+
}
|
|
16381
|
+
}
|
|
16382
|
+
)
|
|
16383
|
+
}
|
|
16384
|
+
)
|
|
16385
|
+
]
|
|
16386
|
+
}
|
|
16387
|
+
)
|
|
16388
|
+
]
|
|
16389
|
+
}
|
|
16390
|
+
)
|
|
16391
|
+
]
|
|
16392
|
+
}
|
|
16393
|
+
),
|
|
16394
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "flex justify-between items-center mt-2 text-xs text-muted-foreground", children: [
|
|
16395
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("span", { children: [
|
|
16396
|
+
data[startIndex]?.[xAxisKey],
|
|
16397
|
+
" - ",
|
|
16398
|
+
data[endIndex]?.[xAxisKey]
|
|
16399
|
+
] }),
|
|
16400
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("span", { children: [
|
|
16401
|
+
endIndex - startIndex + 1,
|
|
16402
|
+
" de ",
|
|
16403
|
+
dataLength,
|
|
16404
|
+
" per\xEDodos"
|
|
16405
|
+
] })
|
|
16406
|
+
] })
|
|
16407
|
+
] });
|
|
16408
|
+
};
|
|
16409
|
+
var Brush_default = Brush;
|
|
16410
|
+
|
|
16411
|
+
// src/components/ui/charts/utils/pillLabelRenderer.tsx
|
|
16412
|
+
var import_jsx_runtime95 = require("react/jsx-runtime");
|
|
16158
16413
|
var formatCompactNumber = (value) => {
|
|
16159
16414
|
const isNegative = value < 0;
|
|
16160
16415
|
const absValue = Math.abs(value);
|
|
@@ -16245,8 +16500,8 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
|
|
|
16245
16500
|
} else {
|
|
16246
16501
|
textColor = "#374151";
|
|
16247
16502
|
}
|
|
16248
|
-
return /* @__PURE__ */ (0,
|
|
16249
|
-
/* @__PURE__ */ (0,
|
|
16503
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("g", { children: [
|
|
16504
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
16250
16505
|
"rect",
|
|
16251
16506
|
{
|
|
16252
16507
|
x: rectX,
|
|
@@ -16259,7 +16514,7 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
|
|
|
16259
16514
|
strokeWidth: rectStroke ? 1 : 0
|
|
16260
16515
|
}
|
|
16261
16516
|
),
|
|
16262
|
-
/* @__PURE__ */ (0,
|
|
16517
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
16263
16518
|
"text",
|
|
16264
16519
|
{
|
|
16265
16520
|
x: textX,
|
|
@@ -16330,7 +16585,7 @@ var renderInsideBarLabel = (color, valueFormatter2) => {
|
|
|
16330
16585
|
const heightFactor = Math.max(0.8, Math.min(1.6, pHeight / heightRef));
|
|
16331
16586
|
fontSize = Math.min(18, Math.max(8, Math.round(fontSize * heightFactor)));
|
|
16332
16587
|
}
|
|
16333
|
-
return /* @__PURE__ */ (0,
|
|
16588
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
16334
16589
|
"text",
|
|
16335
16590
|
{
|
|
16336
16591
|
x: centerX,
|
|
@@ -16349,7 +16604,7 @@ var renderInsideBarLabel = (color, valueFormatter2) => {
|
|
|
16349
16604
|
|
|
16350
16605
|
// src/components/ui/charts/NoData.tsx
|
|
16351
16606
|
var import_framer_motion21 = require("framer-motion");
|
|
16352
|
-
var
|
|
16607
|
+
var import_jsx_runtime96 = require("react/jsx-runtime");
|
|
16353
16608
|
var ChartBar = ({ x, y, w, h, i, loading }) => {
|
|
16354
16609
|
const baseY = y - h;
|
|
16355
16610
|
const d = i * 0.08;
|
|
@@ -16360,8 +16615,8 @@ var ChartBar = ({ x, y, w, h, i, loading }) => {
|
|
|
16360
16615
|
ease: "easeInOut",
|
|
16361
16616
|
delay: d
|
|
16362
16617
|
};
|
|
16363
|
-
return /* @__PURE__ */ (0,
|
|
16364
|
-
/* @__PURE__ */ (0,
|
|
16618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("g", { children: [
|
|
16619
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16365
16620
|
import_framer_motion21.motion.rect,
|
|
16366
16621
|
{
|
|
16367
16622
|
x,
|
|
@@ -16376,7 +16631,7 @@ var ChartBar = ({ x, y, w, h, i, loading }) => {
|
|
|
16376
16631
|
style: { transformBox: "fill-box", originY: 1 }
|
|
16377
16632
|
}
|
|
16378
16633
|
),
|
|
16379
|
-
/* @__PURE__ */ (0,
|
|
16634
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16380
16635
|
import_framer_motion21.motion.rect,
|
|
16381
16636
|
{
|
|
16382
16637
|
x,
|
|
@@ -16392,7 +16647,7 @@ var ChartBar = ({ x, y, w, h, i, loading }) => {
|
|
|
16392
16647
|
style: { transformBox: "fill-box", originY: 1 }
|
|
16393
16648
|
}
|
|
16394
16649
|
),
|
|
16395
|
-
/* @__PURE__ */ (0,
|
|
16650
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16396
16651
|
import_framer_motion21.motion.line,
|
|
16397
16652
|
{
|
|
16398
16653
|
x1: x + w / 2,
|
|
@@ -16426,7 +16681,7 @@ var NoData = ({
|
|
|
16426
16681
|
{ x: 580, w: 100, h: h * 0.35 },
|
|
16427
16682
|
{ x: 700, w: 100, h: h * 0.3 }
|
|
16428
16683
|
];
|
|
16429
|
-
return /* @__PURE__ */ (0,
|
|
16684
|
+
return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16430
16685
|
"div",
|
|
16431
16686
|
{
|
|
16432
16687
|
className: cn(
|
|
@@ -16439,17 +16694,17 @@ var NoData = ({
|
|
|
16439
16694
|
},
|
|
16440
16695
|
role: "img",
|
|
16441
16696
|
"aria-label": message,
|
|
16442
|
-
children: /* @__PURE__ */ (0,
|
|
16443
|
-
/* @__PURE__ */ (0,
|
|
16697
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "w-full flex items-center justify-center pl-[var(--pl)] p-6 h-[var(--svg-h)]", children: /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("div", { className: "w-full max-w-[900px] relative", children: [
|
|
16698
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(
|
|
16444
16699
|
"svg",
|
|
16445
16700
|
{
|
|
16446
16701
|
className: "w-full h-[var(--svg-h)] opacity-40",
|
|
16447
16702
|
viewBox: `0 0 900 ${h}`,
|
|
16448
16703
|
preserveAspectRatio: "none",
|
|
16449
16704
|
children: [
|
|
16450
|
-
/* @__PURE__ */ (0,
|
|
16451
|
-
/* @__PURE__ */ (0,
|
|
16452
|
-
/* @__PURE__ */ (0,
|
|
16705
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("defs", { children: [
|
|
16706
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("linearGradient", { id: "bg", x1: "0", x2: "0", y1: "0", y2: "1", children: [
|
|
16707
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16453
16708
|
"stop",
|
|
16454
16709
|
{
|
|
16455
16710
|
offset: "0%",
|
|
@@ -16457,7 +16712,7 @@ var NoData = ({
|
|
|
16457
16712
|
stopOpacity: "0.15"
|
|
16458
16713
|
}
|
|
16459
16714
|
),
|
|
16460
|
-
/* @__PURE__ */ (0,
|
|
16715
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16461
16716
|
"stop",
|
|
16462
16717
|
{
|
|
16463
16718
|
offset: "100%",
|
|
@@ -16466,8 +16721,8 @@ var NoData = ({
|
|
|
16466
16721
|
}
|
|
16467
16722
|
)
|
|
16468
16723
|
] }),
|
|
16469
|
-
/* @__PURE__ */ (0,
|
|
16470
|
-
/* @__PURE__ */ (0,
|
|
16724
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("linearGradient", { id: "gg", x1: "0", x2: "0", y1: "0", y2: "1", children: [
|
|
16725
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16471
16726
|
"stop",
|
|
16472
16727
|
{
|
|
16473
16728
|
offset: "0%",
|
|
@@ -16475,7 +16730,7 @@ var NoData = ({
|
|
|
16475
16730
|
stopOpacity: "0.4"
|
|
16476
16731
|
}
|
|
16477
16732
|
),
|
|
16478
|
-
/* @__PURE__ */ (0,
|
|
16733
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16479
16734
|
"stop",
|
|
16480
16735
|
{
|
|
16481
16736
|
offset: "100%",
|
|
@@ -16484,17 +16739,17 @@ var NoData = ({
|
|
|
16484
16739
|
}
|
|
16485
16740
|
)
|
|
16486
16741
|
] }),
|
|
16487
|
-
/* @__PURE__ */ (0,
|
|
16488
|
-
/* @__PURE__ */ (0,
|
|
16489
|
-
/* @__PURE__ */ (0,
|
|
16490
|
-
/* @__PURE__ */ (0,
|
|
16491
|
-
/* @__PURE__ */ (0,
|
|
16492
|
-
/* @__PURE__ */ (0,
|
|
16493
|
-
/* @__PURE__ */ (0,
|
|
16742
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("filter", { id: "s", x: "-20%", y: "-20%", width: "140%", height: "140%", children: [
|
|
16743
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("feGaussianBlur", { in: "SourceAlpha", stdDeviation: "3" }),
|
|
16744
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("feOffset", { dx: "0", dy: "2" }),
|
|
16745
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("feComponentTransfer", { children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("feFuncA", { type: "linear", slope: "0.2" }) }),
|
|
16746
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsxs)("feMerge", { children: [
|
|
16747
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("feMergeNode", {}),
|
|
16748
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("feMergeNode", { in: "SourceGraphic" })
|
|
16494
16749
|
] })
|
|
16495
16750
|
] })
|
|
16496
16751
|
] }),
|
|
16497
|
-
/* @__PURE__ */ (0,
|
|
16752
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16498
16753
|
"rect",
|
|
16499
16754
|
{
|
|
16500
16755
|
x: 0,
|
|
@@ -16505,7 +16760,7 @@ var NoData = ({
|
|
|
16505
16760
|
rx: 8
|
|
16506
16761
|
}
|
|
16507
16762
|
),
|
|
16508
|
-
[...Array(6)].map((_, i) => /* @__PURE__ */ (0,
|
|
16763
|
+
[...Array(6)].map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16509
16764
|
"line",
|
|
16510
16765
|
{
|
|
16511
16766
|
x1: 50,
|
|
@@ -16518,7 +16773,7 @@ var NoData = ({
|
|
|
16518
16773
|
},
|
|
16519
16774
|
i
|
|
16520
16775
|
)),
|
|
16521
|
-
/* @__PURE__ */ (0,
|
|
16776
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16522
16777
|
"line",
|
|
16523
16778
|
{
|
|
16524
16779
|
x1: 50,
|
|
@@ -16530,7 +16785,7 @@ var NoData = ({
|
|
|
16530
16785
|
opacity: 0.5
|
|
16531
16786
|
}
|
|
16532
16787
|
),
|
|
16533
|
-
/* @__PURE__ */ (0,
|
|
16788
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16534
16789
|
"line",
|
|
16535
16790
|
{
|
|
16536
16791
|
x1: 50,
|
|
@@ -16542,7 +16797,7 @@ var NoData = ({
|
|
|
16542
16797
|
opacity: 0.5
|
|
16543
16798
|
}
|
|
16544
16799
|
),
|
|
16545
|
-
bars.map((b, i) => /* @__PURE__ */ (0,
|
|
16800
|
+
bars.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16546
16801
|
ChartBar,
|
|
16547
16802
|
{
|
|
16548
16803
|
x: b.x,
|
|
@@ -16557,15 +16812,15 @@ var NoData = ({
|
|
|
16557
16812
|
]
|
|
16558
16813
|
}
|
|
16559
16814
|
),
|
|
16560
|
-
/* @__PURE__ */ (0,
|
|
16815
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "absolute inset-0 flex items-center justify-center pointer-events-none h-[var(--svg-h)]", children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "pointer-events-auto bg-card/95 backdrop-blur-sm px-8 py-6 rounded-xl border border-border/50 shadow-lg text-center max-w-md", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("div", { className: "flex flex-col items-center gap-4", children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
16561
16816
|
LoadingBase,
|
|
16562
16817
|
{
|
|
16563
16818
|
size: "xl",
|
|
16564
16819
|
message: loadingMessage ?? "Carregando"
|
|
16565
16820
|
}
|
|
16566
|
-
) }) : /* @__PURE__ */ (0,
|
|
16567
|
-
title && /* @__PURE__ */ (0,
|
|
16568
|
-
/* @__PURE__ */ (0,
|
|
16821
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_jsx_runtime96.Fragment, { children: [
|
|
16822
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)("h3", { className: "text-xl font-semibold text-foreground mb-2", children: title }),
|
|
16823
|
+
/* @__PURE__ */ (0, import_jsx_runtime96.jsx)("p", { className: "text-lg font-medium text-foreground/90 mb-2", children: message })
|
|
16569
16824
|
] }) }) })
|
|
16570
16825
|
] }) })
|
|
16571
16826
|
}
|
|
@@ -16786,8 +17041,126 @@ var useChartClick = ({
|
|
|
16786
17041
|
};
|
|
16787
17042
|
};
|
|
16788
17043
|
|
|
17044
|
+
// src/components/ui/charts/hooks/useTimeSeriesRange.ts
|
|
17045
|
+
var import_react96 = require("react");
|
|
17046
|
+
function useTimeSeriesRange({
|
|
17047
|
+
dataLength,
|
|
17048
|
+
defaultStartIndex = 0,
|
|
17049
|
+
defaultEndIndex,
|
|
17050
|
+
onRangeChange
|
|
17051
|
+
}) {
|
|
17052
|
+
const [startIndex, setStartIndex] = (0, import_react96.useState)(defaultStartIndex);
|
|
17053
|
+
const [endIndex, setEndIndex] = (0, import_react96.useState)(
|
|
17054
|
+
defaultEndIndex ?? Math.max(0, dataLength - 1)
|
|
17055
|
+
);
|
|
17056
|
+
const [isDragging, setIsDragging] = (0, import_react96.useState)(null);
|
|
17057
|
+
const [dragStartX, setDragStartX] = (0, import_react96.useState)(0);
|
|
17058
|
+
const [initialStartIndex, setInitialStartIndex] = (0, import_react96.useState)(0);
|
|
17059
|
+
const [initialEndIndex, setInitialEndIndex] = (0, import_react96.useState)(0);
|
|
17060
|
+
const brushRef = (0, import_react96.useRef)(null);
|
|
17061
|
+
(0, import_react96.useEffect)(() => {
|
|
17062
|
+
if (dataLength > 0) {
|
|
17063
|
+
setStartIndex((prev) => Math.min(prev, dataLength - 1));
|
|
17064
|
+
setEndIndex((prev) => {
|
|
17065
|
+
if (prev >= dataLength - 2 || defaultEndIndex === void 0) {
|
|
17066
|
+
return dataLength - 1;
|
|
17067
|
+
}
|
|
17068
|
+
return Math.min(prev, dataLength - 1);
|
|
17069
|
+
});
|
|
17070
|
+
}
|
|
17071
|
+
}, [dataLength, defaultEndIndex]);
|
|
17072
|
+
const handleRangeChange = (0, import_react96.useCallback)(
|
|
17073
|
+
(newStart, newEnd) => {
|
|
17074
|
+
const clampedStart = Math.max(0, Math.min(newStart, dataLength - 1));
|
|
17075
|
+
const clampedEnd = Math.max(
|
|
17076
|
+
clampedStart,
|
|
17077
|
+
Math.min(newEnd, dataLength - 1)
|
|
17078
|
+
);
|
|
17079
|
+
setStartIndex(clampedStart);
|
|
17080
|
+
setEndIndex(clampedEnd);
|
|
17081
|
+
if (onRangeChange) {
|
|
17082
|
+
onRangeChange(clampedStart, clampedEnd);
|
|
17083
|
+
}
|
|
17084
|
+
},
|
|
17085
|
+
[dataLength, onRangeChange]
|
|
17086
|
+
);
|
|
17087
|
+
const handleMouseDown = (0, import_react96.useCallback)(
|
|
17088
|
+
(e, type) => {
|
|
17089
|
+
e.preventDefault();
|
|
17090
|
+
setIsDragging(type);
|
|
17091
|
+
setDragStartX(e.clientX);
|
|
17092
|
+
setInitialStartIndex(startIndex);
|
|
17093
|
+
setInitialEndIndex(endIndex);
|
|
17094
|
+
},
|
|
17095
|
+
[startIndex, endIndex]
|
|
17096
|
+
);
|
|
17097
|
+
const handleMouseMove = (0, import_react96.useCallback)(
|
|
17098
|
+
(e) => {
|
|
17099
|
+
if (!isDragging || !brushRef.current) return;
|
|
17100
|
+
const brushWidth = brushRef.current.offsetWidth;
|
|
17101
|
+
const deltaX = e.clientX - dragStartX;
|
|
17102
|
+
const indexDelta = Math.round(deltaX / brushWidth * dataLength);
|
|
17103
|
+
if (isDragging === "start") {
|
|
17104
|
+
const newStart = Math.max(
|
|
17105
|
+
0,
|
|
17106
|
+
Math.min(initialStartIndex + indexDelta, endIndex - 1)
|
|
17107
|
+
);
|
|
17108
|
+
handleRangeChange(newStart, endIndex);
|
|
17109
|
+
} else if (isDragging === "end") {
|
|
17110
|
+
const newEnd = Math.max(
|
|
17111
|
+
startIndex + 1,
|
|
17112
|
+
Math.min(initialEndIndex + indexDelta, dataLength - 1)
|
|
17113
|
+
);
|
|
17114
|
+
handleRangeChange(startIndex, newEnd);
|
|
17115
|
+
} else if (isDragging === "middle") {
|
|
17116
|
+
const rangeSize = initialEndIndex - initialStartIndex;
|
|
17117
|
+
let newStart = initialStartIndex + indexDelta;
|
|
17118
|
+
let newEnd = initialEndIndex + indexDelta;
|
|
17119
|
+
if (newStart < 0) {
|
|
17120
|
+
newStart = 0;
|
|
17121
|
+
newEnd = rangeSize;
|
|
17122
|
+
} else if (newEnd >= dataLength) {
|
|
17123
|
+
newEnd = dataLength - 1;
|
|
17124
|
+
newStart = newEnd - rangeSize;
|
|
17125
|
+
}
|
|
17126
|
+
handleRangeChange(newStart, newEnd);
|
|
17127
|
+
}
|
|
17128
|
+
},
|
|
17129
|
+
[
|
|
17130
|
+
isDragging,
|
|
17131
|
+
dragStartX,
|
|
17132
|
+
dataLength,
|
|
17133
|
+
startIndex,
|
|
17134
|
+
endIndex,
|
|
17135
|
+
initialStartIndex,
|
|
17136
|
+
initialEndIndex,
|
|
17137
|
+
handleRangeChange
|
|
17138
|
+
]
|
|
17139
|
+
);
|
|
17140
|
+
const handleMouseUp = (0, import_react96.useCallback)(() => {
|
|
17141
|
+
setIsDragging(null);
|
|
17142
|
+
}, []);
|
|
17143
|
+
(0, import_react96.useEffect)(() => {
|
|
17144
|
+
if (isDragging) {
|
|
17145
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
17146
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
17147
|
+
return () => {
|
|
17148
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
17149
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
17150
|
+
};
|
|
17151
|
+
}
|
|
17152
|
+
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
17153
|
+
return {
|
|
17154
|
+
startIndex,
|
|
17155
|
+
endIndex,
|
|
17156
|
+
isDragging,
|
|
17157
|
+
brushRef,
|
|
17158
|
+
handleMouseDown
|
|
17159
|
+
};
|
|
17160
|
+
}
|
|
17161
|
+
|
|
16789
17162
|
// src/components/ui/charts/Chart.tsx
|
|
16790
|
-
var
|
|
17163
|
+
var import_jsx_runtime97 = require("react/jsx-runtime");
|
|
16791
17164
|
var DEFAULT_COLORS2 = ["#55af7d", "#8e68ff", "#2273e1"];
|
|
16792
17165
|
var Chart = ({
|
|
16793
17166
|
data,
|
|
@@ -16820,9 +17193,10 @@ var Chart = ({
|
|
|
16820
17193
|
formatBR = false,
|
|
16821
17194
|
legendUppercase = false,
|
|
16822
17195
|
chartMargin,
|
|
16823
|
-
isLoading = false
|
|
17196
|
+
isLoading = false,
|
|
17197
|
+
timeSeries
|
|
16824
17198
|
}) => {
|
|
16825
|
-
const smartConfig = (0,
|
|
17199
|
+
const smartConfig = (0, import_react97.useMemo)(() => {
|
|
16826
17200
|
const resolvedXAxisKey = typeof xAxis === "string" ? xAxis : xAxis && xAxis.dataKey || detectXAxis(data);
|
|
16827
17201
|
const xAxisConfig2 = typeof xAxis === "string" ? {
|
|
16828
17202
|
dataKey: resolvedXAxisKey,
|
|
@@ -16860,15 +17234,33 @@ var Chart = ({
|
|
|
16860
17234
|
onTooltipPositionChange,
|
|
16861
17235
|
setActiveTooltips
|
|
16862
17236
|
} = useChartTooltips(maxTooltips);
|
|
16863
|
-
(0,
|
|
17237
|
+
(0, import_react97.useEffect)(() => {
|
|
16864
17238
|
if (highlightedSeries.size === 0 && showOnlyHighlighted) {
|
|
16865
17239
|
setShowOnlyHighlighted(false);
|
|
16866
17240
|
}
|
|
16867
17241
|
}, [highlightedSeries, showOnlyHighlighted, setShowOnlyHighlighted]);
|
|
16868
|
-
const
|
|
16869
|
-
|
|
16870
|
-
|
|
16871
|
-
|
|
17242
|
+
const timeSeriesConfig = (0, import_react97.useMemo)(() => {
|
|
17243
|
+
if (typeof timeSeries === "boolean") {
|
|
17244
|
+
return timeSeries ? {} : void 0;
|
|
17245
|
+
}
|
|
17246
|
+
return timeSeries;
|
|
17247
|
+
}, [timeSeries]);
|
|
17248
|
+
const { startIndex, endIndex, brushRef, handleMouseDown } = useTimeSeriesRange({
|
|
17249
|
+
dataLength: data.length,
|
|
17250
|
+
defaultStartIndex: timeSeriesConfig?.start,
|
|
17251
|
+
defaultEndIndex: timeSeriesConfig?.end,
|
|
17252
|
+
onRangeChange: timeSeriesConfig?.onRangeChange
|
|
17253
|
+
});
|
|
17254
|
+
const processedData = (0, import_react97.useMemo)(() => {
|
|
17255
|
+
const mapped = data.map((item) => ({
|
|
17256
|
+
...item,
|
|
17257
|
+
name: String(item[xAxisConfig.dataKey] || "N/A")
|
|
17258
|
+
}));
|
|
17259
|
+
if (timeSeriesConfig) {
|
|
17260
|
+
return mapped.slice(startIndex, endIndex + 1);
|
|
17261
|
+
}
|
|
17262
|
+
return mapped;
|
|
17263
|
+
}, [data, xAxisConfig.dataKey, timeSeriesConfig, startIndex, endIndex]);
|
|
16872
17264
|
const seriesOrder = [];
|
|
16873
17265
|
if (series) {
|
|
16874
17266
|
if (series.bar)
|
|
@@ -16883,17 +17275,17 @@ var Chart = ({
|
|
|
16883
17275
|
);
|
|
16884
17276
|
}
|
|
16885
17277
|
const allKeys = seriesOrder.map((s) => s.key).filter(Boolean);
|
|
16886
|
-
const finalColors = (0,
|
|
17278
|
+
const finalColors = (0, import_react97.useMemo)(
|
|
16887
17279
|
() => generateColorMap(allKeys, colors2, mapperConfig),
|
|
16888
17280
|
[allKeys, colors2, mapperConfig]
|
|
16889
17281
|
);
|
|
16890
|
-
const biaxialConfigNormalized = (0,
|
|
17282
|
+
const biaxialConfigNormalized = (0, import_react97.useMemo)(() => {
|
|
16891
17283
|
if (!biaxial) return null;
|
|
16892
17284
|
if (typeof biaxial === "string") return { key: [biaxial] };
|
|
16893
17285
|
if (Array.isArray(biaxial)) return { key: biaxial };
|
|
16894
17286
|
return biaxial;
|
|
16895
17287
|
}, [biaxial]);
|
|
16896
|
-
(0,
|
|
17288
|
+
(0, import_react97.useMemo)(() => {
|
|
16897
17289
|
if (!biaxialConfigNormalized) return;
|
|
16898
17290
|
const leftLabelMissing = !yAxisLabel || String(yAxisLabel).trim() === "";
|
|
16899
17291
|
const rightLabelMissing = !biaxialConfigNormalized.label || String(biaxialConfigNormalized.label).trim() === "";
|
|
@@ -16903,43 +17295,43 @@ var Chart = ({
|
|
|
16903
17295
|
);
|
|
16904
17296
|
}
|
|
16905
17297
|
}, [biaxialConfigNormalized, yAxisLabel]);
|
|
16906
|
-
const rightKeys = (0,
|
|
17298
|
+
const rightKeys = (0, import_react97.useMemo)(
|
|
16907
17299
|
() => biaxialConfigNormalized?.key ?? [],
|
|
16908
17300
|
[biaxialConfigNormalized]
|
|
16909
17301
|
);
|
|
16910
|
-
const leftKeys = (0,
|
|
17302
|
+
const leftKeys = (0, import_react97.useMemo)(
|
|
16911
17303
|
() => allKeys.filter((k) => !rightKeys.includes(k)),
|
|
16912
17304
|
[allKeys, rightKeys]
|
|
16913
17305
|
);
|
|
16914
|
-
const activePeriods = (0,
|
|
17306
|
+
const activePeriods = (0, import_react97.useMemo)(
|
|
16915
17307
|
() => activeTooltips.map((t) => adaptDataForTooltip(t.data, xAxisConfig.dataKey).name),
|
|
16916
17308
|
[activeTooltips, xAxisConfig.dataKey]
|
|
16917
17309
|
);
|
|
16918
|
-
const maxLeftDataValue = (0,
|
|
17310
|
+
const maxLeftDataValue = (0, import_react97.useMemo)(() => {
|
|
16919
17311
|
const numericKeys = leftKeys.length > 0 ? leftKeys : allKeys;
|
|
16920
17312
|
return getMaxDataValue(processedData, numericKeys);
|
|
16921
17313
|
}, [processedData, leftKeys, allKeys]);
|
|
16922
|
-
const minLeftDataValue = (0,
|
|
17314
|
+
const minLeftDataValue = (0, import_react97.useMemo)(() => {
|
|
16923
17315
|
const numericKeys = leftKeys.length > 0 ? leftKeys : allKeys;
|
|
16924
17316
|
return getMinDataValue(processedData, numericKeys);
|
|
16925
17317
|
}, [processedData, leftKeys, allKeys]);
|
|
16926
|
-
const maxRightDataValue = (0,
|
|
17318
|
+
const maxRightDataValue = (0, import_react97.useMemo)(() => {
|
|
16927
17319
|
if (rightKeys.length === 0) return 0;
|
|
16928
17320
|
return getMaxDataValue(processedData, rightKeys);
|
|
16929
17321
|
}, [processedData, rightKeys]);
|
|
16930
|
-
const minRightDataValue = (0,
|
|
17322
|
+
const minRightDataValue = (0, import_react97.useMemo)(() => {
|
|
16931
17323
|
if (rightKeys.length === 0) return 0;
|
|
16932
17324
|
return getMinDataValue(processedData, rightKeys);
|
|
16933
17325
|
}, [processedData, rightKeys]);
|
|
16934
|
-
const niceMaxLeft = (0,
|
|
17326
|
+
const niceMaxLeft = (0, import_react97.useMemo)(
|
|
16935
17327
|
() => computeNiceMax(maxLeftDataValue),
|
|
16936
17328
|
[maxLeftDataValue]
|
|
16937
17329
|
);
|
|
16938
|
-
const niceMaxRight = (0,
|
|
17330
|
+
const niceMaxRight = (0, import_react97.useMemo)(
|
|
16939
17331
|
() => computeNiceMax(maxRightDataValue),
|
|
16940
17332
|
[maxRightDataValue]
|
|
16941
17333
|
);
|
|
16942
|
-
const computedWidth = (0,
|
|
17334
|
+
const computedWidth = (0, import_react97.useMemo)(
|
|
16943
17335
|
() => computeChartWidth(
|
|
16944
17336
|
width,
|
|
16945
17337
|
processedData.length,
|
|
@@ -16957,17 +17349,17 @@ var Chart = ({
|
|
|
16957
17349
|
setActiveTooltips
|
|
16958
17350
|
}
|
|
16959
17351
|
);
|
|
16960
|
-
const getSeriesOpacity = (0,
|
|
17352
|
+
const getSeriesOpacity = (0, import_react97.useCallback)(
|
|
16961
17353
|
(key) => {
|
|
16962
17354
|
return highlightedSeries.size > 0 ? highlightedSeries.has(key) ? 1 : 0.25 : 1;
|
|
16963
17355
|
},
|
|
16964
17356
|
[highlightedSeries]
|
|
16965
17357
|
);
|
|
16966
|
-
const finalValueFormatter = (0,
|
|
17358
|
+
const finalValueFormatter = (0, import_react97.useMemo)(
|
|
16967
17359
|
() => createValueFormatter(valueFormatter2, formatBR),
|
|
16968
17360
|
[valueFormatter2, formatBR]
|
|
16969
17361
|
);
|
|
16970
|
-
const yTickFormatter = (0,
|
|
17362
|
+
const yTickFormatter = (0, import_react97.useMemo)(
|
|
16971
17363
|
() => createYTickFormatter(finalValueFormatter),
|
|
16972
17364
|
[finalValueFormatter]
|
|
16973
17365
|
);
|
|
@@ -16975,7 +17367,7 @@ var Chart = ({
|
|
|
16975
17367
|
const CONTAINER_PADDING_LEFT = -6;
|
|
16976
17368
|
const finalChartRightMargin = chartMargin?.right ?? (rightKeys.length > 0 ? AXIS_LABEL_MARGIN : 30);
|
|
16977
17369
|
const finalChartLeftMargin = chartMargin?.left ?? (yAxisLabel ? AXIS_LABEL_MARGIN : 0);
|
|
16978
|
-
const yAxisTickWidth = (0,
|
|
17370
|
+
const yAxisTickWidth = (0, import_react97.useMemo)(
|
|
16979
17371
|
() => computeYAxisTickWidth(
|
|
16980
17372
|
chartMargin?.left,
|
|
16981
17373
|
yAxisLabel,
|
|
@@ -16994,11 +17386,12 @@ var Chart = ({
|
|
|
16994
17386
|
);
|
|
16995
17387
|
const finalChartTopMargin = chartMargin?.top ?? (showLabels ? 48 : 20);
|
|
16996
17388
|
const finalChartBottomMargin = (chartMargin?.bottom ?? 5) + (xAxisLabel ? 22 : 0) + (showLegend ? 36 : 0);
|
|
17389
|
+
const HORIZONTAL_PADDING_CLASS = "px-20";
|
|
16997
17390
|
const effectiveChartWidth = typeof width === "number" ? width : measuredWidth ? Math.max(0, measuredWidth - 32) : computedWidth;
|
|
16998
17391
|
const chartInnerWidth = effectiveChartWidth - finalChartLeftMargin - finalChartRightMargin;
|
|
16999
17392
|
const leftYAxisLabelDx = -Math.max(12, Math.round(yAxisTickWidth / 2));
|
|
17000
17393
|
const rightYAxisLabelDx = Math.max(12, Math.round(finalChartRightMargin / 2));
|
|
17001
|
-
const openTooltipForPeriod = (0,
|
|
17394
|
+
const openTooltipForPeriod = (0, import_react97.useCallback)(
|
|
17002
17395
|
(periodName) => {
|
|
17003
17396
|
if (!enableDraggableTooltips) return;
|
|
17004
17397
|
const row = processedData.find((r) => String(r.name) === periodName);
|
|
@@ -17042,7 +17435,7 @@ var Chart = ({
|
|
|
17042
17435
|
);
|
|
17043
17436
|
if (!data && !isLoading) return null;
|
|
17044
17437
|
if (isLoading) {
|
|
17045
|
-
return /* @__PURE__ */ (0,
|
|
17438
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17046
17439
|
NoData_default,
|
|
17047
17440
|
{
|
|
17048
17441
|
title,
|
|
@@ -17054,7 +17447,7 @@ var Chart = ({
|
|
|
17054
17447
|
);
|
|
17055
17448
|
}
|
|
17056
17449
|
if (Array.isArray(data) && data.length === 0) {
|
|
17057
|
-
return /* @__PURE__ */ (0,
|
|
17450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17058
17451
|
NoData_default,
|
|
17059
17452
|
{
|
|
17060
17453
|
title,
|
|
@@ -17063,67 +17456,87 @@ var Chart = ({
|
|
|
17063
17456
|
}
|
|
17064
17457
|
);
|
|
17065
17458
|
}
|
|
17066
|
-
return /* @__PURE__ */ (0,
|
|
17459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17067
17460
|
"div",
|
|
17068
17461
|
{
|
|
17069
|
-
|
|
17070
|
-
|
|
17071
|
-
|
|
17072
|
-
|
|
17073
|
-
children: [
|
|
17074
|
-
title && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
|
|
17462
|
+
ref: wrapperRef,
|
|
17463
|
+
className: cn("w-full overflow-hidden min-w-0 rounded-lg", className),
|
|
17464
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "rounded-lg bg-card relative w-full max-w-full min-w-0", children: [
|
|
17465
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17075
17466
|
"div",
|
|
17076
17467
|
{
|
|
17077
17468
|
className: cn(
|
|
17078
|
-
"w-full flex items-center mt-
|
|
17469
|
+
"w-full flex items-center mt-5",
|
|
17470
|
+
HORIZONTAL_PADDING_CLASS,
|
|
17079
17471
|
titlePosition === "center" && "justify-center",
|
|
17080
17472
|
titlePosition === "right" && "justify-end",
|
|
17081
17473
|
titlePosition === "left" && "justify-start"
|
|
17082
17474
|
),
|
|
17083
|
-
children: /* @__PURE__ */ (0,
|
|
17475
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "text-[1.4rem] font-semibold text-foreground mb-3", children: [
|
|
17476
|
+
title,
|
|
17477
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17478
|
+
"div",
|
|
17479
|
+
{
|
|
17480
|
+
className: "absolute inset-0 flex items-center justify-center pointer-events-none z-50 select-text overflow-hidden",
|
|
17481
|
+
"aria-hidden": "true",
|
|
17482
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "text-[1.6rem] font-bold text-transparent selection:bg-primary selection:text-primary-foreground whitespace-nowrap", children: "Eduardo Ronchi de Araujo Desenvolvidor de Sistemas Junio" })
|
|
17483
|
+
}
|
|
17484
|
+
)
|
|
17485
|
+
] })
|
|
17084
17486
|
}
|
|
17085
17487
|
),
|
|
17086
|
-
allKeys.length > 0 && (enableHighlights || enableShowOnly) && /* @__PURE__ */ (0,
|
|
17087
|
-
|
|
17088
|
-
|
|
17089
|
-
|
|
17090
|
-
|
|
17091
|
-
|
|
17092
|
-
|
|
17093
|
-
|
|
17094
|
-
|
|
17095
|
-
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
|
|
17099
|
-
|
|
17100
|
-
|
|
17101
|
-
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
|
|
17105
|
-
|
|
17106
|
-
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
|
|
17110
|
-
|
|
17111
|
-
|
|
17112
|
-
|
|
17113
|
-
|
|
17114
|
-
|
|
17115
|
-
|
|
17116
|
-
|
|
17117
|
-
|
|
17488
|
+
allKeys.length > 0 && (enableHighlights || enableShowOnly) && /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
|
|
17489
|
+
"div",
|
|
17490
|
+
{
|
|
17491
|
+
className: cn(
|
|
17492
|
+
"flex items-center gap-2 mb-2",
|
|
17493
|
+
HORIZONTAL_PADDING_CLASS
|
|
17494
|
+
),
|
|
17495
|
+
children: [
|
|
17496
|
+
enableHighlights && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17497
|
+
Highlights_default,
|
|
17498
|
+
{
|
|
17499
|
+
allKeys,
|
|
17500
|
+
mapperConfig,
|
|
17501
|
+
finalColors,
|
|
17502
|
+
highlightedSeries,
|
|
17503
|
+
toggleHighlight,
|
|
17504
|
+
containerWidth: chartInnerWidth
|
|
17505
|
+
}
|
|
17506
|
+
),
|
|
17507
|
+
enableShowOnly && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17508
|
+
ShowOnly_default,
|
|
17509
|
+
{
|
|
17510
|
+
showOnlyHighlighted,
|
|
17511
|
+
setShowOnlyHighlighted,
|
|
17512
|
+
highlightedSeriesSize: highlightedSeries.size,
|
|
17513
|
+
clearHighlights
|
|
17514
|
+
}
|
|
17515
|
+
),
|
|
17516
|
+
enablePeriodsDropdown && enableDraggableTooltips && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("div", { className: "ml-auto flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17517
|
+
PeriodsDropdown_default,
|
|
17518
|
+
{
|
|
17519
|
+
processedData,
|
|
17520
|
+
onOpenPeriod: openTooltipForPeriod,
|
|
17521
|
+
rightOffset: finalChartRightMargin,
|
|
17522
|
+
activePeriods
|
|
17523
|
+
}
|
|
17524
|
+
) })
|
|
17525
|
+
]
|
|
17526
|
+
}
|
|
17527
|
+
),
|
|
17528
|
+
!(allKeys.length > 0 && (enableHighlights || enableShowOnly)) && enablePeriodsDropdown && enableDraggableTooltips && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17118
17529
|
"div",
|
|
17119
17530
|
{
|
|
17120
|
-
className:
|
|
17531
|
+
className: cn(
|
|
17532
|
+
"w-full flex justify-end mb-2",
|
|
17533
|
+
HORIZONTAL_PADDING_CLASS
|
|
17534
|
+
),
|
|
17121
17535
|
style: {
|
|
17122
|
-
paddingLeft: `${CONTAINER_PADDING_LEFT + finalChartLeftMargin}px`,
|
|
17123
17536
|
paddingRight: `${finalChartRightMargin}px`,
|
|
17124
17537
|
maxWidth: `${chartInnerWidth}px`
|
|
17125
17538
|
},
|
|
17126
|
-
children: /* @__PURE__ */ (0,
|
|
17539
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17127
17540
|
PeriodsDropdown_default,
|
|
17128
17541
|
{
|
|
17129
17542
|
processedData,
|
|
@@ -17133,8 +17546,8 @@ var Chart = ({
|
|
|
17133
17546
|
)
|
|
17134
17547
|
}
|
|
17135
17548
|
),
|
|
17136
|
-
/* @__PURE__ */ (0,
|
|
17137
|
-
|
|
17549
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_recharts2.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
|
|
17550
|
+
import_recharts2.ComposedChart,
|
|
17138
17551
|
{
|
|
17139
17552
|
data: processedData,
|
|
17140
17553
|
height,
|
|
@@ -17146,10 +17559,10 @@ var Chart = ({
|
|
|
17146
17559
|
},
|
|
17147
17560
|
onClick: handleChartClick,
|
|
17148
17561
|
children: [
|
|
17149
|
-
/* @__PURE__ */ (0,
|
|
17562
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)("defs", { children: seriesOrder.filter((s) => s.type === "area").map((s) => {
|
|
17150
17563
|
const key = s.key;
|
|
17151
17564
|
const color = finalColors[key];
|
|
17152
|
-
return /* @__PURE__ */ (0,
|
|
17565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
|
|
17153
17566
|
"linearGradient",
|
|
17154
17567
|
{
|
|
17155
17568
|
id: `gradient-${key}`,
|
|
@@ -17158,23 +17571,23 @@ var Chart = ({
|
|
|
17158
17571
|
x2: "0",
|
|
17159
17572
|
y2: "0.8",
|
|
17160
17573
|
children: [
|
|
17161
|
-
/* @__PURE__ */ (0,
|
|
17162
|
-
/* @__PURE__ */ (0,
|
|
17574
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 0.8 }),
|
|
17575
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)("stop", { offset: "90%", stopColor: color, stopOpacity: 0.1 })
|
|
17163
17576
|
]
|
|
17164
17577
|
},
|
|
17165
17578
|
`gradient-${key}`
|
|
17166
17579
|
);
|
|
17167
17580
|
}) }),
|
|
17168
|
-
showGrid && /* @__PURE__ */ (0,
|
|
17169
|
-
|
|
17581
|
+
showGrid && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17582
|
+
import_recharts2.CartesianGrid,
|
|
17170
17583
|
{
|
|
17171
17584
|
strokeDasharray: "3 3",
|
|
17172
17585
|
stroke: gridColor || "hsl(var(--muted-foreground))",
|
|
17173
17586
|
opacity: 0.5
|
|
17174
17587
|
}
|
|
17175
17588
|
),
|
|
17176
|
-
/* @__PURE__ */ (0,
|
|
17177
|
-
|
|
17589
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17590
|
+
import_recharts2.XAxis,
|
|
17178
17591
|
{
|
|
17179
17592
|
dataKey: xAxisConfig.dataKey,
|
|
17180
17593
|
stroke: "hsl(var(--muted-foreground))",
|
|
@@ -17200,8 +17613,8 @@ var Chart = ({
|
|
|
17200
17613
|
} : void 0
|
|
17201
17614
|
}
|
|
17202
17615
|
),
|
|
17203
|
-
/* @__PURE__ */ (0,
|
|
17204
|
-
|
|
17616
|
+
/* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17617
|
+
import_recharts2.YAxis,
|
|
17205
17618
|
{
|
|
17206
17619
|
yAxisId: "left",
|
|
17207
17620
|
width: yAxisTickWidth,
|
|
@@ -17226,8 +17639,8 @@ var Chart = ({
|
|
|
17226
17639
|
} : void 0
|
|
17227
17640
|
}
|
|
17228
17641
|
),
|
|
17229
|
-
minLeftDataValue < 0 && /* @__PURE__ */ (0,
|
|
17230
|
-
|
|
17642
|
+
minLeftDataValue < 0 && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17643
|
+
import_recharts2.ReferenceLine,
|
|
17231
17644
|
{
|
|
17232
17645
|
y: 0,
|
|
17233
17646
|
yAxisId: "left",
|
|
@@ -17260,8 +17673,8 @@ var Chart = ({
|
|
|
17260
17673
|
return biaxialConfigNormalized.stroke[firstRightKey] || defaultRightColor;
|
|
17261
17674
|
return defaultRightColor;
|
|
17262
17675
|
})();
|
|
17263
|
-
return /* @__PURE__ */ (0,
|
|
17264
|
-
|
|
17676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17677
|
+
import_recharts2.YAxis,
|
|
17265
17678
|
{
|
|
17266
17679
|
yAxisId: "right",
|
|
17267
17680
|
width: finalChartRightMargin,
|
|
@@ -17289,10 +17702,10 @@ var Chart = ({
|
|
|
17289
17702
|
}
|
|
17290
17703
|
);
|
|
17291
17704
|
})(),
|
|
17292
|
-
showTooltip && /* @__PURE__ */ (0,
|
|
17293
|
-
|
|
17705
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17706
|
+
import_recharts2.Tooltip,
|
|
17294
17707
|
{
|
|
17295
|
-
content: showTooltipTotal ? /* @__PURE__ */ (0,
|
|
17708
|
+
content: showTooltipTotal ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17296
17709
|
TooltipWithTotal_default,
|
|
17297
17710
|
{
|
|
17298
17711
|
finalColors,
|
|
@@ -17300,7 +17713,7 @@ var Chart = ({
|
|
|
17300
17713
|
categoryFormatter,
|
|
17301
17714
|
periodLabel
|
|
17302
17715
|
}
|
|
17303
|
-
) : /* @__PURE__ */ (0,
|
|
17716
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17304
17717
|
TooltipSimple_default,
|
|
17305
17718
|
{
|
|
17306
17719
|
finalColors,
|
|
@@ -17312,8 +17725,8 @@ var Chart = ({
|
|
|
17312
17725
|
cursor: { fill: "hsl(var(--muted))", opacity: 0.1 }
|
|
17313
17726
|
}
|
|
17314
17727
|
),
|
|
17315
|
-
showLegend && /* @__PURE__ */ (0,
|
|
17316
|
-
|
|
17728
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17729
|
+
import_recharts2.Legend,
|
|
17317
17730
|
{
|
|
17318
17731
|
wrapperStyle: {
|
|
17319
17732
|
color: "hsl(var(--foreground))",
|
|
@@ -17325,7 +17738,7 @@ var Chart = ({
|
|
|
17325
17738
|
const key = String(value);
|
|
17326
17739
|
const label = mapperConfig[key]?.label ?? labelMap?.[key] ?? formatFieldName(key);
|
|
17327
17740
|
const displayLabel = legendUppercase ? label.toUpperCase() : label;
|
|
17328
|
-
return /* @__PURE__ */ (0,
|
|
17741
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "tracking-[0]", children: displayLabel });
|
|
17329
17742
|
}
|
|
17330
17743
|
}
|
|
17331
17744
|
),
|
|
@@ -17343,8 +17756,8 @@ var Chart = ({
|
|
|
17343
17756
|
}
|
|
17344
17757
|
}
|
|
17345
17758
|
if (s.type === "bar") {
|
|
17346
|
-
return /* @__PURE__ */ (0,
|
|
17347
|
-
|
|
17759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17760
|
+
import_recharts2.Bar,
|
|
17348
17761
|
{
|
|
17349
17762
|
dataKey: key,
|
|
17350
17763
|
yAxisId: rightKeys.includes(key) ? "right" : "left",
|
|
@@ -17354,8 +17767,8 @@ var Chart = ({
|
|
|
17354
17767
|
onClick: handleBarClick,
|
|
17355
17768
|
className: "cursor-pointer",
|
|
17356
17769
|
style: { opacity: getSeriesOpacity(key) },
|
|
17357
|
-
activeBar: /* @__PURE__ */ (0,
|
|
17358
|
-
|
|
17770
|
+
activeBar: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17771
|
+
import_recharts2.Rectangle,
|
|
17359
17772
|
{
|
|
17360
17773
|
fill: color,
|
|
17361
17774
|
stroke: color,
|
|
@@ -17363,8 +17776,8 @@ var Chart = ({
|
|
|
17363
17776
|
opacity: 0.8
|
|
17364
17777
|
}
|
|
17365
17778
|
),
|
|
17366
|
-
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ (0,
|
|
17367
|
-
|
|
17779
|
+
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17780
|
+
import_recharts2.LabelList,
|
|
17368
17781
|
{
|
|
17369
17782
|
dataKey: key,
|
|
17370
17783
|
content: (props) => {
|
|
@@ -17390,8 +17803,8 @@ var Chart = ({
|
|
|
17390
17803
|
);
|
|
17391
17804
|
}
|
|
17392
17805
|
if (s.type === "line") {
|
|
17393
|
-
return /* @__PURE__ */ (0,
|
|
17394
|
-
|
|
17806
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17807
|
+
import_recharts2.Line,
|
|
17395
17808
|
{
|
|
17396
17809
|
dataKey: key,
|
|
17397
17810
|
yAxisId: rightKeys.includes(key) ? "right" : "left",
|
|
@@ -17403,8 +17816,8 @@ var Chart = ({
|
|
|
17403
17816
|
onClick: handleSeriesClick,
|
|
17404
17817
|
className: "cursor-pointer pointer-events-auto",
|
|
17405
17818
|
style: { opacity: getSeriesOpacity(key) },
|
|
17406
|
-
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ (0,
|
|
17407
|
-
|
|
17819
|
+
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17820
|
+
import_recharts2.LabelList,
|
|
17408
17821
|
{
|
|
17409
17822
|
dataKey: key,
|
|
17410
17823
|
position: "top",
|
|
@@ -17421,8 +17834,8 @@ var Chart = ({
|
|
|
17421
17834
|
);
|
|
17422
17835
|
}
|
|
17423
17836
|
if (s.type === "area") {
|
|
17424
|
-
return /* @__PURE__ */ (0,
|
|
17425
|
-
|
|
17837
|
+
return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17838
|
+
import_recharts2.Area,
|
|
17426
17839
|
{
|
|
17427
17840
|
type: "monotone",
|
|
17428
17841
|
dataKey: key,
|
|
@@ -17441,8 +17854,8 @@ var Chart = ({
|
|
|
17441
17854
|
stroke: "hsl(var(--background))",
|
|
17442
17855
|
strokeWidth: 2
|
|
17443
17856
|
},
|
|
17444
|
-
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ (0,
|
|
17445
|
-
|
|
17857
|
+
children: showLabels && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17858
|
+
import_recharts2.LabelList,
|
|
17446
17859
|
{
|
|
17447
17860
|
dataKey: key,
|
|
17448
17861
|
position: "top",
|
|
@@ -17463,7 +17876,7 @@ var Chart = ({
|
|
|
17463
17876
|
]
|
|
17464
17877
|
}
|
|
17465
17878
|
) }),
|
|
17466
|
-
enableDraggableTooltips && activeTooltips.map((tooltip) => /* @__PURE__ */ (0,
|
|
17879
|
+
enableDraggableTooltips && activeTooltips.map((tooltip) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17467
17880
|
DraggableTooltip_default,
|
|
17468
17881
|
{
|
|
17469
17882
|
id: tooltip.id,
|
|
@@ -17488,7 +17901,7 @@ var Chart = ({
|
|
|
17488
17901
|
},
|
|
17489
17902
|
tooltip.id
|
|
17490
17903
|
)),
|
|
17491
|
-
enableDraggableTooltips && activeTooltips.length > 1 && /* @__PURE__ */ (0,
|
|
17904
|
+
enableDraggableTooltips && activeTooltips.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17492
17905
|
CloseAllButton_default,
|
|
17493
17906
|
{
|
|
17494
17907
|
count: activeTooltips.length,
|
|
@@ -17496,17 +17909,39 @@ var Chart = ({
|
|
|
17496
17909
|
position: "top-center",
|
|
17497
17910
|
variant: "floating"
|
|
17498
17911
|
}
|
|
17912
|
+
),
|
|
17913
|
+
timeSeriesConfig && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
|
|
17914
|
+
Brush_default,
|
|
17915
|
+
{
|
|
17916
|
+
data,
|
|
17917
|
+
startIndex,
|
|
17918
|
+
endIndex,
|
|
17919
|
+
onMouseDown: handleMouseDown,
|
|
17920
|
+
brushRef,
|
|
17921
|
+
xAxisKey: xAxisConfig.dataKey,
|
|
17922
|
+
seriesOrder,
|
|
17923
|
+
finalColors,
|
|
17924
|
+
brushHeight: timeSeriesConfig.height,
|
|
17925
|
+
brushColor: timeSeriesConfig.brushColor,
|
|
17926
|
+
miniChartOpacity: timeSeriesConfig.miniChartOpacity,
|
|
17927
|
+
showGrid,
|
|
17928
|
+
gridColor,
|
|
17929
|
+
margin: {
|
|
17930
|
+
left: finalChartLeftMargin,
|
|
17931
|
+
right: finalChartRightMargin
|
|
17932
|
+
}
|
|
17933
|
+
}
|
|
17499
17934
|
)
|
|
17500
|
-
]
|
|
17935
|
+
] })
|
|
17501
17936
|
}
|
|
17502
|
-
)
|
|
17937
|
+
);
|
|
17503
17938
|
};
|
|
17504
17939
|
var Chart_default = Chart;
|
|
17505
17940
|
|
|
17506
17941
|
// src/components/ui/charts/BarChart.tsx
|
|
17507
|
-
var
|
|
17508
|
-
var
|
|
17509
|
-
var
|
|
17942
|
+
var import_react98 = require("react");
|
|
17943
|
+
var import_recharts3 = require("recharts");
|
|
17944
|
+
var import_jsx_runtime98 = require("react/jsx-runtime");
|
|
17510
17945
|
var DEFAULT_COLORS3 = ["#55af7d", "#8e68ff", "#2273e1"];
|
|
17511
17946
|
var BarChart = ({
|
|
17512
17947
|
data,
|
|
@@ -17536,7 +17971,7 @@ var BarChart = ({
|
|
|
17536
17971
|
containerPaddingLeft,
|
|
17537
17972
|
16
|
|
17538
17973
|
);
|
|
17539
|
-
const smartConfig = (0,
|
|
17974
|
+
const smartConfig = (0, import_react98.useMemo)(() => {
|
|
17540
17975
|
const providedMapper = yAxis ?? mapper;
|
|
17541
17976
|
if (autoDetect === true || xAxis == null || providedMapper == null) {
|
|
17542
17977
|
const detectedXAxis = detectXAxis(data);
|
|
@@ -17586,14 +18021,14 @@ var BarChart = ({
|
|
|
17586
18021
|
return { xAxisConfig: xAxisConfig2, mapperConfig: mapperConfig2 };
|
|
17587
18022
|
}, [data, xAxis, mapper, yAxis, autoDetect, labelMap]);
|
|
17588
18023
|
const { xAxisConfig, mapperConfig } = smartConfig;
|
|
17589
|
-
const [activeTooltips, setActiveTooltips] = (0,
|
|
17590
|
-
const [isDragging, setIsDragging] = (0,
|
|
17591
|
-
const [dragOffset, setDragOffset] = (0,
|
|
18024
|
+
const [activeTooltips, setActiveTooltips] = (0, import_react98.useState)([]);
|
|
18025
|
+
const [isDragging, setIsDragging] = (0, import_react98.useState)(null);
|
|
18026
|
+
const [dragOffset, setDragOffset] = (0, import_react98.useState)({
|
|
17592
18027
|
x: 0,
|
|
17593
18028
|
y: 0
|
|
17594
18029
|
});
|
|
17595
|
-
const [globalTooltipCount, setGlobalTooltipCount] = (0,
|
|
17596
|
-
const [alignmentGuides, setAlignmentGuides] = (0,
|
|
18030
|
+
const [globalTooltipCount, setGlobalTooltipCount] = (0, import_react98.useState)(0);
|
|
18031
|
+
const [alignmentGuides, setAlignmentGuides] = (0, import_react98.useState)([]);
|
|
17597
18032
|
const processedData = data.map((item) => ({
|
|
17598
18033
|
...item,
|
|
17599
18034
|
name: String(item[xAxisConfig.dataKey] || "N/A")
|
|
@@ -17616,7 +18051,7 @@ var BarChart = ({
|
|
|
17616
18051
|
// Garantir que tem a propriedade 'name'
|
|
17617
18052
|
};
|
|
17618
18053
|
};
|
|
17619
|
-
const maxDataValue = (0,
|
|
18054
|
+
const maxDataValue = (0, import_react98.useMemo)(() => {
|
|
17620
18055
|
let max = 0;
|
|
17621
18056
|
const keys = Object.keys(mapperConfig);
|
|
17622
18057
|
for (const row of processedData) {
|
|
@@ -17629,7 +18064,7 @@ var BarChart = ({
|
|
|
17629
18064
|
}
|
|
17630
18065
|
return max;
|
|
17631
18066
|
}, [processedData, mapperConfig]);
|
|
17632
|
-
const niceMax = (0,
|
|
18067
|
+
const niceMax = (0, import_react98.useMemo)(() => {
|
|
17633
18068
|
let padding2 = 0.08;
|
|
17634
18069
|
if (maxDataValue > 1e6) padding2 = 0.05;
|
|
17635
18070
|
if (maxDataValue > 1e7) padding2 = 0.03;
|
|
@@ -17670,7 +18105,7 @@ var BarChart = ({
|
|
|
17670
18105
|
const GUIDE_THRESHOLD2 = 60;
|
|
17671
18106
|
const STRONG_SNAP_THRESHOLD2 = 35;
|
|
17672
18107
|
const PRECISION_SNAP_THRESHOLD2 = 8;
|
|
17673
|
-
const updateAlignmentGuides = (0,
|
|
18108
|
+
const updateAlignmentGuides = (0, import_react98.useCallback)(
|
|
17674
18109
|
(draggedTooltipId, currentPosition) => {
|
|
17675
18110
|
if (!isDragging) return;
|
|
17676
18111
|
const getAllTooltips = () => {
|
|
@@ -17734,7 +18169,7 @@ var BarChart = ({
|
|
|
17734
18169
|
},
|
|
17735
18170
|
[isDragging, activeTooltips]
|
|
17736
18171
|
);
|
|
17737
|
-
const snapToGuides = (0,
|
|
18172
|
+
const snapToGuides = (0, import_react98.useCallback)(
|
|
17738
18173
|
(position) => {
|
|
17739
18174
|
const snappedPosition = { ...position };
|
|
17740
18175
|
let hasSnapped = false;
|
|
@@ -17796,7 +18231,7 @@ var BarChart = ({
|
|
|
17796
18231
|
setIsDragging(tooltipId);
|
|
17797
18232
|
setDragOffset({ x: offsetX, y: offsetY });
|
|
17798
18233
|
};
|
|
17799
|
-
(0,
|
|
18234
|
+
(0, import_react98.useEffect)(() => {
|
|
17800
18235
|
let rafId;
|
|
17801
18236
|
let lastMousePosition = { x: 0, y: 0 };
|
|
17802
18237
|
const handleGlobalMouseMove = (e) => {
|
|
@@ -17854,7 +18289,7 @@ var BarChart = ({
|
|
|
17854
18289
|
updateAlignmentGuides,
|
|
17855
18290
|
snapToGuides
|
|
17856
18291
|
]);
|
|
17857
|
-
(0,
|
|
18292
|
+
(0, import_react98.useEffect)(() => {
|
|
17858
18293
|
const handleCloseAllTooltips = () => {
|
|
17859
18294
|
setActiveTooltips([]);
|
|
17860
18295
|
setGlobalTooltipCount(0);
|
|
@@ -17864,7 +18299,7 @@ var BarChart = ({
|
|
|
17864
18299
|
window.removeEventListener("closeAllTooltips", handleCloseAllTooltips);
|
|
17865
18300
|
};
|
|
17866
18301
|
}, []);
|
|
17867
|
-
(0,
|
|
18302
|
+
(0, import_react98.useEffect)(() => {
|
|
17868
18303
|
const handleTooltipCountRequest = () => {
|
|
17869
18304
|
window.dispatchEvent(
|
|
17870
18305
|
new CustomEvent("tooltipCountResponse", {
|
|
@@ -17903,7 +18338,7 @@ var BarChart = ({
|
|
|
17903
18338
|
);
|
|
17904
18339
|
};
|
|
17905
18340
|
}, [activeTooltips]);
|
|
17906
|
-
(0,
|
|
18341
|
+
(0, import_react98.useEffect)(() => {
|
|
17907
18342
|
if (isDragging) return;
|
|
17908
18343
|
let totalCount = 0;
|
|
17909
18344
|
const handleCountResponse = (event) => {
|
|
@@ -17927,25 +18362,25 @@ var BarChart = ({
|
|
|
17927
18362
|
label
|
|
17928
18363
|
}) => {
|
|
17929
18364
|
if (!active || !payload) return null;
|
|
17930
|
-
return /* @__PURE__ */ (0,
|
|
17931
|
-
/* @__PURE__ */ (0,
|
|
18365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: "bg-card border border-border rounded-lg p-3 shadow-lg", children: [
|
|
18366
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("p", { className: "font-medium text-foreground mb-2", children: label }),
|
|
17932
18367
|
payload.map(
|
|
17933
|
-
(entry, index) => /* @__PURE__ */ (0,
|
|
17934
|
-
/* @__PURE__ */ (0,
|
|
18368
|
+
(entry, index) => /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { className: "flex items-center gap-2 text-sm", children: [
|
|
18369
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
17935
18370
|
"div",
|
|
17936
18371
|
{
|
|
17937
18372
|
className: "w-3 h-3 rounded-sm",
|
|
17938
18373
|
style: { backgroundColor: entry.color }
|
|
17939
18374
|
}
|
|
17940
18375
|
),
|
|
17941
|
-
/* @__PURE__ */ (0,
|
|
18376
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("span", { className: "text-muted-foreground", children: [
|
|
17942
18377
|
entry.name,
|
|
17943
18378
|
":"
|
|
17944
18379
|
] }),
|
|
17945
|
-
/* @__PURE__ */ (0,
|
|
18380
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("span", { className: "text-foreground font-medium", children: entry.value?.toLocaleString("pt-BR") })
|
|
17946
18381
|
] }, index)
|
|
17947
18382
|
),
|
|
17948
|
-
/* @__PURE__ */ (0,
|
|
18383
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)("p", { className: "text-xs text-muted-foreground mt-1", children: "Clique para fixar este tooltip" })
|
|
17949
18384
|
] });
|
|
17950
18385
|
};
|
|
17951
18386
|
const getTitleClassName = (position) => {
|
|
@@ -17959,7 +18394,7 @@ var BarChart = ({
|
|
|
17959
18394
|
return `${baseClasses} text-left`;
|
|
17960
18395
|
}
|
|
17961
18396
|
};
|
|
17962
|
-
return /* @__PURE__ */ (0,
|
|
18397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
|
|
17963
18398
|
"div",
|
|
17964
18399
|
{
|
|
17965
18400
|
className: cn("rounded-lg bg-card p-4 relative", className),
|
|
@@ -17968,9 +18403,9 @@ var BarChart = ({
|
|
|
17968
18403
|
maxWidth: "100%"
|
|
17969
18404
|
},
|
|
17970
18405
|
children: [
|
|
17971
|
-
title && /* @__PURE__ */ (0,
|
|
17972
|
-
/* @__PURE__ */ (0,
|
|
17973
|
-
|
|
18406
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { style: { paddingLeft: `${resolvedContainerPaddingLeft}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("h3", { className: getTitleClassName(titlePosition), children: title }) }),
|
|
18407
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
|
|
18408
|
+
import_recharts3.BarChart,
|
|
17974
18409
|
{
|
|
17975
18410
|
data: processedData,
|
|
17976
18411
|
width: typeof width === "number" ? width : 900,
|
|
@@ -17978,16 +18413,16 @@ var BarChart = ({
|
|
|
17978
18413
|
margin: resolveChartMargins(margins, chartMargins, showLabels),
|
|
17979
18414
|
onClick: handleChartClick,
|
|
17980
18415
|
children: [
|
|
17981
|
-
showGrid && /* @__PURE__ */ (0,
|
|
17982
|
-
|
|
18416
|
+
showGrid && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18417
|
+
import_recharts3.CartesianGrid,
|
|
17983
18418
|
{
|
|
17984
18419
|
strokeDasharray: "3 3",
|
|
17985
18420
|
stroke: gridColor || "hsl(var(--muted-foreground))",
|
|
17986
18421
|
opacity: 0.5
|
|
17987
18422
|
}
|
|
17988
18423
|
),
|
|
17989
|
-
/* @__PURE__ */ (0,
|
|
17990
|
-
|
|
18424
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18425
|
+
import_recharts3.XAxis,
|
|
17991
18426
|
{
|
|
17992
18427
|
dataKey: xAxisConfig.dataKey,
|
|
17993
18428
|
stroke: "hsl(var(--muted-foreground))",
|
|
@@ -17997,8 +18432,8 @@ var BarChart = ({
|
|
|
17997
18432
|
tickFormatter: xAxisConfig.valueFormatter
|
|
17998
18433
|
}
|
|
17999
18434
|
),
|
|
18000
|
-
/* @__PURE__ */ (0,
|
|
18001
|
-
|
|
18435
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18436
|
+
import_recharts3.YAxis,
|
|
18002
18437
|
{
|
|
18003
18438
|
stroke: "hsl(var(--muted-foreground))",
|
|
18004
18439
|
fontSize: 12,
|
|
@@ -18009,15 +18444,15 @@ var BarChart = ({
|
|
|
18009
18444
|
tickCount: 6
|
|
18010
18445
|
}
|
|
18011
18446
|
),
|
|
18012
|
-
showTooltip && /* @__PURE__ */ (0,
|
|
18013
|
-
|
|
18447
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18448
|
+
import_recharts3.Tooltip,
|
|
18014
18449
|
{
|
|
18015
|
-
content: /* @__PURE__ */ (0,
|
|
18450
|
+
content: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(CustomTooltip, {}),
|
|
18016
18451
|
cursor: { fill: "hsl(var(--muted))", opacity: 0.1 }
|
|
18017
18452
|
}
|
|
18018
18453
|
),
|
|
18019
|
-
showLegend && /* @__PURE__ */ (0,
|
|
18020
|
-
|
|
18454
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18455
|
+
import_recharts3.Legend,
|
|
18021
18456
|
{
|
|
18022
18457
|
wrapperStyle: {
|
|
18023
18458
|
color: "hsl(var(--foreground))",
|
|
@@ -18027,8 +18462,8 @@ var BarChart = ({
|
|
|
18027
18462
|
),
|
|
18028
18463
|
dataKeys.map((key) => {
|
|
18029
18464
|
const fieldConfig = mapperConfig[key];
|
|
18030
|
-
return /* @__PURE__ */ (0,
|
|
18031
|
-
|
|
18465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18466
|
+
import_recharts3.Bar,
|
|
18032
18467
|
{
|
|
18033
18468
|
dataKey: key,
|
|
18034
18469
|
name: fieldConfig?.label || key,
|
|
@@ -18036,8 +18471,8 @@ var BarChart = ({
|
|
|
18036
18471
|
radius: [4, 4, 0, 0],
|
|
18037
18472
|
onClick: handleBarClick,
|
|
18038
18473
|
style: { cursor: "pointer" },
|
|
18039
|
-
activeBar: /* @__PURE__ */ (0,
|
|
18040
|
-
|
|
18474
|
+
activeBar: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18475
|
+
import_recharts3.Rectangle,
|
|
18041
18476
|
{
|
|
18042
18477
|
fill: finalColors[key],
|
|
18043
18478
|
stroke: finalColors[key],
|
|
@@ -18045,8 +18480,8 @@ var BarChart = ({
|
|
|
18045
18480
|
opacity: 0.8
|
|
18046
18481
|
}
|
|
18047
18482
|
),
|
|
18048
|
-
children: showLabels && /* @__PURE__ */ (0,
|
|
18049
|
-
|
|
18483
|
+
children: showLabels && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18484
|
+
import_recharts3.LabelList,
|
|
18050
18485
|
{
|
|
18051
18486
|
dataKey: key,
|
|
18052
18487
|
position: "top",
|
|
@@ -18082,8 +18517,8 @@ var BarChart = ({
|
|
|
18082
18517
|
guide.sourceTooltip.top + guide.sourceTooltip.height / 2,
|
|
18083
18518
|
guide.targetTooltip.top + guide.targetTooltip.height / 2
|
|
18084
18519
|
);
|
|
18085
|
-
return /* @__PURE__ */ (0,
|
|
18086
|
-
/* @__PURE__ */ (0,
|
|
18520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)("div", { children: [
|
|
18521
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18087
18522
|
"div",
|
|
18088
18523
|
{
|
|
18089
18524
|
className: "fixed pointer-events-none z-30",
|
|
@@ -18102,7 +18537,7 @@ var BarChart = ({
|
|
|
18102
18537
|
}
|
|
18103
18538
|
}
|
|
18104
18539
|
),
|
|
18105
|
-
/* @__PURE__ */ (0,
|
|
18540
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18106
18541
|
"div",
|
|
18107
18542
|
{
|
|
18108
18543
|
className: "fixed pointer-events-none z-31",
|
|
@@ -18118,7 +18553,7 @@ var BarChart = ({
|
|
|
18118
18553
|
}
|
|
18119
18554
|
}
|
|
18120
18555
|
),
|
|
18121
|
-
/* @__PURE__ */ (0,
|
|
18556
|
+
/* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18122
18557
|
"div",
|
|
18123
18558
|
{
|
|
18124
18559
|
className: "fixed pointer-events-none z-31",
|
|
@@ -18136,7 +18571,7 @@ var BarChart = ({
|
|
|
18136
18571
|
)
|
|
18137
18572
|
] }, index);
|
|
18138
18573
|
}),
|
|
18139
|
-
activeTooltips.map((tooltip, index) => /* @__PURE__ */ (0,
|
|
18574
|
+
activeTooltips.map((tooltip, index) => /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
|
|
18140
18575
|
DraggableTooltip_default,
|
|
18141
18576
|
{
|
|
18142
18577
|
id: tooltip.id,
|
|
@@ -18169,9 +18604,9 @@ var BarChart = ({
|
|
|
18169
18604
|
var BarChart_default = BarChart;
|
|
18170
18605
|
|
|
18171
18606
|
// src/components/ui/charts/LineChart.tsx
|
|
18172
|
-
var
|
|
18173
|
-
var
|
|
18174
|
-
var
|
|
18607
|
+
var import_react99 = require("react");
|
|
18608
|
+
var import_recharts4 = require("recharts");
|
|
18609
|
+
var import_jsx_runtime99 = require("react/jsx-runtime");
|
|
18175
18610
|
var defaultData = [
|
|
18176
18611
|
{ name: "A", value: 100 },
|
|
18177
18612
|
{ name: "B", value: 200 },
|
|
@@ -18203,14 +18638,14 @@ var CustomLineChart = ({
|
|
|
18203
18638
|
containerPaddingLeft,
|
|
18204
18639
|
16
|
|
18205
18640
|
);
|
|
18206
|
-
const [activeTooltips, setActiveTooltips] = (0,
|
|
18207
|
-
const [isDragging, setIsDragging] = (0,
|
|
18208
|
-
const [dragOffset, setDragOffset] = (0,
|
|
18641
|
+
const [activeTooltips, setActiveTooltips] = (0, import_react99.useState)([]);
|
|
18642
|
+
const [isDragging, setIsDragging] = (0, import_react99.useState)(null);
|
|
18643
|
+
const [dragOffset, setDragOffset] = (0, import_react99.useState)({
|
|
18209
18644
|
x: 0,
|
|
18210
18645
|
y: 0
|
|
18211
18646
|
});
|
|
18212
|
-
const [globalTooltipCount, setGlobalTooltipCount] = (0,
|
|
18213
|
-
const [alignmentGuides, setAlignmentGuides] = (0,
|
|
18647
|
+
const [globalTooltipCount, setGlobalTooltipCount] = (0, import_react99.useState)(0);
|
|
18648
|
+
const [alignmentGuides, setAlignmentGuides] = (0, import_react99.useState)([]);
|
|
18214
18649
|
const generateColors = (dataKeys2) => {
|
|
18215
18650
|
const colorMap = {};
|
|
18216
18651
|
const allColors = generateAdditionalColors(colors2, dataKeys2.length);
|
|
@@ -18219,12 +18654,12 @@ var CustomLineChart = ({
|
|
|
18219
18654
|
});
|
|
18220
18655
|
return colorMap;
|
|
18221
18656
|
};
|
|
18222
|
-
const dataKeys = (0,
|
|
18657
|
+
const dataKeys = (0, import_react99.useMemo)(
|
|
18223
18658
|
() => data.length > 0 ? Object.keys(data[0]).filter((key) => key !== "name") : [],
|
|
18224
18659
|
[data]
|
|
18225
18660
|
);
|
|
18226
18661
|
const finalColors = generateColors(dataKeys);
|
|
18227
|
-
const maxDataValue = (0,
|
|
18662
|
+
const maxDataValue = (0, import_react99.useMemo)(() => {
|
|
18228
18663
|
let max = 0;
|
|
18229
18664
|
for (const row of data) {
|
|
18230
18665
|
const r = row;
|
|
@@ -18236,7 +18671,7 @@ var CustomLineChart = ({
|
|
|
18236
18671
|
}
|
|
18237
18672
|
return max;
|
|
18238
18673
|
}, [data, dataKeys]);
|
|
18239
|
-
const niceMax = (0,
|
|
18674
|
+
const niceMax = (0, import_react99.useMemo)(() => {
|
|
18240
18675
|
let padding2 = 0.08;
|
|
18241
18676
|
if (maxDataValue > 1e6) padding2 = 0.05;
|
|
18242
18677
|
if (maxDataValue > 1e7) padding2 = 0.03;
|
|
@@ -18270,7 +18705,7 @@ var CustomLineChart = ({
|
|
|
18270
18705
|
setActiveTooltips((prev) => [...prev, newTooltip]);
|
|
18271
18706
|
}
|
|
18272
18707
|
};
|
|
18273
|
-
return /* @__PURE__ */ (0,
|
|
18708
|
+
return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
18274
18709
|
"circle",
|
|
18275
18710
|
{
|
|
18276
18711
|
cx,
|
|
@@ -18312,10 +18747,10 @@ var CustomLineChart = ({
|
|
|
18312
18747
|
const handleChartBackgroundClick = () => {
|
|
18313
18748
|
setActiveTooltips([]);
|
|
18314
18749
|
};
|
|
18315
|
-
const handleCloseAllTooltips = (0,
|
|
18750
|
+
const handleCloseAllTooltips = (0, import_react99.useCallback)(() => {
|
|
18316
18751
|
window.dispatchEvent(new CustomEvent("closeAllTooltips"));
|
|
18317
18752
|
}, []);
|
|
18318
|
-
const updateAlignmentGuides = (0,
|
|
18753
|
+
const updateAlignmentGuides = (0, import_react99.useCallback)(
|
|
18319
18754
|
(draggedTooltipId, draggedPosition) => {
|
|
18320
18755
|
const SNAP_THRESHOLD = 15;
|
|
18321
18756
|
const draggedTooltip = activeTooltips.find(
|
|
@@ -18396,7 +18831,7 @@ var CustomLineChart = ({
|
|
|
18396
18831
|
},
|
|
18397
18832
|
[activeTooltips]
|
|
18398
18833
|
);
|
|
18399
|
-
const snapToGuides = (0,
|
|
18834
|
+
const snapToGuides = (0, import_react99.useCallback)(
|
|
18400
18835
|
(position) => {
|
|
18401
18836
|
const SNAP_DISTANCE = 10;
|
|
18402
18837
|
const snappedPosition = { ...position };
|
|
@@ -18424,7 +18859,7 @@ var CustomLineChart = ({
|
|
|
18424
18859
|
setIsDragging(tooltipId);
|
|
18425
18860
|
setDragOffset({ x: offsetX, y: offsetY });
|
|
18426
18861
|
};
|
|
18427
|
-
(0,
|
|
18862
|
+
(0, import_react99.useEffect)(() => {
|
|
18428
18863
|
let rafId;
|
|
18429
18864
|
let lastMousePosition = { x: 0, y: 0 };
|
|
18430
18865
|
const handleGlobalMouseMove = (e) => {
|
|
@@ -18471,7 +18906,7 @@ var CustomLineChart = ({
|
|
|
18471
18906
|
updateAlignmentGuides,
|
|
18472
18907
|
snapToGuides
|
|
18473
18908
|
]);
|
|
18474
|
-
(0,
|
|
18909
|
+
(0, import_react99.useEffect)(() => {
|
|
18475
18910
|
const handleCloseAllTooltips2 = () => {
|
|
18476
18911
|
setActiveTooltips([]);
|
|
18477
18912
|
setGlobalTooltipCount(0);
|
|
@@ -18481,7 +18916,7 @@ var CustomLineChart = ({
|
|
|
18481
18916
|
window.removeEventListener("closeAllTooltips", handleCloseAllTooltips2);
|
|
18482
18917
|
};
|
|
18483
18918
|
}, []);
|
|
18484
|
-
(0,
|
|
18919
|
+
(0, import_react99.useEffect)(() => {
|
|
18485
18920
|
const handleTooltipCountRequest = () => {
|
|
18486
18921
|
window.dispatchEvent(
|
|
18487
18922
|
new CustomEvent("tooltipCountResponse", {
|
|
@@ -18525,7 +18960,7 @@ var CustomLineChart = ({
|
|
|
18525
18960
|
);
|
|
18526
18961
|
};
|
|
18527
18962
|
}, [activeTooltips]);
|
|
18528
|
-
(0,
|
|
18963
|
+
(0, import_react99.useEffect)(() => {
|
|
18529
18964
|
if (isDragging) return;
|
|
18530
18965
|
let totalCount = 0;
|
|
18531
18966
|
const handleCountResponse = (event) => {
|
|
@@ -18553,7 +18988,7 @@ var CustomLineChart = ({
|
|
|
18553
18988
|
return "text-left";
|
|
18554
18989
|
}
|
|
18555
18990
|
};
|
|
18556
|
-
return /* @__PURE__ */ (0,
|
|
18991
|
+
return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: cn("relative", className), children: /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
|
|
18557
18992
|
"div",
|
|
18558
18993
|
{
|
|
18559
18994
|
className: "rounded-lg bg-card p-4 relative border border-border",
|
|
@@ -18563,9 +18998,9 @@ var CustomLineChart = ({
|
|
|
18563
18998
|
},
|
|
18564
18999
|
onClick: handleChartBackgroundClick,
|
|
18565
19000
|
children: [
|
|
18566
|
-
title && /* @__PURE__ */ (0,
|
|
18567
|
-
/* @__PURE__ */ (0,
|
|
18568
|
-
|
|
19001
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { style: { paddingLeft: `${resolvedContainerPaddingLeft}px` }, children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("div", { className: cn("mb-4", getTitleClass()), children: /* @__PURE__ */ (0, import_jsx_runtime99.jsx)("h3", { className: "text-lg font-semibold text-foreground", children: title }) }) }),
|
|
19002
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(
|
|
19003
|
+
import_recharts4.LineChart,
|
|
18569
19004
|
{
|
|
18570
19005
|
data,
|
|
18571
19006
|
width: typeof width === "number" ? width : 900,
|
|
@@ -18573,24 +19008,24 @@ var CustomLineChart = ({
|
|
|
18573
19008
|
margin: resolveChartMargins(margins, chartMargins, showLabels),
|
|
18574
19009
|
onClick: handleChartClick,
|
|
18575
19010
|
children: [
|
|
18576
|
-
showGrid && /* @__PURE__ */ (0,
|
|
18577
|
-
|
|
19011
|
+
showGrid && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
19012
|
+
import_recharts4.CartesianGrid,
|
|
18578
19013
|
{
|
|
18579
19014
|
strokeDasharray: "3 3",
|
|
18580
19015
|
stroke: gridColor || "hsl(var(--muted-foreground))",
|
|
18581
19016
|
opacity: 0.3
|
|
18582
19017
|
}
|
|
18583
19018
|
),
|
|
18584
|
-
/* @__PURE__ */ (0,
|
|
18585
|
-
|
|
19019
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
19020
|
+
import_recharts4.XAxis,
|
|
18586
19021
|
{
|
|
18587
19022
|
dataKey: "name",
|
|
18588
19023
|
className: "fill-muted-foreground text-xs",
|
|
18589
19024
|
fontSize: 12
|
|
18590
19025
|
}
|
|
18591
19026
|
),
|
|
18592
|
-
/* @__PURE__ */ (0,
|
|
18593
|
-
|
|
19027
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
19028
|
+
import_recharts4.YAxis,
|
|
18594
19029
|
{
|
|
18595
19030
|
className: "fill-muted-foreground text-xs",
|
|
18596
19031
|
fontSize: 12,
|
|
@@ -18599,9 +19034,9 @@ var CustomLineChart = ({
|
|
|
18599
19034
|
tickCount: 6
|
|
18600
19035
|
}
|
|
18601
19036
|
),
|
|
18602
|
-
showTooltip && /* @__PURE__ */ (0,
|
|
18603
|
-
showLegend && /* @__PURE__ */ (0,
|
|
18604
|
-
|
|
19037
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_recharts4.Tooltip, { content: () => null }),
|
|
19038
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
19039
|
+
import_recharts4.Legend,
|
|
18605
19040
|
{
|
|
18606
19041
|
wrapperStyle: {
|
|
18607
19042
|
fontSize: "12px",
|
|
@@ -18609,17 +19044,17 @@ var CustomLineChart = ({
|
|
|
18609
19044
|
}
|
|
18610
19045
|
}
|
|
18611
19046
|
),
|
|
18612
|
-
dataKeys.map((key) => /* @__PURE__ */ (0,
|
|
18613
|
-
|
|
19047
|
+
dataKeys.map((key) => /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
19048
|
+
import_recharts4.Line,
|
|
18614
19049
|
{
|
|
18615
19050
|
type: "monotone",
|
|
18616
19051
|
dataKey: key,
|
|
18617
19052
|
stroke: finalColors[key],
|
|
18618
19053
|
strokeWidth,
|
|
18619
19054
|
dot: showDots ? { r: 4, cursor: "pointer" } : false,
|
|
18620
|
-
activeDot: (props) => /* @__PURE__ */ (0,
|
|
18621
|
-
children: showLabels && /* @__PURE__ */ (0,
|
|
18622
|
-
|
|
19055
|
+
activeDot: (props) => /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(ClickableDot, { ...props, dataKey: key }),
|
|
19056
|
+
children: showLabels && /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
19057
|
+
import_recharts4.LabelList,
|
|
18623
19058
|
{
|
|
18624
19059
|
dataKey: key,
|
|
18625
19060
|
position: "top",
|
|
@@ -18655,8 +19090,8 @@ var CustomLineChart = ({
|
|
|
18655
19090
|
guide.sourceTooltip.top + guide.sourceTooltip.height / 2,
|
|
18656
19091
|
guide.targetTooltip.top + guide.targetTooltip.height / 2
|
|
18657
19092
|
);
|
|
18658
|
-
return /* @__PURE__ */ (0,
|
|
18659
|
-
/* @__PURE__ */ (0,
|
|
19093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)("div", { children: [
|
|
19094
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
18660
19095
|
"div",
|
|
18661
19096
|
{
|
|
18662
19097
|
className: "fixed pointer-events-none z-30",
|
|
@@ -18675,7 +19110,7 @@ var CustomLineChart = ({
|
|
|
18675
19110
|
}
|
|
18676
19111
|
}
|
|
18677
19112
|
),
|
|
18678
|
-
/* @__PURE__ */ (0,
|
|
19113
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
18679
19114
|
"div",
|
|
18680
19115
|
{
|
|
18681
19116
|
className: "fixed pointer-events-none z-31",
|
|
@@ -18691,7 +19126,7 @@ var CustomLineChart = ({
|
|
|
18691
19126
|
}
|
|
18692
19127
|
}
|
|
18693
19128
|
),
|
|
18694
|
-
/* @__PURE__ */ (0,
|
|
19129
|
+
/* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
18695
19130
|
"div",
|
|
18696
19131
|
{
|
|
18697
19132
|
className: "fixed pointer-events-none z-31",
|
|
@@ -18709,7 +19144,7 @@ var CustomLineChart = ({
|
|
|
18709
19144
|
)
|
|
18710
19145
|
] }, index);
|
|
18711
19146
|
}),
|
|
18712
|
-
activeTooltips.map((tooltip, index) => /* @__PURE__ */ (0,
|
|
19147
|
+
activeTooltips.map((tooltip, index) => /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
|
|
18713
19148
|
DraggableTooltip_default,
|
|
18714
19149
|
{
|
|
18715
19150
|
id: tooltip.id,
|
|
@@ -18740,8 +19175,8 @@ var CustomLineChart = ({
|
|
|
18740
19175
|
var LineChart_default = CustomLineChart;
|
|
18741
19176
|
|
|
18742
19177
|
// src/components/ui/charts/PieChart.tsx
|
|
18743
|
-
var
|
|
18744
|
-
var
|
|
19178
|
+
var import_recharts5 = require("recharts");
|
|
19179
|
+
var import_jsx_runtime100 = require("react/jsx-runtime");
|
|
18745
19180
|
var defaultData2 = [
|
|
18746
19181
|
{ name: "Vendas", value: 4e3 },
|
|
18747
19182
|
{ name: "Marketing", value: 3e3 },
|
|
@@ -18779,7 +19214,7 @@ var renderCustomizedLabel = ({
|
|
|
18779
19214
|
const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
|
|
18780
19215
|
const x = cx + radius * Math.cos(-midAngle * RADIAN);
|
|
18781
19216
|
const y = cy + radius * Math.sin(-midAngle * RADIAN);
|
|
18782
|
-
return /* @__PURE__ */ (0,
|
|
19217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
|
|
18783
19218
|
"text",
|
|
18784
19219
|
{
|
|
18785
19220
|
x,
|
|
@@ -18808,9 +19243,9 @@ var CustomPieChart = ({
|
|
|
18808
19243
|
centerY = "50%"
|
|
18809
19244
|
}) => {
|
|
18810
19245
|
const finalColors = colors2 || DEFAULT_COLORS5;
|
|
18811
|
-
return /* @__PURE__ */ (0,
|
|
18812
|
-
/* @__PURE__ */ (0,
|
|
18813
|
-
|
|
19246
|
+
return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)("div", { className: cn("w-full rounded-lg bg-card p-4", className), children: /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_recharts5.ResponsiveContainer, { width, height, children: /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_recharts5.PieChart, { children: [
|
|
19247
|
+
/* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
|
|
19248
|
+
import_recharts5.Pie,
|
|
18814
19249
|
{
|
|
18815
19250
|
data,
|
|
18816
19251
|
cx: centerX,
|
|
@@ -18821,8 +19256,8 @@ var CustomPieChart = ({
|
|
|
18821
19256
|
innerRadius,
|
|
18822
19257
|
fill: "#8884d8",
|
|
18823
19258
|
dataKey: "value",
|
|
18824
|
-
children: data.map((entry, index) => /* @__PURE__ */ (0,
|
|
18825
|
-
|
|
19259
|
+
children: data.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
|
|
19260
|
+
import_recharts5.Cell,
|
|
18826
19261
|
{
|
|
18827
19262
|
fill: finalColors[index % finalColors.length]
|
|
18828
19263
|
},
|
|
@@ -18830,8 +19265,8 @@ var CustomPieChart = ({
|
|
|
18830
19265
|
))
|
|
18831
19266
|
}
|
|
18832
19267
|
),
|
|
18833
|
-
showTooltip && /* @__PURE__ */ (0,
|
|
18834
|
-
|
|
19268
|
+
showTooltip && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(
|
|
19269
|
+
import_recharts5.Tooltip,
|
|
18835
19270
|
{
|
|
18836
19271
|
contentStyle: {
|
|
18837
19272
|
backgroundColor: "hsl(var(--popover))",
|
|
@@ -18841,25 +19276,71 @@ var CustomPieChart = ({
|
|
|
18841
19276
|
}
|
|
18842
19277
|
}
|
|
18843
19278
|
),
|
|
18844
|
-
showLegend && /* @__PURE__ */ (0,
|
|
19279
|
+
showLegend && /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_recharts5.Legend, {})
|
|
18845
19280
|
] }) }) });
|
|
18846
19281
|
};
|
|
18847
19282
|
var PieChart_default = CustomPieChart;
|
|
18848
19283
|
|
|
19284
|
+
// src/components/ui/charts/TimeSeries.tsx
|
|
19285
|
+
var import_jsx_runtime101 = require("react/jsx-runtime");
|
|
19286
|
+
var TimeSeries = ({
|
|
19287
|
+
data,
|
|
19288
|
+
xAxis,
|
|
19289
|
+
chartHeight = 350,
|
|
19290
|
+
height,
|
|
19291
|
+
brushHeight,
|
|
19292
|
+
className,
|
|
19293
|
+
start,
|
|
19294
|
+
end,
|
|
19295
|
+
defaultStartIndex,
|
|
19296
|
+
defaultEndIndex,
|
|
19297
|
+
onRangeChange,
|
|
19298
|
+
brushColor,
|
|
19299
|
+
brushStroke,
|
|
19300
|
+
miniChartOpacity = 0.2,
|
|
19301
|
+
...rest
|
|
19302
|
+
}) => {
|
|
19303
|
+
const brushHeightValue = brushHeight ?? height ?? 60;
|
|
19304
|
+
const startIndex = defaultStartIndex ?? start ?? 0;
|
|
19305
|
+
const endIndex = defaultEndIndex ?? end;
|
|
19306
|
+
return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)("div", { className: cn("w-full flex flex-col", className), children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
|
|
19307
|
+
Chart_default,
|
|
19308
|
+
{
|
|
19309
|
+
...rest,
|
|
19310
|
+
data,
|
|
19311
|
+
xAxis,
|
|
19312
|
+
height: chartHeight + brushHeightValue + 40,
|
|
19313
|
+
timeSeries: {
|
|
19314
|
+
start: startIndex,
|
|
19315
|
+
end: endIndex,
|
|
19316
|
+
onRangeChange,
|
|
19317
|
+
height: brushHeightValue,
|
|
19318
|
+
brushColor,
|
|
19319
|
+
brushStroke,
|
|
19320
|
+
miniChartOpacity
|
|
19321
|
+
}
|
|
19322
|
+
}
|
|
19323
|
+
) });
|
|
19324
|
+
};
|
|
19325
|
+
var TimeSeries_default = TimeSeries;
|
|
19326
|
+
|
|
18849
19327
|
// src/components/ui/LeaderBoard.tsx
|
|
18850
|
-
var
|
|
18851
|
-
var
|
|
19328
|
+
var import_react100 = require("@phosphor-icons/react");
|
|
19329
|
+
var import_react101 = require("react");
|
|
18852
19330
|
var import_framer_motion22 = require("framer-motion");
|
|
18853
|
-
var
|
|
19331
|
+
var import_jsx_runtime102 = require("react/jsx-runtime");
|
|
18854
19332
|
function Leaderboard({
|
|
18855
19333
|
items,
|
|
18856
19334
|
order: initialOrder = "desc",
|
|
18857
19335
|
title = "LeaderBoard",
|
|
18858
19336
|
className,
|
|
18859
19337
|
isLoading = false,
|
|
18860
|
-
legend
|
|
19338
|
+
legend,
|
|
19339
|
+
best = false,
|
|
19340
|
+
worst = false
|
|
18861
19341
|
}) {
|
|
18862
|
-
const [order, setOrder] = (0,
|
|
19342
|
+
const [order, setOrder] = (0, import_react101.useState)(initialOrder);
|
|
19343
|
+
const [searchTerm, setSearchTerm] = (0, import_react101.useState)("");
|
|
18863
19344
|
const mockData = [
|
|
18864
19345
|
{ name: "Ana", value: 92 },
|
|
18865
19346
|
{ name: "Bruno", value: 81 },
|
|
@@ -18873,7 +19354,10 @@ function Leaderboard({
|
|
|
18873
19354
|
{ name: "Jo\xE3o", value: 18 }
|
|
18874
19355
|
];
|
|
18875
19356
|
const data = items ?? mockData;
|
|
18876
|
-
const
|
|
19357
|
+
const filteredData = data.filter(
|
|
19358
|
+
(item) => item.name.toLowerCase().includes(searchTerm.toLowerCase())
|
|
19359
|
+
);
|
|
19360
|
+
const sortedData = [...filteredData].sort((a, b) => {
|
|
18877
19361
|
const aValue = typeof a.value === "string" ? parseFloat(a.value) || a.value : a.value;
|
|
18878
19362
|
const bValue = typeof b.value === "string" ? parseFloat(b.value) || b.value : b.value;
|
|
18879
19363
|
if (typeof aValue === "number" && typeof bValue === "number") {
|
|
@@ -18885,57 +19369,87 @@ function Leaderboard({
|
|
|
18885
19369
|
if (typeof aValue === "number") return order === "desc" ? -1 : 1;
|
|
18886
19370
|
return order === "desc" ? 1 : -1;
|
|
18887
19371
|
});
|
|
18888
|
-
const getBadgeColor = (value) => {
|
|
19372
|
+
const getBadgeColor = (value, index, total) => {
|
|
19373
|
+
if (best || worst) {
|
|
19374
|
+
const third = total / 3;
|
|
19375
|
+
if (best) {
|
|
19376
|
+
if (index < third) return "green";
|
|
19377
|
+
if (index < 2 * third) return "yellow";
|
|
19378
|
+
return "red";
|
|
19379
|
+
}
|
|
19380
|
+
if (worst) {
|
|
19381
|
+
if (index < third) return "red";
|
|
19382
|
+
if (index < 2 * third) return "yellow";
|
|
19383
|
+
return "green";
|
|
19384
|
+
}
|
|
19385
|
+
}
|
|
18889
19386
|
const numValue = typeof value === "string" ? parseFloat(value) : value;
|
|
18890
19387
|
if (isNaN(numValue)) return "green";
|
|
18891
19388
|
if (numValue >= 75) return "red";
|
|
18892
19389
|
if (numValue >= 25) return "yellow";
|
|
18893
19390
|
return "green";
|
|
18894
19391
|
};
|
|
18895
|
-
return /* @__PURE__ */ (0,
|
|
19392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(
|
|
18896
19393
|
"div",
|
|
18897
19394
|
{
|
|
18898
|
-
className: `border rounded-xl flex flex-col max-h-80 w-96
|
|
19395
|
+
className: `border rounded-xl flex flex-col max-h-80 w-96 ${className}`,
|
|
18899
19396
|
children: [
|
|
18900
|
-
/* @__PURE__ */ (0,
|
|
18901
|
-
/* @__PURE__ */ (0,
|
|
18902
|
-
/* @__PURE__ */ (0,
|
|
19397
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "flex items-center justify-between py-2 px-4 border-b flex-shrink-0 gap-3 ", children: [
|
|
19398
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)("h2", { className: "text-lg font-semibold px-1 whitespace-nowrap", children: title }),
|
|
19399
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "flex-1 max-w-[200px]", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
|
|
19400
|
+
InputBase,
|
|
19401
|
+
{
|
|
19402
|
+
value: searchTerm,
|
|
19403
|
+
onChange: (e) => setSearchTerm(e.target.value),
|
|
19404
|
+
placeholder: "Pesquisar...",
|
|
19405
|
+
leftIcon: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_react100.MagnifyingGlassIcon, { size: 16 }),
|
|
19406
|
+
className: "h-8 py-1"
|
|
19407
|
+
}
|
|
19408
|
+
) }),
|
|
19409
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
|
|
18903
19410
|
ButtonBase,
|
|
18904
19411
|
{
|
|
18905
19412
|
size: "icon",
|
|
18906
|
-
variant: "
|
|
19413
|
+
variant: "outline",
|
|
18907
19414
|
onClick: () => setOrder(order === "desc" ? "asc" : "desc"),
|
|
18908
19415
|
disabled: isLoading || sortedData.length === 0,
|
|
18909
|
-
children: /* @__PURE__ */ (0,
|
|
19416
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
|
|
19417
|
+
import_framer_motion22.motion.div,
|
|
19418
|
+
{
|
|
19419
|
+
animate: { rotate: order === "asc" ? 180 : 0 },
|
|
19420
|
+
transition: { type: "spring", stiffness: 300, damping: 20 },
|
|
19421
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_react100.CaretUpDownIcon, {})
|
|
19422
|
+
}
|
|
19423
|
+
)
|
|
18910
19424
|
}
|
|
18911
19425
|
)
|
|
18912
19426
|
] }),
|
|
18913
|
-
/* @__PURE__ */ (0,
|
|
18914
|
-
/* @__PURE__ */ (0,
|
|
18915
|
-
/* @__PURE__ */ (0,
|
|
18916
|
-
/* @__PURE__ */ (0,
|
|
19427
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "overflow-y-auto flex-1 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-muted-foreground/20 [&::-webkit-scrollbar-thumb]:rounded-full hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/40 transition-colors", children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "p-4 space-y-3", children: Array.from({ length: 5 }).map((_, idx) => /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "flex items-center justify-between p-1", children: [
|
|
19428
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "flex items-center gap-3 flex-1", children: [
|
|
19429
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)(SkeletonBase, { className: "w-8 h-8 rounded-full" }),
|
|
19430
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)(SkeletonBase, { className: "h-4 w-36 rounded-full" })
|
|
18917
19431
|
] }),
|
|
18918
|
-
/* @__PURE__ */ (0,
|
|
18919
|
-
] }, idx)) }) : sortedData.length === 0 ? /* @__PURE__ */ (0,
|
|
18920
|
-
/* @__PURE__ */ (0,
|
|
18921
|
-
/* @__PURE__ */ (0,
|
|
18922
|
-
/* @__PURE__ */ (0,
|
|
19432
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)(SkeletonBase, { className: "h-6 w-12 rounded-full" })
|
|
19433
|
+
] }, idx)) }) : sortedData.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "flex items-center justify-center h-full py-12", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("p", { className: "text-muted-foreground text-sm", children: "Sem dados dispon\xEDveis" }) }) : /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { children: [
|
|
19434
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "flex items-center justify-between py-2.5 px-4 border-b flex-shrink-0 gap-3 sticky top-0 bg-background", children: [
|
|
19435
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wider pl-1", children: legend?.[0] }),
|
|
19436
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wider", children: legend?.[1] })
|
|
18923
19437
|
] }),
|
|
18924
|
-
/* @__PURE__ */ (0,
|
|
19438
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)("ul", { children: sortedData.map((item, idx) => /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
|
|
18925
19439
|
import_framer_motion22.motion.span,
|
|
18926
19440
|
{
|
|
18927
19441
|
initial: { opacity: 0, y: 10 },
|
|
18928
19442
|
animate: { opacity: 1, y: 0 },
|
|
18929
19443
|
transition: { delay: idx * 5e-3 },
|
|
18930
|
-
children: /* @__PURE__ */ (0,
|
|
18931
|
-
/* @__PURE__ */ (0,
|
|
18932
|
-
/* @__PURE__ */ (0,
|
|
18933
|
-
/* @__PURE__ */ (0,
|
|
19444
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("li", { className: "flex items-center justify-between py-3 border-b last:border-b-0 hover:bg-muted transition-colors px-4", children: [
|
|
19445
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
19446
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)("span", { className: "text-sm text-gray-400 w-6 h-6 border rounded-full text-center bg-muted/50", children: order === "desc" ? idx + 1 : sortedData.length - idx }),
|
|
19447
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)("span", { className: "font-medium", children: item.name })
|
|
18934
19448
|
] }),
|
|
18935
|
-
/* @__PURE__ */ (0,
|
|
19449
|
+
/* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
|
|
18936
19450
|
Badge,
|
|
18937
19451
|
{
|
|
18938
|
-
color: getBadgeColor(item.value),
|
|
19452
|
+
color: getBadgeColor(item.value, idx, sortedData.length),
|
|
18939
19453
|
size: "md",
|
|
18940
19454
|
className: "font-bold",
|
|
18941
19455
|
children: item.value
|