@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,12 +1,13 @@
1
- import { reactive as k, computed as u, onMounted as b, onUnmounted as y, onActivated as w, onDeactivated as x, resolveComponent as A, openBlock as I, createElementBlock as g, normalizeClass as h, normalizeStyle as z, withModifiers as L, renderSlot as N, createVNode as $ } from "vue";
2
- import { c as C } from "./component-234624bc.js";
3
- import { r as p, c as B } from "./raf-a74f1a06.js";
4
- import { Top as _ } from "@nutui/icons-vue";
5
- import { _ as D } from "./_plugin-vue_export-helper-dad06003.js";
1
+ import { reactive, computed, onMounted, onUnmounted, onActivated, onDeactivated, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, withModifiers, renderSlot, createVNode } from "vue";
2
+ import { c as createComponent } from "./component-81a4c1d0.js";
3
+ import { r as requestAniFrame, c as cancelRaf } from "./raf-729dad54.js";
4
+ import { Top } from "@nutui/icons-vue";
5
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
6
6
  import "../locale/lang";
7
- const { componentName: M, create: S } = C("backtop"), W = S({
7
+ const { componentName, create } = createComponent("backtop");
8
+ const _sfc_main = create({
8
9
  components: {
9
- Top: _
10
+ Top
10
11
  },
11
12
  props: {
12
13
  bottom: {
@@ -31,7 +32,7 @@ const { componentName: M, create: S } = C("backtop"), W = S({
31
32
  },
32
33
  isAnimation: {
33
34
  type: Boolean,
34
- default: !0
35
+ default: true
35
36
  },
36
37
  duration: {
37
38
  type: Number,
@@ -39,70 +40,109 @@ const { componentName: M, create: S } = C("backtop"), W = S({
39
40
  }
40
41
  },
41
42
  emits: ["click"],
42
- setup(t, { emit: n }) {
43
- const e = k({
44
- backTop: !1,
43
+ setup(props, { emit }) {
44
+ const state = reactive({
45
+ backTop: false,
45
46
  scrollTop: 0,
46
47
  scrollEl: window,
47
48
  startTime: 0,
48
- keepAlive: !1
49
- }), s = u(() => ({
50
- [M]: !0,
51
- show: e.backTop
52
- })), c = u(() => ({
53
- right: `${t.right}px`,
54
- bottom: `${t.bottom}px`,
55
- zIndex: t.zIndex
56
- }));
57
- function l() {
58
- e.scrollEl instanceof Window ? e.scrollTop = e.scrollEl.pageYOffset : e.scrollTop = e.scrollEl.scrollTop, e.backTop = e.scrollTop >= t.distance;
49
+ keepAlive: false
50
+ });
51
+ const classes = computed(() => {
52
+ const prefixCls = componentName;
53
+ return {
54
+ [prefixCls]: true,
55
+ show: state.backTop
56
+ };
57
+ });
58
+ const style = computed(() => {
59
+ return {
60
+ right: `${props.right}px`,
61
+ bottom: `${props.bottom}px`,
62
+ zIndex: props.zIndex
63
+ };
64
+ });
65
+ function scrollListener() {
66
+ if (state.scrollEl instanceof Window) {
67
+ state.scrollTop = state.scrollEl.pageYOffset;
68
+ } else {
69
+ state.scrollTop = state.scrollEl.scrollTop;
70
+ }
71
+ state.backTop = state.scrollTop >= props.distance;
59
72
  }
60
- function i(o = 0) {
61
- e.scrollEl instanceof Window ? window.scrollTo(0, o) : e.scrollEl.scrollTop = o;
73
+ function scroll(y = 0) {
74
+ if (state.scrollEl instanceof Window) {
75
+ window.scrollTo(0, y);
76
+ } else {
77
+ state.scrollEl.scrollTop = y;
78
+ }
62
79
  }
63
- function r() {
64
- let o = p(function T() {
65
- var f = t.duration - Math.max(0, e.startTime - +/* @__PURE__ */ new Date() + t.duration), m = f * -e.scrollTop / t.duration + e.scrollTop;
66
- i(m), o = p(T), (f == t.duration || m == 0) && B(o);
80
+ function scrollAnimation() {
81
+ let cid = requestAniFrame(function fn() {
82
+ var t = props.duration - Math.max(0, state.startTime - +/* @__PURE__ */ new Date() + props.duration);
83
+ var y = t * -state.scrollTop / props.duration + state.scrollTop;
84
+ scroll(y);
85
+ cid = requestAniFrame(fn);
86
+ if (t == props.duration || y == 0) {
87
+ cancelRaf(cid);
88
+ }
67
89
  });
68
90
  }
69
- function v() {
70
- e.scrollEl.addEventListener("scroll", l, !1), e.scrollEl.addEventListener("resize", l, !1);
91
+ function addEventListener() {
92
+ state.scrollEl.addEventListener("scroll", scrollListener, false);
93
+ state.scrollEl.addEventListener("resize", scrollListener, false);
71
94
  }
72
- function a() {
73
- e.scrollEl.removeEventListener("scroll", l, !1), e.scrollEl.removeEventListener("resize", l, !1);
95
+ function removeEventListener() {
96
+ state.scrollEl.removeEventListener("scroll", scrollListener, false);
97
+ state.scrollEl.removeEventListener("resize", scrollListener, false);
74
98
  }
75
- function E(o) {
76
- e.startTime = +/* @__PURE__ */ new Date(), t.isAnimation && t.duration > 0 ? r() : i(), n("click", o);
99
+ function click(e) {
100
+ state.startTime = +/* @__PURE__ */ new Date();
101
+ props.isAnimation && props.duration > 0 ? scrollAnimation() : scroll();
102
+ emit("click", e);
77
103
  }
78
- function d() {
79
- t.elId && document.getElementById(t.elId) && (e.scrollEl = document.getElementById(t.elId)), v();
104
+ function init() {
105
+ if (props.elId && document.getElementById(props.elId)) {
106
+ state.scrollEl = document.getElementById(props.elId);
107
+ }
108
+ addEventListener();
80
109
  }
81
- return b(() => {
82
- t.distance == 0 && (e.backTop = !0), d();
83
- }), y(() => {
84
- a();
85
- }), w(() => {
86
- e.keepAlive && (e.keepAlive = !1, d());
87
- }), x(() => {
88
- e.keepAlive = !0, a();
89
- }), {
90
- state: e,
91
- classes: s,
92
- style: c,
93
- click: E
110
+ onMounted(() => {
111
+ if (props.distance == 0) {
112
+ state.backTop = true;
113
+ }
114
+ init();
115
+ });
116
+ onUnmounted(() => {
117
+ removeEventListener();
118
+ });
119
+ onActivated(() => {
120
+ if (state.keepAlive) {
121
+ state.keepAlive = false;
122
+ init();
123
+ }
124
+ });
125
+ onDeactivated(() => {
126
+ state.keepAlive = true;
127
+ removeEventListener();
128
+ });
129
+ return {
130
+ state,
131
+ classes,
132
+ style,
133
+ click
94
134
  };
95
135
  }
96
136
  });
97
- function q(t, n, e, s, c, l) {
98
- const i = A("Top");
99
- return I(), g("div", {
100
- class: h(t.classes),
101
- style: z(t.style),
102
- onClick: n[0] || (n[0] = L((...r) => t.click && t.click(...r), ["stop"]))
137
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
138
+ const _component_Top = resolveComponent("Top");
139
+ return openBlock(), createElementBlock("div", {
140
+ class: normalizeClass(_ctx.classes),
141
+ style: normalizeStyle(_ctx.style),
142
+ onClick: _cache[0] || (_cache[0] = withModifiers((...args) => _ctx.click && _ctx.click(...args), ["stop"]))
103
143
  }, [
104
- N(t.$slots, "default", {}, () => [
105
- $(i, {
144
+ renderSlot(_ctx.$slots, "default", {}, () => [
145
+ createVNode(_component_Top, {
106
146
  width: "19px",
107
147
  height: "19px",
108
148
  class: "nut-backtop-main"
@@ -110,7 +150,7 @@ function q(t, n, e, s, c, l) {
110
150
  ])
111
151
  ], 6);
112
152
  }
113
- const j = /* @__PURE__ */ D(W, [["render", q]]);
153
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
114
154
  export {
115
- j as default
155
+ index as default
116
156
  };
@@ -1,8 +1,9 @@
1
- import { reactive as f, computed as r, openBlock as b, createElementBlock as m, withDirectives as d, createElementVNode as s, normalizeStyle as u, renderSlot as i, vShow as c, toDisplayString as p, normalizeClass as g } from "vue";
2
- import { c as y } from "./component-234624bc.js";
3
- import { _ as h } from "./_plugin-vue_export-helper-dad06003.js";
1
+ import { reactive, computed, openBlock, createElementBlock, withDirectives, createElementVNode, normalizeStyle, renderSlot, vShow, toDisplayString, normalizeClass } from "vue";
2
+ import { c as createComponent } from "./component-81a4c1d0.js";
3
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
4
4
  import "../locale/lang";
5
- const { create: $ } = y("badge"), v = $({
5
+ const { create } = createComponent("badge");
6
+ const _sfc_main = create({
6
7
  props: {
7
8
  value: {
8
9
  type: [String, Number]
@@ -13,15 +14,15 @@ const { create: $ } = y("badge"), v = $({
13
14
  },
14
15
  dot: {
15
16
  type: Boolean,
16
- default: !1
17
+ default: false
17
18
  },
18
19
  bubble: {
19
20
  type: Boolean,
20
- default: !1
21
+ default: false
21
22
  },
22
23
  hidden: {
23
24
  type: Boolean,
24
- default: !1
25
+ default: false
25
26
  },
26
27
  top: {
27
28
  type: String,
@@ -40,46 +41,56 @@ const { create: $ } = y("badge"), v = $({
40
41
  default: ""
41
42
  }
42
43
  },
43
- setup(e) {
44
- const o = f({}), a = r(() => ({
45
- top: `${e.top}px`,
46
- right: `${e.right}px`,
47
- zIndex: e.zIndex,
48
- background: e.color
49
- })), l = r(() => {
50
- if (e.dot)
44
+ setup(props) {
45
+ const state = reactive({});
46
+ const stl = computed(() => {
47
+ return {
48
+ top: `${props.top}px`,
49
+ right: `${props.right}px`,
50
+ zIndex: props.zIndex,
51
+ background: props.color
52
+ };
53
+ });
54
+ const content = computed(() => {
55
+ if (props.dot)
51
56
  return;
52
- const t = e.value, n = e.max;
53
- return typeof t == "number" && typeof n == "number" && n < t ? `${n}+` : t;
57
+ const value = props.value;
58
+ const max = props.max;
59
+ if (typeof value === "number" && typeof max === "number") {
60
+ return max < value ? `${max}+` : value;
61
+ }
62
+ return value;
54
63
  });
55
64
  return {
56
- state: o,
57
- stl: a,
58
- content: l
65
+ state,
66
+ stl,
67
+ content
59
68
  };
60
69
  }
61
- }), _ = { class: "nut-badge" }, S = ["textContent"];
62
- function B(e, o, a, l, t, n) {
63
- return b(), m("view", _, [
64
- d(s("view", {
70
+ });
71
+ const _hoisted_1 = { class: "nut-badge" };
72
+ const _hoisted_2 = ["textContent"];
73
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
74
+ return openBlock(), createElementBlock("view", _hoisted_1, [
75
+ withDirectives(createElementVNode("view", {
65
76
  class: "nut-badge__icon",
66
- style: u(e.stl)
77
+ style: normalizeStyle(_ctx.stl)
67
78
  }, [
68
- i(e.$slots, "icon")
79
+ renderSlot(_ctx.$slots, "icon")
69
80
  ], 4), [
70
- [c, !e.hidden && !e.dot && e.$slots.icon]
81
+ [vShow, !_ctx.hidden && !_ctx.dot && _ctx.$slots.icon]
71
82
  ]),
72
- i(e.$slots, "default"),
73
- d(s("view", {
74
- textContent: p(e.content),
75
- class: g(["nut-badge__content nut-badge__content--sup", { "nut-badge__content--dot": e.dot, "nut-badge__content--bubble": !e.dot && e.bubble }]),
76
- style: u(e.stl)
77
- }, null, 14, S), [
78
- [c, !e.hidden && (e.content || e.dot)]
83
+ renderSlot(_ctx.$slots, "default"),
84
+ withDirectives(createElementVNode("view", {
85
+ textContent: toDisplayString(_ctx.content),
86
+ class: normalizeClass(["nut-badge__content nut-badge__content--sup", { "nut-badge__content--dot": _ctx.dot, "nut-badge__content--bubble": !_ctx.dot && _ctx.bubble }]),
87
+ style: normalizeStyle(_ctx.stl)
88
+ }, null, 14, _hoisted_2), [
89
+ [vShow, !_ctx.hidden && (_ctx.content || _ctx.dot)]
79
90
  ])
80
91
  ]);
81
92
  }
82
- const k = /* @__PURE__ */ h(v, [["render", B]]);
93
+ const Badge = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
83
94
  export {
84
- k as default
95
+ Badge as default
85
96
  };
@@ -1,8 +1,9 @@
1
- import { useSlots as w, computed as S, ref as s, onMounted as k, onUnmounted as D, watch as W, nextTick as q, openBlock as E, createElementBlock as _, normalizeClass as p, createElementVNode as A, renderSlot as H, createCommentVNode as M } from "vue";
2
- import { c as V } from "./component-234624bc.js";
3
- import { _ as j } from "./_plugin-vue_export-helper-dad06003.js";
1
+ import { useSlots, computed, ref, onMounted, onUnmounted, watch, nextTick, openBlock, createElementBlock, normalizeClass, createElementVNode, renderSlot, createCommentVNode } from "vue";
2
+ import { c as createComponent } from "./component-81a4c1d0.js";
3
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js";
4
4
  import "../locale/lang";
5
- const { componentName: z, create: P } = V("barrage"), U = P({
5
+ const { componentName, create } = createComponent("barrage");
6
+ const _sfc_main = create({
6
7
  name: "barrage",
7
8
  props: {
8
9
  danmu: {
@@ -27,90 +28,168 @@ const { componentName: z, create: P } = V("barrage"), U = P({
27
28
  },
28
29
  loop: {
29
30
  type: Boolean,
30
- default: !0
31
+ default: true
31
32
  }
32
33
  },
33
- setup(t) {
34
- const v = (/* @__PURE__ */ new Date()).getTime(), o = !!w().default, h = S(() => ({
35
- [z]: !0
36
- }));
37
- let c = s(document.createElement("div")), r = s(document.createElement("div")), m = null;
38
- const a = s(t.danmu), B = s(t.rows), T = s(t.top), l = s(0), $ = t.speeds, g = s(0);
39
- k(() => {
40
- b(), o && document.addEventListener("visibilitychange", function() {
41
- document.visibilityState === "hidden" ? (y(), l.value = 0, C("hidden")) : document.visibilityState === "visible" && b();
42
- });
43
- }), D(() => {
44
- a.value = [], y();
34
+ setup(props) {
35
+ const classTime = (/* @__PURE__ */ new Date()).getTime();
36
+ const slotDefault = !!useSlots().default;
37
+ const classes = computed(() => {
38
+ const prefixCls = componentName;
39
+ return {
40
+ [prefixCls]: true
41
+ };
42
+ });
43
+ let dmBody = ref(document.createElement("div"));
44
+ let dmContainer = ref(document.createElement("div"));
45
+ let timer = null;
46
+ const danmuList = ref(props.danmu);
47
+ const rows = ref(props.rows);
48
+ const top = ref(props.top);
49
+ const index2 = ref(0);
50
+ const speeds = props.speeds;
51
+ const danmuCWidth = ref(0);
52
+ onMounted(() => {
53
+ init();
54
+ if (slotDefault) {
55
+ document.addEventListener("visibilitychange", function() {
56
+ if (document.visibilityState === "hidden") {
57
+ clearTime();
58
+ index2.value = 0;
59
+ eleSlot("hidden");
60
+ } else if (document.visibilityState === "visible") {
61
+ init();
62
+ }
63
+ });
64
+ }
45
65
  });
46
- const b = () => {
47
- g.value = c.value.offsetWidth, o && C("init"), setTimeout(() => {
48
- var n;
49
- (n = c.value) == null || n.style.setProperty("--move-distance", `-${g.value}px`), L();
66
+ onUnmounted(() => {
67
+ danmuList.value = [];
68
+ clearTime();
69
+ });
70
+ const init = () => {
71
+ danmuCWidth.value = dmBody.value.offsetWidth;
72
+ if (slotDefault) {
73
+ eleSlot("init");
74
+ }
75
+ setTimeout(() => {
76
+ var _a;
77
+ (_a = dmBody.value) == null ? void 0 : _a.style.setProperty("--move-distance", `-${danmuCWidth.value}px`);
78
+ run();
50
79
  }, 300);
51
- }, C = (n) => {
52
- var d;
53
- const e = document.getElementsByClassName("slotBody" + v);
54
- let u = ((d = e == null ? void 0 : e[0]) == null ? void 0 : d.children) || [];
55
- const f = [];
56
- u && Array.from(u).forEach((i) => {
57
- n == "init" ? (i.style.opacity = "0", f.push(i)) : (i.classList = "", i.style = {});
58
- }), n == "init" && (a.value = f);
59
- }, y = () => {
60
- m && (clearTimeout(m), m = null);
61
80
  };
62
- W(
63
- () => t.danmu,
64
- (n) => {
65
- t.danmu.length > 0 && (a.value = [...n]);
81
+ const eleSlot = (flag) => {
82
+ var _a;
83
+ const list = document.getElementsByClassName("slotBody" + classTime);
84
+ let childrens = ((_a = list == null ? void 0 : list[0]) == null ? void 0 : _a.children) || [];
85
+ const dmList = [];
86
+ if (childrens) {
87
+ Array.from(childrens).forEach((item) => {
88
+ if (flag == "init") {
89
+ item.style.opacity = "0";
90
+ dmList.push(item);
91
+ } else {
92
+ item.classList = "";
93
+ item.style = {};
94
+ }
95
+ });
96
+ }
97
+ if (flag == "init") {
98
+ danmuList.value = dmList;
99
+ }
100
+ };
101
+ const clearTime = () => {
102
+ if (timer) {
103
+ clearTimeout(timer);
104
+ timer = null;
105
+ }
106
+ };
107
+ watch(
108
+ () => props.danmu,
109
+ (newValue) => {
110
+ if (props.danmu.length > 0) {
111
+ danmuList.value = [...newValue];
112
+ }
66
113
  }
67
114
  );
68
- const x = (n) => {
69
- const e = l.value % a.value.length;
70
- !t.loop && l.value === a.value.length ? a.value.splice(a.value.length, 0, n) : a.value.splice(e, 0, n);
71
- }, L = () => {
72
- y(), m = setTimeout(() => {
73
- N();
74
- }, t.frequency);
75
- }, N = () => {
76
- var u;
77
- const n = t.loop ? l.value % a.value.length : l.value;
78
- let e = document.createElement("view");
79
- o && typeof a.value[n] == "object" ? (e = a.value[n], (u = e == null ? void 0 : e.classList) == null || u.add("nut-barrage__item")) : (e.innerHTML = a.value[n], e.classList.add("nut-barrage__item"), r.value.appendChild(e)), q(() => {
80
- var d;
81
- const f = e.offsetHeight;
82
- if ((d = e == null ? void 0 : e.classList) == null || d.add("move"), e.style.animationDuration = `${$}ms`, e.style.top = n % B.value * (f + T.value) + 20 + "px", e.style.opacity = "1", !o) {
83
- const i = e.offsetWidth;
84
- e.style.width = i + 20 + "px";
115
+ const add = (word) => {
116
+ const _index = index2.value % danmuList.value.length;
117
+ if (!props.loop && index2.value === danmuList.value.length) {
118
+ danmuList.value.splice(danmuList.value.length, 0, word);
119
+ } else {
120
+ danmuList.value.splice(_index, 0, word);
121
+ }
122
+ };
123
+ const run = () => {
124
+ clearTime();
125
+ timer = setTimeout(() => {
126
+ play();
127
+ }, props.frequency);
128
+ };
129
+ const play = () => {
130
+ var _a;
131
+ const _index = props.loop ? index2.value % danmuList.value.length : index2.value;
132
+ let el = document.createElement(`view`);
133
+ if (slotDefault && typeof danmuList.value[_index] == "object") {
134
+ el = danmuList.value[_index];
135
+ (_a = el == null ? void 0 : el.classList) == null ? void 0 : _a.add("nut-barrage__item");
136
+ } else {
137
+ el.innerHTML = danmuList.value[_index];
138
+ el.classList.add("nut-barrage__item");
139
+ dmContainer.value.appendChild(el);
140
+ }
141
+ nextTick(() => {
142
+ var _a2;
143
+ const height = el.offsetHeight;
144
+ (_a2 = el == null ? void 0 : el.classList) == null ? void 0 : _a2.add("move");
145
+ el.style.animationDuration = `${speeds}ms`;
146
+ el.style.top = _index % rows.value * (height + top.value) + 20 + "px";
147
+ el.style.opacity = "1";
148
+ if (!slotDefault) {
149
+ const width = el.offsetWidth;
150
+ el.style.width = width + 20 + "px";
151
+ }
152
+ el.addEventListener("animationend", () => {
153
+ if (slotDefault) {
154
+ el.classList.remove("move");
155
+ } else {
156
+ dmContainer.value.removeChild(el);
157
+ }
158
+ });
159
+ if (!props.loop && index2.value >= danmuList.value.length - 1) {
160
+ return;
161
+ }
162
+ index2.value++;
163
+ if (index2.value >= danmuList.value.length) {
164
+ index2.value = 0;
85
165
  }
86
- e.addEventListener("animationend", () => {
87
- o ? e.classList.remove("move") : r.value.removeChild(e);
88
- }), !(!t.loop && l.value >= a.value.length - 1) && (l.value++, l.value >= a.value.length && (l.value = 0), e.removeEventListener("animationend", () => {
89
- }), L());
166
+ el.removeEventListener("animationend", () => {
167
+ });
168
+ run();
90
169
  });
91
170
  };
92
- return { classTime: v, classes: h, danmuList: a, dmBody: c, dmContainer: r, add: x };
171
+ return { classTime, classes, danmuList, dmBody, dmContainer, add };
93
172
  }
94
173
  });
95
- function F(t, v, o, h, c, r) {
96
- return E(), _("div", {
174
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
175
+ return openBlock(), createElementBlock("div", {
97
176
  ref: "dmBody",
98
- class: p(t.classes)
177
+ class: normalizeClass(_ctx.classes)
99
178
  }, [
100
- A("div", {
179
+ createElementVNode("div", {
101
180
  ref: "dmContainer",
102
- class: p(["dmContainer", t.$slots.default && "slotContainer"])
181
+ class: normalizeClass(["dmContainer", _ctx.$slots.default && "slotContainer"])
103
182
  }, [
104
- t.$slots.default ? (E(), _("div", {
183
+ _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
105
184
  key: 0,
106
- class: p(["slotBody", "slotBody" + t.classTime])
185
+ class: normalizeClass(["slotBody", "slotBody" + _ctx.classTime])
107
186
  }, [
108
- H(t.$slots, "default")
109
- ], 2)) : M("", !0)
187
+ renderSlot(_ctx.$slots, "default")
188
+ ], 2)) : createCommentVNode("", true)
110
189
  ], 2)
111
190
  ], 2);
112
191
  }
113
- const O = /* @__PURE__ */ j(U, [["render", F]]);
192
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
114
193
  export {
115
- O as default
194
+ index as default
116
195
  };