maz-ui 4.7.2 → 4.7.3

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.
@@ -48,6 +48,7 @@ function useMazDialogConfirm() {
48
48
  data,
49
49
  dialogState,
50
50
  showDialogAndWaitChoice,
51
+ removeDialogFromState,
51
52
  reject: async (currentDialog, response = "reject", onClick) => (await onClick?.(), responseDialog("reject", currentDialog, response)),
52
53
  accept: async (currentDialog, response = "accept", onClick) => (await onClick?.(), responseDialog("accept", currentDialog, response))
53
54
  };
@@ -37,10 +37,12 @@ export declare const defaultData: {
37
37
  };
38
38
  };
39
39
  declare function showDialogAndWaitChoice(identifier: string, callback?: () => unknown): Promise<unknown>;
40
+ declare function removeDialogFromState(identifier: string): MazDialogConfirmState[];
40
41
  export declare function useMazDialogConfirm(): {
41
42
  data: Ref<MazDialogConfirmData, MazDialogConfirmData>;
42
43
  dialogState: Ref<MazDialogConfirmState[], MazDialogConfirmState[]>;
43
44
  showDialogAndWaitChoice: typeof showDialogAndWaitChoice;
45
+ removeDialogFromState: typeof removeDialogFromState;
44
46
  reject: (currentDialog: MazDialogConfirmState, response?: unknown, onClick?: () => unknown) => Promise<unknown>;
45
47
  accept: (currentDialog: MazDialogConfirmState, response?: unknown, onClick?: () => unknown) => Promise<unknown>;
46
48
  };
@@ -1,5 +1,5 @@
1
- import { _ as _sfc_main } from "../chunks/MazDialogConfirm.vue_vue_type_script_setup_true_lang.DjKQKIZg.js";
2
- import { u } from "../chunks/MazDialogConfirm.vue_vue_type_script_setup_true_lang.DjKQKIZg.js";
1
+ import { _ as _sfc_main } from "../chunks/MazDialogConfirm.vue_vue_type_script_setup_true_lang.BB2rYkwY.js";
2
+ import { u } from "../chunks/MazDialogConfirm.vue_vue_type_script_setup_true_lang.BB2rYkwY.js";
3
3
  export {
4
4
  _sfc_main as default,
5
5
  u as useMazDialogConfirm
@@ -19,7 +19,7 @@ import { default as default18 } from "./MazCircularProgressBar.js";
19
19
  import { default as default19 } from "./MazContainer.js";
20
20
  import { default as default20 } from "./MazDatePicker.js";
21
21
  import { default as default21 } from "./MazDialog.js";
22
- import { _ as _2, u } from "../chunks/MazDialogConfirm.vue_vue_type_script_setup_true_lang.DjKQKIZg.js";
22
+ import { _ as _2, u } from "../chunks/MazDialogConfirm.vue_vue_type_script_setup_true_lang.BB2rYkwY.js";
23
23
  import { default as default22 } from "./MazDrawer.js";
24
24
  import { default as default23 } from "./MazDropdown.js";
25
25
  import { default as default24 } from "./MazDropzone.js";
@@ -8,6 +8,7 @@ export type DialogOptions = Partial<Omit<MazDialogConfirmProps, 'modelValue' | '
8
8
  export declare class DialogHandler {
9
9
  private readonly app;
10
10
  readonly globalOptions: DialogOptions;
11
+ private activeDialogs;
11
12
  constructor(app: App, globalOptions?: DialogOptions);
12
13
  open(options: DialogOptions): {
13
14
  destroy: () => void;
@@ -1,4 +1,4 @@
1
- import { _ as _sfc_main, u as useMazDialogConfirm } from "../chunks/MazDialogConfirm.vue_vue_type_script_setup_true_lang.DjKQKIZg.js";
1
+ import { _ as _sfc_main, u as useMazDialogConfirm } from "../chunks/MazDialogConfirm.vue_vue_type_script_setup_true_lang.BB2rYkwY.js";
2
2
  import { useMountComponent } from "../composables/useMountComponent.js";
3
3
  const DEFAULT_OPTIONS = {
4
4
  identifier: "main-dialog"
@@ -7,31 +7,41 @@ class DialogHandler {
7
7
  constructor(app, globalOptions = DEFAULT_OPTIONS) {
8
8
  this.app = app, this.globalOptions = globalOptions;
9
9
  }
10
+ activeDialogs = /* @__PURE__ */ new Map();
10
11
  open(options) {
11
12
  const props = {
12
13
  ...DEFAULT_OPTIONS,
13
14
  ...this.globalOptions,
14
15
  ...options
15
- }, { destroy, vNode } = useMountComponent(_sfc_main, {
16
+ }, { removeDialogFromState } = useMazDialogConfirm(), existing = this.activeDialogs.get(props.identifier);
17
+ existing && (existing.cleanupTimer && clearTimeout(existing.cleanupTimer), removeDialogFromState(props.identifier), existing.destroy(), this.activeDialogs.delete(props.identifier));
18
+ const { destroy, vNode } = useMountComponent(_sfc_main, {
16
19
  props,
17
20
  app: this.app
18
- }), { showDialogAndWaitChoice } = useMazDialogConfirm();
19
- function close() {
20
- vNode.component?.exposed?.isActive?.value && (vNode.component?.exposed?.close(), props.onClose?.(), setTimeout(() => {
21
- destroy();
22
- }, 700));
23
- }
24
- async function runDialog() {
21
+ }), entry = { destroy };
22
+ this.activeDialogs.set(props.identifier, entry);
23
+ const { showDialogAndWaitChoice } = useMazDialogConfirm(), scheduleDestroy = () => {
24
+ const timer = setTimeout(() => {
25
+ this.activeDialogs.get(props.identifier) === entry && (destroy(), this.activeDialogs.delete(props.identifier));
26
+ }, 700);
27
+ entry.cleanupTimer = timer;
28
+ }, close = () => {
29
+ vNode.component?.exposed?.isActive?.value && (vNode.component?.exposed?.close(), props.onClose?.(), scheduleDestroy());
30
+ };
31
+ return (async () => {
25
32
  try {
26
33
  const response = await showDialogAndWaitChoice(props.identifier);
27
34
  props.onAccept && props.onAccept(response);
28
35
  } catch (error) {
29
36
  const response = error;
30
37
  props.onReject && props.onReject(response);
38
+ } finally {
39
+ scheduleDestroy();
31
40
  }
32
- }
33
- return runDialog(), {
34
- destroy,
41
+ })(), {
42
+ destroy: () => {
43
+ entry.cleanupTimer && clearTimeout(entry.cleanupTimer), destroy(), this.activeDialogs.get(props.identifier) === entry && this.activeDialogs.delete(props.identifier);
44
+ },
35
45
  close
36
46
  };
37
47
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "maz-ui",
3
3
  "type": "module",
4
- "version": "4.7.2",
4
+ "version": "4.7.3",
5
5
  "description": "A standalone components library for Vue.Js 3 & Nuxt.Js 3",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -154,23 +154,23 @@
154
154
  }
155
155
  },
156
156
  "dependencies": {
157
- "@floating-ui/vue": "^1.1.10",
157
+ "@floating-ui/vue": "^1.1.11",
158
158
  "chart.js": "^4.5.1",
159
159
  "dayjs": "^1.11.19",
160
- "libphonenumber-js": "^1.12.37",
160
+ "libphonenumber-js": "^1.12.38",
161
161
  "valibot": "^1.2.0",
162
162
  "vue-chartjs": "^5.3.3",
163
- "@maz-ui/cli": "4.7.2",
163
+ "@maz-ui/cli": "4.7.3",
164
164
  "@maz-ui/icons": "4.7.2",
165
- "@maz-ui/utils": "4.7.2",
166
- "@maz-ui/themes": "4.7.2",
167
- "@maz-ui/translations": "4.7.2"
165
+ "@maz-ui/utils": "4.7.3",
166
+ "@maz-ui/translations": "4.7.3",
167
+ "@maz-ui/themes": "4.7.3"
168
168
  },
169
169
  "devDependencies": {
170
170
  "@vitejs/plugin-vue": "^6.0.4",
171
171
  "@vue/compiler-sfc": "^3.5.29",
172
172
  "@vue/test-utils": "^2.4.6",
173
- "autoprefixer": "^10.4.24",
173
+ "autoprefixer": "^10.4.27",
174
174
  "jsdom": "^28.1.0",
175
175
  "lightningcss": "^1.31.1",
176
176
  "nuxt": "^4.3.1",
@@ -179,8 +179,8 @@
179
179
  "unplugin-auto-import": "^21.0.0",
180
180
  "unplugin-vue-components": "^31.0.0",
181
181
  "vue-router": "^5.0.3",
182
- "@maz-ui/node": "4.6.1",
183
- "@maz-ui/eslint-config": "4.7.2"
182
+ "@maz-ui/eslint-config": "4.7.3",
183
+ "@maz-ui/node": "4.6.1"
184
184
  },
185
185
  "lint-staged": {
186
186
  "*.{js,ts,vue,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix",