@gx-design-vue/image 0.1.2 → 0.2.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -7
  3. package/dist/GImage.d.ts +162 -0
  4. package/dist/GImage.js +221 -0
  5. package/dist/ImagePreview/Operations.d.ts +83 -0
  6. package/dist/ImagePreview/Operations.js +71 -0
  7. package/dist/ImagePreview/hooks/getFixScaleEleTransPosition.d.ts +19 -0
  8. package/dist/ImagePreview/hooks/getFixScaleEleTransPosition.js +40 -0
  9. package/dist/ImagePreview/hooks/useImageTransform.d.ts +39 -0
  10. package/dist/ImagePreview/hooks/useImageTransform.js +105 -0
  11. package/dist/ImagePreview/hooks/useMouseEvent.d.ts +14 -0
  12. package/dist/ImagePreview/hooks/useMouseEvent.js +100 -0
  13. package/dist/ImagePreview/hooks/useTouchEvent.d.ts +12 -0
  14. package/dist/ImagePreview/hooks/useTouchEvent.js +123 -0
  15. package/dist/ImagePreview/index.d.ts +162 -0
  16. package/dist/ImagePreview/index.js +303 -0
  17. package/dist/ImagePreview/props.d.ts +88 -0
  18. package/dist/ImagePreview/props.js +53 -0
  19. package/dist/ImagePreview/style.d.ts +30 -0
  20. package/dist/ImagePreview/style.js +286 -0
  21. package/dist/ImagePreview/typings.d.ts +19 -0
  22. package/dist/ImagePreview/typings.js +1 -0
  23. package/dist/ImagePreview/utils/KeyCode.d.ts +438 -0
  24. package/dist/ImagePreview/utils/KeyCode.js +173 -0
  25. package/dist/ImagePreview/utils/addEventListener.d.ts +6 -0
  26. package/dist/ImagePreview/utils/addEventListener.js +22 -0
  27. package/dist/ImagePreview/utils/util.d.ts +7 -0
  28. package/dist/ImagePreview/utils/util.js +8 -0
  29. package/dist/hooks/useFrameSetState.d.ts +5 -0
  30. package/dist/hooks/useFrameSetState.js +33 -0
  31. package/dist/image.esm.js +2374 -0
  32. package/dist/image.js +1 -0
  33. package/dist/index.d.ts +5 -7
  34. package/dist/index.js +6 -0
  35. package/dist/props.d.ts +82 -77
  36. package/dist/props.js +66 -0
  37. package/dist/slots.d.ts +6 -0
  38. package/dist/slots.js +21 -0
  39. package/dist/style.d.ts +9 -0
  40. package/dist/style.js +78 -0
  41. package/dist/typings.d.ts +6 -0
  42. package/dist/typings.js +1 -0
  43. package/dist/utils/aria.d.ts +14 -11
  44. package/dist/utils/aria.js +16 -0
  45. package/dist/utils/util.d.ts +4 -0
  46. package/dist/utils/util.js +8 -0
  47. package/global.d.ts +8 -0
  48. package/package.json +57 -60
  49. package/dist/Image.d.ts +0 -130
  50. package/dist/components/ImageViewer.d.ts +0 -59
  51. package/dist/components/ImageViewerGroup.d.ts +0 -14
  52. package/dist/design/config.less +0 -2
  53. package/dist/image.es.js +0 -801
  54. package/dist/image.umd.js +0 -1
  55. package/dist/style.css +0 -1
  56. package/dist/style.less +0 -177
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 gx12358
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,76 @@
1
- # Image
1
+ <div align="center"><a name="readme-top"></a>
2
2
 
3
- ```shell
4
- pnpm add @gx-design-vue/image
3
+ <img height="180" src="https://gx12358.cn/resource/img/favicon.ico">
4
+
5
+ <h1>Image</h1>
6
+
7
+ </div>
8
+
9
+ ## ✨ Features
10
+
11
+ - 🌈 Enterprise-class UI designed for web applications.
12
+ - 📦 A set of high-quality Vue3 components out of the box.
13
+ - 🛡 Written in TypeScript with predictable static types.
14
+ - ⚙️ Whole package of design resources and development tools.
15
+ - 🌍 Internationalization support for dozens of languages.
16
+ - 🎨 Powerful theme customization based on CSS-in-JS.
17
+
18
+ ## 🖥 Environment Support
19
+
20
+ - Modern browsers
21
+ - Server-side Rendering
22
+ - [Electron](https://www.electronjs.org/)
23
+
24
+ | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="Edge" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)<br>Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)<br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" />](https://godban.github.io/browsers-support-badges/)<br>Electron |
25
+ | --- | --- | --- | --- | --- |
26
+ | Edge | last 2 versions | last 2 versions | last 2 versions | last 2 versions |
27
+
28
+ ## 📦 Install
29
+
30
+ ```bash
31
+ npm install @gx-design-vue/image
5
32
  ```
6
33
 
7
- ```ts
8
- // 可全局引入,也可以单独引入
9
- import { GImage } from '@gx-design-vue/image'
34
+ ```bash
35
+ yarn add @gx-design-vue/image
36
+ ```
37
+
38
+ ```bash
39
+ pnpm add @gx-design-vue/image
40
+ ```
10
41
 
11
- import '@gx-design-vue/image/dist/style.less'
42
+ ```bash
43
+ bun add @gx-design-vue/image
12
44
  ```
45
+
46
+ ## Acknowledgements
47
+
48
+ Antdv Next is inspired by and built upon the following open-source projects.
49
+
50
+ - [Ant Design](https://ant.design/)
51
+ - [Vue.js](https://vuejs.org/)
52
+ - [Vite](https://vitejs.dev/)
53
+
54
+ ## Maintainer
55
+
56
+ [@gx12358](https://github.com/gx12358/vue3-antd-admin)
57
+
58
+ ## Contributors
59
+
60
+ <a href="https://github.com/gx12358/vue3-antd-admin/graphs/contributors">
61
+ <img alt="Contributors" src="https://contrib.rocks/image?repo=gx12358/vue3-antd-admin" />
62
+ </a>
63
+
64
+ ## Special Thanks
65
+
66
+ Thanks to the [vbenjs/vue-vben-admin](https://github.com/gx12358/vue3-antd-admin) project for providing inspiration and reference implementation.
67
+
68
+ ## License
69
+
70
+ [MIT © gx12358-2021](./LICENSE)
71
+
72
+ ## `Star`
73
+
74
+ Thank you very much for the stars from kind-hearted people, thank you for your support :heart:
75
+
76
+ [![Stargazers repo roster for @gx12358/vue3-antd-admin](https://bytecrank.com/nastyox/reporoster/php/stargazersSVG.php?user=gx12358&repo=vue3-antd-admin)](https://github.com/gx12358/vue3-antd-admin/stargazers)
@@ -0,0 +1,162 @@
1
+ import { BaseImagePreviewProps } from "./ImagePreview/props.js";
2
+ import { imageProps } from "./props.js";
3
+ import * as vue0 from "vue";
4
+ import { CSSProperties, ExtractPropTypes, SlotsType } from "vue";
5
+ import * as _gx_design_vue_pro_utils0 from "@gx-design-vue/pro-utils";
6
+ import * as ant_design_vue_es__util_type1 from "ant-design-vue/es/_util/type";
7
+
8
+ //#region src/GImage.d.ts
9
+ type GImageProps = Partial<ExtractPropTypes<typeof imageProps>>;
10
+ declare const GImage: vue0.DefineComponent<ExtractPropTypes<{
11
+ preview: {
12
+ type: vue0.PropType<BaseImagePreviewProps | boolean>;
13
+ default: boolean;
14
+ };
15
+ src: {
16
+ type: vue0.PropType<string>;
17
+ default: string;
18
+ };
19
+ alt: {
20
+ type: vue0.PropType<string>;
21
+ default: string;
22
+ };
23
+ loading: {
24
+ type: vue0.PropType<"eager" | "lazy">;
25
+ };
26
+ fit: {
27
+ type: vue0.PropType<"fill" | "contain" | "cover" | "none" | "scale-down">;
28
+ default: string;
29
+ };
30
+ crossOrigin: {
31
+ type: vue0.PropType<"anonymous" | "use-credentials" | "">;
32
+ };
33
+ lazy: vue0.PropType<boolean>;
34
+ scrollContainer: {
35
+ type: vue0.PropType<string | HTMLElement | undefined>;
36
+ };
37
+ placeholder: {
38
+ type: vue0.PropType<_gx_design_vue_pro_utils0.WithFalse<_gx_design_vue_pro_utils0.CustomRender>>;
39
+ default: () => any;
40
+ };
41
+ fallback: {
42
+ type: vue0.PropType<_gx_design_vue_pro_utils0.WithFalse<_gx_design_vue_pro_utils0.CustomRender>>;
43
+ default: () => any;
44
+ };
45
+ onLoad: {
46
+ type: vue0.PropType<(e: Error) => void>;
47
+ };
48
+ onError: {
49
+ type: vue0.PropType<(e: Error) => void>;
50
+ };
51
+ onClick: {
52
+ type: vue0.PropType<(info: any) => void>;
53
+ };
54
+ imageStyle: {
55
+ type: vue0.PropType<CSSProperties>;
56
+ default: () => {};
57
+ };
58
+ imageClass: vue0.PropType<string>;
59
+ size: vue0.PropType<number>;
60
+ width: vue0.PropType<number>;
61
+ height: vue0.PropType<number>;
62
+ zIndex: {
63
+ type: vue0.PropType<number>;
64
+ default: number;
65
+ };
66
+ getContainer: {
67
+ type: vue0.PropType<string>;
68
+ };
69
+ }>, () => ant_design_vue_es__util_type1.VueNode, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {
70
+ click: (_type: "loaded" | "error" | "success") => true;
71
+ load: (_event: Event) => true;
72
+ error: (_event: Event) => true;
73
+ }, string, vue0.PublicProps, Readonly<ExtractPropTypes<{
74
+ preview: {
75
+ type: vue0.PropType<BaseImagePreviewProps | boolean>;
76
+ default: boolean;
77
+ };
78
+ src: {
79
+ type: vue0.PropType<string>;
80
+ default: string;
81
+ };
82
+ alt: {
83
+ type: vue0.PropType<string>;
84
+ default: string;
85
+ };
86
+ loading: {
87
+ type: vue0.PropType<"eager" | "lazy">;
88
+ };
89
+ fit: {
90
+ type: vue0.PropType<"fill" | "contain" | "cover" | "none" | "scale-down">;
91
+ default: string;
92
+ };
93
+ crossOrigin: {
94
+ type: vue0.PropType<"anonymous" | "use-credentials" | "">;
95
+ };
96
+ lazy: vue0.PropType<boolean>;
97
+ scrollContainer: {
98
+ type: vue0.PropType<string | HTMLElement | undefined>;
99
+ };
100
+ placeholder: {
101
+ type: vue0.PropType<_gx_design_vue_pro_utils0.WithFalse<_gx_design_vue_pro_utils0.CustomRender>>;
102
+ default: () => any;
103
+ };
104
+ fallback: {
105
+ type: vue0.PropType<_gx_design_vue_pro_utils0.WithFalse<_gx_design_vue_pro_utils0.CustomRender>>;
106
+ default: () => any;
107
+ };
108
+ onLoad: {
109
+ type: vue0.PropType<(e: Error) => void>;
110
+ };
111
+ onError: {
112
+ type: vue0.PropType<(e: Error) => void>;
113
+ };
114
+ onClick: {
115
+ type: vue0.PropType<(info: any) => void>;
116
+ };
117
+ imageStyle: {
118
+ type: vue0.PropType<CSSProperties>;
119
+ default: () => {};
120
+ };
121
+ imageClass: vue0.PropType<string>;
122
+ size: vue0.PropType<number>;
123
+ width: vue0.PropType<number>;
124
+ height: vue0.PropType<number>;
125
+ zIndex: {
126
+ type: vue0.PropType<number>;
127
+ default: number;
128
+ };
129
+ getContainer: {
130
+ type: vue0.PropType<string>;
131
+ };
132
+ }>> & Readonly<{
133
+ onError?: (_event: Event) => any;
134
+ onClick?: (_type: "loaded" | "error" | "success") => any;
135
+ onLoad?: (_event: Event) => any;
136
+ }>, {
137
+ fallback: _gx_design_vue_pro_utils0.CustomRender;
138
+ placeholder: _gx_design_vue_pro_utils0.CustomRender;
139
+ zIndex: number;
140
+ preview: boolean;
141
+ src: string;
142
+ alt: string;
143
+ fit: "fill" | "contain" | "cover" | "none" | "scale-down";
144
+ imageStyle: CSSProperties;
145
+ }, SlotsType<{
146
+ default: () => void;
147
+ mask: () => void;
148
+ close: () => void;
149
+ left: () => void;
150
+ right: () => void;
151
+ countRender: () => void;
152
+ rotateRight: () => void;
153
+ zoomIn: () => void;
154
+ zoomOut: () => void;
155
+ flipX: () => void;
156
+ flipY: () => void;
157
+ rotateLeft: () => void;
158
+ fallback: () => void;
159
+ placeholder: () => void;
160
+ }>, {}, {}, string, vue0.ComponentProvideOptions, true, {}, any>;
161
+ //#endregion
162
+ export { GImageProps, GImage as default };
package/dist/GImage.js ADDED
@@ -0,0 +1,221 @@
1
+ import { imageProps } from "./props.js";
2
+ import ImagePreview_default from "./ImagePreview/index.js";
3
+ import { genImageStyle } from "./style.js";
4
+ import { isElement } from "./utils/util.js";
5
+ import { Fragment, computed, createVNode, defineComponent, mergeProps, nextTick, onMounted, ref, watch, watchEffect } from "vue";
6
+ import { EyeOutlined } from "@ant-design/icons-vue";
7
+ import { unit, useProStyle } from "@gx-design-vue/pro-provider";
8
+ import { classNames, getPrefixCls, getScrollContainer, getSlotsProps, isInContainer, isNumber, isString } from "@gx-design-vue/pro-utils";
9
+ import { isClient, useEventListener, useThrottleFn } from "@vueuse/core";
10
+ import { omit } from "es-toolkit";
11
+
12
+ //#region src/GImage.tsx
13
+ let prevOverflow = "";
14
+ function fromPairs(pairs) {
15
+ const result = {};
16
+ for (let i = 0; i < pairs.length; i++) {
17
+ const pair = pairs[i];
18
+ result[pair[0]] = pair[1];
19
+ }
20
+ return result;
21
+ }
22
+ const GImage = /* @__PURE__ */ defineComponent({
23
+ props: imageProps,
24
+ name: "GImage",
25
+ inheritAttrs: false,
26
+ emits: {
27
+ click: (_type) => true,
28
+ load: (_event) => true,
29
+ error: (_event) => true
30
+ },
31
+ slots: Object,
32
+ setup(props, { slots, emit, attrs }) {
33
+ const supportLoading = isClient && "loading" in HTMLImageElement.prototype;
34
+ const baseClassName = getPrefixCls({ suffixCls: "image" });
35
+ const { wrapSSR, hashId } = useProStyle("Image", [genImageStyle], baseClassName);
36
+ const imageViewer = ref();
37
+ const imageSrc = ref();
38
+ const hasLoadError = ref(false);
39
+ const isLoading = ref(true);
40
+ const showViewer = ref(false);
41
+ const container = ref();
42
+ const _scrollContainer = ref();
43
+ let stopScrollListener;
44
+ let stopWheelListener;
45
+ const isManual = computed(() => {
46
+ if (props.loading === "eager") return false;
47
+ return !supportLoading && props.loading === "lazy" || props.lazy;
48
+ });
49
+ const imageStyle = computed(() => {
50
+ if (isClient && props.fit) return {
51
+ ...props.imageStyle,
52
+ objectFit: props.fit
53
+ };
54
+ return props.imageStyle;
55
+ });
56
+ const previewProps = computed(() => typeof props.preview === "object" ? props.preview : {});
57
+ const canPreview = computed(() => !!props.preview);
58
+ const currentImage = computed(() => {
59
+ const { urls = [], current = 0 } = previewProps.value;
60
+ if (isNumber(current)) return urls.length >= current ? current : 0;
61
+ const srcIndex = urls.indexOf(props.src);
62
+ if (srcIndex >= 0) return srcIndex;
63
+ return 0;
64
+ });
65
+ const width = computed(() => unit(props.width));
66
+ const height = computed(() => unit(props.height));
67
+ const loadImage = () => {
68
+ if (!isClient) return;
69
+ isLoading.value = true;
70
+ hasLoadError.value = false;
71
+ imageSrc.value = props.src;
72
+ };
73
+ function handleLoad(event) {
74
+ if (hasLoadError.value) return;
75
+ isLoading.value = false;
76
+ hasLoadError.value = false;
77
+ emit("load", event);
78
+ }
79
+ function handleError(event) {
80
+ isLoading.value = false;
81
+ hasLoadError.value = true;
82
+ emit("error", event);
83
+ }
84
+ function handleLazyLoad() {
85
+ if (isInContainer(container.value, _scrollContainer.value)) {
86
+ loadImage();
87
+ removeLazyLoadListener();
88
+ }
89
+ }
90
+ const lazyLoadHandler = useThrottleFn(handleLazyLoad, 200, true);
91
+ async function addLazyLoadListener() {
92
+ if (!isClient) return;
93
+ await nextTick();
94
+ const { scrollContainer } = props;
95
+ if (isElement(scrollContainer)) _scrollContainer.value = scrollContainer;
96
+ else if (isString(scrollContainer) && scrollContainer !== "") _scrollContainer.value = document.querySelector(scrollContainer) ?? void 0;
97
+ else if (container.value) _scrollContainer.value = getScrollContainer(container.value);
98
+ if (_scrollContainer.value) {
99
+ stopScrollListener = useEventListener(_scrollContainer, "scroll", lazyLoadHandler);
100
+ setTimeout(() => handleLazyLoad(), 100);
101
+ }
102
+ }
103
+ function removeLazyLoadListener() {
104
+ if (!isClient || !_scrollContainer.value || !lazyLoadHandler) return;
105
+ stopScrollListener?.();
106
+ _scrollContainer.value = void 0;
107
+ }
108
+ function wheelHandler(e) {
109
+ if (!e.ctrlKey) return;
110
+ if (e.deltaY < 0) {
111
+ e.preventDefault();
112
+ return false;
113
+ } else if (e.deltaY > 0) {
114
+ e.preventDefault();
115
+ return false;
116
+ }
117
+ }
118
+ const clickHandler = () => {
119
+ emit("click", isLoading.value ? "loaded" : hasLoadError.value ? "error" : "success");
120
+ if (isLoading.value || hasLoadError.value) return;
121
+ if (canPreview.value) {
122
+ stopWheelListener = useEventListener("wheel", wheelHandler, { passive: false });
123
+ prevOverflow = document.body.style.overflow;
124
+ document.body.style.overflow = "hidden";
125
+ showViewer.value = true;
126
+ }
127
+ };
128
+ const closeViewer = () => {
129
+ stopWheelListener?.();
130
+ document.body.style.overflow = prevOverflow;
131
+ showViewer.value = false;
132
+ };
133
+ watch(() => props.src, () => {
134
+ if (isManual.value) {
135
+ isLoading.value = true;
136
+ hasLoadError.value = false;
137
+ removeLazyLoadListener();
138
+ addLazyLoadListener();
139
+ } else loadImage();
140
+ });
141
+ watchEffect(() => {
142
+ if (canPreview.value && showViewer.value) imageViewer.value?.setOpen(true);
143
+ else imageViewer.value?.setOpen(false);
144
+ });
145
+ onMounted(() => {
146
+ if (isManual.value) addLazyLoadListener();
147
+ else loadImage();
148
+ });
149
+ return () => {
150
+ const containerAttrs = fromPairs(Object.entries(attrs).filter(([key]) => /^(?:data-|on[A-Z])/i.test(key) || [
151
+ "id",
152
+ "style",
153
+ "class"
154
+ ].includes(key)));
155
+ const imgAttrs = omit(attrs, Object.keys(containerAttrs));
156
+ const slotsProps = getSlotsProps({
157
+ slots,
158
+ props,
159
+ keys: [
160
+ "fallback",
161
+ "mask",
162
+ "placeholder"
163
+ ],
164
+ render: true
165
+ });
166
+ return wrapSSR(createVNode("div", mergeProps({
167
+ "class": {
168
+ [`${hashId.value}`]: true,
169
+ [`${baseClassName}`]: true
170
+ },
171
+ "ref": container
172
+ }, containerAttrs, {
173
+ "style": {
174
+ width: unit(props.size) || width.value,
175
+ height: unit(props.size) || height.value,
176
+ ...containerAttrs.style || {}
177
+ },
178
+ "onClick": () => {
179
+ if (hasLoadError.value) clickHandler();
180
+ }
181
+ }), [
182
+ hasLoadError.value ? createVNode("div", { "class": classNames(hashId.value, `${baseClassName}-error`) }, [slotsProps.fallback]) : createVNode(Fragment, null, [createVNode("img", mergeProps(imgAttrs, {
183
+ "src": imageSrc.value,
184
+ "loading": props.loading,
185
+ "style": imageStyle.value,
186
+ "class": classNames(hashId.value, props.imageClass, `${baseClassName}-img`, {
187
+ [`${baseClassName}-img-placeholder`]: props.placeholder === true,
188
+ [`${baseClassName}-img-preview`]: canPreview.value
189
+ }),
190
+ "crossorigin": props.crossOrigin,
191
+ "width": width.value,
192
+ "height": height.value,
193
+ "onClick": clickHandler,
194
+ "onLoad": handleLoad,
195
+ "onError": handleError
196
+ }), null), isLoading.value && createVNode("div", {
197
+ "class": classNames(`${baseClassName}-placeholder`, hashId.value),
198
+ "onClick": clickHandler
199
+ }, [slotsProps.placeholder])]),
200
+ previewProps.value.mask && canPreview.value && createVNode("div", {
201
+ "class": classNames(`${baseClassName}-mask`, previewProps.value.maskClass, hashId.value),
202
+ "style": { display: containerAttrs.style?.display === "none" ? "none" : void 0 }
203
+ }, [slotsProps.mask || createVNode("div", { "class": classNames(`${baseClassName}-mask-info`, hashId.value) }, [createVNode(EyeOutlined, null, null)])]),
204
+ canPreview.value && createVNode(ImagePreview_default, mergeProps({ "ref": imageViewer }, previewProps.value, {
205
+ "urls": previewProps.value.urls || [props.src],
206
+ "current": currentImage.value,
207
+ "onClose": () => closeViewer()
208
+ }), slots)
209
+ ]));
210
+ };
211
+ }
212
+ });
213
+ GImage.isGImage = true;
214
+ GImage.install = (app) => {
215
+ app.component(GImage.name, GImage);
216
+ return app;
217
+ };
218
+ var GImage_default = GImage;
219
+
220
+ //#endregion
221
+ export { GImage_default as default };
@@ -0,0 +1,83 @@
1
+ import { PreviewPropsIcons } from "./props.js";
2
+ import { ImagePreviewTools } from "./typings.js";
3
+ import * as vue84 from "vue";
4
+ import { PropType } from "vue";
5
+ import * as _gx_design_vue_pro_utils13 from "@gx-design-vue/pro-utils";
6
+ import * as vue_jsx_runtime0 from "vue/jsx-runtime";
7
+
8
+ //#region src/ImagePreview/Operations.d.ts
9
+ declare const _default: vue84.DefineComponent<vue84.ExtractPropTypes<{
10
+ open: PropType<boolean>;
11
+ count: {
12
+ type: PropType<number>;
13
+ default: number;
14
+ };
15
+ current: {
16
+ type: PropType<number>;
17
+ default: number;
18
+ };
19
+ showSwitch: PropType<boolean>;
20
+ showProgress: PropType<boolean>;
21
+ prefixCls: PropType<string>;
22
+ hashId: PropType<string>;
23
+ zIndex: {
24
+ type: PropType<number>;
25
+ default: number;
26
+ };
27
+ icons: {
28
+ type: PropType<PreviewPropsIcons>;
29
+ default: () => PreviewPropsIcons;
30
+ };
31
+ infinite: {
32
+ type: PropType<boolean>;
33
+ default: boolean;
34
+ };
35
+ getContainer: {
36
+ type: PropType<string>;
37
+ };
38
+ countRender: PropType<_gx_design_vue_pro_utils13.WithFalse<(current: number, total: number) => _gx_design_vue_pro_utils13.CustomRender>>;
39
+ tools: PropType<ImagePreviewTools[]>;
40
+ onClose: PropType<() => void>;
41
+ onActive: PropType<(offset: number) => void>;
42
+ }>, () => vue_jsx_runtime0.JSX.Element, {}, {}, {}, vue84.ComponentOptionsMixin, vue84.ComponentOptionsMixin, {}, string, vue84.PublicProps, Readonly<vue84.ExtractPropTypes<{
43
+ open: PropType<boolean>;
44
+ count: {
45
+ type: PropType<number>;
46
+ default: number;
47
+ };
48
+ current: {
49
+ type: PropType<number>;
50
+ default: number;
51
+ };
52
+ showSwitch: PropType<boolean>;
53
+ showProgress: PropType<boolean>;
54
+ prefixCls: PropType<string>;
55
+ hashId: PropType<string>;
56
+ zIndex: {
57
+ type: PropType<number>;
58
+ default: number;
59
+ };
60
+ icons: {
61
+ type: PropType<PreviewPropsIcons>;
62
+ default: () => PreviewPropsIcons;
63
+ };
64
+ infinite: {
65
+ type: PropType<boolean>;
66
+ default: boolean;
67
+ };
68
+ getContainer: {
69
+ type: PropType<string>;
70
+ };
71
+ countRender: PropType<_gx_design_vue_pro_utils13.WithFalse<(current: number, total: number) => _gx_design_vue_pro_utils13.CustomRender>>;
72
+ tools: PropType<ImagePreviewTools[]>;
73
+ onClose: PropType<() => void>;
74
+ onActive: PropType<(offset: number) => void>;
75
+ }>> & Readonly<{}>, {
76
+ zIndex: number;
77
+ current: number;
78
+ infinite: boolean;
79
+ icons: PreviewPropsIcons;
80
+ count: number;
81
+ }, {}, {}, {}, string, vue84.ComponentProvideOptions, true, {}, any>;
82
+ //#endregion
83
+ export { _default as default };
@@ -0,0 +1,71 @@
1
+ import props_default from "./props.js";
2
+ import { Fragment, Teleport, Transition, cloneVNode, createVNode, defineComponent, vShow, withDirectives } from "vue";
3
+ import { CloseOutlined, LeftOutlined, RightOutlined } from "@ant-design/icons-vue";
4
+ import { getTransitionProps } from "@gx-design-vue/pro-provider";
5
+ import { classNames } from "@gx-design-vue/pro-utils";
6
+
7
+ //#region src/ImagePreview/Operations.tsx
8
+ var Operations_default = /* @__PURE__ */ defineComponent({
9
+ name: "Operations",
10
+ inheritAttrs: false,
11
+ props: {
12
+ open: Boolean,
13
+ count: {
14
+ type: Number,
15
+ default: 0
16
+ },
17
+ current: {
18
+ type: Number,
19
+ default: 0
20
+ },
21
+ showSwitch: Boolean,
22
+ showProgress: Boolean,
23
+ prefixCls: String,
24
+ hashId: String,
25
+ zIndex: props_default.zIndex,
26
+ icons: props_default.icons,
27
+ infinite: props_default.infinite,
28
+ getContainer: props_default.getContainer,
29
+ countRender: props_default.countRender,
30
+ tools: Array,
31
+ onClose: Function,
32
+ onActive: Function
33
+ },
34
+ setup(props) {
35
+ const handleActive = (e, offset) => {
36
+ e.preventDefault();
37
+ e.stopPropagation();
38
+ props.onActive?.(offset);
39
+ };
40
+ return () => {
41
+ const { prefixCls, hashId, tools } = props;
42
+ const transitionProps = getTransitionProps(`${props.prefixCls}-fade`);
43
+ const toolClassName = `${prefixCls}-operations-operation`;
44
+ const iconClassName = `${prefixCls}-operations-icon`;
45
+ return createVNode(Teleport, { "to": props.getContainer || "body" }, { default: () => [createVNode(Transition, transitionProps, { default: () => [withDirectives(createVNode("div", {
46
+ "class": classNames(`${prefixCls}-operations-wrapper`, hashId),
47
+ "style": { zIndex: props.zIndex }
48
+ }, [
49
+ props.icons?.close === null ? null : createVNode("button", {
50
+ "class": `${prefixCls}-close ${hashId}`,
51
+ "onClick": props.onClose
52
+ }, [props.icons?.close || createVNode(CloseOutlined, null, null)]),
53
+ props.showSwitch && createVNode(Fragment, null, [createVNode("div", {
54
+ "class": classNames(`${prefixCls}-switch-left ${hashId}`, { [`${prefixCls}-switch-left-disabled`]: props.infinite ? false : props.current === 0 }),
55
+ "onClick": (e) => handleActive(e, -1)
56
+ }, [props.icons?.left || createVNode(LeftOutlined, null, null)]), createVNode("div", {
57
+ "class": classNames(`${prefixCls}-switch-right ${hashId}`, { [`${prefixCls}-switch-right-disabled`]: props.infinite ? false : props.current === props.count - 1 }),
58
+ "onClick": (e) => handleActive(e, 1)
59
+ }, [props.icons?.right || createVNode(RightOutlined, null, null)])]),
60
+ createVNode("div", { "class": `${prefixCls}-footer ${hashId}` }, [props.showProgress && createVNode("div", { "class": `${prefixCls}-progress` }, [props.countRender ? props.countRender(props.current + 1, props.count) : `${props.current + 1} / ${props.count}`]), createVNode("div", { "class": `${props.prefixCls}-operations` }, [tools?.map(({ icon: IconType, onClick, type, disabled }) => createVNode("div", {
61
+ "class": classNames(toolClassName, { [`${props.prefixCls}-operations-operation-disabled`]: disabled && disabled?.value }),
62
+ "onClick": onClick,
63
+ "key": type
64
+ }, [cloneVNode(IconType, { class: iconClassName })]))])])
65
+ ]), [[vShow, props.open]])] })] });
66
+ };
67
+ }
68
+ });
69
+
70
+ //#endregion
71
+ export { Operations_default as default };
@@ -0,0 +1,19 @@
1
+ //#region src/ImagePreview/hooks/getFixScaleEleTransPosition.d.ts
2
+ /**
3
+ * Fix positon x,y point when
4
+ *
5
+ * Ele width && height < client
6
+ * - Back origin
7
+ *
8
+ * - Ele width | height > clientWidth | clientHeight
9
+ * - left | top > 0 -> Back 0
10
+ * - left | top + width | height < clientWidth | clientHeight -> Back left | top + width | height === clientWidth | clientHeight
11
+ *
12
+ * Regardless of other
13
+ */
14
+ declare function getFixScaleEleTransPosition(width: number, height: number, left: number, top: number): null | {
15
+ x: number;
16
+ y: number;
17
+ };
18
+ //#endregion
19
+ export { getFixScaleEleTransPosition as default };