adminforth 2.22.0-next.33 → 2.22.0-next.35

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.
@@ -11,7 +11,7 @@
11
11
  <div class="relative bg-lightDialogBackgorund rounded-lg shadow-sm dark:bg-darkDialogBackgorund">
12
12
 
13
13
  <!-- Modal body -->
14
- <div class="p-4 md:p-5 space-y-4 text-lightDialogBodyText dark:text-darkDialogBodyText">
14
+ <div class="space-y-4 text-lightDialogBodyText dark:text-darkDialogBodyText">
15
15
  <slot ></slot>
16
16
  </div>
17
17
 
@@ -57,7 +57,8 @@ const removeFromDom = computed(() => {
57
57
  })
58
58
 
59
59
  interface DialogProps {
60
- clickToCloseOutside?: boolean
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
- clickToCloseOutside: true,
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.clickToCloseOutside && e.target === e.currentTarget) {
132
+ if (props.closeByClickOutside && e.target === e.currentTarget) {
114
133
  tryToHideModal();
115
134
  }
116
135
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "2.22.0-next.33",
3
+ "version": "2.22.0-next.35",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",