@mlw-packages/react-components 1.9.6 → 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: [
@@ -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
  }
@@ -18149,7 +18281,7 @@ var HorizontalChart = ({
18149
18281
  margin: {
18150
18282
  top: 10,
18151
18283
  right: finalChartRightMargin,
18152
- left: finalChartLeftMargin,
18284
+ left: 55 + finalChartLeftMargin,
18153
18285
  bottom: 10
18154
18286
  },
18155
18287
  onClick: handleChartClick,
@@ -18192,9 +18324,9 @@ var HorizontalChart = ({
18192
18324
  dataKey: xAxisConfig.dataKey,
18193
18325
  stroke: "hsl(var(--muted-foreground))",
18194
18326
  fontSize: 12,
18195
- tickLine: false,
18196
- axisLine: false,
18197
- width: 125,
18327
+ tickLine: true,
18328
+ minTickGap: 24,
18329
+ axisLine: true,
18198
18330
  tickFormatter: (value) => {
18199
18331
  if (categoryFormatter)
18200
18332
  return categoryFormatter(value);
@@ -18336,109 +18468,6 @@ var HorizontalChart = ({
18336
18468
  );
18337
18469
  };
18338
18470
  var HorizontalChart_default = HorizontalChart;
18339
- var defaultData = [
18340
- { name: "Vendas", value: 4e3 },
18341
- { name: "Marketing", value: 3e3 },
18342
- { name: "Desenvolvimento", value: 2e3 },
18343
- { name: "Suporte", value: 1e3 },
18344
- { name: "Outros", value: 800 }
18345
- ];
18346
- var DEFAULT_COLORS4 = [
18347
- "#55af7d",
18348
- // verde do projeto
18349
- "#8e68ff",
18350
- // roxo do projeto
18351
- "#2273e1",
18352
- // azul do projeto
18353
- "#f59e0b",
18354
- // amarelo complementar
18355
- "#ef4444",
18356
- // vermelho complementar
18357
- "#8b5cf6",
18358
- // roxo claro
18359
- "#06b6d4",
18360
- // ciano
18361
- "#84cc16"
18362
- // verde lima
18363
- ];
18364
- var RADIAN = Math.PI / 180;
18365
- var renderCustomizedLabel = ({
18366
- cx = 0,
18367
- cy = 0,
18368
- midAngle = 0,
18369
- innerRadius = 0,
18370
- outerRadius = 0,
18371
- percent = 0
18372
- }) => {
18373
- const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
18374
- const x = cx + radius * Math.cos(-midAngle * RADIAN);
18375
- const y = cy + radius * Math.sin(-midAngle * RADIAN);
18376
- return /* @__PURE__ */ jsxRuntime.jsx(
18377
- "text",
18378
- {
18379
- x,
18380
- y,
18381
- fill: "white",
18382
- textAnchor: x > cx ? "start" : "end",
18383
- dominantBaseline: "central",
18384
- fontSize: 12,
18385
- fontWeight: "600",
18386
- children: `${(percent * 100).toFixed(0)}%`
18387
- }
18388
- );
18389
- };
18390
- var CustomPieChart = ({
18391
- data = defaultData,
18392
- className,
18393
- height = 400,
18394
- width = "100%",
18395
- colors: colors2,
18396
- showTooltip = true,
18397
- showLegend = true,
18398
- showLabels = true,
18399
- innerRadius = 0,
18400
- outerRadius = 120,
18401
- centerX = "50%",
18402
- centerY = "50%"
18403
- }) => {
18404
- const finalColors = colors2 || DEFAULT_COLORS4;
18405
- 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: [
18406
- /* @__PURE__ */ jsxRuntime.jsx(
18407
- recharts.Pie,
18408
- {
18409
- data,
18410
- cx: centerX,
18411
- cy: centerY,
18412
- labelLine: false,
18413
- label: showLabels ? renderCustomizedLabel : false,
18414
- outerRadius,
18415
- innerRadius,
18416
- fill: "#8884d8",
18417
- dataKey: "value",
18418
- children: data.map((entry, index) => /* @__PURE__ */ jsxRuntime.jsx(
18419
- recharts.Cell,
18420
- {
18421
- fill: finalColors[index % finalColors.length]
18422
- },
18423
- `cell-${entry.name}-${index}`
18424
- ))
18425
- }
18426
- ),
18427
- showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
18428
- recharts.Tooltip,
18429
- {
18430
- contentStyle: {
18431
- backgroundColor: "hsl(var(--popover))",
18432
- border: "1px solid hsl(var(--border))",
18433
- borderRadius: "6px",
18434
- color: "hsl(var(--popover-foreground))"
18435
- }
18436
- }
18437
- ),
18438
- showLegend && /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {})
18439
- ] }) }) });
18440
- };
18441
- var PieChart_default = CustomPieChart;
18442
18471
  var TimeSeries = ({
18443
18472
  data,
18444
18473
  xAxis,
@@ -18747,6 +18776,8 @@ exports.CarouselNextBase = CarouselNextBase;
18747
18776
  exports.CarouselPreviousBase = CarouselPreviousBase;
18748
18777
  exports.ChangeButton = ChangeButton;
18749
18778
  exports.Chart = Chart_default;
18779
+ exports.ChartControls = ChartControls;
18780
+ exports.ChartHeader = ChartHeader;
18750
18781
  exports.ChartTotalLegend = ChartTotalLegend_default;
18751
18782
  exports.CheckButton = CheckButton;
18752
18783
  exports.CheckboxBase = CheckboxBase;
@@ -18902,7 +18933,6 @@ exports.NoData = NoData_default;
18902
18933
  exports.NotificationButton = NotificationButton;
18903
18934
  exports.NumericInput = NumericInput;
18904
18935
  exports.PeriodsDropdown = PeriodsDropdown_default;
18905
- exports.PieChart = PieChart_default;
18906
18936
  exports.PopoverAnchorBase = PopoverAnchorBase;
18907
18937
  exports.PopoverBase = PopoverBase;
18908
18938
  exports.PopoverContentBase = PopoverContentBase;
@@ -19025,6 +19055,7 @@ exports.detectDataFields = detectDataFields;
19025
19055
  exports.detectXAxis = detectXAxis;
19026
19056
  exports.display12HourValue = display12HourValue;
19027
19057
  exports.formatFieldName = formatFieldName;
19058
+ exports.formatLinePercentage = formatLinePercentage;
19028
19059
  exports.generateAdditionalColors = generateAdditionalColors;
19029
19060
  exports.generateColorMap = generateColorMap;
19030
19061
  exports.getAgendaEventsForDay = getAgendaEventsForDay;
@@ -19073,11 +19104,13 @@ exports.setSeconds = setSeconds;
19073
19104
  exports.sortEvents = sortEvents;
19074
19105
  exports.sortEventsAgenda = sortEventsAgenda;
19075
19106
  exports.toast = toast;
19107
+ exports.useBiaxial = useBiaxial;
19076
19108
  exports.useCalendarDnd = useCalendarDnd;
19077
19109
  exports.useCalendarDndAgenda = useCalendarDndAgenda;
19078
19110
  exports.useChartClick = useChartClick;
19079
19111
  exports.useChartDimensions = useChartDimensions;
19080
19112
  exports.useChartHighlights = useChartHighlights;
19113
+ exports.useChartLayout = useChartLayout;
19081
19114
  exports.useChartMinMax = useChartMinMax;
19082
19115
  exports.useChartTooltips = useChartTooltips;
19083
19116
  exports.useCurrentTimeIndicator = useCurrentTimeIndicator;
@@ -19086,6 +19119,9 @@ exports.useDrag = useDrag;
19086
19119
  exports.useEventVisibility = useEventVisibility;
19087
19120
  exports.useEventVisibilityAgenda = useEventVisibilityAgenda;
19088
19121
  exports.useIsMobile = useIsMobile;
19122
+ exports.useOpenTooltipForPeriod = useOpenTooltipForPeriod;
19123
+ exports.useProcessedData = useProcessedData;
19124
+ exports.useSeriesOpacity = useSeriesOpacity;
19089
19125
  exports.useTheme = useTheme;
19090
19126
  exports.useTimeSeriesRange = useTimeSeriesRange;
19091
19127
  exports.visualForItem = visualForItem;