@nutui/nutui 4.0.11 → 4.0.12

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 (158) hide show
  1. package/dist/nutui.es.js +1 -1
  2. package/dist/nutui.js +2 -2
  3. package/dist/nutui.umd.js +1 -1
  4. package/dist/packages/_es/ActionSheet.js +111 -78
  5. package/dist/packages/_es/Address.js +375 -250
  6. package/dist/packages/_es/AddressList.js +354 -269
  7. package/dist/packages/_es/Animate.js +58 -41
  8. package/dist/packages/_es/Audio.js +197 -128
  9. package/dist/packages/_es/AudioOperate.js +71 -60
  10. package/dist/packages/_es/Avatar.js +89 -66
  11. package/dist/packages/_es/AvatarGroup.js +31 -23
  12. package/dist/packages/_es/Backtop.js +99 -59
  13. package/dist/packages/_es/Badge.js +47 -36
  14. package/dist/packages/_es/Barrage.js +147 -68
  15. package/dist/packages/_es/Button.js +66 -47
  16. package/dist/packages/_es/Calendar.js +157 -135
  17. package/dist/packages/_es/CalendarItem.js +6 -6
  18. package/dist/packages/_es/Card.js +56 -42
  19. package/dist/packages/_es/Cascader.js +474 -315
  20. package/dist/packages/_es/Category.js +39 -29
  21. package/dist/packages/_es/CategoryPane.js +83 -57
  22. package/dist/packages/_es/Cell.js +71 -56
  23. package/dist/packages/_es/CellGroup.js +27 -19
  24. package/dist/packages/_es/Checkbox.js +156 -109
  25. package/dist/packages/_es/CheckboxGroup.js +59 -38
  26. package/dist/packages/_es/CircleProgress.js +96 -67
  27. package/dist/packages/_es/Col.js +31 -23
  28. package/dist/packages/_es/Collapse.js +58 -33
  29. package/dist/packages/_es/CollapseItem.js +108 -78
  30. package/dist/packages/_es/Comment.js +279 -207
  31. package/dist/packages/_es/ConfigProvider.js +55 -37
  32. package/dist/packages/_es/Countdown.js +212 -100
  33. package/dist/packages/_es/Countup.js +445 -232
  34. package/dist/packages/_es/DatePicker.js +265 -162
  35. package/dist/packages/_es/Dialog.js +213 -161
  36. package/dist/packages/_es/Divider.js +57 -42
  37. package/dist/packages/_es/Drag.js +153 -70
  38. package/dist/packages/_es/Ecard.js +104 -64
  39. package/dist/packages/_es/Elevator.js +219 -143
  40. package/dist/packages/_es/Ellipsis.js +178 -95
  41. package/dist/packages/_es/Empty.js +39 -23
  42. package/dist/packages/_es/FixedNav.js +116 -93
  43. package/dist/packages/_es/Form.js +178 -107
  44. package/dist/packages/_es/FormItem.js +61 -48
  45. package/dist/packages/_es/Grid.js +6 -5
  46. package/dist/packages/_es/GridItem.js +84 -58
  47. package/dist/packages/_es/Image.js +130 -90
  48. package/dist/packages/_es/ImagePreview.js +412 -256
  49. package/dist/packages/_es/Indicator.js +34 -30
  50. package/dist/packages/_es/InfiniteLoading.js +136 -83
  51. package/dist/packages/_es/Input.js +264 -160
  52. package/dist/packages/_es/InputNumber.js +117 -81
  53. package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
  54. package/dist/packages/_es/Invoice.js +130 -104
  55. package/dist/packages/_es/Layout.js +4 -3
  56. package/dist/packages/_es/List.js +215 -117
  57. package/dist/packages/_es/Menu.js +150 -95
  58. package/dist/packages/_es/MenuItem.js +154 -109
  59. package/dist/packages/_es/Navbar.js +119 -103
  60. package/dist/packages/_es/Noticebar.js +312 -197
  61. package/dist/packages/_es/Notify.js +166 -110
  62. package/dist/packages/_es/NumberKeyboard.js +202 -127
  63. package/dist/packages/_es/Overlay.js +80 -52
  64. package/dist/packages/_es/Pagination.js +100 -70
  65. package/dist/packages/_es/Picker.js +437 -275
  66. package/dist/packages/_es/Popover.js +225 -122
  67. package/dist/packages/_es/Popup.js +4 -4
  68. package/dist/packages/_es/Price.js +82 -44
  69. package/dist/packages/_es/Progress.js +79 -63
  70. package/dist/packages/_es/PullRefresh.js +173 -95
  71. package/dist/packages/_es/Radio.js +4 -4
  72. package/dist/packages/_es/RadioGroup.js +3 -3
  73. package/dist/packages/_es/Range.js +347 -204
  74. package/dist/packages/_es/Rate.js +141 -92
  75. package/dist/packages/_es/Row.js +27 -21
  76. package/dist/packages/_es/Searchbar.js +174 -123
  77. package/dist/packages/_es/ShortPassword.js +93 -69
  78. package/dist/packages/_es/SideNavbar.js +80 -49
  79. package/dist/packages/_es/SideNavbarItem.js +32 -22
  80. package/dist/packages/_es/Signature.js +146 -83
  81. package/dist/packages/_es/Skeleton.js +130 -110
  82. package/dist/packages/_es/Sku.js +343 -250
  83. package/dist/packages/_es/Step.js +86 -59
  84. package/dist/packages/_es/Steps.js +31 -26
  85. package/dist/packages/_es/Sticky.js +4 -4
  86. package/dist/packages/_es/SubSideNavbar.js +74 -52
  87. package/dist/packages/_es/Swipe.js +155 -83
  88. package/dist/packages/_es/Swiper.js +311 -174
  89. package/dist/packages/_es/SwiperItem.js +44 -28
  90. package/dist/packages/_es/Switch.js +68 -55
  91. package/dist/packages/_es/TabPane.js +41 -30
  92. package/dist/packages/_es/Tabbar.js +52 -41
  93. package/dist/packages/_es/TabbarItem.js +82 -61
  94. package/dist/packages/_es/Table.js +165 -109
  95. package/dist/packages/_es/Tabs.js +388 -240
  96. package/dist/packages/_es/Tag.js +61 -44
  97. package/dist/packages/_es/Textarea.js +124 -80
  98. package/dist/packages/_es/TimeDetail.js +76 -49
  99. package/dist/packages/_es/TimePannel.js +48 -34
  100. package/dist/packages/_es/TimeSelect.js +68 -47
  101. package/dist/packages/_es/Toast.js +218 -144
  102. package/dist/packages/_es/Tour.js +192 -138
  103. package/dist/packages/_es/TrendArrow.js +77 -57
  104. package/dist/packages/_es/Uploader.js +359 -234
  105. package/dist/packages/_es/Video.js +316 -191
  106. package/dist/packages/_es/Watermark.js +117 -84
  107. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
  108. package/dist/packages/_es/common-b9a5e726.js +145 -0
  109. package/dist/packages/_es/component-81a4c1d0.js +145 -0
  110. package/dist/packages/_es/index-29892cda.js +33 -0
  111. package/dist/packages/_es/index-43c34ac6.js +30 -0
  112. package/dist/packages/_es/index-54d03fc1.js +8 -0
  113. package/dist/packages/_es/index-79c5dc33.js +10 -0
  114. package/dist/packages/_es/index-7a7385e4.js +67 -0
  115. package/dist/packages/_es/index-87422be8.js +942 -0
  116. package/dist/packages/_es/index-da0a7662.js +259 -0
  117. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
  120. package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
  121. package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
  122. package/dist/packages/_es/raf-729dad54.js +25 -0
  123. package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
  124. package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
  125. package/dist/packages/locale/lang/en-US.js +39 -36
  126. package/dist/packages/locale/lang/id-ID.js +39 -36
  127. package/dist/packages/locale/lang/index.js +44 -22
  128. package/dist/packages/locale/lang/zh-CN.js +38 -35
  129. package/dist/packages/locale/lang/zh-TW.js +38 -35
  130. package/dist/resolver/index.js +26 -1
  131. package/dist/resolver/index.mjs +17 -14
  132. package/dist/smartips/web-types.json +1 -1
  133. package/dist/style.css +1 -1
  134. package/dist/styles/themes/default.scss +48 -48
  135. package/dist/styles/themes/jdb.scss +48 -48
  136. package/dist/styles/themes/jddkh.scss +48 -48
  137. package/dist/styles/themes/jdt.scss +48 -48
  138. package/dist/types/index.d.ts +1 -1
  139. package/package.json +3 -4
  140. package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
  141. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
  142. package/dist/packages/_es/common-d218746f.js +0 -116
  143. package/dist/packages/_es/component-234624bc.js +0 -89
  144. package/dist/packages/_es/index-14dfadc4.js +0 -561
  145. package/dist/packages/_es/index-192a3ef6.js +0 -29
  146. package/dist/packages/_es/index-360c5092.js +0 -210
  147. package/dist/packages/_es/index-496e6e05.js +0 -24
  148. package/dist/packages/_es/index-50eed3d9.js +0 -7
  149. package/dist/packages/_es/index-53ec2d4d.js +0 -34
  150. package/dist/packages/_es/index-fadb0974.js +0 -8
  151. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
  152. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
  153. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
  154. package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
  155. package/dist/packages/_es/pxCheck-38173291.js +0 -4
  156. package/dist/packages/_es/raf-a74f1a06.js +0 -16
  157. package/dist/packages/_es/renderIcon-47498b32.js +0 -5
  158. package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
@@ -1,18 +1,19 @@
1
- import { computed as l, provide as p, resolveComponent as d, openBlock as u, createBlock as _, normalizeStyle as f, withCtx as y, createElementVNode as t, normalizeClass as v, createElementBlock as h, toDisplayString as k, renderSlot as i } from "vue";
2
- import { c as b } from "./component-234624bc.js";
3
- import { P as m } from "./index-360c5092.js";
4
- import { _ as C } from "./_plugin-vue_export-helper-dad06003.js";
1
+ import { computed, provide, resolveComponent, openBlock, createBlock, normalizeStyle, withCtx, createElementVNode, normalizeClass, createElementBlock, toDisplayString, renderSlot } from "vue";
2
+ import { c as createComponent } from "./component-81a4c1d0.js";
3
+ import { P as Popup } from "./index-da0a7662.js";
4
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
5
5
  import "../locale/lang";
6
6
  import "./Overlay.js";
7
7
  import "@nutui/icons-vue";
8
- const { componentName: S, create: w, translate: $ } = b("time-select"), g = w({
8
+ const { componentName, create, translate } = createComponent("time-select");
9
+ const _sfc_main = create({
9
10
  components: {
10
- [m.name]: m
11
+ [Popup.name]: Popup
11
12
  },
12
13
  props: {
13
14
  visible: {
14
15
  type: Boolean,
15
- defalut: !1
16
+ defalut: false
16
17
  },
17
18
  height: {
18
19
  type: [String],
@@ -28,64 +29,84 @@ const { componentName: S, create: w, translate: $ } = b("time-select"), g = w({
28
29
  },
29
30
  currentTime: {
30
31
  type: Array,
31
- default: () => []
32
+ default: () => {
33
+ return [];
34
+ }
32
35
  },
33
36
  lockScroll: {
34
37
  type: [Boolean],
35
- default: !0
38
+ default: true
36
39
  },
37
40
  teleportDisable: {
38
41
  type: Boolean,
39
- default: !1
42
+ default: false
40
43
  }
41
44
  },
42
45
  emits: ["update:visible", "select"],
43
- setup: (e, o) => {
44
- const r = l(() => ({
45
- [S]: !0
46
- })), c = l(() => ({
47
- width: "100%",
48
- height: e.height
49
- })), a = l(() => e.currentKey), s = l(() => e.currentTime), n = () => {
50
- o.emit("update:visible", !1), o.emit("select", s.value);
46
+ setup: (props, context) => {
47
+ const classes = computed(() => {
48
+ const prefixCls = componentName;
49
+ return {
50
+ [prefixCls]: true
51
+ };
52
+ });
53
+ const popStyle = computed(() => {
54
+ return {
55
+ width: "100%",
56
+ height: props.height
57
+ };
58
+ });
59
+ const currentKey = computed(() => props.currentKey);
60
+ const currentTime = computed(() => props.currentTime);
61
+ const close = () => {
62
+ context.emit("update:visible", false);
63
+ context.emit("select", currentTime.value);
51
64
  };
52
- return p("currentKey", a), p("currentTime", s), {
53
- classes: r,
54
- popStyle: c,
55
- props: e,
56
- close: n,
57
- translate: $
65
+ provide("currentKey", currentKey);
66
+ provide("currentTime", currentTime);
67
+ return {
68
+ classes,
69
+ popStyle,
70
+ props,
71
+ close,
72
+ translate
58
73
  };
59
74
  }
60
- }), B = { class: "nut-time-select__title" }, D = { class: "nut-time-select__title__fixed" }, T = { key: 0 }, K = { class: "nut-time-select__content" }, N = { class: "nut-time-select__content__pannel" }, z = { class: "nut-time-select__content__detail" };
61
- function E(e, o, r, c, a, s) {
62
- const n = d("nut-popup");
63
- return u(), _(n, {
75
+ });
76
+ const _hoisted_1 = { class: "nut-time-select__title" };
77
+ const _hoisted_2 = { class: "nut-time-select__title__fixed" };
78
+ const _hoisted_3 = { key: 0 };
79
+ const _hoisted_4 = { class: "nut-time-select__content" };
80
+ const _hoisted_5 = { class: "nut-time-select__content__pannel" };
81
+ const _hoisted_6 = { class: "nut-time-select__content__detail" };
82
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
83
+ const _component_nut_popup = resolveComponent("nut-popup");
84
+ return openBlock(), createBlock(_component_nut_popup, {
64
85
  position: "bottom",
65
86
  closeable: "",
66
87
  round: "",
67
- teleportDisable: e.teleportDisable,
68
- visible: e.visible,
69
- style: f(e.popStyle),
70
- "lock-scroll": e.lockScroll,
71
- onClickOverlay: e.close,
72
- onClickCloseIcon: e.close
88
+ teleportDisable: _ctx.teleportDisable,
89
+ visible: _ctx.visible,
90
+ style: normalizeStyle(_ctx.popStyle),
91
+ "lock-scroll": _ctx.lockScroll,
92
+ onClickOverlay: _ctx.close,
93
+ onClickCloseIcon: _ctx.close
73
94
  }, {
74
- default: y(() => [
75
- t("view", {
76
- class: v(e.classes)
95
+ default: withCtx(() => [
96
+ createElementVNode("view", {
97
+ class: normalizeClass(_ctx.classes)
77
98
  }, [
78
- t("view", B, [
79
- t("view", D, [
80
- e.$slots.title ? i(e.$slots, "title", { key: 1 }) : (u(), h("span", T, k(e.title || e.translate("pickupTime")), 1))
99
+ createElementVNode("view", _hoisted_1, [
100
+ createElementVNode("view", _hoisted_2, [
101
+ !_ctx.$slots.title ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(_ctx.title || _ctx.translate("pickupTime")), 1)) : renderSlot(_ctx.$slots, "title", { key: 1 })
81
102
  ])
82
103
  ]),
83
- t("view", K, [
84
- t("view", N, [
85
- i(e.$slots, "pannel")
104
+ createElementVNode("view", _hoisted_4, [
105
+ createElementVNode("view", _hoisted_5, [
106
+ renderSlot(_ctx.$slots, "pannel")
86
107
  ]),
87
- t("view", z, [
88
- i(e.$slots, "detail")
108
+ createElementVNode("view", _hoisted_6, [
109
+ renderSlot(_ctx.$slots, "detail")
89
110
  ])
90
111
  ])
91
112
  ], 2)
@@ -93,7 +114,7 @@ function E(e, o, r, c, a, s) {
93
114
  _: 3
94
115
  }, 8, ["teleportDisable", "visible", "style", "lock-scroll", "onClickOverlay", "onClickCloseIcon"]);
95
116
  }
96
- const G = /* @__PURE__ */ C(g, [["render", E]]);
117
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
97
118
  export {
98
- G as default
119
+ index as default
99
120
  };
@@ -1,23 +1,31 @@
1
- var M = Object.defineProperty, N = Object.defineProperties;
2
- var D = Object.getOwnPropertyDescriptors;
3
- var b = Object.getOwnPropertySymbols;
4
- var $ = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
5
- var p = (e, t, n) => t in e ? M(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, o = (e, t) => {
6
- for (var n in t || (t = {}))
7
- $.call(t, n) && p(e, n, t[n]);
8
- if (b)
9
- for (var n of b(t))
10
- F.call(t, n) && p(e, n, t[n]);
11
- return e;
12
- }, a = (e, t) => N(e, D(t));
13
- import { reactive as R, onMounted as V, watch as H, computed as y, openBlock as f, createBlock as w, Transition as W, withCtx as j, withDirectives as U, createElementVNode as C, normalizeClass as k, normalizeStyle as S, createElementBlock as T, resolveDynamicComponent as q, createCommentVNode as B, toDisplayString as G, vShow as J, createVNode as K, render as P } from "vue";
14
- import { c as Q } from "./component-234624bc.js";
15
- import { r as X } from "./renderIcon-47498b32.js";
16
- import { _ as Y } from "./_plugin-vue_export-helper-dad06003.js";
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ import { reactive, onMounted, watch, computed, openBlock, createBlock, Transition, withCtx, withDirectives, createElementVNode, normalizeClass, normalizeStyle, createElementBlock, resolveDynamicComponent, createCommentVNode, toDisplayString, vShow, createVNode, render } from "vue";
21
+ import { c as createComponent } from "./component-81a4c1d0.js";
22
+ import { r as renderIcon } from "./renderIcon-3d0fd47c.js";
23
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
17
24
  import "../locale/lang";
18
- import { C as Z } from "./mountComponent-6d4ff200.js";
19
- import { Success as x, Failure as _, Tips as ee, Loading as te } from "@nutui/icons-vue";
20
- const { create: ne } = Q("toast"), oe = ne({
25
+ import { C as CreateComponent } from "./mountComponent-8b24c346.js";
26
+ import { Success, Failure, Tips, Loading } from "@nutui/icons-vue";
27
+ const { create } = createComponent("toast");
28
+ const _sfc_main = create({
21
29
  components: {},
22
30
  props: {
23
31
  id: String,
@@ -28,7 +36,7 @@ const { create: ne } = Q("toast"), oe = ne({
28
36
  },
29
37
  center: {
30
38
  type: Boolean,
31
- default: !0
39
+ default: true
32
40
  },
33
41
  type: {
34
42
  type: String,
@@ -49,11 +57,11 @@ const { create: ne } = Q("toast"), oe = ne({
49
57
  },
50
58
  textAlignCenter: {
51
59
  type: Boolean,
52
- default: !0
60
+ default: true
53
61
  },
54
62
  loadingRotate: {
55
63
  type: Boolean,
56
- default: !0
64
+ default: true
57
65
  },
58
66
  bgColor: {
59
67
  type: String,
@@ -63,7 +71,7 @@ const { create: ne } = Q("toast"), oe = ne({
63
71
  unmount: Function,
64
72
  cover: {
65
73
  type: Boolean,
66
- default: !1
74
+ default: false
67
75
  },
68
76
  coverColor: {
69
77
  type: String,
@@ -75,107 +83,142 @@ const { create: ne } = Q("toast"), oe = ne({
75
83
  },
76
84
  closeOnClickOverlay: {
77
85
  type: Boolean,
78
- default: !1
86
+ default: false
79
87
  }
80
88
  },
81
89
  emits: ["close"],
82
- setup(e, { emit: t }) {
83
- let n;
84
- const r = R({
85
- mounted: !1
90
+ setup(props, { emit }) {
91
+ let timer;
92
+ const state = reactive({
93
+ mounted: false
86
94
  });
87
- V(() => {
88
- r.mounted = !0;
95
+ onMounted(() => {
96
+ state.mounted = true;
89
97
  });
90
- const l = () => {
91
- n && (clearTimeout(n), n = null);
92
- }, u = () => {
93
- r.mounted = !1;
94
- }, d = () => {
95
- l(), e.duration && (n = setTimeout(() => {
96
- u();
97
- }, e.duration));
98
- }, A = () => {
99
- e.closeOnClickOverlay && (u(), t("close"));
98
+ const clearTimer = () => {
99
+ if (timer) {
100
+ clearTimeout(timer);
101
+ timer = null;
102
+ }
103
+ };
104
+ const hide = () => {
105
+ state.mounted = false;
100
106
  };
101
- e.duration && d(), H(
102
- () => e.duration,
103
- (E) => {
104
- E && d();
107
+ const show = () => {
108
+ clearTimer();
109
+ if (props.duration) {
110
+ timer = setTimeout(() => {
111
+ hide();
112
+ }, props.duration);
113
+ }
114
+ };
115
+ const clickCover = () => {
116
+ if (props.closeOnClickOverlay) {
117
+ hide();
118
+ emit("close");
119
+ }
120
+ };
121
+ if (props.duration) {
122
+ show();
123
+ }
124
+ watch(
125
+ () => props.duration,
126
+ (val) => {
127
+ if (val) {
128
+ show();
129
+ }
105
130
  }
106
131
  );
107
- const h = y(() => e.type !== "text" ? !0 : e.icon !== null), L = y(() => [
108
- "nut-toast",
109
- { "nut-toast-center": e.center },
110
- { "nut-toast-has-icon": h.value },
111
- { "nut-toast-cover": e.cover },
112
- { "nut-toast-loading": e.type === "loading" },
113
- e.customClass,
114
- "nut-toast-" + e.size
115
- ]), z = y(() => ["nut-toast-icon-wrapper", { "nut-toast-icon-no-animation": !e.loadingRotate }]);
132
+ const hasIcon = computed(() => {
133
+ if (props.type !== "text") {
134
+ return true;
135
+ } else {
136
+ return props.icon !== null;
137
+ }
138
+ });
139
+ const toastBodyClass = computed(() => {
140
+ return [
141
+ "nut-toast",
142
+ { "nut-toast-center": props.center },
143
+ { "nut-toast-has-icon": hasIcon.value },
144
+ { "nut-toast-cover": props.cover },
145
+ { "nut-toast-loading": props.type === "loading" },
146
+ props.customClass,
147
+ "nut-toast-" + props.size
148
+ ];
149
+ });
150
+ const toastIconWrapperClass = computed(() => {
151
+ return ["nut-toast-icon-wrapper", { "nut-toast-icon-no-animation": !props.loadingRotate }];
152
+ });
153
+ const onAfterLeave = () => {
154
+ clearTimer();
155
+ props.unmount(props.id);
156
+ props.onClose && props.onClose();
157
+ };
116
158
  return {
117
- state: r,
118
- hide: u,
119
- clickCover: A,
120
- hasIcon: h,
121
- toastBodyClass: L,
122
- toastIconWrapperClass: z,
123
- onAfterLeave: () => {
124
- l(), e.unmount(e.id), e.onClose && e.onClose();
125
- },
126
- renderIcon: X
159
+ state,
160
+ hide,
161
+ clickCover,
162
+ hasIcon,
163
+ toastBodyClass,
164
+ toastIconWrapperClass,
165
+ onAfterLeave,
166
+ renderIcon
127
167
  };
128
168
  }
129
- }), re = {
169
+ });
170
+ const _hoisted_1 = {
130
171
  key: 1,
131
172
  class: "nut-toast-title"
132
- }, ae = ["innerHTML"];
133
- function ie(e, t, n, r, l, u) {
134
- return f(), w(W, {
173
+ };
174
+ const _hoisted_2 = ["innerHTML"];
175
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
176
+ return openBlock(), createBlock(Transition, {
135
177
  name: "toast-fade",
136
- onAfterLeave: e.onAfterLeave
178
+ onAfterLeave: _ctx.onAfterLeave
137
179
  }, {
138
- default: j(() => [
139
- U(C("view", {
140
- class: k(e.toastBodyClass),
141
- style: S({
142
- bottom: e.center ? "auto" : e.bottom,
143
- "background-color": e.coverColor
180
+ default: withCtx(() => [
181
+ withDirectives(createElementVNode("view", {
182
+ class: normalizeClass(_ctx.toastBodyClass),
183
+ style: normalizeStyle({
184
+ bottom: _ctx.center ? "auto" : _ctx.bottom,
185
+ "background-color": _ctx.coverColor
144
186
  }),
145
- onClick: t[0] || (t[0] = (...d) => e.clickCover && e.clickCover(...d))
187
+ onClick: _cache[0] || (_cache[0] = (...args) => _ctx.clickCover && _ctx.clickCover(...args))
146
188
  }, [
147
- C("view", {
189
+ createElementVNode("view", {
148
190
  class: "nut-toast-inner",
149
- style: S({
150
- "text-align": e.textAlignCenter ? "center" : "left",
151
- "background-color": e.bgColor
191
+ style: normalizeStyle({
192
+ "text-align": _ctx.textAlignCenter ? "center" : "left",
193
+ "background-color": _ctx.bgColor
152
194
  })
153
195
  }, [
154
- e.hasIcon ? (f(), T("view", {
196
+ _ctx.hasIcon ? (openBlock(), createElementBlock("view", {
155
197
  key: 0,
156
- class: k(e.toastIconWrapperClass)
198
+ class: normalizeClass(_ctx.toastIconWrapperClass)
157
199
  }, [
158
- (f(), w(q(e.renderIcon(e.icon)), { color: "#ffffff" }))
159
- ], 2)) : B("", !0),
160
- e.title ? (f(), T("div", re, G(e.title), 1)) : B("", !0),
161
- C("view", {
200
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.renderIcon(_ctx.icon)), { color: "#ffffff" }))
201
+ ], 2)) : createCommentVNode("", true),
202
+ _ctx.title ? (openBlock(), createElementBlock("div", _hoisted_1, toDisplayString(_ctx.title), 1)) : createCommentVNode("", true),
203
+ createElementVNode("view", {
162
204
  class: "nut-toast-text",
163
- innerHTML: e.msg
164
- }, null, 8, ae)
205
+ innerHTML: _ctx.msg
206
+ }, null, 8, _hoisted_2)
165
207
  ], 4)
166
208
  ], 6), [
167
- [J, e.state.mounted]
209
+ [vShow, _ctx.state.mounted]
168
210
  ])
169
211
  ]),
170
212
  _: 1
171
213
  }, 8, ["onAfterLeave"]);
172
214
  }
173
- const v = /* @__PURE__ */ Y(oe, [["render", ie]]), g = {
215
+ const Toast = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
216
+ const defaultOptions = {
174
217
  msg: "",
175
218
  id: "",
176
219
  duration: 2e3,
177
220
  //显示时间(毫秒)
178
- center: !0,
221
+ center: true,
179
222
  // 未实现
180
223
  type: "text",
181
224
  title: "",
@@ -184,84 +227,115 @@ const v = /* @__PURE__ */ Y(oe, [["render", ie]]), g = {
184
227
  size: "base",
185
228
  iconSize: "20",
186
229
  icon: null,
187
- textAlignCenter: !0,
230
+ textAlignCenter: true,
188
231
  // 未实现
189
- loadingRotate: !0,
232
+ loadingRotate: true,
190
233
  // 未实现
191
234
  bgColor: "",
192
235
  onClose: null,
193
236
  // 未实现
194
237
  unmount: null,
195
- cover: !1,
238
+ cover: false,
196
239
  //透明遮罩层 // 未实现
197
240
  coverColor: "",
198
241
  // 未实现
199
- closeOnClickOverlay: !1
242
+ closeOnClickOverlay: false
200
243
  // 未实现
201
244
  };
202
- let i = [], c = [];
203
- const I = (e) => {
204
- if (e) {
205
- const t = document.getElementById(e);
206
- c = c.filter((n) => n.id !== e), i = i.filter((n) => n !== e), t && document.body.removeChild(t);
207
- } else
208
- i.forEach((t) => {
209
- const n = document.getElementById(t);
210
- n && document.body.removeChild(n);
211
- }), c = [], i = [];
212
- }, le = (e) => {
213
- const t = document.getElementById(e.id);
214
- if (t) {
215
- const n = c.find((l) => l.id === e.id);
216
- n ? e = o(o(o({}, g), n), e) : e = o(o({}, g), e);
217
- const r = K(v, e);
218
- return P(r, t), O;
245
+ let idsMap = [];
246
+ let optsMap = [];
247
+ const clearToast = (id) => {
248
+ if (id) {
249
+ const container = document.getElementById(id);
250
+ optsMap = optsMap.filter((item) => item.id !== id);
251
+ idsMap = idsMap.filter((item) => item !== id);
252
+ if (container) {
253
+ document.body.removeChild(container);
254
+ }
255
+ } else {
256
+ idsMap.forEach((item) => {
257
+ const container = document.getElementById(item);
258
+ if (container) {
259
+ document.body.removeChild(container);
260
+ }
261
+ });
262
+ optsMap = [];
263
+ idsMap = [];
219
264
  }
220
- }, s = (e) => {
221
- e.unmount = I;
222
- let t;
223
- if (e.id) {
224
- if (t = e.id, i.find((n) => n === e.id))
225
- return le(e);
226
- } else
227
- t = (/* @__PURE__ */ new Date()).getTime() + "";
228
- return e = o(o({}, g), e), e.id = t, i.push(e.id), c.push(e), Z(e, {
229
- wrapper: v
230
- }), O;
231
- }, m = (e) => {
232
- if (!e) {
265
+ };
266
+ const updateToast = (opts) => {
267
+ const container = document.getElementById(opts.id);
268
+ if (container) {
269
+ const currentOpt = optsMap.find((item) => item.id === opts.id);
270
+ if (currentOpt) {
271
+ opts = __spreadValues(__spreadValues(__spreadValues({}, defaultOptions), currentOpt), opts);
272
+ } else {
273
+ opts = __spreadValues(__spreadValues({}, defaultOptions), opts);
274
+ }
275
+ const instance = createVNode(Toast, opts);
276
+ render(instance, container);
277
+ return showToast;
278
+ }
279
+ };
280
+ const mountToast = (opts) => {
281
+ opts.unmount = clearToast;
282
+ let _id;
283
+ if (opts.id) {
284
+ _id = opts.id;
285
+ if (idsMap.find((item) => item === opts.id)) {
286
+ return updateToast(opts);
287
+ }
288
+ } else {
289
+ _id = (/* @__PURE__ */ new Date()).getTime() + "";
290
+ }
291
+ opts = __spreadValues(__spreadValues({}, defaultOptions), opts);
292
+ opts.id = _id;
293
+ idsMap.push(opts.id);
294
+ optsMap.push(opts);
295
+ CreateComponent(opts, {
296
+ wrapper: Toast
297
+ });
298
+ return showToast;
299
+ };
300
+ const errorMsg = (msg) => {
301
+ if (!msg) {
233
302
  console.warn("[NutUI Toast]: msg不能为空");
234
303
  return;
235
304
  }
236
- }, O = {
237
- text(e, t = {}) {
238
- return m(e), s(a(o({}, t), { type: "text", msg: e }));
305
+ };
306
+ const showToast = {
307
+ text(msg, opts = {}) {
308
+ errorMsg(msg);
309
+ return mountToast(__spreadProps(__spreadValues({}, opts), { type: "text", msg }));
239
310
  },
240
- success(e, t = {}) {
241
- return m(e), s(a(o({ icon: x }, t), { msg: e, type: "success" }));
311
+ success(msg, opts = {}) {
312
+ errorMsg(msg);
313
+ return mountToast(__spreadProps(__spreadValues({ icon: Success }, opts), { msg, type: "success" }));
242
314
  },
243
- fail(e, t = {}) {
244
- return m(e), s(a(o({ icon: _ }, t), { msg: e, type: "fail" }));
315
+ fail(msg, opts = {}) {
316
+ errorMsg(msg);
317
+ return mountToast(__spreadProps(__spreadValues({ icon: Failure }, opts), { msg, type: "fail" }));
245
318
  },
246
- warn(e, t = {}) {
247
- return m(e), s(a(o({ icon: ee }, t), { msg: e, type: "warn" }));
319
+ warn(msg, opts = {}) {
320
+ errorMsg(msg);
321
+ return mountToast(__spreadProps(__spreadValues({ icon: Tips }, opts), { msg, type: "warn" }));
248
322
  },
249
- loading(e, t = {}) {
250
- return s(a(o({
251
- icon: te
252
- }, t), {
253
- msg: e,
323
+ loading(msg, opts = {}) {
324
+ return mountToast(__spreadProps(__spreadValues({
325
+ icon: Loading
326
+ }, opts), {
327
+ msg,
254
328
  type: "loading"
255
329
  }));
256
330
  },
257
- hide(e) {
258
- I(e);
331
+ hide(id) {
332
+ clearToast(id);
259
333
  },
260
- install(e) {
261
- e.use(v);
334
+ install(app) {
335
+ app.use(Toast);
262
336
  }
263
337
  };
264
338
  export {
265
- v as default,
266
- O as showToast
339
+ Toast as default,
340
+ showToast
267
341
  };