@mlw-packages/react-components 1.9.5 → 1.9.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.js CHANGED
@@ -2558,8 +2558,8 @@ function MultiSelectTriggerBase({
2558
2558
  "aria-disabled": disabled || void 0,
2559
2559
  disabled,
2560
2560
  className: cn(
2561
- "flex h-auto max-h-9 min-h-9 w-full items-center justify-between gap-2 overflow-hidden rounded-md border border-input bg-background px-3 py-1.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",
2562
- error ? "border-destructive focus:ring-1 focus:ring-destructive" : "border-input focus:ring-1 focus:ring-ring",
2561
+ "flex h-auto max-h-9 min-h-9 w-full items-center justify-between gap-2 overflow-hidden rounded-md border border-input bg-background px-3 py-1.5 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground hover:text-primary",
2562
+ error ? "border-destructive focus:ring-1 focus:ring-destructive dark:border-red-500" : "border-border focus:ring-1 focus:ring-ring",
2563
2563
  className
2564
2564
  ),
2565
2565
  children: [
@@ -7886,7 +7886,7 @@ function ScrollColumn({
7886
7886
  {
7887
7887
  className: cn(
7888
7888
  "snap-center flex items-center justify-center select-none font-bold tabular-nums transition-all duration-200",
7889
- isCentered ? "text-2xl sm:text-xl text-foreground scale-110" : "text-base sm:text-sm text-muted-foreground/60"
7889
+ isCentered ? "text-foreground scale-110" : "text-base sm:text-sm text-muted-foreground/60"
7890
7890
  ),
7891
7891
  style: { height: `${itemHeight}px` },
7892
7892
  children: item.toString().padStart(2, "0")
@@ -14017,8 +14017,7 @@ function MultiSelect({
14017
14017
  )
14018
14018
  ]
14019
14019
  }
14020
- ),
14021
- /* @__PURE__ */ jsxRuntime.jsx(ErrorMessage_default, { error })
14020
+ )
14022
14021
  ] });
14023
14022
  }
14024
14023
 
@@ -15418,7 +15417,7 @@ var RechartTooltipWithTotal = ({
15418
15417
  {
15419
15418
  role: "dialog",
15420
15419
  "aria-label": `Tooltip ${label ?? ""}`,
15421
- className: "bg-card border border-border rounded-lg p-3 shadow-2xl max-w-xs",
15420
+ className: "bg-card border border-border rounded-lg p-3 shadow-2xl max-w-xs z-9999",
15422
15421
  style: { minWidth: 220 },
15423
15422
  children: [
15424
15423
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between mb-2", children: [
@@ -15531,7 +15530,7 @@ var TooltipSimple = ({
15531
15530
  {
15532
15531
  role: "dialog",
15533
15532
  "aria-label": `Tooltip ${label ?? ""}`,
15534
- className: "bg-card border border-border rounded-lg p-3 shadow-2xl max-w-[280px]",
15533
+ className: "bg-card border border-border rounded-lg p-3 shadow-2xl max-w-[280px] z-9999",
15535
15534
  style: { minWidth: 220 },
15536
15535
  children: [
15537
15536
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-2", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
@@ -16170,7 +16169,7 @@ var HorizontalLegend = ({
16170
16169
  const label = mapperConfig[key]?.label ?? labelMap?.[key] ?? formatFieldName2(key);
16171
16170
  return legendUppercase ? label.toUpperCase() : label;
16172
16171
  };
16173
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(className), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-2 sm:gap-3 md:gap-4 overflow-x-auto", children: [
16172
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(className), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-left gap-2 sm:gap-3 md:gap-4 overflow-x-auto", children: [
16174
16173
  allKeys.map((key) => {
16175
16174
  const displayLabel = formatLegendLabel(key);
16176
16175
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 sm:gap-2 flex-shrink-0", children: [
@@ -16209,6 +16208,119 @@ var HorizontalLegend = ({
16209
16208
  ] }) });
16210
16209
  };
16211
16210
  var HorizontalLegend_default = HorizontalLegend;
16211
+ function ChartControls({
16212
+ allKeys,
16213
+ mapperConfig,
16214
+ finalColors,
16215
+ highlightedSeries,
16216
+ toggleHighlight,
16217
+ showOnlyHighlighted,
16218
+ setShowOnlyHighlighted,
16219
+ highlightedSeriesSize,
16220
+ clearHighlights,
16221
+ enableHighlights,
16222
+ enableShowOnly,
16223
+ enablePeriodsDropdown,
16224
+ enableDraggableTooltips,
16225
+ processedData,
16226
+ onOpenPeriod,
16227
+ rightOffset,
16228
+ activePeriods,
16229
+ containerClass,
16230
+ containerWidth
16231
+ }) {
16232
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: containerClass, children: [
16233
+ enableHighlights && /* @__PURE__ */ jsxRuntime.jsx(
16234
+ Highlights_default,
16235
+ {
16236
+ allKeys,
16237
+ mapperConfig,
16238
+ finalColors,
16239
+ highlightedSeries,
16240
+ toggleHighlight,
16241
+ containerWidth
16242
+ }
16243
+ ),
16244
+ enableShowOnly && /* @__PURE__ */ jsxRuntime.jsx(
16245
+ ShowOnly_default,
16246
+ {
16247
+ showOnlyHighlighted,
16248
+ setShowOnlyHighlighted,
16249
+ highlightedSeriesSize,
16250
+ clearHighlights
16251
+ }
16252
+ ),
16253
+ enablePeriodsDropdown && enableDraggableTooltips && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
16254
+ PeriodsDropdown_default,
16255
+ {
16256
+ processedData: processedData ?? [],
16257
+ onOpenPeriod: onOpenPeriod ?? (() => {
16258
+ }),
16259
+ rightOffset,
16260
+ activePeriods
16261
+ }
16262
+ ) })
16263
+ ] });
16264
+ }
16265
+ function ChartHeader({
16266
+ title,
16267
+ titlePosition = "left",
16268
+ HORIZONTAL_PADDING_CLASS = "px-24",
16269
+ customLegend,
16270
+ data,
16271
+ allKeys,
16272
+ processedData,
16273
+ finalColors,
16274
+ mapperConfig,
16275
+ finalValueFormatter,
16276
+ formatBR
16277
+ }) {
16278
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16279
+ title && /* @__PURE__ */ jsxRuntime.jsx(
16280
+ "div",
16281
+ {
16282
+ className: cn(
16283
+ "w-full flex items-center mt-3 mb-2",
16284
+ HORIZONTAL_PADDING_CLASS,
16285
+ titlePosition === "center" && "justify-center",
16286
+ titlePosition === "right" && "justify-end",
16287
+ titlePosition === "left" && "justify-start"
16288
+ ),
16289
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[1.4rem] font-semibold text-foreground", children: title })
16290
+ }
16291
+ ),
16292
+ customLegend && !!data.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("px-6 mb-2", HORIZONTAL_PADDING_CLASS), children: /* @__PURE__ */ jsxRuntime.jsx(
16293
+ ChartTotalLegend_default,
16294
+ {
16295
+ items: allKeys.map((key) => {
16296
+ const values = processedData.map(
16297
+ (d) => Number(d[key] || 0)
16298
+ );
16299
+ const total = values.reduce((a, b) => a + b, 0);
16300
+ const first = values[0] || 0;
16301
+ const last = values[values.length - 1] || 0;
16302
+ const trendValue = first !== 0 ? Math.round((last - first) / first * 100) : 0;
16303
+ const formattedTotal = finalValueFormatter ? finalValueFormatter({
16304
+ value: total,
16305
+ formattedValue: String(total)
16306
+ }) : new Intl.NumberFormat(formatBR ? "pt-BR" : "en-US").format(
16307
+ total
16308
+ );
16309
+ return {
16310
+ label: mapperConfig[key]?.label || key,
16311
+ value: formattedTotal,
16312
+ color: finalColors[key],
16313
+ trend: {
16314
+ value: Math.abs(trendValue),
16315
+ positive: trendValue >= 0,
16316
+ neutral: trendValue === 0
16317
+ }
16318
+ };
16319
+ })
16320
+ }
16321
+ ) })
16322
+ ] });
16323
+ }
16212
16324
  var formatCompactNumber = (value) => {
16213
16325
  const isNegative = value < 0;
16214
16326
  const absValue = Math.abs(value);
@@ -16403,6 +16515,19 @@ var renderInsideBarLabel = (color, valueFormatter) => {
16403
16515
  );
16404
16516
  };
16405
16517
  };
16518
+
16519
+ // src/utils/calcDivision.ts
16520
+ var calcDivision = (dividend, divisor) => {
16521
+ return dividend / divisor;
16522
+ };
16523
+
16524
+ // src/components/ui/charts/utils/formatters.ts
16525
+ function formatLinePercentage(value) {
16526
+ const numValue = typeof value === "number" ? value : typeof value === "string" ? parseFloat(value) : 0;
16527
+ const percentage = calcDivision(numValue, 100);
16528
+ const formattedPercentage = typeof percentage === "number" ? percentage.toFixed(1).replace(".", ",") : String(percentage).replace(".", ",");
16529
+ return `${formattedPercentage}%`;
16530
+ }
16406
16531
  var ChartBar = ({ x, y, w, h, i, loading }) => {
16407
16532
  const baseY = y - h;
16408
16533
  const d = i * 0.08;
@@ -16984,6 +17109,94 @@ var useChartMinMax = ({
16984
17109
  };
16985
17110
  }, [processedData, orderBy, xAxisDataKey, categoryFormatter]);
16986
17111
  };
17112
+ function useProcessedData({
17113
+ data,
17114
+ xAxisKey,
17115
+ timeSeriesConfig,
17116
+ startIndex,
17117
+ endIndex
17118
+ }) {
17119
+ return React33.useMemo(() => {
17120
+ const mapped = data.map((item) => ({
17121
+ ...item,
17122
+ name: String(item[xAxisKey] || "N/A")
17123
+ }));
17124
+ if (timeSeriesConfig) {
17125
+ return mapped.slice(startIndex, endIndex + 1);
17126
+ }
17127
+ return mapped;
17128
+ }, [data, xAxisKey, timeSeriesConfig, startIndex, endIndex]);
17129
+ }
17130
+ function useBiaxial(biaxial, yAxisLabel) {
17131
+ return React33.useMemo(() => {
17132
+ if (!biaxial) return null;
17133
+ if (typeof biaxial === "string") return { key: [biaxial] };
17134
+ if (Array.isArray(biaxial)) return { key: biaxial };
17135
+ const normalized = biaxial;
17136
+ const leftLabelMissing = !yAxisLabel || String(yAxisLabel).trim() === "";
17137
+ const rightLabelMissing = !normalized.label || String(normalized.label).trim() === "";
17138
+ if (leftLabelMissing || rightLabelMissing) {
17139
+ throw new Error(
17140
+ "When using `biaxial`, you must provide both `yAxisLabel` (left axis) and `biaxial.label` (right axis)."
17141
+ );
17142
+ }
17143
+ return normalized;
17144
+ }, [biaxial, yAxisLabel]);
17145
+ }
17146
+ function useChartLayout({
17147
+ chartMargin,
17148
+ yAxisLabel,
17149
+ AXIS_LABEL_MARGIN,
17150
+ yTickFormatter,
17151
+ minLeftDataValue,
17152
+ niceMaxLeft,
17153
+ rightKeysLength,
17154
+ measuredWidth,
17155
+ width,
17156
+ computedWidth
17157
+ }) {
17158
+ const finalChartRightMargin = chartMargin?.right ?? (rightKeysLength > 0 ? AXIS_LABEL_MARGIN : 30);
17159
+ const finalChartLeftMargin = chartMargin?.left ?? (yAxisLabel ? AXIS_LABEL_MARGIN : 0);
17160
+ const yAxisTickWidth = React33.useMemo(() => {
17161
+ const yAxisLabelStr = yAxisLabel === null || yAxisLabel === void 0 ? void 0 : String(yAxisLabel);
17162
+ return computeYAxisTickWidth(
17163
+ chartMargin?.left,
17164
+ yAxisLabelStr,
17165
+ AXIS_LABEL_MARGIN,
17166
+ yTickFormatter,
17167
+ minLeftDataValue,
17168
+ niceMaxLeft
17169
+ );
17170
+ }, [
17171
+ chartMargin?.left,
17172
+ yAxisLabel,
17173
+ AXIS_LABEL_MARGIN,
17174
+ yTickFormatter,
17175
+ minLeftDataValue,
17176
+ niceMaxLeft
17177
+ ]);
17178
+ const effectiveChartWidth = typeof width === "number" ? width : measuredWidth ? Math.max(0, measuredWidth - 32) : computedWidth;
17179
+ const chartInnerWidth = effectiveChartWidth - finalChartLeftMargin - finalChartRightMargin;
17180
+ const leftYAxisLabelDx = -Math.max(12, Math.round(yAxisTickWidth / 2));
17181
+ const rightYAxisLabelDx = Math.max(12, Math.round(finalChartRightMargin / 2));
17182
+ return {
17183
+ finalChartRightMargin,
17184
+ finalChartLeftMargin,
17185
+ yAxisTickWidth,
17186
+ effectiveChartWidth,
17187
+ chartInnerWidth,
17188
+ leftYAxisLabelDx,
17189
+ rightYAxisLabelDx
17190
+ };
17191
+ }
17192
+ function useSeriesOpacity(highlightedSeries) {
17193
+ return React33.useCallback(
17194
+ (key) => {
17195
+ return highlightedSeries.size > 0 ? highlightedSeries.has(key) ? 1 : 0.25 : 1;
17196
+ },
17197
+ [highlightedSeries]
17198
+ );
17199
+ }
16987
17200
  var filtersOrder = (mapperConfig, series) => {
16988
17201
  const seriesOrder = [];
16989
17202
  if (series) {
@@ -17107,10 +17320,37 @@ var fnContentLabelList = (p) => {
17107
17320
  return needsOutside ? null : true;
17108
17321
  };
17109
17322
 
17110
- // src/utils/calcDivision.ts
17111
- var calcDivision = (dividend, divisor) => {
17112
- return dividend / divisor;
17113
- };
17323
+ // src/components/ui/charts/hooks/useOpenTooltipForPeriod.ts
17324
+ function useOpenTooltipForPeriod({
17325
+ enableDraggableTooltips,
17326
+ processedData,
17327
+ activeTooltips,
17328
+ setActiveTooltips,
17329
+ maxTooltips,
17330
+ effectiveChartWidth
17331
+ }) {
17332
+ return React33.useCallback(
17333
+ (periodName) => {
17334
+ fnOpenTooltipForPeriod(
17335
+ enableDraggableTooltips,
17336
+ processedData,
17337
+ periodName,
17338
+ activeTooltips,
17339
+ setActiveTooltips,
17340
+ maxTooltips,
17341
+ effectiveChartWidth
17342
+ );
17343
+ },
17344
+ [
17345
+ enableDraggableTooltips,
17346
+ processedData,
17347
+ activeTooltips,
17348
+ effectiveChartWidth,
17349
+ maxTooltips,
17350
+ setActiveTooltips
17351
+ ]
17352
+ );
17353
+ }
17114
17354
  var DEFAULT_COLORS2 = ["#55af7d", "#8e68ff", "#2273e1"];
17115
17355
  var Chart = ({
17116
17356
  data,
@@ -17185,39 +17425,20 @@ var Chart = ({
17185
17425
  defaultEndIndex: timeSeriesConfig?.end,
17186
17426
  onRangeChange: timeSeriesConfig?.onRangeChange
17187
17427
  });
17188
- const processedData = React33.useMemo(() => {
17189
- const mapped = data.map((item) => ({
17190
- ...item,
17191
- name: String(item[xAxisConfig.dataKey] || "N/A")
17192
- }));
17193
- let result = mapped;
17194
- if (timeSeriesConfig) {
17195
- result = mapped.slice(startIndex, endIndex + 1);
17196
- }
17197
- return result;
17198
- }, [data, xAxisConfig.dataKey, timeSeriesConfig, startIndex, endIndex]);
17428
+ const processedData = useProcessedData({
17429
+ data,
17430
+ xAxisKey: xAxisConfig.dataKey,
17431
+ timeSeriesConfig,
17432
+ startIndex,
17433
+ endIndex
17434
+ });
17199
17435
  const seriesOrder = filtersOrder(mapperConfig, series);
17200
17436
  const allKeys = seriesOrder.map((s) => s.key).filter(Boolean);
17201
17437
  const finalColors = React33.useMemo(
17202
17438
  () => generateColorMap(allKeys, colors2, mapperConfig),
17203
17439
  [allKeys, colors2, mapperConfig]
17204
17440
  );
17205
- const biaxialConfigNormalized = React33.useMemo(() => {
17206
- if (!biaxial) return null;
17207
- if (typeof biaxial === "string") return { key: [biaxial] };
17208
- if (Array.isArray(biaxial)) return { key: biaxial };
17209
- return biaxial;
17210
- }, [biaxial]);
17211
- React33.useMemo(() => {
17212
- if (!biaxialConfigNormalized) return;
17213
- const leftLabelMissing = !yAxisLabel || String(yAxisLabel).trim() === "";
17214
- const rightLabelMissing = !biaxialConfigNormalized.label || String(biaxialConfigNormalized.label).trim() === "";
17215
- if (leftLabelMissing || rightLabelMissing) {
17216
- throw new Error(
17217
- "When using `biaxial`, you must provide both `yAxisLabel` (left axis) and `biaxial.label` (right axis)."
17218
- );
17219
- }
17220
- }, [biaxialConfigNormalized, yAxisLabel]);
17441
+ const biaxialConfigNormalized = useBiaxial(biaxial, yAxisLabel);
17221
17442
  const rightKeys = React33.useMemo(
17222
17443
  () => biaxialConfigNormalized?.key ?? [],
17223
17444
  [biaxialConfigNormalized]
@@ -17272,12 +17493,7 @@ var Chart = ({
17272
17493
  setActiveTooltips
17273
17494
  }
17274
17495
  );
17275
- const getSeriesOpacity = React33.useCallback(
17276
- (key) => {
17277
- return highlightedSeries.size > 0 ? highlightedSeries.has(key) ? 1 : 0.25 : 1;
17278
- },
17279
- [highlightedSeries]
17280
- );
17496
+ const getSeriesOpacity = useSeriesOpacity(highlightedSeries);
17281
17497
  const finalValueFormatter = React33.useMemo(
17282
17498
  () => createValueFormatter(valueFormatter, formatBR),
17283
17499
  [valueFormatter, formatBR]
@@ -17288,51 +17504,36 @@ var Chart = ({
17288
17504
  );
17289
17505
  const AXIS_LABEL_MARGIN = 56;
17290
17506
  const CONTAINER_PADDING_LEFT = -6;
17291
- const finalChartRightMargin = chartMargin?.right ?? (rightKeys.length > 0 ? AXIS_LABEL_MARGIN : 30);
17292
- const finalChartLeftMargin = chartMargin?.left ?? (yAxisLabel ? AXIS_LABEL_MARGIN : 0);
17293
- const yAxisTickWidth = React33.useMemo(() => {
17294
- return computeYAxisTickWidth(
17295
- chartMargin?.left,
17296
- yAxisLabel,
17297
- AXIS_LABEL_MARGIN,
17298
- yTickFormatter,
17299
- minLeftDataValue,
17300
- niceMaxLeft
17301
- );
17302
- }, [
17303
- chartMargin?.left,
17507
+ const HORIZONTAL_PADDING_CLASS = "px-24";
17508
+ const teste = "pl-24 pr-4";
17509
+ const {
17510
+ finalChartRightMargin,
17511
+ finalChartLeftMargin,
17512
+ yAxisTickWidth,
17513
+ effectiveChartWidth,
17514
+ chartInnerWidth,
17515
+ leftYAxisLabelDx,
17516
+ rightYAxisLabelDx
17517
+ } = useChartLayout({
17518
+ chartMargin,
17304
17519
  yAxisLabel,
17520
+ AXIS_LABEL_MARGIN,
17305
17521
  yTickFormatter,
17306
17522
  minLeftDataValue,
17307
- niceMaxLeft
17308
- ]);
17309
- const HORIZONTAL_PADDING_CLASS = "px-24";
17310
- const teste = "pl-24 pr-4";
17311
- const effectiveChartWidth = typeof width === "number" ? width : measuredWidth ? Math.max(0, measuredWidth - 32) : computedWidth;
17312
- const chartInnerWidth = effectiveChartWidth - finalChartLeftMargin - finalChartRightMargin;
17313
- const leftYAxisLabelDx = -Math.max(12, Math.round(yAxisTickWidth / 2));
17314
- const rightYAxisLabelDx = Math.max(12, Math.round(finalChartRightMargin / 2));
17315
- const openTooltipForPeriod = React33.useCallback(
17316
- (periodName) => {
17317
- fnOpenTooltipForPeriod(
17318
- enableDraggableTooltips,
17319
- processedData,
17320
- periodName,
17321
- activeTooltips,
17322
- setActiveTooltips,
17323
- maxTooltips,
17324
- effectiveChartWidth
17325
- );
17326
- },
17327
- [
17328
- enableDraggableTooltips,
17329
- processedData,
17330
- activeTooltips,
17331
- effectiveChartWidth,
17332
- maxTooltips,
17333
- setActiveTooltips
17334
- ]
17335
- );
17523
+ niceMaxLeft,
17524
+ rightKeysLength: rightKeys.length,
17525
+ measuredWidth,
17526
+ width,
17527
+ computedWidth
17528
+ });
17529
+ const openTooltipForPeriod = useOpenTooltipForPeriod({
17530
+ enableDraggableTooltips,
17531
+ processedData,
17532
+ activeTooltips,
17533
+ setActiveTooltips,
17534
+ maxTooltips,
17535
+ effectiveChartWidth
17536
+ });
17336
17537
  if (!data && !isLoading) return null;
17337
17538
  if (isLoading) {
17338
17539
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -17347,128 +17548,65 @@ var Chart = ({
17347
17548
  );
17348
17549
  }
17349
17550
  if (Array.isArray(data) && data.length === 0) {
17350
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
17351
- /* @__PURE__ */ jsxRuntime.jsx(
17352
- NoData_default,
17353
- {
17354
- title,
17355
- paddingLeft: CONTAINER_PADDING_LEFT + finalChartLeftMargin,
17356
- height
17357
- }
17358
- ),
17359
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { height: 0 }, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: effectiveChartWidth, height, children: [
17360
- xAxisLabel && /* @__PURE__ */ jsxRuntime.jsx(
17361
- "text",
17362
- {
17363
- x: effectiveChartWidth - 40,
17364
- y: height - 10,
17365
- fontSize: 12,
17366
- fill: "hsl(var(--muted-foreground))",
17367
- fontWeight: 500,
17368
- textAnchor: "end",
17369
- children: xAxisLabel
17370
- }
17371
- ),
17372
- yAxisLabel && /* @__PURE__ */ jsxRuntime.jsx(
17373
- "text",
17374
- {
17375
- x: 20,
17376
- y: 40,
17377
- fontSize: 12,
17378
- fill: "hsl(var(--muted-foreground))",
17379
- fontWeight: 500,
17380
- textAnchor: "start",
17381
- transform: `rotate(-90 20 40)`,
17382
- children: yAxisLabel
17383
- }
17384
- )
17385
- ] }) })
17386
- ] });
17551
+ return /* @__PURE__ */ jsxRuntime.jsx(
17552
+ NoData_default,
17553
+ {
17554
+ title,
17555
+ paddingLeft: CONTAINER_PADDING_LEFT + finalChartLeftMargin,
17556
+ height
17557
+ }
17558
+ );
17387
17559
  }
17388
17560
  return /* @__PURE__ */ jsxRuntime.jsxs(
17389
17561
  "div",
17390
17562
  {
17391
17563
  ref: wrapperRef,
17392
17564
  className: cn(
17393
- "w-full overflow-hidden min-w-0 rounded-lg border-border",
17565
+ "w-full overflow-hidden min-w-0 rounded-lg border-border h-full",
17394
17566
  className
17395
17567
  ),
17396
17568
  children: [
17397
17569
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg bg-card relative w-full max-w-full min-w-0 py-1", children: [
17398
- title && /* @__PURE__ */ jsxRuntime.jsx(
17399
- "div",
17570
+ /* @__PURE__ */ jsxRuntime.jsx(
17571
+ ChartHeader,
17400
17572
  {
17401
- className: cn(
17402
- "w-full flex items-center mt-3 mb-2",
17403
- HORIZONTAL_PADDING_CLASS,
17404
- titlePosition === "center" && "justify-center",
17405
- titlePosition === "right" && "justify-end",
17406
- titlePosition === "left" && "justify-start"
17407
- ),
17408
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[1.4rem] font-semibold text-foreground", children: title })
17573
+ title,
17574
+ titlePosition,
17575
+ HORIZONTAL_PADDING_CLASS,
17576
+ customLegend,
17577
+ data,
17578
+ allKeys,
17579
+ processedData,
17580
+ finalColors,
17581
+ mapperConfig,
17582
+ finalValueFormatter,
17583
+ formatBR
17409
17584
  }
17410
17585
  ),
17411
- customLegend && !!data.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("px-6 mb-2", HORIZONTAL_PADDING_CLASS), children: /* @__PURE__ */ jsxRuntime.jsx(
17412
- ChartTotalLegend_default,
17586
+ allKeys.length > 0 && (enableHighlights || enableShowOnly) && /* @__PURE__ */ jsxRuntime.jsx(
17587
+ ChartControls,
17413
17588
  {
17414
- items: allKeys.map((key) => {
17415
- const values = processedData.map(
17416
- (d) => Number(d[key] || 0)
17417
- );
17418
- const total = values.reduce((a, b) => a + b, 0);
17419
- const first = values[0] || 0;
17420
- const last = values[values.length - 1] || 0;
17421
- const trendValue = first !== 0 ? Math.round((last - first) / first * 100) : 0;
17422
- const formattedTotal = finalValueFormatter ? finalValueFormatter({
17423
- value: total,
17424
- formattedValue: String(total)
17425
- }) : new Intl.NumberFormat(formatBR ? "pt-BR" : "en-US").format(
17426
- total
17427
- );
17428
- return {
17429
- label: mapperConfig[key]?.label || key,
17430
- value: formattedTotal,
17431
- color: finalColors[key],
17432
- trend: {
17433
- value: Math.abs(trendValue),
17434
- positive: trendValue >= 0,
17435
- neutral: trendValue === 0
17436
- }
17437
- };
17438
- })
17589
+ allKeys,
17590
+ mapperConfig,
17591
+ finalColors,
17592
+ highlightedSeries,
17593
+ toggleHighlight,
17594
+ showOnlyHighlighted,
17595
+ setShowOnlyHighlighted,
17596
+ highlightedSeriesSize: highlightedSeries.size,
17597
+ clearHighlights,
17598
+ enableHighlights,
17599
+ enableShowOnly,
17600
+ enablePeriodsDropdown,
17601
+ enableDraggableTooltips,
17602
+ processedData,
17603
+ onOpenPeriod: openTooltipForPeriod,
17604
+ rightOffset: finalChartRightMargin,
17605
+ activePeriods,
17606
+ containerClass: cn("flex items-center gap-2", teste),
17607
+ containerWidth: chartInnerWidth
17439
17608
  }
17440
- ) }),
17441
- allKeys.length > 0 && (enableHighlights || enableShowOnly) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex items-center gap-2", teste), children: [
17442
- enableHighlights && /* @__PURE__ */ jsxRuntime.jsx(
17443
- Highlights_default,
17444
- {
17445
- allKeys,
17446
- mapperConfig,
17447
- finalColors,
17448
- highlightedSeries,
17449
- toggleHighlight,
17450
- containerWidth: chartInnerWidth
17451
- }
17452
- ),
17453
- enableShowOnly && /* @__PURE__ */ jsxRuntime.jsx(
17454
- ShowOnly_default,
17455
- {
17456
- showOnlyHighlighted,
17457
- setShowOnlyHighlighted,
17458
- highlightedSeriesSize: highlightedSeries.size,
17459
- clearHighlights
17460
- }
17461
- ),
17462
- enablePeriodsDropdown && enableDraggableTooltips && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
17463
- PeriodsDropdown_default,
17464
- {
17465
- processedData,
17466
- onOpenPeriod: openTooltipForPeriod,
17467
- rightOffset: finalChartRightMargin,
17468
- activePeriods
17469
- }
17470
- ) })
17471
- ] }),
17609
+ ),
17472
17610
  !(allKeys.length > 0 && (enableHighlights || enableShowOnly)) && enablePeriodsDropdown && enableDraggableTooltips && /* @__PURE__ */ jsxRuntime.jsx(
17473
17611
  "div",
17474
17612
  {
@@ -17490,7 +17628,7 @@ var Chart = ({
17490
17628
  )
17491
17629
  }
17492
17630
  ),
17493
- /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxRuntime.jsxs(
17631
+ /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height, className: "h-full", children: /* @__PURE__ */ jsxRuntime.jsxs(
17494
17632
  recharts.ComposedChart,
17495
17633
  {
17496
17634
  data: processedData,
@@ -17707,12 +17845,6 @@ var Chart = ({
17707
17845
  );
17708
17846
  }
17709
17847
  if (s.type === "line") {
17710
- const lineFormatter = (props) => {
17711
- const numValue = typeof props.value === "number" ? props.value : typeof props.value === "string" ? parseFloat(props.value) : 0;
17712
- const percentage = calcDivision(numValue, 100);
17713
- const formattedPercentage = typeof percentage === "number" ? percentage.toFixed(1).replace(".", ",") : String(percentage).replace(".", ",");
17714
- return `${formattedPercentage}%`;
17715
- };
17716
17848
  return /* @__PURE__ */ jsxRuntime.jsx(
17717
17849
  recharts.Line,
17718
17850
  {
@@ -17734,7 +17866,7 @@ var Chart = ({
17734
17866
  content: pillLabelRenderer_default(
17735
17867
  color,
17736
17868
  "filled",
17737
- lineFormatter
17869
+ (props) => formatLinePercentage(props.value)
17738
17870
  ),
17739
17871
  offset: 14
17740
17872
  }
@@ -17849,109 +17981,493 @@ var Chart = ({
17849
17981
  );
17850
17982
  };
17851
17983
  var Chart_default = Chart;
17852
- var defaultData = [
17853
- { name: "Vendas", value: 4e3 },
17854
- { name: "Marketing", value: 3e3 },
17855
- { name: "Desenvolvimento", value: 2e3 },
17856
- { name: "Suporte", value: 1e3 },
17857
- { name: "Outros", value: 800 }
17858
- ];
17859
- var DEFAULT_COLORS3 = [
17860
- "#55af7d",
17861
- // verde do projeto
17862
- "#8e68ff",
17863
- // roxo do projeto
17864
- "#2273e1",
17865
- // azul do projeto
17866
- "#f59e0b",
17867
- // amarelo complementar
17868
- "#ef4444",
17869
- // vermelho complementar
17870
- "#8b5cf6",
17871
- // roxo claro
17872
- "#06b6d4",
17873
- // ciano
17874
- "#84cc16"
17875
- // verde lima
17876
- ];
17877
- var RADIAN = Math.PI / 180;
17878
- var renderCustomizedLabel = ({
17879
- cx = 0,
17880
- cy = 0,
17881
- midAngle = 0,
17882
- innerRadius = 0,
17883
- outerRadius = 0,
17884
- percent = 0
17885
- }) => {
17886
- const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
17887
- const x = cx + radius * Math.cos(-midAngle * RADIAN);
17888
- const y = cy + radius * Math.sin(-midAngle * RADIAN);
17889
- return /* @__PURE__ */ jsxRuntime.jsx(
17890
- "text",
17891
- {
17892
- x,
17893
- y,
17894
- fill: "white",
17895
- textAnchor: x > cx ? "start" : "end",
17896
- dominantBaseline: "central",
17897
- fontSize: 12,
17898
- fontWeight: "600",
17899
- children: `${(percent * 100).toFixed(0)}%`
17900
- }
17901
- );
17902
- };
17903
- var CustomPieChart = ({
17904
- data = defaultData,
17984
+ var DEFAULT_COLORS3 = ["#0d1136", "#666655", "#1a1a1a"];
17985
+ var HorizontalChart = ({
17986
+ data,
17987
+ series,
17905
17988
  className,
17906
- height = 400,
17989
+ height = 500,
17907
17990
  width = "100%",
17908
- colors: colors2,
17991
+ colors: colors2 = DEFAULT_COLORS3,
17992
+ gridColor,
17993
+ showGrid = true,
17909
17994
  showTooltip = true,
17910
17995
  showLegend = true,
17911
- showLabels = true,
17912
- innerRadius = 0,
17913
- outerRadius = 120,
17914
- centerX = "50%",
17915
- centerY = "50%"
17996
+ title,
17997
+ titlePosition = "left",
17998
+ showLabels = false,
17999
+ labelsVisibility = { bar: true },
18000
+ xAxis,
18001
+ xAxisLabel,
18002
+ yAxisLabel,
18003
+ labelMap,
18004
+ valueFormatter,
18005
+ categoryFormatter,
18006
+ enableHighlights = false,
18007
+ enableShowOnly = false,
18008
+ enablePeriodsDropdown = false,
18009
+ enableDraggableTooltips = false,
18010
+ showTooltipTotal = false,
18011
+ periodLabel = "Per\xEDodo",
18012
+ maxTooltips = 5,
18013
+ formatBR = false,
18014
+ legendUppercase = false,
18015
+ chartMargin,
18016
+ isLoading = false,
18017
+ customLegend,
18018
+ orderBy
17916
18019
  }) => {
17917
- const finalColors = colors2 || DEFAULT_COLORS3;
17918
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full rounded-lg bg-card p-4", className), children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width, height, children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.PieChart, { children: [
17919
- /* @__PURE__ */ jsxRuntime.jsx(
17920
- recharts.Pie,
18020
+ const { xAxisConfig, mapperConfig } = React33.useMemo(() => {
18021
+ return fnSmartConfig({ xAxis, data, labelMap });
18022
+ }, [data, xAxis, labelMap]);
18023
+ const {
18024
+ highlightedSeries,
18025
+ showOnlyHighlighted,
18026
+ toggleHighlight,
18027
+ setShowOnlyHighlighted,
18028
+ clearHighlights
18029
+ } = useChartHighlights();
18030
+ const { wrapperRef, measuredWidth } = useChartDimensions();
18031
+ const {
18032
+ activeTooltips,
18033
+ toggleTooltip,
18034
+ onTooltipPositionChange,
18035
+ setActiveTooltips
18036
+ } = useChartTooltips(maxTooltips);
18037
+ React33.useEffect(() => {
18038
+ if (highlightedSeries.size === 0 && showOnlyHighlighted) {
18039
+ setShowOnlyHighlighted(false);
18040
+ }
18041
+ }, [highlightedSeries, showOnlyHighlighted, setShowOnlyHighlighted]);
18042
+ const processedData = React33.useMemo(() => {
18043
+ const mapped = data.map((item) => ({
18044
+ ...item,
18045
+ name: String(item[xAxisConfig.dataKey] || "N/A")
18046
+ }));
18047
+ if (orderBy && mapped.length > 0) {
18048
+ return [...mapped].sort((a, b) => {
18049
+ const valueA = Number(a[orderBy]) || 0;
18050
+ const valueB = Number(b[orderBy]) || 0;
18051
+ return valueB - valueA;
18052
+ });
18053
+ }
18054
+ return mapped;
18055
+ }, [data, xAxisConfig.dataKey, orderBy]);
18056
+ const seriesOrder = filtersOrder(mapperConfig, series);
18057
+ const allKeys = seriesOrder.map((s) => s.key).filter(Boolean);
18058
+ const finalColors = React33.useMemo(
18059
+ () => generateColorMap(allKeys, colors2, mapperConfig),
18060
+ [allKeys, colors2, mapperConfig]
18061
+ );
18062
+ const activePeriods = React33.useMemo(
18063
+ () => activeTooltips.map((t) => adaptDataForTooltip(t.data, xAxisConfig.dataKey).name),
18064
+ [activeTooltips, xAxisConfig.dataKey]
18065
+ );
18066
+ const maxDataValue = React33.useMemo(() => {
18067
+ return getMaxDataValue(processedData, allKeys);
18068
+ }, [processedData, allKeys]);
18069
+ const minDataValue = React33.useMemo(() => {
18070
+ return getMinDataValue(processedData, allKeys);
18071
+ }, [processedData, allKeys]);
18072
+ const niceMax = React33.useMemo(() => computeNiceMax(maxDataValue), [maxDataValue]);
18073
+ const { handleChartClick, handleBarClick } = useChartClick({
18074
+ enableDraggableTooltips,
18075
+ xAxisDataKey: xAxisConfig.dataKey,
18076
+ toggleTooltip,
18077
+ setActiveTooltips
18078
+ });
18079
+ const getSeriesOpacity = React33.useCallback(
18080
+ (key) => {
18081
+ return highlightedSeries.size > 0 ? highlightedSeries.has(key) ? 1 : 0.25 : 1;
18082
+ },
18083
+ [highlightedSeries]
18084
+ );
18085
+ const finalValueFormatter = React33.useMemo(
18086
+ () => createValueFormatter(valueFormatter, formatBR),
18087
+ [valueFormatter, formatBR]
18088
+ );
18089
+ const yTickFormatter = React33.useMemo(
18090
+ () => createYTickFormatter(finalValueFormatter),
18091
+ [finalValueFormatter]
18092
+ );
18093
+ const CONTAINER_PADDING_LEFT = -6;
18094
+ const finalChartRightMargin = chartMargin?.right ?? 0;
18095
+ const finalChartLeftMargin = chartMargin?.left ?? 0;
18096
+ const HORIZONTAL_PADDING_CLASS = "px-6";
18097
+ const effectiveChartWidth = typeof width === "number" ? width : measuredWidth ? Math.max(0, measuredWidth - 32) : 800;
18098
+ const chartInnerWidth = effectiveChartWidth - finalChartLeftMargin - finalChartRightMargin;
18099
+ const openTooltipForPeriod = React33.useCallback(
18100
+ (periodName) => {
18101
+ fnOpenTooltipForPeriod(
18102
+ enableDraggableTooltips,
18103
+ processedData,
18104
+ periodName,
18105
+ activeTooltips,
18106
+ setActiveTooltips,
18107
+ maxTooltips,
18108
+ effectiveChartWidth
18109
+ );
18110
+ },
18111
+ [
18112
+ enableDraggableTooltips,
18113
+ processedData,
18114
+ activeTooltips,
18115
+ effectiveChartWidth,
18116
+ maxTooltips,
18117
+ setActiveTooltips
18118
+ ]
18119
+ );
18120
+ if (!data && !isLoading) return null;
18121
+ if (isLoading) {
18122
+ return /* @__PURE__ */ jsxRuntime.jsx(
18123
+ NoData_default,
17921
18124
  {
17922
- data,
17923
- cx: centerX,
17924
- cy: centerY,
17925
- labelLine: false,
17926
- label: showLabels ? renderCustomizedLabel : false,
17927
- outerRadius,
17928
- innerRadius,
17929
- fill: "#8884d8",
17930
- dataKey: "value",
17931
- children: data.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
17932
- recharts.Cell,
17933
- {
17934
- fill: finalColors[index % finalColors.length]
17935
- },
17936
- `cell-${entry.name}-${index}`
17937
- ))
18125
+ title,
18126
+ isLoading: true,
18127
+ loadingMessage: typeof title === "string" ? `${title} \u2014 Carregando` : "Carregando",
18128
+ paddingLeft: CONTAINER_PADDING_LEFT + finalChartLeftMargin,
18129
+ height
17938
18130
  }
17939
- ),
17940
- showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
17941
- recharts.Tooltip,
18131
+ );
18132
+ }
18133
+ if (Array.isArray(data) && data.length === 0) {
18134
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
18135
+ NoData_default,
17942
18136
  {
17943
- contentStyle: {
17944
- backgroundColor: "hsl(var(--popover))",
17945
- border: "1px solid hsl(var(--border))",
17946
- borderRadius: "6px",
17947
- color: "hsl(var(--popover-foreground))"
17948
- }
18137
+ title,
18138
+ paddingLeft: CONTAINER_PADDING_LEFT + finalChartLeftMargin,
18139
+ height
17949
18140
  }
17950
- ),
17951
- showLegend && /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {})
17952
- ] }) }) });
18141
+ ) });
18142
+ }
18143
+ return /* @__PURE__ */ jsxRuntime.jsxs(
18144
+ "div",
18145
+ {
18146
+ ref: wrapperRef,
18147
+ className: cn(
18148
+ "w-full overflow-hidden min-w-0 rounded-lg border-border",
18149
+ className
18150
+ ),
18151
+ children: [
18152
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg bg-card relative w-full max-w-full min-w-0 py-1", children: [
18153
+ title && /* @__PURE__ */ jsxRuntime.jsx(
18154
+ "div",
18155
+ {
18156
+ className: cn(
18157
+ "w-full flex items-center mt-3 mb-2",
18158
+ HORIZONTAL_PADDING_CLASS,
18159
+ titlePosition === "center" && "justify-center",
18160
+ titlePosition === "right" && "justify-end",
18161
+ titlePosition === "left" && "justify-start"
18162
+ ),
18163
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[1.4rem] font-semibold text-foreground", children: title })
18164
+ }
18165
+ ),
18166
+ customLegend && !!data.length && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("px-6 mb-2", HORIZONTAL_PADDING_CLASS), children: /* @__PURE__ */ jsxRuntime.jsx(
18167
+ ChartTotalLegend_default,
18168
+ {
18169
+ items: allKeys.map((key) => {
18170
+ const values = processedData.map(
18171
+ (d) => Number(d[key] || 0)
18172
+ );
18173
+ const total = values.reduce((a, b) => a + b, 0);
18174
+ const first = values[0] || 0;
18175
+ const last = values[values.length - 1] || 0;
18176
+ const trendValue = first !== 0 ? Math.round((last - first) / first * 100) : 0;
18177
+ const formattedTotal = finalValueFormatter ? finalValueFormatter({
18178
+ value: total,
18179
+ formattedValue: String(total)
18180
+ }) : new Intl.NumberFormat(formatBR ? "pt-BR" : "en-US").format(
18181
+ total
18182
+ );
18183
+ return {
18184
+ label: mapperConfig[key]?.label || key,
18185
+ value: formattedTotal,
18186
+ color: finalColors[key],
18187
+ trend: {
18188
+ value: Math.abs(trendValue),
18189
+ positive: trendValue >= 0,
18190
+ neutral: trendValue === 0
18191
+ }
18192
+ };
18193
+ })
18194
+ }
18195
+ ) }),
18196
+ allKeys.length > 0 && (enableHighlights || enableShowOnly) && /* @__PURE__ */ jsxRuntime.jsxs(
18197
+ "div",
18198
+ {
18199
+ className: cn("flex items-center gap-2", HORIZONTAL_PADDING_CLASS),
18200
+ children: [
18201
+ enableHighlights && /* @__PURE__ */ jsxRuntime.jsx(
18202
+ Highlights_default,
18203
+ {
18204
+ allKeys,
18205
+ mapperConfig,
18206
+ finalColors,
18207
+ highlightedSeries,
18208
+ toggleHighlight,
18209
+ containerWidth: chartInnerWidth
18210
+ }
18211
+ ),
18212
+ enableShowOnly && /* @__PURE__ */ jsxRuntime.jsx(
18213
+ ShowOnly_default,
18214
+ {
18215
+ showOnlyHighlighted,
18216
+ setShowOnlyHighlighted,
18217
+ highlightedSeriesSize: highlightedSeries.size,
18218
+ clearHighlights
18219
+ }
18220
+ ),
18221
+ enablePeriodsDropdown && enableDraggableTooltips && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "ml-auto flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
18222
+ PeriodsDropdown_default,
18223
+ {
18224
+ processedData,
18225
+ onOpenPeriod: openTooltipForPeriod,
18226
+ rightOffset: finalChartRightMargin,
18227
+ activePeriods
18228
+ }
18229
+ ) })
18230
+ ]
18231
+ }
18232
+ ),
18233
+ !(allKeys.length > 0 && (enableHighlights || enableShowOnly)) && enablePeriodsDropdown && enableDraggableTooltips && /* @__PURE__ */ jsxRuntime.jsx(
18234
+ "div",
18235
+ {
18236
+ className: cn(
18237
+ "w-full flex justify-end mb-2",
18238
+ HORIZONTAL_PADDING_CLASS
18239
+ ),
18240
+ children: /* @__PURE__ */ jsxRuntime.jsx(
18241
+ PeriodsDropdown_default,
18242
+ {
18243
+ processedData,
18244
+ onOpenPeriod: openTooltipForPeriod,
18245
+ rightOffset: finalChartRightMargin
18246
+ }
18247
+ )
18248
+ }
18249
+ ),
18250
+ showLegend && /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("mb-3", HORIZONTAL_PADDING_CLASS), children: /* @__PURE__ */ jsxRuntime.jsx(
18251
+ HorizontalLegend_default,
18252
+ {
18253
+ allKeys,
18254
+ mapperConfig,
18255
+ finalColors,
18256
+ labelMap,
18257
+ legendUppercase
18258
+ }
18259
+ ) }),
18260
+ /* @__PURE__ */ jsxRuntime.jsx(
18261
+ "div",
18262
+ {
18263
+ className: cn(
18264
+ "overflow-y-auto overflow-x-hidden px-6",
18265
+ "scrollbar-thin scrollbar-thumb-muted scrollbar-track-transparent mb-2"
18266
+ ),
18267
+ style: {
18268
+ maxHeight: height
18269
+ },
18270
+ children: /* @__PURE__ */ jsxRuntime.jsx(
18271
+ recharts.ResponsiveContainer,
18272
+ {
18273
+ width: "100%",
18274
+ height: Math.max(height, processedData.length * 50),
18275
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
18276
+ recharts.ComposedChart,
18277
+ {
18278
+ layout: "vertical",
18279
+ data: processedData,
18280
+ height: Math.max(height, processedData.length * 50),
18281
+ margin: {
18282
+ top: 10,
18283
+ right: finalChartRightMargin,
18284
+ left: 55 + finalChartLeftMargin,
18285
+ bottom: 10
18286
+ },
18287
+ onClick: handleChartClick,
18288
+ children: [
18289
+ showGrid && /* @__PURE__ */ jsxRuntime.jsx(
18290
+ recharts.CartesianGrid,
18291
+ {
18292
+ strokeDasharray: "3 3",
18293
+ stroke: gridColor || "hsl(var(--muted-foreground))",
18294
+ opacity: 0.5
18295
+ }
18296
+ ),
18297
+ /* @__PURE__ */ jsxRuntime.jsx(
18298
+ recharts.XAxis,
18299
+ {
18300
+ type: "number",
18301
+ stroke: "hsl(var(--muted-foreground))",
18302
+ fontSize: 12,
18303
+ tickLine: false,
18304
+ orientation: "top",
18305
+ axisLine: false,
18306
+ tickFormatter: yTickFormatter,
18307
+ domain: [Math.min(minDataValue, 0), niceMax],
18308
+ label: yAxisLabel ? {
18309
+ value: yAxisLabel,
18310
+ position: "insideTopRight",
18311
+ offset: -1,
18312
+ style: {
18313
+ fontSize: 12,
18314
+ fill: "hsl(var(--muted-foreground))",
18315
+ fontWeight: 500
18316
+ }
18317
+ } : void 0
18318
+ }
18319
+ ),
18320
+ /* @__PURE__ */ jsxRuntime.jsx(
18321
+ recharts.YAxis,
18322
+ {
18323
+ type: "category",
18324
+ dataKey: xAxisConfig.dataKey,
18325
+ stroke: "hsl(var(--muted-foreground))",
18326
+ fontSize: 12,
18327
+ tickLine: true,
18328
+ minTickGap: 24,
18329
+ axisLine: true,
18330
+ tickFormatter: (value) => {
18331
+ if (categoryFormatter)
18332
+ return categoryFormatter(value);
18333
+ if (xAxisConfig.valueFormatter)
18334
+ return xAxisConfig.valueFormatter(value);
18335
+ return String(value ?? "");
18336
+ },
18337
+ label: xAxisLabel ? {
18338
+ value: xAxisLabel,
18339
+ angle: -90,
18340
+ position: "insideTopLeft",
18341
+ style: {
18342
+ fontSize: 12,
18343
+ fill: "hsl(var(--muted-foreground))",
18344
+ fontWeight: 500,
18345
+ textAnchor: "middle"
18346
+ }
18347
+ } : void 0
18348
+ }
18349
+ ),
18350
+ showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
18351
+ recharts.Tooltip,
18352
+ {
18353
+ content: showTooltipTotal ? /* @__PURE__ */ jsxRuntime.jsx(
18354
+ TooltipWithTotal_default,
18355
+ {
18356
+ finalColors,
18357
+ valueFormatter: finalValueFormatter,
18358
+ categoryFormatter,
18359
+ periodLabel
18360
+ }
18361
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
18362
+ TooltipSimple_default,
18363
+ {
18364
+ finalColors,
18365
+ valueFormatter: finalValueFormatter,
18366
+ categoryFormatter,
18367
+ periodLabel
18368
+ }
18369
+ ),
18370
+ cursor: { fill: "hsl(var(--muted))", opacity: 0.1 }
18371
+ }
18372
+ ),
18373
+ seriesOrder.map((s) => {
18374
+ if (showOnlyHighlighted && !highlightedSeries.has(s.key))
18375
+ return null;
18376
+ const { label, color, key } = fnBuildConfigData(
18377
+ s,
18378
+ mapperConfig,
18379
+ labelMap,
18380
+ finalColors,
18381
+ [],
18382
+ null
18383
+ );
18384
+ if (s.type === "bar") {
18385
+ return /* @__PURE__ */ jsxRuntime.jsx(
18386
+ recharts.Bar,
18387
+ {
18388
+ dataKey: key,
18389
+ name: label,
18390
+ fill: color,
18391
+ radius: [0, 4, 4, 0],
18392
+ onClick: handleBarClick,
18393
+ className: "cursor-pointer",
18394
+ style: { opacity: getSeriesOpacity(key) },
18395
+ activeBar: /* @__PURE__ */ jsxRuntime.jsx(
18396
+ recharts.Rectangle,
18397
+ {
18398
+ fill: color,
18399
+ stroke: color,
18400
+ strokeWidth: 2,
18401
+ opacity: 0.8
18402
+ }
18403
+ ),
18404
+ children: showLabels && labelsVisibility.bar !== false && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsxRuntime.jsx(
18405
+ recharts.LabelList,
18406
+ {
18407
+ dataKey: key,
18408
+ content: (props) => {
18409
+ const inside = renderInsideBarLabel(
18410
+ color,
18411
+ finalValueFormatter
18412
+ );
18413
+ return inside(props);
18414
+ },
18415
+ offset: 0
18416
+ }
18417
+ ) : null
18418
+ },
18419
+ `bar-${key}`
18420
+ );
18421
+ }
18422
+ return null;
18423
+ })
18424
+ ]
18425
+ }
18426
+ )
18427
+ }
18428
+ )
18429
+ }
18430
+ )
18431
+ ] }),
18432
+ enableDraggableTooltips && activeTooltips.map((tooltip) => /* @__PURE__ */ jsxRuntime.jsx(
18433
+ DraggableTooltip_default,
18434
+ {
18435
+ id: tooltip.id,
18436
+ data: adaptDataForTooltip(tooltip.data, xAxisConfig.dataKey),
18437
+ position: tooltip.position,
18438
+ title,
18439
+ dataKeys: allKeys,
18440
+ finalColors,
18441
+ highlightedSeries,
18442
+ toggleHighlight,
18443
+ showOnlyHighlighted,
18444
+ onClose: (id) => setActiveTooltips((prev) => prev.filter((t) => t.id !== id)),
18445
+ onPositionChange: onTooltipPositionChange,
18446
+ periodLabel,
18447
+ dataLabel: "Dados do Per\xEDodo",
18448
+ valueFormatter: finalValueFormatter,
18449
+ categoryFormatter,
18450
+ globalTooltipCount: activeTooltips.length,
18451
+ onCloseAll: () => window.dispatchEvent(new Event("closeAllTooltips")),
18452
+ closeAllButtonPosition: "top-center",
18453
+ closeAllButtonVariant: "floating"
18454
+ },
18455
+ tooltip.id
18456
+ )),
18457
+ enableDraggableTooltips && activeTooltips.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(
18458
+ CloseAllButton_default,
18459
+ {
18460
+ count: activeTooltips.length,
18461
+ onCloseAll: () => window.dispatchEvent(new Event("closeAllTooltips")),
18462
+ position: "top-center",
18463
+ variant: "floating"
18464
+ }
18465
+ )
18466
+ ]
18467
+ }
18468
+ );
17953
18469
  };
17954
- var PieChart_default = CustomPieChart;
18470
+ var HorizontalChart_default = HorizontalChart;
17955
18471
  var TimeSeries = ({
17956
18472
  data,
17957
18473
  xAxis,
@@ -18260,6 +18776,8 @@ exports.CarouselNextBase = CarouselNextBase;
18260
18776
  exports.CarouselPreviousBase = CarouselPreviousBase;
18261
18777
  exports.ChangeButton = ChangeButton;
18262
18778
  exports.Chart = Chart_default;
18779
+ exports.ChartControls = ChartControls;
18780
+ exports.ChartHeader = ChartHeader;
18263
18781
  exports.ChartTotalLegend = ChartTotalLegend_default;
18264
18782
  exports.CheckButton = CheckButton;
18265
18783
  exports.CheckboxBase = CheckboxBase;
@@ -18364,6 +18882,7 @@ exports.FileUploader = FileUploader;
18364
18882
  exports.FilterButton = FilterButton;
18365
18883
  exports.HideButton = HideButton;
18366
18884
  exports.Highlights = Highlights_default;
18885
+ exports.HorizontalChart = HorizontalChart_default;
18367
18886
  exports.HorizontalLegend = HorizontalLegend_default;
18368
18887
  exports.HoverCardBase = HoverCardBase;
18369
18888
  exports.HoverCardContentBase = HoverCardContentBase;
@@ -18414,7 +18933,6 @@ exports.NoData = NoData_default;
18414
18933
  exports.NotificationButton = NotificationButton;
18415
18934
  exports.NumericInput = NumericInput;
18416
18935
  exports.PeriodsDropdown = PeriodsDropdown_default;
18417
- exports.PieChart = PieChart_default;
18418
18936
  exports.PopoverAnchorBase = PopoverAnchorBase;
18419
18937
  exports.PopoverBase = PopoverBase;
18420
18938
  exports.PopoverContentBase = PopoverContentBase;
@@ -18537,6 +19055,7 @@ exports.detectDataFields = detectDataFields;
18537
19055
  exports.detectXAxis = detectXAxis;
18538
19056
  exports.display12HourValue = display12HourValue;
18539
19057
  exports.formatFieldName = formatFieldName;
19058
+ exports.formatLinePercentage = formatLinePercentage;
18540
19059
  exports.generateAdditionalColors = generateAdditionalColors;
18541
19060
  exports.generateColorMap = generateColorMap;
18542
19061
  exports.getAgendaEventsForDay = getAgendaEventsForDay;
@@ -18585,11 +19104,13 @@ exports.setSeconds = setSeconds;
18585
19104
  exports.sortEvents = sortEvents;
18586
19105
  exports.sortEventsAgenda = sortEventsAgenda;
18587
19106
  exports.toast = toast;
19107
+ exports.useBiaxial = useBiaxial;
18588
19108
  exports.useCalendarDnd = useCalendarDnd;
18589
19109
  exports.useCalendarDndAgenda = useCalendarDndAgenda;
18590
19110
  exports.useChartClick = useChartClick;
18591
19111
  exports.useChartDimensions = useChartDimensions;
18592
19112
  exports.useChartHighlights = useChartHighlights;
19113
+ exports.useChartLayout = useChartLayout;
18593
19114
  exports.useChartMinMax = useChartMinMax;
18594
19115
  exports.useChartTooltips = useChartTooltips;
18595
19116
  exports.useCurrentTimeIndicator = useCurrentTimeIndicator;
@@ -18598,6 +19119,9 @@ exports.useDrag = useDrag;
18598
19119
  exports.useEventVisibility = useEventVisibility;
18599
19120
  exports.useEventVisibilityAgenda = useEventVisibilityAgenda;
18600
19121
  exports.useIsMobile = useIsMobile;
19122
+ exports.useOpenTooltipForPeriod = useOpenTooltipForPeriod;
19123
+ exports.useProcessedData = useProcessedData;
19124
+ exports.useSeriesOpacity = useSeriesOpacity;
18601
19125
  exports.useTheme = useTheme;
18602
19126
  exports.useTimeSeriesRange = useTimeSeriesRange;
18603
19127
  exports.visualForItem = visualForItem;