@nutui/nutui 3.1.22 → 3.1.23-beta.0
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 +20418 -4214
- package/dist/nutui.umd.js +20524 -4216
- package/dist/packages/_es/ActionSheet.js +149 -17
- package/dist/packages/_es/Address.js +535 -110
- package/dist/packages/_es/AddressList.js +615 -113
- package/dist/packages/_es/Animate.js +59 -17
- package/dist/packages/_es/Audio.js +257 -53
- package/dist/packages/_es/AudioOperate.js +100 -13
- package/dist/packages/_es/Avatar.js +162 -38
- package/dist/packages/_es/AvatarGroup.js +73 -14
- package/dist/packages/_es/BackTop.js +156 -43
- package/dist/packages/_es/Badge.js +86 -14
- package/dist/packages/_es/Barrage.js +120 -41
- package/dist/packages/_es/Button.js +128 -23
- package/dist/packages/_es/Calendar.js +246 -30
- package/dist/packages/_es/CalendarItem.js +1 -1
- package/dist/packages/_es/Card.js +107 -10
- package/dist/packages/_es/Cascader.js +496 -147
- package/dist/packages/_es/Category.js +58 -15
- package/dist/packages/_es/CategoryPane.js +111 -11
- package/dist/packages/_es/Cell.js +108 -21
- package/dist/packages/_es/CellGroup.js +44 -9
- package/dist/packages/_es/Checkbox.js +134 -29
- package/dist/packages/_es/CheckboxGroup.js +79 -29
- package/dist/packages/_es/CircleProgress.js +150 -28
- package/dist/packages/_es/Col.js +56 -14
- package/dist/packages/_es/Collapse.js +109 -32
- package/dist/packages/_es/CollapseItem.js +253 -59
- package/dist/packages/_es/Comment.js +434 -64
- package/dist/packages/_es/ConfigProvider.js +20 -8
- package/dist/packages/_es/CountDown.js +238 -56
- package/dist/packages/_es/CountUp.js +539 -140
- package/dist/packages/_es/DatePicker.js +315 -98
- package/dist/packages/_es/Dialog.js +289 -60
- package/dist/packages/_es/Divider.js +65 -13
- package/dist/packages/_es/Drag.js +197 -56
- package/dist/packages/_es/Ecard.js +159 -24
- package/dist/packages/_es/Elevator.js +255 -58
- package/dist/packages/_es/Ellipsis.js +200 -58
- package/dist/packages/_es/Empty.js +71 -12
- package/dist/packages/_es/FixedNav.js +122 -15
- package/dist/packages/_es/Form.js +151 -64
- package/dist/packages/_es/FormItem.js +114 -15
- package/dist/packages/_es/Grid.js +6 -5
- package/dist/packages/_es/GridItem.js +144 -33
- package/dist/packages/_es/Icon.js +40 -15
- package/dist/packages/_es/Image.js +137 -26
- package/dist/packages/_es/ImagePreview.js +547 -76
- package/dist/packages/_es/Indicator.js +62 -15
- package/dist/packages/_es/InfiniteLoading.js +249 -57
- package/dist/packages/_es/Input.js +433 -51
- package/dist/packages/_es/InputNumber.js +160 -41
- package/dist/packages/_es/Layout.js +5 -4
- package/dist/packages/_es/List.js +106 -18
- package/dist/packages/_es/Menu.js +168 -44
- package/dist/packages/_es/MenuItem.js +173 -37
- package/dist/packages/_es/Navbar.js +192 -30
- package/dist/packages/_es/NoticeBar.js +380 -74
- package/dist/packages/_es/Notify.js +227 -72
- package/dist/packages/_es/NumberKeyboard.js +272 -41
- package/dist/packages/_es/OldPicker.js +457 -130
- package/dist/packages/_es/OverLay.js +98 -24
- package/dist/packages/_es/Pagination.js +157 -39
- package/dist/packages/_es/Picker.js +460 -129
- package/dist/packages/_es/Popover.js +957 -318
- package/dist/packages/_es/Popup.js +299 -55
- package/dist/packages/_es/Price.js +118 -16
- package/dist/packages/_es/Progress.js +146 -14
- package/dist/packages/_es/PullRefresh.js +339 -84
- package/dist/packages/_es/Radio.js +90 -22
- package/dist/packages/_es/RadioGroup.js +37 -8
- package/dist/packages/_es/Range.js +408 -83
- package/dist/packages/_es/Rate.js +192 -36
- package/dist/packages/_es/Row.js +64 -22
- package/dist/packages/_es/SearchBar.js +238 -37
- package/dist/packages/_es/ShortPassword.js +225 -35
- package/dist/packages/_es/SideNavBar.js +81 -24
- package/dist/packages/_es/SideNavBarItem.js +46 -11
- package/dist/packages/_es/Signature.js +160 -41
- package/dist/packages/_es/Skeleton.js +136 -20
- package/dist/packages/_es/Sku.js +491 -84
- package/dist/packages/_es/Step.js +115 -20
- package/dist/packages/_es/Steps.js +53 -18
- package/dist/packages/_es/Sticky.js +138 -53
- package/dist/packages/_es/SubSideNavBar.js +82 -17
- package/dist/packages/_es/Swipe.js +178 -41
- package/dist/packages/_es/Swiper.js +433 -121
- package/dist/packages/_es/SwiperItem.js +53 -22
- package/dist/packages/_es/Switch.js +116 -21
- package/dist/packages/_es/TabPane.js +39 -12
- package/dist/packages/_es/Tabbar.js +72 -17
- package/dist/packages/_es/TabbarItem.js +151 -29
- package/dist/packages/_es/Table.js +178 -18
- package/dist/packages/_es/Tabs.js +202 -43
- package/dist/packages/_es/Tag.js +97 -20
- package/dist/packages/_es/TextArea.js +160 -42
- package/dist/packages/_es/TimeDetail.js +79 -18
- package/dist/packages/_es/TimePannel.js +48 -14
- package/dist/packages/_es/TimeSelect.js +112 -15
- package/dist/packages/_es/Toast.js +310 -71
- package/dist/packages/_es/Uploader.js +455 -104
- package/dist/packages/_es/Video.js +332 -74
- package/dist/packages/_es/common.js +128 -38
- package/dist/packages/_es/component.js +76 -35
- package/dist/packages/_es/index.js +6 -5
- package/dist/packages/_es/index2.js +30 -9
- package/dist/packages/_es/index3.js +8 -6
- package/dist/packages/_es/index4.js +64 -13
- package/dist/packages/_es/index5.js +780 -164
- package/dist/packages/_es/plugin-vue_export-helper.js +8 -7
- package/dist/packages/_es/pxCheck.js +5 -3
- package/dist/packages/_es/raf.js +15 -8
- package/dist/packages/imagepreview/index.scss +6 -1
- package/dist/packages/locale/lang/baseLang.js +3 -3
- package/dist/packages/locale/lang/en-US.js +105 -5
- package/dist/packages/locale/lang/id-ID.js +105 -5
- package/dist/packages/locale/lang/index.js +38 -16
- package/dist/packages/locale/lang/zh-CN.js +105 -5
- package/dist/packages/locale/lang/zh-TW.js +105 -5
- package/dist/smartips/attributes.json +8 -0
- package/dist/smartips/tags.json +3 -1
- package/dist/smartips/web-types.json +19 -1
- package/dist/style.css +1 -1
- package/dist/style.es.js +1 -1
- package/dist/styles/themes/default.scss +41 -41
- package/dist/styles/themes/jdb.scss +41 -41
- package/dist/styles/themes/jdt.scss +41 -41
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +5 -5
- package/dist/types/__VUE/address/index.vue.d.ts +7 -7
- package/dist/types/__VUE/avatar/index.vue.d.ts +4 -4
- package/dist/types/__VUE/avatargroup/index.vue.d.ts +2 -2
- package/dist/types/__VUE/backtop/index.vue.d.ts +2 -2
- package/dist/types/__VUE/badge/index.vue.d.ts +2 -2
- package/dist/types/__VUE/button/index.vue.d.ts +8 -8
- package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/cascader/index.vue.d.ts +4 -4
- package/dist/types/__VUE/cell/index.vue.d.ts +6 -6
- package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
- package/dist/types/__VUE/collapseitem/index.vue.d.ts +2 -2
- package/dist/types/__VUE/comment/index.vue.d.ts +2 -2
- package/dist/types/__VUE/datepicker/index.vue.d.ts +4 -4
- package/dist/types/__VUE/dialog/index.vue.d.ts +4 -4
- package/dist/types/__VUE/fixednav/index.vue.d.ts +4 -4
- package/dist/types/__VUE/grid/index.vue.d.ts +4 -4
- package/dist/types/__VUE/image/index.vue.d.ts +4 -4
- package/dist/types/__VUE/imagepreview/imagePreviewItem.vue.d.ts +95 -0
- package/dist/types/__VUE/imagepreview/index.vue.d.ts +23 -25
- package/dist/types/__VUE/input/index.vue.d.ts +4 -4
- package/dist/types/__VUE/inputnumber/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menu/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
- package/dist/types/__VUE/noticebar/index.vue.d.ts +3 -3
- package/dist/types/__VUE/notify/index.vue.d.ts +2 -2
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/oldpicker/index.vue.d.ts +5 -5
- package/dist/types/__VUE/picker/Column.vue.d.ts +1 -1
- package/dist/types/__VUE/picker/index.vue.d.ts +6 -6
- package/dist/types/__VUE/popover/index.vue.d.ts +8 -8
- package/dist/types/__VUE/popup/index.vue.d.ts +6 -6
- package/dist/types/__VUE/radio/index.vue.d.ts +4 -4
- package/dist/types/__VUE/range/index.vue.d.ts +4 -4
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
- package/dist/types/__VUE/skeleton/index.vue.d.ts +4 -4
- package/dist/types/__VUE/sku/index.vue.d.ts +5 -5
- package/dist/types/__VUE/step/index.vue.d.ts +2 -2
- package/dist/types/__VUE/sticky/index.vue.d.ts +4 -4
- package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
- package/dist/types/__VUE/swiper/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbaritem/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tag/index.vue.d.ts +2 -2
- package/dist/types/__VUE/timeselect/index.vue.d.ts +2 -2
- package/dist/types/__VUE/toast/index.vue.d.ts +4 -4
- package/dist/types/__VUE/uploader/index.vue.d.ts +4 -4
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -2
|
@@ -1,19 +1,151 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { useSlots
|
|
7
|
-
import { c as
|
|
8
|
-
import { _ as
|
|
6
|
+
import { useSlots, ref, computed, onMounted, resolveComponent, openBlock, createElementBlock, createElementVNode, normalizeClass, normalizeStyle, toDisplayString, createCommentVNode, renderSlot, createBlock } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
9
9
|
import "../locale/lang";
|
|
10
|
-
const { create
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
const { create } = createComponent("progress");
|
|
11
|
+
const _sfc_main = create({
|
|
12
|
+
props: {
|
|
13
|
+
percentage: {
|
|
14
|
+
type: [Number, String],
|
|
15
|
+
default: 0,
|
|
16
|
+
required: true
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: "base"
|
|
21
|
+
},
|
|
22
|
+
status: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: ""
|
|
25
|
+
},
|
|
26
|
+
strokeWidth: {
|
|
27
|
+
type: [Number, String],
|
|
28
|
+
default: ""
|
|
29
|
+
},
|
|
30
|
+
textInside: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
showText: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: true
|
|
37
|
+
},
|
|
38
|
+
strokeColor: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: ""
|
|
41
|
+
},
|
|
42
|
+
textColor: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: ""
|
|
45
|
+
},
|
|
46
|
+
textBackground: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: ""
|
|
49
|
+
},
|
|
50
|
+
iconName: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: "checked"
|
|
53
|
+
},
|
|
54
|
+
iconColor: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: "#439422"
|
|
57
|
+
},
|
|
58
|
+
isShowPercentage: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
default: true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
setup(props, { emit }) {
|
|
64
|
+
const slotDefault = !!useSlots().default;
|
|
65
|
+
const height = ref(props.strokeWidth + "px");
|
|
66
|
+
const progressOuter = ref();
|
|
67
|
+
const insideText = ref();
|
|
68
|
+
const bgStyle = computed(() => {
|
|
69
|
+
return {
|
|
70
|
+
width: props.percentage + "%",
|
|
71
|
+
background: props.strokeColor || ""
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
const textStyle = computed(() => {
|
|
75
|
+
return {
|
|
76
|
+
color: props.textColor || ""
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
onMounted(() => {
|
|
80
|
+
});
|
|
81
|
+
return {
|
|
82
|
+
height,
|
|
83
|
+
bgStyle,
|
|
84
|
+
textStyle,
|
|
85
|
+
progressOuter,
|
|
86
|
+
insideText,
|
|
87
|
+
slotDefault
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const _hoisted_1 = { class: "nut-progress" };
|
|
92
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
93
|
+
const _component_nut_icon = resolveComponent("nut-icon");
|
|
94
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
95
|
+
createElementVNode("div", {
|
|
96
|
+
class: normalizeClass(["nut-progress-outer", [_ctx.showText && !_ctx.textInside ? "nut-progress-outer-part" : "", _ctx.size ? "nut-progress-" + _ctx.size : ""]]),
|
|
97
|
+
ref: "progressOuter",
|
|
98
|
+
style: normalizeStyle({ height: _ctx.height })
|
|
99
|
+
}, [
|
|
100
|
+
createElementVNode("div", {
|
|
101
|
+
class: normalizeClass(["nut-progress-inner", _ctx.status == "active" ? "nut-active" : ""]),
|
|
102
|
+
style: normalizeStyle(_ctx.bgStyle)
|
|
103
|
+
}, [
|
|
104
|
+
_ctx.showText && _ctx.textInside && !_ctx.slotDefault ? (openBlock(), createElementBlock("div", {
|
|
105
|
+
key: 0,
|
|
106
|
+
class: "nut-progress-text nut-progress-insidetext",
|
|
107
|
+
ref: "insideText",
|
|
108
|
+
style: normalizeStyle({
|
|
109
|
+
lineHeight: _ctx.height,
|
|
110
|
+
left: `${_ctx.percentage}%`,
|
|
111
|
+
transform: `translate(-${+_ctx.percentage}%,-50%)`,
|
|
112
|
+
background: _ctx.textBackground || _ctx.strokeColor
|
|
113
|
+
})
|
|
114
|
+
}, [
|
|
115
|
+
createElementVNode("span", {
|
|
116
|
+
style: normalizeStyle(_ctx.textStyle)
|
|
117
|
+
}, toDisplayString(_ctx.percentage) + toDisplayString(_ctx.isShowPercentage ? "%" : ""), 5)
|
|
118
|
+
], 4)) : createCommentVNode("", true),
|
|
119
|
+
_ctx.showText && _ctx.textInside && _ctx.slotDefault ? (openBlock(), createElementBlock("div", {
|
|
120
|
+
key: 1,
|
|
121
|
+
ref: "insideText",
|
|
122
|
+
style: normalizeStyle({
|
|
123
|
+
position: `absolute`,
|
|
124
|
+
top: `50%`,
|
|
125
|
+
left: `${_ctx.percentage}%`,
|
|
126
|
+
transform: `translate(-${+_ctx.percentage}%,-50%)`
|
|
127
|
+
})
|
|
128
|
+
}, [
|
|
129
|
+
renderSlot(_ctx.$slots, "default")
|
|
130
|
+
], 4)) : createCommentVNode("", true)
|
|
131
|
+
], 6)
|
|
132
|
+
], 6),
|
|
133
|
+
_ctx.showText && !_ctx.textInside ? (openBlock(), createElementBlock("div", {
|
|
134
|
+
key: 0,
|
|
135
|
+
class: "nut-progress-text",
|
|
136
|
+
style: normalizeStyle({ lineHeight: _ctx.height })
|
|
137
|
+
}, [
|
|
138
|
+
_ctx.status == "active" || _ctx.status == "" ? (openBlock(), createElementBlock("span", {
|
|
139
|
+
key: 0,
|
|
140
|
+
style: normalizeStyle(_ctx.textStyle)
|
|
141
|
+
}, toDisplayString(_ctx.percentage) + toDisplayString(_ctx.isShowPercentage ? "%" : ""), 5)) : _ctx.status == "icon" ? (openBlock(), createBlock(_component_nut_icon, {
|
|
142
|
+
key: 1,
|
|
143
|
+
size: "16px",
|
|
144
|
+
name: _ctx.iconName,
|
|
145
|
+
color: _ctx.iconColor
|
|
146
|
+
}, null, 8, ["name", "color"])) : createCommentVNode("", true)
|
|
147
|
+
], 4)) : createCommentVNode("", true)
|
|
148
|
+
]);
|
|
149
|
+
}
|
|
150
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
151
|
+
export { index as default };
|
|
@@ -1,94 +1,349 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.0 Mon Jun 27 2022 17:55:50 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import { ref
|
|
7
|
-
import { c as
|
|
8
|
-
import { _ as
|
|
6
|
+
import { ref, toRefs, reactive, computed, onMounted, openBlock, createElementBlock, normalizeStyle, createElementVNode, normalizeClass, toDisplayString, renderSlot } from "vue";
|
|
7
|
+
import { c as createComponent } from "./component.js";
|
|
8
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
9
9
|
import "../locale/lang";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const MIN_DISTANCE = 10;
|
|
11
|
+
function getDirection(x, y) {
|
|
12
|
+
if (x > y && x > MIN_DISTANCE) {
|
|
13
|
+
return "horizontal";
|
|
14
|
+
}
|
|
15
|
+
if (y > x && y > MIN_DISTANCE) {
|
|
16
|
+
return "vertical";
|
|
17
|
+
}
|
|
18
|
+
return "";
|
|
12
19
|
}
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
20
|
+
function useTouch() {
|
|
21
|
+
const startX = ref(0);
|
|
22
|
+
const startY = ref(0);
|
|
23
|
+
const deltaX = ref(0);
|
|
24
|
+
const deltaY = ref(0);
|
|
25
|
+
const offsetX = ref(0);
|
|
26
|
+
const offsetY = ref(0);
|
|
27
|
+
const direction = ref("");
|
|
28
|
+
const isVertical = () => direction.value === "vertical";
|
|
29
|
+
const isHorizontal = () => direction.value === "horizontal";
|
|
30
|
+
const reset = () => {
|
|
31
|
+
deltaX.value = 0;
|
|
32
|
+
deltaY.value = 0;
|
|
33
|
+
offsetX.value = 0;
|
|
34
|
+
offsetY.value = 0;
|
|
35
|
+
direction.value = "";
|
|
36
|
+
};
|
|
37
|
+
const start = (event) => {
|
|
38
|
+
reset();
|
|
39
|
+
startX.value = event.touches[0].clientX;
|
|
40
|
+
startY.value = event.touches[0].clientY;
|
|
41
|
+
};
|
|
42
|
+
const move = (event) => {
|
|
43
|
+
const touch = event.touches[0];
|
|
44
|
+
deltaX.value = touch.clientX - startX.value;
|
|
45
|
+
deltaY.value = touch.clientY - startY.value;
|
|
46
|
+
offsetX.value = Math.abs(deltaX.value);
|
|
47
|
+
offsetY.value = Math.abs(deltaY.value);
|
|
48
|
+
if (!direction.value) {
|
|
49
|
+
direction.value = getDirection(offsetX.value, offsetY.value);
|
|
38
50
|
}
|
|
39
|
-
return e2;
|
|
40
|
-
}), z = a(() => {
|
|
41
|
-
const { status: e2, distance: t2 } = m2, l2 = i2.value == "vertical" ? "top" : "left";
|
|
42
|
-
return e2 == "loading" && (c2.value || h2.value) && t2 > 0 ? u2.loadingText[l2] : e2 == "pulling" && (c2.value || h2.value) && t2 > 0 ? u2.pullingText[l2] : e2 == "loosing" && (c2.value || h2.value) && t2 > 0 ? u2.loosingText[l2] : "";
|
|
43
|
-
}), M = a(() => {
|
|
44
|
-
const { status: e2, distance: t2 } = m2, l2 = i2.value == "vertical" ? "bottom" : "right";
|
|
45
|
-
return e2 == "loading" && (d2.value || p2.value) && t2 < 0 ? u2.loadingText[l2] : e2 == "pulling" && (d2.value || p2.value) && t2 < 0 ? u2.pullingText[l2] : e2 == "loosing" && (d2.value || p2.value) && t2 < 0 ? u2.loosingText[l2] : "";
|
|
46
|
-
}), w = () => m2.status !== "loading" && !v2.value, S = (e2, t2) => {
|
|
47
|
-
m2.distance = e2, t2 ? m2.status = "loading" : e2 === 0 ? m2.status = "normal" : Math.abs(e2) < 50 ? m2.status = "pulling" : m2.status = "loosing";
|
|
48
51
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
return {
|
|
53
|
+
move,
|
|
54
|
+
start,
|
|
55
|
+
reset,
|
|
56
|
+
startX,
|
|
57
|
+
startY,
|
|
58
|
+
deltaX,
|
|
59
|
+
deltaY,
|
|
60
|
+
offsetX,
|
|
61
|
+
offsetY,
|
|
62
|
+
direction,
|
|
63
|
+
isVertical,
|
|
64
|
+
isHorizontal
|
|
60
65
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
66
|
+
}
|
|
67
|
+
function preventDefault(event, isStopPropagation) {
|
|
68
|
+
if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
}
|
|
71
|
+
if (isStopPropagation)
|
|
72
|
+
event.stopPropagation();
|
|
73
|
+
}
|
|
74
|
+
const { componentName, create } = createComponent("pullrefresh");
|
|
75
|
+
const _sfc_main = create({
|
|
76
|
+
props: {
|
|
77
|
+
useWindow: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: true
|
|
80
|
+
},
|
|
81
|
+
containerId: {
|
|
82
|
+
type: String,
|
|
83
|
+
default: ""
|
|
84
|
+
},
|
|
85
|
+
disabled: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: false
|
|
88
|
+
},
|
|
89
|
+
direction: {
|
|
90
|
+
type: String,
|
|
91
|
+
default: "vertical"
|
|
92
|
+
},
|
|
93
|
+
pullingText: {
|
|
94
|
+
type: Object,
|
|
95
|
+
default: {
|
|
96
|
+
top: "\u4E0B\u62C9\u5237\u65B0",
|
|
97
|
+
bottom: "\u4E0A\u62C9\u52A0\u8F7D",
|
|
98
|
+
left: "\u5DE6\u6ED1\u5237\u65B0",
|
|
99
|
+
right: "\u53F3\u6ED1\u52A0\u8F7D"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
loosingText: {
|
|
103
|
+
type: Object,
|
|
104
|
+
default: {
|
|
105
|
+
top: "\u677E\u624B\u91CA\u653E\u5237\u65B0",
|
|
106
|
+
bottom: "\u677E\u624B\u91CA\u653E\u5237\u65B0",
|
|
107
|
+
left: "\u91CA\u653E\u5237\u65B0",
|
|
108
|
+
right: "\u52A0\u8F7D\u66F4\u591A"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
loadingText: {
|
|
112
|
+
type: Object,
|
|
113
|
+
default: {
|
|
114
|
+
top: "\u52A0\u8F7D\u4E2D...",
|
|
115
|
+
bottom: "\u52A0\u8F7D\u4E2D...",
|
|
116
|
+
left: "\u52A0\u8F7D\u4E2D...",
|
|
117
|
+
right: "\u52A0\u8F7D\u4E2D..."
|
|
118
|
+
}
|
|
88
119
|
}
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
120
|
+
},
|
|
121
|
+
emits: ["refresh", "downRefresh"],
|
|
122
|
+
setup(props, { emit }) {
|
|
123
|
+
const { containerId, useWindow, direction, disabled } = toRefs(props);
|
|
124
|
+
const reachTop = ref(false);
|
|
125
|
+
const reachBottom = ref(false);
|
|
126
|
+
const reachLeft = ref(false);
|
|
127
|
+
const reachRight = ref(false);
|
|
128
|
+
const state = reactive({
|
|
129
|
+
status: "normal",
|
|
130
|
+
distance: 0,
|
|
131
|
+
duration: 0
|
|
132
|
+
});
|
|
133
|
+
let scrollEl = document.documentElement || document.body;
|
|
134
|
+
const scroller = ref(null);
|
|
135
|
+
const touch = useTouch();
|
|
136
|
+
const getStyle = computed(() => {
|
|
137
|
+
let style = {};
|
|
138
|
+
const { deltaY, deltaX } = touch;
|
|
139
|
+
if (direction.value == "vertical" && (reachTop.value && deltaY.value > 0 || reachBottom.value && deltaY.value < 0) && touch.isVertical()) {
|
|
140
|
+
style = {
|
|
141
|
+
transitionDuration: `${state.duration}ms`,
|
|
142
|
+
transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : `translate3d(0,0,0)`
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (direction.value == "horizontal" && (reachLeft.value && deltaX.value > 0 || reachRight.value && deltaX.value < 0) && touch.isHorizontal()) {
|
|
146
|
+
style = {
|
|
147
|
+
transitionDuration: `${state.duration}ms`,
|
|
148
|
+
transform: state.distance ? `translate3d(${state.distance}px, 0,0)` : `translate3d(0,0,0)`
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return style;
|
|
152
|
+
});
|
|
153
|
+
const getBottomStyle = computed(() => {
|
|
154
|
+
let style = {};
|
|
155
|
+
if (direction.value == "vertical" && reachBottom.value && touch.deltaY.value < 0 && touch.isVertical()) {
|
|
156
|
+
const dis = Math.abs(state.distance) < 50 ? -state.distance : 50;
|
|
157
|
+
style = {
|
|
158
|
+
height: dis + "px"
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (direction.value == "horizontal" && reachRight.value && touch.deltaX.value < 0 && touch.isVertical()) {
|
|
162
|
+
const dis = Math.abs(state.distance) < 50 ? -state.distance : 50;
|
|
163
|
+
style = {
|
|
164
|
+
width: dis + "px"
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return style;
|
|
168
|
+
});
|
|
169
|
+
const refreshTopTem = computed(() => {
|
|
170
|
+
const { status, distance } = state;
|
|
171
|
+
const tag = direction.value == "vertical" ? "top" : "left";
|
|
172
|
+
if (status == "loading" && (reachTop.value || reachLeft.value) && distance > 0) {
|
|
173
|
+
return props.loadingText[tag];
|
|
174
|
+
}
|
|
175
|
+
if (status == "pulling" && (reachTop.value || reachLeft.value) && distance > 0) {
|
|
176
|
+
return props.pullingText[tag];
|
|
177
|
+
}
|
|
178
|
+
if (status == "loosing" && (reachTop.value || reachLeft.value) && distance > 0) {
|
|
179
|
+
return props.loosingText[tag];
|
|
180
|
+
}
|
|
181
|
+
return "";
|
|
182
|
+
});
|
|
183
|
+
const refreshBottomTem = computed(() => {
|
|
184
|
+
const { status, distance } = state;
|
|
185
|
+
const tag = direction.value == "vertical" ? "bottom" : "right";
|
|
186
|
+
if (status == "loading" && (reachBottom.value || reachRight.value) && distance < 0) {
|
|
187
|
+
return props.loadingText[tag];
|
|
188
|
+
}
|
|
189
|
+
if (status == "pulling" && (reachBottom.value || reachRight.value) && distance < 0) {
|
|
190
|
+
return props.pullingText[tag];
|
|
191
|
+
}
|
|
192
|
+
if (status == "loosing" && (reachBottom.value || reachRight.value) && distance < 0) {
|
|
193
|
+
return props.loosingText[tag];
|
|
194
|
+
}
|
|
195
|
+
return "";
|
|
196
|
+
});
|
|
197
|
+
const isTouchable = () => state.status !== "loading" && !disabled.value;
|
|
198
|
+
const setStatus = (distance, isLoading) => {
|
|
199
|
+
state.distance = distance;
|
|
200
|
+
if (isLoading) {
|
|
201
|
+
state.status = "loading";
|
|
202
|
+
} else if (distance === 0) {
|
|
203
|
+
state.status = "normal";
|
|
204
|
+
} else if (Math.abs(distance) < 50) {
|
|
205
|
+
state.status = "pulling";
|
|
206
|
+
} else {
|
|
207
|
+
state.status = "loosing";
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
const getParentElement = (el) => {
|
|
211
|
+
if (containerId.value != "") {
|
|
212
|
+
return document.querySelector(`#${containerId.value}`);
|
|
213
|
+
}
|
|
214
|
+
return el && el.parentNode;
|
|
215
|
+
};
|
|
216
|
+
onMounted(() => {
|
|
217
|
+
const parentElement = getParentElement(scroller);
|
|
218
|
+
let scrollElCopy = document.documentElement || document.body;
|
|
219
|
+
if (useWindow.value === false) {
|
|
220
|
+
scrollElCopy = parentElement;
|
|
221
|
+
}
|
|
222
|
+
scrollEl = scrollElCopy;
|
|
223
|
+
});
|
|
224
|
+
const ease = (distance) => {
|
|
225
|
+
const headHeight = 50;
|
|
226
|
+
if (distance > headHeight) {
|
|
227
|
+
if (distance < headHeight * 2) {
|
|
228
|
+
distance = headHeight + (distance - headHeight) / 2;
|
|
229
|
+
} else {
|
|
230
|
+
distance = headHeight * 1.5 + (distance - headHeight * 2) / 4;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return Math.round(distance);
|
|
234
|
+
};
|
|
235
|
+
const refreshDone = () => {
|
|
236
|
+
setStatus(0);
|
|
237
|
+
};
|
|
238
|
+
const touchStart = (event) => {
|
|
239
|
+
if (isTouchable()) {
|
|
240
|
+
if (direction.value == "vertical") {
|
|
241
|
+
const top = "scrollTop" in scrollEl ? scrollEl.scrollTop : 0;
|
|
242
|
+
reachTop.value = Math.max(top, 0) == 0 ? true : false;
|
|
243
|
+
const { scrollHeight, clientHeight, scrollTop } = scrollEl;
|
|
244
|
+
reachBottom.value = clientHeight + scrollTop == scrollHeight ? true : false;
|
|
245
|
+
if (reachTop.value || reachBottom.value) {
|
|
246
|
+
state.duration = 0;
|
|
247
|
+
touch.start(event);
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
const { scrollWidth, clientWidth, scrollLeft } = scrollEl;
|
|
251
|
+
const left = "scrollLeft" in scrollEl ? scrollEl.scrollLeft : 0;
|
|
252
|
+
reachLeft.value = Math.max(left, 0) == 0 ? true : false;
|
|
253
|
+
reachRight.value = clientWidth + scrollLeft == scrollWidth ? true : false;
|
|
254
|
+
if (reachLeft.value || reachRight.value) {
|
|
255
|
+
state.duration = 0;
|
|
256
|
+
touch.start(event);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
preventDefault(event);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
const touchMove = (event) => {
|
|
264
|
+
if (isTouchable()) {
|
|
265
|
+
const { deltaY, deltaX } = touch;
|
|
266
|
+
touch.move(event);
|
|
267
|
+
if (direction.value == "vertical" && (reachBottom.value && deltaY.value < 0 || reachTop.value && deltaY.value >= 0) && touch.isVertical()) {
|
|
268
|
+
preventDefault(event);
|
|
269
|
+
setStatus(ease(deltaY.value));
|
|
270
|
+
}
|
|
271
|
+
if (direction.value == "horizontal" && (reachLeft.value && deltaX.value >= 0 || reachRight.value && deltaX.value < 0) && touch.isHorizontal()) {
|
|
272
|
+
preventDefault(event);
|
|
273
|
+
setStatus(ease(deltaX.value));
|
|
274
|
+
}
|
|
275
|
+
} else {
|
|
276
|
+
preventDefault(event);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
const touchEnd = () => {
|
|
280
|
+
if (isTouchable()) {
|
|
281
|
+
const { deltaY, deltaX } = touch;
|
|
282
|
+
if (state.status === "loosing") {
|
|
283
|
+
let dis = 0;
|
|
284
|
+
if (direction.value == "vertical" && reachTop.value && deltaY.value > 0) {
|
|
285
|
+
dis = 50;
|
|
286
|
+
emit("downRefresh", refreshDone);
|
|
287
|
+
}
|
|
288
|
+
if (direction.value == "vertical" && reachBottom.value && deltaY.value < 0) {
|
|
289
|
+
dis = -50;
|
|
290
|
+
emit("refresh", refreshDone);
|
|
291
|
+
}
|
|
292
|
+
if (direction.value == "horizontal" && reachLeft.value && deltaX.value > 0) {
|
|
293
|
+
dis = 50;
|
|
294
|
+
emit("downRefresh", refreshDone);
|
|
295
|
+
}
|
|
296
|
+
if (direction.value == "horizontal" && reachRight.value && deltaX.value < 0) {
|
|
297
|
+
dis = -50;
|
|
298
|
+
emit("refresh", refreshDone);
|
|
299
|
+
}
|
|
300
|
+
setStatus(dis, true);
|
|
301
|
+
} else {
|
|
302
|
+
setStatus(0);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
return {
|
|
307
|
+
scroller,
|
|
308
|
+
touchStart,
|
|
309
|
+
touchMove,
|
|
310
|
+
touchEnd,
|
|
311
|
+
getStyle,
|
|
312
|
+
reachBottom,
|
|
313
|
+
reachTop,
|
|
314
|
+
reachRight,
|
|
315
|
+
reachLeft,
|
|
316
|
+
getBottomStyle,
|
|
317
|
+
refreshTopTem,
|
|
318
|
+
refreshBottomTem,
|
|
319
|
+
...toRefs(state)
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
const _hoisted_1 = {
|
|
324
|
+
class: "pullrefresh-content",
|
|
325
|
+
ref: "pull"
|
|
326
|
+
};
|
|
327
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
328
|
+
return openBlock(), createElementBlock("view", {
|
|
329
|
+
class: "nut-pullrefresh",
|
|
330
|
+
ref: "scroller",
|
|
331
|
+
style: normalizeStyle(_ctx.getStyle),
|
|
332
|
+
onTouchstart: _cache[0] || (_cache[0] = (...args) => _ctx.touchStart && _ctx.touchStart(...args)),
|
|
333
|
+
onTouchmove: _cache[1] || (_cache[1] = (...args) => _ctx.touchMove && _ctx.touchMove(...args)),
|
|
334
|
+
onTouchend: _cache[2] || (_cache[2] = (...args) => _ctx.touchEnd && _ctx.touchEnd(...args))
|
|
335
|
+
}, [
|
|
336
|
+
createElementVNode("view", {
|
|
337
|
+
class: normalizeClass(["pullrefresh-top", _ctx.direction == "horizontal" ? "pullrefresh-top-h" : "pullrefresh-top-v"])
|
|
338
|
+
}, toDisplayString(_ctx.refreshTopTem), 3),
|
|
339
|
+
createElementVNode("view", _hoisted_1, [
|
|
340
|
+
renderSlot(_ctx.$slots, "default")
|
|
341
|
+
], 512),
|
|
342
|
+
createElementVNode("view", {
|
|
343
|
+
class: normalizeClass(["pullrefresh-bottom", _ctx.direction == "horizontal" ? "pullrefresh-bottom-h" : "pullrefresh-bottom-v"]),
|
|
344
|
+
style: normalizeStyle(_ctx.getBottomStyle)
|
|
345
|
+
}, toDisplayString(_ctx.refreshBottomTem), 7)
|
|
346
|
+
], 36);
|
|
347
|
+
}
|
|
348
|
+
var index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
349
|
+
export { index as default };
|