@94ai/nf-confirm 8.3.23 → 10.0.0

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
@@ -8,8 +8,8 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
8
8
  type: string;
9
9
  customClass: string;
10
10
  iconClass: string;
11
- cancelButtonText: string;
12
- confirmButtonText: string;
11
+ cancelButtonText: undefined;
12
+ confirmButtonText: undefined;
13
13
  loading: boolean;
14
14
  onCancel: null;
15
15
  onConfirm: null;
@@ -23,16 +23,22 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
23
23
  type: string;
24
24
  customClass: string;
25
25
  iconClass: string;
26
- cancelButtonText: string;
27
- confirmButtonText: string;
26
+ cancelButtonText: undefined;
27
+ confirmButtonText: undefined;
28
28
  loading: boolean;
29
29
  onCancel: null;
30
30
  onConfirm: null;
31
31
  callback: null;
32
32
  dangerouslyUseHTMLString: boolean;
33
- } & import("vue/types/v3-component-options").ExtractComputedReturns<{
33
+ } & import("vue/types/v3-component-options").ExtractComputedReturns<import("vue-demi").ComponentComputedOptions & {
34
+ localeText(): {
35
+ cancelButtonText: any;
36
+ confirmButtonText: any;
37
+ };
34
38
  typeClass(): string;
35
- }> & import("vue-demi").ComponentCustomProperties & Readonly<import("vue-demi").ExtractPropTypes<{}>>, any, any, any, import("vue-demi").ComponentComputedOptions, import("vue-demi").ComponentMethodOptions> & import("vue/types/v3-component-options").ComponentOptionsBase<Readonly<import("vue-demi").ExtractPropTypes<{}>>, any, {
39
+ }> & {
40
+ t(path: string, params?: Record<string, any> | undefined): string;
41
+ } & import("vue-demi").ComponentCustomProperties & Readonly<import("vue-demi").ExtractPropTypes<{}>>, any, any, any, import("vue-demi").ComponentComputedOptions, import("vue-demi").ComponentMethodOptions> & import("vue/types/v3-component-options").ComponentOptionsBase<Readonly<import("vue-demi").ExtractPropTypes<{}>>, any, {
36
42
  visible: boolean;
37
43
  width: number;
38
44
  title: string;
@@ -40,16 +46,24 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
40
46
  type: string;
41
47
  customClass: string;
42
48
  iconClass: string;
43
- cancelButtonText: string;
44
- confirmButtonText: string;
49
+ cancelButtonText: undefined;
50
+ confirmButtonText: undefined;
45
51
  loading: boolean;
46
52
  onCancel: null;
47
53
  onConfirm: null;
48
54
  callback: null;
49
55
  dangerouslyUseHTMLString: boolean;
50
56
  }, {
57
+ localeText(): {
58
+ cancelButtonText: any;
59
+ confirmButtonText: any;
60
+ };
51
61
  typeClass(): string;
52
- }, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, {}> & {
62
+ }, {}, {
63
+ methods: {
64
+ t(path: string, params?: Record<string, any> | undefined): string;
65
+ };
66
+ }, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, {}> & {
53
67
  props: {};
54
68
  } & PluginObject<undefined>;
55
69
  export default _default;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const commonUtils = require("@94ai/common-utils");
3
4
  const vueDemi = require("vue-demi");
4
5
  const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
5
6
  const typeMap = {
@@ -10,6 +11,7 @@ const typeMap = {
10
11
  };
11
12
  const _sfc_main = vueDemi.defineComponent({
12
13
  name: "nf-confirm",
14
+ mixins: [commonUtils.LocaleMixin],
13
15
  data() {
14
16
  return {
15
17
  visible: false,
@@ -19,8 +21,8 @@ const _sfc_main = vueDemi.defineComponent({
19
21
  type: "",
20
22
  customClass: "",
21
23
  iconClass: "",
22
- cancelButtonText: "取消",
23
- confirmButtonText: "确定",
24
+ cancelButtonText: void 0,
25
+ confirmButtonText: void 0,
24
26
  loading: false,
25
27
  onCancel: null,
26
28
  onConfirm: null,
@@ -29,6 +31,13 @@ const _sfc_main = vueDemi.defineComponent({
29
31
  };
30
32
  },
31
33
  computed: {
34
+ localeText() {
35
+ var _a, _b;
36
+ return {
37
+ cancelButtonText: (_a = this.cancelButtonText) != null ? _a : this.t("nf.common.cancel"),
38
+ confirmButtonText: (_b = this.confirmButtonText) != null ? _b : this.t("nf.common.confirm")
39
+ };
40
+ },
32
41
  typeClass() {
33
42
  return this.type && typeMap[this.type] ? `el-icon-${typeMap[this.type]}` : "";
34
43
  }
@@ -102,7 +111,7 @@ var _sfc_render = function render() {
102
111
  on: {
103
112
  "click": _vm.handleCancel
104
113
  }
105
- }, [_vm._v(_vm._s(_vm.cancelButtonText))]), _c("nf-button", {
114
+ }, [_vm._v(_vm._s(_vm.localeText.cancelButtonText))]), _c("nf-button", {
106
115
  attrs: {
107
116
  "type": "primary",
108
117
  "loading": _vm.loading
@@ -110,7 +119,7 @@ var _sfc_render = function render() {
110
119
  on: {
111
120
  "click": _vm.handleConfirm
112
121
  }
113
- }, [_vm._v(_vm._s(_vm.confirmButtonText))])], 1)])])])], 1);
122
+ }, [_vm._v(_vm._s(_vm.localeText.confirmButtonText))])], 1)])])])], 1);
114
123
  };
115
124
  var _sfc_staticRenderFns = [];
116
125
  var __component__ = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
@@ -130,7 +139,6 @@ function merge(target) {
130
139
  return target;
131
140
  }
132
141
  const ConfirmConstructor = vueDemi.Vue2.extend(NfConfirm);
133
- let currentMsg = null;
134
142
  const Confirm = function(options) {
135
143
  var _a;
136
144
  if ((_a = vueDemi.Vue2.prototype) == null ? void 0 : _a.$isServer)
@@ -139,21 +147,18 @@ const Confirm = function(options) {
139
147
  const instance = new ConfirmConstructor({
140
148
  data: options
141
149
  });
142
- instance.callback = defaultCallBack;
143
150
  instance.$mount();
144
151
  document.body.appendChild(instance.$el);
145
152
  instance.visible = true;
146
153
  return new Promise((resolve, reject) => {
147
- currentMsg = { resolve, reject };
154
+ instance.callback = (action, done) => {
155
+ if (action === "confirm")
156
+ resolve(done);
157
+ else
158
+ reject();
159
+ };
148
160
  });
149
161
  };
150
- const defaultCallBack = (action, done) => {
151
- if (action === "confirm") {
152
- currentMsg.resolve(done);
153
- } else {
154
- currentMsg.reject();
155
- }
156
- };
157
162
  NfConfirm.install = (app) => {
158
163
  app.component("nf-confirm", NfConfirm);
159
164
  app.prototype.$openConfirm = Confirm;
@@ -1,3 +1,4 @@
1
+ import { LocaleMixin } from "@94ai/common-utils";
1
2
  import { defineComponent, Vue2 } from "vue-demi";
2
3
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
3
4
  const typeMap = {
@@ -8,6 +9,7 @@ const typeMap = {
8
9
  };
9
10
  const _sfc_main = defineComponent({
10
11
  name: "nf-confirm",
12
+ mixins: [LocaleMixin],
11
13
  data() {
12
14
  return {
13
15
  visible: false,
@@ -17,8 +19,8 @@ const _sfc_main = defineComponent({
17
19
  type: "",
18
20
  customClass: "",
19
21
  iconClass: "",
20
- cancelButtonText: "取消",
21
- confirmButtonText: "确定",
22
+ cancelButtonText: void 0,
23
+ confirmButtonText: void 0,
22
24
  loading: false,
23
25
  onCancel: null,
24
26
  onConfirm: null,
@@ -27,6 +29,13 @@ const _sfc_main = defineComponent({
27
29
  };
28
30
  },
29
31
  computed: {
32
+ localeText() {
33
+ var _a, _b;
34
+ return {
35
+ cancelButtonText: (_a = this.cancelButtonText) != null ? _a : this.t("nf.common.cancel"),
36
+ confirmButtonText: (_b = this.confirmButtonText) != null ? _b : this.t("nf.common.confirm")
37
+ };
38
+ },
30
39
  typeClass() {
31
40
  return this.type && typeMap[this.type] ? `el-icon-${typeMap[this.type]}` : "";
32
41
  }
@@ -100,7 +109,7 @@ var _sfc_render = function render() {
100
109
  on: {
101
110
  "click": _vm.handleCancel
102
111
  }
103
- }, [_vm._v(_vm._s(_vm.cancelButtonText))]), _c("nf-button", {
112
+ }, [_vm._v(_vm._s(_vm.localeText.cancelButtonText))]), _c("nf-button", {
104
113
  attrs: {
105
114
  "type": "primary",
106
115
  "loading": _vm.loading
@@ -108,7 +117,7 @@ var _sfc_render = function render() {
108
117
  on: {
109
118
  "click": _vm.handleConfirm
110
119
  }
111
- }, [_vm._v(_vm._s(_vm.confirmButtonText))])], 1)])])])], 1);
120
+ }, [_vm._v(_vm._s(_vm.localeText.confirmButtonText))])], 1)])])])], 1);
112
121
  };
113
122
  var _sfc_staticRenderFns = [];
114
123
  var __component__ = /* @__PURE__ */ normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
@@ -128,7 +137,6 @@ function merge(target) {
128
137
  return target;
129
138
  }
130
139
  const ConfirmConstructor = Vue2.extend(NfConfirm);
131
- let currentMsg = null;
132
140
  const Confirm = function(options) {
133
141
  var _a;
134
142
  if ((_a = Vue2.prototype) == null ? void 0 : _a.$isServer)
@@ -137,21 +145,18 @@ const Confirm = function(options) {
137
145
  const instance = new ConfirmConstructor({
138
146
  data: options
139
147
  });
140
- instance.callback = defaultCallBack;
141
148
  instance.$mount();
142
149
  document.body.appendChild(instance.$el);
143
150
  instance.visible = true;
144
151
  return new Promise((resolve, reject) => {
145
- currentMsg = { resolve, reject };
152
+ instance.callback = (action, done) => {
153
+ if (action === "confirm")
154
+ resolve(done);
155
+ else
156
+ reject();
157
+ };
146
158
  });
147
159
  };
148
- const defaultCallBack = (action, done) => {
149
- if (action === "confirm") {
150
- currentMsg.resolve(done);
151
- } else {
152
- currentMsg.reject();
153
- }
154
- };
155
160
  NfConfirm.install = (app) => {
156
161
  app.component("nf-confirm", NfConfirm);
157
162
  app.prototype.$openConfirm = Confirm;
@@ -6,14 +6,22 @@ declare var _default: import("vue-demi").DefineComponent<{}, any, {
6
6
  type: string;
7
7
  customClass: string;
8
8
  iconClass: string;
9
- cancelButtonText: string;
10
- confirmButtonText: string;
9
+ cancelButtonText: undefined;
10
+ confirmButtonText: undefined;
11
11
  loading: boolean;
12
12
  onCancel: null;
13
13
  onConfirm: null;
14
14
  callback: null;
15
15
  dangerouslyUseHTMLString: boolean;
16
16
  }, {
17
+ localeText(): {
18
+ cancelButtonText: any;
19
+ confirmButtonText: any;
20
+ };
17
21
  typeClass(): string;
18
- }, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue-demi").ExtractPropTypes<{}>>, {}>;
22
+ }, {}, {
23
+ methods: {
24
+ t(path: string, params?: Record<string, any> | undefined): string;
25
+ };
26
+ }, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue-demi").ExtractPropTypes<{}>>, {}>;
19
27
  export default _default;
package/package/main.ts CHANGED
@@ -2,7 +2,6 @@ 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
6
5
 
7
6
  const Confirm = function(options) {
8
7
  if (Vue2!.prototype?.$isServer) return;
@@ -10,21 +9,16 @@ const Confirm = function(options) {
10
9
  const instance = new ConfirmConstructor({
11
10
  data: options
12
11
  });
13
- instance.callback = defaultCallBack
14
12
  instance.$mount()
15
13
  document.body.appendChild(instance.$el);
16
14
  instance.visible = true;
17
15
  return new Promise((resolve, reject) => {
18
- currentMsg = { resolve, reject }
16
+ // Each dialog owns its promise; another open dialog must not replace it.
17
+ instance.callback = (action: 'cancel' | 'confirm', done: Function) => {
18
+ if (action === 'confirm') resolve(done)
19
+ else reject()
20
+ }
19
21
  })
20
22
  };
21
23
 
22
- const defaultCallBack = (action: 'cancel' | 'confirm', done: Function) => {
23
- if (action === 'confirm') {
24
- currentMsg!.resolve(done)
25
- } else {
26
- currentMsg!.reject()
27
- }
28
- }
29
-
30
24
  export default Confirm
@@ -8,8 +8,8 @@
8
8
  <p class="nf-confirm__content" v-if="!dangerouslyUseHTMLString">{{ message }}</p>
9
9
  <p class="nf-confirm__content" v-else v-html="message"></p>
10
10
  <div class="nf-confirm__btns">
11
- <nf-button @click="handleCancel">{{ cancelButtonText }}</nf-button>
12
- <nf-button type="primary" :loading="loading" @click="handleConfirm">{{ confirmButtonText }}</nf-button>
11
+ <nf-button @click="handleCancel">{{ localeText.cancelButtonText }}</nf-button>
12
+ <nf-button type="primary" :loading="loading" @click="handleConfirm">{{ localeText.confirmButtonText }}</nf-button>
13
13
  </div>
14
14
  </div>
15
15
  </div>
@@ -18,6 +18,8 @@
18
18
  </template>
19
19
 
20
20
  <script>
21
+ import { LocaleMixin } from '@94ai/common-utils'
22
+
21
23
  import { defineComponent } from 'vue-demi'
22
24
 
23
25
  const typeMap = {
@@ -29,6 +31,7 @@ const typeMap = {
29
31
 
30
32
  export default defineComponent({
31
33
  name: "nf-confirm",
34
+ mixins: [LocaleMixin],
32
35
  data() {
33
36
  return {
34
37
  visible: false,
@@ -38,8 +41,8 @@ export default defineComponent({
38
41
  type: '',
39
42
  customClass: '',
40
43
  iconClass: '',
41
- cancelButtonText: '取消',
42
- confirmButtonText: '确定',
44
+ cancelButtonText: undefined,
45
+ confirmButtonText: undefined,
43
46
  loading: false,
44
47
  onCancel: null,
45
48
  onConfirm: null,
@@ -48,6 +51,12 @@ export default defineComponent({
48
51
  }
49
52
  },
50
53
  computed: {
54
+ localeText() {
55
+ return {
56
+ cancelButtonText: this.cancelButtonText ?? this.t('nf.common.cancel'),
57
+ confirmButtonText: this.confirmButtonText ?? this.t('nf.common.confirm'),
58
+ }
59
+ },
51
60
  typeClass() {
52
61
  return this.type && typeMap[this.type] ? `el-icon-${ typeMap[this.type] }` : '';
53
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-confirm",
3
- "version": "8.3.23",
3
+ "version": "10.0.0",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zhongzhenjie <1476686104@qq.com>",
@@ -11,11 +11,13 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
14
+ "url": "http://gitlab.94ai.pro/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-theme-chalk": "^8.3.23",
18
- "vue-demi": "^0.14.5"
17
+ "@94ai/common-utils": "^10.0.0",
18
+ "@94ai/nf-theme-chalk": "^10.0.0",
19
+ "vue-demi": "^0.14.5",
20
+ "@94ai/vue2-runtime-helpers": "1.0.1"
19
21
  },
20
22
  "peerDependenciesMeta": {
21
23
  "@vue/composition-api": {
@@ -24,11 +26,10 @@
24
26
  },
25
27
  "peerDependencies": {
26
28
  "@vue/composition-api": "^1.0.0-rc.1",
27
- "element-ui": ">=2.13.2",
28
- "vue": "^2.0.0 || >=3.0.0"
29
+ "vue": "^2.0.0 || >=3.0.0",
30
+ "element-ui": ">=2.13.2"
29
31
  },
30
32
  "types": "lib/index.d.ts",
31
33
  "main": "lib/nf-confirm.cjs.js",
32
- "module": "lib/nf-confirm.esm-bundler.js",
33
- "gitHead": "74e871c7972dc4576480bee02b1dc61a3eafc6ba"
34
+ "module": "lib/nf-confirm.esm-bundler.js"
34
35
  }