import { LitElement, CSSResultGroup, TemplateResult, PropertyValues } from 'lit'; import { ButtonData } from '@progressive-development/pd-forms'; import { AppConfiguration, Footer, NavigationPage } from '../../service-provider/service-provider-model.js'; import { LoadingState } from '@progressive-development/pd-content'; import { PdActionEventDetail } from './spa-events.js'; import { ScrollController } from './controllers/ScrollController.js'; /** * Initialize the SPA framework. * * This function must be called before using PdSpaHelper components. * It sets up: * - Service provider (Firebase or Mock) * - Redux store * - Router with configured routes * * @param config - The application configuration * * @example * ```typescript * startInit({ * serviceProvider: "firebase", * firebaseConfig: { ... }, * navigationConfigParam: { * pages: [...], * includeLogin: true, * }, * storeConfigParam: { * appName: "My App", * reducer: [...], * effects: [...], * }, * }); * ``` */ export declare const startInit: (config: AppConfiguration) => void; /** * Abstract base class for SPA applications. * * Extend this class to create your main application component. * Override the abstract methods to customize the layout and content. * * Required abstract methods: * - `_renderRoutePages(route)` - Render content for given route * - `_getFooter()` - Return footer configuration * - `_getAppLogo()` - Return app logo template * - `_setLocale()` - Handle locale changes * - `_getAppConfiguration()` - Return app-specific config */ export declare abstract class PdSpaHelper extends LitElement { /** Controller for scroll threshold detection (teaser collapse) */ protected scrollController: ScrollController; title: string; /** Scroll threshold in pixels for teaser collapse. Default: 100px */ teaserCollapseThreshold: number; /** Current loading states */ protected _loadingState: LoadingState[]; /** Current route name */ protected _route: string; /** * Current path (`/wahlen/kw2025/rat`) — what the address bar shows. * * Kept next to the route NAME because the two answer different questions: * the name selects the page component, the path says where the user is. The * menu needs the latter — its items carry paths (`MenuElement.route`), and * only a path can tell that `/wahlen/kw2025/rat` lies below `/wahlen`. */ protected _path: string; /** Route parameters */ protected _params: Record; /** Query parameters */ protected _query: Record; /** Whether the teaser is collapsed (scrolled past threshold) */ protected teaserCollapsed: boolean; /** * Skip teaser transition during navigate-and-scroll. * Prevents the "teaser appears then collapses" visual glitch. */ private _skipTeaserTransition; /** Pending section ID for navigate-and-scroll (stored until the target page registers its sections) */ private _pendingScrollSectionId; /** Currently selected locale - must be implemented by subclass */ abstract _selectedLocale: string; private _claims; /** Available locales with display text and value - must be implemented by subclass */ abstract _availableLocales: ButtonData[]; /** Whether to show locale selector in single menu only */ protected _singleLocaleMenu: boolean; /** Store subscription for cleanup */ private _subscription?; /** Track previous auth state to detect real transitions (not initial load) */ private _previousAuthState; /** * Per-page map of section ID → DOM element. * Single source of truth for section-scroll navigation; populated when a * page dispatches pd-spa:register-sections and cleared on route leave. */ private _sectionRegistry; /** Map of section IDs to action creator functions (fired once per session on section activation) */ private _sectionActions; static styles: CSSResultGroup; constructor(); connectedCallback(): void; disconnectedCallback(): void; protected willUpdate(changedProps: PropertyValues): void; render(): TemplateResult; /** * Render the loading state while route is being resolved * Can be overridden by subclass */ protected _renderLoading(): TemplateResult; /** * Render the main layout * Can be overridden by subclass for custom layouts */ protected _renderLayout(pageConf: NavigationPage, showTeaser: boolean): TemplateResult; /** * Render the built-in service-worker update dialog (pd-update-prompt). * Texts and behaviour come from `startInit({ pwaUpdateConfigParam })`; * `enabled: false` hides it. Override for a fully custom update UI (own * i18n, own dialog) — the pwaUpdateService keeps running either way. In * apps without a service worker the prompt never shows. */ protected _renderUpdatePrompt(): TemplateResult; /** * Hook for app-global overlays rendered on every route, outside the * page content — e.g. a consent banner or global dialog. Rendered at the * end of the layout (after the toast). Default: empty. * * @example * ```typescript * protected override _renderOverlays(): TemplateResult { * return html``; * } * ``` */ protected _renderOverlays(): TemplateResult; /** * Render the login modal popup. * * Contract: mounten = offen — das Popup wird routen-gesteuert * konditional gerendert und öffnet über startOpen sofort; geschlossen * wird über popup-close (ESC → Navigation zurück) bzw. Unmount beim * Routenwechsel. */ private _renderLoginModal; /** * Handle login popup close (user aborted login via Escape or backdrop click) */ private _handleLoginPopupClose; protected _renderSiteHeader(pageConf: NavigationPage, showTeaser: boolean): TemplateResult; private _getVisibleMenuItems; private _getVisibleTopMenuItems; protected _renderFooter(): TemplateResult; /** * Render slot content for pd-footer (slots `logo` and `extra`), e.g. a * brand block with logo, company name and address. Default: empty. * Override in subclass — the returned template must use `slot="logo"` * and/or `slot="extra"` on its root elements. Same pattern as * `_renderTeaserSlotContent()`. * * @example * ```typescript * protected override _renderFooterSlotContent(): TemplateResult { * return html`
ACME GmbH
`; * } * ``` */ protected _renderFooterSlotContent(): TemplateResult; /** * Render the content for the given route * @param route - The route to render (may differ from _route for modal scenarios) */ protected abstract _renderRoutePages(route: string): TemplateResult; /** * Get the footer configuration */ protected abstract _getFooter(): Footer; /** * Get the app logo template */ protected abstract _getAppLogo(): TemplateResult; /** * Set the locale */ protected abstract _setLocale(locale: string): void; /** * Get app-specific configuration */ protected abstract _getAppConfiguration(): unknown; /** * Whether the app has teaser content. Default: false. * Override in subclass to enable teaser rendering. * Used together with pageConf.withTeaser to determine if the teaser is shown. */ protected _hasTeaserContent(): boolean; /** * Render teaser slot content for pd-site-header. * Override in subclass (or intermediate layer like PdVisitcardApp) * to provide teaser content. The returned template must include * `slot="teaser-content"` on its root element. * * @example * ```typescript * protected override _renderTeaserSlotContent(): TemplateResult { * return html``; * } * ``` */ protected _renderTeaserSlotContent(): TemplateResult; private _handleRouteEvent; private _handleFooterLink; /** * Handle pd-action events dispatched by scoped interceptors on data-pd-action elements. * Handles generic actions (route, section). Override in subclass for app-specific * actions (e.g., "wizard"). * * Unknown actions are silently ignored. * "url" actions are handled natively by the browser via href — no handler needed. */ protected _handlePdAction(e: CustomEvent): void; /** * Scroll to a section by its ID on the current page. O(1) registry lookup; * works for any registered section regardless of menu membership. * * Cross-page navigate-and-scroll uses `route-event` with `{ route, sectionId }` * (same mechanism pd-menu uses) — `_pendingScrollSectionId` is applied once * the target page dispatches pd-spa:register-sections. */ protected _navigateToSection(sectionId: string): void; private _handleRegisterSections; /** * Handle section-activated event from pd-menu. * Dispatches the registered action for a section (once per session). */ private _handleThemeChanged; private _handleSectionActivated; private _handleLocaleChange; private _handleAppConfigEvent; private _activateLoginHandler; private _getMainClass; private _handleHeaderHeightChange; private _navigateToPage; /** * Scroll to a section element. Collapses teaser if expanded. */ private _scrollToSection; } //# sourceMappingURL=PdSpaHelper.d.ts.map