@nutui/nutui 4.0.10-beta.1 → 4.0.10

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 (160) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/nutui.es.js +1 -1
  3. package/dist/nutui.js +6550 -8291
  4. package/dist/nutui.umd.js +1 -1
  5. package/dist/packages/_es/ActionSheet.js +78 -111
  6. package/dist/packages/_es/Address.js +250 -375
  7. package/dist/packages/_es/AddressList.js +269 -354
  8. package/dist/packages/_es/Animate.js +41 -58
  9. package/dist/packages/_es/Audio.js +128 -197
  10. package/dist/packages/_es/AudioOperate.js +60 -71
  11. package/dist/packages/_es/Avatar.js +66 -89
  12. package/dist/packages/_es/AvatarGroup.js +23 -31
  13. package/dist/packages/_es/Backtop.js +59 -99
  14. package/dist/packages/_es/Badge.js +36 -47
  15. package/dist/packages/_es/Barrage.js +68 -147
  16. package/dist/packages/_es/Button.js +47 -66
  17. package/dist/packages/_es/Calendar.js +135 -157
  18. package/dist/packages/_es/CalendarItem.js +6 -6
  19. package/dist/packages/_es/Card.js +42 -56
  20. package/dist/packages/_es/Cascader.js +315 -474
  21. package/dist/packages/_es/Category.js +29 -39
  22. package/dist/packages/_es/CategoryPane.js +57 -83
  23. package/dist/packages/_es/Cell.js +56 -71
  24. package/dist/packages/_es/CellGroup.js +19 -27
  25. package/dist/packages/_es/Checkbox.js +109 -156
  26. package/dist/packages/_es/CheckboxGroup.js +38 -59
  27. package/dist/packages/_es/CircleProgress.js +67 -96
  28. package/dist/packages/_es/Col.js +23 -31
  29. package/dist/packages/_es/Collapse.js +33 -58
  30. package/dist/packages/_es/CollapseItem.js +78 -108
  31. package/dist/packages/_es/Comment.js +207 -279
  32. package/dist/packages/_es/ConfigProvider.js +37 -55
  33. package/dist/packages/_es/Countdown.js +100 -212
  34. package/dist/packages/_es/Countup.js +232 -445
  35. package/dist/packages/_es/DatePicker.js +162 -265
  36. package/dist/packages/_es/Dialog.js +161 -213
  37. package/dist/packages/_es/Divider.js +42 -57
  38. package/dist/packages/_es/Drag.js +70 -153
  39. package/dist/packages/_es/Ecard.js +64 -104
  40. package/dist/packages/_es/Elevator.js +143 -219
  41. package/dist/packages/_es/Ellipsis.js +95 -178
  42. package/dist/packages/_es/Empty.js +23 -39
  43. package/dist/packages/_es/FixedNav.js +93 -116
  44. package/dist/packages/_es/Form.js +107 -178
  45. package/dist/packages/_es/FormItem.js +48 -61
  46. package/dist/packages/_es/Grid.js +5 -6
  47. package/dist/packages/_es/GridItem.js +58 -84
  48. package/dist/packages/_es/Image.js +90 -129
  49. package/dist/packages/_es/ImagePreview.js +256 -412
  50. package/dist/packages/_es/Indicator.js +30 -34
  51. package/dist/packages/_es/InfiniteLoading.js +83 -136
  52. package/dist/packages/_es/Input.js +160 -264
  53. package/dist/packages/_es/InputNumber.js +81 -117
  54. package/dist/packages/_es/Interceptor-6e26b757.js +18 -0
  55. package/dist/packages/_es/Invoice.js +104 -130
  56. package/dist/packages/_es/Layout.js +3 -4
  57. package/dist/packages/_es/List.js +117 -215
  58. package/dist/packages/_es/Menu.js +95 -150
  59. package/dist/packages/_es/MenuItem.js +109 -154
  60. package/dist/packages/_es/Navbar.js +103 -119
  61. package/dist/packages/_es/Noticebar.js +197 -312
  62. package/dist/packages/_es/Notify.js +110 -166
  63. package/dist/packages/_es/NumberKeyboard.js +127 -202
  64. package/dist/packages/_es/Overlay.js +52 -80
  65. package/dist/packages/_es/Pagination.js +70 -100
  66. package/dist/packages/_es/Picker.js +275 -437
  67. package/dist/packages/_es/Popover.js +122 -225
  68. package/dist/packages/_es/Popup.js +4 -4
  69. package/dist/packages/_es/Price.js +44 -82
  70. package/dist/packages/_es/Progress.js +63 -79
  71. package/dist/packages/_es/PullRefresh.js +95 -173
  72. package/dist/packages/_es/Radio.js +4 -4
  73. package/dist/packages/_es/RadioGroup.js +3 -3
  74. package/dist/packages/_es/Range.js +204 -347
  75. package/dist/packages/_es/Rate.js +92 -141
  76. package/dist/packages/_es/Row.js +21 -27
  77. package/dist/packages/_es/Searchbar.js +123 -174
  78. package/dist/packages/_es/ShortPassword.js +69 -93
  79. package/dist/packages/_es/SideNavbar.js +49 -80
  80. package/dist/packages/_es/SideNavbarItem.js +22 -32
  81. package/dist/packages/_es/Signature.js +83 -146
  82. package/dist/packages/_es/Skeleton.js +110 -130
  83. package/dist/packages/_es/Sku.js +250 -343
  84. package/dist/packages/_es/Step.js +59 -86
  85. package/dist/packages/_es/Steps.js +26 -31
  86. package/dist/packages/_es/Sticky.js +4 -4
  87. package/dist/packages/_es/SubSideNavbar.js +52 -74
  88. package/dist/packages/_es/Swipe.js +83 -155
  89. package/dist/packages/_es/Swiper.js +174 -311
  90. package/dist/packages/_es/SwiperItem.js +28 -44
  91. package/dist/packages/_es/Switch.js +55 -68
  92. package/dist/packages/_es/TabPane.js +30 -41
  93. package/dist/packages/_es/Tabbar.js +41 -52
  94. package/dist/packages/_es/TabbarItem.js +61 -82
  95. package/dist/packages/_es/Table.js +109 -165
  96. package/dist/packages/_es/Tabs.js +240 -388
  97. package/dist/packages/_es/Tag.js +44 -61
  98. package/dist/packages/_es/Textarea.js +80 -124
  99. package/dist/packages/_es/TimeDetail.js +49 -76
  100. package/dist/packages/_es/TimePannel.js +34 -48
  101. package/dist/packages/_es/TimeSelect.js +47 -68
  102. package/dist/packages/_es/Toast.js +144 -218
  103. package/dist/packages/_es/Tour.js +138 -192
  104. package/dist/packages/_es/TrendArrow.js +57 -77
  105. package/dist/packages/_es/Uploader.js +234 -359
  106. package/dist/packages/_es/Video.js +191 -316
  107. package/dist/packages/_es/Watermark.js +84 -117
  108. package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +9 -0
  109. package/dist/packages/_es/common-d218746f.js +116 -0
  110. package/dist/packages/_es/component-234624bc.js +89 -0
  111. package/dist/packages/_es/index-14dfadc4.js +561 -0
  112. package/dist/packages/_es/index-192a3ef6.js +29 -0
  113. package/dist/packages/_es/index-360c5092.js +210 -0
  114. package/dist/packages/_es/index-496e6e05.js +24 -0
  115. package/dist/packages/_es/index-50eed3d9.js +7 -0
  116. package/dist/packages/_es/index-53ec2d4d.js +34 -0
  117. package/dist/packages/_es/index-fadb0974.js +8 -0
  118. package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +43 -0
  119. package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +77 -0
  120. package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +110 -0
  121. package/dist/packages/_es/mountComponent-6d4ff200.js +23 -0
  122. package/dist/packages/_es/pxCheck-38173291.js +4 -0
  123. package/dist/packages/_es/raf-a74f1a06.js +16 -0
  124. package/dist/packages/_es/renderIcon-47498b32.js +5 -0
  125. package/dist/smartips/web-types.json +1 -1
  126. package/dist/style.css +1 -1
  127. package/dist/styles/themes/default.scss +154 -51
  128. package/dist/styles/themes/jdb.scss +154 -51
  129. package/dist/styles/themes/jddkh.scss +154 -51
  130. package/dist/styles/themes/jdt.scss +154 -51
  131. package/dist/types/__VUE/address/index.vue.d.ts +1 -1
  132. package/dist/types/__VUE/collapseitem/index.vue.d.ts +110 -3
  133. package/dist/types/__VUE/image/index.vue.d.ts +2 -2
  134. package/dist/types/__VUE/rate/index.vue.d.ts +110 -3
  135. package/dist/types/__VUE/searchbar/index.vue.d.ts +110 -3
  136. package/dist/types/__VUE/skeleton/index.vue.d.ts +2 -2
  137. package/dist/types/__VUE/swiper/index.vue.d.ts +1 -1
  138. package/dist/types/__VUE/table/common.d.ts +55 -2
  139. package/dist/types/__VUE/timeselect/index.vue.d.ts +1 -1
  140. package/dist/types/__VUE/watermark/index.vue.d.ts +1 -1
  141. package/dist/types/index.d.ts +1 -1
  142. package/package.json +2 -2
  143. package/dist/packages/_es/Interceptor-956b24fc.js +0 -29
  144. package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +0 -10
  145. package/dist/packages/_es/common-b9a5e726.js +0 -145
  146. package/dist/packages/_es/component-81a4c1d0.js +0 -145
  147. package/dist/packages/_es/index-29892cda.js +0 -33
  148. package/dist/packages/_es/index-43c34ac6.js +0 -30
  149. package/dist/packages/_es/index-54d03fc1.js +0 -8
  150. package/dist/packages/_es/index-79c5dc33.js +0 -10
  151. package/dist/packages/_es/index-7a7385e4.js +0 -67
  152. package/dist/packages/_es/index-87422be8.js +0 -942
  153. package/dist/packages/_es/index-da0a7662.js +0 -259
  154. package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +0 -46
  155. package/dist/packages/_es/index.vue_vue_type_script_lang-442e4704.js +0 -98
  156. package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +0 -151
  157. package/dist/packages/_es/mountComponent-8b24c346.js +0 -39
  158. package/dist/packages/_es/pxCheck-c6b9f6b7.js +0 -6
  159. package/dist/packages/_es/raf-729dad54.js +0 -25
  160. package/dist/packages/_es/renderIcon-3d0fd47c.js +0 -9
@@ -1,13 +1,12 @@
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";
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";
6
6
  import "../locale/lang";
7
- const { componentName, create } = createComponent("backtop");
8
- const _sfc_main = create({
7
+ const { componentName: M, create: S } = C("backtop"), W = S({
9
8
  components: {
10
- Top
9
+ Top: _
11
10
  },
12
11
  props: {
13
12
  bottom: {
@@ -32,7 +31,7 @@ const _sfc_main = create({
32
31
  },
33
32
  isAnimation: {
34
33
  type: Boolean,
35
- default: true
34
+ default: !0
36
35
  },
37
36
  duration: {
38
37
  type: Number,
@@ -40,109 +39,70 @@ const _sfc_main = create({
40
39
  }
41
40
  },
42
41
  emits: ["click"],
43
- setup(props, { emit }) {
44
- const state = reactive({
45
- backTop: false,
42
+ setup(t, { emit: n }) {
43
+ const e = k({
44
+ backTop: !1,
46
45
  scrollTop: 0,
47
46
  scrollEl: window,
48
47
  startTime: 0,
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;
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;
72
59
  }
73
- function scroll(y = 0) {
74
- if (state.scrollEl instanceof Window) {
75
- window.scrollTo(0, y);
76
- } else {
77
- state.scrollEl.scrollTop = y;
78
- }
60
+ function i(o = 0) {
61
+ e.scrollEl instanceof Window ? window.scrollTo(0, o) : e.scrollEl.scrollTop = o;
79
62
  }
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
- }
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);
89
67
  });
90
68
  }
91
- function addEventListener() {
92
- state.scrollEl.addEventListener("scroll", scrollListener, false);
93
- state.scrollEl.addEventListener("resize", scrollListener, false);
69
+ function v() {
70
+ e.scrollEl.addEventListener("scroll", l, !1), e.scrollEl.addEventListener("resize", l, !1);
94
71
  }
95
- function removeEventListener() {
96
- state.scrollEl.removeEventListener("scroll", scrollListener, false);
97
- state.scrollEl.removeEventListener("resize", scrollListener, false);
72
+ function a() {
73
+ e.scrollEl.removeEventListener("scroll", l, !1), e.scrollEl.removeEventListener("resize", l, !1);
98
74
  }
99
- function click(e) {
100
- state.startTime = +/* @__PURE__ */ new Date();
101
- props.isAnimation && props.duration > 0 ? scrollAnimation() : scroll();
102
- emit("click", e);
75
+ function E(o) {
76
+ e.startTime = +/* @__PURE__ */ new Date(), t.isAnimation && t.duration > 0 ? r() : i(), n("click", o);
103
77
  }
104
- function init() {
105
- if (props.elId && document.getElementById(props.elId)) {
106
- state.scrollEl = document.getElementById(props.elId);
107
- }
108
- addEventListener();
78
+ function d() {
79
+ t.elId && document.getElementById(t.elId) && (e.scrollEl = document.getElementById(t.elId)), v();
109
80
  }
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
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
134
94
  };
135
95
  }
136
96
  });
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"]))
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"]))
143
103
  }, [
144
- renderSlot(_ctx.$slots, "default", {}, () => [
145
- createVNode(_component_Top, {
104
+ N(t.$slots, "default", {}, () => [
105
+ $(i, {
146
106
  width: "19px",
147
107
  height: "19px",
148
108
  class: "nut-backtop-main"
@@ -150,7 +110,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
150
110
  ])
151
111
  ], 6);
152
112
  }
153
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
113
+ const j = /* @__PURE__ */ D(W, [["render", q]]);
154
114
  export {
155
- index as default
115
+ j as default
156
116
  };
@@ -1,9 +1,8 @@
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";
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";
4
4
  import "../locale/lang";
5
- const { create } = createComponent("badge");
6
- const _sfc_main = create({
5
+ const { create: $ } = y("badge"), v = $({
7
6
  props: {
8
7
  value: {
9
8
  type: [String, Number]
@@ -14,15 +13,15 @@ const _sfc_main = create({
14
13
  },
15
14
  dot: {
16
15
  type: Boolean,
17
- default: false
16
+ default: !1
18
17
  },
19
18
  bubble: {
20
19
  type: Boolean,
21
- default: false
20
+ default: !1
22
21
  },
23
22
  hidden: {
24
23
  type: Boolean,
25
- default: false
24
+ default: !1
26
25
  },
27
26
  top: {
28
27
  type: String,
@@ -41,56 +40,46 @@ const _sfc_main = create({
41
40
  default: ""
42
41
  }
43
42
  },
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)
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)
56
51
  return;
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;
52
+ const t = e.value, n = e.max;
53
+ return typeof t == "number" && typeof n == "number" && n < t ? `${n}+` : t;
63
54
  });
64
55
  return {
65
- state,
66
- stl,
67
- content
56
+ state: o,
57
+ stl: a,
58
+ content: l
68
59
  };
69
60
  }
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", {
61
+ }), _ = { class: "nut-badge" }, S = ["textContent"];
62
+ function B(e, o, a, l, t, n) {
63
+ return b(), m("view", _, [
64
+ d(s("view", {
76
65
  class: "nut-badge__icon",
77
- style: normalizeStyle(_ctx.stl)
66
+ style: u(e.stl)
78
67
  }, [
79
- renderSlot(_ctx.$slots, "icon")
68
+ i(e.$slots, "icon")
80
69
  ], 4), [
81
- [vShow, !_ctx.hidden && !_ctx.dot && _ctx.$slots.icon]
70
+ [c, !e.hidden && !e.dot && e.$slots.icon]
82
71
  ]),
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)]
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)]
90
79
  ])
91
80
  ]);
92
81
  }
93
- const Badge = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
82
+ const k = /* @__PURE__ */ h(v, [["render", B]]);
94
83
  export {
95
- Badge as default
84
+ k as default
96
85
  };
@@ -1,9 +1,8 @@
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";
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";
4
4
  import "../locale/lang";
5
- const { componentName, create } = createComponent("barrage");
6
- const _sfc_main = create({
5
+ const { componentName: z, create: P } = V("barrage"), U = P({
7
6
  name: "barrage",
8
7
  props: {
9
8
  danmu: {
@@ -28,168 +27,90 @@ const _sfc_main = create({
28
27
  },
29
28
  loop: {
30
29
  type: Boolean,
31
- default: true
30
+ default: !0
32
31
  }
33
32
  },
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
- }
65
- });
66
- onUnmounted(() => {
67
- danmuList.value = [];
68
- clearTime();
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();
69
45
  });
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();
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();
79
50
  }, 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);
80
61
  };
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
- }
62
+ W(
63
+ () => t.danmu,
64
+ (n) => {
65
+ t.danmu.length > 0 && (a.value = [...n]);
113
66
  }
114
67
  );
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;
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";
165
85
  }
166
- el.removeEventListener("animationend", () => {
167
- });
168
- run();
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());
169
90
  });
170
91
  };
171
- return { classTime, classes, danmuList, dmBody, dmContainer, add };
92
+ return { classTime: v, classes: h, danmuList: a, dmBody: c, dmContainer: r, add: x };
172
93
  }
173
94
  });
174
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
175
- return openBlock(), createElementBlock("div", {
95
+ function F(t, v, o, h, c, r) {
96
+ return E(), _("div", {
176
97
  ref: "dmBody",
177
- class: normalizeClass(_ctx.classes)
98
+ class: p(t.classes)
178
99
  }, [
179
- createElementVNode("div", {
100
+ A("div", {
180
101
  ref: "dmContainer",
181
- class: normalizeClass(["dmContainer", _ctx.$slots.default && "slotContainer"])
102
+ class: p(["dmContainer", t.$slots.default && "slotContainer"])
182
103
  }, [
183
- _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
104
+ t.$slots.default ? (E(), _("div", {
184
105
  key: 0,
185
- class: normalizeClass(["slotBody", "slotBody" + _ctx.classTime])
106
+ class: p(["slotBody", "slotBody" + t.classTime])
186
107
  }, [
187
- renderSlot(_ctx.$slots, "default")
188
- ], 2)) : createCommentVNode("", true)
108
+ H(t.$slots, "default")
109
+ ], 2)) : M("", !0)
189
110
  ], 2)
190
111
  ], 2);
191
112
  }
192
- const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
113
+ const O = /* @__PURE__ */ j(U, [["render", F]]);
193
114
  export {
194
- index as default
115
+ O as default
195
116
  };