@wfrog/vc-ui 1.11.10 → 1.11.11
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/es/chunk/Bw0Rhd-r.mjs +110 -0
- package/dist/es/chunk/CqTdDZkE.mjs +31 -0
- package/dist/es/chunk/{DAnWZLYj.mjs → CzWfBa_8.mjs} +96 -2
- package/dist/es/chunk/D229kQ56.mjs +28 -0
- package/dist/es/chunk/{Cxx_YWUC.mjs → DcouM6gM.mjs} +6 -548
- package/dist/es/chunk/Fo0dZYnz.mjs +128 -0
- package/dist/es/chunk/KanuIcmc.mjs +412 -0
- package/dist/es/chunk/{B71xEPfK.mjs → uuUHUjSk.mjs} +4 -35
- package/dist/es/components/backbottom/backbottom.mjs +3 -2
- package/dist/es/components/button/button.mjs +4 -5
- package/dist/es/components/choice/choice.mjs +4 -4
- package/dist/es/components/choice/index.css +1 -1
- package/dist/es/components/color-switch/color-switch.mjs +73 -1046
- package/dist/es/components/color-switch/index.css +1 -1
- package/dist/es/components/cropper/cropper.mjs +11 -117
- package/dist/es/components/cropper/index.css +1 -1
- package/dist/es/components/currency/currency.mjs +4 -5
- package/dist/es/components/daterange-picker/daterange-picker.mjs +8 -6253
- package/dist/es/components/dialog/dialog.mjs +7 -400
- package/dist/es/components/dialog/index.css +1 -1
- package/dist/es/components/dialog-camera-upload/dialog-camera-upload.mjs +10 -11
- package/dist/es/components/dialog-map-point/dialog-map-point.mjs +4 -3
- package/dist/es/components/dialog-upload-images/dialog-upload-images.mjs +9 -1374
- package/dist/es/components/dialog-upload-images/index.css +1 -1
- package/dist/es/components/drag-verify/drag-verify.mjs +3 -2
- package/dist/es/components/drawer/drawer.mjs +10 -352
- package/dist/es/components/drawer/index.css +1 -1
- package/dist/es/components/easy-pagination/easy-pagination.mjs +3 -2
- package/dist/es/components/explorer/explorer.mjs +3 -3
- package/dist/es/components/explorer-column-table/explorer-column-table.mjs +5 -7
- package/dist/es/components/explorer-column-table/index.css +1 -1
- package/dist/es/components/explorer-container/explorer-container.d.ts +1 -1
- package/dist/es/components/explorer-container/explorer-container.mjs +4 -3
- package/dist/es/components/explorer-filter/explorer-filter.mjs +5 -4
- package/dist/es/components/explorer-footer/explorer-footer.mjs +4 -8
- package/dist/es/components/explorer-form/explorer-form.mjs +4 -3
- package/dist/es/components/explorer-list/explorer-list.mjs +5 -4
- package/dist/es/components/explorer-modal-form/explorer-modal-form.mjs +4 -3
- package/dist/es/components/explorer-panel/explorer-panel.mjs +3 -3
- package/dist/es/components/explorer-query/explorer-query.mjs +9 -2201
- package/dist/es/components/explorer-query/index.css +1 -1
- package/dist/es/components/explorer-table/explorer-table.mjs +5 -8
- package/dist/es/components/explorer-tools/explorer-tools.mjs +13 -264
- package/dist/es/components/explorer-tools/index.css +1 -1
- package/dist/es/components/explorer-tree/explorer-tree.mjs +4 -5
- package/dist/es/components/icon-picker/icon-picker.mjs +8 -12
- package/dist/es/components/image/image.mjs +4 -4
- package/dist/es/components/info-tooltip/info-tooltip.mjs +336 -4
- package/dist/es/components/input/input.mjs +3 -2
- package/dist/es/components/input-number/input-number.mjs +3 -3
- package/dist/es/components/pca-picker/index.css +1 -1
- package/dist/es/components/pca-picker/pca-picker.mjs +443 -601
- package/dist/es/components/screenfull/screenfull.mjs +4 -3
- package/dist/es/components/scrollbar/scrollbar.mjs +3 -2
- package/dist/es/components/select/select.mjs +3 -5
- package/dist/es/components/single-player/index.css +1 -1
- package/dist/es/components/single-player/single-player.mjs +10 -1087
- package/dist/es/components/splitter/splitter.mjs +3 -3
- package/dist/es/components/splitter-panel/splitter-panel.mjs +3 -3
- package/dist/es/components/switch/index.css +1 -1
- package/dist/es/components/switch/switch.mjs +9 -395
- package/dist/es/components/tags/tags.mjs +7 -9
- package/dist/es/components/text-ellipsis/text-ellipsis.mjs +3 -3
- package/dist/es/components/thousand-input/thousand-input.mjs +33 -1
- package/dist/es/components/tinymce/tinymce.mjs +4 -3
- package/dist/es/components/transfer/transfer.mjs +3 -4
- package/dist/es/components/transfer-panel/transfer-panel.mjs +5 -4
- package/dist/es/components/tree-picker/popover-cascader.css +1 -1
- package/dist/es/components/tree-picker/tree-picker.mjs +5 -10
- package/dist/es/index.mjs +1 -1
- package/dist/index.css +13 -40
- package/package.json +1 -1
- package/dist/es/chunk/B-rxnVJv.mjs +0 -3
- package/dist/es/chunk/B5HpgPRt.mjs +0 -69
- package/dist/es/chunk/BBhZKpIc.mjs +0 -2179
- package/dist/es/chunk/BDcsaNYa.mjs +0 -59
- package/dist/es/chunk/BTSSEFfD.mjs +0 -319
- package/dist/es/chunk/BTpNRPQW.mjs +0 -55
- package/dist/es/chunk/BVBK1U57.mjs +0 -96
- package/dist/es/chunk/Bc6yUGLs.mjs +0 -45
- package/dist/es/chunk/BjVI1XMz.mjs +0 -40
- package/dist/es/chunk/BlzQCBDu.mjs +0 -5741
- package/dist/es/chunk/BpJKnxlF.mjs +0 -476
- package/dist/es/chunk/Brp-qSBw.mjs +0 -2003
- package/dist/es/chunk/BunQI8Jb.mjs +0 -390
- package/dist/es/chunk/C0XgBrDz.mjs +0 -775
- package/dist/es/chunk/C0pTANRX.mjs +0 -109
- package/dist/es/chunk/CBMjhoFP.mjs +0 -101
- package/dist/es/chunk/CBiNtNvQ.mjs +0 -242
- package/dist/es/chunk/CBlJeNBO.mjs +0 -890
- package/dist/es/chunk/CCVL_Zj-.mjs +0 -427
- package/dist/es/chunk/CEl4MyfJ.mjs +0 -252
- package/dist/es/chunk/CJK5_jsA.mjs +0 -53
- package/dist/es/chunk/CKOcwq5V.mjs +0 -44
- package/dist/es/chunk/COs9dJZa.mjs +0 -66
- package/dist/es/chunk/CPt6MxJW.mjs +0 -375
- package/dist/es/chunk/CVqW0jzp.mjs +0 -107
- package/dist/es/chunk/CccIsEqA.mjs +0 -128
- package/dist/es/chunk/CjLR27-a.mjs +0 -582
- package/dist/es/chunk/CoGexPPD.mjs +0 -2192
- package/dist/es/chunk/CsLIbnzG.mjs +0 -64
- package/dist/es/chunk/Ct6q2FXg.mjs +0 -5
- package/dist/es/chunk/Cuq5meQh.mjs +0 -184
- package/dist/es/chunk/CvYIOfT1.mjs +0 -23
- package/dist/es/chunk/CxHJBf4l.mjs +0 -31
- package/dist/es/chunk/CzdaOBtA.mjs +0 -66
- package/dist/es/chunk/D0QTifnI.mjs +0 -54
- package/dist/es/chunk/D1QnA2iT.mjs +0 -229
- package/dist/es/chunk/D3AvJlVX.mjs +0 -188
- package/dist/es/chunk/D9Lr0Bzb.mjs +0 -1136
- package/dist/es/chunk/DCkPv0hy.mjs +0 -29
- package/dist/es/chunk/DRwwUUhy.mjs +0 -49
- package/dist/es/chunk/DX-2VRY2.mjs +0 -836
- package/dist/es/chunk/DZ2oTFad.mjs +0 -687
- package/dist/es/chunk/D_bou1py.mjs +0 -55
- package/dist/es/chunk/Da199A5L.mjs +0 -314
- package/dist/es/chunk/DbhQlaOz.mjs +0 -94
- package/dist/es/chunk/Dgu95mOy.mjs +0 -237
- package/dist/es/chunk/DhGOsWxx.mjs +0 -6
- package/dist/es/chunk/Dm_Sj5aH.mjs +0 -487
- package/dist/es/chunk/Dmi-1GRO.mjs +0 -163
- package/dist/es/chunk/DodoD9a9.mjs +0 -52
- package/dist/es/chunk/DrrVDcwm.mjs +0 -955
- package/dist/es/chunk/Du_zJ1Fz.mjs +0 -49
- package/dist/es/chunk/DxxbB5jY.mjs +0 -34
- package/dist/es/chunk/Gk1J52Yw.mjs +0 -207
- package/dist/es/chunk/NsldgdCh.mjs +0 -704
- package/dist/es/chunk/V6KjsUQN.mjs +0 -35
- package/dist/es/chunk/eEsLFV3s.mjs +0 -76
- package/dist/es/chunk/fqiLhk0V.mjs +0 -2065
- package/dist/es/chunk/nxVM7re4.mjs +0 -35
- package/dist/es/chunk/s7HLrANj.mjs +0 -215
- package/dist/es/chunk/vPhxogl3.mjs +0 -19
- package/dist/es/components/icon/icon2.mjs +0 -27
|
@@ -1,955 +0,0 @@
|
|
|
1
|
-
import { defineComponent, markRaw, ref, effectScope, computed, shallowRef, watch, nextTick, onMounted, createBlock, openBlock, unref, withCtx, createVNode, Transition, createElementVNode, normalizeStyle, normalizeClass, createCommentVNode, createElementBlock, renderSlot, withModifiers, Fragment, createTextVNode, toDisplayString, resolveDynamicComponent, useAttrs, mergeProps, createSlots, normalizeProps, guardReactiveProps } from 'vue';
|
|
2
|
-
import { clamp, useEventListener, isClient, useThrottleFn, useIntersectionObserver } from '@vueuse/core';
|
|
3
|
-
import { b as ElTeleport, d as ElFocusTrap } from './CoGexPPD.mjs';
|
|
4
|
-
import { E as ElIcon } from './D0QTifnI.mjs';
|
|
5
|
-
import { ScaleToOriginal, FullScreen, Close, ArrowLeft, ArrowRight, ZoomOut, ZoomIn, RefreshLeft, RefreshRight } from '@element-plus/icons-vue';
|
|
6
|
-
import { b as buildProps, d as definePropType, u as useNamespace, l as fromPairs, c as isArray, i as isString } from './Gk1J52Yw.mjs';
|
|
7
|
-
import { m as mutable } from './B-rxnVJv.mjs';
|
|
8
|
-
import { b as isNumber, f as isElement, e as isWindow } from './Bc6yUGLs.mjs';
|
|
9
|
-
import { _ as _export_sfc, w as withInstall } from './V6KjsUQN.mjs';
|
|
10
|
-
import { u as useLocale } from './CEl4MyfJ.mjs';
|
|
11
|
-
import { u as useZIndex } from './BjVI1XMz.mjs';
|
|
12
|
-
import { u as useLockscreen } from './CJK5_jsA.mjs';
|
|
13
|
-
import { g as getEventCode, E as EVENT_CODE } from './BTpNRPQW.mjs';
|
|
14
|
-
import { k as keysOf } from './Du_zJ1Fz.mjs';
|
|
15
|
-
import { t as throttle } from './B5HpgPRt.mjs';
|
|
16
|
-
import { u as useAttrs$1 } from './CxHJBf4l.mjs';
|
|
17
|
-
import { c as getScrollContainer } from './CccIsEqA.mjs';
|
|
18
|
-
|
|
19
|
-
const imageViewerProps = buildProps({
|
|
20
|
-
urlList: {
|
|
21
|
-
type: definePropType(Array),
|
|
22
|
-
default: () => mutable([])
|
|
23
|
-
},
|
|
24
|
-
zIndex: {
|
|
25
|
-
type: Number
|
|
26
|
-
},
|
|
27
|
-
initialIndex: {
|
|
28
|
-
type: Number,
|
|
29
|
-
default: 0
|
|
30
|
-
},
|
|
31
|
-
infinite: {
|
|
32
|
-
type: Boolean,
|
|
33
|
-
default: true
|
|
34
|
-
},
|
|
35
|
-
hideOnClickModal: Boolean,
|
|
36
|
-
teleported: Boolean,
|
|
37
|
-
closeOnPressEscape: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: true
|
|
40
|
-
},
|
|
41
|
-
zoomRate: {
|
|
42
|
-
type: Number,
|
|
43
|
-
default: 1.2
|
|
44
|
-
},
|
|
45
|
-
scale: {
|
|
46
|
-
type: Number,
|
|
47
|
-
default: 1
|
|
48
|
-
},
|
|
49
|
-
minScale: {
|
|
50
|
-
type: Number,
|
|
51
|
-
default: 0.2
|
|
52
|
-
},
|
|
53
|
-
maxScale: {
|
|
54
|
-
type: Number,
|
|
55
|
-
default: 7
|
|
56
|
-
},
|
|
57
|
-
showProgress: Boolean,
|
|
58
|
-
crossorigin: {
|
|
59
|
-
type: definePropType(String)
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
const imageViewerEmits = {
|
|
63
|
-
close: () => true,
|
|
64
|
-
error: (evt) => evt instanceof Event,
|
|
65
|
-
switch: (index) => isNumber(index),
|
|
66
|
-
rotate: (deg) => isNumber(deg)
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const _hoisted_1$1 = ["src", "crossorigin"];
|
|
70
|
-
const _sfc_main$1 = defineComponent({
|
|
71
|
-
...{
|
|
72
|
-
name: "ElImageViewer"
|
|
73
|
-
},
|
|
74
|
-
__name: "image-viewer",
|
|
75
|
-
props: imageViewerProps,
|
|
76
|
-
emits: imageViewerEmits,
|
|
77
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
78
|
-
var _a;
|
|
79
|
-
const modes = {
|
|
80
|
-
CONTAIN: {
|
|
81
|
-
name: "contain",
|
|
82
|
-
icon: markRaw(FullScreen)
|
|
83
|
-
},
|
|
84
|
-
ORIGINAL: {
|
|
85
|
-
name: "original",
|
|
86
|
-
icon: markRaw(ScaleToOriginal)
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const props = __props;
|
|
90
|
-
const emit = __emit;
|
|
91
|
-
let stopWheelListener;
|
|
92
|
-
const { t } = useLocale();
|
|
93
|
-
const ns = useNamespace("image-viewer");
|
|
94
|
-
const { nextZIndex } = useZIndex();
|
|
95
|
-
const wrapper = ref();
|
|
96
|
-
const imgRef = ref();
|
|
97
|
-
const scopeEventListener = effectScope();
|
|
98
|
-
const scaleClamped = computed(() => {
|
|
99
|
-
const { scale, minScale, maxScale } = props;
|
|
100
|
-
return clamp(scale, minScale, maxScale);
|
|
101
|
-
});
|
|
102
|
-
const loading = ref(true);
|
|
103
|
-
const loadError = ref(false);
|
|
104
|
-
const visible = ref(false);
|
|
105
|
-
const activeIndex = ref(props.initialIndex);
|
|
106
|
-
const mode = shallowRef(modes.CONTAIN);
|
|
107
|
-
const transform = ref({
|
|
108
|
-
scale: scaleClamped.value,
|
|
109
|
-
deg: 0,
|
|
110
|
-
offsetX: 0,
|
|
111
|
-
offsetY: 0,
|
|
112
|
-
enableTransition: false
|
|
113
|
-
});
|
|
114
|
-
const zIndex = ref((_a = props.zIndex) != null ? _a : nextZIndex());
|
|
115
|
-
useLockscreen(visible, { ns });
|
|
116
|
-
const isSingle = computed(() => {
|
|
117
|
-
const { urlList } = props;
|
|
118
|
-
return urlList.length <= 1;
|
|
119
|
-
});
|
|
120
|
-
const isFirst = computed(() => activeIndex.value === 0);
|
|
121
|
-
const isLast = computed(() => activeIndex.value === props.urlList.length - 1);
|
|
122
|
-
const currentImg = computed(() => props.urlList[activeIndex.value]);
|
|
123
|
-
const arrowPrevKls = computed(() => [
|
|
124
|
-
ns.e("btn"),
|
|
125
|
-
ns.e("prev"),
|
|
126
|
-
ns.is("disabled", !props.infinite && isFirst.value)
|
|
127
|
-
]);
|
|
128
|
-
const arrowNextKls = computed(() => [
|
|
129
|
-
ns.e("btn"),
|
|
130
|
-
ns.e("next"),
|
|
131
|
-
ns.is("disabled", !props.infinite && isLast.value)
|
|
132
|
-
]);
|
|
133
|
-
const imgStyle = computed(() => {
|
|
134
|
-
const { scale, deg, offsetX, offsetY, enableTransition } = transform.value;
|
|
135
|
-
let translateX = offsetX / scale;
|
|
136
|
-
let translateY = offsetY / scale;
|
|
137
|
-
const radian = deg * Math.PI / 180;
|
|
138
|
-
const cosRadian = Math.cos(radian);
|
|
139
|
-
const sinRadian = Math.sin(radian);
|
|
140
|
-
translateX = translateX * cosRadian + translateY * sinRadian;
|
|
141
|
-
translateY = translateY * cosRadian - offsetX / scale * sinRadian;
|
|
142
|
-
const style = {
|
|
143
|
-
transform: `scale(${scale}) rotate(${deg}deg) translate(${translateX}px, ${translateY}px)`,
|
|
144
|
-
transition: enableTransition ? "transform .3s" : ""
|
|
145
|
-
};
|
|
146
|
-
if (mode.value.name === modes.CONTAIN.name) {
|
|
147
|
-
style.maxWidth = style.maxHeight = "100%";
|
|
148
|
-
}
|
|
149
|
-
return style;
|
|
150
|
-
});
|
|
151
|
-
const progress = computed(
|
|
152
|
-
() => `${activeIndex.value + 1} / ${props.urlList.length}`
|
|
153
|
-
);
|
|
154
|
-
function hide() {
|
|
155
|
-
unregisterEventListener();
|
|
156
|
-
stopWheelListener == null ? void 0 : stopWheelListener();
|
|
157
|
-
visible.value = false;
|
|
158
|
-
emit("close");
|
|
159
|
-
}
|
|
160
|
-
function registerEventListener() {
|
|
161
|
-
const keydownHandler = throttle((e) => {
|
|
162
|
-
const code = getEventCode(e);
|
|
163
|
-
switch (code) {
|
|
164
|
-
case EVENT_CODE.esc:
|
|
165
|
-
props.closeOnPressEscape && hide();
|
|
166
|
-
break;
|
|
167
|
-
case EVENT_CODE.space:
|
|
168
|
-
toggleMode();
|
|
169
|
-
break;
|
|
170
|
-
case EVENT_CODE.left:
|
|
171
|
-
prev();
|
|
172
|
-
break;
|
|
173
|
-
case EVENT_CODE.up:
|
|
174
|
-
handleActions("zoomIn");
|
|
175
|
-
break;
|
|
176
|
-
case EVENT_CODE.right:
|
|
177
|
-
next();
|
|
178
|
-
break;
|
|
179
|
-
case EVENT_CODE.down:
|
|
180
|
-
handleActions("zoomOut");
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
const mousewheelHandler = throttle((e) => {
|
|
185
|
-
const delta = e.deltaY || e.deltaX;
|
|
186
|
-
handleActions(delta < 0 ? "zoomIn" : "zoomOut", {
|
|
187
|
-
zoomRate: props.zoomRate,
|
|
188
|
-
enableTransition: false
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
scopeEventListener.run(() => {
|
|
192
|
-
useEventListener(document, "keydown", keydownHandler);
|
|
193
|
-
useEventListener(wrapper, "wheel", mousewheelHandler);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
function unregisterEventListener() {
|
|
197
|
-
scopeEventListener.stop();
|
|
198
|
-
}
|
|
199
|
-
function handleImgLoad() {
|
|
200
|
-
loading.value = false;
|
|
201
|
-
}
|
|
202
|
-
function handleImgError(e) {
|
|
203
|
-
loadError.value = true;
|
|
204
|
-
loading.value = false;
|
|
205
|
-
emit("error", e);
|
|
206
|
-
e.target.alt = t("el.image.error");
|
|
207
|
-
}
|
|
208
|
-
function handleMouseDown(e) {
|
|
209
|
-
if (loading.value || e.button !== 0 || !wrapper.value)
|
|
210
|
-
return;
|
|
211
|
-
transform.value.enableTransition = false;
|
|
212
|
-
const { offsetX, offsetY } = transform.value;
|
|
213
|
-
const startX = e.pageX;
|
|
214
|
-
const startY = e.pageY;
|
|
215
|
-
const dragHandler = throttle((ev) => {
|
|
216
|
-
transform.value = {
|
|
217
|
-
...transform.value,
|
|
218
|
-
offsetX: offsetX + ev.pageX - startX,
|
|
219
|
-
offsetY: offsetY + ev.pageY - startY
|
|
220
|
-
};
|
|
221
|
-
});
|
|
222
|
-
const removeMousemove = useEventListener(document, "mousemove", dragHandler);
|
|
223
|
-
const removeMouseup = useEventListener(document, "mouseup", () => {
|
|
224
|
-
removeMousemove();
|
|
225
|
-
removeMouseup();
|
|
226
|
-
});
|
|
227
|
-
e.preventDefault();
|
|
228
|
-
}
|
|
229
|
-
function handleTouchStart(e) {
|
|
230
|
-
if (loading.value || !wrapper.value || e.touches.length !== 1)
|
|
231
|
-
return;
|
|
232
|
-
transform.value.enableTransition = false;
|
|
233
|
-
const { offsetX, offsetY } = transform.value;
|
|
234
|
-
const { pageX: startX, pageY: startY } = e.touches[0];
|
|
235
|
-
const dragHandler = throttle((ev) => {
|
|
236
|
-
const targetTouch = ev.touches[0];
|
|
237
|
-
transform.value = {
|
|
238
|
-
...transform.value,
|
|
239
|
-
offsetX: offsetX + targetTouch.pageX - startX,
|
|
240
|
-
offsetY: offsetY + targetTouch.pageY - startY
|
|
241
|
-
};
|
|
242
|
-
});
|
|
243
|
-
const removeTouchmove = useEventListener(document, "touchmove", dragHandler);
|
|
244
|
-
const removeTouchend = useEventListener(document, "touchend", () => {
|
|
245
|
-
removeTouchmove();
|
|
246
|
-
removeTouchend();
|
|
247
|
-
});
|
|
248
|
-
e.preventDefault();
|
|
249
|
-
}
|
|
250
|
-
function reset() {
|
|
251
|
-
transform.value = {
|
|
252
|
-
scale: scaleClamped.value,
|
|
253
|
-
deg: 0,
|
|
254
|
-
offsetX: 0,
|
|
255
|
-
offsetY: 0,
|
|
256
|
-
enableTransition: false
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
function toggleMode() {
|
|
260
|
-
if (loading.value || loadError.value)
|
|
261
|
-
return;
|
|
262
|
-
const modeNames = keysOf(modes);
|
|
263
|
-
const modeValues = Object.values(modes);
|
|
264
|
-
const currentMode = mode.value.name;
|
|
265
|
-
const index = modeValues.findIndex((i) => i.name === currentMode);
|
|
266
|
-
const nextIndex = (index + 1) % modeNames.length;
|
|
267
|
-
mode.value = modes[modeNames[nextIndex]];
|
|
268
|
-
reset();
|
|
269
|
-
}
|
|
270
|
-
function setActiveItem(index) {
|
|
271
|
-
loadError.value = false;
|
|
272
|
-
const len = props.urlList.length;
|
|
273
|
-
activeIndex.value = (index + len) % len;
|
|
274
|
-
}
|
|
275
|
-
function prev() {
|
|
276
|
-
if (isFirst.value && !props.infinite)
|
|
277
|
-
return;
|
|
278
|
-
setActiveItem(activeIndex.value - 1);
|
|
279
|
-
}
|
|
280
|
-
function next() {
|
|
281
|
-
if (isLast.value && !props.infinite)
|
|
282
|
-
return;
|
|
283
|
-
setActiveItem(activeIndex.value + 1);
|
|
284
|
-
}
|
|
285
|
-
function handleActions(action, options = {}) {
|
|
286
|
-
if (loading.value || loadError.value)
|
|
287
|
-
return;
|
|
288
|
-
const { minScale, maxScale } = props;
|
|
289
|
-
const { zoomRate, rotateDeg, enableTransition } = {
|
|
290
|
-
zoomRate: props.zoomRate,
|
|
291
|
-
rotateDeg: 90,
|
|
292
|
-
enableTransition: true,
|
|
293
|
-
...options
|
|
294
|
-
};
|
|
295
|
-
switch (action) {
|
|
296
|
-
case "zoomOut":
|
|
297
|
-
if (transform.value.scale > minScale) {
|
|
298
|
-
transform.value.scale = Number.parseFloat(
|
|
299
|
-
(transform.value.scale / zoomRate).toFixed(3)
|
|
300
|
-
);
|
|
301
|
-
}
|
|
302
|
-
break;
|
|
303
|
-
case "zoomIn":
|
|
304
|
-
if (transform.value.scale < maxScale) {
|
|
305
|
-
transform.value.scale = Number.parseFloat(
|
|
306
|
-
(transform.value.scale * zoomRate).toFixed(3)
|
|
307
|
-
);
|
|
308
|
-
}
|
|
309
|
-
break;
|
|
310
|
-
case "clockwise":
|
|
311
|
-
transform.value.deg += rotateDeg;
|
|
312
|
-
emit("rotate", transform.value.deg);
|
|
313
|
-
break;
|
|
314
|
-
case "anticlockwise":
|
|
315
|
-
transform.value.deg -= rotateDeg;
|
|
316
|
-
emit("rotate", transform.value.deg);
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
transform.value.enableTransition = enableTransition;
|
|
320
|
-
}
|
|
321
|
-
function onFocusoutPrevented(event) {
|
|
322
|
-
var _a2;
|
|
323
|
-
if (((_a2 = event.detail) == null ? void 0 : _a2.focusReason) === "pointer") {
|
|
324
|
-
event.preventDefault();
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
function onCloseRequested() {
|
|
328
|
-
if (props.closeOnPressEscape) {
|
|
329
|
-
hide();
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
function wheelHandler(e) {
|
|
333
|
-
if (!e.ctrlKey)
|
|
334
|
-
return;
|
|
335
|
-
if (e.deltaY < 0) {
|
|
336
|
-
e.preventDefault();
|
|
337
|
-
return false;
|
|
338
|
-
} else if (e.deltaY > 0) {
|
|
339
|
-
e.preventDefault();
|
|
340
|
-
return false;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
watch(
|
|
344
|
-
() => scaleClamped.value,
|
|
345
|
-
(val) => {
|
|
346
|
-
transform.value.scale = val;
|
|
347
|
-
}
|
|
348
|
-
);
|
|
349
|
-
watch(currentImg, () => {
|
|
350
|
-
nextTick(() => {
|
|
351
|
-
const $img = imgRef.value;
|
|
352
|
-
if (!($img == null ? void 0 : $img.complete)) {
|
|
353
|
-
loading.value = true;
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
watch(activeIndex, (val) => {
|
|
358
|
-
reset();
|
|
359
|
-
emit("switch", val);
|
|
360
|
-
});
|
|
361
|
-
onMounted(() => {
|
|
362
|
-
visible.value = true;
|
|
363
|
-
registerEventListener();
|
|
364
|
-
stopWheelListener = useEventListener("wheel", wheelHandler, {
|
|
365
|
-
passive: false
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
__expose({
|
|
369
|
-
setActiveItem
|
|
370
|
-
});
|
|
371
|
-
return (_ctx, _cache) => {
|
|
372
|
-
return openBlock(), createBlock(unref(ElTeleport), {
|
|
373
|
-
to: "body",
|
|
374
|
-
disabled: !_ctx.teleported
|
|
375
|
-
}, {
|
|
376
|
-
default: withCtx(() => [
|
|
377
|
-
createVNode(Transition, {
|
|
378
|
-
name: "viewer-fade",
|
|
379
|
-
appear: ""
|
|
380
|
-
}, {
|
|
381
|
-
default: withCtx(() => [
|
|
382
|
-
createElementVNode(
|
|
383
|
-
"div",
|
|
384
|
-
{
|
|
385
|
-
ref_key: "wrapper",
|
|
386
|
-
ref: wrapper,
|
|
387
|
-
tabindex: -1,
|
|
388
|
-
class: normalizeClass(unref(ns).e("wrapper")),
|
|
389
|
-
style: normalizeStyle({ zIndex: zIndex.value })
|
|
390
|
-
},
|
|
391
|
-
[
|
|
392
|
-
createVNode(unref(ElFocusTrap), {
|
|
393
|
-
loop: "",
|
|
394
|
-
trapped: "",
|
|
395
|
-
"focus-trap-el": wrapper.value,
|
|
396
|
-
"focus-start-el": "container",
|
|
397
|
-
onFocusoutPrevented,
|
|
398
|
-
onReleaseRequested: onCloseRequested
|
|
399
|
-
}, {
|
|
400
|
-
default: withCtx(() => [
|
|
401
|
-
createElementVNode(
|
|
402
|
-
"div",
|
|
403
|
-
{
|
|
404
|
-
class: normalizeClass(unref(ns).e("mask")),
|
|
405
|
-
onClick: _cache[0] || (_cache[0] = withModifiers(($event) => _ctx.hideOnClickModal && hide(), ["self"]))
|
|
406
|
-
},
|
|
407
|
-
null,
|
|
408
|
-
2
|
|
409
|
-
),
|
|
410
|
-
createCommentVNode(" CLOSE "),
|
|
411
|
-
createElementVNode(
|
|
412
|
-
"span",
|
|
413
|
-
{
|
|
414
|
-
class: normalizeClass([unref(ns).e("btn"), unref(ns).e("close")]),
|
|
415
|
-
onClick: hide
|
|
416
|
-
},
|
|
417
|
-
[
|
|
418
|
-
createVNode(unref(ElIcon), null, {
|
|
419
|
-
default: withCtx(() => [
|
|
420
|
-
createVNode(unref(Close))
|
|
421
|
-
]),
|
|
422
|
-
_: 1
|
|
423
|
-
})
|
|
424
|
-
],
|
|
425
|
-
2
|
|
426
|
-
),
|
|
427
|
-
createCommentVNode(" ARROW "),
|
|
428
|
-
!isSingle.value ? (openBlock(), createElementBlock(
|
|
429
|
-
Fragment,
|
|
430
|
-
{ key: 0 },
|
|
431
|
-
[
|
|
432
|
-
createElementVNode(
|
|
433
|
-
"span",
|
|
434
|
-
{
|
|
435
|
-
class: normalizeClass(arrowPrevKls.value),
|
|
436
|
-
onClick: prev
|
|
437
|
-
},
|
|
438
|
-
[
|
|
439
|
-
createVNode(unref(ElIcon), null, {
|
|
440
|
-
default: withCtx(() => [
|
|
441
|
-
createVNode(unref(ArrowLeft))
|
|
442
|
-
]),
|
|
443
|
-
_: 1
|
|
444
|
-
})
|
|
445
|
-
],
|
|
446
|
-
2
|
|
447
|
-
),
|
|
448
|
-
createElementVNode(
|
|
449
|
-
"span",
|
|
450
|
-
{
|
|
451
|
-
class: normalizeClass(arrowNextKls.value),
|
|
452
|
-
onClick: next
|
|
453
|
-
},
|
|
454
|
-
[
|
|
455
|
-
createVNode(unref(ElIcon), null, {
|
|
456
|
-
default: withCtx(() => [
|
|
457
|
-
createVNode(unref(ArrowRight))
|
|
458
|
-
]),
|
|
459
|
-
_: 1
|
|
460
|
-
})
|
|
461
|
-
],
|
|
462
|
-
2
|
|
463
|
-
)
|
|
464
|
-
],
|
|
465
|
-
64
|
|
466
|
-
)) : createCommentVNode("v-if", true),
|
|
467
|
-
_ctx.$slots.progress || _ctx.showProgress ? (openBlock(), createElementBlock(
|
|
468
|
-
"div",
|
|
469
|
-
{
|
|
470
|
-
key: 1,
|
|
471
|
-
class: normalizeClass([unref(ns).e("btn"), unref(ns).e("progress")])
|
|
472
|
-
},
|
|
473
|
-
[
|
|
474
|
-
renderSlot(_ctx.$slots, "progress", {
|
|
475
|
-
activeIndex: activeIndex.value,
|
|
476
|
-
total: _ctx.urlList.length
|
|
477
|
-
}, () => [
|
|
478
|
-
createTextVNode(
|
|
479
|
-
toDisplayString(progress.value),
|
|
480
|
-
1
|
|
481
|
-
)
|
|
482
|
-
])
|
|
483
|
-
],
|
|
484
|
-
2
|
|
485
|
-
)) : createCommentVNode("v-if", true),
|
|
486
|
-
createCommentVNode(" ACTIONS "),
|
|
487
|
-
createElementVNode(
|
|
488
|
-
"div",
|
|
489
|
-
{
|
|
490
|
-
class: normalizeClass([unref(ns).e("btn"), unref(ns).e("actions")])
|
|
491
|
-
},
|
|
492
|
-
[
|
|
493
|
-
createElementVNode(
|
|
494
|
-
"div",
|
|
495
|
-
{
|
|
496
|
-
class: normalizeClass(unref(ns).e("actions__inner"))
|
|
497
|
-
},
|
|
498
|
-
[
|
|
499
|
-
renderSlot(_ctx.$slots, "toolbar", {
|
|
500
|
-
actions: handleActions,
|
|
501
|
-
prev,
|
|
502
|
-
next,
|
|
503
|
-
reset: toggleMode,
|
|
504
|
-
activeIndex: activeIndex.value,
|
|
505
|
-
setActiveItem
|
|
506
|
-
}, () => [
|
|
507
|
-
createVNode(unref(ElIcon), {
|
|
508
|
-
onClick: _cache[1] || (_cache[1] = ($event) => handleActions("zoomOut"))
|
|
509
|
-
}, {
|
|
510
|
-
default: withCtx(() => [
|
|
511
|
-
createVNode(unref(ZoomOut))
|
|
512
|
-
]),
|
|
513
|
-
_: 1
|
|
514
|
-
}),
|
|
515
|
-
createVNode(unref(ElIcon), {
|
|
516
|
-
onClick: _cache[2] || (_cache[2] = ($event) => handleActions("zoomIn"))
|
|
517
|
-
}, {
|
|
518
|
-
default: withCtx(() => [
|
|
519
|
-
createVNode(unref(ZoomIn))
|
|
520
|
-
]),
|
|
521
|
-
_: 1
|
|
522
|
-
}),
|
|
523
|
-
createElementVNode(
|
|
524
|
-
"i",
|
|
525
|
-
{
|
|
526
|
-
class: normalizeClass(unref(ns).e("actions__divider"))
|
|
527
|
-
},
|
|
528
|
-
null,
|
|
529
|
-
2
|
|
530
|
-
),
|
|
531
|
-
createVNode(unref(ElIcon), { onClick: toggleMode }, {
|
|
532
|
-
default: withCtx(() => [
|
|
533
|
-
(openBlock(), createBlock(resolveDynamicComponent(mode.value.icon)))
|
|
534
|
-
]),
|
|
535
|
-
_: 1
|
|
536
|
-
}),
|
|
537
|
-
createElementVNode(
|
|
538
|
-
"i",
|
|
539
|
-
{
|
|
540
|
-
class: normalizeClass(unref(ns).e("actions__divider"))
|
|
541
|
-
},
|
|
542
|
-
null,
|
|
543
|
-
2
|
|
544
|
-
),
|
|
545
|
-
createVNode(unref(ElIcon), {
|
|
546
|
-
onClick: _cache[3] || (_cache[3] = ($event) => handleActions("anticlockwise"))
|
|
547
|
-
}, {
|
|
548
|
-
default: withCtx(() => [
|
|
549
|
-
createVNode(unref(RefreshLeft))
|
|
550
|
-
]),
|
|
551
|
-
_: 1
|
|
552
|
-
}),
|
|
553
|
-
createVNode(unref(ElIcon), {
|
|
554
|
-
onClick: _cache[4] || (_cache[4] = ($event) => handleActions("clockwise"))
|
|
555
|
-
}, {
|
|
556
|
-
default: withCtx(() => [
|
|
557
|
-
createVNode(unref(RefreshRight))
|
|
558
|
-
]),
|
|
559
|
-
_: 1
|
|
560
|
-
})
|
|
561
|
-
])
|
|
562
|
-
],
|
|
563
|
-
2
|
|
564
|
-
)
|
|
565
|
-
],
|
|
566
|
-
2
|
|
567
|
-
),
|
|
568
|
-
createCommentVNode(" CANVAS "),
|
|
569
|
-
createElementVNode(
|
|
570
|
-
"div",
|
|
571
|
-
{
|
|
572
|
-
class: normalizeClass(unref(ns).e("canvas"))
|
|
573
|
-
},
|
|
574
|
-
[
|
|
575
|
-
loadError.value && _ctx.$slots["viewer-error"] ? renderSlot(_ctx.$slots, "viewer-error", {
|
|
576
|
-
key: 0,
|
|
577
|
-
activeIndex: activeIndex.value,
|
|
578
|
-
src: currentImg.value
|
|
579
|
-
}) : (openBlock(), createElementBlock("img", {
|
|
580
|
-
ref_key: "imgRef",
|
|
581
|
-
ref: imgRef,
|
|
582
|
-
key: currentImg.value,
|
|
583
|
-
src: currentImg.value,
|
|
584
|
-
style: normalizeStyle(imgStyle.value),
|
|
585
|
-
class: normalizeClass(unref(ns).e("img")),
|
|
586
|
-
crossorigin: _ctx.crossorigin,
|
|
587
|
-
onLoad: handleImgLoad,
|
|
588
|
-
onError: handleImgError,
|
|
589
|
-
onMousedown: handleMouseDown,
|
|
590
|
-
onTouchstart: handleTouchStart
|
|
591
|
-
}, null, 46, _hoisted_1$1))
|
|
592
|
-
],
|
|
593
|
-
2
|
|
594
|
-
),
|
|
595
|
-
renderSlot(_ctx.$slots, "default")
|
|
596
|
-
]),
|
|
597
|
-
_: 3
|
|
598
|
-
}, 8, ["focus-trap-el"])
|
|
599
|
-
],
|
|
600
|
-
6
|
|
601
|
-
)
|
|
602
|
-
]),
|
|
603
|
-
_: 3
|
|
604
|
-
})
|
|
605
|
-
]),
|
|
606
|
-
_: 3
|
|
607
|
-
}, 8, ["disabled"]);
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
var ImageViewer = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/image-viewer/src/image-viewer.vue"]]);
|
|
612
|
-
|
|
613
|
-
const ElImageViewer = withInstall(ImageViewer);
|
|
614
|
-
|
|
615
|
-
const imageProps = buildProps({
|
|
616
|
-
hideOnClickModal: Boolean,
|
|
617
|
-
src: {
|
|
618
|
-
type: String,
|
|
619
|
-
default: ""
|
|
620
|
-
},
|
|
621
|
-
fit: {
|
|
622
|
-
type: String,
|
|
623
|
-
values: ["", "contain", "cover", "fill", "none", "scale-down"],
|
|
624
|
-
default: ""
|
|
625
|
-
},
|
|
626
|
-
loading: {
|
|
627
|
-
type: String,
|
|
628
|
-
values: ["eager", "lazy"]
|
|
629
|
-
},
|
|
630
|
-
lazy: Boolean,
|
|
631
|
-
scrollContainer: {
|
|
632
|
-
type: definePropType([String, Object])
|
|
633
|
-
},
|
|
634
|
-
previewSrcList: {
|
|
635
|
-
type: definePropType(Array),
|
|
636
|
-
default: () => mutable([])
|
|
637
|
-
},
|
|
638
|
-
previewTeleported: Boolean,
|
|
639
|
-
zIndex: {
|
|
640
|
-
type: Number
|
|
641
|
-
},
|
|
642
|
-
initialIndex: {
|
|
643
|
-
type: Number,
|
|
644
|
-
default: 0
|
|
645
|
-
},
|
|
646
|
-
infinite: {
|
|
647
|
-
type: Boolean,
|
|
648
|
-
default: true
|
|
649
|
-
},
|
|
650
|
-
closeOnPressEscape: {
|
|
651
|
-
type: Boolean,
|
|
652
|
-
default: true
|
|
653
|
-
},
|
|
654
|
-
zoomRate: {
|
|
655
|
-
type: Number,
|
|
656
|
-
default: 1.2
|
|
657
|
-
},
|
|
658
|
-
scale: {
|
|
659
|
-
type: Number,
|
|
660
|
-
default: 1
|
|
661
|
-
},
|
|
662
|
-
minScale: {
|
|
663
|
-
type: Number,
|
|
664
|
-
default: 0.2
|
|
665
|
-
},
|
|
666
|
-
maxScale: {
|
|
667
|
-
type: Number,
|
|
668
|
-
default: 7
|
|
669
|
-
},
|
|
670
|
-
showProgress: Boolean,
|
|
671
|
-
crossorigin: {
|
|
672
|
-
type: definePropType(String)
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
const imageEmits = {
|
|
676
|
-
load: (evt) => evt instanceof Event,
|
|
677
|
-
error: (evt) => evt instanceof Event,
|
|
678
|
-
switch: (val) => isNumber(val),
|
|
679
|
-
close: () => true,
|
|
680
|
-
show: () => true
|
|
681
|
-
};
|
|
682
|
-
|
|
683
|
-
const _hoisted_1 = ["src", "loading", "crossorigin"];
|
|
684
|
-
const _hoisted_2 = { key: 0 };
|
|
685
|
-
const _sfc_main = defineComponent({
|
|
686
|
-
...{
|
|
687
|
-
name: "ElImage",
|
|
688
|
-
inheritAttrs: false
|
|
689
|
-
},
|
|
690
|
-
__name: "image",
|
|
691
|
-
props: imageProps,
|
|
692
|
-
emits: imageEmits,
|
|
693
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
694
|
-
const props = __props;
|
|
695
|
-
const emit = __emit;
|
|
696
|
-
const { t } = useLocale();
|
|
697
|
-
const ns = useNamespace("image");
|
|
698
|
-
const rawAttrs = useAttrs();
|
|
699
|
-
const containerAttrs = computed(() => {
|
|
700
|
-
return fromPairs(
|
|
701
|
-
Object.entries(rawAttrs).filter(
|
|
702
|
-
([key]) => /^(data-|on[A-Z])/i.test(key) || ["id", "style"].includes(key)
|
|
703
|
-
)
|
|
704
|
-
);
|
|
705
|
-
});
|
|
706
|
-
const imgAttrs = useAttrs$1({
|
|
707
|
-
excludeListeners: true,
|
|
708
|
-
excludeKeys: computed(() => {
|
|
709
|
-
return Object.keys(containerAttrs.value);
|
|
710
|
-
})
|
|
711
|
-
});
|
|
712
|
-
const imageSrc = ref();
|
|
713
|
-
const hasLoadError = ref(false);
|
|
714
|
-
const isLoading = ref(true);
|
|
715
|
-
const showViewer = ref(false);
|
|
716
|
-
const container = ref();
|
|
717
|
-
const _scrollContainer = ref();
|
|
718
|
-
const supportLoading = isClient && "loading" in HTMLImageElement.prototype;
|
|
719
|
-
let stopScrollListener;
|
|
720
|
-
const imageKls = computed(() => [
|
|
721
|
-
ns.e("inner"),
|
|
722
|
-
preview.value && ns.e("preview"),
|
|
723
|
-
isLoading.value && ns.is("loading")
|
|
724
|
-
]);
|
|
725
|
-
const imageStyle = computed(() => {
|
|
726
|
-
const { fit } = props;
|
|
727
|
-
if (isClient && fit) {
|
|
728
|
-
return { objectFit: fit };
|
|
729
|
-
}
|
|
730
|
-
return {};
|
|
731
|
-
});
|
|
732
|
-
const preview = computed(() => {
|
|
733
|
-
const { previewSrcList } = props;
|
|
734
|
-
return isArray(previewSrcList) && previewSrcList.length > 0;
|
|
735
|
-
});
|
|
736
|
-
const imageIndex = computed(() => {
|
|
737
|
-
const { previewSrcList, initialIndex } = props;
|
|
738
|
-
let previewIndex = initialIndex;
|
|
739
|
-
if (initialIndex > previewSrcList.length - 1) {
|
|
740
|
-
previewIndex = 0;
|
|
741
|
-
}
|
|
742
|
-
return previewIndex;
|
|
743
|
-
});
|
|
744
|
-
const isManual = computed(() => {
|
|
745
|
-
if (props.loading === "eager")
|
|
746
|
-
return false;
|
|
747
|
-
return !supportLoading && props.loading === "lazy" || props.lazy;
|
|
748
|
-
});
|
|
749
|
-
const loadImage = () => {
|
|
750
|
-
if (!isClient)
|
|
751
|
-
return;
|
|
752
|
-
isLoading.value = true;
|
|
753
|
-
hasLoadError.value = false;
|
|
754
|
-
imageSrc.value = props.src;
|
|
755
|
-
};
|
|
756
|
-
function handleLoad(event) {
|
|
757
|
-
isLoading.value = false;
|
|
758
|
-
hasLoadError.value = false;
|
|
759
|
-
emit("load", event);
|
|
760
|
-
}
|
|
761
|
-
function handleError(event) {
|
|
762
|
-
isLoading.value = false;
|
|
763
|
-
hasLoadError.value = true;
|
|
764
|
-
emit("error", event);
|
|
765
|
-
}
|
|
766
|
-
function handleLazyLoad(isIntersecting) {
|
|
767
|
-
if (isIntersecting) {
|
|
768
|
-
loadImage();
|
|
769
|
-
removeLazyLoadListener();
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
const lazyLoadHandler = useThrottleFn(handleLazyLoad, 200, true);
|
|
773
|
-
async function addLazyLoadListener() {
|
|
774
|
-
var _a;
|
|
775
|
-
if (!isClient)
|
|
776
|
-
return;
|
|
777
|
-
await nextTick();
|
|
778
|
-
const { scrollContainer } = props;
|
|
779
|
-
if (isElement(scrollContainer)) {
|
|
780
|
-
_scrollContainer.value = scrollContainer;
|
|
781
|
-
} else if (isString(scrollContainer) && scrollContainer !== "") {
|
|
782
|
-
_scrollContainer.value = (_a = document.querySelector(scrollContainer)) != null ? _a : void 0;
|
|
783
|
-
} else if (container.value) {
|
|
784
|
-
const scrollContainer2 = getScrollContainer(container.value);
|
|
785
|
-
_scrollContainer.value = isWindow(scrollContainer2) ? void 0 : scrollContainer2;
|
|
786
|
-
}
|
|
787
|
-
const { stop } = useIntersectionObserver(
|
|
788
|
-
container,
|
|
789
|
-
([entry]) => {
|
|
790
|
-
lazyLoadHandler(entry.isIntersecting);
|
|
791
|
-
},
|
|
792
|
-
{ root: _scrollContainer }
|
|
793
|
-
);
|
|
794
|
-
stopScrollListener = stop;
|
|
795
|
-
}
|
|
796
|
-
function removeLazyLoadListener() {
|
|
797
|
-
if (!isClient || !lazyLoadHandler)
|
|
798
|
-
return;
|
|
799
|
-
stopScrollListener == null ? void 0 : stopScrollListener();
|
|
800
|
-
_scrollContainer.value = void 0;
|
|
801
|
-
stopScrollListener = void 0;
|
|
802
|
-
}
|
|
803
|
-
function clickHandler() {
|
|
804
|
-
if (!preview.value)
|
|
805
|
-
return;
|
|
806
|
-
showViewer.value = true;
|
|
807
|
-
emit("show");
|
|
808
|
-
}
|
|
809
|
-
function closeViewer() {
|
|
810
|
-
showViewer.value = false;
|
|
811
|
-
emit("close");
|
|
812
|
-
}
|
|
813
|
-
function switchViewer(val) {
|
|
814
|
-
emit("switch", val);
|
|
815
|
-
}
|
|
816
|
-
watch(
|
|
817
|
-
() => props.src,
|
|
818
|
-
() => {
|
|
819
|
-
if (isManual.value) {
|
|
820
|
-
isLoading.value = true;
|
|
821
|
-
hasLoadError.value = false;
|
|
822
|
-
removeLazyLoadListener();
|
|
823
|
-
addLazyLoadListener();
|
|
824
|
-
} else {
|
|
825
|
-
loadImage();
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
);
|
|
829
|
-
onMounted(() => {
|
|
830
|
-
if (isManual.value) {
|
|
831
|
-
addLazyLoadListener();
|
|
832
|
-
} else {
|
|
833
|
-
loadImage();
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
__expose({
|
|
837
|
-
showPreview: clickHandler
|
|
838
|
-
});
|
|
839
|
-
return (_ctx, _cache) => {
|
|
840
|
-
return openBlock(), createElementBlock(
|
|
841
|
-
"div",
|
|
842
|
-
mergeProps({
|
|
843
|
-
ref_key: "container",
|
|
844
|
-
ref: container
|
|
845
|
-
}, containerAttrs.value, {
|
|
846
|
-
class: [unref(ns).b(), _ctx.$attrs.class]
|
|
847
|
-
}),
|
|
848
|
-
[
|
|
849
|
-
hasLoadError.value ? renderSlot(_ctx.$slots, "error", { key: 0 }, () => [
|
|
850
|
-
createElementVNode(
|
|
851
|
-
"div",
|
|
852
|
-
{
|
|
853
|
-
class: normalizeClass(unref(ns).e("error"))
|
|
854
|
-
},
|
|
855
|
-
toDisplayString(unref(t)("el.image.error")),
|
|
856
|
-
3
|
|
857
|
-
)
|
|
858
|
-
]) : (openBlock(), createElementBlock(
|
|
859
|
-
Fragment,
|
|
860
|
-
{ key: 1 },
|
|
861
|
-
[
|
|
862
|
-
imageSrc.value !== void 0 ? (openBlock(), createElementBlock("img", mergeProps({ key: 0 }, unref(imgAttrs), {
|
|
863
|
-
src: imageSrc.value,
|
|
864
|
-
loading: _ctx.loading,
|
|
865
|
-
style: imageStyle.value,
|
|
866
|
-
class: imageKls.value,
|
|
867
|
-
crossorigin: _ctx.crossorigin,
|
|
868
|
-
onClick: clickHandler,
|
|
869
|
-
onLoad: handleLoad,
|
|
870
|
-
onError: handleError
|
|
871
|
-
}), null, 16, _hoisted_1)) : createCommentVNode("v-if", true),
|
|
872
|
-
isLoading.value ? (openBlock(), createElementBlock(
|
|
873
|
-
"div",
|
|
874
|
-
{
|
|
875
|
-
key: 1,
|
|
876
|
-
class: normalizeClass(unref(ns).e("wrapper"))
|
|
877
|
-
},
|
|
878
|
-
[
|
|
879
|
-
renderSlot(_ctx.$slots, "placeholder", {}, () => [
|
|
880
|
-
createElementVNode(
|
|
881
|
-
"div",
|
|
882
|
-
{
|
|
883
|
-
class: normalizeClass(unref(ns).e("placeholder"))
|
|
884
|
-
},
|
|
885
|
-
null,
|
|
886
|
-
2
|
|
887
|
-
)
|
|
888
|
-
])
|
|
889
|
-
],
|
|
890
|
-
2
|
|
891
|
-
)) : createCommentVNode("v-if", true)
|
|
892
|
-
],
|
|
893
|
-
64
|
|
894
|
-
)),
|
|
895
|
-
preview.value ? (openBlock(), createElementBlock(
|
|
896
|
-
Fragment,
|
|
897
|
-
{ key: 2 },
|
|
898
|
-
[
|
|
899
|
-
showViewer.value ? (openBlock(), createBlock(unref(ElImageViewer), {
|
|
900
|
-
key: 0,
|
|
901
|
-
"z-index": _ctx.zIndex,
|
|
902
|
-
"initial-index": imageIndex.value,
|
|
903
|
-
infinite: _ctx.infinite,
|
|
904
|
-
"zoom-rate": _ctx.zoomRate,
|
|
905
|
-
"min-scale": _ctx.minScale,
|
|
906
|
-
"max-scale": _ctx.maxScale,
|
|
907
|
-
"show-progress": _ctx.showProgress,
|
|
908
|
-
"url-list": _ctx.previewSrcList,
|
|
909
|
-
scale: _ctx.scale,
|
|
910
|
-
crossorigin: _ctx.crossorigin,
|
|
911
|
-
"hide-on-click-modal": _ctx.hideOnClickModal,
|
|
912
|
-
teleported: _ctx.previewTeleported,
|
|
913
|
-
"close-on-press-escape": _ctx.closeOnPressEscape,
|
|
914
|
-
onClose: closeViewer,
|
|
915
|
-
onSwitch: switchViewer
|
|
916
|
-
}, createSlots({
|
|
917
|
-
toolbar: withCtx((toolbar) => [
|
|
918
|
-
renderSlot(_ctx.$slots, "toolbar", normalizeProps(guardReactiveProps(toolbar)))
|
|
919
|
-
]),
|
|
920
|
-
default: withCtx(() => [
|
|
921
|
-
_ctx.$slots.viewer ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
922
|
-
renderSlot(_ctx.$slots, "viewer")
|
|
923
|
-
])) : createCommentVNode("v-if", true)
|
|
924
|
-
]),
|
|
925
|
-
_: 2
|
|
926
|
-
}, [
|
|
927
|
-
_ctx.$slots.progress ? {
|
|
928
|
-
name: "progress",
|
|
929
|
-
fn: withCtx((progress) => [
|
|
930
|
-
renderSlot(_ctx.$slots, "progress", normalizeProps(guardReactiveProps(progress)))
|
|
931
|
-
]),
|
|
932
|
-
key: "0"
|
|
933
|
-
} : void 0,
|
|
934
|
-
_ctx.$slots["viewer-error"] ? {
|
|
935
|
-
name: "viewer-error",
|
|
936
|
-
fn: withCtx((viewerError) => [
|
|
937
|
-
renderSlot(_ctx.$slots, "viewer-error", normalizeProps(guardReactiveProps(viewerError)))
|
|
938
|
-
]),
|
|
939
|
-
key: "1"
|
|
940
|
-
} : void 0
|
|
941
|
-
]), 1032, ["z-index", "initial-index", "infinite", "zoom-rate", "min-scale", "max-scale", "show-progress", "url-list", "scale", "crossorigin", "hide-on-click-modal", "teleported", "close-on-press-escape"])) : createCommentVNode("v-if", true)
|
|
942
|
-
],
|
|
943
|
-
64
|
|
944
|
-
)) : createCommentVNode("v-if", true)
|
|
945
|
-
],
|
|
946
|
-
16
|
|
947
|
-
);
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
|
-
});
|
|
951
|
-
var Image = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/image/src/image.vue"]]);
|
|
952
|
-
|
|
953
|
-
const ElImage = withInstall(Image);
|
|
954
|
-
|
|
955
|
-
export { ElImage as E };
|