190 lines
4.4 KiB
TypeScript
190 lines
4.4 KiB
TypeScript
|
|
import type { TemplateResult } from '@design.estate/dees-element';
|
||
|
|
import type { IAppBarMenuItem } from './appbarmenuitem.js';
|
||
|
|
import type { ITab } from './tab.js';
|
||
|
|
import type { ISecondaryMenuGroup } from './secondarymenu.js';
|
||
|
|
|
||
|
|
/**
|
||
|
|
* User configuration for the app bar
|
||
|
|
*/
|
||
|
|
export interface IAppUser {
|
||
|
|
name: string;
|
||
|
|
email?: string;
|
||
|
|
avatar?: string;
|
||
|
|
status?: 'online' | 'offline' | 'busy' | 'away';
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* View definition for the view registry
|
||
|
|
*/
|
||
|
|
export interface IViewDefinition {
|
||
|
|
/** Unique identifier for routing */
|
||
|
|
id: string;
|
||
|
|
/** Display name */
|
||
|
|
name: string;
|
||
|
|
/** Optional icon */
|
||
|
|
iconName?: string;
|
||
|
|
/** The view content - can be a tag name, element class, or template function */
|
||
|
|
content: string | (new () => HTMLElement) | (() => TemplateResult);
|
||
|
|
/** Secondary menu items specific to this view */
|
||
|
|
secondaryMenu?: ISecondaryMenuGroup[];
|
||
|
|
/** Content tabs specific to this view */
|
||
|
|
contentTabs?: ITab[];
|
||
|
|
/** Optional route path (defaults to id) */
|
||
|
|
route?: string;
|
||
|
|
/** Badge to show on menu item */
|
||
|
|
badge?: string | number;
|
||
|
|
badgeVariant?: 'default' | 'success' | 'warning' | 'error';
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Main menu section with view references
|
||
|
|
*/
|
||
|
|
export interface IMainMenuSection {
|
||
|
|
/** Section name (optional for ungrouped) */
|
||
|
|
name?: string;
|
||
|
|
/** Views in this section (by ID reference) */
|
||
|
|
views: string[];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Main menu configuration
|
||
|
|
*/
|
||
|
|
export interface IMainMenuConfig {
|
||
|
|
/** Menu sections with view references */
|
||
|
|
sections?: IMainMenuSection[];
|
||
|
|
/** Bottom pinned items (view IDs) */
|
||
|
|
bottomItems?: string[];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* App bar configuration
|
||
|
|
*/
|
||
|
|
export interface IAppBarConfig {
|
||
|
|
menuItems?: IAppBarMenuItem[];
|
||
|
|
breadcrumbs?: string;
|
||
|
|
breadcrumbSeparator?: string;
|
||
|
|
showWindowControls?: boolean;
|
||
|
|
showSearch?: boolean;
|
||
|
|
user?: IAppUser;
|
||
|
|
profileMenuItems?: IAppBarMenuItem[];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Branding configuration
|
||
|
|
*/
|
||
|
|
export interface IBrandingConfig {
|
||
|
|
logoIcon?: string;
|
||
|
|
logoText?: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Routing configuration
|
||
|
|
*/
|
||
|
|
export interface IRoutingConfig {
|
||
|
|
/** Routing mode */
|
||
|
|
mode: 'hash' | 'history' | 'external' | 'none';
|
||
|
|
/** Base path for history mode */
|
||
|
|
basePath?: string;
|
||
|
|
/** Default view ID to show on startup */
|
||
|
|
defaultView?: string;
|
||
|
|
/** Sync URL on view change */
|
||
|
|
syncUrl?: boolean;
|
||
|
|
/** Handle 404s - show view ID or callback */
|
||
|
|
notFound?: string | (() => void);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* State persistence configuration
|
||
|
|
*/
|
||
|
|
export interface IStatePersistenceConfig {
|
||
|
|
/** Enable state persistence */
|
||
|
|
enabled: boolean;
|
||
|
|
/** Storage key prefix */
|
||
|
|
storageKey?: string;
|
||
|
|
/** Storage type */
|
||
|
|
storage?: 'localStorage' | 'sessionStorage' | 'memory';
|
||
|
|
/** What to persist */
|
||
|
|
persist?: {
|
||
|
|
mainMenuCollapsed?: boolean;
|
||
|
|
secondaryMenuCollapsed?: boolean;
|
||
|
|
selectedView?: boolean;
|
||
|
|
secondaryMenuSelection?: boolean;
|
||
|
|
collapsedGroups?: boolean;
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Activity log configuration
|
||
|
|
*/
|
||
|
|
export interface IActivityLogConfig {
|
||
|
|
enabled?: boolean;
|
||
|
|
width?: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Main unified configuration interface for dees-appui-base
|
||
|
|
*/
|
||
|
|
export interface IAppConfig {
|
||
|
|
/** Application branding */
|
||
|
|
branding?: IBrandingConfig;
|
||
|
|
|
||
|
|
/** App bar configuration */
|
||
|
|
appBar?: IAppBarConfig;
|
||
|
|
|
||
|
|
/** View definitions (the registry) */
|
||
|
|
views: IViewDefinition[];
|
||
|
|
|
||
|
|
/** Main menu structure */
|
||
|
|
mainMenu?: IMainMenuConfig;
|
||
|
|
|
||
|
|
/** Routing configuration */
|
||
|
|
routing?: IRoutingConfig;
|
||
|
|
|
||
|
|
/** State persistence configuration */
|
||
|
|
statePersistence?: IStatePersistenceConfig;
|
||
|
|
|
||
|
|
/** Activity log configuration */
|
||
|
|
activityLog?: IActivityLogConfig;
|
||
|
|
|
||
|
|
/** Event callbacks (optional shorthand) */
|
||
|
|
onViewChange?: (viewId: string, view: IViewDefinition) => void;
|
||
|
|
onSearch?: () => void;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Serialized UI state for persistence
|
||
|
|
*/
|
||
|
|
export interface IAppUIState {
|
||
|
|
/** Current view ID */
|
||
|
|
currentViewId?: string;
|
||
|
|
/** Main menu collapsed state */
|
||
|
|
mainMenuCollapsed?: boolean;
|
||
|
|
/** Secondary menu collapsed state */
|
||
|
|
secondaryMenuCollapsed?: boolean;
|
||
|
|
/** Selected secondary menu item key */
|
||
|
|
secondaryMenuSelectedKey?: string;
|
||
|
|
/** Collapsed group names in secondary menu */
|
||
|
|
collapsedGroups?: string[];
|
||
|
|
/** Timestamp of last save */
|
||
|
|
timestamp?: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Route change event detail
|
||
|
|
*/
|
||
|
|
export interface IRouteChangeEvent {
|
||
|
|
viewId: string;
|
||
|
|
previousViewId: string | null;
|
||
|
|
params?: Record<string, string>;
|
||
|
|
source: 'navigation' | 'popstate' | 'initial' | 'programmatic';
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* View change event detail
|
||
|
|
*/
|
||
|
|
export interface IViewChangeEvent {
|
||
|
|
viewId: string;
|
||
|
|
view: IViewDefinition;
|
||
|
|
previousView?: IViewDefinition;
|
||
|
|
}
|