@logickernel/frame 0.8.0 → 0.8.2
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/README.md +39 -31
- package/dist/index.d.mts +52 -28
- package/dist/index.d.ts +52 -28
- package/dist/index.js +136 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +135 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -4
package/dist/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var React2 = require('react');
|
|
4
|
-
var Link = require('next/link');
|
|
5
|
-
var navigation = require('next/navigation');
|
|
6
|
-
var react = require('next-auth/react');
|
|
7
3
|
var LucideIcons = require('lucide-react');
|
|
8
4
|
var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
|
|
5
|
+
var React2 = require('react');
|
|
9
6
|
var reactSlot = require('@radix-ui/react-slot');
|
|
10
7
|
var classVarianceAuthority = require('class-variance-authority');
|
|
11
8
|
var clsx = require('clsx');
|
|
@@ -14,6 +11,9 @@ var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
|
14
11
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
12
|
var AvatarPrimitive = require('@radix-ui/react-avatar');
|
|
16
13
|
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
14
|
+
var Link = require('next/link');
|
|
15
|
+
var navigation = require('next/navigation');
|
|
16
|
+
var react = require('next-auth/react');
|
|
17
17
|
|
|
18
18
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
|
|
@@ -35,15 +35,15 @@ function _interopNamespace(e) {
|
|
|
35
35
|
return Object.freeze(n);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
39
|
-
var Link__default = /*#__PURE__*/_interopDefault(Link);
|
|
40
38
|
var LucideIcons__namespace = /*#__PURE__*/_interopNamespace(LucideIcons);
|
|
41
39
|
var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(CollapsiblePrimitive);
|
|
40
|
+
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
42
41
|
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
|
|
43
42
|
var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
|
|
44
43
|
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
|
|
44
|
+
var Link__default = /*#__PURE__*/_interopDefault(Link);
|
|
45
45
|
|
|
46
|
-
// src/components/
|
|
46
|
+
// src/components/NavMain.tsx
|
|
47
47
|
var Collapsible = CollapsiblePrimitive__namespace.Root;
|
|
48
48
|
var CollapsibleTrigger2 = CollapsiblePrimitive__namespace.CollapsibleTrigger;
|
|
49
49
|
var CollapsibleContent2 = CollapsiblePrimitive__namespace.CollapsibleContent;
|
|
@@ -82,7 +82,10 @@ function useSidebar() {
|
|
|
82
82
|
return context;
|
|
83
83
|
}
|
|
84
84
|
function useIsMobile() {
|
|
85
|
-
const [isMobile, setIsMobile] = React2__namespace.useState(
|
|
85
|
+
const [isMobile, setIsMobile] = React2__namespace.useState(() => {
|
|
86
|
+
if (typeof window === "undefined") return false;
|
|
87
|
+
return window.matchMedia("(max-width: 768px)").matches;
|
|
88
|
+
});
|
|
86
89
|
React2__namespace.useEffect(() => {
|
|
87
90
|
const mql = window.matchMedia("(max-width: 768px)");
|
|
88
91
|
const onChange = () => setIsMobile(mql.matches);
|
|
@@ -104,7 +107,19 @@ var SidebarProvider = React2__namespace.forwardRef(
|
|
|
104
107
|
}, ref) => {
|
|
105
108
|
const isMobile = useIsMobile();
|
|
106
109
|
const [openMobile, setOpenMobile] = React2__namespace.useState(false);
|
|
107
|
-
const
|
|
110
|
+
const getInitialState = React2__namespace.useCallback(() => {
|
|
111
|
+
if (typeof document === "undefined") return defaultOpen;
|
|
112
|
+
const cookies = document.cookie.split(";");
|
|
113
|
+
const sidebarCookie = cookies.find(
|
|
114
|
+
(cookie) => cookie.trim().startsWith(`${SIDEBAR_COOKIE_NAME}=`)
|
|
115
|
+
);
|
|
116
|
+
if (sidebarCookie) {
|
|
117
|
+
const value = sidebarCookie.split("=")[1];
|
|
118
|
+
return value === "true";
|
|
119
|
+
}
|
|
120
|
+
return defaultOpen;
|
|
121
|
+
}, [defaultOpen]);
|
|
122
|
+
const [_open, _setOpen] = React2__namespace.useState(getInitialState);
|
|
108
123
|
const open = openProp ?? _open;
|
|
109
124
|
const setOpen = React2__namespace.useCallback(
|
|
110
125
|
(value) => {
|
|
@@ -119,7 +134,11 @@ var SidebarProvider = React2__namespace.forwardRef(
|
|
|
119
134
|
[setOpenProp, open]
|
|
120
135
|
);
|
|
121
136
|
const toggleSidebar = React2__namespace.useCallback(() => {
|
|
122
|
-
|
|
137
|
+
if (isMobile) {
|
|
138
|
+
setOpenMobile((open2) => !open2);
|
|
139
|
+
} else {
|
|
140
|
+
setOpen((open2) => !open2);
|
|
141
|
+
}
|
|
123
142
|
}, [isMobile, setOpen, setOpenMobile]);
|
|
124
143
|
React2__namespace.useEffect(() => {
|
|
125
144
|
const handleKeyDown = (event) => {
|
|
@@ -131,6 +150,15 @@ var SidebarProvider = React2__namespace.forwardRef(
|
|
|
131
150
|
window.addEventListener("keydown", handleKeyDown);
|
|
132
151
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
133
152
|
}, [toggleSidebar]);
|
|
153
|
+
React2__namespace.useEffect(() => {
|
|
154
|
+
if (isMobile && openMobile) {
|
|
155
|
+
const originalStyle = window.getComputedStyle(document.body).overflow;
|
|
156
|
+
document.body.style.overflow = "hidden";
|
|
157
|
+
return () => {
|
|
158
|
+
document.body.style.overflow = originalStyle;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}, [isMobile, openMobile]);
|
|
134
162
|
const state = open ? "expanded" : "collapsed";
|
|
135
163
|
const contextValue = React2__namespace.useMemo(
|
|
136
164
|
() => ({
|
|
@@ -154,7 +182,7 @@ var SidebarProvider = React2__namespace.forwardRef(
|
|
|
154
182
|
...style
|
|
155
183
|
},
|
|
156
184
|
className: cn(
|
|
157
|
-
"group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",
|
|
185
|
+
"group/sidebar-wrapper flex min-h-svh w-full bg-background has-[[data-variant=inset]]:bg-sidebar",
|
|
158
186
|
className
|
|
159
187
|
),
|
|
160
188
|
ref,
|
|
@@ -190,35 +218,44 @@ var Sidebar = React2__namespace.forwardRef(
|
|
|
190
218
|
);
|
|
191
219
|
}
|
|
192
220
|
if (isMobile) {
|
|
193
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
"fixed inset-y-0 z-50 flex h-svh w-[--sidebar-width] flex-col bg-sidebar p-2 text-sidebar-foreground",
|
|
208
|
-
side === "left" ? "left-0 border-r" : "right-0 border-l",
|
|
209
|
-
className
|
|
210
|
-
),
|
|
211
|
-
style: {
|
|
212
|
-
"--sidebar-width": SIDEBAR_WIDTH_MOBILE
|
|
213
|
-
},
|
|
214
|
-
onClick: (e) => e.stopPropagation(),
|
|
215
|
-
ref,
|
|
216
|
-
...props,
|
|
217
|
-
children
|
|
221
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
222
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
onClick: () => setOpenMobile(false),
|
|
226
|
+
"aria-hidden": "true",
|
|
227
|
+
style: {
|
|
228
|
+
position: "fixed",
|
|
229
|
+
inset: 0,
|
|
230
|
+
zIndex: 40,
|
|
231
|
+
backgroundColor: "rgba(0, 0, 0, 0.8)",
|
|
232
|
+
opacity: openMobile ? 1 : 0,
|
|
233
|
+
transition: "opacity 200ms",
|
|
234
|
+
pointerEvents: openMobile ? "auto" : "none"
|
|
218
235
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
236
|
+
}
|
|
237
|
+
),
|
|
238
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
239
|
+
"div",
|
|
240
|
+
{
|
|
241
|
+
"data-sidebar": "sidebar",
|
|
242
|
+
"data-mobile": "true",
|
|
243
|
+
className: cn(
|
|
244
|
+
"fixed inset-y-0 z-50 flex h-svh w-[--sidebar-width] flex-col bg-sidebar p-2 text-sidebar-foreground transition-transform duration-200 ease-in-out",
|
|
245
|
+
side === "left" ? "left-0 border-r" : "right-0 border-l",
|
|
246
|
+
openMobile ? "translate-x-0" : side === "left" ? "-translate-x-full" : "translate-x-full",
|
|
247
|
+
className
|
|
248
|
+
),
|
|
249
|
+
style: {
|
|
250
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE
|
|
251
|
+
},
|
|
252
|
+
onClick: (e) => e.stopPropagation(),
|
|
253
|
+
ref,
|
|
254
|
+
...props,
|
|
255
|
+
children
|
|
256
|
+
}
|
|
257
|
+
)
|
|
258
|
+
] });
|
|
222
259
|
}
|
|
223
260
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
224
261
|
"div",
|
|
@@ -315,23 +352,24 @@ var SidebarRail = React2__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
315
352
|
});
|
|
316
353
|
SidebarRail.displayName = "SidebarRail";
|
|
317
354
|
var SidebarInset = React2__namespace.forwardRef(({ className, style, ...props }, ref) => {
|
|
318
|
-
const { state, isMobile } = useSidebar();
|
|
319
355
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
320
|
-
"
|
|
356
|
+
"div",
|
|
321
357
|
{
|
|
322
358
|
ref,
|
|
323
359
|
className: cn(
|
|
324
360
|
"relative flex min-h-svh flex-1 flex-col bg-background",
|
|
325
|
-
// Auto-adjust margin based on sidebar state
|
|
326
|
-
// Transition duration uses CSS variable for consistency
|
|
327
361
|
"transition-[margin-left] duration-200 ease-linear",
|
|
362
|
+
// Use peer selectors to respond to sidebar state
|
|
328
363
|
// On mobile, no margin needed (sidebar is overlay)
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
364
|
+
// For default "sidebar" variant, the spacer div already creates space, so no margin needed
|
|
365
|
+
// Only add margin for floating/inset variants that don't have a spacer
|
|
366
|
+
"md:peer-data-[variant=floating]:ml-[--sidebar-width]",
|
|
367
|
+
"md:peer-data-[variant=floating]:peer-data-[collapsible=offcanvas]:ml-0",
|
|
368
|
+
"md:peer-data-[variant=floating]:peer-data-[collapsible=icon]:ml-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]",
|
|
369
|
+
"md:peer-data-[variant=inset]:ml-[--sidebar-width]",
|
|
370
|
+
"md:peer-data-[variant=inset]:peer-data-[collapsible=offcanvas]:ml-0",
|
|
371
|
+
"md:peer-data-[variant=inset]:peer-data-[collapsible=icon]:ml-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]",
|
|
372
|
+
// Inset variant specific styles
|
|
335
373
|
"peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
|
|
336
374
|
className
|
|
337
375
|
),
|
|
@@ -689,7 +727,7 @@ function getIconComponent(icon) {
|
|
|
689
727
|
}
|
|
690
728
|
function NavMain({ items, adapter }) {
|
|
691
729
|
const pathname = adapter.usePathname();
|
|
692
|
-
const
|
|
730
|
+
const Link2 = adapter.Link;
|
|
693
731
|
const groups = [];
|
|
694
732
|
let currentGroup = {
|
|
695
733
|
items: []
|
|
@@ -745,7 +783,7 @@ function NavMain({ items, adapter }) {
|
|
|
745
783
|
]
|
|
746
784
|
}
|
|
747
785
|
) }),
|
|
748
|
-
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSub, { children: item.items?.map((subItem) => /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
786
|
+
/* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSub, { children: item.items?.map((subItem) => /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link2, { href: subItem.url, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title }) }) }) }, subItem.title)) }) })
|
|
749
787
|
] })
|
|
750
788
|
},
|
|
751
789
|
item.title
|
|
@@ -757,7 +795,7 @@ function NavMain({ items, adapter }) {
|
|
|
757
795
|
asChild: true,
|
|
758
796
|
tooltip: item.title,
|
|
759
797
|
isActive,
|
|
760
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
798
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(Link2, { href: item.url, children: [
|
|
761
799
|
item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
|
|
762
800
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
|
|
763
801
|
] })
|
|
@@ -1193,28 +1231,24 @@ function useNavigation({
|
|
|
1193
1231
|
}, [organizationId, apiBaseUrl, enabled]);
|
|
1194
1232
|
return { items, organizations, loading, error };
|
|
1195
1233
|
}
|
|
1196
|
-
var NextJSLink = ({ href, children, className }) => /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href, className, children });
|
|
1197
1234
|
function AppSidebar({
|
|
1198
1235
|
user,
|
|
1199
|
-
adapter
|
|
1236
|
+
adapter,
|
|
1200
1237
|
data,
|
|
1201
1238
|
organizationId,
|
|
1202
1239
|
apiBaseUrl,
|
|
1203
1240
|
...props
|
|
1204
1241
|
}) {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
signOut: react.signOut
|
|
1216
|
-
}), [pathname, router]);
|
|
1217
|
-
const adapter = externalAdapter ?? internalAdapter;
|
|
1242
|
+
if (!adapter) {
|
|
1243
|
+
throw new Error(
|
|
1244
|
+
"AppSidebar: adapter is required. Please provide a framework adapter. For Next.js, use: const adapter = useNextJSAdapter()"
|
|
1245
|
+
);
|
|
1246
|
+
}
|
|
1247
|
+
if (typeof adapter.usePathname !== "function") {
|
|
1248
|
+
throw new Error(
|
|
1249
|
+
"AppSidebar: Invalid adapter provided. The adapter must have a usePathname function. Make sure you're using the correct adapter for your framework."
|
|
1250
|
+
);
|
|
1251
|
+
}
|
|
1218
1252
|
const currentPathname = adapter.usePathname();
|
|
1219
1253
|
const isPropsMode = data !== void 0;
|
|
1220
1254
|
const pathSegments = currentPathname.split("/");
|
|
@@ -1279,24 +1313,46 @@ function AppLayout({
|
|
|
1279
1313
|
),
|
|
1280
1314
|
/* @__PURE__ */ jsxRuntime.jsxs(SidebarInset, { children: [
|
|
1281
1315
|
/* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, {}),
|
|
1282
|
-
|
|
1316
|
+
children
|
|
1283
1317
|
] })
|
|
1284
1318
|
] });
|
|
1285
1319
|
}
|
|
1286
|
-
function
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1320
|
+
function useNextJSAdapter() {
|
|
1321
|
+
const pathname = navigation.usePathname();
|
|
1322
|
+
const nextRouter = navigation.useRouter();
|
|
1323
|
+
const router = React2__namespace.useMemo(
|
|
1324
|
+
() => {
|
|
1325
|
+
if (!nextRouter) {
|
|
1326
|
+
throw new Error(
|
|
1327
|
+
"Next.js router is not available. Make sure you're using useNextJSAdapter in a Client Component ('use client') and that Next.js router is properly initialized."
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1292
1330
|
return {
|
|
1293
|
-
push: (path) =>
|
|
1294
|
-
refresh: () =>
|
|
1331
|
+
push: (path) => nextRouter.push(path),
|
|
1332
|
+
refresh: () => nextRouter.refresh()
|
|
1295
1333
|
};
|
|
1296
1334
|
},
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1335
|
+
[nextRouter]
|
|
1336
|
+
);
|
|
1337
|
+
const NextJSLink = React2__namespace.useMemo(
|
|
1338
|
+
() => ({ href, children, className }) => /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href, className, children }),
|
|
1339
|
+
[]
|
|
1340
|
+
);
|
|
1341
|
+
const adapter = React2__namespace.useMemo(
|
|
1342
|
+
() => ({
|
|
1343
|
+
usePathname: () => {
|
|
1344
|
+
if (pathname === void 0 || pathname === null) {
|
|
1345
|
+
return "";
|
|
1346
|
+
}
|
|
1347
|
+
return pathname;
|
|
1348
|
+
},
|
|
1349
|
+
useRouter: () => router,
|
|
1350
|
+
Link: NextJSLink,
|
|
1351
|
+
signOut: react.signOut
|
|
1352
|
+
}),
|
|
1353
|
+
[pathname, router, NextJSLink]
|
|
1354
|
+
);
|
|
1355
|
+
return adapter;
|
|
1300
1356
|
}
|
|
1301
1357
|
|
|
1302
1358
|
exports.AppLayout = AppLayout;
|
|
@@ -1307,9 +1363,9 @@ exports.SidebarInset = SidebarInset;
|
|
|
1307
1363
|
exports.SidebarProvider = SidebarProvider;
|
|
1308
1364
|
exports.SidebarTrigger = SidebarTrigger;
|
|
1309
1365
|
exports.TeamSwitcher = TeamSwitcher;
|
|
1310
|
-
exports.createNextJSAdapter = createNextJSAdapter;
|
|
1311
1366
|
exports.getIconComponent = getIconComponent;
|
|
1312
1367
|
exports.useNavigation = useNavigation;
|
|
1368
|
+
exports.useNextJSAdapter = useNextJSAdapter;
|
|
1313
1369
|
exports.useSidebar = useSidebar;
|
|
1314
1370
|
//# sourceMappingURL=index.js.map
|
|
1315
1371
|
//# sourceMappingURL=index.js.map
|