@ataraui/ataraui-react 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1392,7 +1392,386 @@ var Skeleton = ({
1392
1392
  );
1393
1393
  };
1394
1394
  Skeleton.displayName = "Skeleton";
1395
+ var tabsListVariants = cva(
1396
+ "flex items-center gap-1 rounded-(--radius-lg) bg-(--color-neutral-100) p-1",
1397
+ {
1398
+ variants: {
1399
+ variant: {
1400
+ default: "bg-(--color-neutral-100)",
1401
+ outline: "bg-transparent border border-(--color-neutral-200)",
1402
+ pills: "bg-transparent gap-2"
1403
+ }
1404
+ },
1405
+ defaultVariants: { variant: "default" }
1406
+ }
1407
+ );
1408
+ var tabsTriggerVariants = cva(
1409
+ "inline-flex items-center justify-center whitespace-nowrap rounded-(--radius-md) px-3 py-1.5 text-sm font-medium transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-(--color-primary-500) disabled:pointer-events-none disabled:opacity-50",
1410
+ {
1411
+ variants: {
1412
+ variant: {
1413
+ default: "text-(--color-neutral-500) data-[state=active]:bg-white data-[state=active]:text-(--color-neutral-900) data-[state=active]:shadow-sm",
1414
+ outline: "text-(--color-neutral-500) data-[state=active]:border data-[state=active]:border-(--color-neutral-200) data-[state=active]:bg-white data-[state=active]:text-(--color-neutral-900)",
1415
+ pills: "text-(--color-neutral-500) rounded-full data-[state=active]:bg-(--color-primary-500) data-[state=active]:text-white"
1416
+ }
1417
+ },
1418
+ defaultVariants: { variant: "default" }
1419
+ }
1420
+ );
1421
+ var TabsContext = React13.createContext(null);
1422
+ var useTabsContext = () => {
1423
+ const ctx = React13.useContext(TabsContext);
1424
+ if (!ctx) throw new Error("Tabs components must be used within <Tabs>");
1425
+ return ctx;
1426
+ };
1427
+ var Tabs = ({
1428
+ value,
1429
+ defaultValue = "",
1430
+ onChange,
1431
+ variant = "default",
1432
+ className,
1433
+ children,
1434
+ ...props
1435
+ }) => {
1436
+ const [uncontrolled, setUncontrolled] = React13.useState(defaultValue);
1437
+ const isControlled = value !== void 0;
1438
+ const active = isControlled ? value : uncontrolled;
1439
+ const setActive = React13.useCallback((val) => {
1440
+ if (!isControlled) setUncontrolled(val);
1441
+ onChange == null ? void 0 : onChange(val);
1442
+ }, [isControlled, onChange]);
1443
+ return /* @__PURE__ */ jsx(TabsContext.Provider, { value: { active, setActive, variant }, children: /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-2", className), ...props, children }) });
1444
+ };
1445
+ Tabs.displayName = "Tabs";
1446
+ var TabsList = ({ className, children, ...props }) => {
1447
+ const { variant } = useTabsContext();
1448
+ return /* @__PURE__ */ jsx(
1449
+ "div",
1450
+ {
1451
+ role: "tablist",
1452
+ className: cn(tabsListVariants({ variant }), className),
1453
+ ...props,
1454
+ children
1455
+ }
1456
+ );
1457
+ };
1458
+ TabsList.displayName = "TabsList";
1459
+ var TabsTrigger = ({
1460
+ value,
1461
+ className,
1462
+ children,
1463
+ ...props
1464
+ }) => {
1465
+ const { active, setActive, variant } = useTabsContext();
1466
+ const isActive = active === value;
1467
+ return /* @__PURE__ */ jsx(
1468
+ "button",
1469
+ {
1470
+ type: "button",
1471
+ role: "tab",
1472
+ "aria-selected": isActive,
1473
+ "data-state": isActive ? "active" : "inactive",
1474
+ onClick: () => setActive(value),
1475
+ className: cn(tabsTriggerVariants({ variant }), className),
1476
+ ...props,
1477
+ children
1478
+ }
1479
+ );
1480
+ };
1481
+ TabsTrigger.displayName = "TabsTrigger";
1482
+ var TabsContent = ({
1483
+ value,
1484
+ className,
1485
+ children,
1486
+ ...props
1487
+ }) => {
1488
+ const { active } = useTabsContext();
1489
+ if (active !== value) return null;
1490
+ return /* @__PURE__ */ jsx(
1491
+ "div",
1492
+ {
1493
+ role: "tabpanel",
1494
+ className: cn("mt-2", className),
1495
+ ...props,
1496
+ children
1497
+ }
1498
+ );
1499
+ };
1500
+ TabsContent.displayName = "TabsContent";
1501
+ var accordionVariants = cva(
1502
+ "w-full",
1503
+ {
1504
+ variants: {
1505
+ variant: {
1506
+ default: "divide-y divide-(--color-neutral-200) rounded-(--radius-lg) border border-(--color-neutral-200)",
1507
+ ghost: "divide-y divide-(--color-neutral-200)",
1508
+ outlined: "flex flex-col gap-2"
1509
+ }
1510
+ },
1511
+ defaultVariants: { variant: "default" }
1512
+ }
1513
+ );
1514
+ var AccordionContext = React13.createContext(null);
1515
+ var useAccordionContext = () => {
1516
+ const ctx = React13.useContext(AccordionContext);
1517
+ if (!ctx) throw new Error("Accordion components must be used within <Accordion>");
1518
+ return ctx;
1519
+ };
1520
+ var Accordion = ({
1521
+ type = "single",
1522
+ value,
1523
+ defaultValue,
1524
+ onChange,
1525
+ variant = "default",
1526
+ className,
1527
+ children,
1528
+ ...props
1529
+ }) => {
1530
+ const initOpen = defaultValue ? Array.isArray(defaultValue) ? defaultValue : [defaultValue] : [];
1531
+ const [uncontrolled, setUncontrolled] = React13.useState(initOpen);
1532
+ const isControlled = value !== void 0;
1533
+ const openItems = isControlled ? Array.isArray(value) ? value : [value] : uncontrolled;
1534
+ const toggle = React13.useCallback((val) => {
1535
+ var _a;
1536
+ let next;
1537
+ if (type === "single") {
1538
+ next = openItems.includes(val) ? [] : [val];
1539
+ } else {
1540
+ next = openItems.includes(val) ? openItems.filter((v) => v !== val) : [...openItems, val];
1541
+ }
1542
+ if (!isControlled) setUncontrolled(next);
1543
+ onChange == null ? void 0 : onChange(type === "single" ? (_a = next[0]) != null ? _a : "" : next);
1544
+ }, [isControlled, onChange, openItems, type]);
1545
+ return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: { openItems, toggle, variant }, children: /* @__PURE__ */ jsx("div", { className: cn(accordionVariants({ variant }), className), ...props, children }) });
1546
+ };
1547
+ Accordion.displayName = "Accordion";
1548
+ var AccordionItemContext = React13.createContext(null);
1549
+ var useAccordionItemContext = () => {
1550
+ const ctx = React13.useContext(AccordionItemContext);
1551
+ if (!ctx) throw new Error("AccordionTrigger/Content must be used within <AccordionItem>");
1552
+ return ctx;
1553
+ };
1554
+ var AccordionItem = ({
1555
+ value,
1556
+ disabled = false,
1557
+ className,
1558
+ children,
1559
+ ...props
1560
+ }) => {
1561
+ const { openItems, variant } = useAccordionContext();
1562
+ const isOpen = openItems.includes(value);
1563
+ return /* @__PURE__ */ jsx(AccordionItemContext.Provider, { value: { value, isOpen, disabled }, children: /* @__PURE__ */ jsx(
1564
+ "div",
1565
+ {
1566
+ "data-state": isOpen ? "open" : "closed",
1567
+ className: cn(
1568
+ variant === "outlined" && "rounded-(--radius-lg) border border-(--color-neutral-200)",
1569
+ disabled && "opacity-50 pointer-events-none",
1570
+ className
1571
+ ),
1572
+ ...props,
1573
+ children
1574
+ }
1575
+ ) });
1576
+ };
1577
+ AccordionItem.displayName = "AccordionItem";
1578
+ var AccordionTrigger = ({
1579
+ className,
1580
+ children,
1581
+ ...props
1582
+ }) => {
1583
+ const { toggle } = useAccordionContext();
1584
+ const { value, isOpen } = useAccordionItemContext();
1585
+ return /* @__PURE__ */ jsxs(
1586
+ "button",
1587
+ {
1588
+ type: "button",
1589
+ "aria-expanded": isOpen,
1590
+ onClick: () => toggle(value),
1591
+ className: cn(
1592
+ "flex w-full items-center justify-between px-4 py-4 text-sm font-medium text-(--color-neutral-900) transition-all hover:bg-(--color-neutral-50) focus:outline-none focus-visible:ring-2 focus-visible:ring-(--color-primary-500)",
1593
+ className
1594
+ ),
1595
+ ...props,
1596
+ children: [
1597
+ children,
1598
+ /* @__PURE__ */ jsx(
1599
+ "svg",
1600
+ {
1601
+ xmlns: "http://www.w3.org/2000/svg",
1602
+ width: "16",
1603
+ height: "16",
1604
+ viewBox: "0 0 24 24",
1605
+ fill: "none",
1606
+ stroke: "currentColor",
1607
+ strokeWidth: "2",
1608
+ strokeLinecap: "round",
1609
+ strokeLinejoin: "round",
1610
+ className: cn("shrink-0 text-(--color-neutral-500) transition-transform duration-200", isOpen && "rotate-180"),
1611
+ children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
1612
+ }
1613
+ )
1614
+ ]
1615
+ }
1616
+ );
1617
+ };
1618
+ AccordionTrigger.displayName = "AccordionTrigger";
1619
+ var AccordionContent = ({
1620
+ className,
1621
+ children,
1622
+ ...props
1623
+ }) => {
1624
+ const { isOpen } = useAccordionItemContext();
1625
+ if (!isOpen) return null;
1626
+ return /* @__PURE__ */ jsx(
1627
+ "div",
1628
+ {
1629
+ className: cn("px-4 pb-4 text-sm text-(--color-neutral-600)", className),
1630
+ ...props,
1631
+ children
1632
+ }
1633
+ );
1634
+ };
1635
+ AccordionContent.displayName = "AccordionContent";
1636
+ var tableVariants = cva(
1637
+ "w-full caption-bottom text-sm",
1638
+ {
1639
+ variants: {
1640
+ variant: {
1641
+ default: "",
1642
+ striped: "",
1643
+ bordered: ""
1644
+ }
1645
+ },
1646
+ defaultVariants: { variant: "default" }
1647
+ }
1648
+ );
1649
+ var TableContext = React13.createContext({ variant: "default" });
1650
+ var Table = ({
1651
+ variant = "default",
1652
+ className,
1653
+ children,
1654
+ ...props
1655
+ }) => {
1656
+ return /* @__PURE__ */ jsx(TableContext.Provider, { value: { variant }, children: /* @__PURE__ */ jsx("div", { className: "w-full overflow-auto rounded-(--radius-lg) border border-(--color-neutral-200)", children: /* @__PURE__ */ jsx(
1657
+ "table",
1658
+ {
1659
+ className: cn(tableVariants({ variant }), className),
1660
+ ...props,
1661
+ children
1662
+ }
1663
+ ) }) });
1664
+ };
1665
+ Table.displayName = "Table";
1666
+ var TableHeader = ({
1667
+ className,
1668
+ children,
1669
+ ...props
1670
+ }) => /* @__PURE__ */ jsx(
1671
+ "thead",
1672
+ {
1673
+ className: cn("bg-(--color-neutral-50) [&_tr]:border-b [&_tr]:border-(--color-neutral-200)", className),
1674
+ ...props,
1675
+ children
1676
+ }
1677
+ );
1678
+ TableHeader.displayName = "TableHeader";
1679
+ var TableBody = ({
1680
+ className,
1681
+ children,
1682
+ ...props
1683
+ }) => {
1684
+ const { variant } = React13.useContext(TableContext);
1685
+ return /* @__PURE__ */ jsx(
1686
+ "tbody",
1687
+ {
1688
+ className: cn(
1689
+ "[&_tr:last-child]:border-0",
1690
+ variant === "striped" && "[&_tr:nth-child(odd)]:bg-(--color-neutral-50)",
1691
+ className
1692
+ ),
1693
+ ...props,
1694
+ children
1695
+ }
1696
+ );
1697
+ };
1698
+ TableBody.displayName = "TableBody";
1699
+ var TableFooter = ({
1700
+ className,
1701
+ children,
1702
+ ...props
1703
+ }) => /* @__PURE__ */ jsx(
1704
+ "tfoot",
1705
+ {
1706
+ className: cn("border-t border-(--color-neutral-200) bg-(--color-neutral-50) font-medium", className),
1707
+ ...props,
1708
+ children
1709
+ }
1710
+ );
1711
+ TableFooter.displayName = "TableFooter";
1712
+ var TableRow = ({
1713
+ className,
1714
+ children,
1715
+ ...props
1716
+ }) => {
1717
+ const { variant } = React13.useContext(TableContext);
1718
+ return /* @__PURE__ */ jsx(
1719
+ "tr",
1720
+ {
1721
+ className: cn(
1722
+ "border-b border-(--color-neutral-200) transition-colors hover:bg-(--color-neutral-50)",
1723
+ variant === "bordered" && "[&_td]:border-r [&_td]:last:border-r-0 [&_th]:border-r [&_th]:last:border-r-0",
1724
+ className
1725
+ ),
1726
+ ...props,
1727
+ children
1728
+ }
1729
+ );
1730
+ };
1731
+ TableRow.displayName = "TableRow";
1732
+ var TableHead = ({
1733
+ className,
1734
+ children,
1735
+ ...props
1736
+ }) => /* @__PURE__ */ jsx(
1737
+ "th",
1738
+ {
1739
+ className: cn(
1740
+ "h-10 px-4 text-left align-middle text-xs font-semibold uppercase tracking-wide text-(--color-neutral-500)",
1741
+ className
1742
+ ),
1743
+ ...props,
1744
+ children
1745
+ }
1746
+ );
1747
+ TableHead.displayName = "TableHead";
1748
+ var TableCell = ({
1749
+ className,
1750
+ children,
1751
+ ...props
1752
+ }) => /* @__PURE__ */ jsx(
1753
+ "td",
1754
+ {
1755
+ className: cn("px-4 py-3 align-middle text-(--color-neutral-700)", className),
1756
+ ...props,
1757
+ children
1758
+ }
1759
+ );
1760
+ TableCell.displayName = "TableCell";
1761
+ var TableCaption = ({
1762
+ className,
1763
+ children,
1764
+ ...props
1765
+ }) => /* @__PURE__ */ jsx(
1766
+ "caption",
1767
+ {
1768
+ className: cn("mt-4 text-sm text-(--color-neutral-500)", className),
1769
+ ...props,
1770
+ children
1771
+ }
1772
+ );
1773
+ TableCaption.displayName = "TableCaption";
1395
1774
 
1396
- export { Alert, AlertDescription, AlertTitle, Avatar, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Drawer, DrawerBody, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, Input, Modal, ModalBody, ModalDescription, ModalFooter, ModalHeader, ModalTitle, Popover, Progress, RadioGroup, Select, Separator, Skeleton, Spinner, Switch, ToastProvider, Toaster, Tooltip, alertVariants, avatarVariants, badgeVariants, buttonVariants, cardVariants, cn, colors, drawerVariants, fontSize, inputVariants, modalVariants, progressVariants, radius, selectVariants, separatorVariants, skeletonVariants, spinnerVariants, toastVariants, useToast };
1775
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertTitle, Avatar, Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Drawer, DrawerBody, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, Input, Modal, ModalBody, ModalDescription, ModalFooter, ModalHeader, ModalTitle, Popover, Progress, RadioGroup, Select, Separator, Skeleton, Spinner, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, ToastProvider, Toaster, Tooltip, accordionVariants, alertVariants, avatarVariants, badgeVariants, buttonVariants, cardVariants, cn, colors, drawerVariants, fontSize, inputVariants, modalVariants, progressVariants, radius, selectVariants, separatorVariants, skeletonVariants, spinnerVariants, tableVariants, tabsListVariants, tabsTriggerVariants, toastVariants, useToast };
1397
1776
  //# sourceMappingURL=index.mjs.map
1398
1777
  //# sourceMappingURL=index.mjs.map