adminforth 2.61.0-next.6 → 2.61.0-next.8

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.
@@ -77,6 +77,56 @@ interface DialogButton {
77
77
  options?: Record<string, any>
78
78
  }
79
79
 
80
+ const modalRef = ref();
81
+
82
+ const props = withDefaults(defineProps<DialogProps>(), {
83
+ header: '',
84
+ headerCloseButton: true,
85
+ buttons: () => [],
86
+ clickToCloseOutside: false,
87
+ closeByEsc: true,
88
+ closeByClickOutside: true,
89
+ beforeCloseFunction: null,
90
+ beforeOpenFunction: null,
91
+ closable: false,
92
+ askForCloseConfirmation: false,
93
+ closeConfirmationText: 'Are you sure you want to close this dialog?',
94
+ removeFromDomOnClose: false,
95
+ })
96
+
97
+ const buttons = computed<DialogButton[]>(() => {
98
+ if (props.buttons && props.buttons.length > 0) {
99
+ return props.buttons;
100
+ }
101
+ return [
102
+ {
103
+ label: 'Close',
104
+ onclick: (dialog: any) => {
105
+ tryToHideModal();
106
+ },
107
+ options: {}
108
+ }
109
+ ];
110
+ });
111
+
112
+
113
+ function open() {
114
+ modalRef.value.open();
115
+ }
116
+
117
+ function close() {
118
+ modalRef.value.close();
119
+ }
120
+
121
+ defineExpose({
122
+ open: open,
123
+ close: close,
124
+ tryToHideModal: tryToHideModal,
125
+ })
126
+
127
+ function tryToHideModal() {
128
+ modalRef.value?.tryToHideModal();
129
+ }
80
130
 
81
131
  interface DialogProps {
82
132
  /**
@@ -114,7 +164,7 @@ interface DialogProps {
114
164
  /**
115
165
  * Function that will be called before the dialog is closed.
116
166
  */
117
- beforeCloseFunction?: (() => void | Promise<void>) | null
167
+ beforeCloseFunction?: (() => void | Promise<void | boolean>) | null
118
168
 
119
169
  /**
120
170
  * Function that will be called before the dialog is opened.
@@ -167,58 +217,4 @@ const dialog: Ref<Dialog> = ref(
167
217
  );
168
218
  /*************************************************************/
169
219
 
170
-
171
-
172
- const modalRef = ref();
173
-
174
- const props = withDefaults(defineProps<DialogProps>(), {
175
- header: '',
176
- headerCloseButton: true,
177
- buttons: () => [],
178
- clickToCloseOutside: false,
179
- closeByEsc: true,
180
- closeByClickOutside: true,
181
- beforeCloseFunction: null,
182
- beforeOpenFunction: null,
183
- closable: false,
184
- askForCloseConfirmation: false,
185
- closeConfirmationText: 'Are you sure you want to close this dialog?',
186
- removeFromDomOnClose: false,
187
- })
188
-
189
- const buttons = computed<DialogButton[]>(() => {
190
- if (props.buttons && props.buttons.length > 0) {
191
- return props.buttons;
192
- }
193
- return [
194
- {
195
- label: 'Close',
196
- onclick: (dialog: any) => {
197
- tryToHideModal();
198
- },
199
- options: {}
200
- }
201
- ];
202
- });
203
-
204
-
205
- function open() {
206
- modalRef.value.open();
207
- }
208
-
209
- function close() {
210
- modalRef.value.close();
211
- }
212
-
213
- defineExpose({
214
- open: open,
215
- close: close,
216
- tryToHideModal: tryToHideModal,
217
- })
218
-
219
- function tryToHideModal() {
220
- modalRef.value?.tryToHideModal();
221
- }
222
-
223
-
224
220
  </script>
@@ -68,7 +68,7 @@ const removeFromDom = computed(() => {
68
68
  interface DialogProps {
69
69
  closeByClickOutside?: boolean
70
70
  closeByEsc?: boolean
71
- beforeCloseFunction?: (() => void | Promise<void>) | null
71
+ beforeCloseFunction?: (() => void | Promise<void | boolean>) | null
72
72
  beforeOpenFunction?: (() => void | Promise<void>) | null
73
73
  askForCloseConfirmation?: boolean
74
74
  closeConfirmationText?: string
@@ -101,7 +101,10 @@ async function open() {
101
101
 
102
102
  async function close() {
103
103
  if (props.beforeCloseFunction) {
104
- await props.beforeCloseFunction?.();
104
+ const shouldClose = await props.beforeCloseFunction?.();
105
+ if (shouldClose === false) {
106
+ return;
107
+ }
105
108
  }
106
109
  isModalOpen.value = false;
107
110
  }
@@ -159,7 +159,7 @@
159
159
  </div>
160
160
  </div>
161
161
 
162
- <div v-if="show" class="bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-30"
162
+ <div v-if="show" class="bg-gray-900/50 dark:bg-gray-900/80 fixed inset-0 z-40"
163
163
  @click="$emit('hide')">
164
164
  </div>
165
165
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "2.61.0-next.6",
3
+ "version": "2.61.0-next.8",
4
4
  "description": "OpenSource Agent-Native forth-generation admin panel",
5
5
  "keywords": [
6
6
  "adminforth",