Skip to main content

modal

caution

All props/parameters are optional unless they are marked with an asterisk ( * ).

tip

It is highly recommended to use this module together with the Modal component.

Example

import { common } from "replugged";
const { modal } = common;

modal.confirm({}).then((confirmed) => {
if (confirmed) console.log("Confirmed!");
else console.log("Cancelled!");
});

The confirm function has title, cancelText, onConfirm, onCancel and onCloseCallback with a default value. Whether the confirm button is pressed determines the return value of the promise.

Enums

info

The following enums are a shortcut to the Flex component enums.

EnumDescription
modal.AlignFlexbox alignments
START | END | CENTER | STRETCH | BASELINE
modal.DirectionFlexbox directions
VERTICAL | HORIZONTAL | HORIZONTAL_REVERSE
modal.JustifyFlexbox justifies
START | END | CENTER | BETWEEN | AROUND
modal.WrapFlexbox wraps
NO_WRAP | WRAP | WRAP_REVERSE

Functions

NameParametersReturn TypeDescription
alert* props: AlertPropsvoidBrings up a modal useful for a quick response
closeModal* modalKey: string
contextKey: string
voidCloses a specific modal by its key
confirm* props: AlertPropsPromise<boolean | null>Brings up an alert modal useful for asking the user for a quick confirmation
openModal* render: (props: ModalProps) => ReactNode
options: ModalOptions
contextKey: string
stringOpens a specific modal and returns its key

AlertProps

NameTypeDefaultDescription
bodystring | ReactElementModal content
cancelTextstringText for the cancel button
classNamestringComponent class name
confirmColorButton.ColorsButton.Colors.BRANDPrimary button color
confirmTextstringOkayText for the cancel button
onCancel() => voidFunction ran on modal cancel
onCloseCallback() => voidFunction ran on modal close
onConfirm() => voidFunction ran when the primary button is used
onConfirmSecondary() => voidFunction ran when the secondary button is used
secondaryConfirmTextstringText for the secondary button
titlestringModal title
titleClassNamestringTitle element class name

ModalOptions

NameTypeDefaultDescription
modalKeystringModal key
onCloseCallback() => voidFunction ran when the modal gets closed
onCloseRequest() => voidFunction ran when clicking outside the modal

ModalProps

NameTypeDefaultDescription
onClose(): Promise<void>Function ran when the modal gets closed
transitionStatestringModal state