analytica-frontend-lib 1.0.34 → 1.0.35
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/DropdownMenu/index.d.mts +36 -5
- package/dist/DropdownMenu/index.d.ts +36 -5
- package/dist/DropdownMenu/index.js +178 -39
- package/dist/DropdownMenu/index.js.map +1 -1
- package/dist/DropdownMenu/index.mjs +175 -43
- package/dist/DropdownMenu/index.mjs.map +1 -1
- package/dist/index.css +82 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +45 -3
- package/dist/index.d.ts +45 -3
- package/dist/index.js +470 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +468 -46
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +82 -0
- package/dist/styles.css.map +1 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -1460,31 +1460,58 @@ var Chips = ({
|
|
|
1460
1460
|
var Chips_default = Chips;
|
|
1461
1461
|
|
|
1462
1462
|
// src/components/DropdownMenu/DropdownMenu.tsx
|
|
1463
|
+
import { SignOut, User } from "phosphor-react";
|
|
1463
1464
|
import {
|
|
1464
|
-
createContext,
|
|
1465
|
-
useState as useState5,
|
|
1466
|
-
useCallback,
|
|
1467
|
-
useContext,
|
|
1468
1465
|
forwardRef as forwardRef9,
|
|
1469
1466
|
useEffect,
|
|
1470
1467
|
useRef,
|
|
1471
|
-
|
|
1468
|
+
isValidElement,
|
|
1469
|
+
Children,
|
|
1470
|
+
cloneElement,
|
|
1471
|
+
useState as useState5
|
|
1472
1472
|
} from "react";
|
|
1473
|
+
import { create as create2, useStore } from "zustand";
|
|
1473
1474
|
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1475
|
+
function createDropdownStore() {
|
|
1476
|
+
return create2((set) => ({
|
|
1477
|
+
open: false,
|
|
1478
|
+
setOpen: (open) => set({ open })
|
|
1479
|
+
}));
|
|
1480
|
+
}
|
|
1481
|
+
var useDropdownStore = (externalStore) => {
|
|
1482
|
+
if (!externalStore) {
|
|
1483
|
+
throw new Error(
|
|
1484
|
+
"Component must be used within a DropdownMenu (store is missing)"
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
return externalStore;
|
|
1488
|
+
};
|
|
1489
|
+
var injectStore = (children, store) => {
|
|
1490
|
+
return Children.map(children, (child) => {
|
|
1491
|
+
if (isValidElement(child)) {
|
|
1492
|
+
const typedChild = child;
|
|
1493
|
+
const newProps = {
|
|
1494
|
+
store
|
|
1495
|
+
};
|
|
1496
|
+
if (typedChild.props.children) {
|
|
1497
|
+
newProps.children = injectStore(typedChild.props.children, store);
|
|
1498
|
+
}
|
|
1499
|
+
return cloneElement(typedChild, newProps);
|
|
1500
|
+
}
|
|
1501
|
+
return child;
|
|
1502
|
+
});
|
|
1503
|
+
};
|
|
1477
1504
|
var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
1478
|
-
const
|
|
1505
|
+
const storeRef = useRef(null);
|
|
1506
|
+
storeRef.current ??= createDropdownStore();
|
|
1507
|
+
const store = storeRef.current;
|
|
1479
1508
|
const isControlled = open !== void 0;
|
|
1480
|
-
const
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
[isControlled, onOpenChange]
|
|
1487
|
-
);
|
|
1509
|
+
const uncontrolledOpen = useStore(store, (s) => s.open);
|
|
1510
|
+
const currentOpen = isControlled ? open : uncontrolledOpen;
|
|
1511
|
+
const setOpen = (newOpen) => {
|
|
1512
|
+
onOpenChange?.(newOpen);
|
|
1513
|
+
if (!isControlled) store.setState({ open: newOpen });
|
|
1514
|
+
};
|
|
1488
1515
|
const menuRef = useRef(null);
|
|
1489
1516
|
const handleArrowDownOrArrowUp = (event) => {
|
|
1490
1517
|
const menuContent = menuRef.current?.querySelector('[role="menu"]');
|
|
@@ -1520,6 +1547,7 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
|
1520
1547
|
}
|
|
1521
1548
|
};
|
|
1522
1549
|
useEffect(() => {
|
|
1550
|
+
onOpenChange?.(currentOpen);
|
|
1523
1551
|
if (currentOpen) {
|
|
1524
1552
|
document.addEventListener("mousedown", handleClickOutside);
|
|
1525
1553
|
document.addEventListener("keydown", handleDownkey);
|
|
@@ -1529,17 +1557,17 @@ var DropdownMenu = ({ children, open, onOpenChange }) => {
|
|
|
1529
1557
|
document.removeEventListener("keydown", handleDownkey);
|
|
1530
1558
|
};
|
|
1531
1559
|
}, [currentOpen]);
|
|
1532
|
-
|
|
1533
|
-
()
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1560
|
+
useEffect(() => {
|
|
1561
|
+
if (isControlled) {
|
|
1562
|
+
store.setState({ open });
|
|
1563
|
+
}
|
|
1564
|
+
}, []);
|
|
1565
|
+
return /* @__PURE__ */ jsx18("div", { className: "relative", ref: menuRef, children: injectStore(children, store) });
|
|
1537
1566
|
};
|
|
1538
|
-
var DropdownMenuTrigger = forwardRef9(({ className, children, onClick, ...props }, ref) => {
|
|
1539
|
-
const
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
const { open, setOpen } = context;
|
|
1567
|
+
var DropdownMenuTrigger = forwardRef9(({ className, children, onClick, store: externalStore, ...props }, ref) => {
|
|
1568
|
+
const store = useDropdownStore(externalStore);
|
|
1569
|
+
const open = useStore(store, (s) => s.open);
|
|
1570
|
+
const toggleOpen = () => store.setState({ open: !open });
|
|
1543
1571
|
return /* @__PURE__ */ jsx18(
|
|
1544
1572
|
"button",
|
|
1545
1573
|
{
|
|
@@ -1547,7 +1575,7 @@ var DropdownMenuTrigger = forwardRef9(({ className, children, onClick, ...props
|
|
|
1547
1575
|
className: `border border-border-200 cursor-pointer bg-background-muted hover:bg-background-200 transition-colors px-4 py-2 rounded-sm ${className}`,
|
|
1548
1576
|
onClick: (e) => {
|
|
1549
1577
|
e.stopPropagation();
|
|
1550
|
-
|
|
1578
|
+
toggleOpen();
|
|
1551
1579
|
if (onClick) onClick(e);
|
|
1552
1580
|
},
|
|
1553
1581
|
"aria-expanded": open,
|
|
@@ -1572,15 +1600,16 @@ var ALIGN_CLASSES = {
|
|
|
1572
1600
|
center: "left-1/2 -translate-x-1/2",
|
|
1573
1601
|
end: "right-0"
|
|
1574
1602
|
};
|
|
1575
|
-
var MenuLabel = forwardRef9(({ className, inset, ...props }, ref) =>
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
)
|
|
1603
|
+
var MenuLabel = forwardRef9(({ className, inset, store: _store, ...props }, ref) => {
|
|
1604
|
+
return /* @__PURE__ */ jsx18(
|
|
1605
|
+
"div",
|
|
1606
|
+
{
|
|
1607
|
+
ref,
|
|
1608
|
+
className: `text-sm w-full ${inset ? "pl-8" : ""} ${className ?? ""}`,
|
|
1609
|
+
...props
|
|
1610
|
+
}
|
|
1611
|
+
);
|
|
1612
|
+
});
|
|
1584
1613
|
MenuLabel.displayName = "MenuLabel";
|
|
1585
1614
|
var MenuContent = forwardRef9(
|
|
1586
1615
|
({
|
|
@@ -1589,9 +1618,11 @@ var MenuContent = forwardRef9(
|
|
|
1589
1618
|
side = "bottom",
|
|
1590
1619
|
sideOffset = 4,
|
|
1591
1620
|
children,
|
|
1621
|
+
store: externalStore,
|
|
1592
1622
|
...props
|
|
1593
1623
|
}, ref) => {
|
|
1594
|
-
const
|
|
1624
|
+
const store = useDropdownStore(externalStore);
|
|
1625
|
+
const open = useStore(store, (s) => s.open);
|
|
1595
1626
|
const [isVisible, setIsVisible] = useState5(open);
|
|
1596
1627
|
useEffect(() => {
|
|
1597
1628
|
if (open) {
|
|
@@ -1634,15 +1665,18 @@ MenuContent.displayName = "MenuContent";
|
|
|
1634
1665
|
var MenuItem = forwardRef9(
|
|
1635
1666
|
({
|
|
1636
1667
|
className,
|
|
1637
|
-
inset,
|
|
1638
1668
|
size = "small",
|
|
1639
1669
|
children,
|
|
1640
1670
|
iconRight,
|
|
1641
1671
|
iconLeft,
|
|
1642
1672
|
disabled = false,
|
|
1643
1673
|
onClick,
|
|
1674
|
+
variant = "menu",
|
|
1675
|
+
store: externalStore,
|
|
1644
1676
|
...props
|
|
1645
1677
|
}, ref) => {
|
|
1678
|
+
const store = useDropdownStore(externalStore);
|
|
1679
|
+
const setOpen = useStore(store, (s) => s.setOpen);
|
|
1646
1680
|
const sizeClasses = ITEM_SIZE_CLASSES[size];
|
|
1647
1681
|
const handleClick = (e) => {
|
|
1648
1682
|
if (disabled) {
|
|
@@ -1651,17 +1685,27 @@ var MenuItem = forwardRef9(
|
|
|
1651
1685
|
return;
|
|
1652
1686
|
}
|
|
1653
1687
|
onClick?.(e);
|
|
1688
|
+
setOpen(false);
|
|
1689
|
+
};
|
|
1690
|
+
const getVariantClasses = () => {
|
|
1691
|
+
if (variant === "profile") {
|
|
1692
|
+
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";
|
|
1693
|
+
}
|
|
1694
|
+
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";
|
|
1695
|
+
};
|
|
1696
|
+
const getVariantProps = () => {
|
|
1697
|
+
return variant === "profile" ? { "data-variant": "profile" } : {};
|
|
1654
1698
|
};
|
|
1655
1699
|
return /* @__PURE__ */ jsxs13(
|
|
1656
1700
|
"div",
|
|
1657
1701
|
{
|
|
1658
1702
|
ref,
|
|
1659
1703
|
role: "menuitem",
|
|
1704
|
+
...getVariantProps(),
|
|
1660
1705
|
"aria-disabled": disabled,
|
|
1661
1706
|
className: `
|
|
1662
1707
|
focus-visible:bg-background-50
|
|
1663
|
-
|
|
1664
|
-
${inset && "pl-8"}
|
|
1708
|
+
${getVariantClasses()}
|
|
1665
1709
|
${sizeClasses}
|
|
1666
1710
|
${className}
|
|
1667
1711
|
${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"}
|
|
@@ -1682,7 +1726,7 @@ var MenuItem = forwardRef9(
|
|
|
1682
1726
|
}
|
|
1683
1727
|
);
|
|
1684
1728
|
MenuItem.displayName = "MenuItem";
|
|
1685
|
-
var MenuSeparator = forwardRef9(({ className, ...props }, ref) => /* @__PURE__ */ jsx18(
|
|
1729
|
+
var MenuSeparator = forwardRef9(({ className, store: _store, ...props }, ref) => /* @__PURE__ */ jsx18(
|
|
1686
1730
|
"div",
|
|
1687
1731
|
{
|
|
1688
1732
|
ref,
|
|
@@ -1691,7 +1735,376 @@ var MenuSeparator = forwardRef9(({ className, ...props }, ref) => /* @__PURE__ *
|
|
|
1691
1735
|
}
|
|
1692
1736
|
));
|
|
1693
1737
|
MenuSeparator.displayName = "MenuSeparator";
|
|
1738
|
+
var ProfileMenuTrigger = forwardRef9(({ className, onClick, store: externalStore, ...props }, ref) => {
|
|
1739
|
+
const store = useDropdownStore(externalStore);
|
|
1740
|
+
const open = useStore(store, (s) => s.open);
|
|
1741
|
+
const toggleOpen = () => store.setState({ open: !open });
|
|
1742
|
+
return /* @__PURE__ */ jsx18(
|
|
1743
|
+
"button",
|
|
1744
|
+
{
|
|
1745
|
+
ref,
|
|
1746
|
+
className: `rounded-lg size-10 bg-background-50 flex items-center justify-center ${className}`,
|
|
1747
|
+
onClick: (e) => {
|
|
1748
|
+
e.stopPropagation();
|
|
1749
|
+
toggleOpen();
|
|
1750
|
+
onClick?.(e);
|
|
1751
|
+
},
|
|
1752
|
+
"aria-expanded": open,
|
|
1753
|
+
...props,
|
|
1754
|
+
children: /* @__PURE__ */ jsx18("span", { className: "size-6 rounded-full bg-background-100 flex items-center justify-center", children: /* @__PURE__ */ jsx18(User, { className: "text-background-950", size: 18 }) })
|
|
1755
|
+
}
|
|
1756
|
+
);
|
|
1757
|
+
});
|
|
1758
|
+
ProfileMenuTrigger.displayName = "ProfileMenuTrigger";
|
|
1759
|
+
var ProfileMenuHeader = forwardRef9(({ className, name, email, store: _store, ...props }, ref) => {
|
|
1760
|
+
return /* @__PURE__ */ jsxs13(
|
|
1761
|
+
"div",
|
|
1762
|
+
{
|
|
1763
|
+
ref,
|
|
1764
|
+
"data-component": "ProfileMenuHeader",
|
|
1765
|
+
className: `
|
|
1766
|
+
flex flex-row gap-4 items-center
|
|
1767
|
+
${className}
|
|
1768
|
+
`,
|
|
1769
|
+
...props,
|
|
1770
|
+
children: [
|
|
1771
|
+
/* @__PURE__ */ jsx18("span", { className: "size-16 bg-background-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx18(User, { size: 34, className: "text-background-950" }) }),
|
|
1772
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col ", children: [
|
|
1773
|
+
/* @__PURE__ */ jsx18("p", { className: "text-xl font-bold text-text-950", children: name }),
|
|
1774
|
+
/* @__PURE__ */ jsx18("p", { className: "text-md text-text-600", children: email })
|
|
1775
|
+
] })
|
|
1776
|
+
]
|
|
1777
|
+
}
|
|
1778
|
+
);
|
|
1779
|
+
});
|
|
1780
|
+
ProfileMenuHeader.displayName = "ProfileMenuHeader";
|
|
1781
|
+
var ProfileMenuSection = forwardRef9(({ className, children, store: _store, ...props }, ref) => {
|
|
1782
|
+
return /* @__PURE__ */ jsx18(
|
|
1783
|
+
"div",
|
|
1784
|
+
{
|
|
1785
|
+
ref,
|
|
1786
|
+
className: `
|
|
1787
|
+
flex flex-col p-2
|
|
1788
|
+
${className}
|
|
1789
|
+
`,
|
|
1790
|
+
...props,
|
|
1791
|
+
children
|
|
1792
|
+
}
|
|
1793
|
+
);
|
|
1794
|
+
});
|
|
1795
|
+
ProfileMenuSection.displayName = "ProfileMenuSection";
|
|
1796
|
+
var ProfileMenuFooter = forwardRef9(
|
|
1797
|
+
({ className, disabled = false, onClick, store: externalStore, ...props }, ref) => {
|
|
1798
|
+
const store = useDropdownStore(externalStore);
|
|
1799
|
+
const setOpen = useStore(store, (s) => s.setOpen);
|
|
1800
|
+
return /* @__PURE__ */ jsxs13(
|
|
1801
|
+
"button",
|
|
1802
|
+
{
|
|
1803
|
+
ref,
|
|
1804
|
+
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}`,
|
|
1805
|
+
disabled,
|
|
1806
|
+
onClick: (e) => {
|
|
1807
|
+
setOpen(false);
|
|
1808
|
+
onClick?.(e);
|
|
1809
|
+
},
|
|
1810
|
+
...props,
|
|
1811
|
+
children: [
|
|
1812
|
+
/* @__PURE__ */ jsx18("span", { className: "mr-2 flex items-center", children: /* @__PURE__ */ jsx18(SignOut, {}) }),
|
|
1813
|
+
/* @__PURE__ */ jsx18("span", { children: "Sair" })
|
|
1814
|
+
]
|
|
1815
|
+
}
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
);
|
|
1819
|
+
ProfileMenuFooter.displayName = "ProfileMenuFooter";
|
|
1694
1820
|
var DropdownMenu_default = DropdownMenu;
|
|
1821
|
+
|
|
1822
|
+
// src/components/Select/Select.tsx
|
|
1823
|
+
import { create as create3, useStore as useStore2 } from "zustand";
|
|
1824
|
+
import {
|
|
1825
|
+
useEffect as useEffect2,
|
|
1826
|
+
useRef as useRef2,
|
|
1827
|
+
forwardRef as forwardRef10,
|
|
1828
|
+
isValidElement as isValidElement2,
|
|
1829
|
+
Children as Children2,
|
|
1830
|
+
cloneElement as cloneElement2
|
|
1831
|
+
} from "react";
|
|
1832
|
+
import { CaretDown, Check as Check3 } from "phosphor-react";
|
|
1833
|
+
import { Fragment as Fragment2, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1834
|
+
var VARIANT_CLASSES2 = {
|
|
1835
|
+
outlined: "border-2 rounded-sm focus:border-primary-950",
|
|
1836
|
+
underlined: "border-b-2 focus:border-primary-950",
|
|
1837
|
+
rounded: "border-2 rounded-4xl focus:border-primary-950"
|
|
1838
|
+
};
|
|
1839
|
+
var SIZE_CLASSES7 = {
|
|
1840
|
+
small: "text-sm",
|
|
1841
|
+
medium: "text-md",
|
|
1842
|
+
large: "text-lg"
|
|
1843
|
+
};
|
|
1844
|
+
var SIDE_CLASSES2 = {
|
|
1845
|
+
top: "bottom-full -translate-y-1",
|
|
1846
|
+
right: "top-full translate-y-1",
|
|
1847
|
+
bottom: "top-full translate-y-1",
|
|
1848
|
+
left: "top-full translate-y-1"
|
|
1849
|
+
};
|
|
1850
|
+
var ALIGN_CLASSES2 = {
|
|
1851
|
+
start: "left-0",
|
|
1852
|
+
center: "left-1/2 -translate-x-1/2",
|
|
1853
|
+
end: "right-0"
|
|
1854
|
+
};
|
|
1855
|
+
function createSelectStore() {
|
|
1856
|
+
return create3((set) => ({
|
|
1857
|
+
open: false,
|
|
1858
|
+
setOpen: (open) => set({ open }),
|
|
1859
|
+
value: "",
|
|
1860
|
+
setValue: (value) => set({ value }),
|
|
1861
|
+
selectedLabel: "",
|
|
1862
|
+
setSelectedLabel: (label) => set({ selectedLabel: label })
|
|
1863
|
+
}));
|
|
1864
|
+
}
|
|
1865
|
+
var useSelectStore = (externalStore) => {
|
|
1866
|
+
if (!externalStore) {
|
|
1867
|
+
throw new Error(
|
|
1868
|
+
"Component must be used within a Select (store is missing)"
|
|
1869
|
+
);
|
|
1870
|
+
}
|
|
1871
|
+
return externalStore;
|
|
1872
|
+
};
|
|
1873
|
+
function getLabelAsNode(children) {
|
|
1874
|
+
if (typeof children === "string" || typeof children === "number") {
|
|
1875
|
+
return children;
|
|
1876
|
+
}
|
|
1877
|
+
const flattened = Children2.toArray(children);
|
|
1878
|
+
if (flattened.length === 1) return flattened[0];
|
|
1879
|
+
return /* @__PURE__ */ jsx19(Fragment2, { children: flattened });
|
|
1880
|
+
}
|
|
1881
|
+
var injectStore2 = (children, store) => {
|
|
1882
|
+
return Children2.map(children, (child) => {
|
|
1883
|
+
if (isValidElement2(child)) {
|
|
1884
|
+
const typedChild = child;
|
|
1885
|
+
const newProps = {
|
|
1886
|
+
store
|
|
1887
|
+
};
|
|
1888
|
+
if (typedChild.props.children) {
|
|
1889
|
+
newProps.children = injectStore2(typedChild.props.children, store);
|
|
1890
|
+
}
|
|
1891
|
+
return cloneElement2(typedChild, newProps);
|
|
1892
|
+
}
|
|
1893
|
+
return child;
|
|
1894
|
+
});
|
|
1895
|
+
};
|
|
1896
|
+
var Select = ({
|
|
1897
|
+
children,
|
|
1898
|
+
defaultValue = "",
|
|
1899
|
+
value: propValue,
|
|
1900
|
+
onValueChange,
|
|
1901
|
+
size = "small"
|
|
1902
|
+
}) => {
|
|
1903
|
+
const storeRef = useRef2(null);
|
|
1904
|
+
storeRef.current ??= createSelectStore();
|
|
1905
|
+
const store = storeRef.current;
|
|
1906
|
+
const selectRef = useRef2(null);
|
|
1907
|
+
const { open, setOpen, setValue, value, selectedLabel } = useStore2(
|
|
1908
|
+
store,
|
|
1909
|
+
(s) => s
|
|
1910
|
+
);
|
|
1911
|
+
const isControlled = propValue !== void 0;
|
|
1912
|
+
const currentValue = isControlled ? propValue : value;
|
|
1913
|
+
const findLabelForValue = (children2, targetValue) => {
|
|
1914
|
+
let found = null;
|
|
1915
|
+
const search = (nodes) => {
|
|
1916
|
+
Children2.forEach(nodes, (child) => {
|
|
1917
|
+
if (!isValidElement2(child)) return;
|
|
1918
|
+
const typedChild = child;
|
|
1919
|
+
if (typedChild.type === SelectItem && typedChild.props.value === targetValue) {
|
|
1920
|
+
if (typeof typedChild.props.children === "string")
|
|
1921
|
+
found = typedChild.props.children;
|
|
1922
|
+
}
|
|
1923
|
+
if (typedChild.props.children && !found)
|
|
1924
|
+
search(typedChild.props.children);
|
|
1925
|
+
});
|
|
1926
|
+
};
|
|
1927
|
+
search(children2);
|
|
1928
|
+
return found;
|
|
1929
|
+
};
|
|
1930
|
+
useEffect2(() => {
|
|
1931
|
+
if (!selectedLabel && defaultValue) {
|
|
1932
|
+
const label = findLabelForValue(children, defaultValue);
|
|
1933
|
+
if (label) store.setState({ selectedLabel: label });
|
|
1934
|
+
}
|
|
1935
|
+
}, [children, defaultValue, selectedLabel]);
|
|
1936
|
+
useEffect2(() => {
|
|
1937
|
+
setValue(currentValue);
|
|
1938
|
+
const handleClickOutside = (event) => {
|
|
1939
|
+
if (selectRef.current && !selectRef.current.contains(event.target)) {
|
|
1940
|
+
setOpen(false);
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1943
|
+
const handleArrowKeys = (event) => {
|
|
1944
|
+
const selectContent = selectRef.current?.querySelector('[role="menu"]');
|
|
1945
|
+
if (selectContent) {
|
|
1946
|
+
event.preventDefault();
|
|
1947
|
+
const items = Array.from(
|
|
1948
|
+
selectContent.querySelectorAll(
|
|
1949
|
+
'[role="menuitem"]:not([aria-disabled="true"])'
|
|
1950
|
+
)
|
|
1951
|
+
).filter((el) => el instanceof HTMLElement);
|
|
1952
|
+
const focused = document.activeElement;
|
|
1953
|
+
const currentIndex = items.findIndex((item) => item === focused);
|
|
1954
|
+
let nextIndex = 0;
|
|
1955
|
+
if (event.key === "ArrowDown") {
|
|
1956
|
+
nextIndex = currentIndex === -1 ? 0 : (currentIndex + 1) % items.length;
|
|
1957
|
+
} else {
|
|
1958
|
+
nextIndex = currentIndex === -1 ? items.length - 1 : (currentIndex - 1 + items.length) % items.length;
|
|
1959
|
+
}
|
|
1960
|
+
items[nextIndex]?.focus();
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
if (open) {
|
|
1964
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
1965
|
+
document.addEventListener("keydown", handleArrowKeys);
|
|
1966
|
+
}
|
|
1967
|
+
return () => {
|
|
1968
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
1969
|
+
document.removeEventListener("keydown", handleArrowKeys);
|
|
1970
|
+
};
|
|
1971
|
+
}, [open]);
|
|
1972
|
+
useEffect2(() => {
|
|
1973
|
+
if (onValueChange) {
|
|
1974
|
+
onValueChange(value);
|
|
1975
|
+
}
|
|
1976
|
+
}, [value]);
|
|
1977
|
+
const sizeClasses = SIZE_CLASSES7[size];
|
|
1978
|
+
return /* @__PURE__ */ jsx19("div", { className: `relative ${sizeClasses} w-[288px]`, ref: selectRef, children: injectStore2(children, store) });
|
|
1979
|
+
};
|
|
1980
|
+
var SelectValue = ({
|
|
1981
|
+
placeholder,
|
|
1982
|
+
store: externalStore
|
|
1983
|
+
}) => {
|
|
1984
|
+
const store = useSelectStore(externalStore);
|
|
1985
|
+
const selectedLabel = useStore2(store, (s) => s.selectedLabel);
|
|
1986
|
+
const value = useStore2(store, (s) => s.value);
|
|
1987
|
+
return /* @__PURE__ */ jsx19("span", { className: "text-inherit", children: selectedLabel || placeholder || value });
|
|
1988
|
+
};
|
|
1989
|
+
var SelectTrigger = forwardRef10(
|
|
1990
|
+
({
|
|
1991
|
+
className,
|
|
1992
|
+
invalid = false,
|
|
1993
|
+
variant = "outlined",
|
|
1994
|
+
store: externalStore,
|
|
1995
|
+
disabled,
|
|
1996
|
+
...props
|
|
1997
|
+
}, ref) => {
|
|
1998
|
+
const store = useSelectStore(externalStore);
|
|
1999
|
+
const open = useStore2(store, (s) => s.open);
|
|
2000
|
+
const toggleOpen = () => store.setState({ open: !open });
|
|
2001
|
+
const variantClasses = VARIANT_CLASSES2[variant];
|
|
2002
|
+
return /* @__PURE__ */ jsxs14(
|
|
2003
|
+
"button",
|
|
2004
|
+
{
|
|
2005
|
+
ref,
|
|
2006
|
+
className: `
|
|
2007
|
+
flex h-9 min-w-[220px] w-full items-center justify-between border-border-300 px-3 py-2
|
|
2008
|
+
${invalid && "border-indicator-error"}
|
|
2009
|
+
${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"}
|
|
2010
|
+
${variantClasses}
|
|
2011
|
+
${className}
|
|
2012
|
+
`,
|
|
2013
|
+
onClick: toggleOpen,
|
|
2014
|
+
"aria-expanded": open,
|
|
2015
|
+
"aria-haspopup": "listbox",
|
|
2016
|
+
"aria-controls": open ? "select-content" : void 0,
|
|
2017
|
+
...props,
|
|
2018
|
+
children: [
|
|
2019
|
+
props.children,
|
|
2020
|
+
/* @__PURE__ */ jsx19(
|
|
2021
|
+
CaretDown,
|
|
2022
|
+
{
|
|
2023
|
+
className: `h-[1em] w-[1em] opacity-50 transition-transform ${open ? "rotate-180" : ""}`
|
|
2024
|
+
}
|
|
2025
|
+
)
|
|
2026
|
+
]
|
|
2027
|
+
}
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
);
|
|
2031
|
+
SelectTrigger.displayName = "SelectTrigger";
|
|
2032
|
+
var SelectContent = forwardRef10(
|
|
2033
|
+
({
|
|
2034
|
+
children,
|
|
2035
|
+
className,
|
|
2036
|
+
align = "start",
|
|
2037
|
+
side = "bottom",
|
|
2038
|
+
store: externalStore,
|
|
2039
|
+
...props
|
|
2040
|
+
}, ref) => {
|
|
2041
|
+
const store = useSelectStore(externalStore);
|
|
2042
|
+
const open = useStore2(store, (s) => s.open);
|
|
2043
|
+
if (!open) return null;
|
|
2044
|
+
const getPositionClasses = () => `absolute ${SIDE_CLASSES2[side]} ${ALIGN_CLASSES2[align]}`;
|
|
2045
|
+
return /* @__PURE__ */ jsx19(
|
|
2046
|
+
"div",
|
|
2047
|
+
{
|
|
2048
|
+
role: "menu",
|
|
2049
|
+
ref,
|
|
2050
|
+
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}`,
|
|
2051
|
+
...props,
|
|
2052
|
+
children
|
|
2053
|
+
}
|
|
2054
|
+
);
|
|
2055
|
+
}
|
|
2056
|
+
);
|
|
2057
|
+
SelectContent.displayName = "SelectContent";
|
|
2058
|
+
var SelectItem = forwardRef10(
|
|
2059
|
+
({
|
|
2060
|
+
className,
|
|
2061
|
+
children,
|
|
2062
|
+
value,
|
|
2063
|
+
disabled = false,
|
|
2064
|
+
store: externalStore,
|
|
2065
|
+
...props
|
|
2066
|
+
}, ref) => {
|
|
2067
|
+
const store = useSelectStore(externalStore);
|
|
2068
|
+
const selectedValue = useStore2(store, (s) => s.value);
|
|
2069
|
+
const { setValue, setSelectedLabel, setOpen } = store.getState();
|
|
2070
|
+
const handleClick = (e) => {
|
|
2071
|
+
const labelNode = getLabelAsNode(children);
|
|
2072
|
+
if (!disabled) {
|
|
2073
|
+
setValue(value);
|
|
2074
|
+
setSelectedLabel(labelNode);
|
|
2075
|
+
setOpen(false);
|
|
2076
|
+
}
|
|
2077
|
+
props.onClick?.(e);
|
|
2078
|
+
};
|
|
2079
|
+
return /* @__PURE__ */ jsxs14(
|
|
2080
|
+
"div",
|
|
2081
|
+
{
|
|
2082
|
+
role: "menuitem",
|
|
2083
|
+
"aria-disabled": disabled,
|
|
2084
|
+
ref,
|
|
2085
|
+
className: `
|
|
2086
|
+
focus-visible:bg-background-50
|
|
2087
|
+
relative flex select-none items-center gap-2 rounded-sm p-3 outline-none transition-colors [&>svg]:size-4 [&>svg]:shrink-0
|
|
2088
|
+
${className}
|
|
2089
|
+
${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"}
|
|
2090
|
+
${selectedValue === value && "bg-background-50"}
|
|
2091
|
+
`,
|
|
2092
|
+
onClick: handleClick,
|
|
2093
|
+
onKeyDown: (e) => {
|
|
2094
|
+
if (e.key === "Enter" || e.key === " ") handleClick(e);
|
|
2095
|
+
},
|
|
2096
|
+
tabIndex: disabled ? -1 : 0,
|
|
2097
|
+
...props,
|
|
2098
|
+
children: [
|
|
2099
|
+
/* @__PURE__ */ jsx19("span", { className: "absolute right-2 flex h-3.5 w-3.5 items-center justify-center", children: selectedValue === value && /* @__PURE__ */ jsx19(Check3, { className: "" }) }),
|
|
2100
|
+
children
|
|
2101
|
+
]
|
|
2102
|
+
}
|
|
2103
|
+
);
|
|
2104
|
+
}
|
|
2105
|
+
);
|
|
2106
|
+
SelectItem.displayName = "SelectItem";
|
|
2107
|
+
var Select_default = Select;
|
|
1695
2108
|
export {
|
|
1696
2109
|
Alert_default as Alert,
|
|
1697
2110
|
Badge_default as Badge,
|
|
@@ -1700,16 +2113,25 @@ export {
|
|
|
1700
2113
|
Chips_default as Chips,
|
|
1701
2114
|
Divider_default as Divider,
|
|
1702
2115
|
DropdownMenu_default as DropdownMenu,
|
|
1703
|
-
MenuContent as DropdownMenuContent,
|
|
1704
|
-
MenuItem as DropdownMenuItem,
|
|
1705
|
-
MenuLabel as DropdownMenuLabel,
|
|
1706
|
-
MenuSeparator as DropdownMenuSeparator,
|
|
1707
2116
|
DropdownMenuTrigger,
|
|
1708
2117
|
IconButton_default as IconButton,
|
|
1709
2118
|
IconRoundedButton_default as IconRoundedButton,
|
|
1710
2119
|
Input_default as Input,
|
|
2120
|
+
MenuContent,
|
|
2121
|
+
MenuItem,
|
|
2122
|
+
MenuLabel,
|
|
2123
|
+
MenuSeparator,
|
|
1711
2124
|
NavButton_default as NavButton,
|
|
2125
|
+
ProfileMenuFooter,
|
|
2126
|
+
ProfileMenuHeader,
|
|
2127
|
+
ProfileMenuSection,
|
|
2128
|
+
ProfileMenuTrigger,
|
|
1712
2129
|
Radio_default as Radio,
|
|
2130
|
+
Select_default as Select,
|
|
2131
|
+
SelectContent,
|
|
2132
|
+
SelectItem,
|
|
2133
|
+
SelectTrigger,
|
|
2134
|
+
SelectValue,
|
|
1713
2135
|
SelectionButton_default as SelectionButton,
|
|
1714
2136
|
Table_default as Table,
|
|
1715
2137
|
Text_default as Text,
|