@plexusone/shell 0.0.0-stage → 0.2.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/README.md +22 -2
- package/dist/index.d.mts +641 -0
- package/dist/index.d.ts +641 -0
- package/dist/index.js +948 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +959 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +56 -3
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @plexusone/shell
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Application shell components for SystemForge applications.
|
|
4
|
+
|
|
5
|
+
Part of [SystemForge Web](https://github.com/plexusone/systemforge-web), React
|
|
6
|
+
packages for applications built on the
|
|
7
|
+
[SystemForge](https://github.com/plexusone/systemforge) platform.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @plexusone/shell @plexusone/auth @plexusone/tenant @plexusone/ui
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires `react`, `@plexusone/auth`, `@plexusone/tenant`, `@plexusone/ui`.
|
|
16
|
+
|
|
17
|
+
## Documentation
|
|
18
|
+
|
|
19
|
+
See the [documentation](https://plexusone.github.io/systemforge-web/packages/shell/) for usage and the API reference.
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CatalogApp, SessionMembership } from '@plexusone/auth';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Navigation item
|
|
7
|
+
*/
|
|
8
|
+
interface NavItem {
|
|
9
|
+
/**
|
|
10
|
+
* Unique identifier
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* Display label
|
|
15
|
+
*/
|
|
16
|
+
label: string;
|
|
17
|
+
/**
|
|
18
|
+
* Navigation path
|
|
19
|
+
*/
|
|
20
|
+
href: string;
|
|
21
|
+
/**
|
|
22
|
+
* Icon component or element
|
|
23
|
+
*/
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* Badge content (e.g., notification count)
|
|
27
|
+
*/
|
|
28
|
+
badge?: string | number;
|
|
29
|
+
/**
|
|
30
|
+
* Whether this item is active
|
|
31
|
+
*/
|
|
32
|
+
isActive?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Child navigation items
|
|
35
|
+
*/
|
|
36
|
+
children?: NavItem[];
|
|
37
|
+
/**
|
|
38
|
+
* Required roles to see this item
|
|
39
|
+
*/
|
|
40
|
+
roles?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Whether to open in new tab
|
|
43
|
+
*/
|
|
44
|
+
external?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Navigation section (group of items)
|
|
48
|
+
*/
|
|
49
|
+
interface NavSection {
|
|
50
|
+
/**
|
|
51
|
+
* Section title (optional)
|
|
52
|
+
*/
|
|
53
|
+
title?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Navigation items in this section
|
|
56
|
+
*/
|
|
57
|
+
items: NavItem[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Breadcrumb item
|
|
61
|
+
*/
|
|
62
|
+
interface BreadcrumbItem {
|
|
63
|
+
/**
|
|
64
|
+
* Display label
|
|
65
|
+
*/
|
|
66
|
+
label: string;
|
|
67
|
+
/**
|
|
68
|
+
* Navigation path (omit for current page)
|
|
69
|
+
*/
|
|
70
|
+
href?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Icon component
|
|
73
|
+
*/
|
|
74
|
+
icon?: ReactNode;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* User action in menu
|
|
78
|
+
*/
|
|
79
|
+
interface UserAction {
|
|
80
|
+
/**
|
|
81
|
+
* Unique identifier
|
|
82
|
+
*/
|
|
83
|
+
id: string;
|
|
84
|
+
/**
|
|
85
|
+
* Display label
|
|
86
|
+
*/
|
|
87
|
+
label: string;
|
|
88
|
+
/**
|
|
89
|
+
* Icon component
|
|
90
|
+
*/
|
|
91
|
+
icon?: ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* Action handler
|
|
94
|
+
*/
|
|
95
|
+
onClick?: () => void;
|
|
96
|
+
/**
|
|
97
|
+
* Navigation path (alternative to onClick)
|
|
98
|
+
*/
|
|
99
|
+
href?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Whether this is a destructive action
|
|
102
|
+
*/
|
|
103
|
+
destructive?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* App shell configuration
|
|
107
|
+
*/
|
|
108
|
+
interface AppShellConfig {
|
|
109
|
+
/**
|
|
110
|
+
* Application name
|
|
111
|
+
*/
|
|
112
|
+
appName: string;
|
|
113
|
+
/**
|
|
114
|
+
* Application logo (image URL or component)
|
|
115
|
+
*/
|
|
116
|
+
logo?: ReactNode;
|
|
117
|
+
/**
|
|
118
|
+
* Collapsed logo (for sidebar collapsed state)
|
|
119
|
+
*/
|
|
120
|
+
logoCollapsed?: ReactNode;
|
|
121
|
+
/**
|
|
122
|
+
* Navigation items for sidebar
|
|
123
|
+
*/
|
|
124
|
+
navigation?: NavSection[];
|
|
125
|
+
/**
|
|
126
|
+
* User menu actions
|
|
127
|
+
*/
|
|
128
|
+
userActions?: UserAction[];
|
|
129
|
+
/**
|
|
130
|
+
* Whether sidebar is collapsible
|
|
131
|
+
*/
|
|
132
|
+
sidebarCollapsible?: boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Default collapsed state
|
|
135
|
+
*/
|
|
136
|
+
defaultCollapsed?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Whether to show organization switcher
|
|
139
|
+
*/
|
|
140
|
+
showOrgSwitcher?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Breadcrumb items for the current page
|
|
143
|
+
*/
|
|
144
|
+
breadcrumbs?: BreadcrumbItem[];
|
|
145
|
+
/**
|
|
146
|
+
* Brand at the start of the bar (logo and wordmark). Default: none.
|
|
147
|
+
*/
|
|
148
|
+
brand?: ReactNode;
|
|
149
|
+
/**
|
|
150
|
+
* This application, as the product switcher shows it. When set, the bar
|
|
151
|
+
* shows the product switcher from the session's app catalog.
|
|
152
|
+
*/
|
|
153
|
+
app?: CatalogApp;
|
|
154
|
+
/**
|
|
155
|
+
* The current organization's ID, for the product switcher's roles and the
|
|
156
|
+
* organization switcher.
|
|
157
|
+
*/
|
|
158
|
+
organizationId?: string;
|
|
159
|
+
/**
|
|
160
|
+
* Called with the chosen organization's ID. When set, the bar shows the
|
|
161
|
+
* controlled OrganizationSwitcher instead of the TenantProvider-based
|
|
162
|
+
* OrgSwitcher.
|
|
163
|
+
*/
|
|
164
|
+
onOrganizationChange?: (organizationId: string) => void;
|
|
165
|
+
/**
|
|
166
|
+
* Client-side navigation between applications composed in one build.
|
|
167
|
+
* Without it, the product switcher links to each application's URL.
|
|
168
|
+
*/
|
|
169
|
+
onNavigateApp?: (url: string) => void;
|
|
170
|
+
/**
|
|
171
|
+
* After the switchers: a search or command bar.
|
|
172
|
+
*/
|
|
173
|
+
command?: ReactNode;
|
|
174
|
+
/**
|
|
175
|
+
* Before the profile menu: the application's own actions, such as
|
|
176
|
+
* notifications.
|
|
177
|
+
*/
|
|
178
|
+
actions?: ReactNode;
|
|
179
|
+
/**
|
|
180
|
+
* The application's own entries in the profile menu, above sign-out.
|
|
181
|
+
*/
|
|
182
|
+
profileItems?: UserAction[];
|
|
183
|
+
/**
|
|
184
|
+
* Show the light, dark and system theme toggle. Default false.
|
|
185
|
+
*/
|
|
186
|
+
showThemeToggle?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Custom navigation handler (for SPA routing)
|
|
189
|
+
*/
|
|
190
|
+
onNavigate?: (href: string) => void;
|
|
191
|
+
/**
|
|
192
|
+
* Callback when sidebar collapse state changes
|
|
193
|
+
*/
|
|
194
|
+
onCollapseChange?: (collapsed: boolean) => void;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* App shell props
|
|
198
|
+
*/
|
|
199
|
+
interface AppShellProps extends AppShellConfig {
|
|
200
|
+
children: ReactNode;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Sidebar props
|
|
204
|
+
*/
|
|
205
|
+
interface SidebarProps {
|
|
206
|
+
/**
|
|
207
|
+
* Navigation sections
|
|
208
|
+
*/
|
|
209
|
+
navigation: NavSection[];
|
|
210
|
+
/**
|
|
211
|
+
* Whether sidebar is collapsed
|
|
212
|
+
*/
|
|
213
|
+
isCollapsed: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Toggle collapsed state
|
|
216
|
+
*/
|
|
217
|
+
onToggleCollapse?: () => void;
|
|
218
|
+
/**
|
|
219
|
+
* Application logo
|
|
220
|
+
*/
|
|
221
|
+
logo?: ReactNode;
|
|
222
|
+
/**
|
|
223
|
+
* Collapsed logo
|
|
224
|
+
*/
|
|
225
|
+
logoCollapsed?: ReactNode;
|
|
226
|
+
/**
|
|
227
|
+
* Custom navigation handler
|
|
228
|
+
*/
|
|
229
|
+
onNavigate?: (href: string) => void;
|
|
230
|
+
/**
|
|
231
|
+
* Current path (for active state)
|
|
232
|
+
*/
|
|
233
|
+
currentPath?: string;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Navbar props
|
|
237
|
+
*/
|
|
238
|
+
interface NavbarProps {
|
|
239
|
+
/**
|
|
240
|
+
* Whether to show org switcher
|
|
241
|
+
*/
|
|
242
|
+
showOrgSwitcher?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* User menu actions
|
|
245
|
+
*/
|
|
246
|
+
userActions?: UserAction[];
|
|
247
|
+
/**
|
|
248
|
+
* Breadcrumb items
|
|
249
|
+
*/
|
|
250
|
+
breadcrumbs?: BreadcrumbItem[];
|
|
251
|
+
/**
|
|
252
|
+
* Toggle sidebar callback
|
|
253
|
+
*/
|
|
254
|
+
onToggleSidebar?: () => void;
|
|
255
|
+
/**
|
|
256
|
+
* Whether sidebar is visible (for mobile)
|
|
257
|
+
*/
|
|
258
|
+
sidebarVisible?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Brand at the start of the bar (logo and wordmark). Default: none.
|
|
261
|
+
*/
|
|
262
|
+
brand?: ReactNode;
|
|
263
|
+
/**
|
|
264
|
+
* This application, as the product switcher shows it. When set, the bar
|
|
265
|
+
* shows the product switcher from the session's app catalog.
|
|
266
|
+
*/
|
|
267
|
+
app?: CatalogApp;
|
|
268
|
+
/**
|
|
269
|
+
* The current organization's ID, for the product switcher's roles and the
|
|
270
|
+
* organization switcher.
|
|
271
|
+
*/
|
|
272
|
+
organizationId?: string;
|
|
273
|
+
/**
|
|
274
|
+
* Called with the chosen organization's ID. When set, the bar shows the
|
|
275
|
+
* controlled OrganizationSwitcher instead of the TenantProvider-based
|
|
276
|
+
* OrgSwitcher.
|
|
277
|
+
*/
|
|
278
|
+
onOrganizationChange?: (organizationId: string) => void;
|
|
279
|
+
/**
|
|
280
|
+
* Client-side navigation between applications composed in one build.
|
|
281
|
+
* Without it, the product switcher links to each application's URL.
|
|
282
|
+
*/
|
|
283
|
+
onNavigateApp?: (url: string) => void;
|
|
284
|
+
/**
|
|
285
|
+
* After the switchers: a search or command bar.
|
|
286
|
+
*/
|
|
287
|
+
command?: ReactNode;
|
|
288
|
+
/**
|
|
289
|
+
* Before the profile menu: the application's own actions, such as
|
|
290
|
+
* notifications.
|
|
291
|
+
*/
|
|
292
|
+
actions?: ReactNode;
|
|
293
|
+
/**
|
|
294
|
+
* The application's own entries in the profile menu, above sign-out.
|
|
295
|
+
*/
|
|
296
|
+
profileItems?: UserAction[];
|
|
297
|
+
/**
|
|
298
|
+
* Show the light, dark and system theme toggle. Default false.
|
|
299
|
+
*/
|
|
300
|
+
showThemeToggle?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Custom navigation handler
|
|
303
|
+
*/
|
|
304
|
+
onNavigate?: (href: string) => void;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Org switcher props
|
|
308
|
+
*/
|
|
309
|
+
interface OrgSwitcherProps {
|
|
310
|
+
/**
|
|
311
|
+
* Compact mode (icon only)
|
|
312
|
+
*/
|
|
313
|
+
compact?: boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Custom navigation handler
|
|
316
|
+
*/
|
|
317
|
+
onNavigate?: (href: string) => void;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* User menu props
|
|
321
|
+
*/
|
|
322
|
+
interface UserMenuProps {
|
|
323
|
+
/**
|
|
324
|
+
* Menu actions
|
|
325
|
+
*/
|
|
326
|
+
actions?: UserAction[];
|
|
327
|
+
/**
|
|
328
|
+
* Custom navigation handler
|
|
329
|
+
*/
|
|
330
|
+
onNavigate?: (href: string) => void;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Breadcrumbs props
|
|
334
|
+
*/
|
|
335
|
+
interface BreadcrumbsProps {
|
|
336
|
+
/**
|
|
337
|
+
* Breadcrumb items
|
|
338
|
+
*/
|
|
339
|
+
items: BreadcrumbItem[];
|
|
340
|
+
/**
|
|
341
|
+
* Custom navigation handler
|
|
342
|
+
*/
|
|
343
|
+
onNavigate?: (href: string) => void;
|
|
344
|
+
/**
|
|
345
|
+
* Separator character/element
|
|
346
|
+
*/
|
|
347
|
+
separator?: ReactNode;
|
|
348
|
+
/**
|
|
349
|
+
* Maximum items to show (rest collapsed)
|
|
350
|
+
*/
|
|
351
|
+
maxItems?: number;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Shell context value
|
|
355
|
+
*/
|
|
356
|
+
interface ShellContextValue {
|
|
357
|
+
/**
|
|
358
|
+
* Whether sidebar is collapsed
|
|
359
|
+
*/
|
|
360
|
+
sidebarCollapsed: boolean;
|
|
361
|
+
/**
|
|
362
|
+
* Toggle sidebar collapsed state
|
|
363
|
+
*/
|
|
364
|
+
toggleSidebar: () => void;
|
|
365
|
+
/**
|
|
366
|
+
* Set sidebar collapsed state
|
|
367
|
+
*/
|
|
368
|
+
setSidebarCollapsed: (collapsed: boolean) => void;
|
|
369
|
+
/**
|
|
370
|
+
* Whether sidebar is visible (mobile)
|
|
371
|
+
*/
|
|
372
|
+
sidebarVisible: boolean;
|
|
373
|
+
/**
|
|
374
|
+
* Toggle sidebar visibility (mobile)
|
|
375
|
+
*/
|
|
376
|
+
toggleSidebarVisible: () => void;
|
|
377
|
+
/**
|
|
378
|
+
* Current path
|
|
379
|
+
*/
|
|
380
|
+
currentPath: string;
|
|
381
|
+
/**
|
|
382
|
+
* Set current path
|
|
383
|
+
*/
|
|
384
|
+
setCurrentPath: (path: string) => void;
|
|
385
|
+
/**
|
|
386
|
+
* Navigate to path
|
|
387
|
+
*/
|
|
388
|
+
navigate: (href: string) => void;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* AppShell - Main application shell with sidebar, navbar, and content area
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```tsx
|
|
396
|
+
* <AppShell
|
|
397
|
+
* appName="My App"
|
|
398
|
+
* navigation={[
|
|
399
|
+
* {
|
|
400
|
+
* items: [
|
|
401
|
+
* { id: 'home', label: 'Home', href: '/', icon: <HomeIcon /> },
|
|
402
|
+
* { id: 'settings', label: 'Settings', href: '/settings', icon: <SettingsIcon /> },
|
|
403
|
+
* ],
|
|
404
|
+
* },
|
|
405
|
+
* ]}
|
|
406
|
+
* >
|
|
407
|
+
* <Dashboard />
|
|
408
|
+
* </AppShell>
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
declare function AppShell(props: AppShellProps): ReactNode;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* Shell provider props
|
|
415
|
+
*/
|
|
416
|
+
interface ShellProviderProps extends Partial<AppShellConfig> {
|
|
417
|
+
children: ReactNode;
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* ShellProvider - Provides shell state to components
|
|
421
|
+
*/
|
|
422
|
+
declare function ShellProvider({ children, defaultCollapsed, onNavigate, onCollapseChange, }: ShellProviderProps): react_jsx_runtime.JSX.Element;
|
|
423
|
+
/**
|
|
424
|
+
* Hook to access shell context
|
|
425
|
+
*
|
|
426
|
+
* @throws Error if used outside ShellProvider
|
|
427
|
+
*/
|
|
428
|
+
declare function useShell(): ShellContextValue;
|
|
429
|
+
/**
|
|
430
|
+
* Get shell context without throwing
|
|
431
|
+
*/
|
|
432
|
+
declare function useShellOptional(): ShellContextValue | null;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Sidebar - Main navigation sidebar
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```tsx
|
|
439
|
+
* <Sidebar
|
|
440
|
+
* navigation={[
|
|
441
|
+
* {
|
|
442
|
+
* items: [
|
|
443
|
+
* { id: 'home', label: 'Home', href: '/', icon: <HomeIcon /> },
|
|
444
|
+
* { id: 'settings', label: 'Settings', href: '/settings', icon: <SettingsIcon /> },
|
|
445
|
+
* ],
|
|
446
|
+
* },
|
|
447
|
+
* ]}
|
|
448
|
+
* isCollapsed={false}
|
|
449
|
+
* />
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
declare function Sidebar({ navigation, isCollapsed, onToggleCollapse, logo, logoCollapsed, onNavigate, currentPath, }: SidebarProps): ReactNode;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* Navbar - Top navigation bar
|
|
456
|
+
*
|
|
457
|
+
* From start to end: the brand, the product switcher, the organization
|
|
458
|
+
* switcher, the command slot, breadcrumbs, the actions slot and the
|
|
459
|
+
* profile menu. The shell owns the layout; slot content is the
|
|
460
|
+
* application's.
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* ```tsx
|
|
464
|
+
* <Navbar
|
|
465
|
+
* brand={<Logo />}
|
|
466
|
+
* app={{ id: 'reports', name: 'Reports', url: '/' }}
|
|
467
|
+
* organizationId={orgId}
|
|
468
|
+
* onOrganizationChange={(id) => navigate(`/orgs/${id}`)}
|
|
469
|
+
* command={<Search />}
|
|
470
|
+
* actions={<Notifications />}
|
|
471
|
+
* />
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
declare function Navbar({ showOrgSwitcher, userActions, breadcrumbs, onToggleSidebar, onNavigate, brand, app, organizationId, onOrganizationChange, onNavigateApp, command, actions, profileItems, showThemeToggle, }: NavbarProps): ReactNode;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* OrgSwitcher - Dropdown for switching between organizations
|
|
478
|
+
*
|
|
479
|
+
* @example
|
|
480
|
+
* ```tsx
|
|
481
|
+
* <OrgSwitcher />
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
declare function OrgSwitcher({ compact }: OrgSwitcherProps): ReactNode;
|
|
485
|
+
|
|
486
|
+
/** Props for {@link OrganizationSwitcher}. */
|
|
487
|
+
interface OrganizationSwitcherProps {
|
|
488
|
+
/** The current organization's ID. */
|
|
489
|
+
value?: string;
|
|
490
|
+
/** Called with the chosen organization's ID. The application decides where it goes, normally the URL. */
|
|
491
|
+
onChange: (organizationId: string) => void;
|
|
492
|
+
/** The memberships to list. Default: the session's. */
|
|
493
|
+
memberships?: SessionMembership[];
|
|
494
|
+
/** Show the switcher with a single membership. Default false. */
|
|
495
|
+
alwaysShow?: boolean;
|
|
496
|
+
className?: string;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* OrganizationSwitcher is a controlled organization picker keyed by
|
|
500
|
+
* organization ID. Unlike {@link OrgSwitcher}, it keeps no state: the
|
|
501
|
+
* application owns the current organization and is told when it changes.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```tsx
|
|
505
|
+
* <OrganizationSwitcher value={orgId} onChange={(id) => navigate(`/orgs/${id}`)} />
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
declare function OrganizationSwitcher({ value, onChange, memberships, alwaysShow, className, }: OrganizationSwitcherProps): ReactNode;
|
|
509
|
+
|
|
510
|
+
/** Props for {@link ProductSwitcher}. */
|
|
511
|
+
interface ProductSwitcherProps {
|
|
512
|
+
/** The application rendering the switcher. Always shown, first. */
|
|
513
|
+
self: CatalogApp;
|
|
514
|
+
/** The current organization's ID; roles are per organization. */
|
|
515
|
+
organizationId?: string;
|
|
516
|
+
/** The catalog. Default: the session's. */
|
|
517
|
+
apps?: CatalogApp[];
|
|
518
|
+
/**
|
|
519
|
+
* Client-side navigation, for applications composed in one build. Without
|
|
520
|
+
* it, entries are plain links to each application's URL.
|
|
521
|
+
*/
|
|
522
|
+
onNavigate?: (url: string) => void;
|
|
523
|
+
className?: string;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* ProductSwitcher lists the deployment's applications the person holds a
|
|
527
|
+
* role in for the current organization, from the session's app catalog.
|
|
528
|
+
*
|
|
529
|
+
* @example
|
|
530
|
+
* ```tsx
|
|
531
|
+
* <ProductSwitcher self={{ id: 'build', name: 'Build', url: '/' }} organizationId={orgId} />
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
declare function ProductSwitcher({ self, organizationId, apps, onNavigate, className, }: ProductSwitcherProps): ReactNode;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* The applications the product switcher shows: those in the catalog in
|
|
538
|
+
* which the member holds a role for the current organization, in catalog
|
|
539
|
+
* order, with the current application always present and first.
|
|
540
|
+
*
|
|
541
|
+
* With an empty catalog (for example in local development) it is the
|
|
542
|
+
* current application alone. Without a membership only the current
|
|
543
|
+
* application is shown, since a role is held per organization.
|
|
544
|
+
*/
|
|
545
|
+
declare function switcherApps(apps: CatalogApp[], self: CatalogApp, membership?: SessionMembership): CatalogApp[];
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* UserMenu - Dropdown menu for user actions
|
|
549
|
+
*
|
|
550
|
+
* @example
|
|
551
|
+
* ```tsx
|
|
552
|
+
* <UserMenu
|
|
553
|
+
* actions={[
|
|
554
|
+
* { id: 'profile', label: 'Profile', href: '/profile' },
|
|
555
|
+
* { id: 'logout', label: 'Logout', onClick: handleLogout, destructive: true },
|
|
556
|
+
* ]}
|
|
557
|
+
* />
|
|
558
|
+
* ```
|
|
559
|
+
*/
|
|
560
|
+
declare function UserMenu({ actions, onNavigate }: UserMenuProps): ReactNode;
|
|
561
|
+
|
|
562
|
+
/** Props for {@link ProfileMenu}. */
|
|
563
|
+
interface ProfileMenuProps {
|
|
564
|
+
/** This application's ID, to show the role held in it. */
|
|
565
|
+
appId?: string;
|
|
566
|
+
/** The current organization's ID. */
|
|
567
|
+
organizationId?: string;
|
|
568
|
+
/** The application's own entries, shown above sign-out. Default: none. */
|
|
569
|
+
items?: UserAction[];
|
|
570
|
+
/** Navigation for entries with an href, for SPA routing. */
|
|
571
|
+
onNavigate?: (href: string) => void;
|
|
572
|
+
/** Called when signing out fails. Default: logged to the console. */
|
|
573
|
+
onSignOutError?: (err: unknown) => void;
|
|
574
|
+
}
|
|
575
|
+
/** One or two initials from a name or email, for an avatar without an image. */
|
|
576
|
+
declare function initials(nameOrEmail: string | undefined): string;
|
|
577
|
+
/**
|
|
578
|
+
* ProfileMenu shows who is signed in, the current organization and the role
|
|
579
|
+
* held in this application, the application's own entries, and sign out. It
|
|
580
|
+
* reads the session from SessionProvider and renders nothing without a
|
|
581
|
+
* signed-in session.
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```tsx
|
|
585
|
+
* <ProfileMenu appId="reports" organizationId={orgId} items={[{ id: 'keys', label: 'API keys', href: '/keys' }]} />
|
|
586
|
+
* ```
|
|
587
|
+
*/
|
|
588
|
+
declare function ProfileMenu({ appId, organizationId, items, onNavigate, onSignOutError, }: ProfileMenuProps): ReactNode;
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* ThemeToggle cycles the theme through light, dark and the system's
|
|
592
|
+
* preference, and remembers the choice.
|
|
593
|
+
*/
|
|
594
|
+
declare function ThemeToggle(): ReactNode;
|
|
595
|
+
|
|
596
|
+
/** A theme choice. `system` follows the operating system's preference. */
|
|
597
|
+
type Theme = 'light' | 'dark' | 'system';
|
|
598
|
+
/** The key the theme choice is stored under. */
|
|
599
|
+
declare const THEME_STORAGE_KEY = "systemforge:theme";
|
|
600
|
+
/** Dispatched on window when the theme changes, so every toggle agrees. */
|
|
601
|
+
declare const THEME_CHANGE_EVENT = "systemforge:theme-change";
|
|
602
|
+
/** The stored theme, or `system` when none is stored or storage is unavailable. */
|
|
603
|
+
declare function readStoredTheme(): Theme;
|
|
604
|
+
/** The theme actually shown for a choice. */
|
|
605
|
+
declare function resolveTheme(theme: Theme, prefersDark?: boolean): 'light' | 'dark';
|
|
606
|
+
/**
|
|
607
|
+
* Applies a theme to the root element: the `dark` class the design system's
|
|
608
|
+
* styles key on, and `color-scheme` for native controls.
|
|
609
|
+
*/
|
|
610
|
+
declare function applyTheme(theme: Theme, root?: HTMLElement): void;
|
|
611
|
+
/**
|
|
612
|
+
* Applies the stored theme. Call it before the first render, so the page
|
|
613
|
+
* does not flash the other theme.
|
|
614
|
+
*/
|
|
615
|
+
declare function applyStoredTheme(): void;
|
|
616
|
+
/** The order the toggle cycles through. */
|
|
617
|
+
declare function nextTheme(theme: Theme): Theme;
|
|
618
|
+
/**
|
|
619
|
+
* The current theme choice and a setter. Setting it stores the choice,
|
|
620
|
+
* applies it to the root element and tells other instances. A `system`
|
|
621
|
+
* choice follows changes in the operating system's preference.
|
|
622
|
+
*/
|
|
623
|
+
declare function useTheme(): [Theme, (theme: Theme) => void];
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Breadcrumbs - Navigation breadcrumb trail
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```tsx
|
|
630
|
+
* <Breadcrumbs
|
|
631
|
+
* items={[
|
|
632
|
+
* { label: 'Home', href: '/' },
|
|
633
|
+
* { label: 'Settings', href: '/settings' },
|
|
634
|
+
* { label: 'Profile' },
|
|
635
|
+
* ]}
|
|
636
|
+
* />
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
declare function Breadcrumbs({ items, onNavigate, separator, maxItems, }: BreadcrumbsProps): ReactNode;
|
|
640
|
+
|
|
641
|
+
export { AppShell, type AppShellConfig, type AppShellProps, type BreadcrumbItem, Breadcrumbs, type BreadcrumbsProps, type NavItem, type NavSection, Navbar, type NavbarProps, OrgSwitcher, type OrgSwitcherProps, OrganizationSwitcher, type OrganizationSwitcherProps, ProductSwitcher, type ProductSwitcherProps, ProfileMenu, type ProfileMenuProps, type ShellContextValue, ShellProvider, Sidebar, type SidebarProps, THEME_CHANGE_EVENT, THEME_STORAGE_KEY, type Theme, ThemeToggle, type UserAction, UserMenu, type UserMenuProps, applyStoredTheme, applyTheme, initials, nextTheme, readStoredTheme, resolveTheme, switcherApps, useShell, useShellOptional, useTheme };
|