|
| 1 | +import {Directive} from "vue"; |
1 | 2 | import { noop, clickNode, cloneObj } from './utilities'
|
2 | 3 | import {CONFIRM_TYPES, DIRECTIVE_ATTRIBUTE_KEY} from './constants'
|
3 |
| -import type PromiseDialog from './promise.dialog' |
| 4 | +import type { PromiseDialog } from './promise.dialog' |
| 5 | +import type {DialogResolverPayload} from "./interface"; |
4 | 6 |
|
5 | 7 |
|
6 | 8 | export class ConfirmDirective {
|
7 | 9 | shouldIgnoreClick = false
|
8 |
| - bindingOptions = {} |
9 | 10 |
|
10 | 11 | constructor(private readonly dialog: PromiseDialog) {}
|
11 | 12 |
|
@@ -33,10 +34,10 @@ export class ConfirmDirective {
|
33 | 34 | if (binding?.value && binding.value.ok) {
|
34 | 35 | return dialog => binding.value.ok({ ...dialog, node: el })
|
35 | 36 | }
|
36 |
| - return dialog => { |
| 37 | + return (dialog: DialogResolverPayload) => { |
37 | 38 | // If we got here, it means the default action is to be executed
|
38 |
| - // We'll then stop the loader if it's enabled and close the dialog |
39 |
| - dialog.loading && dialog.close() |
| 39 | + // We'll then close the dialog even if it has loading enabled |
| 40 | + dialog.close && dialog.close() |
40 | 41 | this.shouldIgnoreClick = true
|
41 | 42 | clickNode(el)
|
42 | 43 | this.shouldIgnoreClick = false
|
@@ -67,7 +68,7 @@ export class ConfirmDirective {
|
67 | 68 | })
|
68 | 69 | }
|
69 | 70 |
|
70 |
| - public static createInstaller(dialog: PromiseDialog) { |
| 71 | + public static createInstaller(dialog: PromiseDialog): Directive { |
71 | 72 | const directive = new ConfirmDirective(dialog)
|
72 | 73 | return {
|
73 | 74 | mounted: (el, binding) => {
|
|
0 commit comments