@logickernel/frame 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.d.mts +57 -1
- package/dist/index.d.ts +57 -1
- package/dist/index.js +53 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -83,6 +83,43 @@ interface FrameworkAdapter {
|
|
|
83
83
|
redirect?: boolean;
|
|
84
84
|
}) => Promise<void>;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Props for AppSidebar component
|
|
88
|
+
*/
|
|
89
|
+
interface AppSidebarProps$1 {
|
|
90
|
+
user: User;
|
|
91
|
+
/** Optional adapter - if not provided, Next.js defaults will be used */
|
|
92
|
+
adapter?: FrameworkAdapter;
|
|
93
|
+
/** Sidebar data containing organizations and navigation items (props mode) */
|
|
94
|
+
data?: SidebarData;
|
|
95
|
+
/** Current organization ID (optional, can be extracted from pathname) */
|
|
96
|
+
organizationId?: string;
|
|
97
|
+
/** Custom API base URL (API mode only, defaults to "/api") */
|
|
98
|
+
apiBaseUrl?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Props for AppLayout component
|
|
102
|
+
*/
|
|
103
|
+
interface AppLayoutProps {
|
|
104
|
+
/** User data for sidebar */
|
|
105
|
+
user: User;
|
|
106
|
+
/** Optional adapter - if not provided, Next.js defaults will be used */
|
|
107
|
+
adapter?: FrameworkAdapter;
|
|
108
|
+
/** Sidebar data containing organizations and navigation items (props mode) */
|
|
109
|
+
data?: SidebarData;
|
|
110
|
+
/** Current organization ID (optional, can be extracted from pathname) */
|
|
111
|
+
organizationId?: string;
|
|
112
|
+
/** Custom API base URL (API mode only, defaults to "/api" which constructs "/api/navigation/{organizationId}") */
|
|
113
|
+
apiBaseUrl?: string;
|
|
114
|
+
/** Enable API mode - library will fetch navigation from API */
|
|
115
|
+
useApiNavigation?: boolean;
|
|
116
|
+
/** Custom header content (breadcrumbs, actions, etc.) */
|
|
117
|
+
headerContent?: ReactNode;
|
|
118
|
+
/** Show/hide default header (default: true) */
|
|
119
|
+
showHeader?: boolean;
|
|
120
|
+
/** Children to render in the main content area */
|
|
121
|
+
children: ReactNode;
|
|
122
|
+
}
|
|
86
123
|
|
|
87
124
|
type SidebarContext = {
|
|
88
125
|
state: "expanded" | "collapsed";
|
|
@@ -125,6 +162,25 @@ interface AppSidebarProps extends React$1.ComponentProps<typeof Sidebar> {
|
|
|
125
162
|
}
|
|
126
163
|
declare function AppSidebar({ user, adapter: externalAdapter, data, organizationId, apiBaseUrl, ...props }: AppSidebarProps): react_jsx_runtime.JSX.Element;
|
|
127
164
|
|
|
165
|
+
/**
|
|
166
|
+
* High-level layout component that handles the entire sidebar + content layout structure.
|
|
167
|
+
*
|
|
168
|
+
* This component wraps AppSidebar and SidebarInset in SidebarProvider and provides
|
|
169
|
+
* a default header with sidebar trigger. It handles all layout concerns internally.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```tsx
|
|
173
|
+
* <AppLayout
|
|
174
|
+
* user={user}
|
|
175
|
+
* useApiNavigation={true}
|
|
176
|
+
* headerContent={<Breadcrumb>...</Breadcrumb>}
|
|
177
|
+
* >
|
|
178
|
+
* {children}
|
|
179
|
+
* </AppLayout>
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
declare function AppLayout({ user, adapter, data, organizationId, apiBaseUrl, useApiNavigation, headerContent, showHeader, children, }: AppLayoutProps): react_jsx_runtime.JSX.Element;
|
|
183
|
+
|
|
128
184
|
interface NavMainProps {
|
|
129
185
|
items: NavigationItem[];
|
|
130
186
|
adapter: FrameworkAdapter;
|
|
@@ -189,4 +245,4 @@ declare function getIconComponent(icon?: string | LucideIcon): LucideIcon | unde
|
|
|
189
245
|
*/
|
|
190
246
|
declare function createNextJSAdapter(): FrameworkAdapter;
|
|
191
247
|
|
|
192
|
-
export { AppSidebar, type FrameworkAdapter, type LinkProps, NavMain, NavUser, type NavigationConfig, type NavigationItem, type Organization, type Router, type SidebarData, SidebarInset, SidebarProvider, SidebarTrigger, TeamSwitcher, type User, createNextJSAdapter, getIconComponent, useNavigation, useSidebar };
|
|
248
|
+
export { AppLayout, type AppLayoutProps, AppSidebar, type AppSidebarProps$1 as AppSidebarProps, type FrameworkAdapter, type LinkProps, NavMain, NavUser, type NavigationConfig, type NavigationItem, type Organization, type Router, type SidebarData, SidebarInset, SidebarProvider, SidebarTrigger, TeamSwitcher, type User, createNextJSAdapter, getIconComponent, useNavigation, useSidebar };
|
package/dist/index.d.ts
CHANGED
|
@@ -83,6 +83,43 @@ interface FrameworkAdapter {
|
|
|
83
83
|
redirect?: boolean;
|
|
84
84
|
}) => Promise<void>;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Props for AppSidebar component
|
|
88
|
+
*/
|
|
89
|
+
interface AppSidebarProps$1 {
|
|
90
|
+
user: User;
|
|
91
|
+
/** Optional adapter - if not provided, Next.js defaults will be used */
|
|
92
|
+
adapter?: FrameworkAdapter;
|
|
93
|
+
/** Sidebar data containing organizations and navigation items (props mode) */
|
|
94
|
+
data?: SidebarData;
|
|
95
|
+
/** Current organization ID (optional, can be extracted from pathname) */
|
|
96
|
+
organizationId?: string;
|
|
97
|
+
/** Custom API base URL (API mode only, defaults to "/api") */
|
|
98
|
+
apiBaseUrl?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Props for AppLayout component
|
|
102
|
+
*/
|
|
103
|
+
interface AppLayoutProps {
|
|
104
|
+
/** User data for sidebar */
|
|
105
|
+
user: User;
|
|
106
|
+
/** Optional adapter - if not provided, Next.js defaults will be used */
|
|
107
|
+
adapter?: FrameworkAdapter;
|
|
108
|
+
/** Sidebar data containing organizations and navigation items (props mode) */
|
|
109
|
+
data?: SidebarData;
|
|
110
|
+
/** Current organization ID (optional, can be extracted from pathname) */
|
|
111
|
+
organizationId?: string;
|
|
112
|
+
/** Custom API base URL (API mode only, defaults to "/api" which constructs "/api/navigation/{organizationId}") */
|
|
113
|
+
apiBaseUrl?: string;
|
|
114
|
+
/** Enable API mode - library will fetch navigation from API */
|
|
115
|
+
useApiNavigation?: boolean;
|
|
116
|
+
/** Custom header content (breadcrumbs, actions, etc.) */
|
|
117
|
+
headerContent?: ReactNode;
|
|
118
|
+
/** Show/hide default header (default: true) */
|
|
119
|
+
showHeader?: boolean;
|
|
120
|
+
/** Children to render in the main content area */
|
|
121
|
+
children: ReactNode;
|
|
122
|
+
}
|
|
86
123
|
|
|
87
124
|
type SidebarContext = {
|
|
88
125
|
state: "expanded" | "collapsed";
|
|
@@ -125,6 +162,25 @@ interface AppSidebarProps extends React$1.ComponentProps<typeof Sidebar> {
|
|
|
125
162
|
}
|
|
126
163
|
declare function AppSidebar({ user, adapter: externalAdapter, data, organizationId, apiBaseUrl, ...props }: AppSidebarProps): react_jsx_runtime.JSX.Element;
|
|
127
164
|
|
|
165
|
+
/**
|
|
166
|
+
* High-level layout component that handles the entire sidebar + content layout structure.
|
|
167
|
+
*
|
|
168
|
+
* This component wraps AppSidebar and SidebarInset in SidebarProvider and provides
|
|
169
|
+
* a default header with sidebar trigger. It handles all layout concerns internally.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```tsx
|
|
173
|
+
* <AppLayout
|
|
174
|
+
* user={user}
|
|
175
|
+
* useApiNavigation={true}
|
|
176
|
+
* headerContent={<Breadcrumb>...</Breadcrumb>}
|
|
177
|
+
* >
|
|
178
|
+
* {children}
|
|
179
|
+
* </AppLayout>
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
declare function AppLayout({ user, adapter, data, organizationId, apiBaseUrl, useApiNavigation, headerContent, showHeader, children, }: AppLayoutProps): react_jsx_runtime.JSX.Element;
|
|
183
|
+
|
|
128
184
|
interface NavMainProps {
|
|
129
185
|
items: NavigationItem[];
|
|
130
186
|
adapter: FrameworkAdapter;
|
|
@@ -189,4 +245,4 @@ declare function getIconComponent(icon?: string | LucideIcon): LucideIcon | unde
|
|
|
189
245
|
*/
|
|
190
246
|
declare function createNextJSAdapter(): FrameworkAdapter;
|
|
191
247
|
|
|
192
|
-
export { AppSidebar, type FrameworkAdapter, type LinkProps, NavMain, NavUser, type NavigationConfig, type NavigationItem, type Organization, type Router, type SidebarData, SidebarInset, SidebarProvider, SidebarTrigger, TeamSwitcher, type User, createNextJSAdapter, getIconComponent, useNavigation, useSidebar };
|
|
248
|
+
export { AppLayout, type AppLayoutProps, AppSidebar, type AppSidebarProps$1 as AppSidebarProps, type FrameworkAdapter, type LinkProps, NavMain, NavUser, type NavigationConfig, type NavigationItem, type Organization, type Router, type SidebarData, SidebarInset, SidebarProvider, SidebarTrigger, TeamSwitcher, type User, createNextJSAdapter, getIconComponent, useNavigation, useSidebar };
|
package/dist/index.js
CHANGED
|
@@ -71,6 +71,7 @@ var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
|
71
71
|
var SIDEBAR_WIDTH = "16rem";
|
|
72
72
|
var SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
73
73
|
var SIDEBAR_WIDTH_ICON = "3rem";
|
|
74
|
+
var SIDEBAR_TRANSITION_DURATION = "200ms";
|
|
74
75
|
var SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
75
76
|
var SidebarContext = React2__namespace.createContext(null);
|
|
76
77
|
function useSidebar() {
|
|
@@ -149,6 +150,7 @@ var SidebarProvider = React2__namespace.forwardRef(
|
|
|
149
150
|
style: {
|
|
150
151
|
"--sidebar-width": SIDEBAR_WIDTH,
|
|
151
152
|
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
153
|
+
"--sidebar-transition-duration": SIDEBAR_TRANSITION_DURATION,
|
|
152
154
|
...style
|
|
153
155
|
},
|
|
154
156
|
className: cn(
|
|
@@ -312,16 +314,29 @@ var SidebarRail = React2__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
312
314
|
);
|
|
313
315
|
});
|
|
314
316
|
SidebarRail.displayName = "SidebarRail";
|
|
315
|
-
var SidebarInset = React2__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
317
|
+
var SidebarInset = React2__namespace.forwardRef(({ className, style, ...props }, ref) => {
|
|
318
|
+
const { state, isMobile } = useSidebar();
|
|
316
319
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
317
320
|
"main",
|
|
318
321
|
{
|
|
319
322
|
ref,
|
|
320
323
|
className: cn(
|
|
321
324
|
"relative flex min-h-svh flex-1 flex-col bg-background",
|
|
325
|
+
// Auto-adjust margin based on sidebar state using CSS variables
|
|
326
|
+
// Transition duration uses CSS variable for consistency
|
|
327
|
+
"transition-[margin-left] ease-linear",
|
|
328
|
+
// On mobile, no margin needed (sidebar is overlay)
|
|
329
|
+
// On desktop, margin-left based on sidebar state
|
|
330
|
+
!isMobile && state === "expanded" && "md:ml-[var(--sidebar-width)]",
|
|
331
|
+
!isMobile && state === "collapsed" && "md:ml-[var(--sidebar-width-icon)]",
|
|
332
|
+
// Keep peer-based styles for inset variant
|
|
322
333
|
"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",
|
|
323
334
|
className
|
|
324
335
|
),
|
|
336
|
+
style: {
|
|
337
|
+
transitionDuration: "var(--sidebar-transition-duration, 200ms)",
|
|
338
|
+
...style
|
|
339
|
+
},
|
|
325
340
|
...props
|
|
326
341
|
}
|
|
327
342
|
);
|
|
@@ -1244,6 +1259,42 @@ function AppSidebar({
|
|
|
1244
1259
|
/* @__PURE__ */ jsxRuntime.jsx(SidebarRail, {})
|
|
1245
1260
|
] });
|
|
1246
1261
|
}
|
|
1262
|
+
function AppLayout({
|
|
1263
|
+
user,
|
|
1264
|
+
adapter,
|
|
1265
|
+
data,
|
|
1266
|
+
organizationId,
|
|
1267
|
+
apiBaseUrl,
|
|
1268
|
+
useApiNavigation,
|
|
1269
|
+
headerContent,
|
|
1270
|
+
showHeader = true,
|
|
1271
|
+
children
|
|
1272
|
+
}) {
|
|
1273
|
+
const isApiMode = useApiNavigation === true;
|
|
1274
|
+
const navigationApiBaseUrl = apiBaseUrl;
|
|
1275
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(SidebarProvider, { children: [
|
|
1276
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1277
|
+
AppSidebar,
|
|
1278
|
+
{
|
|
1279
|
+
user,
|
|
1280
|
+
adapter,
|
|
1281
|
+
data: isApiMode ? void 0 : data,
|
|
1282
|
+
organizationId,
|
|
1283
|
+
apiBaseUrl: navigationApiBaseUrl
|
|
1284
|
+
}
|
|
1285
|
+
),
|
|
1286
|
+
/* @__PURE__ */ jsxRuntime.jsxs(SidebarInset, { children: [
|
|
1287
|
+
showHeader && /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex h-16 shrink-0 items-center gap-2 border-b px-4", children: [
|
|
1288
|
+
/* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, {}),
|
|
1289
|
+
headerContent && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1290
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-px bg-border" }),
|
|
1291
|
+
headerContent
|
|
1292
|
+
] })
|
|
1293
|
+
] }),
|
|
1294
|
+
/* @__PURE__ */ jsxRuntime.jsx("main", { className: "flex flex-1 flex-col gap-4 p-4 md:p-6", children })
|
|
1295
|
+
] })
|
|
1296
|
+
] });
|
|
1297
|
+
}
|
|
1247
1298
|
function createNextJSAdapter() {
|
|
1248
1299
|
const NextJSLink2 = ({ href, children, className }) => /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href, className, children });
|
|
1249
1300
|
return {
|
|
@@ -1260,6 +1311,7 @@ function createNextJSAdapter() {
|
|
|
1260
1311
|
};
|
|
1261
1312
|
}
|
|
1262
1313
|
|
|
1314
|
+
exports.AppLayout = AppLayout;
|
|
1263
1315
|
exports.AppSidebar = AppSidebar;
|
|
1264
1316
|
exports.NavMain = NavMain;
|
|
1265
1317
|
exports.NavUser = NavUser;
|