@94ai/nf-confirm 0.0.1
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/.eslintrc.cjs +49 -0
- package/README.md +15 -0
- package/components.d.ts +8 -0
- package/lib/index.d.ts +56 -0
- package/lib/main.d.ts +2 -0
- package/lib/nf-confirm.cjs.js +160 -0
- package/lib/nf-confirm.esm-bundler.js +160 -0
- package/lib/nf-confirm.vue.d.ts +19 -0
- package/lib/style/css.d.ts +1 -0
- package/lib/style/css.js +1 -0
- package/lib/style/index.d.ts +1 -0
- package/lib/style/index.js +1 -0
- package/package/index.ts +14 -0
- package/package/main.ts +30 -0
- package/package/nf-confirm.vue +86 -0
- package/package/style/css.ts +1 -0
- package/package/style/index.ts +1 -0
- package/package.json +34 -0
- package/postcss.config.js +8 -0
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
"root": true,
|
|
3
|
+
"env": {
|
|
4
|
+
"node": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"plugin:vue/essential"
|
|
8
|
+
],
|
|
9
|
+
"parser": "vue-eslint-parser",
|
|
10
|
+
"parserOptions": {
|
|
11
|
+
"parser": "@typescript-eslint/parser",
|
|
12
|
+
"ecmaVersion": 2020,
|
|
13
|
+
"sourceType": "module"
|
|
14
|
+
},
|
|
15
|
+
"rules": {
|
|
16
|
+
"@typescript-eslint/ban-ts-ignore": "off",
|
|
17
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
19
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
20
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
21
|
+
"vue/custom-event-name-casing": "off",
|
|
22
|
+
"no-use-before-define": "off",
|
|
23
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
24
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
25
|
+
"@typescript-eslint/ban-types": "off",
|
|
26
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
27
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
28
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
29
|
+
"vue/multi-word-component-names": [
|
|
30
|
+
"error",
|
|
31
|
+
{
|
|
32
|
+
"ignores": [
|
|
33
|
+
"index"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"no-console": "warn",
|
|
38
|
+
"no-debugger": "warn",
|
|
39
|
+
"prettier/prettier": [
|
|
40
|
+
"error",
|
|
41
|
+
{
|
|
42
|
+
"tabWidth": 2,
|
|
43
|
+
"singleQuote": true,
|
|
44
|
+
"semi": false,
|
|
45
|
+
"endOfLine": "auto"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# `@94ai/nf-confirm`
|
|
2
|
+
|
|
3
|
+
对话框组件
|
|
4
|
+
|
|
5
|
+
## HomePage
|
|
6
|
+
|
|
7
|
+
官网地址: https://oss.xccjh.top/common-ui/#/ai-index
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
const NfConfirm = import('@94ai/nf-confirm'); // or const NfMessage = require('@94ai/nf-confirm');
|
|
13
|
+
|
|
14
|
+
Vue.use(NfConfirm)
|
|
15
|
+
```
|
package/components.d.ts
ADDED
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PluginObject } from 'vue-demi';
|
|
2
|
+
import Main from './main';
|
|
3
|
+
declare const _default: import("vue/types/v3-component-public-instance").ComponentPublicInstanceConstructor<import("vue/types/v3-component-public-instance").Vue3Instance<{
|
|
4
|
+
visible: boolean;
|
|
5
|
+
width: number;
|
|
6
|
+
title: string;
|
|
7
|
+
message: string;
|
|
8
|
+
type: string;
|
|
9
|
+
customClass: string;
|
|
10
|
+
iconClass: string;
|
|
11
|
+
cancelButtonText: string;
|
|
12
|
+
confirmButtonText: string;
|
|
13
|
+
loading: boolean;
|
|
14
|
+
onCancel: null;
|
|
15
|
+
onConfirm: null;
|
|
16
|
+
callback: null;
|
|
17
|
+
dangerouslyUseHTMLString: boolean;
|
|
18
|
+
}, 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> & {
|
|
19
|
+
visible: boolean;
|
|
20
|
+
width: number;
|
|
21
|
+
title: string;
|
|
22
|
+
message: string;
|
|
23
|
+
type: string;
|
|
24
|
+
customClass: string;
|
|
25
|
+
iconClass: string;
|
|
26
|
+
cancelButtonText: string;
|
|
27
|
+
confirmButtonText: string;
|
|
28
|
+
loading: boolean;
|
|
29
|
+
onCancel: null;
|
|
30
|
+
onConfirm: null;
|
|
31
|
+
callback: null;
|
|
32
|
+
dangerouslyUseHTMLString: boolean;
|
|
33
|
+
} & import("vue/types/v3-component-options").ExtractComputedReturns<{
|
|
34
|
+
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, {
|
|
36
|
+
visible: boolean;
|
|
37
|
+
width: number;
|
|
38
|
+
title: string;
|
|
39
|
+
message: string;
|
|
40
|
+
type: string;
|
|
41
|
+
customClass: string;
|
|
42
|
+
iconClass: string;
|
|
43
|
+
cancelButtonText: string;
|
|
44
|
+
confirmButtonText: string;
|
|
45
|
+
loading: boolean;
|
|
46
|
+
onCancel: null;
|
|
47
|
+
onConfirm: null;
|
|
48
|
+
callback: null;
|
|
49
|
+
dangerouslyUseHTMLString: boolean;
|
|
50
|
+
}, {
|
|
51
|
+
typeClass(): string;
|
|
52
|
+
}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, {}> & {
|
|
53
|
+
props: {};
|
|
54
|
+
} & PluginObject<undefined>;
|
|
55
|
+
export default _default;
|
|
56
|
+
export { Main as Confirm };
|
package/lib/main.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const vueDemi = require("vue-demi");
|
|
4
|
+
const vue2RuntimeHelpers = require("@94ai/vue2-runtime-helpers");
|
|
5
|
+
const typeMap = {
|
|
6
|
+
success: "success",
|
|
7
|
+
info: "info",
|
|
8
|
+
warning: "warning",
|
|
9
|
+
error: "error"
|
|
10
|
+
};
|
|
11
|
+
const _sfc_main = vueDemi.defineComponent({
|
|
12
|
+
name: "nf-confirm",
|
|
13
|
+
data() {
|
|
14
|
+
return {
|
|
15
|
+
visible: false,
|
|
16
|
+
width: 400,
|
|
17
|
+
title: "",
|
|
18
|
+
message: "",
|
|
19
|
+
type: "",
|
|
20
|
+
customClass: "",
|
|
21
|
+
iconClass: "",
|
|
22
|
+
cancelButtonText: "取消",
|
|
23
|
+
confirmButtonText: "确定",
|
|
24
|
+
loading: false,
|
|
25
|
+
onCancel: null,
|
|
26
|
+
onConfirm: null,
|
|
27
|
+
callback: null,
|
|
28
|
+
dangerouslyUseHTMLString: false
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
computed: {
|
|
32
|
+
typeClass() {
|
|
33
|
+
return this.type && typeMap[this.type] ? `el-icon-${typeMap[this.type]}` : "";
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
methods: {
|
|
37
|
+
close() {
|
|
38
|
+
this.loading = false;
|
|
39
|
+
this.visible = false;
|
|
40
|
+
this.$nextTick(() => {
|
|
41
|
+
this.$destroy(true);
|
|
42
|
+
this.$el.parentNode.removeChild(this.$el);
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
handleCancel() {
|
|
46
|
+
if (typeof this.onCancel === "function") {
|
|
47
|
+
this.onCancel(this.close);
|
|
48
|
+
} else {
|
|
49
|
+
this.close();
|
|
50
|
+
this.callback && this.callback("cancel");
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
handleConfirm() {
|
|
54
|
+
if (typeof this.onConfirm === "function") {
|
|
55
|
+
this.loading = true;
|
|
56
|
+
this.onConfirm(this.close);
|
|
57
|
+
} else {
|
|
58
|
+
this.loading = true;
|
|
59
|
+
this.callback && this.callback("confirm", this.close);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
var _sfc_render = function render() {
|
|
65
|
+
var _vm = this, _c = _vm._self._c;
|
|
66
|
+
_vm._self._setupProxy;
|
|
67
|
+
return _c("div", {
|
|
68
|
+
class: ["nf-confirm", _vm.customClass]
|
|
69
|
+
}, [_c("el-dialog", {
|
|
70
|
+
attrs: {
|
|
71
|
+
"visible": _vm.visible,
|
|
72
|
+
"showClose": false,
|
|
73
|
+
"width": `${_vm.width}px`,
|
|
74
|
+
"close-on-click-modal": false
|
|
75
|
+
},
|
|
76
|
+
on: {
|
|
77
|
+
"update:visible": function($event) {
|
|
78
|
+
_vm.visible = $event;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}, [_c("div", {
|
|
82
|
+
staticClass: "nf-confirm__wrapper"
|
|
83
|
+
}, [_vm.type || _vm.iconClass ? _c("i", {
|
|
84
|
+
staticClass: "nf-confirm__icon",
|
|
85
|
+
class: [_vm.typeClass, _vm.iconClass]
|
|
86
|
+
}) : _vm._e(), _c("div", {
|
|
87
|
+
staticClass: "nf-confirm__inner"
|
|
88
|
+
}, [_c("h2", {
|
|
89
|
+
staticClass: "nf-confirm__title"
|
|
90
|
+
}, [_vm._v(_vm._s(_vm.title))]), !_vm.dangerouslyUseHTMLString ? _c("p", {
|
|
91
|
+
staticClass: "nf-confirm__content"
|
|
92
|
+
}, [_vm._v(_vm._s(_vm.message))]) : _c("p", {
|
|
93
|
+
staticClass: "nf-confirm__content",
|
|
94
|
+
domProps: {
|
|
95
|
+
"innerHTML": _vm._s(_vm.message)
|
|
96
|
+
}
|
|
97
|
+
}), _c("div", {
|
|
98
|
+
staticClass: "nf-confirm__btns"
|
|
99
|
+
}, [_c("nf-button", {
|
|
100
|
+
on: {
|
|
101
|
+
"click": _vm.handleCancel
|
|
102
|
+
}
|
|
103
|
+
}, [_vm._v(_vm._s(_vm.cancelButtonText))]), _c("nf-button", {
|
|
104
|
+
attrs: {
|
|
105
|
+
"type": "primary",
|
|
106
|
+
"loading": _vm.loading
|
|
107
|
+
},
|
|
108
|
+
on: {
|
|
109
|
+
"click": _vm.handleConfirm
|
|
110
|
+
}
|
|
111
|
+
}, [_vm._v(_vm._s(_vm.confirmButtonText))])], 1)])])])], 1);
|
|
112
|
+
};
|
|
113
|
+
var _sfc_staticRenderFns = [];
|
|
114
|
+
var __component__ = /* @__PURE__ */ vue2RuntimeHelpers.normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
|
|
115
|
+
const NfConfirm = __component__.exports;
|
|
116
|
+
function merge(target) {
|
|
117
|
+
for (let i = 1, j = arguments.length; i < j; i++) {
|
|
118
|
+
let source = arguments[i] || {};
|
|
119
|
+
for (let prop in source) {
|
|
120
|
+
if (source.hasOwnProperty(prop)) {
|
|
121
|
+
let value = source[prop];
|
|
122
|
+
if (value !== void 0) {
|
|
123
|
+
target[prop] = value;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return target;
|
|
129
|
+
}
|
|
130
|
+
const ConfirmConstructor = vueDemi.Vue2.extend(NfConfirm);
|
|
131
|
+
let currentMsg = null;
|
|
132
|
+
const Confirm = function(options) {
|
|
133
|
+
var _a;
|
|
134
|
+
if ((_a = vueDemi.Vue2.prototype) == null ? void 0 : _a.$isServer)
|
|
135
|
+
return;
|
|
136
|
+
options = merge({}, options);
|
|
137
|
+
const instance = new ConfirmConstructor({
|
|
138
|
+
data: options
|
|
139
|
+
});
|
|
140
|
+
instance.callback = defaultCallBack;
|
|
141
|
+
instance.$mount();
|
|
142
|
+
document.body.appendChild(instance.$el);
|
|
143
|
+
instance.visible = true;
|
|
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
|
+
}
|
|
154
|
+
};
|
|
155
|
+
NfConfirm.install = (app) => {
|
|
156
|
+
app.component("nf-confirm", NfConfirm);
|
|
157
|
+
app.prototype.$openConfirm = Confirm;
|
|
158
|
+
};
|
|
159
|
+
exports.Confirm = Confirm;
|
|
160
|
+
exports.default = NfConfirm;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { defineComponent, Vue2 } from "vue-demi";
|
|
2
|
+
import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
|
|
3
|
+
const typeMap = {
|
|
4
|
+
success: "success",
|
|
5
|
+
info: "info",
|
|
6
|
+
warning: "warning",
|
|
7
|
+
error: "error"
|
|
8
|
+
};
|
|
9
|
+
const _sfc_main = defineComponent({
|
|
10
|
+
name: "nf-confirm",
|
|
11
|
+
data() {
|
|
12
|
+
return {
|
|
13
|
+
visible: false,
|
|
14
|
+
width: 400,
|
|
15
|
+
title: "",
|
|
16
|
+
message: "",
|
|
17
|
+
type: "",
|
|
18
|
+
customClass: "",
|
|
19
|
+
iconClass: "",
|
|
20
|
+
cancelButtonText: "取消",
|
|
21
|
+
confirmButtonText: "确定",
|
|
22
|
+
loading: false,
|
|
23
|
+
onCancel: null,
|
|
24
|
+
onConfirm: null,
|
|
25
|
+
callback: null,
|
|
26
|
+
dangerouslyUseHTMLString: false
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
computed: {
|
|
30
|
+
typeClass() {
|
|
31
|
+
return this.type && typeMap[this.type] ? `el-icon-${typeMap[this.type]}` : "";
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
methods: {
|
|
35
|
+
close() {
|
|
36
|
+
this.loading = false;
|
|
37
|
+
this.visible = false;
|
|
38
|
+
this.$nextTick(() => {
|
|
39
|
+
this.$destroy(true);
|
|
40
|
+
this.$el.parentNode.removeChild(this.$el);
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
handleCancel() {
|
|
44
|
+
if (typeof this.onCancel === "function") {
|
|
45
|
+
this.onCancel(this.close);
|
|
46
|
+
} else {
|
|
47
|
+
this.close();
|
|
48
|
+
this.callback && this.callback("cancel");
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
handleConfirm() {
|
|
52
|
+
if (typeof this.onConfirm === "function") {
|
|
53
|
+
this.loading = true;
|
|
54
|
+
this.onConfirm(this.close);
|
|
55
|
+
} else {
|
|
56
|
+
this.loading = true;
|
|
57
|
+
this.callback && this.callback("confirm", this.close);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var _sfc_render = function render() {
|
|
63
|
+
var _vm = this, _c = _vm._self._c;
|
|
64
|
+
_vm._self._setupProxy;
|
|
65
|
+
return _c("div", {
|
|
66
|
+
class: ["nf-confirm", _vm.customClass]
|
|
67
|
+
}, [_c("el-dialog", {
|
|
68
|
+
attrs: {
|
|
69
|
+
"visible": _vm.visible,
|
|
70
|
+
"showClose": false,
|
|
71
|
+
"width": `${_vm.width}px`,
|
|
72
|
+
"close-on-click-modal": false
|
|
73
|
+
},
|
|
74
|
+
on: {
|
|
75
|
+
"update:visible": function($event) {
|
|
76
|
+
_vm.visible = $event;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, [_c("div", {
|
|
80
|
+
staticClass: "nf-confirm__wrapper"
|
|
81
|
+
}, [_vm.type || _vm.iconClass ? _c("i", {
|
|
82
|
+
staticClass: "nf-confirm__icon",
|
|
83
|
+
class: [_vm.typeClass, _vm.iconClass]
|
|
84
|
+
}) : _vm._e(), _c("div", {
|
|
85
|
+
staticClass: "nf-confirm__inner"
|
|
86
|
+
}, [_c("h2", {
|
|
87
|
+
staticClass: "nf-confirm__title"
|
|
88
|
+
}, [_vm._v(_vm._s(_vm.title))]), !_vm.dangerouslyUseHTMLString ? _c("p", {
|
|
89
|
+
staticClass: "nf-confirm__content"
|
|
90
|
+
}, [_vm._v(_vm._s(_vm.message))]) : _c("p", {
|
|
91
|
+
staticClass: "nf-confirm__content",
|
|
92
|
+
domProps: {
|
|
93
|
+
"innerHTML": _vm._s(_vm.message)
|
|
94
|
+
}
|
|
95
|
+
}), _c("div", {
|
|
96
|
+
staticClass: "nf-confirm__btns"
|
|
97
|
+
}, [_c("nf-button", {
|
|
98
|
+
on: {
|
|
99
|
+
"click": _vm.handleCancel
|
|
100
|
+
}
|
|
101
|
+
}, [_vm._v(_vm._s(_vm.cancelButtonText))]), _c("nf-button", {
|
|
102
|
+
attrs: {
|
|
103
|
+
"type": "primary",
|
|
104
|
+
"loading": _vm.loading
|
|
105
|
+
},
|
|
106
|
+
on: {
|
|
107
|
+
"click": _vm.handleConfirm
|
|
108
|
+
}
|
|
109
|
+
}, [_vm._v(_vm._s(_vm.confirmButtonText))])], 1)])])])], 1);
|
|
110
|
+
};
|
|
111
|
+
var _sfc_staticRenderFns = [];
|
|
112
|
+
var __component__ = /* @__PURE__ */ normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, null, null, null);
|
|
113
|
+
const NfConfirm = __component__.exports;
|
|
114
|
+
function merge(target) {
|
|
115
|
+
for (let i = 1, j = arguments.length; i < j; i++) {
|
|
116
|
+
let source = arguments[i] || {};
|
|
117
|
+
for (let prop in source) {
|
|
118
|
+
if (source.hasOwnProperty(prop)) {
|
|
119
|
+
let value = source[prop];
|
|
120
|
+
if (value !== void 0) {
|
|
121
|
+
target[prop] = value;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return target;
|
|
127
|
+
}
|
|
128
|
+
const ConfirmConstructor = Vue2.extend(NfConfirm);
|
|
129
|
+
let currentMsg = null;
|
|
130
|
+
const Confirm = function(options) {
|
|
131
|
+
var _a;
|
|
132
|
+
if ((_a = Vue2.prototype) == null ? void 0 : _a.$isServer)
|
|
133
|
+
return;
|
|
134
|
+
options = merge({}, options);
|
|
135
|
+
const instance = new ConfirmConstructor({
|
|
136
|
+
data: options
|
|
137
|
+
});
|
|
138
|
+
instance.callback = defaultCallBack;
|
|
139
|
+
instance.$mount();
|
|
140
|
+
document.body.appendChild(instance.$el);
|
|
141
|
+
instance.visible = true;
|
|
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
|
+
}
|
|
152
|
+
};
|
|
153
|
+
NfConfirm.install = (app) => {
|
|
154
|
+
app.component("nf-confirm", NfConfirm);
|
|
155
|
+
app.prototype.$openConfirm = Confirm;
|
|
156
|
+
};
|
|
157
|
+
export {
|
|
158
|
+
Confirm,
|
|
159
|
+
NfConfirm as default
|
|
160
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare var _default: import("vue-demi").DefineComponent<{}, any, {
|
|
2
|
+
visible: boolean;
|
|
3
|
+
width: number;
|
|
4
|
+
title: string;
|
|
5
|
+
message: string;
|
|
6
|
+
type: string;
|
|
7
|
+
customClass: string;
|
|
8
|
+
iconClass: string;
|
|
9
|
+
cancelButtonText: string;
|
|
10
|
+
confirmButtonText: string;
|
|
11
|
+
loading: boolean;
|
|
12
|
+
onCancel: null;
|
|
13
|
+
onConfirm: null;
|
|
14
|
+
callback: null;
|
|
15
|
+
dangerouslyUseHTMLString: boolean;
|
|
16
|
+
}, {
|
|
17
|
+
typeClass(): string;
|
|
18
|
+
}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue-demi").ExtractPropTypes<{}>>, {}>;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/lib/style/css.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/css/nf-confirm.css'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/nf-confirm.scss'
|
package/package/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import NfConfirm from './nf-confirm.vue'
|
|
2
|
+
import { Vue2, PluginObject } from 'vue-demi'
|
|
3
|
+
import Main from './main'
|
|
4
|
+
|
|
5
|
+
NfConfirm.install = (app: typeof Vue2) => {
|
|
6
|
+
app!.component('nf-confirm', NfConfirm)
|
|
7
|
+
app!.prototype.$openConfirm = Main
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default NfConfirm as typeof NfConfirm & PluginObject<undefined>
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
Main as Confirm
|
|
14
|
+
}
|
package/package/main.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Vue2 } from 'vue-demi';
|
|
2
|
+
import Main from './nf-confirm.vue';
|
|
3
|
+
import merge from 'element-ui/src/utils/merge';
|
|
4
|
+
const ConfirmConstructor = Vue2!.extend(Main);
|
|
5
|
+
let currentMsg: { resolve: Function, reject: Function } | null = null
|
|
6
|
+
|
|
7
|
+
const Confirm = function(options) {
|
|
8
|
+
if (Vue2!.prototype?.$isServer) return;
|
|
9
|
+
options = merge({}, options);
|
|
10
|
+
const instance = new ConfirmConstructor({
|
|
11
|
+
data: options
|
|
12
|
+
});
|
|
13
|
+
instance.callback = defaultCallBack
|
|
14
|
+
instance.$mount()
|
|
15
|
+
document.body.appendChild(instance.$el);
|
|
16
|
+
instance.visible = true;
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
currentMsg = { resolve, reject }
|
|
19
|
+
})
|
|
20
|
+
};
|
|
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
|
+
|
|
30
|
+
export default Confirm
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="['nf-confirm', customClass]">
|
|
3
|
+
<el-dialog :visible.sync="visible" :showClose="false" :width="`${width}px`" :close-on-click-modal="false">
|
|
4
|
+
<div class="nf-confirm__wrapper">
|
|
5
|
+
<i class="nf-confirm__icon" :class="[ typeClass, iconClass ]" v-if="type || iconClass"></i>
|
|
6
|
+
<div class="nf-confirm__inner">
|
|
7
|
+
<h2 class="nf-confirm__title">{{ title }}</h2>
|
|
8
|
+
<p class="nf-confirm__content" v-if="!dangerouslyUseHTMLString">{{ message }}</p>
|
|
9
|
+
<p class="nf-confirm__content" v-else v-html="message"></p>
|
|
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>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</el-dialog>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { defineComponent } from 'vue-demi'
|
|
22
|
+
|
|
23
|
+
const typeMap = {
|
|
24
|
+
success: 'success',
|
|
25
|
+
info: 'info',
|
|
26
|
+
warning: 'warning',
|
|
27
|
+
error: 'error'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default defineComponent({
|
|
31
|
+
name: "nf-confirm",
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
visible: false,
|
|
35
|
+
width: 400,
|
|
36
|
+
title: '',
|
|
37
|
+
message: '',
|
|
38
|
+
type: '',
|
|
39
|
+
customClass: '',
|
|
40
|
+
iconClass: '',
|
|
41
|
+
cancelButtonText: '取消',
|
|
42
|
+
confirmButtonText: '确定',
|
|
43
|
+
loading: false,
|
|
44
|
+
onCancel: null,
|
|
45
|
+
onConfirm: null,
|
|
46
|
+
callback: null,
|
|
47
|
+
dangerouslyUseHTMLString: false,
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
computed: {
|
|
51
|
+
typeClass() {
|
|
52
|
+
return this.type && typeMap[this.type] ? `el-icon-${ typeMap[this.type] }` : '';
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
methods: {
|
|
56
|
+
close() {
|
|
57
|
+
this.loading = false
|
|
58
|
+
this.visible = false
|
|
59
|
+
this.$nextTick(()=>{
|
|
60
|
+
this.$destroy(true);
|
|
61
|
+
this.$el.parentNode.removeChild(this.$el);
|
|
62
|
+
})
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
handleCancel() {
|
|
66
|
+
if (typeof this.onCancel === 'function') {
|
|
67
|
+
this.onCancel(this.close);
|
|
68
|
+
} else {
|
|
69
|
+
this.close()
|
|
70
|
+
this.callback && this.callback('cancel')
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
handleConfirm() {
|
|
75
|
+
if (typeof this.onConfirm === 'function') {
|
|
76
|
+
this.loading = true
|
|
77
|
+
this.onConfirm(this.close);
|
|
78
|
+
} else {
|
|
79
|
+
this.loading = true
|
|
80
|
+
this.callback && this.callback('confirm', this.close)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
})
|
|
86
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/css/nf-confirm.css'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@94ai/nf-theme-chalk/lib/nf-confirm.scss'
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@94ai/nf-confirm",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "> TODO: description",
|
|
5
|
+
"keywords": [],
|
|
6
|
+
"author": "zhongzhenjie <1476686104@qq.com>",
|
|
7
|
+
"homepage": "https://oss.xccjh.top/common-ui/#/ai-index",
|
|
8
|
+
"license": "ISC",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@94ai/nf-theme-chalk": "^0.0.1",
|
|
18
|
+
"vue-demi": "^0.14.5"
|
|
19
|
+
},
|
|
20
|
+
"peerDependenciesMeta": {
|
|
21
|
+
"@vue/composition-api": {
|
|
22
|
+
"optional": true
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@vue/composition-api": "^1.0.0-rc.1",
|
|
27
|
+
"element-ui": ">=2.13.2",
|
|
28
|
+
"vue": "^2.0.0 || >=3.0.0"
|
|
29
|
+
},
|
|
30
|
+
"types": "lib/index.d.ts",
|
|
31
|
+
"main": "lib/nf-confirm.cjs.js",
|
|
32
|
+
"module": "lib/nf-confirm.esm-bundler.js",
|
|
33
|
+
"gitHead": "ef9ab40a6f84c41fb25e3466321bec9989af191b"
|
|
34
|
+
}
|