@douyinfe/semi-foundation 2.32.4 → 2.32.5-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/tooltip/foundation.d.ts +2 -1
- package/lib/cjs/tooltip/foundation.js +14 -0
- package/lib/cjs/utils/Event.js +2 -1
- package/lib/es/tooltip/foundation.d.ts +2 -1
- package/lib/es/tooltip/foundation.js +14 -0
- package/lib/es/utils/Event.js +2 -1
- package/package.json +2 -2
- package/tooltip/foundation.ts +14 -2
- package/utils/Event.ts +3 -1
|
@@ -10,7 +10,7 @@ export interface TooltipAdapter<P = Record<string, any>, S = Record<string, any>
|
|
|
10
10
|
notifyVisibleChange(isVisible: any): void;
|
|
11
11
|
getPopupContainerRect(): PopupContainerDOMRect;
|
|
12
12
|
containerIsBody(): boolean;
|
|
13
|
-
off(arg0: string): void;
|
|
13
|
+
off(arg0: string, arg1?: () => void): void;
|
|
14
14
|
canMotion(): boolean;
|
|
15
15
|
registerScrollHandler(arg: () => Record<string, any>): void;
|
|
16
16
|
unregisterScrollHandler(): void;
|
|
@@ -47,6 +47,7 @@ export interface TooltipAdapter<P = Record<string, any>, S = Record<string, any>
|
|
|
47
47
|
notifyEscKeydown(event: any): void;
|
|
48
48
|
getTriggerNode(): any;
|
|
49
49
|
setId(): void;
|
|
50
|
+
getTriggerDOM(): HTMLElement | null;
|
|
50
51
|
}
|
|
51
52
|
export declare type Position = ArrayElement<typeof strings.POSITION_SET>;
|
|
52
53
|
export interface PopupContainerDOMRect extends DOMRectLikeType {
|
|
@@ -93,6 +93,20 @@ class Tooltip extends _foundation.default {
|
|
|
93
93
|
this.calcPosition();
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
+
if (trigger === "hover") {
|
|
97
|
+
const checkTriggerIsHover = () => {
|
|
98
|
+
const triggerDOM = this._adapter.getTriggerDOM();
|
|
99
|
+
|
|
100
|
+
if (trigger && !triggerDOM.matches(":hover")) {
|
|
101
|
+
this.hide();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
this._adapter.off("portalInserted", checkTriggerIsHover);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
this._adapter.on('portalInserted', checkTriggerIsHover);
|
|
108
|
+
}
|
|
109
|
+
|
|
96
110
|
this._adapter.on('positionUpdated', () => {
|
|
97
111
|
this._togglePortalVisible(true);
|
|
98
112
|
});
|
package/lib/cjs/utils/Event.js
CHANGED
|
@@ -67,8 +67,9 @@ class Event {
|
|
|
67
67
|
return false;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
this._eventMap.get(event)
|
|
70
|
+
const callbacks = [...this._eventMap.get(event)]; // clone to avoid someone writing the logic of deleting callback in callbacks into his or her callback code, for example the once func above
|
|
71
71
|
|
|
72
|
+
callbacks.forEach(callback => callback(...args));
|
|
72
73
|
return true;
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -10,7 +10,7 @@ export interface TooltipAdapter<P = Record<string, any>, S = Record<string, any>
|
|
|
10
10
|
notifyVisibleChange(isVisible: any): void;
|
|
11
11
|
getPopupContainerRect(): PopupContainerDOMRect;
|
|
12
12
|
containerIsBody(): boolean;
|
|
13
|
-
off(arg0: string): void;
|
|
13
|
+
off(arg0: string, arg1?: () => void): void;
|
|
14
14
|
canMotion(): boolean;
|
|
15
15
|
registerScrollHandler(arg: () => Record<string, any>): void;
|
|
16
16
|
unregisterScrollHandler(): void;
|
|
@@ -47,6 +47,7 @@ export interface TooltipAdapter<P = Record<string, any>, S = Record<string, any>
|
|
|
47
47
|
notifyEscKeydown(event: any): void;
|
|
48
48
|
getTriggerNode(): any;
|
|
49
49
|
setId(): void;
|
|
50
|
+
getTriggerDOM(): HTMLElement | null;
|
|
50
51
|
}
|
|
51
52
|
export declare type Position = ArrayElement<typeof strings.POSITION_SET>;
|
|
52
53
|
export interface PopupContainerDOMRect extends DOMRectLikeType {
|
|
@@ -79,6 +79,20 @@ export default class Tooltip extends BaseFoundation {
|
|
|
79
79
|
this.calcPosition();
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
+
if (trigger === "hover") {
|
|
83
|
+
const checkTriggerIsHover = () => {
|
|
84
|
+
const triggerDOM = this._adapter.getTriggerDOM();
|
|
85
|
+
|
|
86
|
+
if (trigger && !triggerDOM.matches(":hover")) {
|
|
87
|
+
this.hide();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this._adapter.off("portalInserted", checkTriggerIsHover);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
this._adapter.on('portalInserted', checkTriggerIsHover);
|
|
94
|
+
}
|
|
95
|
+
|
|
82
96
|
this._adapter.on('positionUpdated', () => {
|
|
83
97
|
this._togglePortalVisible(true);
|
|
84
98
|
});
|
package/lib/es/utils/Event.js
CHANGED
|
@@ -57,8 +57,9 @@ export default class Event {
|
|
|
57
57
|
return false;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
this._eventMap.get(event)
|
|
60
|
+
const callbacks = [...this._eventMap.get(event)]; // clone to avoid someone writing the logic of deleting callback in callbacks into his or her callback code, for example the once func above
|
|
61
61
|
|
|
62
|
+
callbacks.forEach(callback => callback(...args));
|
|
62
63
|
return true;
|
|
63
64
|
}
|
|
64
65
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-foundation",
|
|
3
|
-
"version": "2.32.
|
|
3
|
+
"version": "2.32.5-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build:lib": "node ./scripts/compileLib.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"*.scss",
|
|
24
24
|
"*.css"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "6af4807f2242164d654659116f21e692d811ed08",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
29
29
|
"@babel/preset-env": "^7.15.8",
|
package/tooltip/foundation.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface TooltipAdapter<P = Record<string, any>, S = Record<string, any>
|
|
|
32
32
|
notifyVisibleChange(isVisible: any): void;
|
|
33
33
|
getPopupContainerRect(): PopupContainerDOMRect;
|
|
34
34
|
containerIsBody(): boolean;
|
|
35
|
-
off(arg0: string): void;
|
|
35
|
+
off(arg0: string, arg1?: () => void): void;
|
|
36
36
|
canMotion(): boolean;
|
|
37
37
|
registerScrollHandler(arg: () => Record<string, any>): void;
|
|
38
38
|
unregisterScrollHandler(): void;
|
|
@@ -68,7 +68,8 @@ export interface TooltipAdapter<P = Record<string, any>, S = Record<string, any>
|
|
|
68
68
|
setInitialFocus(): void;
|
|
69
69
|
notifyEscKeydown(event: any): void;
|
|
70
70
|
getTriggerNode(): any;
|
|
71
|
-
setId(): void
|
|
71
|
+
setId(): void;
|
|
72
|
+
getTriggerDOM(): HTMLElement|null
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
export type Position = ArrayElement<typeof strings.POSITION_SET>;
|
|
@@ -319,6 +320,17 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
|
|
|
319
320
|
this.calcPosition();
|
|
320
321
|
});
|
|
321
322
|
|
|
323
|
+
if (trigger==="hover") {
|
|
324
|
+
const checkTriggerIsHover = () => {
|
|
325
|
+
const triggerDOM = this._adapter.getTriggerDOM();
|
|
326
|
+
if (trigger && !triggerDOM.matches(":hover")) {
|
|
327
|
+
this.hide();
|
|
328
|
+
}
|
|
329
|
+
this._adapter.off("portalInserted", checkTriggerIsHover);
|
|
330
|
+
};
|
|
331
|
+
this._adapter.on('portalInserted', checkTriggerIsHover);
|
|
332
|
+
}
|
|
333
|
+
|
|
322
334
|
this._adapter.on('positionUpdated', () => {
|
|
323
335
|
this._togglePortalVisible(true);
|
|
324
336
|
});
|
package/utils/Event.ts
CHANGED
|
@@ -45,7 +45,9 @@ export default class Event {
|
|
|
45
45
|
if (!this._eventMap.has(event)) {
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
48
|
-
this._eventMap.get(event)
|
|
48
|
+
const callbacks = [...this._eventMap.get(event)];
|
|
49
|
+
// clone to avoid someone writing the logic of deleting callback in callbacks into his or her callback code, for example the once func above
|
|
50
|
+
callbacks.forEach(callback => callback(...args));
|
|
49
51
|
return true;
|
|
50
52
|
}
|
|
51
53
|
}
|