@@ -5,16 +5,12 @@ import { A, type NativeArray } from '@ember/array';
5
5
import type { ComponentLike } from '@glint/template' ;
6
6
7
7
export type ToastData = {
8
+ component ?: ComponentLike < CustomToastSignature > ;
8
9
title ?: string ;
9
10
message ?: string ;
10
- options : ToastOptions ;
11
+ options : ToastOptions | Record < string , unknown > ;
11
12
} ;
12
13
13
- export type CustomToastData = {
14
- component ?: ComponentLike < CustomToastSignature > ;
15
- options : object ;
16
- }
17
-
18
14
export type ToastOptions = {
19
15
icon ?: string | ComponentLike < { Element : Element } > ;
20
16
closable ?: boolean ;
@@ -24,7 +20,7 @@ export type ToastOptions = {
24
20
25
21
export interface CustomToastSignature {
26
22
Args : {
27
- options : object ;
23
+ options : Record < string , unknown > ;
28
24
close : ( ) => void ;
29
25
} ;
30
26
}
@@ -35,26 +31,26 @@ export default class ToasterService extends Service {
35
31
@tracked toasts : NativeArray < ToastData > = A < ToastData > ( [ ] ) ;
36
32
37
33
displayToast = task ( async ( toast : ToastData ) => {
38
- if ( typeof toast . options . timeOut === 'undefined' ) {
39
- toast . options . timeOut = null ;
34
+ if ( typeof toast . options [ ' timeOut' ] === 'undefined' ) {
35
+ toast . options [ ' timeOut' ] = null ;
40
36
}
41
37
42
- if ( typeof toast . options . closable === 'undefined' ) {
43
- toast . options . closable = true ;
38
+ if ( typeof toast . options [ ' closable' ] === 'undefined' ) {
39
+ toast . options [ ' closable' ] = true ;
44
40
}
45
41
46
42
this . toasts . pushObject ( toast ) ;
47
43
48
- if ( toast . options . timeOut ) {
49
- await timeout ( toast . options . timeOut ) ;
44
+ if ( toast . options [ ' timeOut' ] ) {
45
+ await timeout ( toast . options [ ' timeOut' ] ) ;
50
46
51
47
this . close ( toast ) ;
52
48
}
53
49
} ) ;
54
50
55
51
show (
56
- component : ComponentLike < CustomToastSignature > ,
57
- options : object = { } ,
52
+ component : ComponentLike < unknown > ,
53
+ options : Record < string , unknown > = { } ,
58
54
) {
59
55
const toast = {
60
56
component,
0 commit comments