11import { useKeyboard , useRenderer , useTerminalDimensions } from "@opentui/solid"
2- import {
3- batch ,
4- createContext ,
5- createEffect ,
6- Show ,
7- useContext ,
8- type JSX ,
9- type ParentProps ,
10- } from "solid-js"
2+ import { batch , createContext , Show , useContext , type JSX , type ParentProps } from "solid-js"
113import { useTheme } from "@tui/context/theme"
124import { Renderable , RGBA } from "@opentui/core"
135import { createStore } from "solid-js/store"
14- import { createEventBus } from "@solid-primitives/event-bus"
156
167export function Dialog (
178 props : ParentProps < {
@@ -59,7 +50,6 @@ function init() {
5950 } [ ] ,
6051 size : "medium" as "medium" | "large" ,
6152 } )
62- const allClosedEvent = createEventBus < void > ( )
6353
6454 useKeyboard ( ( evt ) => {
6555 if ( evt . name === "escape" && store . stack . length > 0 ) {
@@ -90,12 +80,6 @@ function init() {
9080 } , 1 )
9181 }
9282
93- createEffect ( ( ) => {
94- if ( store . stack . length === 0 ) {
95- allClosedEvent . emit ( )
96- }
97- } )
98-
9983 return {
10084 clear ( ) {
10185 for ( const item of store . stack ) {
@@ -108,7 +92,9 @@ function init() {
10892 refocus ( )
10993 } ,
11094 replace ( input : any , onClose ?: ( ) => void ) {
111- if ( store . stack . length === 0 ) focus = renderer . currentFocusedRenderable
95+ if ( store . stack . length === 0 ) {
96+ focus = renderer . currentFocusedRenderable
97+ }
11298 for ( const item of store . stack ) {
11399 if ( item . onClose ) item . onClose ( )
114100 }
@@ -129,9 +115,6 @@ function init() {
129115 setSize ( size : "medium" | "large" ) {
130116 setStore ( "size" , size )
131117 } ,
132- get allClosedEvent ( ) {
133- return allClosedEvent
134- } ,
135118 }
136119}
137120
0 commit comments