@gx-design-vue/image 0.1.1 → 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
@@ -0,0 +1,286 @@
1
+ import { Keyframe, mergeToken, useStyle as useStyle$1 } from "@gx-design-vue/pro-provider";
2
+ import { TinyColor } from "@ctrl/tinycolor";
3
+
4
+ //#region src/ImagePreview/style.ts
5
+ const viewFadeIn = new Keyframe("viewFadeIn", {
6
+ "0%": { opacity: 0 },
7
+ "100%": { opacity: 1 }
8
+ });
9
+ const viewFadeOut = new Keyframe("viewFadeOut", {
10
+ "0%": { opacity: 1 },
11
+ "100%": { opacity: 0 }
12
+ });
13
+ const viewZoomBadgeIn = new Keyframe("viewZoomBadgeIn", {
14
+ "0%": {
15
+ transform: "scale(0)",
16
+ opacity: 0
17
+ },
18
+ "100%": {
19
+ transform: "scale(1)",
20
+ opacity: 1
21
+ }
22
+ });
23
+ const viewZoomBadgeOut = new Keyframe("viewZoomBadgeOut", {
24
+ "0%": { transform: "scale(1)" },
25
+ "100%": {
26
+ transform: "scale(0)",
27
+ opacity: 0
28
+ }
29
+ });
30
+ function genBoxStyle(position) {
31
+ return {
32
+ position: position || "absolute",
33
+ inset: 0
34
+ };
35
+ }
36
+ function box(position) {
37
+ return {
38
+ position,
39
+ top: 0,
40
+ insetInlineEnd: 0,
41
+ bottom: 0,
42
+ insetInlineStart: 0
43
+ };
44
+ }
45
+ function resetComponent(token) {
46
+ return {
47
+ boxSizing: "border-box",
48
+ margin: 0,
49
+ padding: 0,
50
+ color: token.colorText,
51
+ fontSize: token.fontSize,
52
+ lineHeight: token.lineHeight,
53
+ listStyle: "none",
54
+ fontFamily: token.fontFamily
55
+ };
56
+ }
57
+ function genPreviewOperationsStyle(token) {
58
+ const { previewCls, modalMaskBg, marginXL, margin, colorTextLightSolid, previewOperationColorDisabled, previewOperationHoverColor, motionDurationSlow, iconCls } = token;
59
+ const closeBg = new TinyColor(modalMaskBg).setAlpha(.1);
60
+ const closeBgHover = closeBg.clone().setAlpha(.2);
61
+ const operationBg = new TinyColor(modalMaskBg).setAlpha(.5);
62
+ const operationsBgHover = new TinyColor(modalMaskBg).setAlpha(.03);
63
+ return {
64
+ [`${previewCls}-footer`]: {
65
+ position: "fixed",
66
+ bottom: marginXL,
67
+ left: {
68
+ _skip_check_: true,
69
+ value: "50%"
70
+ },
71
+ display: "flex",
72
+ flexDirection: "column",
73
+ alignItems: "center",
74
+ color: token.previewOperationColor,
75
+ transform: "translateX(-50%)"
76
+ },
77
+ [`${previewCls}-progress`]: { marginBottom: margin },
78
+ [`${previewCls}-close`]: {
79
+ position: "fixed",
80
+ top: marginXL,
81
+ right: {
82
+ _skip_check_: true,
83
+ value: marginXL
84
+ },
85
+ display: "flex",
86
+ alignItems: "center",
87
+ justifyContent: "center",
88
+ color: colorTextLightSolid,
89
+ backgroundColor: closeBg.toRgbString(),
90
+ borderRadius: token.borderRadiusLG,
91
+ backdropFilter: "saturate(180%) blur(10px)",
92
+ width: token.sizeXL,
93
+ height: token.sizeXL,
94
+ outline: 0,
95
+ border: 0,
96
+ cursor: "pointer",
97
+ transition: `all ${motionDurationSlow}`,
98
+ "&:hover": { backgroundColor: closeBgHover.toRgbString() },
99
+ [`& > ${iconCls}`]: { fontSize: token.previewOperationSize }
100
+ },
101
+ [`${previewCls}-operations`]: {
102
+ display: "flex",
103
+ alignItems: "center",
104
+ gap: token.sizeXXS,
105
+ padding: token.paddingXXS,
106
+ border: `1px solid ${token.colorBorderSecondary}`,
107
+ backgroundColor: operationBg.toRgbString(),
108
+ borderRadius: token.borderRadiusLG,
109
+ backdropFilter: "saturate(150%) blur(10px)",
110
+ "&-operation": {
111
+ display: "flex",
112
+ alignItems: "center",
113
+ justifyContent: "center",
114
+ width: token.sizeXL + 4,
115
+ height: token.sizeXL + 4,
116
+ cursor: "pointer",
117
+ color: colorTextLightSolid,
118
+ borderRadius: token.borderRadiusSM,
119
+ transition: `all ${motionDurationSlow}`,
120
+ userSelect: "none",
121
+ [`&:not(${previewCls}-operations-operation-disabled):hover > ${iconCls}`]: { color: previewOperationHoverColor },
122
+ "&:hover": { backgroundColor: operationsBgHover.toRgbString() },
123
+ "&-disabled": {
124
+ color: previewOperationColorDisabled,
125
+ cursor: "not-allowed"
126
+ },
127
+ "&:first-of-type": { marginInlineStart: 0 },
128
+ [`& > ${iconCls}`]: { fontSize: token.previewOperationSize }
129
+ }
130
+ }
131
+ };
132
+ }
133
+ function genPreviewSwitchStyle(token) {
134
+ const { modalMaskBg, iconCls, previewOperationColorDisabled, previewCls, zIndexPopup, motionDurationSlow, colorTextLightSolid } = token;
135
+ const operationBg = new TinyColor(modalMaskBg).setAlpha(.1);
136
+ const operationBgHover = operationBg.clone().setAlpha(.2);
137
+ return {
138
+ [`${previewCls}-switch-left, ${previewCls}-switch-right`]: {
139
+ position: "fixed",
140
+ insetBlockStart: "50%",
141
+ zIndex: token.calc(zIndexPopup).add(1).equal(),
142
+ display: "flex",
143
+ alignItems: "center",
144
+ justifyContent: "center",
145
+ borderRadius: token.borderRadius,
146
+ backdropFilter: "saturate(180%) blur(10px)",
147
+ width: token.imagePreviewSwitchSize,
148
+ height: token.imagePreviewSwitchSize,
149
+ marginTop: token.calc(token.imagePreviewSwitchSize).mul(-1).div(2).equal(),
150
+ color: colorTextLightSolid,
151
+ background: operationBg.toRgbString(),
152
+ transform: `translateY(-50%)`,
153
+ cursor: "pointer",
154
+ transition: `all ${motionDurationSlow}`,
155
+ userSelect: "none",
156
+ "&:hover": { background: operationBgHover.toRgbString() },
157
+ "&-disabled": { "&, &:hover": {
158
+ color: previewOperationColorDisabled,
159
+ background: "transparent",
160
+ cursor: "not-allowed",
161
+ [`> ${iconCls}`]: { cursor: "not-allowed" }
162
+ } },
163
+ [`> ${iconCls}`]: { fontSize: token.previewOperationSize }
164
+ },
165
+ [`${previewCls}-switch-left`]: { insetInlineStart: token.marginSM },
166
+ [`${previewCls}-switch-right`]: { insetInlineEnd: token.marginSM }
167
+ };
168
+ }
169
+ const genImagePreviewStyle = (token) => {
170
+ const { motionEaseOut, motionDurationSlow } = token;
171
+ return {
172
+ [token.componentCls]: {
173
+ height: "100%",
174
+ textAlign: "center",
175
+ pointerEvents: "none",
176
+ "&-root": {
177
+ ...box("fixed"),
178
+ zIndex: token.zIndexPopup,
179
+ overflow: "auto",
180
+ outline: 0,
181
+ WebkitOverflowScrolling: "touch"
182
+ },
183
+ "&-wrap": {
184
+ ...box("fixed"),
185
+ zIndex: token.zIndexPopup,
186
+ overflow: "auto",
187
+ outline: 0,
188
+ WebkitOverflowScrolling: "touch"
189
+ },
190
+ "&-mask": {
191
+ ...box("fixed"),
192
+ zIndex: token.zIndexPopupBase,
193
+ height: "100%",
194
+ backgroundColor: token.colorBgMask,
195
+ backdropFilter: "blur(8px)"
196
+ },
197
+ "&-body": {
198
+ ...genBoxStyle(),
199
+ overflow: "hidden"
200
+ },
201
+ "&-img": {
202
+ maxWidth: "100%",
203
+ maxHeight: "70%",
204
+ verticalAlign: "middle",
205
+ transform: "scale3d(1, 1, 1)",
206
+ cursor: "grab",
207
+ transition: `transform ${motionDurationSlow} ${motionEaseOut} 0s`,
208
+ userSelect: "none",
209
+ "&-wrapper": {
210
+ ...genBoxStyle(),
211
+ transition: `transform ${motionDurationSlow} ${motionEaseOut} 0s`,
212
+ display: "flex",
213
+ justifyContent: "center",
214
+ alignItems: "center",
215
+ "& > *": { pointerEvents: "auto" },
216
+ "&::before": {
217
+ display: "inline-block",
218
+ width: 1,
219
+ height: "50%",
220
+ marginInlineEnd: -1,
221
+ content: "\"\""
222
+ }
223
+ }
224
+ },
225
+ [`&-moving`]: { [`${token.componentCls}-view-img`]: {
226
+ cursor: "grabbing",
227
+ "&-wrapper": { transitionDuration: "0s" }
228
+ } },
229
+ [`&-mask-zoom-appear, &-mask-zoom-enter`]: {
230
+ animationName: viewFadeIn,
231
+ animationDuration: token.motionDurationSlow,
232
+ animationTimingFunction: "linear",
233
+ userSelect: "none"
234
+ },
235
+ [`&-mask-zoom-leave`]: {
236
+ animationName: viewFadeOut,
237
+ animationDuration: token.motionDurationSlow,
238
+ animationTimingFunction: "linear",
239
+ pointerEvents: "none"
240
+ },
241
+ [`&-zoom-appear, &-zoom-enter`]: {
242
+ animationName: viewZoomBadgeIn,
243
+ opacity: 0,
244
+ animationTimingFunction: token.motionEaseOutCirc,
245
+ animationFillMode: "both",
246
+ transform: "none",
247
+ animationDuration: token.motionDurationMid,
248
+ userSelect: "none"
249
+ },
250
+ [`&-zoom-enter-active`]: { animationPlayState: "running" },
251
+ [`&-zoom-leave`]: {
252
+ animationName: viewZoomBadgeOut,
253
+ animationDuration: token.motionDurationSlow,
254
+ animationTimingFunction: token.motionEaseInOutCirc,
255
+ animationFillMode: "both"
256
+ }
257
+ },
258
+ [`${token.componentCls}-root`]: { [`${token.componentCls}-wrapper`]: { zIndex: token.zIndexPopup } },
259
+ [`${token.componentCls}-operations-wrapper`]: {
260
+ position: "fixed",
261
+ insetBlockStart: 0,
262
+ insetInlineEnd: 0,
263
+ zIndex: token.calc(token.zIndexPopup).add(1).equal(),
264
+ width: "100%"
265
+ },
266
+ "&": [genPreviewOperationsStyle(token), genPreviewSwitchStyle(token)]
267
+ };
268
+ };
269
+ function useStyle(componentCls) {
270
+ return useStyle$1("ImageViewer", (token) => {
271
+ return [genImagePreviewStyle(mergeToken(token, {
272
+ zIndexPopup: token.zIndexPopupBase + 80,
273
+ previewOperationColor: new TinyColor(token.colorTextLightSolid).setAlpha(.65).toRgbString(),
274
+ previewOperationHoverColor: new TinyColor(token.colorTextLightSolid).setAlpha(.85).toRgbString(),
275
+ previewOperationColorDisabled: new TinyColor(token.colorTextLightSolid).setAlpha(.25).toRgbString(),
276
+ imagePreviewSwitchSize: token.sizeXL,
277
+ modalMaskBg: new TinyColor("#000").setAlpha(.45).toRgbString(),
278
+ previewOperationSize: token.fontSizeIcon * 1.5,
279
+ iconCls: ".anticon",
280
+ previewCls: token.componentCls
281
+ }))];
282
+ }, componentCls);
283
+ }
284
+
285
+ //#endregion
286
+ export { genBoxStyle, genPreviewOperationsStyle, genPreviewSwitchStyle, resetComponent, useStyle, viewFadeIn, viewFadeOut };
@@ -0,0 +1,19 @@
1
+ import { PreviewPropsIcons } from "./props.js";
2
+ import { ComputedRef } from "vue";
3
+ import { CustomRender, WithFalse } from "@gx-design-vue/pro-utils";
4
+
5
+ //#region src/ImagePreview/typings.d.ts
6
+ type MouseEventHandler = (e: MouseEvent) => void;
7
+ interface PreviewUrl {
8
+ url: string;
9
+ loading: boolean;
10
+ canPreview: boolean;
11
+ }
12
+ interface ImagePreviewTools {
13
+ type: keyof PreviewPropsIcons;
14
+ icon: WithFalse<CustomRender>;
15
+ onClick: () => void;
16
+ disabled?: ComputedRef<boolean>;
17
+ }
18
+ //#endregion
19
+ export { ImagePreviewTools, MouseEventHandler, PreviewUrl };
@@ -0,0 +1 @@
1
+ export { };