@nutui/nutui 3.1.22-beta.5 → 3.1.23-beta.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/CHANGELOG.md +48 -0
- package/README.md +3 -4
- package/dist/nutui.es.js +20412 -4214
- package/dist/nutui.umd.js +20518 -4216
- package/dist/packages/_es/ActionSheet.js +149 -17
- package/dist/packages/_es/Address.js +535 -110
- package/dist/packages/_es/AddressList.js +615 -113
- package/dist/packages/_es/Animate.js +59 -17
- package/dist/packages/_es/Audio.js +257 -53
- package/dist/packages/_es/AudioOperate.js +100 -13
- package/dist/packages/_es/Avatar.js +162 -38
- package/dist/packages/_es/AvatarGroup.js +73 -14
- package/dist/packages/_es/BackTop.js +156 -43
- package/dist/packages/_es/Badge.js +86 -14
- package/dist/packages/_es/Barrage.js +120 -41
- package/dist/packages/_es/Button.js +128 -23
- package/dist/packages/_es/Calendar.js +246 -30
- package/dist/packages/_es/CalendarItem.js +1 -1
- package/dist/packages/_es/Card.js +107 -10
- package/dist/packages/_es/Cascader.js +496 -147
- package/dist/packages/_es/Category.js +58 -15
- package/dist/packages/_es/CategoryPane.js +111 -11
- package/dist/packages/_es/Cell.js +108 -21
- package/dist/packages/_es/CellGroup.js +44 -9
- package/dist/packages/_es/Checkbox.js +134 -29
- package/dist/packages/_es/CheckboxGroup.js +79 -29
- package/dist/packages/_es/CircleProgress.js +150 -28
- package/dist/packages/_es/Col.js +56 -14
- package/dist/packages/_es/Collapse.js +109 -32
- package/dist/packages/_es/CollapseItem.js +253 -59
- package/dist/packages/_es/Comment.js +434 -64
- package/dist/packages/_es/ConfigProvider.js +20 -8
- package/dist/packages/_es/CountDown.js +238 -56
- package/dist/packages/_es/CountUp.js +539 -140
- package/dist/packages/_es/DatePicker.js +315 -98
- package/dist/packages/_es/Dialog.js +289 -60
- package/dist/packages/_es/Divider.js +65 -13
- package/dist/packages/_es/Drag.js +197 -56
- package/dist/packages/_es/Ecard.js +159 -24
- package/dist/packages/_es/Elevator.js +255 -58
- package/dist/packages/_es/Ellipsis.js +200 -58
- package/dist/packages/_es/Empty.js +71 -12
- package/dist/packages/_es/FixedNav.js +122 -15
- package/dist/packages/_es/Form.js +151 -64
- package/dist/packages/_es/FormItem.js +114 -15
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +144 -33
- package/dist/packages/_es/Icon.js +40 -15
- package/dist/packages/_es/Image.js +137 -26
- package/dist/packages/_es/ImagePreview.js +547 -76
- package/dist/packages/_es/Indicator.js +62 -15
- package/dist/packages/_es/InfiniteLoading.js +249 -57
- package/dist/packages/_es/Input.js +433 -51
- package/dist/packages/_es/InputNumber.js +160 -41
- package/dist/packages/_es/Layout.js +5 -4
- package/dist/packages/_es/List.js +106 -18
- package/dist/packages/_es/Menu.js +168 -44
- package/dist/packages/_es/MenuItem.js +173 -37
- package/dist/packages/_es/Navbar.js +192 -30
- package/dist/packages/_es/NoticeBar.js +380 -74
- package/dist/packages/_es/Notify.js +227 -72
- package/dist/packages/_es/NumberKeyboard.js +272 -41
- package/dist/packages/_es/OldPicker.js +457 -130
- package/dist/packages/_es/OverLay.js +98 -24
- package/dist/packages/_es/Pagination.js +157 -39
- package/dist/packages/_es/Picker.js +454 -129
- package/dist/packages/_es/Popover.js +957 -318
- package/dist/packages/_es/Popup.js +299 -55
- package/dist/packages/_es/Price.js +118 -16
- package/dist/packages/_es/Progress.js +146 -14
- package/dist/packages/_es/PullRefresh.js +339 -84
- package/dist/packages/_es/Radio.js +90 -22
- package/dist/packages/_es/RadioGroup.js +37 -8
- package/dist/packages/_es/Range.js +408 -83
- package/dist/packages/_es/Rate.js +192 -36
- package/dist/packages/_es/Row.js +64 -22
- package/dist/packages/_es/SearchBar.js +238 -37
- package/dist/packages/_es/ShortPassword.js +225 -35
- package/dist/packages/_es/SideNavBar.js +81 -24
- package/dist/packages/_es/SideNavBarItem.js +46 -11
- package/dist/packages/_es/Signature.js +160 -41
- package/dist/packages/_es/Skeleton.js +136 -20
- package/dist/packages/_es/Sku.js +491 -84
- package/dist/packages/_es/Step.js +115 -20
- package/dist/packages/_es/Steps.js +53 -18
- package/dist/packages/_es/Sticky.js +138 -53
- package/dist/packages/_es/SubSideNavBar.js +82 -17
- package/dist/packages/_es/Swipe.js +178 -41
- package/dist/packages/_es/Swiper.js +433 -121
- package/dist/packages/_es/SwiperItem.js +53 -22
- package/dist/packages/_es/Switch.js +116 -21
- package/dist/packages/_es/TabPane.js +39 -12
- package/dist/packages/_es/Tabbar.js +72 -17
- package/dist/packages/_es/TabbarItem.js +151 -29
- package/dist/packages/_es/Table.js +178 -18
- package/dist/packages/_es/Tabs.js +202 -43
- package/dist/packages/_es/Tag.js +97 -20
- package/dist/packages/_es/TextArea.js +160 -42
- package/dist/packages/_es/TimeDetail.js +79 -18
- package/dist/packages/_es/TimePannel.js +48 -14
- package/dist/packages/_es/TimeSelect.js +112 -15
- package/dist/packages/_es/Toast.js +310 -71
- package/dist/packages/_es/Uploader.js +455 -104
- package/dist/packages/_es/Video.js +332 -74
- package/dist/packages/_es/common.js +128 -38
- package/dist/packages/_es/component.js +76 -35
- package/dist/packages/_es/index.js +6 -5
- package/dist/packages/_es/index2.js +30 -9
- package/dist/packages/_es/index3.js +8 -6
- package/dist/packages/_es/index4.js +64 -13
- package/dist/packages/_es/index5.js +780 -164
- package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
- package/dist/packages/_es/pxCheck.js +5 -3
- package/dist/packages/_es/raf.js +15 -8
- package/dist/packages/imagepreview/index.scss +6 -1
- package/dist/packages/locale/lang/baseLang.js +3 -3
- package/dist/packages/locale/lang/en-US.js +105 -5
- package/dist/packages/locale/lang/id-ID.js +105 -5
- package/dist/packages/locale/lang/index.js +38 -16
- package/dist/packages/locale/lang/zh-CN.js +105 -5
- package/dist/packages/locale/lang/zh-TW.js +105 -5
- package/dist/packages/picker/index.scss +13 -0
- package/dist/smartips/attributes.json +8 -0
- package/dist/smartips/tags.json +3 -1
- package/dist/smartips/web-types.json +19 -1
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/themes/default.scss +49 -49
- package/dist/styles/themes/jdb.scss +49 -49
- package/dist/styles/themes/jdt.scss +49 -49
- package/dist/styles/variables-jdb.scss +4 -1
- package/dist/styles/variables-jdt.scss +4 -1
- package/dist/styles/variables.scss +1 -1
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
- package/dist/types/__VUE/address/index.vue.d.ts +4 -4
- package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
- package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
- package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
- package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
- package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
- package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
- package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
- package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
- package/dist/types/__VUE/infiniteloading/index.vue.d.ts +6 -6
- package/dist/types/__VUE/input/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
- package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
- package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/range/index.vue.d.ts +1 -1
- package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
- package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
- package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
- package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
- package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
- package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -2
|
@@ -1,77 +1,316 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { reactive
|
|
7
|
-
import { c as
|
|
8
|
-
import
|
|
9
|
-
import { _ as
|
|
6
|
+
import { reactive, onMounted, watch, computed, resolveComponent, openBlock, createBlock, Transition, withCtx, withDirectives, createElementVNode, normalizeClass, normalizeStyle, createElementBlock, createVNode, createCommentVNode, toDisplayString, vShow, render } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import _sfc_main$1 from "./Icon.js";
|
|
9
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
10
10
|
import "../locale/lang";
|
|
11
11
|
import "./pxCheck.js";
|
|
12
|
-
const { create
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
12
|
+
const { create } = createComponent("toast");
|
|
13
|
+
const _sfc_main = create({
|
|
14
|
+
components: {
|
|
15
|
+
[_sfc_main$1.name]: _sfc_main$1
|
|
16
|
+
},
|
|
17
|
+
props: {
|
|
18
|
+
id: String,
|
|
19
|
+
msg: String,
|
|
20
|
+
duration: {
|
|
21
|
+
type: Number,
|
|
22
|
+
default: 2e3
|
|
23
|
+
},
|
|
24
|
+
center: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true
|
|
27
|
+
},
|
|
28
|
+
type: String,
|
|
29
|
+
customClass: String,
|
|
30
|
+
bottom: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: "30px"
|
|
33
|
+
},
|
|
34
|
+
size: {
|
|
35
|
+
type: [String, Number],
|
|
36
|
+
default: "base"
|
|
37
|
+
},
|
|
38
|
+
iconSize: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: "20"
|
|
41
|
+
},
|
|
42
|
+
icon: String,
|
|
43
|
+
textAlignCenter: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: true
|
|
46
|
+
},
|
|
47
|
+
loadingRotate: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: true
|
|
50
|
+
},
|
|
51
|
+
bgColor: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: ""
|
|
54
|
+
},
|
|
55
|
+
onClose: Function,
|
|
56
|
+
unmount: Function,
|
|
57
|
+
cover: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: false
|
|
60
|
+
},
|
|
61
|
+
coverColor: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: ""
|
|
64
|
+
},
|
|
65
|
+
title: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: ""
|
|
68
|
+
},
|
|
69
|
+
closeOnClickOverlay: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
emits: ["close"],
|
|
75
|
+
setup(props, { emit }) {
|
|
76
|
+
let timer;
|
|
77
|
+
const state = reactive({
|
|
78
|
+
mounted: false
|
|
79
|
+
});
|
|
80
|
+
onMounted(() => {
|
|
81
|
+
state.mounted = true;
|
|
82
|
+
});
|
|
83
|
+
const clearTimer = () => {
|
|
84
|
+
if (timer) {
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
timer = null;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const hide = () => {
|
|
90
|
+
state.mounted = false;
|
|
91
|
+
};
|
|
92
|
+
const show = () => {
|
|
93
|
+
clearTimer();
|
|
94
|
+
if (props.duration) {
|
|
95
|
+
timer = setTimeout(() => {
|
|
96
|
+
hide();
|
|
97
|
+
}, props.duration);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const clickCover = () => {
|
|
101
|
+
if (props.closeOnClickOverlay) {
|
|
102
|
+
hide();
|
|
103
|
+
emit("close");
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
if (props.duration) {
|
|
107
|
+
show();
|
|
108
|
+
}
|
|
109
|
+
watch(() => props.duration, (val) => {
|
|
110
|
+
if (val) {
|
|
111
|
+
show();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const hasIcon = computed(() => {
|
|
115
|
+
if (props.type !== "text") {
|
|
116
|
+
return true;
|
|
117
|
+
} else {
|
|
118
|
+
return !!props.icon;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
const toastBodyClass = computed(() => {
|
|
122
|
+
return [
|
|
123
|
+
"nut-toast",
|
|
124
|
+
{ "nut-toast-center": props.center },
|
|
125
|
+
{ "nut-toast-has-icon": hasIcon.value },
|
|
126
|
+
{ "nut-toast-cover": props.cover },
|
|
127
|
+
{ "nut-toast-loading": props.type === "loading" },
|
|
128
|
+
props.customClass,
|
|
129
|
+
"nut-toast-" + props.size
|
|
130
|
+
];
|
|
131
|
+
});
|
|
132
|
+
const onAfterLeave = () => {
|
|
133
|
+
clearTimer();
|
|
134
|
+
props.unmount(props.id);
|
|
135
|
+
props.onClose && props.onClose();
|
|
136
|
+
};
|
|
137
|
+
return {
|
|
138
|
+
state,
|
|
139
|
+
hide,
|
|
140
|
+
clickCover,
|
|
141
|
+
hasIcon,
|
|
142
|
+
toastBodyClass,
|
|
143
|
+
onAfterLeave
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
const _hoisted_1 = {
|
|
148
|
+
key: 0,
|
|
149
|
+
class: "nut-toast-icon-wrapper"
|
|
150
|
+
};
|
|
151
|
+
const _hoisted_2 = {
|
|
152
|
+
key: 1,
|
|
153
|
+
class: "nut-toast-title"
|
|
154
|
+
};
|
|
155
|
+
const _hoisted_3 = ["innerHTML"];
|
|
156
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
157
|
+
const _component_nut_icon = resolveComponent("nut-icon");
|
|
158
|
+
return openBlock(), createBlock(Transition, {
|
|
159
|
+
name: "toast-fade",
|
|
160
|
+
onAfterLeave: _ctx.onAfterLeave
|
|
161
|
+
}, {
|
|
162
|
+
default: withCtx(() => [
|
|
163
|
+
withDirectives(createElementVNode("view", {
|
|
164
|
+
class: normalizeClass(_ctx.toastBodyClass),
|
|
165
|
+
style: normalizeStyle({
|
|
166
|
+
bottom: _ctx.center ? "auto" : _ctx.bottom,
|
|
167
|
+
"background-color": _ctx.coverColor
|
|
168
|
+
}),
|
|
169
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickCover && _ctx.clickCover(...args))
|
|
170
|
+
}, [
|
|
171
|
+
createElementVNode("view", {
|
|
172
|
+
class: "nut-toast-inner",
|
|
173
|
+
style: normalizeStyle({
|
|
174
|
+
"text-align": _ctx.textAlignCenter ? "center" : "left",
|
|
175
|
+
"background-color": _ctx.bgColor
|
|
176
|
+
})
|
|
177
|
+
}, [
|
|
178
|
+
_ctx.hasIcon ? (openBlock(), createElementBlock("view", _hoisted_1, [
|
|
179
|
+
createVNode(_component_nut_icon, {
|
|
180
|
+
size: _ctx.iconSize,
|
|
181
|
+
color: "#ffffff",
|
|
182
|
+
name: _ctx.icon
|
|
183
|
+
}, null, 8, ["size", "name"])
|
|
184
|
+
])) : createCommentVNode("", true),
|
|
185
|
+
_ctx.title ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(_ctx.title), 1)) : createCommentVNode("", true),
|
|
186
|
+
createElementVNode("view", {
|
|
187
|
+
class: "nut-toast-text",
|
|
188
|
+
innerHTML: _ctx.msg
|
|
189
|
+
}, null, 8, _hoisted_3)
|
|
190
|
+
], 4)
|
|
191
|
+
], 6), [
|
|
192
|
+
[vShow, _ctx.state.mounted]
|
|
193
|
+
])
|
|
194
|
+
]),
|
|
195
|
+
_: 1
|
|
196
|
+
}, 8, ["onAfterLeave"]);
|
|
197
|
+
}
|
|
198
|
+
var Toast = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
199
|
+
const defaultOptions = {
|
|
200
|
+
msg: "",
|
|
201
|
+
id: "",
|
|
202
|
+
duration: 2e3,
|
|
203
|
+
center: true,
|
|
204
|
+
type: "text",
|
|
205
|
+
title: "",
|
|
206
|
+
customClass: "",
|
|
207
|
+
bottom: "30px",
|
|
208
|
+
size: "base",
|
|
209
|
+
iconSize: "20",
|
|
210
|
+
icon: null,
|
|
211
|
+
textAlignCenter: true,
|
|
212
|
+
loadingRotate: true,
|
|
213
|
+
bgColor: "",
|
|
214
|
+
onClose: null,
|
|
215
|
+
unmount: null,
|
|
216
|
+
cover: false,
|
|
217
|
+
coverColor: "",
|
|
218
|
+
closeOnClickOverlay: false
|
|
219
|
+
};
|
|
220
|
+
let idsMap = [];
|
|
221
|
+
let optsMap = [];
|
|
222
|
+
const clearToast = (id) => {
|
|
223
|
+
if (id) {
|
|
224
|
+
const container = document.getElementById(id);
|
|
225
|
+
optsMap = optsMap.filter((item) => item.id !== id);
|
|
226
|
+
idsMap = idsMap.filter((item) => item !== id);
|
|
227
|
+
if (container) {
|
|
228
|
+
document.body.removeChild(container);
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
idsMap.forEach((item) => {
|
|
232
|
+
const container = document.getElementById(item);
|
|
233
|
+
if (container) {
|
|
234
|
+
document.body.removeChild(container);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
optsMap = [];
|
|
238
|
+
idsMap = [];
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const updateToast = (opts) => {
|
|
242
|
+
const container = document.getElementById(opts.id);
|
|
243
|
+
if (container) {
|
|
244
|
+
const currentOpt = optsMap.find((item) => item.id === opts.id);
|
|
245
|
+
if (currentOpt) {
|
|
246
|
+
opts = { ...defaultOptions, ...currentOpt, ...opts };
|
|
247
|
+
} else {
|
|
248
|
+
opts = { ...defaultOptions, ...opts };
|
|
249
|
+
}
|
|
250
|
+
const instance = createVNode(Toast, opts);
|
|
251
|
+
render(instance, container);
|
|
252
|
+
return instance.component.ctx;
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
const mountToast = (opts) => {
|
|
256
|
+
opts.unmount = clearToast;
|
|
257
|
+
let _id;
|
|
258
|
+
if (opts.id) {
|
|
259
|
+
_id = opts.id;
|
|
260
|
+
if (idsMap.find((item) => item === opts.id)) {
|
|
261
|
+
return updateToast(opts);
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
_id = new Date().getTime() + "";
|
|
265
|
+
}
|
|
266
|
+
opts = { ...defaultOptions, ...opts };
|
|
267
|
+
opts.id = _id;
|
|
268
|
+
idsMap.push(opts.id);
|
|
269
|
+
optsMap.push(opts);
|
|
270
|
+
const container = document.createElement("div");
|
|
271
|
+
container.id = opts.id;
|
|
272
|
+
const instance = createVNode(Toast, opts);
|
|
273
|
+
render(instance, container);
|
|
274
|
+
document.body.appendChild(container);
|
|
275
|
+
return instance.component.ctx;
|
|
276
|
+
};
|
|
277
|
+
const errorMsg = (msg) => {
|
|
278
|
+
if (!msg) {
|
|
279
|
+
console.warn("[NutUI Toast]: msg\u4E0D\u80FD\u4E3A\u7A7A");
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const ToastFunction = {
|
|
284
|
+
text(msg, opts = {}) {
|
|
285
|
+
errorMsg(msg);
|
|
286
|
+
return mountToast({ ...opts, type: "text", msg });
|
|
287
|
+
},
|
|
288
|
+
success(msg, opts = {}) {
|
|
289
|
+
errorMsg(msg);
|
|
290
|
+
return mountToast({ icon: "success", ...opts, msg, type: "success" });
|
|
291
|
+
},
|
|
292
|
+
fail(msg, opts = {}) {
|
|
293
|
+
errorMsg(msg);
|
|
294
|
+
return mountToast({ icon: "failure", ...opts, msg, type: "fail" });
|
|
295
|
+
},
|
|
296
|
+
warn(msg, opts = {}) {
|
|
297
|
+
errorMsg(msg);
|
|
298
|
+
return mountToast({ icon: "tips", ...opts, msg, type: "warn" });
|
|
299
|
+
},
|
|
300
|
+
loading(msg, opts = {}) {
|
|
301
|
+
return mountToast({
|
|
302
|
+
icon: "loading",
|
|
303
|
+
...opts,
|
|
304
|
+
msg,
|
|
305
|
+
type: "loading"
|
|
306
|
+
});
|
|
307
|
+
},
|
|
308
|
+
hide(id) {
|
|
309
|
+
clearToast(id);
|
|
310
|
+
},
|
|
311
|
+
install(app) {
|
|
312
|
+
app.use(Toast);
|
|
313
|
+
app.config.globalProperties.$toast = ToastFunction;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
export { Toast, ToastFunction, ToastFunction as default };
|