GeoLeaf Core API - v3.0.0
    Preparing search index...
    Index

    Constructors

    Properties

    container: HTMLElement | null
    maxVisible: number
    maxPersistent: number
    durations: Record<NotifyType, number>
    config: { enabled: boolean; position: string; animations: boolean }
    _eventManager: EventListenerManager | null
    _timerManager: TimerManager | null
    _queue: INotificationQueueEntry[]
    _maxQueueSize: number

    Methods

    • (Re-)initialises the notification system against a container element.

      init() is a full re-initialisation, not a merge (B.19). Every option is resolved from config alone, falling back to its built-in default when omitted, and the renderer always comes back enabled. Calling init(x) therefore lands on the same state whatever ran before it — including after a destroy().

      It used to be neither: position / animations / durations merged over the current state while maxVisible / maxPersistent fell back to the defaults, so a second partial init() silently reset two budgets and kept three other settings. Worse, enabled was never restored, and destroy() clears it — every recreate path came back mute unless the caller knew to enable() by hand. Per-field overrides (durations: { success: 4000 }) keep working: the config is layered over the defaults, not over the previous call.

      Parameters

      • config: INotificationInitConfig = {}

        Renderer configuration; every field falls back to its built-in default (see constants.ts).

      Returns boolean

      true when the container was found and the system is ready, false otherwise — nothing is rendered until a successful init().

    • Displays a notification toast. Two call signatures are supported:

      • show(message, type, duration) — positional
      • show(message, options) — options object

      Parameters

      • message: string

        Text to display.

      • typeOrOptions: string | NotifyOptions = "info"

        Notification type ("success" | "error" | "warning" | "info") or an options object.

      • Optionalduration: number

        Auto-dismiss duration (ms); ignored when typeOrOptions is an object.

      Returns HTMLElement | null | undefined

      The toast element, null when the queue rejected it, or undefined when the system is not initialised.

      GeoLeaf.Notifications.show("Message", "success", 3000);
      
      GeoLeaf.Notifications.show("Message", {
      type: "success",
      duration: 3000,
      persistent: false,
      dismissible: true,
      });
    • Shared body of the four type shortcuts: resolves their number | NotifyOptions | undefined second argument onto show.

      Parameters

      • type: NotifyType

        Notification type forced by the calling shortcut.

      • message: string

        Text to display.

      • OptionaldurationOrOptions: number | NotifyOptions

        Duration (ms) or an options object.

      Returns HTMLElement | null | undefined

    • Displays a success toast (default duration: 3 s).

      Parameters

      • message: string

        Text to display.

      • OptionaldurationOrOptions: number | NotifyOptions

        Duration (ms) or an options object.

      Returns HTMLElement | null | undefined

      GeoLeaf.Notifications.success("Save successful", 3000);
      GeoLeaf.Notifications.success("Save successful", { duration: 3000, persistent: false });
    • Displays an error toast (highest priority, longest default duration: 5 s).

      Parameters

      • message: string

        Text to display.

      • OptionaldurationOrOptions: number | NotifyOptions

        Duration (ms) or an options object.

      Returns HTMLElement | null | undefined

      GeoLeaf.Notifications.error("Perte de connexion au serveur", { persistent: true });

      // Later, when connection is restored:
      GeoLeaf.Notifications.clearAll();
      GeoLeaf.Notifications.success("Connexion rétablie");
    • Displays a warning toast (default duration: 4 s).

      Parameters

      • message: string

        Text to display.

      • OptionaldurationOrOptions: number | NotifyOptions

        Duration (ms) or an options object.

      Returns HTMLElement | null | undefined

      GeoLeaf.Notifications.warning("Mise à jour disponible", {
      persistent: true,
      dismissible: true, // user can dismiss
      });
    • Displays an informational toast (default duration: 3 s).

      Parameters

      • message: string

        Text to display.

      • OptionaldurationOrOptions: number | NotifyOptions

        Duration (ms) or an options object.

      Returns HTMLElement | null | undefined

      GeoLeaf.Notifications.info("Nouvelle mise à jour disponible");
      GeoLeaf.Notifications.info("Message", { duration: 8000 }); // 8 seconds
    • Adds a notification to the priority queue, evicting a lower-priority entry when the queue is full, then processes the queue.

      Parameters

      • message: string

        Text to display.

      • options: Partial<
            {
                type: NotifyType;
                duration: number
                | undefined;
                persistent: boolean;
                dismissible: boolean;
            },
        > & { type?: string }

        Partially resolved display options.

      Returns HTMLElement | null | undefined

      The toast element, or null when the entry was rejected.

    • Evicts one visible temporary toast to make room for a pending error.

      Only a toast that is not already being removed frees a slot: _remove() is a no-op on one that is, and the actual DOM removal is deferred by the exit animation. temporaryToasts — the live counter _processQueue loops on — is therefore updated here, so a burst of errors handled in a single pass cannot re-target the same toast over and over and overflow maxVisible.

      Parameters

      • nextItem: INotificationQueueEntry
      • temporaryToasts: HTMLElement[]

      Returns boolean

      true only when a slot was genuinely freed.

    • Renders one notification straight away — called by the queue once a slot is free.

      Parameters

      • message: string

        Text to display.

      • options: {
            type: NotifyType;
            duration: number | undefined;
            persistent: boolean;
            dismissible: boolean;
        }

        Fully resolved display options.

      Returns HTMLElement

      The toast element appended to the container.

    • Builds the toast's dismiss button and registers its click on the renderer's OWN listener manager, recording the id on the toast so _remove can release it.

      ⚠️ Deliberately not createElement({ onClick }). That prop is not a plain addEventListener: dom-helpers routes it to GeoLeaf.Utils.events whenever that global exists — and in production it always does, pointing at the GLOBAL manager. Every toast therefore left a permanent entry there, holding a strong reference to a button detached seconds later, while _eventManager (created by init() for precisely this, destroyed by destroy()) stayed empty (CAPACITÉS backlog B.35d).

      Parameters

      • toast: HTMLElement

      Returns void

    • Drops the toast's close-button entry from the manager. Idempotent — the dataset key is cleared first, so a second call is a no-op.

      Parameters

      • toast: HTMLElement

      Returns void

    • Removes a notification: marks it, plays the exit animation, then detaches it and re-processes the queue. A no-op on a toast already being removed.

      Parameters

      • toast: HTMLElement

        The toast element to remove.

      • isReorganization: boolean = false

        true when the toast is evicted to free a slot rather than dismissed on its own terms (plays a different animation).

      Returns void

    • Tears the system down: releases every timer and listener, detaches all toasts, empties the queue and marks the renderer disabled.

      A subsequent init brings it back enabled on its own (B.19) — the recreate path needs no enable() of its own.

      Returns void

    • Snapshot of the current renderer state (visible counts, queue depth, budgets).

      Read-only and computed on call — it counts the toasts actually in the DOM rather than a tally kept alongside, so it cannot drift from what the user sees.

      Returns NotifyStatus

      The counts, the two budgets (maxVisible, maxPersistent) and the enabled / initialised flags.

      const s = GeoLeaf.Notifications.getStatus();
      // {
      // enabled: true,
      // initialized: true,
      // activeToasts: 1,
      // temporaryToasts: 1,
      // persistentToasts: 0,
      // queued: 0,
      // maxVisible: 3,
      // maxPersistent: 2,
      // }