import type { IRouterSlot, Params } from '../router-slot/index.js'; import type { UmbModalRouteRegistration } from './modal-route-registration.interface.js'; import type { UmbModalConfig, UmbModalContext, UmbModalManagerContext, UmbModalToken } from '../../modal/index.js'; import type { UmbControllerAlias, UmbControllerHost } from '../../../../libs/controller-api/index.js'; import { UmbControllerBase } from '../../../../libs/class-api/index.js'; import type { UmbDeepPartialObject } from '../../utils/index.js'; export type UmbModalRouteBuilder = (params: { [key: string]: string | number; } | null) => string; export type UmbModalRouteSetupReturn = UmbModalTokenValue extends undefined ? UmbModalTokenValue extends undefined ? { modal?: UmbDeepPartialObject; data?: UmbDeepPartialObject; value?: UmbModalTokenValue; } : { modal?: UmbDeepPartialObject; data?: UmbDeepPartialObject; value: UmbModalTokenValue; } : UmbModalTokenValue extends undefined ? { modal?: UmbDeepPartialObject; data: UmbDeepPartialObject; value?: UmbModalTokenValue; } : { modal?: UmbDeepPartialObject; data: UmbDeepPartialObject; value: UmbModalTokenValue; }; export declare class UmbModalRouteRegistrationController extends UmbControllerBase implements UmbModalRouteRegistration { #private; /** * Creates an instance of UmbModalRouteRegistrationController. * @param {UmbControllerHost} host - The host element of the modal, this determine the ownership of the modal and the origin of it. * @param {UmbModalToken} alias - The alias of the modal, this is used to identify the modal. * @param {UmbControllerAlias} ctrlAlias - The alias for this controller, this is used to identify the controller. * @memberof UmbModalRouteRegistrationController */ constructor(host: UmbControllerHost, alias: UmbModalToken | string, ctrlAlias?: UmbControllerAlias); /** * Appends an additional path to the modal route. * * This can help specify the URL for this modal, or used to add a parameter to the URL like this: "/modal/my-modal/:index/" * A folder name starting with a colon ":" will be interpreted as a parameter. Then this modal can open with any value in that location. * When modal is being setup the value of the parameter can be read from the route params. See the example: * @param {string} additionalPath - The additional path to be appended to the modal route * @returns {UmbModalRouteRegistrationController} this * @example Example of adding an additional path to the modal route * const modalRegistration = new UmbModalRouteRegistrationController(this, MY_MODAL_TOKEN) * modalRegistration.addAdditionalPath(':index') * * modalRegistration.onSetup((params) => { * const index = params.index; * // When entering the url of: "/modal/my-modal/hello-world/" * // Then index will be "hello-world" * } */ addAdditionalPath(additionalPath: string): this; /** * Registerer one or more additional paths to the modal route, similar to addAdditionalPath. But without defining the actual path name. This enables this to be asynchronously defined and even changed later. * This can be useful if your modal has to be unique for this registration, avoiding collision with other registrations. * If you made a modal for editing one of multiple property, then you can add a unique path holding the property id. * Making the URL unique to this modal registration: /modal/my-modal/my-unique-value/ * * Notice the modal will only be available when all unique paths have a value. * @param {Array} uniquePathNames - the unique path names * @returns {UmbModalRouteRegistrationController} this * @example Example of adding an additional unique path to the modal route * const modalRegistration = new UmbModalRouteRegistrationController(this, MY_MODAL_TOKEN) * modalRegistration.addUniquePaths(['myAliasForIdentifyingThisPartOfThePath']) * * // Later: * modalRegistration.setUniquePathValue('myAliasForIdentifyingThisPartOfThePath', 'myValue'); */ addUniquePaths(uniquePathNames: Array): this; /** * Set or change the value of a unique path part. * @param {string} identifier - the unique path part identifier * @param {value | undefined} value - the new value for the unique path part * @example Example of adding an additional unique path to the modal route * const modalRegistration = new UmbModalRouteRegistrationController(this, MY_MODAL_TOKEN) * modalRegistration.addUniquePaths(['first-one', 'another-one']) * * // Later: * modalRegistration.setUniquePathValue('first-one', 'myValue'); */ setUniquePathValue(identifier: string, value: string | undefined): void; getUniquePathValue(identifier: string): string | undefined; hostConnected(): void; hostDisconnected(): void; get key(): string; get alias(): string | UmbModalToken; generateModalPath(): string; get path(): string | undefined; protected _setPath(path: string | undefined): void; /** * Returns true if the modal is currently active. * @returns {boolean} - true if the modal is currently active, false otherwise. */ get active(): boolean; open(params: { [key: string]: string | number; }, prepend?: string): void; /** * Returns the modal context if the modal is currently active. Otherwise its undefined. * @returns {UmbModalContext | undefined} - modal context if the modal is active, otherwise undefined. */ get modalContext(): UmbModalContext | undefined; observeRouteBuilder(callback: (urlBuilder: UmbModalRouteBuilder) => void): this; _internal_setRouteBuilder(urlBuilder: UmbModalRouteBuilder): void; onSetup(callback: (routingInfo: Params) => Promise | false> | UmbModalRouteSetupReturn | false): this; onSubmit(callback: (value: UmbModalTokenValue, data?: UmbModalTokenData) => void): this; onReject(callback: () => void): this; routeSetup(router: IRouterSlot, modalManagerContext: UmbModalManagerContext, params: Params): Promise | undefined>; destroy(): void; }