@logickernel/bridge 0.9.8 → 0.9.9
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.
|
@@ -86,7 +86,7 @@ interface TeamSwitcherProps {
|
|
|
86
86
|
teams: NavigationOrganization[];
|
|
87
87
|
organizationId?: string;
|
|
88
88
|
}
|
|
89
|
-
declare function TeamSwitcher({ teams, organizationId, }: TeamSwitcherProps): react_jsx_runtime.JSX.Element
|
|
89
|
+
declare function TeamSwitcher({ teams, organizationId, }: TeamSwitcherProps): react_jsx_runtime.JSX.Element;
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Icon mapper utility
|
|
@@ -86,7 +86,7 @@ interface TeamSwitcherProps {
|
|
|
86
86
|
teams: NavigationOrganization[];
|
|
87
87
|
organizationId?: string;
|
|
88
88
|
}
|
|
89
|
-
declare function TeamSwitcher({ teams, organizationId, }: TeamSwitcherProps): react_jsx_runtime.JSX.Element
|
|
89
|
+
declare function TeamSwitcher({ teams, organizationId, }: TeamSwitcherProps): react_jsx_runtime.JSX.Element;
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Icon mapper utility
|
package/dist/next/components.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useState, useEffect } from 'react';
|
|
|
3
3
|
import { Slot } from '@radix-ui/react-slot';
|
|
4
4
|
import { cva } from 'class-variance-authority';
|
|
5
5
|
import * as LucideIcons from 'lucide-react';
|
|
6
|
-
import { ChevronRight, ChevronsUpDown, BadgeCheck, LogOut, GalleryVerticalEnd, Check,
|
|
6
|
+
import { ChevronRight, ChevronsUpDown, BadgeCheck, LogOut, GalleryVerticalEnd, Check, XIcon, MenuIcon } from 'lucide-react';
|
|
7
7
|
import { clsx } from 'clsx';
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
9
9
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
@@ -416,14 +416,14 @@ function SidebarTrigger({
|
|
|
416
416
|
"data-slot": "sidebar-trigger",
|
|
417
417
|
variant: "ghost",
|
|
418
418
|
size: "icon",
|
|
419
|
-
className: cn("size-7"
|
|
419
|
+
className: cn(className, "size-7"),
|
|
420
420
|
onClick: (event) => {
|
|
421
421
|
onClick?.(event);
|
|
422
422
|
toggleSidebar();
|
|
423
423
|
},
|
|
424
424
|
...props,
|
|
425
425
|
children: [
|
|
426
|
-
/* @__PURE__ */ jsx(
|
|
426
|
+
/* @__PURE__ */ jsx(MenuIcon, {}),
|
|
427
427
|
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
|
|
428
428
|
]
|
|
429
429
|
}
|
|
@@ -455,12 +455,11 @@ function SidebarRail({ className, ...props }) {
|
|
|
455
455
|
}
|
|
456
456
|
function SidebarInset({ className, ...props }) {
|
|
457
457
|
return /* @__PURE__ */ jsx(
|
|
458
|
-
"
|
|
458
|
+
"div",
|
|
459
459
|
{
|
|
460
460
|
"data-slot": "sidebar-inset",
|
|
461
461
|
className: cn(
|
|
462
462
|
"bg-background relative flex w-full flex-1 flex-col",
|
|
463
|
-
"px-4",
|
|
464
463
|
"md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
|
465
464
|
className
|
|
466
465
|
),
|
|
@@ -728,6 +727,7 @@ function getIconComponent(icon) {
|
|
|
728
727
|
}
|
|
729
728
|
function NavMain({ items }) {
|
|
730
729
|
const pathname = usePathname();
|
|
730
|
+
const { isMobile, setOpenMobile } = useSidebar();
|
|
731
731
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
732
732
|
console.log("[NavMain] Received items:", {
|
|
733
733
|
itemsCount: items.length,
|
|
@@ -827,7 +827,18 @@ function NavMain({ items }) {
|
|
|
827
827
|
]
|
|
828
828
|
}
|
|
829
829
|
) }),
|
|
830
|
-
/* @__PURE__ */ jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsx(SidebarMenuSub, { children: item.items?.map((subItem) => /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
830
|
+
/* @__PURE__ */ jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsx(SidebarMenuSub, { children: item.items?.map((subItem) => /* @__PURE__ */ jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
831
|
+
Link,
|
|
832
|
+
{
|
|
833
|
+
href: subItem.url,
|
|
834
|
+
onClick: () => {
|
|
835
|
+
if (isMobile) {
|
|
836
|
+
setOpenMobile(false);
|
|
837
|
+
}
|
|
838
|
+
},
|
|
839
|
+
children: /* @__PURE__ */ jsx("span", { children: subItem.title })
|
|
840
|
+
}
|
|
841
|
+
) }) }, subItem.title)) }) })
|
|
831
842
|
] })
|
|
832
843
|
},
|
|
833
844
|
item.title
|
|
@@ -839,10 +850,21 @@ function NavMain({ items }) {
|
|
|
839
850
|
asChild: true,
|
|
840
851
|
tooltip: item.title,
|
|
841
852
|
isActive,
|
|
842
|
-
children: /* @__PURE__ */ jsxs(
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
853
|
+
children: /* @__PURE__ */ jsxs(
|
|
854
|
+
Link,
|
|
855
|
+
{
|
|
856
|
+
href: item.url,
|
|
857
|
+
onClick: () => {
|
|
858
|
+
if (isMobile) {
|
|
859
|
+
setOpenMobile(false);
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
children: [
|
|
863
|
+
item.icon && /* @__PURE__ */ jsx(item.icon, {}),
|
|
864
|
+
/* @__PURE__ */ jsx("span", { children: item.title })
|
|
865
|
+
]
|
|
866
|
+
}
|
|
867
|
+
)
|
|
846
868
|
}
|
|
847
869
|
) }, item.title);
|
|
848
870
|
}) })
|
|
@@ -1080,11 +1102,19 @@ function TeamSwitcher({
|
|
|
1080
1102
|
const isAppOrgRoute = pathname.startsWith("/app/") && pathSegments.length > 2 && pathSegments[2] !== "user";
|
|
1081
1103
|
const pathOrgId = isAppOrgRoute ? pathSegments[2] : null;
|
|
1082
1104
|
const currentOrgId = organizationId || (pathOrgId && teams.some((team) => team.id === pathOrgId) ? pathOrgId : null);
|
|
1083
|
-
const activeTeam = currentOrgId ? teams.find((team) => team.id === currentOrgId) : null;
|
|
1084
1105
|
const handleTeamChange = (teamId) => {
|
|
1106
|
+
if (isMobile && sidebar?.setOpenMobile) {
|
|
1107
|
+
sidebar.setOpenMobile(false);
|
|
1108
|
+
}
|
|
1085
1109
|
router.push(`/app/${teamId}/home`);
|
|
1086
1110
|
router.refresh();
|
|
1087
1111
|
};
|
|
1112
|
+
const handleManageOrganizations = () => {
|
|
1113
|
+
if (isMobile && sidebar?.setOpenMobile) {
|
|
1114
|
+
sidebar.setOpenMobile(false);
|
|
1115
|
+
}
|
|
1116
|
+
router.push("/app/user/organizations");
|
|
1117
|
+
};
|
|
1088
1118
|
const teamsWithLogo = teams.map((org) => {
|
|
1089
1119
|
const logoIcon = org.logo ? getIconComponent(org.logo) : GalleryVerticalEnd;
|
|
1090
1120
|
return {
|
|
@@ -1094,6 +1124,7 @@ function TeamSwitcher({
|
|
|
1094
1124
|
plan: org.plan || "Member"
|
|
1095
1125
|
};
|
|
1096
1126
|
});
|
|
1127
|
+
const activeTeamWithLogo = currentOrgId ? teamsWithLogo.find((team) => team.id === currentOrgId) : null;
|
|
1097
1128
|
if (teamsWithLogo.length === 0) {
|
|
1098
1129
|
return /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(SidebarMenuButton, { size: "lg", className: "cursor-default", children: [
|
|
1099
1130
|
/* @__PURE__ */ jsx("div", { className: "bg-muted flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsx(GalleryVerticalEnd, { className: "size-4 text-muted-foreground" }) }),
|
|
@@ -1103,70 +1134,6 @@ function TeamSwitcher({
|
|
|
1103
1134
|
] })
|
|
1104
1135
|
] }) }) });
|
|
1105
1136
|
}
|
|
1106
|
-
if (!activeTeam) {
|
|
1107
|
-
return /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
1108
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
1109
|
-
SidebarMenuButton,
|
|
1110
|
-
{
|
|
1111
|
-
size: "lg",
|
|
1112
|
-
className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
|
|
1113
|
-
children: [
|
|
1114
|
-
/* @__PURE__ */ jsx("div", { className: "bg-muted flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsx(GalleryVerticalEnd, { className: "size-4 text-muted-foreground" }) }),
|
|
1115
|
-
/* @__PURE__ */ jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
|
|
1116
|
-
/* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: "Organizations" }),
|
|
1117
|
-
/* @__PURE__ */ jsxs("span", { className: "truncate text-xs text-muted-foreground", children: [
|
|
1118
|
-
teamsWithLogo.length,
|
|
1119
|
-
" available"
|
|
1120
|
-
] })
|
|
1121
|
-
] }),
|
|
1122
|
-
/* @__PURE__ */ jsx(ChevronsUpDown, { className: "ml-auto" })
|
|
1123
|
-
]
|
|
1124
|
-
}
|
|
1125
|
-
) }),
|
|
1126
|
-
/* @__PURE__ */ jsxs(
|
|
1127
|
-
DropdownMenuContent,
|
|
1128
|
-
{
|
|
1129
|
-
className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
|
|
1130
|
-
align: "start",
|
|
1131
|
-
side: isMobile ? "bottom" : "right",
|
|
1132
|
-
sideOffset: 4,
|
|
1133
|
-
children: [
|
|
1134
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: "Select an organization" }),
|
|
1135
|
-
teamsWithLogo.map((team) => /* @__PURE__ */ jsxs(
|
|
1136
|
-
DropdownMenuItem,
|
|
1137
|
-
{
|
|
1138
|
-
onClick: () => handleTeamChange(team.id),
|
|
1139
|
-
className: "gap-2 p-2",
|
|
1140
|
-
children: [
|
|
1141
|
-
/* @__PURE__ */ jsx("div", { className: "flex size-6 items-center justify-center rounded-md border", children: /* @__PURE__ */ jsx(team.logo, { className: "size-3.5 shrink-0" }) }),
|
|
1142
|
-
team.name
|
|
1143
|
-
]
|
|
1144
|
-
},
|
|
1145
|
-
team.id
|
|
1146
|
-
)),
|
|
1147
|
-
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
1148
|
-
/* @__PURE__ */ jsxs(
|
|
1149
|
-
DropdownMenuItem,
|
|
1150
|
-
{
|
|
1151
|
-
className: "gap-2 p-2",
|
|
1152
|
-
onClick: () => router.push("/app/user/organizations"),
|
|
1153
|
-
children: [
|
|
1154
|
-
/* @__PURE__ */ jsx("div", { className: "flex size-6 items-center justify-center rounded-md border bg-transparent", children: /* @__PURE__ */ jsx(GalleryVerticalEnd, { className: "size-4" }) }),
|
|
1155
|
-
/* @__PURE__ */ jsx("div", { className: "text-muted-foreground font-medium", children: "Manage organizations" })
|
|
1156
|
-
]
|
|
1157
|
-
}
|
|
1158
|
-
)
|
|
1159
|
-
]
|
|
1160
|
-
}
|
|
1161
|
-
)
|
|
1162
|
-
] }) }) });
|
|
1163
|
-
}
|
|
1164
|
-
const activeTeamWithLogo = teamsWithLogo.find(
|
|
1165
|
-
(team) => team.id === currentOrgId
|
|
1166
|
-
);
|
|
1167
|
-
if (!activeTeamWithLogo) {
|
|
1168
|
-
return null;
|
|
1169
|
-
}
|
|
1170
1137
|
return /* @__PURE__ */ jsx(SidebarMenu, { children: /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
1171
1138
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
1172
1139
|
SidebarMenuButton,
|
|
@@ -1174,10 +1141,18 @@ function TeamSwitcher({
|
|
|
1174
1141
|
size: "lg",
|
|
1175
1142
|
className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
|
|
1176
1143
|
children: [
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
/* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: activeTeamWithLogo.name })
|
|
1180
|
-
|
|
1144
|
+
activeTeamWithLogo ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1145
|
+
/* @__PURE__ */ jsx("div", { className: "bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsx(activeTeamWithLogo.logo, { className: "size-4" }) }),
|
|
1146
|
+
/* @__PURE__ */ jsx("div", { className: "grid flex-1 text-left text-sm leading-tight", children: /* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: activeTeamWithLogo.name }) })
|
|
1147
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1148
|
+
/* @__PURE__ */ jsx("div", { className: "bg-muted flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsx(GalleryVerticalEnd, { className: "size-4 text-muted-foreground" }) }),
|
|
1149
|
+
/* @__PURE__ */ jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
|
|
1150
|
+
/* @__PURE__ */ jsx("span", { className: "truncate font-medium", children: "Organizations" }),
|
|
1151
|
+
/* @__PURE__ */ jsxs("span", { className: "truncate text-xs text-muted-foreground", children: [
|
|
1152
|
+
teamsWithLogo.length,
|
|
1153
|
+
" available"
|
|
1154
|
+
] })
|
|
1155
|
+
] })
|
|
1181
1156
|
] }),
|
|
1182
1157
|
/* @__PURE__ */ jsx(ChevronsUpDown, { className: "ml-auto" })
|
|
1183
1158
|
]
|
|
@@ -1191,7 +1166,7 @@ function TeamSwitcher({
|
|
|
1191
1166
|
side: isMobile ? "bottom" : "right",
|
|
1192
1167
|
sideOffset: 4,
|
|
1193
1168
|
children: [
|
|
1194
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: "Organizations" }),
|
|
1169
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: activeTeamWithLogo ? "Organizations" : "Select an organization" }),
|
|
1195
1170
|
teamsWithLogo.map((team) => /* @__PURE__ */ jsxs(
|
|
1196
1171
|
DropdownMenuItem,
|
|
1197
1172
|
{
|
|
@@ -1210,7 +1185,7 @@ function TeamSwitcher({
|
|
|
1210
1185
|
DropdownMenuItem,
|
|
1211
1186
|
{
|
|
1212
1187
|
className: "gap-2 p-2",
|
|
1213
|
-
onClick:
|
|
1188
|
+
onClick: handleManageOrganizations,
|
|
1214
1189
|
children: [
|
|
1215
1190
|
/* @__PURE__ */ jsx("div", { className: "flex size-6 items-center justify-center rounded-md border bg-transparent", children: /* @__PURE__ */ jsx(GalleryVerticalEnd, { className: "size-4" }) }),
|
|
1216
1191
|
/* @__PURE__ */ jsx("div", { className: "text-muted-foreground font-medium", children: "Manage organizations" })
|
|
@@ -1238,16 +1213,12 @@ function useNavigation({
|
|
|
1238
1213
|
enabled,
|
|
1239
1214
|
organizationId,
|
|
1240
1215
|
apiBaseUrl,
|
|
1241
|
-
willFetch: enabled
|
|
1216
|
+
willFetch: enabled
|
|
1242
1217
|
});
|
|
1243
1218
|
}
|
|
1244
|
-
if (!enabled
|
|
1219
|
+
if (!enabled) {
|
|
1245
1220
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1246
|
-
console.log("[useNavigation] Skipping fetch:"
|
|
1247
|
-
reason: !enabled ? "disabled" : "no organizationId",
|
|
1248
|
-
enabled,
|
|
1249
|
-
organizationId
|
|
1250
|
-
});
|
|
1221
|
+
console.log("[useNavigation] Skipping fetch: disabled");
|
|
1251
1222
|
}
|
|
1252
1223
|
setItems([]);
|
|
1253
1224
|
setOrganizations([]);
|
|
@@ -1255,7 +1226,7 @@ function useNavigation({
|
|
|
1255
1226
|
return;
|
|
1256
1227
|
}
|
|
1257
1228
|
const fetchNavigation = async () => {
|
|
1258
|
-
const url = `${apiBaseUrl}/navigation/${organizationId}`;
|
|
1229
|
+
const url = organizationId ? `${apiBaseUrl}/navigation/${organizationId}` : `${apiBaseUrl}/navigation`;
|
|
1259
1230
|
if (typeof window !== "undefined" && process.env.NODE_ENV === "development") {
|
|
1260
1231
|
console.log("[useNavigation] Fetching navigation:", url);
|
|
1261
1232
|
}
|
|
@@ -1283,7 +1254,8 @@ function useNavigation({
|
|
|
1283
1254
|
console.log("[useNavigation] Navigation data received:", {
|
|
1284
1255
|
itemsCount: data.items?.length || 0,
|
|
1285
1256
|
organizationsCount: data.organizations?.length || 0,
|
|
1286
|
-
hasUser: !!data.user
|
|
1257
|
+
hasUser: !!data.user,
|
|
1258
|
+
organizationId: data.organizationId
|
|
1287
1259
|
});
|
|
1288
1260
|
}
|
|
1289
1261
|
setItems(data.items || []);
|
|
@@ -1435,6 +1407,22 @@ function AppSidebar({
|
|
|
1435
1407
|
/* @__PURE__ */ jsx(SidebarRail, {})
|
|
1436
1408
|
] });
|
|
1437
1409
|
}
|
|
1410
|
+
function AppHeader() {
|
|
1411
|
+
const { isMobile } = useSidebar();
|
|
1412
|
+
if (!isMobile) {
|
|
1413
|
+
return null;
|
|
1414
|
+
}
|
|
1415
|
+
return /* @__PURE__ */ jsxs("header", { className: "p-2 relative flex items-center justify-center", children: [
|
|
1416
|
+
/* @__PURE__ */ jsx(SidebarTrigger, { className: "absolute left-2" }),
|
|
1417
|
+
/* @__PURE__ */ jsx("span", { className: "font-sans text-xl", children: "Random Truffle" })
|
|
1418
|
+
] });
|
|
1419
|
+
}
|
|
1420
|
+
function SidebarContent2({ children }) {
|
|
1421
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1422
|
+
/* @__PURE__ */ jsx(AppHeader, {}),
|
|
1423
|
+
/* @__PURE__ */ jsx("main", { className: "px-4 py-2 md:py-4", children })
|
|
1424
|
+
] });
|
|
1425
|
+
}
|
|
1438
1426
|
function AppLayout({
|
|
1439
1427
|
user,
|
|
1440
1428
|
organizationId,
|
|
@@ -1450,10 +1438,7 @@ function AppLayout({
|
|
|
1450
1438
|
apiBaseUrl
|
|
1451
1439
|
}
|
|
1452
1440
|
),
|
|
1453
|
-
/* @__PURE__ */
|
|
1454
|
-
/* @__PURE__ */ jsx(SidebarTrigger, {}),
|
|
1455
|
-
children
|
|
1456
|
-
] })
|
|
1441
|
+
/* @__PURE__ */ jsx(SidebarInset, { children: /* @__PURE__ */ jsx(SidebarContent2, { children }) })
|
|
1457
1442
|
] });
|
|
1458
1443
|
}
|
|
1459
1444
|
|