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