Skip to content

@drawerly/react / DrawerManager

DrawerManager<TDrawerOptions> ​

Public API for managing a stack of drawers.

Type Parameters ​

TDrawerOptions ​

TDrawerOptions extends DrawerOptions = DrawerOptions

Properties ​

bringToTop() ​

ts
bringToTop: (key) => void;

Moves the drawer with the given key to the top of the stack.

Parameters ​

key ​

string

Returns ​

void


close() ​

ts
close: (key?) => void;

Closes the top drawer or the drawer with the given key.

Parameters ​

key? ​

string

Returns ​

void


closeAll() ​

ts
closeAll: () => void;

Closes all drawers.

Returns ​

void


getDefaultOptions() ​

ts
getDefaultOptions: () => DrawerDefaultOptions<TDrawerOptions>;

Returns the current global default options.

Returns ​

DrawerDefaultOptions<TDrawerOptions>


getDrawerInstance() ​

ts
getDrawerInstance: (key) => TDrawerOptions | undefined;

Returns a drawer instance by key, if it exists.

Parameters ​

key ​

string

Returns ​

TDrawerOptions | undefined


getState() ​

ts
getState: () => DrawerState<TDrawerOptions>;

Returns the current drawer state.

Returns ​

DrawerState<TDrawerOptions>


getTopDrawer() ​

ts
getTopDrawer: () => TDrawerOptions | undefined;

Returns the topmost drawer instance, if any.

Returns ​

TDrawerOptions | undefined


isOpen() ​

ts
isOpen: (key) => boolean;

Returns whether a drawer with the given key is in the stack.

Parameters ​

key ​

string

Returns ​

boolean


open() ​

ts
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() ​

ts
subscribe: (listener) => Unsubscribe;

Subscribes to state changes.

Parameters ​

listener ​

DrawerListener<TDrawerOptions>

Returns ​

Unsubscribe


updateDefaultOptions() ​

ts
updateDefaultOptions: (patch) => void;

Merges a patch into the global default options used for future drawers.

Parameters ​

patch ​

DrawerDefaultOptions<TDrawerOptions>

Returns ​

void


updateOptions() ​

ts
updateOptions: (key, patch) => void;

Merges a patch into the options of an existing drawer.

Parameters ​

key ​

string

patch ​

DrawerPatch<TDrawerOptions>

Returns ​

void

Released under the MIT License.