@mlw-packages/react-components 1.7.12 → 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.css +90 -15
- package/dist/index.d.mts +47 -9
- package/dist/index.d.ts +47 -9
- package/dist/index.js +589 -197
- package/dist/index.mjs +656 -264
- package/package.json +3 -2
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,
|
|
@@ -532,6 +532,7 @@ __export(index_exports, {
|
|
|
532
532
|
Chart: () => Chart_default,
|
|
533
533
|
CheckButton: () => CheckButton,
|
|
534
534
|
CheckboxBase: () => CheckboxBase,
|
|
535
|
+
CheckboxTree: () => CheckboxTree,
|
|
535
536
|
CloseAllButton: () => CloseAllButton_default,
|
|
536
537
|
CloseButton: () => CloseButton,
|
|
537
538
|
CodeBlock: () => CodeBlock,
|
|
@@ -1288,6 +1289,7 @@ function ComboboxBase({
|
|
|
1288
1289
|
renderSelected,
|
|
1289
1290
|
handleSelection,
|
|
1290
1291
|
checkIsSelected,
|
|
1292
|
+
disabled = false,
|
|
1291
1293
|
keepOpen = false,
|
|
1292
1294
|
closeAll,
|
|
1293
1295
|
searchPlaceholder,
|
|
@@ -1302,111 +1304,124 @@ function ComboboxBase({
|
|
|
1302
1304
|
className: "col-span-1 w-full",
|
|
1303
1305
|
"data-testid": testIds.root ?? "combobox-base-root",
|
|
1304
1306
|
children: [
|
|
1305
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
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,
|
|
1313
1316
|
{
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
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
|
+
)
|
|
1336
1348
|
}
|
|
1337
|
-
)
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1341
|
-
PopoverContentBase,
|
|
1342
|
-
{
|
|
1343
|
-
className: "max-h-[--radix-popover-content-available-height] w-[--radix-popover-trigger-width] p-0 border-none",
|
|
1344
|
-
"data-testid": testIds.popover ?? "combobox-popover",
|
|
1345
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1346
|
-
CommandBase,
|
|
1349
|
+
),
|
|
1350
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1351
|
+
PopoverContentBase,
|
|
1347
1352
|
{
|
|
1348
|
-
className: "
|
|
1349
|
-
"data-testid": testIds.
|
|
1350
|
-
children:
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
),
|
|
1359
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(CommandListBase, { "data-testid": testIds.list ?? "combobox-list", children: [
|
|
1360
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommandEmptyBase, { "data-testid": testIds.empty ?? "combobox-empty", children: empty }),
|
|
1361
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CommandGroupBase, { "data-testid": testIds.group ?? "combobox-group", children: items.map((item) => {
|
|
1362
|
-
const isSelected = checkIsSelected(item.value);
|
|
1363
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1364
|
-
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,
|
|
1365
1363
|
{
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
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,
|
|
1388
1390
|
{
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
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
|
+
)
|
|
1394
1409
|
}
|
|
1395
1410
|
)
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
)
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1411
|
+
]
|
|
1412
|
+
},
|
|
1413
|
+
item.value
|
|
1414
|
+
);
|
|
1415
|
+
}) })
|
|
1416
|
+
] })
|
|
1417
|
+
]
|
|
1418
|
+
}
|
|
1419
|
+
)
|
|
1405
1420
|
}
|
|
1406
1421
|
)
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1422
|
+
]
|
|
1423
|
+
}
|
|
1424
|
+
),
|
|
1410
1425
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ErrorMessage_default, { error })
|
|
1411
1426
|
]
|
|
1412
1427
|
}
|
|
@@ -1423,6 +1438,7 @@ function Combobox({
|
|
|
1423
1438
|
placeholder,
|
|
1424
1439
|
searchPlaceholder,
|
|
1425
1440
|
empty,
|
|
1441
|
+
disabled = false,
|
|
1426
1442
|
label,
|
|
1427
1443
|
labelClassname,
|
|
1428
1444
|
testIds,
|
|
@@ -1434,11 +1450,15 @@ function Combobox({
|
|
|
1434
1450
|
"span",
|
|
1435
1451
|
{
|
|
1436
1452
|
"data-testid": testIds?.selected ?? "combobox-selected",
|
|
1437
|
-
className: cn(
|
|
1453
|
+
className: cn(
|
|
1454
|
+
"truncate",
|
|
1455
|
+
disabled && "opacity-60 cursor-not-allowed",
|
|
1456
|
+
!selectedItem && "text-gray-500"
|
|
1457
|
+
),
|
|
1438
1458
|
children: selectedItem?.label ?? placeholder ?? "Selecione uma op\xE7\xE3o..."
|
|
1439
1459
|
}
|
|
1440
1460
|
);
|
|
1441
|
-
}, [placeholder, selectedItem, testIds?.selected]);
|
|
1461
|
+
}, [placeholder, selectedItem, testIds?.selected, disabled]);
|
|
1442
1462
|
const checkIsSelected = (0, import_react6.useCallback)(
|
|
1443
1463
|
(value) => selected == null ? false : selected == value,
|
|
1444
1464
|
[selected]
|
|
@@ -1458,6 +1478,7 @@ function Combobox({
|
|
|
1458
1478
|
renderSelected,
|
|
1459
1479
|
handleSelection,
|
|
1460
1480
|
checkIsSelected,
|
|
1481
|
+
disabled,
|
|
1461
1482
|
searchPlaceholder,
|
|
1462
1483
|
empty,
|
|
1463
1484
|
error,
|
|
@@ -1483,8 +1504,10 @@ function MultiCombobox({
|
|
|
1483
1504
|
labelClassname,
|
|
1484
1505
|
testIds = {},
|
|
1485
1506
|
error,
|
|
1507
|
+
disabled = false,
|
|
1486
1508
|
keepOpen = true,
|
|
1487
|
-
showClearAll = false
|
|
1509
|
+
showClearAll = false,
|
|
1510
|
+
empty
|
|
1488
1511
|
}) {
|
|
1489
1512
|
const selectedItems = items.filter((item) => selected.includes(item.value));
|
|
1490
1513
|
const checkIsSelected = (0, import_react7.useCallback)(
|
|
@@ -1508,7 +1531,9 @@ function MultiCombobox({
|
|
|
1508
1531
|
variant: "ghost",
|
|
1509
1532
|
"data-testid": testIds.clearAll ?? "combobox-clear-all",
|
|
1510
1533
|
size: "icon",
|
|
1534
|
+
disabled,
|
|
1511
1535
|
onClick: (e) => {
|
|
1536
|
+
if (disabled) return;
|
|
1512
1537
|
e.stopPropagation();
|
|
1513
1538
|
onChange([]);
|
|
1514
1539
|
},
|
|
@@ -1551,15 +1576,19 @@ function MultiCombobox({
|
|
|
1551
1576
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1552
1577
|
import_framer_motion3.motion.span,
|
|
1553
1578
|
{
|
|
1554
|
-
role: "button",
|
|
1555
|
-
tabIndex: 0,
|
|
1579
|
+
role: disabled ? void 0 : "button",
|
|
1580
|
+
tabIndex: disabled ? -1 : 0,
|
|
1556
1581
|
onClick: (e) => {
|
|
1582
|
+
if (disabled) return;
|
|
1557
1583
|
e.stopPropagation();
|
|
1558
1584
|
handleSelection(item.value);
|
|
1559
1585
|
},
|
|
1560
1586
|
whileHover: { scale: 1.1 },
|
|
1561
1587
|
whileTap: { scale: 0.95 },
|
|
1562
|
-
className:
|
|
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
|
+
),
|
|
1563
1592
|
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react8.XIcon, { size: 14 })
|
|
1564
1593
|
}
|
|
1565
1594
|
)
|
|
@@ -1569,7 +1598,7 @@ function MultiCombobox({
|
|
|
1569
1598
|
)) })
|
|
1570
1599
|
}
|
|
1571
1600
|
);
|
|
1572
|
-
}, [handleSelection, placeholder, selectedItems, testIds]);
|
|
1601
|
+
}, [handleSelection, placeholder, selectedItems, testIds, disabled]);
|
|
1573
1602
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1574
1603
|
"div",
|
|
1575
1604
|
{
|
|
@@ -1594,7 +1623,9 @@ function MultiCombobox({
|
|
|
1594
1623
|
keepOpen,
|
|
1595
1624
|
closeAll,
|
|
1596
1625
|
searchPlaceholder,
|
|
1597
|
-
error
|
|
1626
|
+
error,
|
|
1627
|
+
empty,
|
|
1628
|
+
disabled
|
|
1598
1629
|
}
|
|
1599
1630
|
)
|
|
1600
1631
|
]
|
|
@@ -2199,7 +2230,7 @@ function Select({
|
|
|
2199
2230
|
] });
|
|
2200
2231
|
}
|
|
2201
2232
|
|
|
2202
|
-
// src/components/selects/
|
|
2233
|
+
// src/components/selects/AvatarCombobox.tsx
|
|
2203
2234
|
var import_react15 = require("react");
|
|
2204
2235
|
var import_react16 = require("@phosphor-icons/react");
|
|
2205
2236
|
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
@@ -2224,14 +2255,14 @@ var Square = ({
|
|
|
2224
2255
|
{
|
|
2225
2256
|
"aria-hidden": "true",
|
|
2226
2257
|
className: cn(
|
|
2227
|
-
"flex
|
|
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",
|
|
2228
2259
|
className
|
|
2229
2260
|
),
|
|
2230
2261
|
"data-square": true,
|
|
2231
2262
|
children
|
|
2232
2263
|
}
|
|
2233
2264
|
);
|
|
2234
|
-
function
|
|
2265
|
+
function AvatarCombobox({
|
|
2235
2266
|
items,
|
|
2236
2267
|
groupItems,
|
|
2237
2268
|
placeholder,
|
|
@@ -3518,7 +3549,9 @@ var RechartTooltipWithTotal = ({
|
|
|
3518
3549
|
periodLabel = "Per\xEDodo",
|
|
3519
3550
|
totalLabel = "Total",
|
|
3520
3551
|
valueFormatter: valueFormatter2,
|
|
3521
|
-
categoryFormatter
|
|
3552
|
+
categoryFormatter,
|
|
3553
|
+
yAxisMap,
|
|
3554
|
+
isBiaxial = false
|
|
3522
3555
|
}) => {
|
|
3523
3556
|
if (!active || !payload || payload.length === 0) return null;
|
|
3524
3557
|
const displayLabel = categoryFormatter ? categoryFormatter(String(label ?? "")) : label;
|
|
@@ -3549,6 +3582,13 @@ var RechartTooltipWithTotal = ({
|
|
|
3549
3582
|
(sum, p) => sum + Math.abs(typeof p.value === "number" ? p.value : 0),
|
|
3550
3583
|
0
|
|
3551
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
|
+
}
|
|
3552
3592
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
3553
3593
|
"div",
|
|
3554
3594
|
{
|
|
@@ -3617,7 +3657,12 @@ var RechartTooltipWithTotal = ({
|
|
|
3617
3657
|
children: displayValue
|
|
3618
3658
|
}
|
|
3619
3659
|
),
|
|
3620
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-xs text-muted-foreground", children:
|
|
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)}%` : "-" })
|
|
3621
3666
|
] })
|
|
3622
3667
|
] }),
|
|
3623
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)(
|
|
@@ -3647,7 +3692,9 @@ var TooltipSimple = ({
|
|
|
3647
3692
|
finalColors = {},
|
|
3648
3693
|
periodLabel = "Per\xEDodo",
|
|
3649
3694
|
valueFormatter: valueFormatter2,
|
|
3650
|
-
categoryFormatter
|
|
3695
|
+
categoryFormatter,
|
|
3696
|
+
yAxisMap,
|
|
3697
|
+
isBiaxial = false
|
|
3651
3698
|
}) => {
|
|
3652
3699
|
if (!active || !payload || payload.length === 0) return null;
|
|
3653
3700
|
const displayLabel = categoryFormatter ? categoryFormatter(String(label ?? "")) : label;
|
|
@@ -3666,6 +3713,17 @@ var TooltipSimple = ({
|
|
|
3666
3713
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "divide-y divide-border rounded-md overflow-hidden", children: payload.map((entry, index) => {
|
|
3667
3714
|
const value = typeof entry.value === "number" ? entry.value : 0;
|
|
3668
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
|
+
}
|
|
3669
3727
|
const defaultFormatted = (() => {
|
|
3670
3728
|
try {
|
|
3671
3729
|
if (Math.abs(value) < 1e3) {
|
|
@@ -3700,13 +3758,16 @@ var TooltipSimple = ({
|
|
|
3700
3758
|
),
|
|
3701
3759
|
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-muted-foreground truncate", children: entry.name })
|
|
3702
3760
|
] }),
|
|
3703
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "ml-3", children: /* @__PURE__ */ (0, import_jsx_runtime26.
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
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
|
+
] }) })
|
|
3710
3771
|
]
|
|
3711
3772
|
},
|
|
3712
3773
|
index
|
|
@@ -3771,10 +3832,13 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
|
|
|
3771
3832
|
const vb = props.viewBox;
|
|
3772
3833
|
const cxNum = parseNumber(props.cx);
|
|
3773
3834
|
let centerX;
|
|
3835
|
+
let usedBarCenter = false;
|
|
3774
3836
|
if (typeof px === "number" && typeof pWidth === "number") {
|
|
3775
3837
|
centerX = px + pWidth / 2;
|
|
3838
|
+
usedBarCenter = true;
|
|
3776
3839
|
} else if (typeof xNum === "number" && typeof pWidth === "number") {
|
|
3777
3840
|
centerX = xNum + pWidth / 2;
|
|
3841
|
+
usedBarCenter = true;
|
|
3778
3842
|
} else if (typeof cxNum === "number") {
|
|
3779
3843
|
centerX = cxNum;
|
|
3780
3844
|
} else if (vb && typeof vb.x === "number" && typeof vb.width === "number" && typeof props.index === "number") {
|
|
@@ -3786,32 +3850,26 @@ var renderPillLabel = (color, variant, valueFormatter2) => {
|
|
|
3786
3850
|
} else {
|
|
3787
3851
|
centerX = typeof props.index === "number" ? props.index * 40 + 24 : 0;
|
|
3788
3852
|
}
|
|
3789
|
-
if (vb && typeof vb.x === "number" && typeof vb.width === "number") {
|
|
3790
|
-
const minX = vb.x +
|
|
3791
|
-
const maxX = vb.x + vb.width -
|
|
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;
|
|
3792
3856
|
centerX = Math.max(minX, Math.min(maxX, centerX));
|
|
3793
3857
|
}
|
|
3794
3858
|
const yNum = parseNumber(y);
|
|
3795
3859
|
const py = parseNumber(props.y);
|
|
3796
3860
|
const cyNum = parseNumber(props.cy);
|
|
3797
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);
|
|
3798
|
-
const rectX = centerX - pillWidth /
|
|
3862
|
+
const rectX = centerX - pillWidth / 2;
|
|
3799
3863
|
const rectY = centerY - pillHeight - 6;
|
|
3800
|
-
const textX = centerX
|
|
3864
|
+
const textX = centerX;
|
|
3801
3865
|
const textY = rectY + pillHeight / 2 + 3;
|
|
3802
3866
|
const rectFill = variant === "filled" ? color : variant === "soft" ? `${color}20` : "#ffffff";
|
|
3803
3867
|
const rectStroke = variant === "outline" ? `${color}CC` : void 0;
|
|
3804
|
-
const numValue = parseNumber(value);
|
|
3805
|
-
const isNegative = typeof numValue === "number" && numValue < 0;
|
|
3806
3868
|
let textColor;
|
|
3807
|
-
if (
|
|
3808
|
-
textColor = "#
|
|
3869
|
+
if (variant === "filled") {
|
|
3870
|
+
textColor = "#ffffff";
|
|
3809
3871
|
} else {
|
|
3810
|
-
|
|
3811
|
-
textColor = "#ffffff";
|
|
3812
|
-
} else {
|
|
3813
|
-
textColor = "#374151";
|
|
3814
|
-
}
|
|
3872
|
+
textColor = "#374151";
|
|
3815
3873
|
}
|
|
3816
3874
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("g", { children: [
|
|
3817
3875
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
@@ -3876,7 +3934,10 @@ var Chart = ({
|
|
|
3876
3934
|
showTooltipTotal = false,
|
|
3877
3935
|
maxTooltips = 5,
|
|
3878
3936
|
formatBR = false,
|
|
3879
|
-
chartMargin
|
|
3937
|
+
chartMargin,
|
|
3938
|
+
yAxisMap,
|
|
3939
|
+
yAxes,
|
|
3940
|
+
periodLabel = "Per\xEDodo"
|
|
3880
3941
|
}) => {
|
|
3881
3942
|
const smartConfig = (0, import_react21.useMemo)(() => {
|
|
3882
3943
|
const resolvedXAxisKey = typeof xAxis === "string" ? xAxis : xAxis && xAxis.dataKey || detectXAxis(data);
|
|
@@ -4007,6 +4068,70 @@ var Chart = ({
|
|
|
4007
4068
|
}
|
|
4008
4069
|
return min;
|
|
4009
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]);
|
|
4010
4135
|
const niceMax = (0, import_react21.useMemo)(() => {
|
|
4011
4136
|
let padding = 0.08;
|
|
4012
4137
|
if (maxDataValue > 1e6) padding = 0.05;
|
|
@@ -4196,8 +4321,57 @@ var Chart = ({
|
|
|
4196
4321
|
const defaultChartRightMargin = 30;
|
|
4197
4322
|
const defaultChartLeftMargin = 0;
|
|
4198
4323
|
const containerPaddingLeft = 16;
|
|
4199
|
-
const
|
|
4200
|
-
|
|
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;
|
|
4201
4375
|
const finalChartTopMargin = chartMargin?.top ?? (showLabels ? 48 : 20);
|
|
4202
4376
|
const baseBottom = chartMargin?.bottom ?? 5;
|
|
4203
4377
|
const extraForXAxisLabel = xAxisLabel ? 22 : 0;
|
|
@@ -4275,8 +4449,7 @@ var Chart = ({
|
|
|
4275
4449
|
ref: wrapperRef,
|
|
4276
4450
|
style: {
|
|
4277
4451
|
width: "100%",
|
|
4278
|
-
|
|
4279
|
-
overflowY: "hidden",
|
|
4452
|
+
overflow: "visible",
|
|
4280
4453
|
minWidth: 0
|
|
4281
4454
|
},
|
|
4282
4455
|
children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
@@ -4291,7 +4464,6 @@ var Chart = ({
|
|
|
4291
4464
|
style: {
|
|
4292
4465
|
paddingLeft: `${containerPaddingLeft + finalChartLeftMargin}px`,
|
|
4293
4466
|
width: "100%",
|
|
4294
|
-
maxWidth: `${chartInnerWidth}px`,
|
|
4295
4467
|
display: "flex",
|
|
4296
4468
|
justifyContent: titlePosition === "center" ? "center" : titlePosition === "right" ? "flex-end" : "flex-start",
|
|
4297
4469
|
alignItems: "center",
|
|
@@ -4413,8 +4585,8 @@ var Chart = ({
|
|
|
4413
4585
|
},
|
|
4414
4586
|
label: xAxisLabel ? {
|
|
4415
4587
|
value: xAxisLabel,
|
|
4416
|
-
position: "
|
|
4417
|
-
offset:
|
|
4588
|
+
position: "bottom",
|
|
4589
|
+
offset: 12,
|
|
4418
4590
|
style: {
|
|
4419
4591
|
fontSize: 12,
|
|
4420
4592
|
fill: "hsl(var(--muted-foreground))",
|
|
@@ -4423,7 +4595,61 @@ var Chart = ({
|
|
|
4423
4595
|
} : void 0
|
|
4424
4596
|
}
|
|
4425
4597
|
),
|
|
4426
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.
|
|
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)(
|
|
4427
4653
|
import_recharts.YAxis,
|
|
4428
4654
|
{
|
|
4429
4655
|
stroke: "hsl(var(--muted-foreground))",
|
|
@@ -4436,7 +4662,8 @@ var Chart = ({
|
|
|
4436
4662
|
label: yAxisLabel ? {
|
|
4437
4663
|
value: yAxisLabel,
|
|
4438
4664
|
angle: -90,
|
|
4439
|
-
position: "
|
|
4665
|
+
position: "left",
|
|
4666
|
+
dx: -leftYAxisLabelDx,
|
|
4440
4667
|
style: {
|
|
4441
4668
|
fontSize: 12,
|
|
4442
4669
|
fill: "hsl(var(--muted-foreground))",
|
|
@@ -4445,8 +4672,8 @@ var Chart = ({
|
|
|
4445
4672
|
}
|
|
4446
4673
|
} : void 0
|
|
4447
4674
|
}
|
|
4448
|
-
),
|
|
4449
|
-
minDataValue < 0 && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4675
|
+
) }),
|
|
4676
|
+
(minDataValue < 0 || minLeft < 0 || minRight < 0) && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4450
4677
|
import_recharts.ReferenceLine,
|
|
4451
4678
|
{
|
|
4452
4679
|
y: 0,
|
|
@@ -4461,16 +4688,22 @@ var Chart = ({
|
|
|
4461
4688
|
content: showTooltipTotal ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4462
4689
|
TooltipWithTotal_default,
|
|
4463
4690
|
{
|
|
4691
|
+
periodLabel,
|
|
4464
4692
|
finalColors,
|
|
4465
4693
|
valueFormatter: finalValueFormatter,
|
|
4466
|
-
categoryFormatter
|
|
4694
|
+
categoryFormatter,
|
|
4695
|
+
yAxisMap,
|
|
4696
|
+
isBiaxial: rightKeys.length > 0
|
|
4467
4697
|
}
|
|
4468
4698
|
) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4469
4699
|
TooltipSimple_default,
|
|
4470
4700
|
{
|
|
4701
|
+
periodLabel,
|
|
4471
4702
|
finalColors,
|
|
4472
4703
|
valueFormatter: finalValueFormatter,
|
|
4473
|
-
categoryFormatter
|
|
4704
|
+
categoryFormatter,
|
|
4705
|
+
yAxisMap,
|
|
4706
|
+
isBiaxial: rightKeys.length > 0
|
|
4474
4707
|
}
|
|
4475
4708
|
),
|
|
4476
4709
|
cursor: { fill: "hsl(var(--muted))", opacity: 0.1 }
|
|
@@ -4496,6 +4729,7 @@ var Chart = ({
|
|
|
4496
4729
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4497
4730
|
import_recharts.Bar,
|
|
4498
4731
|
{
|
|
4732
|
+
yAxisId: yAxisMap?.[key],
|
|
4499
4733
|
dataKey: key,
|
|
4500
4734
|
name: label,
|
|
4501
4735
|
fill: color,
|
|
@@ -4535,6 +4769,7 @@ var Chart = ({
|
|
|
4535
4769
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4536
4770
|
import_recharts.Line,
|
|
4537
4771
|
{
|
|
4772
|
+
yAxisId: yAxisMap?.[key],
|
|
4538
4773
|
dataKey: key,
|
|
4539
4774
|
name: label,
|
|
4540
4775
|
stroke: color,
|
|
@@ -4568,6 +4803,7 @@ var Chart = ({
|
|
|
4568
4803
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4569
4804
|
import_recharts.Area,
|
|
4570
4805
|
{
|
|
4806
|
+
yAxisId: yAxisMap?.[key],
|
|
4571
4807
|
dataKey: key,
|
|
4572
4808
|
name: label,
|
|
4573
4809
|
stroke: color,
|
|
@@ -4616,7 +4852,7 @@ var Chart = ({
|
|
|
4616
4852
|
showOnlyHighlighted,
|
|
4617
4853
|
onClose: (id) => setActiveTooltips((prev) => prev.filter((t) => t.id !== id)),
|
|
4618
4854
|
onPositionChange: onTooltipPositionChange,
|
|
4619
|
-
periodLabel
|
|
4855
|
+
periodLabel,
|
|
4620
4856
|
dataLabel: "Dados do Per\xEDodo",
|
|
4621
4857
|
valueFormatter: finalValueFormatter,
|
|
4622
4858
|
categoryFormatter,
|
|
@@ -7527,44 +7763,50 @@ var CheckboxPrimitive = __toESM(require("@radix-ui/react-checkbox"));
|
|
|
7527
7763
|
var import_react30 = require("@phosphor-icons/react");
|
|
7528
7764
|
var import_framer_motion11 = require("framer-motion");
|
|
7529
7765
|
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
7530
|
-
var CheckboxBase = React24.forwardRef(({ className, testid: dataTestId = "checkbox-base", ...props }, ref) =>
|
|
7531
|
-
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7541
|
-
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
))
|
|
7766
|
+
var CheckboxBase = React24.forwardRef(({ className, testid: dataTestId = "checkbox-base", checked: checkedProp, defaultChecked, onCheckedChange, ...props }, ref) => {
|
|
7767
|
+
const isControlled = checkedProp !== void 0;
|
|
7768
|
+
const [checkedState, setCheckedState] = React24.useState(
|
|
7769
|
+
isControlled ? checkedProp : defaultChecked ?? false
|
|
7770
|
+
);
|
|
7771
|
+
React24.useEffect(() => {
|
|
7772
|
+
if (isControlled) setCheckedState(checkedProp);
|
|
7773
|
+
}, [checkedProp, isControlled]);
|
|
7774
|
+
const handleCheckedChange = (next) => {
|
|
7775
|
+
if (!isControlled) setCheckedState(next);
|
|
7776
|
+
onCheckedChange?.(next);
|
|
7777
|
+
};
|
|
7778
|
+
const stateClass = checkedState === true || checkedState === "indeterminate" ? "bg-primary text-primary-foreground" : "";
|
|
7779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
7780
|
+
CheckboxPrimitive.Root,
|
|
7781
|
+
{
|
|
7782
|
+
ref,
|
|
7783
|
+
checked: checkedProp,
|
|
7784
|
+
defaultChecked,
|
|
7785
|
+
onCheckedChange: handleCheckedChange,
|
|
7786
|
+
className: cn(
|
|
7787
|
+
"group h-4 w-4 shrink-0 rounded-md border border-primary shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 transition-colors",
|
|
7788
|
+
stateClass,
|
|
7789
|
+
className
|
|
7790
|
+
),
|
|
7791
|
+
"data-testid": dataTestId,
|
|
7792
|
+
...props,
|
|
7793
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(CheckboxPrimitive.Indicator, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
|
|
7794
|
+
import_framer_motion11.motion.div,
|
|
7795
|
+
{
|
|
7796
|
+
initial: { scale: 0, opacity: 0, rotate: -90 },
|
|
7797
|
+
animate: { scale: 1, opacity: 1, rotate: 0 },
|
|
7798
|
+
exit: { scale: 0, opacity: 0, rotate: 90 },
|
|
7799
|
+
transition: { type: "spring", stiffness: 500, damping: 30 },
|
|
7800
|
+
className: "flex items-center justify-center text-current",
|
|
7801
|
+
children: [
|
|
7802
|
+
checkedState === true && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react30.CheckIcon, { className: "h-4 w-4", weight: "bold" }),
|
|
7803
|
+
checkedState === "indeterminate" && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_react30.MinusIcon, { className: "h-4 w-4", weight: "bold" })
|
|
7804
|
+
]
|
|
7805
|
+
}
|
|
7806
|
+
) })
|
|
7807
|
+
}
|
|
7808
|
+
);
|
|
7809
|
+
});
|
|
7568
7810
|
CheckboxBase.displayName = CheckboxPrimitive.Root.displayName;
|
|
7569
7811
|
|
|
7570
7812
|
// src/components/ui/form/CollapsibleBase.tsx
|
|
@@ -14481,14 +14723,164 @@ function WeekView({
|
|
|
14481
14723
|
] });
|
|
14482
14724
|
}
|
|
14483
14725
|
|
|
14484
|
-
// src/
|
|
14726
|
+
// src/components/ui/form/CheckBoxThree.tsx
|
|
14485
14727
|
var import_react69 = require("react");
|
|
14728
|
+
var import_framer_motion19 = require("framer-motion");
|
|
14729
|
+
var import_jsx_runtime83 = require("react/jsx-runtime");
|
|
14730
|
+
function useCheckboxTree(initialTree) {
|
|
14731
|
+
const initialCheckedNodes = (0, import_react69.useMemo)(() => {
|
|
14732
|
+
const checkedSet = /* @__PURE__ */ new Set();
|
|
14733
|
+
const initializeCheckedNodes = (node) => {
|
|
14734
|
+
if (node.defaultChecked) {
|
|
14735
|
+
checkedSet.add(node.id);
|
|
14736
|
+
}
|
|
14737
|
+
node.children?.forEach(initializeCheckedNodes);
|
|
14738
|
+
};
|
|
14739
|
+
initializeCheckedNodes(initialTree);
|
|
14740
|
+
return checkedSet;
|
|
14741
|
+
}, [initialTree]);
|
|
14742
|
+
const [checkedNodes, setCheckedNodes] = (0, import_react69.useState)(initialCheckedNodes);
|
|
14743
|
+
const isChecked = (0, import_react69.useCallback)(
|
|
14744
|
+
(node) => {
|
|
14745
|
+
if (!node.children) {
|
|
14746
|
+
return checkedNodes.has(node.id);
|
|
14747
|
+
}
|
|
14748
|
+
const childrenChecked = node.children.map((child) => isChecked(child));
|
|
14749
|
+
if (childrenChecked.every((status) => status === true)) {
|
|
14750
|
+
return true;
|
|
14751
|
+
}
|
|
14752
|
+
if (childrenChecked.some(
|
|
14753
|
+
(status) => status === true || status === "indeterminate"
|
|
14754
|
+
)) {
|
|
14755
|
+
return "indeterminate";
|
|
14756
|
+
}
|
|
14757
|
+
return false;
|
|
14758
|
+
},
|
|
14759
|
+
[checkedNodes]
|
|
14760
|
+
);
|
|
14761
|
+
const handleCheck = (0, import_react69.useCallback)(
|
|
14762
|
+
(node) => {
|
|
14763
|
+
const newCheckedNodes = new Set(checkedNodes);
|
|
14764
|
+
const toggleNode = (n, check) => {
|
|
14765
|
+
if (check) {
|
|
14766
|
+
newCheckedNodes.add(n.id);
|
|
14767
|
+
} else {
|
|
14768
|
+
newCheckedNodes.delete(n.id);
|
|
14769
|
+
}
|
|
14770
|
+
for (const child of n.children ?? []) {
|
|
14771
|
+
toggleNode(child, check);
|
|
14772
|
+
}
|
|
14773
|
+
};
|
|
14774
|
+
const currentStatus = isChecked(node);
|
|
14775
|
+
const newCheck = currentStatus !== true;
|
|
14776
|
+
toggleNode(node, newCheck);
|
|
14777
|
+
setCheckedNodes(newCheckedNodes);
|
|
14778
|
+
},
|
|
14779
|
+
[checkedNodes, isChecked]
|
|
14780
|
+
);
|
|
14781
|
+
return { handleCheck, isChecked };
|
|
14782
|
+
}
|
|
14783
|
+
function CheckboxTree({ tree, renderNode }) {
|
|
14784
|
+
const { isChecked, handleCheck } = useCheckboxTree(tree);
|
|
14785
|
+
const DefaultNode = ({
|
|
14786
|
+
node,
|
|
14787
|
+
isChecked: status,
|
|
14788
|
+
onCheckedChange,
|
|
14789
|
+
children
|
|
14790
|
+
}) => {
|
|
14791
|
+
const [open, setOpen] = (0, import_react69.useState)(() => !!node.children && status !== false);
|
|
14792
|
+
const checkboxRef = (0, import_react69.useRef)(null);
|
|
14793
|
+
(0, import_react69.useEffect)(() => {
|
|
14794
|
+
if (checkboxRef.current) {
|
|
14795
|
+
checkboxRef.current.indeterminate = status === "indeterminate";
|
|
14796
|
+
}
|
|
14797
|
+
if (node.children) {
|
|
14798
|
+
setOpen(status !== false);
|
|
14799
|
+
}
|
|
14800
|
+
}, [status, node.children]);
|
|
14801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "pl-1", children: [
|
|
14802
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
14803
|
+
node.children ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
14804
|
+
"button",
|
|
14805
|
+
{
|
|
14806
|
+
"aria-label": open ? "Fechar" : "Abrir",
|
|
14807
|
+
onClick: () => setOpen((v) => !v),
|
|
14808
|
+
className: "w-6 h-6 flex items-center justify-center rounded hover:bg-slate-100 dark:hover:bg-slate-800",
|
|
14809
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
14810
|
+
import_framer_motion19.motion.span,
|
|
14811
|
+
{
|
|
14812
|
+
animate: { rotate: open ? 90 : 0 },
|
|
14813
|
+
transition: { duration: 0.18 },
|
|
14814
|
+
className: "inline-block text-slate-500",
|
|
14815
|
+
children: "\u25B6"
|
|
14816
|
+
}
|
|
14817
|
+
)
|
|
14818
|
+
}
|
|
14819
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "w-6 h-6" }),
|
|
14820
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("label", { className: "flex items-center gap-2 cursor-pointer select-none", children: [
|
|
14821
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsxs)("span", { className: "relative", children: [
|
|
14822
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
14823
|
+
"input",
|
|
14824
|
+
{
|
|
14825
|
+
ref: checkboxRef,
|
|
14826
|
+
type: "checkbox",
|
|
14827
|
+
checked: status === true,
|
|
14828
|
+
onChange: onCheckedChange,
|
|
14829
|
+
className: "appearance-none w-5 h-5 rounded border border-slate-300 dark:border-slate-700 flex items-center justify-center bg-white dark:bg-slate-900 checked:bg-blue-600 checked:border-blue-600 focus:outline-none"
|
|
14830
|
+
}
|
|
14831
|
+
),
|
|
14832
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
14833
|
+
import_framer_motion19.motion.span,
|
|
14834
|
+
{
|
|
14835
|
+
initial: false,
|
|
14836
|
+
animate: { scale: status === true ? 1 : 0.8, opacity: status === true ? 1 : 0 },
|
|
14837
|
+
transition: { duration: 0.14 },
|
|
14838
|
+
className: "pointer-events-none absolute left-0 top-0 w-5 h-5 flex items-center justify-center text-white",
|
|
14839
|
+
children: status === true ? /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("svg", { width: "12", height: "10", viewBox: "0 0 12 10", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("path", { d: "M1 5L4 8L11 1", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) : null
|
|
14840
|
+
}
|
|
14841
|
+
)
|
|
14842
|
+
] }),
|
|
14843
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)("span", { className: "text-sm text-slate-700 dark:text-slate-200", children: node.label })
|
|
14844
|
+
] })
|
|
14845
|
+
] }),
|
|
14846
|
+
/* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_framer_motion19.AnimatePresence, { initial: false, children: open && node.children && /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
14847
|
+
import_framer_motion19.motion.div,
|
|
14848
|
+
{
|
|
14849
|
+
initial: { height: 0, opacity: 0 },
|
|
14850
|
+
animate: { height: "auto", opacity: 1 },
|
|
14851
|
+
exit: { height: 0, opacity: 0 },
|
|
14852
|
+
transition: { duration: 0.18 },
|
|
14853
|
+
className: "ml-6 mt-2 overflow-hidden",
|
|
14854
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "flex flex-col gap-1", children })
|
|
14855
|
+
},
|
|
14856
|
+
"children"
|
|
14857
|
+
) })
|
|
14858
|
+
] });
|
|
14859
|
+
};
|
|
14860
|
+
const renderTreeNode = (node) => {
|
|
14861
|
+
const children = node.children?.map(renderTreeNode);
|
|
14862
|
+
const nodePayload = {
|
|
14863
|
+
children,
|
|
14864
|
+
isChecked: isChecked(node),
|
|
14865
|
+
node,
|
|
14866
|
+
onCheckedChange: () => handleCheck(node)
|
|
14867
|
+
};
|
|
14868
|
+
if (renderNode) {
|
|
14869
|
+
return renderNode(nodePayload);
|
|
14870
|
+
}
|
|
14871
|
+
return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(DefaultNode, { ...nodePayload });
|
|
14872
|
+
};
|
|
14873
|
+
return renderTreeNode(tree);
|
|
14874
|
+
}
|
|
14875
|
+
|
|
14876
|
+
// src/hooks/use-drag.tsx
|
|
14877
|
+
var import_react70 = require("react");
|
|
14486
14878
|
var useDrag = (options = {}) => {
|
|
14487
|
-
const [isDragging, setIsDragging] = (0,
|
|
14488
|
-
const [positions, setPositions] = (0,
|
|
14489
|
-
const dragStartPos = (0,
|
|
14490
|
-
const dragId = (0,
|
|
14491
|
-
const handleMouseDown = (0,
|
|
14879
|
+
const [isDragging, setIsDragging] = (0, import_react70.useState)(null);
|
|
14880
|
+
const [positions, setPositions] = (0, import_react70.useState)({});
|
|
14881
|
+
const dragStartPos = (0, import_react70.useRef)(null);
|
|
14882
|
+
const dragId = (0, import_react70.useRef)(null);
|
|
14883
|
+
const handleMouseDown = (0, import_react70.useCallback)((id, e) => {
|
|
14492
14884
|
e.preventDefault();
|
|
14493
14885
|
const currentPosition = positions[id] || { top: 0, left: 0 };
|
|
14494
14886
|
dragStartPos.current = {
|
|
@@ -14501,7 +14893,7 @@ var useDrag = (options = {}) => {
|
|
|
14501
14893
|
setIsDragging(id);
|
|
14502
14894
|
options.onDragStart?.(id);
|
|
14503
14895
|
}, [positions, options]);
|
|
14504
|
-
const handleMouseMove = (0,
|
|
14896
|
+
const handleMouseMove = (0, import_react70.useCallback)((e) => {
|
|
14505
14897
|
if (!isDragging || !dragStartPos.current || !dragId.current) return;
|
|
14506
14898
|
const deltaX = e.clientX - dragStartPos.current.x;
|
|
14507
14899
|
const deltaY = e.clientY - dragStartPos.current.y;
|
|
@@ -14517,7 +14909,7 @@ var useDrag = (options = {}) => {
|
|
|
14517
14909
|
}));
|
|
14518
14910
|
options.onDrag?.(dragId.current, newPosition);
|
|
14519
14911
|
}, [isDragging, options]);
|
|
14520
|
-
const handleMouseUp = (0,
|
|
14912
|
+
const handleMouseUp = (0, import_react70.useCallback)(() => {
|
|
14521
14913
|
if (dragId.current) {
|
|
14522
14914
|
options.onDragEnd?.(dragId.current);
|
|
14523
14915
|
}
|
|
@@ -14525,7 +14917,7 @@ var useDrag = (options = {}) => {
|
|
|
14525
14917
|
dragStartPos.current = null;
|
|
14526
14918
|
dragId.current = null;
|
|
14527
14919
|
}, [options]);
|
|
14528
|
-
(0,
|
|
14920
|
+
(0, import_react70.useEffect)(() => {
|
|
14529
14921
|
if (isDragging) {
|
|
14530
14922
|
document.addEventListener("mousemove", handleMouseMove);
|
|
14531
14923
|
document.addEventListener("mouseup", handleMouseUp);
|
|
@@ -14537,16 +14929,16 @@ var useDrag = (options = {}) => {
|
|
|
14537
14929
|
};
|
|
14538
14930
|
}
|
|
14539
14931
|
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
14540
|
-
const setPosition = (0,
|
|
14932
|
+
const setPosition = (0, import_react70.useCallback)((id, position) => {
|
|
14541
14933
|
setPositions((prev) => ({
|
|
14542
14934
|
...prev,
|
|
14543
14935
|
[id]: position
|
|
14544
14936
|
}));
|
|
14545
14937
|
}, []);
|
|
14546
|
-
const getPosition = (0,
|
|
14938
|
+
const getPosition = (0, import_react70.useCallback)((id) => {
|
|
14547
14939
|
return positions[id] || { top: 0, left: 0 };
|
|
14548
14940
|
}, [positions]);
|
|
14549
|
-
const isElementDragging = (0,
|
|
14941
|
+
const isElementDragging = (0, import_react70.useCallback)((id) => {
|
|
14550
14942
|
return isDragging === id;
|
|
14551
14943
|
}, [isDragging]);
|
|
14552
14944
|
return {
|