analytica-frontend-lib 1.0.34 → 1.0.36

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
@@ -27,16 +27,26 @@ __export(src_exports, {
27
27
  Chips: () => Chips_default,
28
28
  Divider: () => Divider_default,
29
29
  DropdownMenu: () => DropdownMenu_default,
30
- DropdownMenuContent: () => MenuContent,
31
- DropdownMenuItem: () => MenuItem,
32
- DropdownMenuLabel: () => MenuLabel,
33
- DropdownMenuSeparator: () => MenuSeparator,
34
30
  DropdownMenuTrigger: () => DropdownMenuTrigger,
35
31
  IconButton: () => IconButton_default,
36
32
  IconRoundedButton: () => IconRoundedButton_default,
37
33
  Input: () => Input_default,
34
+ MenuContent: () => MenuContent,
35
+ MenuItem: () => MenuItem,
36
+ MenuLabel: () => MenuLabel,
37
+ MenuSeparator: () => MenuSeparator,
38
38
  NavButton: () => NavButton_default,
39
+ ProfileMenuFooter: () => ProfileMenuFooter,
40
+ ProfileMenuHeader: () => ProfileMenuHeader,
41
+ ProfileMenuSection: () => ProfileMenuSection,
42
+ ProfileMenuTrigger: () => ProfileMenuTrigger,
43
+ ProgressBar: () => ProgressBar_default,
39
44
  Radio: () => Radio_default,
45
+ Select: () => Select_default,
46
+ SelectContent: () => SelectContent,
47
+ SelectItem: () => SelectItem,
48
+ SelectTrigger: () => SelectTrigger,
49
+ SelectValue: () => SelectValue,
40
50
  SelectionButton: () => SelectionButton_default,
41
51
  Table: () => Table_default,
42
52
  Text: () => Text_default,
@@ -1491,23 +1501,193 @@ var Chips = ({
1491
1501
  };
1492
1502
  var Chips_default = Chips;
1493
1503
 
1504
+ // src/components/ProgressBar/ProgressBar.tsx
1505
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1506
+ var SIZE_CLASSES7 = {
1507
+ small: {
1508
+ container: "h-1",
1509
+ // 4px height (h-1 = 4px in Tailwind)
1510
+ bar: "h-1",
1511
+ // 4px height for the fill bar
1512
+ labelSize: "xs",
1513
+ spacing: "gap-2",
1514
+ // 8px gap between label and progress bar
1515
+ layout: "flex-col",
1516
+ // vertical layout for small
1517
+ borderRadius: "rounded-full"
1518
+ // 9999px border radius
1519
+ },
1520
+ medium: {
1521
+ container: "h-2",
1522
+ // 8px height (h-2 = 8px in Tailwind)
1523
+ bar: "h-2",
1524
+ // 8px height for the fill bar
1525
+ labelSize: "xs",
1526
+ // 12px font size (xs in Tailwind)
1527
+ spacing: "gap-2",
1528
+ // 8px gap between progress bar and label
1529
+ layout: "flex-row items-center",
1530
+ // horizontal layout for medium
1531
+ borderRadius: "rounded-lg"
1532
+ // 8px border radius
1533
+ }
1534
+ };
1535
+ var VARIANT_CLASSES2 = {
1536
+ blue: {
1537
+ background: "bg-background-300",
1538
+ // Background track color (#D5D4D4)
1539
+ fill: "bg-primary-700"
1540
+ // Blue for activity progress (#2271C4)
1541
+ },
1542
+ green: {
1543
+ background: "bg-background-300",
1544
+ // Background track color (#D5D4D4)
1545
+ fill: "bg-success-200"
1546
+ // Green for performance (#84D3A2)
1547
+ }
1548
+ };
1549
+ var ProgressBar = ({
1550
+ value,
1551
+ max = 100,
1552
+ size = "medium",
1553
+ variant = "blue",
1554
+ label,
1555
+ showPercentage = false,
1556
+ className = "",
1557
+ labelClassName = "",
1558
+ percentageClassName = ""
1559
+ }) => {
1560
+ const safeValue = isNaN(value) ? 0 : value;
1561
+ const clampedValue = Math.max(0, Math.min(safeValue, max));
1562
+ const percentage = max === 0 ? 0 : clampedValue / max * 100;
1563
+ const sizeClasses = SIZE_CLASSES7[size];
1564
+ const variantClasses = VARIANT_CLASSES2[variant];
1565
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1566
+ "div",
1567
+ {
1568
+ className: `flex ${sizeClasses.layout} ${sizeClasses.spacing} ${className}`,
1569
+ children: [
1570
+ size === "small" && (label || showPercentage) && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-row items-center justify-between w-full", children: [
1571
+ label && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1572
+ Text_default,
1573
+ {
1574
+ as: "div",
1575
+ size: sizeClasses.labelSize,
1576
+ weight: "medium",
1577
+ className: `text-text-950 ${labelClassName}`,
1578
+ children: label
1579
+ }
1580
+ ),
1581
+ showPercentage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1582
+ Text_default,
1583
+ {
1584
+ size: sizeClasses.labelSize,
1585
+ weight: "medium",
1586
+ className: `text-text-700 text-center ${percentageClassName}`,
1587
+ children: [
1588
+ Math.round(percentage),
1589
+ "%"
1590
+ ]
1591
+ }
1592
+ )
1593
+ ] }),
1594
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1595
+ "div",
1596
+ {
1597
+ className: `${size === "medium" ? "flex-grow" : "w-full"} ${sizeClasses.container} ${variantClasses.background} ${sizeClasses.borderRadius} overflow-hidden relative`,
1598
+ children: [
1599
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1600
+ "progress",
1601
+ {
1602
+ value: clampedValue,
1603
+ max,
1604
+ "aria-label": typeof label === "string" ? label : "Progress",
1605
+ className: "absolute inset-0 w-full h-full opacity-0"
1606
+ }
1607
+ ),
1608
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1609
+ "div",
1610
+ {
1611
+ className: `${sizeClasses.bar} ${variantClasses.fill} ${sizeClasses.borderRadius} transition-all duration-300 ease-out shadow-hard-shadow-3`,
1612
+ style: { width: `${percentage}%` }
1613
+ }
1614
+ )
1615
+ ]
1616
+ }
1617
+ ),
1618
+ size === "medium" && showPercentage && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1619
+ Text_default,
1620
+ {
1621
+ size: sizeClasses.labelSize,
1622
+ weight: "medium",
1623
+ className: `text-text-950 text-center flex-none w-[70px] ${percentageClassName}`,
1624
+ children: [
1625
+ Math.round(percentage),
1626
+ "%"
1627
+ ]
1628
+ }
1629
+ ),
1630
+ size === "medium" && label && !showPercentage && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1631
+ Text_default,
1632
+ {
1633
+ as: "div",
1634
+ size: sizeClasses.labelSize,
1635
+ weight: "medium",
1636
+ className: `text-text-950 flex-none ${labelClassName}`,
1637
+ children: label
1638
+ }
1639
+ )
1640
+ ]
1641
+ }
1642
+ );
1643
+ };
1644
+ var ProgressBar_default = ProgressBar;
1645
+
1494
1646
  // src/components/DropdownMenu/DropdownMenu.tsx
1647
+ var import_phosphor_react7 = require("phosphor-react");
1495
1648
  var import_react9 = require("react");
1496
- var import_jsx_runtime18 = require("react/jsx-runtime");
1497
- var DropdownMenuContext = (0, import_react9.createContext)(
1498
- void 0
1499
- );
1649
+ var import_zustand2 = require("zustand");
1650
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1651
+ function createDropdownStore() {
1652
+ return (0, import_zustand2.create)((set) => ({
1653
+ open: false,
1654
+ setOpen: (open) => set({ open })
1655
+ }));
1656
+ }
1657
+ var useDropdownStore = (externalStore) => {
1658
+ if (!externalStore) {
1659
+ throw new Error(
1660
+ "Component must be used within a DropdownMenu (store is missing)"
1661
+ );
1662
+ }
1663
+ return externalStore;
1664
+ };
1665
+ var injectStore = (children, store) => {
1666
+ return import_react9.Children.map(children, (child) => {
1667
+ if ((0, import_react9.isValidElement)(child)) {
1668
+ const typedChild = child;
1669
+ const newProps = {
1670
+ store
1671
+ };
1672
+ if (typedChild.props.children) {
1673
+ newProps.children = injectStore(typedChild.props.children, store);
1674
+ }
1675
+ return (0, import_react9.cloneElement)(typedChild, newProps);
1676
+ }
1677
+ return child;
1678
+ });
1679
+ };
1500
1680
  var DropdownMenu = ({ children, open, onOpenChange }) => {
1501
- const [internalOpen, setInternalOpen] = (0, import_react9.useState)(false);
1681
+ const storeRef = (0, import_react9.useRef)(null);
1682
+ storeRef.current ??= createDropdownStore();
1683
+ const store = storeRef.current;
1502
1684
  const isControlled = open !== void 0;
1503
- const currentOpen = isControlled ? open : internalOpen;
1504
- const setOpen = (0, import_react9.useCallback)(
1505
- (newOpen) => {
1506
- if (onOpenChange) onOpenChange(newOpen);
1507
- if (!isControlled) setInternalOpen(newOpen);
1508
- },
1509
- [isControlled, onOpenChange]
1510
- );
1685
+ const uncontrolledOpen = (0, import_zustand2.useStore)(store, (s) => s.open);
1686
+ const currentOpen = isControlled ? open : uncontrolledOpen;
1687
+ const setOpen = (newOpen) => {
1688
+ onOpenChange?.(newOpen);
1689
+ if (!isControlled) store.setState({ open: newOpen });
1690
+ };
1511
1691
  const menuRef = (0, import_react9.useRef)(null);
1512
1692
  const handleArrowDownOrArrowUp = (event) => {
1513
1693
  const menuContent = menuRef.current?.querySelector('[role="menu"]');
@@ -1543,6 +1723,7 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
1543
1723
  }
1544
1724
  };
1545
1725
  (0, import_react9.useEffect)(() => {
1726
+ onOpenChange?.(currentOpen);
1546
1727
  if (currentOpen) {
1547
1728
  document.addEventListener("mousedown", handleClickOutside);
1548
1729
  document.addEventListener("keydown", handleDownkey);
@@ -1552,25 +1733,25 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
1552
1733
  document.removeEventListener("keydown", handleDownkey);
1553
1734
  };
1554
1735
  }, [currentOpen]);
1555
- const value = (0, import_react9.useMemo)(
1556
- () => ({ open: currentOpen, setOpen }),
1557
- [currentOpen, setOpen]
1558
- );
1559
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DropdownMenuContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "relative", ref: menuRef, children }) });
1736
+ (0, import_react9.useEffect)(() => {
1737
+ if (isControlled) {
1738
+ store.setState({ open });
1739
+ }
1740
+ }, []);
1741
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "relative", ref: menuRef, children: injectStore(children, store) });
1560
1742
  };
1561
- var DropdownMenuTrigger = (0, import_react9.forwardRef)(({ className, children, onClick, ...props }, ref) => {
1562
- const context = (0, import_react9.useContext)(DropdownMenuContext);
1563
- if (!context)
1564
- throw new Error("DropdownMenuTrigger must be used within a DropdownMenu");
1565
- const { open, setOpen } = context;
1566
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1743
+ var DropdownMenuTrigger = (0, import_react9.forwardRef)(({ className, children, onClick, store: externalStore, ...props }, ref) => {
1744
+ const store = useDropdownStore(externalStore);
1745
+ const open = (0, import_zustand2.useStore)(store, (s) => s.open);
1746
+ const toggleOpen = () => store.setState({ open: !open });
1747
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1567
1748
  "button",
1568
1749
  {
1569
1750
  ref,
1570
1751
  className: `border border-border-200 cursor-pointer bg-background-muted hover:bg-background-200 transition-colors px-4 py-2 rounded-sm ${className}`,
1571
1752
  onClick: (e) => {
1572
1753
  e.stopPropagation();
1573
- setOpen(!open);
1754
+ toggleOpen();
1574
1755
  if (onClick) onClick(e);
1575
1756
  },
1576
1757
  "aria-expanded": open,
@@ -1595,15 +1776,16 @@ var ALIGN_CLASSES = {
1595
1776
  center: "left-1/2 -translate-x-1/2",
1596
1777
  end: "right-0"
1597
1778
  };
1598
- var MenuLabel = (0, import_react9.forwardRef)(({ className, inset, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1599
- "fieldset",
1600
- {
1601
- ref,
1602
- role: "group",
1603
- className: `text-sm w-full ${inset ? "pl-8" : ""} ${className ?? ""}`,
1604
- ...props
1605
- }
1606
- ));
1779
+ var MenuLabel = (0, import_react9.forwardRef)(({ className, inset, store: _store, ...props }, ref) => {
1780
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1781
+ "div",
1782
+ {
1783
+ ref,
1784
+ className: `text-sm w-full ${inset ? "pl-8" : ""} ${className ?? ""}`,
1785
+ ...props
1786
+ }
1787
+ );
1788
+ });
1607
1789
  MenuLabel.displayName = "MenuLabel";
1608
1790
  var MenuContent = (0, import_react9.forwardRef)(
1609
1791
  ({
@@ -1612,9 +1794,11 @@ var MenuContent = (0, import_react9.forwardRef)(
1612
1794
  side = "bottom",
1613
1795
  sideOffset = 4,
1614
1796
  children,
1797
+ store: externalStore,
1615
1798
  ...props
1616
1799
  }, ref) => {
1617
- const { open } = (0, import_react9.useContext)(DropdownMenuContext);
1800
+ const store = useDropdownStore(externalStore);
1801
+ const open = (0, import_zustand2.useStore)(store, (s) => s.open);
1618
1802
  const [isVisible, setIsVisible] = (0, import_react9.useState)(open);
1619
1803
  (0, import_react9.useEffect)(() => {
1620
1804
  if (open) {
@@ -1630,7 +1814,7 @@ var MenuContent = (0, import_react9.forwardRef)(
1630
1814
  const horizontal = ALIGN_CLASSES[align];
1631
1815
  return `absolute ${vertical} ${horizontal}`;
1632
1816
  };
1633
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1817
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1634
1818
  "div",
1635
1819
  {
1636
1820
  ref,
@@ -1657,15 +1841,18 @@ MenuContent.displayName = "MenuContent";
1657
1841
  var MenuItem = (0, import_react9.forwardRef)(
1658
1842
  ({
1659
1843
  className,
1660
- inset,
1661
1844
  size = "small",
1662
1845
  children,
1663
1846
  iconRight,
1664
1847
  iconLeft,
1665
1848
  disabled = false,
1666
1849
  onClick,
1850
+ variant = "menu",
1851
+ store: externalStore,
1667
1852
  ...props
1668
1853
  }, ref) => {
1854
+ const store = useDropdownStore(externalStore);
1855
+ const setOpen = (0, import_zustand2.useStore)(store, (s) => s.setOpen);
1669
1856
  const sizeClasses = ITEM_SIZE_CLASSES[size];
1670
1857
  const handleClick = (e) => {
1671
1858
  if (disabled) {
@@ -1674,17 +1861,27 @@ var MenuItem = (0, import_react9.forwardRef)(
1674
1861
  return;
1675
1862
  }
1676
1863
  onClick?.(e);
1864
+ setOpen(false);
1865
+ };
1866
+ const getVariantClasses = () => {
1867
+ if (variant === "profile") {
1868
+ return "relative flex flex-row justify-between select-none items-center gap-2 rounded-sm p-3 text-sm outline-none transition-colors [&>svg]:size-6 [&>svg]:shrink-0";
1869
+ }
1870
+ return "relative flex select-none items-center gap-2 rounded-sm p-3 text-sm outline-none transition-colors [&>svg]:size-4 [&>svg]:shrink-0";
1677
1871
  };
1678
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1872
+ const getVariantProps = () => {
1873
+ return variant === "profile" ? { "data-variant": "profile" } : {};
1874
+ };
1875
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1679
1876
  "div",
1680
1877
  {
1681
1878
  ref,
1682
1879
  role: "menuitem",
1880
+ ...getVariantProps(),
1683
1881
  "aria-disabled": disabled,
1684
1882
  className: `
1685
1883
  focus-visible:bg-background-50
1686
- relative flex select-none items-center gap-2 rounded-sm p-3 text-sm outline-none transition-colors [&>svg]:size-4 [&>svg]:shrink-0
1687
- ${inset && "pl-8"}
1884
+ ${getVariantClasses()}
1688
1885
  ${sizeClasses}
1689
1886
  ${className}
1690
1887
  ${disabled ? "cursor-not-allowed text-text-400" : "cursor-pointer hover:bg-background-50 text-text-700 focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground"}
@@ -1705,7 +1902,7 @@ var MenuItem = (0, import_react9.forwardRef)(
1705
1902
  }
1706
1903
  );
1707
1904
  MenuItem.displayName = "MenuItem";
1708
- var MenuSeparator = (0, import_react9.forwardRef)(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1905
+ var MenuSeparator = (0, import_react9.forwardRef)(({ className, store: _store, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1709
1906
  "div",
1710
1907
  {
1711
1908
  ref,
@@ -1714,7 +1911,369 @@ var MenuSeparator = (0, import_react9.forwardRef)(({ className, ...props }, ref)
1714
1911
  }
1715
1912
  ));
1716
1913
  MenuSeparator.displayName = "MenuSeparator";
1914
+ var ProfileMenuTrigger = (0, import_react9.forwardRef)(({ className, onClick, store: externalStore, ...props }, ref) => {
1915
+ const store = useDropdownStore(externalStore);
1916
+ const open = (0, import_zustand2.useStore)(store, (s) => s.open);
1917
+ const toggleOpen = () => store.setState({ open: !open });
1918
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1919
+ "button",
1920
+ {
1921
+ ref,
1922
+ className: `rounded-lg size-10 bg-background-50 flex items-center justify-center ${className}`,
1923
+ onClick: (e) => {
1924
+ e.stopPropagation();
1925
+ toggleOpen();
1926
+ onClick?.(e);
1927
+ },
1928
+ "aria-expanded": open,
1929
+ ...props,
1930
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "size-6 rounded-full bg-background-100 flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_phosphor_react7.User, { className: "text-background-950", size: 18 }) })
1931
+ }
1932
+ );
1933
+ });
1934
+ ProfileMenuTrigger.displayName = "ProfileMenuTrigger";
1935
+ var ProfileMenuHeader = (0, import_react9.forwardRef)(({ className, name, email, store: _store, ...props }, ref) => {
1936
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1937
+ "div",
1938
+ {
1939
+ ref,
1940
+ "data-component": "ProfileMenuHeader",
1941
+ className: `
1942
+ flex flex-row gap-4 items-center
1943
+ ${className}
1944
+ `,
1945
+ ...props,
1946
+ children: [
1947
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "size-16 bg-background-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_phosphor_react7.User, { size: 34, className: "text-background-950" }) }),
1948
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex flex-col ", children: [
1949
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-xl font-bold text-text-950", children: name }),
1950
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-md text-text-600", children: email })
1951
+ ] })
1952
+ ]
1953
+ }
1954
+ );
1955
+ });
1956
+ ProfileMenuHeader.displayName = "ProfileMenuHeader";
1957
+ var ProfileMenuSection = (0, import_react9.forwardRef)(({ className, children, store: _store, ...props }, ref) => {
1958
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1959
+ "div",
1960
+ {
1961
+ ref,
1962
+ className: `
1963
+ flex flex-col p-2
1964
+ ${className}
1965
+ `,
1966
+ ...props,
1967
+ children
1968
+ }
1969
+ );
1970
+ });
1971
+ ProfileMenuSection.displayName = "ProfileMenuSection";
1972
+ var ProfileMenuFooter = (0, import_react9.forwardRef)(
1973
+ ({ className, disabled = false, onClick, store: externalStore, ...props }, ref) => {
1974
+ const store = useDropdownStore(externalStore);
1975
+ const setOpen = (0, import_zustand2.useStore)(store, (s) => s.setOpen);
1976
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1977
+ "button",
1978
+ {
1979
+ ref,
1980
+ className: `inline-flex items-center justify-center rounded-full cursor-pointer font-medium text-md px-5 py-2.5 w-full bg-transparent text-primary-950 border border-primary-950 hover:bg-background-50 hover:text-primary-400 hover:border-primary-400 focus-visible:border-0 focus-visible:outline-none focus-visible:text-primary-600 focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-indicator-info active:text-primary-700 active:border-primary-700 disabled:opacity-40 disabled:cursor-not-allowed ${className}`,
1981
+ disabled,
1982
+ onClick: (e) => {
1983
+ setOpen(false);
1984
+ onClick?.(e);
1985
+ },
1986
+ ...props,
1987
+ children: [
1988
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "mr-2 flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_phosphor_react7.SignOut, {}) }),
1989
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { children: "Sair" })
1990
+ ]
1991
+ }
1992
+ );
1993
+ }
1994
+ );
1995
+ ProfileMenuFooter.displayName = "ProfileMenuFooter";
1717
1996
  var DropdownMenu_default = DropdownMenu;
1997
+
1998
+ // src/components/Select/Select.tsx
1999
+ var import_zustand3 = require("zustand");
2000
+ var import_react10 = require("react");
2001
+ var import_phosphor_react8 = require("phosphor-react");
2002
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2003
+ var VARIANT_CLASSES3 = {
2004
+ outlined: "border-2 rounded-sm focus:border-primary-950",
2005
+ underlined: "border-b-2 focus:border-primary-950",
2006
+ rounded: "border-2 rounded-4xl focus:border-primary-950"
2007
+ };
2008
+ var SIZE_CLASSES8 = {
2009
+ small: "text-sm",
2010
+ medium: "text-md",
2011
+ large: "text-lg"
2012
+ };
2013
+ var SIDE_CLASSES2 = {
2014
+ top: "bottom-full -translate-y-1",
2015
+ right: "top-full translate-y-1",
2016
+ bottom: "top-full translate-y-1",
2017
+ left: "top-full translate-y-1"
2018
+ };
2019
+ var ALIGN_CLASSES2 = {
2020
+ start: "left-0",
2021
+ center: "left-1/2 -translate-x-1/2",
2022
+ end: "right-0"
2023
+ };
2024
+ function createSelectStore() {
2025
+ return (0, import_zustand3.create)((set) => ({
2026
+ open: false,
2027
+ setOpen: (open) => set({ open }),
2028
+ value: "",
2029
+ setValue: (value) => set({ value }),
2030
+ selectedLabel: "",
2031
+ setSelectedLabel: (label) => set({ selectedLabel: label })
2032
+ }));
2033
+ }
2034
+ var useSelectStore = (externalStore) => {
2035
+ if (!externalStore) {
2036
+ throw new Error(
2037
+ "Component must be used within a Select (store is missing)"
2038
+ );
2039
+ }
2040
+ return externalStore;
2041
+ };
2042
+ function getLabelAsNode(children) {
2043
+ if (typeof children === "string" || typeof children === "number") {
2044
+ return children;
2045
+ }
2046
+ const flattened = import_react10.Children.toArray(children);
2047
+ if (flattened.length === 1) return flattened[0];
2048
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_jsx_runtime20.Fragment, { children: flattened });
2049
+ }
2050
+ var injectStore2 = (children, store) => {
2051
+ return import_react10.Children.map(children, (child) => {
2052
+ if ((0, import_react10.isValidElement)(child)) {
2053
+ const typedChild = child;
2054
+ const newProps = {
2055
+ store
2056
+ };
2057
+ if (typedChild.props.children) {
2058
+ newProps.children = injectStore2(typedChild.props.children, store);
2059
+ }
2060
+ return (0, import_react10.cloneElement)(typedChild, newProps);
2061
+ }
2062
+ return child;
2063
+ });
2064
+ };
2065
+ var Select = ({
2066
+ children,
2067
+ defaultValue = "",
2068
+ value: propValue,
2069
+ onValueChange,
2070
+ size = "small"
2071
+ }) => {
2072
+ const storeRef = (0, import_react10.useRef)(null);
2073
+ storeRef.current ??= createSelectStore();
2074
+ const store = storeRef.current;
2075
+ const selectRef = (0, import_react10.useRef)(null);
2076
+ const { open, setOpen, setValue, value, selectedLabel } = (0, import_zustand3.useStore)(
2077
+ store,
2078
+ (s) => s
2079
+ );
2080
+ const isControlled = propValue !== void 0;
2081
+ const currentValue = isControlled ? propValue : value;
2082
+ const findLabelForValue = (children2, targetValue) => {
2083
+ let found = null;
2084
+ const search = (nodes) => {
2085
+ import_react10.Children.forEach(nodes, (child) => {
2086
+ if (!(0, import_react10.isValidElement)(child)) return;
2087
+ const typedChild = child;
2088
+ if (typedChild.type === SelectItem && typedChild.props.value === targetValue) {
2089
+ if (typeof typedChild.props.children === "string")
2090
+ found = typedChild.props.children;
2091
+ }
2092
+ if (typedChild.props.children && !found)
2093
+ search(typedChild.props.children);
2094
+ });
2095
+ };
2096
+ search(children2);
2097
+ return found;
2098
+ };
2099
+ (0, import_react10.useEffect)(() => {
2100
+ if (!selectedLabel && defaultValue) {
2101
+ const label = findLabelForValue(children, defaultValue);
2102
+ if (label) store.setState({ selectedLabel: label });
2103
+ }
2104
+ }, [children, defaultValue, selectedLabel]);
2105
+ (0, import_react10.useEffect)(() => {
2106
+ setValue(currentValue);
2107
+ const handleClickOutside = (event) => {
2108
+ if (selectRef.current && !selectRef.current.contains(event.target)) {
2109
+ setOpen(false);
2110
+ }
2111
+ };
2112
+ const handleArrowKeys = (event) => {
2113
+ const selectContent = selectRef.current?.querySelector('[role="menu"]');
2114
+ if (selectContent) {
2115
+ event.preventDefault();
2116
+ const items = Array.from(
2117
+ selectContent.querySelectorAll(
2118
+ '[role="menuitem"]:not([aria-disabled="true"])'
2119
+ )
2120
+ ).filter((el) => el instanceof HTMLElement);
2121
+ const focused = document.activeElement;
2122
+ const currentIndex = items.findIndex((item) => item === focused);
2123
+ let nextIndex = 0;
2124
+ if (event.key === "ArrowDown") {
2125
+ nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % items.length;
2126
+ } else {
2127
+ nextIndex = currentIndex === -1 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length;
2128
+ }
2129
+ items[nextIndex]?.focus();
2130
+ }
2131
+ };
2132
+ if (open) {
2133
+ document.addEventListener("mousedown", handleClickOutside);
2134
+ document.addEventListener("keydown", handleArrowKeys);
2135
+ }
2136
+ return () => {
2137
+ document.removeEventListener("mousedown", handleClickOutside);
2138
+ document.removeEventListener("keydown", handleArrowKeys);
2139
+ };
2140
+ }, [open]);
2141
+ (0, import_react10.useEffect)(() => {
2142
+ if (onValueChange) {
2143
+ onValueChange(value);
2144
+ }
2145
+ }, [value]);
2146
+ const sizeClasses = SIZE_CLASSES8[size];
2147
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: `relative ${sizeClasses} w-[288px]`, ref: selectRef, children: injectStore2(children, store) });
2148
+ };
2149
+ var SelectValue = ({
2150
+ placeholder,
2151
+ store: externalStore
2152
+ }) => {
2153
+ const store = useSelectStore(externalStore);
2154
+ const selectedLabel = (0, import_zustand3.useStore)(store, (s) => s.selectedLabel);
2155
+ const value = (0, import_zustand3.useStore)(store, (s) => s.value);
2156
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-inherit", children: selectedLabel || placeholder || value });
2157
+ };
2158
+ var SelectTrigger = (0, import_react10.forwardRef)(
2159
+ ({
2160
+ className,
2161
+ invalid = false,
2162
+ variant = "outlined",
2163
+ store: externalStore,
2164
+ disabled,
2165
+ ...props
2166
+ }, ref) => {
2167
+ const store = useSelectStore(externalStore);
2168
+ const open = (0, import_zustand3.useStore)(store, (s) => s.open);
2169
+ const toggleOpen = () => store.setState({ open: !open });
2170
+ const variantClasses = VARIANT_CLASSES3[variant];
2171
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2172
+ "button",
2173
+ {
2174
+ ref,
2175
+ className: `
2176
+ flex h-9 min-w-[220px] w-full items-center justify-between border-border-300 px-3 py-2
2177
+ ${invalid && "border-indicator-error"}
2178
+ ${disabled ? "cursor-not-allowed text-text-400 pointer-events-none opacity-50" : "cursor-pointer hover:bg-background-50 text-text-700 focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground"}
2179
+ ${variantClasses}
2180
+ ${className}
2181
+ `,
2182
+ onClick: toggleOpen,
2183
+ "aria-expanded": open,
2184
+ "aria-haspopup": "listbox",
2185
+ "aria-controls": open ? "select-content" : void 0,
2186
+ ...props,
2187
+ children: [
2188
+ props.children,
2189
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2190
+ import_phosphor_react8.CaretDown,
2191
+ {
2192
+ className: `h-[1em] w-[1em] opacity-50 transition-transform ${open ? "rotate-180" : ""}`
2193
+ }
2194
+ )
2195
+ ]
2196
+ }
2197
+ );
2198
+ }
2199
+ );
2200
+ SelectTrigger.displayName = "SelectTrigger";
2201
+ var SelectContent = (0, import_react10.forwardRef)(
2202
+ ({
2203
+ children,
2204
+ className,
2205
+ align = "start",
2206
+ side = "bottom",
2207
+ store: externalStore,
2208
+ ...props
2209
+ }, ref) => {
2210
+ const store = useSelectStore(externalStore);
2211
+ const open = (0, import_zustand3.useStore)(store, (s) => s.open);
2212
+ if (!open) return null;
2213
+ const getPositionClasses = () => `absolute ${SIDE_CLASSES2[side]} ${ALIGN_CLASSES2[align]}`;
2214
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2215
+ "div",
2216
+ {
2217
+ role: "menu",
2218
+ ref,
2219
+ className: `bg-background z-50 min-w-[210px] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md border-border-100 ${getPositionClasses()} ${className}`,
2220
+ ...props,
2221
+ children
2222
+ }
2223
+ );
2224
+ }
2225
+ );
2226
+ SelectContent.displayName = "SelectContent";
2227
+ var SelectItem = (0, import_react10.forwardRef)(
2228
+ ({
2229
+ className,
2230
+ children,
2231
+ value,
2232
+ disabled = false,
2233
+ store: externalStore,
2234
+ ...props
2235
+ }, ref) => {
2236
+ const store = useSelectStore(externalStore);
2237
+ const selectedValue = (0, import_zustand3.useStore)(store, (s) => s.value);
2238
+ const { setValue, setSelectedLabel, setOpen } = store.getState();
2239
+ const handleClick = (e) => {
2240
+ const labelNode = getLabelAsNode(children);
2241
+ if (!disabled) {
2242
+ setValue(value);
2243
+ setSelectedLabel(labelNode);
2244
+ setOpen(false);
2245
+ }
2246
+ props.onClick?.(e);
2247
+ };
2248
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2249
+ "div",
2250
+ {
2251
+ role: "menuitem",
2252
+ "aria-disabled": disabled,
2253
+ ref,
2254
+ className: `
2255
+ focus-visible:bg-background-50
2256
+ relative flex select-none items-center gap-2 rounded-sm p-3 outline-none transition-colors [&>svg]:size-4 [&>svg]:shrink-0
2257
+ ${className}
2258
+ ${disabled ? "cursor-not-allowed text-text-400 pointer-events-none opacity-50" : "cursor-pointer hover:bg-background-50 text-text-700 focus:bg-accent focus:text-accent-foreground hover:bg-accent hover:text-accent-foreground"}
2259
+ ${selectedValue === value && "bg-background-50"}
2260
+ `,
2261
+ onClick: handleClick,
2262
+ onKeyDown: (e) => {
2263
+ if (e.key === "Enter" || e.key === " ") handleClick(e);
2264
+ },
2265
+ tabIndex: disabled ? -1 : 0,
2266
+ ...props,
2267
+ children: [
2268
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: selectedValue === value && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_phosphor_react8.Check, { className: "" }) }),
2269
+ children
2270
+ ]
2271
+ }
2272
+ );
2273
+ }
2274
+ );
2275
+ SelectItem.displayName = "SelectItem";
2276
+ var Select_default = Select;
1718
2277
  // Annotate the CommonJS export names for ESM import in node:
1719
2278
  0 && (module.exports = {
1720
2279
  Alert,
@@ -1724,16 +2283,26 @@ var DropdownMenu_default = DropdownMenu;
1724
2283
  Chips,
1725
2284
  Divider,
1726
2285
  DropdownMenu,
1727
- DropdownMenuContent,
1728
- DropdownMenuItem,
1729
- DropdownMenuLabel,
1730
- DropdownMenuSeparator,
1731
2286
  DropdownMenuTrigger,
1732
2287
  IconButton,
1733
2288
  IconRoundedButton,
1734
2289
  Input,
2290
+ MenuContent,
2291
+ MenuItem,
2292
+ MenuLabel,
2293
+ MenuSeparator,
1735
2294
  NavButton,
2295
+ ProfileMenuFooter,
2296
+ ProfileMenuHeader,
2297
+ ProfileMenuSection,
2298
+ ProfileMenuTrigger,
2299
+ ProgressBar,
1736
2300
  Radio,
2301
+ Select,
2302
+ SelectContent,
2303
+ SelectItem,
2304
+ SelectTrigger,
2305
+ SelectValue,
1737
2306
  SelectionButton,
1738
2307
  Table,
1739
2308
  Text,