feat(dees-appui-base): Add unified App UI API to dees-appui-base with ViewRegistry, AppRouter and StateManager
This commit is contained in:
122
readme.hints.md
122
readme.hints.md
@@ -680,4 +680,124 @@ According to Lit's documentation (https://lit.dev/docs/components/decorators/#de
|
||||
- All unit tests passing
|
||||
- Manual testing of key components verified
|
||||
- No regressions detected
|
||||
- Focus management and interactions working correctly
|
||||
- Focus management and interactions working correctly
|
||||
|
||||
## Enhanced AppUI API (2025-12-08)
|
||||
|
||||
The `dees-appui-base` component has been enhanced with a unified configuration API for building real-world applications.
|
||||
|
||||
### New Modules:
|
||||
|
||||
1. **ViewRegistry** (`view.registry.ts`)
|
||||
- Manages view definitions and their lifecycle
|
||||
- Supports tag names, element classes, and template functions as view content
|
||||
- Methods: register, get, renderView, findByRoute
|
||||
|
||||
2. **AppRouter** (`app.router.ts`)
|
||||
- Built-in routing with hash or history mode
|
||||
- External router support for framework integration
|
||||
- Methods: navigate, back, forward, onRouteChange
|
||||
|
||||
3. **StateManager** (`state.manager.ts`)
|
||||
- Persists UI state (collapsed menus, selections, current view)
|
||||
- Supports localStorage, sessionStorage, or memory storage
|
||||
- Methods: save, load, update, clear
|
||||
|
||||
### New Interfaces (in `interfaces/appconfig.ts`):
|
||||
|
||||
```typescript
|
||||
interface IAppConfig {
|
||||
branding?: { logoIcon?: string; logoText?: string };
|
||||
appBar?: IAppBarConfig;
|
||||
views: IViewDefinition[];
|
||||
mainMenu?: IMainMenuConfig;
|
||||
routing?: IRoutingConfig;
|
||||
statePersistence?: IStatePersistenceConfig;
|
||||
onViewChange?: (viewId: string, view: IViewDefinition) => void;
|
||||
}
|
||||
|
||||
interface IViewDefinition {
|
||||
id: string;
|
||||
name: string;
|
||||
iconName?: string;
|
||||
content: string | (new () => HTMLElement) | (() => TemplateResult);
|
||||
secondaryMenu?: ISecondaryMenuGroup[];
|
||||
contentTabs?: ITab[];
|
||||
route?: string;
|
||||
}
|
||||
|
||||
interface IRoutingConfig {
|
||||
mode: 'hash' | 'history' | 'external' | 'none';
|
||||
basePath?: string;
|
||||
defaultView?: string;
|
||||
syncUrl?: boolean;
|
||||
}
|
||||
```
|
||||
|
||||
### New Public Methods on DeesAppuiBase:
|
||||
|
||||
```typescript
|
||||
// Configure with unified config
|
||||
configure(config: IAppConfig): void
|
||||
|
||||
// Navigation
|
||||
navigateToView(viewId: string): boolean
|
||||
getCurrentView(): IViewDefinition | undefined
|
||||
|
||||
// State management
|
||||
getUIState(): IAppUIState
|
||||
restoreUIState(state: IAppUIState): void
|
||||
saveState(): void
|
||||
loadState(): boolean
|
||||
|
||||
// Access internals
|
||||
getViewRegistry(): ViewRegistry
|
||||
getRouter(): AppRouter | null
|
||||
```
|
||||
|
||||
### Usage Example (New Unified Config API):
|
||||
|
||||
```typescript
|
||||
import type { IAppConfig } from '@design.estate/dees-catalog';
|
||||
|
||||
const config: IAppConfig = {
|
||||
branding: { logoIcon: 'lucide:box', logoText: 'My App' },
|
||||
views: [
|
||||
{ id: 'dashboard', name: 'Dashboard', iconName: 'lucide:home', content: 'my-dashboard' },
|
||||
{ id: 'settings', name: 'Settings', iconName: 'lucide:settings', content: 'my-settings' },
|
||||
],
|
||||
mainMenu: {
|
||||
sections: [{ views: ['dashboard'] }],
|
||||
bottomItems: ['settings'],
|
||||
},
|
||||
routing: { mode: 'hash', defaultView: 'dashboard' },
|
||||
statePersistence: { enabled: true, storage: 'localStorage' },
|
||||
};
|
||||
|
||||
html`<dees-appui-base .config=${config}></dees-appui-base>`;
|
||||
```
|
||||
|
||||
### Backward Compatibility:
|
||||
|
||||
The existing property-based API still works:
|
||||
|
||||
```typescript
|
||||
html`
|
||||
<dees-appui-base
|
||||
.mainmenuGroups=${groups}
|
||||
.secondarymenuGroups=${secondaryGroups}
|
||||
@mainmenu-tab-select=${handler}
|
||||
>
|
||||
<div slot="maincontent">...</div>
|
||||
</dees-appui-base>
|
||||
`;
|
||||
```
|
||||
|
||||
### Key Features:
|
||||
|
||||
- **Declarative View Registry**: Map menu items to view components
|
||||
- **Built-in Routing**: Hash or history mode with URL synchronization
|
||||
- **External Router Support**: Integrate with Angular Router or other frameworks
|
||||
- **State Persistence**: Save/restore collapsed menus, selections, and current view
|
||||
- **View-specific Menus**: Each view can define its own secondary menu and tabs
|
||||
- **Full Backward Compatibility**: Existing code continues to work
|
||||
Reference in New Issue
Block a user