Files
supabase/packages/ui-patterns/CommandMenu/internal/state/viewState.ts
Jordi Enric 6f1cfef213 clean circular deps (#34262)
* clean circular deps in telemetry

* clean circular deps in command

* fix commandmenu circular deps

* rm deps.json

* fix consent circular dep

* fix TOC circular deps

* fix wrong import path

* fix test types

* fix missing fn

* undo let change

* fix consent component

* empty
2025-03-20 11:11:11 +01:00

36 lines
821 B
TypeScript

import { proxy } from 'valtio'
import { type IViewState, type DialogSize, type ITouchHandlers } from './viewState.types'
const initViewState = () => {
const state: IViewState = proxy({
initiated: false,
init: () => !state.initiated && (state.initiated = true),
open: false,
size: 'large',
touchHandlers: {
handleTouchStart: () => {},
handleTouchMove: () => {},
handleTouchEnd: () => {},
},
setOpen: (open) => {
state.init()
state.open = open
},
toggleOpen: () => {
state.init()
state.open = !state.open
},
setSize: (size) => {
state.size = size
},
setTouchHandlers: (handlers) => {
state.touchHandlers = handlers
},
})
return state
}
export { initViewState }
export type { DialogSize, ITouchHandlers }