@opensite/ui 1.0.6 → 1.0.7

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.
@@ -8,6 +8,7 @@ var classVarianceAuthority = require('class-variance-authority');
8
8
  var jsxRuntime = require('react/jsx-runtime');
9
9
  var img = require('@page-speed/img');
10
10
  var NavigationMenuPrimitive = require('@radix-ui/react-navigation-menu');
11
+ var AccordionPrimitive = require('@radix-ui/react-accordion');
11
12
 
12
13
  function _interopNamespace(e) {
13
14
  if (e && e.__esModule) return e;
@@ -29,6 +30,7 @@ function _interopNamespace(e) {
29
30
 
30
31
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
31
32
  var NavigationMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(NavigationMenuPrimitive);
33
+ var AccordionPrimitive__namespace = /*#__PURE__*/_interopNamespace(AccordionPrimitive);
32
34
 
33
35
  // components/blocks/navbars/navbar-mega-menu.tsx
34
36
  function cn(...inputs) {
@@ -1130,6 +1132,122 @@ function NavigationMenuLink({
1130
1132
  }
1131
1133
  );
1132
1134
  }
1135
+ function Accordion({
1136
+ ...props
1137
+ }) {
1138
+ return /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Root, { "data-slot": "accordion", ...props });
1139
+ }
1140
+ function AccordionItem({
1141
+ className,
1142
+ ...props
1143
+ }) {
1144
+ return /* @__PURE__ */ jsxRuntime.jsx(
1145
+ AccordionPrimitive__namespace.Item,
1146
+ {
1147
+ "data-slot": "accordion-item",
1148
+ className: cn("border-b ", className),
1149
+ ...props
1150
+ }
1151
+ );
1152
+ }
1153
+ function AccordionTrigger({
1154
+ className,
1155
+ children,
1156
+ ...props
1157
+ }) {
1158
+ return /* @__PURE__ */ jsxRuntime.jsx(AccordionPrimitive__namespace.Header, { className: "flex", children: /* @__PURE__ */ jsxRuntime.jsxs(
1159
+ AccordionPrimitive__namespace.Trigger,
1160
+ {
1161
+ "data-slot": "accordion-trigger",
1162
+ className: cn(
1163
+ "focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-center justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
1164
+ className
1165
+ ),
1166
+ ...props,
1167
+ children: [
1168
+ children,
1169
+ /* @__PURE__ */ jsxRuntime.jsx(
1170
+ DynamicIcon,
1171
+ {
1172
+ name: "lucide/chevron-down",
1173
+ className: "text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"
1174
+ }
1175
+ )
1176
+ ]
1177
+ }
1178
+ ) });
1179
+ }
1180
+ function AccordionContent({
1181
+ className,
1182
+ children,
1183
+ ...props
1184
+ }) {
1185
+ return /* @__PURE__ */ jsxRuntime.jsx(
1186
+ AccordionPrimitive__namespace.Content,
1187
+ {
1188
+ "data-slot": "accordion-content",
1189
+ className: "data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",
1190
+ ...props,
1191
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("pt-0 pb-4", className), children })
1192
+ }
1193
+ );
1194
+ }
1195
+ var NavbarMobileMenu = ({
1196
+ open,
1197
+ onClose,
1198
+ children,
1199
+ className,
1200
+ contentClassName,
1201
+ title = "Mobile Navigation"
1202
+ }) => {
1203
+ React__namespace.useEffect(() => {
1204
+ if (open) {
1205
+ const originalOverflow = document.body.style.overflow;
1206
+ document.body.style.overflow = "hidden";
1207
+ return () => {
1208
+ document.body.style.overflow = originalOverflow;
1209
+ };
1210
+ }
1211
+ }, [open]);
1212
+ if (!open) return null;
1213
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1214
+ "div",
1215
+ {
1216
+ className: cn(
1217
+ "fixed inset-0 z-998 flex flex-col bg-background",
1218
+ "animate-in slide-in-from-top duration-300",
1219
+ "data-[state=closed]:animate-out data-[state=closed]:slide-out-to-top data-[state=closed]:duration-300",
1220
+ className
1221
+ ),
1222
+ "data-state": open ? "open" : "closed",
1223
+ children: [
1224
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sr-only", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { children: title }) }),
1225
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute top-4 right-4 z-10", children: /* @__PURE__ */ jsxRuntime.jsxs(
1226
+ "button",
1227
+ {
1228
+ onClick: onClose,
1229
+ className: "flex size-10 items-center justify-center rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",
1230
+ "aria-label": "Close mobile menu",
1231
+ children: [
1232
+ /* @__PURE__ */ jsxRuntime.jsx(DynamicIcon, { name: "lucide/x", className: "size-4" }),
1233
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
1234
+ ]
1235
+ }
1236
+ ) }),
1237
+ /* @__PURE__ */ jsxRuntime.jsx(
1238
+ "div",
1239
+ {
1240
+ className: cn(
1241
+ "h-full overflow-y-auto pt-20 pb-8 px-4 sm:px-6",
1242
+ contentClassName
1243
+ ),
1244
+ children
1245
+ }
1246
+ )
1247
+ ]
1248
+ }
1249
+ );
1250
+ };
1133
1251
 
1134
1252
  // components/blocks/navbars/types.ts
1135
1253
  function getLinkUrl(item) {
@@ -1372,51 +1490,6 @@ var DesktopMenuItem = ({
1372
1490
  }
1373
1491
  return null;
1374
1492
  };
1375
- var MobileSubmenu = ({
1376
- submenu,
1377
- mobileMenuClassName,
1378
- optixFlowConfig
1379
- }) => {
1380
- const items = submenu.links || [];
1381
- return /* @__PURE__ */ jsxRuntime.jsxs(
1382
- "div",
1383
- {
1384
- className: cn(
1385
- "fixed inset-0 top-[72px] flex h-[calc(100vh-72px)] w-full flex-col overflow-scroll border-t border-border bg-background lg:hidden",
1386
- mobileMenuClassName
1387
- ),
1388
- children: [
1389
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-8 py-3.5 text-xs tracking-widest text-muted-foreground uppercase", children: submenu.label }),
1390
- items.map((item, index) => {
1391
- return /* @__PURE__ */ jsxRuntime.jsxs(
1392
- Pressable,
1393
- {
1394
- href: getLinkUrl(item),
1395
- className: "flex items-start gap-4 border-b border-border px-8 py-5",
1396
- children: [
1397
- item.image && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-10 w-10 overflow-hidden rounded-md border border-border", children: /* @__PURE__ */ jsxRuntime.jsx(
1398
- img.Img,
1399
- {
1400
- src: item.image,
1401
- alt: typeof item.label === "string" ? item.label : "Menu item",
1402
- className: "h-full w-full object-cover object-center",
1403
- optixFlowConfig
1404
- }
1405
- ) }),
1406
- !item.image && (item.icon || item.iconName) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-10 w-10 items-center justify-center rounded-md border border-border bg-muted/40 text-muted-foreground", children: item.icon ? item.icon : item.iconName ? /* @__PURE__ */ jsxRuntime.jsx(DynamicIcon, { name: item.iconName, size: 16 }) : null }),
1407
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1408
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base", children: item.label }),
1409
- item.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: item.description })
1410
- ] })
1411
- ]
1412
- },
1413
- `mobile-item-${index}`
1414
- );
1415
- })
1416
- ]
1417
- }
1418
- );
1419
- };
1420
1493
  var NavbarMegaMenu = ({
1421
1494
  className,
1422
1495
  containerClassName,
@@ -1437,8 +1510,6 @@ var NavbarMegaMenu = ({
1437
1510
  optixFlowConfig
1438
1511
  }) => {
1439
1512
  const [open, setOpen] = React.useState(false);
1440
- const [submenuIndex, setSubmenuIndex] = React.useState(null);
1441
- const activeSubmenu = submenuIndex !== null ? menuLinks?.[submenuIndex] : null;
1442
1513
  const hasDropdownItems = (link) => Boolean(
1443
1514
  link.links && link.links.length > 0 || link.dropdownGroups && link.dropdownGroups.length > 0
1444
1515
  );
@@ -1492,36 +1563,15 @@ var NavbarMegaMenu = ({
1492
1563
  ),
1493
1564
  children: [
1494
1565
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: navWrapperClasses, children: [
1495
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1496
- (!open || submenuIndex === null) && /* @__PURE__ */ jsxRuntime.jsx(
1497
- NavbarLogo,
1498
- {
1499
- logo,
1500
- logoSlot,
1501
- logoClassName,
1502
- optixFlowConfig
1503
- }
1504
- ),
1505
- open && submenuIndex !== null && /* @__PURE__ */ jsxRuntime.jsxs(
1506
- Pressable,
1507
- {
1508
- variant: "outline",
1509
- asButton: true,
1510
- onClick: () => setSubmenuIndex(null),
1511
- children: [
1512
- "Back",
1513
- /* @__PURE__ */ jsxRuntime.jsx(
1514
- DynamicIcon,
1515
- {
1516
- name: "lucide/chevron-left",
1517
- size: 16,
1518
- className: "ml-2"
1519
- }
1520
- )
1521
- ]
1522
- }
1523
- )
1524
- ] }),
1566
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
1567
+ NavbarLogo,
1568
+ {
1569
+ logo,
1570
+ logoSlot,
1571
+ logoClassName,
1572
+ optixFlowConfig
1573
+ }
1574
+ ) }),
1525
1575
  /* @__PURE__ */ jsxRuntime.jsx(
1526
1576
  NavigationMenuList,
1527
1577
  {
@@ -1562,14 +1612,7 @@ var NavbarMegaMenu = ({
1562
1612
  size: "icon",
1563
1613
  asButton: true,
1564
1614
  "aria-label": "Main Menu",
1565
- onClick: () => {
1566
- if (open) {
1567
- setOpen(false);
1568
- setSubmenuIndex(null);
1569
- } else {
1570
- setOpen(true);
1571
- }
1572
- },
1615
+ onClick: () => setOpen(!open),
1573
1616
  children: [
1574
1617
  !open && /* @__PURE__ */ jsxRuntime.jsx(DynamicIcon, { name: "lucide/menu", size: 16 }),
1575
1618
  open && /* @__PURE__ */ jsxRuntime.jsx(DynamicIcon, { name: "lucide/x", size: 16 })
@@ -1577,31 +1620,42 @@ var NavbarMegaMenu = ({
1577
1620
  }
1578
1621
  ) })
1579
1622
  ] }),
1580
- open && submenuIndex === null && /* @__PURE__ */ jsxRuntime.jsxs(
1581
- "div",
1623
+ /* @__PURE__ */ jsxRuntime.jsx(
1624
+ NavbarMobileMenu,
1582
1625
  {
1583
- className: cn(
1584
- "fixed inset-0 top-[72px] flex h-[calc(100vh-72px)] w-full flex-col overflow-scroll border-t border-border bg-background lg:hidden",
1585
- mobileMenuClassName
1586
- ),
1587
- children: [
1588
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: menuLinks?.map((link, index) => {
1626
+ open,
1627
+ onClose: () => setOpen(false),
1628
+ title: "Mobile Navigation",
1629
+ contentClassName: "pt-10 pb-20",
1630
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-screen-sm mx-auto", children: [
1631
+ /* @__PURE__ */ jsxRuntime.jsx(Accordion, { type: "multiple", className: "w-full", children: menuLinks?.map((link, index) => {
1589
1632
  if (hasDropdownItems(link)) {
1633
+ const items = link.links || [];
1590
1634
  return /* @__PURE__ */ jsxRuntime.jsxs(
1591
- "button",
1635
+ AccordionItem,
1592
1636
  {
1593
- type: "button",
1594
- className: "flex w-full items-center border-b border-border px-8 py-7 text-left",
1595
- onClick: () => setSubmenuIndex(index),
1637
+ value: `menu-${index}`,
1638
+ className: "border-b-0",
1596
1639
  children: [
1597
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1", children: link.label }),
1598
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(
1599
- DynamicIcon,
1640
+ /* @__PURE__ */ jsxRuntime.jsx(AccordionTrigger, { className: "h-15 items-center text-base font-normal text-foreground hover:no-underline", children: link.label }),
1641
+ /* @__PURE__ */ jsxRuntime.jsx(AccordionContent, { className: "overflow-x-none", children: items.map((item, itemIndex) => /* @__PURE__ */ jsxRuntime.jsxs(
1642
+ Pressable,
1600
1643
  {
1601
- name: "lucide/chevron-right",
1602
- size: 16
1603
- }
1604
- ) })
1644
+ href: getLinkUrl(item),
1645
+ className: "flex items-center gap-2 pl-4 text-sm text-muted-foreground hover:text-foreground",
1646
+ children: [
1647
+ (item.icon || item.iconName) && (item.icon ? item.icon : item.iconName ? /* @__PURE__ */ jsxRuntime.jsx(
1648
+ DynamicIcon,
1649
+ {
1650
+ name: item.iconName,
1651
+ size: 14
1652
+ }
1653
+ ) : null),
1654
+ item.label
1655
+ ]
1656
+ },
1657
+ `mobile-link-${index}-${itemIndex}`
1658
+ )) })
1605
1659
  ]
1606
1660
  },
1607
1661
  `mobile-menu-link-${index}`
@@ -1614,8 +1668,8 @@ var NavbarMegaMenu = ({
1614
1668
  Pressable,
1615
1669
  {
1616
1670
  href: link.href,
1617
- className: "flex w-full items-center border-b border-border px-8 py-7 text-left",
1618
- children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1", children: link.label })
1671
+ className: "flex h-15 items-center text-base font-normal text-foreground",
1672
+ children: link.label
1619
1673
  },
1620
1674
  `mobile-menu-link-${index}`
1621
1675
  );
@@ -1623,22 +1677,11 @@ var NavbarMegaMenu = ({
1623
1677
  /* @__PURE__ */ jsxRuntime.jsx(
1624
1678
  "div",
1625
1679
  {
1626
- className: cn(
1627
- "mx-8 mt-auto flex flex-col gap-4 py-12",
1628
- actionsClassName
1629
- ),
1680
+ className: cn("mt-6 flex flex-col gap-4", actionsClassName),
1630
1681
  children: renderActions()
1631
1682
  }
1632
1683
  )
1633
- ]
1634
- }
1635
- ),
1636
- open && activeSubmenu && hasDropdownItems(activeSubmenu) && /* @__PURE__ */ jsxRuntime.jsx(
1637
- MobileSubmenu,
1638
- {
1639
- submenu: activeSubmenu,
1640
- mobileMenuClassName,
1641
- optixFlowConfig
1684
+ ] })
1642
1685
  }
1643
1686
  )
1644
1687
  ]