@pablo2410/shared-ui 0.5.0 → 0.6.1
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/DashboardLayout-Bors1KO3.d.ts +160 -0
- package/dist/chunk-MAKRKBBI.js +850 -0
- package/dist/chunk-MAKRKBBI.js.map +1 -0
- package/dist/layout/index.d.ts +4 -158
- package/dist/layout/index.js +20 -828
- package/dist/layout/index.js.map +1 -1
- package/dist/reporting/index.d.ts +18 -26
- package/dist/reporting/index.js +380 -175
- package/dist/reporting/index.js.map +1 -1
- package/dist/shell/index.d.ts +81 -0
- package/dist/shell/index.js +12 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/shell/oplytics-shell.css +2 -0
- package/dist/theme/oplytics-theme.css +86 -0
- package/package.json +12 -3
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SharedSidebar — Config-driven sidebar component for all Oplytics subdomains.
|
|
6
|
+
*
|
|
7
|
+
* Replaces per-subdomain DashboardLayout sidebar implementations with a single
|
|
8
|
+
* shared component. Each subdomain provides its own configuration (menu items,
|
|
9
|
+
* service name, feature flags) and gets a consistent sidebar experience.
|
|
10
|
+
*
|
|
11
|
+
* Features:
|
|
12
|
+
* - Resizable sidebar with localStorage persistence
|
|
13
|
+
* - Collapsible icon mode with tooltips
|
|
14
|
+
* - Service branding (icon + name) in header
|
|
15
|
+
* - "Back to Service Hub/Portal" link (configurable)
|
|
16
|
+
* - Grouped menu sections with optional section labels
|
|
17
|
+
* - Admin-only menu items (role-gated)
|
|
18
|
+
* - User avatar footer with optional logout dropdown
|
|
19
|
+
* - Mobile-responsive with auto-collapse
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* import { createServiceLayout } from "@shared/components/SharedSidebar";
|
|
23
|
+
* const MyLayout = createServiceLayout({ serviceName: "SQDCP", ... });
|
|
24
|
+
* // Then use <MyLayout>{children}</MyLayout> in your routes
|
|
25
|
+
*
|
|
26
|
+
* @module shared/components/SharedSidebar
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
interface MenuItem {
|
|
30
|
+
icon: React__default.ComponentType<{
|
|
31
|
+
className?: string;
|
|
32
|
+
}>;
|
|
33
|
+
label: string;
|
|
34
|
+
path: string;
|
|
35
|
+
/** Optional badge text (e.g. count) */
|
|
36
|
+
badge?: string | number;
|
|
37
|
+
}
|
|
38
|
+
interface MenuSection {
|
|
39
|
+
/** Section label displayed above items */
|
|
40
|
+
label?: string;
|
|
41
|
+
/** Alias for label — used by DashboardLayout */
|
|
42
|
+
title?: string;
|
|
43
|
+
items: MenuItem[];
|
|
44
|
+
adminOnly?: boolean;
|
|
45
|
+
}
|
|
46
|
+
interface SharedSidebarConfig {
|
|
47
|
+
/** Display name shown in sidebar header */
|
|
48
|
+
serviceName: string;
|
|
49
|
+
/** Icon component rendered next to service name */
|
|
50
|
+
serviceIcon: React__default.ReactNode;
|
|
51
|
+
/** Primary navigation items */
|
|
52
|
+
menuSections: MenuSection[];
|
|
53
|
+
/** Show "Back to Service Hub" / "Back to Portal" link at top of nav */
|
|
54
|
+
backLink?: {
|
|
55
|
+
label: string;
|
|
56
|
+
path: string;
|
|
57
|
+
};
|
|
58
|
+
/** localStorage key prefix for sidebar width persistence */
|
|
59
|
+
storageKeyPrefix?: string;
|
|
60
|
+
/** Default sidebar width in pixels (default: 260) */
|
|
61
|
+
defaultWidth?: number;
|
|
62
|
+
/** Minimum sidebar width in pixels (default: 200) */
|
|
63
|
+
minWidth?: number;
|
|
64
|
+
/** Maximum sidebar width in pixels (default: 480) */
|
|
65
|
+
maxWidth?: number;
|
|
66
|
+
}
|
|
67
|
+
interface SharedSidebarProps {
|
|
68
|
+
config: SharedSidebarConfig;
|
|
69
|
+
/** Current route location */
|
|
70
|
+
location: string;
|
|
71
|
+
/** Navigate to a path */
|
|
72
|
+
setLocation: (path: string) => void;
|
|
73
|
+
/** Current user object (null if not authenticated) */
|
|
74
|
+
user: {
|
|
75
|
+
name?: string;
|
|
76
|
+
email?: string;
|
|
77
|
+
role?: string;
|
|
78
|
+
} | null;
|
|
79
|
+
/** Logout handler */
|
|
80
|
+
onLogout?: () => void;
|
|
81
|
+
/** Whether sidebar is collapsed */
|
|
82
|
+
isCollapsed: boolean;
|
|
83
|
+
/** Toggle sidebar collapsed state */
|
|
84
|
+
toggleSidebar: () => void;
|
|
85
|
+
/** Whether user has admin role */
|
|
86
|
+
isAdmin: boolean;
|
|
87
|
+
/** Children rendered in SidebarInset main area */
|
|
88
|
+
children: React__default.ReactNode;
|
|
89
|
+
}
|
|
90
|
+
declare function isAdminRole(role?: string): boolean;
|
|
91
|
+
declare function getInitials(name?: string): string;
|
|
92
|
+
/**
|
|
93
|
+
* Determines if a menu item is active based on current location.
|
|
94
|
+
* Exact match for root paths, startsWith for nested paths.
|
|
95
|
+
*/
|
|
96
|
+
declare function isMenuItemActive(itemPath: string, location: string, basePath?: string): boolean;
|
|
97
|
+
declare function useSidebarResize(config: {
|
|
98
|
+
storageKey: string;
|
|
99
|
+
defaultWidth: number;
|
|
100
|
+
minWidth: number;
|
|
101
|
+
maxWidth: number;
|
|
102
|
+
}): {
|
|
103
|
+
width: number;
|
|
104
|
+
isResizing: boolean;
|
|
105
|
+
startResize: (e: React__default.MouseEvent) => void;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
interface DashboardLayoutUser {
|
|
109
|
+
name?: string;
|
|
110
|
+
email?: string;
|
|
111
|
+
role?: string;
|
|
112
|
+
avatarUrl?: string;
|
|
113
|
+
}
|
|
114
|
+
interface DashboardLayoutEnterprise {
|
|
115
|
+
name: string;
|
|
116
|
+
code?: string;
|
|
117
|
+
}
|
|
118
|
+
interface DashboardLayoutProps {
|
|
119
|
+
/** Service/module name shown in the sidebar brand header (e.g. "OEE Manager"). */
|
|
120
|
+
serviceName: string;
|
|
121
|
+
/** Service icon (a lucide icon element), shown in the sidebar brand + header. */
|
|
122
|
+
serviceIcon?: ReactNode;
|
|
123
|
+
/** Primary navigation sections. */
|
|
124
|
+
menuSections: MenuSection[];
|
|
125
|
+
/** Admin-only navigation sections, rendered when `isAdmin` is true. */
|
|
126
|
+
adminSections?: MenuSection[];
|
|
127
|
+
/** Whether the current user may see `adminSections`. */
|
|
128
|
+
isAdmin?: boolean;
|
|
129
|
+
/** Current route (the app's router supplies this). */
|
|
130
|
+
activePath: string;
|
|
131
|
+
/** Navigate handler (the app's router supplies this). */
|
|
132
|
+
onNavigate: (path: string) => void;
|
|
133
|
+
/** Optional override for active-item detection. */
|
|
134
|
+
isActive?: (itemPath: string, activePath: string) => boolean;
|
|
135
|
+
/** URL for the "← Service Hub" link at the top of the nav (full-page nav). */
|
|
136
|
+
serviceHubUrl?: string;
|
|
137
|
+
/** Footer "Settings" route. Omit to hide the footer. */
|
|
138
|
+
settingsPath?: string;
|
|
139
|
+
/** Authenticated user (drives the header user menu). */
|
|
140
|
+
user?: DashboardLayoutUser | null;
|
|
141
|
+
/** Sign-out handler invoked from the user menu. */
|
|
142
|
+
onLogout?: () => void;
|
|
143
|
+
/** "User Settings" target in the user menu (full-page nav). */
|
|
144
|
+
userSettingsUrl?: string;
|
|
145
|
+
/** App-provided hierarchy navigator rendered in the header breadcrumb slot. */
|
|
146
|
+
hierarchyNavigator?: ReactNode;
|
|
147
|
+
/** Selected enterprise — drives the header enterprise badge. */
|
|
148
|
+
enterprise?: DashboardLayoutEnterprise | null;
|
|
149
|
+
/** App-provided reporting toolbar rendered on the right of the header. */
|
|
150
|
+
reportingToolbar?: ReactNode;
|
|
151
|
+
/** Whether the sidebar starts expanded. Defaults to `!isMobile`. */
|
|
152
|
+
defaultOpen?: boolean;
|
|
153
|
+
/** Extra footer rendered fixed at the bottom (e.g. a debug/health bar). */
|
|
154
|
+
footer?: ReactNode;
|
|
155
|
+
/** Main content. */
|
|
156
|
+
children: ReactNode;
|
|
157
|
+
}
|
|
158
|
+
declare function DashboardLayout(props: DashboardLayoutProps): react_jsx_runtime.JSX.Element;
|
|
159
|
+
|
|
160
|
+
export { DashboardLayout as D, type MenuItem as M, type SharedSidebarConfig as S, type DashboardLayoutEnterprise as a, type DashboardLayoutProps as b, type DashboardLayoutUser as c, type MenuSection as d, type SharedSidebarProps as e, isMenuItemActive as f, getInitials as g, isAdminRole as i, useSidebarResize as u };
|