@mlw-packages/react-components 1.9.2 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -688,7 +688,7 @@ var DialogContentBase = React33__namespace.forwardRef(
688
688
  {
689
689
  ref,
690
690
  className: cn(
691
- "fixed left-[50%] top-[50%] z-50 w-lg grid translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg max-h-[100dvh] overflow-auto rounded-md border-border",
691
+ "fixed left-[50%] top-[50%] z-50 w-[90%] sm:w-lg grid translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg max-h-[100dvh] overflow-y-auto overflow-x-hidden rounded-md border-border",
692
692
  className
693
693
  ),
694
694
  "data-testid": dataTestId,
@@ -1954,21 +1954,28 @@ var CommandDialogBase = ({ children, open, ...props }) => {
1954
1954
  "command-dialog"
1955
1955
  ) }) }) });
1956
1956
  };
1957
- var CommandInputBase = React33__namespace.forwardRef(({ className, testid: dataTestId = "command-input", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center border-b px-3 border-border", "cmdk-input-wrapper": "", children: [
1958
- /* @__PURE__ */ jsxRuntime.jsx(react.MagnifyingGlassIcon, { className: "mr-2 h-4 w-4 shrink-0 text-primary" }),
1959
- /* @__PURE__ */ jsxRuntime.jsx(
1960
- cmdk.Command.Input,
1961
- {
1962
- ref,
1963
- className: cn(
1964
- "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none text-primary placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
1965
- className
1966
- ),
1967
- "data-testid": dataTestId,
1968
- ...props
1969
- }
1970
- )
1971
- ] }));
1957
+ var CommandInputBase = React33__namespace.forwardRef(({ className, testid: dataTestId = "command-input", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1958
+ "div",
1959
+ {
1960
+ className: "flex items-center border-b px-3 border-border",
1961
+ "cmdk-input-wrapper": "",
1962
+ children: [
1963
+ /* @__PURE__ */ jsxRuntime.jsx(react.MagnifyingGlassIcon, { className: "mr-2 h-4 w-4 shrink-0 text-primary" }),
1964
+ /* @__PURE__ */ jsxRuntime.jsx(
1965
+ cmdk.Command.Input,
1966
+ {
1967
+ ref,
1968
+ className: cn(
1969
+ "flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none text-primary placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
1970
+ className
1971
+ ),
1972
+ "data-testid": dataTestId,
1973
+ ...props
1974
+ }
1975
+ )
1976
+ ]
1977
+ }
1978
+ ));
1972
1979
  CommandInputBase.displayName = cmdk.Command.Input.displayName;
1973
1980
  var CommandListBase = React33__namespace.forwardRef(({ className, testid: dataTestId = "command-list", ...props }, ref) => {
1974
1981
  const listRef = React33__namespace.useRef(null);
@@ -1976,11 +1983,45 @@ var CommandListBase = React33__namespace.forwardRef(({ className, testid: dataTe
1976
1983
  const element = listRef.current;
1977
1984
  if (!element) return;
1978
1985
  const handleWheel = (e) => {
1986
+ const target = e.currentTarget;
1987
+ const { scrollTop, scrollHeight, clientHeight } = target;
1988
+ const isScrollingDown = e.deltaY > 0;
1989
+ const isScrollingUp = e.deltaY < 0;
1990
+ const isAtBottom = scrollTop + clientHeight >= scrollHeight - 1;
1991
+ const isAtTop = scrollTop <= 1;
1992
+ if (isScrollingDown && !isAtBottom || isScrollingUp && !isAtTop) {
1993
+ e.stopPropagation();
1994
+ }
1995
+ };
1996
+ let touchStartY = 0;
1997
+ const handleTouchStart = (e) => {
1998
+ touchStartY = e.touches[0].clientY;
1979
1999
  e.stopPropagation();
1980
2000
  };
2001
+ const handleTouchMove = (e) => {
2002
+ const target = e.currentTarget;
2003
+ const { scrollTop, scrollHeight, clientHeight } = target;
2004
+ const touchCurrentY = e.touches[0].clientY;
2005
+ const touchDeltaY = touchStartY - touchCurrentY;
2006
+ const isScrollingDown = touchDeltaY > 0;
2007
+ const isScrollingUp = touchDeltaY < 0;
2008
+ const isAtBottom = scrollTop + clientHeight >= scrollHeight - 1;
2009
+ const isAtTop = scrollTop <= 1;
2010
+ if (isScrollingDown && !isAtBottom || isScrollingUp && !isAtTop) {
2011
+ e.stopPropagation();
2012
+ } else if (isScrollingDown && isAtBottom || isScrollingUp && isAtTop) {
2013
+ e.preventDefault();
2014
+ }
2015
+ };
1981
2016
  element.addEventListener("wheel", handleWheel, { passive: false });
2017
+ element.addEventListener("touchstart", handleTouchStart, {
2018
+ passive: false
2019
+ });
2020
+ element.addEventListener("touchmove", handleTouchMove, { passive: false });
1982
2021
  return () => {
1983
2022
  element.removeEventListener("wheel", handleWheel);
2023
+ element.removeEventListener("touchmove", handleTouchMove);
2024
+ element.removeEventListener("touchstart", handleTouchStart);
1984
2025
  };
1985
2026
  }, []);
1986
2027
  const combinedRef = React33__namespace.useCallback(
@@ -2005,7 +2046,13 @@ var CommandListBase = React33__namespace.forwardRef(({ className, testid: dataTe
2005
2046
  "data-testid": dataTestId,
2006
2047
  style: {
2007
2048
  overscrollBehavior: "contain",
2008
- WebkitOverflowScrolling: "touch"
2049
+ WebkitOverflowScrolling: "touch",
2050
+ touchAction: "pan-y",
2051
+ scrollbarWidth: "thin",
2052
+ scrollbarColor: "hsl(var(--muted)) transparent",
2053
+ overflowY: "auto",
2054
+ willChange: "scroll-position",
2055
+ transform: "translateZ(0)"
2009
2056
  },
2010
2057
  ...props
2011
2058
  }
@@ -2083,6 +2130,7 @@ var PopoverContentBase = React33__namespace.forwardRef(
2083
2130
  align = "center",
2084
2131
  sideOffset = 4,
2085
2132
  testid: dataTestId = "popover-content",
2133
+ style,
2086
2134
  ...props
2087
2135
  }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
2088
2136
  PopoverPrimitive__namespace.Content,
@@ -2091,10 +2139,20 @@ var PopoverContentBase = React33__namespace.forwardRef(
2091
2139
  align,
2092
2140
  sideOffset,
2093
2141
  className: cn(
2094
- "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
2142
+ "z-[100] w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
2095
2143
  className
2096
2144
  ),
2097
2145
  "data-testid": dataTestId,
2146
+ style: {
2147
+ ...style,
2148
+ WebkitOverflowScrolling: "touch",
2149
+ overscrollBehavior: "contain",
2150
+ pointerEvents: "auto"
2151
+ },
2152
+ onWheel: (e) => {
2153
+ e.stopPropagation();
2154
+ props.onWheel?.(e);
2155
+ },
2098
2156
  onInteractOutside: (event) => {
2099
2157
  props.onInteractOutside?.(event);
2100
2158
  if (event.defaultPrevented) return;
@@ -2151,7 +2209,6 @@ function ComboboxBase({
2151
2209
  hideClear = false
2152
2210
  }) {
2153
2211
  const [open, setOpen] = React33.useState(false);
2154
- const isMobile = useIsMobile();
2155
2212
  return /* @__PURE__ */ jsxRuntime.jsxs(
2156
2213
  "div",
2157
2214
  {
@@ -2163,7 +2220,7 @@ function ComboboxBase({
2163
2220
  {
2164
2221
  open,
2165
2222
  onOpenChange: (v) => !disabled && setOpen(v),
2166
- modal: isMobile,
2223
+ modal: false,
2167
2224
  children: [
2168
2225
  /* @__PURE__ */ jsxRuntime.jsx(
2169
2226
  PopoverTriggerBase,
@@ -2895,7 +2952,7 @@ var SelectContentBase = React33__namespace.forwardRef(
2895
2952
  {
2896
2953
  ref,
2897
2954
  className: cn(
2898
- "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
2955
+ "relative z-50 max-h-96 overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md",
2899
2956
  className
2900
2957
  ),
2901
2958
  position,
@@ -5436,14 +5493,29 @@ var TableCaptionBase = React33__namespace.forwardRef(({ className, ...props }, r
5436
5493
  }
5437
5494
  ));
5438
5495
  TableCaptionBase.displayName = "TableCaptionBase";
5439
- var TabsBase = TabsPrimitive__namespace.Root;
5496
+ var TabsBase = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
5497
+ TabsPrimitive__namespace.Root,
5498
+ {
5499
+ ref,
5500
+ className: cn("w-full", className),
5501
+ ...props
5502
+ }
5503
+ ));
5504
+ TabsBase.displayName = TabsPrimitive__namespace.Root.displayName;
5440
5505
  var TabsListBase = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
5441
5506
  TabsPrimitive__namespace.List,
5442
5507
  {
5443
5508
  ref,
5444
5509
  className: cn(
5445
5510
  "relative flex w-full items-center justify-start gap-2 border-b border-border",
5446
- "bg-transparent",
5511
+ "bg-transparent overflow-x-auto",
5512
+ "scrollbar-thin scrollbar-thumb-muted-foreground/30 scrollbar-track-transparent",
5513
+ "hover:scrollbar-thumb-muted-foreground/50",
5514
+ "[&::-webkit-scrollbar]:h-1.5",
5515
+ "[&::-webkit-scrollbar-track]:bg-transparent",
5516
+ "[&::-webkit-scrollbar-thumb]:bg-muted-foreground/30",
5517
+ "[&::-webkit-scrollbar-thumb]:rounded-full",
5518
+ "hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/50",
5447
5519
  className
5448
5520
  ),
5449
5521
  ...props
@@ -8164,7 +8236,7 @@ function DateTimePicker({
8164
8236
  }
8165
8237
  ),
8166
8238
  /* @__PURE__ */ jsxRuntime.jsx(ErrorMessage_default, { error }),
8167
- /* @__PURE__ */ jsxRuntime.jsx(DialogContentBase, { className: "p-0 max-h-[95vh] w-[calc(100vw-24px)] sm:w-[calc(100vw-32px)] overflow-hidden flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto flex-1", children: renderPickerContent() }) })
8239
+ /* @__PURE__ */ jsxRuntime.jsx(DialogContentBase, { className: "p-0 max-h-[95vh] w-3/6 overflow-hidden flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto flex-1", children: renderPickerContent() }) })
8168
8240
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(PopoverBase, { open, onOpenChange: setOpen, children: [
8169
8241
  /* @__PURE__ */ jsxRuntime.jsx(
8170
8242
  PopoverTriggerBase,
@@ -10150,8 +10222,8 @@ function EventAgenda({
10150
10222
  setView(v);
10151
10223
  },
10152
10224
  items: selectItems,
10153
- className: "gap-2 px-3 py-1.5 max-[479px]:h-8",
10154
10225
  placeholder: viewLabel(view),
10226
+ className: "min-w-24",
10155
10227
  hideClear: true
10156
10228
  }
10157
10229
  ) })
@@ -10159,8 +10231,7 @@ function EventAgenda({
10159
10231
  /* @__PURE__ */ jsxRuntime.jsxs(
10160
10232
  "div",
10161
10233
  {
10162
- className: "flex flex-1 flex-col transition-all duration-200 ease-in-out",
10163
- "aria-live": "polite",
10234
+ className: "flex flex-col transition-all duration-200 ease-in-out",
10164
10235
  children: [
10165
10236
  view === "month" && /* @__PURE__ */ jsxRuntime.jsx(
10166
10237
  MonthViewAgenda,
@@ -14168,29 +14239,62 @@ var adaptDataForTooltip = (data, xAxisKey) => {
14168
14239
  };
14169
14240
  var createValueFormatter = (customFormatter, formatBR) => {
14170
14241
  const nf = new Intl.NumberFormat("pt-BR", {
14171
- minimumFractionDigits: 2,
14172
- maximumFractionDigits: 2
14242
+ minimumFractionDigits: 0,
14243
+ maximumFractionDigits: 0
14173
14244
  });
14245
+ const prefixFormats = ["R$", "$", "\u20AC", "\xA3"];
14246
+ const suffixFormats = ["%", "kg", "km", "m", "L", "un", "t", "h", "min", "s"];
14247
+ const getFormattedValue = (baseValue, format17) => {
14248
+ const trimmedFormat = format17.trim();
14249
+ if (prefixFormats.includes(trimmedFormat)) {
14250
+ return `${trimmedFormat} ${baseValue}`;
14251
+ }
14252
+ if (suffixFormats.includes(trimmedFormat)) {
14253
+ return `${baseValue}${trimmedFormat}`;
14254
+ }
14255
+ return `${baseValue} ${trimmedFormat}`;
14256
+ };
14174
14257
  if (customFormatter) {
14175
- if (formatBR) {
14176
- const wrapped = (props) => {
14177
- const { value, formattedValue } = props;
14258
+ if (typeof customFormatter === "object" && !Array.isArray(customFormatter)) {
14259
+ const formatterMap = customFormatter;
14260
+ return (props) => {
14261
+ const {
14262
+ value,
14263
+ formattedValue,
14264
+ dataKey: propsDataKey
14265
+ } = props;
14178
14266
  let num = NaN;
14179
14267
  if (typeof value === "number") num = value;
14180
14268
  else if (typeof value === "string" && value.trim() !== "") {
14181
14269
  const parsed = Number(value);
14182
14270
  num = Number.isNaN(parsed) ? NaN : parsed;
14183
14271
  }
14184
- const brFormatted = !Number.isNaN(num) ? nf.format(num) : String(formattedValue ?? value ?? "");
14185
- return customFormatter({
14186
- ...props,
14187
- formattedValue: brFormatted,
14188
- value: void 0
14189
- });
14272
+ const baseFormatted = formatBR && !Number.isNaN(num) ? nf.format(num) : String(formattedValue ?? value ?? "");
14273
+ const format17 = propsDataKey && formatterMap[propsDataKey] ? formatterMap[propsDataKey] : "";
14274
+ return format17 ? getFormattedValue(baseFormatted, format17) : baseFormatted;
14190
14275
  };
14191
- return wrapped;
14192
14276
  }
14193
- return customFormatter;
14277
+ if (typeof customFormatter === "function") {
14278
+ if (formatBR) {
14279
+ const wrapped = (props) => {
14280
+ const { value, formattedValue } = props;
14281
+ let num = NaN;
14282
+ if (typeof value === "number") num = value;
14283
+ else if (typeof value === "string" && value.trim() !== "") {
14284
+ const parsed = Number(value);
14285
+ num = Number.isNaN(parsed) ? NaN : parsed;
14286
+ }
14287
+ const brFormatted = !Number.isNaN(num) ? nf.format(num) : String(formattedValue ?? value ?? "");
14288
+ return customFormatter({
14289
+ ...props,
14290
+ formattedValue: brFormatted,
14291
+ value: void 0
14292
+ });
14293
+ };
14294
+ return wrapped;
14295
+ }
14296
+ return customFormatter;
14297
+ }
14194
14298
  }
14195
14299
  if (!formatBR) return void 0;
14196
14300
  const builtIn = (props) => {
@@ -14208,8 +14312,8 @@ var createValueFormatter = (customFormatter, formatBR) => {
14208
14312
  };
14209
14313
  var createYTickFormatter = (finalValueFormatter) => {
14210
14314
  const nf = new Intl.NumberFormat("pt-BR", {
14211
- minimumFractionDigits: 2,
14212
- maximumFractionDigits: 2
14315
+ minimumFractionDigits: 0,
14316
+ maximumFractionDigits: 0
14213
14317
  });
14214
14318
  const stripCurrency = (s) => String(s).replace(/^\s*R\$\s?/, "");
14215
14319
  if (finalValueFormatter) {
@@ -15719,7 +15823,7 @@ var Brush = ({
15719
15823
  xAxisKey,
15720
15824
  seriesOrder,
15721
15825
  finalColors,
15722
- brushHeight = 80,
15826
+ brushHeight = 40,
15723
15827
  brushColor,
15724
15828
  miniChartOpacity = 0.3
15725
15829
  }) => {
@@ -15943,16 +16047,76 @@ var ChartTotalLegend = ({ items }) => {
15943
16047
  ] }, index)) });
15944
16048
  };
15945
16049
  var ChartTotalLegend_default = ChartTotalLegend;
16050
+ var formatFieldName2 = (key) => {
16051
+ return key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase()).trim();
16052
+ };
16053
+ var HorizontalLegend = ({
16054
+ allKeys,
16055
+ mapperConfig,
16056
+ finalColors,
16057
+ labelMap,
16058
+ legendUppercase = false,
16059
+ orderBy,
16060
+ maxPeriodLabel,
16061
+ minPeriodLabel,
16062
+ className
16063
+ }) => {
16064
+ const formatLegendLabel = (key) => {
16065
+ const label = mapperConfig[key]?.label ?? labelMap?.[key] ?? formatFieldName2(key);
16066
+ return legendUppercase ? label.toUpperCase() : label;
16067
+ };
16068
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(className), children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 sm:gap-3 md:gap-4 flex-wrap", children: [
16069
+ allKeys.map((key) => {
16070
+ const displayLabel = formatLegendLabel(key);
16071
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 sm:gap-2", children: [
16072
+ /* @__PURE__ */ jsxRuntime.jsx(
16073
+ "div",
16074
+ {
16075
+ className: "w-2.5 h-2.5 sm:w-3 sm:h-3 rounded-sm flex-shrink-0",
16076
+ style: { backgroundColor: finalColors[key] }
16077
+ }
16078
+ ),
16079
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm tracking-[0] break-words", children: displayLabel })
16080
+ ] }, key);
16081
+ }),
16082
+ orderBy && maxPeriodLabel && minPeriodLabel && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 sm:gap-3 md:gap-4 w-full sm:w-auto justify-center mt-2 sm:mt-0 sm:ml-3 sm:pl-3 md:ml-4 md:pl-4 sm:border-l border-border", children: [
16083
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 sm:gap-1.5", children: [
16084
+ /* @__PURE__ */ jsxRuntime.jsx(
16085
+ react.FunnelSimpleIcon,
16086
+ {
16087
+ className: "w-3 h-3 sm:w-4 sm:h-4 text-green-600 flex-shrink-0",
16088
+ weight: "bold"
16089
+ }
16090
+ ),
16091
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm tracking-[0] font-medium truncate max-w-[120px] sm:max-w-none", children: maxPeriodLabel })
16092
+ ] }),
16093
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 sm:gap-1.5", children: [
16094
+ /* @__PURE__ */ jsxRuntime.jsx(
16095
+ react.FunnelSimpleIcon,
16096
+ {
16097
+ className: "w-3 h-3 sm:w-4 sm:h-4 text-red-600 rotate-180 flex-shrink-0",
16098
+ weight: "bold"
16099
+ }
16100
+ ),
16101
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm tracking-[0] font-medium truncate max-w-[120px] sm:max-w-none", children: minPeriodLabel })
16102
+ ] })
16103
+ ] })
16104
+ ] }) });
16105
+ };
16106
+ var HorizontalLegend_default = HorizontalLegend;
15946
16107
  var formatCompactNumber = (value) => {
15947
16108
  const isNegative = value < 0;
15948
16109
  const absValue = Math.abs(value);
15949
16110
  let formatted;
15950
16111
  if (absValue >= 1e9) {
15951
- formatted = (absValue / 1e9).toFixed(1).replace(/\.0$/, "") + "B";
16112
+ const billions = absValue / 1e9;
16113
+ formatted = (billions % 1 === 0 ? billions.toFixed(0) : billions.toFixed(1)) + "B";
15952
16114
  } else if (absValue >= 1e6) {
15953
- formatted = (absValue / 1e6).toFixed(1).replace(/\.0$/, "") + "M";
16115
+ const millions = absValue / 1e6;
16116
+ formatted = (millions % 1 === 0 ? millions.toFixed(0) : millions.toFixed(1)) + "M";
15954
16117
  } else if (absValue >= 1e3) {
15955
- formatted = (absValue / 1e3).toFixed(1).replace(/\.0$/, "") + " mil";
16118
+ const thousands = absValue / 1e3;
16119
+ formatted = (thousands % 1 === 0 ? thousands.toFixed(0) : thousands.toFixed(1)) + " mil";
15956
16120
  } else {
15957
16121
  try {
15958
16122
  const nf = new Intl.NumberFormat("pt-BR", {
@@ -16679,6 +16843,42 @@ function useTimeSeriesRange({
16679
16843
  handleMouseDown
16680
16844
  };
16681
16845
  }
16846
+ var useChartMinMax = ({
16847
+ processedData,
16848
+ orderBy,
16849
+ xAxisDataKey,
16850
+ categoryFormatter
16851
+ }) => {
16852
+ return React33.useMemo(() => {
16853
+ if (!processedData || processedData.length === 0 || !orderBy) {
16854
+ return {
16855
+ maxPeriodLabel: "",
16856
+ minPeriodLabel: ""
16857
+ };
16858
+ }
16859
+ let maxValue = -Infinity;
16860
+ let minValue = Infinity;
16861
+ let maxPeriodLabel = "";
16862
+ let minPeriodLabel = "";
16863
+ processedData.forEach((item) => {
16864
+ const value = Number(item[orderBy]) || 0;
16865
+ const periodName = String(item[xAxisDataKey] || "N/A");
16866
+ const formattedPeriod = categoryFormatter ? categoryFormatter(periodName) : periodName;
16867
+ if (value > maxValue) {
16868
+ maxValue = value;
16869
+ maxPeriodLabel = formattedPeriod;
16870
+ }
16871
+ if (value < minValue) {
16872
+ minValue = value;
16873
+ minPeriodLabel = formattedPeriod;
16874
+ }
16875
+ });
16876
+ return {
16877
+ maxPeriodLabel,
16878
+ minPeriodLabel
16879
+ };
16880
+ }, [processedData, orderBy, xAxisDataKey, categoryFormatter]);
16881
+ };
16682
16882
  var filtersOrder = (mapperConfig, series) => {
16683
16883
  const seriesOrder = [];
16684
16884
  if (series) {
@@ -16751,7 +16951,7 @@ var fnSmartConfig = ({ xAxis, data, labelMap }) => {
16751
16951
  return { xAxisConfig, mapperConfig };
16752
16952
  };
16753
16953
  var fnConfigRightKeys = (biaxialConfigNormalized, yTickFormatter, finalColors) => {
16754
- const decimals = typeof biaxialConfigNormalized?.decimals === "number" ? Math.max(0, Math.floor(biaxialConfigNormalized.decimals)) : 2;
16954
+ const decimals = typeof biaxialConfigNormalized?.decimals === "number" ? Math.max(0, Math.floor(biaxialConfigNormalized.decimals)) : 1;
16755
16955
  const rightTickFormatter = (v) => {
16756
16956
  if (biaxialConfigNormalized?.percentage) {
16757
16957
  const num = Number(String(v));
@@ -16801,6 +17001,11 @@ var fnContentLabelList = (p) => {
16801
17001
  const needsOutside = barHeight > 0 && barHeight < smallThreshold || barWidth > 0 && barWidth < smallThreshold;
16802
17002
  return needsOutside ? null : true;
16803
17003
  };
17004
+
17005
+ // src/utils/calcDivision.ts
17006
+ var calcDivision = (dividend, divisor) => {
17007
+ return dividend / divisor;
17008
+ };
16804
17009
  var DEFAULT_COLORS2 = ["#55af7d", "#8e68ff", "#2273e1"];
16805
17010
  var Chart = ({
16806
17011
  data,
@@ -16837,7 +17042,9 @@ var Chart = ({
16837
17042
  isLoading = false,
16838
17043
  timeSeries,
16839
17044
  timeSeriesLegend,
16840
- customLegend
17045
+ customLegend,
17046
+ horizontal = false,
17047
+ orderBy
16841
17048
  }) => {
16842
17049
  const { xAxisConfig, mapperConfig } = React33.useMemo(() => {
16843
17050
  return fnSmartConfig({ xAxis, data, labelMap });
@@ -16873,16 +17080,38 @@ var Chart = ({
16873
17080
  defaultEndIndex: timeSeriesConfig?.end,
16874
17081
  onRangeChange: timeSeriesConfig?.onRangeChange
16875
17082
  });
17083
+ const { maxPeriodLabel, minPeriodLabel } = useChartMinMax({
17084
+ processedData: data,
17085
+ orderBy,
17086
+ xAxisDataKey: xAxisConfig.dataKey,
17087
+ categoryFormatter
17088
+ });
16876
17089
  const processedData = React33.useMemo(() => {
16877
17090
  const mapped = data.map((item) => ({
16878
17091
  ...item,
16879
17092
  name: String(item[xAxisConfig.dataKey] || "N/A")
16880
17093
  }));
17094
+ let result = mapped;
16881
17095
  if (timeSeriesConfig) {
16882
- return mapped.slice(startIndex, endIndex + 1);
17096
+ result = mapped.slice(startIndex, endIndex + 1);
17097
+ }
17098
+ if (orderBy && horizontal) {
17099
+ result = [...result].sort((a, b) => {
17100
+ const valueA = Number(a[orderBy]) || 0;
17101
+ const valueB = Number(b[orderBy]) || 0;
17102
+ return valueB - valueA;
17103
+ });
16883
17104
  }
16884
- return mapped;
16885
- }, [data, xAxisConfig.dataKey, timeSeriesConfig, startIndex, endIndex]);
17105
+ return result;
17106
+ }, [
17107
+ data,
17108
+ xAxisConfig.dataKey,
17109
+ timeSeriesConfig,
17110
+ startIndex,
17111
+ endIndex,
17112
+ orderBy,
17113
+ horizontal
17114
+ ]);
16886
17115
  const seriesOrder = filtersOrder(mapperConfig, series);
16887
17116
  const allKeys = seriesOrder.map((s) => s.key).filter(Boolean);
16888
17117
  const finalColors = React33.useMemo(
@@ -17048,7 +17277,10 @@ var Chart = ({
17048
17277
  "div",
17049
17278
  {
17050
17279
  ref: wrapperRef,
17051
- className: cn("w-full overflow-hidden min-w-0 rounded-lg border-border", className),
17280
+ className: cn(
17281
+ "w-full overflow-hidden min-w-0 rounded-lg border-border",
17282
+ className
17283
+ ),
17052
17284
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg bg-card relative w-full max-w-full min-w-0 py-1", children: [
17053
17285
  title && /* @__PURE__ */ jsxRuntime.jsx(
17054
17286
  "div",
@@ -17145,303 +17377,416 @@ var Chart = ({
17145
17377
  )
17146
17378
  }
17147
17379
  ),
17148
- /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height, children: /* @__PURE__ */ jsxRuntime.jsxs(
17149
- recharts.ComposedChart,
17380
+ showLegend && horizontal && /* @__PURE__ */ jsxRuntime.jsx(
17381
+ HorizontalLegend_default,
17150
17382
  {
17151
- data: processedData,
17152
- height,
17153
- margin: {
17154
- top: 10,
17155
- right: finalChartRightMargin,
17156
- left: finalChartLeftMargin,
17157
- bottom: 10
17383
+ allKeys,
17384
+ mapperConfig,
17385
+ finalColors,
17386
+ labelMap,
17387
+ legendUppercase,
17388
+ orderBy,
17389
+ maxPeriodLabel,
17390
+ minPeriodLabel,
17391
+ className: cn(HORIZONTAL_PADDING_CLASS)
17392
+ }
17393
+ ),
17394
+ /* @__PURE__ */ jsxRuntime.jsx(
17395
+ "div",
17396
+ {
17397
+ className: cn(
17398
+ horizontal && "overflow-y-auto overflow-x-hidden px-6",
17399
+ horizontal && "scrollbar-thin scrollbar-thumb-muted scrollbar-track-transparent"
17400
+ ),
17401
+ style: {
17402
+ maxHeight: horizontal ? height : void 0
17158
17403
  },
17159
- onClick: handleChartClick,
17160
- children: [
17161
- /* @__PURE__ */ jsxRuntime.jsx("defs", { children: seriesOrder.filter((s) => s.type === "area").map((s) => {
17162
- const key = s.key;
17163
- const color = finalColors[key];
17164
- return /* @__PURE__ */ jsxRuntime.jsxs(
17165
- "linearGradient",
17404
+ children: /* @__PURE__ */ jsxRuntime.jsx(
17405
+ recharts.ResponsiveContainer,
17406
+ {
17407
+ width: "100%",
17408
+ height: horizontal ? Math.max(height, processedData.length * 50) : height,
17409
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
17410
+ recharts.ComposedChart,
17166
17411
  {
17167
- id: `gradient-${key}`,
17168
- x1: "0",
17169
- y1: "0",
17170
- x2: "0",
17171
- y2: "0.8",
17412
+ data: processedData,
17413
+ height: horizontal ? Math.max(height, processedData.length * 50) : height,
17414
+ layout: horizontal ? "vertical" : "horizontal",
17415
+ margin: {
17416
+ top: 10,
17417
+ right: finalChartRightMargin,
17418
+ left: finalChartLeftMargin,
17419
+ bottom: 10
17420
+ },
17421
+ onClick: handleChartClick,
17172
17422
  children: [
17173
- /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "0%", stopColor: color, stopOpacity: 0.8 }),
17174
- /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "90%", stopColor: color, stopOpacity: 0.1 })
17175
- ]
17176
- },
17177
- `gradient-${key}`
17178
- );
17179
- }) }),
17180
- showGrid && /* @__PURE__ */ jsxRuntime.jsx(
17181
- recharts.CartesianGrid,
17182
- {
17183
- strokeDasharray: "3 3",
17184
- stroke: gridColor || "hsl(var(--muted-foreground))",
17185
- opacity: 0.5
17186
- }
17187
- ),
17188
- /* @__PURE__ */ jsxRuntime.jsx(
17189
- recharts.XAxis,
17190
- {
17191
- dataKey: xAxisConfig.dataKey,
17192
- stroke: "hsl(var(--muted-foreground))",
17193
- fontSize: 12,
17194
- tickLine: false,
17195
- axisLine: false,
17196
- tickFormatter: (value) => {
17197
- if (categoryFormatter)
17198
- return categoryFormatter(value);
17199
- if (xAxisConfig.valueFormatter)
17200
- return xAxisConfig.valueFormatter(value);
17201
- return String(value ?? "");
17202
- },
17203
- label: xAxisLabel ? {
17204
- value: xAxisLabel,
17205
- position: "insideBottomRight",
17206
- offset: -5,
17207
- style: {
17208
- fontSize: 12,
17209
- fill: "hsl(var(--muted-foreground))",
17210
- fontWeight: 500
17211
- }
17212
- } : void 0
17213
- }
17214
- ),
17215
- /* @__PURE__ */ jsxRuntime.jsx(
17216
- recharts.YAxis,
17217
- {
17218
- yAxisId: "left",
17219
- width: yAxisTickWidth,
17220
- stroke: "hsl(var(--muted-foreground))",
17221
- fontSize: 12,
17222
- tickLine: false,
17223
- axisLine: false,
17224
- tickFormatter: yTickFormatter,
17225
- domain: [Math.min(minLeftDataValue, 0), niceMaxLeft],
17226
- tickCount: 6,
17227
- label: yAxisLabel ? {
17228
- value: yAxisLabel,
17229
- angle: -90,
17230
- position: "left",
17231
- dx: leftYAxisLabelDx,
17232
- style: {
17233
- fontSize: 12,
17234
- fill: "hsl(var(--muted-foreground))",
17235
- fontWeight: 500,
17236
- textAnchor: "middle"
17237
- }
17238
- } : void 0
17239
- }
17240
- ),
17241
- minLeftDataValue < 0 && /* @__PURE__ */ jsxRuntime.jsx(
17242
- recharts.ReferenceLine,
17243
- {
17244
- y: 0,
17245
- yAxisId: "left",
17246
- stroke: "hsl(var(--muted-foreground))",
17247
- strokeWidth: 1,
17248
- strokeDasharray: "4 4"
17249
- }
17250
- ),
17251
- rightKeys.length > 0 && (() => {
17252
- const { rightAxisColor, rightTickFormatter } = fnConfigRightKeys(biaxialConfigNormalized, yTickFormatter, finalColors);
17253
- return /* @__PURE__ */ jsxRuntime.jsx(
17254
- recharts.YAxis,
17255
- {
17256
- yAxisId: "right",
17257
- width: finalChartRightMargin,
17258
- orientation: "right",
17259
- stroke: "hsl(var(--muted-foreground))",
17260
- fontSize: 12,
17261
- tickLine: false,
17262
- axisLine: false,
17263
- tick: { fill: rightAxisColor },
17264
- tickFormatter: rightTickFormatter,
17265
- domain: [Math.min(minRightDataValue, 0), niceMaxRight],
17266
- tickCount: 6,
17267
- label: biaxialConfigNormalized?.label ? {
17268
- value: biaxialConfigNormalized.label,
17269
- angle: -90,
17270
- position: "right",
17271
- dx: rightYAxisLabelDx,
17272
- style: {
17273
- fontSize: 12,
17274
- fill: "hsl(var(--muted-foreground))",
17275
- fontWeight: 500,
17276
- textAnchor: "middle"
17277
- }
17278
- } : void 0
17279
- }
17280
- );
17281
- })(),
17282
- showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
17283
- recharts.Tooltip,
17284
- {
17285
- content: showTooltipTotal ? /* @__PURE__ */ jsxRuntime.jsx(
17286
- TooltipWithTotal_default,
17287
- {
17288
- finalColors,
17289
- valueFormatter: finalValueFormatter,
17290
- categoryFormatter,
17291
- periodLabel
17292
- }
17293
- ) : /* @__PURE__ */ jsxRuntime.jsx(
17294
- TooltipSimple_default,
17295
- {
17296
- finalColors,
17297
- valueFormatter: finalValueFormatter,
17298
- categoryFormatter,
17299
- periodLabel
17300
- }
17301
- ),
17302
- cursor: { fill: "hsl(var(--muted))", opacity: 0.1 }
17303
- }
17304
- ),
17305
- showLegend && /* @__PURE__ */ jsxRuntime.jsx(
17306
- recharts.Legend,
17307
- {
17308
- iconSize: 12,
17309
- formatter: (value) => {
17310
- return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tracking-[0]", children: fnFormatterValueLegend(
17311
- value,
17312
- mapperConfig,
17313
- labelMap,
17314
- legendUppercase
17315
- ) });
17316
- }
17317
- }
17318
- ),
17319
- seriesOrder.map((s) => {
17320
- if (showOnlyHighlighted && !highlightedSeries.has(s.key))
17321
- return null;
17322
- const { label, color, key } = fnBuildConfigData(
17323
- s,
17324
- mapperConfig,
17325
- labelMap,
17326
- finalColors,
17327
- rightKeys,
17328
- biaxialConfigNormalized
17329
- );
17330
- if (s.type === "bar") {
17331
- return /* @__PURE__ */ jsxRuntime.jsx(
17332
- recharts.Bar,
17333
- {
17334
- dataKey: key,
17335
- yAxisId: rightKeys.includes(key) ? "right" : "left",
17336
- name: label,
17337
- fill: color,
17338
- radius: [4, 4, 0, 0],
17339
- onClick: handleBarClick,
17340
- className: "cursor-pointer",
17341
- style: { opacity: getSeriesOpacity(key) },
17342
- activeBar: /* @__PURE__ */ jsxRuntime.jsx(
17343
- recharts.Rectangle,
17423
+ /* @__PURE__ */ jsxRuntime.jsx("defs", { children: seriesOrder.filter((s) => s.type === "area").map((s) => {
17424
+ const key = s.key;
17425
+ const color = finalColors[key];
17426
+ return /* @__PURE__ */ jsxRuntime.jsxs(
17427
+ "linearGradient",
17428
+ {
17429
+ id: `gradient-${key}`,
17430
+ x1: "0",
17431
+ y1: "0",
17432
+ x2: "0",
17433
+ y2: "0.8",
17434
+ children: [
17435
+ /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "0%", stopColor: color, stopOpacity: 0.8 }),
17436
+ /* @__PURE__ */ jsxRuntime.jsx(
17437
+ "stop",
17438
+ {
17439
+ offset: "90%",
17440
+ stopColor: color,
17441
+ stopOpacity: 0.1
17442
+ }
17443
+ )
17444
+ ]
17445
+ },
17446
+ `gradient-${key}`
17447
+ );
17448
+ }) }),
17449
+ showGrid && /* @__PURE__ */ jsxRuntime.jsx(
17450
+ recharts.CartesianGrid,
17344
17451
  {
17345
- fill: color,
17346
- stroke: color,
17347
- strokeWidth: 2,
17348
- opacity: 0.8
17452
+ strokeDasharray: "3 3",
17453
+ stroke: gridColor || "hsl(var(--muted-foreground))",
17454
+ opacity: 0.5
17349
17455
  }
17350
17456
  ),
17351
- children: showLabels && labelsVisibility.bar !== false && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsxRuntime.jsx(
17352
- recharts.LabelList,
17457
+ horizontal ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17458
+ /* @__PURE__ */ jsxRuntime.jsx(
17459
+ recharts.XAxis,
17460
+ {
17461
+ type: "number",
17462
+ orientation: "top",
17463
+ stroke: "hsl(var(--muted-foreground))",
17464
+ fontSize: 12,
17465
+ tickLine: false,
17466
+ axisLine: false,
17467
+ tickFormatter: yTickFormatter,
17468
+ domain: [Math.min(minLeftDataValue, 0), niceMaxLeft],
17469
+ tickCount: 6,
17470
+ label: yAxisLabel ? {
17471
+ value: yAxisLabel,
17472
+ position: "insideTopRight",
17473
+ offset: -5,
17474
+ style: {
17475
+ fontSize: 12,
17476
+ fill: "hsl(var(--muted-foreground))",
17477
+ fontWeight: 500
17478
+ }
17479
+ } : void 0
17480
+ }
17481
+ ),
17482
+ /* @__PURE__ */ jsxRuntime.jsx(
17483
+ recharts.YAxis,
17484
+ {
17485
+ type: "category",
17486
+ dataKey: xAxisConfig.dataKey,
17487
+ yAxisId: "left",
17488
+ width: yAxisTickWidth,
17489
+ stroke: "hsl(var(--muted-foreground))",
17490
+ fontSize: 12,
17491
+ tickLine: false,
17492
+ axisLine: false,
17493
+ tickFormatter: (value) => {
17494
+ if (categoryFormatter)
17495
+ return categoryFormatter(value);
17496
+ if (xAxisConfig.valueFormatter)
17497
+ return xAxisConfig.valueFormatter(
17498
+ value
17499
+ );
17500
+ return String(value ?? "");
17501
+ },
17502
+ label: xAxisLabel ? {
17503
+ value: xAxisLabel,
17504
+ angle: -90,
17505
+ position: "insideTop",
17506
+ dx: leftYAxisLabelDx,
17507
+ style: {
17508
+ fontSize: 12,
17509
+ fill: "hsl(var(--muted-foreground))",
17510
+ fontWeight: 500,
17511
+ textAnchor: "middle"
17512
+ }
17513
+ } : void 0
17514
+ }
17515
+ )
17516
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17517
+ /* @__PURE__ */ jsxRuntime.jsx(
17518
+ recharts.XAxis,
17519
+ {
17520
+ dataKey: xAxisConfig.dataKey,
17521
+ stroke: "hsl(var(--muted-foreground))",
17522
+ fontSize: 12,
17523
+ tickLine: false,
17524
+ axisLine: false,
17525
+ tickFormatter: (value) => {
17526
+ if (categoryFormatter)
17527
+ return categoryFormatter(value);
17528
+ if (xAxisConfig.valueFormatter)
17529
+ return xAxisConfig.valueFormatter(
17530
+ value
17531
+ );
17532
+ return String(value ?? "");
17533
+ },
17534
+ label: xAxisLabel ? {
17535
+ value: xAxisLabel,
17536
+ position: "insideBottomRight",
17537
+ offset: -5,
17538
+ style: {
17539
+ fontSize: 12,
17540
+ fill: "hsl(var(--muted-foreground))",
17541
+ fontWeight: 500
17542
+ }
17543
+ } : void 0
17544
+ }
17545
+ ),
17546
+ /* @__PURE__ */ jsxRuntime.jsx(
17547
+ recharts.YAxis,
17548
+ {
17549
+ yAxisId: "left",
17550
+ width: yAxisTickWidth,
17551
+ stroke: "hsl(var(--muted-foreground))",
17552
+ fontSize: 12,
17553
+ tickLine: false,
17554
+ axisLine: false,
17555
+ tickFormatter: yTickFormatter,
17556
+ domain: [Math.min(minLeftDataValue, 0), niceMaxLeft],
17557
+ tickCount: 6,
17558
+ label: yAxisLabel ? {
17559
+ value: yAxisLabel,
17560
+ angle: -90,
17561
+ position: "left",
17562
+ dx: leftYAxisLabelDx,
17563
+ style: {
17564
+ fontSize: 12,
17565
+ fill: "hsl(var(--muted-foreground))",
17566
+ fontWeight: 500,
17567
+ textAnchor: "middle"
17568
+ }
17569
+ } : void 0
17570
+ }
17571
+ )
17572
+ ] }),
17573
+ minLeftDataValue < 0 && /* @__PURE__ */ jsxRuntime.jsx(
17574
+ recharts.ReferenceLine,
17353
17575
  {
17354
- dataKey: key,
17355
- content: (props) => {
17356
- if (!fnContentLabelList(props))
17357
- return null;
17358
- const inside = renderInsideBarLabel(
17359
- color,
17360
- finalValueFormatter
17361
- );
17362
- return inside(props);
17363
- },
17364
- offset: 0
17576
+ y: 0,
17577
+ yAxisId: "left",
17578
+ stroke: "hsl(var(--muted-foreground))",
17579
+ strokeWidth: 1,
17580
+ strokeDasharray: "4 4"
17365
17581
  }
17366
- ) : null
17367
- },
17368
- `bar-${key}`
17369
- );
17370
- }
17371
- if (s.type === "line") {
17372
- return /* @__PURE__ */ jsxRuntime.jsx(
17373
- recharts.Line,
17374
- {
17375
- dataKey: key,
17376
- yAxisId: rightKeys.includes(key) ? "right" : "left",
17377
- name: label,
17378
- stroke: color,
17379
- strokeWidth: 2,
17380
- dot: { r: 3 },
17381
- activeDot: { r: 6 },
17382
- onClick: handleSeriesClick,
17383
- className: "cursor-pointer pointer-events-auto",
17384
- style: { opacity: getSeriesOpacity(key) },
17385
- children: showLabels && labelsVisibility.line !== false && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsxRuntime.jsx(
17386
- recharts.LabelList,
17582
+ ),
17583
+ rightKeys.length > 0 && (() => {
17584
+ const { rightAxisColor, rightTickFormatter } = fnConfigRightKeys(
17585
+ biaxialConfigNormalized,
17586
+ yTickFormatter,
17587
+ finalColors
17588
+ );
17589
+ return /* @__PURE__ */ jsxRuntime.jsx(
17590
+ recharts.YAxis,
17591
+ {
17592
+ yAxisId: "right",
17593
+ width: finalChartRightMargin,
17594
+ orientation: "right",
17595
+ stroke: "hsl(var(--muted-foreground))",
17596
+ fontSize: 12,
17597
+ tickLine: false,
17598
+ axisLine: false,
17599
+ tick: { fill: rightAxisColor },
17600
+ tickFormatter: rightTickFormatter,
17601
+ domain: [Math.min(minRightDataValue, 0), niceMaxRight],
17602
+ tickCount: 6,
17603
+ label: biaxialConfigNormalized?.label ? {
17604
+ value: biaxialConfigNormalized.label,
17605
+ angle: -90,
17606
+ position: "right",
17607
+ dx: rightYAxisLabelDx,
17608
+ style: {
17609
+ fontSize: 12,
17610
+ fill: "hsl(var(--muted-foreground))",
17611
+ fontWeight: 500,
17612
+ textAnchor: "middle"
17613
+ }
17614
+ } : void 0
17615
+ }
17616
+ );
17617
+ })(),
17618
+ showTooltip && /* @__PURE__ */ jsxRuntime.jsx(
17619
+ recharts.Tooltip,
17387
17620
  {
17388
- dataKey: key,
17389
- position: "top",
17390
- content: pillLabelRenderer_default(
17391
- color,
17392
- "filled",
17393
- finalValueFormatter
17621
+ content: showTooltipTotal ? /* @__PURE__ */ jsxRuntime.jsx(
17622
+ TooltipWithTotal_default,
17623
+ {
17624
+ finalColors,
17625
+ valueFormatter: finalValueFormatter,
17626
+ categoryFormatter,
17627
+ periodLabel
17628
+ }
17629
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
17630
+ TooltipSimple_default,
17631
+ {
17632
+ finalColors,
17633
+ valueFormatter: finalValueFormatter,
17634
+ categoryFormatter,
17635
+ periodLabel
17636
+ }
17394
17637
  ),
17395
- offset: 14
17638
+ cursor: { fill: "hsl(var(--muted))", opacity: 0.1 }
17396
17639
  }
17397
- ) : null
17398
- },
17399
- `line-${key}`
17400
- );
17401
- }
17402
- if (s.type === "area") {
17403
- return /* @__PURE__ */ jsxRuntime.jsx(
17404
- recharts.Area,
17405
- {
17406
- type: "monotone",
17407
- dataKey: key,
17408
- yAxisId: rightKeys.includes(key) ? "right" : "left",
17409
- name: label,
17410
- stroke: color,
17411
- fill: `url(#gradient-${key})`,
17412
- fillOpacity: 1,
17413
- strokeWidth: 2,
17414
- onClick: handleSeriesClick,
17415
- className: "cursor-pointer pointer-events-auto",
17416
- style: { opacity: getSeriesOpacity(key) },
17417
- activeDot: {
17418
- r: 6,
17419
- fill: color,
17420
- stroke: "hsl(var(--background))",
17421
- strokeWidth: 2
17422
- },
17423
- children: showLabels && labelsVisibility.area !== false && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsxRuntime.jsx(
17424
- recharts.LabelList,
17640
+ ),
17641
+ showLegend && !horizontal && /* @__PURE__ */ jsxRuntime.jsx(
17642
+ recharts.Legend,
17425
17643
  {
17426
- dataKey: key,
17427
- position: "top",
17428
- content: pillLabelRenderer_default(
17429
- color,
17430
- "soft",
17431
- finalValueFormatter
17432
- ),
17433
- offset: 12
17644
+ iconSize: 12,
17645
+ formatter: (value) => {
17646
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tracking-[0] rounded-sm", children: fnFormatterValueLegend(
17647
+ value,
17648
+ mapperConfig,
17649
+ labelMap,
17650
+ legendUppercase
17651
+ ) });
17652
+ }
17434
17653
  }
17435
- ) : null
17436
- },
17437
- `area-${key}`
17438
- );
17439
- }
17440
- return null;
17441
- })
17442
- ]
17654
+ ),
17655
+ seriesOrder.map((s) => {
17656
+ if (showOnlyHighlighted && !highlightedSeries.has(s.key))
17657
+ return null;
17658
+ const { label, color, key } = fnBuildConfigData(
17659
+ s,
17660
+ mapperConfig,
17661
+ labelMap,
17662
+ finalColors,
17663
+ rightKeys,
17664
+ biaxialConfigNormalized
17665
+ );
17666
+ if (s.type === "bar") {
17667
+ return /* @__PURE__ */ jsxRuntime.jsx(
17668
+ recharts.Bar,
17669
+ {
17670
+ dataKey: key,
17671
+ yAxisId: rightKeys.includes(key) ? "right" : "left",
17672
+ name: label,
17673
+ fill: color,
17674
+ radius: horizontal ? [0, 4, 4, 0] : [4, 4, 0, 0],
17675
+ onClick: handleBarClick,
17676
+ className: "cursor-pointer",
17677
+ style: { opacity: getSeriesOpacity(key) },
17678
+ activeBar: /* @__PURE__ */ jsxRuntime.jsx(
17679
+ recharts.Rectangle,
17680
+ {
17681
+ fill: color,
17682
+ stroke: color,
17683
+ strokeWidth: 2,
17684
+ opacity: 0.8
17685
+ }
17686
+ ),
17687
+ children: showLabels && labelsVisibility.bar !== false && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsxRuntime.jsx(
17688
+ recharts.LabelList,
17689
+ {
17690
+ dataKey: key,
17691
+ content: (props) => {
17692
+ if (!fnContentLabelList(props)) return null;
17693
+ const inside = renderInsideBarLabel(
17694
+ color,
17695
+ finalValueFormatter
17696
+ );
17697
+ return inside(props);
17698
+ },
17699
+ offset: 0
17700
+ }
17701
+ ) : null
17702
+ },
17703
+ `bar-${key}`
17704
+ );
17705
+ }
17706
+ if (s.type === "line") {
17707
+ const lineFormatter = (props) => {
17708
+ const numValue = typeof props.value === "number" ? props.value : typeof props.value === "string" ? parseFloat(props.value) : 0;
17709
+ const percentage = calcDivision(numValue, 100);
17710
+ const formattedPercentage = typeof percentage === "number" ? percentage.toFixed(1).replace(".", ",") : String(percentage).replace(".", ",");
17711
+ return `${formattedPercentage}%`;
17712
+ };
17713
+ return /* @__PURE__ */ jsxRuntime.jsx(
17714
+ recharts.Line,
17715
+ {
17716
+ dataKey: key,
17717
+ yAxisId: rightKeys.includes(key) ? "right" : "left",
17718
+ name: label,
17719
+ stroke: color,
17720
+ strokeWidth: 2,
17721
+ dot: { r: 3 },
17722
+ activeDot: { r: 6 },
17723
+ onClick: handleSeriesClick,
17724
+ className: "cursor-pointer pointer-events-auto",
17725
+ style: { opacity: getSeriesOpacity(key) },
17726
+ children: showLabels && labelsVisibility.line !== false && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsxRuntime.jsx(
17727
+ recharts.LabelList,
17728
+ {
17729
+ dataKey: key,
17730
+ position: "top",
17731
+ content: pillLabelRenderer_default(
17732
+ color,
17733
+ "filled",
17734
+ lineFormatter
17735
+ ),
17736
+ offset: 14
17737
+ }
17738
+ ) : null
17739
+ },
17740
+ `line-${key}`
17741
+ );
17742
+ }
17743
+ if (s.type === "area") {
17744
+ return /* @__PURE__ */ jsxRuntime.jsx(
17745
+ recharts.Area,
17746
+ {
17747
+ type: "monotone",
17748
+ dataKey: key,
17749
+ yAxisId: rightKeys.includes(key) ? "right" : "left",
17750
+ name: label,
17751
+ stroke: color,
17752
+ fill: `url(#gradient-${key})`,
17753
+ fillOpacity: 1,
17754
+ strokeWidth: 2,
17755
+ onClick: handleSeriesClick,
17756
+ className: "cursor-pointer pointer-events-auto",
17757
+ style: { opacity: getSeriesOpacity(key) },
17758
+ activeDot: {
17759
+ r: 6,
17760
+ fill: color,
17761
+ stroke: "hsl(var(--background))",
17762
+ strokeWidth: 2
17763
+ },
17764
+ children: showLabels && labelsVisibility.area !== false && highlightedSeries.size === 0 || highlightedSeries.has(key) ? /* @__PURE__ */ jsxRuntime.jsx(
17765
+ recharts.LabelList,
17766
+ {
17767
+ dataKey: key,
17768
+ position: "top",
17769
+ content: pillLabelRenderer_default(
17770
+ color,
17771
+ "soft",
17772
+ finalValueFormatter
17773
+ ),
17774
+ offset: 12
17775
+ }
17776
+ ) : null
17777
+ },
17778
+ `area-${key}`
17779
+ );
17780
+ }
17781
+ return null;
17782
+ })
17783
+ ]
17784
+ }
17785
+ )
17786
+ }
17787
+ )
17443
17788
  }
17444
- ) }),
17789
+ ),
17445
17790
  enableDraggableTooltips && activeTooltips.map((tooltip) => /* @__PURE__ */ jsxRuntime.jsx(
17446
17791
  DraggableTooltip_default,
17447
17792
  {
@@ -18019,6 +18364,7 @@ exports.FileUploader = FileUploader;
18019
18364
  exports.FilterButton = FilterButton;
18020
18365
  exports.HideButton = HideButton;
18021
18366
  exports.Highlights = Highlights_default;
18367
+ exports.HorizontalLegend = HorizontalLegend_default;
18022
18368
  exports.HoverCardBase = HoverCardBase;
18023
18369
  exports.HoverCardContentBase = HoverCardContentBase;
18024
18370
  exports.HoverCardTriggerBase = HoverCardTriggerBase;
@@ -18244,6 +18590,7 @@ exports.useCalendarDndAgenda = useCalendarDndAgenda;
18244
18590
  exports.useChartClick = useChartClick;
18245
18591
  exports.useChartDimensions = useChartDimensions;
18246
18592
  exports.useChartHighlights = useChartHighlights;
18593
+ exports.useChartMinMax = useChartMinMax;
18247
18594
  exports.useChartTooltips = useChartTooltips;
18248
18595
  exports.useCurrentTimeIndicator = useCurrentTimeIndicator;
18249
18596
  exports.useCurrentTimeIndicatorAgenda = useCurrentTimeIndicatorAgenda;