@@ -5,10 +5,13 @@ import { useTerminalDimensions } from "@opentui/solid"
55import { SplitBorder } from "../component/border"
66import { TextAttributes } from "@opentui/core"
77import { Schema } from "effect"
8- import { type TuiEvent } from "../event"
8+ import { TuiEvent } from "../event"
99
10+ type ToastInput = Schema . Codec . Encoded < typeof TuiEvent . ToastShow . properties >
1011export type ToastOptions = Schema . Schema . Type < typeof TuiEvent . ToastShow . properties >
1112
13+ const decodeToastOptions = Schema . decodeUnknownSync ( TuiEvent . ToastShow . properties )
14+
1215export function Toast ( ) {
1316 const toast = useToast ( )
1417 const { theme } = useTheme ( )
@@ -55,13 +58,13 @@ function init() {
5558 let timeoutHandle : NodeJS . Timeout | null = null
5659
5760 const toast = {
58- show ( options : ToastOptions ) {
59- const { duration , ... currentToast } = options
60- setStore ( "currentToast" , currentToast )
61+ show ( options : ToastInput ) {
62+ const toastOptions = decodeToastOptions ( options )
63+ setStore ( "currentToast" , toastOptions )
6164 if ( timeoutHandle ) clearTimeout ( timeoutHandle )
6265 timeoutHandle = setTimeout ( ( ) => {
6366 setStore ( "currentToast" , null )
64- } , duration ) . unref ( )
67+ } , toastOptions . duration ) . unref ( )
6568 } ,
6669 error : ( err : any ) => {
6770 if ( err instanceof Error )
0 commit comments