import { EventSubscriberInterface, EventDispatcherInterface } from '@wlindabla/event_dispatcher'; import { SpaDeleteConfirmRequestedEvent, SpaDeleteProcessingEvent, SpaDeleteSucceededEvent, SpaDeleteFailedEvent, SpaBatchConfirmRequestedEvent, SpaBatchProcessingEvent, SpaBatchSucceededEvent, SpaBatchFailedEvent } from './events.cjs'; import { SpaSubscriberInterface, PageFetcherInterface, DomSwapManagerInterface, HistoryManagerInterface } from './contracts.cjs'; import { SpaRouterOptions, SpaRequest, SpaResponse, RouteMatch } from './types.cjs'; /** * Default delete confirmation subscriber using SweetAlert2. * Registered automatically by SpaKernel. * * To replace with your own UI, register a listener with higher priority: * ```typescript * dispatcher.addListener(SpaEvents.DELETE_CONFIRM_REQUESTED, async (event) => { * event.stopPropagation(); // prevents this default subscriber from running * // your custom confirmation UI * }, 10); // priority > 0 * ``` */ declare class DefaultDeletionOperationSubscriber implements SpaSubscriberInterface { getSubscribedEvents(): ReturnType; onDeleteConfirmRequested(event: SpaDeleteConfirmRequestedEvent): Promise; onDeleteProcessing(event: SpaDeleteProcessingEvent): void; onDeleteSucceeded(event: SpaDeleteSucceededEvent): void; onDeleteFailed(event: SpaDeleteFailedEvent): void; } /** * @wlindabla/sonata_spa — DefaultBatchSubscriber * Default UI handler for all batch lifecycle events. * Uses SweetAlert2 for confirmation and @wlindabla/form_validator dialog helpers * for processing, success and error feedback. * * Developers can override any handler by registering a listener with a higher * priority on the same event and calling event.stopPropagation() if needed. * * @author AGBOKOUDJO Franck */ /** * Default subscriber that handles all batch UI lifecycle events. * * Subscribed events and their default behavior: * * | Event | Priority | Behavior | * |------------------------------|----------|-----------------------------------------------| * | BATCH_CONFIRM_REQUESTED | 0 | SweetAlert2 confirmation modal | * | BATCH_PROCESSING | 0 | showLoadingDialog — spinner while POSTing | * | BATCH_SUCCEEDED | 0 | showSuccessDialog — success feedback | * | BATCH_FAILED | 0 | showErrorDialog — error feedback | * * To replace any handler, register your own listener with `priority > 0`. * To fully suppress the default, call `event.stopPropagation()` in your listener * (only works on stoppable events). */ declare class DefaultBatchSubscriber implements SpaSubscriberInterface { getSubscribedEvents(): ReturnType; /** * Show a SweetAlert2 confirmation modal when a batch action is requested. * * Reads title, message and button text from the Sonata confirmation page data. * Calls {@link SpaBatchConfirmRequestedEvent.accept} or * {@link SpaBatchConfirmRequestedEvent.cancel} based on the user's choice. * * @param event - The batch confirm requested event carrying the confirmation data */ onBatchConfirmRequested(event: SpaBatchConfirmRequestedEvent): Promise; /** * Show a loading dialog while the batch POST request is in progress. * * Triggered immediately after the user confirms, before the HTTP request * is sent. The dialog blocks user interaction to prevent double submission. * * Uses {@link showLoadingDialog} from @wlindabla/form_validator which * displays a spinner consistent with the form submission feedback style. * * @param event - The batch processing event carrying the title and message */ onBatchProcessing(event: SpaBatchProcessingEvent): void; /** * Show a success dialog when the batch action completes successfully. * * Triggered after a 2xx response is received from the server. * The dialog auto-closes after a short delay — the navigation to the * list page is handled by {@link BatchPageSubscriber} with a 3-second timer, * giving this dialog time to display before the transition. * * Uses {@link showSuccessDialog} from @wlindabla/form_validator. * * @param event - The batch succeeded event carrying the resolved title and message */ onBatchSucceeded(event: SpaBatchSucceededEvent): void; /** * Show an error dialog when the batch action fails (4xx–599 from server). * * Triggered when the server returns an HTTP error status. The status code * and status text are forwarded directly from the HTTP response — even when * the server returns a minimal error body, the HTTP layer always carries * a meaningful status (e.g. 403 "Forbidden", 500 "Internal Server Error"). * * Uses {@link showErrorDialog} from @wlindabla/form_validator. * * @param event - The batch failed event carrying the HTTP status code and text */ onBatchFailed(event: SpaBatchFailedEvent): void; } /** * @wlindabla/sonata_spa — AbstractCRUDPageSubscriber * @author AGBOKOUDJO Franck */ /** * @author AGBOKOUDJO Franck */ declare abstract class AbstractCRUDPageSubscriber { protected readonly fetcher: PageFetcherInterface; protected readonly swapManager: DomSwapManagerInterface; private mainContainer; private readonly options; /** Mutable references — updated after each full page swap */ protected mainContentArea: HTMLElement; protected mainContentHeader: HTMLElement | null; protected constructor(fetcher: PageFetcherInterface, swapManager: DomSwapManagerInterface, mainContainer: HTMLElement, mainContentArea: HTMLElement, mainContentHeader: HTMLElement | null, options: SpaRouterOptions); protected finalizeNavigation(request: SpaRequest, spaResponse: SpaResponse, routeMatch: RouteMatch, historyManager: HistoryManagerInterface, dispatcher: EventDispatcherInterface, _updateDomReferences?: boolean): void; /** * Re-query DOM references after a full page swap. * ShowSwapStrategy replaces #app-main.innerHTML so the previous * references to mainContentArea and mainContentHeader are stale. * Also updates the PageFetcher loading targets. */ protected updateDomReferences(): void; } export { AbstractCRUDPageSubscriber as A, DefaultBatchSubscriber as D, DefaultDeletionOperationSubscriber as a };