@v1nt1248/3nclient-lib 0.2.85 → 0.2.87

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.
@@ -8,11 +8,11 @@ declare module '../vue/dist/vue.esm-bundler.js' {
8
8
  interface ComponentCustomProperties {
9
9
  $openDialog: <V>(component: Component, props: ExtractComponentProps<Component>) => Promise<{
10
10
  event: Ui3nDialogEvent;
11
- data?: V | null | Event | undefined;
11
+ data?: V;
12
12
  }>;
13
13
  $closeDialog: <V>(id: string, value: {
14
14
  event: Ui3nDialogEvent;
15
- data?: V | null | Event | undefined;
15
+ data?: V;
16
16
  }) => void;
17
17
  $closeDialogs: () => void;
18
18
  dialogStack: Reactive<DialogOptions<any>[]>;
@@ -35,11 +35,11 @@ declare module 'pinia' {
35
35
  $dialogs: {
36
36
  open: <V>(component: Component, props: ExtractComponentProps<Component>) => Promise<{
37
37
  event: Ui3nDialogEvent;
38
- data?: V | null | Event | undefined;
38
+ data?: V;
39
39
  }>;
40
40
  close: <V>(id: string, value: {
41
41
  event: Ui3nDialogEvent;
42
- data?: V | null | Event | undefined;
42
+ data?: V;
43
43
  }) => void;
44
44
  closeAll: () => void;
45
45
  dialogStack: Reactive<DialogOptions<any>[]>;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@v1nt1248/3nclient-lib",
3
3
  "license": "AGPL-3.0-or-later",
4
4
  "author": "v1nt1248",
5
- "version": "0.2.85",
5
+ "version": "0.2.87",
6
6
  "description": "Library for 3NWeb clients",
7
7
  "type": "module",
8
8
  "files": [
@@ -42,7 +42,7 @@ import type {
42
42
  Ui3nTableEmits,
43
43
  Ui3nTableExpose,
44
44
  } from './ui3n-table/types';
45
- import Ui3nDialogProvider from '../plugins/dialogs/ui3n-dialog-provider.vue';
45
+ import Ui3nDialogProvider from './ui3n-dialog/ui3n-dialog-provider.vue';
46
46
  import Ui3nDialog from './ui3n-dialog/ui3n-dialog.vue';
47
47
  import type {
48
48
  Ui3nDialogComponentProps,
@@ -35,4 +35,5 @@ export interface Ui3nDialogComponentSlots {
35
35
  header?: () => VNode;
36
36
  body: () => VNode;
37
37
  actions?: () => VNode;
38
+ loading?: () => VNode;
38
39
  }
@@ -0,0 +1,52 @@
1
+ <script lang="ts" setup generic="V extends any">
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ import { type Component, inject } from 'vue';
4
+ import { DIALOGS_KEY, type DialogsPlugin } from '@/plugins';
5
+ import type { ExtractComponentProps } from '@/types';
6
+ import type { Ui3nDialogComponentProps, Ui3nDialogEvent } from './types';
7
+
8
+ const { dialogStack, $closeDialog } = inject<DialogsPlugin>(DIALOGS_KEY)!
9
+
10
+ function clickOverlay(id: string, modalProps: ExtractComponentProps<Component>) {
11
+ if (
12
+ (modalProps as Ui3nDialogComponentProps<any>).closeOnClickOverlay ||
13
+ ((modalProps as any).dialogProps as Ui3nDialogComponentProps<any>)?.closeOnClickOverlay
14
+ ) {
15
+ $closeDialog(id, { event: 'click-overlay' });
16
+ }
17
+ }
18
+
19
+ function onAction(id: string, value: { event: Ui3nDialogEvent; data?: V }) {
20
+ $closeDialog(id, value);
21
+ }
22
+ </script>
23
+
24
+ <template>
25
+ <teleport to="body">
26
+ <div
27
+ v-for="dialog in dialogStack"
28
+ :id="`dialog-wrapper-${dialog.id}`"
29
+ :key="dialog.id"
30
+ :class="$style['dialog-provider-overlay']"
31
+ @click.self.prevent="clickOverlay(dialog.id, dialog.props)"
32
+ >
33
+ <component
34
+ :is="dialog.component"
35
+ v-bind="dialog.props"
36
+ @action="onAction(dialog.id, $event)"
37
+ />
38
+ </div>
39
+ </teleport>
40
+ </template>
41
+
42
+ <style lang="scss" module>
43
+ .dialog-provider-overlay {
44
+ position: fixed;
45
+ z-index: 1000;
46
+ inset: 0;
47
+ display: flex;
48
+ justify-content: center;
49
+ align-items: center;
50
+ background-color: var(--shadow-close);
51
+ }
52
+ </style>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup generic="V extends any">
2
- import { computed, defineProps, defineEmits, defineSlots, nextTick, onMounted, ref, withDefaults, useTemplateRef } from 'vue';
2
+ import { computed, nextTick, onMounted, ref, useTemplateRef } from 'vue';
3
3
  import omit from 'lodash/omit';
4
4
  import { determineWindowWidth } from './util';
5
5
  import type { Ui3nDialogComponentProps, Ui3nDialogComponentEmits, Ui3nDialogComponentSlots } from './types';
@@ -214,6 +214,12 @@
214
214
  <slot name="actions" />
215
215
  </div>
216
216
 
217
+ <div
218
+ v-if="$slots['loading']"
219
+ :class="$style.loading"
220
+ >
221
+ <slot name="loading" />
222
+ </div>
217
223
 
218
224
  <ui3n-button
219
225
  :class="$style.closeBtn"
@@ -231,16 +237,6 @@
231
237
  <style lang="scss" module>
232
238
  @use '../../assets/styles/mixins' as mixins;
233
239
 
234
- .modal-overlay {
235
- position: fixed;
236
- z-index: 1000;
237
- inset: 0;
238
- display: flex;
239
- justify-content: center;
240
- align-items: center;
241
- background-color: var(--shadow-close);
242
- }
243
-
244
240
  .dialog {
245
241
  --ui3n-dialog-border-radius: 8px;
246
242
  --ui3n-dialog-title-height: 48px;
@@ -325,4 +321,13 @@
325
321
  align-items: center;
326
322
  gap: var(--spacing-s);
327
323
  }
324
+
325
+ .loading {
326
+ position: absolute;
327
+ inset: 0;
328
+ z-index: 1;
329
+ display: flex;
330
+ justify-content: center;
331
+ align-items: center;
332
+ }
328
333
  </style>