analytica-frontend-lib 1.0.43 → 1.0.44

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.mjs CHANGED
@@ -1254,7 +1254,7 @@ var STATE_CLASSES4 = {
1254
1254
  default: "border-border-300 placeholder:text-text-600 hover:border-border-400",
1255
1255
  error: "border-2 border-indicator-error placeholder:text-text-600",
1256
1256
  disabled: "border-border-300 placeholder:text-text-600 cursor-not-allowed opacity-40",
1257
- "read-only": "border-border-300 !text-text-600 cursor-default focus:outline-none bg-background-50"
1257
+ "read-only": "border-transparent !text-text-600 cursor-default focus:outline-none bg-transparent"
1258
1258
  };
1259
1259
  var VARIANT_CLASSES = {
1260
1260
  outlined: "border rounded-lg",
@@ -1293,6 +1293,9 @@ var getCombinedClasses = (actualState, variant) => {
1293
1293
  if (actualState === "error" && variant === "underlined") {
1294
1294
  return "border-0 border-b-2 border-indicator-error rounded-none bg-transparent focus:outline-none focus:border-primary-950 placeholder:text-text-600";
1295
1295
  }
1296
+ if (actualState === "read-only" && variant === "underlined") {
1297
+ return "border-0 border-b-0 rounded-none bg-transparent focus:outline-none !text-text-900 cursor-default";
1298
+ }
1296
1299
  return `${stateClasses} ${variantClasses}`;
1297
1300
  };
1298
1301
  var Input = forwardRef8(
@@ -1323,7 +1326,7 @@ var Input = forwardRef8(
1323
1326
  [actualState, variant]
1324
1327
  );
1325
1328
  const iconSize = getIconSize(size);
1326
- const baseClasses = "bg-background w-full py-2 px-3 font-normal text-text-900 focus:outline-primary-950";
1329
+ const baseClasses = `bg-background w-full py-2 ${actualState === "read-only" ? "px-0" : "px-3"} font-normal text-text-900 focus:outline-primary-950`;
1327
1330
  const generatedId = useId4();
1328
1331
  const inputId = id ?? `input-${generatedId}`;
1329
1332
  const togglePasswordVisibility = () => setShowPassword(!showPassword);
@@ -1434,7 +1437,7 @@ var Chips = ({
1434
1437
  var Chips_default = Chips;
1435
1438
 
1436
1439
  // src/components/ProgressBar/ProgressBar.tsx
1437
- import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
1440
+ import { Fragment as Fragment2, jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
1438
1441
  var SIZE_CLASSES7 = {
1439
1442
  small: {
1440
1443
  container: "h-1",
@@ -1475,101 +1478,397 @@ var VARIANT_CLASSES2 = {
1475
1478
  // Green for performance (#84D3A2)
1476
1479
  }
1477
1480
  };
1478
- var ProgressBar = ({
1479
- value,
1480
- max = 100,
1481
- size = "medium",
1482
- variant = "blue",
1483
- label,
1484
- showPercentage = false,
1485
- className = "",
1486
- labelClassName = "",
1487
- percentageClassName = ""
1488
- }) => {
1481
+ var calculateProgressValues = (value, max) => {
1489
1482
  const safeValue = isNaN(value) ? 0 : value;
1490
1483
  const clampedValue = Math.max(0, Math.min(safeValue, max));
1491
1484
  const percentage = max === 0 ? 0 : clampedValue / max * 100;
1492
- const sizeClasses = SIZE_CLASSES7[size];
1493
- const variantClasses = VARIANT_CLASSES2[variant];
1494
- return /* @__PURE__ */ jsxs13(
1485
+ return { clampedValue, percentage };
1486
+ };
1487
+ var shouldShowHeader = (label, showPercentage, showHitCount) => {
1488
+ return !!(label || showPercentage || showHitCount);
1489
+ };
1490
+ var getDisplayPriority = (showHitCount, showPercentage, label, clampedValue, max, percentage) => {
1491
+ if (showHitCount) {
1492
+ return {
1493
+ type: "hitCount",
1494
+ content: `${Math.round(clampedValue)} de ${max}`,
1495
+ hasMetrics: true
1496
+ };
1497
+ }
1498
+ if (showPercentage) {
1499
+ return {
1500
+ type: "percentage",
1501
+ content: `${Math.round(percentage)}%`,
1502
+ hasMetrics: true
1503
+ };
1504
+ }
1505
+ return {
1506
+ type: "label",
1507
+ content: label,
1508
+ hasMetrics: false
1509
+ };
1510
+ };
1511
+ var getCompactLayoutConfig = ({
1512
+ showPercentage,
1513
+ showHitCount,
1514
+ percentage,
1515
+ clampedValue,
1516
+ max,
1517
+ label,
1518
+ percentageClassName,
1519
+ labelClassName
1520
+ }) => {
1521
+ const displayPriority = getDisplayPriority(
1522
+ showHitCount,
1523
+ showPercentage,
1524
+ label,
1525
+ clampedValue,
1526
+ max,
1527
+ percentage
1528
+ );
1529
+ return {
1530
+ color: displayPriority.hasMetrics ? "text-primary-600" : "text-primary-700",
1531
+ className: displayPriority.hasMetrics ? percentageClassName : labelClassName,
1532
+ content: displayPriority.content
1533
+ };
1534
+ };
1535
+ var getDefaultLayoutDisplayConfig = (size, label, showPercentage) => ({
1536
+ showHeader: size === "small" && !!(label || showPercentage),
1537
+ showPercentage: size === "medium" && showPercentage,
1538
+ showLabel: size === "medium" && !!label && !showPercentage
1539
+ // Only show label when percentage is not shown
1540
+ });
1541
+ var renderStackedHitCountDisplay = (showHitCount, showPercentage, clampedValue, max, percentage, percentageClassName) => {
1542
+ if (!showHitCount && !showPercentage) return null;
1543
+ const displayPriority = getDisplayPriority(
1544
+ showHitCount,
1545
+ showPercentage,
1546
+ null,
1547
+ // label is not relevant for stacked layout metrics display
1548
+ clampedValue,
1549
+ max,
1550
+ percentage
1551
+ );
1552
+ return /* @__PURE__ */ jsx18(
1495
1553
  "div",
1496
1554
  {
1497
- className: `flex ${sizeClasses.layout} ${size === "medium" ? "gap-2" : sizeClasses.spacing} ${className}`,
1498
- children: [
1499
- size === "small" && (label || showPercentage) && /* @__PURE__ */ jsxs13("div", { className: "flex flex-row items-center justify-between w-full", children: [
1500
- label && /* @__PURE__ */ jsx18(
1501
- Text_default,
1502
- {
1503
- as: "div",
1504
- size: "xs",
1505
- weight: "medium",
1506
- className: `text-text-950 leading-none tracking-normal text-center ${labelClassName}`,
1507
- children: label
1508
- }
1509
- ),
1510
- showPercentage && /* @__PURE__ */ jsxs13(
1511
- Text_default,
1512
- {
1513
- size: "xs",
1514
- weight: "medium",
1515
- className: `text-text-950 leading-none tracking-normal text-center ${percentageClassName}`,
1516
- children: [
1517
- Math.round(percentage),
1518
- "%"
1519
- ]
1520
- }
1521
- )
1522
- ] }),
1523
- /* @__PURE__ */ jsxs13(
1524
- "div",
1525
- {
1526
- className: `${size === "medium" ? "flex-grow" : "w-full"} ${sizeClasses.container} ${variantClasses.background} ${sizeClasses.borderRadius} overflow-hidden relative`,
1527
- children: [
1528
- /* @__PURE__ */ jsx18(
1529
- "progress",
1530
- {
1531
- value: clampedValue,
1532
- max,
1533
- "aria-label": typeof label === "string" ? label : "Progress",
1534
- className: "absolute inset-0 w-full h-full opacity-0"
1535
- }
1536
- ),
1537
- /* @__PURE__ */ jsx18(
1538
- "div",
1539
- {
1540
- className: `${sizeClasses.bar} ${variantClasses.fill} ${sizeClasses.borderRadius} transition-all duration-300 ease-out shadow-hard-shadow-3`,
1541
- style: { width: `${percentage}%` }
1542
- }
1543
- )
1544
- ]
1545
- }
1546
- ),
1547
- size === "medium" && showPercentage && /* @__PURE__ */ jsxs13(
1555
+ className: `text-xs font-medium leading-[14px] text-right ${percentageClassName}`,
1556
+ children: displayPriority.type === "hitCount" ? /* @__PURE__ */ jsxs13(Fragment2, { children: [
1557
+ /* @__PURE__ */ jsx18("span", { className: "text-success-200", children: Math.round(clampedValue) }),
1558
+ /* @__PURE__ */ jsxs13("span", { className: "text-text-600", children: [
1559
+ " de ",
1560
+ max
1561
+ ] })
1562
+ ] }) : /* @__PURE__ */ jsxs13(Text_default, { size: "xs", weight: "medium", className: "text-success-200", children: [
1563
+ Math.round(percentage),
1564
+ "%"
1565
+ ] })
1566
+ }
1567
+ );
1568
+ };
1569
+ var ProgressBarBase = ({
1570
+ clampedValue,
1571
+ max,
1572
+ percentage,
1573
+ label,
1574
+ variantClasses,
1575
+ containerClassName,
1576
+ fillClassName
1577
+ }) => /* @__PURE__ */ jsxs13(
1578
+ "div",
1579
+ {
1580
+ className: `${containerClassName} ${variantClasses.background} overflow-hidden relative`,
1581
+ children: [
1582
+ /* @__PURE__ */ jsx18(
1583
+ "progress",
1584
+ {
1585
+ value: clampedValue,
1586
+ max,
1587
+ "aria-label": typeof label === "string" ? `${label}: ${Math.round(percentage)}% complete` : `Progress: ${Math.round(percentage)}% of ${max}`,
1588
+ className: "absolute inset-0 w-full h-full opacity-0"
1589
+ }
1590
+ ),
1591
+ /* @__PURE__ */ jsx18(
1592
+ "div",
1593
+ {
1594
+ className: `${fillClassName} ${variantClasses.fill} transition-all duration-300 ease-out`,
1595
+ style: { width: `${percentage}%` }
1596
+ }
1597
+ )
1598
+ ]
1599
+ }
1600
+ );
1601
+ var StackedLayout = ({
1602
+ className,
1603
+ label,
1604
+ showPercentage,
1605
+ showHitCount,
1606
+ labelClassName,
1607
+ percentageClassName,
1608
+ clampedValue,
1609
+ max,
1610
+ percentage,
1611
+ variantClasses,
1612
+ dimensions
1613
+ }) => /* @__PURE__ */ jsxs13(
1614
+ "div",
1615
+ {
1616
+ className: `flex flex-col items-start gap-2 ${dimensions.width} ${dimensions.height} ${className}`,
1617
+ children: [
1618
+ shouldShowHeader(label, showPercentage, showHitCount) && /* @__PURE__ */ jsxs13("div", { className: "flex flex-row justify-between items-center w-full h-[19px]", children: [
1619
+ label && /* @__PURE__ */ jsx18(
1548
1620
  Text_default,
1549
1621
  {
1550
- size: "xs",
1622
+ as: "div",
1623
+ size: "md",
1551
1624
  weight: "medium",
1552
- className: `text-text-950 leading-none tracking-normal text-center flex-none ${percentageClassName}`,
1553
- children: [
1554
- Math.round(percentage),
1555
- "%"
1556
- ]
1625
+ className: `text-text-600 leading-[19px] ${labelClassName}`,
1626
+ children: label
1557
1627
  }
1558
1628
  ),
1559
- size === "medium" && label && !showPercentage && /* @__PURE__ */ jsx18(
1629
+ renderStackedHitCountDisplay(
1630
+ showHitCount,
1631
+ showPercentage,
1632
+ clampedValue,
1633
+ max,
1634
+ percentage,
1635
+ percentageClassName
1636
+ )
1637
+ ] }),
1638
+ /* @__PURE__ */ jsx18(
1639
+ ProgressBarBase,
1640
+ {
1641
+ clampedValue,
1642
+ max,
1643
+ percentage,
1644
+ label,
1645
+ variantClasses,
1646
+ containerClassName: "w-full h-2 rounded-lg",
1647
+ fillClassName: "h-2 rounded-lg shadow-hard-shadow-3"
1648
+ }
1649
+ )
1650
+ ]
1651
+ }
1652
+ );
1653
+ var CompactLayout = ({
1654
+ className,
1655
+ label,
1656
+ showPercentage,
1657
+ showHitCount,
1658
+ labelClassName,
1659
+ percentageClassName,
1660
+ clampedValue,
1661
+ max,
1662
+ percentage,
1663
+ variantClasses,
1664
+ dimensions
1665
+ }) => {
1666
+ const {
1667
+ color,
1668
+ className: compactClassName,
1669
+ content
1670
+ } = getCompactLayoutConfig({
1671
+ showPercentage,
1672
+ showHitCount,
1673
+ percentage,
1674
+ clampedValue,
1675
+ max,
1676
+ label,
1677
+ percentageClassName,
1678
+ labelClassName
1679
+ });
1680
+ return /* @__PURE__ */ jsxs13(
1681
+ "div",
1682
+ {
1683
+ className: `flex flex-col items-start gap-1 ${dimensions.width} ${dimensions.height} ${className}`,
1684
+ children: [
1685
+ shouldShowHeader(label, showPercentage, showHitCount) && /* @__PURE__ */ jsx18(
1560
1686
  Text_default,
1561
1687
  {
1562
1688
  as: "div",
1563
- size: "xs",
1689
+ size: "sm",
1564
1690
  weight: "medium",
1565
- className: `text-text-950 leading-none tracking-normal text-center flex-none ${labelClassName}`,
1566
- children: label
1691
+ color,
1692
+ className: `leading-4 w-full ${compactClassName}`,
1693
+ children: content
1694
+ }
1695
+ ),
1696
+ /* @__PURE__ */ jsx18(
1697
+ ProgressBarBase,
1698
+ {
1699
+ clampedValue,
1700
+ max,
1701
+ percentage,
1702
+ label,
1703
+ variantClasses,
1704
+ containerClassName: "w-full h-1 rounded-full",
1705
+ fillClassName: "h-1 rounded-full"
1567
1706
  }
1568
1707
  )
1569
1708
  ]
1570
1709
  }
1571
1710
  );
1572
1711
  };
1712
+ var DefaultLayout = ({
1713
+ className,
1714
+ size,
1715
+ sizeClasses,
1716
+ variantClasses,
1717
+ label,
1718
+ showPercentage,
1719
+ labelClassName,
1720
+ percentageClassName,
1721
+ clampedValue,
1722
+ max,
1723
+ percentage
1724
+ }) => {
1725
+ const gapClass = size === "medium" ? "gap-2" : sizeClasses.spacing;
1726
+ const progressBarClass = size === "medium" ? "flex-grow" : "w-full";
1727
+ const displayConfig = getDefaultLayoutDisplayConfig(
1728
+ size,
1729
+ label,
1730
+ showPercentage
1731
+ );
1732
+ return /* @__PURE__ */ jsxs13("div", { className: `flex ${sizeClasses.layout} ${gapClass} ${className}`, children: [
1733
+ displayConfig.showHeader && /* @__PURE__ */ jsxs13("div", { className: "flex flex-row items-center justify-between w-full", children: [
1734
+ label && /* @__PURE__ */ jsx18(
1735
+ Text_default,
1736
+ {
1737
+ as: "div",
1738
+ size: "xs",
1739
+ weight: "medium",
1740
+ className: `text-text-950 leading-none tracking-normal text-center ${labelClassName}`,
1741
+ children: label
1742
+ }
1743
+ ),
1744
+ showPercentage && /* @__PURE__ */ jsxs13(
1745
+ Text_default,
1746
+ {
1747
+ size: "xs",
1748
+ weight: "medium",
1749
+ className: `text-text-950 leading-none tracking-normal text-center ${percentageClassName}`,
1750
+ children: [
1751
+ Math.round(percentage),
1752
+ "%"
1753
+ ]
1754
+ }
1755
+ )
1756
+ ] }),
1757
+ /* @__PURE__ */ jsx18(
1758
+ ProgressBarBase,
1759
+ {
1760
+ clampedValue,
1761
+ max,
1762
+ percentage,
1763
+ label,
1764
+ variantClasses,
1765
+ containerClassName: `${progressBarClass} ${sizeClasses.container} ${sizeClasses.borderRadius}`,
1766
+ fillClassName: `${sizeClasses.bar} ${sizeClasses.borderRadius} shadow-hard-shadow-3`
1767
+ }
1768
+ ),
1769
+ displayConfig.showPercentage && /* @__PURE__ */ jsxs13(
1770
+ Text_default,
1771
+ {
1772
+ size: "xs",
1773
+ weight: "medium",
1774
+ className: `text-text-950 leading-none tracking-normal text-center flex-none ${percentageClassName}`,
1775
+ children: [
1776
+ Math.round(percentage),
1777
+ "%"
1778
+ ]
1779
+ }
1780
+ ),
1781
+ displayConfig.showLabel && /* @__PURE__ */ jsx18(
1782
+ Text_default,
1783
+ {
1784
+ as: "div",
1785
+ size: "xs",
1786
+ weight: "medium",
1787
+ className: `text-text-950 leading-none tracking-normal text-center flex-none ${labelClassName}`,
1788
+ children: label
1789
+ }
1790
+ )
1791
+ ] });
1792
+ };
1793
+ var ProgressBar = ({
1794
+ value,
1795
+ max = 100,
1796
+ size = "medium",
1797
+ variant = "blue",
1798
+ layout = "default",
1799
+ label,
1800
+ showPercentage = false,
1801
+ showHitCount = false,
1802
+ className = "",
1803
+ labelClassName = "",
1804
+ percentageClassName = "",
1805
+ stackedWidth,
1806
+ stackedHeight,
1807
+ compactWidth,
1808
+ compactHeight
1809
+ }) => {
1810
+ const { clampedValue, percentage } = calculateProgressValues(value, max);
1811
+ const sizeClasses = SIZE_CLASSES7[size];
1812
+ const variantClasses = VARIANT_CLASSES2[variant];
1813
+ if (layout === "stacked") {
1814
+ return /* @__PURE__ */ jsx18(
1815
+ StackedLayout,
1816
+ {
1817
+ className,
1818
+ label,
1819
+ showPercentage,
1820
+ showHitCount,
1821
+ labelClassName,
1822
+ percentageClassName,
1823
+ clampedValue,
1824
+ max,
1825
+ percentage,
1826
+ variantClasses,
1827
+ dimensions: {
1828
+ width: stackedWidth ?? "w-[380px]",
1829
+ height: stackedHeight ?? "h-[35px]"
1830
+ }
1831
+ }
1832
+ );
1833
+ }
1834
+ if (layout === "compact") {
1835
+ return /* @__PURE__ */ jsx18(
1836
+ CompactLayout,
1837
+ {
1838
+ className,
1839
+ label,
1840
+ showPercentage,
1841
+ showHitCount,
1842
+ labelClassName,
1843
+ percentageClassName,
1844
+ clampedValue,
1845
+ max,
1846
+ percentage,
1847
+ variantClasses,
1848
+ dimensions: {
1849
+ width: compactWidth ?? "w-[131px]",
1850
+ height: compactHeight ?? "h-[24px]"
1851
+ }
1852
+ }
1853
+ );
1854
+ }
1855
+ return /* @__PURE__ */ jsx18(
1856
+ DefaultLayout,
1857
+ {
1858
+ className,
1859
+ size,
1860
+ sizeClasses,
1861
+ variantClasses,
1862
+ label,
1863
+ showPercentage,
1864
+ labelClassName,
1865
+ percentageClassName,
1866
+ clampedValue,
1867
+ max,
1868
+ percentage
1869
+ }
1870
+ );
1871
+ };
1573
1872
  var ProgressBar_default = ProgressBar;
1574
1873
 
1575
1874
  // src/components/ProgressCircle/ProgressCircle.tsx
@@ -2627,7 +2926,7 @@ import {
2627
2926
  cloneElement as cloneElement2
2628
2927
  } from "react";
2629
2928
  import { CaretDown, Check as Check3 } from "phosphor-react";
2630
- import { Fragment as Fragment2, jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
2929
+ import { Fragment as Fragment3, jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
2631
2930
  var VARIANT_CLASSES4 = {
2632
2931
  outlined: "border-2 rounded-sm focus:border-primary-950",
2633
2932
  underlined: "border-b-2 focus:border-primary-950",
@@ -2673,7 +2972,7 @@ function getLabelAsNode(children) {
2673
2972
  }
2674
2973
  const flattened = Children2.toArray(children);
2675
2974
  if (flattened.length === 1) return flattened[0];
2676
- return /* @__PURE__ */ jsx22(Fragment2, { children: flattened });
2975
+ return /* @__PURE__ */ jsx22(Fragment3, { children: flattened });
2677
2976
  }
2678
2977
  var injectStore2 = (children, store) => {
2679
2978
  return Children2.map(children, (child) => {