@douyinfe/semi-ui 2.49.1 → 2.50.0-alpha.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 +74 -161
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +465 -389
- 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/image/interface.d.ts +3 -3
- package/lib/cjs/image/previewFooter.js +8 -5
- package/lib/cjs/image/previewHeader.d.ts +2 -2
- package/lib/cjs/image/previewHeader.js +8 -9
- package/lib/cjs/image/previewImage.d.ts +12 -1
- package/lib/cjs/image/previewImage.js +83 -23
- package/lib/cjs/image/previewInner.d.ts +2 -11
- package/lib/cjs/image/previewInner.js +42 -60
- package/lib/cjs/index.d.ts +0 -2
- package/lib/cjs/index.js +0 -14
- package/lib/cjs/modal/confirm.d.ts +6 -6
- package/lib/cjs/notification/index.d.ts +8 -8
- package/lib/cjs/notification/notice.d.ts +1 -1
- package/lib/cjs/notification/notice.js +1 -1
- package/lib/cjs/table/ColumnSorter.d.ts +3 -1
- package/lib/cjs/table/ColumnSorter.js +26 -15
- package/lib/cjs/table/Table.js +1 -0
- package/lib/cjs/table/interface.d.ts +4 -0
- package/lib/cjs/tree/indent.d.ts +9 -0
- package/lib/cjs/tree/indent.js +37 -0
- package/lib/cjs/tree/index.d.ts +2 -0
- package/lib/cjs/tree/index.js +8 -3
- package/lib/cjs/tree/interface.d.ts +2 -0
- package/lib/cjs/tree/treeNode.d.ts +3 -0
- package/lib/cjs/tree/treeNode.js +34 -6
- package/lib/cjs/treeSelect/index.d.ts +2 -1
- package/lib/cjs/treeSelect/index.js +7 -2
- package/lib/es/image/interface.d.ts +3 -3
- package/lib/es/image/previewFooter.js +8 -5
- package/lib/es/image/previewHeader.d.ts +2 -2
- package/lib/es/image/previewHeader.js +3 -4
- package/lib/es/image/previewImage.d.ts +12 -1
- package/lib/es/image/previewImage.js +83 -23
- package/lib/es/image/previewInner.d.ts +2 -11
- package/lib/es/image/previewInner.js +42 -60
- package/lib/es/index.d.ts +0 -2
- package/lib/es/index.js +0 -2
- package/lib/es/modal/confirm.d.ts +6 -6
- package/lib/es/notification/index.d.ts +8 -8
- package/lib/es/notification/notice.d.ts +1 -1
- package/lib/es/notification/notice.js +1 -1
- package/lib/es/table/ColumnSorter.d.ts +3 -1
- package/lib/es/table/ColumnSorter.js +26 -15
- package/lib/es/table/Table.js +1 -0
- package/lib/es/table/interface.d.ts +4 -0
- package/lib/es/tree/indent.d.ts +9 -0
- package/lib/es/tree/indent.js +27 -0
- package/lib/es/tree/index.d.ts +2 -0
- package/lib/es/tree/index.js +8 -3
- package/lib/es/tree/interface.d.ts +2 -0
- package/lib/es/tree/treeNode.d.ts +3 -0
- package/lib/es/tree/treeNode.js +34 -6
- package/lib/es/treeSelect/index.d.ts +2 -1
- package/lib/es/treeSelect/index.js +7 -2
- package/package.json +8 -8
|
@@ -6,14 +6,38 @@ import Spin from "../spin";
|
|
|
6
6
|
import PreviewImageFoundation from '@douyinfe/semi-foundation/lib/es/image/previewImageFoundation';
|
|
7
7
|
const prefixCls = cssClasses.PREFIX;
|
|
8
8
|
const preViewImgPrefixCls = `${prefixCls}-preview-image`;
|
|
9
|
+
let originImageWidth = null;
|
|
10
|
+
let originImageHeight = null;
|
|
11
|
+
let startMouseMove = false;
|
|
12
|
+
// startMouseOffset:The offset of the mouse relative to the left and top of the picture
|
|
13
|
+
let startMouseOffset = {
|
|
14
|
+
x: 0,
|
|
15
|
+
y: 0
|
|
16
|
+
};
|
|
9
17
|
export default class PreviewImage extends BaseComponent {
|
|
10
18
|
get adapter() {
|
|
11
19
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
20
|
+
getOriginImageSize: () => ({
|
|
21
|
+
originImageWidth,
|
|
22
|
+
originImageHeight
|
|
23
|
+
}),
|
|
24
|
+
setOriginImageSize: size => {
|
|
25
|
+
originImageWidth = size.originImageWidth;
|
|
26
|
+
originImageHeight = size.originImageHeight;
|
|
27
|
+
},
|
|
12
28
|
getContainer: () => {
|
|
13
29
|
return this.containerRef.current;
|
|
14
30
|
},
|
|
15
31
|
getImage: () => {
|
|
16
|
-
return this.imageRef
|
|
32
|
+
return this.imageRef;
|
|
33
|
+
},
|
|
34
|
+
getMouseMove: () => startMouseMove,
|
|
35
|
+
setStartMouseMove: move => {
|
|
36
|
+
startMouseMove = move;
|
|
37
|
+
},
|
|
38
|
+
getMouseOffset: () => startMouseOffset,
|
|
39
|
+
setStartMouseOffset: offset => {
|
|
40
|
+
startMouseOffset = offset;
|
|
17
41
|
},
|
|
18
42
|
setLoading: loading => {
|
|
19
43
|
this.setState({
|
|
@@ -21,7 +45,7 @@ export default class PreviewImage extends BaseComponent {
|
|
|
21
45
|
});
|
|
22
46
|
},
|
|
23
47
|
setImageCursor: canDrag => {
|
|
24
|
-
this.imageRef.
|
|
48
|
+
this.imageRef.style.cursor = canDrag ? "grab" : "default";
|
|
25
49
|
}
|
|
26
50
|
});
|
|
27
51
|
}
|
|
@@ -30,22 +54,52 @@ export default class PreviewImage extends BaseComponent {
|
|
|
30
54
|
this.onWindowResize = () => {
|
|
31
55
|
this.foundation.handleWindowResize();
|
|
32
56
|
};
|
|
57
|
+
this.handleZoomChange = (newZoom, e) => {
|
|
58
|
+
this.foundation.handleZoomChange(newZoom, e);
|
|
59
|
+
};
|
|
33
60
|
// Determine the response method of right click according to the disableDownload parameter in props
|
|
34
61
|
this.handleRightClickImage = e => {
|
|
35
62
|
this.foundation.handleRightClickImage(e);
|
|
36
63
|
};
|
|
64
|
+
this.handleWheel = e => {
|
|
65
|
+
this.foundation.handleWheel(e);
|
|
66
|
+
};
|
|
37
67
|
this.handleLoad = e => {
|
|
38
68
|
this.foundation.handleLoad(e);
|
|
39
69
|
};
|
|
40
70
|
this.handleError = e => {
|
|
41
71
|
this.foundation.handleError(e);
|
|
42
72
|
};
|
|
73
|
+
this.resizeImage = () => {
|
|
74
|
+
this.foundation.handleResizeImage();
|
|
75
|
+
};
|
|
43
76
|
this.handleMoveImage = e => {
|
|
44
77
|
this.foundation.handleMoveImage(e);
|
|
45
78
|
};
|
|
79
|
+
// 为什么通过ref注册wheel而不是使用onWheel事件?
|
|
80
|
+
// 因为对于wheel事件,浏览器将 addEventListener 的 passive 默认值更改为 true。如此,事件监听器便不能取消事件,也不会在用户滚动页面时阻止页面呈现。
|
|
81
|
+
// 这里我们需要保持页面不动,仅放大图片,因此此处需要将 passive 更改设置为 false。
|
|
82
|
+
// Why register wheel via ref instead of using onWheel event?
|
|
83
|
+
// 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.
|
|
84
|
+
// 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.
|
|
85
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners。
|
|
86
|
+
this.registryImageRef = ref => {
|
|
87
|
+
if (this.imageRef) {
|
|
88
|
+
this.imageRef.removeEventListener("wheel", this.handleWheel);
|
|
89
|
+
}
|
|
90
|
+
if (ref) {
|
|
91
|
+
ref.addEventListener("wheel", this.handleWheel, {
|
|
92
|
+
passive: false
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
this.imageRef = ref;
|
|
96
|
+
};
|
|
46
97
|
this.onImageMouseDown = e => {
|
|
47
98
|
this.foundation.handleImageMouseDown(e);
|
|
48
99
|
};
|
|
100
|
+
this.onImageMouseUp = () => {
|
|
101
|
+
this.foundation.handleImageMouseUp();
|
|
102
|
+
};
|
|
49
103
|
this.state = {
|
|
50
104
|
width: 0,
|
|
51
105
|
height: 0,
|
|
@@ -59,7 +113,7 @@ export default class PreviewImage extends BaseComponent {
|
|
|
59
113
|
left: 0
|
|
60
114
|
};
|
|
61
115
|
this.containerRef = /*#__PURE__*/React.createRef();
|
|
62
|
-
this.imageRef =
|
|
116
|
+
this.imageRef = null;
|
|
63
117
|
this.foundation = new PreviewImageFoundation(this.adapter);
|
|
64
118
|
}
|
|
65
119
|
componentDidMount() {
|
|
@@ -70,23 +124,28 @@ export default class PreviewImage extends BaseComponent {
|
|
|
70
124
|
}
|
|
71
125
|
componentDidUpdate(prevProps, prevStates) {
|
|
72
126
|
// If src changes, start a new loading
|
|
73
|
-
|
|
74
|
-
const srcChange = this.props.src && this.props.src !== prevProps.src;
|
|
75
|
-
if (srcChange) {
|
|
127
|
+
if (this.props.src && this.props.src !== prevProps.src) {
|
|
76
128
|
this.foundation.setLoading(true);
|
|
77
129
|
}
|
|
78
130
|
// If the incoming zoom changes, other content changes are determined based on the new zoom value
|
|
79
|
-
if (
|
|
80
|
-
this.
|
|
131
|
+
if ("zoom" in this.props && this.props.zoom !== prevStates.currZoom) {
|
|
132
|
+
this.handleZoomChange(this.props.zoom, null);
|
|
81
133
|
}
|
|
82
|
-
if
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
134
|
+
// When the incoming ratio is changed, if it"s adaptation, then resizeImage is triggered to make the image adapt to the page
|
|
135
|
+
// else if it"s adaptation is realSize, then onZoom(1) is called to make the image size the original size;
|
|
136
|
+
if ("ratio" in this.props && this.props.ratio !== prevProps.ratio) {
|
|
137
|
+
if (originImageWidth && originImageHeight) {
|
|
138
|
+
if (this.props.ratio === "adaptation") {
|
|
139
|
+
this.resizeImage();
|
|
140
|
+
} else {
|
|
141
|
+
this.props.onZoom(1);
|
|
142
|
+
}
|
|
88
143
|
}
|
|
89
144
|
}
|
|
145
|
+
// When the incoming rotation angle of the image changes, it needs to be resized to make the image fit on the page
|
|
146
|
+
if ("rotation" in this.props && this.props.rotation !== prevProps.rotation) {
|
|
147
|
+
this.onWindowResize();
|
|
148
|
+
}
|
|
90
149
|
}
|
|
91
150
|
render() {
|
|
92
151
|
const {
|
|
@@ -107,20 +166,21 @@ export default class PreviewImage extends BaseComponent {
|
|
|
107
166
|
transform: `rotate(${-rotation}deg)`,
|
|
108
167
|
top,
|
|
109
168
|
left,
|
|
110
|
-
width
|
|
111
|
-
height
|
|
169
|
+
width: loading ? "auto" : `${width}px`,
|
|
170
|
+
height: loading ? "auto" : `${height}px`
|
|
112
171
|
};
|
|
113
172
|
return /*#__PURE__*/React.createElement("div", {
|
|
114
173
|
className: `${preViewImgPrefixCls}`,
|
|
115
174
|
ref: this.containerRef
|
|
116
175
|
}, /*#__PURE__*/React.createElement("img", {
|
|
117
|
-
ref: this.
|
|
176
|
+
ref: this.registryImageRef,
|
|
118
177
|
src: src,
|
|
119
178
|
alt: "previewImag",
|
|
120
179
|
className: `${preViewImgPrefixCls}-img`,
|
|
121
180
|
key: src,
|
|
122
181
|
onMouseMove: this.handleMoveImage,
|
|
123
182
|
onMouseDown: this.onImageMouseDown,
|
|
183
|
+
onMouseUp: this.onImageMouseUp,
|
|
124
184
|
onContextMenu: this.handleRightClickImage,
|
|
125
185
|
onDragStart: e => e.preventDefault(),
|
|
126
186
|
onLoad: this.handleLoad,
|
|
@@ -137,9 +197,9 @@ PreviewImage.propTypes = {
|
|
|
137
197
|
src: PropTypes.string,
|
|
138
198
|
rotation: PropTypes.number,
|
|
139
199
|
style: PropTypes.object,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
200
|
+
maxZoom: PropTypes.number,
|
|
201
|
+
minZoom: PropTypes.number,
|
|
202
|
+
zoomStep: PropTypes.number,
|
|
143
203
|
zoom: PropTypes.number,
|
|
144
204
|
ratio: PropTypes.string,
|
|
145
205
|
disableDownload: PropTypes.bool,
|
|
@@ -150,8 +210,8 @@ PreviewImage.propTypes = {
|
|
|
150
210
|
onError: PropTypes.func
|
|
151
211
|
};
|
|
152
212
|
PreviewImage.defaultProps = {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
213
|
+
maxZoom: 5,
|
|
214
|
+
minZoom: 0.1,
|
|
215
|
+
zoomStep: 0.1,
|
|
156
216
|
zoom: undefined
|
|
157
217
|
};
|
|
@@ -33,8 +33,6 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
|
|
|
33
33
|
disableDownload: PropTypes.Requireable<boolean>;
|
|
34
34
|
viewerVisibleDelay: PropTypes.Requireable<number>;
|
|
35
35
|
zIndex: PropTypes.Requireable<number>;
|
|
36
|
-
maxZoom: PropTypes.Requireable<number>;
|
|
37
|
-
minZoom: PropTypes.Requireable<number>;
|
|
38
36
|
renderHeader: PropTypes.Requireable<(...args: any[]) => any>;
|
|
39
37
|
renderPreviewMenu: PropTypes.Requireable<(...args: any[]) => any>;
|
|
40
38
|
getPopupContainer: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -60,20 +58,14 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
|
|
|
60
58
|
zIndex: number;
|
|
61
59
|
maskClosable: boolean;
|
|
62
60
|
viewerVisibleDelay: number;
|
|
63
|
-
maxZoom: number;
|
|
64
|
-
minZoom: number;
|
|
65
61
|
};
|
|
66
62
|
private bodyOverflow;
|
|
67
63
|
private scrollBarWidth;
|
|
68
64
|
private originBodyWidth;
|
|
69
65
|
get adapter(): PreviewInnerAdapter<PreviewInnerProps, PreviewInnerStates>;
|
|
66
|
+
timer: any;
|
|
70
67
|
context: PreviewContextProps;
|
|
71
68
|
foundation: PreviewInnerFoundation;
|
|
72
|
-
imageWrapRef: React.RefObject<HTMLDivElement>;
|
|
73
|
-
headerRef: React.RefObject<HTMLElement>;
|
|
74
|
-
footerRef: React.RefObject<HTMLElement>;
|
|
75
|
-
leftIconRef: React.RefObject<HTMLDivElement>;
|
|
76
|
-
rightIconRef: React.RefObject<HTMLDivElement>;
|
|
77
69
|
constructor(props: PreviewInnerProps);
|
|
78
70
|
static getDerivedStateFromProps(props: PreviewInnerProps, state: PreviewInnerStates): Partial<PreviewInnerStates>;
|
|
79
71
|
componentDidMount(): void;
|
|
@@ -89,11 +81,10 @@ export default class PreviewInner extends BaseComponent<PreviewInnerProps, Previ
|
|
|
89
81
|
handleZoomImage: (newZoom: number) => void;
|
|
90
82
|
handleMouseUp: (e: any) => void;
|
|
91
83
|
handleMouseMove: (e: any) => void;
|
|
84
|
+
handleMouseEvent: (e: any, event: string) => void;
|
|
92
85
|
handleKeyDown: (e: KeyboardEvent) => void;
|
|
93
86
|
onImageError: () => void;
|
|
94
87
|
onImageLoad: (src: any) => void;
|
|
95
88
|
handleMouseDown: (e: any) => void;
|
|
96
|
-
handleWheel: (e: any) => void;
|
|
97
|
-
registryImageWrapRef: (ref: any) => void;
|
|
98
89
|
render(): JSX.Element;
|
|
99
90
|
}
|
|
@@ -14,6 +14,14 @@ import PreviewInnerFoundation from '@douyinfe/semi-foundation/lib/es/image/previ
|
|
|
14
14
|
import { PreviewContext } from "./previewContext";
|
|
15
15
|
import { getScrollbarWidth } from "../_utils";
|
|
16
16
|
const prefixCls = cssClasses.PREFIX;
|
|
17
|
+
let startMouseDown = {
|
|
18
|
+
x: 0,
|
|
19
|
+
y: 0
|
|
20
|
+
};
|
|
21
|
+
let mouseActiveTime = null;
|
|
22
|
+
let stopTiming = false;
|
|
23
|
+
let timer = null;
|
|
24
|
+
// let bodyOverflowValue = document.body.style.overflow;
|
|
17
25
|
export default class PreviewInner extends BaseComponent {
|
|
18
26
|
get adapter() {
|
|
19
27
|
return Object.assign(Object.assign({}, super.adapter), {
|
|
@@ -97,22 +105,30 @@ export default class PreviewInner extends BaseComponent {
|
|
|
97
105
|
unregisterKeyDownListener: () => {
|
|
98
106
|
window && window.removeEventListener("keydown", this.handleKeyDown);
|
|
99
107
|
},
|
|
108
|
+
getMouseActiveTime: () => {
|
|
109
|
+
return mouseActiveTime;
|
|
110
|
+
},
|
|
111
|
+
getStopTiming: () => {
|
|
112
|
+
return stopTiming;
|
|
113
|
+
},
|
|
114
|
+
setStopTiming: value => {
|
|
115
|
+
stopTiming = value;
|
|
116
|
+
},
|
|
117
|
+
getStartMouseDown: () => {
|
|
118
|
+
return startMouseDown;
|
|
119
|
+
},
|
|
120
|
+
setStartMouseDown: (x, y) => {
|
|
121
|
+
startMouseDown = {
|
|
122
|
+
x,
|
|
123
|
+
y
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
setMouseActiveTime: time => {
|
|
127
|
+
mouseActiveTime = time;
|
|
128
|
+
},
|
|
100
129
|
getSetDownloadFunc: () => {
|
|
101
130
|
var _a, _b;
|
|
102
131
|
return (_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.setDownloadName) !== null && _b !== void 0 ? _b : this.props.setDownloadName;
|
|
103
|
-
},
|
|
104
|
-
isValidTarget: e => {
|
|
105
|
-
const headerDom = this.headerRef && this.headerRef.current;
|
|
106
|
-
const footerDom = this.footerRef && this.footerRef.current;
|
|
107
|
-
const leftIconDom = this.leftIconRef && this.leftIconRef.current;
|
|
108
|
-
const rightIconDom = this.rightIconRef && this.rightIconRef.current;
|
|
109
|
-
const target = e.target;
|
|
110
|
-
if (headerDom && headerDom.contains(target) || footerDom && footerDom.contains(target) || leftIconDom && leftIconDom.contains(target) || rightIconDom && rightIconDom.contains(target)) {
|
|
111
|
-
// Move in the operation area, return false
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
// Move in the preview area except the operation area, return true
|
|
115
|
-
return true;
|
|
116
132
|
}
|
|
117
133
|
});
|
|
118
134
|
}
|
|
@@ -145,6 +161,9 @@ export default class PreviewInner extends BaseComponent {
|
|
|
145
161
|
this.handleMouseMove = e => {
|
|
146
162
|
this.foundation.handleMouseMove(e);
|
|
147
163
|
};
|
|
164
|
+
this.handleMouseEvent = (e, event) => {
|
|
165
|
+
this.foundation.handleMouseMoveEvent(e, event);
|
|
166
|
+
};
|
|
148
167
|
this.handleKeyDown = e => {
|
|
149
168
|
this.foundation.handleKeyDown(e);
|
|
150
169
|
};
|
|
@@ -157,31 +176,6 @@ export default class PreviewInner extends BaseComponent {
|
|
|
157
176
|
this.handleMouseDown = e => {
|
|
158
177
|
this.foundation.handleMouseDown(e);
|
|
159
178
|
};
|
|
160
|
-
this.handleWheel = e => {
|
|
161
|
-
this.foundation.handleWheel(e);
|
|
162
|
-
};
|
|
163
|
-
// 为什么通过 addEventListener 注册 wheel 事件而不是使用 onWheel 事件?
|
|
164
|
-
// 因为 Passive Event Listeners(https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners)
|
|
165
|
-
// Passive Event Listeners 是一种优化技术,用于提高滚动性能。在默认情况下,浏览器会假设事件的监听器不会调用
|
|
166
|
-
// preventDefault() 方法来阻止事件的默认行为,从而允许进行一些优化操作,例如滚动平滑。
|
|
167
|
-
// 对于 Image 而言,如果使用触控板,双指朝不同方向分开放大图片,则需要 preventDefault 防止页面整体放大。
|
|
168
|
-
// Why register wheel event through addEventListener instead of using onWheel event?
|
|
169
|
-
// Because of Passive Event Listeners(an optimization technique used to improve scrolling performance. By default,
|
|
170
|
-
// the browser will assume that event listeners will not call preventDefault() method to prevent the default behavior of the event,
|
|
171
|
-
// allowing some optimization operations such as scroll smoothing.)
|
|
172
|
-
// For Image, if we use the trackpad and spread your fingers in different directions to enlarge the image, we need to preventDefault
|
|
173
|
-
// to prevent the page from being enlarged as a whole.
|
|
174
|
-
this.registryImageWrapRef = ref => {
|
|
175
|
-
if (this.imageWrapRef) {
|
|
176
|
-
this.imageWrapRef.removeEventListener("wheel", this.handleWheel);
|
|
177
|
-
}
|
|
178
|
-
if (ref) {
|
|
179
|
-
ref.addEventListener("wheel", this.handleWheel, {
|
|
180
|
-
passive: false
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
this.imageWrapRef = ref;
|
|
184
|
-
};
|
|
185
179
|
this.state = {
|
|
186
180
|
imgSrc: [],
|
|
187
181
|
imgLoadStatus: new Map(),
|
|
@@ -198,11 +192,6 @@ export default class PreviewInner extends BaseComponent {
|
|
|
198
192
|
this.bodyOverflow = '';
|
|
199
193
|
this.originBodyWidth = '100%';
|
|
200
194
|
this.scrollBarWidth = 0;
|
|
201
|
-
this.imageWrapRef = null;
|
|
202
|
-
this.headerRef = /*#__PURE__*/React.createRef();
|
|
203
|
-
this.footerRef = /*#__PURE__*/React.createRef();
|
|
204
|
-
this.leftIconRef = /*#__PURE__*/React.createRef();
|
|
205
|
-
this.rightIconRef = /*#__PURE__*/React.createRef();
|
|
206
195
|
}
|
|
207
196
|
static getDerivedStateFromProps(props, state) {
|
|
208
197
|
const willUpdateStates = {};
|
|
@@ -218,9 +207,6 @@ export default class PreviewInner extends BaseComponent {
|
|
|
218
207
|
willUpdateStates.visible = props.visible;
|
|
219
208
|
if (props.visible) {
|
|
220
209
|
willUpdateStates.preloadAfterVisibleChange = true;
|
|
221
|
-
willUpdateStates.viewerVisible = true;
|
|
222
|
-
willUpdateStates.rotation = 0;
|
|
223
|
-
willUpdateStates.ratio = 'adaptation';
|
|
224
210
|
}
|
|
225
211
|
}
|
|
226
212
|
if ("currentIndex" in props && props.currentIndex !== state.currentIndex) {
|
|
@@ -239,8 +225,10 @@ export default class PreviewInner extends BaseComponent {
|
|
|
239
225
|
}
|
|
240
226
|
}
|
|
241
227
|
componentDidUpdate(prevProps, prevState) {
|
|
242
|
-
if (
|
|
243
|
-
|
|
228
|
+
if (prevState.visible !== this.props.visible && this.props.visible) {
|
|
229
|
+
mouseActiveTime = new Date().getTime();
|
|
230
|
+
timer && clearInterval(timer);
|
|
231
|
+
timer = setInterval(this.viewVisibleChange, 1000);
|
|
244
232
|
}
|
|
245
233
|
// hide => show
|
|
246
234
|
if (!prevProps.visible && this.props.visible) {
|
|
@@ -252,7 +240,7 @@ export default class PreviewInner extends BaseComponent {
|
|
|
252
240
|
}
|
|
253
241
|
}
|
|
254
242
|
componentWillUnmount() {
|
|
255
|
-
|
|
243
|
+
timer && clearInterval(timer);
|
|
256
244
|
}
|
|
257
245
|
isInGroup() {
|
|
258
246
|
return Boolean(this.context && this.context.isGroup);
|
|
@@ -317,10 +305,10 @@ export default class PreviewInner extends BaseComponent {
|
|
|
317
305
|
style: style,
|
|
318
306
|
onMouseDown: this.handleMouseDown,
|
|
319
307
|
onMouseUp: this.handleMouseUp,
|
|
320
|
-
|
|
321
|
-
|
|
308
|
+
onMouseMove: this.handleMouseMove,
|
|
309
|
+
onMouseOver: e => this.handleMouseEvent(e.nativeEvent, "over"),
|
|
310
|
+
onMouseOut: e => this.handleMouseEvent(e.nativeEvent, "out")
|
|
322
311
|
}, /*#__PURE__*/React.createElement(Header, {
|
|
323
|
-
ref: this.headerRef,
|
|
324
312
|
className: cls(hideViewerCls),
|
|
325
313
|
onClose: this.handlePreviewClose,
|
|
326
314
|
renderHeader: renderHeader
|
|
@@ -331,6 +319,7 @@ export default class PreviewInner extends BaseComponent {
|
|
|
331
319
|
setRatio: this.handleAdjustRatio,
|
|
332
320
|
zoom: zoom,
|
|
333
321
|
ratio: ratio,
|
|
322
|
+
zoomStep: zoomStep,
|
|
334
323
|
rotation: rotation,
|
|
335
324
|
crossOrigin: crossOrigin,
|
|
336
325
|
onError: this.onImageError,
|
|
@@ -339,7 +328,6 @@ export default class PreviewInner extends BaseComponent {
|
|
|
339
328
|
/*#__PURE__*/
|
|
340
329
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
341
330
|
React.createElement("div", {
|
|
342
|
-
ref: this.leftIconRef,
|
|
343
331
|
className: cls(`${previewPrefixCls}-icon`, `${previewPrefixCls}-prev`, hideViewerCls),
|
|
344
332
|
onClick: () => this.handleSwitchImage("prev")
|
|
345
333
|
}, /*#__PURE__*/React.createElement(IconArrowLeft, {
|
|
@@ -348,13 +336,11 @@ export default class PreviewInner extends BaseComponent {
|
|
|
348
336
|
/*#__PURE__*/
|
|
349
337
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
350
338
|
React.createElement("div", {
|
|
351
|
-
ref: this.rightIconRef,
|
|
352
339
|
className: cls(`${previewPrefixCls}-icon`, `${previewPrefixCls}-next`, hideViewerCls),
|
|
353
340
|
onClick: () => this.handleSwitchImage("next")
|
|
354
341
|
}, /*#__PURE__*/React.createElement(IconArrowRight, {
|
|
355
342
|
size: "large"
|
|
356
343
|
})), /*#__PURE__*/React.createElement(Footer, {
|
|
357
|
-
forwardRef: this.footerRef,
|
|
358
344
|
className: hideViewerCls,
|
|
359
345
|
totalNum: total,
|
|
360
346
|
curPage: currentIndex + 1,
|
|
@@ -412,8 +398,6 @@ PreviewInner.propTypes = {
|
|
|
412
398
|
disableDownload: PropTypes.bool,
|
|
413
399
|
viewerVisibleDelay: PropTypes.number,
|
|
414
400
|
zIndex: PropTypes.number,
|
|
415
|
-
maxZoom: PropTypes.number,
|
|
416
|
-
minZoom: PropTypes.number,
|
|
417
401
|
renderHeader: PropTypes.func,
|
|
418
402
|
renderPreviewMenu: PropTypes.func,
|
|
419
403
|
getPopupContainer: PropTypes.func,
|
|
@@ -438,7 +422,5 @@ PreviewInner.defaultProps = {
|
|
|
438
422
|
preLoadGap: 2,
|
|
439
423
|
zIndex: 1000,
|
|
440
424
|
maskClosable: true,
|
|
441
|
-
viewerVisibleDelay: 10000
|
|
442
|
-
maxZoom: 5,
|
|
443
|
-
minZoom: 0.1
|
|
425
|
+
viewerVisibleDelay: 10000
|
|
444
426
|
};
|
package/lib/es/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import './_base/base.css';
|
|
2
|
-
export { default as BaseFoundation } from '@douyinfe/semi-foundation/lib/es/base/foundation';
|
|
3
|
-
export { default as BaseComponent } from "./_base/baseComponent";
|
|
4
2
|
export { default as Anchor } from './anchor';
|
|
5
3
|
export { default as AutoComplete } from './autoComplete';
|
|
6
4
|
export { default as Avatar } from './avatar';
|
package/lib/es/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import './_base/base.css';
|
|
2
|
-
export { default as BaseFoundation } from '@douyinfe/semi-foundation/lib/es/base/foundation';
|
|
3
|
-
export { default as BaseComponent } from "./_base/baseComponent";
|
|
4
2
|
export { default as Anchor } from './anchor';
|
|
5
3
|
export { default as AutoComplete } from './autoComplete';
|
|
6
4
|
export { default as Avatar } from './avatar';
|
|
@@ -157,13 +157,13 @@ export declare function withError(props: ModalReactProps): {
|
|
|
157
157
|
height?: string | number;
|
|
158
158
|
content?: React.ReactNode;
|
|
159
159
|
icon: string | number | boolean | React.ReactFragment | JSX.Element;
|
|
160
|
+
onCancel?: (e: React.MouseEvent<Element, MouseEvent>) => void | Promise<any>;
|
|
160
161
|
closeOnEsc?: boolean;
|
|
161
162
|
preventScroll?: boolean;
|
|
162
163
|
afterClose?: () => void;
|
|
163
164
|
keepDOM?: boolean;
|
|
164
165
|
cancelText?: string;
|
|
165
166
|
okText?: string;
|
|
166
|
-
onCancel?: (e: React.MouseEvent<Element, MouseEvent>) => void | Promise<any>;
|
|
167
167
|
closeIcon?: React.ReactNode;
|
|
168
168
|
bodyStyle?: React.CSSProperties;
|
|
169
169
|
closable?: boolean;
|
|
@@ -377,6 +377,11 @@ export declare function withError(props: ModalReactProps): {
|
|
|
377
377
|
accessKey?: string;
|
|
378
378
|
autoFocus?: boolean;
|
|
379
379
|
content?: string;
|
|
380
|
+
formAction?: string;
|
|
381
|
+
formEncType?: string;
|
|
382
|
+
formMethod?: string;
|
|
383
|
+
formNoValidate?: boolean;
|
|
384
|
+
formTarget?: string;
|
|
380
385
|
contextMenu?: string;
|
|
381
386
|
dir?: string;
|
|
382
387
|
draggable?: boolean | "true" | "false";
|
|
@@ -458,11 +463,6 @@ export declare function withError(props: ModalReactProps): {
|
|
|
458
463
|
'aria-valuemin'?: number;
|
|
459
464
|
'aria-valuenow'?: number;
|
|
460
465
|
'aria-valuetext'?: string;
|
|
461
|
-
formAction?: string;
|
|
462
|
-
formEncType?: string;
|
|
463
|
-
formMethod?: string;
|
|
464
|
-
formNoValidate?: boolean;
|
|
465
|
-
formTarget?: string;
|
|
466
466
|
};
|
|
467
467
|
};
|
|
468
468
|
export declare function withConfirm(props: ModalReactProps): {
|
|
@@ -33,20 +33,20 @@ declare class NotificationList extends BaseComponent<NotificationListProps, Noti
|
|
|
33
33
|
constructor(props: NotificationListProps);
|
|
34
34
|
context: ContextValue;
|
|
35
35
|
get adapter(): NotificationListAdapter;
|
|
36
|
-
static addNotice(notice: NoticeProps): string
|
|
36
|
+
static addNotice(notice: NoticeProps): string;
|
|
37
37
|
static removeNotice(id: string): string;
|
|
38
|
-
static info(opts: NoticeProps): string
|
|
39
|
-
static success(opts: NoticeProps): string
|
|
40
|
-
static error(opts: NoticeProps): string
|
|
41
|
-
static warning(opts: NoticeProps): string
|
|
42
|
-
static open(opts: NoticeProps): string
|
|
38
|
+
static info(opts: NoticeProps): string;
|
|
39
|
+
static success(opts: NoticeProps): string;
|
|
40
|
+
static error(opts: NoticeProps): string;
|
|
41
|
+
static warning(opts: NoticeProps): string;
|
|
42
|
+
static open(opts: NoticeProps): string;
|
|
43
43
|
static close(id: string): string;
|
|
44
44
|
static destroyAll(): void;
|
|
45
45
|
static config(opts: ConfigProps): void;
|
|
46
46
|
add: (noticeOpts: NoticeProps) => any;
|
|
47
47
|
has: (id: string) => any;
|
|
48
|
-
remove: (id: string
|
|
49
|
-
update: (id: string
|
|
48
|
+
remove: (id: string) => void;
|
|
49
|
+
update: (id: string, opts: NoticeProps) => any;
|
|
50
50
|
destroyAll: () => any;
|
|
51
51
|
renderNoticeInPosition: (notices: NoticeInstance[], position: NoticePosition, removedItems?: NoticeInstance[], updatedItems?: NoticeInstance[]) => JSX.Element;
|
|
52
52
|
setPosInStyle(noticeInstance: NoticeInstance): {};
|
|
@@ -16,7 +16,7 @@ declare class Notice extends BaseComponent<NoticeReactProps, NoticeState> {
|
|
|
16
16
|
static contextType: React.Context<ContextValue>;
|
|
17
17
|
static propTypes: {
|
|
18
18
|
duration: PropTypes.Requireable<number>;
|
|
19
|
-
id: PropTypes.Requireable<
|
|
19
|
+
id: PropTypes.Requireable<string>;
|
|
20
20
|
title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
21
21
|
content: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
22
22
|
type: PropTypes.Requireable<string>;
|
|
@@ -161,7 +161,7 @@ class Notice extends BaseComponent {
|
|
|
161
161
|
Notice.contextType = ConfigContext;
|
|
162
162
|
Notice.propTypes = {
|
|
163
163
|
duration: PropTypes.number,
|
|
164
|
-
id: PropTypes.
|
|
164
|
+
id: PropTypes.string,
|
|
165
165
|
title: PropTypes.node,
|
|
166
166
|
content: PropTypes.node,
|
|
167
167
|
type: PropTypes.oneOf(types),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { SortOrder } from './interface';
|
|
3
|
+
import { SortIcon, SortOrder } from './interface';
|
|
4
4
|
export interface ColumnSorterProps {
|
|
5
5
|
className?: string;
|
|
6
6
|
style?: React.CSSProperties;
|
|
@@ -8,6 +8,7 @@ export interface ColumnSorterProps {
|
|
|
8
8
|
prefixCls?: string;
|
|
9
9
|
sortOrder?: SortOrder;
|
|
10
10
|
title?: React.ReactNode;
|
|
11
|
+
sortIcon?: SortIcon;
|
|
11
12
|
}
|
|
12
13
|
export default class ColumnSorter extends PureComponent<ColumnSorterProps> {
|
|
13
14
|
static propTypes: {
|
|
@@ -16,6 +17,7 @@ export default class ColumnSorter extends PureComponent<ColumnSorterProps> {
|
|
|
16
17
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
17
18
|
prefixCls: PropTypes.Requireable<string>;
|
|
18
19
|
sortOrder: PropTypes.Requireable<NonNullable<string | boolean>>;
|
|
20
|
+
sortIcon: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
21
|
};
|
|
20
22
|
static defaultProps: {
|
|
21
23
|
prefixCls: "semi-table";
|
|
@@ -12,7 +12,8 @@ export default class ColumnSorter extends PureComponent {
|
|
|
12
12
|
onClick,
|
|
13
13
|
sortOrder,
|
|
14
14
|
style,
|
|
15
|
-
title
|
|
15
|
+
title,
|
|
16
|
+
sortIcon
|
|
16
17
|
} = this.props;
|
|
17
18
|
const iconBtnSize = 'default';
|
|
18
19
|
const upCls = cls(`${prefixCls}-column-sorter-up`, {
|
|
@@ -29,25 +30,34 @@ export default class ColumnSorter extends PureComponent {
|
|
|
29
30
|
'aria-label': `Current sort order is ${sortOrder ? `${sortOrder}ing` : 'none'}`,
|
|
30
31
|
'aria-roledescription': 'Sort data with this column'
|
|
31
32
|
};
|
|
33
|
+
const renderSortIcon = () => {
|
|
34
|
+
if (typeof sortIcon === 'function') {
|
|
35
|
+
return sortIcon({
|
|
36
|
+
sortOrder
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
style: style,
|
|
41
|
+
className: `${prefixCls}-column-sorter`
|
|
42
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
className: `${upCls}`
|
|
44
|
+
}, /*#__PURE__*/React.createElement(IconCaretup, {
|
|
45
|
+
size: iconBtnSize
|
|
46
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
47
|
+
className: `${downCls}`
|
|
48
|
+
}, /*#__PURE__*/React.createElement(IconCaretdown, {
|
|
49
|
+
size: iconBtnSize
|
|
50
|
+
})));
|
|
51
|
+
}
|
|
52
|
+
};
|
|
32
53
|
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
33
|
-
role:
|
|
54
|
+
role: "button"
|
|
34
55
|
}, ariaProps, {
|
|
35
56
|
tabIndex: -1,
|
|
36
57
|
className: `${prefixCls}-column-sorter-wrapper`,
|
|
37
58
|
onClick: onClick,
|
|
38
59
|
onKeyPress: e => isEnterPress(e) && onClick(e)
|
|
39
|
-
}), title,
|
|
40
|
-
style: style,
|
|
41
|
-
className: `${prefixCls}-column-sorter`
|
|
42
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
43
|
-
className: `${upCls}`
|
|
44
|
-
}, /*#__PURE__*/React.createElement(IconCaretup, {
|
|
45
|
-
size: iconBtnSize
|
|
46
|
-
})), /*#__PURE__*/React.createElement("span", {
|
|
47
|
-
className: `${downCls}`
|
|
48
|
-
}, /*#__PURE__*/React.createElement(IconCaretdown, {
|
|
49
|
-
size: iconBtnSize
|
|
50
|
-
}))));
|
|
60
|
+
}), title, renderSortIcon());
|
|
51
61
|
}
|
|
52
62
|
}
|
|
53
63
|
ColumnSorter.propTypes = {
|
|
@@ -55,7 +65,8 @@ ColumnSorter.propTypes = {
|
|
|
55
65
|
style: PropTypes.object,
|
|
56
66
|
onClick: PropTypes.func,
|
|
57
67
|
prefixCls: PropTypes.string,
|
|
58
|
-
sortOrder: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
|
|
68
|
+
sortOrder: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
69
|
+
sortIcon: PropTypes.func
|
|
59
70
|
};
|
|
60
71
|
ColumnSorter.defaultProps = {
|
|
61
72
|
prefixCls: cssClasses.PREFIX,
|
package/lib/es/table/Table.js
CHANGED
|
@@ -637,6 +637,7 @@ class Table extends BaseComponent {
|
|
|
637
637
|
const sorter = /*#__PURE__*/React.createElement(ColumnSorter, {
|
|
638
638
|
key: strings.DEFAULT_KEY_COLUMN_SORTER,
|
|
639
639
|
sortOrder: sortOrder,
|
|
640
|
+
sortIcon: column.sortIcon,
|
|
640
641
|
onClick: e => _this2.foundation.handleSort(column, e),
|
|
641
642
|
title: TitleNode
|
|
642
643
|
});
|
|
@@ -83,6 +83,7 @@ export interface ColumnProps<RecordType extends Record<string, any> = any> {
|
|
|
83
83
|
sortChildrenRecord?: boolean;
|
|
84
84
|
sortOrder?: SortOrder;
|
|
85
85
|
sorter?: Sorter<RecordType>;
|
|
86
|
+
sortIcon?: SortIcon;
|
|
86
87
|
title?: ColumnTitle;
|
|
87
88
|
useFullRender?: boolean;
|
|
88
89
|
width?: string | number;
|
|
@@ -95,6 +96,9 @@ export interface ColumnProps<RecordType extends Record<string, any> = any> {
|
|
|
95
96
|
}
|
|
96
97
|
export type Align = BaseAlign;
|
|
97
98
|
export type SortOrder = BaseSortOrder;
|
|
99
|
+
export type SortIcon = (props: {
|
|
100
|
+
sortOrder: SortOrder;
|
|
101
|
+
}) => ReactNode;
|
|
98
102
|
export type FilterIcon = boolean | React.ReactNode | FilterIconRenderFunction;
|
|
99
103
|
export interface Filter extends BaseFilter {
|
|
100
104
|
value?: any;
|