@douyinfe/semi-ui 2.19.2-alpha.0 → 2.20.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/semi.css +243 -968
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +3449 -452
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +1 -1
- package/lib/cjs/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/cjs/carousel/index.d.ts +1 -1
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +1 -1
- package/lib/cjs/datePicker/monthsGrid.d.ts +1 -1
- package/lib/cjs/image/image.d.ts +48 -0
- package/lib/cjs/image/image.js +248 -0
- package/lib/cjs/image/index.d.ts +6 -0
- package/lib/cjs/image/index.js +29 -0
- package/lib/cjs/image/interface.d.ts +178 -0
- package/lib/cjs/image/interface.js +5 -0
- package/lib/cjs/image/preview.d.ts +81 -0
- package/lib/cjs/image/preview.js +249 -0
- package/lib/cjs/image/previewContext.d.ts +12 -0
- package/lib/cjs/image/previewContext.js +11 -0
- package/lib/cjs/image/previewFooter.d.ts +62 -0
- package/lib/cjs/image/previewFooter.js +337 -0
- package/lib/cjs/image/previewHeader.d.ts +4 -0
- package/lib/cjs/image/previewHeader.js +57 -0
- package/lib/cjs/image/previewImage.d.ts +49 -0
- package/lib/cjs/image/previewImage.js +253 -0
- package/lib/cjs/image/previewInner.d.ts +87 -0
- package/lib/cjs/image/previewInner.js +443 -0
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +14 -0
- package/lib/cjs/locale/interface.d.ts +13 -0
- package/lib/cjs/locale/source/ar.js +13 -0
- package/lib/cjs/locale/source/de.js +13 -0
- package/lib/cjs/locale/source/en_GB.js +13 -0
- package/lib/cjs/locale/source/en_US.js +13 -0
- package/lib/cjs/locale/source/es.js +13 -0
- package/lib/cjs/locale/source/fr.js +13 -0
- package/lib/cjs/locale/source/id_ID.js +13 -0
- package/lib/cjs/locale/source/it.js +13 -0
- package/lib/cjs/locale/source/ja_JP.js +13 -0
- package/lib/cjs/locale/source/ko_KR.js +13 -0
- package/lib/cjs/locale/source/ms_MY.js +13 -0
- package/lib/cjs/locale/source/pt_BR.js +13 -0
- package/lib/cjs/locale/source/ru_RU.js +13 -0
- package/lib/cjs/locale/source/th_TH.js +13 -0
- package/lib/cjs/locale/source/tr_TR.js +13 -0
- package/lib/cjs/locale/source/vi_VN.js +13 -0
- package/lib/cjs/locale/source/zh_CN.js +13 -0
- package/lib/cjs/locale/source/zh_TW.js +13 -0
- package/lib/cjs/progress/index.d.ts +10 -2
- package/lib/cjs/progress/index.js +37 -8
- package/lib/cjs/radio/radio.d.ts +1 -1
- package/lib/cjs/radio/radioGroup.d.ts +1 -1
- package/lib/cjs/skeleton/item.d.ts +1 -0
- package/lib/cjs/skeleton/item.js +10 -4
- package/lib/cjs/tag/index.js +5 -1
- package/lib/cjs/tag/interface.d.ts +2 -0
- package/lib/cjs/timePicker/TimePicker.d.ts +2 -2
- package/lib/cjs/timePicker/TimeShape.d.ts +1 -1
- package/lib/cjs/timePicker/index.d.ts +2 -2
- package/lib/cjs/toast/index.d.ts +9 -0
- package/lib/cjs/toast/index.js +50 -10
- package/lib/cjs/toast/toast.d.ts +1 -0
- package/lib/cjs/toast/toast.js +4 -0
- package/lib/cjs/typography/base.d.ts +1 -1
- package/lib/cjs/typography/paragraph.d.ts +1 -1
- package/lib/cjs/typography/text.d.ts +1 -1
- package/lib/cjs/typography/title.d.ts +2 -2
- package/lib/cjs/upload/index.d.ts +1 -1
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/button/index.d.ts +1 -1
- package/lib/es/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/es/carousel/index.d.ts +1 -1
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +1 -1
- package/lib/es/datePicker/monthsGrid.d.ts +1 -1
- package/lib/es/image/image.d.ts +48 -0
- package/lib/es/image/image.js +224 -0
- package/lib/es/image/index.d.ts +6 -0
- package/lib/es/image/index.js +5 -0
- package/lib/es/image/interface.d.ts +178 -0
- package/lib/es/image/interface.js +1 -0
- package/lib/es/image/preview.d.ts +81 -0
- package/lib/es/image/preview.js +229 -0
- package/lib/es/image/previewContext.d.ts +12 -0
- package/lib/es/image/previewContext.js +2 -0
- package/lib/es/image/previewFooter.d.ts +62 -0
- package/lib/es/image/previewFooter.js +301 -0
- package/lib/es/image/previewHeader.d.ts +4 -0
- package/lib/es/image/previewHeader.js +38 -0
- package/lib/es/image/previewImage.d.ts +49 -0
- package/lib/es/image/previewImage.js +235 -0
- package/lib/es/image/previewInner.d.ts +87 -0
- package/lib/es/image/previewInner.js +419 -0
- package/lib/es/index.d.ts +2 -0
- package/lib/es/index.js +3 -1
- package/lib/es/locale/interface.d.ts +13 -0
- package/lib/es/locale/source/ar.js +13 -0
- package/lib/es/locale/source/de.js +13 -0
- package/lib/es/locale/source/en_GB.js +13 -0
- package/lib/es/locale/source/en_US.js +13 -0
- package/lib/es/locale/source/es.js +13 -0
- package/lib/es/locale/source/fr.js +13 -0
- package/lib/es/locale/source/id_ID.js +13 -0
- package/lib/es/locale/source/it.js +13 -0
- package/lib/es/locale/source/ja_JP.js +13 -0
- package/lib/es/locale/source/ko_KR.js +13 -0
- package/lib/es/locale/source/ms_MY.js +13 -0
- package/lib/es/locale/source/pt_BR.js +13 -0
- package/lib/es/locale/source/ru_RU.js +13 -0
- package/lib/es/locale/source/th_TH.js +13 -0
- package/lib/es/locale/source/tr_TR.js +13 -0
- package/lib/es/locale/source/vi_VN.js +13 -0
- package/lib/es/locale/source/zh_CN.js +13 -0
- package/lib/es/locale/source/zh_TW.js +13 -0
- package/lib/es/progress/index.d.ts +10 -2
- package/lib/es/progress/index.js +36 -8
- package/lib/es/radio/radio.d.ts +1 -1
- package/lib/es/radio/radioGroup.d.ts +1 -1
- package/lib/es/skeleton/item.d.ts +1 -0
- package/lib/es/skeleton/item.js +10 -4
- package/lib/es/tag/index.js +5 -1
- package/lib/es/tag/interface.d.ts +2 -0
- package/lib/es/timePicker/TimePicker.d.ts +2 -2
- package/lib/es/timePicker/TimeShape.d.ts +1 -1
- package/lib/es/timePicker/index.d.ts +2 -2
- package/lib/es/toast/index.d.ts +9 -0
- package/lib/es/toast/index.js +50 -10
- package/lib/es/toast/toast.d.ts +1 -0
- package/lib/es/toast/toast.js +4 -0
- package/lib/es/typography/base.d.ts +1 -1
- package/lib/es/typography/paragraph.d.ts +1 -1
- package/lib/es/typography/text.d.ts +1 -1
- package/lib/es/typography/title.d.ts +2 -2
- package/lib/es/upload/index.d.ts +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { IconClose } from "@douyinfe/semi-icons";
|
|
3
|
+
import { cssClasses } from '@douyinfe/semi-foundation/lib/es/image/constants';
|
|
4
|
+
import cls from "classnames";
|
|
5
|
+
import { PreviewContext } from "./previewContext";
|
|
6
|
+
const prefixCls = "".concat(cssClasses.PREFIX, "-preview-header");
|
|
7
|
+
|
|
8
|
+
const Header = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
onClose,
|
|
11
|
+
titleStyle,
|
|
12
|
+
className,
|
|
13
|
+
renderHeader
|
|
14
|
+
} = _ref;
|
|
15
|
+
return /*#__PURE__*/React.createElement(PreviewContext.Consumer, null, _ref2 => {
|
|
16
|
+
let {
|
|
17
|
+
currentIndex,
|
|
18
|
+
titles
|
|
19
|
+
} = _ref2;
|
|
20
|
+
let title;
|
|
21
|
+
|
|
22
|
+
if (titles && typeof currentIndex === "number") {
|
|
23
|
+
title = titles[currentIndex];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return /*#__PURE__*/React.createElement("section", {
|
|
27
|
+
className: cls(prefixCls, className)
|
|
28
|
+
}, /*#__PURE__*/React.createElement("section", {
|
|
29
|
+
className: "".concat(prefixCls, "-title"),
|
|
30
|
+
style: titleStyle
|
|
31
|
+
}, renderHeader ? renderHeader(title) : title), /*#__PURE__*/React.createElement("section", {
|
|
32
|
+
className: "".concat(prefixCls, "-close"),
|
|
33
|
+
onMouseUp: onClose
|
|
34
|
+
}, /*#__PURE__*/React.createElement(IconClose, null)));
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default Header;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import BaseComponent from "../_base/baseComponent";
|
|
3
|
+
import { PreviewImageProps, PreviewImageStates } from "./interface";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import PreviewImageFoundation, { PreviewImageAdapter } from '@douyinfe/semi-foundation/lib/es/image/previewImageFoundation';
|
|
6
|
+
export default class PreviewImage extends BaseComponent<PreviewImageProps, PreviewImageStates> {
|
|
7
|
+
static propTypes: {
|
|
8
|
+
src: PropTypes.Requireable<string>;
|
|
9
|
+
rotation: PropTypes.Requireable<number>;
|
|
10
|
+
style: PropTypes.Requireable<object>;
|
|
11
|
+
maxZoom: PropTypes.Requireable<number>;
|
|
12
|
+
minZoom: PropTypes.Requireable<number>;
|
|
13
|
+
zoomStep: PropTypes.Requireable<number>;
|
|
14
|
+
zoom: PropTypes.Requireable<number>;
|
|
15
|
+
ratio: PropTypes.Requireable<string>;
|
|
16
|
+
disableDownload: PropTypes.Requireable<number>;
|
|
17
|
+
clickZoom: PropTypes.Requireable<number>;
|
|
18
|
+
setRatio: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
onZoom: PropTypes.Requireable<(...args: any[]) => any>;
|
|
20
|
+
onLoad: PropTypes.Requireable<(...args: any[]) => any>;
|
|
21
|
+
onError: PropTypes.Requireable<(...args: any[]) => any>;
|
|
22
|
+
};
|
|
23
|
+
static defaultProps: {
|
|
24
|
+
maxZoom: number;
|
|
25
|
+
minZoom: number;
|
|
26
|
+
zoomStep: number;
|
|
27
|
+
zoom: any;
|
|
28
|
+
};
|
|
29
|
+
get adapter(): PreviewImageAdapter<PreviewImageProps, PreviewImageStates>;
|
|
30
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
31
|
+
imageRef: React.RefObject<HTMLImageElement>;
|
|
32
|
+
foundation: PreviewImageFoundation;
|
|
33
|
+
constructor(props: any);
|
|
34
|
+
componentDidMount(): void;
|
|
35
|
+
componentWillUnmount(): void;
|
|
36
|
+
componentDidUpdate(prevProps: PreviewImageProps, prevStates: PreviewImageStates): void;
|
|
37
|
+
onWindowResize: () => void;
|
|
38
|
+
handleZoomChange: (newZoom: any, e: any) => void;
|
|
39
|
+
handleRightClickImage: (e: any) => void;
|
|
40
|
+
handleWheel: (e: any) => void;
|
|
41
|
+
handleLoad: (e: any) => void;
|
|
42
|
+
handleError: (e: any) => void;
|
|
43
|
+
resizeImage: () => void;
|
|
44
|
+
handleMoveImage: (e: any) => void;
|
|
45
|
+
registryImageRef: (ref: any) => void;
|
|
46
|
+
onImageMouseDown: (e: React.MouseEvent<HTMLImageElement>) => void;
|
|
47
|
+
onImageMouseUp: () => void;
|
|
48
|
+
render(): JSX.Element;
|
|
49
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import BaseComponent from "../_base/baseComponent";
|
|
3
|
+
import { cssClasses } from '@douyinfe/semi-foundation/lib/es/image/constants';
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import Spin from "../spin";
|
|
6
|
+
import PreviewImageFoundation from '@douyinfe/semi-foundation/lib/es/image/previewImageFoundation';
|
|
7
|
+
const prefixCls = cssClasses.PREFIX;
|
|
8
|
+
const preViewImgPrefixCls = "".concat(prefixCls, "-preview-image");
|
|
9
|
+
let originImageWidth = null;
|
|
10
|
+
let originImageHeight = null;
|
|
11
|
+
let startMouseMove = false; // startMouseOffset:The offset of the mouse relative to the left and top of the picture
|
|
12
|
+
|
|
13
|
+
let startMouseOffset = {
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0
|
|
16
|
+
};
|
|
17
|
+
export default class PreviewImage extends BaseComponent {
|
|
18
|
+
constructor(props) {
|
|
19
|
+
super(props);
|
|
20
|
+
|
|
21
|
+
this.onWindowResize = () => {
|
|
22
|
+
this.foundation.handleWindowResize();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
this.handleZoomChange = (newZoom, e) => {
|
|
26
|
+
this.foundation.handleZoomChange(newZoom, e);
|
|
27
|
+
}; // Determine the response method of right click according to the disableDownload parameter in props
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
this.handleRightClickImage = e => {
|
|
31
|
+
this.foundation.handleRightClickImage(e);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
this.handleWheel = e => {
|
|
35
|
+
this.foundation.handleWheel(e);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
this.handleLoad = e => {
|
|
39
|
+
this.foundation.handleLoad(e);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
this.handleError = e => {
|
|
43
|
+
this.foundation.handleError(e);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
this.resizeImage = () => {
|
|
47
|
+
this.foundation.handleResizeImage();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
this.handleMoveImage = e => {
|
|
51
|
+
this.foundation.handleMoveImage(e);
|
|
52
|
+
}; // 为什么通过ref注册wheel而不是使用onWheel事件?
|
|
53
|
+
// 因为对于wheel事件,浏览器将 addEventListener 的 passive 默认值更改为 true。如此,事件监听器便不能取消事件,也不会在用户滚动页面时阻止页面呈现。
|
|
54
|
+
// 这里我们需要保持页面不动,仅放大图片,因此此处需要将 passive 更改设置为 false。
|
|
55
|
+
// Why register wheel via ref instead of using onWheel event?
|
|
56
|
+
// Because for wheel events, the browser changes the passive default of addEventListener to true. This way, the event listener cannot cancel the event, nor prevent the page from rendering when the user scrolls.
|
|
57
|
+
// Here we need to keep the page still and only zoom in on the image, so here we need to set the passive change to false.
|
|
58
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners。
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
this.registryImageRef = ref => {
|
|
62
|
+
if (this.imageRef && this.imageRef.current) {
|
|
63
|
+
this.imageRef.removeEventListener("wheel", this.handleWheel);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (ref) {
|
|
67
|
+
ref.addEventListener("wheel", this.handleWheel, {
|
|
68
|
+
passive: false
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.imageRef = ref;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
this.onImageMouseDown = e => {
|
|
76
|
+
this.foundation.handleImageMouseDown(e);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
this.onImageMouseUp = () => {
|
|
80
|
+
this.foundation.handleImageMouseUp();
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
this.state = {
|
|
84
|
+
width: 0,
|
|
85
|
+
height: 0,
|
|
86
|
+
loading: true,
|
|
87
|
+
offset: {
|
|
88
|
+
x: 0,
|
|
89
|
+
y: 0
|
|
90
|
+
},
|
|
91
|
+
currZoom: 0,
|
|
92
|
+
top: 0,
|
|
93
|
+
left: 0
|
|
94
|
+
};
|
|
95
|
+
this.containerRef = /*#__PURE__*/React.createRef();
|
|
96
|
+
this.imageRef = /*#__PURE__*/React.createRef();
|
|
97
|
+
this.foundation = new PreviewImageFoundation(this.adapter);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get adapter() {
|
|
101
|
+
return Object.assign(Object.assign({}, super.adapter), {
|
|
102
|
+
getOriginImageSize: () => ({
|
|
103
|
+
originImageWidth,
|
|
104
|
+
originImageHeight
|
|
105
|
+
}),
|
|
106
|
+
setOriginImageSize: size => {
|
|
107
|
+
originImageWidth = size.originImageWidth;
|
|
108
|
+
originImageHeight = size.originImageHeight;
|
|
109
|
+
},
|
|
110
|
+
getContainerRef: () => {
|
|
111
|
+
return this.containerRef;
|
|
112
|
+
},
|
|
113
|
+
getImageRef: () => {
|
|
114
|
+
return this.imageRef;
|
|
115
|
+
},
|
|
116
|
+
getMouseMove: () => startMouseMove,
|
|
117
|
+
setStartMouseMove: move => {
|
|
118
|
+
startMouseMove = move;
|
|
119
|
+
},
|
|
120
|
+
getMouseOffset: () => startMouseOffset,
|
|
121
|
+
setStartMouseOffset: offset => {
|
|
122
|
+
startMouseOffset = offset;
|
|
123
|
+
},
|
|
124
|
+
setLoading: loading => {
|
|
125
|
+
this.setState({
|
|
126
|
+
loading
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
componentDidMount() {
|
|
133
|
+
window.addEventListener("resize", this.onWindowResize);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
componentWillUnmount() {
|
|
137
|
+
window.removeEventListener("resize", this.onWindowResize);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
componentDidUpdate(prevProps, prevStates) {
|
|
141
|
+
// If src changes, start a new loading
|
|
142
|
+
if (this.props.src && this.props.src !== prevProps.src) {
|
|
143
|
+
this.foundation.setLoading(true);
|
|
144
|
+
} // If the incoming zoom changes, other content changes are determined based on the new zoom value
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
if ("zoom" in this.props && this.props.zoom !== prevStates.currZoom) {
|
|
148
|
+
this.handleZoomChange(this.props.zoom, null);
|
|
149
|
+
} // When the incoming ratio is changed, if it"s adaptation, then resizeImage is triggered to make the image adapt to the page
|
|
150
|
+
// else if it"s adaptation is realSize, then onZoom(1) is called to make the image size the original size;
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
if ("ratio" in this.props && this.props.ratio !== prevProps.ratio) {
|
|
154
|
+
if (originImageWidth && originImageHeight) {
|
|
155
|
+
if (this.props.ratio === "adaptation") {
|
|
156
|
+
this.resizeImage();
|
|
157
|
+
} else {
|
|
158
|
+
this.props.onZoom(1);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
} // When the incoming rotation angle of the image changes, it needs to be resized to make the image fit on the page
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
if ("rotation" in this.props && this.props.rotation !== prevProps.rotation) {
|
|
165
|
+
this.onWindowResize();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
render() {
|
|
170
|
+
const {
|
|
171
|
+
src,
|
|
172
|
+
rotation
|
|
173
|
+
} = this.props;
|
|
174
|
+
const {
|
|
175
|
+
loading,
|
|
176
|
+
width,
|
|
177
|
+
height,
|
|
178
|
+
top,
|
|
179
|
+
left
|
|
180
|
+
} = this.state;
|
|
181
|
+
const imgStyle = {
|
|
182
|
+
position: "absolute",
|
|
183
|
+
visibility: loading ? "hidden" : "visible",
|
|
184
|
+
transform: "rotate(".concat(-rotation, "deg)"),
|
|
185
|
+
top,
|
|
186
|
+
left,
|
|
187
|
+
width: loading ? "auto" : "".concat(width, "px"),
|
|
188
|
+
height: loading ? "auto" : "".concat(height, "px")
|
|
189
|
+
};
|
|
190
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
191
|
+
className: "".concat(preViewImgPrefixCls),
|
|
192
|
+
ref: this.containerRef
|
|
193
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
194
|
+
ref: this.registryImageRef,
|
|
195
|
+
src: src,
|
|
196
|
+
alt: "previewImag",
|
|
197
|
+
className: "".concat(preViewImgPrefixCls, "-img"),
|
|
198
|
+
key: src,
|
|
199
|
+
onMouseMove: this.handleMoveImage,
|
|
200
|
+
onMouseDown: this.onImageMouseDown,
|
|
201
|
+
onMouseUp: this.onImageMouseUp,
|
|
202
|
+
onContextMenu: this.handleRightClickImage,
|
|
203
|
+
onDragStart: e => e.preventDefault(),
|
|
204
|
+
onLoad: this.handleLoad,
|
|
205
|
+
onError: this.handleError,
|
|
206
|
+
style: imgStyle
|
|
207
|
+
}), loading && /*#__PURE__*/React.createElement(Spin, {
|
|
208
|
+
size: "large",
|
|
209
|
+
wrapperClassName: "".concat(preViewImgPrefixCls, "-spin")
|
|
210
|
+
}));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
PreviewImage.propTypes = {
|
|
215
|
+
src: PropTypes.string,
|
|
216
|
+
rotation: PropTypes.number,
|
|
217
|
+
style: PropTypes.object,
|
|
218
|
+
maxZoom: PropTypes.number,
|
|
219
|
+
minZoom: PropTypes.number,
|
|
220
|
+
zoomStep: PropTypes.number,
|
|
221
|
+
zoom: PropTypes.number,
|
|
222
|
+
ratio: PropTypes.string,
|
|
223
|
+
disableDownload: PropTypes.number,
|
|
224
|
+
clickZoom: PropTypes.number,
|
|
225
|
+
setRatio: PropTypes.func,
|
|
226
|
+
onZoom: PropTypes.func,
|
|
227
|
+
onLoad: PropTypes.func,
|
|
228
|
+
onError: PropTypes.func
|
|
229
|
+
};
|
|
230
|
+
PreviewImage.defaultProps = {
|
|
231
|
+
maxZoom: 5,
|
|
232
|
+
minZoom: 0.1,
|
|
233
|
+
zoomStep: 0.1,
|
|
234
|
+
zoom: undefined
|
|
235
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import BaseComponent from "../_base/baseComponent";
|
|
3
|
+
import { PreviewProps as PreviewInnerProps, PreviewInnerStates, RatioType } from "./interface";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import PreviewInnerFoundation, { PreviewInnerAdapter } from '@douyinfe/semi-foundation/lib/es/image/previewInnerFoundation';
|
|
6
|
+
import { PreviewContextProps } from "./previewContext";
|
|
7
|
+
export default class PreviewInner extends BaseComponent<PreviewInnerProps, PreviewInnerStates> {
|
|
8
|
+
static contextType: React.Context<PreviewContextProps>;
|
|
9
|
+
static propTypes: {
|
|
10
|
+
style: PropTypes.Requireable<object>;
|
|
11
|
+
className: PropTypes.Requireable<string>;
|
|
12
|
+
visible: PropTypes.Requireable<boolean>;
|
|
13
|
+
src: PropTypes.Requireable<string | any[]>;
|
|
14
|
+
currentIndex: PropTypes.Requireable<number>;
|
|
15
|
+
defaultIndex: PropTypes.Requireable<number>;
|
|
16
|
+
defaultVisible: PropTypes.Requireable<boolean>;
|
|
17
|
+
maskClosable: PropTypes.Requireable<boolean>;
|
|
18
|
+
closable: PropTypes.Requireable<boolean>;
|
|
19
|
+
zoomStep: PropTypes.Requireable<number>;
|
|
20
|
+
infinite: PropTypes.Requireable<boolean>;
|
|
21
|
+
showTooltip: PropTypes.Requireable<boolean>;
|
|
22
|
+
closeOnEsc: PropTypes.Requireable<boolean>;
|
|
23
|
+
prevTip: PropTypes.Requireable<string>;
|
|
24
|
+
nextTip: PropTypes.Requireable<string>;
|
|
25
|
+
zoomInTip: PropTypes.Requireable<string>;
|
|
26
|
+
zoomOutTip: PropTypes.Requireable<string>;
|
|
27
|
+
downloadTip: PropTypes.Requireable<string>;
|
|
28
|
+
adaptiveTip: PropTypes.Requireable<string>;
|
|
29
|
+
originTip: PropTypes.Requireable<string>;
|
|
30
|
+
lazyLoad: PropTypes.Requireable<boolean>;
|
|
31
|
+
preLoad: PropTypes.Requireable<boolean>;
|
|
32
|
+
preLoadGap: PropTypes.Requireable<number>;
|
|
33
|
+
disableDownload: PropTypes.Requireable<boolean>;
|
|
34
|
+
viewerVisibleDelay: PropTypes.Requireable<number>;
|
|
35
|
+
zIndex: PropTypes.Requireable<number>;
|
|
36
|
+
renderHeader: PropTypes.Requireable<(...args: any[]) => any>;
|
|
37
|
+
renderPreviewMenu: PropTypes.Requireable<(...args: any[]) => any>;
|
|
38
|
+
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
39
|
+
onVisibleChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
41
|
+
onClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
42
|
+
onZoomIn: PropTypes.Requireable<(...args: any[]) => any>;
|
|
43
|
+
onZoomOut: PropTypes.Requireable<(...args: any[]) => any>;
|
|
44
|
+
onPrev: PropTypes.Requireable<(...args: any[]) => any>;
|
|
45
|
+
onNext: PropTypes.Requireable<(...args: any[]) => any>;
|
|
46
|
+
onDownload: PropTypes.Requireable<(...args: any[]) => any>;
|
|
47
|
+
onRatioChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
48
|
+
onRotateChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
49
|
+
};
|
|
50
|
+
static defaultProps: {
|
|
51
|
+
showTooltip: boolean;
|
|
52
|
+
zoomStep: number;
|
|
53
|
+
infinite: boolean;
|
|
54
|
+
closeOnEsc: boolean;
|
|
55
|
+
lazyLoad: boolean;
|
|
56
|
+
preLoad: boolean;
|
|
57
|
+
preLoadGap: number;
|
|
58
|
+
zIndex: number;
|
|
59
|
+
maskClosable: boolean;
|
|
60
|
+
viewerVisibleDelay: number;
|
|
61
|
+
};
|
|
62
|
+
get adapter(): PreviewInnerAdapter<PreviewInnerProps, PreviewInnerStates>;
|
|
63
|
+
timer: any;
|
|
64
|
+
context: PreviewContextProps;
|
|
65
|
+
foundation: PreviewInnerFoundation;
|
|
66
|
+
constructor(props: PreviewInnerProps);
|
|
67
|
+
static getDerivedStateFromProps(props: PreviewInnerProps, state: PreviewInnerStates): Partial<PreviewInnerStates>;
|
|
68
|
+
componentDidUpdate(prevProps: PreviewInnerProps, prevState: PreviewInnerStates): void;
|
|
69
|
+
componentWillUnmount(): void;
|
|
70
|
+
isInGroup(): boolean;
|
|
71
|
+
viewVisibleChange: () => void;
|
|
72
|
+
handleSwitchImage: (direction: string) => void;
|
|
73
|
+
handleDownload: () => void;
|
|
74
|
+
handlePreviewClose: () => void;
|
|
75
|
+
handleAdjustRatio: (type: string) => void;
|
|
76
|
+
handleRotateImage: (direction: any) => void;
|
|
77
|
+
handleZoomImage: (newZoom: number) => void;
|
|
78
|
+
handleMouseUp: (e: any) => void;
|
|
79
|
+
handleMouseMove: (e: any) => void;
|
|
80
|
+
handleMouseEvent: (e: any, event: string) => void;
|
|
81
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
82
|
+
onImageError: () => void;
|
|
83
|
+
onImageLoad: (src: any) => void;
|
|
84
|
+
handleMouseDown: (e: any) => void;
|
|
85
|
+
handleRatio: (type: RatioType) => void;
|
|
86
|
+
render(): JSX.Element;
|
|
87
|
+
}
|