geoview-core - v2.2.0
    Preparing search index...

    Class ModalApi

    Manages modal instances, handles registration, state changes, and event emissions.

    Provides APIs to create, open, close, and delete modals. Emits events when modals are opened or closed, allowing listeners to react to modal state changes.

    Index

    Constructors

    Properties

    modals: Record<string, TypeModalProps> = {}

    Methods

    • Closes a modal instance by ID, setting it to inactive and emitting the closed event.

      Sets the modal active state to false and triggers onModalClosed listeners. The modal remains registered and can be reopened.

      Parameters

      • modalId: string

        ID of the modal to close

      Returns void

    • Creates a new modal instance with a unique ID and registers it for management.

      Generates a unique modal ID if not provided and automatically wraps the close handler to ensure proper cleanup. Returns the modal ID for later reference when opening or closing the modal.

      Parameters

      • modal: TypeModalProps

        Modal configuration (see TypeModalProps interface)

      Returns string | undefined

      Unique modal ID, or undefined if modal has no content

    • Deletes a modal instance by ID and removes it from the registry.

      Unregisters the modal from management and cleans up references. Should be called when the modal is no longer needed to free resources.

      Parameters

      • modalId: string

        ID of the modal to delete

      Returns void

    • Registers a handler to be called when a modal is closed.

      Parameters

      • callback: ModalClosedDelegate

        Function to execute when modal closed event is triggered

      Returns void

    • Registers a handler to be called when a modal is opened.

      Parameters

      • callback: ModalOpenedDelegate

        Function to execute when modal opened event is triggered

      Returns void

    • Opens a modal instance by ID, setting it to active and emitting the opened event.

      Sets the modal active state to true and triggers onModalOpened listeners. Modal must be created and registered before opening.

      Parameters

      • modalId: string

        ID of the modal to open

      Returns void