Svelte Modals is a modal manager for Svelte. It provides APIs for opening and closing modals as components but leaves functionality
and styling up to you. You provide the component and Svelte Modals handles rendering it with appropriate props.
The Modal Stack
Modals are opened using a LIFO (Last In, First Out) stack. When you open a new modal, it hides
any previously opened modals until it is closed. These are all rendered inside the <Modals /> component,
which should be somewhere near the root of your app or layout.
Opened modal components receive an isOpen prop to indicate whether it is the top modal or not. It is up
to you how to handle it. It will always be true when first opened, but may become false if another modal is opened
before it is closed.
Closing Modals
From anywhere in your app you can call modals.close to close the top modal, modals.close(amount) to
close the last given number of modals, or modals.closeAll() to close all modals.
Modals that are closed will unmount.
The close() prop
Modals receive a close prop which will close and resolve
their corresponding modals.open with the given value.
result:
If you are using Typescript, you can define the type of the value by using the ModalProps interface.