@douyinfe/semi-foundation 2.63.1 → 2.63.2-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.
- package/chat/foundation.ts +18 -23
- package/datePicker/foundation.ts +1 -1
- package/image/image.scss +6 -1
- package/image/previewImageFoundation.ts +233 -150
- package/image/previewInnerFoundation.ts +11 -6
- package/lib/cjs/base/foundation.js +1 -1
- package/lib/cjs/chat/foundation.d.ts +1 -2
- package/lib/cjs/chat/foundation.js +2 -7
- package/lib/cjs/checkbox/checkboxGroupFoundation.js +1 -1
- package/lib/cjs/datePicker/foundation.js +1 -1
- package/lib/cjs/image/image.css +5 -1
- package/lib/cjs/image/image.scss +6 -1
- package/lib/cjs/image/previewImageFoundation.d.ts +46 -13
- package/lib/cjs/image/previewImageFoundation.js +207 -181
- package/lib/cjs/image/previewInnerFoundation.d.ts +4 -3
- package/lib/cjs/image/previewInnerFoundation.js +5 -2
- package/lib/cjs/navigation/foundation.d.ts +8 -8
- package/lib/cjs/navigation/itemFoundation.d.ts +5 -4
- package/lib/cjs/radio/radioInnerFoundation.js +1 -1
- package/lib/cjs/table/utils.d.ts +1 -1
- package/lib/cjs/tabs/constants.d.ts +1 -0
- package/lib/cjs/tabs/constants.js +2 -1
- package/lib/cjs/tabs/tabs.css +28 -199
- package/lib/cjs/tabs/tabs.scss +336 -297
- package/lib/cjs/tabs/variables.scss +21 -2
- package/lib/cjs/tree/treeUtil.d.ts +1 -1
- package/lib/cjs/upload/constants.d.ts +1 -1
- package/lib/es/base/foundation.js +1 -1
- package/lib/es/chat/foundation.d.ts +1 -2
- package/lib/es/chat/foundation.js +2 -7
- package/lib/es/checkbox/checkboxGroupFoundation.js +1 -1
- package/lib/es/datePicker/foundation.js +1 -1
- package/lib/es/image/image.css +5 -1
- package/lib/es/image/image.scss +6 -1
- package/lib/es/image/previewImageFoundation.d.ts +46 -13
- package/lib/es/image/previewImageFoundation.js +207 -181
- package/lib/es/image/previewInnerFoundation.d.ts +4 -3
- package/lib/es/image/previewInnerFoundation.js +5 -2
- package/lib/es/navigation/foundation.d.ts +8 -8
- package/lib/es/navigation/itemFoundation.d.ts +5 -4
- package/lib/es/radio/radioInnerFoundation.js +1 -1
- package/lib/es/table/utils.d.ts +1 -1
- package/lib/es/tabs/constants.d.ts +1 -0
- package/lib/es/tabs/constants.js +2 -1
- package/lib/es/tabs/tabs.css +28 -199
- package/lib/es/tabs/tabs.scss +336 -297
- package/lib/es/tabs/variables.scss +21 -2
- package/lib/es/tree/treeUtil.d.ts +1 -1
- package/lib/es/upload/constants.d.ts +1 -1
- package/navigation/foundation.ts +8 -8
- package/navigation/itemFoundation.ts +6 -4
- package/package.json +3 -3
- package/tabs/constants.ts +2 -1
- package/tabs/tabs.scss +336 -297
- package/tabs/variables.scss +21 -2
|
@@ -6,60 +6,60 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const DefaultDOMRect = {
|
|
10
|
-
bottom: 0,
|
|
11
|
-
height: 0,
|
|
12
|
-
left: 0,
|
|
13
|
-
right: 0,
|
|
14
|
-
top: 0,
|
|
15
|
-
width: 0,
|
|
16
|
-
x: 0,
|
|
17
|
-
y: 0,
|
|
18
|
-
toJSON: () => ({})
|
|
19
|
-
};
|
|
20
9
|
class PreviewImageFoundation extends _foundation.default {
|
|
21
10
|
constructor(adapter) {
|
|
22
11
|
var _this;
|
|
23
12
|
super(Object.assign({}, adapter));
|
|
24
13
|
_this = this;
|
|
25
|
-
this.
|
|
14
|
+
this.startMouseClientPosition = {
|
|
26
15
|
x: 0,
|
|
27
16
|
y: 0
|
|
28
17
|
};
|
|
29
18
|
this.originImageWidth = null;
|
|
30
19
|
this.originImageHeight = null;
|
|
20
|
+
this.containerWidth = 0;
|
|
21
|
+
this.containerHeight = 0;
|
|
31
22
|
this._isImageVertical = () => this.getProp("rotation") % 180 !== 0;
|
|
32
|
-
this.
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
|
|
23
|
+
this._getContainerBoundingRectSize = () => {
|
|
24
|
+
const containerDOM = this._adapter.getContainer();
|
|
25
|
+
if (containerDOM) {
|
|
26
|
+
this.containerWidth = containerDOM.clientWidth;
|
|
27
|
+
this.containerHeight = containerDOM.clientHeight;
|
|
36
28
|
}
|
|
37
|
-
return DefaultDOMRect;
|
|
38
29
|
};
|
|
39
|
-
this.
|
|
30
|
+
this._getAdaptationZoom = () => {
|
|
31
|
+
let _zoom = 1;
|
|
40
32
|
const containerDOM = this._adapter.getContainer();
|
|
41
|
-
if (containerDOM) {
|
|
42
|
-
|
|
33
|
+
if (containerDOM && this.originImageWidth && this.originImageHeight) {
|
|
34
|
+
const {
|
|
35
|
+
rotation
|
|
36
|
+
} = this.getProps();
|
|
37
|
+
const {
|
|
38
|
+
width: imageWidth,
|
|
39
|
+
height: imageHeight
|
|
40
|
+
} = this.calcBoundingRectSize(this.originImageWidth, this.originImageHeight, rotation);
|
|
41
|
+
const reservedWidth = this.containerWidth - 80;
|
|
42
|
+
const reservedHeight = this.containerHeight - 80;
|
|
43
|
+
_zoom = Number(Math.min(reservedWidth / imageWidth, reservedHeight / imageHeight).toFixed(2));
|
|
43
44
|
}
|
|
44
|
-
return
|
|
45
|
+
return _zoom;
|
|
45
46
|
};
|
|
46
|
-
this.
|
|
47
|
+
this._getInitialZoom = () => {
|
|
47
48
|
const {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
ratio
|
|
50
|
+
} = this.getProps();
|
|
51
|
+
let _zoom = 1;
|
|
52
|
+
if (ratio === 'adaptation') {
|
|
53
|
+
_zoom = this._getAdaptationZoom();
|
|
54
|
+
}
|
|
55
|
+
return _zoom;
|
|
55
56
|
};
|
|
56
57
|
this.setLoading = loading => {
|
|
57
58
|
this._adapter.setLoading(loading);
|
|
58
59
|
};
|
|
59
60
|
this.handleWindowResize = () => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
61
|
+
this._getContainerBoundingRectSize();
|
|
62
|
+
this.initializeImage();
|
|
63
63
|
};
|
|
64
64
|
this.handleLoad = e => {
|
|
65
65
|
if (e.target) {
|
|
@@ -74,7 +74,7 @@ class PreviewImageFoundation extends _foundation.default {
|
|
|
74
74
|
});
|
|
75
75
|
// 图片初次加载,计算 zoom,zoom 改变不需要通过回调透出
|
|
76
76
|
// When the image is loaded for the first time, zoom is calculated, and zoom changes do not need to be exposed through callbacks.
|
|
77
|
-
this.
|
|
77
|
+
this.initializeImage(false);
|
|
78
78
|
}
|
|
79
79
|
const {
|
|
80
80
|
src,
|
|
@@ -92,66 +92,36 @@ class PreviewImageFoundation extends _foundation.default {
|
|
|
92
92
|
});
|
|
93
93
|
onError && onError(src);
|
|
94
94
|
};
|
|
95
|
-
this.
|
|
95
|
+
this.handleRatioChange = () => {
|
|
96
|
+
this.initializeImage();
|
|
97
|
+
};
|
|
98
|
+
this.initializeImageZoom = function () {
|
|
96
99
|
let notify = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
97
|
-
const horizontal = !_this._isImageVertical();
|
|
98
100
|
const {
|
|
99
101
|
currZoom
|
|
100
102
|
} = _this.getStates();
|
|
101
|
-
const imgWidth = horizontal ? _this.originImageWidth : _this.originImageHeight;
|
|
102
|
-
const imgHeight = horizontal ? _this.originImageHeight : _this.originImageWidth;
|
|
103
103
|
const {
|
|
104
|
-
onZoom
|
|
105
|
-
setRatio,
|
|
106
|
-
ratio
|
|
104
|
+
onZoom
|
|
107
105
|
} = _this.getProps();
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
} = _this._getContainerBounds();
|
|
114
|
-
const reservedWidth = containerWidth - 80;
|
|
115
|
-
const reservedHeight = containerHeight - 80;
|
|
116
|
-
let _zoom = 1;
|
|
117
|
-
if (imgWidth > reservedWidth || imgHeight > reservedHeight) {
|
|
118
|
-
_zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
|
|
119
|
-
}
|
|
120
|
-
if (currZoom === _zoom) {
|
|
121
|
-
_this.calculatePreviewImage(_zoom, null);
|
|
122
|
-
} else {
|
|
123
|
-
onZoom(_zoom, notify);
|
|
124
|
-
}
|
|
106
|
+
const _zoom = _this._getInitialZoom();
|
|
107
|
+
if (currZoom !== _zoom) {
|
|
108
|
+
onZoom(_zoom, notify);
|
|
109
|
+
} else {
|
|
110
|
+
_this.changeZoom(_zoom);
|
|
125
111
|
}
|
|
126
112
|
};
|
|
127
|
-
this.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const {
|
|
133
|
-
ratio,
|
|
134
|
-
onZoom
|
|
135
|
-
} = this.getProps();
|
|
136
|
-
let _zoom;
|
|
137
|
-
if (ratio === 'adaptation') {
|
|
138
|
-
const horizontal = !this._isImageVertical();
|
|
139
|
-
const imgWidth = horizontal ? this.originImageWidth : this.originImageHeight;
|
|
140
|
-
const imgHeight = horizontal ? this.originImageHeight : this.originImageWidth;
|
|
141
|
-
const {
|
|
142
|
-
width: containerWidth,
|
|
143
|
-
height: containerHeight
|
|
144
|
-
} = this._getContainerBounds();
|
|
145
|
-
const reservedWidth = containerWidth - 80;
|
|
146
|
-
const reservedHeight = containerHeight - 80;
|
|
147
|
-
_zoom = Number(Math.min(reservedWidth / imgWidth, reservedHeight / imgHeight).toFixed(2));
|
|
148
|
-
} else {
|
|
149
|
-
_zoom = 1;
|
|
150
|
-
}
|
|
151
|
-
if (currZoom !== _zoom) {
|
|
152
|
-
onZoom(_zoom);
|
|
113
|
+
this.initializeTranslate = () => {
|
|
114
|
+
this.setState({
|
|
115
|
+
translate: {
|
|
116
|
+
x: 0,
|
|
117
|
+
y: 0
|
|
153
118
|
}
|
|
154
|
-
}
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
this.initializeImage = function () {
|
|
122
|
+
let notify = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
123
|
+
_this.initializeImageZoom(notify);
|
|
124
|
+
_this.initializeTranslate();
|
|
155
125
|
};
|
|
156
126
|
this.handleRightClickImage = e => {
|
|
157
127
|
const {
|
|
@@ -165,140 +135,196 @@ class PreviewImageFoundation extends _foundation.default {
|
|
|
165
135
|
return true;
|
|
166
136
|
}
|
|
167
137
|
};
|
|
168
|
-
this.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
height
|
|
172
|
-
} = this.getStates();
|
|
173
|
-
const {
|
|
174
|
-
rotation
|
|
175
|
-
} = this.getProps();
|
|
176
|
-
const {
|
|
177
|
-
width: containerWidth,
|
|
178
|
-
height: containerHeight
|
|
179
|
-
} = this._getContainerBounds();
|
|
180
|
-
let canDragHorizontal = width > containerWidth;
|
|
181
|
-
let canDragVertical = height > containerHeight;
|
|
182
|
-
if (this._isImageVertical()) {
|
|
183
|
-
canDragHorizontal = height > containerWidth;
|
|
184
|
-
canDragVertical = width > containerHeight;
|
|
185
|
-
}
|
|
138
|
+
this.getCanDragDirection = (width, height) => {
|
|
139
|
+
let canDragHorizontal = width > this.containerWidth;
|
|
140
|
+
let canDragVertical = height > this.containerHeight;
|
|
186
141
|
return {
|
|
187
142
|
canDragVertical,
|
|
188
143
|
canDragHorizontal
|
|
189
144
|
};
|
|
190
145
|
};
|
|
191
|
-
this.
|
|
146
|
+
this.changeZoom = (newZoom, e) => {
|
|
192
147
|
const imageDOM = this._adapter.getImage();
|
|
193
148
|
const {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
149
|
+
currZoom,
|
|
150
|
+
translate,
|
|
151
|
+
width,
|
|
152
|
+
height
|
|
153
|
+
} = this.getStates();
|
|
198
154
|
const {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
155
|
+
rotation
|
|
156
|
+
} = this.getProps();
|
|
157
|
+
const changeScale = newZoom / (currZoom || 1);
|
|
202
158
|
const newWidth = Math.floor(this.originImageWidth * newZoom);
|
|
203
159
|
const newHeight = Math.floor(this.originImageHeight * newZoom);
|
|
204
|
-
|
|
205
|
-
let
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
160
|
+
let newTranslateX = Math.floor(translate.x * changeScale);
|
|
161
|
+
let newTranslateY = Math.floor(translate.y * changeScale);
|
|
162
|
+
const imageBound = this.calcBoundingRectSize(width, height, rotation);
|
|
163
|
+
const newImageBound = {
|
|
164
|
+
width: imageBound.width * changeScale,
|
|
165
|
+
height: imageBound.height * changeScale
|
|
166
|
+
};
|
|
167
|
+
if (e && imageDOM && e.target === imageDOM) {
|
|
168
|
+
const {
|
|
169
|
+
x: offsetX,
|
|
170
|
+
y: offsetY
|
|
171
|
+
} = this.calcBoundingRectMouseOffset({
|
|
172
|
+
width,
|
|
173
|
+
height,
|
|
174
|
+
offset: {
|
|
175
|
+
x: e.offsetX,
|
|
176
|
+
y: e.offsetY
|
|
177
|
+
},
|
|
178
|
+
rotation
|
|
179
|
+
});
|
|
180
|
+
const imageNewCenterX = e.clientX + (imageBound.width / 2 - offsetX) * changeScale;
|
|
181
|
+
const imageNewCenterY = e.clientY + (imageBound.height / 2 - offsetY) * changeScale;
|
|
182
|
+
const containerCenterX = this.containerWidth / 2;
|
|
183
|
+
const containerCenterY = this.containerHeight / 2;
|
|
184
|
+
newTranslateX = imageNewCenterX - containerCenterX;
|
|
185
|
+
newTranslateY = imageNewCenterY - containerCenterY;
|
|
223
186
|
}
|
|
187
|
+
const newTranslate = this.getSafeTranslate(newImageBound.width, newImageBound.height, newTranslateX, newTranslateY);
|
|
224
188
|
this.setState({
|
|
189
|
+
translate: newTranslate,
|
|
225
190
|
width: newWidth,
|
|
226
191
|
height: newHeight,
|
|
227
|
-
offset: _offset,
|
|
228
|
-
left: newLeft,
|
|
229
|
-
top: newTop,
|
|
230
192
|
currZoom: newZoom
|
|
231
193
|
});
|
|
232
194
|
if (imageDOM) {
|
|
195
|
+
const {
|
|
196
|
+
canDragVertical,
|
|
197
|
+
canDragHorizontal
|
|
198
|
+
} = this.getCanDragDirection(newImageBound.width, newImageBound.height);
|
|
199
|
+
const canDrag = canDragVertical || canDragHorizontal;
|
|
233
200
|
this._adapter.setImageCursor(canDrag);
|
|
234
201
|
}
|
|
235
202
|
};
|
|
236
|
-
this.
|
|
203
|
+
this.getExtremeTranslate = (width, height) => {
|
|
204
|
+
return {
|
|
205
|
+
x: (width - this.containerWidth) / 2,
|
|
206
|
+
y: (height - this.containerHeight) / 2
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
this.getSafeTranslate = (width, height, translateX, translateY) => {
|
|
237
210
|
const {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
} = this.
|
|
211
|
+
x: extremeX,
|
|
212
|
+
y: extremeY
|
|
213
|
+
} = this.getExtremeTranslate(width, height);
|
|
241
214
|
const {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
} = this.
|
|
245
|
-
let
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
|
|
249
|
-
|
|
215
|
+
canDragVertical,
|
|
216
|
+
canDragHorizontal
|
|
217
|
+
} = this.getCanDragDirection(width, height);
|
|
218
|
+
let newTranslateX = 0,
|
|
219
|
+
newTranslateY = 0;
|
|
220
|
+
if (canDragHorizontal) {
|
|
221
|
+
newTranslateX = translateX > 0 ? Math.min(translateX, extremeX) : Math.max(translateX, -extremeX);
|
|
222
|
+
}
|
|
223
|
+
if (canDragVertical) {
|
|
224
|
+
newTranslateY = translateY > 0 ? Math.min(translateY, extremeY) : Math.max(translateY, -extremeY);
|
|
250
225
|
}
|
|
251
226
|
return {
|
|
252
|
-
|
|
253
|
-
|
|
227
|
+
x: newTranslateX,
|
|
228
|
+
y: newTranslateY
|
|
254
229
|
};
|
|
255
230
|
};
|
|
256
|
-
this.
|
|
231
|
+
this.handleImageMove = e => {
|
|
232
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
233
|
+
const mouseLeftPress = e.buttons === 1;
|
|
234
|
+
if (mouseLeftPress) {
|
|
235
|
+
this.moveImage(e);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
this.moveImage = e => {
|
|
239
|
+
const {
|
|
240
|
+
clientX,
|
|
241
|
+
clientY
|
|
242
|
+
} = e;
|
|
257
243
|
const {
|
|
258
|
-
offset,
|
|
259
244
|
width,
|
|
260
|
-
height
|
|
245
|
+
height,
|
|
246
|
+
translate
|
|
261
247
|
} = this.getStates();
|
|
248
|
+
const {
|
|
249
|
+
rotation
|
|
250
|
+
} = this.getProps();
|
|
251
|
+
const imageBound = this.calcBoundingRectSize(width, height, rotation);
|
|
262
252
|
const {
|
|
263
253
|
canDragVertical,
|
|
264
254
|
canDragHorizontal
|
|
265
|
-
} = this.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const
|
|
270
|
-
clientX,
|
|
271
|
-
clientY
|
|
272
|
-
} = e;
|
|
273
|
-
const {
|
|
274
|
-
left: containerLeft,
|
|
275
|
-
top: containerTop
|
|
276
|
-
} = this._getContainerBounds();
|
|
277
|
-
const {
|
|
278
|
-
left: extremeLeft,
|
|
279
|
-
top: extremeTop
|
|
280
|
-
} = this.calcExtremeBounds();
|
|
281
|
-
let newX = canDragHorizontal ? clientX - containerLeft - this.startMouseOffset.x : offset.x;
|
|
282
|
-
let newY = canDragVertical ? clientY - containerTop - this.startMouseOffset.y : offset.y;
|
|
283
|
-
if (canDragHorizontal) {
|
|
284
|
-
newX = newX > 0 ? 0 : newX < extremeLeft ? extremeLeft : newX;
|
|
285
|
-
}
|
|
286
|
-
if (canDragVertical) {
|
|
287
|
-
newY = newY > 0 ? 0 : newY < extremeTop ? extremeTop : newY;
|
|
288
|
-
}
|
|
289
|
-
const _offset = {
|
|
290
|
-
x: newX,
|
|
291
|
-
y: newY
|
|
292
|
-
};
|
|
255
|
+
} = this.getCanDragDirection(imageBound.width, imageBound.height);
|
|
256
|
+
if (canDragVertical || canDragHorizontal) {
|
|
257
|
+
let newTranslateX = canDragHorizontal ? translate.x + clientX - this.startMouseClientPosition.x : translate.x;
|
|
258
|
+
let newTranslateY = canDragVertical ? translate.y + clientY - this.startMouseClientPosition.y : translate.y;
|
|
259
|
+
const newTranslate = this.getSafeTranslate(imageBound.width, imageBound.height, newTranslateX, newTranslateY);
|
|
293
260
|
this.setState({
|
|
294
|
-
|
|
295
|
-
left: this._isImageVertical() ? _offset.x - (width - height) / 2 : _offset.x,
|
|
296
|
-
top: this._isImageVertical() ? _offset.y + (width - height) / 2 : _offset.y
|
|
261
|
+
translate: newTranslate
|
|
297
262
|
});
|
|
263
|
+
this.startMouseClientPosition = {
|
|
264
|
+
x: clientX,
|
|
265
|
+
y: clientY
|
|
266
|
+
};
|
|
298
267
|
}
|
|
299
268
|
};
|
|
300
269
|
this.handleImageMouseDown = e => {
|
|
301
|
-
this.
|
|
270
|
+
this.startMouseClientPosition = {
|
|
271
|
+
x: e.clientX,
|
|
272
|
+
y: e.clientY
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
// 鼠标事件的 e.offset 是以 dom 旋转前左上角为零点的, 这个方法会转换为以旋转后元素的外接矩形左上角为零点的 offset
|
|
276
|
+
this.calcBoundingRectMouseOffset = calcBoundingRectMouseOffset => {
|
|
277
|
+
const {
|
|
278
|
+
width,
|
|
279
|
+
height,
|
|
280
|
+
offset,
|
|
281
|
+
rotation = 0
|
|
282
|
+
} = calcBoundingRectMouseOffset;
|
|
283
|
+
let degrees = rotation % 360;
|
|
284
|
+
degrees = degrees >= 0 ? degrees : 360 + degrees;
|
|
285
|
+
let boundOffsetX = 0,
|
|
286
|
+
boundOffsetY = 0;
|
|
287
|
+
switch (degrees) {
|
|
288
|
+
case 0:
|
|
289
|
+
boundOffsetX = offset.x;
|
|
290
|
+
boundOffsetY = offset.y;
|
|
291
|
+
break;
|
|
292
|
+
case 90:
|
|
293
|
+
boundOffsetX = height - offset.y;
|
|
294
|
+
boundOffsetY = offset.x;
|
|
295
|
+
break;
|
|
296
|
+
case 180:
|
|
297
|
+
boundOffsetX = width - offset.x;
|
|
298
|
+
boundOffsetY = height - offset.y;
|
|
299
|
+
break;
|
|
300
|
+
case 270:
|
|
301
|
+
boundOffsetX = offset.y;
|
|
302
|
+
boundOffsetY = width - offset.x;
|
|
303
|
+
break;
|
|
304
|
+
default:
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
x: boundOffsetX,
|
|
309
|
+
y: boundOffsetY
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
init() {
|
|
314
|
+
this._getContainerBoundingRectSize();
|
|
315
|
+
}
|
|
316
|
+
calcBoundingRectSize() {
|
|
317
|
+
let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
318
|
+
let height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
319
|
+
let rotation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
320
|
+
const angleInRadians = rotation * Math.PI / 180;
|
|
321
|
+
const sinTheta = Math.abs(Math.sin(angleInRadians));
|
|
322
|
+
const cosTheta = Math.abs(Math.cos(angleInRadians));
|
|
323
|
+
const boundingWidth = width * cosTheta + height * sinTheta;
|
|
324
|
+
const boundingHeight = width * sinTheta + height * cosTheta;
|
|
325
|
+
return {
|
|
326
|
+
width: boundingWidth,
|
|
327
|
+
height: boundingHeight
|
|
302
328
|
};
|
|
303
329
|
}
|
|
304
330
|
}
|
|
@@ -17,6 +17,7 @@ export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string,
|
|
|
17
17
|
enabledBodyScroll: () => void;
|
|
18
18
|
getSetDownloadFunc: () => (src: string) => string;
|
|
19
19
|
isValidTarget: (e: any) => boolean;
|
|
20
|
+
changeImageZoom: (zoom: number, e?: WheelEvent) => void;
|
|
20
21
|
}
|
|
21
22
|
export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PreviewInnerAdapter<P, S>, P, S> {
|
|
22
23
|
constructor(adapter: PreviewInnerAdapter<P, S>);
|
|
@@ -32,8 +33,8 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
32
33
|
mouseMoveHandler: import("lodash").DebouncedFuncLeading<(e: any) => void>;
|
|
33
34
|
updateTimer: () => void;
|
|
34
35
|
clearTimer: () => void;
|
|
35
|
-
handleWheel: (e:
|
|
36
|
-
onWheel: (e:
|
|
36
|
+
handleWheel: (e: WheelEvent) => void;
|
|
37
|
+
onWheel: (e: WheelEvent) => void;
|
|
37
38
|
handleMouseUp: (e: any) => void;
|
|
38
39
|
handleMouseDown: (e: any) => void;
|
|
39
40
|
handleKeyDown: (e: any) => void;
|
|
@@ -42,7 +43,7 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
42
43
|
handlePreviewClose: (e: any) => void;
|
|
43
44
|
handleAdjustRatio: (type: RatioType) => void;
|
|
44
45
|
handleRotateImage: (direction: string) => void;
|
|
45
|
-
handleZoomImage: (newZoom: number, notify?: boolean) => void;
|
|
46
|
+
handleZoomImage: (newZoom: number, notify?: boolean, e?: WheelEvent) => void;
|
|
46
47
|
preloadGapImage: () => void;
|
|
47
48
|
preloadSingleImage: () => void;
|
|
48
49
|
setLoadSuccessStatus: (src: string) => void;
|
|
@@ -93,7 +93,7 @@ class PreviewInnerFoundation extends _foundation.default {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
if (!(0, _isUndefined2.default)(_zoom)) {
|
|
96
|
-
this.handleZoomImage(_zoom);
|
|
96
|
+
this.handleZoomImage(_zoom, true, e);
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
this.handleMouseUp = e => {
|
|
@@ -191,7 +191,8 @@ class PreviewInnerFoundation extends _foundation.default {
|
|
|
191
191
|
const {
|
|
192
192
|
rotation
|
|
193
193
|
} = this.getStates();
|
|
194
|
-
const
|
|
194
|
+
const ROTATE_STEP = 90;
|
|
195
|
+
const newRotation = rotation + (direction === "left" ? -ROTATE_STEP : ROTATE_STEP);
|
|
195
196
|
this.setState({
|
|
196
197
|
rotation: newRotation
|
|
197
198
|
});
|
|
@@ -199,11 +200,13 @@ class PreviewInnerFoundation extends _foundation.default {
|
|
|
199
200
|
};
|
|
200
201
|
this.handleZoomImage = function (newZoom) {
|
|
201
202
|
let notify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
203
|
+
let e = arguments.length > 2 ? arguments[2] : undefined;
|
|
202
204
|
const {
|
|
203
205
|
zoom
|
|
204
206
|
} = _this.getStates();
|
|
205
207
|
if (zoom !== newZoom) {
|
|
206
208
|
notify && _this._adapter.notifyZoom(newZoom, newZoom > zoom);
|
|
209
|
+
_this._adapter.changeImageZoom(newZoom, e);
|
|
207
210
|
_this.setState({
|
|
208
211
|
zoom: newZoom
|
|
209
212
|
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
|
-
import { ItemProps } from './itemFoundation';
|
|
2
|
+
import { ItemProps, ItemKey } from './itemFoundation';
|
|
3
3
|
export interface ItemKey2ParentKeysMap {
|
|
4
4
|
[key: string]: (string | number)[];
|
|
5
5
|
}
|
|
6
6
|
export interface OnClickData {
|
|
7
|
-
itemKey:
|
|
7
|
+
itemKey: ItemKey;
|
|
8
8
|
domEvent: any;
|
|
9
9
|
isOpen: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface OnSelectData extends OnClickData {
|
|
12
|
-
selectedKeys:
|
|
12
|
+
selectedKeys: ItemKey[];
|
|
13
13
|
selectedItems: ItemProps[];
|
|
14
14
|
}
|
|
15
15
|
export interface OnOpenChangeData extends OnClickData {
|
|
16
|
-
openKeys:
|
|
16
|
+
openKeys: ItemKey[];
|
|
17
17
|
}
|
|
18
18
|
export interface NavItemType {
|
|
19
19
|
props?: ItemProps;
|
|
@@ -39,7 +39,7 @@ export interface NavigationAdapter<P = Record<string, any>, S = Record<string, a
|
|
|
39
39
|
}
|
|
40
40
|
export default class NavigationFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<NavigationAdapter<P, S>, P, S> {
|
|
41
41
|
constructor(adapter: NavigationAdapter<P, S>);
|
|
42
|
-
static getZeroParentKeys(itemKeysMap?: {}, ...itemKeys:
|
|
42
|
+
static getZeroParentKeys(itemKeysMap?: {}, ...itemKeys: ItemKey[]): any[];
|
|
43
43
|
static buildItemKeysMap(items?: NavItemType[], keysMap?: {}, parentKeys?: (string | number)[], keyPropName?: string): {};
|
|
44
44
|
/**
|
|
45
45
|
* init is called in constructor and componentDidMount.
|
|
@@ -74,12 +74,12 @@ export default class NavigationFoundation<P = Record<string, any>, S = Record<st
|
|
|
74
74
|
* @param {*} itemKeysMap
|
|
75
75
|
*/
|
|
76
76
|
getWillOpenKeys(itemKeysMap: ItemKey2ParentKeysMap): any[];
|
|
77
|
-
getShouldOpenKeys(itemKeysMap?: ItemKey2ParentKeysMap, selectedKeys?:
|
|
77
|
+
getShouldOpenKeys(itemKeysMap?: ItemKey2ParentKeysMap, selectedKeys?: ItemKey[]): unknown[];
|
|
78
78
|
destroy(): void;
|
|
79
|
-
selectLevelZeroParentKeys(itemKeysMap: ItemKey2ParentKeysMap, itemKeys:
|
|
79
|
+
selectLevelZeroParentKeys(itemKeysMap: ItemKey2ParentKeysMap, itemKeys: ItemKey[]): any[];
|
|
80
80
|
formatItems(items?: ItemProps[]): any[];
|
|
81
81
|
handleSelect(data: OnSelectData): void;
|
|
82
|
-
judgeIfOpen(openKeys:
|
|
82
|
+
judgeIfOpen(openKeys: ItemKey[], items: NavItemType[]): boolean;
|
|
83
83
|
handleCollapseChange(): void;
|
|
84
84
|
handleItemsChange(isChanged: boolean): void;
|
|
85
85
|
}
|
|
@@ -12,10 +12,11 @@ export interface ItemProps {
|
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
children?: any;
|
|
14
14
|
}
|
|
15
|
+
export type ItemKey = string | number;
|
|
15
16
|
export interface SelectedItemProps<Props = ItemProps> {
|
|
16
|
-
itemKey:
|
|
17
|
+
itemKey: ItemKey;
|
|
17
18
|
text?: any;
|
|
18
|
-
selectedKeys?:
|
|
19
|
+
selectedKeys?: ItemKey[];
|
|
19
20
|
selectedItems?: Props[];
|
|
20
21
|
domEvent?: any;
|
|
21
22
|
}
|
|
@@ -23,8 +24,8 @@ export interface ItemAdapter<P = Record<string, any>, S = Record<string, any>> e
|
|
|
23
24
|
cloneDeep(value: any, customizer?: (value: any) => void): any;
|
|
24
25
|
updateTooltipShow(showTooltip: boolean): void;
|
|
25
26
|
updateSelected(selected: boolean): void;
|
|
26
|
-
updateGlobalSelectedKeys(keys:
|
|
27
|
-
getSelectedKeys():
|
|
27
|
+
updateGlobalSelectedKeys(keys: ItemKey[]): void;
|
|
28
|
+
getSelectedKeys(): ItemKey[];
|
|
28
29
|
getSelectedKeysIsControlled(): boolean;
|
|
29
30
|
notifyGlobalOnSelect(item: SelectedItemProps): void;
|
|
30
31
|
notifyGlobalOnClick(item: SelectedItemProps): void;
|
|
@@ -22,7 +22,7 @@ class RadioInnerFoundation extends _foundation.default {
|
|
|
22
22
|
return this._adapter.getProp('checked');
|
|
23
23
|
}
|
|
24
24
|
handleChange(e) {
|
|
25
|
-
const isControlledMode =
|
|
25
|
+
const isControlledMode = 'checked' in this.getProps();
|
|
26
26
|
const {
|
|
27
27
|
checked
|
|
28
28
|
} = e.target;
|
package/lib/cjs/table/utils.d.ts
CHANGED
|
@@ -102,4 +102,4 @@ export declare function isTreeTable({ dataSource, childrenRecordName }: {
|
|
|
102
102
|
}): boolean;
|
|
103
103
|
export declare function getRTLAlign(align: typeof strings.ALIGNS[number], direction?: 'ltr' | 'rtl'): typeof strings.ALIGNS[number];
|
|
104
104
|
export declare function getRTLFlexAlign(align: typeof strings.ALIGNS[number], direction?: 'ltr' | 'rtl'): typeof strings.JUSTIFY_CONTENT[number];
|
|
105
|
-
export declare function shouldShowEllipsisTitle(ellipsis: BaseEllipsis):
|
|
105
|
+
export declare function shouldShowEllipsisTitle(ellipsis: BaseEllipsis): boolean;
|
|
@@ -11,6 +11,7 @@ const cssClasses = exports.cssClasses = {
|
|
|
11
11
|
TABS_BAR_LINE: `${_constants.BASE_CLASS_PREFIX}-tabs-bar-line`,
|
|
12
12
|
TABS_BAR_CARD: `${_constants.BASE_CLASS_PREFIX}-tabs-bar-card`,
|
|
13
13
|
TABS_BAR_BUTTON: `${_constants.BASE_CLASS_PREFIX}-tabs-bar-button`,
|
|
14
|
+
TABS_BAR_SLASH: `${_constants.BASE_CLASS_PREFIX}-tabs-bar-slash`,
|
|
14
15
|
TABS_BAR_EXTRA: `${_constants.BASE_CLASS_PREFIX}-tabs-bar-extra`,
|
|
15
16
|
TABS_TAB: `${_constants.BASE_CLASS_PREFIX}-tabs-tab`,
|
|
16
17
|
TABS_TAB_ACTIVE: `${_constants.BASE_CLASS_PREFIX}-tabs-tab-active`,
|
|
@@ -32,7 +33,7 @@ const numbers = exports.numbers = {
|
|
|
32
33
|
DEFAULT_ACTIVE_KEY: 1
|
|
33
34
|
};
|
|
34
35
|
const strings = exports.strings = {
|
|
35
|
-
TYPE_MAP: ['line', 'card', 'button'],
|
|
36
|
+
TYPE_MAP: ['line', 'card', 'button', 'slash'],
|
|
36
37
|
SIZE: ['small', 'medium', 'large'],
|
|
37
38
|
POSITION_MAP: ['top', 'left']
|
|
38
39
|
};
|