@nutui/nutui 3.1.22-beta.5 → 3.1.23-beta.1
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/CHANGELOG.md +48 -0
- package/README.md +3 -4
- package/dist/nutui.es.js +20412 -4214
- package/dist/nutui.umd.js +20518 -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 +454 -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/packages/picker/index.scss +13 -0
- 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 +49 -49
- package/dist/styles/themes/jdb.scss +49 -49
- package/dist/styles/themes/jdt.scss +49 -49
- package/dist/styles/variables-jdb.scss +4 -1
- package/dist/styles/variables-jdt.scss +4 -1
- package/dist/styles/variables.scss +1 -1
- package/dist/types/__VUE/actionsheet/index.vue.d.ts +3 -3
- package/dist/types/__VUE/address/index.vue.d.ts +4 -4
- package/dist/types/__VUE/calendar/index.vue.d.ts +1 -1
- package/dist/types/__VUE/cascader/index.vue.d.ts +3 -3
- package/dist/types/__VUE/cell/index.vue.d.ts +2 -2
- package/dist/types/__VUE/checkbox/index.vue.d.ts +2 -2
- package/dist/types/__VUE/collapse/index.vue.d.ts +2 -2
- package/dist/types/__VUE/datepicker/index.vue.d.ts +2 -2
- package/dist/types/__VUE/dialog/index.vue.d.ts +2 -2
- package/dist/types/__VUE/ecard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/fixednav/index.vue.d.ts +2 -2
- package/dist/types/__VUE/grid/index.vue.d.ts +3 -3
- 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/infiniteloading/index.vue.d.ts +6 -6
- package/dist/types/__VUE/input/index.vue.d.ts +2 -2
- package/dist/types/__VUE/menu/index.vue.d.ts +4 -4
- package/dist/types/__VUE/menuitem/index.vue.d.ts +1 -1
- package/dist/types/__VUE/numberkeyboard/index.vue.d.ts +2 -2
- package/dist/types/__VUE/oldpicker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/picker/index.vue.d.ts +3 -3
- package/dist/types/__VUE/popover/index.vue.d.ts +6 -6
- package/dist/types/__VUE/popup/index.vue.d.ts +4 -4
- package/dist/types/__VUE/range/index.vue.d.ts +1 -1
- package/dist/types/__VUE/rate/index.vue.d.ts +2 -2
- package/dist/types/__VUE/searchbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/shortpassword/index.vue.d.ts +1 -1
- package/dist/types/__VUE/sku/index.vue.d.ts +3 -3
- package/dist/types/__VUE/swipe/index.vue.d.ts +2 -2
- package/dist/types/__VUE/switch/index.vue.d.ts +2 -2
- package/dist/types/__VUE/tabbar/index.vue.d.ts +2 -2
- package/dist/types/__VUE/textarea/index.vue.d.ts +2 -2
- package/dist/types/__VUE/toast/index.vue.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -2
|
@@ -1,94 +1,565 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @nutui/nutui v3.1.
|
|
2
|
+
* @nutui/nutui v3.1.23-beta.1 Mon Jun 27 2022 21:39:05 GMT+0800 (中国标准时间)
|
|
3
3
|
* (c) 2022 @jdf2e.
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { c as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
6
|
+
import { reactive, computed, watch, toRefs, resolveComponent, openBlock, createBlock, withCtx, createElementBlock, normalizeStyle, createElementVNode, createCommentVNode, createVNode, ref, onMounted, Fragment, renderList, toDisplayString, render, h } from "vue";
|
|
7
|
+
import { c as createComponent, a as isPromise } from "./component.js";
|
|
8
|
+
import Popup from "./Popup.js";
|
|
9
|
+
import Video from "./Video.js";
|
|
10
|
+
import Swiper from "./Swiper.js";
|
|
11
|
+
import SwiperItem from "./SwiperItem.js";
|
|
12
|
+
import _sfc_main$2 from "./Icon.js";
|
|
13
|
+
import { u as useTouch } from "./index4.js";
|
|
14
|
+
import { _ as _export_sfc } from "./plugin-vue_export-helper.js";
|
|
14
15
|
import "../locale/lang";
|
|
15
16
|
import "./OverLay.js";
|
|
16
17
|
import "./pxCheck.js";
|
|
17
18
|
import "./index3.js";
|
|
18
|
-
const { componentName:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
19
|
+
const { componentName: componentName$1, create: create$1 } = createComponent("imagepreviewitem");
|
|
20
|
+
const _sfc_main$1 = create$1({
|
|
21
|
+
props: {
|
|
22
|
+
show: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false
|
|
25
|
+
},
|
|
26
|
+
initNo: Number,
|
|
27
|
+
image: {
|
|
28
|
+
type: Object,
|
|
29
|
+
default: () => {
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
video: {
|
|
33
|
+
type: Array,
|
|
34
|
+
default: () => {
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
showIndex: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: true
|
|
40
|
+
},
|
|
41
|
+
rootWidth: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 0
|
|
44
|
+
},
|
|
45
|
+
rootHeight: {
|
|
46
|
+
type: Number,
|
|
47
|
+
default: 0
|
|
48
|
+
},
|
|
49
|
+
minZoom: {
|
|
50
|
+
type: Number,
|
|
51
|
+
default: 1 / 3
|
|
52
|
+
},
|
|
53
|
+
maxZoom: {
|
|
54
|
+
type: Number,
|
|
55
|
+
default: 3
|
|
43
56
|
}
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
},
|
|
58
|
+
emits: ["close", "scale"],
|
|
59
|
+
components: {
|
|
60
|
+
[Popup.name]: Popup,
|
|
61
|
+
[Video.name]: Video,
|
|
62
|
+
[Swiper.name]: Swiper,
|
|
63
|
+
[SwiperItem.name]: SwiperItem,
|
|
64
|
+
[_sfc_main$2.name]: _sfc_main$2
|
|
65
|
+
},
|
|
66
|
+
setup(props, { emit }) {
|
|
67
|
+
const state = reactive({
|
|
68
|
+
scale: 1,
|
|
69
|
+
moveX: 0,
|
|
70
|
+
moveY: 0,
|
|
71
|
+
moving: false,
|
|
72
|
+
zooming: false,
|
|
73
|
+
imageRatio: 0,
|
|
74
|
+
displayWidth: 0,
|
|
75
|
+
displayHeight: 0
|
|
76
|
+
});
|
|
77
|
+
const touch = useTouch();
|
|
78
|
+
const vertical = computed(() => {
|
|
79
|
+
const { rootWidth, rootHeight } = props;
|
|
80
|
+
const rootRatio = rootHeight / rootWidth;
|
|
81
|
+
return state.imageRatio > rootRatio;
|
|
82
|
+
});
|
|
83
|
+
const imageStyle = computed(() => {
|
|
84
|
+
const { scale, moveX, moveY, moving, zooming } = state;
|
|
85
|
+
const style = {
|
|
86
|
+
transitionDuration: zooming || moving ? "0s" : ".3s"
|
|
87
|
+
};
|
|
88
|
+
if (scale !== 1) {
|
|
89
|
+
const offsetX = moveX / scale;
|
|
90
|
+
const offsetY = moveY / scale;
|
|
91
|
+
style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
|
|
92
|
+
}
|
|
93
|
+
return style;
|
|
94
|
+
});
|
|
95
|
+
const maxMoveX = computed(() => {
|
|
96
|
+
if (state.imageRatio) {
|
|
97
|
+
const { rootWidth, rootHeight } = props;
|
|
98
|
+
const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
|
|
99
|
+
return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
|
|
100
|
+
}
|
|
101
|
+
return 0;
|
|
102
|
+
});
|
|
103
|
+
const maxMoveY = computed(() => {
|
|
104
|
+
if (state.imageRatio) {
|
|
105
|
+
const { rootWidth, rootHeight } = props;
|
|
106
|
+
const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
|
|
107
|
+
return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
|
|
108
|
+
}
|
|
109
|
+
return 0;
|
|
110
|
+
});
|
|
111
|
+
const imageLoad = (event) => {
|
|
112
|
+
const { naturalWidth, naturalHeight } = event.target;
|
|
113
|
+
state.imageRatio = naturalHeight / naturalWidth;
|
|
114
|
+
};
|
|
115
|
+
const resetScale = () => {
|
|
116
|
+
setScale(1);
|
|
117
|
+
state.moveX = 0;
|
|
118
|
+
state.moveY = 0;
|
|
119
|
+
};
|
|
120
|
+
const setScale = (scale) => {
|
|
121
|
+
scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
|
|
122
|
+
if (scale !== state.scale) {
|
|
123
|
+
state.scale = scale;
|
|
124
|
+
emit("scale", {
|
|
125
|
+
scale,
|
|
126
|
+
index: props.initNo
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const toggleScale = () => {
|
|
131
|
+
const scale = state.scale > 1 ? 1 : 2;
|
|
132
|
+
setScale(scale);
|
|
133
|
+
state.moveX = 0;
|
|
134
|
+
state.moveY = 0;
|
|
135
|
+
};
|
|
136
|
+
const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
|
|
137
|
+
let startMoveX;
|
|
138
|
+
let startMoveY;
|
|
139
|
+
let startScale;
|
|
140
|
+
let startDistance;
|
|
141
|
+
let doubleTapTimer;
|
|
142
|
+
let touchStartTime;
|
|
143
|
+
let fingerNum;
|
|
144
|
+
const onTouchStart = (event) => {
|
|
145
|
+
const { touches } = event;
|
|
146
|
+
const { offsetX } = touch;
|
|
147
|
+
touch.start(event);
|
|
148
|
+
fingerNum = touches.length;
|
|
149
|
+
startMoveX = state.moveX;
|
|
150
|
+
startMoveY = state.moveY;
|
|
151
|
+
touchStartTime = Date.now();
|
|
152
|
+
state.moving = fingerNum === 1 && state.scale !== 1;
|
|
153
|
+
state.zooming = fingerNum === 2 && !offsetX.value;
|
|
154
|
+
if (state.zooming) {
|
|
155
|
+
startScale = state.scale;
|
|
156
|
+
startDistance = getDistance(event.touches);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const onTouchMove = (event) => {
|
|
160
|
+
const { touches } = event;
|
|
161
|
+
touch.move(event);
|
|
162
|
+
if (state.moving || state.zooming) {
|
|
163
|
+
preventDefault(event, true);
|
|
164
|
+
}
|
|
165
|
+
if (state.moving) {
|
|
166
|
+
const { deltaX, deltaY } = touch;
|
|
167
|
+
const moveX = deltaX.value + startMoveX;
|
|
168
|
+
const moveY = deltaY.value + startMoveY;
|
|
169
|
+
state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
|
|
170
|
+
state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
|
|
171
|
+
}
|
|
172
|
+
if (state.zooming && touches.length === 2) {
|
|
173
|
+
const distance = getDistance(touches);
|
|
174
|
+
const scale = startScale * distance / startDistance;
|
|
175
|
+
setScale(scale);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const checkTap = () => {
|
|
179
|
+
if (fingerNum > 1) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const { offsetX, offsetY } = touch;
|
|
183
|
+
const deltaTime = Date.now() - touchStartTime;
|
|
184
|
+
const TAP_TIME = 250;
|
|
185
|
+
const TAP_OFFSET = 5;
|
|
186
|
+
if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
|
|
187
|
+
if (doubleTapTimer) {
|
|
188
|
+
clearTimeout(doubleTapTimer);
|
|
189
|
+
doubleTapTimer = null;
|
|
190
|
+
toggleScale();
|
|
191
|
+
} else {
|
|
192
|
+
doubleTapTimer = setTimeout(() => {
|
|
193
|
+
emit("close");
|
|
194
|
+
doubleTapTimer = null;
|
|
195
|
+
}, TAP_TIME);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const onTouchEnd = (event) => {
|
|
200
|
+
let stopPropagation = false;
|
|
201
|
+
if (state.moving || state.zooming) {
|
|
202
|
+
stopPropagation = true;
|
|
203
|
+
if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
|
|
204
|
+
stopPropagation = false;
|
|
205
|
+
}
|
|
206
|
+
if (!event.touches.length) {
|
|
207
|
+
if (state.zooming) {
|
|
208
|
+
state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
|
|
209
|
+
state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
|
|
210
|
+
state.zooming = false;
|
|
211
|
+
}
|
|
212
|
+
state.moving = false;
|
|
213
|
+
startMoveX = 0;
|
|
214
|
+
startMoveY = 0;
|
|
215
|
+
startScale = 1;
|
|
216
|
+
if (state.scale < 1) {
|
|
217
|
+
resetScale();
|
|
218
|
+
}
|
|
219
|
+
if (state.scale > props.maxZoom) {
|
|
220
|
+
state.scale = +props.maxZoom;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
preventDefault(event, stopPropagation);
|
|
225
|
+
checkTap();
|
|
226
|
+
touch.reset();
|
|
227
|
+
};
|
|
228
|
+
const preventDefault = (event, isStopPropagation) => {
|
|
229
|
+
if (typeof event.cancelable !== "boolean" || event.cancelable) {
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
}
|
|
232
|
+
if (isStopPropagation) {
|
|
233
|
+
event.stopPropagation();
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
|
237
|
+
watch(() => props.initNo, resetScale);
|
|
238
|
+
watch(() => props.show, (value) => {
|
|
239
|
+
if (!value) {
|
|
240
|
+
resetScale();
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return {
|
|
244
|
+
...toRefs(state),
|
|
245
|
+
onTouchStart,
|
|
246
|
+
onTouchMove,
|
|
247
|
+
onTouchEnd,
|
|
248
|
+
getDistance,
|
|
249
|
+
imageStyle,
|
|
250
|
+
imageLoad
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
const _hoisted_1$1 = ["src"];
|
|
255
|
+
const _hoisted_2$1 = {
|
|
256
|
+
key: 1,
|
|
257
|
+
class: "nut-imagepreview-box"
|
|
258
|
+
};
|
|
259
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
260
|
+
const _component_nut_video = resolveComponent("nut-video");
|
|
261
|
+
const _component_nut_swiper_item = resolveComponent("nut-swiper-item");
|
|
262
|
+
return openBlock(), createBlock(_component_nut_swiper_item, {
|
|
263
|
+
onTouchstart: _ctx.onTouchStart,
|
|
264
|
+
onTouchmove: _ctx.onTouchMove,
|
|
265
|
+
onTouchend: _ctx.onTouchEnd,
|
|
266
|
+
onTouchcancel: _ctx.onTouchEnd
|
|
267
|
+
}, {
|
|
268
|
+
default: withCtx(() => [
|
|
269
|
+
_ctx.image && _ctx.image.src ? (openBlock(), createElementBlock("view", {
|
|
270
|
+
key: 0,
|
|
271
|
+
style: normalizeStyle(_ctx.imageStyle),
|
|
272
|
+
class: "nut-imagepreview-box"
|
|
273
|
+
}, [
|
|
274
|
+
createElementVNode("img", {
|
|
275
|
+
src: _ctx.image.src,
|
|
276
|
+
class: "nut-imagepreview-img",
|
|
277
|
+
onLoad: _cache[0] || (_cache[0] = (...args) => _ctx.imageLoad && _ctx.imageLoad(...args))
|
|
278
|
+
}, null, 40, _hoisted_1$1)
|
|
279
|
+
], 4)) : createCommentVNode("", true),
|
|
280
|
+
_ctx.video ? (openBlock(), createElementBlock("view", _hoisted_2$1, [
|
|
281
|
+
createVNode(_component_nut_video, {
|
|
282
|
+
source: _ctx.video.source,
|
|
283
|
+
options: _ctx.video.options
|
|
284
|
+
}, null, 8, ["source", "options"])
|
|
285
|
+
])) : createCommentVNode("", true)
|
|
286
|
+
]),
|
|
287
|
+
_: 1
|
|
288
|
+
}, 8, ["onTouchstart", "onTouchmove", "onTouchend", "onTouchcancel"]);
|
|
289
|
+
}
|
|
290
|
+
var ImagePreviewItem = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
291
|
+
const { componentName, create } = createComponent("imagepreview");
|
|
292
|
+
const _sfc_main = create({
|
|
293
|
+
props: {
|
|
294
|
+
show: {
|
|
295
|
+
type: Boolean,
|
|
296
|
+
default: false
|
|
297
|
+
},
|
|
298
|
+
images: {
|
|
299
|
+
type: Array,
|
|
300
|
+
default: () => []
|
|
301
|
+
},
|
|
302
|
+
videos: {
|
|
303
|
+
type: Array,
|
|
304
|
+
default: () => []
|
|
305
|
+
},
|
|
306
|
+
contentClose: {
|
|
307
|
+
type: Boolean,
|
|
308
|
+
default: true
|
|
309
|
+
},
|
|
310
|
+
initNo: {
|
|
311
|
+
type: Number,
|
|
312
|
+
default: 1
|
|
313
|
+
},
|
|
314
|
+
paginationVisible: {
|
|
315
|
+
type: Boolean,
|
|
316
|
+
default: false
|
|
317
|
+
},
|
|
318
|
+
paginationColor: {
|
|
319
|
+
type: String,
|
|
320
|
+
default: "#fff"
|
|
321
|
+
},
|
|
322
|
+
autoplay: {
|
|
323
|
+
type: [Number, String],
|
|
324
|
+
default: 0
|
|
325
|
+
},
|
|
326
|
+
isWrapTeleport: {
|
|
327
|
+
type: Boolean,
|
|
328
|
+
default: false
|
|
329
|
+
},
|
|
330
|
+
showIndex: {
|
|
331
|
+
type: Boolean,
|
|
332
|
+
default: true
|
|
333
|
+
},
|
|
334
|
+
closeable: {
|
|
335
|
+
type: Boolean,
|
|
336
|
+
default: false
|
|
337
|
+
},
|
|
338
|
+
closeIcon: {
|
|
339
|
+
type: String,
|
|
340
|
+
default: "circle-close"
|
|
341
|
+
},
|
|
342
|
+
closeIconPosition: {
|
|
343
|
+
type: String,
|
|
344
|
+
default: "top-right"
|
|
345
|
+
},
|
|
346
|
+
beforeClose: Function,
|
|
347
|
+
minZoom: {
|
|
348
|
+
type: Number,
|
|
349
|
+
default: 1 / 3
|
|
350
|
+
},
|
|
351
|
+
maxZoom: {
|
|
352
|
+
type: Number,
|
|
353
|
+
default: 3
|
|
61
354
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
355
|
+
},
|
|
356
|
+
emits: ["close", "change"],
|
|
357
|
+
components: {
|
|
358
|
+
[Popup.name]: Popup,
|
|
359
|
+
[Video.name]: Video,
|
|
360
|
+
[Swiper.name]: Swiper,
|
|
361
|
+
[SwiperItem.name]: SwiperItem,
|
|
362
|
+
[_sfc_main$2.name]: _sfc_main$2,
|
|
363
|
+
ImagePreviewItem
|
|
364
|
+
},
|
|
365
|
+
setup(props, { emit }) {
|
|
366
|
+
toRefs(props);
|
|
367
|
+
const swipeRef = ref();
|
|
368
|
+
const state = reactive({
|
|
369
|
+
showPop: false,
|
|
370
|
+
active: 1,
|
|
371
|
+
maxNo: 1,
|
|
372
|
+
rootWidth: 0,
|
|
373
|
+
rootHeight: 0
|
|
374
|
+
});
|
|
375
|
+
const styles = computed(() => {
|
|
376
|
+
let style = {};
|
|
377
|
+
if (props.closeIconPosition == "top-right") {
|
|
378
|
+
style.right = "10px";
|
|
379
|
+
} else {
|
|
380
|
+
style.left = "10px";
|
|
381
|
+
}
|
|
382
|
+
return style;
|
|
383
|
+
});
|
|
384
|
+
const slideChangeEnd = function(page) {
|
|
385
|
+
state.active = page + 1;
|
|
386
|
+
emit("change", state.active);
|
|
387
|
+
};
|
|
388
|
+
const onClose = () => {
|
|
389
|
+
if (props.beforeClose) {
|
|
390
|
+
const returnVal = props.beforeClose.apply(null, state.active);
|
|
391
|
+
if (isPromise(returnVal)) {
|
|
392
|
+
returnVal.then((value) => {
|
|
393
|
+
if (value) {
|
|
394
|
+
closeDone();
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
} else if (returnVal) {
|
|
398
|
+
closeDone();
|
|
399
|
+
}
|
|
400
|
+
} else {
|
|
401
|
+
closeDone();
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
const closeDone = () => {
|
|
405
|
+
state.showPop = false;
|
|
406
|
+
state.active = 1;
|
|
407
|
+
emit("close");
|
|
408
|
+
};
|
|
409
|
+
const handleCloseIcon = () => {
|
|
410
|
+
onClose();
|
|
411
|
+
};
|
|
412
|
+
const init = () => {
|
|
413
|
+
setTimeout(() => {
|
|
414
|
+
state.rootHeight = swipeRef.value.offsetHeight;
|
|
415
|
+
state.rootWidth = swipeRef.value.offsetWidth;
|
|
416
|
+
}, 100);
|
|
417
|
+
};
|
|
418
|
+
watch(() => props.show, (val) => {
|
|
419
|
+
state.showPop = val;
|
|
420
|
+
init();
|
|
421
|
+
});
|
|
422
|
+
onMounted(() => {
|
|
423
|
+
state.active = props.initNo;
|
|
424
|
+
state.showPop = props.show;
|
|
425
|
+
state.maxNo = props.images.length + props.videos.length;
|
|
426
|
+
});
|
|
427
|
+
return {
|
|
428
|
+
swipeRef,
|
|
429
|
+
...toRefs(state),
|
|
430
|
+
slideChangeEnd,
|
|
431
|
+
onClose,
|
|
432
|
+
handleCloseIcon,
|
|
433
|
+
styles
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
const _hoisted_1 = {
|
|
438
|
+
class: "nut-imagepreview",
|
|
439
|
+
ref: "swipeRef"
|
|
440
|
+
};
|
|
441
|
+
const _hoisted_2 = {
|
|
442
|
+
key: 0,
|
|
443
|
+
class: "nut-imagepreview-index"
|
|
444
|
+
};
|
|
445
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
446
|
+
const _component_image_preview_item = resolveComponent("image-preview-item");
|
|
447
|
+
const _component_nut_swiper = resolveComponent("nut-swiper");
|
|
448
|
+
const _component_nut_icon = resolveComponent("nut-icon");
|
|
449
|
+
const _component_nut_popup = resolveComponent("nut-popup");
|
|
450
|
+
return openBlock(), createBlock(_component_nut_popup, {
|
|
451
|
+
"pop-class": "custom-pop",
|
|
452
|
+
visible: _ctx.showPop,
|
|
453
|
+
"onUpdate:visible": _cache[1] || (_cache[1] = ($event) => _ctx.showPop = $event),
|
|
454
|
+
isWrapTeleport: _ctx.isWrapTeleport,
|
|
455
|
+
onClick: _ctx.onClose,
|
|
456
|
+
style: { "width": "100%" }
|
|
457
|
+
}, {
|
|
458
|
+
default: withCtx(() => [
|
|
459
|
+
createElementVNode("view", _hoisted_1, [
|
|
460
|
+
_ctx.showPop ? (openBlock(), createBlock(_component_nut_swiper, {
|
|
461
|
+
key: 0,
|
|
462
|
+
"auto-play": _ctx.autoplay,
|
|
463
|
+
class: "nut-imagepreview-swiper",
|
|
464
|
+
loop: true,
|
|
465
|
+
"is-preventDefault": false,
|
|
466
|
+
direction: "horizontal",
|
|
467
|
+
onChange: _ctx.slideChangeEnd,
|
|
468
|
+
"init-page": _ctx.initNo > _ctx.maxNo ? _ctx.maxNo - 1 : _ctx.initNo - 1,
|
|
469
|
+
"pagination-visible": _ctx.paginationVisible,
|
|
470
|
+
"pagination-color": _ctx.paginationColor
|
|
471
|
+
}, {
|
|
472
|
+
default: withCtx(() => [
|
|
473
|
+
_ctx.videos.length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.videos, (item, index) => {
|
|
474
|
+
return openBlock(), createBlock(_component_image_preview_item, {
|
|
475
|
+
key: index,
|
|
476
|
+
video: item,
|
|
477
|
+
rootHeight: _ctx.rootHeight,
|
|
478
|
+
rootWidth: _ctx.rootWidth,
|
|
479
|
+
show: _ctx.showPop,
|
|
480
|
+
"init-no": _ctx.active,
|
|
481
|
+
onClose: _ctx.onClose,
|
|
482
|
+
maxZoom: _ctx.maxZoom,
|
|
483
|
+
minZoom: _ctx.minZoom
|
|
484
|
+
}, null, 8, ["video", "rootHeight", "rootWidth", "show", "init-no", "onClose", "maxZoom", "minZoom"]);
|
|
485
|
+
}), 128)) : createCommentVNode("", true),
|
|
486
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.images, (item, index) => {
|
|
487
|
+
return openBlock(), createBlock(_component_image_preview_item, {
|
|
488
|
+
key: index,
|
|
489
|
+
image: item,
|
|
490
|
+
rootHeight: _ctx.rootHeight,
|
|
491
|
+
rootWidth: _ctx.rootWidth,
|
|
492
|
+
show: _ctx.showPop,
|
|
493
|
+
"init-no": _ctx.active,
|
|
494
|
+
onClose: _ctx.onClose
|
|
495
|
+
}, null, 8, ["image", "rootHeight", "rootWidth", "show", "init-no", "onClose"]);
|
|
496
|
+
}), 128))
|
|
497
|
+
]),
|
|
498
|
+
_: 1
|
|
499
|
+
}, 8, ["auto-play", "onChange", "init-page", "pagination-visible", "pagination-color"])) : createCommentVNode("", true)
|
|
500
|
+
], 512),
|
|
501
|
+
_ctx.showIndex ? (openBlock(), createElementBlock("view", _hoisted_2, toDisplayString(_ctx.active) + " / " + toDisplayString(_ctx.images.length + _ctx.videos.length), 1)) : createCommentVNode("", true),
|
|
502
|
+
_ctx.closeable ? (openBlock(), createElementBlock("view", {
|
|
503
|
+
key: 1,
|
|
504
|
+
class: "nut-imagepreview-close-icon",
|
|
505
|
+
onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleCloseIcon && _ctx.handleCloseIcon(...args)),
|
|
506
|
+
style: normalizeStyle(_ctx.styles)
|
|
507
|
+
}, [
|
|
508
|
+
createVNode(_component_nut_icon, {
|
|
509
|
+
name: _ctx.closeIcon,
|
|
510
|
+
color: "#ffffff"
|
|
511
|
+
}, null, 8, ["name"])
|
|
512
|
+
], 4)) : createCommentVNode("", true)
|
|
513
|
+
]),
|
|
514
|
+
_: 1
|
|
515
|
+
}, 8, ["visible", "isWrapTeleport", "onClick"]);
|
|
516
|
+
}
|
|
517
|
+
var ImagePreview = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
518
|
+
class ImagePreviewOptions {
|
|
72
519
|
constructor() {
|
|
73
|
-
this.show = false
|
|
520
|
+
this.show = false;
|
|
521
|
+
this.images = [];
|
|
522
|
+
this.initNo = 1;
|
|
523
|
+
this.paginationVisible = false;
|
|
524
|
+
this.paginationColor = "";
|
|
525
|
+
this.teleport = "body";
|
|
526
|
+
this.onClose = () => {
|
|
74
527
|
};
|
|
75
528
|
}
|
|
76
529
|
}
|
|
77
|
-
class
|
|
78
|
-
constructor(
|
|
79
|
-
this.options = new
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
530
|
+
class ImagePreviewFunction {
|
|
531
|
+
constructor(_options) {
|
|
532
|
+
this.options = new ImagePreviewOptions();
|
|
533
|
+
let options = Object.assign(this.options, _options);
|
|
534
|
+
let elWarp = document.body;
|
|
535
|
+
let teleport = options.teleport;
|
|
536
|
+
if (teleport != "body") {
|
|
537
|
+
if (typeof teleport == "string") {
|
|
538
|
+
elWarp = document.querySelector(teleport);
|
|
539
|
+
} else {
|
|
540
|
+
elWarp = options.teleport;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
const root = document.createElement("view");
|
|
544
|
+
root.id = "imagepreview-" + new Date().getTime();
|
|
545
|
+
const Wrapper = {
|
|
546
|
+
setup() {
|
|
547
|
+
options.teleport = `#${root.id}`;
|
|
548
|
+
return () => {
|
|
549
|
+
return h(ImagePreview, options);
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
const instance = createVNode(Wrapper);
|
|
554
|
+
elWarp.appendChild(root);
|
|
555
|
+
render(instance, root);
|
|
86
556
|
}
|
|
87
557
|
}
|
|
88
|
-
const
|
|
89
|
-
return new
|
|
558
|
+
const _ImagePreview = function(options) {
|
|
559
|
+
return new ImagePreviewFunction(options);
|
|
90
560
|
};
|
|
91
|
-
|
|
92
|
-
|
|
561
|
+
_ImagePreview.install = (app) => {
|
|
562
|
+
app.use(ImagePreview);
|
|
563
|
+
app.config.globalProperties.$imagepreview = _ImagePreview;
|
|
93
564
|
};
|
|
94
|
-
export {
|
|
565
|
+
export { ImagePreview, ImagePreviewOptions, _ImagePreview as default };
|