@douyinfe/semi-foundation 2.70.0-alpha.2 → 2.70.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 +17 -2
- package/datePicker/yearAndMonthFoundation.ts +29 -9
- package/lib/cjs/chat/foundation.d.ts +4 -0
- package/lib/cjs/chat/foundation.js +12 -1
- package/lib/cjs/datePicker/yearAndMonthFoundation.js +39 -8
- package/lib/cjs/markdownRender/foundation.d.ts +1 -0
- package/lib/cjs/markdownRender/foundation.js +9 -4
- package/lib/cjs/overflowList/constants.d.ts +1 -1
- package/lib/cjs/resizable/foundation.d.ts +2 -4
- package/lib/cjs/resizable/group/index.d.ts +6 -3
- package/lib/cjs/resizable/group/index.js +90 -23
- package/lib/cjs/resizable/resizable.css +86 -0
- package/lib/cjs/resizable/resizable.scss +100 -3
- package/lib/cjs/resizable/single/index.d.ts +1 -1
- package/lib/cjs/resizable/single/index.js +2 -2
- package/lib/cjs/resizable/types.d.ts +41 -0
- package/lib/cjs/resizable/types.js +12 -0
- package/lib/cjs/resizable/utils.js +5 -5
- package/lib/cjs/resizable/variables.scss +8 -0
- package/lib/cjs/table/table.css +2 -1
- package/lib/cjs/table/table.scss +2 -1
- package/lib/cjs/transfer/transfer.css +1 -0
- package/lib/cjs/transfer/transfer.scss +1 -0
- package/lib/cjs/tree/treeUtil.d.ts +1 -1
- package/lib/cjs/treeSelect/treeSelect.css +3 -1
- package/lib/cjs/treeSelect/treeSelect.scss +4 -1
- package/lib/es/chat/foundation.d.ts +4 -0
- package/lib/es/chat/foundation.js +12 -1
- package/lib/es/datePicker/yearAndMonthFoundation.js +39 -8
- package/lib/es/markdownRender/foundation.d.ts +1 -0
- package/lib/es/markdownRender/foundation.js +9 -4
- package/lib/es/overflowList/constants.d.ts +1 -1
- package/lib/es/resizable/foundation.d.ts +2 -4
- package/lib/es/resizable/foundation.js +2 -4
- package/lib/es/resizable/group/index.d.ts +6 -3
- package/lib/es/resizable/group/index.js +90 -23
- package/lib/es/resizable/resizable.css +86 -0
- package/lib/es/resizable/resizable.scss +100 -3
- package/lib/es/resizable/single/index.d.ts +1 -1
- package/lib/es/resizable/single/index.js +1 -1
- package/lib/es/resizable/types.d.ts +41 -0
- package/lib/es/resizable/types.js +6 -0
- package/lib/es/resizable/utils.js +5 -5
- package/lib/es/resizable/variables.scss +8 -0
- package/lib/es/table/table.css +2 -1
- package/lib/es/table/table.scss +2 -1
- package/lib/es/transfer/transfer.css +1 -0
- package/lib/es/transfer/transfer.scss +1 -0
- package/lib/es/tree/treeUtil.d.ts +1 -1
- package/lib/es/treeSelect/treeSelect.css +3 -1
- package/lib/es/treeSelect/treeSelect.scss +4 -1
- package/markdownRender/foundation.ts +13 -7
- package/package.json +3 -5
- package/resizable/foundation.ts +3 -19
- package/resizable/group/index.ts +92 -29
- package/resizable/resizable.scss +100 -3
- package/resizable/single/index.ts +1 -1
- package/resizable/{singleConstants.ts → types.ts} +0 -65
- package/resizable/utils.ts +7 -6
- package/resizable/variables.scss +8 -0
- package/table/table.scss +2 -1
- package/transfer/transfer.scss +1 -0
- package/treeSelect/treeSelect.scss +4 -1
- package/tsconfig.json +1 -1
- package/jsonViewer/constants.ts +0 -7
- package/jsonViewer/foundation.ts +0 -67
- package/jsonViewer/jsonViewer.scss +0 -152
- package/jsonViewer/script/build.js +0 -51
- package/jsonViewer/variables.scss +0 -27
- package/lib/cjs/jsonViewer/constants.d.ts +0 -4
- package/lib/cjs/jsonViewer/constants.js +0 -10
- package/lib/cjs/jsonViewer/foundation.d.ts +0 -21
- package/lib/cjs/jsonViewer/foundation.js +0 -78
- package/lib/cjs/jsonViewer/jsonViewer.css +0 -136
- package/lib/cjs/jsonViewer/jsonViewer.scss +0 -152
- package/lib/cjs/jsonViewer/variables.scss +0 -27
- package/lib/cjs/resizable/groupConstants.d.ts +0 -16
- package/lib/cjs/resizable/groupConstants.js +0 -25
- package/lib/cjs/resizable/singleConstants.d.ts +0 -105
- package/lib/cjs/resizable/singleConstants.js +0 -67
- package/lib/es/jsonViewer/constants.d.ts +0 -4
- package/lib/es/jsonViewer/constants.js +0 -5
- package/lib/es/jsonViewer/foundation.d.ts +0 -21
- package/lib/es/jsonViewer/foundation.js +0 -60
- package/lib/es/jsonViewer/jsonViewer.css +0 -136
- package/lib/es/jsonViewer/jsonViewer.scss +0 -152
- package/lib/es/jsonViewer/variables.scss +0 -27
- package/lib/es/resizable/groupConstants.d.ts +0 -16
- package/lib/es/resizable/groupConstants.js +0 -19
- package/lib/es/resizable/singleConstants.d.ts +0 -105
- package/lib/es/resizable/singleConstants.js +0 -61
- package/resizable/groupConstants.ts +0 -25
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.70.0
|
|
3
|
+
"version": "2.70.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.70.0
|
|
11
|
-
"@douyinfe/semi-json-viewer-core": "2.70.0-alpha.2",
|
|
10
|
+
"@douyinfe/semi-animation": "2.70.0",
|
|
12
11
|
"@mdx-js/mdx": "^3.0.1",
|
|
13
12
|
"async-validator": "^3.5.0",
|
|
14
13
|
"classnames": "^2.2.6",
|
|
@@ -29,7 +28,7 @@
|
|
|
29
28
|
"*.scss",
|
|
30
29
|
"*.css"
|
|
31
30
|
],
|
|
32
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "0c25d2be6eecc7bb66a02630eeceee81834be9db",
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
35
34
|
"@babel/preset-env": "^7.15.8",
|
|
@@ -38,7 +37,6 @@
|
|
|
38
37
|
"@types/prismjs": "^1.26.3",
|
|
39
38
|
"babel-plugin-lodash": "^3.3.4",
|
|
40
39
|
"del": "^6.0.0",
|
|
41
|
-
"esbuild": "0.24.0",
|
|
42
40
|
"gulp": "^4.0.2",
|
|
43
41
|
"gulp-babel": "^8.0.0",
|
|
44
42
|
"gulp-replace": "^1.1.3",
|
package/resizable/foundation.ts
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
ResizableHandlerAdapter,
|
|
3
|
-
ResizableHandlerFoundation,
|
|
4
|
-
ResizableFoundation,
|
|
5
|
-
ResizableAdapter }
|
|
6
|
-
from './single';
|
|
7
|
-
|
|
8
|
-
export {
|
|
1
|
+
export {
|
|
9
2
|
ResizableHandlerAdapter,
|
|
10
3
|
ResizableHandlerFoundation,
|
|
11
4
|
ResizableFoundation,
|
|
12
5
|
ResizableAdapter
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
ResizeGroupAdapter,
|
|
17
|
-
ResizeItemAdapter,
|
|
18
|
-
ResizeHandlerAdapter,
|
|
19
|
-
ResizeGroupFoundation,
|
|
20
|
-
ResizeItemFoundation,
|
|
21
|
-
ResizeHandlerFoundation
|
|
22
|
-
} from './group';
|
|
6
|
+
} from './single';
|
|
23
7
|
|
|
24
8
|
export {
|
|
25
9
|
ResizeGroupAdapter,
|
|
@@ -28,4 +12,4 @@ export {
|
|
|
28
12
|
ResizeGroupFoundation,
|
|
29
13
|
ResizeItemFoundation,
|
|
30
14
|
ResizeHandlerFoundation
|
|
31
|
-
};
|
|
15
|
+
} from './group';
|
package/resizable/group/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { getItemDirection, getPixelSize } from "../utils";
|
|
2
2
|
import BaseFoundation, { DefaultAdapter } from '../../base/foundation';
|
|
3
|
-
import { ResizeStartCallback, ResizeCallback } from "../
|
|
3
|
+
import { ResizeStartCallback, ResizeCallback } from "../types";
|
|
4
4
|
import { adjustNewSize, judgeConstraint, getOffset } from "../utils";
|
|
5
|
+
import { debounce } from "lodash";
|
|
5
6
|
export interface ResizeHandlerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
6
7
|
registerEvents: () => void;
|
|
7
8
|
unregisterEvents: () => void
|
|
@@ -61,16 +62,23 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
|
|
|
61
62
|
return this._adapter.getGroupRef();
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
get groupSize(): number {
|
|
66
|
+
const { direction } = this.getProps();
|
|
67
|
+
let groupSize = direction === 'horizontal' ? this.groupRef.offsetWidth : this.groupRef.offsetHeight;
|
|
68
|
+
return groupSize;
|
|
69
|
+
}
|
|
70
|
+
|
|
64
71
|
direction: 'horizontal' | 'vertical'
|
|
65
|
-
itemMinusMap: Map<number, number>;
|
|
72
|
+
itemMinusMap: Map<number, number>; // 这个是为了给handler留出空间,方便维护每一个item的size为cal(percent% - minus)
|
|
66
73
|
totalMinus: number;
|
|
67
|
-
|
|
74
|
+
itemPercentMap: Map<number, number>; // 内部维护一个百分比数组,消除浮点计算误差
|
|
68
75
|
|
|
69
76
|
|
|
70
77
|
init(): void {
|
|
71
78
|
this.direction = this.getProp('direction');
|
|
72
79
|
this.itemMinusMap = new Map();
|
|
73
|
-
this.
|
|
80
|
+
this.itemPercentMap = new Map();
|
|
81
|
+
this.initSpace();
|
|
74
82
|
}
|
|
75
83
|
get window(): Window | null {
|
|
76
84
|
return this.groupRef.ownerDocument.defaultView as Window ?? null;
|
|
@@ -93,16 +101,18 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
|
|
|
93
101
|
const lastStyle = this.window.getComputedStyle(lastItem);
|
|
94
102
|
const nextStyle = this.window.getComputedStyle(nextItem);
|
|
95
103
|
|
|
96
|
-
lastOffset = getOffset(lastStyle, this.direction);
|
|
97
|
-
nextOffset = getOffset(nextStyle, this.direction);
|
|
104
|
+
lastOffset = getOffset(lastStyle, this.direction) + this.itemMinusMap.get(handlerIndex);
|
|
105
|
+
nextOffset = getOffset(nextStyle, this.direction) + this.itemMinusMap.get(handlerIndex + 1);
|
|
106
|
+
let lastItemSize = (this.direction === 'horizontal' ? lastItem.offsetWidth : lastItem.offsetHeight) + this.itemMinusMap.get(handlerIndex),
|
|
107
|
+
nextItemSize = (this.direction === 'horizontal' ? nextItem.offsetWidth : nextItem.offsetHeight) + this.itemMinusMap.get(handlerIndex + 1);
|
|
98
108
|
const states = this.getStates();
|
|
99
109
|
this.setState({
|
|
100
110
|
isResizing: true,
|
|
101
111
|
originalPosition: {
|
|
102
112
|
x: clientX,
|
|
103
113
|
y: clientY,
|
|
104
|
-
lastItemSize
|
|
105
|
-
nextItemSize
|
|
114
|
+
lastItemSize,
|
|
115
|
+
nextItemSize,
|
|
106
116
|
lastOffset,
|
|
107
117
|
nextOffset,
|
|
108
118
|
},
|
|
@@ -138,33 +148,38 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
|
|
|
138
148
|
const props = this.getProps();
|
|
139
149
|
const { direction } = props;
|
|
140
150
|
let lastItem = this._adapter.getItem(curHandler), nextItem = this._adapter.getItem(curHandler + 1);
|
|
141
|
-
let parentSize = this.
|
|
142
|
-
let availableSize = parentSize - this.totalMinus;
|
|
143
|
-
|
|
151
|
+
let parentSize = this.groupSize;
|
|
144
152
|
let delta = direction === 'horizontal' ? (clientX - initX) : (clientY - initY);
|
|
145
153
|
let lastNewSize = lastItemSize + delta;
|
|
146
154
|
let nextNewSize = nextItemSize - delta;
|
|
147
155
|
|
|
148
156
|
// 判断是否超出限制
|
|
149
|
-
let lastFlag = judgeConstraint(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler),
|
|
150
|
-
nextFlag = judgeConstraint(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1),
|
|
157
|
+
let lastFlag = judgeConstraint(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), parentSize, lastOffset),
|
|
158
|
+
nextFlag = judgeConstraint(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), parentSize, nextOffset);
|
|
151
159
|
|
|
152
160
|
if (lastFlag) {
|
|
153
|
-
lastNewSize = adjustNewSize(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler),
|
|
161
|
+
lastNewSize = adjustNewSize(lastNewSize, this._adapter.getItemMin(curHandler), this._adapter.getItemMax(curHandler), parentSize, lastOffset);
|
|
154
162
|
nextNewSize = lastItemSize + nextItemSize - lastNewSize;
|
|
155
163
|
}
|
|
156
164
|
|
|
157
165
|
if (nextFlag) {
|
|
158
|
-
nextNewSize = adjustNewSize(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1),
|
|
166
|
+
nextNewSize = adjustNewSize(nextNewSize, this._adapter.getItemMin(curHandler + 1), this._adapter.getItemMax(curHandler + 1), parentSize, nextOffset);
|
|
159
167
|
lastNewSize = lastItemSize + nextItemSize - nextNewSize;
|
|
160
168
|
}
|
|
161
169
|
|
|
170
|
+
let lastItemPercent = this.itemPercentMap.get(curHandler),
|
|
171
|
+
nextItemPercent = this.itemPercentMap.get(curHandler + 1);
|
|
172
|
+
|
|
173
|
+
let lastNewPercent = (lastNewSize) / parentSize * 100;
|
|
174
|
+
let nextNewPercent = lastItemPercent + nextItemPercent - lastNewPercent; // 消除浮点误差
|
|
175
|
+
this.itemPercentMap.set(curHandler, lastNewPercent);
|
|
176
|
+
this.itemPercentMap.set(curHandler + 1, nextNewPercent);
|
|
162
177
|
if (direction === 'horizontal') {
|
|
163
|
-
lastItem.style.width = (
|
|
164
|
-
nextItem.style.width = (
|
|
178
|
+
lastItem.style.width = `calc(${lastNewPercent}% - ${this.itemMinusMap.get(curHandler)}px)`;
|
|
179
|
+
nextItem.style.width = `calc(${nextNewPercent}% - ${this.itemMinusMap.get(curHandler + 1)}px)`;
|
|
165
180
|
} else if (direction === 'vertical') {
|
|
166
|
-
lastItem.style.height = (
|
|
167
|
-
nextItem.style.height = (
|
|
181
|
+
lastItem.style.height = `calc(${lastNewPercent}% - ${this.itemMinusMap.get(curHandler)}px)`;
|
|
182
|
+
nextItem.style.height = `calc(${nextNewPercent}% - ${this.itemMinusMap.get(curHandler + 1)}px)`;
|
|
168
183
|
}
|
|
169
184
|
|
|
170
185
|
let lastFunc = this._adapter.getItemChange(curHandler),
|
|
@@ -197,13 +212,13 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
|
|
|
197
212
|
this.unregisterEvents();
|
|
198
213
|
}
|
|
199
214
|
|
|
200
|
-
|
|
215
|
+
initSpace = () => {
|
|
201
216
|
const props = this.getProps();
|
|
202
217
|
const { direction } = props;
|
|
203
218
|
|
|
204
219
|
// calculate accurate space for group item
|
|
205
220
|
let handlerSizes = new Array(this._adapter.getHandlerCount()).fill(0);
|
|
206
|
-
let
|
|
221
|
+
let parentSize = this.groupSize;
|
|
207
222
|
this.totalMinus = 0;
|
|
208
223
|
for (let i = 0; i < this._adapter.getHandlerCount(); i++) {
|
|
209
224
|
let handlerSize = direction === 'horizontal' ? this._adapter.getHandler(i).offsetWidth : this._adapter.getHandler(i).offsetHeight;
|
|
@@ -225,8 +240,8 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
|
|
|
225
240
|
}
|
|
226
241
|
const child = this._adapter.getItem(i);
|
|
227
242
|
let minSize = this._adapter.getItemMin(i), maxSize = this._adapter.getItemMax(i);
|
|
228
|
-
let minSizePercent = minSize ? getPixelSize(minSize,
|
|
229
|
-
maxSizePercent = maxSize ? getPixelSize(maxSize,
|
|
243
|
+
let minSizePercent = minSize ? getPixelSize(minSize, parentSize) / parentSize * 100 : 0,
|
|
244
|
+
maxSizePercent = maxSize ? getPixelSize(maxSize, parentSize) / parentSize * 100 : 100;
|
|
230
245
|
if (minSizePercent > maxSizePercent) {
|
|
231
246
|
console.warn('[Semi ResizableItem]: min size bigger than max size');
|
|
232
247
|
}
|
|
@@ -237,21 +252,21 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
|
|
|
237
252
|
if (typeof defaultSize === 'string') {
|
|
238
253
|
if (defaultSize.endsWith('%')) {
|
|
239
254
|
itemSizePercent = parseFloat(defaultSize.slice(0, -1));
|
|
255
|
+
this.itemPercentMap.set(i, itemSizePercent);
|
|
240
256
|
} else if (defaultSize.endsWith('px')) {
|
|
241
|
-
itemSizePercent = parseFloat(defaultSize.slice(0, -2)) /
|
|
257
|
+
itemSizePercent = parseFloat(defaultSize.slice(0, -2)) / parentSize * 100;
|
|
258
|
+
this.itemPercentMap.set(i, itemSizePercent);
|
|
242
259
|
} else if (/^-?\d+(\.\d+)?$/.test(defaultSize)) {
|
|
243
260
|
// 仅由数字组成,表示按比例分配剩下空间
|
|
244
261
|
undefineLoc.set(i, parseFloat(defaultSize));
|
|
245
262
|
undefinedTotal += parseFloat(defaultSize);
|
|
246
263
|
continue;
|
|
247
264
|
}
|
|
248
|
-
} else {
|
|
265
|
+
} else if (typeof defaultSize === 'number') {
|
|
249
266
|
undefineLoc.set(i, defaultSize);
|
|
250
267
|
undefinedTotal += defaultSize;
|
|
251
268
|
continue;
|
|
252
269
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
270
|
totalSizePercent += itemSizePercent;
|
|
256
271
|
|
|
257
272
|
if (direction === 'horizontal') {
|
|
@@ -279,14 +294,62 @@ export class ResizeGroupFoundation<P = Record<string, any>, S = Record<string, a
|
|
|
279
294
|
|
|
280
295
|
undefineLoc.forEach((value, key) => {
|
|
281
296
|
const child = this._adapter.getItem(key);
|
|
297
|
+
const percent = value / undefinedTotal * undefineSizePercent;
|
|
298
|
+
this.itemPercentMap.set(key, percent);
|
|
282
299
|
if (direction === 'horizontal') {
|
|
283
|
-
child.style.width = `calc(${
|
|
300
|
+
child.style.width = `calc(${percent}% - ${this.itemMinusMap.get(key)}px)`;
|
|
284
301
|
} else {
|
|
285
|
-
child.style.height = `calc(${
|
|
302
|
+
child.style.height = `calc(${percent}% - ${this.itemMinusMap.get(key)}px)`;
|
|
286
303
|
}
|
|
287
304
|
});
|
|
288
305
|
}
|
|
289
306
|
|
|
307
|
+
ensureConstraint = debounce(() => {
|
|
308
|
+
// 浏览器拖拽时保证px值最大最小仍生效
|
|
309
|
+
const { direction } = this.getProps();
|
|
310
|
+
const itemCount = this._adapter.getItemCount();
|
|
311
|
+
let continueFlag = true;
|
|
312
|
+
for (let i = 0; i < itemCount; i++) {
|
|
313
|
+
const child = this._adapter.getItem(i);
|
|
314
|
+
const childSize = direction === 'horizontal' ? child.offsetWidth : child.offsetHeight;
|
|
315
|
+
// 判断由非鼠标拖拽导致item的size变化过程中是否有超出限制的情况
|
|
316
|
+
const childFlag = judgeConstraint(childSize, this._adapter.getItemMin(i), this._adapter.getItemMax(i), this.groupSize, this.itemMinusMap.get(i));
|
|
317
|
+
if (childFlag) {
|
|
318
|
+
const childNewSize = adjustNewSize(childSize, this._adapter.getItemMin(i), this._adapter.getItemMax(i), this.groupSize, this.itemMinusMap.get(i));
|
|
319
|
+
for (let j = i + 1; j < itemCount; j++) {
|
|
320
|
+
// 找到下一个没有超出限制的item
|
|
321
|
+
const item = this._adapter.getItem(j);
|
|
322
|
+
const itemSize = direction === 'horizontal' ? item.offsetWidth : item.offsetHeight;
|
|
323
|
+
const itemFlag = judgeConstraint(itemSize, this._adapter.getItemMin(j), this._adapter.getItemMax(j), this.groupSize, this.itemMinusMap.get(j));
|
|
324
|
+
if (!itemFlag) {
|
|
325
|
+
let childPercent = this.itemPercentMap.get(i),
|
|
326
|
+
itemPercent = this.itemPercentMap.get(j);
|
|
327
|
+
let childNewPercent = childNewSize / this.groupSize * 100;
|
|
328
|
+
let itemNewPercent = childPercent + itemPercent - childNewPercent;
|
|
329
|
+
this.itemPercentMap.set(i, childNewPercent);
|
|
330
|
+
this.itemPercentMap.set(j, itemNewPercent);
|
|
331
|
+
if (direction === 'horizontal') {
|
|
332
|
+
child.style.width = `calc(${childNewPercent}% - ${this.itemMinusMap.get(i)}px)`;
|
|
333
|
+
item.style.width = `calc(${itemNewPercent}% - ${this.itemMinusMap.get(j)}px)`;
|
|
334
|
+
} else {
|
|
335
|
+
child.style.height = `calc(${childNewPercent}% - ${this.itemMinusMap.get(i)}px)`;
|
|
336
|
+
item.style.height = `calc(${itemNewPercent}% - ${this.itemMinusMap.get(j)}px)`;
|
|
337
|
+
}
|
|
338
|
+
break;
|
|
339
|
+
} else {
|
|
340
|
+
if (j === itemCount - 1) {
|
|
341
|
+
continueFlag = false;
|
|
342
|
+
console.warn('[Semi ResizableGroup]: no enough space to adjust min/max size');
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (!continueFlag) {
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}, 200)
|
|
352
|
+
|
|
290
353
|
destroy(): void {
|
|
291
354
|
|
|
292
355
|
}
|
package/resizable/resizable.scss
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
@import
|
|
2
|
-
|
|
1
|
+
@import "./variables.scss";
|
|
3
2
|
$module: #{$prefix}-resizable;
|
|
4
3
|
|
|
5
4
|
.#{$module} {
|
|
@@ -13,8 +12,83 @@ $module: #{$prefix}-resizable;
|
|
|
13
12
|
position: absolute;
|
|
14
13
|
user-select: none;
|
|
15
14
|
z-index: $z-resizable_handler;
|
|
15
|
+
|
|
16
|
+
// 基础样式
|
|
17
|
+
@mixin row-resize-base {
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: $height-row-handler;
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
cursor: row-resize;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@mixin col-resize-base {
|
|
26
|
+
width: $width-col-handler;
|
|
27
|
+
height: 100%;
|
|
28
|
+
top: 0;
|
|
29
|
+
left: 0;
|
|
30
|
+
cursor: col-resize;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@mixin edge-resize-base {
|
|
34
|
+
width: $width-edge-handler;
|
|
35
|
+
height: $height-edge-handler;
|
|
36
|
+
position: absolute;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 方向样式
|
|
40
|
+
&-top {
|
|
41
|
+
@include row-resize-base;
|
|
42
|
+
top: calc(-1 * $height-row-handler / 2);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&-right {
|
|
46
|
+
@include col-resize-base;
|
|
47
|
+
left: auto;
|
|
48
|
+
right: calc(-1 * $width-col-handler / 2);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&-bottom {
|
|
52
|
+
@include row-resize-base;
|
|
53
|
+
top: auto;
|
|
54
|
+
bottom: calc(-1 * $height-row-handler / 2);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&-left {
|
|
58
|
+
@include col-resize-base;
|
|
59
|
+
left: calc(-1 * $width-col-handler / 2);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 边角样式
|
|
63
|
+
&-topRight {
|
|
64
|
+
@include edge-resize-base;
|
|
65
|
+
right: calc(-1 * $width-edge-handler / 2);
|
|
66
|
+
top: calc(-1 * $height-edge-handler / 2);
|
|
67
|
+
cursor: ne-resize;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&-bottomRight {
|
|
71
|
+
@include edge-resize-base;
|
|
72
|
+
right: calc(-1 * $width-edge-handler / 2);
|
|
73
|
+
bottom: calc(-1 * $height-edge-handler / 2);
|
|
74
|
+
cursor: se-resize;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&-bottomLeft {
|
|
78
|
+
@include edge-resize-base;
|
|
79
|
+
left: calc(-1 * $width-edge-handler / 2);
|
|
80
|
+
bottom: calc(-1 * $height-edge-handler / 2);
|
|
81
|
+
cursor: sw-resize;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&-topLeft {
|
|
85
|
+
@include edge-resize-base;
|
|
86
|
+
left: calc(-1 * $width-edge-handler / 2);
|
|
87
|
+
top: calc(-1 * $height-edge-handler / 2);
|
|
88
|
+
cursor: nw-resize;
|
|
89
|
+
}
|
|
16
90
|
}
|
|
17
|
-
|
|
91
|
+
|
|
18
92
|
&-group {
|
|
19
93
|
display: flex;
|
|
20
94
|
position: relative;
|
|
@@ -37,5 +111,28 @@ $module: #{$prefix}-resizable;
|
|
|
37
111
|
justify-content: center;
|
|
38
112
|
background-color: var(--semi-color-fill-0);
|
|
39
113
|
opacity: 1;
|
|
114
|
+
|
|
115
|
+
&-vertical {
|
|
116
|
+
width: 100%;
|
|
117
|
+
height: $height-vertical-handler;
|
|
118
|
+
flex-shrink: 0;
|
|
119
|
+
cursor: row-resize;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&-horizontal {
|
|
123
|
+
height: 100%;
|
|
124
|
+
width: $width-horizontal-handler;
|
|
125
|
+
flex-shrink: 0;
|
|
126
|
+
cursor: col-resize;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&-background {
|
|
131
|
+
height: 100%;
|
|
132
|
+
width: 100%;
|
|
133
|
+
inset: 0;
|
|
134
|
+
z-index: $z-resizable_background;
|
|
135
|
+
opacity: 0;
|
|
136
|
+
position: fixed;
|
|
40
137
|
}
|
|
41
138
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from '../../base/foundation';
|
|
2
|
-
import { DEFAULT_SIZE, Size, NumberSize, Direction, NewSize } from "../
|
|
2
|
+
import { DEFAULT_SIZE, Size, NumberSize, Direction, NewSize } from "../types";
|
|
3
3
|
import { getStringSize, getNumberSize, has, calculateNewMax, findNextSnap, snap, clamp } from "../utils";
|
|
4
4
|
export interface ResizableHandlerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
5
5
|
registerEvent: () => void;
|
|
@@ -1,71 +1,6 @@
|
|
|
1
1
|
// single
|
|
2
|
-
const rowStyleBase = {
|
|
3
|
-
width: '100%',
|
|
4
|
-
height: '10px',
|
|
5
|
-
top: '0px',
|
|
6
|
-
left: '0px',
|
|
7
|
-
cursor: 'row-resize',
|
|
8
|
-
} as const;
|
|
9
|
-
const colStyleBase = {
|
|
10
|
-
width: '10px',
|
|
11
|
-
height: '100%',
|
|
12
|
-
top: '0px',
|
|
13
|
-
left: '0px',
|
|
14
|
-
cursor: 'col-resize',
|
|
15
|
-
} as const;
|
|
16
|
-
const edgeStyleBase = {
|
|
17
|
-
width: '20px',
|
|
18
|
-
height: '20px',
|
|
19
|
-
position: 'absolute',
|
|
20
|
-
} as const;
|
|
21
|
-
|
|
22
2
|
export const directions = ['top', 'right', 'bottom', 'left', 'topRight', 'bottomRight', 'bottomLeft', 'topLeft'] as const;
|
|
23
3
|
|
|
24
|
-
export const directionStyles = {
|
|
25
|
-
top: {
|
|
26
|
-
...rowStyleBase,
|
|
27
|
-
top: '-5px',
|
|
28
|
-
},
|
|
29
|
-
right: {
|
|
30
|
-
...colStyleBase,
|
|
31
|
-
left: undefined,
|
|
32
|
-
right: '-5px',
|
|
33
|
-
},
|
|
34
|
-
bottom: {
|
|
35
|
-
...rowStyleBase,
|
|
36
|
-
top: undefined,
|
|
37
|
-
bottom: '-5px',
|
|
38
|
-
},
|
|
39
|
-
left: {
|
|
40
|
-
...colStyleBase,
|
|
41
|
-
left: '-5px',
|
|
42
|
-
},
|
|
43
|
-
topRight: {
|
|
44
|
-
...edgeStyleBase,
|
|
45
|
-
right: '-10px',
|
|
46
|
-
top: '-10px',
|
|
47
|
-
cursor: 'ne-resize',
|
|
48
|
-
},
|
|
49
|
-
bottomRight: {
|
|
50
|
-
...edgeStyleBase,
|
|
51
|
-
right: '-10px',
|
|
52
|
-
bottom: '-10px',
|
|
53
|
-
cursor: 'se-resize',
|
|
54
|
-
},
|
|
55
|
-
bottomLeft: {
|
|
56
|
-
...edgeStyleBase,
|
|
57
|
-
left: '-10px',
|
|
58
|
-
bottom: '-10px',
|
|
59
|
-
cursor: 'sw-resize',
|
|
60
|
-
},
|
|
61
|
-
topLeft: {
|
|
62
|
-
...edgeStyleBase,
|
|
63
|
-
left: '-10px',
|
|
64
|
-
top: '-10px',
|
|
65
|
-
cursor: 'nw-resize',
|
|
66
|
-
},
|
|
67
|
-
} as const;
|
|
68
|
-
|
|
69
4
|
export type Direction = 'top' | 'right' | 'bottom' | 'left' | 'topRight' | 'bottomRight' | 'bottomLeft' | 'topLeft';
|
|
70
5
|
|
|
71
6
|
export interface HandleClassName {
|
package/resizable/utils.ts
CHANGED
|
@@ -80,7 +80,8 @@ export const calculateNewMax = (
|
|
|
80
80
|
minWidth,
|
|
81
81
|
minHeight,
|
|
82
82
|
};
|
|
83
|
-
};
|
|
83
|
+
};
|
|
84
|
+
export const getItemDirection = (dir: 'vertical' | 'horizontal') => {
|
|
84
85
|
if (dir === 'vertical') {
|
|
85
86
|
return ['bottom', 'top'];
|
|
86
87
|
} else {
|
|
@@ -104,10 +105,10 @@ export const judgeConstraint = (newSize: number, min: string, max: string, paren
|
|
|
104
105
|
max = max ?? "100%";
|
|
105
106
|
const minSize = getPixelSize(min, parentSize);
|
|
106
107
|
const maxSize = getPixelSize(max, parentSize);
|
|
107
|
-
if (newSize
|
|
108
|
+
if (newSize < minSize + offset) {
|
|
108
109
|
return true;
|
|
109
110
|
}
|
|
110
|
-
if (newSize
|
|
111
|
+
if (newSize > maxSize) {
|
|
111
112
|
return true;
|
|
112
113
|
}
|
|
113
114
|
return false;
|
|
@@ -118,11 +119,11 @@ export const adjustNewSize = (newSize: number, min: string, max: string, parentS
|
|
|
118
119
|
max = max ?? "100%";
|
|
119
120
|
const minSize = getPixelSize(min, parentSize);
|
|
120
121
|
const maxSize = getPixelSize(max, parentSize);
|
|
121
|
-
if (newSize
|
|
122
|
+
if (newSize < minSize + offset) {
|
|
122
123
|
return minSize + offset;
|
|
123
124
|
}
|
|
124
|
-
if (newSize
|
|
125
|
-
return maxSize
|
|
125
|
+
if (newSize > maxSize) {
|
|
126
|
+
return maxSize;
|
|
126
127
|
}
|
|
127
128
|
return newSize;
|
|
128
129
|
};
|
package/resizable/variables.scss
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
1
|
$z-resizable_handler: 2000 !default; // 伸缩框组件中handler的z-index
|
|
2
|
+
$z-resizable_background: 2010; // 伸缩框组件中背景的z-index
|
|
3
|
+
|
|
4
|
+
$height-row-handler: 10px; // 单个伸缩框中上下handler的高度
|
|
5
|
+
$width-col-handler: 10px; // 单个伸缩框中左右handler的宽度
|
|
6
|
+
$width-edge-handler: 20px; // 单个伸缩框中边角handler的宽度
|
|
7
|
+
$height-edge-handler: 20px; // 单个伸缩框中边角handler的高度
|
|
8
|
+
$width-horizontal-handler: 10px; // 组合伸缩框中水平方向handler的宽度
|
|
9
|
+
$height-vertical-handler: 10px; // 组合伸缩框中垂直方向handler的高度
|
package/table/table.scss
CHANGED
|
@@ -145,7 +145,8 @@ $module: #{$prefix}-table;
|
|
|
145
145
|
&.#{$module}-row-head-clickSort {
|
|
146
146
|
cursor: pointer;
|
|
147
147
|
&:hover {
|
|
148
|
-
background: $color-table_th-clickSort-bg-hover;
|
|
148
|
+
background-image: linear-gradient(0deg, $color-table_th-clickSort-bg-hover, $color-table_th-clickSort-bg-hover);
|
|
149
|
+
background-color: $color-table_cell-bg-hover;
|
|
149
150
|
|
|
150
151
|
&.#{$module}-cell-fixed {
|
|
151
152
|
&-left,
|
package/transfer/transfer.scss
CHANGED
|
@@ -53,6 +53,7 @@ $module: #{$prefix}-transfer;
|
|
|
53
53
|
margin-bottom: $spacing-transfer_header-marginBottom;
|
|
54
54
|
margin-left: $spacing-transfer_header-marginLeft;
|
|
55
55
|
color: $color-transfer_header-text;
|
|
56
|
+
flex-shrink: 0;
|
|
56
57
|
|
|
57
58
|
&-all {
|
|
58
59
|
font-weight: $font-transfer_header_all-fontWeight;
|
|
@@ -165,7 +165,6 @@ $module: #{$prefix}-tree-select;
|
|
|
165
165
|
|
|
166
166
|
&-placeholder {
|
|
167
167
|
opacity: .6;
|
|
168
|
-
z-index: -1;
|
|
169
168
|
}
|
|
170
169
|
|
|
171
170
|
&-disabled {
|
|
@@ -174,6 +173,10 @@ $module: #{$prefix}-tree-select;
|
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
175
|
|
|
176
|
+
.#{$module}-triggerSingleSearch-upper {
|
|
177
|
+
z-index: 1;
|
|
178
|
+
}
|
|
179
|
+
|
|
177
180
|
.#{$module}-triggerSingleSearch-wrapper{
|
|
178
181
|
width: 100%;
|
|
179
182
|
|
package/tsconfig.json
CHANGED
package/jsonViewer/constants.ts
DELETED
package/jsonViewer/foundation.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export * from '@douyinfe/semi-json-viewer-core';
|
|
3
|
-
import { JsonViewer, JsonViewerOptions } from '@douyinfe/semi-json-viewer-core';
|
|
4
|
-
import BaseFoundation, { DefaultAdapter, noopFunction } from '../base/foundation';
|
|
5
|
-
|
|
6
|
-
export interface JsonViewerAdapter<P = Record<string, any>, S = Record<string, any>> extends DefaultAdapter<P, S> {
|
|
7
|
-
getJsonViewerRef: () => HTMLElement;
|
|
8
|
-
onValueChange: (value: string) => void;
|
|
9
|
-
onValueHover: (value: string, el: HTMLElement) => HTMLElement | undefined
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class JsonViewerFoundation extends BaseFoundation<JsonViewerAdapter> {
|
|
14
|
-
constructor(adapter: JsonViewerAdapter) {
|
|
15
|
-
super({ ...JsonViewerFoundation, ...adapter });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
jsonViewer: JsonViewer | null = null;
|
|
19
|
-
|
|
20
|
-
init() {
|
|
21
|
-
const props = this.getProps();
|
|
22
|
-
const jsonViewerRef = this._adapter.getJsonViewerRef();
|
|
23
|
-
this.jsonViewer = new JsonViewer(jsonViewerRef, props.value, props.options);
|
|
24
|
-
this.jsonViewer.layout();
|
|
25
|
-
this.jsonViewer.emitter.on('contentChanged', (e) => {
|
|
26
|
-
this.onValueChange(this.jsonViewer?.getModel().getValue());
|
|
27
|
-
});
|
|
28
|
-
this.jsonViewer.emitter.on('hoverNode', (e) => {
|
|
29
|
-
const el = this.onValueHover(e.value, e.target);
|
|
30
|
-
if (el) {
|
|
31
|
-
this.jsonViewer.emitter.emit('renderHoverNode', { el });
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
onValueChange(value: string) {
|
|
37
|
-
this._adapter.onValueChange(value);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
onValueHover(value: string, el: HTMLElement): HTMLElement | undefined {
|
|
41
|
-
return this._adapter.onValueHover(value, el);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
search(searchText: string) {
|
|
45
|
-
const state = this.getState('searchOptions');
|
|
46
|
-
const { caseSensitive, wholeWord, regex } = state;
|
|
47
|
-
this.jsonViewer?.getSearchWidget().search(searchText, caseSensitive, wholeWord, regex);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
prevSearch() {
|
|
51
|
-
this.jsonViewer?.getSearchWidget().navigateResults(-1);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
nextSearch() {
|
|
55
|
-
this.jsonViewer?.getSearchWidget().navigateResults(1);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
replace(replaceText: string) {
|
|
59
|
-
this.jsonViewer?.getSearchWidget().replace(replaceText);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
replaceAll(replaceText: string) {
|
|
63
|
-
this.jsonViewer?.getSearchWidget().replaceAll(replaceText);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export default JsonViewerFoundation;
|