@douyinfe/semi-foundation 2.38.1 → 2.38.2-alpha.2

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.
@@ -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 type Position = ArrayElement<typeof strings.POSITION_SET>;
52
53
  export interface PopupContainerDOMRect extends DOMRectLikeType {
@@ -58,6 +58,16 @@ class Tooltip extends _foundation.default {
58
58
  this.show = () => {
59
59
  const content = this.getProp('content');
60
60
  const trigger = this.getProp('trigger');
61
+ if (trigger === "hover") {
62
+ const checkTriggerIsHover = () => {
63
+ const triggerDOM = this._adapter.getTriggerDOM();
64
+ if (trigger && !triggerDOM.matches(":hover")) {
65
+ this.hide();
66
+ }
67
+ this._adapter.off("portalInserted", checkTriggerIsHover);
68
+ };
69
+ this._adapter.on('portalInserted', checkTriggerIsHover);
70
+ }
61
71
  const clickTriggerToHide = this.getProp('clickTriggerToHide');
62
72
  const {
63
73
  visible,
@@ -75,6 +75,6 @@ export declare function getValueOrKey(data: any): any;
75
75
  export declare function normalizeValue(value: any, withObject: boolean): any;
76
76
  export declare function updateKeys(keySet: Set<string> | string[], keyEntities: KeyEntities): string[];
77
77
  export declare function calcDisabledKeys(keyEntities: KeyEntities): Set<string>;
78
- export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | -1 | 0;
78
+ export declare function calcDropRelativePosition(event: any, treeNode: any): 0 | 1 | -1;
79
79
  export declare function getDragNodesKeys(key: string, keyEntities: KeyEntities): string[];
80
80
  export declare function calcDropActualPosition(pos: string, relativeDropPos: any): any;
@@ -18,7 +18,7 @@ declare const strings: {
18
18
  DRAG_AREA_ILLEGAL: string;
19
19
  TRIGGER_AUTO: "auto";
20
20
  TRIGGER_CUSTOM: "custom";
21
- UPLOAD_TRIGGER: ("auto" | "custom")[];
21
+ UPLOAD_TRIGGER: ("custom" | "auto")[];
22
22
  VALIDATE_STATUS: readonly ["default", "error", "warning", "success"];
23
23
  PROMPT_POSITION: readonly ["left", "right", "bottom"];
24
24
  };
@@ -51,7 +51,9 @@ class Event {
51
51
  if (!this._eventMap.has(event)) {
52
52
  return false;
53
53
  }
54
- this._eventMap.get(event).forEach(callback => callback(...args));
54
+ const callbacks = [...this._eventMap.get(event)];
55
+ // clone to avoid someone writing the logic of deleting callback in callbacks into his or her callback code, for example the once func above
56
+ callbacks.forEach(callback => callback(...args));
55
57
  return true;
56
58
  }
57
59
  }
@@ -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 type Position = ArrayElement<typeof strings.POSITION_SET>;
52
53
  export interface PopupContainerDOMRect extends DOMRectLikeType {
@@ -50,6 +50,16 @@ export default class Tooltip extends BaseFoundation {
50
50
  this.show = () => {
51
51
  const content = this.getProp('content');
52
52
  const trigger = this.getProp('trigger');
53
+ if (trigger === "hover") {
54
+ const checkTriggerIsHover = () => {
55
+ const triggerDOM = this._adapter.getTriggerDOM();
56
+ if (trigger && !triggerDOM.matches(":hover")) {
57
+ this.hide();
58
+ }
59
+ this._adapter.off("portalInserted", checkTriggerIsHover);
60
+ };
61
+ this._adapter.on('portalInserted', checkTriggerIsHover);
62
+ }
53
63
  const clickTriggerToHide = this.getProp('clickTriggerToHide');
54
64
  const {
55
65
  visible,
@@ -75,6 +75,6 @@ export declare function getValueOrKey(data: any): any;
75
75
  export declare function normalizeValue(value: any, withObject: boolean): any;
76
76
  export declare function updateKeys(keySet: Set<string> | string[], keyEntities: KeyEntities): string[];
77
77
  export declare function calcDisabledKeys(keyEntities: KeyEntities): Set<string>;
78
- export declare function calcDropRelativePosition(event: any, treeNode: any): 1 | -1 | 0;
78
+ export declare function calcDropRelativePosition(event: any, treeNode: any): 0 | 1 | -1;
79
79
  export declare function getDragNodesKeys(key: string, keyEntities: KeyEntities): string[];
80
80
  export declare function calcDropActualPosition(pos: string, relativeDropPos: any): any;
@@ -18,7 +18,7 @@ declare const strings: {
18
18
  DRAG_AREA_ILLEGAL: string;
19
19
  TRIGGER_AUTO: "auto";
20
20
  TRIGGER_CUSTOM: "custom";
21
- UPLOAD_TRIGGER: ("auto" | "custom")[];
21
+ UPLOAD_TRIGGER: ("custom" | "auto")[];
22
22
  VALIDATE_STATUS: readonly ["default", "error", "warning", "success"];
23
23
  PROMPT_POSITION: readonly ["left", "right", "bottom"];
24
24
  };
@@ -44,7 +44,9 @@ export default class Event {
44
44
  if (!this._eventMap.has(event)) {
45
45
  return false;
46
46
  }
47
- this._eventMap.get(event).forEach(callback => callback(...args));
47
+ const callbacks = [...this._eventMap.get(event)];
48
+ // clone to avoid someone writing the logic of deleting callback in callbacks into his or her callback code, for example the once func above
49
+ callbacks.forEach(callback => callback(...args));
48
50
  return true;
49
51
  }
50
52
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-foundation",
3
- "version": "2.38.1",
3
+ "version": "2.38.2-alpha.2",
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.1",
10
+ "@douyinfe/semi-animation": "2.38.2-alpha.2",
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": "aaad3c86114e9bd2d9a61c8b78260e18ffc0eec6",
26
+ "gitHead": "8fb732d3d44b16a0bda607843c72b625bd7929af",
27
27
  "devDependencies": {
28
28
  "@babel/plugin-transform-runtime": "^7.15.8",
29
29
  "@babel/preset-env": "^7.15.8",
@@ -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>;
@@ -298,6 +299,16 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
298
299
  show = () => {
299
300
  const content = this.getProp('content');
300
301
  const trigger = this.getProp('trigger');
302
+ if (trigger==="hover") {
303
+ const checkTriggerIsHover = () => {
304
+ const triggerDOM = this._adapter.getTriggerDOM();
305
+ if (trigger && !triggerDOM.matches(":hover")) {
306
+ this.hide();
307
+ }
308
+ this._adapter.off("portalInserted", checkTriggerIsHover);
309
+ };
310
+ this._adapter.on('portalInserted', checkTriggerIsHover);
311
+ }
301
312
  const clickTriggerToHide = this.getProp('clickTriggerToHide');
302
313
  const { visible, displayNone } = this.getStates();
303
314
  if (displayNone) {
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).forEach(callback => callback(...args));
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
  }