@94ai/nf-confirm 100.1.21 → 100.1.22

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.
package/lib/index.d.ts CHANGED
@@ -12,6 +12,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
12
12
  loading: boolean;
13
13
  onCancel: null;
14
14
  onConfirm: null;
15
+ callback: null;
15
16
  dangerouslyUseHTMLString: boolean;
16
17
  }, Readonly<import("vue-demi").ExtractPropTypes<{}>>, Readonly<import("vue-demi").ExtractPropTypes<{}>>, {}, {}, true, import("vue/types/v3-component-options").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, any>> & Readonly<Readonly<import("vue-demi").ExtractPropTypes<{}>>> & import("vue-demi").ShallowUnwrapRef<any> & {
17
18
  visible: boolean;
@@ -26,6 +27,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
26
27
  loading: boolean;
27
28
  onCancel: null;
28
29
  onConfirm: null;
30
+ callback: null;
29
31
  dangerouslyUseHTMLString: boolean;
30
32
  } & import("vue/types/v3-component-options").ExtractComputedReturns<{
31
33
  typeClass(): string;
@@ -42,6 +44,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
42
44
  loading: boolean;
43
45
  onCancel: null;
44
46
  onConfirm: null;
47
+ callback: null;
45
48
  dangerouslyUseHTMLString: boolean;
46
49
  }, {
47
50
  typeClass(): string;
package/lib/main.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const Confirm: (options: any) => any;
1
+ declare const Confirm: (options: any) => Promise<unknown> | undefined;
2
2
  export default Confirm;
@@ -24,6 +24,7 @@ const _sfc_main = vueDemi.defineComponent({
24
24
  loading: false,
25
25
  onCancel: null,
26
26
  onConfirm: null,
27
+ callback: null,
27
28
  dangerouslyUseHTMLString: false
28
29
  };
29
30
  },
@@ -46,12 +47,16 @@ const _sfc_main = vueDemi.defineComponent({
46
47
  this.onCancel(this.close);
47
48
  } else {
48
49
  this.close();
50
+ this.callback && this.callback("cancel");
49
51
  }
50
52
  },
51
53
  handleConfirm() {
52
54
  if (typeof this.onConfirm === "function") {
53
55
  this.loading = true;
54
56
  this.onConfirm(this.close);
57
+ } else {
58
+ this.loading = true;
59
+ this.callback && this.callback("confirm", this.close);
55
60
  }
56
61
  }
57
62
  }
@@ -123,6 +128,7 @@ function merge(target) {
123
128
  return target;
124
129
  }
125
130
  const ConfirmConstructor = vueDemi.Vue2.extend(NfConfirm);
131
+ let currentMsg = null;
126
132
  const Confirm = function(options) {
127
133
  var _a;
128
134
  if ((_a = vueDemi.Vue2.prototype) == null ? void 0 : _a.$isServer)
@@ -131,10 +137,20 @@ const Confirm = function(options) {
131
137
  const instance = new ConfirmConstructor({
132
138
  data: options
133
139
  });
140
+ instance.callback = defaultCallBack;
134
141
  instance.$mount();
135
142
  document.body.appendChild(instance.$el);
136
143
  instance.visible = true;
137
- return instance;
144
+ return new Promise((resolve, reject) => {
145
+ currentMsg = { resolve, reject };
146
+ });
147
+ };
148
+ const defaultCallBack = (action, done) => {
149
+ if (action === "confirm") {
150
+ currentMsg.resolve(done);
151
+ } else {
152
+ currentMsg.reject();
153
+ }
138
154
  };
139
155
  NfConfirm.install = (app) => {
140
156
  app.component("nf-confirm", NfConfirm);
@@ -22,6 +22,7 @@ const _sfc_main = defineComponent({
22
22
  loading: false,
23
23
  onCancel: null,
24
24
  onConfirm: null,
25
+ callback: null,
25
26
  dangerouslyUseHTMLString: false
26
27
  };
27
28
  },
@@ -44,12 +45,16 @@ const _sfc_main = defineComponent({
44
45
  this.onCancel(this.close);
45
46
  } else {
46
47
  this.close();
48
+ this.callback && this.callback("cancel");
47
49
  }
48
50
  },
49
51
  handleConfirm() {
50
52
  if (typeof this.onConfirm === "function") {
51
53
  this.loading = true;
52
54
  this.onConfirm(this.close);
55
+ } else {
56
+ this.loading = true;
57
+ this.callback && this.callback("confirm", this.close);
53
58
  }
54
59
  }
55
60
  }
@@ -121,6 +126,7 @@ function merge(target) {
121
126
  return target;
122
127
  }
123
128
  const ConfirmConstructor = Vue2.extend(NfConfirm);
129
+ let currentMsg = null;
124
130
  const Confirm = function(options) {
125
131
  var _a;
126
132
  if ((_a = Vue2.prototype) == null ? void 0 : _a.$isServer)
@@ -129,10 +135,20 @@ const Confirm = function(options) {
129
135
  const instance = new ConfirmConstructor({
130
136
  data: options
131
137
  });
138
+ instance.callback = defaultCallBack;
132
139
  instance.$mount();
133
140
  document.body.appendChild(instance.$el);
134
141
  instance.visible = true;
135
- return instance;
142
+ return new Promise((resolve, reject) => {
143
+ currentMsg = { resolve, reject };
144
+ });
145
+ };
146
+ const defaultCallBack = (action, done) => {
147
+ if (action === "confirm") {
148
+ currentMsg.resolve(done);
149
+ } else {
150
+ currentMsg.reject();
151
+ }
136
152
  };
137
153
  NfConfirm.install = (app) => {
138
154
  app.component("nf-confirm", NfConfirm);
@@ -11,6 +11,7 @@ declare const _default: import("vue-demi").DefineComponent<{}, any, {
11
11
  loading: boolean;
12
12
  onCancel: null;
13
13
  onConfirm: null;
14
+ callback: null;
14
15
  dangerouslyUseHTMLString: boolean;
15
16
  }, {
16
17
  typeClass(): string;
package/package/main.ts CHANGED
@@ -2,6 +2,7 @@ import { Vue2 } from 'vue-demi';
2
2
  import Main from './nf-confirm.vue';
3
3
  import merge from 'element-ui/src/utils/merge';
4
4
  const ConfirmConstructor = Vue2!.extend(Main);
5
+ let currentMsg: { resolve: Function, reject: Function } | null = null
5
6
 
6
7
  const Confirm = function(options) {
7
8
  if (Vue2!.prototype?.$isServer) return;
@@ -9,10 +10,21 @@ const Confirm = function(options) {
9
10
  const instance = new ConfirmConstructor({
10
11
  data: options
11
12
  });
12
- instance.$mount();
13
+ instance.callback = defaultCallBack
14
+ instance.$mount()
13
15
  document.body.appendChild(instance.$el);
14
16
  instance.visible = true;
15
- return instance;
17
+ return new Promise((resolve, reject) => {
18
+ currentMsg = { resolve, reject }
19
+ })
16
20
  };
17
21
 
22
+ const defaultCallBack = (action: 'cancel' | 'confirm', done: Function) => {
23
+ if (action === 'confirm') {
24
+ currentMsg!.resolve(done)
25
+ } else {
26
+ currentMsg!.reject()
27
+ }
28
+ }
29
+
18
30
  export default Confirm
@@ -43,6 +43,7 @@ export default defineComponent({
43
43
  loading: false,
44
44
  onCancel: null,
45
45
  onConfirm: null,
46
+ callback: null,
46
47
  dangerouslyUseHTMLString: false,
47
48
  }
48
49
  },
@@ -66,6 +67,7 @@ export default defineComponent({
66
67
  this.onCancel(this.close);
67
68
  } else {
68
69
  this.close()
70
+ this.callback && this.callback('cancel')
69
71
  }
70
72
  },
71
73
 
@@ -73,6 +75,9 @@ export default defineComponent({
73
75
  if (typeof this.onConfirm === 'function') {
74
76
  this.loading = true
75
77
  this.onConfirm(this.close);
78
+ } else {
79
+ this.loading = true
80
+ this.callback && this.callback('confirm', this.close)
76
81
  }
77
82
  },
78
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-confirm",
3
- "version": "100.1.21",
3
+ "version": "100.1.22",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zhongzhenjie <1476686104@qq.com>",
@@ -14,7 +14,7 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-theme-chalk": "^100.1.21",
17
+ "@94ai/nf-theme-chalk": "^100.1.22",
18
18
  "vue-demi": "^0.14.5"
19
19
  },
20
20
  "peerDependenciesMeta": {
@@ -30,5 +30,5 @@
30
30
  "types": "lib/index.d.ts",
31
31
  "main": "lib/nf-confirm.cjs.js",
32
32
  "module": "lib/nf-confirm.esm-bundler.js",
33
- "gitHead": "8cbd9254da4ec43f46b29198c0839bf2ba19132d"
33
+ "gitHead": "afcd14101f617ec64d20d834d67d055c6e8dd548"
34
34
  }