Svelte Modals is a modal manager for Svelte. It provides APIs for opening and closing modals, but leaves functionality
and styling of those modals up to you or your UI library. There are no modal components provided out of the box,
it onlys renders your modal component with props to communicate its visibility.
The Modal Stack
Modals are opened using a LIFO (Last In, First Out) stack. When a new modal is opened, 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.