Skip to content

API reference

@dialog-fn/react

createDialog<T, K, S>(Component, options?) => DialogInstance<T, K, S>

ParamTypeDescription
ComponentFC<DialogComponentProps<T,K,S>>Your dialog component.
optionsDialogOptionsMount behavior (optional).

DialogInstance<T, K, S>

MemberTypeDescription
DialogFC<{ state?: S }>Render once to mount the dialog.
showShowDialog<T, K>Open and await the result.
close() => voidDismiss the dialog.

ShowDialog<T, K>

interface ShowDialog<T, K> {
(data?: T): Promise<K | undefined>; // resolves confirm value, or undefined on dismiss
close: () => void;
}

DialogComponentProps<T, K, S>

PropType
isOpenboolean
dataT
onConfirm(value?: K) => void
onClose() => void
stateS

DialogOptions

OptionTypeDefault
forceUnmountbooleanfalse
delayUnmountnumber0

@dialog-fn/core

The framework-agnostic store both adapters are built on. Use it to write an adapter for another framework.

createDialogStore<T, K>(options?) => DialogStore<T, K>

Returns { getState, subscribe, open, close, confirm, setData, showDialog, destroy }. showDialog(data) resolves with the confirm value or undefined; subscribe(listener) returns an unsubscribe function; destroy() settles any pending promise and clears listeners.