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