@douyinfe/semi-foundation 2.78.0-alpha.2 → 2.78.0-beta.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/cropper/foundation.ts +83 -0
- package/jsonViewer/foundation.ts +29 -9
- package/jsonViewer/jsonViewer.scss +2 -0
- package/lib/cjs/cropper/foundation.d.ts +15 -0
- package/lib/cjs/cropper/foundation.js +84 -0
- package/lib/cjs/jsonViewer/foundation.d.ts +4 -3
- package/lib/cjs/jsonViewer/foundation.js +34 -13
- package/lib/cjs/jsonViewer/jsonViewer.css +2 -0
- package/lib/cjs/jsonViewer/jsonViewer.scss +2 -0
- package/lib/cjs/markdownRender/foundation.d.ts +1 -1
- package/lib/cjs/navigation/navigation.css +4 -4
- package/lib/cjs/navigation/variables.scss +2 -2
- package/lib/cjs/tooltip/foundation.d.ts +0 -5
- package/lib/cjs/tooltip/foundation.js +0 -22
- package/lib/cjs/userGuide/userGuide.css +3 -0
- package/lib/cjs/userGuide/userGuide.scss +4 -0
- package/lib/es/cropper/foundation.d.ts +15 -0
- package/lib/es/cropper/foundation.js +84 -0
- package/lib/es/jsonViewer/foundation.d.ts +4 -3
- package/lib/es/jsonViewer/foundation.js +34 -13
- package/lib/es/jsonViewer/jsonViewer.css +2 -0
- package/lib/es/jsonViewer/jsonViewer.scss +2 -0
- package/lib/es/markdownRender/foundation.d.ts +1 -1
- package/lib/es/navigation/navigation.css +4 -4
- package/lib/es/navigation/variables.scss +2 -2
- package/lib/es/tooltip/foundation.d.ts +0 -5
- package/lib/es/tooltip/foundation.js +0 -22
- package/lib/es/userGuide/userGuide.css +3 -0
- package/lib/es/userGuide/userGuide.scss +4 -0
- package/markdownRender/foundation.ts +1 -2
- package/navigation/variables.scss +2 -2
- package/package.json +4 -4
- package/tooltip/foundation.ts +2 -26
- package/userGuide/userGuide.scss +4 -0
package/cropper/foundation.ts
CHANGED
|
@@ -60,6 +60,12 @@ export default class CropperFoundation <P = Record<string, any>, S = Record<stri
|
|
|
60
60
|
rangeX: [number, number];
|
|
61
61
|
rangeY: [number, number];
|
|
62
62
|
initial: boolean;
|
|
63
|
+
previewImg: HTMLImageElement;
|
|
64
|
+
previewContainer: HTMLElement;
|
|
65
|
+
previewContainerInitSize: {
|
|
66
|
+
width: number;
|
|
67
|
+
height: number
|
|
68
|
+
};
|
|
63
69
|
|
|
64
70
|
constructor(adapter: CropperAdapter<P, S>) {
|
|
65
71
|
super({ ...adapter });
|
|
@@ -74,6 +80,8 @@ export default class CropperFoundation <P = Record<string, any>, S = Record<stri
|
|
|
74
80
|
this.rangeX = null;
|
|
75
81
|
this.rangeY = null;
|
|
76
82
|
this.initial = false;
|
|
83
|
+
this.previewImg = null;
|
|
84
|
+
this.previewContainer = null;
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
init() {
|
|
@@ -88,6 +96,7 @@ export default class CropperFoundation <P = Record<string, any>, S = Record<stri
|
|
|
88
96
|
destroy() {
|
|
89
97
|
this.unBindMoveEvent();
|
|
90
98
|
this.unBindResizeEvent();
|
|
99
|
+
this.removePreview();
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
getImgDataWhenResize = (ratio: number) => {
|
|
@@ -228,6 +237,80 @@ export default class CropperFoundation <P = Record<string, any>, S = Record<stri
|
|
|
228
237
|
cropperBox: newCropperBoxState,
|
|
229
238
|
loaded: true,
|
|
230
239
|
} as any);
|
|
240
|
+
|
|
241
|
+
this.renderPreview();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
renderPreview = () => {
|
|
245
|
+
const { preview, src } = this.getProps();
|
|
246
|
+
const previewNode = preview?.();
|
|
247
|
+
if (!previewNode) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const img = document.createElement('img');
|
|
251
|
+
this.previewImg = img;
|
|
252
|
+
this.previewContainer = previewNode;
|
|
253
|
+
img.src = src;
|
|
254
|
+
previewNode.appendChild(img);
|
|
255
|
+
this.previewContainer.style.overflow = 'hidden';
|
|
256
|
+
// 记录预览容器初始宽高
|
|
257
|
+
const { width: previewWidth, height: previewHeight } = previewNode.getBoundingClientRect();
|
|
258
|
+
this.previewContainerInitSize = {
|
|
259
|
+
width: previewWidth,
|
|
260
|
+
height: previewHeight,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
updatePreview = (props: {
|
|
265
|
+
width: number;
|
|
266
|
+
height: number;
|
|
267
|
+
translateX: number;
|
|
268
|
+
translateY: number;
|
|
269
|
+
rotate: number
|
|
270
|
+
}) => {
|
|
271
|
+
if (!this.previewImg) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const { cropperBox } = this.getStates();
|
|
275
|
+
let zoom = 1;
|
|
276
|
+
const { width: containerWidth, height: containerHeight } = this.previewContainerInitSize;
|
|
277
|
+
let previewWidth = containerWidth;
|
|
278
|
+
let previewHeight = containerHeight;
|
|
279
|
+
if (previewWidth < previewHeight) {
|
|
280
|
+
zoom = containerWidth / cropperBox.width;
|
|
281
|
+
let tempHeight = zoom * cropperBox.height;
|
|
282
|
+
if (tempHeight > containerHeight) {
|
|
283
|
+
zoom = containerHeight / cropperBox.height;
|
|
284
|
+
previewWidth = zoom * cropperBox.width;
|
|
285
|
+
} else {
|
|
286
|
+
previewHeight = tempHeight;
|
|
287
|
+
}
|
|
288
|
+
} else {
|
|
289
|
+
zoom = containerHeight / cropperBox.height;
|
|
290
|
+
let tempWidth = zoom * cropperBox.width;
|
|
291
|
+
if (tempWidth > containerWidth) {
|
|
292
|
+
zoom = containerWidth / cropperBox.width;
|
|
293
|
+
previewHeight = zoom * cropperBox.height;
|
|
294
|
+
} else {
|
|
295
|
+
previewWidth = tempWidth;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const { width, height, translateX, translateY, rotate } = props;
|
|
299
|
+
// Set the image style
|
|
300
|
+
this.previewImg.style.width = `${width * zoom}px`;
|
|
301
|
+
this.previewImg.style.height = `${height * zoom}px`;
|
|
302
|
+
this.previewImg.style.transform = `translate(${translateX * zoom}px, ${translateY * zoom}px) rotate(${rotate}deg)`;
|
|
303
|
+
this.previewImg.style.transformOrigin = 'center';
|
|
304
|
+
// set preview container size
|
|
305
|
+
this.previewContainer.style.width = `${previewWidth}px`;
|
|
306
|
+
this.previewContainer.style.height = `${previewHeight}px`;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
removePreview = () => {
|
|
310
|
+
if (this.previewImg && this.previewContainer) {
|
|
311
|
+
this.previewContainer.removeChild(this.previewImg);
|
|
312
|
+
this.previewImg = null;
|
|
313
|
+
}
|
|
231
314
|
}
|
|
232
315
|
|
|
233
316
|
handleWheel = (e: any) => {
|
package/jsonViewer/foundation.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
import { JsonViewer, JsonViewerOptions, CustomRenderRule } from '@douyinfe/semi-json-viewer-core';
|
|
3
2
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
4
3
|
|
|
@@ -37,18 +36,35 @@ class JsonViewerFoundation extends BaseFoundation<JsonViewerAdapter> {
|
|
|
37
36
|
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
search(searchText: string) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
search(searchText: string, caseSensitive?: boolean, wholeWord?: boolean, regex?: boolean) {
|
|
40
|
+
let options;
|
|
41
|
+
if (caseSensitive !== undefined || wholeWord !== undefined || regex !== undefined) {
|
|
42
|
+
options = {
|
|
43
|
+
caseSensitive: caseSensitive ?? false,
|
|
44
|
+
wholeWord: wholeWord ?? false,
|
|
45
|
+
regex: regex ?? false
|
|
46
|
+
};
|
|
47
|
+
} else {
|
|
48
|
+
options = this.getState('searchOptions');
|
|
49
|
+
}
|
|
50
|
+
const { caseSensitive: cs, wholeWord: ww, regex: rx } = options;
|
|
51
|
+
this.jsonViewer?.getSearchWidget().search(searchText, cs, ww, rx);
|
|
44
52
|
}
|
|
45
53
|
|
|
46
|
-
prevSearch() {
|
|
47
|
-
|
|
54
|
+
prevSearch(step?: number) {
|
|
55
|
+
if (step === undefined) {
|
|
56
|
+
this.jsonViewer?.getSearchWidget().navigateResults(-1);
|
|
57
|
+
} else {
|
|
58
|
+
this.jsonViewer?.getSearchWidget().navigateResults(-step);
|
|
59
|
+
}
|
|
48
60
|
}
|
|
49
61
|
|
|
50
|
-
nextSearch() {
|
|
51
|
-
|
|
62
|
+
nextSearch(step?: number) {
|
|
63
|
+
if (step === undefined) {
|
|
64
|
+
this.jsonViewer?.getSearchWidget().navigateResults(1);
|
|
65
|
+
} else {
|
|
66
|
+
this.jsonViewer?.getSearchWidget().navigateResults(step);
|
|
67
|
+
}
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
replace(replaceText: string) {
|
|
@@ -72,6 +88,10 @@ class JsonViewerFoundation extends BaseFoundation<JsonViewerAdapter> {
|
|
|
72
88
|
showSearchBar() {
|
|
73
89
|
this._adapter.showSearchBar();
|
|
74
90
|
}
|
|
91
|
+
|
|
92
|
+
getSearchResults() {
|
|
93
|
+
return this.jsonViewer?.getSearchWidget().searchResults;
|
|
94
|
+
}
|
|
75
95
|
}
|
|
76
96
|
|
|
77
97
|
export default JsonViewerFoundation;
|
|
@@ -51,6 +51,12 @@ export default class CropperFoundation<P = Record<string, any>, S = Record<strin
|
|
|
51
51
|
rangeX: [number, number];
|
|
52
52
|
rangeY: [number, number];
|
|
53
53
|
initial: boolean;
|
|
54
|
+
previewImg: HTMLImageElement;
|
|
55
|
+
previewContainer: HTMLElement;
|
|
56
|
+
previewContainerInitSize: {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
54
60
|
constructor(adapter: CropperAdapter<P, S>);
|
|
55
61
|
init(): void;
|
|
56
62
|
destroy(): void;
|
|
@@ -72,6 +78,15 @@ export default class CropperFoundation<P = Record<string, any>, S = Record<strin
|
|
|
72
78
|
};
|
|
73
79
|
handleResize: () => void;
|
|
74
80
|
handleImageLoad: (e: any) => void;
|
|
81
|
+
renderPreview: () => void;
|
|
82
|
+
updatePreview: (props: {
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
translateX: number;
|
|
86
|
+
translateY: number;
|
|
87
|
+
rotate: number;
|
|
88
|
+
}) => void;
|
|
89
|
+
removePreview: () => void;
|
|
75
90
|
handleWheel: (e: any) => void;
|
|
76
91
|
getMoveParamByDir(dir: string): {
|
|
77
92
|
paramX: number;
|
|
@@ -156,6 +156,87 @@ class CropperFoundation extends _foundation.default {
|
|
|
156
156
|
cropperBox: newCropperBoxState,
|
|
157
157
|
loaded: true
|
|
158
158
|
});
|
|
159
|
+
this.renderPreview();
|
|
160
|
+
};
|
|
161
|
+
this.renderPreview = () => {
|
|
162
|
+
const {
|
|
163
|
+
preview,
|
|
164
|
+
src
|
|
165
|
+
} = this.getProps();
|
|
166
|
+
const previewNode = preview === null || preview === void 0 ? void 0 : preview();
|
|
167
|
+
if (!previewNode) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const img = document.createElement('img');
|
|
171
|
+
this.previewImg = img;
|
|
172
|
+
this.previewContainer = previewNode;
|
|
173
|
+
img.src = src;
|
|
174
|
+
previewNode.appendChild(img);
|
|
175
|
+
this.previewContainer.style.overflow = 'hidden';
|
|
176
|
+
// 记录预览容器初始宽高
|
|
177
|
+
const {
|
|
178
|
+
width: previewWidth,
|
|
179
|
+
height: previewHeight
|
|
180
|
+
} = previewNode.getBoundingClientRect();
|
|
181
|
+
this.previewContainerInitSize = {
|
|
182
|
+
width: previewWidth,
|
|
183
|
+
height: previewHeight
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
this.updatePreview = props => {
|
|
187
|
+
if (!this.previewImg) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const {
|
|
191
|
+
cropperBox
|
|
192
|
+
} = this.getStates();
|
|
193
|
+
let zoom = 1;
|
|
194
|
+
const {
|
|
195
|
+
width: containerWidth,
|
|
196
|
+
height: containerHeight
|
|
197
|
+
} = this.previewContainerInitSize;
|
|
198
|
+
let previewWidth = containerWidth;
|
|
199
|
+
let previewHeight = containerHeight;
|
|
200
|
+
if (previewWidth < previewHeight) {
|
|
201
|
+
zoom = containerWidth / cropperBox.width;
|
|
202
|
+
let tempHeight = zoom * cropperBox.height;
|
|
203
|
+
if (tempHeight > containerHeight) {
|
|
204
|
+
zoom = containerHeight / cropperBox.height;
|
|
205
|
+
previewWidth = zoom * cropperBox.width;
|
|
206
|
+
} else {
|
|
207
|
+
previewHeight = tempHeight;
|
|
208
|
+
}
|
|
209
|
+
} else {
|
|
210
|
+
zoom = containerHeight / cropperBox.height;
|
|
211
|
+
let tempWidth = zoom * cropperBox.width;
|
|
212
|
+
if (tempWidth > containerWidth) {
|
|
213
|
+
zoom = containerWidth / cropperBox.width;
|
|
214
|
+
previewHeight = zoom * cropperBox.height;
|
|
215
|
+
} else {
|
|
216
|
+
previewWidth = tempWidth;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const {
|
|
220
|
+
width,
|
|
221
|
+
height,
|
|
222
|
+
translateX,
|
|
223
|
+
translateY,
|
|
224
|
+
rotate
|
|
225
|
+
} = props;
|
|
226
|
+
// Set the image style
|
|
227
|
+
this.previewImg.style.width = `${width * zoom}px`;
|
|
228
|
+
this.previewImg.style.height = `${height * zoom}px`;
|
|
229
|
+
this.previewImg.style.transform = `translate(${translateX * zoom}px, ${translateY * zoom}px) rotate(${rotate}deg)`;
|
|
230
|
+
this.previewImg.style.transformOrigin = 'center';
|
|
231
|
+
// set preview container size
|
|
232
|
+
this.previewContainer.style.width = `${previewWidth}px`;
|
|
233
|
+
this.previewContainer.style.height = `${previewHeight}px`;
|
|
234
|
+
};
|
|
235
|
+
this.removePreview = () => {
|
|
236
|
+
if (this.previewImg && this.previewContainer) {
|
|
237
|
+
this.previewContainer.removeChild(this.previewImg);
|
|
238
|
+
this.previewImg = null;
|
|
239
|
+
}
|
|
159
240
|
};
|
|
160
241
|
this.handleWheel = e => {
|
|
161
242
|
// 防止双手缩放导致页面被放大
|
|
@@ -729,6 +810,8 @@ class CropperFoundation extends _foundation.default {
|
|
|
729
810
|
this.rangeX = null;
|
|
730
811
|
this.rangeY = null;
|
|
731
812
|
this.initial = false;
|
|
813
|
+
this.previewImg = null;
|
|
814
|
+
this.previewContainer = null;
|
|
732
815
|
}
|
|
733
816
|
init() {
|
|
734
817
|
// 获取容器的宽高
|
|
@@ -741,6 +824,7 @@ class CropperFoundation extends _foundation.default {
|
|
|
741
824
|
destroy() {
|
|
742
825
|
this.unBindMoveEvent();
|
|
743
826
|
this.unBindResizeEvent();
|
|
827
|
+
this.removePreview();
|
|
744
828
|
}
|
|
745
829
|
getMoveParamByDir(dir) {
|
|
746
830
|
let paramX = 0,
|
|
@@ -14,12 +14,13 @@ declare class JsonViewerFoundation extends BaseFoundation<JsonViewerAdapter> {
|
|
|
14
14
|
constructor(adapter: JsonViewerAdapter);
|
|
15
15
|
jsonViewer: JsonViewer | null;
|
|
16
16
|
init(): void;
|
|
17
|
-
search(searchText: string): void;
|
|
18
|
-
prevSearch(): void;
|
|
19
|
-
nextSearch(): void;
|
|
17
|
+
search(searchText: string, caseSensitive?: boolean, wholeWord?: boolean, regex?: boolean): void;
|
|
18
|
+
prevSearch(step?: number): void;
|
|
19
|
+
nextSearch(step?: number): void;
|
|
20
20
|
replace(replaceText: string): void;
|
|
21
21
|
replaceAll(replaceText: string): void;
|
|
22
22
|
setSearchOptions(key: string): void;
|
|
23
23
|
showSearchBar(): void;
|
|
24
|
+
getSearchResults(): import("@douyinfe/semi-json-viewer-core/src/common/model").FindMatch[];
|
|
24
25
|
}
|
|
25
26
|
export default JsonViewerFoundation;
|
|
@@ -28,23 +28,40 @@ class JsonViewerFoundation extends _foundation.default {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
search(searchText) {
|
|
31
|
+
search(searchText, caseSensitive, wholeWord, regex) {
|
|
32
32
|
var _a;
|
|
33
|
-
|
|
33
|
+
let options;
|
|
34
|
+
if (caseSensitive !== undefined || wholeWord !== undefined || regex !== undefined) {
|
|
35
|
+
options = {
|
|
36
|
+
caseSensitive: caseSensitive !== null && caseSensitive !== void 0 ? caseSensitive : false,
|
|
37
|
+
wholeWord: wholeWord !== null && wholeWord !== void 0 ? wholeWord : false,
|
|
38
|
+
regex: regex !== null && regex !== void 0 ? regex : false
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
options = this.getState('searchOptions');
|
|
42
|
+
}
|
|
34
43
|
const {
|
|
35
|
-
caseSensitive,
|
|
36
|
-
wholeWord,
|
|
37
|
-
regex
|
|
38
|
-
} =
|
|
39
|
-
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().search(searchText,
|
|
44
|
+
caseSensitive: cs,
|
|
45
|
+
wholeWord: ww,
|
|
46
|
+
regex: rx
|
|
47
|
+
} = options;
|
|
48
|
+
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().search(searchText, cs, ww, rx);
|
|
40
49
|
}
|
|
41
|
-
prevSearch() {
|
|
42
|
-
var _a;
|
|
43
|
-
(
|
|
50
|
+
prevSearch(step) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
if (step === undefined) {
|
|
53
|
+
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().navigateResults(-1);
|
|
54
|
+
} else {
|
|
55
|
+
(_b = this.jsonViewer) === null || _b === void 0 ? void 0 : _b.getSearchWidget().navigateResults(-step);
|
|
56
|
+
}
|
|
44
57
|
}
|
|
45
|
-
nextSearch() {
|
|
46
|
-
var _a;
|
|
47
|
-
(
|
|
58
|
+
nextSearch(step) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
if (step === undefined) {
|
|
61
|
+
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().navigateResults(1);
|
|
62
|
+
} else {
|
|
63
|
+
(_b = this.jsonViewer) === null || _b === void 0 ? void 0 : _b.getSearchWidget().navigateResults(step);
|
|
64
|
+
}
|
|
48
65
|
}
|
|
49
66
|
replace(replaceText) {
|
|
50
67
|
var _a;
|
|
@@ -66,5 +83,9 @@ class JsonViewerFoundation extends _foundation.default {
|
|
|
66
83
|
showSearchBar() {
|
|
67
84
|
this._adapter.showSearchBar();
|
|
68
85
|
}
|
|
86
|
+
getSearchResults() {
|
|
87
|
+
var _a;
|
|
88
|
+
return (_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().searchResults;
|
|
89
|
+
}
|
|
69
90
|
}
|
|
70
91
|
var _default = exports.default = JsonViewerFoundation;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
2
|
import { MDXProps } from 'mdx/types';
|
|
3
|
-
import type
|
|
3
|
+
import { type PluggableList } from "@mdx-js/mdx/lib/core";
|
|
4
4
|
export interface MarkdownRenderAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
5
5
|
getRuntime: () => any;
|
|
6
6
|
}
|
|
@@ -529,12 +529,12 @@
|
|
|
529
529
|
.semi-navigation-vertical .semi-navigation-header {
|
|
530
530
|
padding-top: 32px;
|
|
531
531
|
padding-bottom: 36px;
|
|
532
|
-
padding-left:
|
|
532
|
+
padding-left: 3.5px;
|
|
533
533
|
padding-right: 8px;
|
|
534
534
|
width: 100%;
|
|
535
535
|
}
|
|
536
536
|
.semi-navigation-vertical .semi-navigation-header-collapsed {
|
|
537
|
-
padding-left:
|
|
537
|
+
padding-left: 3.5px;
|
|
538
538
|
padding-right: 0;
|
|
539
539
|
transition: padding-left 100ms ease-out, width 200ms cubic-bezier(0.62, 0.05, 0.36, 0.95);
|
|
540
540
|
}
|
|
@@ -772,12 +772,12 @@
|
|
|
772
772
|
}
|
|
773
773
|
.semi-rtl .semi-navigation-vertical .semi-navigation-header,
|
|
774
774
|
.semi-portal-rtl .semi-navigation-vertical .semi-navigation-header {
|
|
775
|
-
padding-right:
|
|
775
|
+
padding-right: 3.5px;
|
|
776
776
|
padding-left: 8px;
|
|
777
777
|
}
|
|
778
778
|
.semi-rtl .semi-navigation-vertical .semi-navigation-header-collapsed,
|
|
779
779
|
.semi-portal-rtl .semi-navigation-vertical .semi-navigation-header-collapsed {
|
|
780
|
-
padding-right:
|
|
780
|
+
padding-right: 3.5px;
|
|
781
781
|
padding-left: 0;
|
|
782
782
|
transition: padding-right 100ms ease-out, width 200ms cubic-bezier(0.62, 0.05, 0.36, 0.95);
|
|
783
783
|
}
|
|
@@ -47,9 +47,9 @@ $spacing-navigation_dropdown_item_nav_sub_title-paddingY: $spacing-tight; // 导
|
|
|
47
47
|
$spacing-navigation_dropdown_item_nav_item-marginTop: 0; // 导航栏下拉菜单项顶部外边距
|
|
48
48
|
$spacing-navigation_dropdown_item_nav_item-marginBottom: 0; // 导航栏下拉菜单项底部外边距
|
|
49
49
|
$spacing-navigation_vertical_nav_item_last-marginBottom: 0; // 侧边导航栏下拉最后一个菜单项底部外边距
|
|
50
|
-
$spacing-navigation_vertical_nav_header-paddingLeft: ($width-navigation_container_collapsed - $spacing-
|
|
50
|
+
$spacing-navigation_vertical_nav_header-paddingLeft: ($width-navigation_container_collapsed - $spacing-navigation_collapsed-paddingX * 2 - $width-navigation_border - $height-navigation_header_logo_collapsed) * 0.5; // 侧边导航栏 header 左侧内边距
|
|
51
51
|
$spacing-navigation_vertical_nav_header-paddingRight: $spacing-tight; // 侧边导航栏 header 右侧内边距
|
|
52
|
-
$spacing-navigation_vertical_nav_header_collapsed-paddingLeft: ($width-navigation_container_collapsed - $spacing-
|
|
52
|
+
$spacing-navigation_vertical_nav_header_collapsed-paddingLeft: ($width-navigation_container_collapsed - $spacing-navigation_collapsed-paddingX * 2 - $width-navigation_border - $height-navigation_header_logo_collapsed) * 0.5; // 侧边导航栏收起后 header 左侧内边距
|
|
53
53
|
$spacing-navigation_vertical_nav_header_collapsed-paddingRight: 0; // 侧边导航栏收起后 header 右侧内边距
|
|
54
54
|
$spacing-navigation_vertical_footer-paddingLeft: $spacing-tight; // 侧边导航栏 footer 左侧内边距
|
|
55
55
|
$spacing-navigation_vertical_footer-paddingRight: $spacing-tight; // 侧边导航栏 footer 右侧内边距
|
|
@@ -59,7 +59,6 @@ export interface PopupContainerDOMRect extends DOMRectLikeType {
|
|
|
59
59
|
export default class Tooltip<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TooltipAdapter<P, S>, P, S> {
|
|
60
60
|
_timer: ReturnType<typeof setTimeout>;
|
|
61
61
|
_mounted: boolean;
|
|
62
|
-
anchorName: string;
|
|
63
62
|
constructor(adapter: TooltipAdapter<P, S>);
|
|
64
63
|
init(): void;
|
|
65
64
|
destroy(): void;
|
|
@@ -77,10 +76,6 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
77
76
|
_reducePos(position?: string): string;
|
|
78
77
|
clearDelayTimer(): void;
|
|
79
78
|
updateStateIfCursorOnTrigger: (trigger: HTMLElement) => void;
|
|
80
|
-
getNativeAnchorStyle: () => {
|
|
81
|
-
positionAnchor: string;
|
|
82
|
-
position: string;
|
|
83
|
-
};
|
|
84
79
|
_generateEvent(types: ArrayElement<typeof strings.TRIGGER_SET>): {
|
|
85
80
|
triggerEventSet: {
|
|
86
81
|
[x: string]: (event: any) => void;
|
|
@@ -8,7 +8,6 @@ var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
|
8
8
|
var _get2 = _interopRequireDefault(require("lodash/get"));
|
|
9
9
|
var _foundation = _interopRequireDefault(require("../base/foundation"));
|
|
10
10
|
var _a11y = require("../utils/a11y");
|
|
11
|
-
var _uuid = require("../utils/uuid");
|
|
12
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
12
|
const REGS = {
|
|
14
13
|
TOP: /top/i,
|
|
@@ -29,7 +28,6 @@ class Tooltip extends _foundation.default {
|
|
|
29
28
|
var _this;
|
|
30
29
|
super(Object.assign({}, adapter));
|
|
31
30
|
_this = this;
|
|
32
|
-
this.anchorName = `--native-semi-anchor-${(0, _uuid.getUuidShort)()}`;
|
|
33
31
|
this.removePortal = () => {
|
|
34
32
|
this._adapter.removePortal();
|
|
35
33
|
};
|
|
@@ -44,26 +42,6 @@ class Tooltip extends _foundation.default {
|
|
|
44
42
|
(_b = triggerEventSet[eventNames.mouseEnter]) === null || _b === void 0 ? void 0 : _b.call(triggerEventSet);
|
|
45
43
|
}
|
|
46
44
|
};
|
|
47
|
-
this.getNativeAnchorStyle = () => {
|
|
48
|
-
const style = {
|
|
49
|
-
positionAnchor: this.anchorName,
|
|
50
|
-
position: "fixed"
|
|
51
|
-
};
|
|
52
|
-
const position = this._adapter.getProp("position");
|
|
53
|
-
const spacing = this._adapter.getProp("spacing");
|
|
54
|
-
if (position === "top") {
|
|
55
|
-
style['bottom'] = `anchor(top)`;
|
|
56
|
-
style['justifySelf'] = "anchor-center";
|
|
57
|
-
style["transform"] = `translateY(-${spacing}px)`;
|
|
58
|
-
} else if (position === "bottom") {
|
|
59
|
-
style['top'] = `anchor(bottom)`;
|
|
60
|
-
style['justifySelf'] = "anchor-center";
|
|
61
|
-
style["transform"] = `translateY(${spacing}px)`;
|
|
62
|
-
} else {
|
|
63
|
-
throw new Error(`Currently, not support position ${position} when enable native anchor ability, only 'top' 'bottom'.`);
|
|
64
|
-
}
|
|
65
|
-
return style;
|
|
66
|
-
};
|
|
67
45
|
this.onResize = () => {
|
|
68
46
|
// this.log('resize');
|
|
69
47
|
// rePosition when window resize
|
|
@@ -51,6 +51,12 @@ export default class CropperFoundation<P = Record<string, any>, S = Record<strin
|
|
|
51
51
|
rangeX: [number, number];
|
|
52
52
|
rangeY: [number, number];
|
|
53
53
|
initial: boolean;
|
|
54
|
+
previewImg: HTMLImageElement;
|
|
55
|
+
previewContainer: HTMLElement;
|
|
56
|
+
previewContainerInitSize: {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
54
60
|
constructor(adapter: CropperAdapter<P, S>);
|
|
55
61
|
init(): void;
|
|
56
62
|
destroy(): void;
|
|
@@ -72,6 +78,15 @@ export default class CropperFoundation<P = Record<string, any>, S = Record<strin
|
|
|
72
78
|
};
|
|
73
79
|
handleResize: () => void;
|
|
74
80
|
handleImageLoad: (e: any) => void;
|
|
81
|
+
renderPreview: () => void;
|
|
82
|
+
updatePreview: (props: {
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
translateX: number;
|
|
86
|
+
translateY: number;
|
|
87
|
+
rotate: number;
|
|
88
|
+
}) => void;
|
|
89
|
+
removePreview: () => void;
|
|
75
90
|
handleWheel: (e: any) => void;
|
|
76
91
|
getMoveParamByDir(dir: string): {
|
|
77
92
|
paramX: number;
|
|
@@ -149,6 +149,87 @@ export default class CropperFoundation extends BaseFoundation {
|
|
|
149
149
|
cropperBox: newCropperBoxState,
|
|
150
150
|
loaded: true
|
|
151
151
|
});
|
|
152
|
+
this.renderPreview();
|
|
153
|
+
};
|
|
154
|
+
this.renderPreview = () => {
|
|
155
|
+
const {
|
|
156
|
+
preview,
|
|
157
|
+
src
|
|
158
|
+
} = this.getProps();
|
|
159
|
+
const previewNode = preview === null || preview === void 0 ? void 0 : preview();
|
|
160
|
+
if (!previewNode) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const img = document.createElement('img');
|
|
164
|
+
this.previewImg = img;
|
|
165
|
+
this.previewContainer = previewNode;
|
|
166
|
+
img.src = src;
|
|
167
|
+
previewNode.appendChild(img);
|
|
168
|
+
this.previewContainer.style.overflow = 'hidden';
|
|
169
|
+
// 记录预览容器初始宽高
|
|
170
|
+
const {
|
|
171
|
+
width: previewWidth,
|
|
172
|
+
height: previewHeight
|
|
173
|
+
} = previewNode.getBoundingClientRect();
|
|
174
|
+
this.previewContainerInitSize = {
|
|
175
|
+
width: previewWidth,
|
|
176
|
+
height: previewHeight
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
this.updatePreview = props => {
|
|
180
|
+
if (!this.previewImg) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const {
|
|
184
|
+
cropperBox
|
|
185
|
+
} = this.getStates();
|
|
186
|
+
let zoom = 1;
|
|
187
|
+
const {
|
|
188
|
+
width: containerWidth,
|
|
189
|
+
height: containerHeight
|
|
190
|
+
} = this.previewContainerInitSize;
|
|
191
|
+
let previewWidth = containerWidth;
|
|
192
|
+
let previewHeight = containerHeight;
|
|
193
|
+
if (previewWidth < previewHeight) {
|
|
194
|
+
zoom = containerWidth / cropperBox.width;
|
|
195
|
+
let tempHeight = zoom * cropperBox.height;
|
|
196
|
+
if (tempHeight > containerHeight) {
|
|
197
|
+
zoom = containerHeight / cropperBox.height;
|
|
198
|
+
previewWidth = zoom * cropperBox.width;
|
|
199
|
+
} else {
|
|
200
|
+
previewHeight = tempHeight;
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
zoom = containerHeight / cropperBox.height;
|
|
204
|
+
let tempWidth = zoom * cropperBox.width;
|
|
205
|
+
if (tempWidth > containerWidth) {
|
|
206
|
+
zoom = containerWidth / cropperBox.width;
|
|
207
|
+
previewHeight = zoom * cropperBox.height;
|
|
208
|
+
} else {
|
|
209
|
+
previewWidth = tempWidth;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const {
|
|
213
|
+
width,
|
|
214
|
+
height,
|
|
215
|
+
translateX,
|
|
216
|
+
translateY,
|
|
217
|
+
rotate
|
|
218
|
+
} = props;
|
|
219
|
+
// Set the image style
|
|
220
|
+
this.previewImg.style.width = `${width * zoom}px`;
|
|
221
|
+
this.previewImg.style.height = `${height * zoom}px`;
|
|
222
|
+
this.previewImg.style.transform = `translate(${translateX * zoom}px, ${translateY * zoom}px) rotate(${rotate}deg)`;
|
|
223
|
+
this.previewImg.style.transformOrigin = 'center';
|
|
224
|
+
// set preview container size
|
|
225
|
+
this.previewContainer.style.width = `${previewWidth}px`;
|
|
226
|
+
this.previewContainer.style.height = `${previewHeight}px`;
|
|
227
|
+
};
|
|
228
|
+
this.removePreview = () => {
|
|
229
|
+
if (this.previewImg && this.previewContainer) {
|
|
230
|
+
this.previewContainer.removeChild(this.previewImg);
|
|
231
|
+
this.previewImg = null;
|
|
232
|
+
}
|
|
152
233
|
};
|
|
153
234
|
this.handleWheel = e => {
|
|
154
235
|
// 防止双手缩放导致页面被放大
|
|
@@ -722,6 +803,8 @@ export default class CropperFoundation extends BaseFoundation {
|
|
|
722
803
|
this.rangeX = null;
|
|
723
804
|
this.rangeY = null;
|
|
724
805
|
this.initial = false;
|
|
806
|
+
this.previewImg = null;
|
|
807
|
+
this.previewContainer = null;
|
|
725
808
|
}
|
|
726
809
|
init() {
|
|
727
810
|
// 获取容器的宽高
|
|
@@ -734,6 +817,7 @@ export default class CropperFoundation extends BaseFoundation {
|
|
|
734
817
|
destroy() {
|
|
735
818
|
this.unBindMoveEvent();
|
|
736
819
|
this.unBindResizeEvent();
|
|
820
|
+
this.removePreview();
|
|
737
821
|
}
|
|
738
822
|
getMoveParamByDir(dir) {
|
|
739
823
|
let paramX = 0,
|
|
@@ -14,12 +14,13 @@ declare class JsonViewerFoundation extends BaseFoundation<JsonViewerAdapter> {
|
|
|
14
14
|
constructor(adapter: JsonViewerAdapter);
|
|
15
15
|
jsonViewer: JsonViewer | null;
|
|
16
16
|
init(): void;
|
|
17
|
-
search(searchText: string): void;
|
|
18
|
-
prevSearch(): void;
|
|
19
|
-
nextSearch(): void;
|
|
17
|
+
search(searchText: string, caseSensitive?: boolean, wholeWord?: boolean, regex?: boolean): void;
|
|
18
|
+
prevSearch(step?: number): void;
|
|
19
|
+
nextSearch(step?: number): void;
|
|
20
20
|
replace(replaceText: string): void;
|
|
21
21
|
replaceAll(replaceText: string): void;
|
|
22
22
|
setSearchOptions(key: string): void;
|
|
23
23
|
showSearchBar(): void;
|
|
24
|
+
getSearchResults(): import("@douyinfe/semi-json-viewer-core/src/common/model").FindMatch[];
|
|
24
25
|
}
|
|
25
26
|
export default JsonViewerFoundation;
|
|
@@ -21,23 +21,40 @@ class JsonViewerFoundation extends BaseFoundation {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
search(searchText) {
|
|
24
|
+
search(searchText, caseSensitive, wholeWord, regex) {
|
|
25
25
|
var _a;
|
|
26
|
-
|
|
26
|
+
let options;
|
|
27
|
+
if (caseSensitive !== undefined || wholeWord !== undefined || regex !== undefined) {
|
|
28
|
+
options = {
|
|
29
|
+
caseSensitive: caseSensitive !== null && caseSensitive !== void 0 ? caseSensitive : false,
|
|
30
|
+
wholeWord: wholeWord !== null && wholeWord !== void 0 ? wholeWord : false,
|
|
31
|
+
regex: regex !== null && regex !== void 0 ? regex : false
|
|
32
|
+
};
|
|
33
|
+
} else {
|
|
34
|
+
options = this.getState('searchOptions');
|
|
35
|
+
}
|
|
27
36
|
const {
|
|
28
|
-
caseSensitive,
|
|
29
|
-
wholeWord,
|
|
30
|
-
regex
|
|
31
|
-
} =
|
|
32
|
-
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().search(searchText,
|
|
37
|
+
caseSensitive: cs,
|
|
38
|
+
wholeWord: ww,
|
|
39
|
+
regex: rx
|
|
40
|
+
} = options;
|
|
41
|
+
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().search(searchText, cs, ww, rx);
|
|
33
42
|
}
|
|
34
|
-
prevSearch() {
|
|
35
|
-
var _a;
|
|
36
|
-
(
|
|
43
|
+
prevSearch(step) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
if (step === undefined) {
|
|
46
|
+
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().navigateResults(-1);
|
|
47
|
+
} else {
|
|
48
|
+
(_b = this.jsonViewer) === null || _b === void 0 ? void 0 : _b.getSearchWidget().navigateResults(-step);
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
|
-
nextSearch() {
|
|
39
|
-
var _a;
|
|
40
|
-
(
|
|
51
|
+
nextSearch(step) {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
if (step === undefined) {
|
|
54
|
+
(_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().navigateResults(1);
|
|
55
|
+
} else {
|
|
56
|
+
(_b = this.jsonViewer) === null || _b === void 0 ? void 0 : _b.getSearchWidget().navigateResults(step);
|
|
57
|
+
}
|
|
41
58
|
}
|
|
42
59
|
replace(replaceText) {
|
|
43
60
|
var _a;
|
|
@@ -59,5 +76,9 @@ class JsonViewerFoundation extends BaseFoundation {
|
|
|
59
76
|
showSearchBar() {
|
|
60
77
|
this._adapter.showSearchBar();
|
|
61
78
|
}
|
|
79
|
+
getSearchResults() {
|
|
80
|
+
var _a;
|
|
81
|
+
return (_a = this.jsonViewer) === null || _a === void 0 ? void 0 : _a.getSearchWidget().searchResults;
|
|
82
|
+
}
|
|
62
83
|
}
|
|
63
84
|
export default JsonViewerFoundation;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
2
2
|
import { MDXProps } from 'mdx/types';
|
|
3
|
-
import type
|
|
3
|
+
import { type PluggableList } from "@mdx-js/mdx/lib/core";
|
|
4
4
|
export interface MarkdownRenderAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
5
5
|
getRuntime: () => any;
|
|
6
6
|
}
|
|
@@ -529,12 +529,12 @@
|
|
|
529
529
|
.semi-navigation-vertical .semi-navigation-header {
|
|
530
530
|
padding-top: 32px;
|
|
531
531
|
padding-bottom: 36px;
|
|
532
|
-
padding-left:
|
|
532
|
+
padding-left: 3.5px;
|
|
533
533
|
padding-right: 8px;
|
|
534
534
|
width: 100%;
|
|
535
535
|
}
|
|
536
536
|
.semi-navigation-vertical .semi-navigation-header-collapsed {
|
|
537
|
-
padding-left:
|
|
537
|
+
padding-left: 3.5px;
|
|
538
538
|
padding-right: 0;
|
|
539
539
|
transition: padding-left 100ms ease-out, width 200ms cubic-bezier(0.62, 0.05, 0.36, 0.95);
|
|
540
540
|
}
|
|
@@ -772,12 +772,12 @@
|
|
|
772
772
|
}
|
|
773
773
|
.semi-rtl .semi-navigation-vertical .semi-navigation-header,
|
|
774
774
|
.semi-portal-rtl .semi-navigation-vertical .semi-navigation-header {
|
|
775
|
-
padding-right:
|
|
775
|
+
padding-right: 3.5px;
|
|
776
776
|
padding-left: 8px;
|
|
777
777
|
}
|
|
778
778
|
.semi-rtl .semi-navigation-vertical .semi-navigation-header-collapsed,
|
|
779
779
|
.semi-portal-rtl .semi-navigation-vertical .semi-navigation-header-collapsed {
|
|
780
|
-
padding-right:
|
|
780
|
+
padding-right: 3.5px;
|
|
781
781
|
padding-left: 0;
|
|
782
782
|
transition: padding-right 100ms ease-out, width 200ms cubic-bezier(0.62, 0.05, 0.36, 0.95);
|
|
783
783
|
}
|
|
@@ -47,9 +47,9 @@ $spacing-navigation_dropdown_item_nav_sub_title-paddingY: $spacing-tight; // 导
|
|
|
47
47
|
$spacing-navigation_dropdown_item_nav_item-marginTop: 0; // 导航栏下拉菜单项顶部外边距
|
|
48
48
|
$spacing-navigation_dropdown_item_nav_item-marginBottom: 0; // 导航栏下拉菜单项底部外边距
|
|
49
49
|
$spacing-navigation_vertical_nav_item_last-marginBottom: 0; // 侧边导航栏下拉最后一个菜单项底部外边距
|
|
50
|
-
$spacing-navigation_vertical_nav_header-paddingLeft: ($width-navigation_container_collapsed - $spacing-
|
|
50
|
+
$spacing-navigation_vertical_nav_header-paddingLeft: ($width-navigation_container_collapsed - $spacing-navigation_collapsed-paddingX * 2 - $width-navigation_border - $height-navigation_header_logo_collapsed) * 0.5; // 侧边导航栏 header 左侧内边距
|
|
51
51
|
$spacing-navigation_vertical_nav_header-paddingRight: $spacing-tight; // 侧边导航栏 header 右侧内边距
|
|
52
|
-
$spacing-navigation_vertical_nav_header_collapsed-paddingLeft: ($width-navigation_container_collapsed - $spacing-
|
|
52
|
+
$spacing-navigation_vertical_nav_header_collapsed-paddingLeft: ($width-navigation_container_collapsed - $spacing-navigation_collapsed-paddingX * 2 - $width-navigation_border - $height-navigation_header_logo_collapsed) * 0.5; // 侧边导航栏收起后 header 左侧内边距
|
|
53
53
|
$spacing-navigation_vertical_nav_header_collapsed-paddingRight: 0; // 侧边导航栏收起后 header 右侧内边距
|
|
54
54
|
$spacing-navigation_vertical_footer-paddingLeft: $spacing-tight; // 侧边导航栏 footer 左侧内边距
|
|
55
55
|
$spacing-navigation_vertical_footer-paddingRight: $spacing-tight; // 侧边导航栏 footer 右侧内边距
|
|
@@ -59,7 +59,6 @@ export interface PopupContainerDOMRect extends DOMRectLikeType {
|
|
|
59
59
|
export default class Tooltip<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TooltipAdapter<P, S>, P, S> {
|
|
60
60
|
_timer: ReturnType<typeof setTimeout>;
|
|
61
61
|
_mounted: boolean;
|
|
62
|
-
anchorName: string;
|
|
63
62
|
constructor(adapter: TooltipAdapter<P, S>);
|
|
64
63
|
init(): void;
|
|
65
64
|
destroy(): void;
|
|
@@ -77,10 +76,6 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
77
76
|
_reducePos(position?: string): string;
|
|
78
77
|
clearDelayTimer(): void;
|
|
79
78
|
updateStateIfCursorOnTrigger: (trigger: HTMLElement) => void;
|
|
80
|
-
getNativeAnchorStyle: () => {
|
|
81
|
-
positionAnchor: string;
|
|
82
|
-
position: string;
|
|
83
|
-
};
|
|
84
79
|
_generateEvent(types: ArrayElement<typeof strings.TRIGGER_SET>): {
|
|
85
80
|
triggerEventSet: {
|
|
86
81
|
[x: string]: (event: any) => void;
|
|
@@ -2,7 +2,6 @@ import _isEmpty from "lodash/isEmpty";
|
|
|
2
2
|
import _get from "lodash/get";
|
|
3
3
|
import BaseFoundation from '../base/foundation';
|
|
4
4
|
import { handlePrevent } from '../utils/a11y';
|
|
5
|
-
import { getUuidShort } from "../utils/uuid";
|
|
6
5
|
const REGS = {
|
|
7
6
|
TOP: /top/i,
|
|
8
7
|
RIGHT: /right/i,
|
|
@@ -22,7 +21,6 @@ export default class Tooltip extends BaseFoundation {
|
|
|
22
21
|
var _this;
|
|
23
22
|
super(Object.assign({}, adapter));
|
|
24
23
|
_this = this;
|
|
25
|
-
this.anchorName = `--native-semi-anchor-${getUuidShort()}`;
|
|
26
24
|
this.removePortal = () => {
|
|
27
25
|
this._adapter.removePortal();
|
|
28
26
|
};
|
|
@@ -37,26 +35,6 @@ export default class Tooltip extends BaseFoundation {
|
|
|
37
35
|
(_b = triggerEventSet[eventNames.mouseEnter]) === null || _b === void 0 ? void 0 : _b.call(triggerEventSet);
|
|
38
36
|
}
|
|
39
37
|
};
|
|
40
|
-
this.getNativeAnchorStyle = () => {
|
|
41
|
-
const style = {
|
|
42
|
-
positionAnchor: this.anchorName,
|
|
43
|
-
position: "fixed"
|
|
44
|
-
};
|
|
45
|
-
const position = this._adapter.getProp("position");
|
|
46
|
-
const spacing = this._adapter.getProp("spacing");
|
|
47
|
-
if (position === "top") {
|
|
48
|
-
style['bottom'] = `anchor(top)`;
|
|
49
|
-
style['justifySelf'] = "anchor-center";
|
|
50
|
-
style["transform"] = `translateY(-${spacing}px)`;
|
|
51
|
-
} else if (position === "bottom") {
|
|
52
|
-
style['top'] = `anchor(bottom)`;
|
|
53
|
-
style['justifySelf'] = "anchor-center";
|
|
54
|
-
style["transform"] = `translateY(${spacing}px)`;
|
|
55
|
-
} else {
|
|
56
|
-
throw new Error(`Currently, not support position ${position} when enable native anchor ability, only 'top' 'bottom'.`);
|
|
57
|
-
}
|
|
58
|
-
return style;
|
|
59
|
-
};
|
|
60
38
|
this.onResize = () => {
|
|
61
39
|
// this.log('resize');
|
|
62
40
|
// rePosition when window resize
|
|
@@ -2,8 +2,7 @@ import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
|
2
2
|
import { CompileOptions, evaluate, compile, EvaluateOptions, evaluateSync, RunOptions } from '@mdx-js/mdx';
|
|
3
3
|
import { MDXProps } from 'mdx/types';
|
|
4
4
|
import remarkGfm from 'remark-gfm';
|
|
5
|
-
import type
|
|
6
|
-
|
|
5
|
+
import { type PluggableList } from "@mdx-js/mdx/lib/core";
|
|
7
6
|
export interface MarkdownRenderAdapter <P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
8
7
|
getRuntime: () => any
|
|
9
8
|
|
|
@@ -47,9 +47,9 @@ $spacing-navigation_dropdown_item_nav_sub_title-paddingY: $spacing-tight; // 导
|
|
|
47
47
|
$spacing-navigation_dropdown_item_nav_item-marginTop: 0; // 导航栏下拉菜单项顶部外边距
|
|
48
48
|
$spacing-navigation_dropdown_item_nav_item-marginBottom: 0; // 导航栏下拉菜单项底部外边距
|
|
49
49
|
$spacing-navigation_vertical_nav_item_last-marginBottom: 0; // 侧边导航栏下拉最后一个菜单项底部外边距
|
|
50
|
-
$spacing-navigation_vertical_nav_header-paddingLeft: ($width-navigation_container_collapsed - $spacing-
|
|
50
|
+
$spacing-navigation_vertical_nav_header-paddingLeft: ($width-navigation_container_collapsed - $spacing-navigation_collapsed-paddingX * 2 - $width-navigation_border - $height-navigation_header_logo_collapsed) * 0.5; // 侧边导航栏 header 左侧内边距
|
|
51
51
|
$spacing-navigation_vertical_nav_header-paddingRight: $spacing-tight; // 侧边导航栏 header 右侧内边距
|
|
52
|
-
$spacing-navigation_vertical_nav_header_collapsed-paddingLeft: ($width-navigation_container_collapsed - $spacing-
|
|
52
|
+
$spacing-navigation_vertical_nav_header_collapsed-paddingLeft: ($width-navigation_container_collapsed - $spacing-navigation_collapsed-paddingX * 2 - $width-navigation_border - $height-navigation_header_logo_collapsed) * 0.5; // 侧边导航栏收起后 header 左侧内边距
|
|
53
53
|
$spacing-navigation_vertical_nav_header_collapsed-paddingRight: 0; // 侧边导航栏收起后 header 右侧内边距
|
|
54
54
|
$spacing-navigation_vertical_footer-paddingLeft: $spacing-tight; // 侧边导航栏 footer 左侧内边距
|
|
55
55
|
$spacing-navigation_vertical_footer-paddingRight: $spacing-tight; // 侧边导航栏 footer 右侧内边距
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.78.0-
|
|
3
|
+
"version": "2.78.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
7
7
|
"prepublishOnly": "npm run build:lib"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@douyinfe/semi-animation": "2.78.0-
|
|
11
|
-
"@douyinfe/semi-json-viewer-core": "2.78.0-
|
|
10
|
+
"@douyinfe/semi-animation": "2.78.0-beta.0",
|
|
11
|
+
"@douyinfe/semi-json-viewer-core": "2.78.0-beta.0",
|
|
12
12
|
"@mdx-js/mdx": "^3.0.1",
|
|
13
13
|
"async-validator": "^3.5.0",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"*.scss",
|
|
30
30
|
"*.css"
|
|
31
31
|
],
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "763dd181e5b8c00d69b15a0cec20b011532742ab",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
35
35
|
"@babel/preset-env": "^7.15.8",
|
package/tooltip/foundation.ts
CHANGED
|
@@ -4,7 +4,6 @@ import BaseFoundation, { DefaultAdapter } from '../base/foundation';
|
|
|
4
4
|
import { ArrayElement } from '../utils/type';
|
|
5
5
|
import { strings } from './constants';
|
|
6
6
|
import { handlePrevent } from '../utils/a11y';
|
|
7
|
-
import { getUuidShort } from "../utils/uuid";
|
|
8
7
|
|
|
9
8
|
const REGS = {
|
|
10
9
|
TOP: /top/i,
|
|
@@ -82,7 +81,7 @@ export interface PopupContainerDOMRect extends DOMRectLikeType {
|
|
|
82
81
|
export default class Tooltip<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<TooltipAdapter<P, S>, P, S> {
|
|
83
82
|
_timer: ReturnType<typeof setTimeout>;
|
|
84
83
|
_mounted: boolean;
|
|
85
|
-
|
|
84
|
+
|
|
86
85
|
constructor(adapter: TooltipAdapter<P, S>) {
|
|
87
86
|
super({ ...adapter });
|
|
88
87
|
this._timer = null;
|
|
@@ -136,7 +135,7 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
136
135
|
unBindResizeEvent() {
|
|
137
136
|
this._adapter.unregisterResizeHandler(this.onResize);
|
|
138
137
|
}
|
|
139
|
-
|
|
138
|
+
|
|
140
139
|
removePortal = () => {
|
|
141
140
|
this._adapter.removePortal();
|
|
142
141
|
}
|
|
@@ -200,29 +199,6 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
|
|
203
|
-
getNativeAnchorStyle = () => {
|
|
204
|
-
const style = {
|
|
205
|
-
positionAnchor: this.anchorName,
|
|
206
|
-
position: "fixed",
|
|
207
|
-
};
|
|
208
|
-
const position = this._adapter.getProp("position");
|
|
209
|
-
const spacing = this._adapter.getProp("spacing");
|
|
210
|
-
if (position === "top") {
|
|
211
|
-
style['bottom'] = `anchor(top)`;
|
|
212
|
-
style['justifySelf'] = "anchor-center";
|
|
213
|
-
style["transform"] = `translateY(-${spacing}px)`;
|
|
214
|
-
|
|
215
|
-
} else if (position === "bottom") {
|
|
216
|
-
style['top'] = `anchor(bottom)`;
|
|
217
|
-
style['justifySelf'] = "anchor-center";
|
|
218
|
-
style["transform"] = `translateY(${spacing}px)`;
|
|
219
|
-
|
|
220
|
-
} else {
|
|
221
|
-
throw new Error(`Currently, not support position ${position} when enable native anchor ability, only 'top' 'bottom'.`);
|
|
222
|
-
}
|
|
223
|
-
return style;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
202
|
_generateEvent(types: ArrayElement<typeof strings.TRIGGER_SET>) {
|
|
227
203
|
const eventNames = this._adapter.getEventName();
|
|
228
204
|
const triggerEventSet = {
|
package/userGuide/userGuide.scss
CHANGED