@logickernel/frame 0.5.0 → 0.7.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 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,28 @@ 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
326
+ // Transition duration uses CSS variable for consistency
327
+ "transition-[margin-left] duration-200 ease-linear",
328
+ // On mobile, no margin needed (sidebar is overlay)
329
+ // On desktop, margin-left based on sidebar state:
330
+ // - Expanded: ml-64 (256px / 16rem)
331
+ // - Collapsed: ml-12 (48px / 3rem)
332
+ !isMobile && state === "expanded" && "md:ml-64",
333
+ !isMobile && state === "collapsed" && "md:ml-12",
334
+ // Keep peer-based styles for inset variant
322
335
  "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
336
  className
324
337
  ),
338
+ style,
325
339
  ...props
326
340
  }
327
341
  );
@@ -1244,6 +1258,42 @@ function AppSidebar({
1244
1258
  /* @__PURE__ */ jsxRuntime.jsx(SidebarRail, {})
1245
1259
  ] });
1246
1260
  }
1261
+ function AppLayout({
1262
+ user,
1263
+ adapter,
1264
+ data,
1265
+ organizationId,
1266
+ apiBaseUrl,
1267
+ useApiNavigation,
1268
+ headerContent,
1269
+ showHeader = true,
1270
+ children
1271
+ }) {
1272
+ const isApiMode = useApiNavigation === true;
1273
+ const navigationApiBaseUrl = apiBaseUrl;
1274
+ return /* @__PURE__ */ jsxRuntime.jsxs(SidebarProvider, { children: [
1275
+ /* @__PURE__ */ jsxRuntime.jsx(
1276
+ AppSidebar,
1277
+ {
1278
+ user,
1279
+ adapter,
1280
+ data: isApiMode ? void 0 : data,
1281
+ organizationId,
1282
+ apiBaseUrl: navigationApiBaseUrl
1283
+ }
1284
+ ),
1285
+ /* @__PURE__ */ jsxRuntime.jsxs(SidebarInset, { children: [
1286
+ showHeader && /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex h-16 shrink-0 items-center gap-2 border-b px-4", children: [
1287
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, {}),
1288
+ headerContent && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1289
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-px bg-border" }),
1290
+ headerContent
1291
+ ] })
1292
+ ] }),
1293
+ /* @__PURE__ */ jsxRuntime.jsx("main", { className: "flex flex-1 flex-col gap-4 p-4 md:p-6", children })
1294
+ ] })
1295
+ ] });
1296
+ }
1247
1297
  function createNextJSAdapter() {
1248
1298
  const NextJSLink2 = ({ href, children, className }) => /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href, className, children });
1249
1299
  return {
@@ -1260,6 +1310,7 @@ function createNextJSAdapter() {
1260
1310
  };
1261
1311
  }
1262
1312
 
1313
+ exports.AppLayout = AppLayout;
1263
1314
  exports.AppSidebar = AppSidebar;
1264
1315
  exports.NavMain = NavMain;
1265
1316
  exports.NavUser = NavUser;