@mlw-packages/react-components 1.7.13 → 1.7.14

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
@@ -500,9 +500,9 @@ __export(index_exports, {
500
500
  AlertDialogTitleBase: () => AlertDialogTitleBase,
501
501
  AlertDialogTriggerBase: () => AlertDialogTriggerBase,
502
502
  AvatarBase: () => AvatarBase,
503
+ AvatarCombobox: () => AvatarCombobox,
503
504
  AvatarFallbackBase: () => AvatarFallbackBase,
504
505
  AvatarImageBase: () => AvatarImageBase,
505
- AvatarSelect: () => AvatarSelect,
506
506
  BackButton: () => BackButton,
507
507
  Badge: () => Badge,
508
508
  BarChart: () => BarChart_default,
@@ -1289,6 +1289,7 @@ function ComboboxBase({
1289
1289
  renderSelected,
1290
1290
  handleSelection,
1291
1291
  checkIsSelected,
1292
+ disabled = false,
1292
1293
  keepOpen = false,
1293
1294
  closeAll,
1294
1295
  searchPlaceholder,
@@ -1303,111 +1304,124 @@ function ComboboxBase({
1303
1304
  className: "col-span-1 w-full",
1304
1305
  "data-testid": testIds.root ?? "combobox-base-root",
1305
1306
  children: [
1306
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(PopoverBase, { open, onOpenChange: setOpen, modal: true, children: [
1307
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1308
- PopoverTriggerBase,
1309
- {
1310
- asChild: true,
1311
- className: "flex w-full justify-between dark:bg-[hsl(231,15%,19%)]",
1312
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1313
- ButtonBase,
1307
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1308
+ PopoverBase,
1309
+ {
1310
+ open,
1311
+ onOpenChange: (v) => !disabled && setOpen(v),
1312
+ modal: true,
1313
+ children: [
1314
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1315
+ PopoverTriggerBase,
1314
1316
  {
1315
- variant: "select",
1316
- size: "select",
1317
- role: "combobox",
1318
- "aria-expanded": open,
1319
- className: cn(
1320
- "flex items-center gap-2 justify-between h-auto [&>div]:line-clamp-1 [&>span]:line-clamp-1",
1321
- error && "border-red-500"
1322
- ),
1323
- "data-testid": testIds.trigger ?? "combobox-trigger",
1324
- children: [
1325
- renderSelected,
1326
- closeAll,
1327
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1328
- import_framer_motion2.motion.div,
1329
- {
1330
- animate: { rotate: open ? 180 : 0 },
1331
- transition: { duration: 0.3 },
1332
- className: "flex",
1333
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.CaretDownIcon, { className: " flex-shrink-0" })
1334
- }
1335
- )
1336
- ]
1317
+ asChild: true,
1318
+ className: "flex w-full justify-between dark:bg-[hsl(231,15%,19%)]",
1319
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1320
+ ButtonBase,
1321
+ {
1322
+ variant: "select",
1323
+ size: "select",
1324
+ role: "combobox",
1325
+ "aria-expanded": open,
1326
+ "aria-disabled": disabled || void 0,
1327
+ disabled,
1328
+ className: cn(
1329
+ "flex items-center gap-2 justify-between h-auto [&>div]:line-clamp-1 [&>span]:line-clamp-1",
1330
+ error && "border-red-500"
1331
+ ),
1332
+ "data-testid": testIds.trigger ?? "combobox-trigger",
1333
+ children: [
1334
+ renderSelected,
1335
+ closeAll,
1336
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1337
+ import_framer_motion2.motion.div,
1338
+ {
1339
+ animate: { rotate: open ? 180 : 0 },
1340
+ transition: { duration: 0.3 },
1341
+ className: "flex",
1342
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react5.CaretDownIcon, { className: " flex-shrink-0" })
1343
+ }
1344
+ )
1345
+ ]
1346
+ }
1347
+ )
1337
1348
  }
1338
- )
1339
- }
1340
- ),
1341
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1342
- PopoverContentBase,
1343
- {
1344
- className: "max-h-[--radix-popover-content-available-height] w-[--radix-popover-trigger-width] p-0 border-none",
1345
- "data-testid": testIds.popover ?? "combobox-popover",
1346
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1347
- CommandBase,
1349
+ ),
1350
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1351
+ PopoverContentBase,
1348
1352
  {
1349
- className: "dark:text-white hover:bg-rsecondary",
1350
- "data-testid": testIds.command ?? "combobox-command",
1351
- children: [
1352
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1353
- CommandInputBase,
1354
- {
1355
- tabIndex: -1,
1356
- placeholder: searchPlaceholder ?? "Busque uma op\xE7\xE3o...",
1357
- "data-testid": testIds.search ?? "combobox-search"
1358
- }
1359
- ),
1360
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(CommandListBase, { "data-testid": testIds.list ?? "combobox-list", children: [
1361
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommandEmptyBase, { "data-testid": testIds.empty ?? "combobox-empty", children: empty }),
1362
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommandGroupBase, { "data-testid": testIds.group ?? "combobox-group", children: items.map((item) => {
1363
- const isSelected = checkIsSelected(item.value);
1364
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1365
- CommandItemBase,
1353
+ className: "max-h-[--radix-popover-content-available-height] w-[--radix-popover-trigger-width] p-0 border-none",
1354
+ "data-testid": testIds.popover ?? "combobox-popover",
1355
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1356
+ CommandBase,
1357
+ {
1358
+ className: "dark:text-white hover:bg-rsecondary",
1359
+ "data-testid": testIds.command ?? "combobox-command",
1360
+ children: [
1361
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1362
+ CommandInputBase,
1366
1363
  {
1367
- keywords: [item.label],
1368
- value: item.value,
1369
- onSelect: (value) => {
1370
- handleSelection(value);
1371
- if (!keepOpen) setOpen(false);
1372
- },
1373
- "data-testid": testIds.option ?? "combobox-option",
1374
- children: [
1375
- item.label,
1376
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1377
- import_framer_motion2.motion.div,
1378
- {
1379
- initial: { scale: 0 },
1380
- animate: { scale: isSelected ? 1 : 0 },
1381
- transition: {
1382
- type: "spring",
1383
- stiffness: 500,
1384
- damping: 30
1385
- },
1386
- className: "ml-auto ",
1387
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1388
- import_react5.CheckIcon,
1364
+ tabIndex: -1,
1365
+ disabled,
1366
+ placeholder: searchPlaceholder ?? "Busque uma op\xE7\xE3o...",
1367
+ "data-testid": testIds.search ?? "combobox-search"
1368
+ }
1369
+ ),
1370
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(CommandListBase, { "data-testid": testIds.list ?? "combobox-list", children: [
1371
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommandEmptyBase, { "data-testid": testIds.empty ?? "combobox-empty", children: empty }),
1372
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommandGroupBase, { "data-testid": testIds.group ?? "combobox-group", children: items.map((item) => {
1373
+ const isSelected = checkIsSelected(item.value);
1374
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1375
+ CommandItemBase,
1376
+ {
1377
+ keywords: [item.label],
1378
+ value: item.value,
1379
+ onSelect: (value) => {
1380
+ if (disabled) return;
1381
+ handleSelection(value);
1382
+ if (!keepOpen) setOpen(false);
1383
+ },
1384
+ disabled,
1385
+ "data-testid": testIds.option ?? "combobox-option",
1386
+ children: [
1387
+ item.label,
1388
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1389
+ import_framer_motion2.motion.div,
1389
1390
  {
1390
- className: cn(
1391
- "ml-auto",
1392
- isSelected ? "opacity-100" : "opacity-0"
1393
- ),
1394
- "data-testid": isSelected ? testIds.check ?? "combobox-option-check" : void 0
1391
+ initial: { scale: 0 },
1392
+ animate: { scale: isSelected ? 1 : 0 },
1393
+ transition: {
1394
+ type: "spring",
1395
+ stiffness: 500,
1396
+ damping: 30
1397
+ },
1398
+ className: "ml-auto ",
1399
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1400
+ import_react5.CheckIcon,
1401
+ {
1402
+ className: cn(
1403
+ "ml-auto",
1404
+ isSelected ? "opacity-100" : "opacity-0"
1405
+ ),
1406
+ "data-testid": isSelected ? testIds.check ?? "combobox-option-check" : void 0
1407
+ }
1408
+ )
1395
1409
  }
1396
1410
  )
1397
- }
1398
- )
1399
- ]
1400
- },
1401
- item.value
1402
- );
1403
- }) })
1404
- ] })
1405
- ]
1411
+ ]
1412
+ },
1413
+ item.value
1414
+ );
1415
+ }) })
1416
+ ] })
1417
+ ]
1418
+ }
1419
+ )
1406
1420
  }
1407
1421
  )
1408
- }
1409
- )
1410
- ] }),
1422
+ ]
1423
+ }
1424
+ ),
1411
1425
  /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ErrorMessage_default, { error })
1412
1426
  ]
1413
1427
  }
@@ -1424,6 +1438,7 @@ function Combobox({
1424
1438
  placeholder,
1425
1439
  searchPlaceholder,
1426
1440
  empty,
1441
+ disabled = false,
1427
1442
  label,
1428
1443
  labelClassname,
1429
1444
  testIds,
@@ -1435,11 +1450,15 @@ function Combobox({
1435
1450
  "span",
1436
1451
  {
1437
1452
  "data-testid": testIds?.selected ?? "combobox-selected",
1438
- className: cn("truncate", !selectedItem && "text-gray-500"),
1453
+ className: cn(
1454
+ "truncate",
1455
+ disabled && "opacity-60 cursor-not-allowed",
1456
+ !selectedItem && "text-gray-500"
1457
+ ),
1439
1458
  children: selectedItem?.label ?? placeholder ?? "Selecione uma op\xE7\xE3o..."
1440
1459
  }
1441
1460
  );
1442
- }, [placeholder, selectedItem, testIds?.selected]);
1461
+ }, [placeholder, selectedItem, testIds?.selected, disabled]);
1443
1462
  const checkIsSelected = (0, import_react6.useCallback)(
1444
1463
  (value) => selected == null ? false : selected == value,
1445
1464
  [selected]
@@ -1459,6 +1478,7 @@ function Combobox({
1459
1478
  renderSelected,
1460
1479
  handleSelection,
1461
1480
  checkIsSelected,
1481
+ disabled,
1462
1482
  searchPlaceholder,
1463
1483
  empty,
1464
1484
  error,
@@ -1484,8 +1504,10 @@ function MultiCombobox({
1484
1504
  labelClassname,
1485
1505
  testIds = {},
1486
1506
  error,
1507
+ disabled = false,
1487
1508
  keepOpen = true,
1488
- showClearAll = false
1509
+ showClearAll = false,
1510
+ empty
1489
1511
  }) {
1490
1512
  const selectedItems = items.filter((item) => selected.includes(item.value));
1491
1513
  const checkIsSelected = (0, import_react7.useCallback)(
@@ -1509,7 +1531,9 @@ function MultiCombobox({
1509
1531
  variant: "ghost",
1510
1532
  "data-testid": testIds.clearAll ?? "combobox-clear-all",
1511
1533
  size: "icon",
1534
+ disabled,
1512
1535
  onClick: (e) => {
1536
+ if (disabled) return;
1513
1537
  e.stopPropagation();
1514
1538
  onChange([]);
1515
1539
  },
@@ -1552,15 +1576,19 @@ function MultiCombobox({
1552
1576
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1553
1577
  import_framer_motion3.motion.span,
1554
1578
  {
1555
- role: "button",
1556
- tabIndex: 0,
1579
+ role: disabled ? void 0 : "button",
1580
+ tabIndex: disabled ? -1 : 0,
1557
1581
  onClick: (e) => {
1582
+ if (disabled) return;
1558
1583
  e.stopPropagation();
1559
1584
  handleSelection(item.value);
1560
1585
  },
1561
1586
  whileHover: { scale: 1.1 },
1562
1587
  whileTap: { scale: 0.95 },
1563
- className: "cursor-pointer text-xs flex items-center justify-center hover:text-red-500 transition-colors flex-shrink-0 rounded hover:bg-red-50 ",
1588
+ className: cn(
1589
+ "text-xs flex items-center justify-center transition-colors flex-shrink-0 rounded",
1590
+ !disabled ? "cursor-pointer hover:text-red-500 hover:bg-red-50" : "opacity-50 pointer-events-none"
1591
+ ),
1564
1592
  children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react8.XIcon, { size: 14 })
1565
1593
  }
1566
1594
  )
@@ -1570,7 +1598,7 @@ function MultiCombobox({
1570
1598
  )) })
1571
1599
  }
1572
1600
  );
1573
- }, [handleSelection, placeholder, selectedItems, testIds]);
1601
+ }, [handleSelection, placeholder, selectedItems, testIds, disabled]);
1574
1602
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
1575
1603
  "div",
1576
1604
  {
@@ -1595,7 +1623,9 @@ function MultiCombobox({
1595
1623
  keepOpen,
1596
1624
  closeAll,
1597
1625
  searchPlaceholder,
1598
- error
1626
+ error,
1627
+ empty,
1628
+ disabled
1599
1629
  }
1600
1630
  )
1601
1631
  ]
@@ -2200,7 +2230,7 @@ function Select({
2200
2230
  ] });
2201
2231
  }
2202
2232
 
2203
- // src/components/selects/AvatarSelect.tsx
2233
+ // src/components/selects/AvatarCombobox.tsx
2204
2234
  var import_react15 = require("react");
2205
2235
  var import_react16 = require("@phosphor-icons/react");
2206
2236
  var import_jsx_runtime19 = require("react/jsx-runtime");
@@ -2225,14 +2255,14 @@ var Square = ({
2225
2255
  {
2226
2256
  "aria-hidden": "true",
2227
2257
  className: cn(
2228
- "flex size-5 items-center justify-center rounded bg-muted font-medium text-muted-foreground text-xs",
2258
+ "flex h-6 w-6 flex-shrink-0 items-center justify-center rounded bg-muted font-medium text-muted-foreground leading-none overflow-hidden",
2229
2259
  className
2230
2260
  ),
2231
2261
  "data-square": true,
2232
2262
  children
2233
2263
  }
2234
2264
  );
2235
- function AvatarSelect({
2265
+ function AvatarCombobox({
2236
2266
  items,
2237
2267
  groupItems,
2238
2268
  placeholder,
@@ -3519,7 +3549,9 @@ var RechartTooltipWithTotal = ({
3519
3549
  periodLabel = "Per\xEDodo",
3520
3550
  totalLabel = "Total",
3521
3551
  valueFormatter: valueFormatter2,
3522
- categoryFormatter
3552
+ categoryFormatter,
3553
+ yAxisMap,
3554
+ isBiaxial = false
3523
3555
  }) => {
3524
3556
  if (!active || !payload || payload.length === 0) return null;
3525
3557
  const displayLabel = categoryFormatter ? categoryFormatter(String(label ?? "")) : label;
@@ -3550,6 +3582,13 @@ var RechartTooltipWithTotal = ({
3550
3582
  (sum, p) => sum + Math.abs(typeof p.value === "number" ? p.value : 0),
3551
3583
  0
3552
3584
  );
3585
+ const axisDenominators = {};
3586
+ if (isBiaxial && yAxisMap) {
3587
+ for (const p of numeric) {
3588
+ const axis = yAxisMap[p.dataKey] || "left";
3589
+ axisDenominators[axis] = (axisDenominators[axis] || 0) + Math.abs(p.value || 0);
3590
+ }
3591
+ }
3553
3592
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
3554
3593
  "div",
3555
3594
  {
@@ -3618,7 +3657,12 @@ var RechartTooltipWithTotal = ({
3618
3657
  children: displayValue
3619
3658
  }
3620
3659
  ),
3621
- /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-xs text-muted-foreground", children: absDenominator > 0 ? `${pct.toFixed(1)}%` : "-" })
3660
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-xs text-muted-foreground", children: isBiaxial && yAxisMap ? (() => {
3661
+ const axis = yAxisMap[entry.dataKey] || "left";
3662
+ const denom = axisDenominators[axis] || 0;
3663
+ const p = denom > 0 ? Math.abs(value) / denom * 100 : 0;
3664
+ return denom > 0 ? `${p.toFixed(1)}%` : "-";
3665
+ })() : absDenominator > 0 ? `${pct.toFixed(1)}%` : "-" })
3622
3666
  ] })
3623
3667
  ] }),
3624
3668
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "w-full bg-muted rounded-full h-1 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
@@ -3648,7 +3692,9 @@ var TooltipSimple = ({
3648
3692
  finalColors = {},
3649
3693
  periodLabel = "Per\xEDodo",
3650
3694
  valueFormatter: valueFormatter2,
3651
- categoryFormatter
3695
+ categoryFormatter,
3696
+ yAxisMap,
3697
+ isBiaxial = false
3652
3698
  }) => {
3653
3699
  if (!active || !payload || payload.length === 0) return null;
3654
3700
  const displayLabel = categoryFormatter ? categoryFormatter(String(label ?? "")) : label;
@@ -3667,6 +3713,17 @@ var TooltipSimple = ({
3667
3713
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "divide-y divide-border rounded-md overflow-hidden", children: payload.map((entry, index) => {
3668
3714
  const value = typeof entry.value === "number" ? entry.value : 0;
3669
3715
  const color = finalColors[entry.dataKey] || entry.color || "#999";
3716
+ let pct = 0;
3717
+ if (isBiaxial && yAxisMap) {
3718
+ const axis = yAxisMap[entry.dataKey] || "left";
3719
+ const axisSum = payload.filter(
3720
+ (p) => (yAxisMap[p.dataKey] || "left") === axis
3721
+ ).reduce(
3722
+ (s, p) => s + Math.abs(typeof p.value === "number" ? p.value : 0),
3723
+ 0
3724
+ );
3725
+ pct = axisSum > 0 ? Math.abs(value) / axisSum * 100 : 0;
3726
+ }
3670
3727
  const defaultFormatted = (() => {
3671
3728
  try {
3672
3729
  if (Math.abs(value) < 1e3) {
@@ -3701,13 +3758,16 @@ var TooltipSimple = ({
3701
3758
  ),
3702
3759
  /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-muted-foreground truncate", children: entry.name })
3703
3760
  ] }),
3704
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "ml-3", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3705
- "span",
3706
- {
3707
- className: `font-medium tabular-nums ${value < 0 ? "text-destructive" : "text-foreground"}`,
3708
- children: displayValue
3709
- }
3710
- ) })
3761
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "ml-3", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-baseline gap-2", children: [
3762
+ /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
3763
+ "span",
3764
+ {
3765
+ className: `font-medium tabular-nums ${value < 0 ? "text-destructive" : "text-foreground"}`,
3766
+ children: displayValue
3767
+ }
3768
+ ),
3769
+ isBiaxial ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-xs text-muted-foreground", children: pct > 0 ? `${pct.toFixed(1)}%` : "-" }) : null
3770
+ ] }) })
3711
3771
  ]
3712
3772
  },
3713
3773
  index
@@ -3772,10 +3832,13 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
3772
3832
  const vb = props.viewBox;
3773
3833
  const cxNum = parseNumber(props.cx);
3774
3834
  let centerX;
3835
+ let usedBarCenter = false;
3775
3836
  if (typeof px === "number" && typeof pWidth === "number") {
3776
3837
  centerX = px + pWidth / 2;
3838
+ usedBarCenter = true;
3777
3839
  } else if (typeof xNum === "number" && typeof pWidth === "number") {
3778
3840
  centerX = xNum + pWidth / 2;
3841
+ usedBarCenter = true;
3779
3842
  } else if (typeof cxNum === "number") {
3780
3843
  centerX = cxNum;
3781
3844
  } else if (vb && typeof vb.x === "number" && typeof vb.width === "number" && typeof props.index === "number") {
@@ -3787,32 +3850,26 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
3787
3850
  } else {
3788
3851
  centerX = typeof props.index === "number" ? props.index * 40 + 24 : 0;
3789
3852
  }
3790
- if (vb && typeof vb.x === "number" && typeof vb.width === "number") {
3791
- const minX = vb.x + 0 + pillWidth / 22;
3792
- const maxX = vb.x + vb.width - 2 - pillWidth / 2;
3853
+ if (!usedBarCenter && vb && typeof vb.x === "number" && typeof vb.width === "number") {
3854
+ const minX = vb.x + pillWidth / 2;
3855
+ const maxX = vb.x + vb.width - pillWidth / 2;
3793
3856
  centerX = Math.max(minX, Math.min(maxX, centerX));
3794
3857
  }
3795
3858
  const yNum = parseNumber(y);
3796
3859
  const py = parseNumber(props.y);
3797
3860
  const cyNum = parseNumber(props.cy);
3798
3861
  const centerY = yNum ?? (typeof py === "number" ? py : vb && typeof vb.y === "number" && typeof vb.height === "number" ? vb.y + vb.height / 2 : typeof cyNum === "number" ? cyNum : 0);
3799
- const rectX = centerX - pillWidth / 3.5;
3862
+ const rectX = centerX - pillWidth / 2;
3800
3863
  const rectY = centerY - pillHeight - 6;
3801
- const textX = centerX - pillWidth / 3.5 + pillWidth / 2;
3864
+ const textX = centerX;
3802
3865
  const textY = rectY + pillHeight / 2 + 3;
3803
3866
  const rectFill = variant === "filled" ? color : variant === "soft" ? `${color}20` : "#ffffff";
3804
3867
  const rectStroke = variant === "outline" ? `${color}CC` : void 0;
3805
- const numValue = parseNumber(value);
3806
- const isNegative = typeof numValue === "number" && numValue < 0;
3807
3868
  let textColor;
3808
- if (isNegative) {
3809
- textColor = "#dc2626";
3869
+ if (variant === "filled") {
3870
+ textColor = "#ffffff";
3810
3871
  } else {
3811
- if (variant === "filled") {
3812
- textColor = "#ffffff";
3813
- } else {
3814
- textColor = "#374151";
3815
- }
3872
+ textColor = "#374151";
3816
3873
  }
3817
3874
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("g", { children: [
3818
3875
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
@@ -3877,7 +3934,10 @@ var Chart = ({
3877
3934
  showTooltipTotal = false,
3878
3935
  maxTooltips = 5,
3879
3936
  formatBR = false,
3880
- chartMargin
3937
+ chartMargin,
3938
+ yAxisMap,
3939
+ yAxes,
3940
+ periodLabel = "Per\xEDodo"
3881
3941
  }) => {
3882
3942
  const smartConfig = (0, import_react21.useMemo)(() => {
3883
3943
  const resolvedXAxisKey = typeof xAxis === "string" ? xAxis : xAxis && xAxis.dataKey || detectXAxis(data);
@@ -4008,6 +4068,70 @@ var Chart = ({
4008
4068
  }
4009
4069
  return min;
4010
4070
  }, [processedData, allKeys]);
4071
+ const leftKeys = (0, import_react21.useMemo)(
4072
+ () => !yAxisMap ? allKeys : allKeys.filter((k) => (yAxisMap?.[k] ?? "left") === "left"),
4073
+ [allKeys, yAxisMap]
4074
+ );
4075
+ const rightKeys = (0, import_react21.useMemo)(
4076
+ () => !yAxisMap ? [] : allKeys.filter((k) => (yAxisMap?.[k] ?? "left") === "right"),
4077
+ [allKeys, yAxisMap]
4078
+ );
4079
+ const maxForKeys = (0, import_react21.useCallback)(
4080
+ (keys) => {
4081
+ let max = 0;
4082
+ for (const row of processedData) {
4083
+ const r = row;
4084
+ for (const key of keys) {
4085
+ const v = r[key];
4086
+ if (typeof v === "number" && Number.isFinite(v) && v > max)
4087
+ max = v;
4088
+ }
4089
+ }
4090
+ return max;
4091
+ },
4092
+ [processedData]
4093
+ );
4094
+ const minForKeys = (0, import_react21.useCallback)(
4095
+ (keys) => {
4096
+ let min = 0;
4097
+ for (const row of processedData) {
4098
+ const r = row;
4099
+ for (const key of keys) {
4100
+ const v = r[key];
4101
+ if (typeof v === "number" && Number.isFinite(v) && v < min)
4102
+ min = v;
4103
+ }
4104
+ }
4105
+ return min;
4106
+ },
4107
+ [processedData]
4108
+ );
4109
+ const maxLeft = (0, import_react21.useMemo)(() => maxForKeys(leftKeys), [leftKeys, maxForKeys]);
4110
+ const minLeft = (0, import_react21.useMemo)(() => minForKeys(leftKeys), [leftKeys, minForKeys]);
4111
+ const maxRight = (0, import_react21.useMemo)(
4112
+ () => rightKeys.length > 0 ? maxForKeys(rightKeys) : 0,
4113
+ [rightKeys, maxForKeys]
4114
+ );
4115
+ const minRight = (0, import_react21.useMemo)(
4116
+ () => rightKeys.length > 0 ? minForKeys(rightKeys) : 0,
4117
+ [rightKeys, minForKeys]
4118
+ );
4119
+ const niceMaxLeft = (0, import_react21.useMemo)(() => {
4120
+ let padding = 0.08;
4121
+ if (maxLeft > 1e6) padding = 0.05;
4122
+ if (maxLeft > 1e7) padding = 0.03;
4123
+ if (maxLeft === 0) padding = 0.12;
4124
+ const padded = maxLeft * (1 + padding);
4125
+ return niceCeil(padded);
4126
+ }, [maxLeft]);
4127
+ const niceMaxRight = (0, import_react21.useMemo)(() => {
4128
+ let padding = 0.08;
4129
+ if (maxRight > 1e6) padding = 0.05;
4130
+ if (maxRight > 1e7) padding = 0.03;
4131
+ if (maxRight === 0) padding = 0.12;
4132
+ const padded = maxRight * (1 + padding);
4133
+ return niceCeil(padded);
4134
+ }, [maxRight]);
4011
4135
  const niceMax = (0, import_react21.useMemo)(() => {
4012
4136
  let padding = 0.08;
4013
4137
  if (maxDataValue > 1e6) padding = 0.05;
@@ -4197,8 +4321,57 @@ var Chart = ({
4197
4321
  const defaultChartRightMargin = 30;
4198
4322
  const defaultChartLeftMargin = 0;
4199
4323
  const containerPaddingLeft = 16;
4200
- const finalChartRightMargin = chartMargin?.right ?? defaultChartRightMargin;
4201
- const finalChartLeftMargin = chartMargin?.left ?? (yAxisLabel ? 40 : defaultChartLeftMargin);
4324
+ const estimateTextWidth = (0, import_react21.useCallback)((text) => {
4325
+ const s = String(text ?? "");
4326
+ if (typeof document === "undefined")
4327
+ return Math.min(200, s.length * 8 + 12);
4328
+ const canvas = document.createElement("canvas");
4329
+ const ctx = canvas.getContext("2d");
4330
+ if (!ctx) return Math.min(200, s.length * 8 + 12);
4331
+ ctx.font = "12px system-ui, -apple-system, 'Segoe UI', Roboto";
4332
+ const w = Math.ceil(ctx.measureText(s).width) + 12;
4333
+ return Math.min(300, w);
4334
+ }, []);
4335
+ const leftLabelSample = (0, import_react21.useMemo)(() => {
4336
+ if (!leftKeys || leftKeys.length === 0) return "";
4337
+ const candidates = [maxLeft, minLeft, niceMaxLeft];
4338
+ return String(
4339
+ candidates.map((v) => yTickFormatter(v)).sort((a, b) => String(b).length - String(a).length)[0] ?? ""
4340
+ );
4341
+ }, [leftKeys, maxLeft, minLeft, niceMaxLeft, yTickFormatter]);
4342
+ const rightLabelSample = (0, import_react21.useMemo)(() => {
4343
+ if (!rightKeys || rightKeys.length === 0) return "";
4344
+ const candidates = [maxRight, minRight, niceMaxRight];
4345
+ return String(
4346
+ candidates.map((v) => yTickFormatter(v)).sort((a, b) => String(b).length - String(a).length)[0] ?? ""
4347
+ );
4348
+ }, [rightKeys, maxRight, minRight, niceMaxRight, yTickFormatter]);
4349
+ const estimatedLeftNeeded = (0, import_react21.useMemo)(() => {
4350
+ const tickW = leftLabelSample ? estimateTextWidth(leftLabelSample) : 0;
4351
+ const axisW = yAxisLabel ? estimateTextWidth(yAxisLabel) + 8 : 0;
4352
+ return Math.max(
4353
+ defaultChartLeftMargin,
4354
+ Math.ceil(tickW + axisW + containerPaddingLeft / 2)
4355
+ );
4356
+ }, [leftLabelSample, yAxisLabel, estimateTextWidth]);
4357
+ const estimatedRightNeeded = (0, import_react21.useMemo)(() => {
4358
+ const tickW = rightLabelSample ? estimateTextWidth(rightLabelSample) : 0;
4359
+ const axisW = yAxes?.right?.label ? estimateTextWidth(yAxes.right.label) + 8 : 0;
4360
+ return Math.max(defaultChartRightMargin, Math.ceil(tickW + axisW / 2));
4361
+ }, [rightLabelSample, yAxes, estimateTextWidth]);
4362
+ const leftAxisLabelWidth = (0, import_react21.useMemo)(() => {
4363
+ const label = yAxes?.left?.label ?? yAxisLabel;
4364
+ return label ? estimateTextWidth(label) : 0;
4365
+ }, [yAxes, yAxisLabel, estimateTextWidth]);
4366
+ const rightAxisLabelWidth = (0, import_react21.useMemo)(() => {
4367
+ const label = yAxes?.right?.label;
4368
+ return label ? estimateTextWidth(label) : 0;
4369
+ }, [yAxes, estimateTextWidth]);
4370
+ const leftYAxisLabelDx = Math.ceil(leftAxisLabelWidth / 2) + 8;
4371
+ const rightYAxisLabelDx = Math.ceil(rightAxisLabelWidth / 2) + 8;
4372
+ const finalChartLeftMargin = chartMargin?.left ?? Math.max(estimatedLeftNeeded, yAxisLabel ? 40 : defaultChartLeftMargin);
4373
+ const finalChartRightMarginFinal = chartMargin?.right ?? estimatedRightNeeded;
4374
+ const finalChartRightMargin = finalChartRightMarginFinal;
4202
4375
  const finalChartTopMargin = chartMargin?.top ?? (showLabels ? 48 : 20);
4203
4376
  const baseBottom = chartMargin?.bottom ?? 5;
4204
4377
  const extraForXAxisLabel = xAxisLabel ? 22 : 0;
@@ -4276,8 +4449,7 @@ var Chart = ({
4276
4449
  ref: wrapperRef,
4277
4450
  style: {
4278
4451
  width: "100%",
4279
- overflowX: "hidden",
4280
- overflowY: "hidden",
4452
+ overflow: "visible",
4281
4453
  minWidth: 0
4282
4454
  },
4283
4455
  children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
@@ -4292,7 +4464,6 @@ var Chart = ({
4292
4464
  style: {
4293
4465
  paddingLeft: `${containerPaddingLeft + finalChartLeftMargin}px`,
4294
4466
  width: "100%",
4295
- maxWidth: `${chartInnerWidth}px`,
4296
4467
  display: "flex",
4297
4468
  justifyContent: titlePosition === "center" ? "center" : titlePosition === "right" ? "flex-end" : "flex-start",
4298
4469
  alignItems: "center",
@@ -4414,8 +4585,8 @@ var Chart = ({
4414
4585
  },
4415
4586
  label: xAxisLabel ? {
4416
4587
  value: xAxisLabel,
4417
- position: "insideBottomRight",
4418
- offset: -5,
4588
+ position: "bottom",
4589
+ offset: 12,
4419
4590
  style: {
4420
4591
  fontSize: 12,
4421
4592
  fill: "hsl(var(--muted-foreground))",
@@ -4424,7 +4595,61 @@ var Chart = ({
4424
4595
  } : void 0
4425
4596
  }
4426
4597
  ),
4427
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4598
+ rightKeys.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
4599
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4600
+ import_recharts.YAxis,
4601
+ {
4602
+ yAxisId: "left",
4603
+ stroke: yAxes?.left?.stroke || "hsl(var(--muted-foreground))",
4604
+ width: yAxes?.left?.width,
4605
+ fontSize: 12,
4606
+ tickLine: false,
4607
+ axisLine: false,
4608
+ tickFormatter: yTickFormatter,
4609
+ domain: [Math.min(minLeft, 0), niceMaxLeft],
4610
+ tickCount: 6,
4611
+ label: yAxes?.left?.label ?? yAxisLabel ? {
4612
+ value: yAxes?.left?.label ?? yAxisLabel,
4613
+ angle: -90,
4614
+ position: "left",
4615
+ dx: -leftYAxisLabelDx,
4616
+ style: {
4617
+ fontSize: 12,
4618
+ fill: "hsl(var(--muted-foreground))",
4619
+ fontWeight: 500,
4620
+ textAnchor: "middle"
4621
+ }
4622
+ } : void 0
4623
+ }
4624
+ ),
4625
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4626
+ import_recharts.YAxis,
4627
+ {
4628
+ yAxisId: "right",
4629
+ orientation: "right",
4630
+ stroke: yAxes?.right?.stroke || "hsl(var(--muted-foreground))",
4631
+ width: yAxes?.right?.width,
4632
+ fontSize: 12,
4633
+ tickLine: false,
4634
+ axisLine: false,
4635
+ tickFormatter: yTickFormatter,
4636
+ domain: [Math.min(minRight, 0), niceMaxRight],
4637
+ tickCount: 6,
4638
+ label: yAxes?.right?.label ? {
4639
+ value: yAxes?.right?.label,
4640
+ angle: -90,
4641
+ position: "right",
4642
+ dx: rightYAxisLabelDx,
4643
+ style: {
4644
+ fontSize: 12,
4645
+ fill: "hsl(var(--muted-foreground))",
4646
+ fontWeight: 500,
4647
+ textAnchor: "middle"
4648
+ }
4649
+ } : void 0
4650
+ }
4651
+ )
4652
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_jsx_runtime28.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4428
4653
  import_recharts.YAxis,
4429
4654
  {
4430
4655
  stroke: "hsl(var(--muted-foreground))",
@@ -4437,7 +4662,8 @@ var Chart = ({
4437
4662
  label: yAxisLabel ? {
4438
4663
  value: yAxisLabel,
4439
4664
  angle: -90,
4440
- position: "leftTop",
4665
+ position: "left",
4666
+ dx: -leftYAxisLabelDx,
4441
4667
  style: {
4442
4668
  fontSize: 12,
4443
4669
  fill: "hsl(var(--muted-foreground))",
@@ -4446,8 +4672,8 @@ var Chart = ({
4446
4672
  }
4447
4673
  } : void 0
4448
4674
  }
4449
- ),
4450
- minDataValue < 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4675
+ ) }),
4676
+ (minDataValue < 0 || minLeft < 0 || minRight < 0) && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4451
4677
  import_recharts.ReferenceLine,
4452
4678
  {
4453
4679
  y: 0,
@@ -4462,16 +4688,22 @@ var Chart = ({
4462
4688
  content: showTooltipTotal ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4463
4689
  TooltipWithTotal_default,
4464
4690
  {
4691
+ periodLabel,
4465
4692
  finalColors,
4466
4693
  valueFormatter: finalValueFormatter,
4467
- categoryFormatter
4694
+ categoryFormatter,
4695
+ yAxisMap,
4696
+ isBiaxial: rightKeys.length > 0
4468
4697
  }
4469
4698
  ) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4470
4699
  TooltipSimple_default,
4471
4700
  {
4701
+ periodLabel,
4472
4702
  finalColors,
4473
4703
  valueFormatter: finalValueFormatter,
4474
- categoryFormatter
4704
+ categoryFormatter,
4705
+ yAxisMap,
4706
+ isBiaxial: rightKeys.length > 0
4475
4707
  }
4476
4708
  ),
4477
4709
  cursor: { fill: "hsl(var(--muted))", opacity: 0.1 }
@@ -4497,6 +4729,7 @@ var Chart = ({
4497
4729
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4498
4730
  import_recharts.Bar,
4499
4731
  {
4732
+ yAxisId: yAxisMap?.[key],
4500
4733
  dataKey: key,
4501
4734
  name: label,
4502
4735
  fill: color,
@@ -4536,6 +4769,7 @@ var Chart = ({
4536
4769
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4537
4770
  import_recharts.Line,
4538
4771
  {
4772
+ yAxisId: yAxisMap?.[key],
4539
4773
  dataKey: key,
4540
4774
  name: label,
4541
4775
  stroke: color,
@@ -4569,6 +4803,7 @@ var Chart = ({
4569
4803
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
4570
4804
  import_recharts.Area,
4571
4805
  {
4806
+ yAxisId: yAxisMap?.[key],
4572
4807
  dataKey: key,
4573
4808
  name: label,
4574
4809
  stroke: color,
@@ -4617,7 +4852,7 @@ var Chart = ({
4617
4852
  showOnlyHighlighted,
4618
4853
  onClose: (id) => setActiveTooltips((prev) => prev.filter((t) => t.id !== id)),
4619
4854
  onPositionChange: onTooltipPositionChange,
4620
- periodLabel: "Per\xEDodo Selecionado",
4855
+ periodLabel,
4621
4856
  dataLabel: "Dados do Per\xEDodo",
4622
4857
  valueFormatter: finalValueFormatter,
4623
4858
  categoryFormatter,