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.js CHANGED
@@ -1301,7 +1301,7 @@ var STATE_CLASSES4 = {
1301
1301
  default: "border-border-300 placeholder:text-text-600 hover:border-border-400",
1302
1302
  error: "border-2 border-indicator-error placeholder:text-text-600",
1303
1303
  disabled: "border-border-300 placeholder:text-text-600 cursor-not-allowed opacity-40",
1304
- "read-only": "border-border-300 !text-text-600 cursor-default focus:outline-none bg-background-50"
1304
+ "read-only": "border-transparent !text-text-600 cursor-default focus:outline-none bg-transparent"
1305
1305
  };
1306
1306
  var VARIANT_CLASSES = {
1307
1307
  outlined: "border rounded-lg",
@@ -1340,6 +1340,9 @@ var getCombinedClasses = (actualState, variant) => {
1340
1340
  if (actualState === "error" && variant === "underlined") {
1341
1341
  return "border-0 border-b-2 border-indicator-error rounded-none bg-transparent focus:outline-none focus:border-primary-950 placeholder:text-text-600";
1342
1342
  }
1343
+ if (actualState === "read-only" && variant === "underlined") {
1344
+ return "border-0 border-b-0 rounded-none bg-transparent focus:outline-none !text-text-900 cursor-default";
1345
+ }
1343
1346
  return `${stateClasses} ${variantClasses}`;
1344
1347
  };
1345
1348
  var Input = (0, import_react8.forwardRef)(
@@ -1370,7 +1373,7 @@ var Input = (0, import_react8.forwardRef)(
1370
1373
  [actualState, variant]
1371
1374
  );
1372
1375
  const iconSize = getIconSize(size);
1373
- const baseClasses = "bg-background w-full py-2 px-3 font-normal text-text-900 focus:outline-primary-950";
1376
+ const baseClasses = `bg-background w-full py-2 ${actualState === "read-only" ? "px-0" : "px-3"} font-normal text-text-900 focus:outline-primary-950`;
1374
1377
  const generatedId = (0, import_react8.useId)();
1375
1378
  const inputId = id ?? `input-${generatedId}`;
1376
1379
  const togglePasswordVisibility = () => setShowPassword(!showPassword);
@@ -1522,101 +1525,397 @@ var VARIANT_CLASSES2 = {
1522
1525
  // Green for performance (#84D3A2)
1523
1526
  }
1524
1527
  };
1525
- var ProgressBar = ({
1526
- value,
1527
- max = 100,
1528
- size = "medium",
1529
- variant = "blue",
1530
- label,
1531
- showPercentage = false,
1532
- className = "",
1533
- labelClassName = "",
1534
- percentageClassName = ""
1535
- }) => {
1528
+ var calculateProgressValues = (value, max) => {
1536
1529
  const safeValue = isNaN(value) ? 0 : value;
1537
1530
  const clampedValue = Math.max(0, Math.min(safeValue, max));
1538
1531
  const percentage = max === 0 ? 0 : clampedValue / max * 100;
1539
- const sizeClasses = SIZE_CLASSES7[size];
1540
- const variantClasses = VARIANT_CLASSES2[variant];
1541
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1532
+ return { clampedValue, percentage };
1533
+ };
1534
+ var shouldShowHeader = (label, showPercentage, showHitCount) => {
1535
+ return !!(label || showPercentage || showHitCount);
1536
+ };
1537
+ var getDisplayPriority = (showHitCount, showPercentage, label, clampedValue, max, percentage) => {
1538
+ if (showHitCount) {
1539
+ return {
1540
+ type: "hitCount",
1541
+ content: `${Math.round(clampedValue)} de ${max}`,
1542
+ hasMetrics: true
1543
+ };
1544
+ }
1545
+ if (showPercentage) {
1546
+ return {
1547
+ type: "percentage",
1548
+ content: `${Math.round(percentage)}%`,
1549
+ hasMetrics: true
1550
+ };
1551
+ }
1552
+ return {
1553
+ type: "label",
1554
+ content: label,
1555
+ hasMetrics: false
1556
+ };
1557
+ };
1558
+ var getCompactLayoutConfig = ({
1559
+ showPercentage,
1560
+ showHitCount,
1561
+ percentage,
1562
+ clampedValue,
1563
+ max,
1564
+ label,
1565
+ percentageClassName,
1566
+ labelClassName
1567
+ }) => {
1568
+ const displayPriority = getDisplayPriority(
1569
+ showHitCount,
1570
+ showPercentage,
1571
+ label,
1572
+ clampedValue,
1573
+ max,
1574
+ percentage
1575
+ );
1576
+ return {
1577
+ color: displayPriority.hasMetrics ? "text-primary-600" : "text-primary-700",
1578
+ className: displayPriority.hasMetrics ? percentageClassName : labelClassName,
1579
+ content: displayPriority.content
1580
+ };
1581
+ };
1582
+ var getDefaultLayoutDisplayConfig = (size, label, showPercentage) => ({
1583
+ showHeader: size === "small" && !!(label || showPercentage),
1584
+ showPercentage: size === "medium" && showPercentage,
1585
+ showLabel: size === "medium" && !!label && !showPercentage
1586
+ // Only show label when percentage is not shown
1587
+ });
1588
+ var renderStackedHitCountDisplay = (showHitCount, showPercentage, clampedValue, max, percentage, percentageClassName) => {
1589
+ if (!showHitCount && !showPercentage) return null;
1590
+ const displayPriority = getDisplayPriority(
1591
+ showHitCount,
1592
+ showPercentage,
1593
+ null,
1594
+ // label is not relevant for stacked layout metrics display
1595
+ clampedValue,
1596
+ max,
1597
+ percentage
1598
+ );
1599
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1542
1600
  "div",
1543
1601
  {
1544
- className: `flex ${sizeClasses.layout} ${size === "medium" ? "gap-2" : sizeClasses.spacing} ${className}`,
1545
- children: [
1546
- size === "small" && (label || showPercentage) && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-row items-center justify-between w-full", children: [
1547
- label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1548
- Text_default,
1549
- {
1550
- as: "div",
1551
- size: "xs",
1552
- weight: "medium",
1553
- className: `text-text-950 leading-none tracking-normal text-center ${labelClassName}`,
1554
- children: label
1555
- }
1556
- ),
1557
- showPercentage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1558
- Text_default,
1559
- {
1560
- size: "xs",
1561
- weight: "medium",
1562
- className: `text-text-950 leading-none tracking-normal text-center ${percentageClassName}`,
1563
- children: [
1564
- Math.round(percentage),
1565
- "%"
1566
- ]
1567
- }
1568
- )
1569
- ] }),
1570
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1571
- "div",
1572
- {
1573
- className: `${size === "medium" ? "flex-grow" : "w-full"} ${sizeClasses.container} ${variantClasses.background} ${sizeClasses.borderRadius} overflow-hidden relative`,
1574
- children: [
1575
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1576
- "progress",
1577
- {
1578
- value: clampedValue,
1579
- max,
1580
- "aria-label": typeof label === "string" ? label : "Progress",
1581
- className: "absolute inset-0 w-full h-full opacity-0"
1582
- }
1583
- ),
1584
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1585
- "div",
1586
- {
1587
- className: `${sizeClasses.bar} ${variantClasses.fill} ${sizeClasses.borderRadius} transition-all duration-300 ease-out shadow-hard-shadow-3`,
1588
- style: { width: `${percentage}%` }
1589
- }
1590
- )
1591
- ]
1592
- }
1593
- ),
1594
- size === "medium" && showPercentage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1602
+ className: `text-xs font-medium leading-[14px] text-right ${percentageClassName}`,
1603
+ children: displayPriority.type === "hitCount" ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
1604
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-success-200", children: Math.round(clampedValue) }),
1605
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "text-text-600", children: [
1606
+ " de ",
1607
+ max
1608
+ ] })
1609
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Text_default, { size: "xs", weight: "medium", className: "text-success-200", children: [
1610
+ Math.round(percentage),
1611
+ "%"
1612
+ ] })
1613
+ }
1614
+ );
1615
+ };
1616
+ var ProgressBarBase = ({
1617
+ clampedValue,
1618
+ max,
1619
+ percentage,
1620
+ label,
1621
+ variantClasses,
1622
+ containerClassName,
1623
+ fillClassName
1624
+ }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1625
+ "div",
1626
+ {
1627
+ className: `${containerClassName} ${variantClasses.background} overflow-hidden relative`,
1628
+ children: [
1629
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1630
+ "progress",
1631
+ {
1632
+ value: clampedValue,
1633
+ max,
1634
+ "aria-label": typeof label === "string" ? `${label}: ${Math.round(percentage)}% complete` : `Progress: ${Math.round(percentage)}% of ${max}`,
1635
+ className: "absolute inset-0 w-full h-full opacity-0"
1636
+ }
1637
+ ),
1638
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1639
+ "div",
1640
+ {
1641
+ className: `${fillClassName} ${variantClasses.fill} transition-all duration-300 ease-out`,
1642
+ style: { width: `${percentage}%` }
1643
+ }
1644
+ )
1645
+ ]
1646
+ }
1647
+ );
1648
+ var StackedLayout = ({
1649
+ className,
1650
+ label,
1651
+ showPercentage,
1652
+ showHitCount,
1653
+ labelClassName,
1654
+ percentageClassName,
1655
+ clampedValue,
1656
+ max,
1657
+ percentage,
1658
+ variantClasses,
1659
+ dimensions
1660
+ }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1661
+ "div",
1662
+ {
1663
+ className: `flex flex-col items-start gap-2 ${dimensions.width} ${dimensions.height} ${className}`,
1664
+ children: [
1665
+ shouldShowHeader(label, showPercentage, showHitCount) && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-row justify-between items-center w-full h-[19px]", children: [
1666
+ label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1595
1667
  Text_default,
1596
1668
  {
1597
- size: "xs",
1669
+ as: "div",
1670
+ size: "md",
1598
1671
  weight: "medium",
1599
- className: `text-text-950 leading-none tracking-normal text-center flex-none ${percentageClassName}`,
1600
- children: [
1601
- Math.round(percentage),
1602
- "%"
1603
- ]
1672
+ className: `text-text-600 leading-[19px] ${labelClassName}`,
1673
+ children: label
1604
1674
  }
1605
1675
  ),
1606
- size === "medium" && label && !showPercentage && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1676
+ renderStackedHitCountDisplay(
1677
+ showHitCount,
1678
+ showPercentage,
1679
+ clampedValue,
1680
+ max,
1681
+ percentage,
1682
+ percentageClassName
1683
+ )
1684
+ ] }),
1685
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1686
+ ProgressBarBase,
1687
+ {
1688
+ clampedValue,
1689
+ max,
1690
+ percentage,
1691
+ label,
1692
+ variantClasses,
1693
+ containerClassName: "w-full h-2 rounded-lg",
1694
+ fillClassName: "h-2 rounded-lg shadow-hard-shadow-3"
1695
+ }
1696
+ )
1697
+ ]
1698
+ }
1699
+ );
1700
+ var CompactLayout = ({
1701
+ className,
1702
+ label,
1703
+ showPercentage,
1704
+ showHitCount,
1705
+ labelClassName,
1706
+ percentageClassName,
1707
+ clampedValue,
1708
+ max,
1709
+ percentage,
1710
+ variantClasses,
1711
+ dimensions
1712
+ }) => {
1713
+ const {
1714
+ color,
1715
+ className: compactClassName,
1716
+ content
1717
+ } = getCompactLayoutConfig({
1718
+ showPercentage,
1719
+ showHitCount,
1720
+ percentage,
1721
+ clampedValue,
1722
+ max,
1723
+ label,
1724
+ percentageClassName,
1725
+ labelClassName
1726
+ });
1727
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1728
+ "div",
1729
+ {
1730
+ className: `flex flex-col items-start gap-1 ${dimensions.width} ${dimensions.height} ${className}`,
1731
+ children: [
1732
+ shouldShowHeader(label, showPercentage, showHitCount) && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1607
1733
  Text_default,
1608
1734
  {
1609
1735
  as: "div",
1610
- size: "xs",
1736
+ size: "sm",
1611
1737
  weight: "medium",
1612
- className: `text-text-950 leading-none tracking-normal text-center flex-none ${labelClassName}`,
1613
- children: label
1738
+ color,
1739
+ className: `leading-4 w-full ${compactClassName}`,
1740
+ children: content
1741
+ }
1742
+ ),
1743
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1744
+ ProgressBarBase,
1745
+ {
1746
+ clampedValue,
1747
+ max,
1748
+ percentage,
1749
+ label,
1750
+ variantClasses,
1751
+ containerClassName: "w-full h-1 rounded-full",
1752
+ fillClassName: "h-1 rounded-full"
1614
1753
  }
1615
1754
  )
1616
1755
  ]
1617
1756
  }
1618
1757
  );
1619
1758
  };
1759
+ var DefaultLayout = ({
1760
+ className,
1761
+ size,
1762
+ sizeClasses,
1763
+ variantClasses,
1764
+ label,
1765
+ showPercentage,
1766
+ labelClassName,
1767
+ percentageClassName,
1768
+ clampedValue,
1769
+ max,
1770
+ percentage
1771
+ }) => {
1772
+ const gapClass = size === "medium" ? "gap-2" : sizeClasses.spacing;
1773
+ const progressBarClass = size === "medium" ? "flex-grow" : "w-full";
1774
+ const displayConfig = getDefaultLayoutDisplayConfig(
1775
+ size,
1776
+ label,
1777
+ showPercentage
1778
+ );
1779
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `flex ${sizeClasses.layout} ${gapClass} ${className}`, children: [
1780
+ displayConfig.showHeader && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-row items-center justify-between w-full", children: [
1781
+ label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1782
+ Text_default,
1783
+ {
1784
+ as: "div",
1785
+ size: "xs",
1786
+ weight: "medium",
1787
+ className: `text-text-950 leading-none tracking-normal text-center ${labelClassName}`,
1788
+ children: label
1789
+ }
1790
+ ),
1791
+ showPercentage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1792
+ Text_default,
1793
+ {
1794
+ size: "xs",
1795
+ weight: "medium",
1796
+ className: `text-text-950 leading-none tracking-normal text-center ${percentageClassName}`,
1797
+ children: [
1798
+ Math.round(percentage),
1799
+ "%"
1800
+ ]
1801
+ }
1802
+ )
1803
+ ] }),
1804
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1805
+ ProgressBarBase,
1806
+ {
1807
+ clampedValue,
1808
+ max,
1809
+ percentage,
1810
+ label,
1811
+ variantClasses,
1812
+ containerClassName: `${progressBarClass} ${sizeClasses.container} ${sizeClasses.borderRadius}`,
1813
+ fillClassName: `${sizeClasses.bar} ${sizeClasses.borderRadius} shadow-hard-shadow-3`
1814
+ }
1815
+ ),
1816
+ displayConfig.showPercentage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1817
+ Text_default,
1818
+ {
1819
+ size: "xs",
1820
+ weight: "medium",
1821
+ className: `text-text-950 leading-none tracking-normal text-center flex-none ${percentageClassName}`,
1822
+ children: [
1823
+ Math.round(percentage),
1824
+ "%"
1825
+ ]
1826
+ }
1827
+ ),
1828
+ displayConfig.showLabel && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1829
+ Text_default,
1830
+ {
1831
+ as: "div",
1832
+ size: "xs",
1833
+ weight: "medium",
1834
+ className: `text-text-950 leading-none tracking-normal text-center flex-none ${labelClassName}`,
1835
+ children: label
1836
+ }
1837
+ )
1838
+ ] });
1839
+ };
1840
+ var ProgressBar = ({
1841
+ value,
1842
+ max = 100,
1843
+ size = "medium",
1844
+ variant = "blue",
1845
+ layout = "default",
1846
+ label,
1847
+ showPercentage = false,
1848
+ showHitCount = false,
1849
+ className = "",
1850
+ labelClassName = "",
1851
+ percentageClassName = "",
1852
+ stackedWidth,
1853
+ stackedHeight,
1854
+ compactWidth,
1855
+ compactHeight
1856
+ }) => {
1857
+ const { clampedValue, percentage } = calculateProgressValues(value, max);
1858
+ const sizeClasses = SIZE_CLASSES7[size];
1859
+ const variantClasses = VARIANT_CLASSES2[variant];
1860
+ if (layout === "stacked") {
1861
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1862
+ StackedLayout,
1863
+ {
1864
+ className,
1865
+ label,
1866
+ showPercentage,
1867
+ showHitCount,
1868
+ labelClassName,
1869
+ percentageClassName,
1870
+ clampedValue,
1871
+ max,
1872
+ percentage,
1873
+ variantClasses,
1874
+ dimensions: {
1875
+ width: stackedWidth ?? "w-[380px]",
1876
+ height: stackedHeight ?? "h-[35px]"
1877
+ }
1878
+ }
1879
+ );
1880
+ }
1881
+ if (layout === "compact") {
1882
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1883
+ CompactLayout,
1884
+ {
1885
+ className,
1886
+ label,
1887
+ showPercentage,
1888
+ showHitCount,
1889
+ labelClassName,
1890
+ percentageClassName,
1891
+ clampedValue,
1892
+ max,
1893
+ percentage,
1894
+ variantClasses,
1895
+ dimensions: {
1896
+ width: compactWidth ?? "w-[131px]",
1897
+ height: compactHeight ?? "h-[24px]"
1898
+ }
1899
+ }
1900
+ );
1901
+ }
1902
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1903
+ DefaultLayout,
1904
+ {
1905
+ className,
1906
+ size,
1907
+ sizeClasses,
1908
+ variantClasses,
1909
+ label,
1910
+ showPercentage,
1911
+ labelClassName,
1912
+ percentageClassName,
1913
+ clampedValue,
1914
+ max,
1915
+ percentage
1916
+ }
1917
+ );
1918
+ };
1620
1919
  var ProgressBar_default = ProgressBar;
1621
1920
 
1622
1921
  // src/components/ProgressCircle/ProgressCircle.tsx