@logickernel/frame 0.1.0 → 0.3.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/README.md +1 -1
- package/dist/index.d.mts +143 -11
- package/dist/index.d.ts +143 -11
- package/dist/index.js +851 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +793 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -22
- package/dist/adapters/nextjs.js +0 -31
- package/dist/adapters/nextjs.js.map +0 -1
- package/dist/adapters/nextjs.mjs +0 -25
- package/dist/adapters/nextjs.mjs.map +0 -1
- package/dist/components/AppSidebar.js +0 -467
- package/dist/components/AppSidebar.js.map +0 -1
- package/dist/components/AppSidebar.mjs +0 -446
- package/dist/components/AppSidebar.mjs.map +0 -1
- package/dist/components/NavMain.js +0 -133
- package/dist/components/NavMain.js.map +0 -1
- package/dist/components/NavMain.mjs +0 -112
- package/dist/components/NavMain.mjs.map +0 -1
- package/dist/components/NavUser.js +0 -88
- package/dist/components/NavUser.js.map +0 -1
- package/dist/components/NavUser.mjs +0 -86
- package/dist/components/NavUser.mjs.map +0 -1
- package/dist/components/TeamSwitcher.js +0 -164
- package/dist/components/TeamSwitcher.js.map +0 -1
- package/dist/components/TeamSwitcher.mjs +0 -162
- package/dist/components/TeamSwitcher.mjs.map +0 -1
- package/dist/hooks/useNavigation.d.mts +0 -24
- package/dist/hooks/useNavigation.d.ts +0 -24
- package/dist/hooks/useNavigation.js +0 -59
- package/dist/hooks/useNavigation.js.map +0 -1
- package/dist/hooks/useNavigation.mjs +0 -57
- package/dist/hooks/useNavigation.mjs.map +0 -1
- package/dist/types/index.d.mts +0 -85
- package/dist/types/index.d.ts +0 -85
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -3
- package/dist/types/index.mjs.map +0 -1
- package/dist/types/ui-components.d.js +0 -4
- package/dist/types/ui-components.d.js.map +0 -1
- package/dist/types/ui-components.d.mjs +0 -3
- package/dist/types/ui-components.d.mjs.map +0 -1
- package/dist/utils/iconMapper.d.mts +0 -16
- package/dist/utils/iconMapper.d.ts +0 -16
- package/dist/utils/iconMapper.js +0 -52
- package/dist/utils/iconMapper.js.map +0 -1
- package/dist/utils/iconMapper.mjs +0 -30
- package/dist/utils/iconMapper.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -252,7 +252,7 @@ const { items, organizations, loading, error } = useNavigation({
|
|
|
252
252
|
**Options:**
|
|
253
253
|
- `organizationId?: string` - Organization ID to fetch navigation for
|
|
254
254
|
- `apiBaseUrl?: string` - API base URL (default: "/api")
|
|
255
|
-
- `enabled?: boolean` - Enable/disable fetching (default: true)
|
|
255
|
+
- `enabled?: boolean` - Enable/disable fetching (default: true). Useful for conditional fetching, e.g., `enabled: !!user` to only fetch when a user is logged in
|
|
256
256
|
|
|
257
257
|
**Returns:**
|
|
258
258
|
- `items: NavigationItem[]` - Navigation items
|
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,119 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import * as React$1 from 'react';
|
|
3
|
+
import { ComponentType, ReactNode } from 'react';
|
|
4
|
+
import { LucideIcon } from 'lucide-react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @logickernel/frame library types
|
|
8
|
+
* Shared types for navigation, user, and organization data
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Navigation item for facade components
|
|
13
|
+
* Supports both icon components (props) and icon names (API)
|
|
14
|
+
*/
|
|
15
|
+
interface NavigationItem {
|
|
16
|
+
title: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
icon?: string | LucideIcon;
|
|
19
|
+
isActive?: boolean;
|
|
20
|
+
items?: {
|
|
21
|
+
title: string;
|
|
22
|
+
url: string;
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Navigation configuration
|
|
27
|
+
*/
|
|
28
|
+
interface NavigationConfig {
|
|
29
|
+
items: NavigationItem[];
|
|
30
|
+
organizationId?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Sidebar data payload for props mode
|
|
34
|
+
* Contains organizations and navigation items
|
|
35
|
+
*/
|
|
36
|
+
interface SidebarData {
|
|
37
|
+
organizations: Organization[];
|
|
38
|
+
navigationItems: NavigationItem[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* User data structure
|
|
42
|
+
*/
|
|
43
|
+
interface User {
|
|
44
|
+
name: string | null;
|
|
45
|
+
email: string;
|
|
46
|
+
image: string | null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Organization data structure
|
|
50
|
+
*/
|
|
51
|
+
interface Organization {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
logo?: LucideIcon | React.ComponentType<{
|
|
55
|
+
className?: string;
|
|
56
|
+
}>;
|
|
57
|
+
plan?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Router interface for framework-agnostic navigation
|
|
61
|
+
*/
|
|
62
|
+
interface Router {
|
|
63
|
+
push: (path: string) => void;
|
|
64
|
+
refresh?: () => void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Link component props
|
|
68
|
+
*/
|
|
69
|
+
interface LinkProps {
|
|
70
|
+
href: string;
|
|
71
|
+
children: ReactNode;
|
|
72
|
+
className?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Framework adapter interface
|
|
76
|
+
* Provides router functions and components for the library
|
|
77
|
+
*/
|
|
78
|
+
interface FrameworkAdapter {
|
|
79
|
+
usePathname: () => string;
|
|
80
|
+
useRouter: () => Router;
|
|
81
|
+
Link: ComponentType<LinkProps>;
|
|
82
|
+
signOut?: (options?: {
|
|
83
|
+
redirect?: boolean;
|
|
84
|
+
}) => Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type SidebarContext = {
|
|
88
|
+
state: "expanded" | "collapsed";
|
|
89
|
+
open: boolean;
|
|
90
|
+
setOpen: (open: boolean) => void;
|
|
91
|
+
openMobile: boolean;
|
|
92
|
+
setOpenMobile: (open: boolean) => void;
|
|
93
|
+
isMobile: boolean;
|
|
94
|
+
toggleSidebar: () => void;
|
|
95
|
+
};
|
|
96
|
+
declare const SidebarContext: React$1.Context<SidebarContext | null>;
|
|
97
|
+
declare function useSidebar(): SidebarContext;
|
|
98
|
+
declare const SidebarProvider: React$1.ForwardRefExoticComponent<Omit<React$1.ClassAttributes<HTMLDivElement> & React$1.HTMLAttributes<HTMLDivElement> & {
|
|
99
|
+
defaultOpen?: boolean;
|
|
100
|
+
open?: boolean;
|
|
101
|
+
onOpenChange?: (open: boolean) => void;
|
|
102
|
+
}, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
103
|
+
declare const Sidebar: React$1.ForwardRefExoticComponent<Omit<React$1.ClassAttributes<HTMLDivElement> & React$1.HTMLAttributes<HTMLDivElement> & {
|
|
104
|
+
side?: "left" | "right";
|
|
105
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
106
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
107
|
+
}, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
9
108
|
|
|
10
109
|
/**
|
|
11
110
|
* Props mode: Pass data (organizations + navigationItems)
|
|
12
111
|
* API mode: Omit data (fetched from API)
|
|
13
112
|
*/
|
|
14
|
-
interface AppSidebarProps extends React.ComponentProps<typeof Sidebar> {
|
|
113
|
+
interface AppSidebarProps extends React$1.ComponentProps<typeof Sidebar> {
|
|
15
114
|
user: User;
|
|
16
|
-
adapter
|
|
115
|
+
/** Optional adapter - if not provided, Next.js defaults will be used */
|
|
116
|
+
adapter?: FrameworkAdapter;
|
|
17
117
|
/** Sidebar data containing organizations and navigation items (props mode) */
|
|
18
118
|
data?: SidebarData;
|
|
19
119
|
/** Current organization ID (optional, can be extracted from pathname) */
|
|
@@ -21,7 +121,7 @@ interface AppSidebarProps extends React.ComponentProps<typeof Sidebar> {
|
|
|
21
121
|
/** Custom API base URL (API mode only, defaults to "/api") */
|
|
22
122
|
apiBaseUrl?: string;
|
|
23
123
|
}
|
|
24
|
-
declare function AppSidebar({ user, adapter, data, organizationId, apiBaseUrl, ...props }: AppSidebarProps): react_jsx_runtime.JSX.Element;
|
|
124
|
+
declare function AppSidebar({ user, adapter: externalAdapter, data, organizationId, apiBaseUrl, ...props }: AppSidebarProps): react_jsx_runtime.JSX.Element;
|
|
25
125
|
|
|
26
126
|
interface NavMainProps {
|
|
27
127
|
items: NavigationItem[];
|
|
@@ -42,6 +142,38 @@ interface TeamSwitcherProps {
|
|
|
42
142
|
}
|
|
43
143
|
declare function TeamSwitcher({ teams, organizationId, adapter, }: TeamSwitcherProps): react_jsx_runtime.JSX.Element | null;
|
|
44
144
|
|
|
145
|
+
interface UseNavigationOptions {
|
|
146
|
+
organizationId?: string;
|
|
147
|
+
apiBaseUrl?: string;
|
|
148
|
+
enabled?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Hook to fetch navigation items and organizations from API
|
|
152
|
+
* Falls back to empty array if API is unavailable or disabled
|
|
153
|
+
*
|
|
154
|
+
* @param options - Configuration options
|
|
155
|
+
* @returns Navigation items, organizations, loading state, and error
|
|
156
|
+
*/
|
|
157
|
+
declare function useNavigation({ organizationId, apiBaseUrl, enabled, }?: UseNavigationOptions): {
|
|
158
|
+
items: NavigationItem[];
|
|
159
|
+
organizations: Organization[];
|
|
160
|
+
loading: boolean;
|
|
161
|
+
error: Error | null;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Icon mapper utility
|
|
166
|
+
* Maps icon name strings to Lucide React icon components
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Get icon component from icon name or component
|
|
171
|
+
*
|
|
172
|
+
* @param icon - Icon name (string) or icon component
|
|
173
|
+
* @returns Icon component or undefined
|
|
174
|
+
*/
|
|
175
|
+
declare function getIconComponent(icon?: string | LucideIcon): LucideIcon | undefined;
|
|
176
|
+
|
|
45
177
|
/**
|
|
46
178
|
* Next.js adapter for @logickernel/frame
|
|
47
179
|
* Provides Next.js-specific implementations of FrameworkAdapter
|
|
@@ -55,4 +187,4 @@ declare function TeamSwitcher({ teams, organizationId, adapter, }: TeamSwitcherP
|
|
|
55
187
|
*/
|
|
56
188
|
declare function createNextJSAdapter(): FrameworkAdapter;
|
|
57
189
|
|
|
58
|
-
export { AppSidebar, FrameworkAdapter, NavMain, NavUser, NavigationItem, Organization, SidebarData, TeamSwitcher, User, createNextJSAdapter };
|
|
190
|
+
export { AppSidebar, type FrameworkAdapter, type LinkProps, NavMain, NavUser, type NavigationConfig, type NavigationItem, type Organization, type Router, type SidebarData, SidebarProvider, TeamSwitcher, type User, createNextJSAdapter, getIconComponent, useNavigation, useSidebar };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,119 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import * as React$1 from 'react';
|
|
3
|
+
import { ComponentType, ReactNode } from 'react';
|
|
4
|
+
import { LucideIcon } from 'lucide-react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @logickernel/frame library types
|
|
8
|
+
* Shared types for navigation, user, and organization data
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Navigation item for facade components
|
|
13
|
+
* Supports both icon components (props) and icon names (API)
|
|
14
|
+
*/
|
|
15
|
+
interface NavigationItem {
|
|
16
|
+
title: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
icon?: string | LucideIcon;
|
|
19
|
+
isActive?: boolean;
|
|
20
|
+
items?: {
|
|
21
|
+
title: string;
|
|
22
|
+
url: string;
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Navigation configuration
|
|
27
|
+
*/
|
|
28
|
+
interface NavigationConfig {
|
|
29
|
+
items: NavigationItem[];
|
|
30
|
+
organizationId?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Sidebar data payload for props mode
|
|
34
|
+
* Contains organizations and navigation items
|
|
35
|
+
*/
|
|
36
|
+
interface SidebarData {
|
|
37
|
+
organizations: Organization[];
|
|
38
|
+
navigationItems: NavigationItem[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* User data structure
|
|
42
|
+
*/
|
|
43
|
+
interface User {
|
|
44
|
+
name: string | null;
|
|
45
|
+
email: string;
|
|
46
|
+
image: string | null;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Organization data structure
|
|
50
|
+
*/
|
|
51
|
+
interface Organization {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
logo?: LucideIcon | React.ComponentType<{
|
|
55
|
+
className?: string;
|
|
56
|
+
}>;
|
|
57
|
+
plan?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Router interface for framework-agnostic navigation
|
|
61
|
+
*/
|
|
62
|
+
interface Router {
|
|
63
|
+
push: (path: string) => void;
|
|
64
|
+
refresh?: () => void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Link component props
|
|
68
|
+
*/
|
|
69
|
+
interface LinkProps {
|
|
70
|
+
href: string;
|
|
71
|
+
children: ReactNode;
|
|
72
|
+
className?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Framework adapter interface
|
|
76
|
+
* Provides router functions and components for the library
|
|
77
|
+
*/
|
|
78
|
+
interface FrameworkAdapter {
|
|
79
|
+
usePathname: () => string;
|
|
80
|
+
useRouter: () => Router;
|
|
81
|
+
Link: ComponentType<LinkProps>;
|
|
82
|
+
signOut?: (options?: {
|
|
83
|
+
redirect?: boolean;
|
|
84
|
+
}) => Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type SidebarContext = {
|
|
88
|
+
state: "expanded" | "collapsed";
|
|
89
|
+
open: boolean;
|
|
90
|
+
setOpen: (open: boolean) => void;
|
|
91
|
+
openMobile: boolean;
|
|
92
|
+
setOpenMobile: (open: boolean) => void;
|
|
93
|
+
isMobile: boolean;
|
|
94
|
+
toggleSidebar: () => void;
|
|
95
|
+
};
|
|
96
|
+
declare const SidebarContext: React$1.Context<SidebarContext | null>;
|
|
97
|
+
declare function useSidebar(): SidebarContext;
|
|
98
|
+
declare const SidebarProvider: React$1.ForwardRefExoticComponent<Omit<React$1.ClassAttributes<HTMLDivElement> & React$1.HTMLAttributes<HTMLDivElement> & {
|
|
99
|
+
defaultOpen?: boolean;
|
|
100
|
+
open?: boolean;
|
|
101
|
+
onOpenChange?: (open: boolean) => void;
|
|
102
|
+
}, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
103
|
+
declare const Sidebar: React$1.ForwardRefExoticComponent<Omit<React$1.ClassAttributes<HTMLDivElement> & React$1.HTMLAttributes<HTMLDivElement> & {
|
|
104
|
+
side?: "left" | "right";
|
|
105
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
106
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
107
|
+
}, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
|
|
9
108
|
|
|
10
109
|
/**
|
|
11
110
|
* Props mode: Pass data (organizations + navigationItems)
|
|
12
111
|
* API mode: Omit data (fetched from API)
|
|
13
112
|
*/
|
|
14
|
-
interface AppSidebarProps extends React.ComponentProps<typeof Sidebar> {
|
|
113
|
+
interface AppSidebarProps extends React$1.ComponentProps<typeof Sidebar> {
|
|
15
114
|
user: User;
|
|
16
|
-
adapter
|
|
115
|
+
/** Optional adapter - if not provided, Next.js defaults will be used */
|
|
116
|
+
adapter?: FrameworkAdapter;
|
|
17
117
|
/** Sidebar data containing organizations and navigation items (props mode) */
|
|
18
118
|
data?: SidebarData;
|
|
19
119
|
/** Current organization ID (optional, can be extracted from pathname) */
|
|
@@ -21,7 +121,7 @@ interface AppSidebarProps extends React.ComponentProps<typeof Sidebar> {
|
|
|
21
121
|
/** Custom API base URL (API mode only, defaults to "/api") */
|
|
22
122
|
apiBaseUrl?: string;
|
|
23
123
|
}
|
|
24
|
-
declare function AppSidebar({ user, adapter, data, organizationId, apiBaseUrl, ...props }: AppSidebarProps): react_jsx_runtime.JSX.Element;
|
|
124
|
+
declare function AppSidebar({ user, adapter: externalAdapter, data, organizationId, apiBaseUrl, ...props }: AppSidebarProps): react_jsx_runtime.JSX.Element;
|
|
25
125
|
|
|
26
126
|
interface NavMainProps {
|
|
27
127
|
items: NavigationItem[];
|
|
@@ -42,6 +142,38 @@ interface TeamSwitcherProps {
|
|
|
42
142
|
}
|
|
43
143
|
declare function TeamSwitcher({ teams, organizationId, adapter, }: TeamSwitcherProps): react_jsx_runtime.JSX.Element | null;
|
|
44
144
|
|
|
145
|
+
interface UseNavigationOptions {
|
|
146
|
+
organizationId?: string;
|
|
147
|
+
apiBaseUrl?: string;
|
|
148
|
+
enabled?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Hook to fetch navigation items and organizations from API
|
|
152
|
+
* Falls back to empty array if API is unavailable or disabled
|
|
153
|
+
*
|
|
154
|
+
* @param options - Configuration options
|
|
155
|
+
* @returns Navigation items, organizations, loading state, and error
|
|
156
|
+
*/
|
|
157
|
+
declare function useNavigation({ organizationId, apiBaseUrl, enabled, }?: UseNavigationOptions): {
|
|
158
|
+
items: NavigationItem[];
|
|
159
|
+
organizations: Organization[];
|
|
160
|
+
loading: boolean;
|
|
161
|
+
error: Error | null;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Icon mapper utility
|
|
166
|
+
* Maps icon name strings to Lucide React icon components
|
|
167
|
+
*/
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Get icon component from icon name or component
|
|
171
|
+
*
|
|
172
|
+
* @param icon - Icon name (string) or icon component
|
|
173
|
+
* @returns Icon component or undefined
|
|
174
|
+
*/
|
|
175
|
+
declare function getIconComponent(icon?: string | LucideIcon): LucideIcon | undefined;
|
|
176
|
+
|
|
45
177
|
/**
|
|
46
178
|
* Next.js adapter for @logickernel/frame
|
|
47
179
|
* Provides Next.js-specific implementations of FrameworkAdapter
|
|
@@ -55,4 +187,4 @@ declare function TeamSwitcher({ teams, organizationId, adapter, }: TeamSwitcherP
|
|
|
55
187
|
*/
|
|
56
188
|
declare function createNextJSAdapter(): FrameworkAdapter;
|
|
57
189
|
|
|
58
|
-
export { AppSidebar, FrameworkAdapter, NavMain, NavUser, NavigationItem, Organization, SidebarData, TeamSwitcher, User, createNextJSAdapter };
|
|
190
|
+
export { AppSidebar, type FrameworkAdapter, type LinkProps, NavMain, NavUser, type NavigationConfig, type NavigationItem, type Organization, type Router, type SidebarData, SidebarProvider, TeamSwitcher, type User, createNextJSAdapter, getIconComponent, useNavigation, useSidebar };
|