export { D as DomSwapManager } from './DomSwapManager-CBjWYRG4.cjs'; import { SwapStrategyInterface } from './contracts.cjs'; import { CRUDPageType, SwapContext } from './types.cjs'; import '@wlindabla/event_dispatcher/browser'; import '@wlindabla/http_client'; import '@wlindabla/event_dispatcher'; import '@wlindabla/form_validator/utils'; /** * @wlindabla/sonata_spa — ListSwapStrategy * Surgical DOM swap strategy for Sonata list pages. * Handles filters, data table, filter actions and CRUD action buttons. * @author AGBOKOUDJO Franck */ /** * Surgical DOM swap strategy for Sonata list pages (crud:list). * * Instead of replacing the entire page, this strategy replaces * only the parts that actually changed: * * 1. Filter actions → ul[id^="filter-list-"] in content-header navbar * 2. Filters box → .sonata-filters-box in content area * 3. Data table → .list-table-container row in content area * 4. Sonata actions → ul[id^="container-sonata-actions"] in content-header * * For each element, handles all 3 cases: * - newEl exists + currentEl exists → replaceWith() * - newEl exists + currentEl absent → append to container * - newEl absent + currentEl exists → remove() * * Sonata list page HTML structure (AdminLTE 4 + Bootstrap 5): * ```html *
* *
*
*
*
...
← filters box *
*
*
*
...
← data table *
*
*
* ``` * @author AGBOKOUDJO Franck */ declare class ListSwapStrategy implements SwapStrategyInterface { supports(pageType: CRUDPageType): boolean; swap(context: SwapContext): void; /** * Swap the filter action buttons in the content header navbar. * These are the buttons that show/hide the filters box. * Selector: ul[id^="filter-list-"] */ private swapFilterActions; /** * Swap the Sonata CRUD action buttons (Add new, Export, etc.) * in the content header navbar. * Selector: ul[id^="container-sonata-actions"] */ private swapSonataActions; /** * Swap the filters box (search/filter form). * Selector: configurable via filtersBoxSelector option, * defaults to '.sonata-filters-box' */ private swapFiltersBox; /** * Swap the list data table. * Selector: configurable via listDataTableContainerSelector option, * defaults to '.col-xs-12.col-md-12:has(.list-table-container)' * * Sonata wraps the table in: * ```html *
*
← this is what we swap *
* ...
*
*
*
* ``` */ private swapListTable; } /** * @wlindabla/sonata_spa — ShowSwapStrategy * Full page swap strategy for Sonata show and dashboard pages. * Replaces the entire #app-main container content. * @author AGBOKOUDJO Franck */ /** * Full page swap strategy for show and dashboard pages. * * Unlike ListSwapStrategy which performs surgical swaps, * this strategy replaces the entire #app-main container content. * * Why a full swap for show pages? * Show pages have a completely different layout — they display * detail panels, related entities, action buttons — all different * from the list layout. A surgical swap would be too complex * and fragile. A full #app-main swap is simpler and more reliable. * * Why a full swap for dashboard? * The dashboard has a completely unique layout with widgets, * charts and statistics — nothing in common with CRUD pages. * * Process: * 1. Parse the virtualDoc (already done by PageFetcher) * 2. Find #app-main in the virtual document * 3. Replace the live #app-main innerHTML with the virtual one * 4. Update DOM references (mainContentArea, mainContentHeader) * so subsequent operations target the new elements * @author AGBOKOUDJO Franck */ declare class ShowSwapStrategy implements SwapStrategyInterface { supports(pageType: CRUDPageType): boolean; swap(context: SwapContext): void; /** * Fallback generic content swap when #app-main is not found * in the virtual document. * Swaps known Sonata content selectors individually. */ private swapGenericContent; } /** * @wlindabla/sonata_spa — FormSwapStrategy * DOM swap strategy for Sonata form pages (create/edit). * Swaps only the .sonata-ba-form container. * Used to display server-side validation errors without full page reload. * @author AGBOKOUDJO Franck */ /** * DOM swap strategy for Sonata form pages. * * This strategy is used in two scenarios: * * 1. Server-side validation errors * When Sonata returns the form with errors (HTTP 200 + form HTML), * we swap only .sonata-ba-form to display the errors inline * without reloading the entire page. * * 2. Create/Edit pages loaded via SPA (if developer removes them from serverManaged) * By default, create and edit are server-managed (full reload). * But if the developer removes them from serverManagedUrlOptions, * this strategy handles the DOM swap. * * What gets swapped: * - .sonata-ba-form → the main form container * - .sonata-ba-preview → preview section (if present) * * What is NOT swapped (preserved): * - #app-content-header → content header with breadcrumbs/actions * - .sonata-ba-filter → filter box (not present on form pages) * - sidebar → never touched * * Sonata form page HTML structure: * ```html *
* {% if _preview is not empty %} *
{{ _preview|raw }}
* {% endif %} * {% if _form is not empty %} *
*
...
*
* {% endif %} *
* ``` * @author AGBOKOUDJO Franck */ declare class FormSwapStrategy implements SwapStrategyInterface { supports(pageType: CRUDPageType): boolean; swap(context: SwapContext): void; /** * Swap the main form container .sonata-ba-form. * This is the primary target — contains the Symfony form with all fields. */ private swapFormContainer; /** * Swap the preview container .sonata-ba-preview. * Present when Sonata has a preview section before the form. */ private swapPreviewContainer; /** * Swap the Sonata action buttons in the content header. * On form pages these typically contain Back, Delete buttons. * Selector: ul[id^="container-sonata-actions"] */ private swapSonataActions; } /** * @wlindabla/sonata_spa — GenericSwapStrategy * Fallback DOM swap strategy for unknown or custom Sonata page types. * Iterates over known Sonata CSS selectors and swaps each one individually. * @author AGBOKOUDJO Franck */ /** * Default fallback swap strategy. * Used when no other strategy matches the current page type. * * Iterates over a list of known Sonata content selectors and * performs a surgical swap for each one found in the virtual document. * * Default selectors (in order): * 1. .sonata-ba-form → create/edit form * 2. .sonata-ba-show → show detail panel * 3. .sonata-ba-content → generic content block * 4. .sonata-ba-preview → preview section * * The developer can extend the selector list via SpaRouterOptions.genericSelectors. * * This strategy supports ALL page types — it is always the last * resort when DomSwapManager finds no matching strategy. * @author AGBOKOUDJO Franck */ declare class GenericSwapStrategy implements SwapStrategyInterface { /** * Default Sonata content selectors to swap. * Order matters — more specific selectors first. */ private static readonly DEFAULT_SELECTORS; private readonly selectors; /** * @param customSelectors - Additional selectors from SpaRouterOptions.genericSelectors. * These are merged with the default selectors. */ constructor(customSelectors?: string[]); /** * GenericSwapStrategy supports all page types. * It is always the last fallback in DomSwapManager. */ supports(_pageType: CRUDPageType): boolean; swap(context: SwapContext): void; /** * Swap a single element by CSS selector. * Handles all 3 cases: replace, add, remove. * * @param selector - CSS selector to find the element * @param virtualDoc - The parsed virtual document from server response * @param mainContentArea - The live content area to swap within */ private swapElement; /** * Get the currently active selectors. * Useful for debugging. */ getSelectors(): string[]; } export { FormSwapStrategy, GenericSwapStrategy, ListSwapStrategy, ShowSwapStrategy };