@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
|
@@ -20,7 +20,8 @@ export interface PreviewInnerAdapter<P = Record<string, any>, S = Record<string,
|
|
|
20
20
|
disabledBodyScroll: () => void;
|
|
21
21
|
enabledBodyScroll: () => void;
|
|
22
22
|
getSetDownloadFunc: () => (src: string) => string;
|
|
23
|
-
isValidTarget: (e: any) => boolean
|
|
23
|
+
isValidTarget: (e: any) => boolean;
|
|
24
|
+
changeImageZoom: (zoom: number, e?: WheelEvent) => void
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
|
|
@@ -90,12 +91,12 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
handleWheel = (e:
|
|
94
|
+
handleWheel = (e: WheelEvent) => {
|
|
94
95
|
this.onWheel(e);
|
|
95
96
|
handlePrevent(e);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
onWheel = (e:
|
|
99
|
+
onWheel = (e: WheelEvent): void => {
|
|
99
100
|
const { zoomStep, maxZoom, minZoom } = this.getProps();
|
|
100
101
|
const { zoom: currZoom } = this.getStates();
|
|
101
102
|
let _zoom: number;
|
|
@@ -111,7 +112,7 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
if (!isUndefined(_zoom)) {
|
|
114
|
-
this.handleZoomImage(_zoom);
|
|
115
|
+
this.handleZoomImage(_zoom, true, e);
|
|
115
116
|
}
|
|
116
117
|
};
|
|
117
118
|
|
|
@@ -193,17 +194,21 @@ export default class PreviewInnerFoundation<P = Record<string, any>, S = Record<
|
|
|
193
194
|
|
|
194
195
|
handleRotateImage = (direction: string) => {
|
|
195
196
|
const { rotation } = this.getStates();
|
|
196
|
-
const
|
|
197
|
+
const ROTATE_STEP = 90;
|
|
198
|
+
const newRotation = rotation + (direction === "left" ? -ROTATE_STEP : ROTATE_STEP);
|
|
199
|
+
|
|
197
200
|
this.setState({
|
|
198
201
|
rotation: newRotation,
|
|
199
202
|
} as any);
|
|
200
203
|
this._adapter.notifyRotateChange(newRotation);
|
|
201
204
|
}
|
|
202
205
|
|
|
203
|
-
handleZoomImage = (newZoom: number, notify: boolean = true) => {
|
|
206
|
+
handleZoomImage = (newZoom: number, notify: boolean = true, e?: WheelEvent) => {
|
|
204
207
|
const { zoom } = this.getStates();
|
|
205
208
|
if (zoom !== newZoom) {
|
|
206
209
|
notify && this._adapter.notifyZoom(newZoom, newZoom > zoom);
|
|
210
|
+
|
|
211
|
+
this._adapter.changeImageZoom(newZoom, e);
|
|
207
212
|
this.setState({
|
|
208
213
|
zoom: newZoom,
|
|
209
214
|
} as any);
|
|
@@ -93,7 +93,7 @@ class BaseFoundation {
|
|
|
93
93
|
_isControlledComponent() {
|
|
94
94
|
let key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'value';
|
|
95
95
|
const props = this.getProps();
|
|
96
|
-
const isControlComponent =
|
|
96
|
+
const isControlComponent = key in props;
|
|
97
97
|
return isControlComponent;
|
|
98
98
|
}
|
|
99
99
|
// Does the user have incoming props, eg: _isInProps (value)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
/// <reference types="lodash" />
|
|
3
2
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation";
|
|
4
3
|
export interface Content {
|
|
@@ -27,7 +26,7 @@ export interface Message {
|
|
|
27
26
|
[x: string]: any;
|
|
28
27
|
}
|
|
29
28
|
export interface ChatAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
30
|
-
getContainerRef: () =>
|
|
29
|
+
getContainerRef: () => HTMLDivElement;
|
|
31
30
|
setWheelScroll: (flag: boolean) => void;
|
|
32
31
|
notifyChatsChange: (chats: Message[]) => void;
|
|
33
32
|
notifyLikeMessage: (message: Message) => void;
|
|
@@ -33,16 +33,14 @@ class ChatFoundation extends _foundation.default {
|
|
|
33
33
|
this._adapter.notifyStopGenerate(e);
|
|
34
34
|
};
|
|
35
35
|
this.scrollToBottomImmediately = () => {
|
|
36
|
-
const
|
|
37
|
-
const element = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
36
|
+
const element = this._adapter.getContainerRef();
|
|
38
37
|
if (element) {
|
|
39
38
|
element.scrollTop = element.scrollHeight;
|
|
40
39
|
}
|
|
41
40
|
};
|
|
42
41
|
this.scrollToBottomWithAnimation = () => {
|
|
43
42
|
const duration = SCROLL_ANIMATION_TIME;
|
|
44
|
-
const
|
|
45
|
-
const element = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
43
|
+
const element = this._adapter.getContainerRef();
|
|
46
44
|
if (!element) {
|
|
47
45
|
return;
|
|
48
46
|
}
|
|
@@ -68,9 +66,6 @@ class ChatFoundation extends _foundation.default {
|
|
|
68
66
|
this.animation.start();
|
|
69
67
|
};
|
|
70
68
|
this.containerScroll = e => {
|
|
71
|
-
if (e.target !== e.currentTarget) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
69
|
e.persist();
|
|
75
70
|
const update = () => {
|
|
76
71
|
this.getScroll(e.target);
|
|
@@ -40,7 +40,7 @@ class CheckboxGroupFoundation extends _foundation.default {
|
|
|
40
40
|
} else {
|
|
41
41
|
newValue = prevValue.filter((itm, idx) => itm !== evt.target.value);
|
|
42
42
|
}
|
|
43
|
-
const isControlledMode =
|
|
43
|
+
const isControlledMode = 'value' in this.getProps();
|
|
44
44
|
if (isControlledMode) {
|
|
45
45
|
// Controlled mode only needs to notify
|
|
46
46
|
this.notifyChange(newValue);
|
|
@@ -265,7 +265,7 @@ class DatePickerFoundation extends _foundation.default {
|
|
|
265
265
|
const {
|
|
266
266
|
value
|
|
267
267
|
} = this._adapter.getStates();
|
|
268
|
-
const needResetCachedSelectedValue = !this.isCachedSelectedValueValid(willUpdateDates) || this._adapter.needConfirm() && !this.clickConfirmButton;
|
|
268
|
+
const needResetCachedSelectedValue = (0, _isNullOrUndefined.default)(willUpdateDates) || !this.isCachedSelectedValueValid(willUpdateDates) || this._adapter.needConfirm() && !this.clickConfirmButton;
|
|
269
269
|
if (needResetCachedSelectedValue) {
|
|
270
270
|
this.resetCachedSelectedValue(value);
|
|
271
271
|
}
|
package/lib/cjs/image/image.css
CHANGED
|
@@ -90,6 +90,7 @@
|
|
|
90
90
|
align-items: center;
|
|
91
91
|
padding: 0 24px;
|
|
92
92
|
z-index: 1;
|
|
93
|
+
pointer-events: none;
|
|
93
94
|
}
|
|
94
95
|
.semi-image-preview-header-title {
|
|
95
96
|
flex: 1;
|
|
@@ -102,6 +103,7 @@
|
|
|
102
103
|
width: 30px;
|
|
103
104
|
height: 30px;
|
|
104
105
|
border-radius: 50%;
|
|
106
|
+
pointer-events: auto;
|
|
105
107
|
}
|
|
106
108
|
.semi-image-preview-header-close:hover {
|
|
107
109
|
background-color: rgba(0, 0, 0, 0.75);
|
|
@@ -166,11 +168,13 @@
|
|
|
166
168
|
.semi-image-preview-image {
|
|
167
169
|
position: relative;
|
|
168
170
|
height: 100%;
|
|
171
|
+
display: flex;
|
|
172
|
+
justify-content: center;
|
|
173
|
+
align-items: center;
|
|
169
174
|
}
|
|
170
175
|
.semi-image-preview-image-img {
|
|
171
176
|
position: absolute;
|
|
172
177
|
transform: scale3d(1, 1, 1) var(--semi-transform-rotate-none);
|
|
173
|
-
transition: transform 300ms 0s;
|
|
174
178
|
z-index: 0;
|
|
175
179
|
user-select: none;
|
|
176
180
|
}
|
package/lib/cjs/image/image.scss
CHANGED
|
@@ -100,6 +100,7 @@ $module: #{$prefix}-image;
|
|
|
100
100
|
align-items: center;
|
|
101
101
|
padding: $spacing-image_preview_header-paddingY $spacing-image_preview_header-paddingX;
|
|
102
102
|
z-index: $z-image_preview_header;
|
|
103
|
+
pointer-events: none;
|
|
103
104
|
|
|
104
105
|
&-title {
|
|
105
106
|
flex: 1;
|
|
@@ -113,6 +114,7 @@ $module: #{$prefix}-image;
|
|
|
113
114
|
width: $width-image_preview_header_close;
|
|
114
115
|
height: $height-image_preview_header_close;
|
|
115
116
|
border-radius: 50%;
|
|
117
|
+
pointer-events: auto;
|
|
116
118
|
|
|
117
119
|
&:hover {
|
|
118
120
|
background-color: $color-image_header_close-bg;
|
|
@@ -192,11 +194,14 @@ $module: #{$prefix}-image;
|
|
|
192
194
|
&-image {
|
|
193
195
|
position: relative;
|
|
194
196
|
height: 100%;
|
|
197
|
+
display: flex;
|
|
198
|
+
justify-content: center;
|
|
199
|
+
align-items: center;
|
|
195
200
|
|
|
196
201
|
&-img {
|
|
197
202
|
position: absolute;
|
|
198
203
|
transform: scale3d($transform_scale3d-image_preview_image_img) $transform_rotate-image_preview_image_img;
|
|
199
|
-
transition: transform $transition_duration-image_preview_image_img $transition_delay-image_preview_image_img;
|
|
204
|
+
// transition: transform $transition_duration-image_preview_image_img $transition_delay-image_preview_image_img;
|
|
200
205
|
z-index: 0;
|
|
201
206
|
user-select: none;
|
|
202
207
|
}
|
|
@@ -9,36 +9,69 @@ export interface DragDirection {
|
|
|
9
9
|
canDragVertical: boolean;
|
|
10
10
|
canDragHorizontal: boolean;
|
|
11
11
|
}
|
|
12
|
-
export interface
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
export interface ExtremeTranslate {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
15
|
}
|
|
16
|
-
export interface
|
|
16
|
+
export interface Offset {
|
|
17
17
|
x: number;
|
|
18
18
|
y: number;
|
|
19
19
|
}
|
|
20
|
+
export interface Translate {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
}
|
|
24
|
+
interface CalcBoundingRectMouseOffset {
|
|
25
|
+
offset: Offset;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
rotation?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface BoundingRectSize {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}
|
|
20
34
|
export default class PreviewImageFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<PreviewImageAdapter<P, S>, P, S> {
|
|
21
35
|
constructor(adapter: PreviewImageAdapter<P, S>);
|
|
22
|
-
|
|
36
|
+
startMouseClientPosition: {
|
|
23
37
|
x: number;
|
|
24
38
|
y: number;
|
|
25
39
|
};
|
|
26
40
|
originImageWidth: any;
|
|
27
41
|
originImageHeight: any;
|
|
42
|
+
containerWidth: number;
|
|
43
|
+
containerHeight: number;
|
|
44
|
+
init(): void;
|
|
28
45
|
_isImageVertical: () => boolean;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
46
|
+
_getContainerBoundingRectSize: () => void;
|
|
47
|
+
_getAdaptationZoom: () => number;
|
|
48
|
+
_getInitialZoom: () => number;
|
|
32
49
|
setLoading: (loading: boolean) => void;
|
|
33
50
|
handleWindowResize: () => void;
|
|
34
51
|
handleLoad: (e: any) => void;
|
|
35
52
|
handleError: (e: any) => void;
|
|
36
|
-
handleResizeImage: (notify?: boolean) => void;
|
|
37
53
|
handleRatioChange: () => void;
|
|
54
|
+
initializeImageZoom: (notify?: boolean) => void;
|
|
55
|
+
initializeTranslate: () => void;
|
|
56
|
+
initializeImage: (notify?: boolean) => void;
|
|
38
57
|
handleRightClickImage: (e: any) => boolean;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
58
|
+
calcBoundingRectSize(width?: number, height?: number, rotation?: number): {
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
};
|
|
62
|
+
getCanDragDirection: (width: number, height: number) => DragDirection;
|
|
63
|
+
changeZoom: (newZoom: number, e?: WheelEvent) => void;
|
|
64
|
+
getExtremeTranslate: (width: number, height: number) => ExtremeTranslate;
|
|
65
|
+
getSafeTranslate: (width: number, height: number, translateX: number, translateY: number) => {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
};
|
|
69
|
+
handleImageMove: (e: MouseEvent) => void;
|
|
70
|
+
moveImage: (e: MouseEvent) => void;
|
|
43
71
|
handleImageMouseDown: (e: any) => void;
|
|
72
|
+
calcBoundingRectMouseOffset: (calcBoundingRectMouseOffset: CalcBoundingRectMouseOffset) => {
|
|
73
|
+
x: number;
|
|
74
|
+
y: number;
|
|
75
|
+
};
|
|
44
76
|
}
|
|
77
|
+
export {};
|