@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.
Files changed (168) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +3 -4
  3. package/dist/nutui.es.js +20412 -4214
  4. package/dist/nutui.umd.js +20518 -4216
  5. package/dist/packages/_es/ActionSheet.js +149 -17
  6. package/dist/packages/_es/Address.js +535 -110
  7. package/dist/packages/_es/AddressList.js +615 -113
  8. package/dist/packages/_es/Animate.js +59 -17
  9. package/dist/packages/_es/Audio.js +257 -53
  10. package/dist/packages/_es/AudioOperate.js +100 -13
  11. package/dist/packages/_es/Avatar.js +162 -38
  12. package/dist/packages/_es/AvatarGroup.js +73 -14
  13. package/dist/packages/_es/BackTop.js +156 -43
  14. package/dist/packages/_es/Badge.js +86 -14
  15. package/dist/packages/_es/Barrage.js +120 -41
  16. package/dist/packages/_es/Button.js +128 -23
  17. package/dist/packages/_es/Calendar.js +246 -30
  18. package/dist/packages/_es/CalendarItem.js +1 -1
  19. package/dist/packages/_es/Card.js +107 -10
  20. package/dist/packages/_es/Cascader.js +496 -147
  21. package/dist/packages/_es/Category.js +58 -15
  22. package/dist/packages/_es/CategoryPane.js +111 -11
  23. package/dist/packages/_es/Cell.js +108 -21
  24. package/dist/packages/_es/CellGroup.js +44 -9
  25. package/dist/packages/_es/Checkbox.js +134 -29
  26. package/dist/packages/_es/CheckboxGroup.js +79 -29
  27. package/dist/packages/_es/CircleProgress.js +150 -28
  28. package/dist/packages/_es/Col.js +56 -14
  29. package/dist/packages/_es/Collapse.js +109 -32
  30. package/dist/packages/_es/CollapseItem.js +253 -59
  31. package/dist/packages/_es/Comment.js +434 -64
  32. package/dist/packages/_es/ConfigProvider.js +20 -8
  33. package/dist/packages/_es/CountDown.js +238 -56
  34. package/dist/packages/_es/CountUp.js +539 -140
  35. package/dist/packages/_es/DatePicker.js +315 -98
  36. package/dist/packages/_es/Dialog.js +289 -60
  37. package/dist/packages/_es/Divider.js +65 -13
  38. package/dist/packages/_es/Drag.js +197 -56
  39. package/dist/packages/_es/Ecard.js +159 -24
  40. package/dist/packages/_es/Elevator.js +255 -58
  41. package/dist/packages/_es/Ellipsis.js +200 -58
  42. package/dist/packages/_es/Empty.js +71 -12
  43. package/dist/packages/_es/FixedNav.js +122 -15
  44. package/dist/packages/_es/Form.js +151 -64
  45. package/dist/packages/_es/FormItem.js +114 -15
  46. package/dist/packages/_es/Grid.js +6 -5
  47. package/dist/packages/_es/GridItem.js +144 -33
  48. package/dist/packages/_es/Icon.js +40 -15
  49. package/dist/packages/_es/Image.js +137 -26
  50. package/dist/packages/_es/ImagePreview.js +547 -76
  51. package/dist/packages/_es/Indicator.js +62 -15
  52. package/dist/packages/_es/InfiniteLoading.js +249 -57
  53. package/dist/packages/_es/Input.js +433 -51
  54. package/dist/packages/_es/InputNumber.js +160 -41
  55. package/dist/packages/_es/Layout.js +5 -4
  56. package/dist/packages/_es/List.js +106 -18
  57. package/dist/packages/_es/Menu.js +168 -44
  58. package/dist/packages/_es/MenuItem.js +173 -37
  59. package/dist/packages/_es/Navbar.js +192 -30
  60. package/dist/packages/_es/NoticeBar.js +380 -74
  61. package/dist/packages/_es/Notify.js +227 -72
  62. package/dist/packages/_es/NumberKeyboard.js +272 -41
  63. package/dist/packages/_es/OldPicker.js +457 -130
  64. package/dist/packages/_es/OverLay.js +98 -24
  65. package/dist/packages/_es/Pagination.js +157 -39
  66. package/dist/packages/_es/Picker.js +454 -129
  67. package/dist/packages/_es/Popover.js +957 -318
  68. package/dist/packages/_es/Popup.js +299 -55
  69. package/dist/packages/_es/Price.js +118 -16
  70. package/dist/packages/_es/Progress.js +146 -14
  71. package/dist/packages/_es/PullRefresh.js +339 -84
  72. package/dist/packages/_es/Radio.js +90 -22
  73. package/dist/packages/_es/RadioGroup.js +37 -8
  74. package/dist/packages/_es/Range.js +408 -83
  75. package/dist/packages/_es/Rate.js +192 -36
  76. package/dist/packages/_es/Row.js +64 -22
  77. package/dist/packages/_es/SearchBar.js +238 -37
  78. package/dist/packages/_es/ShortPassword.js +225 -35
  79. package/dist/packages/_es/SideNavBar.js +81 -24
  80. package/dist/packages/_es/SideNavBarItem.js +46 -11
  81. package/dist/packages/_es/Signature.js +160 -41
  82. package/dist/packages/_es/Skeleton.js +136 -20
  83. package/dist/packages/_es/Sku.js +491 -84
  84. package/dist/packages/_es/Step.js +115 -20
  85. package/dist/packages/_es/Steps.js +53 -18
  86. package/dist/packages/_es/Sticky.js +138 -53
  87. package/dist/packages/_es/SubSideNavBar.js +82 -17
  88. package/dist/packages/_es/Swipe.js +178 -41
  89. package/dist/packages/_es/Swiper.js +433 -121
  90. package/dist/packages/_es/SwiperItem.js +53 -22
  91. package/dist/packages/_es/Switch.js +116 -21
  92. package/dist/packages/_es/TabPane.js +39 -12
  93. package/dist/packages/_es/Tabbar.js +72 -17
  94. package/dist/packages/_es/TabbarItem.js +151 -29
  95. package/dist/packages/_es/Table.js +178 -18
  96. package/dist/packages/_es/Tabs.js +202 -43
  97. package/dist/packages/_es/Tag.js +97 -20
  98. package/dist/packages/_es/TextArea.js +160 -42
  99. package/dist/packages/_es/TimeDetail.js +79 -18
  100. package/dist/packages/_es/TimePannel.js +48 -14
  101. package/dist/packages/_es/TimeSelect.js +112 -15
  102. package/dist/packages/_es/Toast.js +310 -71
  103. package/dist/packages/_es/Uploader.js +455 -104
  104. package/dist/packages/_es/Video.js +332 -74
  105. package/dist/packages/_es/common.js +128 -38
  106. package/dist/packages/_es/component.js +76 -35
  107. package/dist/packages/_es/index.js +6 -5
  108. package/dist/packages/_es/index2.js +30 -9
  109. package/dist/packages/_es/index3.js +8 -6
  110. package/dist/packages/_es/index4.js +64 -13
  111. package/dist/packages/_es/index5.js +780 -164
  112. package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
  113. package/dist/packages/_es/pxCheck.js +5 -3
  114. package/dist/packages/_es/raf.js +15 -8
  115. package/dist/packages/imagepreview/index.scss +6 -1
  116. package/dist/packages/locale/lang/baseLang.js +3 -3
  117. package/dist/packages/locale/lang/en-US.js +105 -5
  118. package/dist/packages/locale/lang/id-ID.js +105 -5
  119. package/dist/packages/locale/lang/index.js +38 -16
  120. package/dist/packages/locale/lang/zh-CN.js +105 -5
  121. package/dist/packages/locale/lang/zh-TW.js +105 -5
  122. package/dist/packages/picker/index.scss +13 -0
  123. package/dist/smartips/attributes.json +8 -0
  124. package/dist/smartips/tags.json +3 -1
  125. package/dist/smartips/web-types.json +19 -1
  126. package/dist/style.css +1 -1
  127. package/dist/style.es.js +1 -1
  128. package/dist/styles/themes/default.scss +49 -49
  129. package/dist/styles/themes/jdb.scss +49 -49
  130. package/dist/styles/themes/jdt.scss +49 -49
  131. package/dist/styles/variables-jdb.scss +4 -1
  132. package/dist/styles/variables-jdt.scss +4 -1
  133. package/dist/styles/variables.scss +1 -1
  134. package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
  135. package/dist/types/__VUE/address/index.vue.d.ts +4 -4
  136. package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
  137. package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
  138. package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
  139. package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
  140. package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
  141. package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
  142. package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
  143. package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
  144. package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
  145. package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
  146. package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
  147. package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
  148. package/dist/types/__VUE/infiniteloading/index.vue.d.ts +6 -6
  149. package/dist/types/__VUE/input/index.vue.d.ts +2 -2
  150. package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
  151. package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
  152. package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
  153. package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
  154. package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
  155. package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
  156. package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
  157. package/dist/types/__VUE/range/index.vue.d.ts +1 -1
  158. package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
  159. package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
  160. package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
  161. package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
  162. package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
  163. package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
  164. package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
  165. package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
  166. package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
  167. package/dist/types/index.d.ts +1 -1
  168. package/package.json +1 -2
@@ -1,77 +1,316 @@
1
1
  /*!
2
- * @nutui/nutui v3.1.22-beta.5 Fri Jun 24 2022 15:10:09 GMT+0800 (中国标准时间)
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 as t, onMounted as e, watch as o, computed as n, resolveComponent as i, openBlock as l, createBlock as s, Transition as a, withCtx as c, withDirectives as r, createElementVNode as u, normalizeClass as d, normalizeStyle as m, createElementBlock as p, createVNode as f, createCommentVNode as g, toDisplayString as y, vShow as v, render as C } from "vue";
7
- import { c as b } from "./component.js";
8
- import x from "./Icon.js";
9
- import { _ as S } from "./plugin-vue_export-helper.js";
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: h } = b("toast"), k = h({ components: { [x.name]: x }, props: { id: String, msg: String, duration: { type: Number, default: 2e3 }, center: { type: Boolean, default: true }, type: String, customClass: String, bottom: { type: String, default: "30px" }, size: { type: [String, Number], default: "base" }, iconSize: { type: String, default: "20" }, icon: String, textAlignCenter: { type: Boolean, default: true }, loadingRotate: { type: Boolean, default: true }, bgColor: { type: String, default: "" }, onClose: Function, unmount: Function, cover: { type: Boolean, default: false }, coverColor: { type: String, default: "" }, title: { type: String, default: "" }, closeOnClickOverlay: { type: Boolean, default: false } }, emits: ["close"], setup(i2, { emit: l2 }) {
13
- let s2;
14
- const a2 = t({ mounted: false });
15
- e(() => {
16
- a2.mounted = true;
17
- });
18
- const c2 = () => {
19
- s2 && (clearTimeout(s2), s2 = null);
20
- }, r2 = () => {
21
- a2.mounted = false;
22
- }, u2 = () => {
23
- c2(), i2.duration && (s2 = setTimeout(() => {
24
- r2();
25
- }, i2.duration));
26
- };
27
- i2.duration && u2(), o(() => i2.duration, (t2) => {
28
- t2 && u2();
29
- });
30
- const d2 = n(() => i2.type !== "text" || !!i2.icon), m2 = n(() => ["nut-toast", { "nut-toast-center": i2.center }, { "nut-toast-has-icon": d2.value }, { "nut-toast-cover": i2.cover }, { "nut-toast-loading": i2.type === "loading" }, i2.customClass, "nut-toast-" + i2.size]);
31
- return { state: a2, hide: r2, clickCover: () => {
32
- i2.closeOnClickOverlay && (r2(), l2("close"));
33
- }, hasIcon: d2, toastBodyClass: m2, onAfterLeave: () => {
34
- c2(), i2.unmount(i2.id), i2.onClose && i2.onClose();
35
- } };
36
- } }), B = { key: 0, class: "nut-toast-icon-wrapper" }, w = { key: 1, class: "nut-toast-title" }, z = ["innerHTML"];
37
- var A = S(k, [["render", function(t2, e2, o2, n2, C2, b2) {
38
- const x2 = i("nut-icon");
39
- return l(), s(a, { name: "toast-fade", onAfterLeave: t2.onAfterLeave }, { default: c(() => [r(u("view", { class: d(t2.toastBodyClass), style: m({ bottom: t2.center ? "auto" : t2.bottom, "background-color": t2.coverColor }), onClick: e2[0] || (e2[0] = (...e3) => t2.clickCover && t2.clickCover(...e3)) }, [u("view", { class: "nut-toast-inner", style: m({ "text-align": t2.textAlignCenter ? "center" : "left", "background-color": t2.bgColor }) }, [t2.hasIcon ? (l(), p("view", B, [f(x2, { size: t2.iconSize, color: "#ffffff", name: t2.icon }, null, 8, ["size", "name"])])) : g("", true), t2.title ? (l(), p("div", w, y(t2.title), 1)) : g("", true), u("view", { class: "nut-toast-text", innerHTML: t2.msg }, null, 8, z)], 4)], 6), [[v, t2.state.mounted]])]), _: 1 }, 8, ["onAfterLeave"]);
40
- }]]);
41
- const I = { msg: "", id: "", duration: 2e3, center: true, type: "text", title: "", customClass: "", bottom: "30px", size: "base", iconSize: "20", icon: null, textAlignCenter: true, loadingRotate: true, bgColor: "", onClose: null, unmount: null, cover: false, coverColor: "", closeOnClickOverlay: false };
42
- let L = [], O = [];
43
- const E = (t2) => {
44
- if (t2) {
45
- const e2 = document.getElementById(t2);
46
- O = O.filter((e3) => e3.id !== t2), L = L.filter((e3) => e3 !== t2), e2 && document.body.removeChild(e2);
47
- } else
48
- L.forEach((t3) => {
49
- const e2 = document.getElementById(t3);
50
- e2 && document.body.removeChild(e2);
51
- }), O = [], L = [];
52
- }, T = (t2) => {
53
- let e2;
54
- if (t2.unmount = E, t2.id) {
55
- if (e2 = t2.id, L.find((e3) => e3 === t2.id))
56
- return ((t3) => {
57
- const e3 = document.getElementById(t3.id);
58
- if (e3) {
59
- const o3 = O.find((e4) => e4.id === t3.id);
60
- t3 = o3 ? { ...I, ...o3, ...t3 } : { ...I, ...t3 };
61
- const n3 = f(A, t3);
62
- return C(n3, e3), n3.component.ctx;
63
- }
64
- })(t2);
65
- } else
66
- e2 = new Date().getTime() + "";
67
- (t2 = { ...I, ...t2 }).id = e2, L.push(t2.id), O.push(t2);
68
- const o2 = document.createElement("div");
69
- o2.id = t2.id;
70
- const n2 = f(A, t2);
71
- return C(n2, o2), document.body.appendChild(o2), n2.component.ctx;
72
- }, j = { text: (t2, e2 = {}) => T({ ...e2, type: "text", msg: t2 }), success: (t2, e2 = {}) => T({ icon: "success", ...e2, msg: t2, type: "success" }), fail: (t2, e2 = {}) => T({ icon: "failure", ...e2, msg: t2, type: "fail" }), warn: (t2, e2 = {}) => T({ icon: "tips", ...e2, msg: t2, type: "warn" }), loading: (t2, e2 = {}) => T({ icon: "loading", ...e2, msg: t2, type: "loading" }), hide(t2) {
73
- E(t2);
74
- }, install(t2) {
75
- t2.use(A), t2.config.globalProperties.$toast = j;
76
- } };
77
- export { A as Toast, j as ToastFunction, j as default };
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 };