@douyinfe/semi-foundation 2.38.0 → 2.38.2-alpha.1
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/anchor/foundation.ts +7 -4
- package/autoComplete/foundation.ts +6 -4
- package/lib/cjs/anchor/foundation.js +8 -3
- package/lib/cjs/autoComplete/foundation.d.ts +2 -0
- package/lib/cjs/autoComplete/foundation.js +4 -3
- package/lib/es/anchor/foundation.js +8 -3
- package/lib/es/autoComplete/foundation.d.ts +2 -0
- package/lib/es/autoComplete/foundation.js +4 -3
- package/package.json +3 -3
package/anchor/foundation.ts
CHANGED
|
@@ -171,7 +171,7 @@ export default class AnchorFoundation<P = Record<string, any>, S = Record<string
|
|
|
171
171
|
* 2. There is a scroll axis (clientHeight < scrollHeight | | clientWidth < scrollWidth)
|
|
172
172
|
* 3.overflowX or overflowY has a value and is not visible or clip
|
|
173
173
|
* For details, please see https://github.com/stipsan/compute-scroll-into-view
|
|
174
|
-
*
|
|
174
|
+
*
|
|
175
175
|
* behavior定义滚动行为
|
|
176
176
|
* - 可选 'auto' | 'smooth' | Function
|
|
177
177
|
* - Function 自定义滚动行为
|
|
@@ -184,9 +184,12 @@ export default class AnchorFoundation<P = Record<string, any>, S = Record<string
|
|
|
184
184
|
*/
|
|
185
185
|
behavior: actions => {
|
|
186
186
|
// We just need to scroll the innermost target container
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
const verticalScrollAction = actions.find(action => {
|
|
188
|
+
const { el } = action;
|
|
189
|
+
return el.scrollHeight > el.clientHeight;
|
|
190
|
+
});
|
|
191
|
+
const el = get(verticalScrollAction, 'el');
|
|
192
|
+
const top = get(verticalScrollAction, 'top');
|
|
190
193
|
if (el) {
|
|
191
194
|
const offsetTop = top - targetOffset;
|
|
192
195
|
if (el.scroll && canSmoothScroll) {
|
|
@@ -39,7 +39,9 @@ export interface AutoCompleteAdapter<P = Record<string, any>, S = Record<string,
|
|
|
39
39
|
notifyFocus: (event?: any) => void;
|
|
40
40
|
notifyBlur: (event?: any) => void;
|
|
41
41
|
rePositionDropdown: () => void;
|
|
42
|
-
persistEvent: (event: any) => void
|
|
42
|
+
persistEvent: (event: any) => void;
|
|
43
|
+
registerClickOutsideHandler: (cb: (e: any) => void) => void;
|
|
44
|
+
unregisterClickOutsideHandler: () => void
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<AutoCompleteAdapter<P, S>, P, S> {
|
|
@@ -79,7 +81,7 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
destroy(): void {
|
|
82
|
-
|
|
84
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
83
85
|
// this.unBindKeyBoardEvent();
|
|
84
86
|
}
|
|
85
87
|
|
|
@@ -114,7 +116,7 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
114
116
|
this.isPanelOpen = true;
|
|
115
117
|
this._adapter.toggleListVisible(true);
|
|
116
118
|
this._setDropdownWidth();
|
|
117
|
-
|
|
119
|
+
this._adapter.registerClickOutsideHandler(e => this.closeDropdown(e));
|
|
118
120
|
this._adapter.notifyDropdownVisibleChange(true);
|
|
119
121
|
this._modifyFocusIndexOnPanelOpen();
|
|
120
122
|
}
|
|
@@ -122,7 +124,7 @@ class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> e
|
|
|
122
124
|
closeDropdown(e?: any): void {
|
|
123
125
|
this.isPanelOpen = false;
|
|
124
126
|
this._adapter.toggleListVisible(false);
|
|
125
|
-
|
|
127
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
126
128
|
this._adapter.notifyDropdownVisibleChange(false);
|
|
127
129
|
// After closing the panel, you can still open the panel by pressing the enter key
|
|
128
130
|
// this.unBindKeyBoardEvent();
|
|
@@ -165,9 +165,14 @@ class AnchorFoundation extends _foundation.default {
|
|
|
165
165
|
*/
|
|
166
166
|
behavior: actions => {
|
|
167
167
|
// We just need to scroll the innermost target container
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
const verticalScrollAction = actions.find(action => {
|
|
169
|
+
const {
|
|
170
|
+
el
|
|
171
|
+
} = action;
|
|
172
|
+
return el.scrollHeight > el.clientHeight;
|
|
173
|
+
});
|
|
174
|
+
const el = (0, _get2.default)(verticalScrollAction, 'el');
|
|
175
|
+
const top = (0, _get2.default)(verticalScrollAction, 'top');
|
|
171
176
|
if (el) {
|
|
172
177
|
const offsetTop = top - targetOffset;
|
|
173
178
|
if (el.scroll && canSmoothScroll) {
|
|
@@ -31,6 +31,8 @@ export interface AutoCompleteAdapter<P = Record<string, any>, S = Record<string,
|
|
|
31
31
|
notifyBlur: (event?: any) => void;
|
|
32
32
|
rePositionDropdown: () => void;
|
|
33
33
|
persistEvent: (event: any) => void;
|
|
34
|
+
registerClickOutsideHandler: (cb: (e: any) => void) => void;
|
|
35
|
+
unregisterClickOutsideHandler: () => void;
|
|
34
36
|
}
|
|
35
37
|
declare class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<AutoCompleteAdapter<P, S>, P, S> {
|
|
36
38
|
private _keydownHandler;
|
|
@@ -47,9 +47,10 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
destroy() {
|
|
50
|
-
|
|
50
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
51
51
|
// this.unBindKeyBoardEvent();
|
|
52
52
|
}
|
|
53
|
+
|
|
53
54
|
_setDropdownWidth() {
|
|
54
55
|
const {
|
|
55
56
|
style,
|
|
@@ -86,14 +87,14 @@ class AutoCompleteFoundation extends _foundation.default {
|
|
|
86
87
|
this.isPanelOpen = true;
|
|
87
88
|
this._adapter.toggleListVisible(true);
|
|
88
89
|
this._setDropdownWidth();
|
|
89
|
-
|
|
90
|
+
this._adapter.registerClickOutsideHandler(e => this.closeDropdown(e));
|
|
90
91
|
this._adapter.notifyDropdownVisibleChange(true);
|
|
91
92
|
this._modifyFocusIndexOnPanelOpen();
|
|
92
93
|
}
|
|
93
94
|
closeDropdown(e) {
|
|
94
95
|
this.isPanelOpen = false;
|
|
95
96
|
this._adapter.toggleListVisible(false);
|
|
96
|
-
|
|
97
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
97
98
|
this._adapter.notifyDropdownVisibleChange(false);
|
|
98
99
|
// After closing the panel, you can still open the panel by pressing the enter key
|
|
99
100
|
// this.unBindKeyBoardEvent();
|
|
@@ -158,9 +158,14 @@ export default class AnchorFoundation extends BaseFoundation {
|
|
|
158
158
|
*/
|
|
159
159
|
behavior: actions => {
|
|
160
160
|
// We just need to scroll the innermost target container
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
const verticalScrollAction = actions.find(action => {
|
|
162
|
+
const {
|
|
163
|
+
el
|
|
164
|
+
} = action;
|
|
165
|
+
return el.scrollHeight > el.clientHeight;
|
|
166
|
+
});
|
|
167
|
+
const el = _get(verticalScrollAction, 'el');
|
|
168
|
+
const top = _get(verticalScrollAction, 'top');
|
|
164
169
|
if (el) {
|
|
165
170
|
const offsetTop = top - targetOffset;
|
|
166
171
|
if (el.scroll && canSmoothScroll) {
|
|
@@ -31,6 +31,8 @@ export interface AutoCompleteAdapter<P = Record<string, any>, S = Record<string,
|
|
|
31
31
|
notifyBlur: (event?: any) => void;
|
|
32
32
|
rePositionDropdown: () => void;
|
|
33
33
|
persistEvent: (event: any) => void;
|
|
34
|
+
registerClickOutsideHandler: (cb: (e: any) => void) => void;
|
|
35
|
+
unregisterClickOutsideHandler: () => void;
|
|
34
36
|
}
|
|
35
37
|
declare class AutoCompleteFoundation<P = Record<string, any>, S = Record<string, any>> extends BaseFoundation<AutoCompleteAdapter<P, S>, P, S> {
|
|
36
38
|
private _keydownHandler;
|
|
@@ -39,9 +39,10 @@ class AutoCompleteFoundation extends BaseFoundation {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
destroy() {
|
|
42
|
-
|
|
42
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
43
43
|
// this.unBindKeyBoardEvent();
|
|
44
44
|
}
|
|
45
|
+
|
|
45
46
|
_setDropdownWidth() {
|
|
46
47
|
const {
|
|
47
48
|
style,
|
|
@@ -78,14 +79,14 @@ class AutoCompleteFoundation extends BaseFoundation {
|
|
|
78
79
|
this.isPanelOpen = true;
|
|
79
80
|
this._adapter.toggleListVisible(true);
|
|
80
81
|
this._setDropdownWidth();
|
|
81
|
-
|
|
82
|
+
this._adapter.registerClickOutsideHandler(e => this.closeDropdown(e));
|
|
82
83
|
this._adapter.notifyDropdownVisibleChange(true);
|
|
83
84
|
this._modifyFocusIndexOnPanelOpen();
|
|
84
85
|
}
|
|
85
86
|
closeDropdown(e) {
|
|
86
87
|
this.isPanelOpen = false;
|
|
87
88
|
this._adapter.toggleListVisible(false);
|
|
88
|
-
|
|
89
|
+
this._adapter.unregisterClickOutsideHandler();
|
|
89
90
|
this._adapter.notifyDropdownVisibleChange(false);
|
|
90
91
|
// After closing the panel, you can still open the panel by pressing the enter key
|
|
91
92
|
// this.unBindKeyBoardEvent();
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.38.
|
|
3
|
+
"version": "2.38.2-alpha.1",
|
|
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.38.
|
|
10
|
+
"@douyinfe/semi-animation": "2.38.2-alpha.1",
|
|
11
11
|
"async-validator": "^3.5.0",
|
|
12
12
|
"classnames": "^2.2.6",
|
|
13
13
|
"date-fns": "^2.29.3",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"*.scss",
|
|
24
24
|
"*.css"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "cb42a0565bba8660255835264d23dfcba6ff4aa3",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
29
29
|
"@babel/preset-env": "^7.15.8",
|