adminforth 2.22.0-next.32 → 2.22.0-next.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/spa/src/afcl/Modal.vue +23 -4
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<slot name="trigger"></slot>
|
|
7
7
|
</div>
|
|
8
8
|
<Teleport to="body">
|
|
9
|
-
<div v-show="isModalOpen" v-if="!removeFromDom" @click="backdropClick" v-bind="$attrs" class="bg-black/50 overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-1rem max-h-full flex" >
|
|
9
|
+
<div v-show="isModalOpen" v-if="!removeFromDom" @click="backdropClick" v-bind="$attrs" class="bg-black/50 overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full h-full md:inset-0 h-1rem max-h-full flex" >
|
|
10
10
|
<!-- Modal content -->
|
|
11
11
|
<div class="relative bg-lightDialogBackgorund rounded-lg shadow-sm dark:bg-darkDialogBackgorund">
|
|
12
12
|
|
|
@@ -57,7 +57,8 @@ const removeFromDom = computed(() => {
|
|
|
57
57
|
})
|
|
58
58
|
|
|
59
59
|
interface DialogProps {
|
|
60
|
-
|
|
60
|
+
closeByClickOutside?: boolean
|
|
61
|
+
closeByEsc?: boolean
|
|
61
62
|
beforeCloseFunction?: (() => void | Promise<void>) | null
|
|
62
63
|
beforeOpenFunction?: (() => void | Promise<void>) | null
|
|
63
64
|
askForCloseConfirmation?: boolean
|
|
@@ -66,7 +67,8 @@ interface DialogProps {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
const props = withDefaults(defineProps<DialogProps>(), {
|
|
69
|
-
|
|
70
|
+
closeByClickOutside: true,
|
|
71
|
+
closeByEsc: true,
|
|
70
72
|
beforeCloseFunction: null,
|
|
71
73
|
beforeOpenFunction: null,
|
|
72
74
|
askForCloseConfirmation: false,
|
|
@@ -109,8 +111,25 @@ function toggleModal() {
|
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
|
114
|
+
function onEsc(event: KeyboardEvent) {
|
|
115
|
+
if (event.key === 'Escape') {
|
|
116
|
+
if (props.closeByEsc) {
|
|
117
|
+
tryToHideModal();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
onMounted(() => {
|
|
123
|
+
document.addEventListener('keydown', onEsc)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
onUnmounted(() => {
|
|
127
|
+
document.removeEventListener('keydown', onEsc)
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
|
|
112
131
|
function backdropClick(e: MouseEvent) {
|
|
113
|
-
if (props.
|
|
132
|
+
if (props.closeByClickOutside && e.target === e.currentTarget) {
|
|
114
133
|
tryToHideModal();
|
|
115
134
|
}
|
|
116
135
|
}
|