@drawerly/react / DrawerManager
DrawerManager<TDrawerOptions>
Public API for managing a stack of drawers.
Type Parameters
TDrawerOptions
TDrawerOptions extends DrawerOptions = DrawerOptions
Properties
bringToTop()
bringToTop: (key) => void;Moves the drawer with the given key to the top of the stack.
Parameters
key
string
Returns
void
close()
close: (key?) => void;Closes the top drawer or the drawer with the given key.
Parameters
key?
string
Returns
void
closeAll()
closeAll: () => void;Closes all drawers.
Returns
void
getDefaultOptions()
getDefaultOptions: () => DrawerDefaultOptions<TDrawerOptions>;Returns the current global default options.
Returns
DrawerDefaultOptions<TDrawerOptions>
getDrawerInstance()
getDrawerInstance: (key) => TDrawerOptions | undefined;Returns a drawer instance by key, if it exists.
Parameters
key
string
Returns
TDrawerOptions | undefined
getState()
getState: () => DrawerState<TDrawerOptions>;Returns the current drawer state.
Returns
DrawerState<TDrawerOptions>
getTopDrawer()
getTopDrawer: () => TDrawerOptions | undefined;Returns the topmost drawer instance, if any.
Returns
TDrawerOptions | undefined
isOpen()
isOpen: (key) => boolean;Returns whether a drawer with the given key is in the stack.
Parameters
key
string
Returns
boolean
open()
open: (options) => string;Opens a drawer at the top of the stack. Options of an already open drawer are replaced.
Parameters
options
TDrawerOptions
Returns
string
subscribe()
subscribe: (listener) => Unsubscribe;Subscribes to state changes.
Parameters
listener
DrawerListener<TDrawerOptions>
Returns
updateDefaultOptions()
updateDefaultOptions: (patch) => void;Merges a patch into the global default options used for future drawers.
Parameters
patch
DrawerDefaultOptions<TDrawerOptions>
Returns
void
updateOptions()
updateOptions: (key, patch) => void;Merges a patch into the options of an existing drawer.
Parameters
key
string
patch
DrawerPatch<TDrawerOptions>
Returns
void