mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
feat(useOverlay): add isOpen method to check overlay state (#4041)
This commit is contained in:
@@ -13,7 +13,9 @@ const modal = overlay.create(LazyModalExample, {
|
||||
})
|
||||
|
||||
async function open() {
|
||||
const shouldIncrement = await modal.open()
|
||||
const instance = modal.open()
|
||||
|
||||
const shouldIncrement = await instance.result
|
||||
|
||||
if (shouldIncrement) {
|
||||
count.value++
|
||||
|
||||
@@ -13,7 +13,9 @@ const slideover = overlay.create(LazySlideoverExample, {
|
||||
})
|
||||
|
||||
async function open() {
|
||||
const shouldIncrement = await slideover.open()
|
||||
const instance = slideover.open()
|
||||
|
||||
const shouldIncrement = await instance.result
|
||||
|
||||
if (shouldIncrement) {
|
||||
count.value++
|
||||
|
||||
@@ -66,6 +66,13 @@ Update an overlay using its `id`
|
||||
|
||||
Removes the overlay from the DOM using its `id`
|
||||
|
||||
- Parameters:
|
||||
- `id`: The identifier of the overlay
|
||||
|
||||
### `isOpen(id: symbol): boolean`
|
||||
|
||||
Checks if an overlay its open using its `id`
|
||||
|
||||
- Parameters:
|
||||
- `id`: The identifier of the overlay
|
||||
|
||||
|
||||
@@ -122,6 +122,12 @@ function _useOverlay() {
|
||||
return overlay
|
||||
}
|
||||
|
||||
const isOpen = (id: symbol): boolean => {
|
||||
const overlay = getOverlay(id)
|
||||
|
||||
return overlay.isOpen
|
||||
}
|
||||
|
||||
return {
|
||||
overlays,
|
||||
open,
|
||||
@@ -129,7 +135,8 @@ function _useOverlay() {
|
||||
closeAll,
|
||||
create,
|
||||
patch,
|
||||
unMount
|
||||
unMount,
|
||||
isOpen
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user