@nutui/nutui 4.0.12-beta.1 → 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.
- package/dist/nutui.es.js +1 -1
- package/dist/nutui.js +1 -1
- package/dist/nutui.umd.js +1 -1
- package/dist/packages/_es/ActionSheet.js +111 -78
- package/dist/packages/_es/Address.js +375 -250
- package/dist/packages/_es/AddressList.js +354 -269
- package/dist/packages/_es/Animate.js +58 -41
- package/dist/packages/_es/Audio.js +197 -128
- package/dist/packages/_es/AudioOperate.js +71 -60
- package/dist/packages/_es/Avatar.js +89 -66
- package/dist/packages/_es/AvatarGroup.js +31 -23
- package/dist/packages/_es/Backtop.js +99 -59
- package/dist/packages/_es/Badge.js +47 -36
- package/dist/packages/_es/Barrage.js +147 -68
- package/dist/packages/_es/Button.js +66 -47
- package/dist/packages/_es/Calendar.js +157 -135
- package/dist/packages/_es/CalendarItem.js +6 -6
- package/dist/packages/_es/Card.js +56 -42
- package/dist/packages/_es/Cascader.js +474 -315
- package/dist/packages/_es/Category.js +39 -29
- package/dist/packages/_es/CategoryPane.js +83 -57
- package/dist/packages/_es/Cell.js +71 -56
- package/dist/packages/_es/CellGroup.js +27 -19
- package/dist/packages/_es/Checkbox.js +156 -109
- package/dist/packages/_es/CheckboxGroup.js +59 -38
- package/dist/packages/_es/CircleProgress.js +96 -67
- package/dist/packages/_es/Col.js +31 -23
- package/dist/packages/_es/Collapse.js +58 -33
- package/dist/packages/_es/CollapseItem.js +108 -78
- package/dist/packages/_es/Comment.js +279 -207
- package/dist/packages/_es/ConfigProvider.js +55 -37
- package/dist/packages/_es/Countdown.js +212 -100
- package/dist/packages/_es/Countup.js +445 -232
- package/dist/packages/_es/DatePicker.js +265 -162
- package/dist/packages/_es/Dialog.js +213 -161
- package/dist/packages/_es/Divider.js +57 -42
- package/dist/packages/_es/Drag.js +153 -70
- package/dist/packages/_es/Ecard.js +104 -64
- package/dist/packages/_es/Elevator.js +219 -143
- package/dist/packages/_es/Ellipsis.js +178 -95
- package/dist/packages/_es/Empty.js +39 -23
- package/dist/packages/_es/FixedNav.js +116 -93
- package/dist/packages/_es/Form.js +178 -107
- package/dist/packages/_es/FormItem.js +61 -48
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +84 -58
- package/dist/packages/_es/Image.js +130 -90
- package/dist/packages/_es/ImagePreview.js +412 -256
- package/dist/packages/_es/Indicator.js +34 -30
- package/dist/packages/_es/InfiniteLoading.js +136 -83
- package/dist/packages/_es/Input.js +264 -160
- package/dist/packages/_es/InputNumber.js +117 -81
- package/dist/packages/_es/Interceptor-956b24fc.js +29 -0
- package/dist/packages/_es/Invoice.js +130 -104
- package/dist/packages/_es/Layout.js +4 -3
- package/dist/packages/_es/List.js +215 -117
- package/dist/packages/_es/Menu.js +150 -95
- package/dist/packages/_es/MenuItem.js +154 -109
- package/dist/packages/_es/Navbar.js +119 -103
- package/dist/packages/_es/Noticebar.js +312 -197
- package/dist/packages/_es/Notify.js +166 -110
- package/dist/packages/_es/NumberKeyboard.js +202 -127
- package/dist/packages/_es/Overlay.js +80 -52
- package/dist/packages/_es/Pagination.js +100 -70
- package/dist/packages/_es/Picker.js +437 -275
- package/dist/packages/_es/Popover.js +225 -122
- package/dist/packages/_es/Popup.js +4 -4
- package/dist/packages/_es/Price.js +82 -44
- package/dist/packages/_es/Progress.js +79 -63
- package/dist/packages/_es/PullRefresh.js +173 -95
- package/dist/packages/_es/Radio.js +4 -4
- package/dist/packages/_es/RadioGroup.js +3 -3
- package/dist/packages/_es/Range.js +347 -204
- package/dist/packages/_es/Rate.js +141 -92
- package/dist/packages/_es/Row.js +27 -21
- package/dist/packages/_es/Searchbar.js +174 -123
- package/dist/packages/_es/ShortPassword.js +93 -69
- package/dist/packages/_es/SideNavbar.js +80 -49
- package/dist/packages/_es/SideNavbarItem.js +32 -22
- package/dist/packages/_es/Signature.js +146 -83
- package/dist/packages/_es/Skeleton.js +130 -110
- package/dist/packages/_es/Sku.js +343 -250
- package/dist/packages/_es/Step.js +86 -59
- package/dist/packages/_es/Steps.js +31 -26
- package/dist/packages/_es/Sticky.js +4 -4
- package/dist/packages/_es/SubSideNavbar.js +74 -52
- package/dist/packages/_es/Swipe.js +155 -83
- package/dist/packages/_es/Swiper.js +311 -174
- package/dist/packages/_es/SwiperItem.js +44 -28
- package/dist/packages/_es/Switch.js +68 -55
- package/dist/packages/_es/TabPane.js +41 -30
- package/dist/packages/_es/Tabbar.js +52 -41
- package/dist/packages/_es/TabbarItem.js +82 -61
- package/dist/packages/_es/Table.js +165 -109
- package/dist/packages/_es/Tabs.js +388 -240
- package/dist/packages/_es/Tag.js +61 -44
- package/dist/packages/_es/Textarea.js +124 -80
- package/dist/packages/_es/TimeDetail.js +76 -49
- package/dist/packages/_es/TimePannel.js +48 -34
- package/dist/packages/_es/TimeSelect.js +68 -47
- package/dist/packages/_es/Toast.js +218 -144
- package/dist/packages/_es/Tour.js +192 -138
- package/dist/packages/_es/TrendArrow.js +77 -57
- package/dist/packages/_es/Uploader.js +359 -234
- package/dist/packages/_es/Video.js +316 -191
- package/dist/packages/_es/Watermark.js +117 -84
- package/dist/packages/_es/_plugin-vue_export-helper-cc2b3d55.js +10 -0
- package/dist/packages/_es/common-b9a5e726.js +145 -0
- package/dist/packages/_es/component-81a4c1d0.js +145 -0
- package/dist/packages/_es/index-29892cda.js +33 -0
- package/dist/packages/_es/index-43c34ac6.js +30 -0
- package/dist/packages/_es/index-54d03fc1.js +8 -0
- package/dist/packages/_es/index-79c5dc33.js +10 -0
- package/dist/packages/_es/index-7a7385e4.js +67 -0
- package/dist/packages/_es/index-87422be8.js +942 -0
- package/dist/packages/_es/index-da0a7662.js +259 -0
- package/dist/packages/_es/index.vue_vue_type_script_lang-22dfc112.js +46 -0
- package/dist/packages/_es/index.vue_vue_type_script_lang-a8856969.js +97 -0
- package/dist/packages/_es/index.vue_vue_type_script_lang-cc5c4086.js +151 -0
- package/dist/packages/_es/mountComponent-8b24c346.js +39 -0
- package/dist/packages/_es/pxCheck-c6b9f6b7.js +6 -0
- package/dist/packages/_es/raf-729dad54.js +25 -0
- package/dist/packages/_es/renderIcon-3d0fd47c.js +9 -0
- package/dist/packages/locale/lang/baseLang-3a8457ac.js +5 -0
- package/dist/packages/locale/lang/en-US.js +39 -36
- package/dist/packages/locale/lang/id-ID.js +39 -36
- package/dist/packages/locale/lang/index.js +44 -22
- package/dist/packages/locale/lang/zh-CN.js +38 -35
- package/dist/packages/locale/lang/zh-TW.js +38 -35
- package/dist/resolver/index.js +26 -1
- package/dist/resolver/index.mjs +17 -14
- package/dist/smartips/web-types.json +1 -1
- package/dist/style.css +1 -1
- package/dist/styles/themes/default.scss +50 -50
- package/dist/styles/themes/jdb.scss +50 -50
- package/dist/styles/themes/jddkh.scss +50 -50
- package/dist/styles/themes/jdt.scss +50 -50
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/packages/_es/Interceptor-6e26b757.js +0 -18
- package/dist/packages/_es/_plugin-vue_export-helper-dad06003.js +0 -9
- package/dist/packages/_es/common-d218746f.js +0 -116
- package/dist/packages/_es/component-234624bc.js +0 -89
- package/dist/packages/_es/index-14dfadc4.js +0 -561
- package/dist/packages/_es/index-192a3ef6.js +0 -29
- package/dist/packages/_es/index-360c5092.js +0 -210
- package/dist/packages/_es/index-496e6e05.js +0 -24
- package/dist/packages/_es/index-50eed3d9.js +0 -7
- package/dist/packages/_es/index-53ec2d4d.js +0 -34
- package/dist/packages/_es/index-fadb0974.js +0 -8
- package/dist/packages/_es/index.vue_vue_type_script_lang-1139b29a.js +0 -43
- package/dist/packages/_es/index.vue_vue_type_script_lang-43b774dd.js +0 -77
- package/dist/packages/_es/index.vue_vue_type_script_lang-f44c159d.js +0 -110
- package/dist/packages/_es/mountComponent-6d4ff200.js +0 -23
- package/dist/packages/_es/pxCheck-38173291.js +0 -4
- package/dist/packages/_es/raf-a74f1a06.js +0 -16
- package/dist/packages/_es/renderIcon-47498b32.js +0 -5
- package/dist/packages/locale/lang/baseLang-0bdc6353.js +0 -5
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { reactive
|
|
2
|
-
import { c as
|
|
3
|
-
import { r as
|
|
4
|
-
import { Top
|
|
5
|
-
import { _ as
|
|
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
|
|
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:
|
|
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(
|
|
43
|
-
const
|
|
44
|
-
backTop:
|
|
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:
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
61
|
-
|
|
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
|
|
64
|
-
let
|
|
65
|
-
var
|
|
66
|
-
|
|
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
|
|
70
|
-
|
|
91
|
+
function addEventListener() {
|
|
92
|
+
state.scrollEl.addEventListener("scroll", scrollListener, false);
|
|
93
|
+
state.scrollEl.addEventListener("resize", scrollListener, false);
|
|
71
94
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
95
|
+
function removeEventListener() {
|
|
96
|
+
state.scrollEl.removeEventListener("scroll", scrollListener, false);
|
|
97
|
+
state.scrollEl.removeEventListener("resize", scrollListener, false);
|
|
74
98
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
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
|
|
79
|
-
|
|
104
|
+
function init() {
|
|
105
|
+
if (props.elId && document.getElementById(props.elId)) {
|
|
106
|
+
state.scrollEl = document.getElementById(props.elId);
|
|
107
|
+
}
|
|
108
|
+
addEventListener();
|
|
80
109
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
|
98
|
-
const
|
|
99
|
-
return
|
|
100
|
-
class:
|
|
101
|
-
style:
|
|
102
|
-
onClick:
|
|
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
|
-
|
|
105
|
-
|
|
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
|
|
153
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
114
154
|
export {
|
|
115
|
-
|
|
155
|
+
index as default
|
|
116
156
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { reactive
|
|
2
|
-
import { c as
|
|
3
|
-
import { _ as
|
|
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
|
|
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:
|
|
17
|
+
default: false
|
|
17
18
|
},
|
|
18
19
|
bubble: {
|
|
19
20
|
type: Boolean,
|
|
20
|
-
default:
|
|
21
|
+
default: false
|
|
21
22
|
},
|
|
22
23
|
hidden: {
|
|
23
24
|
type: Boolean,
|
|
24
|
-
default:
|
|
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(
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
53
|
-
|
|
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
|
|
57
|
-
stl
|
|
58
|
-
content
|
|
65
|
+
state,
|
|
66
|
+
stl,
|
|
67
|
+
content
|
|
59
68
|
};
|
|
60
69
|
}
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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:
|
|
77
|
+
style: normalizeStyle(_ctx.stl)
|
|
67
78
|
}, [
|
|
68
|
-
|
|
79
|
+
renderSlot(_ctx.$slots, "icon")
|
|
69
80
|
], 4), [
|
|
70
|
-
[
|
|
81
|
+
[vShow, !_ctx.hidden && !_ctx.dot && _ctx.$slots.icon]
|
|
71
82
|
]),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
textContent:
|
|
75
|
-
class:
|
|
76
|
-
style:
|
|
77
|
-
}, null, 14,
|
|
78
|
-
[
|
|
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
|
|
93
|
+
const Badge = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
83
94
|
export {
|
|
84
|
-
|
|
95
|
+
Badge as default
|
|
85
96
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { useSlots
|
|
2
|
-
import { c as
|
|
3
|
-
import { _ as
|
|
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
|
|
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:
|
|
31
|
+
default: true
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
|
-
setup(
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
(
|
|
65
|
-
|
|
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
|
|
69
|
-
const
|
|
70
|
-
!
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}), L());
|
|
166
|
+
el.removeEventListener("animationend", () => {
|
|
167
|
+
});
|
|
168
|
+
run();
|
|
90
169
|
});
|
|
91
170
|
};
|
|
92
|
-
return { classTime
|
|
171
|
+
return { classTime, classes, danmuList, dmBody, dmContainer, add };
|
|
93
172
|
}
|
|
94
173
|
});
|
|
95
|
-
function
|
|
96
|
-
return
|
|
174
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
175
|
+
return openBlock(), createElementBlock("div", {
|
|
97
176
|
ref: "dmBody",
|
|
98
|
-
class:
|
|
177
|
+
class: normalizeClass(_ctx.classes)
|
|
99
178
|
}, [
|
|
100
|
-
|
|
179
|
+
createElementVNode("div", {
|
|
101
180
|
ref: "dmContainer",
|
|
102
|
-
class:
|
|
181
|
+
class: normalizeClass(["dmContainer", _ctx.$slots.default && "slotContainer"])
|
|
103
182
|
}, [
|
|
104
|
-
|
|
183
|
+
_ctx.$slots.default ? (openBlock(), createElementBlock("div", {
|
|
105
184
|
key: 0,
|
|
106
|
-
class:
|
|
185
|
+
class: normalizeClass(["slotBody", "slotBody" + _ctx.classTime])
|
|
107
186
|
}, [
|
|
108
|
-
|
|
109
|
-
], 2)) :
|
|
187
|
+
renderSlot(_ctx.$slots, "default")
|
|
188
|
+
], 2)) : createCommentVNode("", true)
|
|
110
189
|
], 2)
|
|
111
190
|
], 2);
|
|
112
191
|
}
|
|
113
|
-
const
|
|
192
|
+
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
114
193
|
export {
|
|
115
|
-
|
|
194
|
+
index as default
|
|
116
195
|
};
|