@douyinfe/semi-foundation 2.101.0 → 2.102.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/button/button.scss +1 -0
- package/dragMove/foundation.ts +36 -3
- package/lib/cjs/button/button.css +1 -0
- package/lib/cjs/button/button.scss +1 -0
- package/lib/cjs/dragMove/foundation.d.ts +5 -0
- package/lib/cjs/dragMove/foundation.js +27 -3
- package/lib/cjs/tree/foundation.js +4 -1
- package/lib/es/button/button.css +1 -0
- package/lib/es/button/button.scss +1 -0
- package/lib/es/dragMove/foundation.d.ts +5 -0
- package/lib/es/dragMove/foundation.js +27 -3
- package/lib/es/tree/foundation.js +4 -1
- package/package.json +4 -4
- package/tree/foundation.ts +4 -1
package/button/button.scss
CHANGED
|
@@ -19,6 +19,7 @@ $module: #{$prefix}-button;
|
|
|
19
19
|
padding-right: $spacing-button_default-paddingRight;
|
|
20
20
|
padding-top: $spacing-button_default-paddingTop;
|
|
21
21
|
padding-bottom: $spacing-button_default-paddingTop;
|
|
22
|
+
font-family: inherit;
|
|
22
23
|
font-size: $font-button-fontSize;
|
|
23
24
|
line-height: $font-button-lineHeight;
|
|
24
25
|
font-weight: $font-button-fontWeight;
|
package/dragMove/foundation.ts
CHANGED
|
@@ -25,6 +25,10 @@ export default class DragMoveFoundation<P = Record<string, any>, S = Record<stri
|
|
|
25
25
|
yMin: number;
|
|
26
26
|
startOffsetX: number;
|
|
27
27
|
startOffsetY: number;
|
|
28
|
+
startClientX: number;
|
|
29
|
+
startClientY: number;
|
|
30
|
+
startLeft: number;
|
|
31
|
+
startTop: number;
|
|
28
32
|
|
|
29
33
|
get constrainer() {
|
|
30
34
|
return this._adapter.getConstrainer();
|
|
@@ -44,11 +48,15 @@ export default class DragMoveFoundation<P = Record<string, any>, S = Record<stri
|
|
|
44
48
|
throw new Error('drag element must be a valid element');
|
|
45
49
|
}
|
|
46
50
|
this.element = element;
|
|
47
|
-
this.
|
|
51
|
+
this.updatePositionStrategy();
|
|
48
52
|
this.handler.style.cursor = 'move';
|
|
49
53
|
this._registerStartEvent();
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
updatePositionStrategy = () => {
|
|
57
|
+
this.element.style.position = this.getProp('positionStrategy') === 'relative' ? 'relative' : 'absolute';
|
|
58
|
+
}
|
|
59
|
+
|
|
52
60
|
_registerStartEvent = () => {
|
|
53
61
|
this.handler.addEventListener('mousedown', this.onMouseDown);
|
|
54
62
|
this.handler.addEventListener('touchstart', this.onTouchStart);
|
|
@@ -95,6 +103,18 @@ export default class DragMoveFoundation<P = Record<string, any>, S = Record<stri
|
|
|
95
103
|
_calcMoveRange() {
|
|
96
104
|
// Calculate the range within which an element can move
|
|
97
105
|
if (this.constrainer) {
|
|
106
|
+
if (this.getProp('positionStrategy') === 'relative') {
|
|
107
|
+
const elementRect = this.element.getBoundingClientRect();
|
|
108
|
+
const constrainerRect = this.constrainer.getBoundingClientRect();
|
|
109
|
+
const style = window.getComputedStyle(this.element);
|
|
110
|
+
const currentLeft = parseFloat(style.left) || 0;
|
|
111
|
+
const currentTop = parseFloat(style.top) || 0;
|
|
112
|
+
this.xMin = currentLeft + constrainerRect.left - elementRect.left;
|
|
113
|
+
this.xMax = currentLeft + constrainerRect.right - elementRect.right;
|
|
114
|
+
this.yMin = currentTop + constrainerRect.top - elementRect.top;
|
|
115
|
+
this.yMax = currentTop + constrainerRect.bottom - elementRect.bottom;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
98
118
|
let node = this.element.offsetParent as HTMLElement;
|
|
99
119
|
let startX = 0;
|
|
100
120
|
let startY = 0;
|
|
@@ -126,6 +146,14 @@ export default class DragMoveFoundation<P = Record<string, any>, S = Record<stri
|
|
|
126
146
|
}
|
|
127
147
|
|
|
128
148
|
_calcOffset = (e: Touch | MouseEvent) => {
|
|
149
|
+
if (this.getProp('positionStrategy') === 'relative') {
|
|
150
|
+
const style = window.getComputedStyle(this.element);
|
|
151
|
+
this.startClientX = e.clientX;
|
|
152
|
+
this.startClientY = e.clientY;
|
|
153
|
+
this.startLeft = parseFloat(style.left) || 0;
|
|
154
|
+
this.startTop = parseFloat(style.top) || 0;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
129
157
|
this.startOffsetX = e.clientX - this.element.offsetLeft;
|
|
130
158
|
this.startOffsetY = e.clientY - this.element.offsetTop;
|
|
131
159
|
}
|
|
@@ -161,8 +189,13 @@ export default class DragMoveFoundation<P = Record<string, any>, S = Record<stri
|
|
|
161
189
|
|
|
162
190
|
_changePos = (e: Touch | MouseEvent) => {
|
|
163
191
|
const { customMove } = this.getProps();
|
|
164
|
-
|
|
165
|
-
let
|
|
192
|
+
const useRelativePosition = this.getProp('positionStrategy') === 'relative';
|
|
193
|
+
let newLeft = useRelativePosition ?
|
|
194
|
+
this.startLeft + e.clientX - this.startClientX :
|
|
195
|
+
e.clientX - this.startOffsetX;
|
|
196
|
+
let newTop = useRelativePosition ?
|
|
197
|
+
this.startTop + e.clientY - this.startClientY :
|
|
198
|
+
e.clientY - this.startOffsetY;
|
|
166
199
|
if (this.constrainer) {
|
|
167
200
|
newLeft = clampValueInRange(newLeft, this.xMin, this.xMax);
|
|
168
201
|
newTop = clampValueInRange(newTop, this.yMin, this.yMax);
|
|
@@ -19,6 +19,7 @@ $module: #{$prefix}-button;
|
|
|
19
19
|
padding-right: $spacing-button_default-paddingRight;
|
|
20
20
|
padding-top: $spacing-button_default-paddingTop;
|
|
21
21
|
padding-bottom: $spacing-button_default-paddingTop;
|
|
22
|
+
font-family: inherit;
|
|
22
23
|
font-size: $font-button-fontSize;
|
|
23
24
|
line-height: $font-button-lineHeight;
|
|
24
25
|
font-weight: $font-button-fontWeight;
|
|
@@ -20,10 +20,15 @@ export default class DragMoveFoundation<P = Record<string, any>, S = Record<stri
|
|
|
20
20
|
yMin: number;
|
|
21
21
|
startOffsetX: number;
|
|
22
22
|
startOffsetY: number;
|
|
23
|
+
startClientX: number;
|
|
24
|
+
startClientY: number;
|
|
25
|
+
startLeft: number;
|
|
26
|
+
startTop: number;
|
|
23
27
|
get constrainer(): HTMLElement;
|
|
24
28
|
get handler(): HTMLElement;
|
|
25
29
|
constructor(adapter: DragMoveAdapter<P, S>);
|
|
26
30
|
init(): void;
|
|
31
|
+
updatePositionStrategy: () => void;
|
|
27
32
|
_registerStartEvent: () => void;
|
|
28
33
|
_unRegisterStartEvent: () => void;
|
|
29
34
|
destroy(): void;
|
|
@@ -19,6 +19,9 @@ class DragMoveFoundation extends _foundation.default {
|
|
|
19
19
|
}
|
|
20
20
|
constructor(adapter) {
|
|
21
21
|
super(Object.assign({}, adapter));
|
|
22
|
+
this.updatePositionStrategy = () => {
|
|
23
|
+
this.element.style.position = this.getProp('positionStrategy') === 'relative' ? 'relative' : 'absolute';
|
|
24
|
+
};
|
|
22
25
|
this._registerStartEvent = () => {
|
|
23
26
|
this.handler.addEventListener('mousedown', this.onMouseDown);
|
|
24
27
|
this.handler.addEventListener('touchstart', this.onTouchStart);
|
|
@@ -46,6 +49,14 @@ class DragMoveFoundation extends _foundation.default {
|
|
|
46
49
|
document.removeEventListener('touchcancel', this._onTouchCancel);
|
|
47
50
|
};
|
|
48
51
|
this._calcOffset = e => {
|
|
52
|
+
if (this.getProp('positionStrategy') === 'relative') {
|
|
53
|
+
const style = window.getComputedStyle(this.element);
|
|
54
|
+
this.startClientX = e.clientX;
|
|
55
|
+
this.startClientY = e.clientY;
|
|
56
|
+
this.startLeft = parseFloat(style.left) || 0;
|
|
57
|
+
this.startTop = parseFloat(style.top) || 0;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
49
60
|
this.startOffsetX = e.clientX - this.element.offsetLeft;
|
|
50
61
|
this.startOffsetY = e.clientY - this.element.offsetTop;
|
|
51
62
|
};
|
|
@@ -79,8 +90,9 @@ class DragMoveFoundation extends _foundation.default {
|
|
|
79
90
|
const {
|
|
80
91
|
customMove
|
|
81
92
|
} = this.getProps();
|
|
82
|
-
|
|
83
|
-
let
|
|
93
|
+
const useRelativePosition = this.getProp('positionStrategy') === 'relative';
|
|
94
|
+
let newLeft = useRelativePosition ? this.startLeft + e.clientX - this.startClientX : e.clientX - this.startOffsetX;
|
|
95
|
+
let newTop = useRelativePosition ? this.startTop + e.clientY - this.startClientY : e.clientY - this.startOffsetY;
|
|
84
96
|
if (this.constrainer) {
|
|
85
97
|
newLeft = clampValueInRange(newLeft, this.xMin, this.xMax);
|
|
86
98
|
newTop = clampValueInRange(newTop, this.yMin, this.yMax);
|
|
@@ -122,7 +134,7 @@ class DragMoveFoundation extends _foundation.default {
|
|
|
122
134
|
throw new Error('drag element must be a valid element');
|
|
123
135
|
}
|
|
124
136
|
this.element = element;
|
|
125
|
-
this.
|
|
137
|
+
this.updatePositionStrategy();
|
|
126
138
|
this.handler.style.cursor = 'move';
|
|
127
139
|
this._registerStartEvent();
|
|
128
140
|
}
|
|
@@ -137,6 +149,18 @@ class DragMoveFoundation extends _foundation.default {
|
|
|
137
149
|
_calcMoveRange() {
|
|
138
150
|
// Calculate the range within which an element can move
|
|
139
151
|
if (this.constrainer) {
|
|
152
|
+
if (this.getProp('positionStrategy') === 'relative') {
|
|
153
|
+
const elementRect = this.element.getBoundingClientRect();
|
|
154
|
+
const constrainerRect = this.constrainer.getBoundingClientRect();
|
|
155
|
+
const style = window.getComputedStyle(this.element);
|
|
156
|
+
const currentLeft = parseFloat(style.left) || 0;
|
|
157
|
+
const currentTop = parseFloat(style.top) || 0;
|
|
158
|
+
this.xMin = currentLeft + constrainerRect.left - elementRect.left;
|
|
159
|
+
this.xMax = currentLeft + constrainerRect.right - elementRect.right;
|
|
160
|
+
this.yMin = currentTop + constrainerRect.top - elementRect.top;
|
|
161
|
+
this.yMax = currentTop + constrainerRect.bottom - elementRect.bottom;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
140
164
|
let node = this.element.offsetParent;
|
|
141
165
|
let startX = 0;
|
|
142
166
|
let startY = 0;
|
|
@@ -440,7 +440,10 @@ class TreeFoundation extends _foundation.default {
|
|
|
440
440
|
this._adapter.cacheFlattenNodes(motionType === 'hide' && this._isAnimated());
|
|
441
441
|
if (!this._isExpandControlled()) {
|
|
442
442
|
const flattenNodes = (0, _treeUtil.flattenTreeData)(treeData, expandedKeys, keyMaps, isSearching && showFilteredOnly && filteredShownKeys);
|
|
443
|
-
|
|
443
|
+
let motionKeys = this._isAnimated() ? (0, _treeUtil.getMotionKeys)(eventKey, expandedKeys, keyEntities) : [];
|
|
444
|
+
if (isSearching && showFilteredOnly) {
|
|
445
|
+
motionKeys = motionKeys.filter(key => filteredShownKeys.has(key));
|
|
446
|
+
}
|
|
444
447
|
const newState = {
|
|
445
448
|
[expandedStateKey]: expandedKeys,
|
|
446
449
|
flattenNodes,
|
package/lib/es/button/button.css
CHANGED
|
@@ -19,6 +19,7 @@ $module: #{$prefix}-button;
|
|
|
19
19
|
padding-right: $spacing-button_default-paddingRight;
|
|
20
20
|
padding-top: $spacing-button_default-paddingTop;
|
|
21
21
|
padding-bottom: $spacing-button_default-paddingTop;
|
|
22
|
+
font-family: inherit;
|
|
22
23
|
font-size: $font-button-fontSize;
|
|
23
24
|
line-height: $font-button-lineHeight;
|
|
24
25
|
font-weight: $font-button-fontWeight;
|
|
@@ -20,10 +20,15 @@ export default class DragMoveFoundation<P = Record<string, any>, S = Record<stri
|
|
|
20
20
|
yMin: number;
|
|
21
21
|
startOffsetX: number;
|
|
22
22
|
startOffsetY: number;
|
|
23
|
+
startClientX: number;
|
|
24
|
+
startClientY: number;
|
|
25
|
+
startLeft: number;
|
|
26
|
+
startTop: number;
|
|
23
27
|
get constrainer(): HTMLElement;
|
|
24
28
|
get handler(): HTMLElement;
|
|
25
29
|
constructor(adapter: DragMoveAdapter<P, S>);
|
|
26
30
|
init(): void;
|
|
31
|
+
updatePositionStrategy: () => void;
|
|
27
32
|
_registerStartEvent: () => void;
|
|
28
33
|
_unRegisterStartEvent: () => void;
|
|
29
34
|
destroy(): void;
|
|
@@ -11,6 +11,9 @@ export default class DragMoveFoundation extends BaseFoundation {
|
|
|
11
11
|
}
|
|
12
12
|
constructor(adapter) {
|
|
13
13
|
super(Object.assign({}, adapter));
|
|
14
|
+
this.updatePositionStrategy = () => {
|
|
15
|
+
this.element.style.position = this.getProp('positionStrategy') === 'relative' ? 'relative' : 'absolute';
|
|
16
|
+
};
|
|
14
17
|
this._registerStartEvent = () => {
|
|
15
18
|
this.handler.addEventListener('mousedown', this.onMouseDown);
|
|
16
19
|
this.handler.addEventListener('touchstart', this.onTouchStart);
|
|
@@ -38,6 +41,14 @@ export default class DragMoveFoundation extends BaseFoundation {
|
|
|
38
41
|
document.removeEventListener('touchcancel', this._onTouchCancel);
|
|
39
42
|
};
|
|
40
43
|
this._calcOffset = e => {
|
|
44
|
+
if (this.getProp('positionStrategy') === 'relative') {
|
|
45
|
+
const style = window.getComputedStyle(this.element);
|
|
46
|
+
this.startClientX = e.clientX;
|
|
47
|
+
this.startClientY = e.clientY;
|
|
48
|
+
this.startLeft = parseFloat(style.left) || 0;
|
|
49
|
+
this.startTop = parseFloat(style.top) || 0;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
41
52
|
this.startOffsetX = e.clientX - this.element.offsetLeft;
|
|
42
53
|
this.startOffsetY = e.clientY - this.element.offsetTop;
|
|
43
54
|
};
|
|
@@ -71,8 +82,9 @@ export default class DragMoveFoundation extends BaseFoundation {
|
|
|
71
82
|
const {
|
|
72
83
|
customMove
|
|
73
84
|
} = this.getProps();
|
|
74
|
-
|
|
75
|
-
let
|
|
85
|
+
const useRelativePosition = this.getProp('positionStrategy') === 'relative';
|
|
86
|
+
let newLeft = useRelativePosition ? this.startLeft + e.clientX - this.startClientX : e.clientX - this.startOffsetX;
|
|
87
|
+
let newTop = useRelativePosition ? this.startTop + e.clientY - this.startClientY : e.clientY - this.startOffsetY;
|
|
76
88
|
if (this.constrainer) {
|
|
77
89
|
newLeft = clampValueInRange(newLeft, this.xMin, this.xMax);
|
|
78
90
|
newTop = clampValueInRange(newTop, this.yMin, this.yMax);
|
|
@@ -114,7 +126,7 @@ export default class DragMoveFoundation extends BaseFoundation {
|
|
|
114
126
|
throw new Error('drag element must be a valid element');
|
|
115
127
|
}
|
|
116
128
|
this.element = element;
|
|
117
|
-
this.
|
|
129
|
+
this.updatePositionStrategy();
|
|
118
130
|
this.handler.style.cursor = 'move';
|
|
119
131
|
this._registerStartEvent();
|
|
120
132
|
}
|
|
@@ -129,6 +141,18 @@ export default class DragMoveFoundation extends BaseFoundation {
|
|
|
129
141
|
_calcMoveRange() {
|
|
130
142
|
// Calculate the range within which an element can move
|
|
131
143
|
if (this.constrainer) {
|
|
144
|
+
if (this.getProp('positionStrategy') === 'relative') {
|
|
145
|
+
const elementRect = this.element.getBoundingClientRect();
|
|
146
|
+
const constrainerRect = this.constrainer.getBoundingClientRect();
|
|
147
|
+
const style = window.getComputedStyle(this.element);
|
|
148
|
+
const currentLeft = parseFloat(style.left) || 0;
|
|
149
|
+
const currentTop = parseFloat(style.top) || 0;
|
|
150
|
+
this.xMin = currentLeft + constrainerRect.left - elementRect.left;
|
|
151
|
+
this.xMax = currentLeft + constrainerRect.right - elementRect.right;
|
|
152
|
+
this.yMin = currentTop + constrainerRect.top - elementRect.top;
|
|
153
|
+
this.yMax = currentTop + constrainerRect.bottom - elementRect.bottom;
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
132
156
|
let node = this.element.offsetParent;
|
|
133
157
|
let startX = 0;
|
|
134
158
|
let startY = 0;
|
|
@@ -432,7 +432,10 @@ export default class TreeFoundation extends BaseFoundation {
|
|
|
432
432
|
this._adapter.cacheFlattenNodes(motionType === 'hide' && this._isAnimated());
|
|
433
433
|
if (!this._isExpandControlled()) {
|
|
434
434
|
const flattenNodes = flattenTreeData(treeData, expandedKeys, keyMaps, isSearching && showFilteredOnly && filteredShownKeys);
|
|
435
|
-
|
|
435
|
+
let motionKeys = this._isAnimated() ? getMotionKeys(eventKey, expandedKeys, keyEntities) : [];
|
|
436
|
+
if (isSearching && showFilteredOnly) {
|
|
437
|
+
motionKeys = motionKeys.filter(key => filteredShownKeys.has(key));
|
|
438
|
+
}
|
|
436
439
|
const newState = {
|
|
437
440
|
[expandedStateKey]: expandedKeys,
|
|
438
441
|
flattenNodes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.102.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "rimraf lib",
|
|
@@ -14225,8 +14225,8 @@
|
|
|
14225
14225
|
}
|
|
14226
14226
|
},
|
|
14227
14227
|
"dependencies": {
|
|
14228
|
-
"@douyinfe/semi-animation": "2.
|
|
14229
|
-
"@douyinfe/semi-json-viewer-core": "2.
|
|
14228
|
+
"@douyinfe/semi-animation": "2.102.0",
|
|
14229
|
+
"@douyinfe/semi-json-viewer-core": "2.102.0",
|
|
14230
14230
|
"@mdx-js/mdx": "^3.0.1",
|
|
14231
14231
|
"async-validator": "^3.5.0",
|
|
14232
14232
|
"classnames": "^2.2.6",
|
|
@@ -14247,7 +14247,7 @@
|
|
|
14247
14247
|
"*.scss",
|
|
14248
14248
|
"*.css"
|
|
14249
14249
|
],
|
|
14250
|
-
"gitHead": "
|
|
14250
|
+
"gitHead": "88d7738ddb55821f38d3ab3c5b7c877ebda08edf",
|
|
14251
14251
|
"devDependencies": {
|
|
14252
14252
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
14253
14253
|
"@babel/preset-env": "^7.15.8",
|
package/tree/foundation.ts
CHANGED
|
@@ -711,7 +711,10 @@ export default class TreeFoundation extends BaseFoundation<TreeAdapter, BasicTre
|
|
|
711
711
|
keyMaps,
|
|
712
712
|
isSearching && showFilteredOnly && filteredShownKeys
|
|
713
713
|
);
|
|
714
|
-
|
|
714
|
+
let motionKeys = this._isAnimated() ? getMotionKeys(eventKey, expandedKeys, keyEntities) : [];
|
|
715
|
+
if (isSearching && showFilteredOnly) {
|
|
716
|
+
motionKeys = motionKeys.filter(key => filteredShownKeys.has(key));
|
|
717
|
+
}
|
|
715
718
|
const newState = {
|
|
716
719
|
[expandedStateKey]: expandedKeys,
|
|
717
720
|
flattenNodes,
|