@v-c/image 1.0.9 → 1.0.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/Image.js +21 -15
- package/dist/Preview/CloseBtn.d.ts +3 -0
- package/dist/Preview/CloseBtn.js +19 -7
- package/dist/Preview/Footer.js +26 -48
- package/dist/Preview/PrevNext.js +9 -12
- package/dist/Preview/index.d.ts +3 -1
- package/dist/Preview/index.js +48 -29
- package/dist/PreviewGroup.js +7 -5
- package/dist/common.js +3 -1
- package/dist/context.js +2 -0
- package/dist/getFixScaleEleTransPosition.js +14 -0
- package/dist/hooks/useImageTransform.js +16 -4
- package/dist/hooks/useMouseEvent.js +5 -2
- package/dist/hooks/usePreviewItems.js +5 -0
- package/dist/hooks/useRegisterImage.js +2 -0
- package/dist/hooks/useStatus.js +2 -0
- package/dist/hooks/useTouchEvent.js +6 -2
- package/dist/index.js +7 -6
- package/dist/previewConfig.js +6 -2
- package/dist/util.js +2 -0
- package/package.json +1 -1
- package/dist/util/dist/Dom/canUseDom.js +0 -4
- package/dist/util/dist/Dom/findDOMNode.js +0 -20
- package/dist/util/dist/Dom/focus.js +0 -129
- package/dist/util/dist/Dom/isVisible.js +0 -16
- package/dist/util/dist/KeyCode.js +0 -81
- package/dist/util/dist/hooks/useId.js +0 -12
- package/dist/util/dist/hooks/useMergedState.js +0 -24
- package/dist/util/dist/isEqual.js +0 -27
- package/dist/util/dist/omit.js +0 -8
- package/dist/util/dist/pickAttrs.js +0 -39
- package/dist/util/dist/props-util/index.js +0 -32
- package/dist/util/dist/raf.js +0 -36
- package/dist/util/dist/type.js +0 -2
- package/dist/util/dist/utils/transition.js +0 -21
- package/dist/util/dist/warning.js +0 -37
package/dist/Image.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { useMergedState } from "./util/dist/hooks/useMergedState.js";
|
|
2
|
-
import { pickAttrs } from "./util/dist/pickAttrs.js";
|
|
3
|
-
import { getAttrStyleAndClass, getStylePxValue } from "./util/dist/props-util/index.js";
|
|
4
1
|
import { COMMON_PROPS } from "./common.js";
|
|
5
2
|
import { usePreviewGroupContext } from "./context.js";
|
|
6
3
|
import useRegisterImage from "./hooks/useRegisterImage.js";
|
|
7
4
|
import useStatus from "./hooks/useStatus.js";
|
|
8
|
-
import
|
|
5
|
+
import Preview from "./Preview/index.js";
|
|
9
6
|
import { Fragment, computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef } from "vue";
|
|
10
|
-
import { clsx } from "@v-c/util";
|
|
11
|
-
|
|
7
|
+
import { clsx, omit } from "@v-c/util";
|
|
8
|
+
import useMergedState from "@v-c/util/dist/hooks/useMergedState";
|
|
9
|
+
import pickAttrs from "@v-c/util/dist/pickAttrs";
|
|
10
|
+
import { getAttrStyleAndClass, getStylePxValue } from "@v-c/util/dist/props-util";
|
|
11
|
+
//#region src/Image.tsx
|
|
12
|
+
var Image = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
|
|
12
13
|
const groupContext = usePreviewGroupContext();
|
|
13
14
|
const prefixCls = computed(() => props.prefixCls ?? "vc-image");
|
|
14
15
|
const previewPrefixCls = computed(() => props.previewPrefixCls ?? `${prefixCls.value}-preview`);
|
|
@@ -41,7 +42,10 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
|
|
|
41
42
|
const imgCommonProps = computed(() => {
|
|
42
43
|
const obj = {};
|
|
43
44
|
COMMON_PROPS.forEach((prop) => {
|
|
44
|
-
|
|
45
|
+
const fromProps = props[prop];
|
|
46
|
+
const fromAttrs = attrs[prop];
|
|
47
|
+
const val = fromProps !== void 0 ? fromProps : fromAttrs;
|
|
48
|
+
if (val !== void 0) obj[prop] = val;
|
|
45
49
|
});
|
|
46
50
|
return obj;
|
|
47
51
|
});
|
|
@@ -71,7 +75,7 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
|
|
|
71
75
|
};
|
|
72
76
|
const onPreviewKeyDown = (event) => {
|
|
73
77
|
props.onKeydown?.(event);
|
|
74
|
-
if (!canPreview) return;
|
|
78
|
+
if (!canPreview.value) return;
|
|
75
79
|
if (event.key === "Enter" || event.key === " ") {
|
|
76
80
|
event.preventDefault();
|
|
77
81
|
const rect = event.target.getBoundingClientRect();
|
|
@@ -90,6 +94,7 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
|
|
|
90
94
|
return () => {
|
|
91
95
|
const { width, height } = props;
|
|
92
96
|
const { className, style: attrStyle, restAttrs } = getAttrStyleAndClass(attrs);
|
|
97
|
+
const rootAttrs = pickAttrs(omit(restAttrs, COMMON_PROPS), false);
|
|
93
98
|
const coverPlacement = typeof cover.value === "object" && cover.value && cover.value.placement ? cover.value.placement || "center" : "center";
|
|
94
99
|
const coverNode = slots.cover?.() || (typeof cover.value === "object" && cover.value && cover.value.coverNode ? cover.value.coverNode : cover.value);
|
|
95
100
|
const imgStyle = [
|
|
@@ -111,12 +116,12 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
|
|
|
111
116
|
...info
|
|
112
117
|
}) : mergedPreviewConfig.value.actionsRender;
|
|
113
118
|
const { src: _previewSrc, open: _previewOpen, onOpenChange: _onPreviewOpenChange, cover: _cover, rootClassName: _previewRootCls, ...restPreviewProps } = mergedPreviewConfig.value;
|
|
114
|
-
return createVNode(Fragment, null, [createVNode("div", mergeProps(
|
|
119
|
+
return createVNode(Fragment, null, [createVNode("div", mergeProps(rootAttrs, {
|
|
115
120
|
"class": rootCls,
|
|
116
121
|
"onClick": canPreview.value ? onPreview : onInternalClick,
|
|
117
|
-
"role": canPreview ? "button" : restAttrs.role,
|
|
118
|
-
"tabindex": canPreview && restAttrs.tabIndex == null ? 0 : restAttrs.tabIndex,
|
|
119
|
-
"aria-label": canPreview ? restAttrs["aria-label"] ??
|
|
122
|
+
"role": canPreview.value ? "button" : restAttrs.role,
|
|
123
|
+
"tabindex": canPreview.value && restAttrs.tabIndex == null ? 0 : restAttrs.tabIndex,
|
|
124
|
+
"aria-label": canPreview.value ? restAttrs["aria-label"] ?? imgCommonProps.value.alt : restAttrs["aria-label"],
|
|
120
125
|
"onKeydown": onPreviewKeyDown,
|
|
121
126
|
"style": rootStyle
|
|
122
127
|
}), [
|
|
@@ -138,14 +143,14 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
|
|
|
138
143
|
"class": clsx(`${prefixCls.value}-cover`, props.classNames?.cover, `${prefixCls.value}-cover-${coverPlacement}`),
|
|
139
144
|
"style": props.styles?.cover
|
|
140
145
|
}, [coverNode])
|
|
141
|
-
]), !groupContext && canPreview.value && createVNode(
|
|
146
|
+
]), !groupContext && canPreview.value && createVNode(Preview, mergeProps({
|
|
142
147
|
"aria-hidden": !isShowPreview.value,
|
|
143
148
|
"open": isShowPreview.value,
|
|
144
149
|
"prefixCls": previewPrefixCls.value,
|
|
145
150
|
"onClose": onPreviewClose,
|
|
146
151
|
"mousePosition": mousePosition.value,
|
|
147
152
|
"src": src.value,
|
|
148
|
-
"alt":
|
|
153
|
+
"alt": imgCommonProps.value.alt,
|
|
149
154
|
"imageInfo": {
|
|
150
155
|
width: props.width,
|
|
151
156
|
height: props.height
|
|
@@ -253,4 +258,5 @@ var Image_default = /* @__PURE__ */ defineComponent((props, { attrs, slots }) =>
|
|
|
253
258
|
name: "Image",
|
|
254
259
|
inheritAttrs: false
|
|
255
260
|
});
|
|
256
|
-
|
|
261
|
+
//#endregion
|
|
262
|
+
export { Image as default };
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { VueNode } from '@v-c/util/dist/type';
|
|
2
|
+
import { CSSProperties } from 'vue';
|
|
2
3
|
export interface CloseBtnProps {
|
|
3
4
|
prefixCls: string;
|
|
4
5
|
icon?: VueNode;
|
|
5
6
|
onClick: (e: MouseEvent) => void;
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: CSSProperties;
|
|
6
9
|
}
|
|
7
10
|
declare const CloseBtn: import('vue').DefineSetupFnComponent<CloseBtnProps, {}, {}, CloseBtnProps & {}, import('vue').PublicProps>;
|
|
8
11
|
export default CloseBtn;
|
package/dist/Preview/CloseBtn.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { createVNode, defineComponent } from "vue";
|
|
2
|
-
|
|
2
|
+
import { clsx } from "@v-c/util";
|
|
3
|
+
//#region src/Preview/CloseBtn.tsx
|
|
4
|
+
var CloseBtn = /* @__PURE__ */ defineComponent((props) => {
|
|
3
5
|
return () => {
|
|
4
|
-
const { prefixCls, icon, onClick } = props;
|
|
6
|
+
const { prefixCls, icon, onClick, className, style } = props;
|
|
5
7
|
return createVNode("button", {
|
|
6
|
-
"class": `${prefixCls}-close`,
|
|
8
|
+
"class": clsx(`${prefixCls}-close`, className),
|
|
9
|
+
"style": style,
|
|
7
10
|
"type": "button",
|
|
8
11
|
"onClick": onClick
|
|
9
12
|
}, [icon]);
|
|
@@ -12,8 +15,7 @@ var CloseBtn_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
12
15
|
props: {
|
|
13
16
|
prefixCls: {
|
|
14
17
|
type: String,
|
|
15
|
-
required: true
|
|
16
|
-
default: void 0
|
|
18
|
+
required: true
|
|
17
19
|
},
|
|
18
20
|
icon: {
|
|
19
21
|
type: [
|
|
@@ -30,10 +32,20 @@ var CloseBtn_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
30
32
|
},
|
|
31
33
|
onClick: {
|
|
32
34
|
type: Function,
|
|
33
|
-
required: true
|
|
35
|
+
required: true
|
|
36
|
+
},
|
|
37
|
+
className: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: false,
|
|
40
|
+
default: void 0
|
|
41
|
+
},
|
|
42
|
+
style: {
|
|
43
|
+
type: Object,
|
|
44
|
+
required: false,
|
|
34
45
|
default: void 0
|
|
35
46
|
}
|
|
36
47
|
},
|
|
37
48
|
name: "ImagePreviewCloseBtn"
|
|
38
49
|
});
|
|
39
|
-
|
|
50
|
+
//#endregion
|
|
51
|
+
export { CloseBtn as default };
|
package/dist/Preview/Footer.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createVNode, defineComponent } from "vue";
|
|
2
2
|
import { clsx } from "@v-c/util";
|
|
3
|
-
|
|
3
|
+
//#region src/Preview/Footer.tsx
|
|
4
|
+
var Footer = /* @__PURE__ */ defineComponent((props) => {
|
|
4
5
|
const renderOperation = ({ type, disabled, onClick, icon }) => {
|
|
5
6
|
const actionCls = `${props.prefixCls}-actions-action`;
|
|
6
7
|
return createVNode("button", {
|
|
@@ -108,13 +109,11 @@ var Footer_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
108
109
|
props: {
|
|
109
110
|
prefixCls: {
|
|
110
111
|
type: String,
|
|
111
|
-
required: true
|
|
112
|
-
default: void 0
|
|
112
|
+
required: true
|
|
113
113
|
},
|
|
114
114
|
showProgress: {
|
|
115
115
|
type: Boolean,
|
|
116
|
-
required: true
|
|
117
|
-
default: void 0
|
|
116
|
+
required: true
|
|
118
117
|
},
|
|
119
118
|
countRender: {
|
|
120
119
|
type: Function,
|
|
@@ -128,104 +127,83 @@ var Footer_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
128
127
|
},
|
|
129
128
|
current: {
|
|
130
129
|
type: Number,
|
|
131
|
-
required: true
|
|
132
|
-
default: void 0
|
|
130
|
+
required: true
|
|
133
131
|
},
|
|
134
132
|
count: {
|
|
135
133
|
type: Number,
|
|
136
|
-
required: true
|
|
137
|
-
default: void 0
|
|
134
|
+
required: true
|
|
138
135
|
},
|
|
139
136
|
showSwitch: {
|
|
140
137
|
type: Boolean,
|
|
141
|
-
required: true
|
|
142
|
-
default: void 0
|
|
143
|
-
},
|
|
144
|
-
icons: {
|
|
145
|
-
required: true,
|
|
146
|
-
default: void 0
|
|
138
|
+
required: true
|
|
147
139
|
},
|
|
140
|
+
icons: { required: true },
|
|
148
141
|
scale: {
|
|
149
142
|
type: Number,
|
|
150
|
-
required: true
|
|
151
|
-
default: void 0
|
|
143
|
+
required: true
|
|
152
144
|
},
|
|
153
145
|
minScale: {
|
|
154
146
|
type: Number,
|
|
155
|
-
required: true
|
|
156
|
-
default: void 0
|
|
147
|
+
required: true
|
|
157
148
|
},
|
|
158
149
|
maxScale: {
|
|
159
150
|
type: Number,
|
|
160
|
-
required: true
|
|
161
|
-
default: void 0
|
|
151
|
+
required: true
|
|
162
152
|
},
|
|
163
153
|
image: {
|
|
164
154
|
type: Object,
|
|
165
|
-
required: true
|
|
166
|
-
default: void 0
|
|
155
|
+
required: true
|
|
167
156
|
},
|
|
168
157
|
transform: {
|
|
169
158
|
type: Object,
|
|
170
|
-
required: true
|
|
171
|
-
default: void 0
|
|
159
|
+
required: true
|
|
172
160
|
},
|
|
173
161
|
classNames: {
|
|
174
162
|
type: Object,
|
|
175
|
-
required: true
|
|
176
|
-
default: void 0
|
|
163
|
+
required: true
|
|
177
164
|
},
|
|
178
165
|
styles: {
|
|
179
166
|
type: Object,
|
|
180
|
-
required: true
|
|
181
|
-
default: void 0
|
|
167
|
+
required: true
|
|
182
168
|
},
|
|
183
169
|
onActive: {
|
|
184
170
|
type: Function,
|
|
185
|
-
required: true
|
|
186
|
-
default: void 0
|
|
171
|
+
required: true
|
|
187
172
|
},
|
|
188
173
|
onFlipY: {
|
|
189
174
|
type: Function,
|
|
190
|
-
required: true
|
|
191
|
-
default: void 0
|
|
175
|
+
required: true
|
|
192
176
|
},
|
|
193
177
|
onFlipX: {
|
|
194
178
|
type: Function,
|
|
195
|
-
required: true
|
|
196
|
-
default: void 0
|
|
179
|
+
required: true
|
|
197
180
|
},
|
|
198
181
|
onRotateLeft: {
|
|
199
182
|
type: Function,
|
|
200
|
-
required: true
|
|
201
|
-
default: void 0
|
|
183
|
+
required: true
|
|
202
184
|
},
|
|
203
185
|
onRotateRight: {
|
|
204
186
|
type: Function,
|
|
205
|
-
required: true
|
|
206
|
-
default: void 0
|
|
187
|
+
required: true
|
|
207
188
|
},
|
|
208
189
|
onZoomOut: {
|
|
209
190
|
type: Function,
|
|
210
|
-
required: true
|
|
211
|
-
default: void 0
|
|
191
|
+
required: true
|
|
212
192
|
},
|
|
213
193
|
onZoomIn: {
|
|
214
194
|
type: Function,
|
|
215
|
-
required: true
|
|
216
|
-
default: void 0
|
|
195
|
+
required: true
|
|
217
196
|
},
|
|
218
197
|
onClose: {
|
|
219
198
|
type: Function,
|
|
220
|
-
required: true
|
|
221
|
-
default: void 0
|
|
199
|
+
required: true
|
|
222
200
|
},
|
|
223
201
|
onReset: {
|
|
224
202
|
type: Function,
|
|
225
|
-
required: true
|
|
226
|
-
default: void 0
|
|
203
|
+
required: true
|
|
227
204
|
}
|
|
228
205
|
},
|
|
229
206
|
name: "ImagePreviewFooter"
|
|
230
207
|
});
|
|
231
|
-
|
|
208
|
+
//#endregion
|
|
209
|
+
export { Footer as default };
|
package/dist/Preview/PrevNext.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment, createVNode, defineComponent } from "vue";
|
|
2
2
|
import { clsx } from "@v-c/util";
|
|
3
|
-
|
|
3
|
+
//#region src/Preview/PrevNext.tsx
|
|
4
|
+
var PrevNext = /* @__PURE__ */ defineComponent((props) => {
|
|
4
5
|
return () => {
|
|
5
6
|
const { prefixCls, onActive, current, count, icons } = props;
|
|
6
7
|
const switchCls = `${prefixCls}-switch`;
|
|
@@ -26,30 +27,26 @@ var PrevNext_default = /* @__PURE__ */ defineComponent((props) => {
|
|
|
26
27
|
props: {
|
|
27
28
|
prefixCls: {
|
|
28
29
|
type: String,
|
|
29
|
-
required: true
|
|
30
|
-
default: void 0
|
|
30
|
+
required: true
|
|
31
31
|
},
|
|
32
32
|
onActive: {
|
|
33
33
|
type: Function,
|
|
34
|
-
required: true
|
|
35
|
-
default: void 0
|
|
34
|
+
required: true
|
|
36
35
|
},
|
|
37
36
|
current: {
|
|
38
37
|
type: Number,
|
|
39
|
-
required: true
|
|
40
|
-
default: void 0
|
|
38
|
+
required: true
|
|
41
39
|
},
|
|
42
40
|
count: {
|
|
43
41
|
type: Number,
|
|
44
|
-
required: true
|
|
45
|
-
default: void 0
|
|
42
|
+
required: true
|
|
46
43
|
},
|
|
47
44
|
icons: {
|
|
48
45
|
type: Object,
|
|
49
|
-
required: true
|
|
50
|
-
default: void 0
|
|
46
|
+
required: true
|
|
51
47
|
}
|
|
52
48
|
},
|
|
53
49
|
name: "ImagePreviewPrevNext"
|
|
54
50
|
});
|
|
55
|
-
|
|
51
|
+
//#endregion
|
|
52
|
+
export { PrevNext as default };
|
package/dist/Preview/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CSSProperties } from 'vue';
|
|
|
4
4
|
import { TransformAction, TransformType } from '../hooks/useImageTransform';
|
|
5
5
|
import { ImgInfo } from '../Image';
|
|
6
6
|
import { FooterSemanticName } from './Footer';
|
|
7
|
-
export type PreviewSemanticName = 'root' | 'mask' | 'body' | FooterSemanticName;
|
|
7
|
+
export type PreviewSemanticName = 'root' | 'mask' | 'body' | 'close' | FooterSemanticName;
|
|
8
8
|
export interface OperationIcons {
|
|
9
9
|
rotateLeft?: VueNode;
|
|
10
10
|
rotateRight?: VueNode;
|
|
@@ -60,7 +60,9 @@ export interface InternalPreviewConfig {
|
|
|
60
60
|
open?: boolean;
|
|
61
61
|
getContainer?: PortalProps['getContainer'];
|
|
62
62
|
zIndex?: number;
|
|
63
|
+
maskClosable?: boolean;
|
|
63
64
|
afterOpenChange?: (open: boolean) => void;
|
|
65
|
+
focusTrap?: boolean;
|
|
64
66
|
movable?: boolean;
|
|
65
67
|
icons?: OperationIcons;
|
|
66
68
|
closeIcon?: VueNode | boolean | null;
|
package/dist/Preview/index.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { usePreviewGroupContext } from "../context.js";
|
|
2
2
|
import useStatus from "../hooks/useStatus.js";
|
|
3
|
-
import { canUseDom } from "../util/dist/Dom/canUseDom.js";
|
|
4
|
-
import { useLockFocus } from "../util/dist/Dom/focus.js";
|
|
5
|
-
import { KeyCodeStr } from "../util/dist/KeyCode.js";
|
|
6
|
-
import { getTransitionProps } from "../util/dist/utils/transition.js";
|
|
7
3
|
import useImageTransform from "../hooks/useImageTransform.js";
|
|
8
|
-
import
|
|
4
|
+
import "../previewConfig.js";
|
|
9
5
|
import useMouseEvent from "../hooks/useMouseEvent.js";
|
|
10
6
|
import useTouchEvent from "../hooks/useTouchEvent.js";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
7
|
+
import CloseBtn from "./CloseBtn.js";
|
|
8
|
+
import Footer from "./Footer.js";
|
|
9
|
+
import PrevNext from "./PrevNext.js";
|
|
14
10
|
import { Transition, computed, createVNode, defineComponent, mergeDefaults, mergeProps, nextTick, shallowRef, watch, watchEffect } from "vue";
|
|
15
11
|
import { clsx } from "@v-c/util";
|
|
16
12
|
import Portal from "@v-c/portal";
|
|
17
|
-
|
|
13
|
+
import canUseDom from "@v-c/util/dist/Dom/canUseDom";
|
|
14
|
+
import { useLockFocus } from "@v-c/util/dist/Dom/focus";
|
|
15
|
+
import { KeyCodeStr } from "@v-c/util/dist/KeyCode";
|
|
16
|
+
import { getTransitionProps } from "@v-c/util/dist/utils/transition";
|
|
17
|
+
//#region src/Preview/index.tsx
|
|
18
|
+
var Preview = /* @__PURE__ */ defineComponent((props, { attrs, slots }) => {
|
|
18
19
|
const imgEl = shallowRef();
|
|
19
20
|
const wrapperRef = shallowRef(null);
|
|
21
|
+
const triggerRef = shallowRef(null);
|
|
20
22
|
const groupContext = usePreviewGroupContext();
|
|
21
23
|
const showLeftOrRightSwitches = computed(() => !!groupContext && (props.count ?? 1) > 1);
|
|
22
24
|
const showOperationsProgress = computed(() => !!groupContext && (props.count ?? 1) >= 1);
|
|
@@ -33,6 +35,9 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
33
35
|
watch(() => props.open, (open) => {
|
|
34
36
|
if (!open) resetTransform("close");
|
|
35
37
|
});
|
|
38
|
+
watch(() => props.open, (open) => {
|
|
39
|
+
if (open && canUseDom()) triggerRef.value = document.activeElement;
|
|
40
|
+
});
|
|
36
41
|
const onDoubleClick = (event) => {
|
|
37
42
|
if (!props.open) return;
|
|
38
43
|
if (transform.value.scale !== 1) updateTransform({
|
|
@@ -76,10 +81,6 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
76
81
|
const onKeyDown = (event) => {
|
|
77
82
|
if (!props.open) return;
|
|
78
83
|
const { key } = event;
|
|
79
|
-
if (key === KeyCodeStr.Escape) {
|
|
80
|
-
props.onClose?.();
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
84
|
if (showLeftOrRightSwitches.value) {
|
|
84
85
|
if (key === KeyCodeStr.ArrowLeft) onActive(-1);
|
|
85
86
|
else if (key === KeyCodeStr.ArrowRight) onActive(1);
|
|
@@ -104,6 +105,8 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
104
105
|
if (!nextVisible) {
|
|
105
106
|
animatedVisible.value = false;
|
|
106
107
|
portalRender.value = false;
|
|
108
|
+
triggerRef.value?.focus?.();
|
|
109
|
+
triggerRef.value = null;
|
|
107
110
|
}
|
|
108
111
|
props.afterOpenChange?.(nextVisible);
|
|
109
112
|
};
|
|
@@ -114,14 +117,16 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
114
117
|
src: computed(() => props.src),
|
|
115
118
|
fallback: computed(() => props.fallback)
|
|
116
119
|
});
|
|
117
|
-
|
|
120
|
+
const focusTrap = computed(() => props.focusTrap ?? true);
|
|
121
|
+
useLockFocus(computed(() => !!(focusTrap.value && props.open && portalRender.value)), () => wrapperRef.value);
|
|
118
122
|
return () => {
|
|
119
|
-
const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender = slots?.actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {}, movable = true } = props;
|
|
123
|
+
const { prefixCls, rootClassName, src, alt, imageInfo, open, closeIcon, getContainer, current = 0, count = 1, countRender, motionName = "fade", imageRender, imgCommonProps, actionsRender = slots?.actionsRender, classNames = {}, styles = {}, mousePosition, zIndex, icons = {}, movable = true, maskClosable = true } = props;
|
|
124
|
+
const mergedAlt = alt ?? imgCommonProps?.alt;
|
|
120
125
|
const bodyStyle = { ...styles.body ?? {} };
|
|
121
126
|
if (mousePosition) bodyStyle.transformOrigin = `${mousePosition.x}px ${mousePosition.y}px`;
|
|
122
127
|
const image = {
|
|
123
128
|
url: src || "",
|
|
124
|
-
alt:
|
|
129
|
+
alt: mergedAlt || "",
|
|
125
130
|
...imageInfo
|
|
126
131
|
};
|
|
127
132
|
const imgNode = createVNode("img", mergeProps(imgCommonProps, {
|
|
@@ -133,7 +138,7 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
133
138
|
"width": props.width,
|
|
134
139
|
"height": props.height,
|
|
135
140
|
"class": `${prefixCls}-img`,
|
|
136
|
-
"alt":
|
|
141
|
+
"alt": mergedAlt,
|
|
137
142
|
"onLoad": srcAndOnload.value.onLoad,
|
|
138
143
|
"style": {
|
|
139
144
|
transform: `translate3d(${transform.value.x}px, ${transform.value.y}px, 0) scale3d(${transform.value.flipX ? "-" : ""}${transform.value.scale}, ${transform.value.flipY ? "-" : ""}${transform.value.scale}, 1) rotate(${transform.value.rotate}deg)`,
|
|
@@ -160,7 +165,10 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
160
165
|
return createVNode(Portal, {
|
|
161
166
|
"open": open || animatedVisible.value || portalRender.value,
|
|
162
167
|
"getContainer": getContainer,
|
|
163
|
-
"autoLock": open || animatedVisible.value
|
|
168
|
+
"autoLock": open || animatedVisible.value,
|
|
169
|
+
"onEsc": ({ top }) => {
|
|
170
|
+
if (top) props.onClose?.();
|
|
171
|
+
}
|
|
164
172
|
}, { default: () => [createVNode(Transition, mergeProps(transitionProps, {
|
|
165
173
|
"onAfterEnter": () => onVisibleChanged(true),
|
|
166
174
|
"onAfterLeave": () => onVisibleChanged(false)
|
|
@@ -172,13 +180,13 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
172
180
|
"style": mergedRootStyle,
|
|
173
181
|
"role": "dialog",
|
|
174
182
|
"aria-modal": "true",
|
|
175
|
-
"aria-label":
|
|
183
|
+
"aria-label": mergedAlt,
|
|
176
184
|
"tabindex": -1
|
|
177
185
|
}, [
|
|
178
186
|
createVNode("div", {
|
|
179
187
|
"class": clsx(`${prefixCls}-mask`, classNames.mask),
|
|
180
188
|
"style": styles.mask,
|
|
181
|
-
"onClick": () => props.onClose?.()
|
|
189
|
+
"onClick": maskClosable ? () => props.onClose?.() : void 0
|
|
182
190
|
}, null),
|
|
183
191
|
createVNode("div", {
|
|
184
192
|
"class": clsx(`${prefixCls}-body`, classNames.body),
|
|
@@ -188,19 +196,21 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
188
196
|
image,
|
|
189
197
|
...groupContext ? { current } : {}
|
|
190
198
|
}) : imgNode]),
|
|
191
|
-
closeIcon !== false && closeIcon !== null && createVNode(
|
|
199
|
+
closeIcon !== false && closeIcon !== null && createVNode(CloseBtn, {
|
|
192
200
|
"prefixCls": prefixCls,
|
|
193
201
|
"icon": closeIcon === true ? icons.close : closeIcon || icons.close,
|
|
194
|
-
"onClick": () => props.onClose?.()
|
|
202
|
+
"onClick": () => props.onClose?.(),
|
|
203
|
+
"className": classNames.close,
|
|
204
|
+
"style": styles.close
|
|
195
205
|
}, null),
|
|
196
|
-
showLeftOrRightSwitches.value && createVNode(
|
|
206
|
+
showLeftOrRightSwitches.value && createVNode(PrevNext, {
|
|
197
207
|
"prefixCls": prefixCls,
|
|
198
208
|
"current": current,
|
|
199
209
|
"count": count,
|
|
200
210
|
"icons": icons,
|
|
201
211
|
"onActive": onActive
|
|
202
212
|
}, null),
|
|
203
|
-
createVNode(
|
|
213
|
+
createVNode(Footer, {
|
|
204
214
|
"prefixCls": prefixCls,
|
|
205
215
|
"showProgress": showOperationsProgress.value,
|
|
206
216
|
"current": current,
|
|
@@ -233,8 +243,7 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
233
243
|
props: /* @__PURE__ */ mergeDefaults({
|
|
234
244
|
prefixCls: {
|
|
235
245
|
type: String,
|
|
236
|
-
required: true
|
|
237
|
-
default: void 0
|
|
246
|
+
required: true
|
|
238
247
|
},
|
|
239
248
|
classNames: {
|
|
240
249
|
type: Object,
|
|
@@ -293,8 +302,7 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
293
302
|
},
|
|
294
303
|
mousePosition: {
|
|
295
304
|
type: [null, Object],
|
|
296
|
-
required: true
|
|
297
|
-
default: void 0
|
|
305
|
+
required: true
|
|
298
306
|
},
|
|
299
307
|
rootClassName: {
|
|
300
308
|
type: String,
|
|
@@ -345,11 +353,21 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
345
353
|
required: false,
|
|
346
354
|
default: void 0
|
|
347
355
|
},
|
|
356
|
+
maskClosable: {
|
|
357
|
+
type: Boolean,
|
|
358
|
+
required: false,
|
|
359
|
+
default: void 0
|
|
360
|
+
},
|
|
348
361
|
afterOpenChange: {
|
|
349
362
|
type: Function,
|
|
350
363
|
required: false,
|
|
351
364
|
default: void 0
|
|
352
365
|
},
|
|
366
|
+
focusTrap: {
|
|
367
|
+
type: Boolean,
|
|
368
|
+
required: false,
|
|
369
|
+
default: void 0
|
|
370
|
+
},
|
|
353
371
|
movable: {
|
|
354
372
|
type: Boolean,
|
|
355
373
|
required: false,
|
|
@@ -406,4 +424,5 @@ var Preview_default = /* @__PURE__ */ defineComponent((props, { attrs, slots })
|
|
|
406
424
|
name: "ImagePreview",
|
|
407
425
|
inheritAttrs: false
|
|
408
426
|
});
|
|
409
|
-
|
|
427
|
+
//#endregion
|
|
428
|
+
export { Preview as default };
|
package/dist/PreviewGroup.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { useMergedState } from "./util/dist/hooks/useMergedState.js";
|
|
2
1
|
import { usePreviewGroupProvider } from "./context.js";
|
|
3
|
-
import
|
|
2
|
+
import Preview from "./Preview/index.js";
|
|
4
3
|
import usePreviewItems from "./hooks/usePreviewItems.js";
|
|
5
4
|
import { Fragment, computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef, toRef, watch } from "vue";
|
|
6
|
-
|
|
5
|
+
import useMergedState from "@v-c/util/dist/hooks/useMergedState";
|
|
6
|
+
//#region src/PreviewGroup.tsx
|
|
7
|
+
var PreviewGroup = /* @__PURE__ */ defineComponent((props, { slots, emit }) => {
|
|
7
8
|
const mergedPreviewConfig = computed(() => {
|
|
8
9
|
if (props.preview && typeof props.preview === "object") return props.preview;
|
|
9
10
|
return {};
|
|
@@ -54,7 +55,7 @@ var PreviewGroup_default = /* @__PURE__ */ defineComponent((props, { slots, emit
|
|
|
54
55
|
const { src, ...imgCommonProps } = itemsList[current.value]?.data || {};
|
|
55
56
|
const countRender = slots.countRender ? (currentNum, total) => slots.countRender?.(currentNum, total) : mergedPreviewConfig.value.countRender;
|
|
56
57
|
const { open: _open, current: _current, onOpenChange: _onOpenChange, onChange: _onChange, ...restPreviewConfig } = mergedPreviewConfig.value;
|
|
57
|
-
return createVNode(Fragment, null, [slots.default?.(), createVNode(
|
|
58
|
+
return createVNode(Fragment, null, [slots.default?.(), createVNode(Preview, mergeProps({
|
|
58
59
|
"aria-hidden": !isShowPreview.value,
|
|
59
60
|
"open": isShowPreview.value,
|
|
60
61
|
"prefixCls": props.previewPrefixCls,
|
|
@@ -130,4 +131,5 @@ var PreviewGroup_default = /* @__PURE__ */ defineComponent((props, { slots, emit
|
|
|
130
131
|
inheritAttrs: false,
|
|
131
132
|
emits: ["change"]
|
|
132
133
|
});
|
|
133
|
-
|
|
134
|
+
//#endregion
|
|
135
|
+
export { PreviewGroup as default };
|
package/dist/common.js
CHANGED
package/dist/context.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { inject, provide } from "vue";
|
|
2
|
+
//#region src/context.ts
|
|
2
3
|
var PreviewGroupContextKey = Symbol("PreviewGroupContext");
|
|
3
4
|
function usePreviewGroupContext() {
|
|
4
5
|
return inject(PreviewGroupContextKey, null);
|
|
@@ -6,4 +7,5 @@ function usePreviewGroupContext() {
|
|
|
6
7
|
function usePreviewGroupProvider(value) {
|
|
7
8
|
provide(PreviewGroupContextKey, value);
|
|
8
9
|
}
|
|
10
|
+
//#endregion
|
|
9
11
|
export { usePreviewGroupContext, usePreviewGroupProvider };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getClientSize } from "./util.js";
|
|
2
|
+
//#region src/getFixScaleEleTransPosition.ts
|
|
2
3
|
function fixPoint(key, start, width, clientWidth) {
|
|
3
4
|
const startAddWidth = start + width;
|
|
4
5
|
const offsetStart = (width - clientWidth) / 2;
|
|
@@ -8,6 +9,18 @@ function fixPoint(key, start, width, clientWidth) {
|
|
|
8
9
|
} else if (start < 0 || startAddWidth > clientWidth) return { [key]: start < 0 ? offsetStart : -offsetStart };
|
|
9
10
|
return {};
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Fix positon x,y point when
|
|
14
|
+
*
|
|
15
|
+
* Ele width && height < client
|
|
16
|
+
* - Back origin
|
|
17
|
+
*
|
|
18
|
+
* - Ele width | height > clientWidth | clientHeight
|
|
19
|
+
* - left | top > 0 -> Back 0
|
|
20
|
+
* - left | top + width | height < clientWidth | clientHeight -> Back left | top + width | height === clientWidth | clientHeight
|
|
21
|
+
*
|
|
22
|
+
* Regardless of other
|
|
23
|
+
*/
|
|
11
24
|
function getFixScaleEleTransPosition(width, height, left, top) {
|
|
12
25
|
const { width: clientWidth, height: clientHeight } = getClientSize();
|
|
13
26
|
let fixPos = null;
|
|
@@ -21,4 +34,5 @@ function getFixScaleEleTransPosition(width, height, left, top) {
|
|
|
21
34
|
};
|
|
22
35
|
return fixPos;
|
|
23
36
|
}
|
|
37
|
+
//#endregion
|
|
24
38
|
export { getFixScaleEleTransPosition as default };
|