(options: ToastOptions | string)
| 104 | } |
| 105 | |
| 106 | export function showToast(options: ToastOptions | string) { |
| 107 | const opts = typeof options === "string" ? { description: options } : options |
| 108 | return toaster.show((props) => ( |
| 109 | <Toast toastId={props.toastId} duration={opts.duration} data-variant={opts.variant ?? "default"}> |
| 110 | <Show when={opts.icon}> |
| 111 | <Toast.Icon name={opts.icon!} /> |
| 112 | </Show> |
| 113 | <Toast.Content> |
| 114 | <Show when={opts.title}> |
| 115 | <Toast.Title>{opts.title}</Toast.Title> |
| 116 | </Show> |
| 117 | <Show when={opts.description}> |
| 118 | <Toast.Description>{opts.description}</Toast.Description> |
| 119 | </Show> |
| 120 | <Show when={opts.actions?.length}> |
| 121 | <Toast.Actions> |
| 122 | {opts.actions!.map((action) => ( |
| 123 | <button data-slot="toast-action" onClick={action.onClick}> |
| 124 | {action.label} |
| 125 | </button> |
| 126 | ))} |
| 127 | </Toast.Actions> |
| 128 | </Show> |
| 129 | </Toast.Content> |
| 130 | <Toast.CloseButton /> |
| 131 | </Toast> |
| 132 | )) |
| 133 | } |
| 134 | |
| 135 | export interface ToastPromiseOptions<T, U = unknown> { |
| 136 | loading?: JSX.Element |
nothing calls this directly
no outgoing calls
no test coverage detected