# All files ToastManager.tsx

98.58% Statements 558/566
95.83% Branches 69/72
95.45% Functions 21/22
98.58% Lines 558/566

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    5671x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    108x
    108x
    108x
    104x
    104x
    108x
    18x
    18x
    151x
    30x
    30x
    121x
    121x
    121x
    18x
    18x
    44x
    44x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    3x
    3x
    3x
    3x
    3x
    3x
    3x
    1x
    3x
    2x
    2x
    3x
    18x
    18x
    18x
    18x
    18x
    34x
    34x
    34x
    34x
    34x
    32x
    2x
    34x
    34x

    34x
    34x
    34x
    34x
    34x
    34x
    34x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    471x
    471x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    48x
    48x
    48x
    48x
    48x
    48x
    48x
    48x
    48x
    48x
    6x
    6x
    6x
    6x
    6x
    6x
    1x
    1x
    1x
    1x
    1x
    5x
    5x
    5x
    6x
    3x
    6x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    4x
    4x
    6x
    4x
    4x
    4x
    4x
    4x
    4x
    4x
    42x
    42x
    42x
    42x
    42x
    42x
    42x
    42x
    42x
    42x
    42x
    42x
    42x
    48x
    1x
    48x
    41x
    4x
    41x
    2x
    41x
    39x
    39x
    42x
    42x
    42x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    40x
    40x

    40x
    40x
    40x
    1x
    1x
    1x
    39x
    39x
    40x
    33x
    33x
    33x
    33x
    40x
    40x
    40x
    40x
    2x
    2x
    39x
    39x
    39x
    25x
    39x
    39x
    39x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    4x
    4x
    4x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    2x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    2x
    2x
    2x

    2x
    2x
    2x
    2x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    55x
    55x
    1x
    1x
    54x
    55x
    26x
    26x
    26x
    26x
    28x
    28x
    28x
    28x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    69x
    69x
    69x
    69x
    18x
    18x
    18x
    18x
    18x
    18x
    1x
    1x
    1x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    18x
    4x
    4x
    1x
    1x
    4x
    4x
    1x
    1x
    4x
    18x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    8x
    1x
    1x
    1x
    1x
    1x
    1x

    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    2x
    1x
    1x
    1x
    1x
    1x
    1x
     import { nanoid } from "nanoid";
    import { type ConfigurableToastProps } from "./Toast.js";

    /**
     * @remarks \@since 6.0.0
     */
    export const DEFAULT_TOAST_VISIBLE_TIME = 5000;

    /**
     * - `"normal"` - the toast will be added to the end of the queue
     * - `"next"` - the toast will be inserted next-in-line in the queue, waiting
     *   for the current visible toast to exit before being shown. If the toast does
     *   not support duplicates, the existing toast will be moved instead and merged
     *   with the toast.
     * - `"replace"` - if there is a currently visible toast, it will start the
     *   leave transition and display the newly added toast instead.
     * - `"immediate"` - the same behavior as `"replace"` except that if there was a
     *   currently visible toast, it will be shown once the newly added toast again.
     *
     * @remarks \@since 6.0.0 Renamed from `MessagePriority` to `ToastPriority`
     */
    export type ToastPriority = "normal" | "next" | "replace" | "immediate";

    /**
     * - `"allow"` - toasts with the same `toastId` can be added into the queue, but
     *   the leave timeout behavior might not work if multiple toasts can be shown
     *   at the same time.
     * - `"restart"` - (default) toasts that have the same `toastId` as a toast
     *   being shown will restart the exit timeout and update the toast with any
     *   differences in the toast. If the toast is not currently being shown, a new
     *   toast will not be added.
     * - `"update"` - toasts that have the same `toastId` will just update the toast
     *   with the latest content while maintaining any existing timeouts
     *
     * @remarks \@since 6.0.0 Renamed from `DuplicateBehavior`
     */
    export type ToastDuplicateBehavior = "allow" | "restart" | "update";

    /**
     * @remarks \@since 6.0.0
     */
    export interface ToastMeta {
      /**
       * This will be `true` if the exit timeout has been paused either by hovering
       * the toast or the page has become inactive through blur or minimizing.
       */
      paused: boolean;

      /**
       * This will be `true` when the toast should be visible and `false` during the
       * exit animation.
       */
      visible: boolean;

      /**
       * The current toast's id which can be used with the:
       * - {@link ToastManager.removeToast}
       * - {@link ToastManager.startRemoveTimeout}
       * - {@link ToastManager.pauseRemoveTimeout}
       * - {@link ToastManager.resumeRemoveTimeout}
       */
      toastId: string;
      priority: ToastPriority;
      duplicates: ToastDuplicateBehavior;
      visibleTime: number | null;
    }

    /**
     * @remarks \@since 6.0.0
     */
    export interface CreateToastOptions extends ConfigurableToastProps {
      /**
       * @defaultValue `nanoid()`
       */
      toastId?: string;

      /**
       * @see {@link ToastDuplicateBehavior}
       * @defaultValue `"restart"`
       */
      duplicates?: ToastDuplicateBehavior;

      /**
       * @see {@link ToastPriority}
       * @defaultValue `"normal"`
       */
      priority?: ToastPriority;

      /**
       * Set this to `null` to prevent the toast from automatically hiding,
       * otherwise set this to the number of milliseconds to remain visible.
       *
       * @see {@link DEFAULT_TOAST_VISIBLE_TIME}
       * @defaultValue `DEFAULT_TOAST_VISIBLE_TIME`
       */
      visibleTime?: number | null;
    }

    /**
     * @remarks \@since 6.0.0
     */
    export interface QueuedToast extends ConfigurableToastProps, ToastMeta {}

    /**
     * @remarks \@since 6.0.0
     */
    export type ToastQueue = readonly Readonly<QueuedToast>[];

    /**
     * @remarks \@since 6.0.0
     */
    export type ToastCallback = (queue: ToastQueue) => void;

    /**
     * @internal
     * @remarks \@since 6.0.0
     */
    export interface ToastVisibilityTimers {
      inactive: boolean;
      startTime: number;
      elapsedTime: number;
      exitTimeout?: number;
    }

    /**
     * @see {@link ToastManagerProvider}
     *
     * @remarks \@since 6.0.0
     */
    export class ToastManager {
      #queue: QueuedToast[];
      #timers: Map<string, ToastVisibilityTimers>;
      #listeners: ToastCallback[];

      constructor() {
        this.#queue = [];
        this.#timers = new Map();
        this.#listeners = [];

        // All of the class methods must be arrow functions to preserve the correct
        // `this` value. If they aren't arrow functions, I'd have to wrap each call
        // in an arrow function to work.
        //
        // i.e.
        // useSyncExternalStore(
        //   (cb) => manager.subscribe(cb),
        //   () => manager.getQueue(),
        //   () => manager.getQueue(),
        // );
      }

      #emit = (): void => {
        // shallow clone to ensure react updates
        this.#queue = [...this.#queue];
        this.#listeners.forEach((callback) => {
          callback(this.#queue);
        });
      };

      #getToastIndex = (toastId: string | undefined): number => {
        if (!toastId) {
          return -1;
        }

        return this.#queue.findIndex((toast) => toast.toastId === toastId);
      };

      #getToast = (toastId: string | undefined): QueuedToast | undefined => {
        return this.#queue[this.#getToastIndex(toastId)];
      };

      /**
       * Starts the exit transition for the currently shown toast and adds the next
       * toast into the queue. This requires a manual call to `this.#emit()`
       * afterwards.
       */
      #addToastImmediately = (nextToast: QueuedToast): void => {
        const [current] = this.#queue;
        this.clearTimer(current.toastId);
        this.#queue[0] = {
          ...current,
          visible: false,
        };
        if (nextToast.priority === "immediate") {
          this.#queue.splice(1, 0, nextToast, current);
        } else {
          this.#queue.splice(1, 0, nextToast);
        }
      };

      /**
       * This calls `this.#emit()` if the toast was updated
       */
      #updateToast = (
        toastIdOrIndex: string | number,
        patch: Partial<QueuedToast>
      ): void => {
        const index =
          typeof toastIdOrIndex === "number"
            ? toastIdOrIndex
            : this.#getToastIndex(toastIdOrIndex);

        if (index === -1) {
          return;
        }

        this.#queue[index] = {
          ...this.#queue[index],
          ...patch,
        };
        this.#emit();
      };

      /**
       * This is just used to subscribe to changes in the {@link useToastQueue}.
       *
       * ```tsx
       * useSyncExternalStore(
       *   toastManager.subscribe,
       *   toastManager.getQueue,
       *   toastManager.getQueue,
       * );
       * ```
       *
       * @internal
       */
      subscribe = (callback: ToastCallback): (() => void) => {
        this.#listeners.push(callback);

        return () => {
          this.#listeners = this.#listeners.filter((cb) => cb !== callback);
        };
      };

      /**
       * @see {@link subscribe}
       * @internal
       */
      getQueue = (): ToastQueue => {
        return this.#queue;
      };

      /**
       * Either adds the toast to the queue or updates an existing toast when using
       * an existing `toastId`.
       *
       * @example
       * Adding toasts
       * ```tsx
       * // create a toast when the user is offline that will not disappear
       * addToast({ toastId: "offline", visibleTime: null });
       *
       * // add a new toast that displays `"Toast"` to the queue
       * addToast({ children: "Toast!" });
       *
       * // add an online toast notification. since these three use the same toast
       * // id, the hide timer will be reset each time
       * addToast({ toastId: "online" });
       * addToast({ toastId: "online" });
       * addToast({ toastId: "online" });
       *
       * // add a server error toast to the queue where the second one will be
       * // ignored
       * addToast({
       *   toastId: "ServerError",
       *   theme: "error",
       *   duplicates: "prevent",
       * });
       * addToast({
       *   toastId: "ServerError",
       *   theme: "error",
       *   duplicates: "prevent",
       * });
       *
       * // add a toast to the queue that has an action button that says "Goodbye"
       * addToast({
       *   children: "Hello, world!",
       *   action: "Goodbye",
       * });
       *
       * // add a toast to the queue that has an action button that says "Goodbye"
       * // and a custom click handler
       * addToast({
       *   children: "Hello, world!",
       *   action: {
       *     onClick: () => {
       *       logout();
       *     },
       *     children: "Goodbye",
       *   },
       * });
       *
       * // add a toast to the queue that renders a react component in the content,
       * // a custom action button implementation (using `ToastActionButton`), and a
       * // close button
       * addToast({
       *   children: <SomeCustomComponent />,
       *   actionButton: <SomeCustomActionButton />,
       *   closeButton: true,
       * });
       * ```
       */
      addToast = (toast: CreateToastOptions): void => {
        const {
          toastId = nanoid(),
          visibleTime = DEFAULT_TOAST_VISIBLE_TIME,
          role = visibleTime === null ? "alert" : "status",
          priority = "normal",
          duplicates = "restart",
        } = toast;

        const existingIndex = this.#getToastIndex(toast.toastId);
        if (existingIndex !== -1 && duplicates !== "allow") {
          const existingToast = this.#queue[existingIndex];

          // reorder/move the existing toast to be the next item in the queue by:
          // - removing the toast from the queue
          // - inserting it into the next position with the updates
          if (priority === "next" && existingIndex > 1) {
            this.#queue.splice(existingIndex, 1);
            this.#queue.splice(1, 0, { ...existingToast, ...toast });
            this.#emit();
            return;
          }

          // only need to reorder the queue if it is not being shown
          if (
            (priority === "replace" || priority === "immediate") &&
            existingIndex !== 0
          ) {
            this.#queue.splice(existingIndex, 1);
            this.#addToastImmediately({
              ...existingToast,
              ...toast,
            });
            this.#emit();
            return;
          }

          const timers = this.#timers.get(toastId);
          if (existingToast.visible && duplicates === "restart" && timers) {
            this.#timers.set(toastId, { ...timers, elapsedTime: 0 });
            this.startRemoveTimeout(toastId);
          }

          this.#updateToast(existingIndex, toast);
          return;
        }

        const nextToast: QueuedToast = {
          ...toast,
          role,
          paused: false,
          visible: true,
          toastId,
          priority,
          duplicates,
          visibleTime,
        };

        const queueSize = this.#queue.length;
        if (priority === "next" && queueSize > 1) {
          this.#queue.splice(1, 0, nextToast);
        } else if (
          (priority === "replace" || priority === "immediate") &&
          queueSize > 0
        ) {
          this.#addToastImmediately(nextToast);
        } else {
          this.#queue.push(nextToast);
        }

        this.#emit();
      };

      /**
       * Attempts to start the timeout for removing the toast when the `visibleTime`
       * is not null for a toast.
       *
       * @param toastId - The specific toastId to update
       */
      startRemoveTimeout = (toastId: string): void => {
        const toast = this.#getToast(toastId);
        if (!toast) {
          return;
        }

        const { visibleTime } = toast;
        if (visibleTime === null) {
          // Must manually be closed
          return;
        }

        const cached = this.#timers.get(toastId);
        const timers = (cached && { ...cached }) || {
          inactive: false,
          startTime: Date.now(),
          elapsedTime: 0,
        };
        window.clearTimeout(timers.exitTimeout);

        let duration = visibleTime;
        if (timers.elapsedTime) {
          duration -= timers.elapsedTime;
        }

        timers.inactive = false;
        timers.exitTimeout = window.setTimeout(() => {
          this.removeToast(toastId, true);
        }, duration);
        this.#timers.set(toastId, timers);
      };

      /**
       * Pauses the remove timeout for a specific toast normally with hover events
       * or the browser becoming inactive.
       *
       * @param toastId - The specific toastId to pause
       */
      pauseRemoveTimeout = (toastId: string): void => {
        const toast = this.#getToast(toastId);
        const cached = this.#timers.get(toastId);
        if (!toast || !cached || cached.inactive) {
          return;
        }

        window.clearTimeout(cached.exitTimeout);
        const timers = { ...cached };
        timers.inactive = true;
        timers.elapsedTime = Date.now() - timers.startTime + timers.elapsedTime;
        this.#timers.set(toastId, timers);
        this.#updateToast(toastId, { paused: true });
      };

      /**
       * Resumes the current remove timeout if it was paused by
       * {@link pauseRemoveTimeout}.
       *
       * @param toastId - The specific toastId to resume
       */
      resumeRemoveTimeout = (toastId: string): void => {
        const toastIndex = this.#getToastIndex(toastId);
        const timers = this.#timers.get(toastId);
        if (toastIndex === -1 || !timers?.startTime) {
          return;
        }

        this.#updateToast(toastIndex, { paused: false });
        this.startRemoveTimeout(toastId);
      };

      /**
       * Removes a toast by id from the queue without any exit animation.
       *
       * @param toastId - The specific {@link QueuedToast.toastId}
       * @param transition - Set this to `true` to remove the toast by the exit
       * transition instead of immediately.
       */
      removeToast = (toastId: string, transition: boolean): void => {
        const toastIndex = this.#getToastIndex(toastId);
        if (toastIndex === -1) {
          return;
        }

        if (transition) {
          this.clearTimer(toastId);
          this.#updateToast(toastIndex, { visible: false });
          return;
        }

        this.#queue.splice(toastIndex, 1);
        this.#emit();
      };

      /**
       * Clears any pending timers for the provided toast id. This should generally
       * be used in the `useEffect` cleanup effect for any custom toast renderer
       * implementations.
       *
       * @example
       * ```tsx
       * const { toastId } = toast;
       * const toastManager = useToastManager();
       *
       * useEffect(() => {
       *   return () => {
       *     toastManager.clearTimer(toastId):
       *   }
       * }, [toastManager, toastId]);
       * ```
       */
      clearTimer = (toastId: string): void => {
        const timer = this.#timers.get(toastId);
        window.clearTimeout(timer?.exitTimeout);
        this.#timers.delete(toastId);
      };

      /**
       * Removes first toast from the queue without any exit animation. You most
       * likely want to use {@link removeToast} instead.
       */
      popToast = (): void => {
        this.#queue.pop();
        this.#emit();
      };

      /**
       * Removes all toasts from the queue. There will be no exit animation.
       *
       * @param disableEmit - Set this to `true` to disable emitting the empty queue.
       * Mostly used for tests.
       */
      clearToasts = (disableEmit = false): void => {
        this.#queue = [];
        this.#timers.forEach((meta) => {
          window.clearTimeout(meta.exitTimeout);
        });
        this.#timers.clear();
        if (!disableEmit) {
          this.#emit();
        }
      };
    }

    /**
     * The default toast manager for react-md apps that will allow toasts to be
     * added without setting up the {@link ToastManagerProvider}.
     *
     * @internal
     * @remarks \@since 6.0.0
     */
    export const toastManager = new ToastManager();

    /**
     * @see {@link ToastManager.addToast}
     * @remarks \@since 6.0.0
     */
    export const addToast: ToastManager["addToast"] = (toast) =>
      toastManager.addToast(toast);

    /**
     * @see {@link ToastManager.startRemoveTimeout}
     * @remarks \@since 6.0.0
     */
    export const startRemoveToastTimeout: ToastManager["startRemoveTimeout"] = (
      toastId
    ) => toastManager.startRemoveTimeout(toastId);

    /**
     * @see {@link ToastManager.popToast}
     * @remarks \@since 6.0.0
     */
    export const popToast: ToastManager["popToast"] = () => toastManager.popToast();

    /**
     * @see {@link ToastManager.removeToast}
     * @remarks \@since 6.0.0
     */
    export const removeToast: ToastManager["removeToast"] = (toastId, transition) =>
      toastManager.removeToast(toastId, transition);

    /**
     * @see {@link ToastManager.clearToasts}
     * @remarks \@since 6.0.0
     */
    export const clearToasts = (): void => toastManager.clearToasts();